@graffiti-garden/wrapper-synchronize 0.0.1
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.
- package/README.md +40 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/index.browser.js +42 -0
- package/dist/index.browser.js.map +7 -0
- package/dist/index.d.ts +134 -0
- package/dist/index.d.ts.map +1 -0
- package/package.json +63 -0
- package/src/index.spec.ts +408 -0
- package/src/index.ts +315 -0
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Graffiti Synchronize
|
|
2
|
+
|
|
3
|
+
This library wraps the [Graffiti API](https://api.graffiti.garden/classes/Graffiti.html)
|
|
4
|
+
so that changes made or received in one part of an application
|
|
5
|
+
are automatically routed to other parts of the application.
|
|
6
|
+
This is an important tool for building responsive
|
|
7
|
+
and consistent user interfaces, and is built upon to make
|
|
8
|
+
the [Graffiti Vue Plugin](https://vue.graffiti.garden/variables/GraffitiPlugin.html)
|
|
9
|
+
and possibly other front-end libraries in the future.
|
|
10
|
+
|
|
11
|
+
[**View the Documentation**](https://sync.graffiti.garden/classes/GraffitiSynchronize.html)
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
In node.js, simply install the package with npm:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @graffiti-garden/wrapper-synchronize
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
In the browser, you can use a CDN like jsDelivr. Add an import map the the `<head>` of your HTML file:
|
|
22
|
+
```html
|
|
23
|
+
<head>
|
|
24
|
+
<script type="importmap">
|
|
25
|
+
{
|
|
26
|
+
"imports": {
|
|
27
|
+
"@graffiti-garden/wrapper-synchronize": "https://cdn.jsdelivr.net/npm/@graffiti-garden/wrapper-synchronize/dist/index.browser.js"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
</script>
|
|
31
|
+
</head>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
In either case, you can then import and contruct the class as follows:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { GraffitiSynchronize } from "@graffiti-garden/wrapper-syncronize";
|
|
38
|
+
const graffiti = new GraffitiLocal() // or any other implementation of the Graffiti API
|
|
39
|
+
const graffitiSynchronized = new GraffitiSynchronize(graffiti)
|
|
40
|
+
```
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var O=Object.create;var h=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var k=(r,t)=>{for(var e in t)h(r,e,{get:t[e],enumerable:!0})},b=(r,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of w(t))!g.call(r,i)&&i!==e&&h(r,i,{get:()=>t[i],enumerable:!(a=v(t,i))||a.enumerable});return r};var x=(r,t,e)=>(e=r!=null?O(z(r)):{},b(t||!r||!r.__esModule?h(e,"default",{value:r,enumerable:!0}):e,r)),B=r=>b(h({},"__esModule",{value:!0}),r);var U={};k(U,{GraffitiSynchronize:()=>T});module.exports=B(U);var u=x(require("ajv-draft-04")),d=require("@graffiti-garden/api"),G=require("@repeaterjs/repeater"),S=require("fast-json-patch"),c=require("@graffiti-garden/implementation-local/utilities");class T extends d.Graffiti{ajv;graffiti;callbacks=new Set;channelStats;locationToUri;uriToLocation;login;logout;sessionEvents;constructor(t,e){super(),this.ajv=e??new u.default({strict:!1}),this.graffiti=t,this.channelStats=t.channelStats.bind(t),this.locationToUri=t.locationToUri.bind(t),this.uriToLocation=t.uriToLocation.bind(t),this.login=t.login.bind(t),this.logout=t.logout.bind(t),this.sessionEvents=t.sessionEvents}synchronize(t,e,a,i){const o=(0,c.attemptAjvCompile)(this.ajv,a);return new G.Repeater(async(n,l)=>{const m=(j,y)=>{for(const f of[y,j])if(f&&t(f)&&(0,c.isActorAllowedGraffitiObject)(f,i)){const p={...f};if((0,c.maskGraffitiObject)(p,e,i),o(p)){n({value:p});break}}};this.callbacks.add(m),await l,this.callbacks.delete(m)})}synchronizeDiscover(...t){const[e,a,i]=t;function o(s){return s.channels.some(n=>e.includes(n))}return this.synchronize(o,e,a,i)}synchronizeGet(...t){const[e,a,i]=t;function o(s){const n=(0,c.locationToUri)(s),{uri:l}=(0,c.unpackLocationOrUri)(e);return n===l}return this.synchronize(o,[],a,i)}synchronizeRecoverOrphans(...t){const[e,a]=t;function i(o){return o.actor===a.actor&&o.channels.length===0}return this.synchronize(i,[],e,a)}async synchronizeDispatch(t,e,a=!1){for(const i of this.callbacks)i(t,e);a&&await new Promise(i=>setTimeout(i,0))}get=async(...t)=>{const e=await this.graffiti.get(...t);return this.synchronizeDispatch(e),e};put=async(...t)=>{const e=await this.graffiti.put(...t),a=t[0],i={...e,value:a.value,channels:a.channels,allowed:a.allowed,tombstone:!1};return await this.synchronizeDispatch(e,i,!0),e};patch=async(...t)=>{const e=await this.graffiti.patch(...t),a={...e};a.tombstone=!1;for(const i of["value","channels","allowed"])(0,c.applyGraffitiPatch)(S.applyPatch,i,t[0],a);return await this.synchronizeDispatch(e,a,!0),e};delete=async(...t)=>{const e=await this.graffiti.delete(...t);return await this.synchronizeDispatch(e,void 0,!0),e};objectStream(t){const e=this.synchronizeDispatch.bind(this);return async function*(){let i=await t.next();for(;!i.done;)i.value.error||e(i.value.value),yield i.value,i=await t.next();return i.value}()}discover=(...t)=>{const e=this.graffiti.discover(...t);return this.objectStream(e)};recoverOrphans=(...t)=>{const e=this.graffiti.recoverOrphans(...t);return this.objectStream(e)}}
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["import Ajv from \"ajv-draft-04\";\nimport { Graffiti } from \"@graffiti-garden/api\";\nimport type {\n GraffitiSession,\n GraffitiObject,\n JSONSchema4,\n GraffitiStream,\n} from \"@graffiti-garden/api\";\nimport type { GraffitiObjectBase } from \"@graffiti-garden/api\";\nimport { Repeater } from \"@repeaterjs/repeater\";\nimport { applyPatch } from \"fast-json-patch\";\nimport {\n applyGraffitiPatch,\n attemptAjvCompile,\n isActorAllowedGraffitiObject,\n locationToUri,\n maskGraffitiObject,\n unpackLocationOrUri,\n} from \"@graffiti-garden/implementation-local/utilities\";\nexport type * from \"@graffiti-garden/api\";\n\nexport type GraffitiSynchronizeCallback = (\n oldObject: GraffitiObjectBase,\n newObject?: GraffitiObjectBase,\n) => void;\n\n/**\n * Wraps the [Graffiti API](https://api.graffiti.garden/classes/Graffiti.html)\n * so that changes made or received in one part of an application\n * are automatically routed to other parts of the application.\n * This is an important tool for building responsive\n * and consistent user interfaces, and is built upon to make\n * the [Graffiti Vue Plugin](https://vue.graffiti.garden/variables/GraffitiPlugin.html)\n * and possibly other front-end libraries in the future.\n *\n * Specifically, it provides the following *synchronize*\n * methods for each of the following API methods:\n *\n * | API Method | Synchronize Method |\n * |------------|--------------------|\n * | {@link get} | {@link synchronizeGet} |\n * | {@link discover} | {@link synchronizeDiscover} |\n * | {@link recoverOrphans} | {@link synchronizeRecoverOrphans} |\n *\n * Whenever a change is made via {@link put}, {@link patch}, and {@link delete} or\n * received from {@link get}, {@link discover}, and {@link recoverOrphans},\n * those changes are forwarded to the appropriate synchronize method.\n * Each synchronize method returns an iterator that streams these changes\n * continually until the user calls `return` on the iterator or `break`s out of the loop,\n * allowing for live updates without additional polling.\n *\n * Example 1: Suppose a user publishes a post using {@link put}. If the feed\n * displaying that user's posts is using {@link synchronizeDiscover} to listen for changes,\n * then the user's new post will instantly appear in their feed, giving the UI a\n * responsive feel.\n *\n * Example 2: Suppose one of a user's friends changes their name. As soon as the\n * user's application receives one notice of that change (using {@link get}\n * or {@link discover}), then {@link synchronizeDiscover} listeners can be used to update\n * all instance's of that friend's name in the user's application instantly,\n * providing a consistent user experience.\n *\n * @groupDescription Synchronize Methods\n * This group contains methods that listen for changes made via\n * {@link put}, {@link patch}, and {@link delete} or fetched from\n * {@link get}, {@link discover}, and {@link recoverOrphans} and then\n * streams appropriate changes to provide a responsive and consistent user experience.\n */\nexport class GraffitiSynchronize extends Graffiti {\n protected readonly ajv: Ajv;\n protected readonly graffiti: Graffiti;\n protected readonly callbacks = new Set<GraffitiSynchronizeCallback>();\n\n channelStats: Graffiti[\"channelStats\"];\n locationToUri: Graffiti[\"locationToUri\"];\n uriToLocation: Graffiti[\"uriToLocation\"];\n login: Graffiti[\"login\"];\n logout: Graffiti[\"logout\"];\n sessionEvents: Graffiti[\"sessionEvents\"];\n\n /**\n * Wraps a Graffiti API instance to provide the synchronize methods.\n * The GraffitiSyncrhonize class rather than the Graffiti class\n * must be used for all functions for the synchronize methods to work.\n */\n constructor(\n /**\n * The [Graffiti API](https://api.graffiti.garden/classes/Graffiti.html)\n * instance to wrap.\n */\n graffiti: Graffiti,\n /**\n * An optional instance of Ajv to use for validating\n * objects before dispatching them to listeners.\n * If not provided, a new instance of Ajv will be created.\n */\n ajv?: Ajv,\n ) {\n super();\n this.ajv = ajv ?? new Ajv({ strict: false });\n this.graffiti = graffiti;\n this.channelStats = graffiti.channelStats.bind(graffiti);\n this.locationToUri = graffiti.locationToUri.bind(graffiti);\n this.uriToLocation = graffiti.uriToLocation.bind(graffiti);\n this.login = graffiti.login.bind(graffiti);\n this.logout = graffiti.logout.bind(graffiti);\n this.sessionEvents = graffiti.sessionEvents;\n }\n\n protected synchronize<Schema extends JSONSchema4>(\n matchObject: (object: GraffitiObjectBase) => boolean,\n channels: string[],\n schema: Schema,\n session?: GraffitiSession | null,\n ) {\n const validate = attemptAjvCompile(this.ajv, schema);\n\n const repeater: GraffitiStream<GraffitiObject<Schema>> = new Repeater(\n async (push, stop) => {\n const callback: GraffitiSynchronizeCallback = (\n oldObjectRaw,\n newObjectRaw,\n ) => {\n for (const objectRaw of [newObjectRaw, oldObjectRaw]) {\n if (\n objectRaw &&\n matchObject(objectRaw) &&\n isActorAllowedGraffitiObject(objectRaw, session)\n ) {\n const object = { ...objectRaw };\n maskGraffitiObject(object, channels, session);\n if (validate(object)) {\n push({ value: object });\n break;\n }\n }\n }\n };\n\n this.callbacks.add(callback);\n await stop;\n this.callbacks.delete(callback);\n },\n );\n\n return repeater;\n }\n\n /**\n * This method has the same signature as {@link discover} but listens for\n * changes made via {@link put}, {@link patch}, and {@link delete} or\n * fetched from {@link get}, {@link discover}, and {@link recoverOrphans}\n * and then streams appropriate changes to provide a responsive and\n * consistent user experience.\n *\n * Unlike {@link discover}, this method continuously listens for changes\n * and will not terminate unless the user calls the `return` method on the iterator\n * or `break`s out of the loop.\n *\n * @group Synchronize Methods\n */\n synchronizeDiscover<Schema extends JSONSchema4>(\n ...args: Parameters<typeof Graffiti.prototype.discover<Schema>>\n ): GraffitiStream<GraffitiObject<Schema>> {\n const [channels, schema, session] = args;\n function matchObject(object: GraffitiObjectBase) {\n return object.channels.some((channel) => channels.includes(channel));\n }\n return this.synchronize(matchObject, channels, schema, session);\n }\n\n /**\n * This method has the same signature as {@link get} but\n * listens for changes made via {@link put}, {@link patch}, and {@link delete} or\n * fetched from {@link get}, {@link discover}, and {@link recoverOrphans} and then\n * streams appropriate changes to provide a responsive and consistent user experience.\n *\n * Unlike {@link get}, which returns a single result, this method continuously\n * listens for changes which are output as an asynchronous {@link GraffitiStream}.\n *\n * @group Synchronize Methods\n */\n synchronizeGet<Schema extends JSONSchema4>(\n ...args: Parameters<typeof Graffiti.prototype.get<Schema>>\n ): GraffitiStream<GraffitiObject<Schema>> {\n const [locationOrUri, schema, session] = args;\n function matchObject(object: GraffitiObjectBase) {\n const objectUri = locationToUri(object);\n const { uri } = unpackLocationOrUri(locationOrUri);\n return objectUri === uri;\n }\n return this.synchronize(matchObject, [], schema, session);\n }\n\n /**\n * This method has the same signature as {@link recoverOrphans} but\n * listens for changes made via\n * {@link put}, {@link patch}, and {@link delete} or fetched from\n * {@link get}, {@link discover}, and {@link recoverOrphans} and then\n * streams appropriate changes to provide a responsive and consistent user experience.\n *\n * Unlike {@link recoverOrphans}, this method continuously listens for changes\n * and will not terminate unless the user calls the `return` method on the iterator\n * or `break`s out of the loop.\n *\n * @group Synchronize Methods\n */\n synchronizeRecoverOrphans<Schema extends JSONSchema4>(\n ...args: Parameters<typeof Graffiti.prototype.recoverOrphans<Schema>>\n ): GraffitiStream<GraffitiObject<Schema>> {\n const [schema, session] = args;\n function matchObject(object: GraffitiObjectBase) {\n return object.actor === session.actor && object.channels.length === 0;\n }\n return this.synchronize(matchObject, [], schema, session);\n }\n\n protected async synchronizeDispatch(\n oldObject: GraffitiObjectBase,\n newObject?: GraffitiObjectBase,\n waitForListeners = false,\n ) {\n for (const callback of this.callbacks) {\n callback(oldObject, newObject);\n }\n if (waitForListeners) {\n // Wait for the listeners to receive\n // their objects, before returning the operation\n // that triggered them.\n //\n // This is important for mutators (put, patch, delete)\n // to ensure the application state has been updated\n // everywhere before returning, giving consistent\n // feedback to the user that the operation has completed.\n //\n // The opposite is true for accessors (get, discover, recoverOrphans),\n // where it is a weird user experience to call `get`\n // in one place and have the application update\n // somewhere else first. It is also less efficient.\n //\n // The hack is simply to await one \"macro task cycle\".\n // We need to wait for this cycle rather than using\n // `await push` in the callback, because it turns out\n // that `await push` won't resolve until the following\n // .next() call of the iterator, so if only\n // one .next() is called, this dispatch will hang.\n await new Promise((resolve) => setTimeout(resolve, 0));\n }\n }\n\n get: Graffiti[\"get\"] = async (...args) => {\n const object = await this.graffiti.get(...args);\n this.synchronizeDispatch(object);\n return object;\n };\n\n put: Graffiti[\"put\"] = async (...args) => {\n const oldObject = await this.graffiti.put(...args);\n const partialObject = args[0];\n const newObject: GraffitiObjectBase = {\n ...oldObject,\n value: partialObject.value,\n channels: partialObject.channels,\n allowed: partialObject.allowed,\n tombstone: false,\n };\n await this.synchronizeDispatch(oldObject, newObject, true);\n return oldObject;\n };\n\n patch: Graffiti[\"patch\"] = async (...args) => {\n const oldObject = await this.graffiti.patch(...args);\n const newObject: GraffitiObjectBase = { ...oldObject };\n newObject.tombstone = false;\n for (const prop of [\"value\", \"channels\", \"allowed\"] as const) {\n applyGraffitiPatch(applyPatch, prop, args[0], newObject);\n }\n await this.synchronizeDispatch(oldObject, newObject, true);\n return oldObject;\n };\n\n delete: Graffiti[\"delete\"] = async (...args) => {\n const oldObject = await this.graffiti.delete(...args);\n await this.synchronizeDispatch(oldObject, undefined, true);\n return oldObject;\n };\n\n protected objectStream<Schema extends JSONSchema4>(\n iterator: ReturnType<typeof Graffiti.prototype.discover<Schema>>,\n ) {\n const dispatch = this.synchronizeDispatch.bind(this);\n const wrapper = async function* () {\n let result = await iterator.next();\n while (!result.done) {\n if (!result.value.error) {\n dispatch(result.value.value);\n }\n yield result.value;\n result = await iterator.next();\n }\n return result.value;\n };\n return wrapper();\n }\n\n discover: Graffiti[\"discover\"] = (...args) => {\n const iterator = this.graffiti.discover(...args);\n return this.objectStream(iterator);\n };\n\n recoverOrphans: Graffiti[\"recoverOrphans\"] = (...args) => {\n const iterator = this.graffiti.recoverOrphans(...args);\n return this.objectStream(iterator);\n };\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAgB,2BAChBC,EAAyB,gCAQzBC,EAAyB,gCACzBC,EAA2B,2BAC3BC,EAOO,2DAkDA,MAAMN,UAA4B,UAAS,CAC7B,IACA,SACA,UAAY,IAAI,IAEnC,aACA,cACA,cACA,MACA,OACA,cAOA,YAKEO,EAMAC,EACA,CACA,MAAM,EACN,KAAK,IAAMA,GAAO,IAAI,EAAAC,QAAI,CAAE,OAAQ,EAAM,CAAC,EAC3C,KAAK,SAAWF,EAChB,KAAK,aAAeA,EAAS,aAAa,KAAKA,CAAQ,EACvD,KAAK,cAAgBA,EAAS,cAAc,KAAKA,CAAQ,EACzD,KAAK,cAAgBA,EAAS,cAAc,KAAKA,CAAQ,EACzD,KAAK,MAAQA,EAAS,MAAM,KAAKA,CAAQ,EACzC,KAAK,OAASA,EAAS,OAAO,KAAKA,CAAQ,EAC3C,KAAK,cAAgBA,EAAS,aAChC,CAEU,YACRG,EACAC,EACAC,EACAC,EACA,CACA,MAAMC,KAAW,qBAAkB,KAAK,IAAKF,CAAM,EA8BnD,OA5ByD,IAAI,WAC3D,MAAOG,EAAMC,IAAS,CACpB,MAAMC,EAAwC,CAC5CC,EACAC,IACG,CACH,UAAWC,IAAa,CAACD,EAAcD,CAAY,EACjD,GACEE,GACAV,EAAYU,CAAS,MACrB,gCAA6BA,EAAWP,CAAO,EAC/C,CACA,MAAMQ,EAAS,CAAE,GAAGD,CAAU,EAE9B,MADA,sBAAmBC,EAAQV,EAAUE,CAAO,EACxCC,EAASO,CAAM,EAAG,CACpBN,EAAK,CAAE,MAAOM,CAAO,CAAC,EACtB,KACF,CACF,CAEJ,EAEA,KAAK,UAAU,IAAIJ,CAAQ,EAC3B,MAAMD,EACN,KAAK,UAAU,OAAOC,CAAQ,CAChC,CACF,CAGF,CAeA,uBACKK,EACqC,CACxC,KAAM,CAACX,EAAUC,EAAQC,CAAO,EAAIS,EACpC,SAASZ,EAAYW,EAA4B,CAC/C,OAAOA,EAAO,SAAS,KAAME,GAAYZ,EAAS,SAASY,CAAO,CAAC,CACrE,CACA,OAAO,KAAK,YAAYb,EAAaC,EAAUC,EAAQC,CAAO,CAChE,CAaA,kBACKS,EACqC,CACxC,KAAM,CAACE,EAAeZ,EAAQC,CAAO,EAAIS,EACzC,SAASZ,EAAYW,EAA4B,CAC/C,MAAMI,KAAY,iBAAcJ,CAAM,EAChC,CAAE,IAAAK,CAAI,KAAI,uBAAoBF,CAAa,EACjD,OAAOC,IAAcC,CACvB,CACA,OAAO,KAAK,YAAYhB,EAAa,CAAC,EAAGE,EAAQC,CAAO,CAC1D,CAeA,6BACKS,EACqC,CACxC,KAAM,CAACV,EAAQC,CAAO,EAAIS,EAC1B,SAASZ,EAAYW,EAA4B,CAC/C,OAAOA,EAAO,QAAUR,EAAQ,OAASQ,EAAO,SAAS,SAAW,CACtE,CACA,OAAO,KAAK,YAAYX,EAAa,CAAC,EAAGE,EAAQC,CAAO,CAC1D,CAEA,MAAgB,oBACdc,EACAC,EACAC,EAAmB,GACnB,CACA,UAAWZ,KAAY,KAAK,UAC1BA,EAASU,EAAWC,CAAS,EAE3BC,GAqBF,MAAM,IAAI,QAASC,GAAY,WAAWA,EAAS,CAAC,CAAC,CAEzD,CAEA,IAAuB,SAAUR,IAAS,CACxC,MAAMD,EAAS,MAAM,KAAK,SAAS,IAAI,GAAGC,CAAI,EAC9C,YAAK,oBAAoBD,CAAM,EACxBA,CACT,EAEA,IAAuB,SAAUC,IAAS,CACxC,MAAMK,EAAY,MAAM,KAAK,SAAS,IAAI,GAAGL,CAAI,EAC3CS,EAAgBT,EAAK,CAAC,EACtBM,EAAgC,CACpC,GAAGD,EACH,MAAOI,EAAc,MACrB,SAAUA,EAAc,SACxB,QAASA,EAAc,QACvB,UAAW,EACb,EACA,aAAM,KAAK,oBAAoBJ,EAAWC,EAAW,EAAI,EAClDD,CACT,EAEA,MAA2B,SAAUL,IAAS,CAC5C,MAAMK,EAAY,MAAM,KAAK,SAAS,MAAM,GAAGL,CAAI,EAC7CM,EAAgC,CAAE,GAAGD,CAAU,EACrDC,EAAU,UAAY,GACtB,UAAWI,IAAQ,CAAC,QAAS,WAAY,SAAS,KAChD,sBAAmB,aAAYA,EAAMV,EAAK,CAAC,EAAGM,CAAS,EAEzD,aAAM,KAAK,oBAAoBD,EAAWC,EAAW,EAAI,EAClDD,CACT,EAEA,OAA6B,SAAUL,IAAS,CAC9C,MAAMK,EAAY,MAAM,KAAK,SAAS,OAAO,GAAGL,CAAI,EACpD,aAAM,KAAK,oBAAoBK,EAAW,OAAW,EAAI,EAClDA,CACT,EAEU,aACRM,EACA,CACA,MAAMC,EAAW,KAAK,oBAAoB,KAAK,IAAI,EAYnD,OAXgB,iBAAmB,CACjC,IAAIC,EAAS,MAAMF,EAAS,KAAK,EACjC,KAAO,CAACE,EAAO,MACRA,EAAO,MAAM,OAChBD,EAASC,EAAO,MAAM,KAAK,EAE7B,MAAMA,EAAO,MACbA,EAAS,MAAMF,EAAS,KAAK,EAE/B,OAAOE,EAAO,KAChB,EACe,CACjB,CAEA,SAAiC,IAAIb,IAAS,CAC5C,MAAMW,EAAW,KAAK,SAAS,SAAS,GAAGX,CAAI,EAC/C,OAAO,KAAK,aAAaW,CAAQ,CACnC,EAEA,eAA6C,IAAIX,IAAS,CACxD,MAAMW,EAAW,KAAK,SAAS,eAAe,GAAGX,CAAI,EACrD,OAAO,KAAK,aAAaW,CAAQ,CACnC,CACF",
|
|
6
|
+
"names": ["src_exports", "__export", "GraffitiSynchronize", "__toCommonJS", "import_ajv_draft_04", "import_api", "import_repeater", "import_fast_json_patch", "import_utilities", "graffiti", "ajv", "Ajv", "matchObject", "channels", "schema", "session", "validate", "push", "stop", "callback", "oldObjectRaw", "newObjectRaw", "objectRaw", "object", "args", "channel", "locationOrUri", "objectUri", "uri", "oldObject", "newObject", "waitForListeners", "resolve", "partialObject", "prop", "iterator", "dispatch", "result"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import m from"ajv-draft-04";import{Graffiti as b}from"@graffiti-garden/api";import{Repeater as u}from"@repeaterjs/repeater";import{applyPatch as d}from"fast-json-patch";import{applyGraffitiPatch as G,attemptAjvCompile as S,isActorAllowedGraffitiObject as j,locationToUri as y,maskGraffitiObject as O,unpackLocationOrUri as v}from"@graffiti-garden/implementation-local/utilities";class T extends b{ajv;graffiti;callbacks=new Set;channelStats;locationToUri;uriToLocation;login;logout;sessionEvents;constructor(t,e){super(),this.ajv=e??new m({strict:!1}),this.graffiti=t,this.channelStats=t.channelStats.bind(t),this.locationToUri=t.locationToUri.bind(t),this.uriToLocation=t.uriToLocation.bind(t),this.login=t.login.bind(t),this.logout=t.logout.bind(t),this.sessionEvents=t.sessionEvents}synchronize(t,e,a,i){const r=S(this.ajv,a);return new u(async(c,s)=>{const h=(l,p)=>{for(const n of[p,l])if(n&&t(n)&&j(n,i)){const f={...n};if(O(f,e,i),r(f)){c({value:f});break}}};this.callbacks.add(h),await s,this.callbacks.delete(h)})}synchronizeDiscover(...t){const[e,a,i]=t;function r(o){return o.channels.some(c=>e.includes(c))}return this.synchronize(r,e,a,i)}synchronizeGet(...t){const[e,a,i]=t;function r(o){const c=y(o),{uri:s}=v(e);return c===s}return this.synchronize(r,[],a,i)}synchronizeRecoverOrphans(...t){const[e,a]=t;function i(r){return r.actor===a.actor&&r.channels.length===0}return this.synchronize(i,[],e,a)}async synchronizeDispatch(t,e,a=!1){for(const i of this.callbacks)i(t,e);a&&await new Promise(i=>setTimeout(i,0))}get=async(...t)=>{const e=await this.graffiti.get(...t);return this.synchronizeDispatch(e),e};put=async(...t)=>{const e=await this.graffiti.put(...t),a=t[0],i={...e,value:a.value,channels:a.channels,allowed:a.allowed,tombstone:!1};return await this.synchronizeDispatch(e,i,!0),e};patch=async(...t)=>{const e=await this.graffiti.patch(...t),a={...e};a.tombstone=!1;for(const i of["value","channels","allowed"])G(d,i,t[0],a);return await this.synchronizeDispatch(e,a,!0),e};delete=async(...t)=>{const e=await this.graffiti.delete(...t);return await this.synchronizeDispatch(e,void 0,!0),e};objectStream(t){const e=this.synchronizeDispatch.bind(this);return async function*(){let i=await t.next();for(;!i.done;)i.value.error||e(i.value.value),yield i.value,i=await t.next();return i.value}()}discover=(...t)=>{const e=this.graffiti.discover(...t);return this.objectStream(e)};recoverOrphans=(...t)=>{const e=this.graffiti.recoverOrphans(...t);return this.objectStream(e)}}export{T as GraffitiSynchronize};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["import Ajv from \"ajv-draft-04\";\nimport { Graffiti } from \"@graffiti-garden/api\";\nimport type {\n GraffitiSession,\n GraffitiObject,\n JSONSchema4,\n GraffitiStream,\n} from \"@graffiti-garden/api\";\nimport type { GraffitiObjectBase } from \"@graffiti-garden/api\";\nimport { Repeater } from \"@repeaterjs/repeater\";\nimport { applyPatch } from \"fast-json-patch\";\nimport {\n applyGraffitiPatch,\n attemptAjvCompile,\n isActorAllowedGraffitiObject,\n locationToUri,\n maskGraffitiObject,\n unpackLocationOrUri,\n} from \"@graffiti-garden/implementation-local/utilities\";\nexport type * from \"@graffiti-garden/api\";\n\nexport type GraffitiSynchronizeCallback = (\n oldObject: GraffitiObjectBase,\n newObject?: GraffitiObjectBase,\n) => void;\n\n/**\n * Wraps the [Graffiti API](https://api.graffiti.garden/classes/Graffiti.html)\n * so that changes made or received in one part of an application\n * are automatically routed to other parts of the application.\n * This is an important tool for building responsive\n * and consistent user interfaces, and is built upon to make\n * the [Graffiti Vue Plugin](https://vue.graffiti.garden/variables/GraffitiPlugin.html)\n * and possibly other front-end libraries in the future.\n *\n * Specifically, it provides the following *synchronize*\n * methods for each of the following API methods:\n *\n * | API Method | Synchronize Method |\n * |------------|--------------------|\n * | {@link get} | {@link synchronizeGet} |\n * | {@link discover} | {@link synchronizeDiscover} |\n * | {@link recoverOrphans} | {@link synchronizeRecoverOrphans} |\n *\n * Whenever a change is made via {@link put}, {@link patch}, and {@link delete} or\n * received from {@link get}, {@link discover}, and {@link recoverOrphans},\n * those changes are forwarded to the appropriate synchronize method.\n * Each synchronize method returns an iterator that streams these changes\n * continually until the user calls `return` on the iterator or `break`s out of the loop,\n * allowing for live updates without additional polling.\n *\n * Example 1: Suppose a user publishes a post using {@link put}. If the feed\n * displaying that user's posts is using {@link synchronizeDiscover} to listen for changes,\n * then the user's new post will instantly appear in their feed, giving the UI a\n * responsive feel.\n *\n * Example 2: Suppose one of a user's friends changes their name. As soon as the\n * user's application receives one notice of that change (using {@link get}\n * or {@link discover}), then {@link synchronizeDiscover} listeners can be used to update\n * all instance's of that friend's name in the user's application instantly,\n * providing a consistent user experience.\n *\n * @groupDescription Synchronize Methods\n * This group contains methods that listen for changes made via\n * {@link put}, {@link patch}, and {@link delete} or fetched from\n * {@link get}, {@link discover}, and {@link recoverOrphans} and then\n * streams appropriate changes to provide a responsive and consistent user experience.\n */\nexport class GraffitiSynchronize extends Graffiti {\n protected readonly ajv: Ajv;\n protected readonly graffiti: Graffiti;\n protected readonly callbacks = new Set<GraffitiSynchronizeCallback>();\n\n channelStats: Graffiti[\"channelStats\"];\n locationToUri: Graffiti[\"locationToUri\"];\n uriToLocation: Graffiti[\"uriToLocation\"];\n login: Graffiti[\"login\"];\n logout: Graffiti[\"logout\"];\n sessionEvents: Graffiti[\"sessionEvents\"];\n\n /**\n * Wraps a Graffiti API instance to provide the synchronize methods.\n * The GraffitiSyncrhonize class rather than the Graffiti class\n * must be used for all functions for the synchronize methods to work.\n */\n constructor(\n /**\n * The [Graffiti API](https://api.graffiti.garden/classes/Graffiti.html)\n * instance to wrap.\n */\n graffiti: Graffiti,\n /**\n * An optional instance of Ajv to use for validating\n * objects before dispatching them to listeners.\n * If not provided, a new instance of Ajv will be created.\n */\n ajv?: Ajv,\n ) {\n super();\n this.ajv = ajv ?? new Ajv({ strict: false });\n this.graffiti = graffiti;\n this.channelStats = graffiti.channelStats.bind(graffiti);\n this.locationToUri = graffiti.locationToUri.bind(graffiti);\n this.uriToLocation = graffiti.uriToLocation.bind(graffiti);\n this.login = graffiti.login.bind(graffiti);\n this.logout = graffiti.logout.bind(graffiti);\n this.sessionEvents = graffiti.sessionEvents;\n }\n\n protected synchronize<Schema extends JSONSchema4>(\n matchObject: (object: GraffitiObjectBase) => boolean,\n channels: string[],\n schema: Schema,\n session?: GraffitiSession | null,\n ) {\n const validate = attemptAjvCompile(this.ajv, schema);\n\n const repeater: GraffitiStream<GraffitiObject<Schema>> = new Repeater(\n async (push, stop) => {\n const callback: GraffitiSynchronizeCallback = (\n oldObjectRaw,\n newObjectRaw,\n ) => {\n for (const objectRaw of [newObjectRaw, oldObjectRaw]) {\n if (\n objectRaw &&\n matchObject(objectRaw) &&\n isActorAllowedGraffitiObject(objectRaw, session)\n ) {\n const object = { ...objectRaw };\n maskGraffitiObject(object, channels, session);\n if (validate(object)) {\n push({ value: object });\n break;\n }\n }\n }\n };\n\n this.callbacks.add(callback);\n await stop;\n this.callbacks.delete(callback);\n },\n );\n\n return repeater;\n }\n\n /**\n * This method has the same signature as {@link discover} but listens for\n * changes made via {@link put}, {@link patch}, and {@link delete} or\n * fetched from {@link get}, {@link discover}, and {@link recoverOrphans}\n * and then streams appropriate changes to provide a responsive and\n * consistent user experience.\n *\n * Unlike {@link discover}, this method continuously listens for changes\n * and will not terminate unless the user calls the `return` method on the iterator\n * or `break`s out of the loop.\n *\n * @group Synchronize Methods\n */\n synchronizeDiscover<Schema extends JSONSchema4>(\n ...args: Parameters<typeof Graffiti.prototype.discover<Schema>>\n ): GraffitiStream<GraffitiObject<Schema>> {\n const [channels, schema, session] = args;\n function matchObject(object: GraffitiObjectBase) {\n return object.channels.some((channel) => channels.includes(channel));\n }\n return this.synchronize(matchObject, channels, schema, session);\n }\n\n /**\n * This method has the same signature as {@link get} but\n * listens for changes made via {@link put}, {@link patch}, and {@link delete} or\n * fetched from {@link get}, {@link discover}, and {@link recoverOrphans} and then\n * streams appropriate changes to provide a responsive and consistent user experience.\n *\n * Unlike {@link get}, which returns a single result, this method continuously\n * listens for changes which are output as an asynchronous {@link GraffitiStream}.\n *\n * @group Synchronize Methods\n */\n synchronizeGet<Schema extends JSONSchema4>(\n ...args: Parameters<typeof Graffiti.prototype.get<Schema>>\n ): GraffitiStream<GraffitiObject<Schema>> {\n const [locationOrUri, schema, session] = args;\n function matchObject(object: GraffitiObjectBase) {\n const objectUri = locationToUri(object);\n const { uri } = unpackLocationOrUri(locationOrUri);\n return objectUri === uri;\n }\n return this.synchronize(matchObject, [], schema, session);\n }\n\n /**\n * This method has the same signature as {@link recoverOrphans} but\n * listens for changes made via\n * {@link put}, {@link patch}, and {@link delete} or fetched from\n * {@link get}, {@link discover}, and {@link recoverOrphans} and then\n * streams appropriate changes to provide a responsive and consistent user experience.\n *\n * Unlike {@link recoverOrphans}, this method continuously listens for changes\n * and will not terminate unless the user calls the `return` method on the iterator\n * or `break`s out of the loop.\n *\n * @group Synchronize Methods\n */\n synchronizeRecoverOrphans<Schema extends JSONSchema4>(\n ...args: Parameters<typeof Graffiti.prototype.recoverOrphans<Schema>>\n ): GraffitiStream<GraffitiObject<Schema>> {\n const [schema, session] = args;\n function matchObject(object: GraffitiObjectBase) {\n return object.actor === session.actor && object.channels.length === 0;\n }\n return this.synchronize(matchObject, [], schema, session);\n }\n\n protected async synchronizeDispatch(\n oldObject: GraffitiObjectBase,\n newObject?: GraffitiObjectBase,\n waitForListeners = false,\n ) {\n for (const callback of this.callbacks) {\n callback(oldObject, newObject);\n }\n if (waitForListeners) {\n // Wait for the listeners to receive\n // their objects, before returning the operation\n // that triggered them.\n //\n // This is important for mutators (put, patch, delete)\n // to ensure the application state has been updated\n // everywhere before returning, giving consistent\n // feedback to the user that the operation has completed.\n //\n // The opposite is true for accessors (get, discover, recoverOrphans),\n // where it is a weird user experience to call `get`\n // in one place and have the application update\n // somewhere else first. It is also less efficient.\n //\n // The hack is simply to await one \"macro task cycle\".\n // We need to wait for this cycle rather than using\n // `await push` in the callback, because it turns out\n // that `await push` won't resolve until the following\n // .next() call of the iterator, so if only\n // one .next() is called, this dispatch will hang.\n await new Promise((resolve) => setTimeout(resolve, 0));\n }\n }\n\n get: Graffiti[\"get\"] = async (...args) => {\n const object = await this.graffiti.get(...args);\n this.synchronizeDispatch(object);\n return object;\n };\n\n put: Graffiti[\"put\"] = async (...args) => {\n const oldObject = await this.graffiti.put(...args);\n const partialObject = args[0];\n const newObject: GraffitiObjectBase = {\n ...oldObject,\n value: partialObject.value,\n channels: partialObject.channels,\n allowed: partialObject.allowed,\n tombstone: false,\n };\n await this.synchronizeDispatch(oldObject, newObject, true);\n return oldObject;\n };\n\n patch: Graffiti[\"patch\"] = async (...args) => {\n const oldObject = await this.graffiti.patch(...args);\n const newObject: GraffitiObjectBase = { ...oldObject };\n newObject.tombstone = false;\n for (const prop of [\"value\", \"channels\", \"allowed\"] as const) {\n applyGraffitiPatch(applyPatch, prop, args[0], newObject);\n }\n await this.synchronizeDispatch(oldObject, newObject, true);\n return oldObject;\n };\n\n delete: Graffiti[\"delete\"] = async (...args) => {\n const oldObject = await this.graffiti.delete(...args);\n await this.synchronizeDispatch(oldObject, undefined, true);\n return oldObject;\n };\n\n protected objectStream<Schema extends JSONSchema4>(\n iterator: ReturnType<typeof Graffiti.prototype.discover<Schema>>,\n ) {\n const dispatch = this.synchronizeDispatch.bind(this);\n const wrapper = async function* () {\n let result = await iterator.next();\n while (!result.done) {\n if (!result.value.error) {\n dispatch(result.value.value);\n }\n yield result.value;\n result = await iterator.next();\n }\n return result.value;\n };\n return wrapper();\n }\n\n discover: Graffiti[\"discover\"] = (...args) => {\n const iterator = this.graffiti.discover(...args);\n return this.objectStream(iterator);\n };\n\n recoverOrphans: Graffiti[\"recoverOrphans\"] = (...args) => {\n const iterator = this.graffiti.recoverOrphans(...args);\n return this.objectStream(iterator);\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAAS,eAChB,OAAS,YAAAC,MAAgB,uBAQzB,OAAS,YAAAC,MAAgB,uBACzB,OAAS,cAAAC,MAAkB,kBAC3B,OACE,sBAAAC,EACA,qBAAAC,EACA,gCAAAC,EACA,iBAAAC,EACA,sBAAAC,EACA,uBAAAC,MACK,kDAkDA,MAAMC,UAA4BT,CAAS,CAC7B,IACA,SACA,UAAY,IAAI,IAEnC,aACA,cACA,cACA,MACA,OACA,cAOA,YAKEU,EAMAC,EACA,CACA,MAAM,EACN,KAAK,IAAMA,GAAO,IAAIZ,EAAI,CAAE,OAAQ,EAAM,CAAC,EAC3C,KAAK,SAAWW,EAChB,KAAK,aAAeA,EAAS,aAAa,KAAKA,CAAQ,EACvD,KAAK,cAAgBA,EAAS,cAAc,KAAKA,CAAQ,EACzD,KAAK,cAAgBA,EAAS,cAAc,KAAKA,CAAQ,EACzD,KAAK,MAAQA,EAAS,MAAM,KAAKA,CAAQ,EACzC,KAAK,OAASA,EAAS,OAAO,KAAKA,CAAQ,EAC3C,KAAK,cAAgBA,EAAS,aAChC,CAEU,YACRE,EACAC,EACAC,EACAC,EACA,CACA,MAAMC,EAAWZ,EAAkB,KAAK,IAAKU,CAAM,EA8BnD,OA5ByD,IAAIb,EAC3D,MAAOgB,EAAMC,IAAS,CACpB,MAAMC,EAAwC,CAC5CC,EACAC,IACG,CACH,UAAWC,IAAa,CAACD,EAAcD,CAAY,EACjD,GACEE,GACAV,EAAYU,CAAS,GACrBjB,EAA6BiB,EAAWP,CAAO,EAC/C,CACA,MAAMQ,EAAS,CAAE,GAAGD,CAAU,EAE9B,GADAf,EAAmBgB,EAAQV,EAAUE,CAAO,EACxCC,EAASO,CAAM,EAAG,CACpBN,EAAK,CAAE,MAAOM,CAAO,CAAC,EACtB,KACF,CACF,CAEJ,EAEA,KAAK,UAAU,IAAIJ,CAAQ,EAC3B,MAAMD,EACN,KAAK,UAAU,OAAOC,CAAQ,CAChC,CACF,CAGF,CAeA,uBACKK,EACqC,CACxC,KAAM,CAACX,EAAUC,EAAQC,CAAO,EAAIS,EACpC,SAASZ,EAAYW,EAA4B,CAC/C,OAAOA,EAAO,SAAS,KAAME,GAAYZ,EAAS,SAASY,CAAO,CAAC,CACrE,CACA,OAAO,KAAK,YAAYb,EAAaC,EAAUC,EAAQC,CAAO,CAChE,CAaA,kBACKS,EACqC,CACxC,KAAM,CAACE,EAAeZ,EAAQC,CAAO,EAAIS,EACzC,SAASZ,EAAYW,EAA4B,CAC/C,MAAMI,EAAYrB,EAAciB,CAAM,EAChC,CAAE,IAAAK,CAAI,EAAIpB,EAAoBkB,CAAa,EACjD,OAAOC,IAAcC,CACvB,CACA,OAAO,KAAK,YAAYhB,EAAa,CAAC,EAAGE,EAAQC,CAAO,CAC1D,CAeA,6BACKS,EACqC,CACxC,KAAM,CAACV,EAAQC,CAAO,EAAIS,EAC1B,SAASZ,EAAYW,EAA4B,CAC/C,OAAOA,EAAO,QAAUR,EAAQ,OAASQ,EAAO,SAAS,SAAW,CACtE,CACA,OAAO,KAAK,YAAYX,EAAa,CAAC,EAAGE,EAAQC,CAAO,CAC1D,CAEA,MAAgB,oBACdc,EACAC,EACAC,EAAmB,GACnB,CACA,UAAWZ,KAAY,KAAK,UAC1BA,EAASU,EAAWC,CAAS,EAE3BC,GAqBF,MAAM,IAAI,QAASC,GAAY,WAAWA,EAAS,CAAC,CAAC,CAEzD,CAEA,IAAuB,SAAUR,IAAS,CACxC,MAAMD,EAAS,MAAM,KAAK,SAAS,IAAI,GAAGC,CAAI,EAC9C,YAAK,oBAAoBD,CAAM,EACxBA,CACT,EAEA,IAAuB,SAAUC,IAAS,CACxC,MAAMK,EAAY,MAAM,KAAK,SAAS,IAAI,GAAGL,CAAI,EAC3CS,EAAgBT,EAAK,CAAC,EACtBM,EAAgC,CACpC,GAAGD,EACH,MAAOI,EAAc,MACrB,SAAUA,EAAc,SACxB,QAASA,EAAc,QACvB,UAAW,EACb,EACA,aAAM,KAAK,oBAAoBJ,EAAWC,EAAW,EAAI,EAClDD,CACT,EAEA,MAA2B,SAAUL,IAAS,CAC5C,MAAMK,EAAY,MAAM,KAAK,SAAS,MAAM,GAAGL,CAAI,EAC7CM,EAAgC,CAAE,GAAGD,CAAU,EACrDC,EAAU,UAAY,GACtB,UAAWI,IAAQ,CAAC,QAAS,WAAY,SAAS,EAChD/B,EAAmBD,EAAYgC,EAAMV,EAAK,CAAC,EAAGM,CAAS,EAEzD,aAAM,KAAK,oBAAoBD,EAAWC,EAAW,EAAI,EAClDD,CACT,EAEA,OAA6B,SAAUL,IAAS,CAC9C,MAAMK,EAAY,MAAM,KAAK,SAAS,OAAO,GAAGL,CAAI,EACpD,aAAM,KAAK,oBAAoBK,EAAW,OAAW,EAAI,EAClDA,CACT,EAEU,aACRM,EACA,CACA,MAAMC,EAAW,KAAK,oBAAoB,KAAK,IAAI,EAYnD,OAXgB,iBAAmB,CACjC,IAAIC,EAAS,MAAMF,EAAS,KAAK,EACjC,KAAO,CAACE,EAAO,MACRA,EAAO,MAAM,OAChBD,EAASC,EAAO,MAAM,KAAK,EAE7B,MAAMA,EAAO,MACbA,EAAS,MAAMF,EAAS,KAAK,EAE/B,OAAOE,EAAO,KAChB,EACe,CACjB,CAEA,SAAiC,IAAIb,IAAS,CAC5C,MAAMW,EAAW,KAAK,SAAS,SAAS,GAAGX,CAAI,EAC/C,OAAO,KAAK,aAAaW,CAAQ,CACnC,EAEA,eAA6C,IAAIX,IAAS,CACxD,MAAMW,EAAW,KAAK,SAAS,eAAe,GAAGX,CAAI,EACrD,OAAO,KAAK,aAAaW,CAAQ,CACnC,CACF",
|
|
6
|
+
"names": ["Ajv", "Graffiti", "Repeater", "applyPatch", "applyGraffitiPatch", "attemptAjvCompile", "isActorAllowedGraffitiObject", "locationToUri", "maskGraffitiObject", "unpackLocationOrUri", "GraffitiSynchronize", "graffiti", "ajv", "matchObject", "channels", "schema", "session", "validate", "push", "stop", "callback", "oldObjectRaw", "newObjectRaw", "objectRaw", "object", "args", "channel", "locationOrUri", "objectUri", "uri", "oldObject", "newObject", "waitForListeners", "resolve", "partialObject", "prop", "iterator", "dispatch", "result"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var Ra=Object.create;var Tr=Object.defineProperty;var ka=Object.getOwnPropertyDescriptor;var Aa=Object.getOwnPropertyNames;var Ca=Object.getPrototypeOf,Da=Object.prototype.hasOwnProperty;var _=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Is=(t,e)=>{for(var r in e)Tr(t,r,{get:e[r],enumerable:!0})},Ma=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Aa(e))!Da.call(t,s)&&s!==r&&Tr(t,s,{get:()=>e[s],enumerable:!(n=ka(e,s))||n.enumerable});return t};var xa=(t,e,r)=>(r=t!=null?Ra(Ca(t)):{},Ma(e||!t||!t.__esModule?Tr(r,"default",{value:t,enumerable:!0}):r,t));var ot=_(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0});I.regexpCode=I.getEsmExportName=I.getProperty=I.safeStringify=I.stringify=I.strConcat=I.addCodeArg=I.str=I._=I.nil=I._Code=I.Name=I.IDENTIFIER=I._CodeOrName=void 0;var nt=class{};I._CodeOrName=nt;I.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Se=class extends nt{constructor(e){if(super(),!I.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};I.Name=Se;var X=class extends nt{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof Se&&(r[n.str]=(r[n.str]||0)+1),r),{})}};I._Code=X;I.nil=new X("");function qs(t,...e){let r=[t[0]],n=0;for(;n<e.length;)qr(r,e[n]),r.push(t[++n]);return new X(r)}I._=qs;var Ir=new X("+");function Rs(t,...e){let r=[st(t[0])],n=0;for(;n<e.length;)r.push(Ir),qr(r,e[n]),r.push(Ir,st(t[++n]));return Ga(r),new X(r)}I.str=Rs;function qr(t,e){e instanceof X?t.push(...e._items):e instanceof Se?t.push(e):t.push(Va(e))}I.addCodeArg=qr;function Ga(t){let e=1;for(;e<t.length-1;){if(t[e]===Ir){let r=Ua(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function Ua(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Se||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof Se))return`"${t}${e.slice(1)}`}function za(t,e){return e.emptyStr()?t:t.emptyStr()?e:Rs`${t}${e}`}I.strConcat=za;function Va(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:st(Array.isArray(t)?t.join(","):t)}function La(t){return new X(st(t))}I.stringify=La;function st(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}I.safeStringify=st;function Fa(t){return typeof t=="string"&&I.IDENTIFIER.test(t)?new X(`.${t}`):qs`[${t}]`}I.getProperty=Fa;function Ka(t){if(typeof t=="string"&&I.IDENTIFIER.test(t))return new X(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}I.getEsmExportName=Ka;function Ha(t){return new X(t.toString())}I.regexpCode=Ha});var Ar=_(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.ValueScope=B.ValueScopeName=B.Scope=B.varKinds=B.UsedValueState=void 0;var J=ot(),Rr=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Ct;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Ct||(B.UsedValueState=Ct={}));B.varKinds={const:new J.Name("const"),let:new J.Name("let"),var:new J.Name("var")};var Dt=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof J.Name?e:this.name(e)}name(e){return new J.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};B.Scope=Dt;var Mt=class extends J.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,J._)`.${new J.Name(r)}[${n}]`}};B.ValueScopeName=Mt;var Ja=(0,J._)`\n`,kr=class extends Dt{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?Ja:J.nil}}get(){return this._scope}name(e){return new Mt(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let s=this.toName(e),{prefix:o}=s,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[o];if(a){let l=a.get(i);if(l)return l}else a=this._values[o]=new Map;a.set(i,s);let c=this._scope[o]||(this._scope[o]=[]),u=c.length;return c[u]=r.ref,s.setValue(r,{property:o,itemIndex:u}),s}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,J._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,s=>{if(s.value===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return s.value.code},r,n)}_reduceValues(e,r,n={},s){let o=J.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Ct.Started);let l=r(u);if(l){let f=this.opts.es5?B.varKinds.var:B.varKinds.const;o=(0,J._)`${o}${f} ${u} = ${l};${this.opts._n}`}else if(l=s?.(u))o=(0,J._)`${o}${l}${this.opts._n}`;else throw new Rr(u);c.set(u,Ct.Completed)})}return o}};B.ValueScope=kr});var N=_(S=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0});S.or=S.and=S.not=S.CodeGen=S.operators=S.varKinds=S.ValueScopeName=S.ValueScope=S.Scope=S.Name=S.regexpCode=S.stringify=S.getProperty=S.nil=S.strConcat=S.str=S._=void 0;var j=ot(),te=Ar(),ve=ot();Object.defineProperty(S,"_",{enumerable:!0,get:function(){return ve._}});Object.defineProperty(S,"str",{enumerable:!0,get:function(){return ve.str}});Object.defineProperty(S,"strConcat",{enumerable:!0,get:function(){return ve.strConcat}});Object.defineProperty(S,"nil",{enumerable:!0,get:function(){return ve.nil}});Object.defineProperty(S,"getProperty",{enumerable:!0,get:function(){return ve.getProperty}});Object.defineProperty(S,"stringify",{enumerable:!0,get:function(){return ve.stringify}});Object.defineProperty(S,"regexpCode",{enumerable:!0,get:function(){return ve.regexpCode}});Object.defineProperty(S,"Name",{enumerable:!0,get:function(){return ve.Name}});var zt=Ar();Object.defineProperty(S,"Scope",{enumerable:!0,get:function(){return zt.Scope}});Object.defineProperty(S,"ValueScope",{enumerable:!0,get:function(){return zt.ValueScope}});Object.defineProperty(S,"ValueScopeName",{enumerable:!0,get:function(){return zt.ValueScopeName}});Object.defineProperty(S,"varKinds",{enumerable:!0,get:function(){return zt.varKinds}});S.operators={GT:new j._Code(">"),GTE:new j._Code(">="),LT:new j._Code("<"),LTE:new j._Code("<="),EQ:new j._Code("==="),NEQ:new j._Code("!=="),NOT:new j._Code("!"),OR:new j._Code("||"),AND:new j._Code("&&"),ADD:new j._Code("+")};var de=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Cr=class extends de{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?te.varKinds.var:this.varKind,s=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${s};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=Ge(this.rhs,e,r)),this}get names(){return this.rhs instanceof j._CodeOrName?this.rhs.names:{}}},xt=class extends de{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof j.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Ge(this.rhs,e,r),this}get names(){let e=this.lhs instanceof j.Name?{}:{...this.lhs.names};return Ut(e,this.rhs)}},Dr=class extends xt{constructor(e,r,n,s){super(e,n,s),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Mr=class extends de{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},xr=class extends de{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Gr=class extends de{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Ur=class extends de{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=Ge(this.code,e,r),this}get names(){return this.code instanceof j._CodeOrName?this.code.names:{}}},it=class extends de{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,s=n.length;for(;s--;){let o=n[s];o.optimizeNames(e,r)||(Ba(e,o.names),n.splice(s,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>je(e,r.names),{})}},he=class extends it{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},zr=class extends it{},xe=class extends he{};xe.kind="else";var Oe=class t extends he{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new xe(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(ks(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=Ge(this.condition,e,r),this}get names(){let e=super.names;return Ut(e,this.condition),this.else&&je(e,this.else.names),e}};Oe.kind="if";var Ne=class extends he{};Ne.kind="for";var Vr=class extends Ne{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=Ge(this.iteration,e,r),this}get names(){return je(super.names,this.iteration.names)}},Lr=class extends Ne{constructor(e,r,n,s){super(),this.varKind=e,this.name=r,this.from=n,this.to=s}render(e){let r=e.es5?te.varKinds.var:this.varKind,{name:n,from:s,to:o}=this;return`for(${r} ${n}=${s}; ${n}<${o}; ${n}++)`+super.render(e)}get names(){let e=Ut(super.names,this.from);return Ut(e,this.to)}},Gt=class extends Ne{constructor(e,r,n,s){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=s}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=Ge(this.iterable,e,r),this}get names(){return je(super.names,this.iterable.names)}},at=class extends he{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};at.kind="func";var ut=class extends it{render(e){return"return "+super.render(e)}};ut.kind="return";var Fr=class extends he{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,s;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(s=this.finally)===null||s===void 0||s.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&je(e,this.catch.names),this.finally&&je(e,this.finally.names),e}},ct=class extends he{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};ct.kind="catch";var lt=class extends he{render(e){return"finally"+super.render(e)}};lt.kind="finally";var Kr=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
2
|
+
`:""},this._extScope=e,this._scope=new te.Scope({parent:e}),this._nodes=[new zr]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,s){let o=this._scope.toName(r);return n!==void 0&&s&&(this._constants[o.str]=n),this._leafNode(new Cr(e,o,n)),o}const(e,r,n){return this._def(te.varKinds.const,e,r,n)}let(e,r,n){return this._def(te.varKinds.let,e,r,n)}var(e,r,n){return this._def(te.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new xt(e,r,n))}add(e,r){return this._leafNode(new Dr(e,S.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==j.nil&&this._leafNode(new Ur(e)),this}object(...e){let r=["{"];for(let[n,s]of e)r.length>1&&r.push(","),r.push(n),(n!==s||this.opts.es5)&&(r.push(":"),(0,j.addCodeArg)(r,s));return r.push("}"),new j._Code(r)}if(e,r,n){if(this._blockNode(new Oe(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new Oe(e))}else(){return this._elseNode(new xe)}endIf(){return this._endBlockNode(Oe,xe)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Vr(e),r)}forRange(e,r,n,s,o=this.opts.es5?te.varKinds.var:te.varKinds.let){let i=this._scope.toName(e);return this._for(new Lr(o,i,r,n),()=>s(i))}forOf(e,r,n,s=te.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let i=r instanceof j.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,j._)`${i}.length`,a=>{this.var(o,(0,j._)`${i}[${a}]`),n(o)})}return this._for(new Gt("of",s,o,r),()=>n(o))}forIn(e,r,n,s=this.opts.es5?te.varKinds.var:te.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,j._)`Object.keys(${r})`,n);let o=this._scope.toName(e);return this._for(new Gt("in",s,o,r),()=>n(o))}endFor(){return this._endBlockNode(Ne)}label(e){return this._leafNode(new Mr(e))}break(e){return this._leafNode(new xr(e))}return(e){let r=new ut;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(ut)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let s=new Fr;if(this._blockNode(s),this.code(e),r){let o=this.name("e");this._currNode=s.catch=new ct(o),r(o)}return n&&(this._currNode=s.finally=new lt,this.code(n)),this._endBlockNode(ct,lt)}throw(e){return this._leafNode(new Gr(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=j.nil,n,s){return this._blockNode(new at(e,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(at)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof Oe))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};S.CodeGen=Kr;function je(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Ut(t,e){return e instanceof j._CodeOrName?je(t,e.names):t}function Ge(t,e,r){if(t instanceof j.Name)return n(t);if(!s(t))return t;return new j._Code(t._items.reduce((o,i)=>(i instanceof j.Name&&(i=n(i)),i instanceof j._Code?o.push(...i._items):o.push(i),o),[]));function n(o){let i=r[o.str];return i===void 0||e[o.str]!==1?o:(delete e[o.str],i)}function s(o){return o instanceof j._Code&&o._items.some(i=>i instanceof j.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function Ba(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function ks(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,j._)`!${Hr(t)}`}S.not=ks;var Wa=As(S.operators.AND);function Qa(...t){return t.reduce(Wa)}S.and=Qa;var Xa=As(S.operators.OR);function Ya(...t){return t.reduce(Xa)}S.or=Ya;function As(t){return(e,r)=>e===j.nil?r:r===j.nil?e:(0,j._)`${Hr(e)} ${t} ${Hr(r)}`}function Hr(t){return t instanceof j.Name?t:(0,j._)`(${t})`}});var q=_(O=>{"use strict";Object.defineProperty(O,"__esModule",{value:!0});O.checkStrictMode=O.getErrorPath=O.Type=O.useFunc=O.setEvaluated=O.evaluatedPropsToName=O.mergeEvaluated=O.eachItem=O.unescapeJsonPointer=O.escapeJsonPointer=O.escapeFragment=O.unescapeFragment=O.schemaRefOrVal=O.schemaHasRulesButRef=O.schemaHasRules=O.checkUnknownRules=O.alwaysValidSchema=O.toHash=void 0;var k=N(),Za=ot();function eu(t){let e={};for(let r of t)e[r]=!0;return e}O.toHash=eu;function tu(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Ms(t,e),!xs(e,t.self.RULES.all))}O.alwaysValidSchema=tu;function Ms(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let s=n.RULES.keywords;for(let o in e)s[o]||zs(t,`unknown keyword: "${o}"`)}O.checkUnknownRules=Ms;function xs(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}O.schemaHasRules=xs;function ru(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}O.schemaHasRulesButRef=ru;function nu({topSchemaRef:t,schemaPath:e},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,k._)`${r}`}return(0,k._)`${t}${e}${(0,k.getProperty)(n)}`}O.schemaRefOrVal=nu;function su(t){return Gs(decodeURIComponent(t))}O.unescapeFragment=su;function ou(t){return encodeURIComponent(Br(t))}O.escapeFragment=ou;function Br(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}O.escapeJsonPointer=Br;function Gs(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}O.unescapeJsonPointer=Gs;function iu(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}O.eachItem=iu;function Cs({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(s,o,i,a)=>{let c=i===void 0?o:i instanceof k.Name?(o instanceof k.Name?t(s,o,i):e(s,o,i),i):o instanceof k.Name?(e(s,i,o),o):r(o,i);return a===k.Name&&!(c instanceof k.Name)?n(s,c):c}}O.mergeEvaluated={props:Cs({mergeNames:(t,e,r)=>t.if((0,k._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,k._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,k._)`${r} || {}`).code((0,k._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,k._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,k._)`${r} || {}`),Wr(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:Us}),items:Cs({mergeNames:(t,e,r)=>t.if((0,k._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,k._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,k._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,k._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function Us(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,k._)`{}`);return e!==void 0&&Wr(t,r,e),r}O.evaluatedPropsToName=Us;function Wr(t,e,r){Object.keys(r).forEach(n=>t.assign((0,k._)`${e}${(0,k.getProperty)(n)}`,!0))}O.setEvaluated=Wr;var Ds={};function au(t,e){return t.scopeValue("func",{ref:e,code:Ds[e.code]||(Ds[e.code]=new Za._Code(e.code))})}O.useFunc=au;var Jr;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Jr||(O.Type=Jr={}));function uu(t,e,r){if(t instanceof k.Name){let n=e===Jr.Num;return r?n?(0,k._)`"[" + ${t} + "]"`:(0,k._)`"['" + ${t} + "']"`:n?(0,k._)`"/" + ${t}`:(0,k._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,k.getProperty)(t).toString():"/"+Br(t)}O.getErrorPath=uu;function zs(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}O.checkStrictMode=zs});var pe=_(Qr=>{"use strict";Object.defineProperty(Qr,"__esModule",{value:!0});var V=N(),cu={data:new V.Name("data"),valCxt:new V.Name("valCxt"),instancePath:new V.Name("instancePath"),parentData:new V.Name("parentData"),parentDataProperty:new V.Name("parentDataProperty"),rootData:new V.Name("rootData"),dynamicAnchors:new V.Name("dynamicAnchors"),vErrors:new V.Name("vErrors"),errors:new V.Name("errors"),this:new V.Name("this"),self:new V.Name("self"),scope:new V.Name("scope"),json:new V.Name("json"),jsonPos:new V.Name("jsonPos"),jsonLen:new V.Name("jsonLen"),jsonPart:new V.Name("jsonPart")};Qr.default=cu});var ft=_(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.extendErrors=L.resetErrorsCount=L.reportExtraError=L.reportError=L.keyword$DataError=L.keywordError=void 0;var T=N(),Vt=q(),K=pe();L.keywordError={message:({keyword:t})=>(0,T.str)`must pass "${t}" keyword validation`};L.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,T.str)`"${t}" keyword must be ${e} ($data)`:(0,T.str)`"${t}" keyword is invalid ($data)`};function lu(t,e=L.keywordError,r,n){let{it:s}=t,{gen:o,compositeRule:i,allErrors:a}=s,c=Fs(t,e,r);n??(i||a)?Vs(o,c):Ls(s,(0,T._)`[${c}]`)}L.reportError=lu;function fu(t,e=L.keywordError,r){let{it:n}=t,{gen:s,compositeRule:o,allErrors:i}=n,a=Fs(t,e,r);Vs(s,a),o||i||Ls(n,K.default.vErrors)}L.reportExtraError=fu;function du(t,e){t.assign(K.default.errors,e),t.if((0,T._)`${K.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,T._)`${K.default.vErrors}.length`,e),()=>t.assign(K.default.vErrors,null)))}L.resetErrorsCount=du;function hu({gen:t,keyword:e,schemaValue:r,data:n,errsCount:s,it:o}){if(s===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",s,K.default.errors,a=>{t.const(i,(0,T._)`${K.default.vErrors}[${a}]`),t.if((0,T._)`${i}.instancePath === undefined`,()=>t.assign((0,T._)`${i}.instancePath`,(0,T.strConcat)(K.default.instancePath,o.errorPath))),t.assign((0,T._)`${i}.schemaPath`,(0,T.str)`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign((0,T._)`${i}.schema`,r),t.assign((0,T._)`${i}.data`,n))})}L.extendErrors=hu;function Vs(t,e){let r=t.const("err",e);t.if((0,T._)`${K.default.vErrors} === null`,()=>t.assign(K.default.vErrors,(0,T._)`[${r}]`),(0,T._)`${K.default.vErrors}.push(${r})`),t.code((0,T._)`${K.default.errors}++`)}function Ls(t,e){let{gen:r,validateName:n,schemaEnv:s}=t;s.$async?r.throw((0,T._)`new ${t.ValidationError}(${e})`):(r.assign((0,T._)`${n}.errors`,e),r.return(!1))}var Te={keyword:new T.Name("keyword"),schemaPath:new T.Name("schemaPath"),params:new T.Name("params"),propertyName:new T.Name("propertyName"),message:new T.Name("message"),schema:new T.Name("schema"),parentSchema:new T.Name("parentSchema")};function Fs(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,T._)`{}`:pu(t,e,r)}function pu(t,e,r={}){let{gen:n,it:s}=t,o=[mu(s,r),yu(t,r)];return vu(t,e,o),n.object(...o)}function mu({errorPath:t},{instancePath:e}){let r=e?(0,T.str)`${t}${(0,Vt.getErrorPath)(e,Vt.Type.Str)}`:t;return[K.default.instancePath,(0,T.strConcat)(K.default.instancePath,r)]}function yu({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let s=n?e:(0,T.str)`${e}/${t}`;return r&&(s=(0,T.str)`${s}${(0,Vt.getErrorPath)(r,Vt.Type.Str)}`),[Te.schemaPath,s]}function vu(t,{params:e,message:r},n){let{keyword:s,data:o,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:f}=a;n.push([Te.keyword,s],[Te.params,typeof e=="function"?e(t):e||(0,T._)`{}`]),c.messages&&n.push([Te.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([Te.schema,i],[Te.parentSchema,(0,T._)`${l}${f}`],[K.default.data,o]),u&&n.push([Te.propertyName,u])}});var Hs=_(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});Ue.boolOrEmptySchema=Ue.topBoolOrEmptySchema=void 0;var _u=ft(),gu=N(),wu=pe(),$u={message:"boolean schema is false"};function bu(t){let{gen:e,schema:r,validateName:n}=t;r===!1?Ks(t,!1):typeof r=="object"&&r.$async===!0?e.return(wu.default.data):(e.assign((0,gu._)`${n}.errors`,null),e.return(!0))}Ue.topBoolOrEmptySchema=bu;function Eu(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),Ks(t)):r.var(e,!0)}Ue.boolOrEmptySchema=Eu;function Ks(t,e){let{gen:r,data:n}=t,s={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,_u.reportError)(s,$u,void 0,e)}});var Xr=_(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.getRules=ze.isJSONType=void 0;var Pu=["string","number","integer","boolean","null","object","array"],Su=new Set(Pu);function Ou(t){return typeof t=="string"&&Su.has(t)}ze.isJSONType=Ou;function Nu(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}ze.getRules=Nu});var Yr=_(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.shouldUseRule=_e.shouldUseGroup=_e.schemaHasRulesForType=void 0;function ju({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&Js(t,n)}_e.schemaHasRulesForType=ju;function Js(t,e){return e.rules.some(r=>Bs(t,r))}_e.shouldUseGroup=Js;function Bs(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}_e.shouldUseRule=Bs});var dt=_(F=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.reportTypeError=F.checkDataTypes=F.checkDataType=F.coerceAndCheckDataType=F.getJSONTypes=F.getSchemaTypes=F.DataType=void 0;var Tu=Xr(),Iu=Yr(),qu=ft(),E=N(),Ws=q(),Ve;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(Ve||(F.DataType=Ve={}));function Ru(t){let e=Qs(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}F.getSchemaTypes=Ru;function Qs(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(Tu.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}F.getJSONTypes=Qs;function ku(t,e){let{gen:r,data:n,opts:s}=t,o=Au(e,s.coerceTypes),i=e.length>0&&!(o.length===0&&e.length===1&&(0,Iu.schemaHasRulesForType)(t,e[0]));if(i){let a=en(e,n,s.strictNumbers,Ve.Wrong);r.if(a,()=>{o.length?Cu(t,e,o):tn(t)})}return i}F.coerceAndCheckDataType=ku;var Xs=new Set(["string","number","integer","boolean","null"]);function Au(t,e){return e?t.filter(r=>Xs.has(r)||e==="array"&&r==="array"):[]}function Cu(t,e,r){let{gen:n,data:s,opts:o}=t,i=n.let("dataType",(0,E._)`typeof ${s}`),a=n.let("coerced",(0,E._)`undefined`);o.coerceTypes==="array"&&n.if((0,E._)`${i} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,E._)`${s}[0]`).assign(i,(0,E._)`typeof ${s}`).if(en(e,s,o.strictNumbers),()=>n.assign(a,s))),n.if((0,E._)`${a} !== undefined`);for(let u of r)(Xs.has(u)||u==="array"&&o.coerceTypes==="array")&&c(u);n.else(),tn(t),n.endIf(),n.if((0,E._)`${a} !== undefined`,()=>{n.assign(s,a),Du(t,a)});function c(u){switch(u){case"string":n.elseIf((0,E._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,E._)`"" + ${s}`).elseIf((0,E._)`${s} === null`).assign(a,(0,E._)`""`);return;case"number":n.elseIf((0,E._)`${i} == "boolean" || ${s} === null
|
|
3
|
+
|| (${i} == "string" && ${s} && ${s} == +${s})`).assign(a,(0,E._)`+${s}`);return;case"integer":n.elseIf((0,E._)`${i} === "boolean" || ${s} === null
|
|
4
|
+
|| (${i} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(a,(0,E._)`+${s}`);return;case"boolean":n.elseIf((0,E._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(a,!1).elseIf((0,E._)`${s} === "true" || ${s} === 1`).assign(a,!0);return;case"null":n.elseIf((0,E._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(a,null);return;case"array":n.elseIf((0,E._)`${i} === "string" || ${i} === "number"
|
|
5
|
+
|| ${i} === "boolean" || ${s} === null`).assign(a,(0,E._)`[${s}]`)}}}function Du({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,E._)`${e} !== undefined`,()=>t.assign((0,E._)`${e}[${r}]`,n))}function Zr(t,e,r,n=Ve.Correct){let s=n===Ve.Correct?E.operators.EQ:E.operators.NEQ,o;switch(t){case"null":return(0,E._)`${e} ${s} null`;case"array":o=(0,E._)`Array.isArray(${e})`;break;case"object":o=(0,E._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":o=i((0,E._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":o=i();break;default:return(0,E._)`typeof ${e} ${s} ${t}`}return n===Ve.Correct?o:(0,E.not)(o);function i(a=E.nil){return(0,E.and)((0,E._)`typeof ${e} == "number"`,a,r?(0,E._)`isFinite(${e})`:E.nil)}}F.checkDataType=Zr;function en(t,e,r,n){if(t.length===1)return Zr(t[0],e,r,n);let s,o=(0,Ws.toHash)(t);if(o.array&&o.object){let i=(0,E._)`typeof ${e} != "object"`;s=o.null?i:(0,E._)`!${e} || ${i}`,delete o.null,delete o.array,delete o.object}else s=E.nil;o.number&&delete o.integer;for(let i in o)s=(0,E.and)(s,Zr(i,e,r,n));return s}F.checkDataTypes=en;var Mu={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,E._)`{type: ${t}}`:(0,E._)`{type: ${e}}`};function tn(t){let e=xu(t);(0,qu.reportError)(e,Mu)}F.reportTypeError=tn;function xu(t){let{gen:e,data:r,schema:n}=t,s=(0,Ws.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:t}}});var Zs=_(Lt=>{"use strict";Object.defineProperty(Lt,"__esModule",{value:!0});Lt.assignDefaults=void 0;var Le=N(),Gu=q();function Uu(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let s in r)Ys(t,s,r[s].default);else e==="array"&&Array.isArray(n)&&n.forEach((s,o)=>Ys(t,o,s.default))}Lt.assignDefaults=Uu;function Ys(t,e,r){let{gen:n,compositeRule:s,data:o,opts:i}=t;if(r===void 0)return;let a=(0,Le._)`${o}${(0,Le.getProperty)(e)}`;if(s){(0,Gu.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,Le._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Le._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Le._)`${a} = ${(0,Le.stringify)(r)}`)}});var Y=_(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.validateUnion=R.validateArray=R.usePattern=R.callValidateCode=R.schemaProperties=R.allSchemaProperties=R.noPropertyInData=R.propertyInData=R.isOwnProperty=R.hasPropFunc=R.reportMissingProp=R.checkMissingProp=R.checkReportMissingProp=void 0;var C=N(),rn=q(),ge=pe(),zu=q();function Vu(t,e){let{gen:r,data:n,it:s}=t;r.if(sn(r,n,e,s.opts.ownProperties),()=>{t.setParams({missingProperty:(0,C._)`${e}`},!0),t.error()})}R.checkReportMissingProp=Vu;function Lu({gen:t,data:e,it:{opts:r}},n,s){return(0,C.or)(...n.map(o=>(0,C.and)(sn(t,e,o,r.ownProperties),(0,C._)`${s} = ${o}`)))}R.checkMissingProp=Lu;function Fu(t,e){t.setParams({missingProperty:e},!0),t.error()}R.reportMissingProp=Fu;function eo(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,C._)`Object.prototype.hasOwnProperty`})}R.hasPropFunc=eo;function nn(t,e,r){return(0,C._)`${eo(t)}.call(${e}, ${r})`}R.isOwnProperty=nn;function Ku(t,e,r,n){let s=(0,C._)`${e}${(0,C.getProperty)(r)} !== undefined`;return n?(0,C._)`${s} && ${nn(t,e,r)}`:s}R.propertyInData=Ku;function sn(t,e,r,n){let s=(0,C._)`${e}${(0,C.getProperty)(r)} === undefined`;return n?(0,C.or)(s,(0,C.not)(nn(t,e,r))):s}R.noPropertyInData=sn;function to(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}R.allSchemaProperties=to;function Hu(t,e){return to(e).filter(r=>!(0,rn.alwaysValidSchema)(t,e[r]))}R.schemaProperties=Hu;function Ju({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:i},a,c,u){let l=u?(0,C._)`${t}, ${e}, ${n}${s}`:e,f=[[ge.default.instancePath,(0,C.strConcat)(ge.default.instancePath,o)],[ge.default.parentData,i.parentData],[ge.default.parentDataProperty,i.parentDataProperty],[ge.default.rootData,ge.default.rootData]];i.opts.dynamicRef&&f.push([ge.default.dynamicAnchors,ge.default.dynamicAnchors]);let d=(0,C._)`${l}, ${r.object(...f)}`;return c!==C.nil?(0,C._)`${a}.call(${c}, ${d})`:(0,C._)`${a}(${d})`}R.callValidateCode=Ju;var Bu=(0,C._)`new RegExp`;function Wu({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:s}=e.code,o=s(r,n);return t.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,C._)`${s.code==="new RegExp"?Bu:(0,zu.useFunc)(t,s)}(${r}, ${n})`})}R.usePattern=Wu;function Qu(t){let{gen:e,data:r,keyword:n,it:s}=t,o=e.name("valid");if(s.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(o,!0),i(()=>e.break()),o;function i(a){let c=e.const("len",(0,C._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:rn.Type.Num},o),e.if((0,C.not)(o),a)})}}R.validateArray=Qu;function Xu(t){let{gen:e,schema:r,keyword:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,rn.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(i,(0,C._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,C.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}R.validateUnion=Xu});var so=_(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.validateKeywordUsage=ie.validSchemaType=ie.funcKeywordCode=ie.macroKeywordCode=void 0;var H=N(),Ie=pe(),Yu=Y(),Zu=ft();function ec(t,e){let{gen:r,keyword:n,schema:s,parentSchema:o,it:i}=t,a=e.macro.call(i.self,s,o,i),c=no(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:H.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}ie.macroKeywordCode=ec;function tc(t,e){var r;let{gen:n,keyword:s,schema:o,parentSchema:i,$data:a,it:c}=t;nc(c,e);let u=!a&&e.compile?e.compile.call(c.self,o,i,c):e.validate,l=no(n,s,u),f=n.let("valid");t.block$data(f,d),t.ok((r=e.valid)!==null&&r!==void 0?r:f);function d(){if(e.errors===!1)m(),e.modifying&&ro(t),y(()=>t.error());else{let v=e.async?h():p();e.modifying&&ro(t),y(()=>rc(t,v))}}function h(){let v=n.let("ruleErrs",null);return n.try(()=>m((0,H._)`await `),P=>n.assign(f,!1).if((0,H._)`${P} instanceof ${c.ValidationError}`,()=>n.assign(v,(0,H._)`${P}.errors`),()=>n.throw(P))),v}function p(){let v=(0,H._)`${l}.errors`;return n.assign(v,null),m(H.nil),v}function m(v=e.async?(0,H._)`await `:H.nil){let P=c.opts.passContext?Ie.default.this:Ie.default.self,w=!("compile"in e&&!a||e.schema===!1);n.assign(f,(0,H._)`${v}${(0,Yu.callValidateCode)(t,l,P,w)}`,e.modifying)}function y(v){var P;n.if((0,H.not)((P=e.valid)!==null&&P!==void 0?P:f),v)}}ie.funcKeywordCode=tc;function ro(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,H._)`${n.parentData}[${n.parentDataProperty}]`))}function rc(t,e){let{gen:r}=t;r.if((0,H._)`Array.isArray(${e})`,()=>{r.assign(Ie.default.vErrors,(0,H._)`${Ie.default.vErrors} === null ? ${e} : ${Ie.default.vErrors}.concat(${e})`).assign(Ie.default.errors,(0,H._)`${Ie.default.vErrors}.length`),(0,Zu.extendErrors)(t)},()=>t.error())}function nc({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function no(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,H.stringify)(r)})}function sc(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}ie.validSchemaType=sc;function oc({schema:t,opts:e,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");let i=s.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${o}: ${i.join(",")}`);if(s.validateSchema&&!s.validateSchema(t[o])){let c=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}ie.validateKeywordUsage=oc});var io=_(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.extendSubschemaMode=we.extendSubschemaData=we.getSubschema=void 0;var ae=N(),oo=q();function ic(t,{keyword:e,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,ae._)`${t.schemaPath}${(0,ae.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,ae._)`${t.schemaPath}${(0,ae.getProperty)(e)}${(0,ae.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,oo.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:i,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}we.getSubschema=ic;function ac(t,e,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:i}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:f}=e,d=a.let("data",(0,ae._)`${e.data}${(0,ae.getProperty)(r)}`,!0);c(d),t.errorPath=(0,ae.str)`${u}${(0,oo.getErrorPath)(r,n,f.jsPropertySyntax)}`,t.parentDataProperty=(0,ae._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(s!==void 0){let u=s instanceof ae.Name?s:a.let("data",s,!0);c(u),i!==void 0&&(t.propertyName=i)}o&&(t.dataTypes=o);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}we.extendSubschemaData=ac;function uc(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(t.compositeRule=n),s!==void 0&&(t.createErrors=s),o!==void 0&&(t.allErrors=o),t.jtdDiscriminator=e,t.jtdMetadata=r}we.extendSubschemaMode=uc});var on=_((Bh,ao)=>{"use strict";ao.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,s,o;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(s=n;s--!==0;)if(!t(e[s],r[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(o=Object.keys(e),n=o.length,n!==Object.keys(r).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[s]))return!1;for(s=n;s--!==0;){var i=o[s];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var co=_((Wh,uo)=>{"use strict";var $e=uo.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};Ft(e,n,s,t,"",t)};$e.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};$e.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};$e.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};$e.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Ft(t,e,r,n,s,o,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,s,o,i,a,c,u);for(var l in n){var f=n[l];if(Array.isArray(f)){if(l in $e.arrayKeywords)for(var d=0;d<f.length;d++)Ft(t,e,r,f[d],s+"/"+l+"/"+d,o,s,l,n,d)}else if(l in $e.propsKeywords){if(f&&typeof f=="object")for(var h in f)Ft(t,e,r,f[h],s+"/"+l+"/"+cc(h),o,s,l,n,h)}else(l in $e.keywords||t.allKeys&&!(l in $e.skipKeywords))&&Ft(t,e,r,f,s+"/"+l,o,s,l,n)}r(n,s,o,i,a,c,u)}}function cc(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var ht=_(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.getSchemaRefs=W.resolveUrl=W.normalizeId=W._getFullPath=W.getFullPath=W.inlineRef=void 0;var lc=q(),fc=on(),dc=co(),hc=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function pc(t,e=!0){return typeof t=="boolean"?!0:e===!0?!an(t):e?lo(t)<=e:!1}W.inlineRef=pc;var mc=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function an(t){for(let e in t){if(mc.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(an)||typeof r=="object"&&an(r))return!0}return!1}function lo(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!hc.has(r)&&(typeof t[r]=="object"&&(0,lc.eachItem)(t[r],n=>e+=lo(n)),e===1/0))return 1/0}return e}function fo(t,e="",r){r!==!1&&(e=Fe(e));let n=t.parse(e);return ho(t,n)}W.getFullPath=fo;function ho(t,e){return t.serialize(e).split("#")[0]+"#"}W._getFullPath=ho;var yc=/#\/?$/;function Fe(t){return t?t.replace(yc,""):""}W.normalizeId=Fe;function vc(t,e,r){return r=Fe(r),t.resolve(e,r)}W.resolveUrl=vc;var _c=/^[a-z_][-a-z0-9._]*$/i;function gc(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,s=Fe(t[r]||e),o={"":s},i=fo(n,s,!1),a={},c=new Set;return dc(t,{allKeys:!0},(f,d,h,p)=>{if(p===void 0)return;let m=i+d,y=o[p];typeof f[r]=="string"&&(y=v.call(this,f[r])),P.call(this,f.$anchor),P.call(this,f.$dynamicAnchor),o[d]=y;function v(w){let A=this.opts.uriResolver.resolve;if(w=Fe(y?A(y,w):w),c.has(w))throw l(w);c.add(w);let b=this.refs[w];return typeof b=="string"&&(b=this.refs[b]),typeof b=="object"?u(f,b.schema,w):w!==Fe(m)&&(w[0]==="#"?(u(f,a[w],w),a[w]=f):this.refs[w]=m),w}function P(w){if(typeof w=="string"){if(!_c.test(w))throw new Error(`invalid anchor "${w}"`);v.call(this,`#${w}`)}}}),a;function u(f,d,h){if(d!==void 0&&!fc(f,d))throw l(h)}function l(f){return new Error(`reference "${f}" resolves to more than one schema`)}}W.getSchemaRefs=gc});var Jt=_(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.getData=be.KeywordCxt=be.validateFunctionCode=void 0;var _o=Hs(),po=dt(),cn=Yr(),Kt=dt(),wc=Zs(),mt=so(),un=io(),g=N(),$=pe(),$c=ht(),me=q(),pt=ft();function bc(t){if($o(t)&&(bo(t),wo(t))){Sc(t);return}go(t,()=>(0,_o.topBoolOrEmptySchema)(t))}be.validateFunctionCode=bc;function go({gen:t,validateName:e,schema:r,schemaEnv:n,opts:s},o){s.code.es5?t.func(e,(0,g._)`${$.default.data}, ${$.default.valCxt}`,n.$async,()=>{t.code((0,g._)`"use strict"; ${mo(r,s)}`),Pc(t,s),t.code(o)}):t.func(e,(0,g._)`${$.default.data}, ${Ec(s)}`,n.$async,()=>t.code(mo(r,s)).code(o))}function Ec(t){return(0,g._)`{${$.default.instancePath}="", ${$.default.parentData}, ${$.default.parentDataProperty}, ${$.default.rootData}=${$.default.data}${t.dynamicRef?(0,g._)`, ${$.default.dynamicAnchors}={}`:g.nil}}={}`}function Pc(t,e){t.if($.default.valCxt,()=>{t.var($.default.instancePath,(0,g._)`${$.default.valCxt}.${$.default.instancePath}`),t.var($.default.parentData,(0,g._)`${$.default.valCxt}.${$.default.parentData}`),t.var($.default.parentDataProperty,(0,g._)`${$.default.valCxt}.${$.default.parentDataProperty}`),t.var($.default.rootData,(0,g._)`${$.default.valCxt}.${$.default.rootData}`),e.dynamicRef&&t.var($.default.dynamicAnchors,(0,g._)`${$.default.valCxt}.${$.default.dynamicAnchors}`)},()=>{t.var($.default.instancePath,(0,g._)`""`),t.var($.default.parentData,(0,g._)`undefined`),t.var($.default.parentDataProperty,(0,g._)`undefined`),t.var($.default.rootData,$.default.data),e.dynamicRef&&t.var($.default.dynamicAnchors,(0,g._)`{}`)})}function Sc(t){let{schema:e,opts:r,gen:n}=t;go(t,()=>{r.$comment&&e.$comment&&Po(t),Ic(t),n.let($.default.vErrors,null),n.let($.default.errors,0),r.unevaluated&&Oc(t),Eo(t),kc(t)})}function Oc(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,g._)`${r}.evaluated`),e.if((0,g._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,g._)`${t.evaluated}.props`,(0,g._)`undefined`)),e.if((0,g._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,g._)`${t.evaluated}.items`,(0,g._)`undefined`))}function mo(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,g._)`/*# sourceURL=${r} */`:g.nil}function Nc(t,e){if($o(t)&&(bo(t),wo(t))){jc(t,e);return}(0,_o.boolOrEmptySchema)(t,e)}function wo({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function $o(t){return typeof t.schema!="boolean"}function jc(t,e){let{schema:r,gen:n,opts:s}=t;s.$comment&&r.$comment&&Po(t),qc(t),Rc(t);let o=n.const("_errs",$.default.errors);Eo(t,o),n.var(e,(0,g._)`${o} === ${$.default.errors}`)}function bo(t){(0,me.checkUnknownRules)(t),Tc(t)}function Eo(t,e){if(t.opts.jtd)return yo(t,[],!1,e);let r=(0,po.getSchemaTypes)(t.schema),n=(0,po.coerceAndCheckDataType)(t,r);yo(t,r,!n,e)}function Tc(t){let{schema:e,errSchemaPath:r,opts:n,self:s}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,me.schemaHasRulesButRef)(e,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Ic(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,me.checkStrictMode)(t,"default is ignored in the schema root")}function qc(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,$c.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function Rc(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function Po({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:s}){let o=r.$comment;if(s.$comment===!0)t.code((0,g._)`${$.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){let i=(0,g.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,g._)`${$.default.self}.opts.$comment(${o}, ${i}, ${a}.schema)`)}}function kc(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=t;r.$async?e.if((0,g._)`${$.default.errors} === 0`,()=>e.return($.default.data),()=>e.throw((0,g._)`new ${s}(${$.default.vErrors})`)):(e.assign((0,g._)`${n}.errors`,$.default.vErrors),o.unevaluated&&Ac(t),e.return((0,g._)`${$.default.errors} === 0`))}function Ac({gen:t,evaluated:e,props:r,items:n}){r instanceof g.Name&&t.assign((0,g._)`${e}.props`,r),n instanceof g.Name&&t.assign((0,g._)`${e}.items`,n)}function yo(t,e,r,n){let{gen:s,schema:o,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,me.schemaHasRulesButRef)(o,l))){s.block(()=>Oo(t,"$ref",l.all.$ref.definition));return}c.jtd||Cc(t,e),s.block(()=>{for(let d of l.rules)f(d);f(l.post)});function f(d){(0,cn.shouldUseGroup)(o,d)&&(d.type?(s.if((0,Kt.checkDataType)(d.type,i,c.strictNumbers)),vo(t,d),e.length===1&&e[0]===d.type&&r&&(s.else(),(0,Kt.reportTypeError)(t)),s.endIf()):vo(t,d),a||s.if((0,g._)`${$.default.errors} === ${n||0}`))}}function vo(t,e){let{gen:r,schema:n,opts:{useDefaults:s}}=t;s&&(0,wc.assignDefaults)(t,e.type),r.block(()=>{for(let o of e.rules)(0,cn.shouldUseRule)(n,o)&&Oo(t,o.keyword,o.definition,e.type)})}function Cc(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(Dc(t,e),t.opts.allowUnionTypes||Mc(t,e),xc(t,t.dataTypes))}function Dc(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{So(t.dataTypes,r)||ln(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),Uc(t,e)}}function Mc(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&ln(t,"use allowUnionTypes to allow union type keyword")}function xc(t,e){let r=t.self.RULES.all;for(let n in r){let s=r[n];if(typeof s=="object"&&(0,cn.shouldUseRule)(t.schema,s)){let{type:o}=s.definition;o.length&&!o.some(i=>Gc(e,i))&&ln(t,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function Gc(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function So(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function Uc(t,e){let r=[];for(let n of t.dataTypes)So(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function ln(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,me.checkStrictMode)(t,e,t.opts.strictTypes)}var Ht=class{constructor(e,r,n){if((0,mt.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,me.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",No(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,mt.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",$.default.errors))}result(e,r,n){this.failResult((0,g.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,g.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,g._)`${r} !== undefined && (${(0,g.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?pt.reportExtraError:pt.reportError)(this,this.def.error,r)}$dataError(){(0,pt.reportError)(this,this.def.$dataError||pt.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,pt.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=g.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=g.nil,r=g.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:o,def:i}=this;n.if((0,g.or)((0,g._)`${s} === undefined`,r)),e!==g.nil&&n.assign(e,!0),(o.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==g.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,g.or)(i(),a());function i(){if(n.length){if(!(r instanceof g.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,g._)`${(0,Kt.checkDataTypes)(c,r,o.opts.strictNumbers,Kt.DataType.Wrong)}`}return g.nil}function a(){if(s.validateSchema){let c=e.scopeValue("validate$data",{ref:s.validateSchema});return(0,g._)`!${c}(${r})`}return g.nil}}subschema(e,r){let n=(0,un.getSubschema)(this.it,e);(0,un.extendSubschemaData)(n,this.it,e),(0,un.extendSubschemaMode)(n,e);let s={...this.it,...n,items:void 0,props:void 0};return Nc(s,r),s}mergeEvaluated(e,r){let{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=me.mergeEvaluated.props(s,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=me.mergeEvaluated.items(s,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(e,g.Name)),!0}};be.KeywordCxt=Ht;function Oo(t,e,r,n){let s=new Ht(t,r,e);"code"in r?r.code(s,n):s.$data&&r.validate?(0,mt.funcKeywordCode)(s,r):"macro"in r?(0,mt.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,mt.funcKeywordCode)(s,r)}var zc=/^\/(?:[^~]|~0|~1)*$/,Vc=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function No(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let s,o;if(t==="")return $.default.rootData;if(t[0]==="/"){if(!zc.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);s=t,o=$.default.rootData}else{let u=Vc.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(s=u[2],s==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(o=r[e-l],!s)return o}let i=o,a=s.split("/");for(let u of a)u&&(o=(0,g._)`${o}${(0,g.getProperty)((0,me.unescapeJsonPointer)(u))}`,i=(0,g._)`${i} && ${o}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}be.getData=No});var hn=_(dn=>{"use strict";Object.defineProperty(dn,"__esModule",{value:!0});var fn=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};dn.default=fn});var Bt=_(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});var pn=ht(),mn=class extends Error{constructor(e,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,pn.resolveUrl)(e,r,n),this.missingSchema=(0,pn.normalizeId)((0,pn.getFullPath)(e,this.missingRef))}};yn.default=mn});var Qt=_(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.resolveSchema=Z.getCompilingSchema=Z.resolveRef=Z.compileSchema=Z.SchemaEnv=void 0;var re=N(),Lc=hn(),qe=pe(),ne=ht(),jo=q(),Fc=Jt(),Ke=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,ne.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};Z.SchemaEnv=Ke;function _n(t){let e=To.call(this,t);if(e)return e;let r=(0,ne.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,i=new re.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o}),a;t.$async&&(a=i.scopeValue("Error",{ref:Lc.default,code:(0,re._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:qe.default.data,parentData:qe.default.parentData,parentDataProperty:qe.default.parentDataProperty,dataNames:[qe.default.data],dataPathArr:[re.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,re.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:re.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,re._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,Fc.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let f=i.toString();l=`${i.scopeRefs(qe.default.scope)}return ${f}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let h=new Function(`${qe.default.self}`,`${qe.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:h}),h.errors=null,h.schema=t.schema,h.schemaEnv=t,t.$async&&(h.$async=!0),this.opts.code.source===!0&&(h.source={validateName:c,validateCode:f,scopeValues:i._values}),this.opts.unevaluated){let{props:p,items:m}=u;h.evaluated={props:p instanceof re.Name?void 0:p,items:m instanceof re.Name?void 0:m,dynamicProps:p instanceof re.Name,dynamicItems:m instanceof re.Name},h.source&&(h.source.evaluated=(0,re.stringify)(h.evaluated))}return t.validate=h,t}catch(f){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),f}finally{this._compilations.delete(t)}}Z.compileSchema=_n;function Kc(t,e,r){var n;r=(0,ne.resolveUrl)(this.opts.uriResolver,e,r);let s=t.refs[r];if(s)return s;let o=Bc.call(this,t,r);if(o===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(o=new Ke({schema:i,schemaId:a,root:t,baseId:e}))}if(o!==void 0)return t.refs[r]=Hc.call(this,o)}Z.resolveRef=Kc;function Hc(t){return(0,ne.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:_n.call(this,t)}function To(t){for(let e of this._compilations)if(Jc(e,t))return e}Z.getCompilingSchema=To;function Jc(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Bc(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Wt.call(this,t,e)}function Wt(t,e){let r=this.opts.uriResolver.parse(e),n=(0,ne._getFullPath)(this.opts.uriResolver,r),s=(0,ne.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===s)return vn.call(this,r,t);let o=(0,ne.normalizeId)(n),i=this.refs[o]||this.schemas[o];if(typeof i=="string"){let a=Wt.call(this,t,i);return typeof a?.schema!="object"?void 0:vn.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||_n.call(this,i),o===(0,ne.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(s=(0,ne.resolveUrl)(this.opts.uriResolver,s,u)),new Ke({schema:a,schemaId:c,root:t,baseId:s})}return vn.call(this,r,i)}}Z.resolveSchema=Wt;var Wc=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function vn(t,{baseId:e,schema:r,root:n}){var s;if(((s=t.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,jo.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!Wc.has(a)&&u&&(e=(0,ne.resolveUrl)(this.opts.uriResolver,e,u))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,jo.schemaHasRulesButRef)(r,this.RULES)){let a=(0,ne.resolveUrl)(this.opts.uriResolver,e,r.$ref);o=Wt.call(this,n,a)}let{schemaId:i}=this.opts;if(o=o||new Ke({schema:r,schemaId:i,root:n,baseId:e}),o.schema!==o.root.schema)return o}});var Io=_((tp,Qc)=>{Qc.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var Ro=_((rp,qo)=>{"use strict";var Xc={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};qo.exports={HEX:Xc}});var Uo=_((np,Go)=>{"use strict";var{HEX:Yc}=Ro(),Zc=/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u;function Do(t){if(xo(t,".")<3)return{host:t,isIPV4:!1};let e=t.match(Zc)||[],[r]=e;return r?{host:tl(r,"."),isIPV4:!0}:{host:t,isIPV4:!1}}function gn(t,e=!1){let r="",n=!0;for(let s of t){if(Yc[s]===void 0)return;s!=="0"&&n===!0&&(n=!1),n||(r+=s)}return e&&r.length===0&&(r="0"),r}function el(t){let e=0,r={error:!1,address:"",zone:""},n=[],s=[],o=!1,i=!1,a=!1;function c(){if(s.length){if(o===!1){let u=gn(s);if(u!==void 0)n.push(u);else return r.error=!0,!1}s.length=0}return!0}for(let u=0;u<t.length;u++){let l=t[u];if(!(l==="["||l==="]"))if(l===":"){if(i===!0&&(a=!0),!c())break;if(e++,n.push(":"),e>7){r.error=!0;break}u-1>=0&&t[u-1]===":"&&(i=!0);continue}else if(l==="%"){if(!c())break;o=!0}else{s.push(l);continue}}return s.length&&(o?r.zone=s.join(""):a?n.push(s.join("")):n.push(gn(s))),r.address=n.join(""),r}function Mo(t){if(xo(t,":")<2)return{host:t,isIPV6:!1};let e=el(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,escapedHost:n,isIPV6:!0}}}function tl(t,e){let r="",n=!0,s=t.length;for(let o=0;o<s;o++){let i=t[o];i==="0"&&n?(o+1<=s&&t[o+1]===e||o+1===s)&&(r+=i,n=!1):(i===e?n=!0:n=!1,r+=i)}return r}function xo(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}var ko=/^\.\.?\//u,Ao=/^\/\.(?:\/|$)/u,Co=/^\/\.\.(?:\/|$)/u,rl=/^\/?(?:.|\n)*?(?=\/|$)/u;function nl(t){let e=[];for(;t.length;)if(t.match(ko))t=t.replace(ko,"");else if(t.match(Ao))t=t.replace(Ao,"/");else if(t.match(Co))t=t.replace(Co,"/"),e.pop();else if(t==="."||t==="..")t="";else{let r=t.match(rl);if(r){let n=r[0];t=t.slice(n.length),e.push(n)}else throw new Error("Unexpected dot segment condition")}return e.join("")}function sl(t,e){let r=e!==!0?escape:unescape;return t.scheme!==void 0&&(t.scheme=r(t.scheme)),t.userinfo!==void 0&&(t.userinfo=r(t.userinfo)),t.host!==void 0&&(t.host=r(t.host)),t.path!==void 0&&(t.path=r(t.path)),t.query!==void 0&&(t.query=r(t.query)),t.fragment!==void 0&&(t.fragment=r(t.fragment)),t}function ol(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host),n=Do(r);if(n.isIPV4)r=n.host;else{let s=Mo(n.host);s.isIPV6===!0?r=`[${s.escapedHost}]`:r=t.host}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}Go.exports={recomposeAuthority:ol,normalizeComponentEncoding:sl,removeDotSegments:nl,normalizeIPv4:Do,normalizeIPv6:Mo,stringArrayToHexStripped:gn}});var Ho=_((sp,Ko)=>{"use strict";var il=/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu,al=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;function zo(t){return typeof t.secure=="boolean"?t.secure:String(t.scheme).toLowerCase()==="wss"}function Vo(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function Lo(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function ul(t){return t.secure=zo(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function cl(t){if((t.port===(zo(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function ll(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(al);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let s=`${n}:${e.nid||t.nid}`,o=wn[s];t.path=void 0,o&&(t=o.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function fl(t,e){let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),s=`${r}:${e.nid||n}`,o=wn[s];o&&(t=o.serialize(t,e));let i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function dl(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!il.test(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function hl(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var Fo={scheme:"http",domainHost:!0,parse:Vo,serialize:Lo},pl={scheme:"https",domainHost:Fo.domainHost,parse:Vo,serialize:Lo},Xt={scheme:"ws",domainHost:!0,parse:ul,serialize:cl},ml={scheme:"wss",domainHost:Xt.domainHost,parse:Xt.parse,serialize:Xt.serialize},yl={scheme:"urn",parse:ll,serialize:fl,skipNormalize:!0},vl={scheme:"urn:uuid",parse:dl,serialize:hl,skipNormalize:!0},wn={http:Fo,https:pl,ws:Xt,wss:ml,urn:yl,"urn:uuid":vl};Ko.exports=wn});var Bo=_((op,Zt)=>{"use strict";var{normalizeIPv6:_l,normalizeIPv4:gl,removeDotSegments:yt,recomposeAuthority:wl,normalizeComponentEncoding:Yt}=Uo(),$n=Ho();function $l(t,e){return typeof t=="string"?t=ue(ye(t,e),e):typeof t=="object"&&(t=ye(ue(t,e),e)),t}function bl(t,e,r){let n=Object.assign({scheme:"null"},r),s=Jo(ye(t,n),ye(e,n),n,!0);return ue(s,{...n,skipEscape:!0})}function Jo(t,e,r,n){let s={};return n||(t=ye(ue(t,r),r),e=ye(ue(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(s.scheme=e.scheme,s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=yt(e.path||""),s.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=yt(e.path||""),s.query=e.query):(e.path?(e.path.charAt(0)==="/"?s.path=yt(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?s.path="/"+e.path:t.path?s.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:s.path=e.path,s.path=yt(s.path)),s.query=e.query):(s.path=t.path,e.query!==void 0?s.query=e.query:s.query=t.query),s.userinfo=t.userinfo,s.host=t.host,s.port=t.port),s.scheme=t.scheme),s.fragment=e.fragment,s}function El(t,e,r){return typeof t=="string"?(t=unescape(t),t=ue(Yt(ye(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=ue(Yt(t,!0),{...r,skipEscape:!0})),typeof e=="string"?(e=unescape(e),e=ue(Yt(ye(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=ue(Yt(e,!0),{...r,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()}function ue(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),s=[],o=$n[(n.scheme||r.scheme||"").toLowerCase()];o&&o.serialize&&o.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&s.push(r.scheme,":");let i=wl(r);if(i!==void 0&&(n.reference!=="suffix"&&s.push("//"),s.push(i),r.path&&r.path.charAt(0)!=="/"&&s.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!o||!o.absolutePath)&&(a=yt(a)),i===void 0&&(a=a.replace(/^\/\//u,"/%2F")),s.push(a)}return r.query!==void 0&&s.push("?",r.query),r.fragment!==void 0&&s.push("#",r.fragment),s.join("")}var Pl=Array.from({length:127},(t,e)=>/[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(e)));function Sl(t){let e=0;for(let r=0,n=t.length;r<n;++r)if(e=t.charCodeAt(r),e>126||Pl[e])return!0;return!1}var Ol=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function ye(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},s=t.indexOf("%")!==-1,o=!1;r.reference==="suffix"&&(t=(r.scheme?r.scheme+":":"")+"//"+t);let i=t.match(Ol);if(i){if(n.scheme=i[1],n.userinfo=i[3],n.host=i[4],n.port=parseInt(i[5],10),n.path=i[6]||"",n.query=i[7],n.fragment=i[8],isNaN(n.port)&&(n.port=i[5]),n.host){let c=gl(n.host);if(c.isIPV4===!1){let u=_l(c.host);n.host=u.host.toLowerCase(),o=u.isIPV6}else n.host=c.host,o=!0}n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let a=$n[(r.scheme||n.scheme||"").toLowerCase()];if(!r.unicodeSupport&&(!a||!a.unicodeSupport)&&n.host&&(r.domainHost||a&&a.domainHost)&&o===!1&&Sl(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(c){n.error=n.error||"Host's domain name can not be converted to ASCII: "+c}(!a||a&&!a.skipNormalize)&&(s&&n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),s&&n.host!==void 0&&(n.host=unescape(n.host)),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),a&&a.parse&&a.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}var bn={SCHEMES:$n,normalize:$l,resolve:bl,resolveComponents:Jo,equal:El,serialize:ue,parse:ye};Zt.exports=bn;Zt.exports.default=bn;Zt.exports.fastUri=bn});var Qo=_(En=>{"use strict";Object.defineProperty(En,"__esModule",{value:!0});var Wo=Bo();Wo.code='require("ajv/dist/runtime/uri").default';En.default=Wo});var wt=_(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.CodeGen=G.Name=G.nil=G.stringify=G.str=G._=G.KeywordCxt=void 0;var Nl=Jt();Object.defineProperty(G,"KeywordCxt",{enumerable:!0,get:function(){return Nl.KeywordCxt}});var He=N();Object.defineProperty(G,"_",{enumerable:!0,get:function(){return He._}});Object.defineProperty(G,"str",{enumerable:!0,get:function(){return He.str}});Object.defineProperty(G,"stringify",{enumerable:!0,get:function(){return He.stringify}});Object.defineProperty(G,"nil",{enumerable:!0,get:function(){return He.nil}});Object.defineProperty(G,"Name",{enumerable:!0,get:function(){return He.Name}});Object.defineProperty(G,"CodeGen",{enumerable:!0,get:function(){return He.CodeGen}});var jl=hn(),ti=Bt(),Tl=Xr(),vt=Qt(),Il=N(),_t=ht(),er=dt(),Sn=q(),Xo=Io(),ql=Qo(),ri=(t,e)=>new RegExp(t,e);ri.code="new RegExp";var Rl=["removeAdditional","useDefaults","coerceTypes"],kl=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Al={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},Cl={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Yo=200;function Dl(t){var e,r,n,s,o,i,a,c,u,l,f,d,h,p,m,y,v,P,w,A,b,oe,fe,Or,Nr;let rt=t.strict,jr=(e=t.code)===null||e===void 0?void 0:e.optimize,js=jr===!0||jr===void 0?1:jr||0,Ts=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:ri,qa=(s=t.uriResolver)!==null&&s!==void 0?s:ql.default;return{strictSchema:(i=(o=t.strictSchema)!==null&&o!==void 0?o:rt)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:rt)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:rt)!==null&&l!==void 0?l:"log",strictTuples:(d=(f=t.strictTuples)!==null&&f!==void 0?f:rt)!==null&&d!==void 0?d:"log",strictRequired:(p=(h=t.strictRequired)!==null&&h!==void 0?h:rt)!==null&&p!==void 0?p:!1,code:t.code?{...t.code,optimize:js,regExp:Ts}:{optimize:js,regExp:Ts},loopRequired:(m=t.loopRequired)!==null&&m!==void 0?m:Yo,loopEnum:(y=t.loopEnum)!==null&&y!==void 0?y:Yo,meta:(v=t.meta)!==null&&v!==void 0?v:!0,messages:(P=t.messages)!==null&&P!==void 0?P:!0,inlineRefs:(w=t.inlineRefs)!==null&&w!==void 0?w:!0,schemaId:(A=t.schemaId)!==null&&A!==void 0?A:"$id",addUsedSchema:(b=t.addUsedSchema)!==null&&b!==void 0?b:!0,validateSchema:(oe=t.validateSchema)!==null&&oe!==void 0?oe:!0,validateFormats:(fe=t.validateFormats)!==null&&fe!==void 0?fe:!0,unicodeRegExp:(Or=t.unicodeRegExp)!==null&&Or!==void 0?Or:!0,int32range:(Nr=t.int32range)!==null&&Nr!==void 0?Nr:!0,uriResolver:qa}}var gt=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...Dl(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new Il.ValueScope({scope:{},prefixes:kl,es5:r,lines:n}),this.logger=Vl(e.logger);let s=e.validateFormats;e.validateFormats=!1,this.RULES=(0,Tl.getRules)(),Zo.call(this,Al,e,"NOT SUPPORTED"),Zo.call(this,Cl,e,"DEPRECATED","warn"),this._metaOpts=Ul.call(this),e.formats&&xl.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&Gl.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),Ml.call(this),e.validateFormats=s}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,s=Xo;n==="id"&&(s={...Xo},s.id=s.$id,delete s.$id),r&&e&&this.addMetaSchema(s,s[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let s=n(r);return"$async"in n||(this.errors=n.errors),s}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return s.call(this,e,r);async function s(l,f){await o.call(this,l.$schema);let d=this._addSchema(l,f);return d.validate||i.call(this,d)}async function o(l){l&&!this.getSchema(l)&&await s.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(f){if(!(f instanceof ti.default))throw f;return a.call(this,f),await c.call(this,f.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:f}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${f} cannot be resolved`)}async function c(l){let f=await u.call(this,l);this.refs[l]||await o.call(this,f.$schema),this.refs[l]||this.addSchema(f,l,r)}async function u(l){let f=this._loading[l];if(f)return f;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(e,r,n,s=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,s);return this}let o;if(typeof e=="object"){let{schemaId:i}=this.opts;if(o=e[i],o!==void 0&&typeof o!="string")throw new Error(`schema ${i} must be string`)}return r=(0,_t.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,s,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let s=this.validate(n,e);if(!s&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return s}getSchema(e){let r;for(;typeof(r=ei.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,s=new vt.SchemaEnv({schema:{},schemaId:n});if(r=vt.resolveSchema.call(this,s,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=ei.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,_t.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(Fl.call(this,n,r),!r)return(0,Sn.eachItem)(n,o=>Pn.call(this,o)),this;Hl.call(this,r);let s={...r,type:(0,er.getJSONTypes)(r.type),schemaType:(0,er.getJSONTypes)(r.schemaType)};return(0,Sn.eachItem)(n,s.type.length===0?o=>Pn.call(this,o,s):o=>s.type.forEach(i=>Pn.call(this,o,s,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let s=n.rules.findIndex(o=>o.keyword===e);s>=0&&n.rules.splice(s,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(s=>`${n}${s.instancePath} ${s.message}`).reduce((s,o)=>s+r+o)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let s of r){let o=s.split("/").slice(1),i=e;for(let a of o)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=ni(l))}}return e}_removeAllSchemas(e,r){for(let n in e){let s=e[n];(!r||r.test(n))&&(typeof s=="string"?delete e[n]:s&&!s.meta&&(this._cache.delete(s.schema),delete e[n]))}}_addSchema(e,r,n,s=this.opts.validateSchema,o=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,_t.normalizeId)(i||n);let u=_t.getSchemaRefs.call(this,e,n);return c=new vt.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),s&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):vt.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{vt.compileSchema.call(this,e)}finally{this.opts=r}}};gt.ValidationError=jl.default;gt.MissingRefError=ti.default;G.default=gt;function Zo(t,e,r,n="error"){for(let s in t){let o=s;o in e&&this.logger[n](`${r}: option ${s}. ${t[o]}`)}}function ei(t){return t=(0,_t.normalizeId)(t),this.schemas[t]||this.refs[t]}function Ml(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function xl(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function Gl(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function Ul(){let t={...this.opts};for(let e of Rl)delete t[e];return t}var zl={log(){},warn(){},error(){}};function Vl(t){if(t===!1)return zl;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var Ll=/^[a-z_$][a-z0-9_$:-]*$/i;function Fl(t,e){let{RULES:r}=this;if((0,Sn.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!Ll.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function Pn(t,e,r){var n;let s=e?.post;if(r&&s)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,i=s?o.post:o.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},o.rules.push(i)),o.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,er.getJSONTypes)(e.type),schemaType:(0,er.getJSONTypes)(e.schemaType)}};e.before?Kl.call(this,i,a,e.before):i.rules.push(a),o.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function Kl(t,e,r){let n=t.rules.findIndex(s=>s.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function Hl(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=ni(e)),t.validateSchema=this.compile(e,!0))}var Jl={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ni(t){return{anyOf:[t,Jl]}}});var ai=_(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.callRef=Re.getValidate=void 0;var Bl=Bt(),si=Y(),Q=N(),Je=pe(),oi=Qt(),tr=q(),Wl={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:s,schemaEnv:o,validateName:i,opts:a,self:c}=n,{root:u}=o;if((r==="#"||r==="#/")&&s===u.baseId)return f();let l=oi.resolveRef.call(c,u,s,r);if(l===void 0)throw new Bl.default(n.opts.uriResolver,s,r);if(l instanceof oi.SchemaEnv)return d(l);return h(l);function f(){if(o===u)return rr(t,i,o,o.$async);let p=e.scopeValue("root",{ref:u});return rr(t,(0,Q._)`${p}.validate`,u,u.$async)}function d(p){let m=ii(t,p);rr(t,m,p,p.$async)}function h(p){let m=e.scopeValue("schema",a.code.source===!0?{ref:p,code:(0,Q.stringify)(p)}:{ref:p}),y=e.name("valid"),v=t.subschema({schema:p,dataTypes:[],schemaPath:Q.nil,topSchemaRef:m,errSchemaPath:r},y);t.mergeEvaluated(v),t.ok(y)}}};function ii(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Q._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Re.getValidate=ii;function rr(t,e,r,n){let{gen:s,it:o}=t,{allErrors:i,schemaEnv:a,opts:c}=o,u=c.passContext?Je.default.this:Q.nil;n?l():f();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let p=s.let("valid");s.try(()=>{s.code((0,Q._)`await ${(0,si.callValidateCode)(t,e,u)}`),h(e),i||s.assign(p,!0)},m=>{s.if((0,Q._)`!(${m} instanceof ${o.ValidationError})`,()=>s.throw(m)),d(m),i||s.assign(p,!1)}),t.ok(p)}function f(){t.result((0,si.callValidateCode)(t,e,u),()=>h(e),()=>d(e))}function d(p){let m=(0,Q._)`${p}.errors`;s.assign(Je.default.vErrors,(0,Q._)`${Je.default.vErrors} === null ? ${m} : ${Je.default.vErrors}.concat(${m})`),s.assign(Je.default.errors,(0,Q._)`${Je.default.vErrors}.length`)}function h(p){var m;if(!o.opts.unevaluated)return;let y=(m=r?.validate)===null||m===void 0?void 0:m.evaluated;if(o.props!==!0)if(y&&!y.dynamicProps)y.props!==void 0&&(o.props=tr.mergeEvaluated.props(s,y.props,o.props));else{let v=s.var("props",(0,Q._)`${p}.evaluated.props`);o.props=tr.mergeEvaluated.props(s,v,o.props,Q.Name)}if(o.items!==!0)if(y&&!y.dynamicItems)y.items!==void 0&&(o.items=tr.mergeEvaluated.items(s,y.items,o.items));else{let v=s.var("items",(0,Q._)`${p}.evaluated.items`);o.items=tr.mergeEvaluated.items(s,v,o.items,Q.Name)}}}Re.callRef=rr;Re.default=Wl});var ui=_(On=>{"use strict";Object.defineProperty(On,"__esModule",{value:!0});var Ql=ai(),Xl=["$schema","id","$defs",{keyword:"$comment"},"definitions",Ql.default];On.default=Xl});var ci=_(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});var Nn=wt(),Yl=N(),Ee=Yl.operators,jn={maximum:{exclusive:"exclusiveMaximum",ops:[{okStr:"<=",ok:Ee.LTE,fail:Ee.GT},{okStr:"<",ok:Ee.LT,fail:Ee.GTE}]},minimum:{exclusive:"exclusiveMinimum",ops:[{okStr:">=",ok:Ee.GTE,fail:Ee.LT},{okStr:">",ok:Ee.GT,fail:Ee.LTE}]}},Zl={message:t=>Nn.str`must be ${Tn(t).okStr} ${t.schemaCode}`,params:t=>Nn._`{comparison: ${Tn(t).okStr}, limit: ${t.schemaCode}}`},ef={keyword:Object.keys(jn),type:"number",schemaType:"number",$data:!0,error:Zl,code(t){let{data:e,schemaCode:r}=t;t.fail$data(Nn._`${e} ${Tn(t).fail} ${r} || isNaN(${e})`)}};function Tn(t){var e;let r=t.keyword,n=!((e=t.parentSchema)===null||e===void 0)&&e[jn[r].exclusive]?1:0;return jn[r].ops[n]}In.default=ef});var fi=_(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});var li={exclusiveMaximum:"maximum",exclusiveMinimum:"minimum"},tf={keyword:Object.keys(li),type:"number",schemaType:"boolean",code({keyword:t,parentSchema:e}){let r=li[t];if(e[r]===void 0)throw new Error(`${t} can only be used with ${r}`)}};qn.default=tf});var di=_(Rn=>{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});var $t=N(),rf={message:({schemaCode:t})=>(0,$t.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,$t._)`{multipleOf: ${t}}`},nf={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:rf,code(t){let{gen:e,data:r,schemaCode:n,it:s}=t,o=s.opts.multipleOfPrecision,i=e.let("res"),a=o?(0,$t._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${o}`:(0,$t._)`${i} !== parseInt(${i})`;t.fail$data((0,$t._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Rn.default=nf});var pi=_(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});function hi(t){let e=t.length,r=0,n=0,s;for(;n<e;)r++,s=t.charCodeAt(n++),s>=55296&&s<=56319&&n<e&&(s=t.charCodeAt(n),(s&64512)===56320&&n++);return r}kn.default=hi;hi.code='require("ajv/dist/runtime/ucs2length").default'});var mi=_(An=>{"use strict";Object.defineProperty(An,"__esModule",{value:!0});var ke=N(),sf=q(),of=pi(),af={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,ke.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,ke._)`{limit: ${t}}`},uf={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:af,code(t){let{keyword:e,data:r,schemaCode:n,it:s}=t,o=e==="maxLength"?ke.operators.GT:ke.operators.LT,i=s.opts.unicode===!1?(0,ke._)`${r}.length`:(0,ke._)`${(0,sf.useFunc)(t.gen,of.default)}(${r})`;t.fail$data((0,ke._)`${i} ${o} ${n}`)}};An.default=uf});var yi=_(Cn=>{"use strict";Object.defineProperty(Cn,"__esModule",{value:!0});var cf=Y(),nr=N(),lf={message:({schemaCode:t})=>(0,nr.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,nr._)`{pattern: ${t}}`},ff={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:lf,code(t){let{data:e,$data:r,schema:n,schemaCode:s,it:o}=t,i=o.opts.unicodeRegExp?"u":"",a=r?(0,nr._)`(new RegExp(${s}, ${i}))`:(0,cf.usePattern)(t,n);t.fail$data((0,nr._)`!${a}.test(${e})`)}};Cn.default=ff});var vi=_(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});var bt=N(),df={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,bt.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,bt._)`{limit: ${t}}`},hf={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:df,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxProperties"?bt.operators.GT:bt.operators.LT;t.fail$data((0,bt._)`Object.keys(${r}).length ${s} ${n}`)}};Dn.default=hf});var _i=_(Mn=>{"use strict";Object.defineProperty(Mn,"__esModule",{value:!0});var Et=Y(),Pt=N(),pf=q(),mf={message:({params:{missingProperty:t}})=>(0,Pt.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Pt._)`{missingProperty: ${t}}`},yf={keyword:"required",type:"object",schemaType:"array",$data:!0,error:mf,code(t){let{gen:e,schema:r,schemaCode:n,data:s,$data:o,it:i}=t,{opts:a}=i;if(!o&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let h=t.parentSchema.properties,{definedProperties:p}=t.it;for(let m of r)if(h?.[m]===void 0&&!p.has(m)){let y=i.schemaEnv.baseId+i.errSchemaPath,v=`required property "${m}" is not defined at "${y}" (strictRequired)`;(0,pf.checkStrictMode)(i,v,i.opts.strictRequired)}}function u(){if(c||o)t.block$data(Pt.nil,f);else for(let h of r)(0,Et.checkReportMissingProp)(t,h)}function l(){let h=e.let("missing");if(c||o){let p=e.let("valid",!0);t.block$data(p,()=>d(h,p)),t.ok(p)}else e.if((0,Et.checkMissingProp)(t,r,h)),(0,Et.reportMissingProp)(t,h),e.else()}function f(){e.forOf("prop",n,h=>{t.setParams({missingProperty:h}),e.if((0,Et.noPropertyInData)(e,s,h,a.ownProperties),()=>t.error())})}function d(h,p){t.setParams({missingProperty:h}),e.forOf(h,n,()=>{e.assign(p,(0,Et.propertyInData)(e,s,h,a.ownProperties)),e.if((0,Pt.not)(p),()=>{t.error(),e.break()})},Pt.nil)}}};Mn.default=yf});var gi=_(xn=>{"use strict";Object.defineProperty(xn,"__esModule",{value:!0});var St=N(),vf={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,St.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,St._)`{limit: ${t}}`},_f={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:vf,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxItems"?St.operators.GT:St.operators.LT;t.fail$data((0,St._)`${r}.length ${s} ${n}`)}};xn.default=_f});var sr=_(Gn=>{"use strict";Object.defineProperty(Gn,"__esModule",{value:!0});var wi=on();wi.code='require("ajv/dist/runtime/equal").default';Gn.default=wi});var $i=_(zn=>{"use strict";Object.defineProperty(zn,"__esModule",{value:!0});var Un=dt(),U=N(),gf=q(),wf=sr(),$f={message:({params:{i:t,j:e}})=>(0,U.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,U._)`{i: ${t}, j: ${e}}`},bf={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:$f,code(t){let{gen:e,data:r,$data:n,schema:s,parentSchema:o,schemaCode:i,it:a}=t;if(!n&&!s)return;let c=e.let("valid"),u=o.items?(0,Un.getSchemaTypes)(o.items):[];t.block$data(c,l,(0,U._)`${i} === false`),t.ok(c);function l(){let p=e.let("i",(0,U._)`${r}.length`),m=e.let("j");t.setParams({i:p,j:m}),e.assign(c,!0),e.if((0,U._)`${p} > 1`,()=>(f()?d:h)(p,m))}function f(){return u.length>0&&!u.some(p=>p==="object"||p==="array")}function d(p,m){let y=e.name("item"),v=(0,Un.checkDataTypes)(u,y,a.opts.strictNumbers,Un.DataType.Wrong),P=e.const("indices",(0,U._)`{}`);e.for((0,U._)`;${p}--;`,()=>{e.let(y,(0,U._)`${r}[${p}]`),e.if(v,(0,U._)`continue`),u.length>1&&e.if((0,U._)`typeof ${y} == "string"`,(0,U._)`${y} += "_"`),e.if((0,U._)`typeof ${P}[${y}] == "number"`,()=>{e.assign(m,(0,U._)`${P}[${y}]`),t.error(),e.assign(c,!1).break()}).code((0,U._)`${P}[${y}] = ${p}`)})}function h(p,m){let y=(0,gf.useFunc)(e,wf.default),v=e.name("outer");e.label(v).for((0,U._)`;${p}--;`,()=>e.for((0,U._)`${m} = ${p}; ${m}--;`,()=>e.if((0,U._)`${y}(${r}[${p}], ${r}[${m}])`,()=>{t.error(),e.assign(c,!1).break(v)})))}}};zn.default=bf});var bi=_(Ln=>{"use strict";Object.defineProperty(Ln,"__esModule",{value:!0});var Vn=N(),Ef=q(),Pf=sr(),Sf={message:"must be equal to constant",params:({schemaCode:t})=>(0,Vn._)`{allowedValue: ${t}}`},Of={keyword:"const",$data:!0,error:Sf,code(t){let{gen:e,data:r,$data:n,schemaCode:s,schema:o}=t;n||o&&typeof o=="object"?t.fail$data((0,Vn._)`!${(0,Ef.useFunc)(e,Pf.default)}(${r}, ${s})`):t.fail((0,Vn._)`${o} !== ${r}`)}};Ln.default=Of});var Ei=_(Fn=>{"use strict";Object.defineProperty(Fn,"__esModule",{value:!0});var Ot=N(),Nf=q(),jf=sr(),Tf={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Ot._)`{allowedValues: ${t}}`},If={keyword:"enum",schemaType:"array",$data:!0,error:Tf,code(t){let{gen:e,data:r,$data:n,schema:s,schemaCode:o,it:i}=t;if(!n&&s.length===0)throw new Error("enum must have non-empty array");let a=s.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,Nf.useFunc)(e,jf.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,f);else{if(!Array.isArray(s))throw new Error("ajv implementation error");let h=e.const("vSchema",o);l=(0,Ot.or)(...s.map((p,m)=>d(h,m)))}t.pass(l);function f(){e.assign(l,!1),e.forOf("v",o,h=>e.if((0,Ot._)`${u()}(${r}, ${h})`,()=>e.assign(l,!0).break()))}function d(h,p){let m=s[p];return typeof m=="object"&&m!==null?(0,Ot._)`${u()}(${r}, ${h}[${p}])`:(0,Ot._)`${r} === ${m}`}}};Fn.default=If});var Pi=_(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});var qf=ci(),Rf=fi(),kf=di(),Af=mi(),Cf=yi(),Df=vi(),Mf=_i(),xf=gi(),Gf=$i(),Uf=bi(),zf=Ei(),Vf=[qf.default,Rf.default,kf.default,Af.default,Cf.default,Df.default,Mf.default,xf.default,Gf.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Uf.default,zf.default];Kn.default=Vf});var Jn=_(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.validateAdditionalItems=void 0;var Ae=N(),Hn=q(),Lf={message:({params:{len:t}})=>(0,Ae.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Ae._)`{limit: ${t}}`},Ff={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:Lf,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Hn.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Si(t,n)}};function Si(t,e){let{gen:r,schema:n,data:s,keyword:o,it:i}=t;i.items=!0;let a=r.const("len",(0,Ae._)`${s}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,Ae._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Hn.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,Ae._)`${a} <= ${e.length}`);r.if((0,Ae.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:o,dataProp:l,dataPropType:Hn.Type.Num},u),i.allErrors||r.if((0,Ae.not)(u),()=>r.break())})}}Nt.validateAdditionalItems=Si;Nt.default=Ff});var Bn=_(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.validateTuple=void 0;var Oi=N(),or=q(),Kf=Y(),Hf={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return Ni(t,"additionalItems",e);r.items=!0,!(0,or.alwaysValidSchema)(r,e)&&t.ok((0,Kf.validateArray)(t))}};function Ni(t,e,r=t.schema){let{gen:n,parentSchema:s,data:o,keyword:i,it:a}=t;l(s),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=or.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,Oi._)`${o}.length`);r.forEach((f,d)=>{(0,or.alwaysValidSchema)(a,f)||(n.if((0,Oi._)`${u} > ${d}`,()=>t.subschema({keyword:i,schemaProp:d,dataProp:d},c)),t.ok(c))});function l(f){let{opts:d,errSchemaPath:h}=a,p=r.length,m=p===f.minItems&&(p===f.maxItems||f[e]===!1);if(d.strictTuples&&!m){let y=`"${i}" is ${p}-tuple, but minItems or maxItems/${e} are not specified or different at path "${h}"`;(0,or.checkStrictMode)(a,y,d.strictTuples)}}}jt.validateTuple=Ni;jt.default=Hf});var ji=_(Wn=>{"use strict";Object.defineProperty(Wn,"__esModule",{value:!0});var Jf=Bn(),Bf={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,Jf.validateTuple)(t,"items")};Wn.default=Bf});var Ii=_(Qn=>{"use strict";Object.defineProperty(Qn,"__esModule",{value:!0});var Ti=N(),Wf=q(),Qf=Y(),Xf=Jn(),Yf={message:({params:{len:t}})=>(0,Ti.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Ti._)`{limit: ${t}}`},Zf={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Yf,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:s}=r;n.items=!0,!(0,Wf.alwaysValidSchema)(n,e)&&(s?(0,Xf.validateAdditionalItems)(t,s):t.ok((0,Qf.validateArray)(t)))}};Qn.default=Zf});var qi=_(Xn=>{"use strict";Object.defineProperty(Xn,"__esModule",{value:!0});var ee=N(),ir=q(),ed={message:({params:{min:t,max:e}})=>e===void 0?(0,ee.str)`must contain at least ${t} valid item(s)`:(0,ee.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,ee._)`{minContains: ${t}}`:(0,ee._)`{minContains: ${t}, maxContains: ${e}}`},td={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:ed,code(t){let{gen:e,schema:r,parentSchema:n,data:s,it:o}=t,i,a,{minContains:c,maxContains:u}=n;o.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=e.const("len",(0,ee._)`${s}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,ir.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,ir.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,ir.alwaysValidSchema)(o,r)){let m=(0,ee._)`${l} >= ${i}`;a!==void 0&&(m=(0,ee._)`${m} && ${l} <= ${a}`),t.pass(m);return}o.items=!0;let f=e.name("valid");a===void 0&&i===1?h(f,()=>e.if(f,()=>e.break())):i===0?(e.let(f,!0),a!==void 0&&e.if((0,ee._)`${s}.length > 0`,d)):(e.let(f,!1),d()),t.result(f,()=>t.reset());function d(){let m=e.name("_valid"),y=e.let("count",0);h(m,()=>e.if(m,()=>p(y)))}function h(m,y){e.forRange("i",0,l,v=>{t.subschema({keyword:"contains",dataProp:v,dataPropType:ir.Type.Num,compositeRule:!0},m),y()})}function p(m){e.code((0,ee._)`${m}++`),a===void 0?e.if((0,ee._)`${m} >= ${i}`,()=>e.assign(f,!0).break()):(e.if((0,ee._)`${m} > ${a}`,()=>e.assign(f,!1).break()),i===1?e.assign(f,!0):e.if((0,ee._)`${m} >= ${i}`,()=>e.assign(f,!0)))}}};Xn.default=td});var Ai=_(ce=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});ce.validateSchemaDeps=ce.validatePropertyDeps=ce.error=void 0;var Yn=N(),rd=q(),Tt=Y();ce.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,Yn.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,Yn._)`{property: ${t},
|
|
6
|
+
missingProperty: ${n},
|
|
7
|
+
depsCount: ${e},
|
|
8
|
+
deps: ${r}}`};var nd={keyword:"dependencies",type:"object",schemaType:"object",error:ce.error,code(t){let[e,r]=sd(t);Ri(t,e),ki(t,r)}};function sd({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let s=Array.isArray(t[n])?e:r;s[n]=t[n]}return[e,r]}function Ri(t,e=t.schema){let{gen:r,data:n,it:s}=t;if(Object.keys(e).length===0)return;let o=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,Tt.propertyInData)(r,n,i,s.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),s.allErrors?r.if(c,()=>{for(let u of a)(0,Tt.checkReportMissingProp)(t,u)}):(r.if((0,Yn._)`${c} && (${(0,Tt.checkMissingProp)(t,a,o)})`),(0,Tt.reportMissingProp)(t,o),r.else())}}ce.validatePropertyDeps=Ri;function ki(t,e=t.schema){let{gen:r,data:n,keyword:s,it:o}=t,i=r.name("valid");for(let a in e)(0,rd.alwaysValidSchema)(o,e[a])||(r.if((0,Tt.propertyInData)(r,n,a,o.opts.ownProperties),()=>{let c=t.subschema({keyword:s,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}ce.validateSchemaDeps=ki;ce.default=nd});var Di=_(Zn=>{"use strict";Object.defineProperty(Zn,"__esModule",{value:!0});var Ci=N(),od=q(),id={message:"property name must be valid",params:({params:t})=>(0,Ci._)`{propertyName: ${t.propertyName}}`},ad={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:id,code(t){let{gen:e,schema:r,data:n,it:s}=t;if((0,od.alwaysValidSchema)(s,r))return;let o=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},o),e.if((0,Ci.not)(o),()=>{t.error(!0),s.allErrors||e.break()})}),t.ok(o)}};Zn.default=ad});var ts=_(es=>{"use strict";Object.defineProperty(es,"__esModule",{value:!0});var ar=Y(),se=N(),ud=pe(),ur=q(),cd={message:"must NOT have additional properties",params:({params:t})=>(0,se._)`{additionalProperty: ${t.additionalProperty}}`},ld={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:cd,code(t){let{gen:e,schema:r,parentSchema:n,data:s,errsCount:o,it:i}=t;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,ur.alwaysValidSchema)(i,r))return;let u=(0,ar.allSchemaProperties)(n.properties),l=(0,ar.allSchemaProperties)(n.patternProperties);f(),t.ok((0,se._)`${o} === ${ud.default.errors}`);function f(){e.forIn("key",s,y=>{!u.length&&!l.length?p(y):e.if(d(y),()=>p(y))})}function d(y){let v;if(u.length>8){let P=(0,ur.schemaRefOrVal)(i,n.properties,"properties");v=(0,ar.isOwnProperty)(e,P,y)}else u.length?v=(0,se.or)(...u.map(P=>(0,se._)`${y} === ${P}`)):v=se.nil;return l.length&&(v=(0,se.or)(v,...l.map(P=>(0,se._)`${(0,ar.usePattern)(t,P)}.test(${y})`))),(0,se.not)(v)}function h(y){e.code((0,se._)`delete ${s}[${y}]`)}function p(y){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){h(y);return}if(r===!1){t.setParams({additionalProperty:y}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,ur.alwaysValidSchema)(i,r)){let v=e.name("valid");c.removeAdditional==="failing"?(m(y,v,!1),e.if((0,se.not)(v),()=>{t.reset(),h(y)})):(m(y,v),a||e.if((0,se.not)(v),()=>e.break()))}}function m(y,v,P){let w={keyword:"additionalProperties",dataProp:y,dataPropType:ur.Type.Str};P===!1&&Object.assign(w,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(w,v)}}};es.default=ld});var Gi=_(ns=>{"use strict";Object.defineProperty(ns,"__esModule",{value:!0});var fd=Jt(),Mi=Y(),rs=q(),xi=ts(),dd={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:s,it:o}=t;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&xi.default.code(new fd.KeywordCxt(o,xi.default,"additionalProperties"));let i=(0,Mi.allSchemaProperties)(r);for(let f of i)o.definedProperties.add(f);o.opts.unevaluated&&i.length&&o.props!==!0&&(o.props=rs.mergeEvaluated.props(e,(0,rs.toHash)(i),o.props));let a=i.filter(f=>!(0,rs.alwaysValidSchema)(o,r[f]));if(a.length===0)return;let c=e.name("valid");for(let f of a)u(f)?l(f):(e.if((0,Mi.propertyInData)(e,s,f,o.opts.ownProperties)),l(f),o.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(f),t.ok(c);function u(f){return o.opts.useDefaults&&!o.compositeRule&&r[f].default!==void 0}function l(f){t.subschema({keyword:"properties",schemaProp:f,dataProp:f},c)}}};ns.default=dd});var Li=_(ss=>{"use strict";Object.defineProperty(ss,"__esModule",{value:!0});var Ui=Y(),cr=N(),zi=q(),Vi=q(),hd={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:s,it:o}=t,{opts:i}=o,a=(0,Ui.allSchemaProperties)(r),c=a.filter(m=>(0,zi.alwaysValidSchema)(o,r[m]));if(a.length===0||c.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&s.properties,l=e.name("valid");o.props!==!0&&!(o.props instanceof cr.Name)&&(o.props=(0,Vi.evaluatedPropsToName)(e,o.props));let{props:f}=o;d();function d(){for(let m of a)u&&h(m),o.allErrors?p(m):(e.var(l,!0),p(m),e.if(l))}function h(m){for(let y in u)new RegExp(m).test(y)&&(0,zi.checkStrictMode)(o,`property ${y} matches pattern ${m} (use allowMatchingProperties)`)}function p(m){e.forIn("key",n,y=>{e.if((0,cr._)`${(0,Ui.usePattern)(t,m)}.test(${y})`,()=>{let v=c.includes(m);v||t.subschema({keyword:"patternProperties",schemaProp:m,dataProp:y,dataPropType:Vi.Type.Str},l),o.opts.unevaluated&&f!==!0?e.assign((0,cr._)`${f}[${y}]`,!0):!v&&!o.allErrors&&e.if((0,cr.not)(l),()=>e.break())})})}}};ss.default=hd});var Fi=_(os=>{"use strict";Object.defineProperty(os,"__esModule",{value:!0});var pd=q(),md={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,pd.alwaysValidSchema)(n,r)){t.fail();return}let s=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),t.failResult(s,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};os.default=md});var Ki=_(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});var yd=Y(),vd={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:yd.validateUnion,error:{message:"must match a schema in anyOf"}};is.default=vd});var Hi=_(as=>{"use strict";Object.defineProperty(as,"__esModule",{value:!0});var lr=N(),_d=q(),gd={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,lr._)`{passingSchemas: ${t.passing}}`},wd={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:gd,code(t){let{gen:e,schema:r,parentSchema:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;let o=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){o.forEach((l,f)=>{let d;(0,_d.alwaysValidSchema)(s,l)?e.var(c,!0):d=t.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&e.if((0,lr._)`${c} && ${i}`).assign(i,!1).assign(a,(0,lr._)`[${a}, ${f}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,f),d&&t.mergeEvaluated(d,lr.Name)})})}}};as.default=wd});var Ji=_(us=>{"use strict";Object.defineProperty(us,"__esModule",{value:!0});var $d=q(),bd={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let s=e.name("valid");r.forEach((o,i)=>{if((0,$d.alwaysValidSchema)(n,o))return;let a=t.subschema({keyword:"allOf",schemaProp:i},s);t.ok(s),t.mergeEvaluated(a)})}};us.default=bd});var Qi=_(cs=>{"use strict";Object.defineProperty(cs,"__esModule",{value:!0});var fr=N(),Wi=q(),Ed={message:({params:t})=>(0,fr.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,fr._)`{failingKeyword: ${t.ifClause}}`},Pd={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Ed,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,Wi.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=Bi(n,"then"),o=Bi(n,"else");if(!s&&!o)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),s&&o){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else s?e.if(a,u("then")):e.if((0,fr.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,f){return()=>{let d=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(d,i),f?e.assign(f,(0,fr._)`${l}`):t.setParams({ifClause:l})}}}};function Bi(t,e){let r=t.schema[e];return r!==void 0&&!(0,Wi.alwaysValidSchema)(t,r)}cs.default=Pd});var Xi=_(ls=>{"use strict";Object.defineProperty(ls,"__esModule",{value:!0});var Sd=q(),Od={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,Sd.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};ls.default=Od});var Yi=_(fs=>{"use strict";Object.defineProperty(fs,"__esModule",{value:!0});var Nd=Jn(),jd=ji(),Td=Bn(),Id=Ii(),qd=qi(),Rd=Ai(),kd=Di(),Ad=ts(),Cd=Gi(),Dd=Li(),Md=Fi(),xd=Ki(),Gd=Hi(),Ud=Ji(),zd=Qi(),Vd=Xi();function Ld(t=!1){let e=[Md.default,xd.default,Gd.default,Ud.default,zd.default,Vd.default,kd.default,Ad.default,Rd.default,Cd.default,Dd.default];return t?e.push(jd.default,Id.default):e.push(Nd.default,Td.default),e.push(qd.default),e}fs.default=Ld});var Zi=_(ds=>{"use strict";Object.defineProperty(ds,"__esModule",{value:!0});var M=N(),Fd={message:({schemaCode:t})=>(0,M.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,M._)`{format: ${t}}`},Kd={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:Fd,code(t,e){let{gen:r,data:n,$data:s,schema:o,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:f}=a;if(!c.validateFormats)return;s?d():h();function d(){let p=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),m=r.const("fDef",(0,M._)`${p}[${i}]`),y=r.let("fType"),v=r.let("format");r.if((0,M._)`typeof ${m} == "object" && !(${m} instanceof RegExp)`,()=>r.assign(y,(0,M._)`${m}.type || "string"`).assign(v,(0,M._)`${m}.validate`),()=>r.assign(y,(0,M._)`"string"`).assign(v,m)),t.fail$data((0,M.or)(P(),w()));function P(){return c.strictSchema===!1?M.nil:(0,M._)`${i} && !${v}`}function w(){let A=l.$async?(0,M._)`(${m}.async ? await ${v}(${n}) : ${v}(${n}))`:(0,M._)`${v}(${n})`,b=(0,M._)`(typeof ${v} == "function" ? ${A} : ${v}.test(${n}))`;return(0,M._)`${v} && ${v} !== true && ${y} === ${e} && !${b}`}}function h(){let p=f.formats[o];if(!p){P();return}if(p===!0)return;let[m,y,v]=w(p);m===e&&t.pass(A());function P(){if(c.strictSchema===!1){f.logger.warn(b());return}throw new Error(b());function b(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function w(b){let oe=b instanceof RegExp?(0,M.regexpCode)(b):c.code.formats?(0,M._)`${c.code.formats}${(0,M.getProperty)(o)}`:void 0,fe=r.scopeValue("formats",{key:o,ref:b,code:oe});return typeof b=="object"&&!(b instanceof RegExp)?[b.type||"string",b.validate,(0,M._)`${fe}.validate`]:["string",b,fe]}function A(){if(typeof p=="object"&&!(p instanceof RegExp)&&p.async){if(!l.$async)throw new Error("async format in sync schema");return(0,M._)`await ${v}(${n})`}return typeof y=="function"?(0,M._)`${v}(${n})`:(0,M._)`${v}.test(${n})`}}}};ds.default=Kd});var ea=_(hs=>{"use strict";Object.defineProperty(hs,"__esModule",{value:!0});var Hd=Zi(),Jd=[Hd.default];hs.default=Jd});var ta=_(ps=>{"use strict";Object.defineProperty(ps,"__esModule",{value:!0});var Bd=ui(),Wd=Pi(),Qd=Yi(),Xd=ea(),Yd=["title","description","default"],Zd=[Bd.default,Wd.default,Qd.default(),Xd.default,Yd];ps.default=Zd});var na=_(dr=>{"use strict";Object.defineProperty(dr,"__esModule",{value:!0});dr.DiscrError=void 0;var ra;(function(t){t.Tag="tag",t.Mapping="mapping"})(ra||(dr.DiscrError=ra={}))});var oa=_(ys=>{"use strict";Object.defineProperty(ys,"__esModule",{value:!0});var Be=N(),ms=na(),sa=Qt(),eh=Bt(),th=q(),rh={message:({params:{discrError:t,tagName:e}})=>t===ms.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Be._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},nh={keyword:"discriminator",type:"object",schemaType:"object",error:rh,code(t){let{gen:e,data:r,schema:n,parentSchema:s,it:o}=t,{oneOf:i}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,Be._)`${r}${(0,Be.getProperty)(a)}`);e.if((0,Be._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:ms.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let h=d();e.if(!1);for(let p in h)e.elseIf((0,Be._)`${u} === ${p}`),e.assign(c,f(h[p]));e.else(),t.error(!1,{discrError:ms.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function f(h){let p=e.name("valid"),m=t.subschema({keyword:"oneOf",schemaProp:h},p);return t.mergeEvaluated(m,Be.Name),p}function d(){var h;let p={},m=v(s),y=!0;for(let A=0;A<i.length;A++){let b=i[A];if(b?.$ref&&!(0,th.schemaHasRulesButRef)(b,o.self.RULES)){let fe=b.$ref;if(b=sa.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,fe),b instanceof sa.SchemaEnv&&(b=b.schema),b===void 0)throw new eh.default(o.opts.uriResolver,o.baseId,fe)}let oe=(h=b?.properties)===null||h===void 0?void 0:h[a];if(typeof oe!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);y=y&&(m||v(b)),P(oe,A)}if(!y)throw new Error(`discriminator: "${a}" must be required`);return p;function v({required:A}){return Array.isArray(A)&&A.includes(a)}function P(A,b){if(A.const)w(A.const,b);else if(A.enum)for(let oe of A.enum)w(oe,b);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function w(A,b){if(typeof A!="string"||A in p)throw new Error(`discriminator: "${a}" values must be unique strings`);p[A]=b}}}};ys.default=nh});var ia=_((Hp,sh)=>{sh.exports={id:"http://json-schema.org/draft-04/schema#",$schema:"http://json-schema.org/draft-04/schema#",description:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},positiveInteger:{type:"integer",minimum:0},positiveIntegerDefault0:{allOf:[{$ref:"#/definitions/positiveInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},minItems:1,uniqueItems:!0}},type:"object",properties:{id:{type:"string",format:"uri"},$schema:{type:"string",format:"uri"},title:{type:"string"},description:{type:"string"},default:{},multipleOf:{type:"number",minimum:0,exclusiveMinimum:!0},maximum:{type:"number"},exclusiveMaximum:{type:"boolean",default:!1},minimum:{type:"number"},exclusiveMinimum:{type:"boolean",default:!1},maxLength:{$ref:"#/definitions/positiveInteger"},minLength:{$ref:"#/definitions/positiveIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{anyOf:[{type:"boolean"},{$ref:"#"}],default:{}},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:{}},maxItems:{$ref:"#/definitions/positiveInteger"},minItems:{$ref:"#/definitions/positiveIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxProperties:{$ref:"#/definitions/positiveInteger"},minProperties:{$ref:"#/definitions/positiveIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{anyOf:[{type:"boolean"},{$ref:"#"}],default:{}},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},enum:{type:"array",minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},dependencies:{exclusiveMaximum:["maximum"],exclusiveMinimum:["minimum"]},default:{}}});var ca=_((x,ua)=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.CodeGen=x.Name=x.nil=x.stringify=x.str=x._=x.KeywordCxt=void 0;var oh=wt(),ih=ta(),ah=oa(),aa=ia(),uh=["/properties"],hr="http://json-schema.org/draft-04/schema",pr=class extends oh.default{constructor(e={}){super({...e,schemaId:"id"})}_addVocabularies(){super._addVocabularies(),ih.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(ah.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(aa,uh):aa;this.addMetaSchema(e,hr,!1),this.refs["http://json-schema.org/schema"]=hr}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(hr)?hr:void 0)}};ua.exports=x=pr;Object.defineProperty(x,"__esModule",{value:!0});x.default=pr;var ch=wt();Object.defineProperty(x,"KeywordCxt",{enumerable:!0,get:function(){return ch.KeywordCxt}});var We=wt();Object.defineProperty(x,"_",{enumerable:!0,get:function(){return We._}});Object.defineProperty(x,"str",{enumerable:!0,get:function(){return We.str}});Object.defineProperty(x,"stringify",{enumerable:!0,get:function(){return We.stringify}});Object.defineProperty(x,"nil",{enumerable:!0,get:function(){return We.nil}});Object.defineProperty(x,"Name",{enumerable:!0,get:function(){return We.Name}});Object.defineProperty(x,"CodeGen",{enumerable:!0,get:function(){return We.CodeGen}})});var Ia=xa(ca());var la=class{objectToUri(t){return this.locationToUri(t)}};var _s=function(t,e){return _s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var s in n)n.hasOwnProperty(s)&&(r[s]=n[s])},_s(t,e)};function lh(t,e){_s(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function Xe(t,e,r,n){function s(o){return o instanceof r?o:new r(function(i){i(o)})}return new(r||(r=Promise))(function(o,i){function a(l){try{u(n.next(l))}catch(f){i(f)}}function c(l){try{u(n.throw(l))}catch(f){i(f)}}function u(l){l.done?o(l.value):s(l.value).then(a,c)}u((n=n.apply(t,e||[])).next())})}function Pe(t,e){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,s,o,i;return i={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(u){return function(l){return c([u,l])}}function c(u){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,s&&(o=u[0]&2?s.return:u[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,u[1])).done)return o;switch(s=0,o&&(u=[u[0]&2,o.value]),u[0]){case 0:case 1:o=u;break;case 4:return r.label++,{value:u[1],done:!1};case 5:r.label++,s=u[1],u=[0];continue;case 7:u=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!o||u[1]>o[0]&&u[1]<o[3])){r.label=u[1];break}if(u[0]===6&&r.label<o[1]){r.label=o[1],o=u;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(u);break}o[2]&&r.ops.pop(),r.trys.pop();continue}u=e.call(t,r)}catch(l){u=[6,l],s=0}finally{n=o=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function Ye(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function qt(t){return this instanceof qt?(this.v=t,this):new qt(t)}function fh(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),s,o=[];return s={},i("next"),i("throw"),i("return"),s[Symbol.asyncIterator]=function(){return this},s;function i(d){n[d]&&(s[d]=function(h){return new Promise(function(p,m){o.push([d,h,p,m])>1||a(d,h)})})}function a(d,h){try{c(n[d](h))}catch(p){f(o[0][3],p)}}function c(d){d.value instanceof qt?Promise.resolve(d.value.v).then(u,l):f(o[0][2],d)}function u(d){a("next",d)}function l(d){a("throw",d)}function f(d,h){d(h),o.shift(),o.length&&a(o[0][0],o[0][1])}}var ha=function(t){lh(e,t);function e(r){var n=t.call(this,r)||this;return Object.defineProperty(n,"name",{value:"RepeaterOverflowError",enumerable:!1}),typeof Object.setPrototypeOf=="function"?Object.setPrototypeOf(n,n.constructor.prototype):n.__proto__=n.constructor.prototype,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(n,n.constructor),n}return e}(Error),Wp=function(){function t(e){if(e<0)throw new RangeError("Capacity may not be less than 0");this._c=e,this._q=[]}return Object.defineProperty(t.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return this._q.length>=this._c},enumerable:!1,configurable:!0}),t.prototype.add=function(e){if(this.full)throw new Error("Buffer full");this._q.push(e)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},t}(),Qp=function(){function t(e){if(e<1)throw new RangeError("Capacity may not be less than 1");this._c=e,this._q=[]}return Object.defineProperty(t.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.add=function(e){for(;this._q.length>=this._c;)this._q.shift();this._q.push(e)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},t}(),Xp=function(){function t(e){if(e<1)throw new RangeError("Capacity may not be less than 1");this._c=e,this._q=[]}return Object.defineProperty(t.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.add=function(e){this._q.length<this._c&&this._q.push(e)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},t}();function gs(t){t!=null&&typeof t.then=="function"&&t.then(_r,_r)}var vs=0,fa=1,De=2,yr=3,ws=4,vr=1024,_r=function(){};function Qe(t){var e=t.err,r=Promise.resolve(t.execution).then(function(n){if(e!=null)throw e;return n});return t.err=void 0,t.execution=r.then(function(){},function(){}),t.pending===void 0?r:t.pending.then(function(){return r})}function Ce(t,e){var r=t.state>=yr;return Promise.resolve(e).then(function(n){return!r&&t.state>=ws?Qe(t).then(function(s){return{value:s,done:!0}}):{value:n,done:r}})}function $s(t,e){var r,n;if(!(t.state>=De))if(t.state=De,t.onnext(),t.onstop(),t.err==null&&(t.err=e),t.pushes.length===0&&(typeof t.buffer>"u"||t.buffer.empty))It(t);else try{for(var s=Ye(t.pushes),o=s.next();!o.done;o=s.next()){var i=o.value;i.resolve()}}catch(a){r={error:a}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}}function It(t){var e,r;if(!(t.state>=yr)){t.state<De&&$s(t),t.state=yr,t.buffer=void 0;try{for(var n=Ye(t.nexts),s=n.next();!s.done;s=n.next()){var o=s.value,i=t.pending===void 0?Qe(t):t.pending.then(function(){return Qe(t)});o.resolve(Ce(t,i))}}catch(a){e={error:a}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}t.pushes=[],t.nexts=[]}}function da(t){t.state>=ws||(t.state<yr&&It(t),t.state=ws)}function dh(t,e){if(gs(e),t.pushes.length>=vr)throw new ha("No more than "+vr+" pending calls to push are allowed on a single repeater.");if(t.state>=De)return Promise.resolve(void 0);var r=t.pending===void 0?Promise.resolve(e):t.pending.then(function(){return e});r=r.catch(function(c){t.state<De&&(t.err=c),da(t)});var n;if(t.nexts.length){var s=t.nexts.shift();s.resolve(Ce(t,r)),t.nexts.length?n=Promise.resolve(t.nexts[0].value):typeof t.buffer<"u"&&!t.buffer.full?n=Promise.resolve(void 0):n=new Promise(function(c){return t.onnext=c})}else typeof t.buffer<"u"&&!t.buffer.full?(t.buffer.add(r),n=Promise.resolve(void 0)):n=new Promise(function(c){return t.pushes.push({resolve:c,value:r})});var o=!0,i={},a=n.catch(function(c){if(o)throw c});return i.then=function(c,u){return o=!1,Promise.prototype.then.call(n,c,u)},i.catch=function(c){return o=!1,Promise.prototype.catch.call(n,c)},i.finally=n.finally.bind(n),t.pending=r.then(function(){return a}).catch(function(c){t.err=c,da(t)}),i}function hh(t){var e=$s.bind(null,t),r=new Promise(function(n){return t.onstop=n});return e.then=r.then.bind(r),e.catch=r.catch.bind(r),e.finally=r.finally.bind(r),e}function ph(t){if(!(t.state>=fa)){t.state=fa;var e=dh.bind(null,t),r=hh(t);t.execution=new Promise(function(n){return n(t.executor(e,r))}),t.execution.catch(function(){return $s(t)})}}var mr=new WeakMap,Ze=function(){function t(e,r){mr.set(this,{executor:e,buffer:r,err:void 0,state:vs,pushes:[],nexts:[],pending:void 0,execution:void 0,onnext:_r,onstop:_r})}return t.prototype.next=function(e){gs(e);var r=mr.get(this);if(r===void 0)throw new Error("WeakMap error");if(r.nexts.length>=vr)throw new ha("No more than "+vr+" pending calls to next are allowed on a single repeater.");if(r.state<=vs&&ph(r),r.onnext(e),typeof r.buffer<"u"&&!r.buffer.empty){var n=Ce(r,r.buffer.remove());if(r.pushes.length){var s=r.pushes.shift();r.buffer.add(s.value),r.onnext=s.resolve}return n}else if(r.pushes.length){var o=r.pushes.shift();return r.onnext=o.resolve,Ce(r,o.value)}else if(r.state>=De)return It(r),Ce(r,Qe(r));return new Promise(function(i){return r.nexts.push({resolve:i,value:e})})},t.prototype.return=function(e){gs(e);var r=mr.get(this);if(r===void 0)throw new Error("WeakMap error");return It(r),r.execution=Promise.resolve(r.execution).then(function(){return e}),Ce(r,Qe(r))},t.prototype.throw=function(e){var r=mr.get(this);if(r===void 0)throw new Error("WeakMap error");return r.state<=vs||r.state>=De||typeof r.buffer<"u"&&!r.buffer.empty?(It(r),r.err==null&&(r.err=e),Ce(r,Qe(r))):this.next(Promise.reject(e))},t.prototype[Symbol.asyncIterator]=function(){return this},t.race=mh,t.merge=yh,t.zip=vh,t.latest=_h,t}();function gr(t,e){var r,n,s=[],o=function(u){u!=null&&typeof u[Symbol.asyncIterator]=="function"?s.push(u[Symbol.asyncIterator]()):u!=null&&typeof u[Symbol.iterator]=="function"?s.push(u[Symbol.iterator]()):s.push(function(){return fh(this,arguments,function(){return Pe(this,function(d){switch(d.label){case 0:return e.yieldValues?[4,qt(u)]:[3,3];case 1:return[4,d.sent()];case 2:d.sent(),d.label=3;case 3:return e.returnValues?[4,qt(u)]:[3,5];case 4:return[2,d.sent()];case 5:return[2]}})})}())};try{for(var i=Ye(t),a=i.next();!a.done;a=i.next()){var c=a.value;o(c)}}catch(u){r={error:u}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return s}function mh(t){var e=this,r=gr(t,{returnValues:!0});return new Ze(function(n,s){return Xe(e,void 0,void 0,function(){var o,i,a,c,u,l;return Pe(this,function(f){switch(f.label){case 0:if(!r.length)return s(),[2];i=!1,s.then(function(){o(),i=!0}),f.label=1;case 1:f.trys.push([1,,5,7]),c=void 0,u=0,l=function(){var d,h,p,m,y,v;return Pe(this,function(P){switch(P.label){case 0:d=u;try{for(h=(y=void 0,Ye(r)),p=h.next();!p.done;p=h.next())m=p.value,Promise.resolve(m.next()).then(function(w){w.done?(s(),a===void 0&&(a=w)):u===d&&(u++,o(w))},function(w){return s(w)})}catch(w){y={error:w}}finally{try{p&&!p.done&&(v=h.return)&&v.call(h)}finally{if(y)throw y.error}}return[4,new Promise(function(w){return o=w})];case 1:return c=P.sent(),c===void 0?[3,3]:[4,n(c.value)];case 2:P.sent(),P.label=3;case 3:return[2]}})},f.label=2;case 2:return i?[3,4]:[5,l()];case 3:return f.sent(),[3,2];case 4:return[2,a&&a.value];case 5:return s(),[4,Promise.race(r.map(function(d){return d.return&&d.return()}))];case 6:return f.sent(),[7];case 7:return[2]}})})})}function yh(t){var e=this,r=gr(t,{yieldValues:!0});return new Ze(function(n,s){return Xe(e,void 0,void 0,function(){var o,i,a,c=this;return Pe(this,function(u){switch(u.label){case 0:if(!r.length)return s(),[2];o=[],i=!1,s.then(function(){var l,f;i=!0;try{for(var d=Ye(o),h=d.next();!h.done;h=d.next()){var p=h.value;p()}}catch(m){l={error:m}}finally{try{h&&!h.done&&(f=d.return)&&f.call(d)}finally{if(l)throw l.error}}}),u.label=1;case 1:return u.trys.push([1,,3,4]),[4,Promise.all(r.map(function(l,f){return Xe(c,void 0,void 0,function(){var d,h;return Pe(this,function(p){switch(p.label){case 0:p.trys.push([0,,6,9]),p.label=1;case 1:return i?[3,5]:(Promise.resolve(l.next()).then(function(m){return o[f](m)},function(m){return s(m)}),[4,new Promise(function(m){o[f]=m})]);case 2:return d=p.sent(),d===void 0?[3,4]:d.done?(a=d,[2]):[4,n(d.value)];case 3:p.sent(),p.label=4;case 4:return[3,1];case 5:return[3,9];case 6:return h=l.return,h?[4,l.return()]:[3,8];case 7:h=p.sent(),p.label=8;case 8:return[7];case 9:return[2]}})})}))];case 2:return u.sent(),[2,a&&a.value];case 3:return s(),[7];case 4:return[2]}})})})}function vh(t){var e=this,r=gr(t,{returnValues:!0});return new Ze(function(n,s){return Xe(e,void 0,void 0,function(){var o,i,a,c;return Pe(this,function(u){switch(u.label){case 0:if(!r.length)return s(),[2,[]];i=!1,s.then(function(){o(),i=!0}),u.label=1;case 1:u.trys.push([1,,6,8]),u.label=2;case 2:return i?[3,5]:(Promise.all(r.map(function(l){return l.next()})).then(function(l){return o(l)},function(l){return s(l)}),[4,new Promise(function(l){return o=l})]);case 3:return a=u.sent(),a===void 0?[2]:(c=a.map(function(l){return l.value}),a.some(function(l){return l.done})?[2,c]:[4,n(c)]);case 4:return u.sent(),[3,2];case 5:return[3,8];case 6:return s(),[4,Promise.all(r.map(function(l){return l.return&&l.return()}))];case 7:return u.sent(),[7];case 8:return[2]}})})})}function _h(t){var e=this,r=gr(t,{yieldValues:!0,returnValues:!0});return new Ze(function(n,s){return Xe(e,void 0,void 0,function(){var o,i,a,c,u,l=this;return Pe(this,function(f){switch(f.label){case 0:if(!r.length)return s(),[2,[]];i=[],a=!1,s.then(function(){var d,h;o();try{for(var p=Ye(i),m=p.next();!m.done;m=p.next()){var y=m.value;y()}}catch(v){d={error:v}}finally{try{m&&!m.done&&(h=p.return)&&h.call(p)}finally{if(d)throw d.error}}a=!0}),f.label=1;case 1:return f.trys.push([1,,5,7]),Promise.all(r.map(function(d){return d.next()})).then(function(d){return o(d)},function(d){return s(d)}),[4,new Promise(function(d){return o=d})];case 2:return c=f.sent(),c===void 0?[2]:(u=c.map(function(d){return d.value}),c.every(function(d){return d.done})?[2,u]:[4,n(u.slice())]);case 3:return f.sent(),[4,Promise.all(r.map(function(d,h){return Xe(l,void 0,void 0,function(){var p;return Pe(this,function(m){switch(m.label){case 0:if(c[h].done)return[2,c[h].value];m.label=1;case 1:return a?[3,4]:(Promise.resolve(d.next()).then(function(y){return i[h](y)},function(y){return s(y)}),[4,new Promise(function(y){return i[h]=y})]);case 2:return p=m.sent(),p===void 0?[2,c[h].value]:p.done?[2,p.value]:(u[h]=p.value,[4,n(u.slice())]);case 3:return m.sent(),[3,1];case 4:return[2]}})})}))];case 4:return[2,f.sent()];case 5:return s(),[4,Promise.all(r.map(function(d){return d.return&&d.return()}))];case 6:return f.sent(),[7];case 7:return[2]}})})})}var bs={};Is(bs,{JsonPatchError:()=>D,_areEquals:()=>At,applyOperation:()=>Me,applyPatch:()=>tt,applyReducer:()=>Eh,deepClone:()=>$h,getValueByPointer:()=>Pr,validate:()=>ma,validator:()=>Sr});var gh=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,s){n.__proto__=s}||function(n,s){for(var o in s)s.hasOwnProperty(o)&&(n[o]=s[o])},t(e,r)};return function(e,r){t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),wh=Object.prototype.hasOwnProperty;function $r(t,e){return wh.call(t,e)}function br(t){if(Array.isArray(t)){for(var e=new Array(t.length),r=0;r<e.length;r++)e[r]=""+r;return e}if(Object.keys)return Object.keys(t);var n=[];for(var s in t)$r(t,s)&&n.push(s);return n}function z(t){switch(typeof t){case"object":return JSON.parse(JSON.stringify(t));case"undefined":return null;default:return t}}function Er(t){for(var e=0,r=t.length,n;e<r;){if(n=t.charCodeAt(e),n>=48&&n<=57){e++;continue}return!1}return!0}function le(t){return t.indexOf("/")===-1&&t.indexOf("~")===-1?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}function Rt(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function wr(t){if(t===void 0)return!0;if(t){if(Array.isArray(t)){for(var e=0,r=t.length;e<r;e++)if(wr(t[e]))return!0}else if(typeof t=="object"){for(var n=br(t),s=n.length,o=0;o<s;o++)if(wr(t[n[o]]))return!0}}return!1}function pa(t,e){var r=[t];for(var n in e){var s=typeof e[n]=="object"?JSON.stringify(e[n],null,2):e[n];typeof s<"u"&&r.push(n+": "+s)}return r.join(`
|
|
9
|
+
`)}var kt=function(t){gh(e,t);function e(r,n,s,o,i){var a=this.constructor,c=t.call(this,pa(r,{name:n,index:s,operation:o,tree:i}))||this;return c.name=n,c.index=s,c.operation=o,c.tree=i,Object.setPrototypeOf(c,a.prototype),c.message=pa(r,{name:n,index:s,operation:o,tree:i}),c}return e}(Error);var D=kt,$h=z,et={add:function(t,e,r){return t[e]=this.value,{newDocument:r}},remove:function(t,e,r){var n=t[e];return delete t[e],{newDocument:r,removed:n}},replace:function(t,e,r){var n=t[e];return t[e]=this.value,{newDocument:r,removed:n}},move:function(t,e,r){var n=Pr(r,this.path);n&&(n=z(n));var s=Me(r,{op:"remove",path:this.from}).removed;return Me(r,{op:"add",path:this.path,value:s}),{newDocument:r,removed:n}},copy:function(t,e,r){var n=Pr(r,this.from);return Me(r,{op:"add",path:this.path,value:z(n)}),{newDocument:r}},test:function(t,e,r){return{newDocument:r,test:At(t[e],this.value)}},_get:function(t,e,r){return this.value=t[e],{newDocument:r}}},bh={add:function(t,e,r){return Er(e)?t.splice(e,0,this.value):t[e]=this.value,{newDocument:r,index:e}},remove:function(t,e,r){var n=t.splice(e,1);return{newDocument:r,removed:n[0]}},replace:function(t,e,r){var n=t[e];return t[e]=this.value,{newDocument:r,removed:n}},move:et.move,copy:et.copy,test:et.test,_get:et._get};function Pr(t,e){if(e=="")return t;var r={op:"_get",path:e};return Me(t,r),r.value}function Me(t,e,r,n,s,o){if(r===void 0&&(r=!1),n===void 0&&(n=!0),s===void 0&&(s=!0),o===void 0&&(o=0),r&&(typeof r=="function"?r(e,0,t,e.path):Sr(e,0)),e.path===""){var i={newDocument:t};if(e.op==="add")return i.newDocument=e.value,i;if(e.op==="replace")return i.newDocument=e.value,i.removed=t,i;if(e.op==="move"||e.op==="copy")return i.newDocument=Pr(t,e.from),e.op==="move"&&(i.removed=t),i;if(e.op==="test"){if(i.test=At(t,e.value),i.test===!1)throw new D("Test operation failed","TEST_OPERATION_FAILED",o,e,t);return i.newDocument=t,i}else{if(e.op==="remove")return i.removed=t,i.newDocument=null,i;if(e.op==="_get")return e.value=t,i;if(r)throw new D("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",o,e,t);return i}}else{n||(t=z(t));var a=e.path||"",c=a.split("/"),u=t,l=1,f=c.length,d=void 0,h=void 0,p=void 0;for(typeof r=="function"?p=r:p=Sr;;){if(h=c[l],h&&h.indexOf("~")!=-1&&(h=Rt(h)),s&&(h=="__proto__"||h=="prototype"&&l>0&&c[l-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(r&&d===void 0&&(u[h]===void 0?d=c.slice(0,l).join("/"):l==f-1&&(d=e.path),d!==void 0&&p(e,0,t,d)),l++,Array.isArray(u)){if(h==="-")h=u.length;else{if(r&&!Er(h))throw new D("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",o,e,t);Er(h)&&(h=~~h)}if(l>=f){if(r&&e.op==="add"&&h>u.length)throw new D("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",o,e,t);var i=bh[e.op].call(e,u,h,t);if(i.test===!1)throw new D("Test operation failed","TEST_OPERATION_FAILED",o,e,t);return i}}else if(l>=f){var i=et[e.op].call(e,u,h,t);if(i.test===!1)throw new D("Test operation failed","TEST_OPERATION_FAILED",o,e,t);return i}if(u=u[h],r&&l<f&&(!u||typeof u!="object"))throw new D("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",o,e,t)}}}function tt(t,e,r,n,s){if(n===void 0&&(n=!0),s===void 0&&(s=!0),r&&!Array.isArray(e))throw new D("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");n||(t=z(t));for(var o=new Array(e.length),i=0,a=e.length;i<a;i++)o[i]=Me(t,e[i],r,!0,s,i),t=o[i].newDocument;return o.newDocument=t,o}function Eh(t,e,r){var n=Me(t,e);if(n.test===!1)throw new D("Test operation failed","TEST_OPERATION_FAILED",r,e,t);return n.newDocument}function Sr(t,e,r,n){if(typeof t!="object"||t===null||Array.isArray(t))throw new D("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,t,r);if(et[t.op]){if(typeof t.path!="string")throw new D("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,t,r);if(t.path.indexOf("/")!==0&&t.path.length>0)throw new D('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,t,r);if((t.op==="move"||t.op==="copy")&&typeof t.from!="string")throw new D("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,t,r);if((t.op==="add"||t.op==="replace"||t.op==="test")&&t.value===void 0)throw new D("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,t,r);if((t.op==="add"||t.op==="replace"||t.op==="test")&&wr(t.value))throw new D("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,t,r);if(r){if(t.op=="add"){var s=t.path.split("/").length,o=n.split("/").length;if(s!==o+1&&s!==o)throw new D("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,t,r)}else if(t.op==="replace"||t.op==="remove"||t.op==="_get"){if(t.path!==n)throw new D("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,t,r)}else if(t.op==="move"||t.op==="copy"){var i={op:"_get",path:t.from,value:void 0},a=ma([i],r);if(a&&a.name==="OPERATION_PATH_UNRESOLVABLE")throw new D("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,t,r)}}}else throw new D("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,t,r)}function ma(t,e,r){try{if(!Array.isArray(t))throw new D("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)tt(z(e),z(t),r||!0);else{r=r||Sr;for(var n=0;n<t.length;n++)r(t[n],n,e,void 0)}}catch(s){if(s instanceof D)return s;throw s}}function At(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var r=Array.isArray(t),n=Array.isArray(e),s,o,i;if(r&&n){if(o=t.length,o!=e.length)return!1;for(s=o;s--!==0;)if(!At(t[s],e[s]))return!1;return!0}if(r!=n)return!1;var a=Object.keys(t);if(o=a.length,o!==Object.keys(e).length)return!1;for(s=o;s--!==0;)if(!e.hasOwnProperty(a[s]))return!1;for(s=o;s--!==0;)if(i=a[s],!At(t[i],e[i]))return!1;return!0}return t!==t&&e!==e}var Os={};Is(Os,{compare:()=>qh,generate:()=>Es,observe:()=>Ih,unobserve:()=>Th});var Ps=new WeakMap,Ph=function(){function t(e){this.observers=new Map,this.obj=e}return t}(),Sh=function(){function t(e,r){this.callback=e,this.observer=r}return t}();function Oh(t){return Ps.get(t)}function Nh(t,e){return t.observers.get(e)}function jh(t,e){t.observers.delete(e.callback)}function Th(t,e){e.unobserve()}function Ih(t,e){var r=[],n,s=Oh(t);if(!s)s=new Ph(t),Ps.set(t,s);else{var o=Nh(s,e);n=o&&o.observer}if(n)return n;if(n={},s.value=z(t),e){n.callback=e,n.next=null;var i=function(){Es(n)},a=function(){clearTimeout(n.next),n.next=setTimeout(i)};typeof window<"u"&&(window.addEventListener("mouseup",a),window.addEventListener("keyup",a),window.addEventListener("mousedown",a),window.addEventListener("keydown",a),window.addEventListener("change",a))}return n.patches=r,n.object=t,n.unobserve=function(){Es(n),clearTimeout(n.next),jh(s,n),typeof window<"u"&&(window.removeEventListener("mouseup",a),window.removeEventListener("keyup",a),window.removeEventListener("mousedown",a),window.removeEventListener("keydown",a),window.removeEventListener("change",a))},s.observers.set(e,new Sh(e,n)),n}function Es(t,e){e===void 0&&(e=!1);var r=Ps.get(t.object);Ss(r.value,t.object,t.patches,"",e),t.patches.length&&tt(r.value,t.patches);var n=t.patches;return n.length>0&&(t.patches=[],t.callback&&t.callback(n)),n}function Ss(t,e,r,n,s){if(e!==t){typeof e.toJSON=="function"&&(e=e.toJSON());for(var o=br(e),i=br(t),a=!1,c=!1,u=i.length-1;u>=0;u--){var l=i[u],f=t[l];if($r(e,l)&&!(e[l]===void 0&&f!==void 0&&Array.isArray(e)===!1)){var d=e[l];typeof f=="object"&&f!=null&&typeof d=="object"&&d!=null&&Array.isArray(f)===Array.isArray(d)?Ss(f,d,r,n+"/"+le(l),s):f!==d&&(a=!0,s&&r.push({op:"test",path:n+"/"+le(l),value:z(f)}),r.push({op:"replace",path:n+"/"+le(l),value:z(d)}))}else Array.isArray(t)===Array.isArray(e)?(s&&r.push({op:"test",path:n+"/"+le(l),value:z(f)}),r.push({op:"remove",path:n+"/"+le(l)}),c=!0):(s&&r.push({op:"test",path:n,value:t}),r.push({op:"replace",path:n,value:e}),a=!0)}if(!(!c&&o.length==i.length))for(var u=0;u<o.length;u++){var l=o[u];!$r(t,l)&&e[l]!==void 0&&r.push({op:"add",path:n+"/"+le(l),value:z(e[l])})}}}function qh(t,e,r){r===void 0&&(r=!1);var n=[];return Ss(t,e,n,"",r),n}var sm=Object.assign({},bs,Os,{JsonPatchError:kt,deepClone:z,escapePathComponent:le,unescapePathComponent:Rt});var ya=class va extends Error{constructor(e){super(e),this.name="GraffitiErrorInvalidSchema",Object.setPrototypeOf(this,va.prototype)}};var _a=class ga extends Error{constructor(e){super(e),this.name="GraffitiErrorPatchTestFailed",Object.setPrototypeOf(this,ga.prototype)}},wa=class $a extends Error{constructor(e){super(e),this.name="GraffitiErrorPatchError",Object.setPrototypeOf(this,$a.prototype)}},ba=class Ea extends Error{constructor(e){super(e),this.name="GraffitiErrorInvalidUri",Object.setPrototypeOf(this,Ea.prototype)}};var Ns=t=>`${t.source}/${encodeURIComponent(t.actor)}/${encodeURIComponent(t.name)}`,Rh=t=>{let e=t.split("/"),r=e.pop(),n=e.pop();if(!r||!n||!e.length)throw new ba;return{name:decodeURIComponent(r),actor:decodeURIComponent(n),source:e.join("/")}};function Pa(t){return typeof t=="string"?{location:Rh(t),uri:t}:{location:{name:t.name,actor:t.actor,source:t.source},uri:Ns(t)}}function Sa(t,e,r,n){let s=r[e];if(!(!s||!s.length))try{n[e]=t(n[e],s,!0,!1).newDocument}catch(o){throw typeof o=="object"&&o&&"name"in o&&typeof o.name=="string"&&"message"in o&&typeof o.message=="string"?o.name==="TEST_OPERATION_FAILED"?new _a(o.message):new wa(o.name+": "+o.message):o}}function Oa(t,e){try{return t.compile(e)}catch(r){throw new ya(r instanceof Error?r.message:void 0)}}function Na(t,e,r){t.actor!==r?.actor&&(t.allowed=t.allowed&&r?[r.actor]:void 0,t.channels=t.channels.filter(n=>e.includes(n)))}function ja(t,e){return t.allowed===void 0||t.allowed===null||!!e?.actor&&(t.actor===e.actor||t.allowed.includes(e.actor))}var Ta=class extends la{ajv;graffiti;callbacks=new Set;channelStats;locationToUri;uriToLocation;login;logout;sessionEvents;constructor(e,r){super(),this.ajv=r??new Ia.default({strict:!1}),this.graffiti=e,this.channelStats=e.channelStats.bind(e),this.locationToUri=e.locationToUri.bind(e),this.uriToLocation=e.uriToLocation.bind(e),this.login=e.login.bind(e),this.logout=e.logout.bind(e),this.sessionEvents=e.sessionEvents}synchronize(e,r,n,s){let o=Oa(this.ajv,n);return new Ze(async(a,c)=>{let u=(l,f)=>{for(let d of[f,l])if(d&&e(d)&&ja(d,s)){let h={...d};if(Na(h,r,s),o(h)){a({value:h});break}}};this.callbacks.add(u),await c,this.callbacks.delete(u)})}synchronizeDiscover(...e){let[r,n,s]=e;function o(i){return i.channels.some(a=>r.includes(a))}return this.synchronize(o,r,n,s)}synchronizeGet(...e){let[r,n,s]=e;function o(i){let a=Ns(i),{uri:c}=Pa(r);return a===c}return this.synchronize(o,[],n,s)}synchronizeRecoverOrphans(...e){let[r,n]=e;function s(o){return o.actor===n.actor&&o.channels.length===0}return this.synchronize(s,[],r,n)}async synchronizeDispatch(e,r,n=!1){for(let s of this.callbacks)s(e,r);n&&await new Promise(s=>setTimeout(s,0))}get=async(...e)=>{let r=await this.graffiti.get(...e);return this.synchronizeDispatch(r),r};put=async(...e)=>{let r=await this.graffiti.put(...e),n=e[0],s={...r,value:n.value,channels:n.channels,allowed:n.allowed,tombstone:!1};return await this.synchronizeDispatch(r,s,!0),r};patch=async(...e)=>{let r=await this.graffiti.patch(...e),n={...r};n.tombstone=!1;for(let s of["value","channels","allowed"])Sa(tt,s,e[0],n);return await this.synchronizeDispatch(r,n,!0),r};delete=async(...e)=>{let r=await this.graffiti.delete(...e);return await this.synchronizeDispatch(r,void 0,!0),r};objectStream(e){let r=this.synchronizeDispatch.bind(this);return async function*(){let s=await e.next();for(;!s.done;)s.value.error||r(s.value.value),yield s.value,s=await e.next();return s.value}()}discover=(...e)=>{let r=this.graffiti.discover(...e);return this.objectStream(r)};recoverOrphans=(...e)=>{let r=this.graffiti.recoverOrphans(...e);return this.objectStream(r)}};export{Ta as GraffitiSynchronize};
|
|
10
|
+
/*! Bundled license information:
|
|
11
|
+
|
|
12
|
+
@repeaterjs/repeater/repeater.js:
|
|
13
|
+
(*! *****************************************************************************
|
|
14
|
+
Copyright (c) Microsoft Corporation.
|
|
15
|
+
|
|
16
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
17
|
+
purpose with or without fee is hereby granted.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
20
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
21
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
22
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
23
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
24
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
25
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
26
|
+
***************************************************************************** *)
|
|
27
|
+
|
|
28
|
+
fast-json-patch/module/helpers.mjs:
|
|
29
|
+
(*!
|
|
30
|
+
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
31
|
+
* (c) 2017-2022 Joachim Wester
|
|
32
|
+
* MIT licensed
|
|
33
|
+
*)
|
|
34
|
+
|
|
35
|
+
fast-json-patch/module/duplex.mjs:
|
|
36
|
+
(*!
|
|
37
|
+
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
38
|
+
* (c) 2017-2021 Joachim Wester
|
|
39
|
+
* MIT license
|
|
40
|
+
*)
|
|
41
|
+
*/
|
|
42
|
+
//# sourceMappingURL=index.browser.js.map
|