@opra/common 1.0.0-beta.2 → 1.0.0-beta.4

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 (105) hide show
  1. package/browser/index.cjs +5 -5
  2. package/browser/index.mjs +5 -5
  3. package/cjs/document/api-document.js +14 -0
  4. package/cjs/document/common/api-base.js +5 -3
  5. package/cjs/document/common/document-node.js +6 -2
  6. package/cjs/document/constants.js +2 -1
  7. package/cjs/document/decorators/http-controller.decorator.js +1 -1
  8. package/cjs/document/decorators/http-operation-entity.decorator.js +1 -1
  9. package/cjs/document/decorators/http-operation.decorator.js +5 -5
  10. package/cjs/document/decorators/rpc-controller.decorator.js +69 -0
  11. package/cjs/document/decorators/rpc-operation.decorator.js +80 -0
  12. package/cjs/document/factory/api-document.factory.js +9 -3
  13. package/cjs/document/factory/data-type.factory.js +20 -0
  14. package/cjs/document/factory/http-api.factory.js +50 -77
  15. package/cjs/document/factory/rpc-api.factory.js +202 -0
  16. package/cjs/document/http/http-api.js +5 -4
  17. package/cjs/document/http/http-controller.js +16 -0
  18. package/cjs/document/http/http-operation.js +6 -0
  19. package/cjs/document/index.js +8 -0
  20. package/cjs/document/rpc/rpc-api.js +54 -0
  21. package/cjs/document/rpc/rpc-controller.js +116 -0
  22. package/cjs/document/rpc/rpc-header.js +40 -0
  23. package/cjs/document/rpc/rpc-operation-response.js +58 -0
  24. package/cjs/document/rpc/rpc-operation.js +80 -0
  25. package/cjs/enums/index.js +7 -0
  26. package/cjs/exception/http-errors/forbidden.error.js +1 -1
  27. package/cjs/exception/http-errors/resource-not.available.error.js +1 -1
  28. package/cjs/index.js +1 -1
  29. package/cjs/schema/opra-schema.js +3 -0
  30. package/cjs/schema/rpc/rpc-controller.interface.js +11 -0
  31. package/cjs/schema/rpc/rpc-header.interface.js +2 -0
  32. package/cjs/schema/rpc/rpc-operation.interface.js +7 -0
  33. package/esm/document/api-document.js +14 -0
  34. package/esm/document/common/api-base.js +5 -3
  35. package/esm/document/common/document-node.js +6 -2
  36. package/esm/document/constants.js +1 -0
  37. package/esm/document/decorators/http-controller.decorator.js +1 -1
  38. package/esm/document/decorators/http-operation-entity.decorator.js +1 -1
  39. package/esm/document/decorators/http-operation.decorator.js +5 -5
  40. package/esm/document/decorators/rpc-controller.decorator.js +65 -0
  41. package/esm/document/decorators/rpc-operation.decorator.js +76 -0
  42. package/esm/document/factory/api-document.factory.js +9 -3
  43. package/esm/document/factory/data-type.factory.js +20 -0
  44. package/esm/document/factory/http-api.factory.js +50 -77
  45. package/esm/document/factory/rpc-api.factory.js +198 -0
  46. package/esm/document/http/http-api.js +5 -4
  47. package/esm/document/http/http-controller.js +17 -1
  48. package/esm/document/http/http-operation.js +6 -0
  49. package/esm/document/index.js +8 -0
  50. package/esm/document/rpc/rpc-api.js +50 -0
  51. package/esm/document/rpc/rpc-controller.js +113 -0
  52. package/esm/document/rpc/rpc-header.js +37 -0
  53. package/esm/document/rpc/rpc-operation-response.js +54 -0
  54. package/esm/document/rpc/rpc-operation.js +77 -0
  55. package/esm/enums/index.js +4 -0
  56. package/esm/exception/http-errors/forbidden.error.js +1 -1
  57. package/esm/exception/http-errors/resource-not.available.error.js +1 -1
  58. package/esm/index.js +1 -1
  59. package/esm/schema/opra-schema.js +3 -0
  60. package/esm/schema/rpc/rpc-controller.interface.js +8 -0
  61. package/esm/schema/rpc/rpc-header.interface.js +1 -0
  62. package/esm/schema/rpc/rpc-operation.interface.js +4 -0
  63. package/package.json +2 -2
  64. package/types/document/api-document.d.ts +5 -2
  65. package/types/document/common/api-base.d.ts +3 -2
  66. package/types/document/constants.d.ts +1 -0
  67. package/types/document/decorators/http-operation.decorator.d.ts +3 -3
  68. package/types/document/decorators/rpc-controller.decorator.d.ts +20 -0
  69. package/types/document/decorators/rpc-operation.decorator.d.ts +32 -0
  70. package/types/document/factory/api-document.factory.d.ts +2 -1
  71. package/types/document/factory/data-type.factory.d.ts +1 -0
  72. package/types/document/factory/http-api.factory.d.ts +10 -6
  73. package/types/document/factory/rpc-api.factory.d.ts +40 -0
  74. package/types/document/http/http-api.d.ts +8 -3
  75. package/types/document/http/http-controller.d.ts +8 -2
  76. package/types/document/index.d.ts +11 -0
  77. package/types/document/rpc/rpc-api.d.ts +27 -0
  78. package/types/document/rpc/rpc-controller.d.ts +89 -0
  79. package/types/document/rpc/rpc-header.d.ts +47 -0
  80. package/types/document/rpc/rpc-operation-response.d.ts +41 -0
  81. package/types/document/rpc/rpc-operation.d.ts +77 -0
  82. package/types/enums/index.d.ts +4 -0
  83. package/types/exception/http-errors/forbidden.error.d.ts +1 -1
  84. package/types/index.d.cts +1 -1
  85. package/types/index.d.ts +1 -1
  86. package/types/schema/api-document.interface.d.ts +25 -4
  87. package/types/schema/opra-schema.d.ts +3 -0
  88. package/types/schema/rpc/rpc-controller.interface.d.ts +22 -0
  89. package/types/schema/rpc/rpc-header.interface.d.ts +19 -0
  90. package/types/schema/rpc/rpc-operation.interface.d.ts +26 -0
  91. package/cjs/http/index.js +0 -7
  92. package/esm/http/index.js +0 -4
  93. package/types/http/index.d.ts +0 -4
  94. /package/cjs/{http/enums → enums}/http-headers-codes.enum.js +0 -0
  95. /package/cjs/{http/enums → enums}/http-status-codes.enum.js +0 -0
  96. /package/cjs/{http/enums → enums}/http-status-messages.js +0 -0
  97. /package/cjs/{http/enums → enums}/mime-types.enum.js +0 -0
  98. /package/esm/{http/enums → enums}/http-headers-codes.enum.js +0 -0
  99. /package/esm/{http/enums → enums}/http-status-codes.enum.js +0 -0
  100. /package/esm/{http/enums → enums}/http-status-messages.js +0 -0
  101. /package/esm/{http/enums → enums}/mime-types.enum.js +0 -0
  102. /package/types/{http/enums → enums}/http-headers-codes.enum.d.ts +0 -0
  103. /package/types/{http/enums → enums}/http-status-codes.enum.d.ts +0 -0
  104. /package/types/{http/enums → enums}/http-status-messages.d.ts +0 -0
  105. /package/types/{http/enums → enums}/mime-types.enum.d.ts +0 -0
package/browser/index.mjs CHANGED
@@ -3,10 +3,10 @@
3
3
  * http://www.panates.com
4
4
  *****************************************/
5
5
 
6
- var Vo=Object.defineProperty;var s=(i,e)=>Vo(i,"name",{value:e,configurable:!0});var Ko=(i,e)=>{for(var t in e)Vo(i,t,{get:e[t],enumerable:!0})};import"reflect-metadata";BigInt.prototype.toJSON||(BigInt.prototype.toJSON=function(){return this.toString()});RegExp.prototype.toJSON||(RegExp.prototype.toJSON=function(){return this.toString()});import $s from"putil-promisify";function Gt(i){return typeof i=="function"&&i.prototype&&i.prototype.constructor===i&&i.prototype.constructor.name!=="Function"&&i.prototype.constructor.name!=="embedded"}s(Gt,"isConstructor");function zr(i){return i!==null&&typeof i=="object"&&typeof i.pipe=="function"}s(zr,"isStream");function sc(i){return zr(i)&&typeof i._read=="function"&&typeof i._readableState=="object"}s(sc,"isReadable");function ac(i){return zr(i)&&typeof i._write=="function"}s(ac,"isWritable");function pc(i){return zr(i)&&typeof i.getReader=="function"&&typeof i.pipeThrough=="function"&&typeof i.pipeTo=="function"}s(pc,"isReadableStream");function cc(i){return i!==null&&typeof i=="object"&&typeof i.size=="number"&&typeof i.arrayBuffer=="function"&&typeof i.stream=="function"}s(cc,"isBlob");function lc(i){return i!==null&&typeof i.constructor=="function"&&i.constructor.name==="FormData"&&typeof i.append=="function"&&typeof i.getAll=="function"}s(lc,"isFormData");function fc(i){return i!==null&&typeof i=="object"&&typeof i.host=="string"&&typeof i.href=="string"}s(fc,"isURL");function uc(i){return Symbol.iterator in i}s(uc,"isIterable");function mc(i){return Symbol.asyncIterator in i}s(mc,"isAsyncIterable");async function xe(i){return i=$s.isPromise(i)?await i:i,typeof i=="function"?Gt(i)?i:await i():i}s(xe,"resolveThunk");var zo=/^(?:file:\/\/)?(.+)$/;function xc(i=1){if(i>=Error.stackTraceLimit)throw new TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+i+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");let e=Error.prepareStackTrace;Error.prepareStackTrace=(r,n)=>n;let t=new Error().stack;if(Error.prepareStackTrace=e,t!==null&&typeof t=="object"){let r=t[i]?t[i].getFileName():void 0,n=r?zo.exec(r):void 0;return n?n[1]:""}return""}s(xc,"getStackFileName");function gc(i=1){if(i>=Error.stackTraceLimit)throw new TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+i+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");let e=Error.prepareStackTrace;Error.prepareStackTrace=(r,n)=>n;let t=new Error().stack;if(Error.prepareStackTrace=e,t!==null&&typeof t=="object"){let r=t[i]?t[i].getFileName():void 0,n=r?zo.exec(r):void 0;return n?n[1]:""}return""}s(gc,"getErrorStack");function Yt(i,e,t){for(let r of Object.getOwnPropertyNames(e))r==="constructor"||r==="__proto__"||r==="toJSON"||r==="toString"||t&&!t(r)||Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(e,r)||Object.create(null))}s(Yt,"mergePrototype");function Qt(i,e,t=r=>!0){try{let r=new e;Object.getOwnPropertyNames(r).filter(o=>typeof r[o]<"u"&&typeof i[o]>"u").filter(o=>t(o)).forEach(o=>{i[o]=r[o]})}catch{}}s(Qt,"inheritPropertyInitializers");import Jr from"putil-isplainobject";import Vs from"putil-merge";var T=Symbol.for("opra.type.metadata"),te=Symbol("opra.http-controller.metadata"),y=Symbol.for("opra.type.decoder"),g=Symbol("opra.type.encoder"),S=Symbol.for("DECORATOR"),Ie=Symbol.for("BUILTIN"),Jo=/([a-z$_]\w+):(.+)/i,$=/^[a-z][\w_]*$/i,Xt=/^(.*)Type(\d*)$/,B=Symbol.for("kDataTypeMap"),Zt=Symbol.for("kCtorMap"),ge=Symbol.for("kTypeNSMap");function I(i,e){return Vs({},i,{deep:s(t=>Jr(t)&&!t[T],"deep"),descriptor:!0,filter:s((t,r)=>{let n=t[r];return!e||typeof n!="function"&&(typeof n!="object"||Jr(n)||Array.isArray(n))},"filter")})}s(I,"cloneObject");function x(i,e){if(!(i&&typeof i=="object"))return i;for(let t of Object.keys(i))i[t]===void 0?delete i[t]:e&&typeof i[t]=="object"&&x(i[t]);return i}s(x,"omitUndefined");function Ks(i,e){if(!(i&&typeof i=="object"))return i;for(let t of Object.keys(i))i[t]==null?delete i[t]:e&&Jr(i[t])&&Ks(i[t]);return i}s(Ks,"omitNullish");import{splitString as Wo}from"fast-tokenizer";var zs=/^([+-])?([a-z_$]\w*)$/i,Js=/[^.]\(/g,Wr=class Wr{};s(Wr,"FieldsProjection");var Le=Wr;(function(i){let t=class t{};s(t,"Item");let e=t;i.Item=e})(Le||(Le={}));function Go(i,e){let t=Array.isArray(i)?i:[i];if(!(t&&t.length))return;let r=new Le;for(let n of t)e||(n=n.toLowerCase()),Yo(n,r);return r}s(Go,"parseFieldsProjection");function Yo(i,e){i=i.replace(Js,r=>r.charAt(0)+"."+r.substring(1));let t=Wo(i,{delimiters:".",brackets:!0,keepBrackets:!1});for(let r=0;r<t.length;r++){let n=t[r];if(n.includes(",")){let c=Wo(n,{delimiters:",",brackets:!0,keepBrackets:!0});for(let l of c)Yo(l,e);continue}let o=zs.exec(n);if(!o)throw new TypeError(`Invalid field path (${i})`);let a=o[2],p=e[a]=e[a]||new Le.Item;o[1]&&(p.sign=o[1]),r===t.length-1?delete p.projection:e=p.projection=p.projection||new Le}}s(Yo,"parse");function Ws(i){return i&&typeof i.forEach=="function"}s(Ws,"isMap");var V=Symbol.for("kEntries"),ie=Symbol.for("kKeyMap"),Ht=Symbol.for("kWellKnownKeys"),Gr=Symbol.for("kOptions"),Ke=Symbol.for("kSize"),Yr=class Yr{constructor(e,t){Object.defineProperty(this,Ke,{value:0,enumerable:!1,writable:!0}),Object.defineProperty(this,V,{value:{},enumerable:!1,writable:!0}),Object.defineProperty(this,ie,{value:{},enumerable:!1,writable:!0}),Object.defineProperty(this,Ht,{value:{},enumerable:!1,writable:!0});let r=!!(t!=null&&t.caseSensitive);Object.defineProperty(this,Gr,{value:{caseSensitive:r},enumerable:!1}),t!=null&&t.wellKnownKeys&&t.wellKnownKeys.forEach(n=>{r?this[Ht][n]=n:this[Ht][n.toLowerCase()]=n}),this.clear(),e&&this.setAll(e)}get size(){return this[Ke]}clear(){Object.keys(this[V]).forEach(e=>delete this[V][e]),Object.keys(this[ie]).forEach(e=>delete this[ie][e]),this[Ke]=0}forEach(e,t){for(let[r,n]of this.entries())e.call(t,n,r,this)}get(e){if(e)return this[V][this._getStoringKey(e)]}has(e){return e?Object.prototype.hasOwnProperty.call(this[V],this._getStoringKey(e)):!1}set(e,t){let r=this._getStoringKey(e);e=this._getOriginalKey(e);let n=Object.prototype.hasOwnProperty.call(this[V],r);return this[V][r]=t,n||this[Ke]++,this[ie][r]=e,this}setAll(e){return Ws(e)?e.forEach((t,r)=>this.set(r,t)):Object.keys(e).forEach(t=>this.set(t,e[t])),this}keys(){return Object.values(this[ie])[Symbol.iterator]()}values(){return Object.values(this[V])[Symbol.iterator]()}entries(){return Object.entries(this[V])[Symbol.iterator]()}delete(e){let t=this._getStoringKey(e),r=Object.prototype.hasOwnProperty.call(this[V],t);return delete this[V][t],delete this[ie][t],r||this[Ke]--,r}sort(e){let t={...this[V]},r={...this[ie]},n=Array.from(this.keys());e?n.sort(e):n.sort(),this.clear();for(let o of n)this[V][o]=t[o],this[ie][o]=r[o];return this[Ke]=n.length,this}toObject(){let e={};for(let[t,r]of Object.entries(this[ie]))e[r]=this[V][t];return e}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"[Object ResponsiveMap]"}_getOriginalKey(e){if(!e||this[Gr].caseSensitive)return e;let t=this._getStoringKey(e);return this[ie][t]??this[Ht][t]??e}_getStoringKey(e){return this[Gr].caseSensitive?e:e.toLowerCase()}};s(Yr,"ResponsiveMap");var P=Yr;function jc(i,e,t){let r=new WeakSet;return JSON.stringify(i,(n,o)=>{if(o!==null&&typeof o=="object"){if(r.has(o))return;r.add(o)}return e?e(n,o):o},t)}s(jc,"safeJsonStringify");var h={};Ko(h,{ComplexType:()=>ze,EnumType:()=>Je,HttpController:()=>Dt,HttpOperation:()=>Qr,MappedType:()=>We,MixinType:()=>Ge,SimpleType:()=>Ye,SpecVersion:()=>Gs,isComplexType:()=>Qs,isDataType:()=>Ys,isEnumType:()=>ea,isHttpController:()=>ta,isMappedType:()=>Hs,isMixinType:()=>Zs,isSimpleType:()=>Xs});var Gs="1.0";var ze;(function(i){i.Kind="ComplexType"})(ze||(ze={}));var Je;(function(i){i.Kind="EnumType"})(Je||(Je={}));var We;(function(i){i.Kind="MappedType"})(We||(We={}));var Ge;(function(i){i.Kind="MixinType"})(Ge||(Ge={}));var Ye;(function(i){i.Kind="SimpleType"})(Ye||(Ye={}));var Dt;(function(i){i.Kind="HttpController"})(Dt||(Dt={}));var Qr;(function(i){i.Kind="HttpOperation"})(Qr||(Qr={}));function Ys(i){return i&&typeof i=="object"&&(i.kind===ze.Kind||i.kind===Je.Kind||i.kind===We.Kind||i.kind===Ye.Kind||i.kind===Ge.Kind)}s(Ys,"isDataType");function Qs(i){return i&&typeof i=="object"&&i.kind===ze.Kind}s(Qs,"isComplexType");function Xs(i){return i&&typeof i=="object"&&i.kind===Ye.Kind}s(Xs,"isSimpleType");function Zs(i){return i&&typeof i=="object"&&i.kind===Ge.Kind}s(Zs,"isMixinType");function Hs(i){return i&&typeof i=="object"&&i.kind===We.Kind}s(Hs,"isMappedType");function ea(i){return i&&typeof i=="object"&&i.kind===Je.Kind}s(ea,"isEnumType");function ta(i){return i&&typeof i=="object"&&i.kind===Dt.Kind}s(ta,"isHttpController");import na from"@browsery/i18next";import{splitString as oa,tokenize as Zo}from"fast-tokenizer";var ra=/\\(.)/g,ia=/(\\)/g;function Qo(i){return i.replace(ia,"\\\\")}s(Qo,"escapeString");function Xo(i){return i.replace(ra,"$1")}s(Xo,"unescapeString");var sa=Object.getPrototypeOf(na.createInstance()).constructor,St=class St extends sa{async init(e,t){let r=typeof e=="object"?e:{},n=typeof e=="function"?e:t;try{let o=await super.init(r,n),a=this.services.formatter;if(a.add("lowercase",(p,c)=>p.toLocaleLowerCase(c)),a.add("uppercase",(p,c)=>p.toLocaleUpperCase(c)),a.add("upperFirst",(p,c)=>p.charAt(0).toLocaleUpperCase(c)+p.substring(1)),r!=null&&r.resources)for(let p of Object.keys(r.resources)){let c=r.resources[p];for(let l of Object.keys(c))this.addResourceBundle(p,l,c[l],!1,!0)}return n&&n(null,o),o}catch(o){throw n&&n(o,this.t),o}}deep(e,t){if(e==null)return e;let r=new WeakMap;return this._deepTranslate(e,r,t)}createInstance(e,t){return new St(e,t)}static createInstance(e,t){return new St(e,t)}_deepTranslate(e,t,r){if(e==null||r!=null&&r.ignore&&r.ignore(e,this))return e;if(typeof e=="object"&&t.has(e))return t.get(e);if(typeof e=="string"){let n="";for(let o of Zo(e,{brackets:{"$t(":")"},quotes:!0,keepQuotes:!0,keepBrackets:!0,keepDelimiters:!0})){if(o.startsWith("$t(")&&o.endsWith(")")){o=o.substring(3,o.length-1);let a=oa(o,{delimiters:"?",quotes:!0,brackets:{"{":"}"}}),p=Xo(o.substring((a[0]||"").length+1));o=a[0]||"";let c=[],l=null;for(let u of Zo(o,{delimiters:",",quotes:!0,brackets:{"{":"}"}})){if(u.startsWith("{")){l=JSON.parse(u);continue}c.push(u)}let _=c.length>1?"$t("+c.join(",")+")":c[0];n+=p?this.t(_,p,{...r,...l}):this.t(_,{...r,...l});continue}n+=o}return n}if(Array.isArray(e)){let n=Array(e.length);t.set(e,n);for(let o=0,a=e.length;o<a;o++)n[o]=this._deepTranslate(e[o],t,r);return t.delete(e),n}if(typeof e=="object"){if(Buffer.isBuffer(e)||Buffer.isBuffer(e)||e instanceof Symbol||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof WeakMap||e instanceof WeakSet)return e;let n={};t.set(e,n);let o=Object.keys(e);for(let a=0,p=o.length;a<p;a++){let c=o[a];n[c]=this._deepTranslate(e[c],t,r)}return t.delete(e),n}return e}static get defaultInstance(){return aa}};s(St,"I18n");var It=St,aa=It.createInstance();var pa=/(\))/g;function R(i,e,t){let r=e&&typeof e=="object"?e:void 0,n=typeof e=="string"?e:t;return"$t("+i+(r?","+JSON.stringify(r):"")+(n?"?"+Qo(n).replace(pa,"\\$1"):"")+")"}s(R,"translate");var Xr=It.createInstance();Xr.init().catch(()=>{});var Zr=class Zr extends Error{constructor(e,t){super("Unknown error"),this.severity="error",t=t||(e instanceof Error?e:void 0),e instanceof Error&&(t=e),t&&t instanceof Error&&(this.cause=t,t.stack&&(this.stack=t.stack)),typeof e=="string"?this.initString(e):e instanceof Error?this.initError(e):this.init(e),this.message=this.message||this.constructor.name}toString(){return Xr.deep(this.message)}toJSON(){var t;let e="production";return x({message:this.message,severity:this.severity,system:this.system,code:this.code,details:this.details,stack:e==="dev"||e==="development"||e==="test"?(t=this.stack)==null?void 0:t.split(`
7
- `):void 0},!0)}init(e){this.message=(e==null?void 0:e.message)||this.constructor.name,this.severity=(e==null?void 0:e.severity)||"error",e&&(this.system=e.system,this.code=e.code,this.details=e.details)}initString(e){this.init({message:String(e||"")||this.constructor.name,severity:"error",code:this.constructor.name})}initError(e){this.init({message:e.message,severity:e.severity||"error",code:e.code||e.constructor.name})}};s(Zr,"OpraException");var me=Zr;var Hr=class Hr extends me{constructor(){super(""),this.details=[]}add(e){return this.details.push(e),this}};s(Hr,"OpraDocumentError");var Qe=Hr;var ei=class ei{constructor(e){this.path="",this.error=new Qe,this.showErrorDetails=!0,this.maxErrors=(e==null?void 0:e.maxErrors)||0,this.error.message=""}addError(e){if(!this.error.details.length)if(e instanceof Error)this.error.stack=e.stack;else{let t=new Error;Error.captureStackTrace(t,this.addError),this.error.stack=t.stack}if(this.error.add({message:typeof e=="string"?e:e.message,path:this.path,...typeof e=="object"?e:void 0}),this.error.details.length>=this.maxErrors)throw this.error}enter(e,t){let r=this.path;this.path=this.path+e;try{return t()}catch(n){n!==this.error&&this.addError(n)}finally{this.path=r}}async enterAsync(e,t){let r=this.path;this.path=this.path+e;try{return await t()}catch(n){n!==this.error&&this.addError(n)}finally{this.path=r}}extend(e){let t={...e};return Object.setPrototypeOf(t,this),t}};s(ei,"DocumentInitContext");var ne=ei;import"reflect-metadata";import{asMutable as Ta}from"ts-gems";import ca from"lodash.omit";function ti(i){return function(e){var n;let t;if(!(i!=null&&i.embedded))if(i!=null&&i.name){if(!$.test(i.name))throw new TypeError(`"${i.name}" is not a valid type name`);t=i.name}else t=((n=e.name.match(Xt))==null?void 0:n[1])||e.name;let r=Reflect.getOwnMetadata(T,e);r||(r={},Reflect.defineMetadata(T,r,e)),r.kind=h.ComplexType.Kind,r.name=t,i&&Object.assign(r,ca(i,["kind","name","base","fields"]))}}s(ti,"ComplexTypeDecorator");import{asMutable as ya}from"ts-gems";import{asMutable as la}from"ts-gems";import{uid as fa}from"uid";var ri=class ri{constructor(e,t){this.element=e,this.parent=t}getDocument(){if(this._document)return this._document;if(this.element[ge])return this.element;if(this.parent)return this._document=this.parent.getDocument();throw new Error("ApiDocument not found in document tree")}hasDataType(e){var r;let t=(r=this[B])==null?void 0:r.has(e);return t||(this.parent?this.parent.hasDataType(e):!1)}findDataType(e){var r;let t=(r=this[B])==null?void 0:r.get(e);return t||(this.parent?this.parent.findDataType(e):void 0)}getDataType(e){let t=this.findDataType(e);if(t)return t;let r="";if(typeof e=="function")r=Reflect.getMetadata(T,e).name;else if(typeof e=="object"){let n=e[T];r=n==null?void 0:n.name}throw typeof e=="string"&&(r=e),new TypeError("Unknown data type"+(r?" ("+r+")":""))}getDataTypeNameWithNs(e){if(!e.name)return;let t=this.getDocument().getDataTypeNs(e);return t?t+":"+e.name:e.name}getComplexType(e){let t=this.getDataType(e);if(t.kind===h.ComplexType.Kind)return t;throw new TypeError(`Data type "${t.name}" is not a ComplexType`)}getSimpleType(e){let t=this.getDataType(e);if(t.kind===h.SimpleType.Kind)return t;throw new TypeError(`Data type "${t.name||t}" is not a SimpleType`)}getEnumType(e){let t=this.getDataType(e);if(t.kind===h.EnumType.Kind)return t;throw new TypeError(`Data type "${t.name||t}" is not a EnumType`)}getMappedType(e){let t=this.getDataType(e);if(t.kind===h.MappedType.Kind)return t;throw new TypeError(`Data type "${t.name||t}" is not a MappedType`)}getMixinType(e){let t=this.getDataType(e);if(t.kind===h.MixinType.Kind)return t;throw new TypeError(`Data type "${t.name||t}" is not a MixinType`)}};s(ri,"DocumentNode");var er=ri;var b=s(function(i){if(!this)throw new TypeError('"this" should be passed to call class constructor');let e=la(this);e.id=fa(16),Object.defineProperty(e,"node",{value:new er(this,i==null?void 0:i.node),enumerable:!1,writable:!0}),i&&Object.defineProperty(e,"owner",{value:i,enumerable:!1,writable:!0})},"DocumentElement"),ni=class ni{};s(ni,"DocumentElementClass");var ii=ni;b.prototype=ii.prototype;function oi(i){return function(e,t){if(typeof t!="string")throw new TypeError("Symbol properties can't be used as a field");let r=Reflect.getOwnMetadata(T,e.constructor)||{};r.kind=h.ComplexType.Kind,r.fields=r.fields||{};let n=Reflect.getMetadata("design:type",e,t),o=r.fields[t]={...i};n===Array?o.isArray=!0:o.type=o.type||n,Reflect.defineMetadata(T,r,e.constructor)}}s(oi,"ApiFieldDecorator");import{asMutable as ma}from"ts-gems";import{validator as ha,vg as Pe}from"valgen";import{asMutable as ua}from"ts-gems";var tr=Symbol.for("nodejs.util.inspect.custom"),Lt="\x1B[0m",rr="\x1B[33m",ir="\x1B[35m";var O=s(function(i,e,t){if(!this)throw new TypeError('"this" should be passed to call class constructor');if(e!=null&&e.name&&!$.test(e.name))throw new TypeError(`"${e.name}" is not a valid DataType name`);b.call(this,i);let r=ua(this);r.kind=e.kind,r.name=e.name,r.description=e.description,r.abstract=e.abstract,r.examples=e.examples},"DataType"),ai=class ai extends b{get embedded(){return!this.name}toJSON(){return x({kind:this.kind,description:this.description,abstract:this.abstract,examples:this.examples})}toString(){return`[${Object.getPrototypeOf(this).constructor.name} ${this.name||"#Embedded"}]`}[tr](){return`[${rr+Object.getPrototypeOf(this).constructor.name+Lt} ${ir+this.name+Lt}]`}};s(ai,"DataTypeClass");var si=ai;O.prototype=si.prototype;var da=/^([+-])?([a-z$_][\w.]*)$/i,w=s(function(...i){if(!this)throw new TypeError('"this" should be passed to call class constructor');let[e,t,r]=i;O.call(this,e,t,r);let n=ma(this);n.fields=new P},"ComplexTypeBase"),ci=class ci extends O{findField(e){if(e.includes(".")){let r=this.parseFieldPath(e).pop();return r==null?void 0:r.field}return this.fields.get(e)}getField(e){let t=this.findField(e);if(!t)throw new Error(R("error:UNKNOWN_FIELD",{field:e}));return t}parseFieldPath(e,t){var u,C,$o;let r=this,n,o=e.split("."),a=o.length,p=[],c=this.owner.node.getDataType("object"),l=t==null?void 0:t.allowSigns,_=s(()=>p.map(Se=>Se.fieldName).join("."),"getStrPath");for(let Se=0;Se<a;Se++){let z={fieldName:o[Se],dataType:c};p.push(z);let Wt=da.exec(o[Se]);if(!Wt)throw new TypeError(`Invalid field name (${_()})`);if(Wt[1]&&((Se===0&&l==="first"||l==="each")&&(z.sign=Wt[1]),z.fieldName=Wt[2]),r){if(r instanceof w){if(n=r.fields.get(z.fieldName),n){z.fieldName=n.name,z.field=n,z.dataType=n.type,r=n.type;continue}if(((u=r.additionalFields)==null?void 0:u[0])===!0){z.additionalField=!0,z.dataType=c,r=void 0;continue}if(((C=r.additionalFields)==null?void 0:C[0])==="type"&&(($o=r.additionalFields)==null?void 0:$o[1])instanceof O){z.additionalField=!0,z.dataType=r.additionalFields[1],r=r.additionalFields[1];continue}throw new Error(`Unknown field (${p.map(Kr=>Kr.fieldName).join(".")})`)}throw new TypeError(`"${p.map(Kr=>Kr.fieldName).join(".")}" field is not a complex type and has no child fields`)}z.additionalField=!0,z.dataType=c}return p}normalizeFieldPath(e,t){return this.parseFieldPath(e,t).map(r=>(r.sign||"")+r.fieldName).join(".")}generateCodec(e,t){let r=Array.isArray(t==null?void 0:t.projection)?Go(t.projection):t==null?void 0:t.projection,n=this._generateSchema(e,{...t,projection:r,currentPath:""}),o;if(this.additionalFields instanceof O)o=this.additionalFields.generateCodec(e,t);else if(typeof this.additionalFields=="boolean")o=this.additionalFields;else if(Array.isArray(this.additionalFields))if(this.additionalFields.length<2)o="error";else{let a=o[1];o=ha((p,c,l)=>c.fail(l,a,p))}return Pe.isObject(n,{ctor:this.name==="object"?Object:this.ctor,additionalFields:o,name:this.name,coerce:!0,caseInSensitive:t==null?void 0:t.caseInSensitive,onFail:t==null?void 0:t.onFail})}_generateSchema(e,t){var c;let r={},{currentPath:n,projection:o}=t,a=!!(o&&Object.values(o).find(l=>!l.sign)),p;for(let l of this.fields.values()){if(t.ignoreReadonlyFields&&l.readonly||t.ignoreWriteonlyFields&&l.writeonly||t.ignoreHiddenFields&&l.hidden){r[l.name]=Pe.isUndefined({coerce:!0});continue}p=l.name;let _;if(o!=="*"&&(_=o==null?void 0:o[p.toLowerCase()],(_==null?void 0:_.sign)==="-"||a&&!_||!a&&l.exclusive&&!_)){r[l.name]=Pe.isUndefined({coerce:!0});continue}let u=this._generateFieldCodec(e,l,{...t,partial:t.partial==="deep"?t.partial:void 0,projection:typeof o=="object"?((c=o[p])==null?void 0:c.projection)||"*":o,currentPath:n+(n?".":"")+p});r[p]=t.partial||!l.required?Pe.optional(u):Pe.required(u)}return r}_generateFieldCodec(e,t,r){let n=t.type.generateCodec(e,r);return t.fixed&&(n=Pe.isEnum([t.fixed])),t.isArray&&(n=Pe.isArray(n)),n}};s(ci,"ComplexTypeBaseClass");var pi=ci;w.prototype=pi.prototype;var M=s(function(...i){if(!this){let[o]=i;return M[S](o)}let[e,t]=i;b.call(this,e);let r=ya(this);r.name=t.name;let n=t.origin||e;if(!(n instanceof w))throw new Error("Field origin should be one of ComplexType, MappedType or MixinType");r.origin=n,r.type=t.type||e.node.getDataType("any"),r.description=t.description,r.isArray=t.isArray,r.default=t.default,r.fixed=t.fixed,r.required=t.required,r.exclusive=t.exclusive,r.translatable=t.translatable,r.deprecated=t.deprecated,r.readonly=t.readonly,r.writeonly=t.writeonly,r.examples=t.examples,r.hidden=t.hidden},"ApiField"),fi=class fi extends b{toJSON(){var t;let e=this.type?this.node.getDataTypeNameWithNs(this.type):void 0;return x({type:e||((t=this.type)==null?void 0:t.toJSON()),description:this.description,isArray:this.isArray||void 0,default:this.default,fixed:this.fixed,required:this.required||void 0,exclusive:this.exclusive||void 0,translatable:this.translatable||void 0,deprecated:this.deprecated||void 0,readonly:this.readonly||void 0,writeonly:this.writeonly||void 0,examples:this.examples})}};s(fi,"ApiFieldClass");var li=fi;M.prototype=li.prototype;Object.assign(M,oi);M[S]=oi;var Q=s(function(...i){var o;if(!this)return Q[S].apply(void 0,i);let[e,t]=i,r=i[2]||new ne({maxErrors:0});w.call(this,e,t,r);let n=Ta(this);n.kind=h.ComplexType.Kind,n.additionalFields=t.additionalFields,n.keyField=t.keyField,t.base&&r.enter(".base",()=>{if(!(t.base instanceof w))throw new TypeError(`"${t.base.kind}" can't be set as base for a "${this.kind}"`);n.base=t.base,n.additionalFields==null&&n.base.additionalFields&&(n.additionalFields=n.base.additionalFields);for(let a of n.base.fields.values())this.fields.set(a.name,new M(this,a))}),n.ctor=t.ctor||((o=n.base)==null?void 0:o.ctor),t.fields&&r.enter(".fields",()=>{for(let[a,p]of Object.entries(t.fields)){let c=new M(this,{...p,name:a});this.fields.set(c.name,c)}})},"ComplexType"),mi=class mi extends w{extendsFrom(e){var t;return e instanceof O||(e=this.node.getDataType(e)),e instanceof w?e===this?!0:!!((t=this.base)!=null&&t.extendsFrom(e)):!1}toJSON(){let e=this.base?this.node.getDataTypeNameWithNs(this.base):void 0,t=x({...w.prototype.toJSON.call(this),kind:this.kind,base:this.base?e||this.base.toJSON():void 0});if(this.additionalFields)if(this.additionalFields instanceof O){let r=this.node.getDataTypeNameWithNs(this.additionalFields);t.additionalFields=r||this.additionalFields.toJSON()}else t.additionalFields=this.additionalFields;if(this.fields.size){let r={},n=0;for(let o of this.fields.values())o.origin===this&&(r[o.name]=o.toJSON(),n++);n&&(t.fields=r)}return x(t)}};s(mi,"ComplexTypeClass");var ui=mi;Q.prototype=ui.prototype;Object.assign(Q,ti);Q[S]=ti;import"reflect-metadata";import{asMutable as Ea}from"ts-gems";import{vg as _a}from"valgen";var oe=s(function(...i){if(!this)return oe[S].apply(void 0,i);let[e,t,r]=i;O.call(this,e,t,r);let n=Ea(this);if(n.kind=h.EnumType.Kind,t.base){if(!(t.base instanceof oe))throw new TypeError(`"${t.base.kind}" can't be set as base for a "${n.kind}"`);n.base=t.base}n.instance=t.instance,n.ownAttributes=I(t.attributes||{}),n.attributes=n.base?I(n.base.attributes):{};for(let[o,a]of Object.entries(n.ownAttributes))n.attributes[o]=a},"EnumType"),hi=class hi extends O{extendsFrom(e){var t;return e instanceof O||(e=this.node.getDataType(e)),e instanceof oe?e===this?!0:!!((t=this.base)!=null&&t.extendsFrom(e)):!1}generateCodec(){return _a.isEnum(Object.keys(this.attributes))}toJSON(){let e=this.base?this.node.getDataTypeNameWithNs(this.base):void 0;return x({...O.prototype.toJSON.call(this),base:this.base?e||this.base.toJSON():void 0,attributes:I(this.ownAttributes)})}};s(hi,"EnumTypeClass");var Pt=hi;oe.prototype=Pt.prototype;Object.assign(oe,Pt);function xa(i,...e){let t=e.length>=2?e[0]:void 0,r=e.length>=2?e[1]:e[0],n={},o=i;if(Array.isArray(i)){if(t){if(!Array.isArray(t))throw new TypeError('Both "target" and "base" arguments should be array');o=[...t,...i]}n={},i.forEach(p=>{var l;let c=(l=r==null?void 0:r.meanings)==null?void 0:l[p];n[p]=x({description:c})})}else{if(t){if(Array.isArray(t))throw new TypeError('Both "target" and "base" arguments should be enum object');o={...t,...i}}Object.keys(i).forEach(p=>{var l;let c=(l=r==null?void 0:r.meanings)==null?void 0:l[p];n[i[p]]=x({alias:p,description:c})})}let a={kind:h.EnumType.Kind,attributes:n,base:r.base,name:r.name,description:r==null?void 0:r.description};return Object.defineProperty(i,T,{value:a,enumerable:!1,configurable:!0,writable:!0}),o}s(xa,"EnumTypeFactory");oe.prototype=Pt.prototype;oe[S]=xa;import"reflect-metadata";import{asMutable as ga}from"ts-gems";function nr(i,e){let t=i==null?void 0:i.map(n=>String(n).toLowerCase()),r=e==null?void 0:e.map(n=>String(n).toLowerCase());return n=>r&&r.includes(n.toLowerCase())?!1:t?t.includes(n.toLowerCase()):!0}s(nr,"getIsInheritedPredicateFn");var Me=s(function(...i){var o;if(!this)throw new TypeError('"this" should be passed to call class constructor');let[e,t,r]=i;w.call(this,e,t,r);let n=ga(this);if(n.kind=h.MappedType.Kind,t.base){if(!(t.base instanceof w))throw new TypeError(`"${t.base.kind}" can't be set as base for a "${this.kind}"`);n.base=t.base,n.ctor=t.ctor||n.base.ctor,t.pick?n.pick=t.pick.map(l=>n.base.normalizeFieldPath(l)):t.omit?n.omit=t.omit.map(l=>n.base.normalizeFieldPath(l)):t.partial?n.partial=Array.isArray(t.partial)?t.partial.map(l=>n.base.normalizeFieldPath(l)):t.partial:t.required&&(n.required=Array.isArray(t.required)?t.required.map(l=>n.base.normalizeFieldPath(l)):t.required);let a=nr(n.pick,n.omit),p=Array.isArray(n.partial)?n.partial.map(l=>l.toLowerCase()):n.partial,c=Array.isArray(n.required)?n.required.map(l=>l.toLowerCase()):n.required;for(let[l,_]of n.base.fields.entries()){if(!a(l))continue;let u={..._};p===!0||Array.isArray(p)&&p.includes(_.name.toLowerCase())?u.required=!1:(c===!0||Array.isArray(c)&&c.includes(_.name.toLowerCase()))&&(u.required=!0);let C=new M(this,u);n.fields.set(C.name,C)}(!n.pick||n.base.additionalFields===!1||Array.isArray(n.base.additionalFields)&&((o=n.base.additionalFields)==null?void 0:o[0])==="error")&&(n.additionalFields=n.base.additionalFields),t.base.keyField&&a(t.base.keyField)&&(n.keyField=t.base.keyField)}},"MappedType"),yi=class yi extends w{extendsFrom(e){var t;return e instanceof O||(e=this.node.getDataType(e)),e instanceof w?e===this?!0:!!((t=this.base)!=null&&t.extendsFrom(e)):!1}toJSON(){let e=this.base?this.node.getDataTypeNameWithNs(this.base):void 0;return x({...w.prototype.toJSON.call(this),base:e||this.base.toJSON(),kind:this.kind,pick:this.pick,omit:this.omit,partial:this.partial,required:this.required})}};s(yi,"MappedTypeClass");var di=yi;Me.prototype=di.prototype;Me._applyMixin=()=>{};import"reflect-metadata";import{asMutable as Oa}from"ts-gems";var Xe=s(function(...i){if(!this)return Xe[S].apply(void 0,i);let[e,t,r]=i;w.call(this,e,t,r);let n=Oa(this);n.kind=h.MixinType.Kind,n.types=[];for(let o of t.types){n.additionalFields!==!0&&(o.additionalFields===!0?n.additionalFields=!0:n.additionalFields||(n.additionalFields=o.additionalFields));for(let a of o.fields.values()){let p=new M(this,a);n.fields.set(p.name,p)}n.types.push(o),o.keyField&&(n.keyField=o.keyField)}},"MixinType"),Ei=class Ei extends w{extendsFrom(e){if(e instanceof O||(e=this.node.getDataType(e)),!(e instanceof w))return!1;if(e===this)return!0;for(let t of this.types)if(t.extendsFrom(e))return!0;return!1}toJSON(){return x({...w.prototype.toJSON.call(this),kind:this.kind,types:this.types.map(e=>{let t=this.node.getDataTypeNameWithNs(e);return t||e.toJSON()})})}};s(Ei,"MixinTypeClass");var Ti=Ei;Xe.prototype=Ti.prototype;Xe[S]=Ra;function Ra(...i){let e=i.filter(a=>typeof a=="function"),t=typeof i[i.length-1]=="object"?i[i.length-1]:void 0;if(!e.length)throw new TypeError("No Class has been provided");if(e.length===1)return e[0];let r=e[0].name+"Mixin",n={[r]:class{constructor(){for(let a of e)Qt(this,a)}}}[r],o={...t,kind:h.MixinType.Kind,types:[]};Reflect.defineMetadata(T,o,n);for(let a of e){let p=Reflect.getMetadata(T,a);if(!(p&&(p.kind===h.ComplexType.Kind||p.kind===h.MixinType.Kind||p.kind===h.MappedType.Kind)))throw new TypeError(`Class "${a.name}" is not a ${h.ComplexType.Kind}, ${h.MixinType.Kind} or ${h.MappedType.Kind}`);o.types.push(a),Yt(n.prototype,a.prototype)}return n}s(Ra,"MixinTypeFactory");import"reflect-metadata";import{asMutable as ba}from"ts-gems";import{isAny as es}from"valgen";import Aa from"lodash.omit";function _i(i){let e=[],t=s(function(r){var a;let n;if(!(i!=null&&i.embedded))if(i!=null&&i.name){if(!$.test(i.name))throw new TypeError(`"${i.name}" is not a valid type name`);n=i.name}else n=((a=r.name.match(Xt))==null?void 0:a[1])||r.name,n=n.toLowerCase();let o=Reflect.getOwnMetadata(T,r)||{};o.kind=h.SimpleType.Kind,o.name=n,i&&Object.assign(o,Aa(i,["kind","name"])),Reflect.defineMetadata(T,o,r)},"decorator");return t.Example=(r,n)=>(e.push(o=>{o.examples=o.examples||[],o.examples.push({description:n,value:r})}),t),t}s(_i,"SimpleTypeDecoratorFactory");function Ho(i){return(e,t)=>{if(typeof t!="string")throw new TypeError("Symbol properties can't be decorated with Attribute");let r=Reflect.getOwnMetadata(T,e.constructor)||{},n=Reflect.getMetadata("design:type",e,t),o="string";n===Boolean?o="boolean":n===Number&&(o="number"),r.kind=h.SimpleType.Kind,r.attributes=r.attributes||{},r.attributes[t]={format:(i==null?void 0:i.format)||o,description:i==null?void 0:i.description,deprecated:i==null?void 0:i.deprecated},Reflect.defineMetadata(T,r,e.constructor)}}s(Ho,"AttributeDecoratorFactory");var m=s(function(...i){var o,a;if(!this)return m[S](...i);let[e,t,r]=i;O.call(this,e,t,r);let n=ba(this);if(n.kind=h.SimpleType.Kind,t.base){if(!(t.base instanceof m))throw new TypeError(`"${t.base.kind}" can't be set as base for a "${this.kind}"`);n.base=t.base}if(n.properties=t.properties,n.ownNameMappings={...t.nameMappings},n.nameMappings={...(o=n.base)==null?void 0:o.nameMappings,...t.nameMappings},n.ownAttributes=I(t.attributes||{}),n.attributes=n.base?I(n.base.attributes):{},n.ownAttributes)for(let[p,c]of Object.entries(n.ownAttributes)){if((a=n.attributes[p])!=null&&a.sealed)throw new TypeError(`Sealed attribute "${p}" can not be overwritten`);n.attributes[p]=c}n._generateDecoder=t.generateDecoder,n._generateEncoder=t.generateEncoder},"SimpleType"),gi=class gi extends O{extendsFrom(e){var t;return e instanceof O||(e=this.node.getDataType(e)),e instanceof m?e===this?!0:!!((t=this.base)!=null&&t.extendsFrom(e)):!1}generateCodec(e,t,r){let n={...this.properties,...r};if(e==="decode"){let a=this;for(;a;){if(a._generateDecoder)return a._generateDecoder(n,(t==null?void 0:t.documentElement)||this.owner);a=this.base}return es}let o=this;for(;o;){if(o._generateEncoder)return o._generateEncoder(n,(t==null?void 0:t.documentElement)||this.owner);o=this.base}return es}toJSON(){let e=x(this.ownAttributes),t;this.properties&&typeof this.properties.toJSON=="function"?t=this.properties.toJSON(this.properties,this.owner):t=this.properties?I(this.properties):{};let r=this.base?this.node.getDataTypeNameWithNs(this.base):void 0,n=x({...O.prototype.toJSON.apply(this),base:this.base?r||this.base.toJSON():void 0,attributes:e&&Object.keys(e).length?e:void 0,properties:Object.keys(t).length?t:void 0});return Object.keys(this.ownNameMappings).length&&(n.nameMappings={...this.ownNameMappings}),n}};s(gi,"SimpleTypeClass");var xi=gi;m.prototype=xi.prototype;Object.assign(m,_i);m[S]=_i;m.Attribute=Ho;var Oi=Symbol("initializing"),Ri=class Ri{static async createDataType(e,t,r){e=e||new ne({maxErrors:0});let n=await this._importDataTypeArgs(e,t,r);if(n)return typeof n=="string"?t.node.getDataType(n):this._createDataType(e,t,n)}static async addDataTypes(e,t,r){let n=t.node[B];if(!n)throw new TypeError("DocumentElement should has [kDataTypeMap] property");let o=await this.createAllDataTypes(e,t,r);if(o)for(let a of o)a!=null&&a.name&&n.set(a.name,a)}static async createAllDataTypes(e,t,r){e=e||new ne({maxErrors:0});let n=await this._prepareAllInitArgs(e,t,r);if(!n)return;let o=new P;for(let c of n)o.set(c.name,c);let a=e.extend({initArgsMap:o}),p=[];for(let[c,l]of o.entries())e.enter(`[${c}]`,()=>{if(!o.has(c))return;let _=this._createDataType(a,t,l);_&&p.push(_)});return p}static async _prepareAllInitArgs(e,t,r){let n=new P,o=new P,a=e.extend({owner:t,importQueue:n,initArgsMap:o});if(!t.node[B])throw new TypeError("DocumentElement should has [kDataTypeMap] property");if(Array.isArray(r)){let p=0;for(let c of r)await a.enterAsync(`$[${p++}]`,async()=>{c=await xe(c);let l=Reflect.getMetadata(T,c)||c[T];if(!(l&&l.name))return typeof c=="function"?a.addError(`Class "${c.name}" doesn't have a valid data type metadata`):a.addError("Object doesn't have a valid data type metadata");n.set(l.name,c)})}else{let p,c;for([c,p]of Object.entries(r))p=await xe(p),n.set(c,typeof p=="object"?{...p,name:c}:p)}for(let p of Array.from(n.keys())){if(!n.has(p))continue;let c=await this._importDataTypeArgs(a,t,p);c&&typeof c!="string"&&a.addError("Embedded data type can't be loaded into document node directly")}return Array.from(o.values())}static async _importDataTypeArgs(e,t,r){var _;r=await xe(r);let{importQueue:n,initArgsMap:o}=e,a=t.node.findDataType(r);if(a instanceof O)return a.name;let p,c,l;if(typeof r!="string"){let C=t.node.getDocument().types[Zt].get(r);C&&(r=C)}if(typeof r=="string"){let u=r;if(r=(n==null?void 0:n.get(u))||((_=e.initArgsMap)==null?void 0:_.get(u)),!r)return e.addError(`Unknown data type (${u})`)}if(typeof r=="function"){if(p=Reflect.getMetadata(T,r),!p)return e.addError(`Class "${r.name}" doesn't have a valid DataType metadata`);c=r}else if(typeof r=="object"){if(p=r[T],p)l=r,p.kind!==h.EnumType.Kind&&(p=void 0);else if(h.isDataType(r))p=r,c=p.ctor;else if(c=Object.getPrototypeOf(r).constructor,p=c&&Reflect.getMetadata(T,c),p&&p.kind===h.SimpleType.Kind){let u=await this._importDataTypeArgs(e,t,p.name);return u?typeof u=="object"&&u.kind!==h.SimpleType.Kind?e.addError("Kind of base data type is not same"):{kind:h.SimpleType.Kind,name:void 0,base:u,properties:r}:void 0}}return p?e.enterAsync(p.name?`[${p.name}]`:"",async()=>{if(p.name){let C=o==null?void 0:o.get(p.name);if(C)return C[Oi]?e.addError("Circular reference detected"):p.name}let u={kind:p.kind,name:p.name};u[Oi]=!0;try{if(u.name)if(n!=null&&n.has(u.name))o==null||o.set(p.name,u),u._instance={name:p.name},u[B]=t.node[B];else return e.addError(`Data Type (${u.name}) must be explicitly added to type list in the document scope`);switch(u.kind){case h.ComplexType.Kind:u.ctor=c,await this._prepareComplexTypeArgs(e,t,u,p);break;case h.EnumType.Kind:u.instance=l,await this._prepareEnumTypeArgs(e,t,u,p);break;case h.MappedType.Kind:await this._prepareMappedTypeArgs(e,t,u,p);break;case h.MixinType.Kind:await this._prepareMixinTypeArgs(e,t,u,p);break;case h.SimpleType.Kind:u.ctor=c,await this._prepareSimpleTypeArgs(e,t,u,p);break;default:return e.addError(`Invalid data type kind ${p.kind}`)}}finally{u.name&&(n==null||n.delete(u.name)),delete u[Oi]}return n&&u.name?u.name:u}):e.addError("No DataType metadata found")}static async _prepareDataTypeArgs(e,t,r){t.description=r.description,t.abstract=r.abstract,t.examples=r.examples}static async _prepareComplexTypeArgs(e,t,r,n){await this._prepareDataTypeArgs(e,r,n),await e.enterAsync(".base",async()=>{let o;if(n.base)o=await this._importDataTypeArgs(e,t,n.base);else if(r.ctor){let a=Object.getPrototypeOf(r.ctor.prototype).constructor;Reflect.hasMetadata(T,a)&&(o=await this._importDataTypeArgs(e,t,a))}o&&(r.base=ve(o),r.ctor=r.ctor||o.ctor)}),n.additionalFields!=null&&(typeof n.additionalFields=="boolean"||Array.isArray(n.additionalFields)?r.additionalFields=n.additionalFields:await e.enterAsync(".additionalFields",async()=>{let o=await this._importDataTypeArgs(e,t,n.additionalFields);o&&(r.additionalFields=ve(o))})),n.fields&&(r.fields={},await e.enterAsync(".fields",async()=>{for(let[o,a]of Object.entries(n.fields))await e.enterAsync(`[${o}]`,async()=>{let p=typeof a=="string"?{type:a}:a;if(p.isArray&&!p.type)return e.addError('"type" must be defined explicitly for array fields');let c=await this._importDataTypeArgs(e,t,p.type||"any");c&&(r.fields[o]={...p,type:ve(c)})})}))}static async _prepareEnumTypeArgs(e,t,r,n){await this._prepareDataTypeArgs(e,r,n),n.base&&await e.enterAsync(".base",async()=>{let o=await this._importDataTypeArgs(e,t,n.base);o&&(r.base=ve(o))}),r.attributes=I(n.attributes)}static async _prepareSimpleTypeArgs(e,t,r,n){var o,a,p,c;await this._prepareDataTypeArgs(e,r,n),await e.enterAsync(".base",async()=>{let l;if(n.base)l=await this._importDataTypeArgs(e,t,n.base);else if(r.ctor){let _=Object.getPrototypeOf(r.ctor.prototype).constructor;Reflect.hasMetadata(T,_)&&(l=await this._importDataTypeArgs(e,t,_))}l&&(r.base=ve(l),r.ctor=r.ctor||l.ctor)}),r.properties=n.properties,r.nameMappings=n.nameMappings,!r.properties&&r.ctor&&(r.properties=new r.ctor),n.attributes&&(r.attributes=I(n.attributes)),typeof((o=r.properties)==null?void 0:o[y])=="function"&&(r.generateDecoder=(a=r.properties)==null?void 0:a[y].bind(r.properties)),typeof((p=r.properties)==null?void 0:p[g])=="function"&&(r.generateEncoder=(c=r.properties)==null?void 0:c[g].bind(r.properties))}static async _prepareMappedTypeArgs(e,t,r,n){await this._prepareDataTypeArgs(e,r,n),await e.enterAsync(".base",async()=>{let o;if(n.base)o=await this._importDataTypeArgs(e,t,n.base);else if(r.ctor){let a=Object.getPrototypeOf(r.ctor.prototype).constructor;Reflect.hasMetadata(T,a)&&(o=await this._importDataTypeArgs(e,t,a))}o&&(r.base=ve(o),r.ctor=r.ctor||o.ctor)}),n.pick?r.pick=[...n.pick]:n.omit?r.omit=[...n.omit]:n.partial?r.partial=Array.isArray(n.partial)?[...n.partial]:n.partial:n.required&&(r.required=Array.isArray(n.required)?[...n.required]:n.required)}static async _prepareMixinTypeArgs(e,t,r,n){await this._prepareDataTypeArgs(e,r,n),r.types=[],await e.enterAsync(".types",async()=>{let o=n.types,a=0;for(let p of o)await e.enterAsync(`[${a++}]`,async()=>{let c=await this._importDataTypeArgs(e,t,p);c&&r.types.push(ve(c))})})}static _createDataType(e,t,r){var a;let n=t.node.findDataType(typeof r=="string"?r:r.name||"");if(n instanceof O)return n;let o=typeof r=="string"?(a=e.initArgsMap)==null?void 0:a.get(r):r;if(o){let p=o[B];switch(p||delete o._instance,n=o._instance,n!=null&&n.name&&p&&p.set(n.name,n),o==null?void 0:o.kind){case h.ComplexType.Kind:return this._createComplexType(e,t,o);case h.EnumType.Kind:return this._createEnumType(e,t,o);case h.MappedType.Kind:return this._createMappedType(e,t,o);case h.MixinType.Kind:return this._createMixinType(e,t,o);case h.SimpleType.Kind:return this._createSimpleType(e,t,o);default:break}}e.addError(`Unknown data type (${String(r)})`)}static _createComplexType(e,t,r){let n=r._instance||{};Object.setPrototypeOf(n,Q.prototype);let o=I(r);return r.base&&e.enter(".base",()=>{o.base=this._createDataType(e,t,r.base)}),r.additionalFields&&e.enter(".additionalFields",()=>{typeof r.additionalFields=="boolean"||Array.isArray(r.additionalFields)?o.additionalFields=r.additionalFields:o.additionalFields=this._createDataType(e,t,r.additionalFields)}),o.fields={},r.fields&&e.enter(".fields",()=>{for(let[a,p]of Object.entries(r.fields))e.enter(`[${a}]`,()=>{let c=this._createDataType(e,t,p.type);c&&(o.fields[a]={...p,name:a,type:c})})}),Q.apply(n,[t,o]),n}static _createEnumType(e,t,r){let n=r._instance||{};Object.setPrototypeOf(n,oe.prototype);let o=I(r);return r.base&&e.enter(".base",()=>{o.base=this._createDataType(e,t,r.base)}),o.attributes=r.attributes,oe.apply(n,[t,o]),n}static _createMappedType(e,t,r){let n=r._instance||{};Object.setPrototypeOf(n,Me.prototype);let o=I(r);return r.base&&e.enter(".base",()=>{o.base=this._createDataType(e,t,r.base)}),Me.apply(n,[t,o]),n}static _createMixinType(e,t,r){let n=r._instance||{};Object.setPrototypeOf(n,Xe.prototype);let o=I(r);return r.types&&e.enter(".types",()=>{o.types=[];let a=0;for(let p of r.types)e.enter(`[${a++}]`,()=>{let c=this._createDataType(e,t,p);if(!(c instanceof w))throw new TypeError(`"${c==null?void 0:c.kind}" can't be set as base for a "${o.kind}"`);o.types.push(c)})}),Xe.apply(n,[t,o]),n}static _createSimpleType(e,t,r){let n=r._instance||{};Object.setPrototypeOf(n,m.prototype);let o=I(r);return r.base&&e.enter(".base",()=>{o.base=this._createDataType(e,t,r.base)}),m.apply(n,[t,o]),n}};s(Ri,"DataTypeFactory");var J=Ri;function ve(i){return typeof i=="object"&&i.name?i.name:i}s(ve,"preferName");var Ai=class Ai extends b{constructor(e){super(e),this.name="OpraApi"}toJSON(){return x({protocol:this.protocol,name:this.name,description:this.description})}async _initialize(e,t){if(!$.test(e.name))throw new TypeError(`Invalid api name (${e.name})`);this.name=e.name,this.description=e==null?void 0:e.description}};s(Ai,"ApiBase");var or=Ai;import Sa from"path-browserify";import{asMutable as Ia}from"ts-gems";var ts,rs,X=Symbol.for("kMap"),Mt=Symbol.for("kCtorMap"),bi=class bi{constructor(){this[ts]=new P,this[rs]=new WeakMap}get size(){return this[X].size}forEach(e,t){this[X].forEach(e,t)}get(e){let t=typeof e=="string"?e:this[Mt].get(e);if(!t&&typeof e=="function"){let r=Reflect.getMetadata(T,e);t=r==null?void 0:r.name}if(!t&&typeof e=="object"){let r=e[T];t=r==null?void 0:r.name}return t?this[X].get(t):void 0}set(e,t){this[X].set(e,t),t.ctor?this[Mt].set(t.ctor,e):t.instance&&this[Mt].set(t.instance,e)}has(e){if(e instanceof O)return!!e.name&&this[X].has(e.name);let t=typeof e=="string"?e:this[Mt].get(e);return t?this[X].has(t):!1}keys(){return this[X].keys()}values(){return this[X].values()}entries(){return this[X].entries()}sort(e){return this[X].sort(e),this}[(ts=X,rs=Mt,Symbol.iterator)](){return this[X][Symbol.iterator]()}};s(bi,"DataTypeMap");var Oe=bi;import Na from"lodash.omit";import wi from"putil-merge";var Da=/^(.*)(Controller)$/;function Ni(i){let e=[],t=s(function(r){var c;let n=i==null?void 0:i.name;n||(n=((c=Da.exec(r.name))==null?void 0:c[1])||r.name);let o={},a=Reflect.getOwnMetadata(te,Object.getPrototypeOf(r));a&&wi(o,a,{deep:!0});let p=Reflect.getOwnMetadata(te,r);p&&wi(o,p,{deep:!0}),wi(o,{kind:h.HttpController.Kind,name:n,path:n,...Na(i,["kind","name","instance","endpoints","key"])},{deep:!0}),Reflect.defineMetadata(te,o,r);for(let l of e)l(o);Reflect.defineMetadata(te,o,r)},"decorator");return t.Cookie=(r,n)=>(e.push(o=>{let a=typeof n=="string"||typeof n=="function"?{name:r,location:"cookie",type:n}:{...n,name:r,location:"cookie"};o.parameters=o.parameters||[],o.parameters.push(a)}),t),t.Header=(r,n)=>(e.push(o=>{let a=typeof n=="string"||typeof n=="function"?{name:r,location:"header",type:n}:{...n,name:r,location:"header"};o.parameters=o.parameters||[],o.parameters.push(a)}),t),t.QueryParam=(r,n)=>(e.push(o=>{let a=typeof n=="string"||typeof n=="function"?{name:r,location:"query",type:n}:{...n,name:r,location:"query"};o.parameters=o.parameters||[],o.parameters.push(a)}),t),t.PathParam=(r,n)=>(e.push(o=>{let a=typeof n=="string"||typeof n=="function"?{name:r,location:"path",type:n}:{...n,name:r,location:"path"};o.parameters=o.parameters||[],o.parameters.push(a)}),t),t.KeyParam=(r,n)=>(e.push(o=>{var p;(p=o.path)!=null&&p.includes(":"+r)||(o.path=(o.path||"")+"@:"+r);let a=typeof n=="string"||typeof n=="function"?{name:r,location:"path",type:n,keyParam:!0}:{...n,name:r,location:"path",keyParam:!0};o.parameters=o.parameters||[],o.parameters.push(a)}),t),t.UseType=(...r)=>(e.push(n=>{n.types=n.types||[],n.types.push(...r)}),t),t}s(Ni,"HttpControllerDecoratorFactory");var Z=s(function(...i){var n;if(!this)return Z[S].apply(void 0,i);let[e,t]=i;if(b.call(this,e),!$.test(t.name))throw new TypeError(`Invalid resource name (${t.name})`);let r=Ia(this);r.kind=h.HttpController.Kind,r.types=r.node[B]=new Oe,r.operations=new P,r.controllers=new P,r.parameters=[],r.name=t.name,r.description=t.description,r.path=t.path??t.name,r.instance=t.instance,r.ctor=t.ctor,r._controllerReverseMap=new WeakMap,(n=r._initialize)==null||n.call(r,t)},"HttpController"),Si=class Si extends b{get isRoot(){return!(this.owner instanceof Z)}findController(e){if(typeof e=="function"){let t=this._controllerReverseMap.get(e);if(t!=null)return t;for(let r of this.controllers.values()){if(r.ctor===e)return this._controllerReverseMap.set(e,r),r;if(r.controllers.size&&(t=r.findController(e),t))return this._controllerReverseMap.set(e,t),t}this._controllerReverseMap.set(e,null);return}if(e.startsWith("/")&&(e=e.substring(1)),e.includes("/")){let t=e.split("/"),r=this;for(;r&&t.length>0;)r=r.controllers.get(t.shift());return r}return this.controllers.get(e)}findParameter(e,t){let r=e.toLowerCase(),n;for(n of this.parameters)if(!(t&&t!==n.location)&&(typeof n.name=="string"&&(n._nameLower=n._nameLower||n.name.toLowerCase(),n._nameLower===r)||n.name instanceof RegExp&&n.name.test(e)))return n;if(this.node.parent&&this.node.parent.element instanceof Z)return this.node.parent.element.findParameter(e,t)}getFullUrl(){return Sa.posix.join(this.owner instanceof Z?this.owner.getFullUrl():"/",this.path)}toString(){return`[HttpController ${this.name}]`}toJSON(){let e=x({kind:this.kind,description:this.description,path:this.path});if(this.operations.size){e.operations={};for(let t of this.operations.values())e.operations[t.name]=t.toJSON()}if(this.controllers.size){e.controllers={};for(let t of this.controllers.values())e.controllers[t.name]=t.toJSON()}if(this.types.size){e.types={};for(let t of this.types.values())e.types[t.name]=t.toJSON()}if(this.parameters.length){e.parameters=[];for(let t of this.parameters)e.parameters.push(t.toJSON())}return e}[tr](){return`[${rr}HttpController${ir+this.name+Lt}]`}};s(Si,"HttpControllerClass");var Di=Si;Z.prototype=Di.prototype;Object.assign(Z,Ni);Z[S]=Ni;var Ii=class Ii extends or{constructor(e){super(e),this._controllerReverseMap=new WeakMap,this.protocol="http",this.controllers=new P}findController(e){return Z.prototype.findController.call(this,e)}findOperation(e,t){let r=this.findController(e);return r==null?void 0:r.operations.get(t)}toJSON(){let t={...super.toJSON(),protocol:this.protocol,url:this.url,controllers:{}};for(let r of this.controllers.values())t.controllers[r.name]=r.toJSON();return t}};s(Ii,"HttpApi");var sr=Ii;import La from"@browsery/type-is";import{asMutable as Pa}from"ts-gems";import{isAny as Ma,vg as va}from"valgen";var Re=s(function(i,e){if(!this)throw new TypeError('"this" should be passed to call class constructor');b.call(this,i);let t=Pa(this);if(e.contentType){let r=Array.isArray(e.contentType)?e.contentType:[e.contentType];r=r.map(n=>n.split(/\s*,\s*/)).flat(),t.contentType=r.length>1?r:r[0]}t.description=e.description,t.contentEncoding=e.contentEncoding,t.examples=e.examples,t.multipartFields=[],t.maxFieldsSize=e.maxFieldsSize,t.maxFields=e.maxFields,t.maxFiles=e.maxFiles,t.maxFileSize=e.maxFileSize,t.maxTotalFileSize=e.maxTotalFileSize,e!=null&&e.type&&(t.type=(e==null?void 0:e.type)instanceof O?e.type:t.owner.node.getDataType(e.type)),t.isArray=e.isArray},"HttpMediaType"),Pi=class Pi extends b{findMultipartField(e,t){if(this.multipartFields){for(let r of this.multipartFields)if((!t||t===r.fieldType)&&(r.fieldName instanceof RegExp&&r.fieldName.test(e)||r.fieldName===e))return r}}toJSON(){var r,n;let e=this.type?this.node.getDataTypeNameWithNs(this.type):void 0,t=x({description:this.description,contentType:this.contentType,contentEncoding:this.contentEncoding,type:e||((r=this.type)==null?void 0:r.toJSON()),isArray:this.isArray,example:this.example,examples:this.examples,maxFields:this.maxFields,maxFieldsSize:this.maxFieldsSize,maxFiles:this.maxFiles,maxFileSize:this.maxFileSize,maxTotalFileSize:this.maxTotalFileSize});return(n=this.multipartFields)!=null&&n.length&&(t.multipartFields=this.multipartFields.map(o=>o.toJSON())),t}generateCodec(e,t){let r;return this.type?r=this.type.generateCodec(e,t):this.contentType&&(Array.isArray(this.contentType)?this.contentType:[this.contentType]).find(o=>La.is(o,["json"]))&&(r=this.node.findDataType("object").generateCodec(e)),r=r||Ma,this.isArray?va.isArray(r):r}};s(Pi,"HttpMediaTypeClass");var Li=Pi;Re.prototype=Li.prototype;function ar(i,e){let t=i.lastIndexOf("/");if(i.startsWith("/")&&t){let r=i.substring(1,t),n=i.substring(t+1);if(e!=null&&e.includeFlags)for(let o of e==null?void 0:e.includeFlags)n.includes(o)||(n+=o);if(e!=null&&e.excludeFlags)for(let o of e==null?void 0:e.excludeFlags)n.replace(o,"");return new RegExp(r,n)}throw new TypeError(`"${i}" is not a valid RegExp string`)}s(ar,"parseRegExp");var Mi=class Mi extends Re{constructor(e,t){super(e,t),this.fieldName=t.fieldName instanceof RegExp?t.fieldName:t.fieldName.startsWith("/")?ar(t.fieldName):t.fieldName,this.fieldType=t.fieldType,this.required=t.required}toJSON(){return x({fieldName:this.fieldName,fieldType:this.fieldType,required:this.required,...super.toJSON()})}};s(Mi,"HttpMultipartField");var pr=Mi;import ka from"path-browserify";import{asMutable as ja}from"ts-gems";import Fa from"lodash.omit";var is;(function(i){i.X_Opra_Version="X-Opra-Version",i.X_Total_Count="X-Total-Count",i.WWW_Authenticate="WWW-Authenticate",i.Authorization="Authorization",i.Proxy_Authenticate="Proxy-Authenticate",i.Proxy_Authorization="Proxy-Authorization",i.Age="Age",i.Cache_Control="Cache-Control",i.Clear_Site_Data="Clear-Site-Data",i.Expires="Expires",i.Pragma="Pragma",i.Last_Modified="Last-Modified",i.ETag="ETag",i.If_Match="If-Match",i.If_None_Match="If-None-Match",i.If_Modified_Since="If-Modified-Since",i.If_Unmodified_Since="If-Unmodified-Since",i.Vary="Vary",i.Connection="Connection",i.Keep_Alive="Keep-Alive",i.Accept="Accept",i.Accept_Encoding="Accept-Encoding",i.Accept_Language="Accept-Language",i.Expect="Expect",i.Cookie="Cookie",i.Set_Cookie="Set-Cookie",i.Access_Control_Allow_Origin="Access-Control-Allow-Origin",i.Access_Control_Allow_Credentials="Access-Control-Allow-Credentials",i.Access_Control_Allow_Headers="Access-Control-Allow-Headers",i.Access_Control_Allow_Methods="Access-Control-Allow-Methods",i.Access_Control_Expose_Headers="Access-Control-Expose-Headers",i.Access_Control_Max_Age="Access-Control-Max-Age",i.Access_Control_Request_Headers="Access-Control-Request-Headers",i.Access_Control_Request_Method="Access-Control-Request-Method",i.Origin="Origin",i.Timing_Allow_Origin="Timing-Allow-Origin",i.Content_Disposition="Content-Disposition",i.Content_ID="Content-ID",i.Content_Length="Content-Length",i.Content_Type="Content-Type",i.Content_Transfer_Encoding="Content-Transfer-Encoding",i.Content_Encoding="Content-Encoding",i.Content_Language="Content-Language",i.Content_Location="Content-Location",i.Forwarded="Forwarded",i.X_Forwarded_For="X-Forwarded-For",i.X_Forwarded_Host="X-Forwarded-Host",i.X_Forwarded_Proto="X-Forwarded-Proto",i.Via="Via",i.Location="Location",i.From="From",i.Host="Host",i.Referer="Referer",i.Referrer_Policy="Referrer-Policy",i.User_Agent="User-Agent",i.Allow="Allow",i.Server="Server",i.Accept_Ranges="Accept-Ranges",i.Range="Range",i.If_Range="If-Range",i.Content_Range="Content-Range",i.Cross_Origin_Embedder_Policy="Cross-Origin-Embedder-Policy",i.Cross_Origin_Opener_Policy="Cross-Origin-Opener-Policy",i.Cross_Origin_Resource_Policy="Cross-Origin-Resource-Policy",i.Content_Security_Policy="Content-Security-Policy",i.Content_Security_Policy_Report_Only="Content-Security-Policy-Report-Only",i.Expect_CT="Expect-CT",i.Feature_Policy="Feature-Policy",i.Strict_Transport_Security="Strict-Transport-Security",i.Upgrade="Upgrade",i.Upgrade_Insecure_Requests="Upgrade-Insecure-Requests",i.X_Content_Type_Options="X-Content-Type-Options",i.X_Download_Options="X-Download-Options",i.X_Frame_Options="X-Frame-Options",i.X_Permitted_Cross_Domain_Policies="X-Permitted-Cross-Domain-Policies",i.X_Powered_By="X-Powered-By",i.X_XSS_Protection="X-XSS-Protection",i.Transfer_Encoding="Transfer-Encoding",i.TE="TE",i.Trailer="Trailer",i.Sec_WebSocket_Key="Sec-WebSocket-Key",i.Sec_WebSocket_Extensions="Sec-WebSocket-Extensions",i.Sec_WebSocket_Accept="Sec-WebSocket-Accept",i.Sec_WebSocket_Protocol="Sec-WebSocket-Protocol",i.Sec_WebSocket_Version="Sec-WebSocket-Version",i.Date="Date",i.Retry_After="Retry-After",i.Server_Timing="Server-Timing",i.X_DNS_Prefetch_Control="X-DNS-Prefetch-Control",i.Max_Forwards="Max-Forwards"})(is||(is={}));var N;(function(i){i[i.CONTINUE=100]="CONTINUE",i[i.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",i[i.PROCESSING=102]="PROCESSING",i[i.EARLYHINTS=103]="EARLYHINTS",i[i.OK=200]="OK",i[i.CREATED=201]="CREATED",i[i.ACCEPTED=202]="ACCEPTED",i[i.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",i[i.NO_CONTENT=204]="NO_CONTENT",i[i.RESET_CONTENT=205]="RESET_CONTENT",i[i.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",i[i.AMBIGUOUS=300]="AMBIGUOUS",i[i.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",i[i.FOUND=302]="FOUND",i[i.SEE_OTHER=303]="SEE_OTHER",i[i.NOT_MODIFIED=304]="NOT_MODIFIED",i[i.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",i[i.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",i[i.BAD_REQUEST=400]="BAD_REQUEST",i[i.UNAUTHORIZED=401]="UNAUTHORIZED",i[i.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",i[i.FORBIDDEN=403]="FORBIDDEN",i[i.NOT_FOUND=404]="NOT_FOUND",i[i.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",i[i.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",i[i.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",i[i.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",i[i.CONFLICT=409]="CONFLICT",i[i.GONE=410]="GONE",i[i.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",i[i.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",i[i.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",i[i.URI_TOO_LONG=414]="URI_TOO_LONG",i[i.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",i[i.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",i[i.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",i[i.I_AM_A_TEAPOT=418]="I_AM_A_TEAPOT",i[i.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",i[i.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",i[i.LOCKED=423]="LOCKED",i[i.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",i[i.TOO_EARLY=425]="TOO_EARLY",i[i.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",i[i.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",i[i.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",i[i.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",i[i.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",i[i.BAD_GATEWAY=502]="BAD_GATEWAY",i[i.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",i[i.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",i[i.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",i[i.VARIANT_ALSO_NEGOTIATES=506]="VARIANT_ALSO_NEGOTIATES",i[i.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",i[i.LOOP_DETECTED=508]="LOOP_DETECTED",i[i.NOT_EXTENDED=510]="NOT_EXTENDED",i[i.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"})(N||(N={}));var n0={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a Teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"};var L;(function(i){i.json="application/json",i.opra_response_json="application/opra.response+json",i.xml="application/XML",i.text="text/plain",i.html="text/html",i.markdown="text/markdown",i.binary="binary/octet-stream"})(L||(L={}));function F(i,e){let t=s((r,n)=>{if(typeof n!="string")throw new TypeError("Symbol properties can not be decorated");let o={kind:h.HttpOperation.Kind,...Fa(e,["kind"])},a=Reflect.getOwnMetadata(te,r.constructor)||{};a.operations=a.operations||{},a.operations[n]=o;for(let p of i)p(o);Reflect.defineMetadata(te,a,r.constructor)},"decorator");return t.Cookie=(r,n)=>(i.push(o=>{let a=typeof n=="string"||typeof n=="function"?{name:r,location:"cookie",type:n}:{...n,name:r,location:"cookie"};o.parameters?o.parameters=o.parameters.filter(p=>!(p.location==="cookie"&&String(p.name)===String(r))):o.parameters=[],o.parameters.push(a)}),t),t.Header=(r,n)=>(i.push(o=>{let a=typeof n=="string"||typeof n=="function"?{name:r,location:"header",type:n}:{...n,name:r,location:"header"};o.parameters?o.parameters=o.parameters.filter(p=>!(p.location==="header"&&String(p.name)===String(r))):o.parameters=[],o.parameters.push(a)}),t),t.QueryParam=(r,n)=>(i.push(o=>{let a=typeof n=="string"||typeof n=="function"?{name:r,location:"query",type:n}:{...n,name:r,location:"query"};o.parameters?o.parameters=o.parameters.filter(p=>!(p.location==="query"&&String(p.name)===String(r))):o.parameters=[],o.parameters.push(a)}),t),t.PathParam=(r,n)=>(i.push(o=>{let a=typeof n=="string"||typeof n=="function"?{name:r,location:"path",type:n}:{...n,name:r,location:"path"};o.parameters?o.parameters=o.parameters.filter(p=>!(p.location==="path"&&String(p.name)===String(r))):o.parameters=[],o.parameters.push(a)}),t),t.Response=(r,n)=>{let o={...n,statusCode:r};return o.type&&(o.contentType=o.contentType||L.opra_response_json,o.contentEncoding=o.contentEncoding||"utf-8"),o.contentType===L.opra_response_json&&(o.contentEncoding=o.contentEncoding||"utf-8"),i.push(a=>{a.responses=a.responses||[],a.responses.push(o)}),t},t.RequestContent=function(r){let n=typeof r=="object"?r:{type:r};return n.type&&(n.contentType=n.contentType||L.json,n.contentEncoding=n.contentEncoding||"utf-8"),i.push(o=>{o.requestBody=o.requestBody||{required:!0,content:[]},o.requestBody.content=o.requestBody.content||[],o.requestBody.content.push(n)}),t},t.MultipartContent=function(r,n){let o={...r,contentType:(r==null?void 0:r.contentType)||"multipart/form-data"};if(i.push(a=>{a.requestBody=a.requestBody||{required:!0,content:[]},a.requestBody.content=a.requestBody.content||[],a.requestBody.content.push(o)}),n){let a={Field(p,c){return o.multipartFields=o.multipartFields||[],o.multipartFields.push({fieldName:p,fieldType:"field",...c}),a},File(p,c){return o.multipartFields=o.multipartFields||[],o.multipartFields.push({fieldName:p,fieldType:"file",...c}),a}};n(a)}return t},t.UseType=(...r)=>(i.push(n=>{n.types=n.types||[],n.types.push(...r)}),t),t}s(F,"HttpOperationDecoratorFactory");var D=s(function(...i){if(!this){let[n]=i,o=[];return D[S].call(void 0,o,n)}let[e,t]=i;if(b.call(this,e),!$.test(t.name))throw new TypeError(`Invalid operation name (${t.name})`);let r=ja(this);r.parameters=[],r.responses=[],r.types=r.node[B]=new Oe,r.name=t.name,r.path=t.path,r.mergePath=t.mergePath,r.method=t.method||"GET",r.description=t.description,r.composition=t.composition,r.compositionOptions=t.compositionOptions?I(t.compositionOptions):void 0},"HttpOperation"),Fi=class Fi extends b{findParameter(e,t){let r=e.toLowerCase(),n;for(n of this.parameters)if(!(t&&t!==n.location)&&(typeof n.name=="string"&&(n._nameLower=n._nameLower||n.name.toLowerCase(),n._nameLower===r)||n.name instanceof RegExp&&n.name.test(e)))return n}getFullUrl(){let e=this.owner.getFullUrl();return e?this.path?this.mergePath?e+this.path:ka.posix.join(e,this.path):e:this.path||"/"}toJSON(){var t;let e=x({kind:h.HttpOperation.Kind,description:this.description,method:this.method,path:this.path,mergePath:this.mergePath,composition:this.composition,requestBody:(t=this.requestBody)==null?void 0:t.toJSON()});if(this.parameters.length){e.parameters=[];for(let r of this.parameters)e.parameters.push(r.toJSON())}return this.responses.length&&(e.responses=this.responses.map(r=>r.toJSON())),e}};s(Fi,"HttpOperationClass");var vi=Fi;D.prototype=vi.prototype;D[S]=F;D.GET=function(i){return F([],{...i,method:"GET"})};D.DELETE=function(i){return F([],{...i,method:"DELETE"})};D.HEAD=function(i){return F([],{...i,method:"HEAD"})};D.OPTIONS=function(i){return F([],{...i,method:"OPTIONS"})};D.PATCH=function(i){return F([],{...i,method:"PATCH"})};D.POST=function(i){return F([],{...i,method:"POST"})};D.PUT=function(i){return F([],{...i,method:"PUT"})};D.SEARCH=function(i){return F([],{...i,method:"SEARCH"})};var Ua=/^([1-6]\d{2})(?:-([1-6]\d{2}))?$/,ki=class ki{constructor(e,t){if(this.start=0,this.end=0,e&&typeof e=="object"&&(this.start=e.start||0,this.end=e.end||0),typeof e=="number"&&(this.start=e,this.end=t||this.start),typeof e=="string"){let r=Ua.exec(e);if(!r)throw new TypeError(`"${e}" is not a valid Status Code range`);this.start=parseInt(r[1],10),this.end=r[2]?parseInt(r[2],10):this.start}}includes(e){return e>=this.start&&e<=this.end}intersects(e,t){return t>=this.start&&e<=this.end}toString(){return this.start===this.end?String(this.start):String(this.start)+"-"+String(this.end)}toJSON(){return!this.end||this.start===this.end?this.start:{start:this.start,end:this.end}}};s(ki,"HttpStatusRange");var vt=ki;var ji=class ji extends Re{constructor(e,t){super(e,t),this.parameters=[],this.statusCode=(Array.isArray(t.statusCode)?t.statusCode:[t.statusCode]).map(r=>typeof r=="object"?new vt(r.start,r.end):new vt(r)),this.partial=t.partial}findParameter(e,t){e=e.toLowerCase();for(let r of this.parameters)if((!t||t===r.location)&&(r.name instanceof RegExp&&r.name.test(e)||r.name===e))return r}toJSON(){let e=this.statusCode.map(r=>r.toJSON()),t=x({...super.toJSON(),statusCode:e.length===1&&typeof e[0]=="number"?e[0]:e,partial:this.partial});if(this.parameters.length){t.parameters=[];for(let r of this.parameters)t.parameters.push(r.toJSON())}return t}};s(ji,"HttpOperationResponse");var cr=ji;import{asMutable as Ba}from"ts-gems";import{asMutable as Ca}from"ts-gems";var lr=s(function(i,e){if(!this)throw new TypeError('"this" should be passed to call class constructor');b.call(this,i);let t=Ca(this);t.description=e.description,t.type=e.type,t.examples=e.examples,t.isArray=e.isArray},"Value"),Ci=class Ci extends b{toJSON(){let e=this.type?this.node.getDataTypeNameWithNs(this.type):void 0;return x({type:this.type?e||this.type.toJSON():"any",description:this.description,isArray:this.isArray,examples:this.examples})}};s(Ci,"ValueClass");var Ui=Ci;lr.prototype=Ui.prototype;var Ft=s(function(i,e){if(!this)throw new TypeError('"this" should be passed to call class constructor');lr.call(this,i,e);let t=Ba(this);e.name&&(t.name=e.name instanceof RegExp?e.name:e.name.startsWith("/")?ar(e.name,{includeFlags:"i",excludeFlags:"m"}):e.name),t.location=e.location,t.deprecated=e.deprecated,t.required=e.required,t.required==null&&e.location==="path"&&(t.required=!0),t.arraySeparator=e.arraySeparator,t.keyParam=e.keyParam},"HttpParameter"),qi=class qi extends lr{toJSON(){return x({...super.toJSON(),name:this.name,location:this.location,arraySeparator:this.arraySeparator,keyParam:this.keyParam,required:this.required,deprecated:this.deprecated})}};s(qi,"HttpParameterClass");var Bi=qi;Ft.prototype=Bi.prototype;var $i=class $i extends b{constructor(e){super(e),this.content=[]}toJSON(){return x({description:this.description,required:this.required,maxContentSize:this.maxContentSize,content:this.content.length?this.content.map(e=>e.toJSON()):[],partial:this.partial})}};s($i,"HttpRequestBody");var fr=$i;var Vi=class Vi{static async createApi(e,t,r){let n=new sr(t);return n.name=r.name,n.description=r.description,n.url=r.url,r.controllers&&await e.enterAsync(".controllers",async()=>{if(Array.isArray(r.controllers))for(let o of r.controllers){let a=await this._createController(e,n,o);a&&n.controllers.set(a.name,a)}else for(let[o,a]of Object.entries(r.controllers)){let p=await this._createController(e,n,a,o);p&&n.controllers.set(p.name,p)}}),n}static async _createController(e,t,r,n){typeof r=="function"&&!Gt(r)&&(r=t instanceof Z?r(t.instance):r()),r=await xe(r);let o,a,p;if(typeof r=="function"){if(a=Reflect.getMetadata(te,r),!a)return e.addError(`Class "${r.name}" doesn't have a valid HttpController metadata`);o=r}else o=Object.getPrototypeOf(r).constructor,a=Reflect.getMetadata(te,o),a?p=r:(a=r,r.instance==="object"&&(p=r.instance,o=Object.getPrototypeOf(p).constructor));if(!a)return e.addError(`Class "${o.name}" is not decorated with HttpController()`);if(n=n||a.name,!n)throw new TypeError("Controller name required");let c=new Z(t,{...a,name:n,instance:p,ctor:o});return a.types&&await e.enterAsync(".types",async()=>{await J.addDataTypes(e,c,a.types)}),a.parameters&&await e.enterAsync(".parameters",async()=>{let l=0;for(let _ of a.parameters)await e.enterAsync(`[${l++}]`,async()=>{let u={..._};await e.enterAsync(".type",async()=>{_.type&&(u.type=c.node.findDataType(_.type)),!u.type&&typeof _.type=="object"&&(u.type=await J.createDataType(e,c,_.type)),u.type||(u.type=c.node.getDataType("any"))});let C=new Ft(c,u);c.parameters.push(C)})}),a.operations&&await e.enterAsync(".operations",async()=>{for(let[l,_]of Object.entries(a.operations))await e.enterAsync(`[${l}]`,async()=>{let u=new D(c,{name:l,method:"GET"});await this._initHttpOperation(e,u,_),c.operations.set(l,u)})}),a.controllers&&await e.enterAsync(".controllers",async()=>{if(Array.isArray(a.controllers)){let l=0;for(let _ of a.controllers)await e.enterAsync(`[${l}]`,async()=>{let u=await this._createController(e,c,_);u&&(c.controllers.get(u.name)&&e.addError(`Duplicate controller name (${u.name})`),c.controllers.set(u.name,u))}),l++}else for(let[l,_]of Object.entries(a.controllers))await e.enterAsync(`[${l}]`,async()=>{let u=await this._createController(e,c,_,l);u&&(c.controllers.get(u.name)&&e.addError(`Duplicate controller name (${u.name})`),c.controllers.set(u.name,u))})}),c}static async _initHttpOperation(e,t,r){let n={...r,name:t.name,types:void 0};return D.apply(t,[t.owner,n]),r.types&&await e.enterAsync(".types",async()=>{await J.addDataTypes(e,t,r.types)}),r.parameters&&await e.enterAsync(".parameters",async()=>{let o=0;for(let a of r.parameters)await e.enterAsync(`[${o++}]`,async()=>{let p={...a};await e.enterAsync(".type",async()=>{a.type&&(p.type=t.node.findDataType(a.type)),!p.type&&typeof a.type=="object"&&(p.type=await J.createDataType(e,t,a.type)),p.type||(p.type=t.node.getDataType("any"))});let c=new Ft(t,p);t.parameters.push(c)})}),r.responses&&await e.enterAsync(".responses",async()=>{let o=0;for(let a of r.responses)await e.enterAsync(`[${o++}]`,async()=>{let p=new cr(t,{statusCode:a.statusCode});await this._initHttpOperationResponse(e,p,a),t.responses.push(p)})}),r.requestBody&&await e.enterAsync(".requestBody",async()=>{let o=new fr(t);await this._initHttpRequestBody(e,o,r.requestBody),t.requestBody=o}),t}static async _initHttpMediaType(e,t,r){Re.call(t,t.owner,{...r,type:void 0,multipartFields:void 0}),r.type&&await e.enterAsync(".type",async()=>{r.type&&(t.type=t.node.findDataType(r.type)),!t.type&&(typeof r.type=="object"||typeof r.type=="function")&&(t.type=await J.createDataType(e,t,r.type)),t.type||(t.type=t.node.getDataType("any"))}),r.multipartFields&&await e.enterAsync(".multipartFields",async()=>{for(let n=0;n<r.multipartFields.length;n++)await e.enterAsync(`[${n}]`,async()=>{let o=r.multipartFields[n],a=new pr(t,{fieldName:o.fieldName,fieldType:o.fieldType});await this._initHttpMediaType(e,a,o),t.multipartFields.push(a)})})}static async _initHttpOperationResponse(e,t,r){await this._initHttpMediaType(e,t,r),t.partial=r.partial,r.parameters&&await e.enterAsync(".parameters",async()=>{let n=0;for(let o of r.parameters)await e.enterAsync(`[${n++}]`,async()=>{let a={...o};await e.enterAsync(".type",async()=>{o.type&&(a.type=t.node.findDataType(o.type)),!a.type&&typeof o.type=="object"&&(a.type=await J.createDataType(e,t,o.type)),a.type||(a.type=t.node.getDataType("any"))});let p=new Ft(t,a);t.parameters.push(p)})})}static async _initHttpRequestBody(e,t,r){t.description=r.description,t.required=r.required,t.maxContentSize=r.maxContentSize,t.immediateFetch=r.immediateFetch,t.partial=r.partial,r.content&&await e.enterAsync(".content",async()=>{for(let n=0;n<r.content.length;n++)await e.enterAsync(`[${n}]`,async()=>{let o=r.content[n],a=new Re(t,String(n));await this._initHttpMediaType(e,a,o),t.content.push(a)})})}};s(Vi,"HttpApiFactory");var Ze=Vi;import{md5 as $a}from"super-fast-md5";var ns,Ki=class Ki extends b{constructor(){super(null),this[ns]=new WeakMap,this.id="",this.info={},this.references=new P,this.types=new Oe,this.node[B]=this.types,this.node.findDataType=this._findDataType.bind(this)}getDataTypeNs(e){let t=e instanceof O?this._findDataType(e.name||""):this._findDataType(e);if(t)return this[ge].get(t)}findDocument(e){if(this.id===e)return this;for(let t of this.references.values()){if(t.id===e)return t;let r=t.findDocument(e);if(r)return r}}toJSON(){return this.export()}export(){let e=x({spec:h.SpecVersion,id:this.id,url:this.url,info:I(this.info,!0)});if(this.references.size){let t=0,r={};for(let[n,o]of this.references.entries())o[Ie]||(r[n]={id:o.id,url:o.url,info:I(o.info,!0)},t++);t&&(e.references=r)}if(this.types.size){e.types={};for(let t of this.types.values())e.types[t.name]=t.toJSON()}return this.api&&(e.api=this.api.toJSON()),e}invalidate(){let e=this.export();delete e.id,this.id=$a(JSON.stringify(e)),this[ge]=new WeakMap}_findDataType(e,t){let r=this.types.get(e);if(r||!this.references.size)return r;if(typeof e=="string"){let o=Jo.exec(e);if(o){let a=o[1];if(a){let p=this.references.get(a);return p?(t=t||new WeakMap,t.set(this,!0),t.set(p,!0),p._findDataType(o[2],t)):void 0}e=o[2]}}t=t||new WeakMap,t.set(this,!0);let n=Array.from(this.references.keys()).reverse();for(let o of n){let a=this.references.get(o);if(r=a==null?void 0:a.types.get(e),r)return this[ge].set(r,a!=null&&a[Ie]?"":o),r}for(let o of n){let a=this.references.get(o);if(t.set(a,!0),r=a._findDataType(e,t),r)return this[ge].set(r,a!=null&&a[Ie]?"":o),r}}};s(Ki,"ApiDocument");var Fe=Ki;ns=ge;import{__decorate as Va,__metadata as Ka}from"tslib";import{vg as os}from"valgen";var He,ur=(He=class{constructor(e){e&&Object.assign(this,e)}[y](){return os.isBase64({coerce:!0})}[g](){return os.isBase64({coerce:!0})}},s(He,"Base64Type"),He);ur=Va([m({description:"A stream of bytes, base64 encoded",nameMappings:{js:"string",json:"string"}}),Ka("design:paramtypes",[Object])],ur);import{__decorate as zi,__metadata as Ji}from"tslib";import{isDateString as mr,toString as ss,vg as Ae}from"valgen";var et,tt=(et=class{constructor(e){e&&Object.assign(this,e)}[y](e){let t=Ae.isDate({precision:"date",coerce:!0}),r=[];return e.minValue&&(mr(e.minValue),r.push(ss,Ae.isGte(e.minValue))),e.maxValue&&(mr(e.maxValue),r.push(ss,Ae.isLte(e.maxValue))),r.length>0?Ae.pipe([t,...r],{returnIndex:0}):t}[g](e){let t=Ae.isDateString({precision:"date",trim:"date",coerce:!0}),r=[];return e.minValue&&(mr(e.minValue),r.push(Ae.isGte(e.minValue))),e.maxValue&&(mr(e.maxValue),r.push(Ae.isLte(e.maxValue))),r.length>0?Ae.pipe([t,...r],{returnIndex:0}):t}},s(et,"DateType"),et);zi([m.Attribute({description:"Minimum value"}),Ji("design:type",String)],tt.prototype,"minValue",void 0);zi([m.Attribute({description:"Maximum value"}),Ji("design:type",String)],tt.prototype,"maxValue",void 0);tt=zi([m({description:"A date without time",nameMappings:{js:"Date",json:"string"}}).Example("2021-04-18","Full date value"),Ji("design:paramtypes",[Object])],tt);import{__decorate as Wi,__metadata as Gi}from"tslib";import{vg as hr}from"valgen";var rt,it=(rt=class{constructor(e){e&&Object.assign(this,e)}[y](e){let t=hr.isDateString({trim:"date",coerce:!0}),r=[];return e.minValue&&r.push(hr.isGte(e.minValue)),e.maxValue&&r.push(hr.isLte(e.maxValue)),r.length>0?hr.pipe([t,...r],{returnIndex:0}):t}[g](e){return this[y](e)}},s(rt,"DateStringType"),rt);Wi([m.Attribute({description:"Minimum value"}),Gi("design:type",String)],it.prototype,"minValue",void 0);Wi([m.Attribute({description:"Maximum value"}),Gi("design:type",String)],it.prototype,"maxValue",void 0);it=Wi([m({description:"Date string value",nameMappings:{js:"string",json:"string"}}).Example("2021-04-18","Full date value").Example("2021-04","Date value without day").Example("2021","Year only value"),Gi("design:paramtypes",[Object])],it);import{__decorate as Yi,__metadata as Qi}from"tslib";import{isDateString as dr,toString as as,vg as be}from"valgen";var nt,ot=(nt=class{constructor(e){e&&Object.assign(this,e)}[y](e){let t=be.isDate({precision:"time",coerce:!0}),r=[];return e.minValue&&(dr(e.minValue),r.push(as,be.isGte(e.minValue))),e.maxValue&&(dr(e.maxValue),r.push(as,be.isLte(e.maxValue))),r.length>0?be.pipe([t,...r],{returnIndex:0}):t}[g](e){let t=be.isDateString({precision:"time",trim:"time",coerce:!0}),r=[];return e.minValue&&(dr(e.minValue),r.push(be.isGte(e.minValue))),e.maxValue&&(dr(e.maxValue),r.push(be.isLte(e.maxValue))),r.length>0?be.pipe([t,...r],{returnIndex:0}):t}},s(nt,"DateTimeType"),nt);Yi([m.Attribute({description:"Minimum value"}),Qi("design:type",String)],ot.prototype,"minValue",void 0);Yi([m.Attribute({description:"Maximum value"}),Qi("design:type",String)],ot.prototype,"maxValue",void 0);ot=Yi([m({description:"A full datetime value",nameMappings:{js:"string",json:"string"}}).Example("2021-04-18T22:30:15").Example("2021-04-18 22:30:15").Example("2021-04-18 22:30"),Qi("design:paramtypes",[Object])],ot);import{__decorate as Xi,__metadata as Zi}from"tslib";import{vg as yr}from"valgen";var st,at=(st=class{constructor(e){e&&Object.assign(this,e)}[y](e){let t=yr.isDateString({coerce:!0}),r=[];return e.minValue&&r.push(yr.isGte(e.minValue)),e.maxValue&&r.push(yr.isLte(e.maxValue)),r.length>0?yr.pipe([t,...r]):t}[g](e){return this[y](e)}},s(st,"DateTimeStringType"),st);Xi([m.Attribute({description:"Minimum value"}),Zi("design:type",String)],at.prototype,"minValue",void 0);Xi([m.Attribute({description:"Maximum value"}),Zi("design:type",String)],at.prototype,"maxValue",void 0);at=Xi([m({description:"DateTime string value",nameMappings:{js:"string",json:"string"}}).Example("2021-04-18T22:30:15+01:00","Full date-time value with timezone").Example("2021-04-18T22:30:15","Full date-time value without timezone").Example("2021-04-18 22:30","Date-time value").Example("2021-04-18","Date value").Example("2021-04","Date value without day").Example("2021","Year only value"),Zi("design:paramtypes",[Object])],at);import{__decorate as se,__metadata as ae}from"tslib";import{vg as ps}from"valgen";var pt,W=(pt=class{constructor(e){e&&Object.assign(this,e)}[y](e){return ps.isEmail({...e,coerce:!0})}[g](e){return ps.isEmail({...e,coerce:!0})}},s(pt,"EmailType"),pt);se([m.Attribute({description:"If set to `true`, the validator will also match `Display Name <email-address>",default:!1}),ae("design:type",Boolean)],W.prototype,"allowDisplayName",void 0);se([m.Attribute({description:"If set to `true`, the validator will reject strings without the format `Display Name <email-address>",default:!1}),ae("design:type",Boolean)],W.prototype,"requireDisplayName",void 0);se([m.Attribute({description:"If set to `false`, the validator will not allow any non-English UTF8 character in email address's local part",default:!0}),ae("design:type",Boolean)],W.prototype,"utf8LocalPart",void 0);se([m.Attribute({description:"If set to `true`, the validator will not check for the standard max length of an email",default:!1}),ae("design:type",Boolean)],W.prototype,"ignoreMaxLength",void 0);se([m.Attribute({description:"If set to `true`, the validator will allow IP addresses in the host part",default:!1}),ae("design:type",Boolean)],W.prototype,"allowIpDomain",void 0);se([m.Attribute({description:"If set to `true`, some additional validation will be enabled, e.g. disallowing certain syntactically valid email addresses that are rejected by GMail.",default:!1}),ae("design:type",Boolean)],W.prototype,"domainSpecificValidation",void 0);se([m.Attribute({description:"If set to an array of strings and the part of the email after the @ symbol one of the strings defined in it, the validation fails."}),ae("design:type",Array)],W.prototype,"hostBlacklist",void 0);se([m.Attribute({description:"If set to an array of strings and the part of the email after the @ symbol matches none of the strings defined in it, the validation fails."}),ae("design:type",Array)],W.prototype,"hostWhitelist",void 0);se([m.Attribute({description:"If set to a string, then the validator will reject emails that include any of the characters in the string, in the name part."}),ae("design:type",String)],W.prototype,"blacklistedChars",void 0);W=se([m({description:"An email value",nameMappings:{js:"string",json:"string"}}).Example("some.body@example.com"),ae("design:paramtypes",[Object])],W);import{__decorate as Hi,__metadata as en}from"tslib";import{toString as za,validator as Ja,vg as Wa}from"valgen";var ct,H=(ct=class{constructor(e){e&&Object.assign(this,e)}[y](e,t){let r=e.dataType?t.node.getComplexType(e.dataType):t.node.getComplexType("object"),n=e.allowSigns,o=Ja("decodeFieldPath",a=>r.normalizeFieldPath(a,{allowSigns:n}));return Wa.pipe([za,o])}[g](e,t){return this[y](e,t)}toJSON(e,t){let r=e.dataType?t.node.getComplexType(e.dataType):t.node.getComplexType("object"),n=r?t.node.getDataTypeNameWithNs(r):void 0;return{dataType:n||r.toJSON(),allowSigns:e.allowSigns}}},s(ct,"FieldPathType"),ct);Hi([m.Attribute({description:"Data type which field belong to"}),en("design:type",Object)],H.prototype,"dataType",void 0);Hi([m.Attribute({description:'Determines if signs (+,-) are allowed. If set "first" signs are allowed only beginning of the field pathIf set "each" signs are allowed at each field in the path'}),en("design:type",String)],H.prototype,"allowSigns",void 0);H=Hi([m({description:"Field path",nameMappings:{js:"string",json:"string"}}),en("design:paramtypes",[Object])],H);import{__decorate as Mo,__metadata as vo}from"tslib";import{validator as Ns}from"valgen";var tn=class tn extends me{constructor(e,t,r){super(e,t instanceof Error?t:void 0),this.status=(typeof t=="number"?t:Number(r))||500}setStatus(e){return this.status=e,this}initError(e){typeof e.status=="number"?this.status=e.status:typeof e.getStatus=="function"&&(this.status=e.getStatus()),super.initError(e)}};s(tn,"OpraHttpError");var A=tn;var rn=class rn extends A{constructor(){super(...arguments),this.status=400}init(e){super.init({message:R("error:BAD_REQUEST","Bad request"),code:"BAD_REQUEST",...e})}};s(rn,"BadRequestError");var cs=rn;var nn=class nn extends A{constructor(){super(...arguments),this.status=409}init(e){super.init({message:R("error:CONFLICT","Conflict"),code:"CONFLICT",...e})}};s(nn,"ConflictError");var ls=nn;var on=class on extends A{constructor(){super(...arguments),this.status=424}init(e){super.init({message:R("error:FAILED_DEPENDENCY","The request failed due to failure of a previous request"),code:"FAILED_DEPENDENCY",...e})}};s(on,"FailedDependencyError");var fs=on;var sn=class sn extends A{constructor(){super(...arguments),this.status=N.FORBIDDEN}init(e){super.init({message:R("error:FORBIDDEN","You are not authorized to perform this action"),code:"FORBIDDEN",...e})}};s(sn,"ForbiddenError");var Tr=sn;var an=class an extends A{constructor(){super(...arguments),this.status=500}init(e){super.init({message:R("error:INTERNAL_SERVER_ERROR","Internal server error"),code:"INTERNAL_SERVER_ERROR",severity:"fatal",...e})}};s(an,"InternalServerError");var us=an;var pn=class pn extends A{constructor(){super(...arguments),this.status=405}init(e){super.init({message:R("error:METHOD_NOT_ALLOWED","Method not allowed"),code:"METHOD_NOT_ALLOWED",...e})}};s(pn,"MethodNotAllowedError");var ms=pn;var cn=class cn extends A{constructor(){super(...arguments),this.status=406}init(e){super.init({message:R("error:NOT_ACCEPTABLE","Not Acceptable"),code:"NOT_ACCEPTABLE",...e})}};s(cn,"NotAcceptableError");var hs=cn;var ln=class ln extends A{constructor(){super(...arguments),this.status=404}init(e){super.init({message:R("error:NOT_FOUND","Not found"),code:"NOT_FOUND",...e})}};s(ln,"NotFoundError");var ds=ln;var fn=class fn extends Tr{init(e){super.init({message:R("error:PERMISSION_ERROR","You dont have permission for this operation"),code:"PERMISSION_ERROR",...e})}};s(fn,"PermissionError");var ys=fn;var un=class un extends A{constructor(e,t,r){super({message:R("error:RESOURCE_CONFLICT",{resource:e,fields:t},"There is already an other {{resource}} resource with same values ({{fields}})"),severity:"error",code:"RESOURCE_CONFLICT",details:{resource:e,location:t}},r),this.status=409}};s(un,"ResourceConflictError");var Ts=un;var mn=class mn extends A{constructor(e,t,r){super({message:R("error:RESOURCE_NOT_AVAILABLE",`Resource "${e}${t?"/"+t:""}" is not available`),severity:"error",code:"RESOURCE_NOT_AVAILABLE",details:{resource:e,key:t}},r,N.UNPROCESSABLE_ENTITY)}};s(mn,"ResourceNotAvailableError");var Es=mn;var hn=class hn extends A{constructor(){super(...arguments),this.status=401}init(e){super.init({message:R("error:UNAUTHORIZED","You have not been authenticated to perform this action"),code:"UNAUTHORIZED",...e})}};s(hn,"UnauthorizedError");var _s=hn;var dn=class dn extends A{constructor(){super(...arguments),this.status=422}init(e){super.init({message:R("error:UNPROCESSABLE_ENTITY","Unprocessable entity"),severity:"error",code:"UNPROCESSABLE_ENTITY",...e})}};s(dn,"UnprocessableEntityError");var xs=dn;var gs;(function(i){let e;(function(t){t.fatal="fatal",t.error="error",t.warning="warning",t.info="info"})(e=i.Enum||(i.Enum={})),i.name="IssueSeverity",i.description="Severity of the issue",i.Keys=Object.keys(i),i.descriptions={fatal:"The issue caused the action to fail and no further checking could be performed",error:"The issue is sufficiently important to cause the action to fail",warning:"The issue is not important enough to cause the action to fail but may cause it to be performed suboptimally or in a way that is not as desired",info:"The issue has no relation to the degree of success of the action"}})(gs||(gs={}));var yn=class yn{constructor(){this.kind=Object.getPrototypeOf(this).constructor.name}};s(yn,"Ast");var kt=yn;var Tn=class Tn extends kt{};s(Tn,"Expression");var k=Tn;var En=class En extends k{};s(En,"Term");var ke=En;var _n=class _n extends ke{constructor(e){super(),this.value=e}toString(){return""+this.value}};s(_n,"Literal");var v=_n;var xn=class xn extends k{constructor(){super(),this.items=[]}append(e,t){return this.items.push(new Er({op:e,expression:t})),this}toString(){return this.items.map((e,t)=>(t>0?e.op:"")+e.expression).join("")}};s(xn,"ArithmeticExpression");var je=xn,gn=class gn{constructor(e){Object.assign(this,e)}};s(gn,"ArithmeticExpressionItem");var Er=gn;var On=class On extends ke{constructor(e){super(),this.items=e}toString(){return"["+this.items.map(e=>""+e).join(",")+"]"}};s(On,"ArrayExpression");var he=On;var Ga=/\w/,Rn=class Rn extends k{constructor(e){super(),Object.assign(this,e)}toString(){return`${this.left}${Ga.test(this.op)?" "+this.op+" ":this.op}${this.right}`}};s(Rn,"ComparisonExpression");var de=Rn;var An=class An extends k{constructor(e){super(),Object.assign(this,e),this.op==="&&"&&(this.op="and"),this.op==="||"&&(this.op="or")}toString(){return this.items.map(e=>""+e).join(" "+this.op+" ")}};s(An,"LogicalExpression");var pe=An;var bn=class bn extends k{constructor(e){super(),this.expression=e}toString(){return`(${this.expression})`}};s(bn,"NegativeExpression");var jt=bn;var wn=class wn extends k{constructor(e){super(),this.expression=e}toString(){return`(${this.expression})`}};s(wn,"ParenthesizedExpression");var ye=wn;var Nn=class Nn extends v{constructor(e){super(e)}};s(Nn,"BooleanLiteral");var Ue=Nn;import{toDateDef as ep}from"putil-varhelpers";var Dn=class Dn extends TypeError{};s(Dn,"SyntaxError");var _r=Dn,Sn=class Sn extends TypeError{constructor(e){super(typeof e=="string"?e:e==null?void 0:e.message),typeof e=="object"&&Object.assign(this,e)}};s(Sn,"FilterValidationError");var we=Sn,In=class In extends Error{constructor(e,t){super(e),Object.assign(this,t)}};s(In,"FilterParseError");var xr=In;var Ya=/'/g,Qa=/(\\)/g,Xa=/\\(.)/g;function Za(i){return i.replace(Qa,"\\\\")}s(Za,"escapeString");function Ha(i){return i.replace(Xa,"$1")}s(Ha,"unescapeString");function lt(i){return"'"+Za(i).replace(Ya,"\\'")+"'"}s(lt,"quoteFilterString");function Ut(i){return i&&(i.startsWith("'")||i.startsWith('"'))&&i.endsWith(i.charAt(0))?Ha(i.substring(1,i.length-1)):i}s(Ut,"unquoteFilterString");var Os=new Date(0),Ln=class Ln extends v{constructor(e){if(super(""),e instanceof Date){this.value=e.toISOString();return}if(typeof e=="string"&&ep(e,Os)!==Os){this.value=e;return}throw new we(`Invalid date value "${e}"`)}toString(){return lt(this.value)}};s(Ln,"DateLiteral");var Te=Ln;var Pn=class Pn extends v{constructor(){super(null),this.value=null}};s(Pn,"NullLiteral");var Ce=Pn;var Mn=class Mn extends v{constructor(e){if(super(0),typeof e=="number"||typeof e=="bigint"){this.value=e;return}try{if(typeof e=="string"){if(e.includes(".")){this.value=parseFloat(e);return}let t=Number(e);""+t===e?this.value=t:this.value=BigInt(e);return}}catch{}throw new we(`Invalid number literal ${e}`)}toString(){return typeof this.value=="bigint"?(""+this.value).replace(/n$/,""):""+this.value}};s(Mn,"NumberLiteral");var Ee=Mn;var vn=class vn extends v{constructor(e){super(""+e)}};s(vn,"QualifiedIdentifier");var ce=vn;var Fn=class Fn extends v{constructor(e){super(""+e)}toString(){return lt(this.value)}};s(Fn,"StringLiteral");var Be=Fn;var tp=/^([01]\d|2[0-3]):([0-5]\d)(:[0-5]\d)?(\.(\d+))?$/,kn=class kn extends v{constructor(e){if(super(""),e instanceof Date){this.value=gr(e.getHours())+":"+gr(e.getMinutes())+(e.getSeconds()?":"+gr(e.getSeconds()):"")+(e.getMilliseconds()?"."+gr(e.getMilliseconds()):"");return}if(typeof e=="string"&&tp.test(e)){this.value=e;return}throw new we(`Invalid time value "${e}"`)}toString(){return lt(this.value)}};s(kn,"TimeLiteral");var qe=kn;function gr(i){return i<=9?"0"+i:""+i}s(gr,"pad");import{CharStream as Tp,CommonTokenStream as Ep}from"@browsery/antlr4";import{ATNDeserializer as rp,DFA as ip,Lexer as np,LexerATNSimulator as op,PredictionContextCache as sp,Token as ap}from"@browsery/antlr4";var q=class q extends np{constructor(e){super(e),this._interp=new op(this,q._ATN,q.DecisionsToDFA,new sp)}get grammarFileName(){return"OpraFilter.g4"}get literalNames(){return q.literalNames}get symbolicNames(){return q.symbolicNames}get ruleNames(){return q.ruleNames}get serializedATN(){return q._serializedATN}get channelNames(){return q.channelNames}get modeNames(){return q.modeNames}static get _ATN(){return q.__ATN||(q.__ATN=new rp().deserialize(q._serializedATN)),q.__ATN}};s(q,"OpraFilterLexer");var d=q;d.T__0=1;d.T__1=2;d.T__2=3;d.T__3=4;d.T__4=5;d.T__5=6;d.T__6=7;d.T__7=8;d.T__8=9;d.T__9=10;d.T__10=11;d.T__11=12;d.T__12=13;d.T__13=14;d.T__14=15;d.T__15=16;d.T__16=17;d.T__17=18;d.T__18=19;d.T__19=20;d.T__20=21;d.T__21=22;d.T__22=23;d.T__23=24;d.T__24=25;d.T__25=26;d.T__26=27;d.T__27=28;d.T__28=29;d.T__29=30;d.T__30=31;d.T__31=32;d.T__32=33;d.T__33=34;d.IDENTIFIER=35;d.POLAR_OP=36;d.DATE=37;d.DATETIME=38;d.TIME=39;d.NUMBER=40;d.INTEGER=41;d.STRING=42;d.WHITESPACE=43;d.EOF=ap.EOF;d.channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"];d.literalNames=[null,"'('","')'","'not'","'!'","'.'","'@'","'['","','","']'","'true'","'false'","'null'","'Infinity'","'infinity'","'+'","'-'","'*'","'/'","'<='","'<'","'>'","'>='","'='","'!='","'in'","'!in'","'like'","'!like'","'ilike'","'!ilike'","'and'","'or'","'&&'","'||'"];d.symbolicNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"IDENTIFIER","POLAR_OP","DATE","DATETIME","TIME","NUMBER","INTEGER","STRING","WHITESPACE"];d.modeNames=["DEFAULT_MODE"];d.ruleNames=["T__0","T__1","T__2","T__3","T__4","T__5","T__6","T__7","T__8","T__9","T__10","T__11","T__12","T__13","T__14","T__15","T__16","T__17","T__18","T__19","T__20","T__21","T__22","T__23","T__24","T__25","T__26","T__27","T__28","T__29","T__30","T__31","T__32","T__33","IDENTIFIER","POLAR_OP","DATE","DATETIME","TIME","NUMBER","INTEGER","STRING","WHITESPACE","DIGIT","DATEFORMAT","TIMEFORMAT","TIMEZONEOFFSETFORMAT","ESC","UNICODE","HEX"];d._serializedATN=[4,0,43,426,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,45,2,46,7,46,2,47,7,47,2,48,7,48,2,49,7,49,1,0,1,0,1,1,1,1,1,2,1,2,1,2,1,2,1,3,1,3,1,4,1,4,1,5,1,5,1,6,1,6,1,7,1,7,1,8,1,8,1,9,1,9,1,9,1,9,1,9,1,10,1,10,1,10,1,10,1,10,1,10,1,11,1,11,1,11,1,11,1,11,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,14,1,14,1,15,1,15,1,16,1,16,1,17,1,17,1,18,1,18,1,18,1,19,1,19,1,20,1,20,1,21,1,21,1,21,1,22,1,22,1,23,1,23,1,23,1,24,1,24,1,24,1,25,1,25,1,25,1,25,1,26,1,26,1,26,1,26,1,26,1,27,1,27,1,27,1,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,28,1,29,1,29,1,29,1,29,1,29,1,29,1,29,1,30,1,30,1,30,1,30,1,31,1,31,1,31,1,32,1,32,1,32,1,33,1,33,1,33,1,34,1,34,5,34,225,8,34,10,34,12,34,228,9,34,1,35,1,35,1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,36,3,36,240,8,36,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,3,37,256,8,37,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,3,38,266,8,38,1,39,3,39,269,8,39,1,39,4,39,272,8,39,11,39,12,39,273,1,39,1,39,5,39,278,8,39,10,39,12,39,281,9,39,3,39,283,8,39,1,39,1,39,3,39,287,8,39,1,39,4,39,290,8,39,11,39,12,39,291,3,39,294,8,39,1,39,1,39,1,39,1,39,4,39,300,8,39,11,39,12,39,301,3,39,304,8,39,1,40,3,40,307,8,40,1,40,4,40,310,8,40,11,40,12,40,311,1,40,1,40,1,40,1,40,4,40,318,8,40,11,40,12,40,319,3,40,322,8,40,1,41,1,41,1,41,5,41,327,8,41,10,41,12,41,330,9,41,1,41,1,41,1,41,1,41,5,41,336,8,41,10,41,12,41,339,9,41,1,41,3,41,342,8,41,1,42,4,42,345,8,42,11,42,12,42,346,1,42,1,42,1,43,1,43,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,3,44,362,8,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,3,44,371,8,44,1,45,1,45,1,45,1,45,3,45,377,8,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,4,45,389,8,45,11,45,12,45,390,3,45,393,8,45,3,45,395,8,45,1,46,1,46,1,46,3,46,400,8,46,1,46,1,46,1,46,3,46,405,8,46,1,46,1,46,1,46,3,46,410,8,46,3,46,412,8,46,1,47,1,47,1,47,3,47,417,8,47,1,48,1,48,1,48,1,48,1,48,1,48,1,49,1,49,0,0,50,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,27,14,29,15,31,16,33,17,35,18,37,19,39,20,41,21,43,22,45,23,47,24,49,25,51,26,53,27,55,28,57,29,59,30,61,31,63,32,65,33,67,34,69,35,71,36,73,37,75,38,77,39,79,40,81,41,83,42,85,43,87,0,89,0,91,0,93,0,95,0,97,0,99,0,1,0,16,4,0,36,36,65,90,95,95,97,122,5,0,36,36,48,57,65,90,95,95,97,122,2,0,43,43,45,45,1,0,39,39,1,0,34,34,3,0,9,10,13,13,32,32,1,0,48,57,1,0,48,48,1,0,49,57,1,0,49,49,1,0,48,50,1,0,49,51,1,0,48,49,1,0,48,51,1,0,48,53,3,0,48,57,65,70,97,102,453,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,0,0,47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,0,57,1,0,0,0,0,59,1,0,0,0,0,61,1,0,0,0,0,63,1,0,0,0,0,65,1,0,0,0,0,67,1,0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73,1,0,0,0,0,75,1,0,0,0,0,77,1,0,0,0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,0,0,0,85,1,0,0,0,1,101,1,0,0,0,3,103,1,0,0,0,5,105,1,0,0,0,7,109,1,0,0,0,9,111,1,0,0,0,11,113,1,0,0,0,13,115,1,0,0,0,15,117,1,0,0,0,17,119,1,0,0,0,19,121,1,0,0,0,21,126,1,0,0,0,23,132,1,0,0,0,25,137,1,0,0,0,27,146,1,0,0,0,29,155,1,0,0,0,31,157,1,0,0,0,33,159,1,0,0,0,35,161,1,0,0,0,37,163,1,0,0,0,39,166,1,0,0,0,41,168,1,0,0,0,43,170,1,0,0,0,45,173,1,0,0,0,47,175,1,0,0,0,49,178,1,0,0,0,51,181,1,0,0,0,53,185,1,0,0,0,55,190,1,0,0,0,57,196,1,0,0,0,59,202,1,0,0,0,61,209,1,0,0,0,63,213,1,0,0,0,65,216,1,0,0,0,67,219,1,0,0,0,69,222,1,0,0,0,71,229,1,0,0,0,73,239,1,0,0,0,75,255,1,0,0,0,77,265,1,0,0,0,79,303,1,0,0,0,81,321,1,0,0,0,83,341,1,0,0,0,85,344,1,0,0,0,87,350,1,0,0,0,89,352,1,0,0,0,91,376,1,0,0,0,93,411,1,0,0,0,95,413,1,0,0,0,97,418,1,0,0,0,99,424,1,0,0,0,101,102,5,40,0,0,102,2,1,0,0,0,103,104,5,41,0,0,104,4,1,0,0,0,105,106,5,110,0,0,106,107,5,111,0,0,107,108,5,116,0,0,108,6,1,0,0,0,109,110,5,33,0,0,110,8,1,0,0,0,111,112,5,46,0,0,112,10,1,0,0,0,113,114,5,64,0,0,114,12,1,0,0,0,115,116,5,91,0,0,116,14,1,0,0,0,117,118,5,44,0,0,118,16,1,0,0,0,119,120,5,93,0,0,120,18,1,0,0,0,121,122,5,116,0,0,122,123,5,114,0,0,123,124,5,117,0,0,124,125,5,101,0,0,125,20,1,0,0,0,126,127,5,102,0,0,127,128,5,97,0,0,128,129,5,108,0,0,129,130,5,115,0,0,130,131,5,101,0,0,131,22,1,0,0,0,132,133,5,110,0,0,133,134,5,117,0,0,134,135,5,108,0,0,135,136,5,108,0,0,136,24,1,0,0,0,137,138,5,73,0,0,138,139,5,110,0,0,139,140,5,102,0,0,140,141,5,105,0,0,141,142,5,110,0,0,142,143,5,105,0,0,143,144,5,116,0,0,144,145,5,121,0,0,145,26,1,0,0,0,146,147,5,105,0,0,147,148,5,110,0,0,148,149,5,102,0,0,149,150,5,105,0,0,150,151,5,110,0,0,151,152,5,105,0,0,152,153,5,116,0,0,153,154,5,121,0,0,154,28,1,0,0,0,155,156,5,43,0,0,156,30,1,0,0,0,157,158,5,45,0,0,158,32,1,0,0,0,159,160,5,42,0,0,160,34,1,0,0,0,161,162,5,47,0,0,162,36,1,0,0,0,163,164,5,60,0,0,164,165,5,61,0,0,165,38,1,0,0,0,166,167,5,60,0,0,167,40,1,0,0,0,168,169,5,62,0,0,169,42,1,0,0,0,170,171,5,62,0,0,171,172,5,61,0,0,172,44,1,0,0,0,173,174,5,61,0,0,174,46,1,0,0,0,175,176,5,33,0,0,176,177,5,61,0,0,177,48,1,0,0,0,178,179,5,105,0,0,179,180,5,110,0,0,180,50,1,0,0,0,181,182,5,33,0,0,182,183,5,105,0,0,183,184,5,110,0,0,184,52,1,0,0,0,185,186,5,108,0,0,186,187,5,105,0,0,187,188,5,107,0,0,188,189,5,101,0,0,189,54,1,0,0,0,190,191,5,33,0,0,191,192,5,108,0,0,192,193,5,105,0,0,193,194,5,107,0,0,194,195,5,101,0,0,195,56,1,0,0,0,196,197,5,105,0,0,197,198,5,108,0,0,198,199,5,105,0,0,199,200,5,107,0,0,200,201,5,101,0,0,201,58,1,0,0,0,202,203,5,33,0,0,203,204,5,105,0,0,204,205,5,108,0,0,205,206,5,105,0,0,206,207,5,107,0,0,207,208,5,101,0,0,208,60,1,0,0,0,209,210,5,97,0,0,210,211,5,110,0,0,211,212,5,100,0,0,212,62,1,0,0,0,213,214,5,111,0,0,214,215,5,114,0,0,215,64,1,0,0,0,216,217,5,38,0,0,217,218,5,38,0,0,218,66,1,0,0,0,219,220,5,124,0,0,220,221,5,124,0,0,221,68,1,0,0,0,222,226,7,0,0,0,223,225,7,1,0,0,224,223,1,0,0,0,225,228,1,0,0,0,226,224,1,0,0,0,226,227,1,0,0,0,227,70,1,0,0,0,228,226,1,0,0,0,229,230,7,2,0,0,230,72,1,0,0,0,231,232,5,39,0,0,232,233,3,89,44,0,233,234,5,39,0,0,234,240,1,0,0,0,235,236,5,34,0,0,236,237,3,89,44,0,237,238,5,34,0,0,238,240,1,0,0,0,239,231,1,0,0,0,239,235,1,0,0,0,240,74,1,0,0,0,241,242,5,39,0,0,242,243,3,89,44,0,243,244,5,84,0,0,244,245,3,91,45,0,245,246,3,93,46,0,246,247,5,39,0,0,247,256,1,0,0,0,248,249,5,34,0,0,249,250,3,89,44,0,250,251,5,84,0,0,251,252,3,91,45,0,252,253,3,93,46,0,253,254,5,34,0,0,254,256,1,0,0,0,255,241,1,0,0,0,255,248,1,0,0,0,256,76,1,0,0,0,257,258,5,39,0,0,258,259,3,91,45,0,259,260,5,39,0,0,260,266,1,0,0,0,261,262,5,34,0,0,262,263,3,91,45,0,263,264,5,34,0,0,264,266,1,0,0,0,265,257,1,0,0,0,265,261,1,0,0,0,266,78,1,0,0,0,267,269,3,71,35,0,268,267,1,0,0,0,268,269,1,0,0,0,269,271,1,0,0,0,270,272,3,87,43,0,271,270,1,0,0,0,272,273,1,0,0,0,273,271,1,0,0,0,273,274,1,0,0,0,274,282,1,0,0,0,275,279,5,46,0,0,276,278,3,87,43,0,277,276,1,0,0,0,278,281,1,0,0,0,279,277,1,0,0,0,279,280,1,0,0,0,280,283,1,0,0,0,281,279,1,0,0,0,282,275,1,0,0,0,282,283,1,0,0,0,283,293,1,0,0,0,284,286,5,69,0,0,285,287,7,2,0,0,286,285,1,0,0,0,286,287,1,0,0,0,287,289,1,0,0,0,288,290,3,87,43,0,289,288,1,0,0,0,290,291,1,0,0,0,291,289,1,0,0,0,291,292,1,0,0,0,292,294,1,0,0,0,293,284,1,0,0,0,293,294,1,0,0,0,294,304,1,0,0,0,295,296,5,48,0,0,296,297,5,120,0,0,297,299,1,0,0,0,298,300,3,99,49,0,299,298,1,0,0,0,300,301,1,0,0,0,301,299,1,0,0,0,301,302,1,0,0,0,302,304,1,0,0,0,303,268,1,0,0,0,303,295,1,0,0,0,304,80,1,0,0,0,305,307,3,71,35,0,306,305,1,0,0,0,306,307,1,0,0,0,307,309,1,0,0,0,308,310,3,87,43,0,309,308,1,0,0,0,310,311,1,0,0,0,311,309,1,0,0,0,311,312,1,0,0,0,312,322,1,0,0,0,313,314,5,48,0,0,314,315,5,120,0,0,315,317,1,0,0,0,316,318,3,99,49,0,317,316,1,0,0,0,318,319,1,0,0,0,319,317,1,0,0,0,319,320,1,0,0,0,320,322,1,0,0,0,321,306,1,0,0,0,321,313,1,0,0,0,322,82,1,0,0,0,323,328,5,39,0,0,324,327,3,95,47,0,325,327,8,3,0,0,326,324,1,0,0,0,326,325,1,0,0,0,327,330,1,0,0,0,328,326,1,0,0,0,328,329,1,0,0,0,329,331,1,0,0,0,330,328,1,0,0,0,331,342,5,39,0,0,332,337,5,34,0,0,333,336,3,95,47,0,334,336,8,4,0,0,335,333,1,0,0,0,335,334,1,0,0,0,336,339,1,0,0,0,337,335,1,0,0,0,337,338,1,0,0,0,338,340,1,0,0,0,339,337,1,0,0,0,340,342,5,34,0,0,341,323,1,0,0,0,341,332,1,0,0,0,342,84,1,0,0,0,343,345,7,5,0,0,344,343,1,0,0,0,345,346,1,0,0,0,346,344,1,0,0,0,346,347,1,0,0,0,347,348,1,0,0,0,348,349,6,42,0,0,349,86,1,0,0,0,350,351,7,6,0,0,351,88,1,0,0,0,352,353,7,6,0,0,353,354,7,6,0,0,354,355,7,6,0,0,355,356,7,6,0,0,356,361,5,45,0,0,357,358,7,7,0,0,358,362,7,8,0,0,359,360,7,9,0,0,360,362,7,10,0,0,361,357,1,0,0,0,361,359,1,0,0,0,362,363,1,0,0,0,363,370,5,45,0,0,364,365,7,11,0,0,365,371,7,7,0,0,366,367,7,10,0,0,367,371,7,8,0,0,368,369,5,51,0,0,369,371,5,49,0,0,370,364,1,0,0,0,370,366,1,0,0,0,370,368,1,0,0,0,371,90,1,0,0,0,372,373,7,12,0,0,373,377,7,6,0,0,374,375,5,50,0,0,375,377,7,13,0,0,376,372,1,0,0,0,376,374,1,0,0,0,377,378,1,0,0,0,378,379,5,58,0,0,379,380,7,14,0,0,380,381,7,6,0,0,381,394,1,0,0,0,382,383,5,58,0,0,383,384,7,14,0,0,384,385,7,6,0,0,385,392,1,0,0,0,386,388,5,46,0,0,387,389,7,6,0,0,388,387,1,0,0,0,389,390,1,0,0,0,390,388,1,0,0,0,390,391,1,0,0,0,391,393,1,0,0,0,392,386,1,0,0,0,392,393,1,0,0,0,393,395,1,0,0,0,394,382,1,0,0,0,394,395,1,0,0,0,395,92,1,0,0,0,396,412,5,90,0,0,397,404,7,2,0,0,398,400,7,12,0,0,399,398,1,0,0,0,399,400,1,0,0,0,400,401,1,0,0,0,401,405,7,6,0,0,402,403,5,50,0,0,403,405,7,13,0,0,404,399,1,0,0,0,404,402,1,0,0,0,405,409,1,0,0,0,406,407,5,58,0,0,407,408,7,14,0,0,408,410,7,6,0,0,409,406,1,0,0,0,409,410,1,0,0,0,410,412,1,0,0,0,411,396,1,0,0,0,411,397,1,0,0,0,412,94,1,0,0,0,413,416,5,92,0,0,414,417,3,97,48,0,415,417,9,0,0,0,416,414,1,0,0,0,416,415,1,0,0,0,417,96,1,0,0,0,418,419,5,117,0,0,419,420,3,99,49,0,420,421,3,99,49,0,421,422,3,99,49,0,422,423,3,99,49,0,423,98,1,0,0,0,424,425,7,15,0,0,425,100,1,0,0,0,35,0,226,239,255,265,268,273,279,282,286,291,293,301,303,306,311,319,321,326,328,335,337,341,346,361,370,376,390,392,394,399,404,409,411,416,1,0,1,0];d.DecisionsToDFA=d._ATN.decisionToState.map((i,e)=>new ip(i,e));var Rs=d;import{ATN as As,ATNDeserializer as pp,DFA as cp,FailedPredicateException as lp,NoViableAltException as jn,Parser as fp,ParserATNSimulator as up,ParserRuleContext as U,PredictionContextCache as mp,RecognitionException as j,Token as hp}from"@browsery/antlr4";var E=class E extends fp{get grammarFileName(){return"OpraFilter.g4"}get literalNames(){return E.literalNames}get symbolicNames(){return E.symbolicNames}get ruleNames(){return E.ruleNames}get serializedATN(){return E._serializedATN}createFailedPredicateException(e,t){return new lp(this,e,t)}constructor(e){super(e),this._interp=new up(this,E._ATN,E.DecisionsToDFA,new mp)}root(){let e=new Un(this,this._ctx,this.state);this.enterRule(e,0,E.RULE_root);try{this.enterOuterAlt(e,1),this.state=34,this.expression(0),this.state=35,this.match(E.EOF)}catch(t){if(t instanceof j)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}expression(e){e===void 0&&(e=0);let t=this._ctx,r=this.state,n=new G(this,this._ctx,r),o=n,a=2;this.enterRecursionRule(n,2,E.RULE_expression,e);let p;try{let c;this.enterOuterAlt(n,1);{switch(this.state=48,this._errHandler.sync(this),this._input.LA(1)){case 35:n=new qn(this,n),this._ctx=n,o=n,this.state=38,n._left=this.comparisonLeft(),this.state=39,n._operator=this.comparisonOperator(),this.state=40,n._right=this.comparisonRight();break;case 1:n=new Cn(this,n),this._ctx=n,o=n,this.state=42,this.match(E.T__0),this.state=43,this.parenthesizedItem(),this.state=44,this.match(E.T__1);break;case 3:case 4:n=new Bn(this,n),this._ctx=n,o=n,this.state=46,p=this._input.LA(1),p===3||p===4?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this),this.state=47,this.expression(1);break;default:throw new jn(this)}for(this._ctx.stop=this._input.LT(-1),this.state=56,this._errHandler.sync(this),c=this._interp.adaptivePredict(this._input,1,this._ctx);c!==2&&c!==As.INVALID_ALT_NUMBER;){if(c===1){this._parseListeners!=null&&this.triggerExitRuleEvent(),o=n;{if(n=new Ct(this,new G(this,t,r)),this.pushNewRecursionContext(n,a,E.RULE_expression),this.state=50,!this.precpred(this._ctx,3))throw this.createFailedPredicateException("this.precpred(this._ctx, 3)");this.state=51,n._op=this.logicalOperator(),this.state=52,this.expression(4)}}this.state=58,this._errHandler.sync(this),c=this._interp.adaptivePredict(this._input,1,this._ctx)}}}catch(c){if(c instanceof j)n.exception=c,this._errHandler.reportError(this,c),this._errHandler.recover(this,c);else throw c}finally{this.unrollRecursionContexts(t)}return n}comparisonLeft(){let e=new Or(this,this._ctx,this.state);this.enterRule(e,4,E.RULE_comparisonLeft);try{this.enterOuterAlt(e,1),this.state=59,this.qualifiedIdentifier()}catch(t){if(t instanceof j)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}comparisonRight(){let e=new Rr(this,this._ctx,this.state);this.enterRule(e,6,E.RULE_comparisonRight);try{switch(this.state=65,this._errHandler.sync(this),this._input.LA(1)){case 10:case 11:case 12:case 13:case 14:case 37:case 38:case 39:case 40:case 42:this.enterOuterAlt(e,1),this.state=61,this.value();break;case 35:this.enterOuterAlt(e,2),this.state=62,this.qualifiedIdentifier();break;case 6:this.enterOuterAlt(e,3),this.state=63,this.externalConstant();break;case 7:this.enterOuterAlt(e,4),this.state=64,this.arrayValue();break;default:throw new jn(this)}}catch(t){if(t instanceof j)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}parenthesizedItem(){let e=new Ar(this,this._ctx,this.state);this.enterRule(e,8,E.RULE_parenthesizedItem);try{this.enterOuterAlt(e,1),this.state=67,this.expression(0)}catch(t){if(t instanceof j)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}value(){let e=new K(this,this._ctx,this.state);this.enterRule(e,10,E.RULE_value);try{switch(this.state=77,this._errHandler.sync(this),this._input.LA(1)){case 40:e=new Yn(this,e),this.enterOuterAlt(e,1),this.state=69,this.match(E.NUMBER);break;case 13:case 14:e=new Wn(this,e),this.enterOuterAlt(e,2),this.state=70,this.infinity();break;case 10:case 11:e=new Gn(this,e),this.enterOuterAlt(e,3),this.state=71,this.boolean_();break;case 12:e=new Vn(this,e),this.enterOuterAlt(e,4),this.state=72,this.null_();break;case 37:e=new Jn(this,e),this.enterOuterAlt(e,5),this.state=73,this.match(E.DATE);break;case 38:e=new Kn(this,e),this.enterOuterAlt(e,6),this.state=74,this.match(E.DATETIME);break;case 39:e=new $n(this,e),this.enterOuterAlt(e,7),this.state=75,this.match(E.TIME);break;case 42:e=new zn(this,e),this.enterOuterAlt(e,8),this.state=76,this.match(E.STRING);break;default:throw new jn(this)}}catch(t){if(t instanceof j)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}qualifiedIdentifier(){let e=new Bt(this,this._ctx,this.state);this.enterRule(e,12,E.RULE_qualifiedIdentifier);try{let t;this.enterOuterAlt(e,1);{for(this.state=84,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,4,this._ctx);t!==2&&t!==As.INVALID_ALT_NUMBER;)t===1&&(this.state=79,this.identifier(),this.state=80,this.match(E.T__4)),this.state=86,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,4,this._ctx);this.state=87,this.identifier()}}catch(t){if(t instanceof j)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}externalConstant(){let e=new br(this,this._ctx,this.state);this.enterRule(e,14,E.RULE_externalConstant);try{this.enterOuterAlt(e,1),this.state=89,this.match(E.T__5),this.state=90,this.identifier()}catch(t){if(t instanceof j)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}identifier(){let e=new ft(this,this._ctx,this.state);this.enterRule(e,16,E.RULE_identifier);try{this.enterOuterAlt(e,1),this.state=92,this.match(E.IDENTIFIER)}catch(t){if(t instanceof j)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}arrayValue(){let e=new wr(this,this._ctx,this.state);this.enterRule(e,18,E.RULE_arrayValue);let t;try{this.enterOuterAlt(e,1);{for(this.state=94,this.match(E.T__6),this.state=95,this.value(),this.state=100,this._errHandler.sync(this),t=this._input.LA(1);t===8;)this.state=96,this.match(E.T__7),this.state=97,this.value(),this.state=102,this._errHandler.sync(this),t=this._input.LA(1);this.state=103,this.match(E.T__8)}}catch(r){if(r instanceof j)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}boolean_(){let e=new Nr(this,this._ctx,this.state);this.enterRule(e,20,E.RULE_boolean);let t;try{this.enterOuterAlt(e,1),this.state=105,t=this._input.LA(1),t===10||t===11?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this)}catch(r){if(r instanceof j)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}null_(){let e=new Dr(this,this._ctx,this.state);this.enterRule(e,22,E.RULE_null);try{this.enterOuterAlt(e,1),this.state=107,this.match(E.T__11)}catch(t){if(t instanceof j)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}infinity(){let e=new Sr(this,this._ctx,this.state);this.enterRule(e,24,E.RULE_infinity);let t;try{this.enterOuterAlt(e,1),this.state=109,t=this._input.LA(1),t===13||t===14?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this)}catch(r){if(r instanceof j)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}arithmeticOperator(){let e=new Qn(this,this._ctx,this.state);this.enterRule(e,26,E.RULE_arithmeticOperator);let t;try{this.enterOuterAlt(e,1),this.state=111,t=this._input.LA(1),!(t&-32)&&1<<t&491520?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this)}catch(r){if(r instanceof j)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}comparisonOperator(){let e=new Ir(this,this._ctx,this.state);this.enterRule(e,28,E.RULE_comparisonOperator);let t;try{this.enterOuterAlt(e,1),this.state=113,t=this._input.LA(1),!(t&-32)&&1<<t&2146959360?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this)}catch(r){if(r instanceof j)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}logicalOperator(){let e=new Lr(this,this._ctx,this.state);this.enterRule(e,30,E.RULE_logicalOperator);let t;try{this.enterOuterAlt(e,1),this.state=115,t=this._input.LA(1),!(t-31&-32)&&1<<t-31&15?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this)}catch(r){if(r instanceof j)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}polarityOperator(){let e=new Xn(this,this._ctx,this.state);this.enterRule(e,32,E.RULE_polarityOperator);try{this.enterOuterAlt(e,1),this.state=117,this.match(E.POLAR_OP)}catch(t){if(t instanceof j)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}sempred(e,t,r){switch(t){case 1:return this.expression_sempred(e,r)}return!0}expression_sempred(e,t){switch(t){case 0:return this.precpred(this._ctx,3)}return!0}static get _ATN(){return E.__ATN||(E.__ATN=new pp().deserialize(E._serializedATN)),E.__ATN}};s(E,"OpraFilterParser");var f=E;f.T__0=1;f.T__1=2;f.T__2=3;f.T__3=4;f.T__4=5;f.T__5=6;f.T__6=7;f.T__7=8;f.T__8=9;f.T__9=10;f.T__10=11;f.T__11=12;f.T__12=13;f.T__13=14;f.T__14=15;f.T__15=16;f.T__16=17;f.T__17=18;f.T__18=19;f.T__19=20;f.T__20=21;f.T__21=22;f.T__22=23;f.T__23=24;f.T__24=25;f.T__25=26;f.T__26=27;f.T__27=28;f.T__28=29;f.T__29=30;f.T__30=31;f.T__31=32;f.T__32=33;f.T__33=34;f.IDENTIFIER=35;f.POLAR_OP=36;f.DATE=37;f.DATETIME=38;f.TIME=39;f.NUMBER=40;f.INTEGER=41;f.STRING=42;f.WHITESPACE=43;f.EOF=hp.EOF;f.RULE_root=0;f.RULE_expression=1;f.RULE_comparisonLeft=2;f.RULE_comparisonRight=3;f.RULE_parenthesizedItem=4;f.RULE_value=5;f.RULE_qualifiedIdentifier=6;f.RULE_externalConstant=7;f.RULE_identifier=8;f.RULE_arrayValue=9;f.RULE_boolean=10;f.RULE_null=11;f.RULE_infinity=12;f.RULE_arithmeticOperator=13;f.RULE_comparisonOperator=14;f.RULE_logicalOperator=15;f.RULE_polarityOperator=16;f.literalNames=[null,"'('","')'","'not'","'!'","'.'","'@'","'['","','","']'","'true'","'false'","'null'","'Infinity'","'infinity'","'+'","'-'","'*'","'/'","'<='","'<'","'>'","'>='","'='","'!='","'in'","'!in'","'like'","'!like'","'ilike'","'!ilike'","'and'","'or'","'&&'","'||'"];f.symbolicNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"IDENTIFIER","POLAR_OP","DATE","DATETIME","TIME","NUMBER","INTEGER","STRING","WHITESPACE"];f.ruleNames=["root","expression","comparisonLeft","comparisonRight","parenthesizedItem","value","qualifiedIdentifier","externalConstant","identifier","arrayValue","boolean","null","infinity","arithmeticOperator","comparisonOperator","logicalOperator","polarityOperator"];f._serializedATN=[4,1,43,120,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,49,8,1,1,1,1,1,1,1,1,1,5,1,55,8,1,10,1,12,1,58,9,1,1,2,1,2,1,3,1,3,1,3,1,3,3,3,66,8,3,1,4,1,4,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,3,5,78,8,5,1,6,1,6,1,6,5,6,83,8,6,10,6,12,6,86,9,6,1,6,1,6,1,7,1,7,1,7,1,8,1,8,1,9,1,9,1,9,1,9,5,9,99,8,9,10,9,12,9,102,9,9,1,9,1,9,1,10,1,10,1,11,1,11,1,12,1,12,1,13,1,13,1,14,1,14,1,15,1,15,1,16,1,16,1,16,0,1,2,17,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,0,6,1,0,3,4,1,0,10,11,1,0,13,14,1,0,15,18,1,0,19,30,1,0,31,34,117,0,34,1,0,0,0,2,48,1,0,0,0,4,59,1,0,0,0,6,65,1,0,0,0,8,67,1,0,0,0,10,77,1,0,0,0,12,84,1,0,0,0,14,89,1,0,0,0,16,92,1,0,0,0,18,94,1,0,0,0,20,105,1,0,0,0,22,107,1,0,0,0,24,109,1,0,0,0,26,111,1,0,0,0,28,113,1,0,0,0,30,115,1,0,0,0,32,117,1,0,0,0,34,35,3,2,1,0,35,36,5,0,0,1,36,1,1,0,0,0,37,38,6,1,-1,0,38,39,3,4,2,0,39,40,3,28,14,0,40,41,3,6,3,0,41,49,1,0,0,0,42,43,5,1,0,0,43,44,3,8,4,0,44,45,5,2,0,0,45,49,1,0,0,0,46,47,7,0,0,0,47,49,3,2,1,1,48,37,1,0,0,0,48,42,1,0,0,0,48,46,1,0,0,0,49,56,1,0,0,0,50,51,10,3,0,0,51,52,3,30,15,0,52,53,3,2,1,4,53,55,1,0,0,0,54,50,1,0,0,0,55,58,1,0,0,0,56,54,1,0,0,0,56,57,1,0,0,0,57,3,1,0,0,0,58,56,1,0,0,0,59,60,3,12,6,0,60,5,1,0,0,0,61,66,3,10,5,0,62,66,3,12,6,0,63,66,3,14,7,0,64,66,3,18,9,0,65,61,1,0,0,0,65,62,1,0,0,0,65,63,1,0,0,0,65,64,1,0,0,0,66,7,1,0,0,0,67,68,3,2,1,0,68,9,1,0,0,0,69,78,5,40,0,0,70,78,3,24,12,0,71,78,3,20,10,0,72,78,3,22,11,0,73,78,5,37,0,0,74,78,5,38,0,0,75,78,5,39,0,0,76,78,5,42,0,0,77,69,1,0,0,0,77,70,1,0,0,0,77,71,1,0,0,0,77,72,1,0,0,0,77,73,1,0,0,0,77,74,1,0,0,0,77,75,1,0,0,0,77,76,1,0,0,0,78,11,1,0,0,0,79,80,3,16,8,0,80,81,5,5,0,0,81,83,1,0,0,0,82,79,1,0,0,0,83,86,1,0,0,0,84,82,1,0,0,0,84,85,1,0,0,0,85,87,1,0,0,0,86,84,1,0,0,0,87,88,3,16,8,0,88,13,1,0,0,0,89,90,5,6,0,0,90,91,3,16,8,0,91,15,1,0,0,0,92,93,5,35,0,0,93,17,1,0,0,0,94,95,5,7,0,0,95,100,3,10,5,0,96,97,5,8,0,0,97,99,3,10,5,0,98,96,1,0,0,0,99,102,1,0,0,0,100,98,1,0,0,0,100,101,1,0,0,0,101,103,1,0,0,0,102,100,1,0,0,0,103,104,5,9,0,0,104,19,1,0,0,0,105,106,7,1,0,0,106,21,1,0,0,0,107,108,5,12,0,0,108,23,1,0,0,0,109,110,7,2,0,0,110,25,1,0,0,0,111,112,7,3,0,0,112,27,1,0,0,0,113,114,7,4,0,0,114,29,1,0,0,0,115,116,7,5,0,0,116,31,1,0,0,0,117,118,5,36,0,0,118,33,1,0,0,0,6,48,56,65,77,84,100];f.DecisionsToDFA=f._ATN.decisionToState.map((i,e)=>new cp(i,e));var bs=f,Zn=class Zn extends U{constructor(e,t,r){super(t,r),this.parser=e}expression(){return this.getTypedRuleContext(G,0)}EOF(){return this.getToken(f.EOF,0)}get ruleIndex(){return f.RULE_root}enterRule(e){e.enterRoot&&e.enterRoot(this)}exitRule(e){e.exitRoot&&e.exitRoot(this)}accept(e){return e.visitRoot?e.visitRoot(this):e.visitChildren(this)}};s(Zn,"RootContext");var Un=Zn,Hn=class Hn extends U{constructor(e,t,r){super(t,r),this.parser=e}get ruleIndex(){return f.RULE_expression}copyFrom(e){super.copyFrom(e)}};s(Hn,"ExpressionContext");var G=Hn,eo=class eo extends G{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}parenthesizedItem(){return this.getTypedRuleContext(Ar,0)}enterRule(e){e.enterParenthesizedExpression&&e.enterParenthesizedExpression(this)}exitRule(e){e.exitParenthesizedExpression&&e.exitParenthesizedExpression(this)}accept(e){return e.visitParenthesizedExpression?e.visitParenthesizedExpression(this):e.visitChildren(this)}};s(eo,"ParenthesizedExpressionContext");var Cn=eo,to=class to extends G{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}expression(){return this.getTypedRuleContext(G,0)}enterRule(e){e.enterNegativeExpression&&e.enterNegativeExpression(this)}exitRule(e){e.exitNegativeExpression&&e.exitNegativeExpression(this)}accept(e){return e.visitNegativeExpression?e.visitNegativeExpression(this):e.visitChildren(this)}};s(to,"NegativeExpressionContext");var Bn=to,ro=class ro extends G{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}comparisonLeft(){return this.getTypedRuleContext(Or,0)}comparisonOperator(){return this.getTypedRuleContext(Ir,0)}comparisonRight(){return this.getTypedRuleContext(Rr,0)}enterRule(e){e.enterComparisonExpression&&e.enterComparisonExpression(this)}exitRule(e){e.exitComparisonExpression&&e.exitComparisonExpression(this)}accept(e){return e.visitComparisonExpression?e.visitComparisonExpression(this):e.visitChildren(this)}};s(ro,"ComparisonExpressionContext");var qn=ro,io=class io extends G{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}expression_list(){return this.getTypedRuleContexts(G)}expression(e){return this.getTypedRuleContext(G,e)}logicalOperator(){return this.getTypedRuleContext(Lr,0)}enterRule(e){e.enterLogicalExpression&&e.enterLogicalExpression(this)}exitRule(e){e.exitLogicalExpression&&e.exitLogicalExpression(this)}accept(e){return e.visitLogicalExpression?e.visitLogicalExpression(this):e.visitChildren(this)}};s(io,"LogicalExpressionContext");var Ct=io,no=class no extends U{constructor(e,t,r){super(t,r),this.parser=e}qualifiedIdentifier(){return this.getTypedRuleContext(Bt,0)}get ruleIndex(){return f.RULE_comparisonLeft}enterRule(e){e.enterComparisonLeft&&e.enterComparisonLeft(this)}exitRule(e){e.exitComparisonLeft&&e.exitComparisonLeft(this)}accept(e){return e.visitComparisonLeft?e.visitComparisonLeft(this):e.visitChildren(this)}};s(no,"ComparisonLeftContext");var Or=no,oo=class oo extends U{constructor(e,t,r){super(t,r),this.parser=e}value(){return this.getTypedRuleContext(K,0)}qualifiedIdentifier(){return this.getTypedRuleContext(Bt,0)}externalConstant(){return this.getTypedRuleContext(br,0)}arrayValue(){return this.getTypedRuleContext(wr,0)}get ruleIndex(){return f.RULE_comparisonRight}enterRule(e){e.enterComparisonRight&&e.enterComparisonRight(this)}exitRule(e){e.exitComparisonRight&&e.exitComparisonRight(this)}accept(e){return e.visitComparisonRight?e.visitComparisonRight(this):e.visitChildren(this)}};s(oo,"ComparisonRightContext");var Rr=oo,so=class so extends U{constructor(e,t,r){super(t,r),this.parser=e}expression(){return this.getTypedRuleContext(G,0)}get ruleIndex(){return f.RULE_parenthesizedItem}enterRule(e){e.enterParenthesizedItem&&e.enterParenthesizedItem(this)}exitRule(e){e.exitParenthesizedItem&&e.exitParenthesizedItem(this)}accept(e){return e.visitParenthesizedItem?e.visitParenthesizedItem(this):e.visitChildren(this)}};s(so,"ParenthesizedItemContext");var Ar=so,ao=class ao extends U{constructor(e,t,r){super(t,r),this.parser=e}get ruleIndex(){return f.RULE_value}copyFrom(e){super.copyFrom(e)}};s(ao,"ValueContext");var K=ao,po=class po extends K{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}TIME(){return this.getToken(f.TIME,0)}enterRule(e){e.enterTimeLiteral&&e.enterTimeLiteral(this)}exitRule(e){e.exitTimeLiteral&&e.exitTimeLiteral(this)}accept(e){return e.visitTimeLiteral?e.visitTimeLiteral(this):e.visitChildren(this)}};s(po,"TimeLiteralContext");var $n=po,co=class co extends K{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}null_(){return this.getTypedRuleContext(Dr,0)}enterRule(e){e.enterNullLiteral&&e.enterNullLiteral(this)}exitRule(e){e.exitNullLiteral&&e.exitNullLiteral(this)}accept(e){return e.visitNullLiteral?e.visitNullLiteral(this):e.visitChildren(this)}};s(co,"NullLiteralContext");var Vn=co,lo=class lo extends K{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}DATETIME(){return this.getToken(f.DATETIME,0)}enterRule(e){e.enterDateTimeLiteral&&e.enterDateTimeLiteral(this)}exitRule(e){e.exitDateTimeLiteral&&e.exitDateTimeLiteral(this)}accept(e){return e.visitDateTimeLiteral?e.visitDateTimeLiteral(this):e.visitChildren(this)}};s(lo,"DateTimeLiteralContext");var Kn=lo,fo=class fo extends K{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}STRING(){return this.getToken(f.STRING,0)}enterRule(e){e.enterStringLiteral&&e.enterStringLiteral(this)}exitRule(e){e.exitStringLiteral&&e.exitStringLiteral(this)}accept(e){return e.visitStringLiteral?e.visitStringLiteral(this):e.visitChildren(this)}};s(fo,"StringLiteralContext");var zn=fo,uo=class uo extends K{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}DATE(){return this.getToken(f.DATE,0)}enterRule(e){e.enterDateLiteral&&e.enterDateLiteral(this)}exitRule(e){e.exitDateLiteral&&e.exitDateLiteral(this)}accept(e){return e.visitDateLiteral?e.visitDateLiteral(this):e.visitChildren(this)}};s(uo,"DateLiteralContext");var Jn=uo,mo=class mo extends K{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}infinity(){return this.getTypedRuleContext(Sr,0)}enterRule(e){e.enterInfinityLiteral&&e.enterInfinityLiteral(this)}exitRule(e){e.exitInfinityLiteral&&e.exitInfinityLiteral(this)}accept(e){return e.visitInfinityLiteral?e.visitInfinityLiteral(this):e.visitChildren(this)}};s(mo,"InfinityLiteralContext");var Wn=mo,ho=class ho extends K{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}boolean_(){return this.getTypedRuleContext(Nr,0)}enterRule(e){e.enterBooleanLiteral&&e.enterBooleanLiteral(this)}exitRule(e){e.exitBooleanLiteral&&e.exitBooleanLiteral(this)}accept(e){return e.visitBooleanLiteral?e.visitBooleanLiteral(this):e.visitChildren(this)}};s(ho,"BooleanLiteralContext");var Gn=ho,yo=class yo extends K{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}NUMBER(){return this.getToken(f.NUMBER,0)}enterRule(e){e.enterNumberLiteral&&e.enterNumberLiteral(this)}exitRule(e){e.exitNumberLiteral&&e.exitNumberLiteral(this)}accept(e){return e.visitNumberLiteral?e.visitNumberLiteral(this):e.visitChildren(this)}};s(yo,"NumberLiteralContext");var Yn=yo,To=class To extends U{constructor(e,t,r){super(t,r),this.parser=e}identifier_list(){return this.getTypedRuleContexts(ft)}identifier(e){return this.getTypedRuleContext(ft,e)}get ruleIndex(){return f.RULE_qualifiedIdentifier}enterRule(e){e.enterQualifiedIdentifier&&e.enterQualifiedIdentifier(this)}exitRule(e){e.exitQualifiedIdentifier&&e.exitQualifiedIdentifier(this)}accept(e){return e.visitQualifiedIdentifier?e.visitQualifiedIdentifier(this):e.visitChildren(this)}};s(To,"QualifiedIdentifierContext");var Bt=To,Eo=class Eo extends U{constructor(e,t,r){super(t,r),this.parser=e}identifier(){return this.getTypedRuleContext(ft,0)}get ruleIndex(){return f.RULE_externalConstant}enterRule(e){e.enterExternalConstant&&e.enterExternalConstant(this)}exitRule(e){e.exitExternalConstant&&e.exitExternalConstant(this)}accept(e){return e.visitExternalConstant?e.visitExternalConstant(this):e.visitChildren(this)}};s(Eo,"ExternalConstantContext");var br=Eo,_o=class _o extends U{constructor(e,t,r){super(t,r),this.parser=e}IDENTIFIER(){return this.getToken(f.IDENTIFIER,0)}get ruleIndex(){return f.RULE_identifier}enterRule(e){e.enterIdentifier&&e.enterIdentifier(this)}exitRule(e){e.exitIdentifier&&e.exitIdentifier(this)}accept(e){return e.visitIdentifier?e.visitIdentifier(this):e.visitChildren(this)}};s(_o,"IdentifierContext");var ft=_o,xo=class xo extends U{constructor(e,t,r){super(t,r),this.parser=e}value_list(){return this.getTypedRuleContexts(K)}value(e){return this.getTypedRuleContext(K,e)}get ruleIndex(){return f.RULE_arrayValue}enterRule(e){e.enterArrayValue&&e.enterArrayValue(this)}exitRule(e){e.exitArrayValue&&e.exitArrayValue(this)}accept(e){return e.visitArrayValue?e.visitArrayValue(this):e.visitChildren(this)}};s(xo,"ArrayValueContext");var wr=xo,go=class go extends U{constructor(e,t,r){super(t,r),this.parser=e}get ruleIndex(){return f.RULE_boolean}enterRule(e){e.enterBoolean&&e.enterBoolean(this)}exitRule(e){e.exitBoolean&&e.exitBoolean(this)}accept(e){return e.visitBoolean?e.visitBoolean(this):e.visitChildren(this)}};s(go,"BooleanContext");var Nr=go,Oo=class Oo extends U{constructor(e,t,r){super(t,r),this.parser=e}get ruleIndex(){return f.RULE_null}enterRule(e){e.enterNull&&e.enterNull(this)}exitRule(e){e.exitNull&&e.exitNull(this)}accept(e){return e.visitNull?e.visitNull(this):e.visitChildren(this)}};s(Oo,"NullContext");var Dr=Oo,Ro=class Ro extends U{constructor(e,t,r){super(t,r),this.parser=e}get ruleIndex(){return f.RULE_infinity}enterRule(e){e.enterInfinity&&e.enterInfinity(this)}exitRule(e){e.exitInfinity&&e.exitInfinity(this)}accept(e){return e.visitInfinity?e.visitInfinity(this):e.visitChildren(this)}};s(Ro,"InfinityContext");var Sr=Ro,Ao=class Ao extends U{constructor(e,t,r){super(t,r),this.parser=e}get ruleIndex(){return f.RULE_arithmeticOperator}enterRule(e){e.enterArithmeticOperator&&e.enterArithmeticOperator(this)}exitRule(e){e.exitArithmeticOperator&&e.exitArithmeticOperator(this)}accept(e){return e.visitArithmeticOperator?e.visitArithmeticOperator(this):e.visitChildren(this)}};s(Ao,"ArithmeticOperatorContext");var Qn=Ao,bo=class bo extends U{constructor(e,t,r){super(t,r),this.parser=e}get ruleIndex(){return f.RULE_comparisonOperator}enterRule(e){e.enterComparisonOperator&&e.enterComparisonOperator(this)}exitRule(e){e.exitComparisonOperator&&e.exitComparisonOperator(this)}accept(e){return e.visitComparisonOperator?e.visitComparisonOperator(this):e.visitChildren(this)}};s(bo,"ComparisonOperatorContext");var Ir=bo,wo=class wo extends U{constructor(e,t,r){super(t,r),this.parser=e}get ruleIndex(){return f.RULE_logicalOperator}enterRule(e){e.enterLogicalOperator&&e.enterLogicalOperator(this)}exitRule(e){e.exitLogicalOperator&&e.exitLogicalOperator(this)}accept(e){return e.visitLogicalOperator?e.visitLogicalOperator(this):e.visitChildren(this)}};s(wo,"LogicalOperatorContext");var Lr=wo,No=class No extends U{constructor(e,t,r){super(t,r),this.parser=e}POLAR_OP(){return this.getToken(f.POLAR_OP,0)}get ruleIndex(){return f.RULE_polarityOperator}enterRule(e){e.enterPolarityOperator&&e.enterPolarityOperator(this)}exitRule(e){e.exitPolarityOperator&&e.exitPolarityOperator(this)}accept(e){return e.visitPolarityOperator?e.visitPolarityOperator(this):e.visitChildren(this)}};s(No,"PolarityOperatorContext");var Xn=No;import{ParseTreeVisitor as dp}from"@browsery/antlr4";var Do=class Do extends v{constructor(e){super(""+e)}toString(){return"@"+super.toString()}};s(Do,"ExternalConstant");var Pr=Do;var So=class So extends dp{constructor(e){super(),this._timeZone=e==null?void 0:e.timeZone}visitChildren(e){let t=super.visitChildren(e);return Array.isArray(t)&&t.length<2?t[0]:t??e.getText()}defaultResult(){}visitRoot(e){return this.visit(e.expression())}visitParenthesizedExpression(e){let t=this.visit(e.parenthesizedItem());return new ye(t)}visitParenthesizedItem(e){return this.visit(e.expression())}visitNegativeExpression(e){let t=this.visit(e.expression());return new jt(t)}visitComparisonExpression(e){return new de({op:e.comparisonOperator().getText(),left:this.visit(e.comparisonLeft()),right:this.visit(e.comparisonRight())})}visitLogicalExpression(e){let t=[],r=s((n,o)=>{for(let a of n){if(a instanceof Ct&&a.logicalOperator().getText()===o){r(a.expression_list(),a.logicalOperator().getText());continue}let p=this.visit(a);t.push(p)}},"wrapChildren");return r(e.expression_list(),e.logicalOperator().getText()),new pe({op:e.logicalOperator().getText(),items:t})}visitQualifiedIdentifier(e){return new ce(e.getText())}visitExternalConstant(e){return new Pr(e.identifier().getText())}visitNullLiteral(){return new Ce}visitBooleanLiteral(e){return new Ue(e.getText()==="true")}visitNumberLiteral(e){return new Ee(e.getText())}visitStringLiteral(e){return new Be(Ut(e.getText()))}visitInfinityLiteral(){return new Ee(1/0)}visitDateLiteral(e){return new Te(Ut(e.getText()))}visitDateTimeLiteral(e){return new Te(Ut(e.getText()))}visitTimeLiteral(e){return new qe(Ut(e.getText()))}visitArrayValue(e){return new he(e.value_list().map(t=>this.visit(t)))}};s(So,"FilterTreeVisitor");var qt=So;import{ErrorListener as yp}from"@browsery/antlr4";var Io=class Io extends yp{constructor(e){super(),this.errors=e}syntaxError(e,t,r,n,o,a){this.errors.push(new xr(o,{recognizer:e,offendingSymbol:t,line:r,column:n,e:a}))}};s(Io,"OpraErrorListener");var $t=Io;function Lo(i,e){let t=new Tp(i),r=new Rs(t),n=new Ep(r),o=new bs(n);o.buildParseTrees=!0;let a=[],p=new $t(a);r.removeErrorListeners(),r.addErrorListener(p),o.removeErrorListeners(),o.addErrorListener(p);let c=o.root();if(a.length){let l=[];for(let u of a)l.push(u.message+(i.includes(`
8
- `)?" at line: "+u.line+" column: "+u.column:" at column: "+u.column));let _=new _r(l.join(`
9
- `));throw _.errors=a,_}return e=e||new qt,e.visit(c)}s(Lo,"parse");var Po=class Po{constructor(e,t){if(this._rules=new P,Object.defineProperty(this,"_rules",{value:new P(null,{caseSensitive:t==null?void 0:t.caseSensitive}),enumerable:!1}),e)for(let[r,n]of Object.entries(e))this.set(r,n)}set(e,t){let r=typeof(t==null?void 0:t.operators)=="string"?t.operators.split(/\s*[,| ]\s*/):t==null?void 0:t.operators;this._rules.set(e,x({...t,operators:r}))}normalizeFilter(e,t){if(!e)return;let r=typeof e=="string"?Lo(e):e;if(r instanceof de){if(this.normalizeFilter(r.left,t),!(r.left instanceof ce&&r.left.field))throw new TypeError("Invalid filter query. Left side should be a data field.");let n=this._rules.get(r.left.value);if(!n)throw new me({message:R("error:UNACCEPTED_FILTER_FIELD",{field:r.left.value}),code:"UNACCEPTED_FILTER_FIELD",details:{field:r.left.value}});if(n.operators&&!n.operators.includes(r.op))throw new me({message:R("error:UNACCEPTED_FILTER_OPERATION",{field:r.left.value}),code:"UNACCEPTED_FILTER_OPERATION",details:{field:r.left.value,operator:r.op}});return this.normalizeFilter(r.right,t),r}return r instanceof pe?(r.items.forEach(n=>this.normalizeFilter(n,t)),r):r instanceof je?(r.items.forEach(n=>this.normalizeFilter(n.expression,t)),r):r instanceof he?(r.items.forEach(n=>this.normalizeFilter(n,t)),r):r instanceof ye?(this.normalizeFilter(r.expression,t),r):(r instanceof ce&&t&&(r.value=t.normalizeFieldPath(r.value),r.field=t.getField(r.value),r.dataType=r.field.type),r)}toJSON(){return this._rules.toObject()}[Symbol.iterator](){return this._rules.entries()}};s(Po,"FilterRules");var _e=Po;var Vt={};Ko(Vt,{$and:()=>xp,$arithmetic:()=>Up,$array:()=>ws,$date:()=>gp,$eq:()=>bp,$field:()=>Ap,$gt:()=>Np,$gte:()=>Dp,$ilike:()=>Fp,$in:()=>Lp,$like:()=>Mp,$lt:()=>Sp,$lte:()=>Ip,$ne:()=>wp,$notILike:()=>kp,$notIn:()=>Pp,$notLike:()=>vp,$number:()=>Rp,$or:()=>_p,$paren:()=>jp,$time:()=>Op,ArithmeticExpression:()=>je,ArithmeticExpressionItem:()=>Er,ArrayExpression:()=>he,Ast:()=>kt,BooleanLiteral:()=>Ue,ComparisonExpression:()=>de,DateLiteral:()=>Te,Expression:()=>k,FilterTreeVisitor:()=>qt,Literal:()=>v,LogicalExpression:()=>pe,NegativeExpression:()=>jt,NullLiteral:()=>Ce,NumberLiteral:()=>Ee,OpraErrorListener:()=>$t,ParenthesizedExpression:()=>ye,QualifiedIdentifier:()=>ce,StringLiteral:()=>Be,Term:()=>ke,TimeLiteral:()=>qe,parse:()=>Lo});function _p(...i){return new pe({op:"or",items:i})}s(_p,"$or");function xp(...i){return new pe({op:"and",items:i})}s(xp,"$and");function gp(i){return new Te(i)}s(gp,"$date");function Op(i){return new qe(i)}s(Op,"$time");function Rp(i){return new Ee(i)}s(Rp,"$number");function ws(...i){return new he(i.map(Mr))}s(ws,"$array");function Ap(i){return new ce(i)}s(Ap,"$field");function bp(i,e){return ee("=",i,e)}s(bp,"$eq");function wp(i,e){return ee("!=",i,e)}s(wp,"$ne");function Np(i,e){return ee(">",i,e)}s(Np,"$gt");function Dp(i,e){return ee(">=",i,e)}s(Dp,"$gte");function Sp(i,e){return ee("<",i,e)}s(Sp,"$lt");function Ip(i,e){return ee("<=",i,e)}s(Ip,"$lte");function Lp(i,e){return ee("in",i,e)}s(Lp,"$in");function Pp(i,e){return ee("!in",i,e)}s(Pp,"$notIn");function Mp(i,e){return ee("like",i,e)}s(Mp,"$like");function vp(i,e){return ee("!like",i,e)}s(vp,"$notLike");function Fp(i,e){return ee("ilike",i,e)}s(Fp,"$ilike");function kp(i,e){return ee("!ilike",i,e)}s(kp,"$notILike");function jp(i){return new ye(i)}s(jp,"$paren");function Up(i){let e=new je;return e.add=t=>(e.append("+",ut(t)),e),e.sub=t=>(e.append("-",ut(t)),e),e.mul=t=>(e.append("*",ut(t)),e),e.div=t=>(e.append("/",ut(t)),e),e.append("+",Mr(i)),e}s(Up,"$arithmetic");function ee(i,e,t){let r=Mr(e),n=Mr(t);return new de({op:i,left:r,right:n})}s(ee,"comparisonExpression");var Mr=s(i=>Array.isArray(i)?ws(...i.map(ut)):ut(i),"wrapEntryValue"),ut=s(i=>i instanceof k?i:typeof i=="boolean"?new Ue(i):typeof i=="number"||typeof i=="bigint"?new Ee(i):i==null?new Ce:i instanceof Date?new Te(i):new Be(""+i),"_wrapEntryValue");var mt,re=(mt=class{constructor(e){e&&Object.assign(this,e)}[y](e,t){let r=e.dataType?t.node.getComplexType(e.dataType):t.node.getComplexType("object"),n=e.rules?new _e(e.rules):void 0;return Cp(r,n)}[g](){return Bp}toJSON(e,t){let r=e.dataType?t.node.getComplexType(e.dataType):t.node.getComplexType("object");return{dataType:r.name?r.name:r.toJSON(),rules:e.rules}}},s(mt,"FilterType"),mt);Mo([m.Attribute({description:"Data type which filtering fields belong to"}),vo("design:type",Object)],re.prototype,"dataType",void 0);Mo([m.Attribute({description:"Stringified JSON object defines filtering rules",format:"string"}),vo("design:type",Object)],re.prototype,"rules",void 0);re=Mo([m({description:"A query filter",nameMappings:{js:"object",json:"string"}}),vo("design:paramtypes",[Object])],re);var Cp=s((i,e)=>Ns("decodeFilter",(t,r,n)=>{if(typeof t=="string")try{let o=Vt.parse(t);return e?e.normalizeFilter(o,i):o}catch(o){r.fail(n,`Not a valid filter expression. ${o.message}`,t);return}r.fail(n,"Nt a valid filter expression string",t)}),"decodeFilter"),Bp=Ns("encodeFilter",(i,e,t)=>{if(i instanceof Vt.Ast)return i.toString();e.fail(t,"Not a valid filter expression",i)});import{__decorate as qp,__metadata as $p}from"tslib";import{vg as Ds}from"valgen";var ht,vr=(ht=class{constructor(e){e&&Object.assign(this,e)}[y](){return Ds.isObjectId({coerce:!0})}[g](){return Ds.isObjectId({coerce:!0})}},s(ht,"ObjectIdType"),ht);vr=qp([m({description:"A MongoDB ObjectID value",nameMappings:{js:"object",json:"string"}}),$p("design:paramtypes",[Object])],vr);import{__decorate as le,__metadata as fe}from"tslib";var dt,Y=(dt=class{constructor(e){e&&Object.assign(this,e)}},s(dt,"OperationResult"),dt);le([M(),fe("design:type",Number)],Y.prototype,"affected",void 0);le([M(),fe("design:type",Number)],Y.prototype,"totalMatches",void 0);le([M(),fe("design:type",String)],Y.prototype,"context",void 0);le([M(),fe("design:type",String)],Y.prototype,"type",void 0);le([M(),fe("design:type",String)],Y.prototype,"message",void 0);le([M({type:"any"}),fe("design:type",Object)],Y.prototype,"payload",void 0);le([M({type:"object"}),fe("design:type",Array)],Y.prototype,"errors",void 0);Y=le([Q({description:"Operation result"}),fe("design:paramtypes",[Object])],Y);(function(i){function e(t){var n;let r=(n=class extends i{constructor(...a){super(...a)}},s(n,"OperationResult_"),n);return le([M({type:t,required:!0}),fe("design:type",Object)],r.prototype,"payload",void 0),r=le([Q({embedded:!0}),fe("design:paramtypes",[Object])],r),r}s(e,"forPayload"),i.forPayload=e})(Y||(Y={}));import{__decorate as Fo,__metadata as ko}from"tslib";import{vg as Fr}from"valgen";var Vp=/^([0-1][0-9]|2[0-4]):([0-5][0-9])(?::([0-5][0-9]))?$/,yt,Tt=(yt=class{constructor(e){e&&Object.assign(this,e)}[y](e){let t=Fr.matches(Vp,{formatName:"time",coerce:!0}),r=[];return e.minValue&&r.push(Fr.isGte(e.minValue)),e.maxValue&&r.push(Fr.isLte(e.maxValue)),r.length>0?Fr.pipe([t,...r],{returnIndex:0}):t}[g](e){return this[y](e)}},s(yt,"TimeType"),yt);Fo([m.Attribute({description:"Minimum value"}),ko("design:type",String)],Tt.prototype,"minValue",void 0);Fo([m.Attribute({description:"Maximum value"}),ko("design:type",String)],Tt.prototype,"maxValue",void 0);Tt=Fo([m({description:"Time string in 24h format",nameMappings:{js:"string",json:"string"}}).Example("18:23:00","Full time value").Example("18:23:00","Time value without seconds"),ko("design:paramtypes",[Object])],Tt);import{__decorate as Kp,__metadata as zp}from"tslib";import{vg as Ss}from"valgen";var Et,kr=(Et=class{constructor(e){e&&Object.assign(this,e)}[y](){return Ss.isURL({coerce:!0})}[g](){return Ss.isURL({coerce:!0})}},s(Et,"UrlType"),Et);kr=Kp([m({description:"A Uniform Resource Identifier Reference (RFC 3986 icon) value",nameMappings:{js:"string",json:"string"}}).Example("http://tempuri.org"),zp("design:paramtypes",[Object])],kr);import{__decorate as Ls,__metadata as Ps}from"tslib";import{vg as Is}from"valgen";var _t,Kt=(_t=class{constructor(e){e&&Object.assign(this,e)}[y](e){return Is.isUUID(e==null?void 0:e.version,{coerce:!0})}[g](e){return Is.isUUID(e==null?void 0:e.version,{coerce:!0})}},s(_t,"UuidType"),_t);Ls([m.Attribute({description:"Version of the UUID"}),Ps("design:type",Number)],Kt.prototype,"version",void 0);Kt=Ls([m({description:"A Universal Unique Identifier (UUID) value",nameMappings:{js:"string",json:"string"}}),Ps("design:paramtypes",[Object])],Kt);function Ne(i,e,t){let r=nr(e.pick,e.omit),n=typeof i=="string"?i.charAt(0).toUpperCase()+i.substring(1):i.name,o=(t==null?void 0:t.name)||n+"Mapped",a={[o]:class{constructor(){typeof i=="function"&&Qt(this,i,r)}}}[o];if(typeof i=="function"&&Yt(a.prototype,i.prototype),typeof i=="function"){let c=Reflect.getOwnMetadata(T,i);if(!c)throw new TypeError(`Class "${i}" doesn't have datatype metadata information`);if(!(c.kind===h.ComplexType.Kind||c.kind===h.MappedType.Kind||c.kind===h.MixinType.Kind))throw new TypeError(`Class "${i}" is not a ${h.ComplexType.Kind}`)}let p={...t,kind:"MappedType",base:i};return e.pick&&(p.pick=e.pick),e.omit&&(p.omit=e.omit),e.partial&&(p.partial=e.partial),e.required&&(p.required=e.required),Reflect.defineMetadata(T,p,a),typeof i=="function"&&Me._applyMixin(a,i,{...e,isInheritedPredicate:r}),a}s(Ne,"createMappedClass");function GE(i,e,t){return Ne(i,{omit:e},t)}s(GE,"OmitType");function ZE(i,...e){let t=Array.isArray(e[0])?e[0]:!0,r=Array.isArray(e[0])?e[1]:e[0];return Ne(i,{partial:t},r)}s(ZE,"PartialType");function r3(i,e,t){return Ne(i,{pick:e},t)}s(r3,"PickType");import{__decorate as Jp,__metadata as Wp}from"tslib";import{isAny as Ms}from"valgen";var xt,jr=(xt=class{constructor(e){e&&Object.assign(this,e)}[y](){return Ms}[g](){return Ms}},s(xt,"AnyType"),xt);jr=Jp([m({description:"Represents any value"}),Wp("design:paramtypes",[Object])],jr);import{__decorate as Gp,__metadata as Yp}from"tslib";import{toBigint as Fs,vg as Bo}from"valgen";import{__decorate as Uo,__metadata as Co}from"tslib";import{toNumber as vs,vg as jo}from"valgen";var gt,ue=(gt=class{constructor(e){e&&Object.assign(this,e)}[y](e){let t=[];return e.minValue&&t.push(jo.isGte(e.minValue)),e.maxValue&&t.push(jo.isLte(e.maxValue)),t.length>0?jo.pipe([vs,...t],{returnIndex:0}):vs}[g](e){return this[y](e)}},s(gt,"NumberType"),gt);Uo([m.Attribute({description:"Determines the minimum value"}),Co("design:type",Number)],ue.prototype,"minValue",void 0);Uo([m.Attribute({description:"Determines the maximum value"}),Co("design:type",Number)],ue.prototype,"maxValue",void 0);ue=Uo([m({description:"Both Integer as well as Floating-Point numbers",nameMappings:{js:"number",json:"number"}}),Co("design:paramtypes",[Object])],ue);var Ot,Ur=(Ot=class extends ue{constructor(e){super(e)}[y](e){let t=[];return e.minValue&&t.push(Bo.isGte(e.minValue)),e.maxValue&&t.push(Bo.isLte(e.maxValue)),t.length>0?Bo.pipe([Fs,...t],{returnIndex:0}):Fs}[g](e){return this[y](e)}},s(Ot,"BigintType"),Ot);Ur=Gp([m({description:"BigInt number",nameMappings:{js:"bigint",json:"string"}}),Yp("design:paramtypes",[Object])],Ur);import{__decorate as Qp,__metadata as Xp}from"tslib";import{toBoolean as ks}from"valgen";var Rt,Cr=(Rt=class{constructor(e){e&&Object.assign(this,e)}[y](){return ks}[g](){return ks}},s(Rt,"BooleanType"),Rt);Cr=Qp([m({description:"Simple true/false value",nameMappings:{js:"boolean",json:"boolean"}}),Xp("design:paramtypes",[Object])],Cr);import{__decorate as Zp,__metadata as Hp}from"tslib";import{toInteger as js,vg as qo}from"valgen";var At,$e=(At=class extends ue{constructor(e){super(e)}[y](e){let t=[];return e.minValue&&t.push(qo.isGte(e.minValue)),e.maxValue&&t.push(qo.isLte(e.maxValue)),t.length>0?qo.pipe([js,...t],{returnIndex:0}):js}[g](e){return this[y](e)}},s(At,"IntegerType"),At);$e=Zp([m({description:"An integer number",nameMappings:{js:"number",json:"number"}}),Hp("design:paramtypes",[Object])],$e);import{__decorate as ec,__metadata as tc}from"tslib";import{isNull as Us}from"valgen";var bt,Br=(bt=class{constructor(e){e&&Object.assign(this,e)}[y](){return Us}[g](){return Us}},s(bt,"NullType"),bt);Br=ec([m({description:"A Null value",nameMappings:{js:"null",json:"null"}}),tc("design:paramtypes",[Object])],Br);import{__decorate as rc,__metadata as ic}from"tslib";var wt,qr=(wt=class{constructor(e){e&&Object.assign(this,e)}},s(wt,"ObjectType"),wt);qr=rc([Q({name:"object",description:"A non modelled object",additionalFields:!0}),ic("design:paramtypes",[Object])],qr);import{__decorate as zt,__metadata as Jt}from"tslib";import{toString as Cs,vg as $r}from"valgen";var Nt,De=(Nt=class{constructor(e){e&&Object.assign(this,e)}[y](e){let t=[];if(e.pattern){let r=e.patternName;r||(r=Reflect.getMetadata(T,Object.getPrototypeOf(this).constructor).name),t.push($r.matches(e.pattern,{formatName:r}))}return e.minLength&&t.push($r.lengthMin(e.minLength)),e.maxLength&&t.push($r.lengthMax(e.maxLength)),t.length>0?$r.pipe([Cs,...t],{returnIndex:0}):Cs}[g](e){return this[y](e)}},s(Nt,"StringType"),Nt);zt([m.Attribute({description:"Regex pattern to be used for validation"}),Jt("design:type",Object)],De.prototype,"pattern",void 0);zt([m.Attribute({description:"Name of the pattern"}),Jt("design:type",String)],De.prototype,"patternName",void 0);zt([m.Attribute({description:"Minimum number of characters"}),Jt("design:type",Number)],De.prototype,"minLength",void 0);zt([m.Attribute({description:"Minimum number of characters"}),Jt("design:type",Number)],De.prototype,"maxLength",void 0);De=zt([m({description:"A sequence of characters",nameMappings:{js:"string",json:"string"}}),Jt("design:paramtypes",[Object])],De);function c2(i,...e){let t=Array.isArray(e[0])?e[0]:!0,r=Array.isArray(e[0])?e[1]:e[0];return Ne(i,{required:t},r)}s(c2,"RequiredType");D.Entity={};D.Entity.Create=function(i,e){var o;let t;typeof i=="object"&&!i[T]?t=i:t={...e,type:i};let r=[],n=F(r,{method:"POST",...t,composition:"Entity.Create",requestBody:{immediateFetch:!0,...t.requestBody,required:!0}});return n.QueryParam("projection",{description:"Determines fields projection",type:new H({dataType:t.type,allowSigns:"each"}),isArray:!0,arraySeparator:","}).RequestContent(((o=t.requestBody)==null?void 0:o.type)||t.type).Response(N.CREATED,{description:'Operation is successful. Returns OperationResult with "payload" field that contains the created resource.',contentType:L.opra_response_json,type:t.type,partial:"deep"}).Response(N.UNPROCESSABLE_ENTITY,{description:"The request was well-formed but was unable to process operation due to one or many errors.",contentType:L.opra_response_json}),r.push(a=>{let p=a.compositionOptions=a.compositionOptions||{};p.type=Ve(t.type)}),n};D.Entity.Delete=function(i,e){let t;typeof i=="object"&&!i[T]?t=i:t={...e,type:i};let r=[],n=F(r,{method:"DELETE",...t,composition:"Entity.Delete"});return n.Response(N.OK,{description:'Operation is successful. Returns OperationResult with "affected" field.',contentType:L.opra_response_json}).Response(N.UNPROCESSABLE_ENTITY,{description:"The request was well-formed but was unable to process operation due to one or many errors.",contentType:L.opra_response_json}),n.KeyParam=(o,a)=>{let p=typeof a=="string"||typeof a=="function"?{name:o,location:"path",type:a,keyParam:!0}:{...a,name:o,location:"path",keyParam:!0};return n.PathParam(o,p),r.push(c=>{var l;(l=c.path)!=null&&l.includes(":"+o)||(c.path=(c.path||"")+"@:"+o),c.mergePath=!0}),n},r.push(o=>{let a=o.compositionOptions=o.compositionOptions||{};a.type=Ve(t.type)}),n};D.Entity.DeleteMany=function(i,e){let t;typeof i=="object"&&!i[T]?t=i:t={...e,type:i};let r=[],n=new _e,o=new re({dataType:t.type});o.rules={};let a=F(r,{method:"DELETE",...t,composition:"Entity.DeleteMany"});return a.Response(N.OK,{description:'Operation is successful. Returns OperationResult with "affected" field.',contentType:L.opra_response_json}).Response(N.UNPROCESSABLE_ENTITY,{description:"The request was well-formed but was unable to process operation due to one or many errors.",contentType:L.opra_response_json}).QueryParam("filter",{type:o,description:"Determines filter fields"}),r.push(p=>{let c=p.compositionOptions=p.compositionOptions||{};c.type=Ve(t.type)}),a.Filter=(p,c,l)=>(r.push(()=>{n.set(p,{operators:c,description:l}),o.rules=n.toJSON()}),a),a};D.Entity.FindMany=function(i,e){let t;typeof i=="object"&&!i[T]?t=i:t={...e,type:i};let r=[],n=new _e,o=new re({dataType:t.type});o.rules={};let a=F(r,{method:"GET",...t,composition:"Entity.FindMany"});return a.Response(N.OK,{description:'Operation is successful. Returns OperationResult with "payload" field that contains list of resources.',contentType:L.opra_response_json,type:t.type,partial:"deep",isArray:!0}).Response(N.UNPROCESSABLE_ENTITY,{description:"The request was well-formed but was unable to process operation due to one or many errors.",contentType:L.opra_response_json}).QueryParam("limit",{description:"Determines number of returning instances",type:new $e({minValue:1,maxValue:t.maxLimit})}).QueryParam("skip",{description:"Determines number of returning instances",type:new $e({minValue:1})}).QueryParam("count",{description:"Counts all matching instances if enabled",type:Boolean}).QueryParam("projection",{description:"Determines fields projection",type:new H({dataType:t.type,allowSigns:"each"}),isArray:!0,arraySeparator:","}).QueryParam("filter",{type:o,description:"Determines filter fields"}).QueryParam("sort",{description:"Determines sort fields",type:new H({dataType:t.type,allowSigns:"first"}),isArray:!0,arraySeparator:","}),r.push(p=>{let c=p.compositionOptions=p.compositionOptions||{};c.type=Ve(t.type),t.defaultLimit&&(c.defaultLimit=t.defaultLimit),t.defaultProjection&&(c.defaultProjection=t.defaultProjection),t.maxLimit&&(c.maxLimit=t.maxLimit)}),a.DefaultSort=(...p)=>(r.push(c=>{let l=c.compositionOptions=c.compositionOptions||{};l.defaultSort=p}),a),a.SortFields=(...p)=>(r.push(c=>{let l=c.compositionOptions=c.compositionOptions||{};l.sortFields=p}),a),a.Filter=(p,c,l)=>(r.push(()=>{n.set(p,{operators:c,description:l}),o.rules=n.toJSON()}),a),a};D.Entity.Get=function(i,e){let t;typeof i=="object"&&!i[T]?t=i:t={...e,type:i};let r=[],n=F(r,{method:"GET",...t,composition:"Entity.Get"});return n.QueryParam("projection",{description:"Determines fields projection",type:new H({dataType:t.type,allowSigns:"each"}),isArray:!0,arraySeparator:","}).Response(N.OK,{description:'Operation is successful. Returns OperationResult with "payload" field that contains the resource asked for.',contentType:L.opra_response_json,type:t.type,partial:"deep"}).Response(N.NO_CONTENT,{description:"Operation is successful but no resource found"}).Response(N.UNPROCESSABLE_ENTITY,{description:"The request was well-formed but was unable to process operation due to one or many errors.",contentType:L.opra_response_json}),n.KeyParam=(o,a)=>{let p=typeof a=="string"||typeof a=="function"?{name:o,location:"path",type:a,keyParam:!0}:{...a,name:o,location:"path",keyParam:!0};return n.PathParam(o,p),r.push(c=>{var l;(l=c.path)!=null&&l.includes(":"+o)||(c.path=(c.path||"")+"@:"+o),c.mergePath=!0}),n},r.push(o=>{let a=o.compositionOptions=o.compositionOptions||{};a.type=Ve(t.type)}),n};D.Entity.UpdateMany=function(i,e){var p;let t;typeof i=="object"&&!i[T]?t=i:t={...e,type:i};let r=[],n=new re({dataType:t.type});n.rules={};let o=new _e,a=F(r,{method:"PATCH",...t,composition:"Entity.UpdateMany",requestBody:{immediateFetch:!0,partial:"deep",...t.requestBody,required:!0}});return a.RequestContent(((p=t.requestBody)==null?void 0:p.type)||t.type).Response(N.OK,{description:'Operation is successful. Returns OperationResult with "affected" field.',contentType:L.opra_response_json}).Response(N.UNPROCESSABLE_ENTITY,{description:"The request was well-formed but was unable to process operation due to one or many errors.",contentType:L.opra_response_json}).QueryParam("filter",{type:n,description:"Determines filter fields"}),r.push(c=>{let l=c.compositionOptions=c.compositionOptions||{};l.type=Ve(t.type)}),a.Filter=(c,l,_)=>(r.push(()=>{o.set(c,{operators:l,description:_}),n.rules=o.toJSON()}),a),a};D.Entity.Update=function(i,e){var p;let t;typeof i=="object"&&!i[T]?t=i:t={...e,type:i};let r=[],n=new _e,o=new re({dataType:t.type});o.rules={};let a=F(r,{method:"PATCH",...t,composition:"Entity.Update",requestBody:{partial:"deep",immediateFetch:!0,...t.requestBody,required:!0}});return a.QueryParam("projection",{description:"Determines fields projection",type:new H({dataType:t.type,allowSigns:"each"}),isArray:!0,arraySeparator:","}).QueryParam("filter",{type:o,description:"Determines filter fields"}).RequestContent(((p=t.requestBody)==null?void 0:p.type)||t.type).Response(N.OK,{description:'Operation is successful. Returns OperationResult with "payload" field that contains updated resource.',contentType:L.opra_response_json,type:t.type,partial:"deep"}).Response(N.NO_CONTENT,{description:"Operation is successful but no resource found"}).Response(N.UNPROCESSABLE_ENTITY,{description:"The request was well-formed but was unable to process operation due to one or many errors.",contentType:L.opra_response_json}),a.KeyParam=(c,l)=>{let _=typeof l=="string"||typeof l=="function"?{name:c,location:"path",type:l,keyParam:!0}:{...l,name:c,location:"path",keyParam:!0};return a.PathParam(c,_),r.push(u=>{var C;(C=u.path)!=null&&C.includes(":"+c)||(u.path=(u.path||"")+"@:"+c),u.mergePath=!0}),a},r.push(c=>{let l=c.compositionOptions=c.compositionOptions||{};l.type=Ve(t.type)}),a.Filter=(c,l,_)=>(r.push(()=>{n.set(c,{operators:l,description:_}),o.rules=n.toJSON()}),a),a};function Ve(i){if(typeof i=="string")return i;let e=Reflect.getMetadata(T,i);if(!e)throw new TypeError(`Type (${i}) is not decorated with any datatype decorators`);if(e!=null&&e.name)return e.name;throw new TypeError("You should provide named data type but embedded one found")}s(Ve,"getDataTypeName");var nc="https://oprajs.com/spec/v"+h.SpecVersion,Vr=class Vr{constructor(){this._allDocuments={}}static async createDocument(e,t){let r=new Vr,n=t instanceof ne?t:new ne(t);try{let o=new Fe;if(await r.initDocument(o,n,e),n.error.details.length)throw n.error;return o}catch(o){try{o instanceof Qe||n.addError(o)}catch{}if(!n.error.message){let a=n.error.details.length;n.error.message=`(${a}) error${a>1?"s":""} found in document schema.`,n.showErrorDetails&&(n.error.message+=n.error.details.map(p=>`
6
+ var ls=Object.defineProperty;var s=(i,e)=>ls(i,"name",{value:e,configurable:!0});var fs=(i,e)=>{for(var t in e)ls(i,t,{get:e[t],enumerable:!0})};import"reflect-metadata";import _a from"lodash.omit";import oi from"putil-merge";var m={};fs(m,{ComplexType:()=>Ge,EnumType:()=>Ye,HttpController:()=>$t,HttpOperation:()=>ti,MappedType:()=>Qe,MixinType:()=>Xe,RpcController:()=>ri,RpcOperation:()=>ii,SimpleType:()=>Ze,SpecVersion:()=>fa,isComplexType:()=>ma,isDataType:()=>ua,isEnumType:()=>Ta,isHttpController:()=>Ea,isMappedType:()=>ya,isMixinType:()=>ha,isSimpleType:()=>da});var fa="1.0";var Ge;(function(i){i.Kind="ComplexType"})(Ge||(Ge={}));var Ye;(function(i){i.Kind="EnumType"})(Ye||(Ye={}));var Qe;(function(i){i.Kind="MappedType"})(Qe||(Qe={}));var Xe;(function(i){i.Kind="MixinType"})(Xe||(Xe={}));var Ze;(function(i){i.Kind="SimpleType"})(Ze||(Ze={}));var $t;(function(i){i.Kind="HttpController"})($t||($t={}));var ti;(function(i){i.Kind="HttpOperation"})(ti||(ti={}));var ri;(function(i){i.Kind="RpcController"})(ri||(ri={}));var ii;(function(i){i.Kind="RpcOperation"})(ii||(ii={}));function ua(i){return i&&typeof i=="object"&&(i.kind===Ge.Kind||i.kind===Ye.Kind||i.kind===Qe.Kind||i.kind===Ze.Kind||i.kind===Xe.Kind)}s(ua,"isDataType");function ma(i){return i&&typeof i=="object"&&i.kind===Ge.Kind}s(ma,"isComplexType");function da(i){return i&&typeof i=="object"&&i.kind===Ze.Kind}s(da,"isSimpleType");function ha(i){return i&&typeof i=="object"&&i.kind===Xe.Kind}s(ha,"isMixinType");function ya(i){return i&&typeof i=="object"&&i.kind===Qe.Kind}s(ya,"isMappedType");function Ta(i){return i&&typeof i=="object"&&i.kind===Ye.Kind}s(Ta,"isEnumType");function Ea(i){return i&&typeof i=="object"&&i.kind===$t.Kind}s(Ea,"isHttpController");var E=Symbol.for("opra.type.metadata"),V=Symbol("opra.http-controller.metadata"),K=Symbol("opra.rpc-controller.metadata"),T=Symbol.for("opra.type.decoder"),O=Symbol("opra.type.encoder"),A=Symbol.for("DECORATOR"),Le=Symbol.for("BUILTIN"),us=/([a-z$_]\w+):(.+)/i,j=/^[a-z][\w_]*$/i,cr=/^(.*)Type(\d*)$/,F=Symbol.for("kDataTypeMap"),lr=Symbol.for("kCtorMap"),we=Symbol.for("kTypeNSMap");var xa=/^(.*)(Controller)$/,ms=[];function He(i){let e=[],t=s(function(r){var c;let o=i==null?void 0:i.name;o||(o=((c=xa.exec(r.name))==null?void 0:c[1])||r.name);let n={},a=Reflect.getOwnMetadata(K,Object.getPrototypeOf(r));a&&oi(n,a,{deep:!0});let p=Reflect.getOwnMetadata(K,r);p&&oi(n,p,{deep:!0}),oi(n,{kind:m.RpcController.Kind,name:o,path:o,..._a(i,["kind","name","instance","endpoints","key"])},{deep:!0}),Reflect.defineMetadata(K,n,r);for(let l of e)l(n,r);Reflect.defineMetadata(K,n,r)},"decorator");return t.Header=(r,o)=>(e.push(n=>{let a=typeof o=="string"||typeof o=="function"?{name:r,type:o}:{...o,name:r};n.headers=n.headers||[],n.headers.push(a)}),t),t.UseType=(...r)=>(e.push(o=>{o.types=o.types||[],o.types.push(...r)}),t),ms.forEach(r=>r(t,e,i)),t}s(He,"RpcControllerDecoratorFactory");He.augment=function(i){ms.push(i)};import ga from"lodash.omit";var ds=[];function Bt(i,e,t){let r=!1,o=s((n,a)=>{if(typeof a!="string")throw new TypeError("Symbol properties can not be decorated");let p={kind:m.RpcOperation.Kind,channel:a,...ga(t,["kind"]),payloadType:e},c=Reflect.getOwnMetadata(K,n.constructor)||{};c.operations=c.operations||{},c.operations[a]=p;for(let l of i)l(p,n,a);Reflect.defineMetadata(K,c,n.constructor)},"decorator");return o.UseType=(...n)=>(i.push(a=>{a.types=a.types||[],a.types.push(...n)}),o),o.Header=(n,a)=>(i.push(p=>{let c=typeof a=="string"||typeof a=="function"?{name:n,type:a}:{...a,name:n},l=r?p.response:p;l.headers?l.headers=l.headers.filter(x=>String(x.name)!==String(n)):l.headers=[],l.headers.push(c)}),o),o.Response=(n,a)=>(i.push(p=>{r=!0,p.response={...a,payloadType:n}}),o),ds.forEach(n=>n(o,i,e,t)),o}s(Bt,"RpcOperationDecoratorFactory");Bt.augment=function(i){ds.push(i)};BigInt.prototype.toJSON||(BigInt.prototype.toJSON=function(){return this.toString()});RegExp.prototype.toJSON||(RegExp.prototype.toJSON=function(){return this.toString()});import wa from"putil-promisify";function et(i){return typeof i=="function"&&i.prototype&&i.prototype.constructor===i&&i.prototype.constructor.name!=="Function"&&i.prototype.constructor.name!=="embedded"}s(et,"isConstructor");function ni(i){return i!==null&&typeof i=="object"&&typeof i.pipe=="function"}s(ni,"isStream");function kl(i){return ni(i)&&typeof i._read=="function"&&typeof i._readableState=="object"}s(kl,"isReadable");function jl(i){return ni(i)&&typeof i._write=="function"}s(jl,"isWritable");function Cl(i){return ni(i)&&typeof i.getReader=="function"&&typeof i.pipeThrough=="function"&&typeof i.pipeTo=="function"}s(Cl,"isReadableStream");function Ul(i){return i!==null&&typeof i=="object"&&typeof i.size=="number"&&typeof i.arrayBuffer=="function"&&typeof i.stream=="function"}s(Ul,"isBlob");function ql(i){return i!==null&&typeof i.constructor=="function"&&i.constructor.name==="FormData"&&typeof i.append=="function"&&typeof i.getAll=="function"}s(ql,"isFormData");function $l(i){return i!==null&&typeof i=="object"&&typeof i.host=="string"&&typeof i.href=="string"}s($l,"isURL");function Bl(i){return Symbol.iterator in i}s(Bl,"isIterable");function Vl(i){return Symbol.asyncIterator in i}s(Vl,"isAsyncIterable");async function ne(i){return i=wa.isPromise(i)?await i:i,typeof i=="function"?et(i)?i:await i():i}s(ne,"resolveThunk");var hs=/^(?:file:\/\/)?(.+)$/;function Ql(i=1){if(i>=Error.stackTraceLimit)throw new TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+i+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");let e=Error.prepareStackTrace;Error.prepareStackTrace=(r,o)=>o;let t=new Error().stack;if(Error.prepareStackTrace=e,t!==null&&typeof t=="object"){let r=t[i]?t[i].getFileName():void 0,o=r?hs.exec(r):void 0;return o?o[1]:""}return""}s(Ql,"getStackFileName");function Xl(i=1){if(i>=Error.stackTraceLimit)throw new TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+i+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");let e=Error.prepareStackTrace;Error.prepareStackTrace=(r,o)=>o;let t=new Error().stack;if(Error.prepareStackTrace=e,t!==null&&typeof t=="object"){let r=t[i]?t[i].getFileName():void 0,o=r?hs.exec(r):void 0;return o?o[1]:""}return""}s(Xl,"getErrorStack");function fr(i,e,t){for(let r of Object.getOwnPropertyNames(e))r==="constructor"||r==="__proto__"||r==="toJSON"||r==="toString"||t&&!t(r)||Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(e,r)||Object.create(null))}s(fr,"mergePrototype");function ur(i,e,t=r=>!0){try{let r=new e;Object.getOwnPropertyNames(r).filter(n=>typeof r[n]<"u"&&typeof i[n]>"u").filter(n=>t(n)).forEach(n=>{i[n]=r[n]})}catch{}}s(ur,"inheritPropertyInitializers");import si from"putil-isplainobject";import Aa from"putil-merge";function L(i,e){return Aa({},i,{deep:s(t=>si(t)&&!t[E],"deep"),descriptor:!0,filter:s((t,r)=>{let o=t[r];return!e||typeof o!="function"&&(typeof o!="object"||si(o)||Array.isArray(o))},"filter")})}s(L,"cloneObject");function y(i,e){if(!(i&&typeof i=="object"))return i;for(let t of Object.keys(i))i[t]===void 0?delete i[t]:e&&typeof i[t]=="object"&&y(i[t]);return i}s(y,"omitUndefined");function ba(i,e){if(!(i&&typeof i=="object"))return i;for(let t of Object.keys(i))i[t]==null?delete i[t]:e&&si(i[t])&&ba(i[t]);return i}s(ba,"omitNullish");import{splitString as ys}from"fast-tokenizer";var Na=/^([+-])?([a-z_$]\w*)$/i,Da=/[^.]\(/g,ai=class ai{};s(ai,"FieldsProjection");var ve=ai;(function(i){let t=class t{};s(t,"Item");let e=t;i.Item=e})(ve||(ve={}));function Ts(i,e){let t=Array.isArray(i)?i:[i];if(!(t&&t.length))return;let r=new ve;for(let o of t)e||(o=o.toLowerCase()),Es(o,r);return r}s(Ts,"parseFieldsProjection");function Es(i,e){i=i.replace(Da,r=>r.charAt(0)+"."+r.substring(1));let t=ys(i,{delimiters:".",brackets:!0,keepBrackets:!1});for(let r=0;r<t.length;r++){let o=t[r];if(o.includes(",")){let c=ys(o,{delimiters:",",brackets:!0,keepBrackets:!0});for(let l of c)Es(l,e);continue}let n=Na.exec(o);if(!n)throw new TypeError(`Invalid field path (${i})`);let a=n[2],p=e[a]=e[a]||new ve.Item;n[1]&&(p.sign=n[1]),r===t.length-1?delete p.projection:e=p.projection=p.projection||new ve}}s(Es,"parse");function Sa(i){return i&&typeof i.forEach=="function"}s(Sa,"isMap");var J=Symbol.for("kEntries"),se=Symbol.for("kKeyMap"),mr=Symbol.for("kWellKnownKeys"),pi=Symbol.for("kOptions"),tt=Symbol.for("kSize"),ci=class ci{constructor(e,t){Object.defineProperty(this,tt,{value:0,enumerable:!1,writable:!0}),Object.defineProperty(this,J,{value:{},enumerable:!1,writable:!0}),Object.defineProperty(this,se,{value:{},enumerable:!1,writable:!0}),Object.defineProperty(this,mr,{value:{},enumerable:!1,writable:!0});let r=!!(t!=null&&t.caseSensitive);Object.defineProperty(this,pi,{value:{caseSensitive:r},enumerable:!1}),t!=null&&t.wellKnownKeys&&t.wellKnownKeys.forEach(o=>{r?this[mr][o]=o:this[mr][o.toLowerCase()]=o}),this.clear(),e&&this.setAll(e)}get size(){return this[tt]}clear(){Object.keys(this[J]).forEach(e=>delete this[J][e]),Object.keys(this[se]).forEach(e=>delete this[se][e]),this[tt]=0}forEach(e,t){for(let[r,o]of this.entries())e.call(t,o,r,this)}get(e){if(e)return this[J][this._getStoringKey(e)]}has(e){return e?Object.prototype.hasOwnProperty.call(this[J],this._getStoringKey(e)):!1}set(e,t){let r=this._getStoringKey(e);e=this._getOriginalKey(e);let o=Object.prototype.hasOwnProperty.call(this[J],r);return this[J][r]=t,o||this[tt]++,this[se][r]=e,this}setAll(e){return Sa(e)?e.forEach((t,r)=>this.set(r,t)):Object.keys(e).forEach(t=>this.set(t,e[t])),this}keys(){return Object.values(this[se])[Symbol.iterator]()}values(){return Object.values(this[J])[Symbol.iterator]()}entries(){return Object.entries(this[J])[Symbol.iterator]()}delete(e){let t=this._getStoringKey(e),r=Object.prototype.hasOwnProperty.call(this[J],t);return delete this[J][t],delete this[se][t],r||this[tt]--,r}sort(e){let t={...this[J]},r={...this[se]},o=Array.from(this.keys());e?o.sort(e):o.sort(),this.clear();for(let n of o)this[J][n]=t[n],this[se][n]=r[n];return this[tt]=o.length,this}toObject(){let e={};for(let[t,r]of Object.entries(this[se]))e[r]=this[J][t];return e}[Symbol.iterator](){return this.entries()}get[Symbol.toStringTag](){return"[Object ResponsiveMap]"}_getOriginalKey(e){if(!e||this[pi].caseSensitive)return e;let t=this._getStoringKey(e);return this[se][t]??this[mr][t]??e}_getStoringKey(e){return this[pi].caseSensitive?e:e.toLowerCase()}};s(ci,"ResponsiveMap");var N=ci;function mf(i,e,t){let r=new WeakSet;return JSON.stringify(i,(o,n)=>{if(n!==null&&typeof n=="object"){if(r.has(n))return;r.add(n)}return e?e(o,n):n},t)}s(mf,"safeJsonStringify");import La from"@browsery/i18next";import{splitString as va,tokenize as Os}from"fast-tokenizer";var Ia=/\\(.)/g,Ma=/(\\)/g;function _s(i){return i.replace(Ma,"\\\\")}s(_s,"escapeString");function xs(i){return i.replace(Ia,"$1")}s(xs,"unescapeString");var Pa=Object.getPrototypeOf(La.createInstance()).constructor,Vt=class Vt extends Pa{async init(e,t){let r=typeof e=="object"?e:{},o=typeof e=="function"?e:t;try{let n=await super.init(r,o),a=this.services.formatter;if(a.add("lowercase",(p,c)=>p.toLocaleLowerCase(c)),a.add("uppercase",(p,c)=>p.toLocaleUpperCase(c)),a.add("upperFirst",(p,c)=>p.charAt(0).toLocaleUpperCase(c)+p.substring(1)),r!=null&&r.resources)for(let p of Object.keys(r.resources)){let c=r.resources[p];for(let l of Object.keys(c))this.addResourceBundle(p,l,c[l],!1,!0)}return o&&o(null,n),n}catch(n){throw o&&o(n,this.t),n}}deep(e,t){if(e==null)return e;let r=new WeakMap;return this._deepTranslate(e,r,t)}createInstance(e,t){return new Vt(e,t)}static createInstance(e,t){return new Vt(e,t)}_deepTranslate(e,t,r){if(e==null||r!=null&&r.ignore&&r.ignore(e,this))return e;if(typeof e=="object"&&t.has(e))return t.get(e);if(typeof e=="string"){let o="";for(let n of Os(e,{brackets:{"$t(":")"},quotes:!0,keepQuotes:!0,keepBrackets:!0,keepDelimiters:!0})){if(n.startsWith("$t(")&&n.endsWith(")")){n=n.substring(3,n.length-1);let a=va(n,{delimiters:"?",quotes:!0,brackets:{"{":"}"}}),p=xs(n.substring((a[0]||"").length+1));n=a[0]||"";let c=[],l=null;for(let d of Os(n,{delimiters:",",quotes:!0,brackets:{"{":"}"}})){if(d.startsWith("{")){l=JSON.parse(d);continue}c.push(d)}let x=c.length>1?"$t("+c.join(",")+")":c[0];o+=p?this.t(x,p,{...r,...l}):this.t(x,{...r,...l});continue}o+=n}return o}if(Array.isArray(e)){let o=Array(e.length);t.set(e,o);for(let n=0,a=e.length;n<a;n++)o[n]=this._deepTranslate(e[n],t,r);return t.delete(e),o}if(typeof e=="object"){if(Buffer.isBuffer(e)||Buffer.isBuffer(e)||e instanceof Symbol||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof WeakMap||e instanceof WeakSet)return e;let o={};t.set(e,o);let n=Object.keys(e);for(let a=0,p=n.length;a<p;a++){let c=n[a];o[c]=this._deepTranslate(e[c],t,r)}return t.delete(e),o}return e}static get defaultInstance(){return Fa}};s(Vt,"I18n");var Kt=Vt,Fa=Kt.createInstance();var ka=/(\))/g;function w(i,e,t){let r=e&&typeof e=="object"?e:void 0,o=typeof e=="string"?e:t;return"$t("+i+(r?","+JSON.stringify(r):"")+(o?"?"+_s(o).replace(ka,"\\$1"):"")+")"}s(w,"translate");var li=Kt.createInstance();li.init().catch(()=>{});var fi=class fi extends Error{constructor(e,t){super("Unknown error"),this.severity="error",t=t||(e instanceof Error?e:void 0),e instanceof Error&&(t=e),t&&t instanceof Error&&(this.cause=t,t.stack&&(this.stack=t.stack)),typeof e=="string"?this.initString(e):e instanceof Error?this.initError(e):this.init(e),this.message=this.message||this.constructor.name}toString(){return li.deep(this.message)}toJSON(){var t;let e="production";return y({message:this.message,severity:this.severity,system:this.system,code:this.code,details:this.details,stack:e==="dev"||e==="development"||e==="test"?(t=this.stack)==null?void 0:t.split(`
7
+ `):void 0},!0)}init(e){this.message=(e==null?void 0:e.message)||this.constructor.name,this.severity=(e==null?void 0:e.severity)||"error",e&&(this.system=e.system,this.code=e.code,this.details=e.details)}initString(e){this.init({message:String(e||"")||this.constructor.name,severity:"error",code:this.constructor.name})}initError(e){this.init({message:e.message,severity:e.severity||"error",code:e.code||e.constructor.name})}};s(fi,"OpraException");var ye=fi;var ui=class ui extends ye{constructor(){super(""),this.details=[]}add(e){return this.details.push(e),this}};s(ui,"OpraDocumentError");var rt=ui;var mi=class mi{constructor(e){this.path="",this.error=new rt,this.showErrorDetails=!0,this.maxErrors=(e==null?void 0:e.maxErrors)||0,this.error.message=""}addError(e){if(!this.error.details.length)if(e instanceof Error)this.error.stack=e.stack;else{let t=new Error;Error.captureStackTrace(t,this.addError),this.error.stack=t.stack}if(this.error.add({message:typeof e=="string"?e:e.message,path:this.path,...typeof e=="object"?e:void 0}),this.error.details.length>=this.maxErrors)throw this.error}enter(e,t){let r=this.path;this.path=this.path+e;try{return t()}catch(o){o!==this.error&&this.addError(o)}finally{this.path=r}}async enterAsync(e,t){let r=this.path;this.path=this.path+e;try{return await t()}catch(o){o!==this.error&&this.addError(o)}finally{this.path=r}}extend(e){let t={...e};return Object.setPrototypeOf(t,this),t}};s(mi,"DocumentInitContext");var ae=mi;import"reflect-metadata";import{asMutable as za}from"ts-gems";import ja from"lodash.omit";function di(i){return function(e){var o;let t;if(!(i!=null&&i.embedded))if(i!=null&&i.name){if(!j.test(i.name))throw new TypeError(`"${i.name}" is not a valid type name`);t=i.name}else t=((o=e.name.match(cr))==null?void 0:o[1])||e.name;let r=Reflect.getOwnMetadata(E,e);r||(r={},Reflect.defineMetadata(E,r,e)),r.kind=m.ComplexType.Kind,r.name=t,i&&Object.assign(r,ja(i,["kind","name","base","fields"]))}}s(di,"ComplexTypeDecorator");import{asMutable as Ka}from"ts-gems";import{asMutable as Ca}from"ts-gems";import{uid as Ua}from"uid";var hi=class hi{constructor(e,t){this.element=e,this.parent=t}getDocument(){if(this._document)return this._document;if(this.element[we])return this.element;if(this.parent)return this._document=this.parent.getDocument();throw new Error("ApiDocument not found in document tree")}hasDataType(e){var r;let t=(r=this[F])==null?void 0:r.has(e);return t||(this.parent?this.parent.hasDataType(e):!1)}findDataType(e){var r;let t=(r=this[F])==null?void 0:r.get(e);return t||(this.parent?this.parent.findDataType(e):void 0)}getDataType(e){let t=this.findDataType(e);if(t)return t;let r="";if(typeof e=="function")r=Reflect.getMetadata(E,e).name;else if(typeof e=="object"){let o=e[E];r=o==null?void 0:o.name}throw r||(e&&typeof e=="string"?r=e:typeof e=="function"&&(r=e.name)),new TypeError("Unknown data type"+(r?" ("+r+")":""))}getDataTypeNameWithNs(e){if(!e.name)return;let t=this.getDocument().getDataTypeNs(e);return t?t+":"+e.name:e.name}getComplexType(e){let t=this.getDataType(e);if(t.kind===m.ComplexType.Kind)return t;throw new TypeError(`Data type "${t.name}" is not a ComplexType`)}getSimpleType(e){let t=this.getDataType(e);if(t.kind===m.SimpleType.Kind)return t;throw new TypeError(`Data type "${t.name||t}" is not a SimpleType`)}getEnumType(e){let t=this.getDataType(e);if(t.kind===m.EnumType.Kind)return t;throw new TypeError(`Data type "${t.name||t}" is not a EnumType`)}getMappedType(e){let t=this.getDataType(e);if(t.kind===m.MappedType.Kind)return t;throw new TypeError(`Data type "${t.name||t}" is not a MappedType`)}getMixinType(e){let t=this.getDataType(e);if(t.kind===m.MixinType.Kind)return t;throw new TypeError(`Data type "${t.name||t}" is not a MixinType`)}};s(hi,"DocumentNode");var dr=hi;var R=s(function(i){if(!this)throw new TypeError('"this" should be passed to call class constructor');let e=Ca(this);e.id=Ua(16),Object.defineProperty(e,"node",{value:new dr(this,i==null?void 0:i.node),enumerable:!1,writable:!0}),i&&Object.defineProperty(e,"owner",{value:i,enumerable:!1,writable:!0})},"DocumentElement"),Ti=class Ti{};s(Ti,"DocumentElementClass");var yi=Ti;R.prototype=yi.prototype;function Ei(i){return function(e,t){if(typeof t!="string")throw new TypeError("Symbol properties can't be used as a field");let r=Reflect.getOwnMetadata(E,e.constructor)||{};r.kind=m.ComplexType.Kind,r.fields=r.fields||{};let o=Reflect.getMetadata("design:type",e,t),n=r.fields[t]={...i};o===Array?n.isArray=!0:n.type=n.type||o,Reflect.defineMetadata(E,r,e.constructor)}}s(Ei,"ApiFieldDecorator");import{asMutable as $a}from"ts-gems";import{validator as Ba,vg as Fe}from"valgen";import{asMutable as qa}from"ts-gems";var it=Symbol.for("nodejs.util.inspect.custom"),Pe="\x1B[0m",ot="\x1B[33m",nt="\x1B[35m";var g=s(function(i,e,t){if(!this)throw new TypeError('"this" should be passed to call class constructor');if(e!=null&&e.name&&!j.test(e.name))throw new TypeError(`"${e.name}" is not a valid DataType name`);R.call(this,i);let r=qa(this);r.kind=e.kind,r.name=e.name,r.description=e.description,r.abstract=e.abstract,r.examples=e.examples},"DataType"),xi=class xi extends R{get embedded(){return!this.name}toJSON(){return y({kind:this.kind,description:this.description,abstract:this.abstract,examples:this.examples})}toString(){return`[${Object.getPrototypeOf(this).constructor.name} ${this.name||"#Embedded"}]`}[it](){return`[${ot+Object.getPrototypeOf(this).constructor.name+Pe} ${nt+this.name+Pe}]`}};s(xi,"DataTypeClass");var _i=xi;g.prototype=_i.prototype;var Va=/^([+-])?([a-z$_][\w.]*)$/i,D=s(function(...i){if(!this)throw new TypeError('"this" should be passed to call class constructor');let[e,t,r]=i;g.call(this,e,t,r);let o=$a(this);o.fields=new N},"ComplexTypeBase"),gi=class gi extends g{findField(e){if(e.includes(".")){let r=this.parseFieldPath(e).pop();return r==null?void 0:r.field}return this.fields.get(e)}getField(e){let t=this.findField(e);if(!t)throw new Error(w("error:UNKNOWN_FIELD",{field:e}));return t}parseFieldPath(e,t){var d,B,cs;let r=this,o,n=e.split("."),a=n.length,p=[],c=this.owner.node.getDataType("object"),l=t==null?void 0:t.allowSigns,x=s(()=>p.map(Me=>Me.fieldName).join("."),"getStrPath");for(let Me=0;Me<a;Me++){let Y={fieldName:n[Me],dataType:c};p.push(Y);let pr=Va.exec(n[Me]);if(!pr)throw new TypeError(`Invalid field name (${x()})`);if(pr[1]&&((Me===0&&l==="first"||l==="each")&&(Y.sign=pr[1]),Y.fieldName=pr[2]),r){if(r instanceof D){if(o=r.fields.get(Y.fieldName),o){Y.fieldName=o.name,Y.field=o,Y.dataType=o.type,r=o.type;continue}if(((d=r.additionalFields)==null?void 0:d[0])===!0){Y.additionalField=!0,Y.dataType=c,r=void 0;continue}if(((B=r.additionalFields)==null?void 0:B[0])==="type"&&((cs=r.additionalFields)==null?void 0:cs[1])instanceof g){Y.additionalField=!0,Y.dataType=r.additionalFields[1],r=r.additionalFields[1];continue}throw new Error(`Unknown field (${p.map(ei=>ei.fieldName).join(".")})`)}throw new TypeError(`"${p.map(ei=>ei.fieldName).join(".")}" field is not a complex type and has no child fields`)}Y.additionalField=!0,Y.dataType=c}return p}normalizeFieldPath(e,t){return this.parseFieldPath(e,t).map(r=>(r.sign||"")+r.fieldName).join(".")}generateCodec(e,t){let r=Array.isArray(t==null?void 0:t.projection)?Ts(t.projection):t==null?void 0:t.projection,o=this._generateSchema(e,{...t,projection:r,currentPath:""}),n;if(this.additionalFields instanceof g)n=this.additionalFields.generateCodec(e,t);else if(typeof this.additionalFields=="boolean")n=this.additionalFields;else if(Array.isArray(this.additionalFields))if(this.additionalFields.length<2)n="error";else{let a=n[1];n=Ba((p,c,l)=>c.fail(l,a,p))}return Fe.isObject(o,{ctor:this.name==="object"?Object:this.ctor,additionalFields:n,name:this.name,coerce:!0,caseInSensitive:t==null?void 0:t.caseInSensitive,onFail:t==null?void 0:t.onFail})}_generateSchema(e,t){var c;let r={},{currentPath:o,projection:n}=t,a=!!(n&&Object.values(n).find(l=>!l.sign)),p;for(let l of this.fields.values()){if(t.ignoreReadonlyFields&&l.readonly||t.ignoreWriteonlyFields&&l.writeonly||t.ignoreHiddenFields&&l.hidden){r[l.name]=Fe.isUndefined({coerce:!0});continue}p=l.name;let x;if(n!=="*"&&(x=n==null?void 0:n[p.toLowerCase()],(x==null?void 0:x.sign)==="-"||a&&!x||!a&&l.exclusive&&!x)){r[l.name]=Fe.isUndefined({coerce:!0});continue}let d=this._generateFieldCodec(e,l,{...t,partial:t.partial==="deep"?t.partial:void 0,projection:typeof n=="object"?((c=n[p])==null?void 0:c.projection)||"*":n,currentPath:o+(o?".":"")+p});r[p]=t.partial||!l.required?Fe.optional(d):Fe.required(d)}return r}_generateFieldCodec(e,t,r){let o=t.type.generateCodec(e,r);return t.fixed&&(o=Fe.isEnum([t.fixed])),t.isArray&&(o=Fe.isArray(o)),o}};s(gi,"ComplexTypeBaseClass");var Oi=gi;D.prototype=Oi.prototype;var P=s(function(...i){if(!this){let[n]=i;return P[A](n)}let[e,t]=i;R.call(this,e);let r=Ka(this);r.name=t.name;let o=t.origin||e;if(!(o instanceof D))throw new Error("Field origin should be one of ComplexType, MappedType or MixinType");r.origin=o,r.type=t.type||e.node.getDataType("any"),r.description=t.description,r.isArray=t.isArray,r.default=t.default,r.fixed=t.fixed,r.required=t.required,r.exclusive=t.exclusive,r.translatable=t.translatable,r.deprecated=t.deprecated,r.readonly=t.readonly,r.writeonly=t.writeonly,r.examples=t.examples,r.hidden=t.hidden},"ApiField"),wi=class wi extends R{toJSON(){var t;let e=this.type?this.node.getDataTypeNameWithNs(this.type):void 0;return y({type:e||((t=this.type)==null?void 0:t.toJSON()),description:this.description,isArray:this.isArray||void 0,default:this.default,fixed:this.fixed,required:this.required||void 0,exclusive:this.exclusive||void 0,translatable:this.translatable||void 0,deprecated:this.deprecated||void 0,readonly:this.readonly||void 0,writeonly:this.writeonly||void 0,examples:this.examples})}};s(wi,"ApiFieldClass");var Ri=wi;P.prototype=Ri.prototype;Object.assign(P,Ei);P[A]=Ei;var H=s(function(...i){var n;if(!this)return H[A].apply(void 0,i);let[e,t]=i,r=i[2]||new ae({maxErrors:0});D.call(this,e,t,r);let o=za(this);o.kind=m.ComplexType.Kind,o.additionalFields=t.additionalFields,o.keyField=t.keyField,t.base&&r.enter(".base",()=>{if(!(t.base instanceof D))throw new TypeError(`"${t.base.kind}" can't be set as base for a "${this.kind}"`);o.base=t.base,o.additionalFields==null&&o.base.additionalFields&&(o.additionalFields=o.base.additionalFields);for(let a of o.base.fields.values())this.fields.set(a.name,new P(this,a))}),o.ctor=t.ctor||((n=o.base)==null?void 0:n.ctor),t.fields&&r.enter(".fields",()=>{for(let[a,p]of Object.entries(t.fields)){let c=new P(this,{...p,name:a});this.fields.set(c.name,c)}})},"ComplexType"),bi=class bi extends D{extendsFrom(e){var t;return e instanceof g||(e=this.node.getDataType(e)),e instanceof D?e===this?!0:!!((t=this.base)!=null&&t.extendsFrom(e)):!1}toJSON(){let e=this.base?this.node.getDataTypeNameWithNs(this.base):void 0,t=y({...D.prototype.toJSON.call(this),kind:this.kind,base:this.base?e||this.base.toJSON():void 0});if(this.additionalFields)if(this.additionalFields instanceof g){let r=this.node.getDataTypeNameWithNs(this.additionalFields);t.additionalFields=r||this.additionalFields.toJSON()}else t.additionalFields=this.additionalFields;if(this.fields.size){let r={},o=0;for(let n of this.fields.values())n.origin===this&&(r[n.name]=n.toJSON(),o++);o&&(t.fields=r)}return y(t)}};s(bi,"ComplexTypeClass");var Ai=bi;H.prototype=Ai.prototype;Object.assign(H,di);H[A]=di;import"reflect-metadata";import{asMutable as Ja}from"ts-gems";import{vg as Wa}from"valgen";var pe=s(function(...i){if(!this)return pe[A].apply(void 0,i);let[e,t,r]=i;g.call(this,e,t,r);let o=Ja(this);if(o.kind=m.EnumType.Kind,t.base){if(!(t.base instanceof pe))throw new TypeError(`"${t.base.kind}" can't be set as base for a "${o.kind}"`);o.base=t.base}o.instance=t.instance,o.ownAttributes=L(t.attributes||{}),o.attributes=o.base?L(o.base.attributes):{};for(let[n,a]of Object.entries(o.ownAttributes))o.attributes[n]=a},"EnumType"),Ni=class Ni extends g{extendsFrom(e){var t;return e instanceof g||(e=this.node.getDataType(e)),e instanceof pe?e===this?!0:!!((t=this.base)!=null&&t.extendsFrom(e)):!1}generateCodec(){return Wa.isEnum(Object.keys(this.attributes))}toJSON(){let e=this.base?this.node.getDataTypeNameWithNs(this.base):void 0;return y({...g.prototype.toJSON.call(this),base:this.base?e||this.base.toJSON():void 0,attributes:L(this.ownAttributes)})}};s(Ni,"EnumTypeClass");var zt=Ni;pe.prototype=zt.prototype;Object.assign(pe,zt);function Ga(i,...e){let t=e.length>=2?e[0]:void 0,r=e.length>=2?e[1]:e[0],o={},n=i;if(Array.isArray(i)){if(t){if(!Array.isArray(t))throw new TypeError('Both "target" and "base" arguments should be array');n=[...t,...i]}o={},i.forEach(p=>{var l;let c=(l=r==null?void 0:r.meanings)==null?void 0:l[p];o[p]=y({description:c})})}else{if(t){if(Array.isArray(t))throw new TypeError('Both "target" and "base" arguments should be enum object');n={...t,...i}}Object.keys(i).forEach(p=>{var l;let c=(l=r==null?void 0:r.meanings)==null?void 0:l[p];o[i[p]]=y({alias:p,description:c})})}let a={kind:m.EnumType.Kind,attributes:o,base:r.base,name:r.name,description:r==null?void 0:r.description};return Object.defineProperty(i,E,{value:a,enumerable:!1,configurable:!0,writable:!0}),n}s(Ga,"EnumTypeFactory");pe.prototype=zt.prototype;pe[A]=Ga;import"reflect-metadata";import{asMutable as Ya}from"ts-gems";function hr(i,e){let t=i==null?void 0:i.map(o=>String(o).toLowerCase()),r=e==null?void 0:e.map(o=>String(o).toLowerCase());return o=>r&&r.includes(o.toLowerCase())?!1:t?t.includes(o.toLowerCase()):!0}s(hr,"getIsInheritedPredicateFn");var ke=s(function(...i){var n;if(!this)throw new TypeError('"this" should be passed to call class constructor');let[e,t,r]=i;D.call(this,e,t,r);let o=Ya(this);if(o.kind=m.MappedType.Kind,t.base){if(!(t.base instanceof D))throw new TypeError(`"${t.base.kind}" can't be set as base for a "${this.kind}"`);o.base=t.base,o.ctor=t.ctor||o.base.ctor,t.pick?o.pick=t.pick.map(l=>o.base.normalizeFieldPath(l)):t.omit?o.omit=t.omit.map(l=>o.base.normalizeFieldPath(l)):t.partial?o.partial=Array.isArray(t.partial)?t.partial.map(l=>o.base.normalizeFieldPath(l)):t.partial:t.required&&(o.required=Array.isArray(t.required)?t.required.map(l=>o.base.normalizeFieldPath(l)):t.required);let a=hr(o.pick,o.omit),p=Array.isArray(o.partial)?o.partial.map(l=>l.toLowerCase()):o.partial,c=Array.isArray(o.required)?o.required.map(l=>l.toLowerCase()):o.required;for(let[l,x]of o.base.fields.entries()){if(!a(l))continue;let d={...x};p===!0||Array.isArray(p)&&p.includes(x.name.toLowerCase())?d.required=!1:(c===!0||Array.isArray(c)&&c.includes(x.name.toLowerCase()))&&(d.required=!0);let B=new P(this,d);o.fields.set(B.name,B)}(!o.pick||o.base.additionalFields===!1||Array.isArray(o.base.additionalFields)&&((n=o.base.additionalFields)==null?void 0:n[0])==="error")&&(o.additionalFields=o.base.additionalFields),t.base.keyField&&a(t.base.keyField)&&(o.keyField=t.base.keyField)}},"MappedType"),Si=class Si extends D{extendsFrom(e){var t;return e instanceof g||(e=this.node.getDataType(e)),e instanceof D?e===this?!0:!!((t=this.base)!=null&&t.extendsFrom(e)):!1}toJSON(){let e=this.base?this.node.getDataTypeNameWithNs(this.base):void 0;return y({...D.prototype.toJSON.call(this),base:e||this.base.toJSON(),kind:this.kind,pick:this.pick,omit:this.omit,partial:this.partial,required:this.required})}};s(Si,"MappedTypeClass");var Di=Si;ke.prototype=Di.prototype;ke._applyMixin=()=>{};import"reflect-metadata";import{asMutable as Qa}from"ts-gems";var st=s(function(...i){if(!this)return st[A].apply(void 0,i);let[e,t,r]=i;D.call(this,e,t,r);let o=Qa(this);o.kind=m.MixinType.Kind,o.types=[];for(let n of t.types){o.additionalFields!==!0&&(n.additionalFields===!0?o.additionalFields=!0:o.additionalFields||(o.additionalFields=n.additionalFields));for(let a of n.fields.values()){let p=new P(this,a);o.fields.set(p.name,p)}o.types.push(n),n.keyField&&(o.keyField=n.keyField)}},"MixinType"),Mi=class Mi extends D{extendsFrom(e){if(e instanceof g||(e=this.node.getDataType(e)),!(e instanceof D))return!1;if(e===this)return!0;for(let t of this.types)if(t.extendsFrom(e))return!0;return!1}toJSON(){return y({...D.prototype.toJSON.call(this),kind:this.kind,types:this.types.map(e=>{let t=this.node.getDataTypeNameWithNs(e);return t||e.toJSON()})})}};s(Mi,"MixinTypeClass");var Ii=Mi;st.prototype=Ii.prototype;st[A]=Xa;function Xa(...i){let e=i.filter(a=>typeof a=="function"),t=typeof i[i.length-1]=="object"?i[i.length-1]:void 0;if(!e.length)throw new TypeError("No Class has been provided");if(e.length===1)return e[0];let r=e[0].name+"Mixin",o={[r]:class{constructor(){for(let a of e)ur(this,a)}}}[r],n={...t,kind:m.MixinType.Kind,types:[]};Reflect.defineMetadata(E,n,o);for(let a of e){let p=Reflect.getMetadata(E,a);if(!(p&&(p.kind===m.ComplexType.Kind||p.kind===m.MixinType.Kind||p.kind===m.MappedType.Kind)))throw new TypeError(`Class "${a.name}" is not a ${m.ComplexType.Kind}, ${m.MixinType.Kind} or ${m.MappedType.Kind}`);n.types.push(a),fr(o.prototype,a.prototype)}return o}s(Xa,"MixinTypeFactory");import"reflect-metadata";import{asMutable as Ha}from"ts-gems";import{isAny as Rs}from"valgen";import Za from"lodash.omit";function Li(i){let e=[],t=s(function(r){var a;let o;if(!(i!=null&&i.embedded))if(i!=null&&i.name){if(!j.test(i.name))throw new TypeError(`"${i.name}" is not a valid type name`);o=i.name}else o=((a=r.name.match(cr))==null?void 0:a[1])||r.name,o=o.toLowerCase();let n=Reflect.getOwnMetadata(E,r)||{};n.kind=m.SimpleType.Kind,n.name=o,i&&Object.assign(n,Za(i,["kind","name"])),Reflect.defineMetadata(E,n,r)},"decorator");return t.Example=(r,o)=>(e.push(n=>{n.examples=n.examples||[],n.examples.push({description:o,value:r})}),t),t}s(Li,"SimpleTypeDecoratorFactory");function gs(i){return(e,t)=>{if(typeof t!="string")throw new TypeError("Symbol properties can't be decorated with Attribute");let r=Reflect.getOwnMetadata(E,e.constructor)||{},o=Reflect.getMetadata("design:type",e,t),n="string";o===Boolean?n="boolean":o===Number&&(n="number"),r.kind=m.SimpleType.Kind,r.attributes=r.attributes||{},r.attributes[t]={format:(i==null?void 0:i.format)||n,description:i==null?void 0:i.description,deprecated:i==null?void 0:i.deprecated},Reflect.defineMetadata(E,r,e.constructor)}}s(gs,"AttributeDecoratorFactory");var u=s(function(...i){var n,a;if(!this)return u[A](...i);let[e,t,r]=i;g.call(this,e,t,r);let o=Ha(this);if(o.kind=m.SimpleType.Kind,t.base){if(!(t.base instanceof u))throw new TypeError(`"${t.base.kind}" can't be set as base for a "${this.kind}"`);o.base=t.base}if(o.properties=t.properties,o.ownNameMappings={...t.nameMappings},o.nameMappings={...(n=o.base)==null?void 0:n.nameMappings,...t.nameMappings},o.ownAttributes=L(t.attributes||{}),o.attributes=o.base?L(o.base.attributes):{},o.ownAttributes)for(let[p,c]of Object.entries(o.ownAttributes)){if((a=o.attributes[p])!=null&&a.sealed)throw new TypeError(`Sealed attribute "${p}" can not be overwritten`);o.attributes[p]=c}o._generateDecoder=t.generateDecoder,o._generateEncoder=t.generateEncoder},"SimpleType"),Pi=class Pi extends g{extendsFrom(e){var t;return e instanceof g||(e=this.node.getDataType(e)),e instanceof u?e===this?!0:!!((t=this.base)!=null&&t.extendsFrom(e)):!1}generateCodec(e,t,r){let o={...this.properties,...r};if(e==="decode"){let a=this;for(;a;){if(a._generateDecoder)return a._generateDecoder(o,(t==null?void 0:t.documentElement)||this.owner);a=this.base}return Rs}let n=this;for(;n;){if(n._generateEncoder)return n._generateEncoder(o,(t==null?void 0:t.documentElement)||this.owner);n=this.base}return Rs}toJSON(){let e=y(this.ownAttributes),t;this.properties&&typeof this.properties.toJSON=="function"?t=this.properties.toJSON(this.properties,this.owner):t=this.properties?L(this.properties):{};let r=this.base?this.node.getDataTypeNameWithNs(this.base):void 0,o=y({...g.prototype.toJSON.apply(this),base:this.base?r||this.base.toJSON():void 0,attributes:e&&Object.keys(e).length?e:void 0,properties:Object.keys(t).length?t:void 0});return Object.keys(this.ownNameMappings).length&&(o.nameMappings={...this.ownNameMappings}),o}};s(Pi,"SimpleTypeClass");var vi=Pi;u.prototype=vi.prototype;Object.assign(u,Li);u[A]=Li;u.Attribute=gs;var Fi=Symbol("initializing"),yr=class yr{static async createDataType(e,t,r){e=e||new ae({maxErrors:0});let o=await this._importDataTypeArgs(e,t,r);if(o)return typeof o=="string"?t.node.getDataType(o):this._createDataType(e,t,o)}static async resolveDataType(e,t,r){if(r){let o=t.node.findDataType(r);if(o)return o}if(typeof r=="object"||typeof r=="function"){let o=await yr.createDataType(e,t,r);if(o)return o}if(r){let o=t.node.getDataType(r);if(o)return o}return t.node.getDataType("any")}static async addDataTypes(e,t,r){let o=t.node[F];if(!o)throw new TypeError("DocumentElement should has [kDataTypeMap] property");let n=await this.createAllDataTypes(e,t,r);if(n)for(let a of n)a!=null&&a.name&&o.set(a.name,a)}static async createAllDataTypes(e,t,r){e=e||new ae({maxErrors:0});let o=await this._prepareAllInitArgs(e,t,r);if(!o)return;let n=new N;for(let c of o)n.set(c.name,c);let a=e.extend({initArgsMap:n}),p=[];for(let[c,l]of n.entries())e.enter(`[${c}]`,()=>{if(!n.has(c))return;let x=this._createDataType(a,t,l);x&&p.push(x)});return p}static async _prepareAllInitArgs(e,t,r){let o=new N,n=new N,a=e.extend({owner:t,importQueue:o,initArgsMap:n});if(!t.node[F])throw new TypeError("DocumentElement should has [kDataTypeMap] property");if(Array.isArray(r)){let p=0;for(let c of r)await a.enterAsync(`$[${p++}]`,async()=>{c=await ne(c);let l=Reflect.getMetadata(E,c)||c[E];if(!(l&&l.name))return typeof c=="function"?a.addError(`Class "${c.name}" doesn't have a valid data type metadata`):a.addError("Object doesn't have a valid data type metadata");o.set(l.name,c)})}else{let p,c;for([c,p]of Object.entries(r))p=await ne(p),o.set(c,typeof p=="object"?{...p,name:c}:p)}for(let p of Array.from(o.keys())){if(!o.has(p))continue;let c=await this._importDataTypeArgs(a,t,p);c&&typeof c!="string"&&a.addError("Embedded data type can't be loaded into document node directly")}return Array.from(n.values())}static async _importDataTypeArgs(e,t,r){var x;r=await ne(r);let{importQueue:o,initArgsMap:n}=e,a=t.node.findDataType(r);if(a instanceof g)return a.name;let p,c,l;if(typeof r!="string"){let B=t.node.getDocument().types[lr].get(r);B&&(r=B)}if(typeof r=="string"){let d=r;if(r=(o==null?void 0:o.get(d))||((x=e.initArgsMap)==null?void 0:x.get(d)),!r)return e.addError(`Unknown data type (${d})`)}if(typeof r=="function"){if(p=Reflect.getMetadata(E,r),!p)return e.addError(`Class "${r.name}" doesn't have a valid DataType metadata`);c=r}else if(typeof r=="object"){if(p=r[E],p)l=r,p.kind!==m.EnumType.Kind&&(p=void 0);else if(m.isDataType(r))p=r,c=p.ctor;else if(c=Object.getPrototypeOf(r).constructor,p=c&&Reflect.getMetadata(E,c),p&&p.kind===m.SimpleType.Kind){let d=await this._importDataTypeArgs(e,t,p.name);return d?typeof d=="object"&&d.kind!==m.SimpleType.Kind?e.addError("Kind of base data type is not same"):{kind:m.SimpleType.Kind,name:void 0,base:d,properties:r}:void 0}}return p?e.enterAsync(p.name?`[${p.name}]`:"",async()=>{if(p.name){let B=n==null?void 0:n.get(p.name);if(B)return B[Fi]?e.addError("Circular reference detected"):p.name}let d={kind:p.kind,name:p.name};d[Fi]=!0;try{if(d.name)if(o!=null&&o.has(d.name))n==null||n.set(p.name,d),d._instance={name:p.name},d[F]=t.node[F];else return e.addError(`Data Type (${d.name}) must be explicitly added to type list in the document scope`);switch(d.kind){case m.ComplexType.Kind:d.ctor=c,await this._prepareComplexTypeArgs(e,t,d,p);break;case m.EnumType.Kind:d.instance=l,await this._prepareEnumTypeArgs(e,t,d,p);break;case m.MappedType.Kind:await this._prepareMappedTypeArgs(e,t,d,p);break;case m.MixinType.Kind:await this._prepareMixinTypeArgs(e,t,d,p);break;case m.SimpleType.Kind:d.ctor=c,await this._prepareSimpleTypeArgs(e,t,d,p);break;default:return e.addError(`Invalid data type kind ${p.kind}`)}}finally{d.name&&(o==null||o.delete(d.name)),delete d[Fi]}return o&&d.name?d.name:d}):e.addError("No DataType metadata found")}static async _prepareDataTypeArgs(e,t,r){t.description=r.description,t.abstract=r.abstract,t.examples=r.examples}static async _prepareComplexTypeArgs(e,t,r,o){await this._prepareDataTypeArgs(e,r,o),await e.enterAsync(".base",async()=>{let n;if(o.base)n=await this._importDataTypeArgs(e,t,o.base);else if(r.ctor){let a=Object.getPrototypeOf(r.ctor.prototype).constructor;Reflect.hasMetadata(E,a)&&(n=await this._importDataTypeArgs(e,t,a))}n&&(r.base=je(n),r.ctor=r.ctor||n.ctor)}),o.additionalFields!=null&&(typeof o.additionalFields=="boolean"||Array.isArray(o.additionalFields)?r.additionalFields=o.additionalFields:await e.enterAsync(".additionalFields",async()=>{let n=await this._importDataTypeArgs(e,t,o.additionalFields);n&&(r.additionalFields=je(n))})),o.fields&&(r.fields={},await e.enterAsync(".fields",async()=>{for(let[n,a]of Object.entries(o.fields))await e.enterAsync(`[${n}]`,async()=>{let p=typeof a=="string"?{type:a}:a;if(p.isArray&&!p.type)return e.addError('"type" must be defined explicitly for array fields');let c=await this._importDataTypeArgs(e,t,p.type||"any");c&&(r.fields[n]={...p,type:je(c)})})}))}static async _prepareEnumTypeArgs(e,t,r,o){await this._prepareDataTypeArgs(e,r,o),o.base&&await e.enterAsync(".base",async()=>{let n=await this._importDataTypeArgs(e,t,o.base);n&&(r.base=je(n))}),r.attributes=L(o.attributes)}static async _prepareSimpleTypeArgs(e,t,r,o){var n,a,p,c;await this._prepareDataTypeArgs(e,r,o),await e.enterAsync(".base",async()=>{let l;if(o.base)l=await this._importDataTypeArgs(e,t,o.base);else if(r.ctor){let x=Object.getPrototypeOf(r.ctor.prototype).constructor;Reflect.hasMetadata(E,x)&&(l=await this._importDataTypeArgs(e,t,x))}l&&(r.base=je(l),r.ctor=r.ctor||l.ctor)}),r.properties=o.properties,r.nameMappings=o.nameMappings,!r.properties&&r.ctor&&(r.properties=new r.ctor),o.attributes&&(r.attributes=L(o.attributes)),typeof((n=r.properties)==null?void 0:n[T])=="function"&&(r.generateDecoder=(a=r.properties)==null?void 0:a[T].bind(r.properties)),typeof((p=r.properties)==null?void 0:p[O])=="function"&&(r.generateEncoder=(c=r.properties)==null?void 0:c[O].bind(r.properties))}static async _prepareMappedTypeArgs(e,t,r,o){await this._prepareDataTypeArgs(e,r,o),await e.enterAsync(".base",async()=>{let n;if(o.base)n=await this._importDataTypeArgs(e,t,o.base);else if(r.ctor){let a=Object.getPrototypeOf(r.ctor.prototype).constructor;Reflect.hasMetadata(E,a)&&(n=await this._importDataTypeArgs(e,t,a))}n&&(r.base=je(n),r.ctor=r.ctor||n.ctor)}),o.pick?r.pick=[...o.pick]:o.omit?r.omit=[...o.omit]:o.partial?r.partial=Array.isArray(o.partial)?[...o.partial]:o.partial:o.required&&(r.required=Array.isArray(o.required)?[...o.required]:o.required)}static async _prepareMixinTypeArgs(e,t,r,o){await this._prepareDataTypeArgs(e,r,o),r.types=[],await e.enterAsync(".types",async()=>{let n=o.types,a=0;for(let p of n)await e.enterAsync(`[${a++}]`,async()=>{let c=await this._importDataTypeArgs(e,t,p);c&&r.types.push(je(c))})})}static _createDataType(e,t,r){var a;let o=t.node.findDataType(typeof r=="string"?r:r.name||"");if(o instanceof g)return o;let n=typeof r=="string"?(a=e.initArgsMap)==null?void 0:a.get(r):r;if(n){let p=n[F];switch(p||delete n._instance,o=n._instance,o!=null&&o.name&&p&&p.set(o.name,o),n==null?void 0:n.kind){case m.ComplexType.Kind:return this._createComplexType(e,t,n);case m.EnumType.Kind:return this._createEnumType(e,t,n);case m.MappedType.Kind:return this._createMappedType(e,t,n);case m.MixinType.Kind:return this._createMixinType(e,t,n);case m.SimpleType.Kind:return this._createSimpleType(e,t,n);default:break}}e.addError(`Unknown data type (${String(r)})`)}static _createComplexType(e,t,r){let o=r._instance||{};Object.setPrototypeOf(o,H.prototype);let n=L(r);return r.base&&e.enter(".base",()=>{n.base=this._createDataType(e,t,r.base)}),r.additionalFields&&e.enter(".additionalFields",()=>{typeof r.additionalFields=="boolean"||Array.isArray(r.additionalFields)?n.additionalFields=r.additionalFields:n.additionalFields=this._createDataType(e,t,r.additionalFields)}),n.fields={},r.fields&&e.enter(".fields",()=>{for(let[a,p]of Object.entries(r.fields))e.enter(`[${a}]`,()=>{let c=this._createDataType(e,t,p.type);c&&(n.fields[a]={...p,name:a,type:c})})}),H.apply(o,[t,n]),o}static _createEnumType(e,t,r){let o=r._instance||{};Object.setPrototypeOf(o,pe.prototype);let n=L(r);return r.base&&e.enter(".base",()=>{n.base=this._createDataType(e,t,r.base)}),n.attributes=r.attributes,pe.apply(o,[t,n]),o}static _createMappedType(e,t,r){let o=r._instance||{};Object.setPrototypeOf(o,ke.prototype);let n=L(r);return r.base&&e.enter(".base",()=>{n.base=this._createDataType(e,t,r.base)}),ke.apply(o,[t,n]),o}static _createMixinType(e,t,r){let o=r._instance||{};Object.setPrototypeOf(o,st.prototype);let n=L(r);return r.types&&e.enter(".types",()=>{n.types=[];let a=0;for(let p of r.types)e.enter(`[${a++}]`,()=>{let c=this._createDataType(e,t,p);if(!(c instanceof D))throw new TypeError(`"${c==null?void 0:c.kind}" can't be set as base for a "${n.kind}"`);n.types.push(c)})}),st.apply(o,[t,n]),o}static _createSimpleType(e,t,r){let o=r._instance||{};Object.setPrototypeOf(o,u.prototype);let n=L(r);return r.base&&e.enter(".base",()=>{n.base=this._createDataType(e,t,r.base)}),u.apply(o,[t,n]),o}};s(yr,"DataTypeFactory");var S=yr;function je(i){return typeof i=="object"&&i.name?i.name:i}s(je,"preferName");var ki=class ki extends R{constructor(e){super(e.owner),this.name="OpraApi",this.name=e.name,this.description=e.description}toJSON(){return y({transport:this.transport,name:this.name,description:this.description})}async _initialize(e,t){if(!j.test(e.name))throw new TypeError(`Invalid api name (${e.name})`);this.name=e.name,this.description=e==null?void 0:e.description}};s(ki,"ApiBase");var at=ki;import ip from"path-browserify";import{asMutable as op}from"ts-gems";var ws,As,ee=Symbol.for("kMap"),Jt=Symbol.for("kCtorMap"),ji=class ji{constructor(){this[ws]=new N,this[As]=new WeakMap}get size(){return this[ee].size}forEach(e,t){this[ee].forEach(e,t)}get(e){let t=typeof e=="string"?e:this[Jt].get(e);if(!t&&typeof e=="function"){let r=Reflect.getMetadata(E,e);t=r==null?void 0:r.name}if(!t&&typeof e=="object"){let r=e[E];t=r==null?void 0:r.name}return t?this[ee].get(t):void 0}set(e,t){this[ee].set(e,t),t.ctor?this[Jt].set(t.ctor,e):t.instance&&this[Jt].set(t.instance,e)}has(e){if(e instanceof g)return!!e.name&&this[ee].has(e.name);let t=typeof e=="string"?e:this[Jt].get(e);return t?this[ee].has(t):!1}keys(){return this[ee].keys()}values(){return this[ee].values()}entries(){return this[ee].entries()}sort(e){return this[ee].sort(e),this}[(ws=ee,As=Jt,Symbol.iterator)](){return this[ee][Symbol.iterator]()}};s(ji,"DataTypeMap");var te=ji;import tp from"lodash.omit";import Ci from"putil-merge";var rp=/^(.*)(Controller)$/;function Ui(i){let e=[],t=s(function(r){var c;let o=i==null?void 0:i.name;o||(o=((c=rp.exec(r.name))==null?void 0:c[1])||r.name);let n={},a=Reflect.getOwnMetadata(V,Object.getPrototypeOf(r));a&&Ci(n,a,{deep:!0});let p=Reflect.getOwnMetadata(V,r);p&&Ci(n,p,{deep:!0}),Ci(n,{kind:m.HttpController.Kind,name:o,path:o,...tp(i,["kind","name","instance","endpoints","key"])},{deep:!0}),Reflect.defineMetadata(V,n,r);for(let l of e)l(n,r);Reflect.defineMetadata(V,n,r)},"decorator");return t.Cookie=(r,o)=>(e.push(n=>{let a=typeof o=="string"||typeof o=="function"?{name:r,location:"cookie",type:o}:{...o,name:r,location:"cookie"};n.parameters=n.parameters||[],n.parameters.push(a)}),t),t.Header=(r,o)=>(e.push(n=>{let a=typeof o=="string"||typeof o=="function"?{name:r,location:"header",type:o}:{...o,name:r,location:"header"};n.parameters=n.parameters||[],n.parameters.push(a)}),t),t.QueryParam=(r,o)=>(e.push(n=>{let a=typeof o=="string"||typeof o=="function"?{name:r,location:"query",type:o}:{...o,name:r,location:"query"};n.parameters=n.parameters||[],n.parameters.push(a)}),t),t.PathParam=(r,o)=>(e.push(n=>{let a=typeof o=="string"||typeof o=="function"?{name:r,location:"path",type:o}:{...o,name:r,location:"path"};n.parameters=n.parameters||[],n.parameters.push(a)}),t),t.KeyParam=(r,o)=>(e.push(n=>{var p;(p=n.path)!=null&&p.includes(":"+r)||(n.path=(n.path||"")+"@:"+r);let a=typeof o=="string"||typeof o=="function"?{name:r,location:"path",type:o,keyParam:!0}:{...o,name:r,location:"path",keyParam:!0};n.parameters=n.parameters||[],n.parameters.push(a)}),t),t.UseType=(...r)=>(e.push(o=>{o.types=o.types||[],o.types.push(...r)}),t),t}s(Ui,"HttpControllerDecoratorFactory");var W=s(function(...i){var o;if(!this)return W[A].apply(void 0,i);let[e,t]=i;if(R.call(this,e),!j.test(t.name))throw new TypeError(`Invalid resource name (${t.name})`);let r=op(this);r.kind=m.HttpController.Kind,r.types=r.node[F]=new te,r.operations=new N,r.controllers=new N,r.parameters=[],r.name=t.name,r.description=t.description,r.path=t.path??t.name,r.instance=t.instance,r.ctor=t.ctor,r._controllerReverseMap=new WeakMap,(o=r._initialize)==null||o.call(r,t),r.onInit=t.onInit,r.onShutdown=t.onShutdown},"HttpController"),$i=class $i extends R{get isRoot(){return!(this.owner instanceof W)}findController(e){if(typeof e=="function"){let t=this._controllerReverseMap.get(e);if(t!=null)return t;for(let r of this.controllers.values()){if(r.ctor===e)return this._controllerReverseMap.set(e,r),r;if(r.controllers.size&&(t=r.findController(e),t))return this._controllerReverseMap.set(e,t),t}this._controllerReverseMap.set(e,null);return}if(e.startsWith("/")&&(e=e.substring(1)),e.includes("/")){let t=e.split("/"),r=this;for(;r&&t.length>0;)r=r.controllers.get(t.shift());return r}return this.controllers.get(e)}findParameter(e,t){let r=e.toLowerCase(),o;for(o of this.parameters)if(!(t&&t!==o.location)&&(typeof o.name=="string"&&(o._nameLower=o._nameLower||o.name.toLowerCase(),o._nameLower===r)||o.name instanceof RegExp&&o.name.test(e)))return o;if(this.node.parent&&this.node.parent.element instanceof W)return this.node.parent.element.findParameter(e,t)}getFullUrl(){return ip.posix.join(this.owner instanceof W?this.owner.getFullUrl():"/",this.path)}toString(){return`[HttpController ${this.name}]`}toJSON(){let e=y({kind:this.kind,description:this.description,path:this.path});if(this.operations.size){e.operations={};for(let t of this.operations.values())e.operations[t.name]=t.toJSON()}if(this.controllers.size){e.controllers={};for(let t of this.controllers.values())e.controllers[t.name]=t.toJSON()}if(this.types.size){e.types={};for(let t of this.types.values())e.types[t.name]=t.toJSON()}if(this.parameters.length){e.parameters=[];for(let t of this.parameters)e.parameters.push(t.toJSON())}return e}[it](){return`[${ot}HttpController${nt+this.name+Pe}]`}};s($i,"HttpControllerClass");var qi=$i;W.prototype=qi.prototype;Object.assign(W,Ui);W[A]=Ui;W.OnInit=function(){return(i,e)=>{let t=Reflect.getOwnMetadata(V,i.constructor)||{};t.onInit=i[e],Reflect.defineMetadata(V,i.constructor,t)}};W.OnShutdown=function(){return(i,e)=>{let t=Reflect.getOwnMetadata(V,i.constructor)||{};t.onShutdown=i[e],Reflect.defineMetadata(V,i.constructor,t)}};var Bi=class Bi extends at{constructor(e){super(e),this._controllerReverseMap=new WeakMap,this.transport="http",this.controllers=new N,this.url=e.url}findController(e){return W.prototype.findController.call(this,e)}findOperation(e,t){let r=this.findController(e);return r==null?void 0:r.operations.get(t)}toJSON(){let t={...super.toJSON(),transport:this.transport,url:this.url,controllers:{}};for(let r of this.controllers.values())t.controllers[r.name]=r.toJSON();return t}};s(Bi,"HttpApi");var pt=Bi;import np from"@browsery/type-is";import{asMutable as sp}from"ts-gems";import{isAny as ap,vg as pp}from"valgen";var Ae=s(function(i,e){if(!this)throw new TypeError('"this" should be passed to call class constructor');R.call(this,i);let t=sp(this);if(e.contentType){let r=Array.isArray(e.contentType)?e.contentType:[e.contentType];r=r.map(o=>o.split(/\s*,\s*/)).flat(),t.contentType=r.length>1?r:r[0]}t.description=e.description,t.contentEncoding=e.contentEncoding,t.examples=e.examples,t.multipartFields=[],t.maxFieldsSize=e.maxFieldsSize,t.maxFields=e.maxFields,t.maxFiles=e.maxFiles,t.maxFileSize=e.maxFileSize,t.maxTotalFileSize=e.maxTotalFileSize,e!=null&&e.type&&(t.type=(e==null?void 0:e.type)instanceof g?e.type:t.owner.node.getDataType(e.type)),t.isArray=e.isArray},"HttpMediaType"),Ki=class Ki extends R{findMultipartField(e,t){if(this.multipartFields){for(let r of this.multipartFields)if((!t||t===r.fieldType)&&(r.fieldName instanceof RegExp&&r.fieldName.test(e)||r.fieldName===e))return r}}toJSON(){var r,o;let e=this.type?this.node.getDataTypeNameWithNs(this.type):void 0,t=y({description:this.description,contentType:this.contentType,contentEncoding:this.contentEncoding,type:e||((r=this.type)==null?void 0:r.toJSON()),isArray:this.isArray,example:this.example,examples:this.examples,maxFields:this.maxFields,maxFieldsSize:this.maxFieldsSize,maxFiles:this.maxFiles,maxFileSize:this.maxFileSize,maxTotalFileSize:this.maxTotalFileSize});return(o=this.multipartFields)!=null&&o.length&&(t.multipartFields=this.multipartFields.map(n=>n.toJSON())),t}generateCodec(e,t){let r;return this.type?r=this.type.generateCodec(e,t):this.contentType&&(Array.isArray(this.contentType)?this.contentType:[this.contentType]).find(n=>np.is(n,["json"]))&&(r=this.node.findDataType("object").generateCodec(e)),r=r||ap,this.isArray?pp.isArray(r):r}};s(Ki,"HttpMediaTypeClass");var Vi=Ki;Ae.prototype=Vi.prototype;function ct(i,e){let t=i.lastIndexOf("/");if(i.startsWith("/")&&t){let r=i.substring(1,t),o=i.substring(t+1);if(e!=null&&e.includeFlags)for(let n of e==null?void 0:e.includeFlags)o.includes(n)||(o+=n);if(e!=null&&e.excludeFlags)for(let n of e==null?void 0:e.excludeFlags)o.replace(n,"");return new RegExp(r,o)}throw new TypeError(`"${i}" is not a valid RegExp string`)}s(ct,"parseRegExp");var zi=class zi extends Ae{constructor(e,t){super(e,t),this.fieldName=t.fieldName instanceof RegExp?t.fieldName:t.fieldName.startsWith("/")?ct(t.fieldName):t.fieldName,this.fieldType=t.fieldType,this.required=t.required}toJSON(){return y({fieldName:this.fieldName,fieldType:this.fieldType,required:this.required,...super.toJSON()})}};s(zi,"HttpMultipartField");var Tr=zi;import lp from"path-browserify";import{asMutable as fp}from"ts-gems";import cp from"lodash.omit";var bs;(function(i){i.X_Opra_Version="X-Opra-Version",i.X_Total_Count="X-Total-Count",i.WWW_Authenticate="WWW-Authenticate",i.Authorization="Authorization",i.Proxy_Authenticate="Proxy-Authenticate",i.Proxy_Authorization="Proxy-Authorization",i.Age="Age",i.Cache_Control="Cache-Control",i.Clear_Site_Data="Clear-Site-Data",i.Expires="Expires",i.Pragma="Pragma",i.Last_Modified="Last-Modified",i.ETag="ETag",i.If_Match="If-Match",i.If_None_Match="If-None-Match",i.If_Modified_Since="If-Modified-Since",i.If_Unmodified_Since="If-Unmodified-Since",i.Vary="Vary",i.Connection="Connection",i.Keep_Alive="Keep-Alive",i.Accept="Accept",i.Accept_Encoding="Accept-Encoding",i.Accept_Language="Accept-Language",i.Expect="Expect",i.Cookie="Cookie",i.Set_Cookie="Set-Cookie",i.Access_Control_Allow_Origin="Access-Control-Allow-Origin",i.Access_Control_Allow_Credentials="Access-Control-Allow-Credentials",i.Access_Control_Allow_Headers="Access-Control-Allow-Headers",i.Access_Control_Allow_Methods="Access-Control-Allow-Methods",i.Access_Control_Expose_Headers="Access-Control-Expose-Headers",i.Access_Control_Max_Age="Access-Control-Max-Age",i.Access_Control_Request_Headers="Access-Control-Request-Headers",i.Access_Control_Request_Method="Access-Control-Request-Method",i.Origin="Origin",i.Timing_Allow_Origin="Timing-Allow-Origin",i.Content_Disposition="Content-Disposition",i.Content_ID="Content-ID",i.Content_Length="Content-Length",i.Content_Type="Content-Type",i.Content_Transfer_Encoding="Content-Transfer-Encoding",i.Content_Encoding="Content-Encoding",i.Content_Language="Content-Language",i.Content_Location="Content-Location",i.Forwarded="Forwarded",i.X_Forwarded_For="X-Forwarded-For",i.X_Forwarded_Host="X-Forwarded-Host",i.X_Forwarded_Proto="X-Forwarded-Proto",i.Via="Via",i.Location="Location",i.From="From",i.Host="Host",i.Referer="Referer",i.Referrer_Policy="Referrer-Policy",i.User_Agent="User-Agent",i.Allow="Allow",i.Server="Server",i.Accept_Ranges="Accept-Ranges",i.Range="Range",i.If_Range="If-Range",i.Content_Range="Content-Range",i.Cross_Origin_Embedder_Policy="Cross-Origin-Embedder-Policy",i.Cross_Origin_Opener_Policy="Cross-Origin-Opener-Policy",i.Cross_Origin_Resource_Policy="Cross-Origin-Resource-Policy",i.Content_Security_Policy="Content-Security-Policy",i.Content_Security_Policy_Report_Only="Content-Security-Policy-Report-Only",i.Expect_CT="Expect-CT",i.Feature_Policy="Feature-Policy",i.Strict_Transport_Security="Strict-Transport-Security",i.Upgrade="Upgrade",i.Upgrade_Insecure_Requests="Upgrade-Insecure-Requests",i.X_Content_Type_Options="X-Content-Type-Options",i.X_Download_Options="X-Download-Options",i.X_Frame_Options="X-Frame-Options",i.X_Permitted_Cross_Domain_Policies="X-Permitted-Cross-Domain-Policies",i.X_Powered_By="X-Powered-By",i.X_XSS_Protection="X-XSS-Protection",i.Transfer_Encoding="Transfer-Encoding",i.TE="TE",i.Trailer="Trailer",i.Sec_WebSocket_Key="Sec-WebSocket-Key",i.Sec_WebSocket_Extensions="Sec-WebSocket-Extensions",i.Sec_WebSocket_Accept="Sec-WebSocket-Accept",i.Sec_WebSocket_Protocol="Sec-WebSocket-Protocol",i.Sec_WebSocket_Version="Sec-WebSocket-Version",i.Date="Date",i.Retry_After="Retry-After",i.Server_Timing="Server-Timing",i.X_DNS_Prefetch_Control="X-DNS-Prefetch-Control",i.Max_Forwards="Max-Forwards"})(bs||(bs={}));var I;(function(i){i[i.CONTINUE=100]="CONTINUE",i[i.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",i[i.PROCESSING=102]="PROCESSING",i[i.EARLYHINTS=103]="EARLYHINTS",i[i.OK=200]="OK",i[i.CREATED=201]="CREATED",i[i.ACCEPTED=202]="ACCEPTED",i[i.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",i[i.NO_CONTENT=204]="NO_CONTENT",i[i.RESET_CONTENT=205]="RESET_CONTENT",i[i.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",i[i.AMBIGUOUS=300]="AMBIGUOUS",i[i.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",i[i.FOUND=302]="FOUND",i[i.SEE_OTHER=303]="SEE_OTHER",i[i.NOT_MODIFIED=304]="NOT_MODIFIED",i[i.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",i[i.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",i[i.BAD_REQUEST=400]="BAD_REQUEST",i[i.UNAUTHORIZED=401]="UNAUTHORIZED",i[i.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",i[i.FORBIDDEN=403]="FORBIDDEN",i[i.NOT_FOUND=404]="NOT_FOUND",i[i.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",i[i.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",i[i.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",i[i.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",i[i.CONFLICT=409]="CONFLICT",i[i.GONE=410]="GONE",i[i.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",i[i.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",i[i.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",i[i.URI_TOO_LONG=414]="URI_TOO_LONG",i[i.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",i[i.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",i[i.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",i[i.I_AM_A_TEAPOT=418]="I_AM_A_TEAPOT",i[i.MISDIRECTED_REQUEST=421]="MISDIRECTED_REQUEST",i[i.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",i[i.LOCKED=423]="LOCKED",i[i.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",i[i.TOO_EARLY=425]="TOO_EARLY",i[i.UPGRADE_REQUIRED=426]="UPGRADE_REQUIRED",i[i.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",i[i.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",i[i.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",i[i.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",i[i.BAD_GATEWAY=502]="BAD_GATEWAY",i[i.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",i[i.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",i[i.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",i[i.VARIANT_ALSO_NEGOTIATES=506]="VARIANT_ALSO_NEGOTIATES",i[i.INSUFFICIENT_STORAGE=507]="INSUFFICIENT_STORAGE",i[i.LOOP_DETECTED=508]="LOOP_DETECTED",i[i.NOT_EXTENDED=510]="NOT_EXTENDED",i[i.NETWORK_AUTHENTICATION_REQUIRED=511]="NETWORK_AUTHENTICATION_REQUIRED"})(I||(I={}));var Y0={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a Teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"};var v;(function(i){i.json="application/json",i.opra_response_json="application/opra.response+json",i.xml="application/XML",i.text="text/plain",i.html="text/html",i.markdown="text/markdown",i.binary="binary/octet-stream"})(v||(v={}));function C(i,e){let t=s((r,o)=>{if(typeof o!="string")throw new TypeError("Symbol properties can not be decorated");let n={kind:m.HttpOperation.Kind,...cp(e,["kind"])},a=Reflect.getOwnMetadata(V,r.constructor)||{};a.operations=a.operations||{},a.operations[o]=n;for(let p of i)p(n);Reflect.defineMetadata(V,a,r.constructor)},"decorator");return t.Cookie=(r,o)=>(i.push(n=>{let a=typeof o=="string"||typeof o=="function"?{name:r,location:"cookie",type:o}:{...o,name:r,location:"cookie"};n.parameters?n.parameters=n.parameters.filter(p=>!(p.location==="cookie"&&String(p.name)===String(r))):n.parameters=[],n.parameters.push(a)}),t),t.Header=(r,o)=>(i.push(n=>{let a=typeof o=="string"||typeof o=="function"?{name:r,location:"header",type:o}:{...o,name:r,location:"header"};n.parameters?n.parameters=n.parameters.filter(p=>!(p.location==="header"&&String(p.name)===String(r))):n.parameters=[],n.parameters.push(a)}),t),t.QueryParam=(r,o)=>(i.push(n=>{let a=typeof o=="string"||typeof o=="function"?{name:r,location:"query",type:o}:{...o,name:r,location:"query"};n.parameters?n.parameters=n.parameters.filter(p=>!(p.location==="query"&&String(p.name)===String(r))):n.parameters=[],n.parameters.push(a)}),t),t.PathParam=(r,o)=>(i.push(n=>{let a=typeof o=="string"||typeof o=="function"?{name:r,location:"path",type:o}:{...o,name:r,location:"path"};n.parameters?n.parameters=n.parameters.filter(p=>!(p.location==="path"&&String(p.name)===String(r))):n.parameters=[],n.parameters.push(a)}),t),t.Response=(r,o)=>{let n={...o,statusCode:r};return n.type&&(n.contentType=n.contentType||v.opra_response_json,n.contentEncoding=n.contentEncoding||"utf-8"),n.contentType===v.opra_response_json&&(n.contentEncoding=n.contentEncoding||"utf-8"),i.push(a=>{a.responses=a.responses||[],a.responses.push(n)}),t},t.RequestContent=function(r){let o=typeof r=="object"?r:{type:r};return o.type&&(o.contentType=o.contentType||v.json,o.contentEncoding=o.contentEncoding||"utf-8"),i.push(n=>{n.requestBody=n.requestBody||{required:!0,content:[]},n.requestBody.content=n.requestBody.content||[],n.requestBody.content.push(o)}),t},t.MultipartContent=function(r,o){let n={...r,contentType:(r==null?void 0:r.contentType)||"multipart/form-data"};if(i.push(a=>{a.requestBody=a.requestBody||{required:!0,content:[]},a.requestBody.content=a.requestBody.content||[],a.requestBody.content.push(n)}),o){let a={Field(p,c){return n.multipartFields=n.multipartFields||[],n.multipartFields.push({fieldName:p,fieldType:"field",...c}),a},File(p,c){return n.multipartFields=n.multipartFields||[],n.multipartFields.push({fieldName:p,fieldType:"file",...c}),a}};o(a)}return t},t.UseType=(...r)=>(i.push(o=>{o.types=o.types||[],o.types.push(...r)}),t),t}s(C,"HttpOperationDecoratorFactory");var M=s(function(...i){if(!this){let[o]=i,n=[];return M[A].call(void 0,n,o)}let[e,t]=i;if(R.call(this,e),!j.test(t.name))throw new TypeError(`Invalid operation name (${t.name})`);let r=fp(this);r.parameters=[],r.responses=[],r.types=r.node[F]=new te,r.name=t.name,r.path=t.path,r.mergePath=t.mergePath,r.method=t.method||"GET",r.description=t.description,r.composition=t.composition,r.compositionOptions=t.compositionOptions?L(t.compositionOptions):void 0},"HttpOperation"),Wi=class Wi extends R{findParameter(e,t){let r=e.toLowerCase(),o;for(o of this.parameters)if(!(t&&t!==o.location)&&(typeof o.name=="string"&&(o._nameLower=o._nameLower||o.name.toLowerCase(),o._nameLower===r)||o.name instanceof RegExp&&o.name.test(e)))return o}getFullUrl(){let e=this.owner.getFullUrl();return e?this.path?this.mergePath?e+this.path:lp.posix.join(e,this.path):e:this.path||"/"}toJSON(){var t;let e=y({kind:m.HttpOperation.Kind,description:this.description,method:this.method,path:this.path,mergePath:this.mergePath,composition:this.composition,requestBody:(t=this.requestBody)==null?void 0:t.toJSON()});if(this.types.size){e.types={};for(let r of this.types.values())e.types[r.name]=r.toJSON()}if(this.parameters.length){e.parameters=[];for(let r of this.parameters)e.parameters.push(r.toJSON())}return this.responses.length&&(e.responses=this.responses.map(r=>r.toJSON())),e}};s(Wi,"HttpOperationClass");var Ji=Wi;M.prototype=Ji.prototype;M[A]=C;M.GET=function(i){return C([],{...i,method:"GET"})};M.DELETE=function(i){return C([],{...i,method:"DELETE"})};M.HEAD=function(i){return C([],{...i,method:"HEAD"})};M.OPTIONS=function(i){return C([],{...i,method:"OPTIONS"})};M.PATCH=function(i){return C([],{...i,method:"PATCH"})};M.POST=function(i){return C([],{...i,method:"POST"})};M.PUT=function(i){return C([],{...i,method:"PUT"})};M.SEARCH=function(i){return C([],{...i,method:"SEARCH"})};var up=/^([1-6]\d{2})(?:-([1-6]\d{2}))?$/,Gi=class Gi{constructor(e,t){if(this.start=0,this.end=0,e&&typeof e=="object"&&(this.start=e.start||0,this.end=e.end||0),typeof e=="number"&&(this.start=e,this.end=t||this.start),typeof e=="string"){let r=up.exec(e);if(!r)throw new TypeError(`"${e}" is not a valid Status Code range`);this.start=parseInt(r[1],10),this.end=r[2]?parseInt(r[2],10):this.start}}includes(e){return e>=this.start&&e<=this.end}intersects(e,t){return t>=this.start&&e<=this.end}toString(){return this.start===this.end?String(this.start):String(this.start)+"-"+String(this.end)}toJSON(){return!this.end||this.start===this.end?this.start:{start:this.start,end:this.end}}};s(Gi,"HttpStatusRange");var Wt=Gi;var Yi=class Yi extends Ae{constructor(e,t){super(e,t),this.parameters=[],this.statusCode=(Array.isArray(t.statusCode)?t.statusCode:[t.statusCode]).map(r=>typeof r=="object"?new Wt(r.start,r.end):new Wt(r)),this.partial=t.partial}findParameter(e,t){e=e.toLowerCase();for(let r of this.parameters)if((!t||t===r.location)&&(r.name instanceof RegExp&&r.name.test(e)||r.name===e))return r}toJSON(){let e=this.statusCode.map(r=>r.toJSON()),t=y({...super.toJSON(),statusCode:e.length===1&&typeof e[0]=="number"?e[0]:e,partial:this.partial});if(this.parameters.length){t.parameters=[];for(let r of this.parameters)t.parameters.push(r.toJSON())}return t}};s(Yi,"HttpOperationResponse");var Er=Yi;import{asMutable as dp}from"ts-gems";import{asMutable as mp}from"ts-gems";var Ce=s(function(i,e){if(!this)throw new TypeError('"this" should be passed to call class constructor');R.call(this,i);let t=mp(this);t.description=e.description,t.type=e.type,t.examples=e.examples,t.isArray=e.isArray},"Value"),Xi=class Xi extends R{toJSON(){let e=this.type?this.node.getDataTypeNameWithNs(this.type):void 0;return y({type:this.type?e||this.type.toJSON():"any",description:this.description,isArray:this.isArray,examples:this.examples})}};s(Xi,"ValueClass");var Qi=Xi;Ce.prototype=Qi.prototype;var Gt=s(function(i,e){if(!this)throw new TypeError('"this" should be passed to call class constructor');Ce.call(this,i,e);let t=dp(this);e.name&&(t.name=e.name instanceof RegExp?e.name:e.name.startsWith("/")?ct(e.name,{includeFlags:"i",excludeFlags:"m"}):e.name),t.location=e.location,t.deprecated=e.deprecated,t.required=e.required,t.required==null&&e.location==="path"&&(t.required=!0),t.arraySeparator=e.arraySeparator,t.keyParam=e.keyParam},"HttpParameter"),Hi=class Hi extends Ce{toJSON(){return y({...super.toJSON(),name:this.name,location:this.location,arraySeparator:this.arraySeparator,keyParam:this.keyParam,required:this.required,deprecated:this.deprecated})}};s(Hi,"HttpParameterClass");var Zi=Hi;Gt.prototype=Zi.prototype;var eo=class eo extends R{constructor(e){super(e),this.content=[]}toJSON(){return y({description:this.description,required:this.required,maxContentSize:this.maxContentSize,content:this.content.length?this.content.map(e=>e.toJSON()):[],partial:this.partial})}};s(eo,"HttpRequestBody");var _r=eo;var to=class to{static async createApi(e,t){let r=new pt(t);return t.controllers&&await e.enterAsync(".controllers",async()=>{await this._createControllers(e,r,t.controllers)}),r}static async _createControllers(e,t,r){if(Array.isArray(r)){let o=0;for(let n of r){let a;await e.enterAsync(`[${o++}]`,async()=>{a=await this._resolveControllerMetadata(e,t,n)}),a&&await e.enterAsync(`[${a.metadata.name}]`,async()=>{let p=await this._createController(e,t,a.metadata,a.instance,a.ctor);p&&(t.controllers.get(p.name)&&e.addError(`Duplicate controller name (${a.name})`),t.controllers.set(p.name,p))})}return}for(let[o,n]of Object.entries(r))await e.enterAsync(`[${o}]`,async()=>{let a=await this._resolveControllerMetadata(e,t,n);if(!a)return;let p=await this._createController(e,t,{...a.metadata,name:o},a.instance,a.ctor);p&&(t.controllers.get(p.name)&&e.addError(`Duplicate controller name (${o})`),t.controllers.set(p.name,p))})}static async _resolveControllerMetadata(e,t,r){typeof r=="function"&&!et(r)&&(r=t instanceof W?r(t.instance):r()),r=await ne(r);let o,n,a;if(typeof r=="function"){if(n=Reflect.getMetadata(V,r),!n)return e.addError(`Class "${r.name}" doesn't have a valid HttpController metadata`);o=r}else o=Object.getPrototypeOf(r).constructor,n=Reflect.getMetadata(V,o),n?a=r:(n=r,r.instance==="object"&&(a=r.instance,o=Object.getPrototypeOf(a).constructor));return n?{metadata:n,instance:a,ctor:o}:e.addError(`Class "${o.name}" is not decorated with HttpController()`)}static async _createController(e,t,r,o,n){if(!r.name)throw new TypeError("Controller name required");let a=new W(t,{...r,instance:o,ctor:n});return r.types&&await e.enterAsync(".types",async()=>{await S.addDataTypes(e,a,r.types)}),r.parameters&&await e.enterAsync(".parameters",async()=>{let p=0;for(let c of r.parameters)await e.enterAsync(`[${p++}]`,async()=>{let l={...c};await e.enterAsync(".type",async()=>{l.type=await S.resolveDataType(e,a,c.type)});let x=new Gt(a,l);a.parameters.push(x)})}),r.operations&&await e.enterAsync(".operations",async()=>{for(let[p,c]of Object.entries(r.operations))await e.enterAsync(`[${p}]`,async()=>{let l=new M(a,{name:p,method:"GET"});await this._initHttpOperation(e,l,c),a.operations.set(p,l)})}),r.controllers&&await e.enterAsync(".controllers",async()=>{await this._createControllers(e,a,r.controllers)}),a}static async _initHttpOperation(e,t,r){let o={...r,name:t.name,types:void 0};return M.apply(t,[t.owner,o]),r.types&&await e.enterAsync(".types",async()=>{await S.addDataTypes(e,t,r.types)}),r.parameters&&await e.enterAsync(".parameters",async()=>{let n=0;for(let a of r.parameters)await e.enterAsync(`[${n++}]`,async()=>{let p={...a};await e.enterAsync(".type",async()=>{p.type=await S.resolveDataType(e,t,a.type)});let c=new Gt(t,p);t.parameters.push(c)})}),r.responses&&await e.enterAsync(".responses",async()=>{let n=0;for(let a of r.responses)await e.enterAsync(`[${n++}]`,async()=>{let p=new Er(t,{statusCode:a.statusCode});await this._initHttpOperationResponse(e,p,a),t.responses.push(p)})}),r.requestBody&&await e.enterAsync(".requestBody",async()=>{let n=new _r(t);await this._initHttpRequestBody(e,n,r.requestBody),t.requestBody=n}),t}static async _initHttpMediaType(e,t,r){Ae.call(t,t.owner,{...r,type:void 0,multipartFields:void 0}),r.type&&await e.enterAsync(".type",async()=>{t.type=await S.resolveDataType(e,t,r.type)}),r.multipartFields&&await e.enterAsync(".multipartFields",async()=>{for(let o=0;o<r.multipartFields.length;o++)await e.enterAsync(`[${o}]`,async()=>{let n=r.multipartFields[o],a=new Tr(t,{fieldName:n.fieldName,fieldType:n.fieldType});await this._initHttpMediaType(e,a,n),t.multipartFields.push(a)})})}static async _initHttpOperationResponse(e,t,r){await this._initHttpMediaType(e,t,r),t.partial=r.partial,r.parameters&&await e.enterAsync(".parameters",async()=>{let o=0;for(let n of r.parameters)await e.enterAsync(`[${o++}]`,async()=>{let a={...n};await e.enterAsync(".type",async()=>{a.type=await S.resolveDataType(e,t,n.type)});let p=new Gt(t,a);t.parameters.push(p)})})}static async _initHttpRequestBody(e,t,r){t.description=r.description,t.required=r.required,t.maxContentSize=r.maxContentSize,t.immediateFetch=r.immediateFetch,t.partial=r.partial,r.content&&await e.enterAsync(".content",async()=>{for(let o=0;o<r.content.length;o++)await e.enterAsync(`[${o}]`,async()=>{let n=r.content[o],a=new Ae(t,String(o));await this._initHttpMediaType(e,a,n),t.content.push(a)})})}};s(to,"HttpApiFactory");var lt=to;import{md5 as yp}from"super-fast-md5";var ro=class ro extends at{constructor(e){super(e),this._controllerReverseMap=new WeakMap,this.transport="rpc",this.controllers=new N,this.platform=e.platform}findController(e){if(typeof e=="function"){let t=this._controllerReverseMap.get(e);if(t!=null)return t;for(let r of this.controllers.values())if(r.ctor===e)return this._controllerReverseMap.set(e,r),r;this._controllerReverseMap.set(e,null);return}return this.controllers.get(e)}findOperation(e,t){let r=this.findController(e);return r==null?void 0:r.operations.get(t)}toJSON(){let t={...super.toJSON(),transport:this.transport,platform:this.platform,controllers:{}};for(let r of this.controllers.values())t.controllers[r.name]=r.toJSON();return t}};s(ro,"RpcApi");var ft=ro;var Ns,io=class io extends R{constructor(){super(null),this[Ns]=new WeakMap,this.id="",this.info={},this.references=new N,this.types=new te,this.node[F]=this.types,this.node.findDataType=this._findDataType.bind(this)}getDataTypeNs(e){let t=e instanceof g?this._findDataType(e.name||""):this._findDataType(e);if(t)return this[we].get(t)}findDocument(e){if(this.id===e)return this;for(let t of this.references.values()){if(t.id===e)return t;let r=t.findDocument(e);if(r)return r}}get httpApi(){if(!(this.api&&this.api instanceof pt))throw new TypeError("The document do not contains HttpApi instance");return this.api}get rpcApi(){if(!(this.api&&this.api instanceof ft))throw new TypeError("The document do not contains RpcApi instance");return this.api}toJSON(){return this.export()}export(){let e=y({spec:m.SpecVersion,id:this.id,url:this.url,info:L(this.info,!0)});if(this.references.size){let t=0,r={};for(let[o,n]of this.references.entries())n[Le]||(r[o]={id:n.id,url:n.url,info:L(n.info,!0)},t++);t&&(e.references=r)}if(this.types.size){e.types={};for(let t of this.types.values())e.types[t.name]=t.toJSON()}return this.api&&(e.api=this.api.toJSON()),e}invalidate(){let e=this.export();delete e.id,this.id=yp(JSON.stringify(e)),this[we]=new WeakMap}_findDataType(e,t){let r=this.types.get(e);if(r||!this.references.size)return r;if(typeof e=="string"){let n=us.exec(e);if(n){let a=n[1];if(a){let p=this.references.get(a);return p?(t=t||new WeakMap,t.set(this,!0),t.set(p,!0),p._findDataType(n[2],t)):void 0}e=n[2]}}t=t||new WeakMap,t.set(this,!0);let o=Array.from(this.references.keys()).reverse();for(let n of o){let a=this.references.get(n);if(r=a==null?void 0:a.types.get(e),r)return this[we].set(r,a!=null&&a[Le]?"":n),r}for(let n of o){let a=this.references.get(n);if(t.set(a,!0),r=a._findDataType(e,t),r)return this[we].set(r,a!=null&&a[Le]?"":n),r}}};s(io,"ApiDocument");var Ue=io;Ns=we;import{__decorate as Tp,__metadata as Ep}from"tslib";import{vg as Ds}from"valgen";var ut,xr=(ut=class{constructor(e){e&&Object.assign(this,e)}[T](){return Ds.isBase64({coerce:!0})}[O](){return Ds.isBase64({coerce:!0})}},s(ut,"Base64Type"),ut);xr=Tp([u({description:"A stream of bytes, base64 encoded",nameMappings:{js:"string",json:"string"}}),Ep("design:paramtypes",[Object])],xr);import{__decorate as oo,__metadata as no}from"tslib";import{isDateString as Or,toString as Ss,vg as be}from"valgen";var mt,dt=(mt=class{constructor(e){e&&Object.assign(this,e)}[T](e){let t=be.isDate({precision:"date",coerce:!0}),r=[];return e.minValue&&(Or(e.minValue),r.push(Ss,be.isGte(e.minValue))),e.maxValue&&(Or(e.maxValue),r.push(Ss,be.isLte(e.maxValue))),r.length>0?be.pipe([t,...r],{returnIndex:0}):t}[O](e){let t=be.isDateString({precision:"date",trim:"date",coerce:!0}),r=[];return e.minValue&&(Or(e.minValue),r.push(be.isGte(e.minValue))),e.maxValue&&(Or(e.maxValue),r.push(be.isLte(e.maxValue))),r.length>0?be.pipe([t,...r],{returnIndex:0}):t}},s(mt,"DateType"),mt);oo([u.Attribute({description:"Minimum value"}),no("design:type",String)],dt.prototype,"minValue",void 0);oo([u.Attribute({description:"Maximum value"}),no("design:type",String)],dt.prototype,"maxValue",void 0);dt=oo([u({description:"A date without time",nameMappings:{js:"Date",json:"string"}}).Example("2021-04-18","Full date value"),no("design:paramtypes",[Object])],dt);import{__decorate as so,__metadata as ao}from"tslib";import{vg as gr}from"valgen";var ht,yt=(ht=class{constructor(e){e&&Object.assign(this,e)}[T](e){let t=gr.isDateString({trim:"date",coerce:!0}),r=[];return e.minValue&&r.push(gr.isGte(e.minValue)),e.maxValue&&r.push(gr.isLte(e.maxValue)),r.length>0?gr.pipe([t,...r],{returnIndex:0}):t}[O](e){return this[T](e)}},s(ht,"DateStringType"),ht);so([u.Attribute({description:"Minimum value"}),ao("design:type",String)],yt.prototype,"minValue",void 0);so([u.Attribute({description:"Maximum value"}),ao("design:type",String)],yt.prototype,"maxValue",void 0);yt=so([u({description:"Date string value",nameMappings:{js:"string",json:"string"}}).Example("2021-04-18","Full date value").Example("2021-04","Date value without day").Example("2021","Year only value"),ao("design:paramtypes",[Object])],yt);import{__decorate as po,__metadata as co}from"tslib";import{isDateString as Rr,toString as Is,vg as Ne}from"valgen";var Tt,Et=(Tt=class{constructor(e){e&&Object.assign(this,e)}[T](e){let t=Ne.isDate({precision:"time",coerce:!0}),r=[];return e.minValue&&(Rr(e.minValue),r.push(Is,Ne.isGte(e.minValue))),e.maxValue&&(Rr(e.maxValue),r.push(Is,Ne.isLte(e.maxValue))),r.length>0?Ne.pipe([t,...r],{returnIndex:0}):t}[O](e){let t=Ne.isDateString({precision:"time",trim:"time",coerce:!0}),r=[];return e.minValue&&(Rr(e.minValue),r.push(Ne.isGte(e.minValue))),e.maxValue&&(Rr(e.maxValue),r.push(Ne.isLte(e.maxValue))),r.length>0?Ne.pipe([t,...r],{returnIndex:0}):t}},s(Tt,"DateTimeType"),Tt);po([u.Attribute({description:"Minimum value"}),co("design:type",String)],Et.prototype,"minValue",void 0);po([u.Attribute({description:"Maximum value"}),co("design:type",String)],Et.prototype,"maxValue",void 0);Et=po([u({description:"A full datetime value",nameMappings:{js:"string",json:"string"}}).Example("2021-04-18T22:30:15").Example("2021-04-18 22:30:15").Example("2021-04-18 22:30"),co("design:paramtypes",[Object])],Et);import{__decorate as lo,__metadata as fo}from"tslib";import{vg as wr}from"valgen";var _t,xt=(_t=class{constructor(e){e&&Object.assign(this,e)}[T](e){let t=wr.isDateString({coerce:!0}),r=[];return e.minValue&&r.push(wr.isGte(e.minValue)),e.maxValue&&r.push(wr.isLte(e.maxValue)),r.length>0?wr.pipe([t,...r]):t}[O](e){return this[T](e)}},s(_t,"DateTimeStringType"),_t);lo([u.Attribute({description:"Minimum value"}),fo("design:type",String)],xt.prototype,"minValue",void 0);lo([u.Attribute({description:"Maximum value"}),fo("design:type",String)],xt.prototype,"maxValue",void 0);xt=lo([u({description:"DateTime string value",nameMappings:{js:"string",json:"string"}}).Example("2021-04-18T22:30:15+01:00","Full date-time value with timezone").Example("2021-04-18T22:30:15","Full date-time value without timezone").Example("2021-04-18 22:30","Date-time value").Example("2021-04-18","Date value").Example("2021-04","Date value without day").Example("2021","Year only value"),fo("design:paramtypes",[Object])],xt);import{__decorate as ce,__metadata as le}from"tslib";import{vg as Ms}from"valgen";var Ot,Q=(Ot=class{constructor(e){e&&Object.assign(this,e)}[T](e){return Ms.isEmail({...e,coerce:!0})}[O](e){return Ms.isEmail({...e,coerce:!0})}},s(Ot,"EmailType"),Ot);ce([u.Attribute({description:"If set to `true`, the validator will also match `Display Name <email-address>",default:!1}),le("design:type",Boolean)],Q.prototype,"allowDisplayName",void 0);ce([u.Attribute({description:"If set to `true`, the validator will reject strings without the format `Display Name <email-address>",default:!1}),le("design:type",Boolean)],Q.prototype,"requireDisplayName",void 0);ce([u.Attribute({description:"If set to `false`, the validator will not allow any non-English UTF8 character in email address's local part",default:!0}),le("design:type",Boolean)],Q.prototype,"utf8LocalPart",void 0);ce([u.Attribute({description:"If set to `true`, the validator will not check for the standard max length of an email",default:!1}),le("design:type",Boolean)],Q.prototype,"ignoreMaxLength",void 0);ce([u.Attribute({description:"If set to `true`, the validator will allow IP addresses in the host part",default:!1}),le("design:type",Boolean)],Q.prototype,"allowIpDomain",void 0);ce([u.Attribute({description:"If set to `true`, some additional validation will be enabled, e.g. disallowing certain syntactically valid email addresses that are rejected by GMail.",default:!1}),le("design:type",Boolean)],Q.prototype,"domainSpecificValidation",void 0);ce([u.Attribute({description:"If set to an array of strings and the part of the email after the @ symbol one of the strings defined in it, the validation fails."}),le("design:type",Array)],Q.prototype,"hostBlacklist",void 0);ce([u.Attribute({description:"If set to an array of strings and the part of the email after the @ symbol matches none of the strings defined in it, the validation fails."}),le("design:type",Array)],Q.prototype,"hostWhitelist",void 0);ce([u.Attribute({description:"If set to a string, then the validator will reject emails that include any of the characters in the string, in the name part."}),le("design:type",String)],Q.prototype,"blacklistedChars",void 0);Q=ce([u({description:"An email value",nameMappings:{js:"string",json:"string"}}).Example("some.body@example.com"),le("design:paramtypes",[Object])],Q);import{__decorate as uo,__metadata as mo}from"tslib";import{toString as _p,validator as xp,vg as Op}from"valgen";var gt,re=(gt=class{constructor(e){e&&Object.assign(this,e)}[T](e,t){let r=e.dataType?t.node.getComplexType(e.dataType):t.node.getComplexType("object"),o=e.allowSigns,n=xp("decodeFieldPath",a=>r.normalizeFieldPath(a,{allowSigns:o}));return Op.pipe([_p,n])}[O](e,t){return this[T](e,t)}toJSON(e,t){let r=e.dataType?t.node.getComplexType(e.dataType):t.node.getComplexType("object"),o=r?t.node.getDataTypeNameWithNs(r):void 0;return{dataType:o||r.toJSON(),allowSigns:e.allowSigns}}},s(gt,"FieldPathType"),gt);uo([u.Attribute({description:"Data type which field belong to"}),mo("design:type",Object)],re.prototype,"dataType",void 0);uo([u.Attribute({description:'Determines if signs (+,-) are allowed. If set "first" signs are allowed only beginning of the field pathIf set "each" signs are allowed at each field in the path'}),mo("design:type",String)],re.prototype,"allowSigns",void 0);re=uo([u({description:"Field path",nameMappings:{js:"string",json:"string"}}),mo("design:paramtypes",[Object])],re);import{__decorate as Jn,__metadata as Wn}from"tslib";import{validator as Qs}from"valgen";var ho=class ho extends ye{constructor(e,t,r){super(e,t instanceof Error?t:void 0),this.status=(typeof t=="number"?t:Number(r))||500}setStatus(e){return this.status=e,this}initError(e){typeof e.status=="number"?this.status=e.status:typeof e.getStatus=="function"&&(this.status=e.getStatus()),super.initError(e)}};s(ho,"OpraHttpError");var b=ho;var yo=class yo extends b{constructor(){super(...arguments),this.status=400}init(e){super.init({message:w("error:BAD_REQUEST","Bad request"),code:"BAD_REQUEST",...e})}};s(yo,"BadRequestError");var Ls=yo;var To=class To extends b{constructor(){super(...arguments),this.status=409}init(e){super.init({message:w("error:CONFLICT","Conflict"),code:"CONFLICT",...e})}};s(To,"ConflictError");var vs=To;var Eo=class Eo extends b{constructor(){super(...arguments),this.status=424}init(e){super.init({message:w("error:FAILED_DEPENDENCY","The request failed due to failure of a previous request"),code:"FAILED_DEPENDENCY",...e})}};s(Eo,"FailedDependencyError");var Ps=Eo;var _o=class _o extends b{constructor(){super(...arguments),this.status=I.FORBIDDEN}init(e){super.init({message:w("error:FORBIDDEN","You are not authorized to perform this action"),code:"FORBIDDEN",...e})}};s(_o,"ForbiddenError");var Ar=_o;var xo=class xo extends b{constructor(){super(...arguments),this.status=500}init(e){super.init({message:w("error:INTERNAL_SERVER_ERROR","Internal server error"),code:"INTERNAL_SERVER_ERROR",severity:"fatal",...e})}};s(xo,"InternalServerError");var Fs=xo;var Oo=class Oo extends b{constructor(){super(...arguments),this.status=405}init(e){super.init({message:w("error:METHOD_NOT_ALLOWED","Method not allowed"),code:"METHOD_NOT_ALLOWED",...e})}};s(Oo,"MethodNotAllowedError");var ks=Oo;var go=class go extends b{constructor(){super(...arguments),this.status=406}init(e){super.init({message:w("error:NOT_ACCEPTABLE","Not Acceptable"),code:"NOT_ACCEPTABLE",...e})}};s(go,"NotAcceptableError");var js=go;var Ro=class Ro extends b{constructor(){super(...arguments),this.status=404}init(e){super.init({message:w("error:NOT_FOUND","Not found"),code:"NOT_FOUND",...e})}};s(Ro,"NotFoundError");var Cs=Ro;var wo=class wo extends Ar{init(e){super.init({message:w("error:PERMISSION_ERROR","You dont have permission for this operation"),code:"PERMISSION_ERROR",...e})}};s(wo,"PermissionError");var Us=wo;var Ao=class Ao extends b{constructor(e,t,r){super({message:w("error:RESOURCE_CONFLICT",{resource:e,fields:t},"There is already an other {{resource}} resource with same values ({{fields}})"),severity:"error",code:"RESOURCE_CONFLICT",details:{resource:e,location:t}},r),this.status=409}};s(Ao,"ResourceConflictError");var qs=Ao;var bo=class bo extends b{constructor(e,t,r){super({message:w("error:RESOURCE_NOT_AVAILABLE",`Resource "${e}${t?"/"+t:""}" is not available`),severity:"error",code:"RESOURCE_NOT_AVAILABLE",details:{resource:e,key:t}},r,I.UNPROCESSABLE_ENTITY)}};s(bo,"ResourceNotAvailableError");var $s=bo;var No=class No extends b{constructor(){super(...arguments),this.status=401}init(e){super.init({message:w("error:UNAUTHORIZED","You have not been authenticated to perform this action"),code:"UNAUTHORIZED",...e})}};s(No,"UnauthorizedError");var Bs=No;var Do=class Do extends b{constructor(){super(...arguments),this.status=422}init(e){super.init({message:w("error:UNPROCESSABLE_ENTITY","Unprocessable entity"),severity:"error",code:"UNPROCESSABLE_ENTITY",...e})}};s(Do,"UnprocessableEntityError");var Vs=Do;var Ks;(function(i){let e;(function(t){t.fatal="fatal",t.error="error",t.warning="warning",t.info="info"})(e=i.Enum||(i.Enum={})),i.name="IssueSeverity",i.description="Severity of the issue",i.Keys=Object.keys(i),i.descriptions={fatal:"The issue caused the action to fail and no further checking could be performed",error:"The issue is sufficiently important to cause the action to fail",warning:"The issue is not important enough to cause the action to fail but may cause it to be performed suboptimally or in a way that is not as desired",info:"The issue has no relation to the degree of success of the action"}})(Ks||(Ks={}));var So=class So{constructor(){this.kind=Object.getPrototypeOf(this).constructor.name}};s(So,"Ast");var Yt=So;var Io=class Io extends Yt{};s(Io,"Expression");var U=Io;var Mo=class Mo extends U{};s(Mo,"Term");var qe=Mo;var Lo=class Lo extends qe{constructor(e){super(),this.value=e}toString(){return""+this.value}};s(Lo,"Literal");var k=Lo;var vo=class vo extends U{constructor(){super(),this.items=[]}append(e,t){return this.items.push(new br({op:e,expression:t})),this}toString(){return this.items.map((e,t)=>(t>0?e.op:"")+e.expression).join("")}};s(vo,"ArithmeticExpression");var $e=vo,Po=class Po{constructor(e){Object.assign(this,e)}};s(Po,"ArithmeticExpressionItem");var br=Po;var Fo=class Fo extends qe{constructor(e){super(),this.items=e}toString(){return"["+this.items.map(e=>""+e).join(",")+"]"}};s(Fo,"ArrayExpression");var Te=Fo;var gp=/\w/,ko=class ko extends U{constructor(e){super(),Object.assign(this,e)}toString(){return`${this.left}${gp.test(this.op)?" "+this.op+" ":this.op}${this.right}`}};s(ko,"ComparisonExpression");var Ee=ko;var jo=class jo extends U{constructor(e){super(),Object.assign(this,e),this.op==="&&"&&(this.op="and"),this.op==="||"&&(this.op="or")}toString(){return this.items.map(e=>""+e).join(" "+this.op+" ")}};s(jo,"LogicalExpression");var fe=jo;var Co=class Co extends U{constructor(e){super(),this.expression=e}toString(){return`(${this.expression})`}};s(Co,"NegativeExpression");var Qt=Co;var Uo=class Uo extends U{constructor(e){super(),this.expression=e}toString(){return`(${this.expression})`}};s(Uo,"ParenthesizedExpression");var _e=Uo;var qo=class qo extends k{constructor(e){super(e)}};s(qo,"BooleanLiteral");var Be=qo;import{toDateDef as Dp}from"putil-varhelpers";var $o=class $o extends TypeError{};s($o,"SyntaxError");var Nr=$o,Bo=class Bo extends TypeError{constructor(e){super(typeof e=="string"?e:e==null?void 0:e.message),typeof e=="object"&&Object.assign(this,e)}};s(Bo,"FilterValidationError");var De=Bo,Vo=class Vo extends Error{constructor(e,t){super(e),Object.assign(this,t)}};s(Vo,"FilterParseError");var Dr=Vo;var Rp=/'/g,wp=/(\\)/g,Ap=/\\(.)/g;function bp(i){return i.replace(wp,"\\\\")}s(bp,"escapeString");function Np(i){return i.replace(Ap,"$1")}s(Np,"unescapeString");function Rt(i){return"'"+bp(i).replace(Rp,"\\'")+"'"}s(Rt,"quoteFilterString");function Xt(i){return i&&(i.startsWith("'")||i.startsWith('"'))&&i.endsWith(i.charAt(0))?Np(i.substring(1,i.length-1)):i}s(Xt,"unquoteFilterString");var zs=new Date(0),Ko=class Ko extends k{constructor(e){if(super(""),e instanceof Date){this.value=e.toISOString();return}if(typeof e=="string"&&Dp(e,zs)!==zs){this.value=e;return}throw new De(`Invalid date value "${e}"`)}toString(){return Rt(this.value)}};s(Ko,"DateLiteral");var xe=Ko;var zo=class zo extends k{constructor(){super(null),this.value=null}};s(zo,"NullLiteral");var Ve=zo;var Jo=class Jo extends k{constructor(e){if(super(0),typeof e=="number"||typeof e=="bigint"){this.value=e;return}try{if(typeof e=="string"){if(e.includes(".")){this.value=parseFloat(e);return}let t=Number(e);""+t===e?this.value=t:this.value=BigInt(e);return}}catch{}throw new De(`Invalid number literal ${e}`)}toString(){return typeof this.value=="bigint"?(""+this.value).replace(/n$/,""):""+this.value}};s(Jo,"NumberLiteral");var Oe=Jo;var Wo=class Wo extends k{constructor(e){super(""+e)}};s(Wo,"QualifiedIdentifier");var ue=Wo;var Go=class Go extends k{constructor(e){super(""+e)}toString(){return Rt(this.value)}};s(Go,"StringLiteral");var Ke=Go;var Sp=/^([01]\d|2[0-3]):([0-5]\d)(:[0-5]\d)?(\.(\d+))?$/,Yo=class Yo extends k{constructor(e){if(super(""),e instanceof Date){this.value=Sr(e.getHours())+":"+Sr(e.getMinutes())+(e.getSeconds()?":"+Sr(e.getSeconds()):"")+(e.getMilliseconds()?"."+Sr(e.getMilliseconds()):"");return}if(typeof e=="string"&&Sp.test(e)){this.value=e;return}throw new De(`Invalid time value "${e}"`)}toString(){return Rt(this.value)}};s(Yo,"TimeLiteral");var ze=Yo;function Sr(i){return i<=9?"0"+i:""+i}s(Sr,"pad");import{CharStream as zp,CommonTokenStream as Jp}from"@browsery/antlr4";import{ATNDeserializer as Ip,DFA as Mp,Lexer as Lp,LexerATNSimulator as vp,PredictionContextCache as Pp,Token as Fp}from"@browsery/antlr4";var z=class z extends Lp{constructor(e){super(e),this._interp=new vp(this,z._ATN,z.DecisionsToDFA,new Pp)}get grammarFileName(){return"OpraFilter.g4"}get literalNames(){return z.literalNames}get symbolicNames(){return z.symbolicNames}get ruleNames(){return z.ruleNames}get serializedATN(){return z._serializedATN}get channelNames(){return z.channelNames}get modeNames(){return z.modeNames}static get _ATN(){return z.__ATN||(z.__ATN=new Ip().deserialize(z._serializedATN)),z.__ATN}};s(z,"OpraFilterLexer");var h=z;h.T__0=1;h.T__1=2;h.T__2=3;h.T__3=4;h.T__4=5;h.T__5=6;h.T__6=7;h.T__7=8;h.T__8=9;h.T__9=10;h.T__10=11;h.T__11=12;h.T__12=13;h.T__13=14;h.T__14=15;h.T__15=16;h.T__16=17;h.T__17=18;h.T__18=19;h.T__19=20;h.T__20=21;h.T__21=22;h.T__22=23;h.T__23=24;h.T__24=25;h.T__25=26;h.T__26=27;h.T__27=28;h.T__28=29;h.T__29=30;h.T__30=31;h.T__31=32;h.T__32=33;h.T__33=34;h.IDENTIFIER=35;h.POLAR_OP=36;h.DATE=37;h.DATETIME=38;h.TIME=39;h.NUMBER=40;h.INTEGER=41;h.STRING=42;h.WHITESPACE=43;h.EOF=Fp.EOF;h.channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"];h.literalNames=[null,"'('","')'","'not'","'!'","'.'","'@'","'['","','","']'","'true'","'false'","'null'","'Infinity'","'infinity'","'+'","'-'","'*'","'/'","'<='","'<'","'>'","'>='","'='","'!='","'in'","'!in'","'like'","'!like'","'ilike'","'!ilike'","'and'","'or'","'&&'","'||'"];h.symbolicNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"IDENTIFIER","POLAR_OP","DATE","DATETIME","TIME","NUMBER","INTEGER","STRING","WHITESPACE"];h.modeNames=["DEFAULT_MODE"];h.ruleNames=["T__0","T__1","T__2","T__3","T__4","T__5","T__6","T__7","T__8","T__9","T__10","T__11","T__12","T__13","T__14","T__15","T__16","T__17","T__18","T__19","T__20","T__21","T__22","T__23","T__24","T__25","T__26","T__27","T__28","T__29","T__30","T__31","T__32","T__33","IDENTIFIER","POLAR_OP","DATE","DATETIME","TIME","NUMBER","INTEGER","STRING","WHITESPACE","DIGIT","DATEFORMAT","TIMEFORMAT","TIMEZONEOFFSETFORMAT","ESC","UNICODE","HEX"];h._serializedATN=[4,0,43,426,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,45,2,46,7,46,2,47,7,47,2,48,7,48,2,49,7,49,1,0,1,0,1,1,1,1,1,2,1,2,1,2,1,2,1,3,1,3,1,4,1,4,1,5,1,5,1,6,1,6,1,7,1,7,1,8,1,8,1,9,1,9,1,9,1,9,1,9,1,10,1,10,1,10,1,10,1,10,1,10,1,11,1,11,1,11,1,11,1,11,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,12,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,14,1,14,1,15,1,15,1,16,1,16,1,17,1,17,1,18,1,18,1,18,1,19,1,19,1,20,1,20,1,21,1,21,1,21,1,22,1,22,1,23,1,23,1,23,1,24,1,24,1,24,1,25,1,25,1,25,1,25,1,26,1,26,1,26,1,26,1,26,1,27,1,27,1,27,1,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,28,1,29,1,29,1,29,1,29,1,29,1,29,1,29,1,30,1,30,1,30,1,30,1,31,1,31,1,31,1,32,1,32,1,32,1,33,1,33,1,33,1,34,1,34,5,34,225,8,34,10,34,12,34,228,9,34,1,35,1,35,1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,36,3,36,240,8,36,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,1,37,3,37,256,8,37,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,3,38,266,8,38,1,39,3,39,269,8,39,1,39,4,39,272,8,39,11,39,12,39,273,1,39,1,39,5,39,278,8,39,10,39,12,39,281,9,39,3,39,283,8,39,1,39,1,39,3,39,287,8,39,1,39,4,39,290,8,39,11,39,12,39,291,3,39,294,8,39,1,39,1,39,1,39,1,39,4,39,300,8,39,11,39,12,39,301,3,39,304,8,39,1,40,3,40,307,8,40,1,40,4,40,310,8,40,11,40,12,40,311,1,40,1,40,1,40,1,40,4,40,318,8,40,11,40,12,40,319,3,40,322,8,40,1,41,1,41,1,41,5,41,327,8,41,10,41,12,41,330,9,41,1,41,1,41,1,41,1,41,5,41,336,8,41,10,41,12,41,339,9,41,1,41,3,41,342,8,41,1,42,4,42,345,8,42,11,42,12,42,346,1,42,1,42,1,43,1,43,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,3,44,362,8,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,3,44,371,8,44,1,45,1,45,1,45,1,45,3,45,377,8,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,4,45,389,8,45,11,45,12,45,390,3,45,393,8,45,3,45,395,8,45,1,46,1,46,1,46,3,46,400,8,46,1,46,1,46,1,46,3,46,405,8,46,1,46,1,46,1,46,3,46,410,8,46,3,46,412,8,46,1,47,1,47,1,47,3,47,417,8,47,1,48,1,48,1,48,1,48,1,48,1,48,1,49,1,49,0,0,50,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,27,14,29,15,31,16,33,17,35,18,37,19,39,20,41,21,43,22,45,23,47,24,49,25,51,26,53,27,55,28,57,29,59,30,61,31,63,32,65,33,67,34,69,35,71,36,73,37,75,38,77,39,79,40,81,41,83,42,85,43,87,0,89,0,91,0,93,0,95,0,97,0,99,0,1,0,16,4,0,36,36,65,90,95,95,97,122,5,0,36,36,48,57,65,90,95,95,97,122,2,0,43,43,45,45,1,0,39,39,1,0,34,34,3,0,9,10,13,13,32,32,1,0,48,57,1,0,48,48,1,0,49,57,1,0,49,49,1,0,48,50,1,0,49,51,1,0,48,49,1,0,48,51,1,0,48,53,3,0,48,57,65,70,97,102,453,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,0,0,47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,0,57,1,0,0,0,0,59,1,0,0,0,0,61,1,0,0,0,0,63,1,0,0,0,0,65,1,0,0,0,0,67,1,0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73,1,0,0,0,0,75,1,0,0,0,0,77,1,0,0,0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,0,0,0,85,1,0,0,0,1,101,1,0,0,0,3,103,1,0,0,0,5,105,1,0,0,0,7,109,1,0,0,0,9,111,1,0,0,0,11,113,1,0,0,0,13,115,1,0,0,0,15,117,1,0,0,0,17,119,1,0,0,0,19,121,1,0,0,0,21,126,1,0,0,0,23,132,1,0,0,0,25,137,1,0,0,0,27,146,1,0,0,0,29,155,1,0,0,0,31,157,1,0,0,0,33,159,1,0,0,0,35,161,1,0,0,0,37,163,1,0,0,0,39,166,1,0,0,0,41,168,1,0,0,0,43,170,1,0,0,0,45,173,1,0,0,0,47,175,1,0,0,0,49,178,1,0,0,0,51,181,1,0,0,0,53,185,1,0,0,0,55,190,1,0,0,0,57,196,1,0,0,0,59,202,1,0,0,0,61,209,1,0,0,0,63,213,1,0,0,0,65,216,1,0,0,0,67,219,1,0,0,0,69,222,1,0,0,0,71,229,1,0,0,0,73,239,1,0,0,0,75,255,1,0,0,0,77,265,1,0,0,0,79,303,1,0,0,0,81,321,1,0,0,0,83,341,1,0,0,0,85,344,1,0,0,0,87,350,1,0,0,0,89,352,1,0,0,0,91,376,1,0,0,0,93,411,1,0,0,0,95,413,1,0,0,0,97,418,1,0,0,0,99,424,1,0,0,0,101,102,5,40,0,0,102,2,1,0,0,0,103,104,5,41,0,0,104,4,1,0,0,0,105,106,5,110,0,0,106,107,5,111,0,0,107,108,5,116,0,0,108,6,1,0,0,0,109,110,5,33,0,0,110,8,1,0,0,0,111,112,5,46,0,0,112,10,1,0,0,0,113,114,5,64,0,0,114,12,1,0,0,0,115,116,5,91,0,0,116,14,1,0,0,0,117,118,5,44,0,0,118,16,1,0,0,0,119,120,5,93,0,0,120,18,1,0,0,0,121,122,5,116,0,0,122,123,5,114,0,0,123,124,5,117,0,0,124,125,5,101,0,0,125,20,1,0,0,0,126,127,5,102,0,0,127,128,5,97,0,0,128,129,5,108,0,0,129,130,5,115,0,0,130,131,5,101,0,0,131,22,1,0,0,0,132,133,5,110,0,0,133,134,5,117,0,0,134,135,5,108,0,0,135,136,5,108,0,0,136,24,1,0,0,0,137,138,5,73,0,0,138,139,5,110,0,0,139,140,5,102,0,0,140,141,5,105,0,0,141,142,5,110,0,0,142,143,5,105,0,0,143,144,5,116,0,0,144,145,5,121,0,0,145,26,1,0,0,0,146,147,5,105,0,0,147,148,5,110,0,0,148,149,5,102,0,0,149,150,5,105,0,0,150,151,5,110,0,0,151,152,5,105,0,0,152,153,5,116,0,0,153,154,5,121,0,0,154,28,1,0,0,0,155,156,5,43,0,0,156,30,1,0,0,0,157,158,5,45,0,0,158,32,1,0,0,0,159,160,5,42,0,0,160,34,1,0,0,0,161,162,5,47,0,0,162,36,1,0,0,0,163,164,5,60,0,0,164,165,5,61,0,0,165,38,1,0,0,0,166,167,5,60,0,0,167,40,1,0,0,0,168,169,5,62,0,0,169,42,1,0,0,0,170,171,5,62,0,0,171,172,5,61,0,0,172,44,1,0,0,0,173,174,5,61,0,0,174,46,1,0,0,0,175,176,5,33,0,0,176,177,5,61,0,0,177,48,1,0,0,0,178,179,5,105,0,0,179,180,5,110,0,0,180,50,1,0,0,0,181,182,5,33,0,0,182,183,5,105,0,0,183,184,5,110,0,0,184,52,1,0,0,0,185,186,5,108,0,0,186,187,5,105,0,0,187,188,5,107,0,0,188,189,5,101,0,0,189,54,1,0,0,0,190,191,5,33,0,0,191,192,5,108,0,0,192,193,5,105,0,0,193,194,5,107,0,0,194,195,5,101,0,0,195,56,1,0,0,0,196,197,5,105,0,0,197,198,5,108,0,0,198,199,5,105,0,0,199,200,5,107,0,0,200,201,5,101,0,0,201,58,1,0,0,0,202,203,5,33,0,0,203,204,5,105,0,0,204,205,5,108,0,0,205,206,5,105,0,0,206,207,5,107,0,0,207,208,5,101,0,0,208,60,1,0,0,0,209,210,5,97,0,0,210,211,5,110,0,0,211,212,5,100,0,0,212,62,1,0,0,0,213,214,5,111,0,0,214,215,5,114,0,0,215,64,1,0,0,0,216,217,5,38,0,0,217,218,5,38,0,0,218,66,1,0,0,0,219,220,5,124,0,0,220,221,5,124,0,0,221,68,1,0,0,0,222,226,7,0,0,0,223,225,7,1,0,0,224,223,1,0,0,0,225,228,1,0,0,0,226,224,1,0,0,0,226,227,1,0,0,0,227,70,1,0,0,0,228,226,1,0,0,0,229,230,7,2,0,0,230,72,1,0,0,0,231,232,5,39,0,0,232,233,3,89,44,0,233,234,5,39,0,0,234,240,1,0,0,0,235,236,5,34,0,0,236,237,3,89,44,0,237,238,5,34,0,0,238,240,1,0,0,0,239,231,1,0,0,0,239,235,1,0,0,0,240,74,1,0,0,0,241,242,5,39,0,0,242,243,3,89,44,0,243,244,5,84,0,0,244,245,3,91,45,0,245,246,3,93,46,0,246,247,5,39,0,0,247,256,1,0,0,0,248,249,5,34,0,0,249,250,3,89,44,0,250,251,5,84,0,0,251,252,3,91,45,0,252,253,3,93,46,0,253,254,5,34,0,0,254,256,1,0,0,0,255,241,1,0,0,0,255,248,1,0,0,0,256,76,1,0,0,0,257,258,5,39,0,0,258,259,3,91,45,0,259,260,5,39,0,0,260,266,1,0,0,0,261,262,5,34,0,0,262,263,3,91,45,0,263,264,5,34,0,0,264,266,1,0,0,0,265,257,1,0,0,0,265,261,1,0,0,0,266,78,1,0,0,0,267,269,3,71,35,0,268,267,1,0,0,0,268,269,1,0,0,0,269,271,1,0,0,0,270,272,3,87,43,0,271,270,1,0,0,0,272,273,1,0,0,0,273,271,1,0,0,0,273,274,1,0,0,0,274,282,1,0,0,0,275,279,5,46,0,0,276,278,3,87,43,0,277,276,1,0,0,0,278,281,1,0,0,0,279,277,1,0,0,0,279,280,1,0,0,0,280,283,1,0,0,0,281,279,1,0,0,0,282,275,1,0,0,0,282,283,1,0,0,0,283,293,1,0,0,0,284,286,5,69,0,0,285,287,7,2,0,0,286,285,1,0,0,0,286,287,1,0,0,0,287,289,1,0,0,0,288,290,3,87,43,0,289,288,1,0,0,0,290,291,1,0,0,0,291,289,1,0,0,0,291,292,1,0,0,0,292,294,1,0,0,0,293,284,1,0,0,0,293,294,1,0,0,0,294,304,1,0,0,0,295,296,5,48,0,0,296,297,5,120,0,0,297,299,1,0,0,0,298,300,3,99,49,0,299,298,1,0,0,0,300,301,1,0,0,0,301,299,1,0,0,0,301,302,1,0,0,0,302,304,1,0,0,0,303,268,1,0,0,0,303,295,1,0,0,0,304,80,1,0,0,0,305,307,3,71,35,0,306,305,1,0,0,0,306,307,1,0,0,0,307,309,1,0,0,0,308,310,3,87,43,0,309,308,1,0,0,0,310,311,1,0,0,0,311,309,1,0,0,0,311,312,1,0,0,0,312,322,1,0,0,0,313,314,5,48,0,0,314,315,5,120,0,0,315,317,1,0,0,0,316,318,3,99,49,0,317,316,1,0,0,0,318,319,1,0,0,0,319,317,1,0,0,0,319,320,1,0,0,0,320,322,1,0,0,0,321,306,1,0,0,0,321,313,1,0,0,0,322,82,1,0,0,0,323,328,5,39,0,0,324,327,3,95,47,0,325,327,8,3,0,0,326,324,1,0,0,0,326,325,1,0,0,0,327,330,1,0,0,0,328,326,1,0,0,0,328,329,1,0,0,0,329,331,1,0,0,0,330,328,1,0,0,0,331,342,5,39,0,0,332,337,5,34,0,0,333,336,3,95,47,0,334,336,8,4,0,0,335,333,1,0,0,0,335,334,1,0,0,0,336,339,1,0,0,0,337,335,1,0,0,0,337,338,1,0,0,0,338,340,1,0,0,0,339,337,1,0,0,0,340,342,5,34,0,0,341,323,1,0,0,0,341,332,1,0,0,0,342,84,1,0,0,0,343,345,7,5,0,0,344,343,1,0,0,0,345,346,1,0,0,0,346,344,1,0,0,0,346,347,1,0,0,0,347,348,1,0,0,0,348,349,6,42,0,0,349,86,1,0,0,0,350,351,7,6,0,0,351,88,1,0,0,0,352,353,7,6,0,0,353,354,7,6,0,0,354,355,7,6,0,0,355,356,7,6,0,0,356,361,5,45,0,0,357,358,7,7,0,0,358,362,7,8,0,0,359,360,7,9,0,0,360,362,7,10,0,0,361,357,1,0,0,0,361,359,1,0,0,0,362,363,1,0,0,0,363,370,5,45,0,0,364,365,7,11,0,0,365,371,7,7,0,0,366,367,7,10,0,0,367,371,7,8,0,0,368,369,5,51,0,0,369,371,5,49,0,0,370,364,1,0,0,0,370,366,1,0,0,0,370,368,1,0,0,0,371,90,1,0,0,0,372,373,7,12,0,0,373,377,7,6,0,0,374,375,5,50,0,0,375,377,7,13,0,0,376,372,1,0,0,0,376,374,1,0,0,0,377,378,1,0,0,0,378,379,5,58,0,0,379,380,7,14,0,0,380,381,7,6,0,0,381,394,1,0,0,0,382,383,5,58,0,0,383,384,7,14,0,0,384,385,7,6,0,0,385,392,1,0,0,0,386,388,5,46,0,0,387,389,7,6,0,0,388,387,1,0,0,0,389,390,1,0,0,0,390,388,1,0,0,0,390,391,1,0,0,0,391,393,1,0,0,0,392,386,1,0,0,0,392,393,1,0,0,0,393,395,1,0,0,0,394,382,1,0,0,0,394,395,1,0,0,0,395,92,1,0,0,0,396,412,5,90,0,0,397,404,7,2,0,0,398,400,7,12,0,0,399,398,1,0,0,0,399,400,1,0,0,0,400,401,1,0,0,0,401,405,7,6,0,0,402,403,5,50,0,0,403,405,7,13,0,0,404,399,1,0,0,0,404,402,1,0,0,0,405,409,1,0,0,0,406,407,5,58,0,0,407,408,7,14,0,0,408,410,7,6,0,0,409,406,1,0,0,0,409,410,1,0,0,0,410,412,1,0,0,0,411,396,1,0,0,0,411,397,1,0,0,0,412,94,1,0,0,0,413,416,5,92,0,0,414,417,3,97,48,0,415,417,9,0,0,0,416,414,1,0,0,0,416,415,1,0,0,0,417,96,1,0,0,0,418,419,5,117,0,0,419,420,3,99,49,0,420,421,3,99,49,0,421,422,3,99,49,0,422,423,3,99,49,0,423,98,1,0,0,0,424,425,7,15,0,0,425,100,1,0,0,0,35,0,226,239,255,265,268,273,279,282,286,291,293,301,303,306,311,319,321,326,328,335,337,341,346,361,370,376,390,392,394,399,404,409,411,416,1,0,1,0];h.DecisionsToDFA=h._ATN.decisionToState.map((i,e)=>new Mp(i,e));var Js=h;import{ATN as Ws,ATNDeserializer as kp,DFA as jp,FailedPredicateException as Cp,NoViableAltException as Qo,Parser as Up,ParserATNSimulator as qp,ParserRuleContext as $,PredictionContextCache as $p,RecognitionException as q,Token as Bp}from"@browsery/antlr4";var _=class _ extends Up{get grammarFileName(){return"OpraFilter.g4"}get literalNames(){return _.literalNames}get symbolicNames(){return _.symbolicNames}get ruleNames(){return _.ruleNames}get serializedATN(){return _._serializedATN}createFailedPredicateException(e,t){return new Cp(this,e,t)}constructor(e){super(e),this._interp=new qp(this,_._ATN,_.DecisionsToDFA,new $p)}root(){let e=new Xo(this,this._ctx,this.state);this.enterRule(e,0,_.RULE_root);try{this.enterOuterAlt(e,1),this.state=34,this.expression(0),this.state=35,this.match(_.EOF)}catch(t){if(t instanceof q)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}expression(e){e===void 0&&(e=0);let t=this._ctx,r=this.state,o=new X(this,this._ctx,r),n=o,a=2;this.enterRecursionRule(o,2,_.RULE_expression,e);let p;try{let c;this.enterOuterAlt(o,1);{switch(this.state=48,this._errHandler.sync(this),this._input.LA(1)){case 35:o=new en(this,o),this._ctx=o,n=o,this.state=38,o._left=this.comparisonLeft(),this.state=39,o._operator=this.comparisonOperator(),this.state=40,o._right=this.comparisonRight();break;case 1:o=new Zo(this,o),this._ctx=o,n=o,this.state=42,this.match(_.T__0),this.state=43,this.parenthesizedItem(),this.state=44,this.match(_.T__1);break;case 3:case 4:o=new Ho(this,o),this._ctx=o,n=o,this.state=46,p=this._input.LA(1),p===3||p===4?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this),this.state=47,this.expression(1);break;default:throw new Qo(this)}for(this._ctx.stop=this._input.LT(-1),this.state=56,this._errHandler.sync(this),c=this._interp.adaptivePredict(this._input,1,this._ctx);c!==2&&c!==Ws.INVALID_ALT_NUMBER;){if(c===1){this._parseListeners!=null&&this.triggerExitRuleEvent(),n=o;{if(o=new Zt(this,new X(this,t,r)),this.pushNewRecursionContext(o,a,_.RULE_expression),this.state=50,!this.precpred(this._ctx,3))throw this.createFailedPredicateException("this.precpred(this._ctx, 3)");this.state=51,o._op=this.logicalOperator(),this.state=52,this.expression(4)}}this.state=58,this._errHandler.sync(this),c=this._interp.adaptivePredict(this._input,1,this._ctx)}}}catch(c){if(c instanceof q)o.exception=c,this._errHandler.reportError(this,c),this._errHandler.recover(this,c);else throw c}finally{this.unrollRecursionContexts(t)}return o}comparisonLeft(){let e=new Ir(this,this._ctx,this.state);this.enterRule(e,4,_.RULE_comparisonLeft);try{this.enterOuterAlt(e,1),this.state=59,this.qualifiedIdentifier()}catch(t){if(t instanceof q)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}comparisonRight(){let e=new Mr(this,this._ctx,this.state);this.enterRule(e,6,_.RULE_comparisonRight);try{switch(this.state=65,this._errHandler.sync(this),this._input.LA(1)){case 10:case 11:case 12:case 13:case 14:case 37:case 38:case 39:case 40:case 42:this.enterOuterAlt(e,1),this.state=61,this.value();break;case 35:this.enterOuterAlt(e,2),this.state=62,this.qualifiedIdentifier();break;case 6:this.enterOuterAlt(e,3),this.state=63,this.externalConstant();break;case 7:this.enterOuterAlt(e,4),this.state=64,this.arrayValue();break;default:throw new Qo(this)}}catch(t){if(t instanceof q)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}parenthesizedItem(){let e=new Lr(this,this._ctx,this.state);this.enterRule(e,8,_.RULE_parenthesizedItem);try{this.enterOuterAlt(e,1),this.state=67,this.expression(0)}catch(t){if(t instanceof q)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}value(){let e=new G(this,this._ctx,this.state);this.enterRule(e,10,_.RULE_value);try{switch(this.state=77,this._errHandler.sync(this),this._input.LA(1)){case 40:e=new cn(this,e),this.enterOuterAlt(e,1),this.state=69,this.match(_.NUMBER);break;case 13:case 14:e=new an(this,e),this.enterOuterAlt(e,2),this.state=70,this.infinity();break;case 10:case 11:e=new pn(this,e),this.enterOuterAlt(e,3),this.state=71,this.boolean_();break;case 12:e=new rn(this,e),this.enterOuterAlt(e,4),this.state=72,this.null_();break;case 37:e=new sn(this,e),this.enterOuterAlt(e,5),this.state=73,this.match(_.DATE);break;case 38:e=new on(this,e),this.enterOuterAlt(e,6),this.state=74,this.match(_.DATETIME);break;case 39:e=new tn(this,e),this.enterOuterAlt(e,7),this.state=75,this.match(_.TIME);break;case 42:e=new nn(this,e),this.enterOuterAlt(e,8),this.state=76,this.match(_.STRING);break;default:throw new Qo(this)}}catch(t){if(t instanceof q)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}qualifiedIdentifier(){let e=new Ht(this,this._ctx,this.state);this.enterRule(e,12,_.RULE_qualifiedIdentifier);try{let t;this.enterOuterAlt(e,1);{for(this.state=84,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,4,this._ctx);t!==2&&t!==Ws.INVALID_ALT_NUMBER;)t===1&&(this.state=79,this.identifier(),this.state=80,this.match(_.T__4)),this.state=86,this._errHandler.sync(this),t=this._interp.adaptivePredict(this._input,4,this._ctx);this.state=87,this.identifier()}}catch(t){if(t instanceof q)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}externalConstant(){let e=new vr(this,this._ctx,this.state);this.enterRule(e,14,_.RULE_externalConstant);try{this.enterOuterAlt(e,1),this.state=89,this.match(_.T__5),this.state=90,this.identifier()}catch(t){if(t instanceof q)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}identifier(){let e=new wt(this,this._ctx,this.state);this.enterRule(e,16,_.RULE_identifier);try{this.enterOuterAlt(e,1),this.state=92,this.match(_.IDENTIFIER)}catch(t){if(t instanceof q)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}arrayValue(){let e=new Pr(this,this._ctx,this.state);this.enterRule(e,18,_.RULE_arrayValue);let t;try{this.enterOuterAlt(e,1);{for(this.state=94,this.match(_.T__6),this.state=95,this.value(),this.state=100,this._errHandler.sync(this),t=this._input.LA(1);t===8;)this.state=96,this.match(_.T__7),this.state=97,this.value(),this.state=102,this._errHandler.sync(this),t=this._input.LA(1);this.state=103,this.match(_.T__8)}}catch(r){if(r instanceof q)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}boolean_(){let e=new Fr(this,this._ctx,this.state);this.enterRule(e,20,_.RULE_boolean);let t;try{this.enterOuterAlt(e,1),this.state=105,t=this._input.LA(1),t===10||t===11?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this)}catch(r){if(r instanceof q)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}null_(){let e=new kr(this,this._ctx,this.state);this.enterRule(e,22,_.RULE_null);try{this.enterOuterAlt(e,1),this.state=107,this.match(_.T__11)}catch(t){if(t instanceof q)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}infinity(){let e=new jr(this,this._ctx,this.state);this.enterRule(e,24,_.RULE_infinity);let t;try{this.enterOuterAlt(e,1),this.state=109,t=this._input.LA(1),t===13||t===14?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this)}catch(r){if(r instanceof q)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}arithmeticOperator(){let e=new ln(this,this._ctx,this.state);this.enterRule(e,26,_.RULE_arithmeticOperator);let t;try{this.enterOuterAlt(e,1),this.state=111,t=this._input.LA(1),!(t&-32)&&1<<t&491520?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this)}catch(r){if(r instanceof q)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}comparisonOperator(){let e=new Cr(this,this._ctx,this.state);this.enterRule(e,28,_.RULE_comparisonOperator);let t;try{this.enterOuterAlt(e,1),this.state=113,t=this._input.LA(1),!(t&-32)&&1<<t&2146959360?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this)}catch(r){if(r instanceof q)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}logicalOperator(){let e=new Ur(this,this._ctx,this.state);this.enterRule(e,30,_.RULE_logicalOperator);let t;try{this.enterOuterAlt(e,1),this.state=115,t=this._input.LA(1),!(t-31&-32)&&1<<t-31&15?(this._errHandler.reportMatch(this),this.consume()):this._errHandler.recoverInline(this)}catch(r){if(r instanceof q)e.exception=r,this._errHandler.reportError(this,r),this._errHandler.recover(this,r);else throw r}finally{this.exitRule()}return e}polarityOperator(){let e=new fn(this,this._ctx,this.state);this.enterRule(e,32,_.RULE_polarityOperator);try{this.enterOuterAlt(e,1),this.state=117,this.match(_.POLAR_OP)}catch(t){if(t instanceof q)e.exception=t,this._errHandler.reportError(this,t),this._errHandler.recover(this,t);else throw t}finally{this.exitRule()}return e}sempred(e,t,r){switch(t){case 1:return this.expression_sempred(e,r)}return!0}expression_sempred(e,t){switch(t){case 0:return this.precpred(this._ctx,3)}return!0}static get _ATN(){return _.__ATN||(_.__ATN=new kp().deserialize(_._serializedATN)),_.__ATN}};s(_,"OpraFilterParser");var f=_;f.T__0=1;f.T__1=2;f.T__2=3;f.T__3=4;f.T__4=5;f.T__5=6;f.T__6=7;f.T__7=8;f.T__8=9;f.T__9=10;f.T__10=11;f.T__11=12;f.T__12=13;f.T__13=14;f.T__14=15;f.T__15=16;f.T__16=17;f.T__17=18;f.T__18=19;f.T__19=20;f.T__20=21;f.T__21=22;f.T__22=23;f.T__23=24;f.T__24=25;f.T__25=26;f.T__26=27;f.T__27=28;f.T__28=29;f.T__29=30;f.T__30=31;f.T__31=32;f.T__32=33;f.T__33=34;f.IDENTIFIER=35;f.POLAR_OP=36;f.DATE=37;f.DATETIME=38;f.TIME=39;f.NUMBER=40;f.INTEGER=41;f.STRING=42;f.WHITESPACE=43;f.EOF=Bp.EOF;f.RULE_root=0;f.RULE_expression=1;f.RULE_comparisonLeft=2;f.RULE_comparisonRight=3;f.RULE_parenthesizedItem=4;f.RULE_value=5;f.RULE_qualifiedIdentifier=6;f.RULE_externalConstant=7;f.RULE_identifier=8;f.RULE_arrayValue=9;f.RULE_boolean=10;f.RULE_null=11;f.RULE_infinity=12;f.RULE_arithmeticOperator=13;f.RULE_comparisonOperator=14;f.RULE_logicalOperator=15;f.RULE_polarityOperator=16;f.literalNames=[null,"'('","')'","'not'","'!'","'.'","'@'","'['","','","']'","'true'","'false'","'null'","'Infinity'","'infinity'","'+'","'-'","'*'","'/'","'<='","'<'","'>'","'>='","'='","'!='","'in'","'!in'","'like'","'!like'","'ilike'","'!ilike'","'and'","'or'","'&&'","'||'"];f.symbolicNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"IDENTIFIER","POLAR_OP","DATE","DATETIME","TIME","NUMBER","INTEGER","STRING","WHITESPACE"];f.ruleNames=["root","expression","comparisonLeft","comparisonRight","parenthesizedItem","value","qualifiedIdentifier","externalConstant","identifier","arrayValue","boolean","null","infinity","arithmeticOperator","comparisonOperator","logicalOperator","polarityOperator"];f._serializedATN=[4,1,43,120,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,49,8,1,1,1,1,1,1,1,1,1,5,1,55,8,1,10,1,12,1,58,9,1,1,2,1,2,1,3,1,3,1,3,1,3,3,3,66,8,3,1,4,1,4,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,3,5,78,8,5,1,6,1,6,1,6,5,6,83,8,6,10,6,12,6,86,9,6,1,6,1,6,1,7,1,7,1,7,1,8,1,8,1,9,1,9,1,9,1,9,5,9,99,8,9,10,9,12,9,102,9,9,1,9,1,9,1,10,1,10,1,11,1,11,1,12,1,12,1,13,1,13,1,14,1,14,1,15,1,15,1,16,1,16,1,16,0,1,2,17,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,0,6,1,0,3,4,1,0,10,11,1,0,13,14,1,0,15,18,1,0,19,30,1,0,31,34,117,0,34,1,0,0,0,2,48,1,0,0,0,4,59,1,0,0,0,6,65,1,0,0,0,8,67,1,0,0,0,10,77,1,0,0,0,12,84,1,0,0,0,14,89,1,0,0,0,16,92,1,0,0,0,18,94,1,0,0,0,20,105,1,0,0,0,22,107,1,0,0,0,24,109,1,0,0,0,26,111,1,0,0,0,28,113,1,0,0,0,30,115,1,0,0,0,32,117,1,0,0,0,34,35,3,2,1,0,35,36,5,0,0,1,36,1,1,0,0,0,37,38,6,1,-1,0,38,39,3,4,2,0,39,40,3,28,14,0,40,41,3,6,3,0,41,49,1,0,0,0,42,43,5,1,0,0,43,44,3,8,4,0,44,45,5,2,0,0,45,49,1,0,0,0,46,47,7,0,0,0,47,49,3,2,1,1,48,37,1,0,0,0,48,42,1,0,0,0,48,46,1,0,0,0,49,56,1,0,0,0,50,51,10,3,0,0,51,52,3,30,15,0,52,53,3,2,1,4,53,55,1,0,0,0,54,50,1,0,0,0,55,58,1,0,0,0,56,54,1,0,0,0,56,57,1,0,0,0,57,3,1,0,0,0,58,56,1,0,0,0,59,60,3,12,6,0,60,5,1,0,0,0,61,66,3,10,5,0,62,66,3,12,6,0,63,66,3,14,7,0,64,66,3,18,9,0,65,61,1,0,0,0,65,62,1,0,0,0,65,63,1,0,0,0,65,64,1,0,0,0,66,7,1,0,0,0,67,68,3,2,1,0,68,9,1,0,0,0,69,78,5,40,0,0,70,78,3,24,12,0,71,78,3,20,10,0,72,78,3,22,11,0,73,78,5,37,0,0,74,78,5,38,0,0,75,78,5,39,0,0,76,78,5,42,0,0,77,69,1,0,0,0,77,70,1,0,0,0,77,71,1,0,0,0,77,72,1,0,0,0,77,73,1,0,0,0,77,74,1,0,0,0,77,75,1,0,0,0,77,76,1,0,0,0,78,11,1,0,0,0,79,80,3,16,8,0,80,81,5,5,0,0,81,83,1,0,0,0,82,79,1,0,0,0,83,86,1,0,0,0,84,82,1,0,0,0,84,85,1,0,0,0,85,87,1,0,0,0,86,84,1,0,0,0,87,88,3,16,8,0,88,13,1,0,0,0,89,90,5,6,0,0,90,91,3,16,8,0,91,15,1,0,0,0,92,93,5,35,0,0,93,17,1,0,0,0,94,95,5,7,0,0,95,100,3,10,5,0,96,97,5,8,0,0,97,99,3,10,5,0,98,96,1,0,0,0,99,102,1,0,0,0,100,98,1,0,0,0,100,101,1,0,0,0,101,103,1,0,0,0,102,100,1,0,0,0,103,104,5,9,0,0,104,19,1,0,0,0,105,106,7,1,0,0,106,21,1,0,0,0,107,108,5,12,0,0,108,23,1,0,0,0,109,110,7,2,0,0,110,25,1,0,0,0,111,112,7,3,0,0,112,27,1,0,0,0,113,114,7,4,0,0,114,29,1,0,0,0,115,116,7,5,0,0,116,31,1,0,0,0,117,118,5,36,0,0,118,33,1,0,0,0,6,48,56,65,77,84,100];f.DecisionsToDFA=f._ATN.decisionToState.map((i,e)=>new jp(i,e));var Gs=f,un=class un extends ${constructor(e,t,r){super(t,r),this.parser=e}expression(){return this.getTypedRuleContext(X,0)}EOF(){return this.getToken(f.EOF,0)}get ruleIndex(){return f.RULE_root}enterRule(e){e.enterRoot&&e.enterRoot(this)}exitRule(e){e.exitRoot&&e.exitRoot(this)}accept(e){return e.visitRoot?e.visitRoot(this):e.visitChildren(this)}};s(un,"RootContext");var Xo=un,mn=class mn extends ${constructor(e,t,r){super(t,r),this.parser=e}get ruleIndex(){return f.RULE_expression}copyFrom(e){super.copyFrom(e)}};s(mn,"ExpressionContext");var X=mn,dn=class dn extends X{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}parenthesizedItem(){return this.getTypedRuleContext(Lr,0)}enterRule(e){e.enterParenthesizedExpression&&e.enterParenthesizedExpression(this)}exitRule(e){e.exitParenthesizedExpression&&e.exitParenthesizedExpression(this)}accept(e){return e.visitParenthesizedExpression?e.visitParenthesizedExpression(this):e.visitChildren(this)}};s(dn,"ParenthesizedExpressionContext");var Zo=dn,hn=class hn extends X{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}expression(){return this.getTypedRuleContext(X,0)}enterRule(e){e.enterNegativeExpression&&e.enterNegativeExpression(this)}exitRule(e){e.exitNegativeExpression&&e.exitNegativeExpression(this)}accept(e){return e.visitNegativeExpression?e.visitNegativeExpression(this):e.visitChildren(this)}};s(hn,"NegativeExpressionContext");var Ho=hn,yn=class yn extends X{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}comparisonLeft(){return this.getTypedRuleContext(Ir,0)}comparisonOperator(){return this.getTypedRuleContext(Cr,0)}comparisonRight(){return this.getTypedRuleContext(Mr,0)}enterRule(e){e.enterComparisonExpression&&e.enterComparisonExpression(this)}exitRule(e){e.exitComparisonExpression&&e.exitComparisonExpression(this)}accept(e){return e.visitComparisonExpression?e.visitComparisonExpression(this):e.visitChildren(this)}};s(yn,"ComparisonExpressionContext");var en=yn,Tn=class Tn extends X{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}expression_list(){return this.getTypedRuleContexts(X)}expression(e){return this.getTypedRuleContext(X,e)}logicalOperator(){return this.getTypedRuleContext(Ur,0)}enterRule(e){e.enterLogicalExpression&&e.enterLogicalExpression(this)}exitRule(e){e.exitLogicalExpression&&e.exitLogicalExpression(this)}accept(e){return e.visitLogicalExpression?e.visitLogicalExpression(this):e.visitChildren(this)}};s(Tn,"LogicalExpressionContext");var Zt=Tn,En=class En extends ${constructor(e,t,r){super(t,r),this.parser=e}qualifiedIdentifier(){return this.getTypedRuleContext(Ht,0)}get ruleIndex(){return f.RULE_comparisonLeft}enterRule(e){e.enterComparisonLeft&&e.enterComparisonLeft(this)}exitRule(e){e.exitComparisonLeft&&e.exitComparisonLeft(this)}accept(e){return e.visitComparisonLeft?e.visitComparisonLeft(this):e.visitChildren(this)}};s(En,"ComparisonLeftContext");var Ir=En,_n=class _n extends ${constructor(e,t,r){super(t,r),this.parser=e}value(){return this.getTypedRuleContext(G,0)}qualifiedIdentifier(){return this.getTypedRuleContext(Ht,0)}externalConstant(){return this.getTypedRuleContext(vr,0)}arrayValue(){return this.getTypedRuleContext(Pr,0)}get ruleIndex(){return f.RULE_comparisonRight}enterRule(e){e.enterComparisonRight&&e.enterComparisonRight(this)}exitRule(e){e.exitComparisonRight&&e.exitComparisonRight(this)}accept(e){return e.visitComparisonRight?e.visitComparisonRight(this):e.visitChildren(this)}};s(_n,"ComparisonRightContext");var Mr=_n,xn=class xn extends ${constructor(e,t,r){super(t,r),this.parser=e}expression(){return this.getTypedRuleContext(X,0)}get ruleIndex(){return f.RULE_parenthesizedItem}enterRule(e){e.enterParenthesizedItem&&e.enterParenthesizedItem(this)}exitRule(e){e.exitParenthesizedItem&&e.exitParenthesizedItem(this)}accept(e){return e.visitParenthesizedItem?e.visitParenthesizedItem(this):e.visitChildren(this)}};s(xn,"ParenthesizedItemContext");var Lr=xn,On=class On extends ${constructor(e,t,r){super(t,r),this.parser=e}get ruleIndex(){return f.RULE_value}copyFrom(e){super.copyFrom(e)}};s(On,"ValueContext");var G=On,gn=class gn extends G{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}TIME(){return this.getToken(f.TIME,0)}enterRule(e){e.enterTimeLiteral&&e.enterTimeLiteral(this)}exitRule(e){e.exitTimeLiteral&&e.exitTimeLiteral(this)}accept(e){return e.visitTimeLiteral?e.visitTimeLiteral(this):e.visitChildren(this)}};s(gn,"TimeLiteralContext");var tn=gn,Rn=class Rn extends G{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}null_(){return this.getTypedRuleContext(kr,0)}enterRule(e){e.enterNullLiteral&&e.enterNullLiteral(this)}exitRule(e){e.exitNullLiteral&&e.exitNullLiteral(this)}accept(e){return e.visitNullLiteral?e.visitNullLiteral(this):e.visitChildren(this)}};s(Rn,"NullLiteralContext");var rn=Rn,wn=class wn extends G{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}DATETIME(){return this.getToken(f.DATETIME,0)}enterRule(e){e.enterDateTimeLiteral&&e.enterDateTimeLiteral(this)}exitRule(e){e.exitDateTimeLiteral&&e.exitDateTimeLiteral(this)}accept(e){return e.visitDateTimeLiteral?e.visitDateTimeLiteral(this):e.visitChildren(this)}};s(wn,"DateTimeLiteralContext");var on=wn,An=class An extends G{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}STRING(){return this.getToken(f.STRING,0)}enterRule(e){e.enterStringLiteral&&e.enterStringLiteral(this)}exitRule(e){e.exitStringLiteral&&e.exitStringLiteral(this)}accept(e){return e.visitStringLiteral?e.visitStringLiteral(this):e.visitChildren(this)}};s(An,"StringLiteralContext");var nn=An,bn=class bn extends G{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}DATE(){return this.getToken(f.DATE,0)}enterRule(e){e.enterDateLiteral&&e.enterDateLiteral(this)}exitRule(e){e.exitDateLiteral&&e.exitDateLiteral(this)}accept(e){return e.visitDateLiteral?e.visitDateLiteral(this):e.visitChildren(this)}};s(bn,"DateLiteralContext");var sn=bn,Nn=class Nn extends G{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}infinity(){return this.getTypedRuleContext(jr,0)}enterRule(e){e.enterInfinityLiteral&&e.enterInfinityLiteral(this)}exitRule(e){e.exitInfinityLiteral&&e.exitInfinityLiteral(this)}accept(e){return e.visitInfinityLiteral?e.visitInfinityLiteral(this):e.visitChildren(this)}};s(Nn,"InfinityLiteralContext");var an=Nn,Dn=class Dn extends G{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}boolean_(){return this.getTypedRuleContext(Fr,0)}enterRule(e){e.enterBooleanLiteral&&e.enterBooleanLiteral(this)}exitRule(e){e.exitBooleanLiteral&&e.exitBooleanLiteral(this)}accept(e){return e.visitBooleanLiteral?e.visitBooleanLiteral(this):e.visitChildren(this)}};s(Dn,"BooleanLiteralContext");var pn=Dn,Sn=class Sn extends G{constructor(e,t){super(e,t.parentCtx,t.invokingState),super.copyFrom(t)}NUMBER(){return this.getToken(f.NUMBER,0)}enterRule(e){e.enterNumberLiteral&&e.enterNumberLiteral(this)}exitRule(e){e.exitNumberLiteral&&e.exitNumberLiteral(this)}accept(e){return e.visitNumberLiteral?e.visitNumberLiteral(this):e.visitChildren(this)}};s(Sn,"NumberLiteralContext");var cn=Sn,In=class In extends ${constructor(e,t,r){super(t,r),this.parser=e}identifier_list(){return this.getTypedRuleContexts(wt)}identifier(e){return this.getTypedRuleContext(wt,e)}get ruleIndex(){return f.RULE_qualifiedIdentifier}enterRule(e){e.enterQualifiedIdentifier&&e.enterQualifiedIdentifier(this)}exitRule(e){e.exitQualifiedIdentifier&&e.exitQualifiedIdentifier(this)}accept(e){return e.visitQualifiedIdentifier?e.visitQualifiedIdentifier(this):e.visitChildren(this)}};s(In,"QualifiedIdentifierContext");var Ht=In,Mn=class Mn extends ${constructor(e,t,r){super(t,r),this.parser=e}identifier(){return this.getTypedRuleContext(wt,0)}get ruleIndex(){return f.RULE_externalConstant}enterRule(e){e.enterExternalConstant&&e.enterExternalConstant(this)}exitRule(e){e.exitExternalConstant&&e.exitExternalConstant(this)}accept(e){return e.visitExternalConstant?e.visitExternalConstant(this):e.visitChildren(this)}};s(Mn,"ExternalConstantContext");var vr=Mn,Ln=class Ln extends ${constructor(e,t,r){super(t,r),this.parser=e}IDENTIFIER(){return this.getToken(f.IDENTIFIER,0)}get ruleIndex(){return f.RULE_identifier}enterRule(e){e.enterIdentifier&&e.enterIdentifier(this)}exitRule(e){e.exitIdentifier&&e.exitIdentifier(this)}accept(e){return e.visitIdentifier?e.visitIdentifier(this):e.visitChildren(this)}};s(Ln,"IdentifierContext");var wt=Ln,vn=class vn extends ${constructor(e,t,r){super(t,r),this.parser=e}value_list(){return this.getTypedRuleContexts(G)}value(e){return this.getTypedRuleContext(G,e)}get ruleIndex(){return f.RULE_arrayValue}enterRule(e){e.enterArrayValue&&e.enterArrayValue(this)}exitRule(e){e.exitArrayValue&&e.exitArrayValue(this)}accept(e){return e.visitArrayValue?e.visitArrayValue(this):e.visitChildren(this)}};s(vn,"ArrayValueContext");var Pr=vn,Pn=class Pn extends ${constructor(e,t,r){super(t,r),this.parser=e}get ruleIndex(){return f.RULE_boolean}enterRule(e){e.enterBoolean&&e.enterBoolean(this)}exitRule(e){e.exitBoolean&&e.exitBoolean(this)}accept(e){return e.visitBoolean?e.visitBoolean(this):e.visitChildren(this)}};s(Pn,"BooleanContext");var Fr=Pn,Fn=class Fn extends ${constructor(e,t,r){super(t,r),this.parser=e}get ruleIndex(){return f.RULE_null}enterRule(e){e.enterNull&&e.enterNull(this)}exitRule(e){e.exitNull&&e.exitNull(this)}accept(e){return e.visitNull?e.visitNull(this):e.visitChildren(this)}};s(Fn,"NullContext");var kr=Fn,kn=class kn extends ${constructor(e,t,r){super(t,r),this.parser=e}get ruleIndex(){return f.RULE_infinity}enterRule(e){e.enterInfinity&&e.enterInfinity(this)}exitRule(e){e.exitInfinity&&e.exitInfinity(this)}accept(e){return e.visitInfinity?e.visitInfinity(this):e.visitChildren(this)}};s(kn,"InfinityContext");var jr=kn,jn=class jn extends ${constructor(e,t,r){super(t,r),this.parser=e}get ruleIndex(){return f.RULE_arithmeticOperator}enterRule(e){e.enterArithmeticOperator&&e.enterArithmeticOperator(this)}exitRule(e){e.exitArithmeticOperator&&e.exitArithmeticOperator(this)}accept(e){return e.visitArithmeticOperator?e.visitArithmeticOperator(this):e.visitChildren(this)}};s(jn,"ArithmeticOperatorContext");var ln=jn,Cn=class Cn extends ${constructor(e,t,r){super(t,r),this.parser=e}get ruleIndex(){return f.RULE_comparisonOperator}enterRule(e){e.enterComparisonOperator&&e.enterComparisonOperator(this)}exitRule(e){e.exitComparisonOperator&&e.exitComparisonOperator(this)}accept(e){return e.visitComparisonOperator?e.visitComparisonOperator(this):e.visitChildren(this)}};s(Cn,"ComparisonOperatorContext");var Cr=Cn,Un=class Un extends ${constructor(e,t,r){super(t,r),this.parser=e}get ruleIndex(){return f.RULE_logicalOperator}enterRule(e){e.enterLogicalOperator&&e.enterLogicalOperator(this)}exitRule(e){e.exitLogicalOperator&&e.exitLogicalOperator(this)}accept(e){return e.visitLogicalOperator?e.visitLogicalOperator(this):e.visitChildren(this)}};s(Un,"LogicalOperatorContext");var Ur=Un,qn=class qn extends ${constructor(e,t,r){super(t,r),this.parser=e}POLAR_OP(){return this.getToken(f.POLAR_OP,0)}get ruleIndex(){return f.RULE_polarityOperator}enterRule(e){e.enterPolarityOperator&&e.enterPolarityOperator(this)}exitRule(e){e.exitPolarityOperator&&e.exitPolarityOperator(this)}accept(e){return e.visitPolarityOperator?e.visitPolarityOperator(this):e.visitChildren(this)}};s(qn,"PolarityOperatorContext");var fn=qn;import{ParseTreeVisitor as Vp}from"@browsery/antlr4";var $n=class $n extends k{constructor(e){super(""+e)}toString(){return"@"+super.toString()}};s($n,"ExternalConstant");var qr=$n;var Bn=class Bn extends Vp{constructor(e){super(),this._timeZone=e==null?void 0:e.timeZone}visitChildren(e){let t=super.visitChildren(e);return Array.isArray(t)&&t.length<2?t[0]:t??e.getText()}defaultResult(){}visitRoot(e){return this.visit(e.expression())}visitParenthesizedExpression(e){let t=this.visit(e.parenthesizedItem());return new _e(t)}visitParenthesizedItem(e){return this.visit(e.expression())}visitNegativeExpression(e){let t=this.visit(e.expression());return new Qt(t)}visitComparisonExpression(e){return new Ee({op:e.comparisonOperator().getText(),left:this.visit(e.comparisonLeft()),right:this.visit(e.comparisonRight())})}visitLogicalExpression(e){let t=[],r=s((o,n)=>{for(let a of o){if(a instanceof Zt&&a.logicalOperator().getText()===n){r(a.expression_list(),a.logicalOperator().getText());continue}let p=this.visit(a);t.push(p)}},"wrapChildren");return r(e.expression_list(),e.logicalOperator().getText()),new fe({op:e.logicalOperator().getText(),items:t})}visitQualifiedIdentifier(e){return new ue(e.getText())}visitExternalConstant(e){return new qr(e.identifier().getText())}visitNullLiteral(){return new Ve}visitBooleanLiteral(e){return new Be(e.getText()==="true")}visitNumberLiteral(e){return new Oe(e.getText())}visitStringLiteral(e){return new Ke(Xt(e.getText()))}visitInfinityLiteral(){return new Oe(1/0)}visitDateLiteral(e){return new xe(Xt(e.getText()))}visitDateTimeLiteral(e){return new xe(Xt(e.getText()))}visitTimeLiteral(e){return new ze(Xt(e.getText()))}visitArrayValue(e){return new Te(e.value_list().map(t=>this.visit(t)))}};s(Bn,"FilterTreeVisitor");var er=Bn;import{ErrorListener as Kp}from"@browsery/antlr4";var Vn=class Vn extends Kp{constructor(e){super(),this.errors=e}syntaxError(e,t,r,o,n,a){this.errors.push(new Dr(n,{recognizer:e,offendingSymbol:t,line:r,column:o,e:a}))}};s(Vn,"OpraErrorListener");var tr=Vn;function Kn(i,e){let t=new zp(i),r=new Js(t),o=new Jp(r),n=new Gs(o);n.buildParseTrees=!0;let a=[],p=new tr(a);r.removeErrorListeners(),r.addErrorListener(p),n.removeErrorListeners(),n.addErrorListener(p);let c=n.root();if(a.length){let l=[];for(let d of a)l.push(d.message+(i.includes(`
8
+ `)?" at line: "+d.line+" column: "+d.column:" at column: "+d.column));let x=new Nr(l.join(`
9
+ `));throw x.errors=a,x}return e=e||new er,e.visit(c)}s(Kn,"parse");var zn=class zn{constructor(e,t){if(this._rules=new N,Object.defineProperty(this,"_rules",{value:new N(null,{caseSensitive:t==null?void 0:t.caseSensitive}),enumerable:!1}),e)for(let[r,o]of Object.entries(e))this.set(r,o)}set(e,t){let r=typeof(t==null?void 0:t.operators)=="string"?t.operators.split(/\s*[,| ]\s*/):t==null?void 0:t.operators;this._rules.set(e,y({...t,operators:r}))}normalizeFilter(e,t){if(!e)return;let r=typeof e=="string"?Kn(e):e;if(r instanceof Ee){if(this.normalizeFilter(r.left,t),!(r.left instanceof ue&&r.left.field))throw new TypeError("Invalid filter query. Left side should be a data field.");let o=this._rules.get(r.left.value);if(!o)throw new ye({message:w("error:UNACCEPTED_FILTER_FIELD",{field:r.left.value}),code:"UNACCEPTED_FILTER_FIELD",details:{field:r.left.value}});if(o.operators&&!o.operators.includes(r.op))throw new ye({message:w("error:UNACCEPTED_FILTER_OPERATION",{field:r.left.value}),code:"UNACCEPTED_FILTER_OPERATION",details:{field:r.left.value,operator:r.op}});return this.normalizeFilter(r.right,t),r}return r instanceof fe?(r.items.forEach(o=>this.normalizeFilter(o,t)),r):r instanceof $e?(r.items.forEach(o=>this.normalizeFilter(o.expression,t)),r):r instanceof Te?(r.items.forEach(o=>this.normalizeFilter(o,t)),r):r instanceof _e?(this.normalizeFilter(r.expression,t),r):(r instanceof ue&&t&&(r.value=t.normalizeFieldPath(r.value),r.field=t.getField(r.value),r.dataType=r.field.type),r)}toJSON(){return this._rules.toObject()}[Symbol.iterator](){return this._rules.entries()}};s(zn,"FilterRules");var ge=zn;var rr={};fs(rr,{$and:()=>Gp,$arithmetic:()=>uc,$array:()=>Ys,$date:()=>Yp,$eq:()=>Hp,$field:()=>Zp,$gt:()=>tc,$gte:()=>rc,$ilike:()=>cc,$in:()=>nc,$like:()=>ac,$lt:()=>ic,$lte:()=>oc,$ne:()=>ec,$notILike:()=>lc,$notIn:()=>sc,$notLike:()=>pc,$number:()=>Xp,$or:()=>Wp,$paren:()=>fc,$time:()=>Qp,ArithmeticExpression:()=>$e,ArithmeticExpressionItem:()=>br,ArrayExpression:()=>Te,Ast:()=>Yt,BooleanLiteral:()=>Be,ComparisonExpression:()=>Ee,DateLiteral:()=>xe,Expression:()=>U,FilterTreeVisitor:()=>er,Literal:()=>k,LogicalExpression:()=>fe,NegativeExpression:()=>Qt,NullLiteral:()=>Ve,NumberLiteral:()=>Oe,OpraErrorListener:()=>tr,ParenthesizedExpression:()=>_e,QualifiedIdentifier:()=>ue,StringLiteral:()=>Ke,Term:()=>qe,TimeLiteral:()=>ze,parse:()=>Kn});function Wp(...i){return new fe({op:"or",items:i})}s(Wp,"$or");function Gp(...i){return new fe({op:"and",items:i})}s(Gp,"$and");function Yp(i){return new xe(i)}s(Yp,"$date");function Qp(i){return new ze(i)}s(Qp,"$time");function Xp(i){return new Oe(i)}s(Xp,"$number");function Ys(...i){return new Te(i.map($r))}s(Ys,"$array");function Zp(i){return new ue(i)}s(Zp,"$field");function Hp(i,e){return ie("=",i,e)}s(Hp,"$eq");function ec(i,e){return ie("!=",i,e)}s(ec,"$ne");function tc(i,e){return ie(">",i,e)}s(tc,"$gt");function rc(i,e){return ie(">=",i,e)}s(rc,"$gte");function ic(i,e){return ie("<",i,e)}s(ic,"$lt");function oc(i,e){return ie("<=",i,e)}s(oc,"$lte");function nc(i,e){return ie("in",i,e)}s(nc,"$in");function sc(i,e){return ie("!in",i,e)}s(sc,"$notIn");function ac(i,e){return ie("like",i,e)}s(ac,"$like");function pc(i,e){return ie("!like",i,e)}s(pc,"$notLike");function cc(i,e){return ie("ilike",i,e)}s(cc,"$ilike");function lc(i,e){return ie("!ilike",i,e)}s(lc,"$notILike");function fc(i){return new _e(i)}s(fc,"$paren");function uc(i){let e=new $e;return e.add=t=>(e.append("+",At(t)),e),e.sub=t=>(e.append("-",At(t)),e),e.mul=t=>(e.append("*",At(t)),e),e.div=t=>(e.append("/",At(t)),e),e.append("+",$r(i)),e}s(uc,"$arithmetic");function ie(i,e,t){let r=$r(e),o=$r(t);return new Ee({op:i,left:r,right:o})}s(ie,"comparisonExpression");var $r=s(i=>Array.isArray(i)?Ys(...i.map(At)):At(i),"wrapEntryValue"),At=s(i=>i instanceof U?i:typeof i=="boolean"?new Be(i):typeof i=="number"||typeof i=="bigint"?new Oe(i):i==null?new Ve:i instanceof Date?new xe(i):new Ke(""+i),"_wrapEntryValue");var bt,oe=(bt=class{constructor(e){e&&Object.assign(this,e)}[T](e,t){let r=e.dataType?t.node.getComplexType(e.dataType):t.node.getComplexType("object"),o=e.rules?new ge(e.rules):void 0;return mc(r,o)}[O](){return dc}toJSON(e,t){let r=e.dataType?t.node.getComplexType(e.dataType):t.node.getComplexType("object");return{dataType:r.name?r.name:r.toJSON(),rules:e.rules}}},s(bt,"FilterType"),bt);Jn([u.Attribute({description:"Data type which filtering fields belong to"}),Wn("design:type",Object)],oe.prototype,"dataType",void 0);Jn([u.Attribute({description:"Stringified JSON object defines filtering rules",format:"string"}),Wn("design:type",Object)],oe.prototype,"rules",void 0);oe=Jn([u({description:"A query filter",nameMappings:{js:"object",json:"string"}}),Wn("design:paramtypes",[Object])],oe);var mc=s((i,e)=>Qs("decodeFilter",(t,r,o)=>{if(typeof t=="string")try{let n=rr.parse(t);return e?e.normalizeFilter(n,i):n}catch(n){r.fail(o,`Not a valid filter expression. ${n.message}`,t);return}r.fail(o,"Nt a valid filter expression string",t)}),"decodeFilter"),dc=Qs("encodeFilter",(i,e,t)=>{if(i instanceof rr.Ast)return i.toString();e.fail(t,"Not a valid filter expression",i)});import{__decorate as hc,__metadata as yc}from"tslib";import{vg as Xs}from"valgen";var Nt,Br=(Nt=class{constructor(e){e&&Object.assign(this,e)}[T](){return Xs.isObjectId({coerce:!0})}[O](){return Xs.isObjectId({coerce:!0})}},s(Nt,"ObjectIdType"),Nt);Br=hc([u({description:"A MongoDB ObjectID value",nameMappings:{js:"object",json:"string"}}),yc("design:paramtypes",[Object])],Br);import{__decorate as me,__metadata as de}from"tslib";var Dt,Z=(Dt=class{constructor(e){e&&Object.assign(this,e)}},s(Dt,"OperationResult"),Dt);me([P(),de("design:type",Number)],Z.prototype,"affected",void 0);me([P(),de("design:type",Number)],Z.prototype,"totalMatches",void 0);me([P(),de("design:type",String)],Z.prototype,"context",void 0);me([P(),de("design:type",String)],Z.prototype,"type",void 0);me([P(),de("design:type",String)],Z.prototype,"message",void 0);me([P({type:"any"}),de("design:type",Object)],Z.prototype,"payload",void 0);me([P({type:"object"}),de("design:type",Array)],Z.prototype,"errors",void 0);Z=me([H({description:"Operation result"}),de("design:paramtypes",[Object])],Z);(function(i){function e(t){var o;let r=(o=class extends i{constructor(...a){super(...a)}},s(o,"OperationResult_"),o);return me([P({type:t,required:!0}),de("design:type",Object)],r.prototype,"payload",void 0),r=me([H({embedded:!0}),de("design:paramtypes",[Object])],r),r}s(e,"forPayload"),i.forPayload=e})(Z||(Z={}));import{__decorate as Gn,__metadata as Yn}from"tslib";import{vg as Vr}from"valgen";var Tc=/^([0-1][0-9]|2[0-4]):([0-5][0-9])(?::([0-5][0-9]))?$/,St,It=(St=class{constructor(e){e&&Object.assign(this,e)}[T](e){let t=Vr.matches(Tc,{formatName:"time",coerce:!0}),r=[];return e.minValue&&r.push(Vr.isGte(e.minValue)),e.maxValue&&r.push(Vr.isLte(e.maxValue)),r.length>0?Vr.pipe([t,...r],{returnIndex:0}):t}[O](e){return this[T](e)}},s(St,"TimeType"),St);Gn([u.Attribute({description:"Minimum value"}),Yn("design:type",String)],It.prototype,"minValue",void 0);Gn([u.Attribute({description:"Maximum value"}),Yn("design:type",String)],It.prototype,"maxValue",void 0);It=Gn([u({description:"Time string in 24h format",nameMappings:{js:"string",json:"string"}}).Example("18:23:00","Full time value").Example("18:23:00","Time value without seconds"),Yn("design:paramtypes",[Object])],It);import{__decorate as Ec,__metadata as _c}from"tslib";import{vg as Zs}from"valgen";var Mt,Kr=(Mt=class{constructor(e){e&&Object.assign(this,e)}[T](){return Zs.isURL({coerce:!0})}[O](){return Zs.isURL({coerce:!0})}},s(Mt,"UrlType"),Mt);Kr=Ec([u({description:"A Uniform Resource Identifier Reference (RFC 3986 icon) value",nameMappings:{js:"string",json:"string"}}).Example("http://tempuri.org"),_c("design:paramtypes",[Object])],Kr);import{__decorate as ea,__metadata as ta}from"tslib";import{vg as Hs}from"valgen";var Lt,ir=(Lt=class{constructor(e){e&&Object.assign(this,e)}[T](e){return Hs.isUUID(e==null?void 0:e.version,{coerce:!0})}[O](e){return Hs.isUUID(e==null?void 0:e.version,{coerce:!0})}},s(Lt,"UuidType"),Lt);ea([u.Attribute({description:"Version of the UUID"}),ta("design:type",Number)],ir.prototype,"version",void 0);ir=ea([u({description:"A Universal Unique Identifier (UUID) value",nameMappings:{js:"string",json:"string"}}),ta("design:paramtypes",[Object])],ir);function Se(i,e,t){let r=hr(e.pick,e.omit),o=typeof i=="string"?i.charAt(0).toUpperCase()+i.substring(1):i.name,n=(t==null?void 0:t.name)||o+"Mapped",a={[n]:class{constructor(){typeof i=="function"&&ur(this,i,r)}}}[n];if(typeof i=="function"&&fr(a.prototype,i.prototype),typeof i=="function"){let c=Reflect.getOwnMetadata(E,i);if(!c)throw new TypeError(`Class "${i}" doesn't have datatype metadata information`);if(!(c.kind===m.ComplexType.Kind||c.kind===m.MappedType.Kind||c.kind===m.MixinType.Kind))throw new TypeError(`Class "${i}" is not a ${m.ComplexType.Kind}`)}let p={...t,kind:"MappedType",base:i};return e.pick&&(p.pick=e.pick),e.omit&&(p.omit=e.omit),e.partial&&(p.partial=e.partial),e.required&&(p.required=e.required),Reflect.defineMetadata(E,p,a),typeof i=="function"&&ke._applyMixin(a,i,{...e,isInheritedPredicate:r}),a}s(Se,"createMappedClass");function z3(i,e,t){return Se(i,{omit:e},t)}s(z3,"OmitType");function Y3(i,...e){let t=Array.isArray(e[0])?e[0]:!0,r=Array.isArray(e[0])?e[1]:e[0];return Se(i,{partial:t},r)}s(Y3,"PartialType");function H3(i,e,t){return Se(i,{pick:e},t)}s(H3,"PickType");import{__decorate as xc,__metadata as Oc}from"tslib";import{isAny as ra}from"valgen";var vt,zr=(vt=class{constructor(e){e&&Object.assign(this,e)}[T](){return ra}[O](){return ra}},s(vt,"AnyType"),vt);zr=xc([u({description:"Represents any value"}),Oc("design:paramtypes",[Object])],zr);import{__decorate as gc,__metadata as Rc}from"tslib";import{toBigint as oa,vg as Hn}from"valgen";import{__decorate as Xn,__metadata as Zn}from"tslib";import{toNumber as ia,vg as Qn}from"valgen";var Pt,he=(Pt=class{constructor(e){e&&Object.assign(this,e)}[T](e){let t=[];return e.minValue&&t.push(Qn.isGte(e.minValue)),e.maxValue&&t.push(Qn.isLte(e.maxValue)),t.length>0?Qn.pipe([ia,...t],{returnIndex:0}):ia}[O](e){return this[T](e)}},s(Pt,"NumberType"),Pt);Xn([u.Attribute({description:"Determines the minimum value"}),Zn("design:type",Number)],he.prototype,"minValue",void 0);Xn([u.Attribute({description:"Determines the maximum value"}),Zn("design:type",Number)],he.prototype,"maxValue",void 0);he=Xn([u({description:"Both Integer as well as Floating-Point numbers",nameMappings:{js:"number",json:"number"}}),Zn("design:paramtypes",[Object])],he);var Ft,Jr=(Ft=class extends he{constructor(e){super(e)}[T](e){let t=[];return e.minValue&&t.push(Hn.isGte(e.minValue)),e.maxValue&&t.push(Hn.isLte(e.maxValue)),t.length>0?Hn.pipe([oa,...t],{returnIndex:0}):oa}[O](e){return this[T](e)}},s(Ft,"BigintType"),Ft);Jr=gc([u({description:"BigInt number",nameMappings:{js:"bigint",json:"string"}}),Rc("design:paramtypes",[Object])],Jr);import{__decorate as wc,__metadata as Ac}from"tslib";import{toBoolean as na}from"valgen";var kt,Wr=(kt=class{constructor(e){e&&Object.assign(this,e)}[T](){return na}[O](){return na}},s(kt,"BooleanType"),kt);Wr=wc([u({description:"Simple true/false value",nameMappings:{js:"boolean",json:"boolean"}}),Ac("design:paramtypes",[Object])],Wr);import{__decorate as bc,__metadata as Nc}from"tslib";import{toInteger as sa,vg as es}from"valgen";var jt,Je=(jt=class extends he{constructor(e){super(e)}[T](e){let t=[];return e.minValue&&t.push(es.isGte(e.minValue)),e.maxValue&&t.push(es.isLte(e.maxValue)),t.length>0?es.pipe([sa,...t],{returnIndex:0}):sa}[O](e){return this[T](e)}},s(jt,"IntegerType"),jt);Je=bc([u({description:"An integer number",nameMappings:{js:"number",json:"number"}}),Nc("design:paramtypes",[Object])],Je);import{__decorate as Dc,__metadata as Sc}from"tslib";import{isNull as aa}from"valgen";var Ct,Gr=(Ct=class{constructor(e){e&&Object.assign(this,e)}[T](){return aa}[O](){return aa}},s(Ct,"NullType"),Ct);Gr=Dc([u({description:"A Null value",nameMappings:{js:"null",json:"null"}}),Sc("design:paramtypes",[Object])],Gr);import{__decorate as Ic,__metadata as Mc}from"tslib";var Ut,Yr=(Ut=class{constructor(e){e&&Object.assign(this,e)}},s(Ut,"ObjectType"),Ut);Yr=Ic([H({name:"object",description:"A non modelled object",additionalFields:!0}),Mc("design:paramtypes",[Object])],Yr);import{__decorate as or,__metadata as nr}from"tslib";import{toString as pa,vg as Qr}from"valgen";var qt,Ie=(qt=class{constructor(e){e&&Object.assign(this,e)}[T](e){let t=[];if(e.pattern){let r=e.patternName;r||(r=Reflect.getMetadata(E,Object.getPrototypeOf(this).constructor).name),t.push(Qr.matches(e.pattern,{formatName:r}))}return e.minLength&&t.push(Qr.lengthMin(e.minLength)),e.maxLength&&t.push(Qr.lengthMax(e.maxLength)),t.length>0?Qr.pipe([pa,...t],{returnIndex:0}):pa}[O](e){return this[T](e)}},s(qt,"StringType"),qt);or([u.Attribute({description:"Regex pattern to be used for validation"}),nr("design:type",Object)],Ie.prototype,"pattern",void 0);or([u.Attribute({description:"Name of the pattern"}),nr("design:type",String)],Ie.prototype,"patternName",void 0);or([u.Attribute({description:"Minimum number of characters"}),nr("design:type",Number)],Ie.prototype,"minLength",void 0);or([u.Attribute({description:"Minimum number of characters"}),nr("design:type",Number)],Ie.prototype,"maxLength",void 0);Ie=or([u({description:"A sequence of characters",nameMappings:{js:"string",json:"string"}}),nr("design:paramtypes",[Object])],Ie);function s_(i,...e){let t=Array.isArray(e[0])?e[0]:!0,r=Array.isArray(e[0])?e[1]:e[0];return Se(i,{required:t},r)}s(s_,"RequiredType");M.Entity={};M.Entity.Create=function(i,e){var n;let t;typeof i=="object"&&!i[E]?t=i:t={...e,type:i};let r=[],o=C(r,{method:"POST",...t,composition:"Entity.Create",requestBody:{immediateFetch:!0,...t.requestBody,required:!0}});return o.QueryParam("projection",{description:"Determines fields projection",type:new re({dataType:t.type,allowSigns:"each"}),isArray:!0,arraySeparator:","}).RequestContent(((n=t.requestBody)==null?void 0:n.type)||t.type).Response(I.CREATED,{description:'Operation is successful. Returns OperationResult with "payload" field that contains the created resource.',contentType:v.opra_response_json,type:t.type,partial:"deep"}).Response(I.UNPROCESSABLE_ENTITY,{description:"The request was well-formed but was unable to process operation due to one or many errors.",contentType:v.opra_response_json}),r.push(a=>{let p=a.compositionOptions=a.compositionOptions||{};p.type=We(t.type)}),o};M.Entity.Delete=function(i,e){let t;typeof i=="object"&&!i[E]?t=i:t={...e,type:i};let r=[],o=C(r,{method:"DELETE",...t,composition:"Entity.Delete"});return o.Response(I.OK,{description:'Operation is successful. Returns OperationResult with "affected" field.',contentType:v.opra_response_json}).Response(I.UNPROCESSABLE_ENTITY,{description:"The request was well-formed but was unable to process operation due to one or many errors.",contentType:v.opra_response_json}),o.KeyParam=(n,a)=>{let p=typeof a=="string"||typeof a=="function"?{name:n,location:"path",type:a,keyParam:!0}:{...a,name:n,location:"path",keyParam:!0};return o.PathParam(n,p),r.push(c=>{var l;(l=c.path)!=null&&l.includes(":"+n)||(c.path=(c.path||"")+"@:"+n),c.mergePath=!0}),o},r.push(n=>{let a=n.compositionOptions=n.compositionOptions||{};a.type=We(t.type)}),o};M.Entity.DeleteMany=function(i,e){let t;typeof i=="object"&&!i[E]?t=i:t={...e,type:i};let r=[],o=new ge,n=new oe({dataType:t.type});n.rules={};let a=C(r,{method:"DELETE",...t,composition:"Entity.DeleteMany"});return a.Response(I.OK,{description:'Operation is successful. Returns OperationResult with "affected" field.',contentType:v.opra_response_json}).Response(I.UNPROCESSABLE_ENTITY,{description:"The request was well-formed but was unable to process operation due to one or many errors.",contentType:v.opra_response_json}).QueryParam("filter",{type:n,description:"Determines filter fields"}),r.push(p=>{let c=p.compositionOptions=p.compositionOptions||{};c.type=We(t.type)}),a.Filter=(p,c,l)=>(r.push(()=>{o.set(p,{operators:c,description:l}),n.rules=o.toJSON()}),a),a};M.Entity.FindMany=function(i,e){let t;typeof i=="object"&&!i[E]?t=i:t={...e,type:i};let r=[],o=new ge,n=new oe({dataType:t.type});n.rules={};let a=C(r,{method:"GET",...t,composition:"Entity.FindMany"});return a.Response(I.OK,{description:'Operation is successful. Returns OperationResult with "payload" field that contains list of resources.',contentType:v.opra_response_json,type:t.type,partial:"deep",isArray:!0}).Response(I.UNPROCESSABLE_ENTITY,{description:"The request was well-formed but was unable to process operation due to one or many errors.",contentType:v.opra_response_json}).QueryParam("limit",{description:"Determines number of returning instances",type:new Je({minValue:1,maxValue:t.maxLimit})}).QueryParam("skip",{description:"Determines number of returning instances",type:new Je({minValue:1})}).QueryParam("count",{description:"Counts all matching instances if enabled",type:Boolean}).QueryParam("projection",{description:"Determines fields projection",type:new re({dataType:t.type,allowSigns:"each"}),isArray:!0,arraySeparator:","}).QueryParam("filter",{type:n,description:"Determines filter fields"}).QueryParam("sort",{description:"Determines sort fields",type:new re({dataType:t.type,allowSigns:"first"}),isArray:!0,arraySeparator:","}),r.push(p=>{let c=p.compositionOptions=p.compositionOptions||{};c.type=We(t.type),t.defaultLimit&&(c.defaultLimit=t.defaultLimit),t.defaultProjection&&(c.defaultProjection=t.defaultProjection),t.maxLimit&&(c.maxLimit=t.maxLimit)}),a.DefaultSort=(...p)=>(r.push(c=>{let l=c.compositionOptions=c.compositionOptions||{};l.defaultSort=p}),a),a.SortFields=(...p)=>(r.push(c=>{let l=c.compositionOptions=c.compositionOptions||{};l.sortFields=p}),a),a.Filter=(p,c,l)=>(r.push(()=>{o.set(p,{operators:c,description:l}),n.rules=o.toJSON()}),a),a};M.Entity.Get=function(i,e){let t;typeof i=="object"&&!i[E]?t=i:t={...e,type:i};let r=[],o=C(r,{method:"GET",...t,composition:"Entity.Get"});return o.QueryParam("projection",{description:"Determines fields projection",type:new re({dataType:t.type,allowSigns:"each"}),isArray:!0,arraySeparator:","}).Response(I.OK,{description:'Operation is successful. Returns OperationResult with "payload" field that contains the resource asked for.',contentType:v.opra_response_json,type:t.type,partial:"deep"}).Response(I.NO_CONTENT,{description:"Operation is successful but no resource found"}).Response(I.UNPROCESSABLE_ENTITY,{description:"The request was well-formed but was unable to process operation due to one or many errors.",contentType:v.opra_response_json}),o.KeyParam=(n,a)=>{let p=typeof a=="string"||typeof a=="function"?{name:n,location:"path",type:a,keyParam:!0}:{...a,name:n,location:"path",keyParam:!0};return o.PathParam(n,p),r.push(c=>{var l;(l=c.path)!=null&&l.includes(":"+n)||(c.path=(c.path||"")+"@:"+n),c.mergePath=!0}),o},r.push(n=>{let a=n.compositionOptions=n.compositionOptions||{};a.type=We(t.type)}),o};M.Entity.UpdateMany=function(i,e){var p;let t;typeof i=="object"&&!i[E]?t=i:t={...e,type:i};let r=[],o=new oe({dataType:t.type});o.rules={};let n=new ge,a=C(r,{method:"PATCH",...t,composition:"Entity.UpdateMany",requestBody:{immediateFetch:!0,partial:"deep",...t.requestBody,required:!0}});return a.RequestContent(((p=t.requestBody)==null?void 0:p.type)||t.type).Response(I.OK,{description:'Operation is successful. Returns OperationResult with "affected" field.',contentType:v.opra_response_json}).Response(I.UNPROCESSABLE_ENTITY,{description:"The request was well-formed but was unable to process operation due to one or many errors.",contentType:v.opra_response_json}).QueryParam("filter",{type:o,description:"Determines filter fields"}),r.push(c=>{let l=c.compositionOptions=c.compositionOptions||{};l.type=We(t.type)}),a.Filter=(c,l,x)=>(r.push(()=>{n.set(c,{operators:l,description:x}),o.rules=n.toJSON()}),a),a};M.Entity.Update=function(i,e){var p;let t;typeof i=="object"&&!i[E]?t=i:t={...e,type:i};let r=[],o=new ge,n=new oe({dataType:t.type});n.rules={};let a=C(r,{method:"PATCH",...t,composition:"Entity.Update",requestBody:{partial:"deep",immediateFetch:!0,...t.requestBody,required:!0}});return a.QueryParam("projection",{description:"Determines fields projection",type:new re({dataType:t.type,allowSigns:"each"}),isArray:!0,arraySeparator:","}).QueryParam("filter",{type:n,description:"Determines filter fields"}).RequestContent(((p=t.requestBody)==null?void 0:p.type)||t.type).Response(I.OK,{description:'Operation is successful. Returns OperationResult with "payload" field that contains updated resource.',contentType:v.opra_response_json,type:t.type,partial:"deep"}).Response(I.NO_CONTENT,{description:"Operation is successful but no resource found"}).Response(I.UNPROCESSABLE_ENTITY,{description:"The request was well-formed but was unable to process operation due to one or many errors.",contentType:v.opra_response_json}),a.KeyParam=(c,l)=>{let x=typeof l=="string"||typeof l=="function"?{name:c,location:"path",type:l,keyParam:!0}:{...l,name:c,location:"path",keyParam:!0};return a.PathParam(c,x),r.push(d=>{var B;(B=d.path)!=null&&B.includes(":"+c)||(d.path=(d.path||"")+"@:"+c),d.mergePath=!0}),a},r.push(c=>{let l=c.compositionOptions=c.compositionOptions||{};l.type=We(t.type)}),a.Filter=(c,l,x)=>(r.push(()=>{o.set(c,{operators:l,description:x}),n.rules=o.toJSON()}),a),a};function We(i){if(typeof i=="string")return i;let e=Reflect.getMetadata(E,i);if(!e)throw new TypeError(`Type (${i}) is not decorated with any datatype decorators`);if(e!=null&&e.name)return e.name;throw new TypeError("You should provide named data type but embedded one found")}s(We,"getDataTypeName");import{asMutable as Lc}from"ts-gems";var Re=s(function(...i){var o;if(!this)return Re[A].apply(void 0,i);let[e,t]=i;if(R.call(this,e),!j.test(t.name))throw new TypeError(`Invalid resource name (${t.name})`);let r=Lc(this);r.kind=m.RpcController.Kind,r.types=r.node[F]=new te,r.operations=new N,r.headers=[],r.name=t.name,r.description=t.description,r.instance=t.instance,r.ctor=t.ctor,r._controllerReverseMap=new WeakMap,(o=r._initialize)==null||o.call(r,t),r.onInit=t.onInit,r.onShutdown=t.onShutdown},"RpcController"),rs=class rs extends R{findHeader(e,t){let r=e.toLowerCase(),o;for(o of this.headers)if(typeof o.name=="string"&&(o._nameLower=o._nameLower||o.name.toLowerCase(),o._nameLower===r)||o.name instanceof RegExp&&o.name.test(e))return o;if(this.node.parent&&this.node.parent.element instanceof Re)return this.node.parent.element.findHeader(e,t)}toString(){return`[RpcController ${this.name}]`}toJSON(){let e=y({kind:this.kind,description:this.description});if(this.operations.size){e.operations={};for(let t of this.operations.values())e.operations[t.name]=t.toJSON()}if(this.types.size){e.types={};for(let t of this.types.values())e.types[t.name]=t.toJSON()}if(this.headers.length){e.headers=[];for(let t of this.headers)e.headers.push(t.toJSON())}return e}[it](){return`[${ot}RpcController${nt+this.name+Pe}]`}};s(rs,"RpcControllerClass");var ts=rs;Re.prototype=ts.prototype;Object.assign(Re,He);Re[A]=He;Re.OnInit=function(){return(i,e)=>{let t=Reflect.getOwnMetadata(K,i.constructor)||{};t.onInit=i[e],Reflect.defineMetadata(K,i.constructor,t)}};Re.OnShutdown=function(){return(i,e)=>{let t=Reflect.getOwnMetadata(K,i.constructor)||{};t.onShutdown=i[e],Reflect.defineMetadata(K,i.constructor,t)}};import{asMutable as vc}from"ts-gems";var sr=s(function(i,e){if(!this)throw new TypeError('"this" should be passed to call class constructor');Ce.call(this,i,e);let t=vc(this);e.name&&(t.name=e.name instanceof RegExp?e.name:e.name.startsWith("/")?ct(e.name,{includeFlags:"i",excludeFlags:"m"}):e.name),t.deprecated=e.deprecated,t.required=e.required},"RpcHeader"),os=class os extends Ce{toJSON(){return y({...super.toJSON(),name:this.name,required:this.required,deprecated:this.deprecated})}};s(os,"RpcHeaderClass");var is=os;sr.prototype=is.prototype;import{asMutable as Pc}from"ts-gems";var ar=s(function(...i){if(!this){let[o,n]=i,a=[];return ar[A].call(void 0,a,o,n)}let[e,t]=i;if(R.call(this,e),!j.test(t.name))throw new TypeError(`Invalid operation name (${t.name})`);let r=Pc(this);r.headers=[],r.types=r.node[F]=new te,r.name=t.name,r.description=t.description,r.channel=t.channel,t!=null&&t.payloadType&&(r.payloadType=(t==null?void 0:t.payloadType)instanceof g?t.payloadType:r.owner.node.getDataType(t.payloadType)),t!=null&&t.keyType&&(r.keyType=(t==null?void 0:t.keyType)instanceof g?t.keyType:r.owner.node.getDataType(t.keyType))},"RpcOperation"),ss=class ss extends R{findHeader(e){let t=e.toLowerCase(),r;for(r of this.headers)if(typeof r.name=="string"&&(r._nameLower=r._nameLower||r.name.toLowerCase(),r._nameLower===t)||r.name instanceof RegExp&&r.name.test(e))return r}toJSON(){var t;let e=y({kind:m.RpcOperation.Kind,description:this.description,channel:this.channel,payloadType:this.payloadType.name?this.payloadType.name:this.payloadType.toJSON(),keyType:this.keyType?this.keyType.name?this.keyType.name:this.keyType.toJSON():void 0,response:(t=this.response)==null?void 0:t.toJSON()});if(this.headers.length){e.headers=[];for(let r of this.headers)e.headers.push(r.toJSON())}return e}};s(ss,"RpcOperationClass");var ns=ss;ar.prototype=ns.prototype;ar[A]=Bt;var as=class as extends R{constructor(e,t){super(e),this.headers=[],this.channel=t==null?void 0:t.channel,this.description=t==null?void 0:t.description,t!=null&&t.payloadType?this.payloadType=(t==null?void 0:t.payloadType)instanceof g?t.payloadType:this.owner.node.getDataType(t.payloadType):this.payloadType=this.owner.node.getDataType("any"),t!=null&&t.keyType&&(this.keyType=(t==null?void 0:t.keyType)instanceof g?t.keyType:this.owner.node.getDataType(t.keyType))}findHeader(e){let t=e.toLowerCase(),r;for(r of this.headers)if(typeof r.name=="string"&&(r._nameLower=r._nameLower||r.name.toLowerCase(),r._nameLower===t)||r.name instanceof RegExp&&r.name.test(e))return r}toJSON(){let e=y({description:this.description,channel:this.channel,payloadType:this.payloadType.name?this.payloadType.name:this.payloadType.toJSON(),keyType:this.keyType?this.keyType.name?this.keyType.name:this.keyType.toJSON():void 0});if(this.headers.length){e.headers=[];for(let t of this.headers)e.headers.push(t.toJSON())}return e}};s(as,"RpcOperationResponse");var Xr=as;var ps=class ps{static async createApi(e,t){let r=new ft(t);return t.controllers&&await e.enterAsync(".controllers",async()=>{if(Array.isArray(t.controllers))for(let o of t.controllers){let n=await this._createController(e,r,o);n&&r.controllers.set(n.name,n)}else for(let[o,n]of Object.entries(t.controllers)){let a=await this._createController(e,r,n,o);a&&r.controllers.set(a.name,a)}}),r}static async _createController(e,t,r,o){typeof r=="function"&&!et(r)&&(r=r()),r=await ne(r);let n,a,p;if(typeof r=="function"){if(a=Reflect.getMetadata(K,r),!a)return e.addError(`Class "${r.name}" doesn't have a valid RpcController metadata`);n=r}else n=Object.getPrototypeOf(r).constructor,a=Reflect.getMetadata(K,n),a?p=r:(a=r,r.instance==="object"&&(p=r.instance,n=Object.getPrototypeOf(p).constructor));if(!a)return e.addError(`Class "${n.name}" is not decorated with RpcController()`);if(o=o||a.name,!o)throw new TypeError("Controller name required");let c=new Re(t,{...a,name:o,instance:p,ctor:n});return a.types&&await e.enterAsync(".types",async()=>{await S.addDataTypes(e,c,a.types)}),a.headers&&await e.enterAsync(".headers",async()=>{let l=0;for(let x of a.headers)await e.enterAsync(`[${l++}]`,async()=>{let d={...x};await e.enterAsync(".type",async()=>{x.type&&(d.type=c.node.findDataType(x.type)),!d.type&&typeof x.type=="object"&&(d.type=await S.createDataType(e,c,x.type)),d.type||(d.type=c.node.getDataType("any"))});let B=new sr(c,d);c.headers.push(B)})}),a.operations&&await e.enterAsync(".operations",async()=>{for(let[l,x]of Object.entries(a.operations))await e.enterAsync(`[${l}]`,async()=>{let d=new ar(c,{...x,name:l,types:void 0,payloadType:void 0,keyType:void 0});await this._initRpcOperation(e,d,x),c.operations.set(d.name,d)})}),c}static async _initRpcOperation(e,t,r){r.types&&await e.enterAsync(".types",async()=>{await S.addDataTypes(e,t,r.types)}),t.payloadType=await S.resolveDataType(e,t,r.payloadType),r.keyType&&(t.keyType=await S.resolveDataType(e,t,r.keyType)),r.headers&&await e.enterAsync(".headers",async()=>{let o=0;for(let n of r.headers)await e.enterAsync(`[${o++}]`,async()=>{let a={...n};await e.enterAsync(".type",async()=>{a.type=await S.resolveDataType(e,t,n.type)});let p=new sr(t,a);t.headers.push(p)})}),r.response&&await e.enterAsync(".response",async()=>{let o=new Xr(t,{...r.response,payloadType:void 0,keyType:void 0});await this._initRpcOperationResponse(e,o,r.response),t.response=o})}static async _initRpcOperationResponse(e,t,r){t.payloadType=await S.resolveDataType(e,t,r.payloadType),r.keyType&&(t.keyType=await S.resolveDataType(e,t,r.keyType)),r.headers&&await e.enterAsync(".headers",async()=>{let o=0;for(let n of r.headers)await e.enterAsync(`[${o++}]`,async()=>{let a={...n};await e.enterAsync(".type",async()=>{a.type=await S.resolveDataType(e,t,n.type)});let p=new sr(t,a);t.headers.push(p)})})}};s(ps,"RpcApiFactory");var Zr=ps;var Fc="https://oprajs.com/spec/v"+m.SpecVersion,Hr=class Hr{constructor(){this._allDocuments={}}static async createDocument(e,t){let r=new Hr,o=t instanceof ae?t:new ae(t);try{let n=new Ue;if(await r.initDocument(n,o,e),o.error.details.length)throw o.error;return n}catch(n){try{n instanceof rt||o.addError(n)}catch{}if(!o.error.message){let a=o.error.details.length;o.error.message=`(${a}) error${a>1?"s":""} found in document schema.`,o.showErrorDetails&&(o.error.message+=o.error.details.map(p=>`
10
10
 
11
11
  - ${p.message}`+(p.path?`
12
- @${p.path}`:"")).join(""))}throw n.error}}async initDocument(e,t,r){let n;if(typeof r=="string"){if(n=await(await fetch(r,{method:"GET"})).json(),!n)return t.addError(`Invalid response returned from url: ${r}`);n.url=r}else n=r;let o;if(!e[Ie]){let a=e.node.findDataType("string");o=a==null?void 0:a.node.getDocument(),o||(o=await this.createBuiltinDocument(t),e.references.set("opra",o))}n.spec=n.spec||h.SpecVersion,e.url=n.url,n.info&&(e.info={...n.info}),n.references&&await t.enterAsync(".references",async()=>{let a,p;for([a,p]of Object.entries(n.references))p=await xe(p),await t.enterAsync(`[${a}]`,async()=>{if(!$.test(a))throw new TypeError(`Invalid namespace (${a})`);if(p instanceof Fe){e.references.set(a,p);return}let c=new Fe;o&&c.references.set("opra",o),await this.initDocument(c,t,p),e.references.set(a,this._allDocuments[c.id])})}),n.types&&await t.enterAsync(".types",async()=>{await J.addDataTypes(t,e,n.types)}),n.api&&await t.enterAsync(".api",async()=>{if(n.api.protocol==="http"){let a=await Ze.createApi(t,e,n.api);a&&(e.api=a)}else t.addError(`Unknown service protocol (${n.api.protocol})`)}),e.invalidate(),this._allDocuments[e.id]||(this._allDocuments[e.id]=e)}async createBuiltinDocument(e){let t={spec:h.SpecVersion,url:nc,info:{version:h.SpecVersion,title:"Opra built-in types",license:{url:"https://github.com/oprajs/opra/blob/main/LICENSE",name:"MIT"}},types:[jr,Ur,Cr,$e,Br,ue,qr,De,ur,tt,it,ot,at,W,H,re,vr,Y,Tt,kr,Kt]},r=new Fe;r[Ie]=!0;let n=Object.getPrototypeOf(BigInt(0)).constructor,o=Object.getPrototypeOf(Buffer.from([])),a=r.types[Zt];return a.set(Object,"object"),a.set(String,"string"),a.set(Number,"number"),a.set(Boolean,"boolean"),a.set(Object,"any"),a.set(Date,"datetime"),a.set(n,"bigint"),a.set(ArrayBuffer,"base64"),a.set(SharedArrayBuffer,"base64"),a.set(o,"base64"),await this.initDocument(r,e,t),r}};s(Vr,"ApiDocumentFactory");var Bs=Vr;var qs;(function(i){i.HttpApiFactory=Ze,i.DataTypeFactory=J})(qs||(qs={}));import{uid as O_}from"uid";export{jr as AnyType,or as ApiBase,Fe as ApiDocument,Bs as ApiDocumentFactory,M as ApiField,Ie as BUILTIN,cs as BadRequestError,ur as Base64Type,sa as BaseI18n,Ur as BigintType,Cr as BooleanType,$ as CLASS_NAME_PATTERN,Q as ComplexType,ls as ConflictError,T as DATATYPE_METADATA,y as DECODER,S as DECORATOR,O as DataType,Oe as DataTypeMap,it as DateStringType,at as DateTimeStringType,ot as DateTimeType,tt as DateType,b as DocumentElement,ne as DocumentInitContext,er as DocumentNode,g as ENCODER,Xt as EXTRACT_TYPENAME_PATTERN,W as EmailType,oe as EnumType,fs as FailedDependencyError,H as FieldPathType,Le as FieldsProjection,re as FilterType,Tr as ForbiddenError,te as HTTP_CONTROLLER_METADATA,sr as HttpApi,Z as HttpController,is as HttpHeaderCodes,Re as HttpMediaType,pr as HttpMultipartField,D as HttpOperation,cr as HttpOperationResponse,Ft as HttpParameter,fr as HttpRequestBody,N as HttpStatusCode,n0 as HttpStatusMessages,vt as HttpStatusRange,It as I18n,$e as IntegerType,us as InternalServerError,gs as IssueSeverity,Me as MappedType,ms as MethodNotAllowedError,L as MimeTypes,Xe as MixinType,Jo as NAMESPACE_PATTERN,hs as NotAcceptableError,ds as NotFoundError,Br as NullType,ue as NumberType,vr as ObjectIdType,qr as ObjectType,GE as OmitType,Y as OperationResult,Qe as OpraDocumentError,me as OpraException,Vt as OpraFilter,A as OpraHttpError,h as OpraSchema,ZE as PartialType,ys as PermissionError,r3 as PickType,c2 as RequiredType,Ts as ResourceConflictError,Es as ResourceNotAvailableError,P as ResponsiveMap,m as SimpleType,De as StringType,Tt as TimeType,_s as UnauthorizedError,xs as UnprocessableEntityError,kr as UrlType,Kt as UuidType,qs as classes,I as cloneObject,gc as getErrorStack,xc as getStackFileName,Xr as i18n,Qt as inheritPropertyInitializers,mc as isAsyncIterable,cc as isBlob,Gt as isConstructor,lc as isFormData,uc as isIterable,sc as isReadable,pc as isReadableStream,zr as isStream,fc as isURL,ac as isWritable,Zt as kCtorMap,B as kDataTypeMap,ge as kTypeNSMap,Yt as mergePrototype,Ks as omitNullish,x as omitUndefined,Yo as parse,Go as parseFieldsProjection,xe as resolveThunk,jc as safeJsonStringify,R as translate,O_ as uid};
12
+ @${p.path}`:"")).join(""))}throw o.error}}async initDocument(e,t,r){let o;if(typeof r=="string"){if(o=await(await fetch(r,{method:"GET"})).json(),!o)return t.addError(`Invalid response returned from url: ${r}`);o.url=r}else o=r;let n;if(!e[Le]){let a=e.node.findDataType("string");n=a==null?void 0:a.node.getDocument(),n||(n=await this.createBuiltinDocument(t),e.references.set("opra",n))}o.spec=o.spec||m.SpecVersion,e.url=o.url,o.info&&(e.info={...o.info}),o.references&&await t.enterAsync(".references",async()=>{let a,p;for([a,p]of Object.entries(o.references))p=await ne(p),await t.enterAsync(`[${a}]`,async()=>{if(!j.test(a))throw new TypeError(`Invalid namespace (${a})`);if(p instanceof Ue){e.references.set(a,p);return}let c=new Ue;n&&c.references.set("opra",n),await this.initDocument(c,t,p),e.references.set(a,this._allDocuments[c.id])})}),o.types&&await t.enterAsync(".types",async()=>{await S.addDataTypes(t,e,o.types)}),o.api&&await t.enterAsync(".api",async()=>{if(o.api&&o.api.transport==="http"){let a=await lt.createApi(t,{...o.api,owner:e});a&&(e.api=a)}else if(o.api&&o.api.transport==="rpc"){let a=await Zr.createApi(t,{...o.api,owner:e});a&&(e.api=a)}else t.addError(`Unknown service transport (${o.api.transport})`)}),e.invalidate(),this._allDocuments[e.id]||(this._allDocuments[e.id]=e)}async createBuiltinDocument(e){let t={spec:m.SpecVersion,url:Fc,info:{version:m.SpecVersion,title:"Opra built-in types",license:{url:"https://github.com/oprajs/opra/blob/main/LICENSE",name:"MIT"}},types:[zr,Jr,Wr,Je,Gr,he,Yr,Ie,xr,dt,yt,Et,xt,Q,re,oe,Br,Z,It,Kr,ir]},r=new Ue;r[Le]=!0;let o=Object.getPrototypeOf(BigInt(0)).constructor,n=Object.getPrototypeOf(Buffer.from([])),a=r.types[lr];return a.set(Object,"object"),a.set(String,"string"),a.set(Number,"number"),a.set(Boolean,"boolean"),a.set(Object,"any"),a.set(Date,"datetime"),a.set(o,"bigint"),a.set(ArrayBuffer,"base64"),a.set(SharedArrayBuffer,"base64"),a.set(n,"base64"),await this.initDocument(r,e,t),r}};s(Hr,"ApiDocumentFactory");var ca=Hr;var la;(function(i){i.HttpApiFactory=lt,i.DataTypeFactory=S,i.RpcOperationDecoratorFactory=Bt,i.RpcControllerDecoratorFactory=He})(la||(la={}));import{uid as fO}from"uid";export{zr as AnyType,at as ApiBase,Ue as ApiDocument,ca as ApiDocumentFactory,P as ApiField,Le as BUILTIN,Ls as BadRequestError,xr as Base64Type,Pa as BaseI18n,Jr as BigintType,Wr as BooleanType,j as CLASS_NAME_PATTERN,H as ComplexType,vs as ConflictError,E as DATATYPE_METADATA,T as DECODER,A as DECORATOR,g as DataType,te as DataTypeMap,yt as DateStringType,xt as DateTimeStringType,Et as DateTimeType,dt as DateType,R as DocumentElement,ae as DocumentInitContext,dr as DocumentNode,O as ENCODER,cr as EXTRACT_TYPENAME_PATTERN,Q as EmailType,pe as EnumType,Ps as FailedDependencyError,re as FieldPathType,ve as FieldsProjection,oe as FilterType,Ar as ForbiddenError,V as HTTP_CONTROLLER_METADATA,pt as HttpApi,W as HttpController,bs as HttpHeaderCodes,Ae as HttpMediaType,Tr as HttpMultipartField,M as HttpOperation,Er as HttpOperationResponse,Gt as HttpParameter,_r as HttpRequestBody,I as HttpStatusCode,Y0 as HttpStatusMessages,Wt as HttpStatusRange,Kt as I18n,Je as IntegerType,Fs as InternalServerError,Ks as IssueSeverity,ke as MappedType,ks as MethodNotAllowedError,v as MimeTypes,st as MixinType,us as NAMESPACE_PATTERN,js as NotAcceptableError,Cs as NotFoundError,Gr as NullType,he as NumberType,Br as ObjectIdType,Yr as ObjectType,z3 as OmitType,Z as OperationResult,rt as OpraDocumentError,ye as OpraException,rr as OpraFilter,b as OpraHttpError,m as OpraSchema,Y3 as PartialType,Us as PermissionError,H3 as PickType,K as RPC_CONTROLLER_METADATA,s_ as RequiredType,qs as ResourceConflictError,$s as ResourceNotAvailableError,N as ResponsiveMap,ft as RpcApi,Re as RpcController,sr as RpcHeader,ar as RpcOperation,u as SimpleType,Ie as StringType,It as TimeType,Bs as UnauthorizedError,Vs as UnprocessableEntityError,Kr as UrlType,ir as UuidType,la as classes,L as cloneObject,Xl as getErrorStack,Ql as getStackFileName,li as i18n,ur as inheritPropertyInitializers,Vl as isAsyncIterable,Ul as isBlob,et as isConstructor,ql as isFormData,Bl as isIterable,kl as isReadable,Cl as isReadableStream,ni as isStream,$l as isURL,jl as isWritable,lr as kCtorMap,F as kDataTypeMap,we as kTypeNSMap,fr as mergePrototype,ba as omitNullish,y as omitUndefined,Es as parse,Ts as parseFieldsProjection,ne as resolveThunk,mf as safeJsonStringify,w as translate,fO as uid};