From e51684274e44f3cb696b291a4daa16683f696b37 Mon Sep 17 00:00:00 2001 From: Eric Tuvesson Date: Fri, 20 Dec 2024 15:26:16 +0100 Subject: [PATCH] testing new custom runtime --- .gitignore | 1 - .../external/cloudruntime/global.d.ts.keep | 565 ++++++++++++++ .../src/external/cloudruntime/index.html | 9 + .../src/external/cloudruntime/manifest.json | 1 + .../cloudruntime/sandbox.viewer.bundle.js | 2 + .../cloudruntime/sandbox.viewer.bundle.js.map | 1 + .../src/external/deploy/index.html | 74 ++ .../noodl-editor/src/external/deploy/index.js | 10 + .../src/external/deploy/index.json | 10 + .../src/external/deploy/load_terminator.js | 1 + .../src/external/deploy/noodl-app.png | Bin 0 -> 10346 bytes .../src/external/deploy/noodl.deploy.js | 3 + .../deploy/noodl.deploy.js.LICENSE.txt | 20 + .../src/external/deploy/noodl.deploy.js.map | 1 + .../deploy/react-dom.production.min.js | 219 ++++++ .../external/deploy/react.production.min.js | 32 + .../src/external/viewer/global.d.ts.keep | 721 ++++++++++++++++++ .../src/external/viewer/index.html | 96 +++ .../src/external/viewer/load_terminator.js | 1 + .../viewer/ndl_assets/OpenSans-Bold.ttf | Bin 0 -> 224592 bytes .../viewer/ndl_assets/OpenSans-Regular.ttf | Bin 0 -> 217360 bytes .../external/viewer/ndl_assets/home-icon.svg | 3 + .../ndl_assets/make-home-instructions@2x.png | Bin 0 -> 25696 bytes .../viewer/ndl_assets/noodl-logo-black.svg | 3 + .../src/external/viewer/noodl-app.png | Bin 0 -> 10346 bytes .../src/external/viewer/noodl.viewer.js | 3 + .../viewer/noodl.viewer.js.LICENSE.txt | 20 + .../src/external/viewer/noodl.viewer.js.map | 1 + .../viewer/react-dom.production.min.js | 219 ++++++ .../external/viewer/react.production.min.js | 32 + scripts/build-editor.ts | 18 +- 31 files changed, 2056 insertions(+), 10 deletions(-) create mode 100644 packages/noodl-editor/src/external/cloudruntime/global.d.ts.keep create mode 100644 packages/noodl-editor/src/external/cloudruntime/index.html create mode 100644 packages/noodl-editor/src/external/cloudruntime/manifest.json create mode 100644 packages/noodl-editor/src/external/cloudruntime/sandbox.viewer.bundle.js create mode 100644 packages/noodl-editor/src/external/cloudruntime/sandbox.viewer.bundle.js.map create mode 100644 packages/noodl-editor/src/external/deploy/index.html create mode 100644 packages/noodl-editor/src/external/deploy/index.js create mode 100644 packages/noodl-editor/src/external/deploy/index.json create mode 100644 packages/noodl-editor/src/external/deploy/load_terminator.js create mode 100644 packages/noodl-editor/src/external/deploy/noodl-app.png create mode 100644 packages/noodl-editor/src/external/deploy/noodl.deploy.js create mode 100644 packages/noodl-editor/src/external/deploy/noodl.deploy.js.LICENSE.txt create mode 100644 packages/noodl-editor/src/external/deploy/noodl.deploy.js.map create mode 100644 packages/noodl-editor/src/external/deploy/react-dom.production.min.js create mode 100644 packages/noodl-editor/src/external/deploy/react.production.min.js create mode 100644 packages/noodl-editor/src/external/viewer/global.d.ts.keep create mode 100644 packages/noodl-editor/src/external/viewer/index.html create mode 100644 packages/noodl-editor/src/external/viewer/load_terminator.js create mode 100644 packages/noodl-editor/src/external/viewer/ndl_assets/OpenSans-Bold.ttf create mode 100644 packages/noodl-editor/src/external/viewer/ndl_assets/OpenSans-Regular.ttf create mode 100644 packages/noodl-editor/src/external/viewer/ndl_assets/home-icon.svg create mode 100644 packages/noodl-editor/src/external/viewer/ndl_assets/make-home-instructions@2x.png create mode 100644 packages/noodl-editor/src/external/viewer/ndl_assets/noodl-logo-black.svg create mode 100644 packages/noodl-editor/src/external/viewer/noodl-app.png create mode 100644 packages/noodl-editor/src/external/viewer/noodl.viewer.js create mode 100644 packages/noodl-editor/src/external/viewer/noodl.viewer.js.LICENSE.txt create mode 100644 packages/noodl-editor/src/external/viewer/noodl.viewer.js.map create mode 100644 packages/noodl-editor/src/external/viewer/react-dom.production.min.js create mode 100644 packages/noodl-editor/src/external/viewer/react.production.min.js diff --git a/.gitignore b/.gitignore index 1c591b2..8ca0079 100644 --- a/.gitignore +++ b/.gitignore @@ -165,6 +165,5 @@ packages/noodl-editor/tests/vendors-node_modules_monaco-editor_esm_vs_language_j packages/noodl-editor/tests/vendors-node_modules_monaco-editor_esm_vs_language_typescript_tsMode_js.index.bundle.js # Other -packages/noodl-editor/src/external .github/.secrets packages/noodl-viewer-cloud/publish diff --git a/packages/noodl-editor/src/external/cloudruntime/global.d.ts.keep b/packages/noodl-editor/src/external/cloudruntime/global.d.ts.keep new file mode 100644 index 0000000..39a6fa6 --- /dev/null +++ b/packages/noodl-editor/src/external/cloudruntime/global.d.ts.keep @@ -0,0 +1,565 @@ +/* eslint-disable */ + +declare namespace Noodl { + function getProjectSettings(): any; + function getMetaData(): any; + + interface VariablesApi { + [K in VariableNames]: any + } + + /** + * You can access all variables in your application trough the Noodl.Variables object. + * Changing a variable will trigger all connections to be updated for all Variable nodes + * in your project with the corresponding variable name. + * + * Example: + * ```ts + * // This will change the variable named MyVariable + * // and trigger all variable nodes in your project + * Noodl.Variables.MyVariable = "Hello"; + * + * // Use this if you have spaces in your variable name + * Noodl.Variables["My Variable"] = 10; + * + * Noodl.Variables.userName = "Mickeeeey"; + * + * // Reading variables + * console.log(Noodl.Variables.userName); + * ``` + * + * {@link https://docs.noodl.net/#/javascript/reference/variables} + */ + const Variables: VariablesApi; + + /** + * One step above Variables are Objects, this is a global data model of Noodl objects. + * Each object is referenced with an Id and can contain a set of properties. + * You can access all objects in your workspace through their Id and the Noodl.Objects prefix. + * Change a property of an object will trigger all connections + * from object nodes with the corresponding Id and property. + * + * Example: + * ```ts + * // This will change the property MyProperty + * // of object with id MyObjectId and trigger + * // all object nodes (with that id) in your project + * Noodl.Objects.MyObjectId.MyProperty = "Hello"; + * + * // Use this notation of that object id contains spaces + * Noodl.Objects["Form Values"].input_text = "Whoops"; + * + * Noodl.Objects["Form Values"]["A property with spaces"] = 20; + * + * // Reading an object property + * console.log(Noodl.Objects.CurrentUser.Name); + * + * // This will set all properties of the object you assign with + * // to the object with id "SomeId" + * // You cannot set the id property this way, + * // that property will be ignored if part of the object you assign + * Noodl.Objects.SomeId = { + * // ... + * } + * ``` + * + * {@link https://docs.noodl.net/#/javascript/reference/objects} + */ + const Objects: any; + + /** + * Allows access to Object from Javascript. + * + * {@link https://docs.noodl.net/#/javascript/reference/object} + */ + const Object: any; + + type RecordQuery = + { + lessThan: T + } | + { + lessThanOrEqualTo: T + } | + { + greaterThan: T + } | + { + greaterThanOrEqualTo: T + } | + { + equalTo: T + } | + { + notEqualTo: T + } | + { + containedIn: T + } | + { + notContainedIn : T + } | + { + exists: T + } | + { + matchesRegex: T + } | + { + text: T + } | + { + idEqualTo: T + } | + { + idContainedIn: T + } | + { + pointsTo: T + } | + { + relatedTo: T + }; + + type RecordQueryField = T extends RecordQuery ? + { [K in keyof T]: { [P in K]: T[P] } & Partial, never>> }[keyof T] + : never; + + type RecordSortKey = (`${T}` | `-${T}`)[]; + + interface RecordsApi { + /** + * This is an async function that will query the database using the query + * that you provide and return the result or throw an exception if failed. + * + * The query parameter has the same format as the advanced query of the Query Records node. + * {@link https://docs.noodl.net/#/nodes/data/cloud-data/query-records/#advanced-filters} + * + * Example: + * ```ts + * const results = await Noodl.Records.query("myClass", { + * Completed: { equalTo: true }, + * }) + * ``` + * + * The result is an array of Noodl.Object. The options can be used to specify sorting, + * it also follows the same pattern as the advanced filters of the Query Records node. + * + * Example: + * ```ts + * const results = await Noodl.Records.query("myClass", { + * Completed: { equalTo: true }, + * }, { + * sort:['createdAt'] + * }) + * ``` + * + * You can also specify the limit for how many records to return as a maximum (defaults to 100) + * with the limit option, and if you want the returned records to start from a given + * index specify the skip option. + * + * ```ts + * const results = await Noodl.Records.query("myClass", { + * Completed: { equalTo: true }, + * }, { + * sort: ['-createdAt'], // use - to sort descending + * skip: 50, + * limit: 200 + * }) + * ``` + */ + query( + className: TClassName, + query?: + RecordQueryField<{ [K in keyof DatabaseSchema[TClassName]]: RecordQuery }> | + { and: RecordQueryField<{ [K in keyof DatabaseSchema[TClassName]]: RecordQuery }>[] }, + options?: { + limit?: number; + skip?: number; + sort?: string | RecordSortKey; + include?: string | (keyof DatabaseSchema[TClassName])[]; + select?: string | (keyof DatabaseSchema[TClassName])[]; + } + ): Promise; + + /** + * This function returns the count of the number of records of a given class, + * optionally matching a query filter. + * + * Example: + * ```ts + * // The number of records of myClass in the database + * const count = await Noodl.Records.count("myClass") + * + * // The number of myClass records in the database that match a query + * const completedCount = await Noodl.Records.count("myClass", { + * Completed: { equalTo: true }, + * }) + * ``` + */ + count(className: RecordClassName, query?: any): Promise; + + /** + * returns an array of unique values for a given propery or all records in + * the database of a given class. Optionally you can suppoly a query filter. + */ + distinct( + className: RecordClassName, + property: string, + query: any + ): Promise; + + /** + * Use this function to fetch the latest properties of a specific record + * from the cloud database. It will return the object / record. + * + * Example: + * ```ts + * // If you use the a record ID you must also specify the class + * const myRecord = await Noodl.Records.fetch(myRecordId, { className: "myClass" }) + * + * // You can also fetch a record you have previously fetched or received from a + * // query, to get the latest properties from the backend + * await Noodl.Records.fetch(myRecord) + * ``` + */ + fetch( + objectOrId: string | { getId(): string; }, + options?: { + className?: RecordClassName; + keys?: string[] | string; + include?: string[] | string; + excludeKeys?: string[] | string; + } + ): Promise; + + /** + * Use this function to write an existing record to the cloud database. + * It will attempt to save all properties of the record / object + * if you don't specify the optional properties argument, + * if so it will set and save those properties. + * + * Example: + * ```ts + * Noodl.Objects[myRecordId].SomeProperty = "hello" + * + * // If you use the record id to save, you need to specify the classname explicitly + * // by specfiying null or undefinded for properties it will save all proporties in + * // the record + * await Noodl.Records.save(myRecordId, null, { className: "myClass" }) + * + * // Or use the object directly + * await Noodl.Records.save(Noodl.Objects[myRecordId]) + * + * // Set specified properties and save only those to the backned + * await Noodl.Records.save(myRecord, { + * SomeProperty:'hello' + * }) + * ``` + */ + save( + objectOrId: string | { getId(): string; }, + properties: any, + options?: { + className?: RecordClassName; + acl?: any; + } + ): Promise; + + /** + * This function will increment (or decrease) propertis of a certain record + * saving it to the cloud database in a race condition safe way. + * That is, normally you would have to first read the current value, + * modify it and save it to the database. Here you can do it with one operation. + * + * Example: + * ```ts + * // Modify the specified numbers in the cloud + * await Noodl.Records.increment(myRecord, { + * Score: 10, + * Life: -1 + * }) + * + * // Like save, you can use a record Id and class + * await Noodl.Records.save(myRecordId, { Likes: 1 }, { className: "myClass" }) + * ``` + * + * Using the options you can also specify access control as described in this guide, + * this let's you control which users can access a specific record. + * The access control is specified as below: + * ```ts + * await Noodl.Records.save(myRecord, null, { + * acl: { + * // "*" means everyone, this rules gives everyone read access but not write + * "*": { read: true, write: false }, + * // give a specific user write access + * "a-user-id": { read: true, write: true }, + * // give a specific role write access + * "role:a-role-name": { read: true, write: true }, + * } + * }) + * ``` + */ + increment( + objectOrId: string | { getId(): string; }, + properties: any, + options?: { + className?: RecordClassName; + } + ): Promise; + + /** + * This function will create a new record in the cloud database and return + * the Noodl.Object of the newly created record. + * If it's unsuccessful it will throw an exception. + * + * Example: + * ```ts + * const myNewRecord = await Noodl.Records.create("myClass",{ + * SomeProperty:"Hello" + * }) + * + * console.log(myNewRecord.SomeProperty) + * ``` + * + * You can use the options agrument to specify access control rules + * as detailed under Noodl.Records.save above. + */ + create( + className: RecordClassName, + properties: any, + options?: { + acl?: any + } + ): Promise; + + /** + * Use this function to delete an existing record from the cloud database. + * + * Example: + * ```ts + * // If you specify the id of a record to be deleted, you must also provide the + * // class name in the options + * await Noodl.Records.delete(myRecordId,{className:"myClass"}) + * + * // Or use the object directly (provided it was previously fetched or received via a query) + * await Noodl.Records.delete(Noodl.Objects[myRecordId]) + * ``` + */ + delete( + objectOrId: string | { getId(): string; }, + options?: { + className?: RecordClassName; + } + ): Promise; + + /** + * Use this function to add a relation between two records. + * + * Example: + * ```ts + * // You can either specify the Ids and classes directly + * await Noodl.Records.addRelation({ + * className: "myClass", + * recordId: "owning-record-id", + * key: "the-relation-key-on-the-owning-record", + * targetRecordId: "the-id-of-the-record-to-add-a-relation-to", + * targetClassName: "the-class-of-the-target-record" + * }) + * + * // Or if you already have two records that have been previously fetched or returned from a + * // query + * await Noodl.Records.addRelation({ + * record: myRecord, + * key: 'relation-key', + * targetRecord: theTargetRecord + * }) + * ``` + */ + addRelation( + options: { + recordId: string | { getId(): string; }, + className?: RecordClassName, + key: string, + targetRecordId: string | { getId(): string; }, + targetClassName?: RecordClassName + } + ): Promise; + + /** + * Use this function to remove a relation between two records. + * + * ```ts + * // You can either specify the Ids and classes directly + * await Noodl.Records.removeRelation({ + * className: "myClass", + * recordId: "owning-record-id", + * key: "the-relation-key-on-the-owning-record", + * targetRecordId: "the-id-of-the-record-to-remove-a-relation-to", + * targetClassName: "the-class-of-the-target-record" + * }) + * + * // Or if you already have two records that have been previously fetched or returned from a + * // query + * await Noodl.Records.removeRelation({ + * record: myRecord, + * key: 'relation-key', + * targetRecord: theTargetRecord + * }) + * ``` + */ + removeRelation( + options: { + recordId: string | { getId(): string; }, + className?: RecordClassName, + key: string, + targetRecordId: string | { getId(): string; }, + targetClassName?: RecordClassName + } + ): Promise; + + + /** + * compute a set of aggregates based on properties in the records. + * It can be limited with a query. + * + * You can use the following aggregate functions: + * - sum Compute the sum of a number property access matching records. + * - min Compute the minimum value of a number property access matching records. + * - max Compute the maximum value of a number property access matching records. + * - avg Compute the average value of a number property access matching records. + */ + aggregate( + className: RecordClassName, + aggregates: any, + query: any + ): Promise; + } + + /** + * With Records you can query, read and write records to the cloud database. + * All functions are async and will throw an exception if they fail. + * + * Example: + * ```ts + * try { + * await Noodl.Records.delete(myRecord) + * } + * catch(e) { + * console.log(e) + * } + * ``` + * + * {@link https://docs.noodl.net/#/javascript/reference/records} + */ + const Records: RecordsApi; + + interface CurrentUserObject { + UserId: string; + + // TODO: Fill in the User Record here. + Properties: Record; + + /** + * Attempt to save the properties of the current user. + * + * If you have made changes to the current() user object you will need + * to call this function to write the changes to the backend. + */ + save(): Promise; + + /** + * Fetch that laters properties of the user object from the cloud database. + * It will throw an exception if the user session has expired. + */ + fetch(): Promise; + } + + interface UsersApi { + /** + * Attempt to login to create a user session. + * + * After a successful login you can access the user object with `Noodl.Users.Current`. + */ + logIn(options: { username: string; password: string }): Promise; + + /** + * Get a session token for a user that you can later send to the client to log that user in. + * This does not require a password and must be runon a cloud function + * (since they all have full access to the database). + * + * You can provide a duration for the session, + * or it will expire after 24 hours as default. + * + * If successful this call will return a user object that contains a session token + * that you can return to the client and use with the become function. + * + * __installationId__ is an optional that is a unique id for the client if you don't want + * to share sessions between different clients. Most common is to generate a random id + * on the client and pass to the cloud function when you are logging in. + */ + impersonate(username: string, options?: { duration?: number, installationID?: string }): Promise; + + /** + * Return the current user object and properties if one exists. + */ + get Current(): CurrentUserObject | undefined; + } + + /** + * The Noodl.Users object let's you access the current session user. + * + * {@link https://docs.noodl.net/#/javascript/reference/users} + */ + const Users: UsersApi; + + interface FilesApi { + /** + * Delete a file that has been uploaded to the backend. + * You need to provide the file name that was returned when the file was uploaded. + * So not the full url but the hash+filename returned by the upload function. + */ + delete(filename: string): Promise; + } + + /** + * The Noodl.Files service lets you access the cloud services files. + * + * {@link https://docs.noodl.net/#/javascript/reference/files} + */ + const Files: FilesApi; +} + +interface ComponentApi { + /** + * `Component.Object` is the Component Object of the current component and + * you can use it just like any other Noodl.Object. + * Most commonly this means accessing the properties of the object. + * When you set a property any Component Object node in this component + * instance will update accordingly. + */ + Object: any; + + /** + * Object is the Parent Component Object, + * that is the Component Object of the parent component in the visual heirarchy. + * It is also used like any other Noodl.Object. + */ + ParentObject: any; + + /** + * If this component is the template of a repeater this will contain + * the object of the items array corresponding to this specific component instance. + * That is the same object as if you set an object Id Source to From Repeater, as shown below. + */ + RepeaterObject: any; +} + +/** + * The `Component` object is ony available in Function and Script nodes and + * it contains things related to the component scope where the + * Function or Script node is executing. + * + * {@link https://docs.noodl.net/#/javascript/reference/component} + */ +declare const Component: ComponentApi; diff --git a/packages/noodl-editor/src/external/cloudruntime/index.html b/packages/noodl-editor/src/external/cloudruntime/index.html new file mode 100644 index 0000000..0528484 --- /dev/null +++ b/packages/noodl-editor/src/external/cloudruntime/index.html @@ -0,0 +1,9 @@ + + + + + Noodl Editor Cloud Runtime + + + + \ No newline at end of file diff --git a/packages/noodl-editor/src/external/cloudruntime/manifest.json b/packages/noodl-editor/src/external/cloudruntime/manifest.json new file mode 100644 index 0000000..e8fd4fc --- /dev/null +++ b/packages/noodl-editor/src/external/cloudruntime/manifest.json @@ -0,0 +1 @@ +{"version":"cloud-runtime-0-6-3"} \ No newline at end of file diff --git a/packages/noodl-editor/src/external/cloudruntime/sandbox.viewer.bundle.js b/packages/noodl-editor/src/external/cloudruntime/sandbox.viewer.bundle.js new file mode 100644 index 0000000..f58c724 --- /dev/null +++ b/packages/noodl-editor/src/external/cloudruntime/sandbox.viewer.bundle.js @@ -0,0 +1,2 @@ +const{ipcRenderer}=require("electron"),_noodl_cloud_runtime_version="cloud-runtime-0-6-3";(()=>{var __webpack_modules__={2806:(e,t,n)=>{var o="__lodash_hash_undefined__",i=9007199254740991,s="[object Arguments]",r="[object Function]",a="[object GeneratorFunction]",u=/^\[object .+?Constructor\]$/,c="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,l="object"==typeof self&&self&&self.Object===Object&&self,d=c||l||Function("return this")();function p(e,t){return!(!e||!e.length)&&function(e,t,n){if(t!=t)return function(e,t,n,o){for(var i=e.length,s=-1;++s-1}function h(e,t,n){for(var o=-1,i=e?e.length:0;++o0&&n(a)?t>1?U(a,t-1,n,o,i):m(i,a):o||(i[i.length]=a)}return i}function W(e,t){var n,o,i=e.__data__;return("string"==(o=typeof(n=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function L(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return function(e){if(!K(e)||C&&C in e)return!1;var t=B(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?w:u;return t.test(function(e){if(null!=e){try{return O.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}(n)?n:void 0}function q(e){return H(e)||function(e){return z(e)&&N.call(e,"callee")&&(!E.call(e,"callee")||S.call(e)==s)}(e)||!!(T&&e&&e[T])}F.prototype.clear=function(){this.__data__=j?j(null):{}},F.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},F.prototype.get=function(e){var t=this.__data__;if(j){var n=t[e];return n===o?void 0:n}return N.call(t,e)?t[e]:void 0},F.prototype.has=function(e){var t=this.__data__;return j?void 0!==t[e]:N.call(t,e)},F.prototype.set=function(e,t){return this.__data__[e]=j&&void 0===t?o:t,this},M.prototype.clear=function(){this.__data__=[]},M.prototype.delete=function(e){var t=this.__data__,n=k(t,e);return!(n<0||(n==t.length-1?t.pop():x.call(t,n,1),0))},M.prototype.get=function(e){var t=this.__data__,n=k(t,e);return n<0?void 0:t[n][1]},M.prototype.has=function(e){return k(this.__data__,e)>-1},M.prototype.set=function(e,t){var n=this.__data__,o=k(n,e);return o<0?n.push([e,t]):n[o][1]=t,this},A.prototype.clear=function(){this.__data__={hash:new F,map:new(R||M),string:new F}},A.prototype.delete=function(e){return W(this,e).delete(e)},A.prototype.get=function(e){return W(this,e).get(e)},A.prototype.has=function(e){return W(this,e).has(e)},A.prototype.set=function(e,t){return W(this,e).set(e,t),this},V.prototype.add=V.prototype.push=function(e){return this.__data__.set(e,o),this},V.prototype.has=function(e){return this.__data__.has(e)};var G,$,J=(G=function(e,t){return z(e)?function(e,t,n,o){var i,s=-1,r=p,a=!0,u=e.length,c=[],l=t.length;if(!u)return c;n&&(t=function(e,t){for(var n=-1,o=e?e.length:0,i=Array(o);++n=200&&(r=g,a=!1,t=new V(t));e:for(;++s-1&&e%1==0&&e<=i}(e.length)&&!B(e)}(e)}function B(e){var t=K(e)?S.call(e):"";return t==r||t==a}function K(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=J},1920:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudRunner=void 0;const i=n(1565),s=o(n(3948)),r=o(n(3839)),a=o(n(61));n(4067),n(8715),t.CloudRunner=class{constructor(e){this.runtime=new s.default({type:"cloud",platform:{requestUpdate:e=>setImmediate(e),getCurrentTime:()=>(new Date).getTime(),objectToString:e=>JSON.stringify(e,null,2),webSocketClass:e.webSocketClass,isRunningLocally:()=>e.connectToEditor},componentFilter:e=>e.name.startsWith("/#__cloud__/"),dontCreateRootComponent:!0}),(0,i.registerNodes)(this.runtime),this.runtime.setDebugInspectorsEnabled(e.enableDebugInspectors),e.connectToEditor&&e.editorAddress&&this.runtime.connectToEditor(e.editorAddress)}async load(e,t){await this.runtime.setData(e),t&&this.runtime.setProjectSettings(t)}async run(e,t){return new Promise(((n,o)=>{const i=Math.random().toString(26).slice(2),s=new a.default(this.runtime.context);s.modelScope=new r.default.Scope,this.runtime.context.createComponentInstanceNode("/#__cloud__/"+e,i+"-"+e,s).then((e=>{const i=e.nodeScope.getNodesWithType("noodl.cloud.request")[0];if(i){let r=!1;e.nodeScope.getNodesWithTypeRecursive("noodl.cloud.response").forEach((t=>{t._internal._sendResponseCallback=t=>{r||(r=!0,e._onNodeDeleted(),s.reset(),s.modelScope.reset(),n(t))}})),setImmediate((()=>{try{i.sendRequest(t).catch(o)}catch(e){o(e)}}))}else o(Error("Could not find request node for function"))})).catch((e=>{o(e)}))}))}}},1450:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setup=t.node=void 0;const i=o(n(3839)),s=o(n(3948)),r=o(n(1458));t.node={name:"noodl.cloud.request",displayNodeName:"Request",category:"Cloud",docs:"https://docs.noodl.net/nodes/cloud-functions/request",useVariants:!1,mountedInput:!1,allowAsExportRoot:!1,singleton:!0,color:"data",connectionPanel:{groupPriority:["General","Mounted"]},outputs:{receive:{displayName:"Received",type:"signal",group:"General"},auth:{displayName:"Authenticated",type:"boolean",group:"Request",getter:function(){return!!this._internal.authenticated}},userId:{displayName:"User Id",type:"boolean",group:"Request",getter:function(){return this._internal.authUserId}}},inputs:{allowNoAuth:{group:"General",type:"boolean",displayName:"Allow Unauthenticated",default:!1,set:function(e){this._internal.allowNoAuth=e}},params:{group:"Parameters",type:{name:"stringlist",allowEditOnly:!0},set:function(e){this._internal.params=e}}},initialize:function(){this._internal.allowNoAuth=!1,this._internal.requestParameters={},this._internal.userProperties={Authenticated:!1}},methods:{getRequestParameter:function(e){return this._internal.requestParameters[e]},setRequestParameter:function(e,t){this._internal.requestParameters[e]=t,this.hasOutput("pm-"+e)&&this.flagOutputDirty("pm-"+e)},fetchCurrentUser:async function(e){return new Promise(((t,n)=>{s.default.Services.UserService.forScope(this.nodeScope.modelScope).fetchCurrentUser({sessionToken:e,success:t,error:n})}))},sendRequest:async function(e){const t=e.headers["x-parse-session-token"];let n={};try{n=JSON.parse(e.body)}catch(e){}if(t)try{await this.fetchCurrentUser(t);const e=s.default.Services.UserService.forScope(this.nodeScope.modelScope).current;this._internal.authenticated=!0,this._internal.authUserId=e.getId(),this.flagOutputDirty("userId")}catch(e){if(!this._internal.allowNoAuth)throw Error("Unauthenticated requests not accepted.")}else if(!this._internal.allowNoAuth)throw Error("Unauthenticated requests not accepted.");await r.default.instance.getConfig();const o=(this.nodeScope.modelScope||i.default).get("Request");o.set("Authenticated",!!this._internal.authenticated),o.set("UserId",this._internal.authUserId),o.set("Parameters",n),o.set("Headers",e.headers),this.flagOutputDirty("auth");for(let e in n)this.setRequestParameter(e,n[e]);this.sendSignalOnOutput("receive")},registerOutputIfNeeded:function(e){this.hasOutput(e)||e.startsWith("pm-")&&this.registerOutput(e,{getter:this.getRequestParameter.bind(this,e.substring(3))})}}},t.setup=function(e,t){function n(t){function n(){var n=[],o=t.parameters.params;if(void 0!==o)for(var i in o=o.split(",")){var s=o[i];n.push({type:"*",plug:"output",group:"Parameters",name:"pm-"+s,displayName:s})}e.editorConnection.sendDynamicPorts(t.id,n)}n(),t.on("parameterUpdated",(function(e){"params"===e.name&&n()}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.noodl.cloud.request",(function(e){n(e)}));for(const e of t.getNodesWithType("noodl.cloud.request"))n(e)}))}},5275:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setup=t.node=void 0,t.node={name:"noodl.cloud.response",displayNodeName:"Response",category:"Cloud",docs:"https://docs.noodl.net/nodes/cloud-functions/response",useVariants:!1,mountedInput:!1,allowAsExportRoot:!1,color:"data",connectionPanel:{groupPriority:["General","Mounted"]},dynamicports:[{name:"conditionalports/extended",condition:"status = success OR status NOT SET",inputs:["params"]},{name:"conditionalports/extended",condition:"status = failure",inputs:["errorMessage"]}],initialize:function(){this._internal.responseParameters={}},inputs:{params:{group:"Parameters",type:{name:"stringlist",allowEditOnly:!0},set:function(e){this._internal.params=e}},errorMessage:{group:"General",type:"string",displayName:"Error Message",set:function(e){this._internal.errorMessage=e}},send:{displayName:"Send",type:"signal",group:"General",valueChangedToTrue:function(){void 0===this._internal.status||"success"===this._internal.status?this._internal._sendResponseCallback({statusCode:200,body:JSON.stringify({result:this._internal.responseParameters})}):this._internal._sendResponseCallback({statusCode:400,body:JSON.stringify({error:this._internal.errorMessage})})}},status:{group:"General",displayName:"Status",type:{name:"enum",enums:[{label:"Success",value:"success"},{label:"Failure",value:"failure"}]},default:"success",set:function(e){this._internal.status=e}}},methods:{setResponseParameter:function(e,t){this._internal.responseParameters[e]=t},registerInputIfNeeded:function(e){this.hasInput(e)||e.startsWith("pm-")&&this.registerInput(e,{set:this.setResponseParameter.bind(this,e.substring(3))})}}},t.setup=function(e,t){function n(t){function n(){var n=[];if("success"===t.parameters.status||void 0===t.parameters.status){var o=t.parameters.params;if(void 0!==o)for(var i in o=o.split(",")){var s=o[i];n.push({type:"*",plug:"input",group:"Parameters",name:"pm-"+s,displayName:s})}}e.editorConnection.sendDynamicPorts(t.id,n)}n(),t.on("parameterUpdated",(function(e){"params"===e.name&&n()}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.noodl.cloud.response",(function(e){n(e)}));for(const e of t.getNodesWithType("noodl.cloud.response"))n(e)}))}},1565:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.registerNodes=void 0,t.registerNodes=function(e){[n(1450),n(5275),n(6011)].forEach((function(t){e.registerNode(t)}))}},3948:(e,t,n)=>{"use strict";const o=n(480),i=n(3278),s=n(511),r=n(4190),a=n(9397),u=n(3157),c=n(2487),l=n(6416),d=n(3855),p=n(6607),h=n(5627),m=n(7701);function f(e){if((e=e||{}).platform=e.platform||{},f.instance=this,this.type=e.type||"browser",this.noodlModules=[],this.eventEmitter=new h,this.updateScheduled=!1,this.rootComponent=null,this._currentLoadedData=null,this.isWaitingForExport=!0,this.graphModel=new a,this.errorHandlers=[],this.frameNumber=0,this.dontCreateRootComponent=!!e.dontCreateRootComponent,this.componentFilter=e.componentFilter,this.runningInEditor=!e.runDeployed,this.platform={requestUpdate:e.platform.requestUpdate,getCurrentTime:e.platform.getCurrentTime,webSocketOptions:e.platform.webSocketOptions,objectToString:e.platform.objectToString},!e.platform.requestUpdate)throw new Error("platform.requestUpdate must be set");if(!e.platform.getCurrentTime)throw new Error("platform.getCurrentTime must be set");var t;this.editorConnection=new i({platform:e.platform,runtimeType:this.type}),this.context=new o({runningInEditor:!e.runDeployed,editorConnection:this.editorConnection,platform:this.platform,graphModel:this.graphModel}),this.context.eventEmitter.on("scheduleUpdate",this.scheduleUpdate.bind(this)),e.runDeployed||this._setupEditorCommunication(e),this.registerGraphModelListeners(),t=this,[n(8197),n(1208),n(3734),n(6430),n(8675),n(9222),n(3690),n(9),n(6280),n(8865),n(4763),n(3421),n(1421),n(5962),n(5271),n(2474),n(9780),n(8022),n(6204),n(7383),n(4950),n(3033),n(1665),n(3113),n(6307),n(5010),n(8911),n(461),n(7820),n(2283),n(5533),n(3843),n(6969),n(7425),n(6736)].forEach((e=>t.registerNode(e)))}f.prototype.prefetchBundles=async function(e,t){await m(t,e,(async e=>{await this.context.fetchComponentBundle(e)}))},f.prototype._setupEditorCommunication=function(e){function t(e,n){if(null==e||null==n)return e===n;if(e===n)return!0;if(Array.isArray(e)&&e.length!==n.length)return!1;if(!(e instanceof Object))return!1;if(!(n instanceof Object))return!1;var o=Object.keys(e);return Object.keys(n).every((function(e){return-1!==o.indexOf(e)}))&&o.every((function(o){return t(e[o],n[o])}))}this.editorConnection.on("exportDataFull",(async e=>{if(!1!==this.graphModel.isEmpty()){if(this.isWaitingForExport=!1,!1===t(this._currentLoadedData,e)){if(this.componentFilter&&(e.components=e.components.filter((e=>this.componentFilter(e)))),await this.setData(e),e.componentIndex){const t=Object.keys(e.componentIndex);await this.prefetchBundles(t,2)}this.graphModel.emit("editorImportComplete")}}else this.reload()})),this.editorConnection.on("reload",this.reload.bind(this)),this.editorConnection.on("modelUpdate",this.onModelUpdateReceived.bind(this)),this.editorConnection.on("metadataUpdate",this.onMetaDataUpdateReceived.bind(this)),this.editorConnection.on("connected",(()=>{this.sendNodeLibrary()}))},f.prototype.setDebugInspectorsEnabled=function(e){this.context.setDebugInspectorsEnabled(e)},f.prototype.registerModule=function(e){if(e.nodes)for(let t of e.nodes)t.node||(t={node:t}),t.node.module=e.name||"Unknown Module",this.registerNode(t);this.noodlModules.push(e)},f.prototype.registerGraphModelListeners=function(){var e=this;this.graphModel.on("componentAdded",(function(t){e.context.registerComponentModel(t)}),this),this.graphModel.on("componentRemoved",(function(t){e.context.deregisterComponentModel(t)}),this)},f.prototype.reload=function(){location.reload()},f.prototype.registerNode=function(e){if(e.node){const t=u.defineNode(e.node);this.context.nodeRegister.register(t),t.setupNumberedInputDynamicPorts&&t.setupNumberedInputDynamicPorts(this.context,this.graphModel)}else this.context.nodeRegister.register(e);e.setup&&e.setup(this.context,this.graphModel)},f.prototype._setRootComponent=async function(e){this.rootComponent&&this.rootComponent.name===e||(this.rootComponent&&(this.rootComponent.model&&this.rootComponent.model.removeListenersWithRef(this),this.rootComponent=void 0),e&&(this.rootComponent=await this.context.createComponentInstanceNode(e,"rootComponent"),this.rootComponent.componentModel.on("rootAdded",(()=>this.eventEmitter.emit("rootComponentUpdated")),this),this.rootComponent.componentModel.on("rootRemoved",(()=>this.eventEmitter.emit("rootComponentUpdated")),this),this.context.setRootComponent(this.rootComponent)),this.eventEmitter.emit("rootComponentUpdated"))},f.prototype.setData=async function(e){if(!this._disableLoad){this._currentLoadedData=e,await this.graphModel.importEditorData(e);for(const e of this.noodlModules)"function"==typeof e.setup&&e.setup.apply(e);!0!==this.dontCreateRootComponent&&(await this._setRootComponent(this.graphModel.rootComponent),this.graphModel.on("rootComponentNameUpdated",(e=>{this._setRootComponent(e)})),this.graphModel.on("componentRemoved",(e=>{this.rootComponent&&this.rootComponent.name===e.name&&this._setRootComponent(null)})),this.graphModel.on("componentAdded",(e=>{setTimeout((()=>{this.rootComponent||this.graphModel.rootComponent!==e.name||this._setRootComponent(e.name)}),1)}))),this.scheduleUpdate()}},f.prototype.scheduleUpdate=function(){this.updateScheduled||(this.updateScheduled=!0,this.platform.requestUpdate(f.prototype._doUpdate.bind(this)))},f.prototype._doUpdate=function(){this.updateScheduled=!1,this.context.currentFrameTime=this.platform.getCurrentTime(),this.context.eventEmitter.emit("frameStart"),this.context.update(),this.context.eventEmitter.emit("frameEnd"),this.frameNumber++},f.prototype.setProjectSettings=function(e){this.projectSettings=e},f.prototype.getNodeLibrary=function(){var e=r.generateProjectSettings(this.graphModel.getSettings(),this.noodlModules);this.projectSettings&&(this.projectSettings.ports&&(e.ports=e.ports.concat(this.projectSettings.ports)),this.projectSettings.dynamicports&&(e.dynamicports=e.ports.concat(this.projectSettings.dynamicports)));var t=s(this.context.nodeRegister);return t.projectsettings=e,JSON.stringify(t,null,3)},f.prototype.sendNodeLibrary=function(){const e=this.getNodeLibrary();this.lastSentNodeLibrary!==e&&(this.lastSentNodeLibrary=e,this.editorConnection.sendNodeLibrary(e))},f.prototype.connectToEditor=function(e){this.editorConnection.connect(e)},f.prototype.onMetaDataUpdateReceived=function(e){this.graphModel.isEmpty()||EditorMetaDataEventsHandler.handleEvent(this.context,this.graphModel,e)},f.prototype.onModelUpdateReceived=async function(e){this.isWaitingForExport||("projectInstanceChanged"===e.type?this.reload():!1===this.graphModel.isEmpty()&&await l.handleEvent(this.context,this.graphModel,e))},f.prototype.addErrorHandler=function(e){this.errorHandlers.push(e)},f.prototype.reportError=function(e){this.errorHandlers.forEach((function(t){t(e)}))},f.prototype.getProjectSettings=function(){return this.graphModel.getSettings()},f.prototype.getMetaData=function(e){return this.graphModel.getMetaData(e)},f.Services=d,f.Node=c,f.NodeDefinition=u,f.EdgeTriggeredInput=p,e.exports=f},4497:e=>{e.exports=class{constructor({name:e,url:t}){this.name=e,this.url=t}getUrl(){return this.url}getName(){return this.name}toString(){return this.url}}},4007:(e,t,n)=>{const o=n(3948),i=n(3839),s=n(9160),r=n(4497),a=n(5627),u={_common:["_createdAt","_updatedAt","objectId"],_User:["_email_verify_token"]};function c(e,t){const n=Object.assign({},e);return u._common.forEach((e=>delete n[e])),t&&u[t]&&u[t].forEach((e=>delete n[e])),n}class l{constructor(e){this._initCloudServices(),this.events=new a,this.events.setMaxListeners(1e4),this.modelScope=e,this._fromJSON=(t,n)=>l._fromJSON(t,n,e),this._deserializeJSON=(t,n)=>l._deserializeJSON(t,n,e),this._serializeObject=(t,n)=>l._serializeObject(t,n,e)}_initCloudServices(){g=void 0;const e=o.instance.getMetaData("cloudservices");e&&(this.appId=e.appId,this.endpoint=e.endpoint);const t=o.instance.getMetaData("dbVersionMajor");this.dbVersionMajor=t}on(){this.events.on.apply(this.events,arguments)}off(){this.events.off.apply(this.events,arguments)}_makeRequest(e,t){if(void 0===_noodl_cloud_runtime_version){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState){var e;try{e=JSON.parse(n.response||n.responseText)}catch(e){}200===n.status||201===n.status?t.success(e):t.error(e||{error:n.responseText,status:n.status})}},n.open(t.method||"GET",this.endpoint+e,!0),n.setRequestHeader("X-Parse-Application-Id",this.appId),"undefined"!=typeof _noodl_cloudservices&&n.setRequestHeader("X-Parse-Master-Key",_noodl_cloudservices.masterKey);var o=localStorage["Parse/"+this.appId+"/currentUser"];if(void 0!==o)try{const e=JSON.parse(o);n.setRequestHeader("X-Parse-Session-Token",e.sessionToken)}catch(e){}t.onUploadProgress&&(n.upload.onprogress=e=>t.onUploadProgress(e)),t.content instanceof File?n.send(t.content):(n.setRequestHeader("Content-Type","application/json"),n.send(JSON.stringify(t.content)))}else{const n="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.endpoint:this.endpoint,o="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.appId:this.appId,i="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.masterKey:void 0;fetch(n+e,{method:t.method||"GET",headers:{"X-Parse-Application-Id":o,"X-Parse-Master-Key":i,"Content-Type":"application/json"},body:JSON.stringify(t.content)}).then((e=>{200===e.status||201===e.status?"DELETE"===t.method?t.success(void 0):e.json().then((e=>t.success(e))).catch((e=>t.error({error:"CloudStore: Failed to get json result."}))):"DELETE"===t.method?t.error({error:"Failed to delete."}):e.json().then((e=>t.error(e))).catch((e=>t.error({error:"Failed to fetch."})))})).catch((e=>{t.error({error:e.message})}))}}query(e){this._makeRequest("/classes/"+e.collection,{method:"POST",content:{_method:"GET",where:e.where,limit:e.limit,skip:e.skip,include:Array.isArray(e.include)?e.include.join(","):e.include,keys:Array.isArray(e.select)?e.select.join(","):e.select,order:Array.isArray(e.sort)?e.sort.join(","):e.sort,count:e.count},success:function(t){e.success(t.results,t.count)},error:function(){e.error()}})}aggregate(e){const t=[];if(!e.group)return void e.error("You need to provide group option.");e.limit&&t.push("limit="+e.limit),e.skip&&t.push("skip="+e.skip);const n={};Object.keys(e.group).forEach((t=>{const o={},i=e.group[t];void 0!==i.avg?o.$avg="$"+i.avg:void 0!==i.sum?o.$sum="$"+i.sum:void 0!==i.max?o.$max="$"+i.max:void 0!==i.min?o.$min="$"+i.min:void 0!==i.distinct&&(o.$addToSet="$"+i.distinct),n[t]=o})),this.dbVersionMajor&&this.dbVersionMajor>4?(n._id=null,e.where&&t.push("$match="+encodeURIComponent(JSON.stringify(e.where))),t.push("$group="+JSON.stringify(n))):(n.objectId=null,e.where&&t.push("match="+encodeURIComponent(JSON.stringify(e.where))),t.push("group="+JSON.stringify(n))),this._makeRequest("/aggregate/"+e.collection+(t.length>0?"?"+t.join("&"):""),{success:function(t){const n={};t.results&&1===t.results.length?(Object.keys(e.group).forEach((e=>{n[e]=t.results[0][e]})),e.success(n)):e.success({})},error:function(){e.error()}})}count(e){const t=[];e.where&&t.push("where="+encodeURIComponent(JSON.stringify(e.where))),t.push("limit=0"),t.push("count=1"),this._makeRequest("/classes/"+e.collection+(t.length>0?"?"+t.join("&"):""),{success:function(t){e.success(t.count)},error:function(){e.error()}})}distinct(e){const t=[];e.where&&t.push("where="+encodeURIComponent(JSON.stringify(e.where))),t.push("distinct="+e.property),this._makeRequest("/aggregate/"+e.collection+(t.length>0?"?"+t.join("&"):""),{success:function(t){e.success(t.results)},error:function(){e.error()}})}fetch(e){const t=[];e.include&&t.push("include="+(Array.isArray(e.include)?e.include.join(","):e.include)),e.keys&&t.push("keys="+(Array.isArray(e.keys)?e.keys.join(","):e.keys)),e.excludeKeys&&t.push("excludeKeys="+(Array.isArray(e.excludeKeys)?e.excludeKeys.join(","):e.excludeKeys)),this._makeRequest("/classes/"+e.collection+"/"+e.objectId+(t.length>0?"?"+t.join("&"):""),{method:"GET",success:t=>{e.success(t),this.events.emit("fetch",{type:"fetch",objectId:e.objectId,object:t,collection:e.collection})},error:function(t){e.error(t.error)}})}create(e){this._makeRequest("/classes/"+e.collection,{method:"POST",content:Object.assign(c(p(e.data,e.collection),e.collection),{ACL:e.acl}),success:t=>{const n=Object.assign({},e.data,t);e.success(n),this.events.emit("create",{type:"create",objectId:e.objectId,object:n,collection:e.collection})},error:function(t){e.error(t.error)}})}increment(e){const t={};for(let n in e.properties)t[n]={__op:"Increment",amount:e.properties[n]};this._makeRequest("/classes/"+e.collection+"/"+e.objectId,{method:"PUT",content:t,success:t=>{e.success(t)},error:function(t){e.error(t.error)}})}save(e){const t=Object.assign({},e.data);delete t.createdAt,delete t.updatedAt,this._makeRequest("/classes/"+e.collection+"/"+e.objectId,{method:"PUT",content:Object.assign(c(p(t,e.collection),e.collection),{ACL:e.acl}),success:t=>{e.success(t),this.events.emit("save",{type:"save",objectId:e.objectId,object:Object.assign({},e.data,t),collection:e.collection})},error:function(t){e.error(t.error)}})}delete(e){this._makeRequest("/classes/"+e.collection+"/"+e.objectId,{method:"DELETE",success:()=>{e.success(),this.events.emit("delete",{type:"delete",objectId:e.objectId,collection:e.collection})},error:function(t){e.error(t.error)}})}addRelation(e){const t={};t[e.key]={__op:"AddRelation",objects:[{__type:"Pointer",objectId:e.targetObjectId,className:e.targetClass}]},this._makeRequest("/classes/"+e.collection+"/"+e.objectId,{method:"PUT",content:t,success:function(t){e.success(t)},error:function(t){e.error(t.error)}})}removeRelation(e){const t={};t[e.key]={__op:"RemoveRelation",objects:[{__type:"Pointer",objectId:e.targetObjectId,className:e.targetClass}]},this._makeRequest("/classes/"+e.collection+"/"+e.objectId,{method:"PUT",content:t,success:function(t){e.success(t)},error:function(t){e.error(t.error)}})}uploadFile(e){this._makeRequest("/files/"+e.file.name,{method:"POST",content:e.file,contentType:e.file.type,success:t=>e.success(Object.assign({},e.data,t)),error:t=>e.error(t),onUploadProgress:e.onUploadProgress})}deleteFile(e){this._makeRequest("/files/"+e.file.name,{method:"DELETE",success:t=>e.success(Object.assign({},e.data,t)),error:t=>e.error(t)})}}function d(e){if(e instanceof i){var t={};for(var n in e.data)t[n]=d(e.data[n]);return t}return e instanceof s?(t=[],e.items.forEach((e=>{t.push(d(e))})),t):e}function p(e,t,n){if(l._collections[t])var o=l._collections[t].schema;for(var a in e){var u=o&&o.properties&&o.properties[a]?o.properties[a].type:void 0;if(void 0===e[a]||null===e[a]);else if("Pointer"===u&&"string"==typeof e[a])e[a]={__type:"Pointer",className:o.properties[a].targetClass,objectId:e[a]};else if("Pointer"===u&&"object"==typeof e[a]&&(n||i).instanceOf(e[a]))e[a]={__type:"Pointer",className:o.properties[a].targetClass,objectId:e[a].getId()};else if("Date"===u&&("string"==typeof e[a]||e[a]instanceof Date))e[a]={__type:"Date",iso:e[a]instanceof Date?e[a].toISOString():e[a]};else if("File"===u&&e[a]instanceof r){const t=e[a];e[a]={__type:"File",url:t.getUrl(),name:t.getName()}}else"Array"===u&&"string"==typeof e[a]&&s.exists(e[a])?e[a]=d(s.get(e[a])):"Object"===u&&"string"==typeof e[a]&&(n||i).exists(e[a])?e[a]=d((n||i).get(e[a])):"GeoPoint"===u&&"object"==typeof e[a]?e[a]={__type:"GeoPoint",latitude:Number(e[a].latitude),longitude:Number(e[a].longitude)}:e[a]=d(e[a])}return e}function h(e,t,n){if(void 0!==e){if(null===e)return null;if("Relation"!==t||"Relation"!==e.__type){if("Pointer"===t&&"Pointer"===e.__type)return e.objectId;if("Date"===t&&"Date"===e.__type)return new Date(e.iso);if("Date"===t&&"string"==typeof e)return new Date(e);if("File"===t&&"File"===e.__type)return new r(e);if("GeoPoint"===t&&"GeoPoint"===e.__type)return{latitude:e.latitude,longitude:e.longitude};if(function(e){if(!Array.isArray(e))return!1;for(var t=0;tvoid 0===e?l.instance:(e._cloudStore||(e._cloudStore=new l(e)),e._cloudStore),Object.defineProperty(l,"instance",{get:function(){return void 0===f&&(f=new l),f}}),Object.defineProperty(l,"_collections",{get:function(){return void 0===g&&(g={},(o.instance.getMetaData("dbCollections")||[]).forEach((e=>{g[e.name]=e})),(o.instance.getMetaData("systemCollections")||[]).forEach((e=>{g[e.name]=e}))),g}}),l.invalidateCollections=()=>{g=void 0},e.exports=l},1458:(e,t,n)=>{const o=n(3948);class i{constructor(){this.cacheDuration=9e5}_makeRequest(e,t){if(void 0===_noodl_cloud_runtime_version){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState){var e;try{e=JSON.parse(n.response)}catch(e){}200===n.status||201===n.status?t.success(e):t.error(e||{error:n.responseText,status:n.status})}};const i=o.instance.getMetaData("cloudservices"),s=i.appId,r=i.endpoint;n.open("GET",r+e,!0),n.setRequestHeader("X-Parse-Application-Id",s),n.send()}else{const n="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.endpoint:this.endpoint,o="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.appId:this.appId,i="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.masterKey:void 0;fetch(n+e,{method:"GET",headers:{"X-Parse-Application-Id":o,"X-Parse-Master-Key":i}}).then((e=>{200===e.status||201===e.status?e.json().then((e=>t.success(e))).catch((e=>t.error({error:"Config: Failed to get json result."}))):e.json().then((e=>t.error(e))).catch((e=>t.error({error:"Failed to fetch."})))})).catch((e=>{t.error({error:e.message})}))}}_getConfig(){return new Promise(((e,t)=>{this._makeRequest("/config",{success:t=>{e(t.params||{})},error:e=>{t(e)}})}))}async getConfig(){return this.configCachePending?this.configCachePending:this.configCache?(Date.now()>this.ttl&&this._getConfig().then((e=>{this.configCache=e,this.ttl=Date.now()+this.cacheDuration})),this.configCache):(this.configCachePending=this._getConfig(),this.configCache=await this.configCachePending,delete this.configCachePending,this.ttl=Date.now()+this.cacheDuration,this.configCache)}clearCache(){delete this.configCache}}i.instance=new i,e.exports=i},5802:(e,t,n)=>{const o=n(4007),i=n(3839);function s(e){return e instanceof Date&&"function"==typeof e.toISOString?{__type:"Date",iso:e.toISOString()}:e}e.exports={convertVisualFilter:function e(t,n){var i=n.queryParameters;if(void 0!==t.combinator&&void 0!==t.rules){if(0===t.rules.length)return;if(1===t.rules.length)return e(t.rules[0],n);{const o={},i="$"+t.combinator;return o[i]=[],t.rules.forEach((t=>{var s=e(t,n);void 0!==s&&o[i].push(s)})),o}}if("related to"===t.operator){if(void 0===(r=void 0!==t.input?i[t.input]:void 0))return;return{$relatedTo:{object:{__type:"Pointer",objectId:r,className:t.relatedTo},key:t.relationProperty}}}{const e={};var s,r=void 0!==t.input?i[t.input]:t.value;if("exist"===t.operator)return e[t.property]={$exists:!0},e;if("not exist"===t.operator)return e[t.property]={$exists:!1},e;if(void 0===r)return;if(o._collections[n.collectionName])var a=o._collections[n.collectionName].schema;return"Date"===(a&&a.properties&&a.properties[t.property]?a.properties[t.property].type:void 0)&&(r instanceof Date||(r=new Date(r.toString())),r={__type:"Date",iso:r.toISOString()}),"greater than"===t.operator?s={$gt:r}:"greater than or equal to"===t.operator?s={$gte:r}:"less than"===t.operator?s={$lt:r}:"less than or equal to"===t.operator?s={$lte:r}:"equal to"===t.operator?s={$eq:r}:"not equal to"===t.operator?s={$ne:r}:"points to"===t.operator?s={$eq:{__type:"Pointer",objectId:r,className:a&&a.properties&&a.properties[t.property]?a.properties[t.property].targetClass:void 0}}:"contain"===t.operator&&(s={$regex:r,$options:"i"}),e[t.property]=s,e}},compareObjects:function(e,t,n){for(var o=0;on.get(e))return-1;if(t.get(e)n.get(i))return 1;if(t.get(i){o&=e(t,n)})):void 0!==n.$or?(o=!1,n.$or.forEach((n=>{o|=e(t,n)}))):Object.keys(n).forEach((e=>{if("objectId"===e)void 0!==n[e].$eq?o&=t.getId()===n[e].$eq:void 0!==n[e].$in&&(o&=-1!==n[e].$in.indexOf(t.getId()));else if("$relatedTo"===e)o=!1;else{var i=t.get(e);void 0!==n[e].$eq&&"Pointer"===n[e].$eq.__type?o&=i===n[e].$eq.objectId:void 0!==n[e].$eq?o&=i==n[e].$eq:void 0!==n[e].$ne?o&=i!=n[e].$ne:void 0!==n[e].$lt?o&=in[e].$gt:void 0!==n[e].$gte?o&=i>=n[e].$gte:void 0!==n[e].$exists?o&=void 0!==i:void 0!==n[e].$in?o&=-1!==n[e].$in.indexOf(i):void 0!==n[e].$nin?o&=-1===n[e].$in.indexOf(i):void 0!==n[e].$regex&&(o&=new RegExp(n[e].$regex,n[e].$options).test(i))}})),o)},convertVisualSorting:function(e){return e.map((e=>("descending"===e.order?"-":"")+e.property))},convertFilterOp:function e(t,n){const r=Object.keys(t);if(0===r.length)return{};if(1!==r.length)return n.error("Filter must only have one key found "+r.join(","));const a={},u=r[0];if(void 0!==t.and&&Array.isArray(t.and))a.$and=t.and.map((t=>e(t,n)));else if(void 0!==t.or&&Array.isArray(t.or))a.$or=t.or.map((t=>e(t,n)));else if(void 0!==t.idEqualTo)a.objectId={$eq:t.idEqualTo};else if(void 0!==t.idContainedIn)a.objectId={$in:t.idContainedIn};else if(void 0!==t.relatedTo){const e=t.relatedTo.id;if(void 0===e)return n.error("Must provide id in relatedTo filter");const o=t.relatedTo.key;if(void 0===o)return n.error("Must provide key in relatedTo filter");const s=t.relatedTo.className||(n.modelScope||i).get(e)?._class;if(void 0===s)return n.error("Must preload the Pointer or include className");a.$relatedTo={object:{__type:"Pointer",objectId:e,className:s},key:o}}else if("object"==typeof t[u]){const e=t[u];if(void 0!==e.equalTo)a[u]={$eq:s(e.equalTo)};else if(void 0!==e.notEqualTo)a[u]={$ne:s(e.notEqualTo)};else if(void 0!==e.lessThan)a[u]={$lt:s(e.lessThan)};else if(void 0!==e.greaterThan)a[u]={$gt:s(e.greaterThan)};else if(void 0!==e.lessThanOrEqualTo)a[u]={$lte:s(e.lessThanOrEqualTo)};else if(void 0!==e.greaterThanOrEqualTo)a[u]={$gte:s(e.greaterThanOrEqualTo)};else if(void 0!==e.exists)a[u]={$exists:e.exists};else if(void 0!==e.containedIn)a[u]={$in:e.containedIn};else if(void 0!==e.notContainedIn)a[u]={$nin:e.notContainedIn};else if(void 0!==e.pointsTo){let t=null;o._collections[n.collectionName]&&(t=o._collections[n.collectionName].schema);const i=t&&t.properties&&t.properties[u]?t.properties[u].targetClass:void 0;"Relation"===(t&&t.properties&&t.properties[u]?t.properties[u].type:void 0)?a[u]={__type:"Pointer",objectId:e.pointsTo,className:i}:Array.isArray(e.pointsTo)?a[u]={$in:e.pointsTo.map((e=>({__type:"Pointer",objectId:e,className:i})))}:a[u]={$eq:{__type:"Pointer",objectId:e.pointsTo,className:i}}}else if(void 0!==e.matchesRegex)a[u]={$regex:e.matchesRegex,$options:e.options};else if(void 0!==e.text&&void 0!==e.text.search){var c=e.text.search;a[u]="string"==typeof c?{$text:{$search:{$term:c,$caseSensitive:!1}}}:{$text:{$search:{$term:c.term,$language:c.language,$caseSensitive:c.caseSensitive,$diacriticSensitive:c.diacriticSensitive}}}}else void 0!==e.nearSphere?(c=e.nearSphere,a[u]={$nearSphere:{__type:"GeoPoint",latitude:c.latitude,longitude:c.longitude},$maxDistanceInMiles:c.$maxDistanceInMiles,$maxDistanceInKilometers:c.maxDistanceInKilometers,$maxDistanceInRadians:c.maxDistanceInRadians}):void 0!==e.withinBox?(c=e.withinBox,a[u]={$within:{$box:c.map((e=>({__type:"GeoPoint",latitude:e.latitude,longitude:e.longitude})))}}):void 0!==e.withinPolygon&&(c=e.withinPolygon,a[u]={$geoWithin:{$polygon:c.map((e=>({__type:"GeoPoint",latitude:e.latitude,longitude:e.longitude})))}})}else n.error("Unrecognized filter keys "+r.join(","));return a}}},4552:(e,t,n)=>{const o=n(4007),i=n(5802),s=n(3839);e.exports=function(e){let t;const n=()=>(t||(t=new o(e)),t);return{async query(t,o,s){if(void 0===t)throw new Error("'className' is undefined");return new Promise(((r,a)=>{n().query({collection:t,where:i.convertFilterOp(o||{},{collectionName:t,error:e=>a(e),modelScope:e}),limit:s?s.limit:void 0,sort:s?s.sort:void 0,skip:s?s.skip:void 0,include:s?s.include:void 0,select:s?s.select:void 0,count:s?s.count:void 0,success:(e,o)=>{const i=e.map((e=>n()._fromJSON(e,t)));r(void 0!==o?{results:i,count:o}:i)},error:e=>{a(Error(e||"Failed to query."))}})}))},async count(t,o){if(void 0===t)throw new Error("'className' is undefined");return new Promise(((s,r)=>{n().count({collection:t,where:o?i.convertFilterOp(o||{},{collectionName:t,error:e=>r(e),modelScope:e}):void 0,success:e=>{s(e)},error:e=>{r(Error(e||"Failed to query."))}})}))},async distinct(t,o,s){if(void 0===t)throw new Error("'className' is undefined");return new Promise(((r,a)=>{n().distinct({collection:t,property:o,where:s?i.convertFilterOp(s||{},{collectionName:t,error:e=>a(e),modelScope:e}):void 0,success:e=>{r(e)},error:e=>{a(Error(e||"Failed to query."))}})}))},async aggregate(t,o,s){if(void 0===t)throw new Error("'className' is undefined");return new Promise(((r,a)=>{n().aggregate({collection:t,group:o,where:s?i.convertFilterOp(s||{},{collectionName:t,error:e=>a(e),modelScope:e}):void 0,success:e=>{r(e)},error:e=>{a(Error(e||"Failed to aggregate."))}})}))},async fetch(t,o){if(void 0===t)return Promise.reject(new Error("'objectOrId' is undefined."));"string"!=typeof t&&(t=t.getId());const i=(o?o.className:void 0)||(e||s).get(t)._class;return new Promise(((e,s)=>{if(!i)return s("No class name specified");n().fetch({collection:i,objectId:t,keys:o?.keys,include:o?.include,excludeKeys:o?.excludeKeys,success:function(t){const o=n()._fromJSON(t,i);e(o)},error:function(e){s(Error(e||"Failed to fetch."))}})}))},async increment(t,o,i){if(void 0===t)return Promise.reject(new Error("'objectOrId' is undefined."));"string"!=typeof t&&(t=t.getId());const r=(i?i.className:void 0)||(e||s).get(t)._class;return new Promise(((e,i)=>{if(!r)return i("No class name specified");n().increment({collection:r,objectId:t,properties:o,success:o=>{n()._fromJSON(Object.assign({objectId:t},o),r),e()},error:e=>{i(Error(e||"Failed to increment."))}})}))},async save(t,o,i){if(void 0===t)return Promise.reject(new Error("'objectOrId' is undefined."));"string"!=typeof t&&(t=t.getId());const r=(i?i.className:void 0)||(e||s).get(t)._class,a=(e||s).get(t);return o&&Object.keys(o).forEach((e=>{a.set(e,o[e])})),new Promise(((e,s)=>{if(!r)return s("No class name specified");n().save({collection:r,objectId:t,data:o||a.data,acl:i?i.acl:void 0,success:o=>{n()._fromJSON(Object.assign({objectId:t},o),r),e()},error:e=>{s(Error(e||"Failed to save."))}})}))},async create(e,t,o){if(void 0===e)throw new Error("'className' is undefined");return new Promise(((i,s)=>{n().create({collection:e,data:t,acl:o?o.acl:void 0,success:t=>{const o=n()._fromJSON(t,e);i(o)},error:e=>{s(Error(e||"Failed to insert."))}})}))},async delete(t,o){if(void 0===t)return Promise.reject(new Error("'objectOrId' is undefined."));"string"!=typeof t&&(t=t.getId());const i=(o?o.className:void 0)||(e||s).get(t)._class;return new Promise(((o,r)=>{if(!i)return r("No class name specified");n().delete({collection:i,objectId:t,success:()=>{(e||s).get(t).notify("delete"),o()},error:e=>{r(Error(e||"Failed to delete."))}})}))},async addRelation(t){const o=t.recordId||t.record.getId(),i=t.className||(e||s).get(o)._class,r=t.targetRecordId||t.targetRecord.getId(),a=t.targetClassName||(e||s).get(r)._class;return new Promise(((e,s)=>i?a?void n().addRelation({collection:i,objectId:o,key:t.key,targetObjectId:r,targetClass:a,success:t=>{e()},error:e=>{s(Error(e||"Failed to add relation."))}}):s("No target class name specified"):s("No class name specified")))},async removeRelation(t){const o=t.recordId||t.record.getId(),i=t.className||(e||s).get(o)._class,r=t.targetRecordId||t.targetRecord.getId(),a=t.targetClassName||(e||s).get(r)._class;return new Promise(((e,s)=>i?a?void n().removeRelation({collection:i,objectId:o,key:t.key,targetObjectId:r,targetClass:a,success:t=>{e()},error:e=>{s(Error(e||"Failed to add relation."))}}):s("No target class name specified"):s("No class name specified")))}}}},7701:e=>{e.exports=async function(e,t,n){const o=[],i=[];for(const s of t){const r=Promise.resolve().then((()=>n(s,t)));if(o.push(r),e<=t.length){const t=r.then((()=>i.splice(i.indexOf(t),1)));i.push(t),i.length>=e&&await Promise.race(i)}}return Promise.all(o)}},9160:(e,t,n)=>{"use strict";var o=n(3839);Object.defineProperty(Array.prototype,"items",{enumerable:!1,get(){return this},set(e){this.set(e)}}),Object.defineProperty(Array.prototype,"each",{enumerable:!1,writable:!1,value:Array.prototype.forEach}),Object.defineProperty(Array.prototype,"size",{enumerable:!1,writable:!1,value:function(){return this.length}}),Object.defineProperty(Array.prototype,"get",{enumerable:!1,writable:!1,value:function(e){return this[e]}}),Object.defineProperty(Array.prototype,"getId",{enumerable:!1,writable:!1,value:function(){return this._id}}),Object.defineProperty(Array.prototype,"id",{enumerable:!1,get(){return this.getId()}}),Object.defineProperty(Array.prototype,"set",{enumerable:!1,writable:!1,value:function(e){var t,n;if(e!==this){var i=[];for(t=(e=e||[]).length,n=0;n{"use strict";e.exports={createSetter:function(e){var t=!1;return function(n){(n=!!n)&&!1===t&&e.valueChangedToTrue.call(this),t=n}}}},5153:e=>{e.exports=class{constructor(){this.currentWarnings=new Map}setWarning(e,t,n){if(this.currentWarnings.has(e)){const o=this.currentWarnings.get(e);return o[t]!==n&&(o[t]=n,!0)}return this.currentWarnings.set(e,{[t]:n}),!0}clearWarning(e,t){const n=this.currentWarnings.get(e);return!(!n||!n[t]||(delete n[t],0===Object.keys(n).length&&this.currentWarnings.delete(e),0))}clearWarnings(e){return!1!==this.currentWarnings.has(e)&&(this.currentWarnings.delete(e),!0)}}},3278:(e,t,n)=>{"use strict";var o=n(9092),i=n(3855),s=n(7662);const r=n(5153);function a(e){var t=e||{};o.call(this),this.runtimeType=t.runtimeType,this.platform=t.platform,this.ws=t.platform&&t.platform.webSocketClass||("undefined"!=typeof WebSocket?WebSocket:void 0),this.wsOptions=t.platform&&t.platform.webSocketOptions||void 0,this.reconnectOnClose=!0,this.enableDebugger=!1,this.lastSendTimestamp=0,this.sendQueue=[],this.sendTimer=void 0,this.activeWarnings=new r}a.prototype=Object.create(o.prototype),a.prototype.constructor=a,a.prototype.isRunningLocally=function(){return this.platform.isRunningLocally&&this.platform.isRunningLocally()||"undefined"!=typeof document&&("localhost"===document.location.hostname||"127.0.0.1"===document.location.hostname)},a.prototype.connect=function(e){this.socket=this.wsOptions?new this.ws(e,this.wsOptions):new this.ws(e);var t=this;this.socket.addEventListener("open",(function(){t.clientId=s(),t.socket.send(JSON.stringify({cmd:"register",type:"viewer",clientId:t.clientId})),t.emit("connected")})),this.socket.addEventListener("close",(function(n){t.reconnectOnClose&&t.reconnect(e),console.log("Editor connection closed",n.code,n.reason),t.emit("connectionClosed")})),this.socket.addEventListener("error",(function(e){console.log("Editor connection error, trying to reconnect")})),this.socket.addEventListener("message",(async e=>{const n="string"==typeof e.data?e.data:await e.data.text(),o=JSON.parse(n);let s;"registered"===o.cmd||("export"===o.cmd?(s=JSON.parse(o.content),"full"===o.type&&o.target===this.clientId&&t.emit("exportDataFull",s)):"hoverStart"===o.cmd?t.emit("hoverStart",o.content.id):"hoverEnd"===o.cmd?t.emit("hoverEnd",o.content.id):"refresh"===o.cmd?t.emit("reload"):"debugInspectors"===o.cmd?this.debugInspectorsEnabled&&(s=JSON.parse(o.content),t.emit("debugInspectorsUpdated",s.inspectors)):"debuggingEnabled"===o.cmd?t.isRunningLocally()&&(s=JSON.parse(o.content),t.emit("debuggingEnabledChanged",s.enabled)):"getConnectionValue"===o.cmd?t.isRunningLocally()&&(s=JSON.parse(o.content),await t.emit("getConnectionValue",{clientId:s.clientId,connectionId:s.connectionId})):"modelUpdate"===o.cmd?await t.emit("modelUpdate",o.content):"publish"===o.cmd?i.pubsub.routeMessage(o):"noodlModules"===o.cmd?t.emit("noodlModules",JSON.parse(o.content)):"mqttUpdate"===o.cmd?t.emit("mqttUpdate",o.content):"activeComponentChanged"===o.cmd?t.emit("activeComponentChanged",o.component):console.log("Command not implemented",o))}))},a.prototype.reconnect=function(e){var t=this;setTimeout((function(){t.connect(e)}),2e3)},a.prototype.isConnected=function(){return void 0!==this.socket&&this.socket.readyState===this.ws.OPEN},a.prototype.send=function(e){const t=this.platform.getCurrentTime(),n=t-this.lastSendTimestamp,o=e=>{try{this.socket.send(JSON.stringify(e))}catch(t){if(t.message&&t.message.startsWith("Converting circular"))try{this.socket.send(JSON.stringify(e,(()=>{const e=new WeakSet;return(t,n)=>{if("object"==typeof n&&null!==n){if(e.has(n))return"[Circular]";e.add(n)}return n}})()))}catch(t){console.log("failed to send message to editor",e,t)}else console.log("failed to send message to editor",e,t)}};n<200||this.sendTimer||!this.isConnected()?(this.sendQueue.push(e),this.sendTimer||(this.sendTimer=setTimeout((()=>{if(!1!==this.isConnected()){for(let e=0;e{var o=JSON.parse(u[e]),i=[].concat(t);n.prefix&&(o=o.filter((e=>e.name.startsWith(n.prefix))),i=i.filter((e=>e.name.startsWith(n.prefix)))),n.plug&&(o=o.filter((e=>e.plug===n.plug)),i=i.filter((e=>e.plug===n.plug))),i=i.map((e=>e.name.substring((n.prefix||"").length)));var r=function(e,t){if(e&&t&&e.length===t.length){for(var n={},o=0;oe.name.substring((n.prefix||"").length))),i);r&&s.push({plug:n.plug,patterns:[(n.prefix||"")+"{{*}}"],before:r.before,after:r.after})})),s.length>0&&(n.renamed=s),delete n.detectRenamed}u[e]=o,this.send({cmd:"instanceports",type:"viewer",content:JSON.stringify({nodeid:e,ports:t,options:n})})}},a.prototype.sendWarning=function(e,t,n,o){this.activeWarnings.setWarning(t,n,o)&&this.send({cmd:"showwarning",type:"viewer",content:JSON.stringify({componentName:e,nodeId:t,key:n,warning:o})})},a.prototype.clearWarning=function(e,t,n){this.activeWarnings.clearWarning(t,n)&&this.send({cmd:"showwarning",type:"viewer",content:JSON.stringify({componentName:e,nodeId:t,key:n,warning:void 0})})},a.prototype.clearWarnings=function(e,t){this.activeWarnings.clearWarnings(t)&&this.send({cmd:"clearwarnings",type:"viewer",content:JSON.stringify({componentName:e,nodeId:t})})},a.prototype.sendPatches=function(e){this.send({cmd:"patchproject",type:"viewer",content:JSON.stringify(e)})},a.prototype.requestFullExport=function(){this.send({cmd:"register",type:"viewer"})},a.prototype.requestNoodlModules=function(){this.send({cmd:"getNoodlModules",type:"viewer"})};var c={};a.prototype.sendServiceRequest=function(e,t){e.token=s(),e.clientId=this.clientId,c[e.token]=t,this.send(e)},a.prototype.close=function(){this.reconnectOnClose=!1,!1!==this.isConnected()&&this.socket.close()},a.prototype.sendNodeLibrary=function(e){this.send({cmd:"nodelibrary",type:"viewer",runtimeType:this.runtimeType,content:e,clientId:this.clientId})},a.prototype.sendComponentMetadata=function(e,t,n){this.send({cmd:"componentMetadata",type:"viewer",content:JSON.stringify({componentName:e,key:t,data:n})})},a.prototype.sendProjectMetadata=function(e,t){this.send({cmd:"projectMetadata",type:"viewer",content:JSON.stringify({key:e,data:t})})},e.exports=a},6416:e=>{"use strict";function t(e,t){const n=new Set(t);return e.filter((e=>!n.has(e)))}e.exports={handleEvent:async function(e,n,o){function i(n,o){var i={},r={};o.forEach((function(e){e&&"outputs"===e.plug&&(e.plug="output"),"input"!==e.plug&&"input/output"!==e.plug||(i[e.name]=e),"output"!==e.plug&&"input/output"!==e.plug||(r[e.name]=e)}));var a=Object.keys(n.getInputPorts()),u=t(a,Object.keys(i)),c=t(Object.keys(i),a);n.updateInputPortTypes(i),u.forEach(n.removeInputPortWithName.bind(n)),c.forEach((function(t){n.addInputPort(i[t]),n.parameters&&n.parameters.hasOwnProperty(t)&&s(e.rootComponent.nodeScope,n,t,n.parameters[t])})),n.updateOutputPortTypes(r);var l=Object.keys(n.getOutputPorts()),d=t(l,Object.keys(r)),p=t(Object.keys(r),l);d.forEach(n.removeOutputPortWithName.bind(n)),p.forEach((function(e){n.addOutputPort(r[e])}))}function s(e,t,n,o){e.getNodesWithIdRecursive(t.id).forEach((function(e){e.queueInput(n,o)}))}var r;if(!o.componentName||(r=n.getComponentWithName(o.componentName))){o.port&&"outputs"===o.port.plug&&(o.port.plug="output");var a={nodeAdded:function(e){r.importEditorNodeData(e.model,e.parentId,e.childIndex)},nodeRemoved:async function(e){r.hasNodeWithId(e.model.id)&&await r.removeNodeWithId(e.model.id)},connectionAdded:function(e){r.addConnection(e.model)},connectionRemoved:function(t){r.removeConnection(t.model);var n=r.getNodeWithId(t.model.targetId);if(0===r.getConnectionsToPort(n.id,t.model.targetId).length){var o=n.parameters[t.model.targetPort];void 0===o&&(o=e.getDefaultValueForInput(n.type,t.model.targetPort)),s(e.rootComponent.nodeScope,n,t.model.targetPort,o)}},parameterChanged:function(e){const t=r.getNodeWithId(e.nodeId);if(void 0!==t){if(e.parameters){const n=new Set(Object.keys(e.parameters).concat(Object.keys(e.oldParameters)));for(const o of n)t.setParameter(o,e.parameters[o])}e.parameterName&&t.setParameter(e.parameterName,e.parameterValue,e.state)}else console.log("parameterChanged: Unknown node id",e)},nodeAttached:function(e){r.setNodeParent(r.getNodeWithId(e.nodeId),r.getNodeWithId(e.parentId),e.childIndex)},nodeDetached:function(e){r.setNodeParent(r.getNodeWithId(e.nodeId),null),r.addRootId(e.nodeId)},componentAdded:function(e){n.importComponentFromEditorData(e.model)},componentRemoved:async function(e){await n.removeComponentWithName(e.componentName)},rootAdded:function(e){r.addRootId(e.nodeId)},portAdded:function(t){var n=r.getNodeWithId(t.nodeId);"input"!==t.port.plug&&"input/output"!==t.port.plug||(n.addInputPort(t.port),n.parameters.hasOwnProperty(t.port)&&s(e.rootComponent.nodeScope,n,t.port,n.parameters[t.port])),"output"!==t.port.plug&&"input/output"!==t.port.plug||n.addOutputPort(t.port)},portRemoved:function(e){var t=r.getNodeWithId(e.nodeId);"input"!==e.port.plug&&"input/output"!==e.port.plug||t.removeInputPortWithName(e.port.name),"output"!==e.port.plug&&"input/output"!==e.port.plug||t.removeOutputPortWithName(e.port.name)},nodePortRenamed:function(e){"input"!==e.port.plug&&"input/output"!==e.port.plug||r.renameInputPortOnNodeWithId(e.nodeId,e.oldName,e.port.name),"output"!==e.port.plug&&"input/output"!==e.port.plug||r.renameOutputPortOnNodeWithId(e.nodeId,e.oldName,e.port.name);var t=r.getNodeWithId(e.nodeId);"Component Inputs"===t.type?(r.addInputPort(e.port),n.getNodesWithType(r.name).forEach((function(t){t.component.renameInputPortOnNodeWithId(t.id,e.oldName,e.port.name)})),r.removeInputPortWithName(e.oldName)):"Component Outputs"===t.type&&(r.addOutputPort(e.port),n.getNodesWithType(r.name).forEach((function(t){t.component.renameOutputPortOnNodeWithId(t.id,e.oldName,e.port.name)})),r.removeOutputPortWithName(e.oldName))},componentPortsUpdated:function(e){i(r,e.ports)},instancePortsChanged:function(e){r.hasNodeWithId(e.nodeId)&&i(r.getNodeWithId(e.nodeId),e.ports)},componentRenamed:function(e){n.renameComponent(e.oldName,e.newName)},settingsChanged:function(e){n.setSettings(e.settings)},metadataChanged:function(e){n.setMetaData(e.key,e.data)},componentMetadataChanged:function(e){const t=n.getComponentWithName(e.componentName);t&&t.setMetadata(e.key,e.data)},variantParametersChanged:function(t){if(t.variant)n.updateVariant(t.variant);else if(n.updateVariantParameter(t.variantName,t.variantTypeName,t.parameterName,t.parameterValue,t.state),void 0===t.parameterValue){const o=n.getVariant(t.variantTypeName,t.variantName);e.rootComponent.nodeScope.getAllNodesWithVariantRecursive(o).forEach((e=>{e.queueInput(t.parameterName,e.getParameter(t.parameterName))}))}},variantDeleted:function(e){n.deleteVariant(e.variantTypeName,e.variantName)},variantChanged:function(e){const t=r.getNodeWithId(e.nodeId),o=n.getVariant(t.type,e.variantName);t.setVariant(o)},variantRenamed:function(e){const t=n.getVariant(e.variantTypeName,e.oldVariantName);t&&(t.name=t.variantName)},defaultStateTransitionChanged:function(e){r.getNodeWithId(e.nodeId).setDefaultStateTransition(e.curve,e.state)},stateTransitionsChanged:function(e){const t=r.getNodeWithId(e.nodeId);e.parameterName&&t.setStateTransitionParamter(e.parameterName,e.curve,e.state)},variantDefaultStateTransitionChanged:function(e){n.updateVariantDefaultStateTransition(e.variantName,e.variantTypeName,e.curve,e.state)},variantStateTransitionsChanged:function(e){n.updateVariantStateTransition(e)},routerIndexChanged:function(e){n.routerIndex=e.data}};a.hasOwnProperty(o.type)?(await a[o.type](o),e.scheduleUpdate()):console.log("Unknown event",o)}}}},5627:e=>{"use strict";var t,n="object"==typeof Reflect?Reflect:null,o=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise((function(n,o){function i(n){e.removeListener(t,s),o(n)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}f(e,t,s,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&f(e,"error",t,{once:!0})}(e,i)}))},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var r=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function c(e,t,n,o){var i,s,r,c;if(a(n),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),r=s[t]),void 0===r)r=s[t]=n,++e._eventsCount;else if("function"==typeof r?r=s[t]=o?[n,r]:[r,n]:o?r.unshift(n):r.push(n),(i=u(e))>0&&r.length>i&&!r.warned){r.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=r.length,c=l,console&&console.warn&&console.warn(c)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,n){var o={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=l.bind(o);return i.listener=n,o.wrapFn=i,i}function p(e,t,n){var o=e._events;if(void 0===o)return[];var i=o[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n0&&(r=t[0]),r instanceof Error)throw r;var a=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw a.context=r,a}var u=s[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var c=u.length,l=m(u,c);for(n=0;n=0;s--)if(n[s]===t||n[s].listener===t){r=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1=0;o--)this.removeListener(e,t[o]);return this},s.prototype.listeners=function(e){return p(this,e,!0)},s.prototype.rawListeners=function(e){return p(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h,s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},9092:e=>{"use strict";function t(){this.listeners={},this.listenersWithRefs={}}t.prototype.on=function(e,t,n){n?(this.listenersWithRefs.hasOwnProperty(e)||(this.listenersWithRefs[e]=new Map),this.listenersWithRefs[e].get(n)||this.listenersWithRefs[e].set(n,[]),this.listenersWithRefs[e].get(n).push(t)):(this.listeners.hasOwnProperty(e)||(this.listeners[e]=[]),this.listeners[e].push(t))},t.prototype.removeListenersWithRef=function(e){Object.keys(this.listenersWithRefs).forEach((t=>{const n=this.listenersWithRefs[t];n.has(e)&&n.delete(e)}))},t.prototype.removeAllListeners=function(e){e?(delete this.listeners[e],delete this.listenersWithRefs[e]):(this.listeners={},this.listenersWithRefs={})},t.prototype.emit=async function(e,t){const n=this.listeners[e];if(n)for(let e=0;e{e.exports=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}},5995:(e,t,n)=>{"use strict";const o=n(3839),{getAbsoluteUrl:i}=n(5722);var s={};function r(e,t){this.inputs={},this.outputs={},this.error=void 0,this.code=e;const n=t?t.node:void 0;this._initializeAPIs();var o=s[e];if(!o)try{o=new Function(["define","script","Node","Component"],r.getCodePrefix()+e),s[e]=o}catch(e){this.error=e.message,console.error(e)}if(o)try{o(this.define.bind(this),this.script.bind(this),this.apis.Node,n?r.getComponentScopeForNode(n):{}),this._afterSourced()}catch(e){this.error=e.message,console.error(e)}}r.prototype.define=function(e){this.inputs=e.inputs||{},this.outputs=e.outputs||{},this.setup=e.setup,this.change=e.run||e.change,this.destroy=e.destroy,this.definedObject=e},r.prototype.script=function(e){var t=function(e){var t={inputs:e.inputs||{},outputs:e.outputs||{},setup:function(t,n){if(this.inputs=t,this.outputs=n,this.setOutputs=function(e){for(var t in e)this.outputs[t]=e[t],this.flagOutputDirty(t)},e.methods)for(var o in e.methods)this[o]=e.methods[o];e.setup&&e.setup.apply(this)},destroy:function(t,n){this.inputs=t,this.outputs=n,e.destroy&&e.destroy.apply(this)},change:function(t,n){this.inputs=t,this.outputs=n;var o=this._oldInputs||{};if(e.changed)for(var i in t)if(t[i]!==o[i]){var s=e.changed[i];"function"==typeof s&&s.apply(this,[t[i],o[i]])}this._oldInputs=Object.assign({},t)}};if(e.signals)for(var n in e.signals)t[n]=e.signals[n],t.inputs[n]="signal";return t}(e);this.inputs=t.inputs||{},this.outputs=t.outputs||{},this.setup=t.setup,this.change=t.run||t.change,this.destroy=t.destroy,this.definedObject=t},r.prototype._initializeAPIs=function(){this.apis={},this.apis.Node={Inputs:{},Outputs:{},Signals:{},Setters:{}}},r.prototype._afterSourced=function(){if(void 0===this.definedObject){var e=this.apis.Node;if(this.inputs=Object.assign({},e.Inputs||{}),this.outputs=Object.assign({},e.Outputs||{}),this.setup=function(t,n){const o=this;e.setOutputs=function(e){for(var t in e)n[t]=e[t],o.flagOutputDirty(t)},e.OnInit&&e.OnInit.apply(this)},this.destroy=e.OnDestroy||this.destory,this.change=(t,n,o)=>{for(var i in o)"function"==typeof e.Setters[i]&&e.Setters[i](t[i]);"function"==typeof e.OnInputsChanged&&e.OnInputsChanged()},this.definedObject={inputs:this.inputs,outputs:this.outputs,setup:this.setup,destroy:this.destroy,change:this.change},void 0!==e.Signals)for(var t in e.Signals)"function"==typeof e.Signals[t]&&(this.inputs[t]="signal",this.definedObject[t]=e.Signals[t])}},r.createFromCode=function(e,t){return new r(e,t)},r.createFromURL=function(e,t,n){e=i(e);var o=new window.XMLHttpRequest;o.open("GET",e,!0),o.onreadystatechange=function(){4!==this.readyState&&this.readyState!==XMLHttpRequest.DONE||t(new r(this.response))},o.onerror=function(){console.log("Failed to request",e)},o.send()},r.parseAndAddPortsFromScript=function(e,t,n){function o(e,n){if(null==e)return;const o={};for(const t of e){let e=t[1];void 0!==e&&(o[e]=!0)}Object.keys(o).forEach((e=>{var o;("string"==typeof(o={name:n.prefix+e,plug:n.plug})?void 0===t.find((e=>e.name===o)):void 0===t.find((e=>e.name===o.name&&e.plug===o.plug)))&&t.push({name:n.prefix+e,displayName:e,plug:n.plug,type:n.type,group:n.group})}))}n.skipInputs||(o(e.matchAll(/Inputs\.([A-Za-z0-9_]+)/g),{type:n.inputType||"*",plug:"input",group:n.inputGroup||"Inputs",prefix:n.inputPrefix||""}),o(e.matchAll(/Inputs\s*\[\s*(?:'|")(.*)(?:'|")\s*\]/g),{type:n.inputType||"*",plug:"inputs",group:n.inputGroup||"Inputs",prefix:n.inputPrefix||""})),n.skipOutputs||(n.skipOutputSignals||(o(e.matchAll(/Outputs\.([A-Za-z0-9]+)\s*\(\s*\)/g),{type:"signal",plug:"output",group:"Outputs",prefix:n.outputPrefix||""}),o(e.matchAll(/Outputs\s*\[\s*(?:'|")(.*)(?:'|")\s*\]\(\s*\)/g),{type:"signal",plug:"output",group:"Outputs",prefix:n.outputPrefix||""})),n.skipRegularOutputs||(o(e.matchAll(/Outputs\.([A-Za-z0-9_]+)/g),{type:"*",plug:"output",group:"Outputs",prefix:n.outputPrefix||""}),o(e.matchAll(/Outputs\s*\[\s*\"([^\"]*)\"\s*\]/g),{type:"*",plug:"output",group:"Outputs",prefix:n.outputPrefix||""})))},r.prototype.getPorts=function(){var e=[],t=this;return Object.keys(this.inputs).forEach((function(n){var o=t.inputs[n],i={name:n,plug:"input"};if("string"==typeof o)i.type={name:o},i.group="Inputs";else for(var s in o)i[s]=o[s];e.push(i)})),Object.keys(this.outputs).forEach((function(n){e.push({name:n,type:{name:t.outputs[n]},plug:"output",group:"Outputs"})})),r.parseAndAddPortsFromScript(this.code,e,{}),e};const a={};r.getComponentScopeForNode=function(e){const t=e.nodeScope.componentOwner.getInstanceId();if(void 0===a[t]){a[t]={};const n=(e.nodeScope.modelScope||o).get("componentState"+t);a[t].Object=n}const n=function(e){const t=function e(t){let n;if(t.getRoots().length>0){const e=t.getRoots()[0];e.getVisualParentNode?e.getVisualParentNode()&&(n=e.getVisualParentNode().nodeScope.componentOwner):e.parentNodeScope&&(n=t.parentNodeScope.componentOwner)}else t.parentNodeScope&&(n=t.parentNodeScope.componentOwner);if(n&&n.nodeScope&&n.nodeScope.componentOwner!==t)return n.nodeScope.getNodesWithType("net.noodl.ComponentObject").length>0||n.nodeScope.getNodesWithType("Component State").length>0?n:e(n)}(e.nodeScope.componentOwner);if(t)return"componentState"+t.getInstanceId()}(e),i=void 0!==n?(e.nodeScope.modelScope||o).get(n):void 0;return a[t].ParentObject=i,a[t].RepeaterObject=function(e){for(var t=e.nodeScope.componentOwner;void 0!==t&&void 0===t._forEachModel&&t.parentNodeScope;)t=t.parentNodeScope.componentOwner;return void 0!==t?t._forEachModel:void 0}(e),a[t]},r.getCodePrefix=function(){return"const Script = (typeof Node !== 'undefined')?Node:undefined;\n"},r.createNoodlAPI=function(){return"undefined"!=typeof window&&void 0!==window.Noodl?window.Noodl:{}},e.exports=r},3839:e=>{function t(e,t){this.id=e,this.data=t}const n=t._models={},o={},i={get:function(e,t,n){return"function"==typeof e[t]?e[t].bind(e):t in e?Reflect.get(e,t,n):e.get(t)},set:function(e,t,n){if("_class"===t)e._class=n;else{if("id"===t)return console.log(`Noodl.Object warning: id is readonly (Id is ${e.id}, trying to set to ${n})`),!0;e.set(t,n)}return!0},ownKeys:e=>Reflect.ownKeys(e.data),getOwnPropertyDescriptor:(e,t)=>Object.getOwnPropertyDescriptor(e.data,t)};function s(e){if(0===e)throw new Error("Zero-length randomString is useless.");let t="";for(let n=0;n{"use strict";var o=n(6371),i=n(9092);function s(e){i.call(this),this.name=e,this.nodes=[],this.connections=[],this.roots=[],this.inputPorts={},this.outputPorts={},this.metadata={}}s.prototype=Object.create(i.prototype),s.prototype.addNode=async function(e){e.component=this,this.nodes[e.id]=e,await this.emit("nodeAdded",e)},s.prototype.hasNodeWithId=function(e){return void 0!==this.getNodeWithId(e)},s.prototype.getNodeWithId=function(e){return this.nodes[e]},s.prototype.getAllNodes=function(){return Object.values(this.nodes)},s.prototype.getNodesWithType=function(e){var t=[],n=this;return Object.keys(this.nodes).forEach((function(o){var i=n.nodes[o];i.type===e&&t.push(i)})),t},s.prototype.addConnection=function(e){if(this.connections.push(e),this.emit("connectionAdded",e),e.targetId){const t=this.getNodeWithId(e.targetId);t&&t.emit("inputConnectionAdded",e)}},s.prototype.removeConnection=function(e){const t=this.connections.findIndex((t=>t.sourceId===e.sourceId&&t.sourcePort===e.sourcePort&&t.targetId===e.targetId&&t.targetPort===e.targetPort));if(-1!==t){if(this.connections.splice(t,1),this.emit("connectionRemoved",e),e.targetId){const t=this.getNodeWithId(e.targetId);t&&t.emit("inputConnectionRemoved",e)}}else console.log("Connection doesn't exist",e)},s.prototype.getConnectionsFromPort=function(e,t){return this.connections.filter((function(n){return n.sourceId===e&&n.sourcePort===t}))},s.prototype.getConnectionsToPort=function(e,t){return this.connections.filter((function(n){return n.targetId===e&&n.targetPort===t}))},s.prototype.getConnectionsFrom=function(e){return this.connections.filter((function(t){return t.sourceId===e}))},s.prototype.getConnectionsTo=function(e){return this.connections.filter((function(t){return t.targetId===e}))},s.prototype.addRootId=function(e){-1===this.roots.indexOf(e)&&(this.roots.push(e),this.emit("rootAdded",e))},s.prototype.removeRootId=function(e){const t=this.roots.indexOf(e);-1!==t&&(this.roots.splice(t,1),this.emit("rootRemoved",e))},s.prototype.getRoots=function(){return this.roots},s.prototype.removeNodeWithId=async function(e){const t=this.getNodeWithId(e);if(!t)return console.warn("ERROR: Attempted to remove non-existing node with ID:",e),!1;for(;t.children.length>0;){const e=t.children[0];await this.removeNodeWithId(e.id)||t.children.shift()}const n=this.getConnectionsTo(e).concat(this.getConnectionsFrom(e));for(let e=0;e0)throw new Error("Not all nodes were removed during a reset");if(this.connections.length>0)throw new Error("Not all connections were removed during a reset")},s.prototype.rename=function(e){var t=this.name;this.name=e,this.emit("renamed",{oldName:t,newName:e})},s.prototype.setMetadata=function(e,t){this.metadata[e]=t},s.prototype.getMetadata=function(e){return e?this.metadata[e]:this.metadata},s.createFromExportData=async function(e){var t=new s(e.name);if(e.metadata)for(const n in e.metadata)t.setMetadata(n,e.metadata[n]);if(e.ports&&e.ports.forEach((function(e){"input"!==e.plug&&"input/output"!==e.plug||t.addInputPort(e),"output"!==e.plug&&"input/output"!==e.plug||t.addOutputPort(e)})),e.nodes)for(const n of e.nodes)await t.importEditorNodeData(n);return e.connections&&e.connections.forEach((e=>t.addConnection(e))),e.roots&&e.roots.forEach((e=>t.addRootId(e))),t},e.exports=s},9397:(e,t,n)=>{"use strict";var o=n(7863),i=n(9092);function s(){i.call(this),this.components={},this.settings={},this.metadata={}}s.prototype=Object.create(i.prototype),s.prototype.importComponentFromEditorData=async function(e){var t=await o.createFromExportData(e);this.addComponent(t)},s.prototype.getBundleContainingComponent=function(e){return this.componentToBundleMap.get(e)},s.prototype.getBundlesContainingSheet=function(e){const t=new Set;for(const n of this.componentToBundleMap.keys()){const o=0!==n.indexOf("/#");(o&&"Default"===e||!o&&0===n.indexOf("/#"+e))&&t.add(this.componentToBundleMap.get(n))}return Array.from(t)},s.prototype.getBundleDependencies=function(e){const t=new Set,n=e=>{const o=this.componentIndex[e];for(const e of o.dependencies)t.has(e)||(t.add(e),n(e))};return n(e),Array.from(t)},s.prototype.importEditorData=async function(e){this.componentIndex=e.componentIndex,this.routerIndex=e.routerIndex,this.componentToBundleMap=new Map;for(const t in e.componentIndex){const n=e.componentIndex[t];for(const e of n.components)this.componentToBundleMap.set(e,t)}this.variants=e.variants||[],e.settings&&this.setSettings(e.settings),e.metadata&&this.setAllMetaData(e.metadata);for(const t of e.components)await this.importComponentFromEditorData(t);this.setRootComponentName(e.rootComponent)},s.prototype.setRootComponentName=function(e){this.rootComponent=e,this.emit("rootComponentNameUpdated",e)},s.prototype.getNodesWithType=function(e){for(var t=[],n=Object.keys(this.components),o=0;othis.components[e]))},s.prototype.getAllNodes=function(){for(var e=[],t=Object.keys(this.components),n=0;n{e.addInputPort(n[t])})),Object.keys(o).forEach((t=>{e.addOutputPort(o[t])}))}},s.prototype._onNodeAdded=function(e){this._addComponentPorts(e),this.emit("nodeAdded",e),this.emit("nodeAdded."+e.type,e)},s.prototype._onNodeRemoved=function(e){this.emit("nodeRemoved",e),this.emit("nodeRemoved."+e.type,e)},s.prototype._onNodeWasRemoved=function(e){this.emit("nodeWasRemoved",e),this.emit("nodeWasRemoved."+e.type,e)},s.prototype.reset=async function(){for(const e of Object.keys(this.components))await this.removeComponentWithName(e);this.setSettings({})},s.prototype.isEmpty=function(){return 0===Object.keys(this.components).length},s.prototype.setSettings=function(e){this.settings=e,this.emit("projectSettingsChanged",e)},s.prototype.getSettings=function(){return this.settings},s.prototype.setAllMetaData=function(e){for(const t in e)this.setMetaData(t,e[t])},s.prototype.setMetaData=function(e,t){this.metadata[e]&&JSON.stringify(this.metadata[e])===JSON.stringify(t)||(this.metadata[e]=t,this.emit("metadataChanged",{key:e,data:t}),this.emit("metadataChanged."+e,t))},s.prototype.getMetaData=function(e){return e?this.metadata[e]:this.metadata},s.prototype.getVariants=function(){return this.variants||[]},s.prototype.getVariant=function(e,t){return this.variants.find((n=>n.name===t&&n.typename===e))},s.prototype.updateVariant=function(e){const t=this.variants.findIndex((t=>t.name===e.name&&t.typename===e.typename));-1!==t&&this.variants.splice(t,1),this.variants.push(e),this.emit("variantUpdated",e)},s.prototype.updateVariantParameter=function(e,t,n,o,i){const s=this.getVariant(t,e);s?(i?(s.stateParameters.hasOwnProperty(i)||(s.stateParameters[i]={}),void 0===o?delete s.stateParameters[i][n]:s.stateParameters[i][n]=o):void 0===o?delete s.parameters[n]:s.parameters[n]=o,this.emit("variantUpdated",s)):console.log("updateVariantParameter: can't find variant",e,t)},s.prototype.updateVariantDefaultStateTransition=function(e,t,n,o){const i=this.getVariant(t,e);i&&(i.defaultStateTransitions[o]=n,this.emit("variantUpdated",i))},s.prototype.updateVariantStateTransition=function(e){const{variantTypeName:t,variantName:n,state:o,parameterName:i,curve:s}=e,r=this.getVariant(t,n);r&&(r.stateTransitions[o]||(r.stateTransitions[o]={}),r.stateTransitions[o][i]=s)},s.prototype.deleteVariant=function(e,t){const n=this.variants.findIndex((n=>n.name===t&&n.typename===e));-1!==n&&this.variants.splice(n,1)},e.exports=s},6371:(e,t,n)=>{"use strict";var o=n(9092);function i(e,t){o.call(this),this.id=e,this.type=t,this.inputs=[],this.outputs=[],this.children=[],this.parameters={},this.inputPorts={},this.outputPorts={}}i.prototype=Object.create(o.prototype),i.prototype.setParameter=function(e,t,n){n?(this.stateParameters||(this.stateParameters={}),this.stateParameters[n]||(this.stateParameters[n]={}),void 0===t?delete this.stateParameters[n][e]:this.stateParameters[n][e]=t):void 0===t?delete this.parameters[e]:this.parameters[e]=t,this.emit("parameterUpdated",{name:e,value:t,state:n})},i.prototype.setParameters=function(e){Object.keys(e).forEach((t=>{this.setParameter(t,e[t])}))},i.prototype.setStateParameters=function(e){this.stateParameters=e},i.prototype.setStateTransitions=function(e){this.stateTransitions=e},i.prototype.setStateTransitionParamter=function(e,t,n){this.stateTransitions||(this.stateTransitions={}),t?this.stateTransitions[n][e]=t:delete this.stateTransitions[n][e]},i.prototype.setDefaultStateTransition=function(e,t){this.defaultStateTransitions||(this.defaultStateTransitions={}),this.defaultStateTransitions[t]=e},i.prototype.addInputPort=function(e){this.inputPorts[e.name]=e,this.emit("inputPortAdded",e)},i.prototype.getInputPort=function(e){return this.inputPorts[e]},i.prototype.getInputPorts=function(){return this.inputPorts},i.prototype.removeInputPortWithName=function(e){if(this.inputPorts.hasOwnProperty(e)){var t=this.inputPorts[e];delete this.inputPorts[e],this.emit("inputPortRemoved",t)}},i.prototype.updateInputPortTypes=function(e){var t=!1;for(var n in e)void 0!==this.inputPorts[n]&&(this.inputPorts[n].type=e[n].type,t=!0);t&&this.emit("inputPortTypesUpdated")},i.prototype.addOutputPort=function(e){this.outputPorts[e.name]=e,this.emit("outputPortAdded",e)},i.prototype.getOutputPort=function(e){return this.outputPorts[e]},i.prototype.getOutputPorts=function(){return this.outputPorts},i.prototype.removeOutputPortWithName=function(e){if(this.outputPorts.hasOwnProperty(e)){var t=this.outputPorts[e];delete this.outputPorts[e],this.emit("outputPortRemoved",t)}},i.prototype.updateOutputPortTypes=function(e){var t=!1;for(var n in e)void 0!==this.outputPorts[n]&&(this.outputPorts[n].type=e[n].type,t=!0);t&&this.emit("outputPortTypesUpdated")},i.prototype.addChild=function(e,t){e.parent=this,void 0===t?this.children.push(e):this.children.splice(t,0,e),this.emit("childAdded",e)},i.prototype.removeChild=function(e){e.parent=void 0;var t=this.children.indexOf(e);this.children.splice(t,1),this.emit("childRemoved",e)},i.prototype.reset=function(){this.removeAllListeners()},i.prototype.setVariant=function(e){this.variant=e,this.emit("variantUpdated",e)},i.createFromExportData=function(e){var t=new i(e.id,e.type);if(e.parameters&&t.setParameters(e.parameters),e.stateParameters&&t.setStateParameters(e.stateParameters),e.stateTransitions&&t.setStateTransitions(e.stateTransitions),e.defaultStateTransitions)for(const n in e.defaultStateTransitions)t.setDefaultStateTransition(e.defaultStateTransitions[n],n);return e.ports&&e.ports.forEach((function(e){"outputs"===e.plug&&(e.plug="output"),"input"!==e.plug&&"input/output"!==e.plug||t.addInputPort(e),"output"!==e.plug&&"input/output"!==e.plug||t.addOutputPort(e)})),e.variant&&t.setVariant(e.variant),t},e.exports=i},2487:(module,__unused_webpack_exports,__webpack_require__)=>{const OutputProperty=__webpack_require__(6454);function Node(e,t){this.id=t,this.context=e,this._dirty=!1,this._inputs={},this._inputValues={},this._outputs={},this._inputConnections={},this._outputList=[],this._isUpdating=!1,this._inputValuesQueue={},this._afterInputsHaveUpdatedCallbacks=[],this._internal={},this._signalsSentThisUpdate={},this._deleted=!1,this._deleteListeners=[],this._isFirstUpdate=!0,this._valuesFromConnections={},this.updateOnDirtyFlagging=!0}Node.prototype.getInputValue=function(e){return this._inputValues[e]},Node.prototype.registerInput=function(e,t){if(this.hasInput(e))throw new Error("Input property "+e+" already registered");if(this._inputs[e]=t,t.type&&t.type.units){const n=t.type.defaultUnit||t.type.units[0];this._inputValues[e]={value:t.default,type:n}}else t.hasOwnProperty("default")&&(this._inputValues[e]=t.default)},Node.prototype.deregisterInput=function(e){if(!1===this.hasInput(e))throw new Error("Input property "+e+" doesn't exist");delete this._inputs[e],delete this._inputValues[e]},Node.prototype.registerInputs=function(e){for(const t in e)this.registerInput(t,e[t])},Node.prototype.getInput=function(e){if(!1!==this.hasInput(e))return this._inputs[e];console.log("Node "+this.name+": Invalid input property "+e)},Node.prototype.hasInput=function(e){return e in this._inputs},Node.prototype.registerInputIfNeeded=function(){},Node.prototype.setInputValue=function(name,value){const input=this.getInput(name);if(!input)return void console.log("node doesn't have input",name);const currentInputValue=this._inputValues[name];if(!1===isNaN(value)&¤tInputValue&¤tInputValue.unit){const e=Object.assign({},currentInputValue);e.value=value,value=e}if(this._inputValues[name]=value,"color"===input.type&&this.context&&this.context.styles)value=this.context.styles.resolveColor(value);else if("array"===input.type&&"string"==typeof value)try{value=eval(value),this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"invalid-array-"+name)}catch(e){value=[],console.log(e),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"invalid-array-"+name,{showGlobally:!0,message:"Invalid array
"+e.toString()})}input.set.call(this,value)},Node.prototype.hasOutput=function(e){return e in this._outputs},Node.prototype.registerOutput=function(e,t){if(this.hasOutput(e))throw new Error("Output property "+e+" already registered");const n=new OutputProperty({owner:this,getter:t.get||t.getter,name:e,onFirstConnectionAdded:t.onFirstConnectionAdded,onLastConnectionRemoved:t.onLastConnectionRemoved});this._outputs[e]=n,this._outputList.push(n)},Node.prototype.deregisterOutput=function(e){if(!1===this.hasOutput(e))throw new Error("Output property "+e+" isn't registered");const t=this._outputs[e];if(t.hasConnections())throw new Error("Output property "+e+" has connections and can't be removed");delete this._outputs[e];var n=this._outputList.indexOf(t);this._outputList.splice(n,1)},Node.prototype.registerOutputs=function(e){for(var t in e)this.registerOutput(t,e[t])},Node.prototype.registerOutputIfNeeded=function(){},Node.prototype.getOutput=function(e){if(!1===this.hasOutput(e))throw new Error("Node "+this.name+" doesn't have a port named "+e);return this._outputs[e]},Node.prototype.connectInput=function(e,t,n){if(!1===this.hasInput(e))throw new Error("Invalid connection, input doesn't exist. Trying to connect from "+t.name+" output "+n+" to "+this.name+" input "+e);var o=t.getOutput(n);if(o.registerConnection(this,e),this._inputConnections[e]||(this._inputConnections[e]=[]),this._inputConnections[e].push(o),t._signalsSentThisUpdate[n])this._setValueFromConnection(e,!0),this._setValueFromConnection(e,!1);else{var i=o.value;void 0!==i&&(this._setValueFromConnection(e,i),this.context&&this.context.connectionSentValue(o,o.value))}this.flagDirty()},Node.prototype.removeInputConnection=function(e,t,n){if(!this._inputConnections[e])throw new Error("Node removeInputConnection: Input doesn't exist");const o=this._inputConnections[e];for(let i=0;i"Component Inputs"!==e.owner.name||e.owner.nodeScope.componentOwner.isInputConnected(e.name)))},Node.prototype.update=function(){if(!this._isUpdating&&!1!==this._dirty){this._updatedAtIteration!==this.context.updateIteration&&(this._updatedAtIteration=this.context.updateIteration,this._updateIteration=0,this._cyclicLoop&&(this._cyclicLoop=!1)),this._isUpdating=!0;try{for(;this._dirty&&!this._cyclicLoop;){this._updateDependencies(),this._dirty=!1;const e=Object.keys(this._inputValuesQueue);let t=!0;for(;t&&!this._cyclicLoop;){t=!1;for(let n=0;n0&&(this.setInputValue(o,i.shift()),i.length>0&&(t=!0))}const n=this._afterInputsHaveUpdatedCallbacks;this._afterInputsHaveUpdatedCallbacks=[];for(let e=0;e=100&&(this._cyclicLoop=!0)}}catch(e){throw this._isUpdating=!1,e}this._cyclicLoop&&(this.context.scheduleNextFrame((()=>{this.context.nodeIsDirty(this)})),this.context.editorConnection&&!this._cyclicWarningSent&&this.context.isWarningTypeEnabled("cyclicLoops")&&(this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"cyclic-loop",{showGlobally:!0,message:"Cyclic loop detected"}),this._cyclicWarningSent=!0,console.log("cycle detected",{id:this.id,name:this.name,component:this.nodeScope.componentOwner.name}))),this._isFirstUpdate=!1,this._isUpdating=!1}},Node.prototype._updateDependencies=function(){for(var e in this._inputConnections)for(var t=this._inputConnections[e],n=0;n{this.hasInput(e.name)&&this.deregisterInput(e.name)}),this),e.on("outputPortRemoved",(e=>{this.hasOutput(e.name)&&this.deregisterOutput(e.name)}),this)},Node.prototype.addDeleteListener=function(e){this._deleteListeners.push(e)},Node.prototype._onNodeDeleted=function(){this.model&&(this.model.removeListenersWithRef(this),this.model=void 0),this._deleted=!0;for(const e of this._deleteListeners)e.call(this)},Node.prototype._onNodeModelParameterUpdated=function(e){if(this.registerInputIfNeeded(e.name),void 0!==e.value)if(e.state){if(!this._getVisualStates)return void console.log("Node has nos visual states, but got a parameter for state",e.state);-1!==this._getVisualStates().indexOf(e.state)&&this.queueInput(e.name,e.value)}else this.queueInput(e.name,e.value);else{let t;const n=this.variant;e.state?n&&n.stateParameters.hasOwnProperty(e.state)&&n.stateParameters[e.state].hasOwnProperty(e.name)?t=n.stateParameters[e.state][e.name]:this.model.parameters.hasOwnProperty(e.name)?t=this.model.parameters[e.name]:n&&n.parameters.hasOwnProperty(e.name)&&(t=n.parameters[e.name]):n&&n.parameters.hasOwnProperty(e.name)&&(t=n.parameters[e.name]),void 0===t&&(t=this.context.getDefaultValueForInput(this.model.type,e.name),this._resetReactVirtualDOM&&this._resetReactVirtualDOM()),this.queueInput(e.name,t)}},Node.prototype._onNodeModelVariantUpdated=function(e){this.setVariant(e)},module.exports=Node},480:(e,t,n)=>{"use strict";var o=n(5627),i=n(6365),s=n(3187);const r=n(84);function a(e){(e=e||{}).runningInEditor=!!e.hasOwnProperty("runningInEditor")&&e.runningInEditor,this._dirtyNodes=[],this.callbacksAfterUpdate=[],this.graphModel=e.graphModel,this.platform=e.platform,this.eventEmitter=new o,this.eventEmitter.setMaxListeners(1e6),this.eventSenderEmitter=new o,this.eventSenderEmitter.setMaxListeners(1e6),this.globalValues={},this.globalsEventEmitter=new o,this.globalsEventEmitter.setMaxListeners(1e6),this.runningInEditor=e.runningInEditor,this.currentFrameTime=0,this.frameNumber=0,this.updateIteration=0,this.nodeRegister=new i(this),this.timerScheduler=new s(this.scheduleUpdate.bind(this)),this.componentModels={},this.debugInspectorsEnabled=!1,this.connectionsToPulse={},this.connectionsToPulseChanged=!1,this.debugInspectors={},this.connectionPulsingCallbackScheduled=!1,this.editorConnection=e.editorConnection,this.rootComponent=void 0,this._outputHistory={},this._signalHistory={},this.warningTypes={},this.bundleFetchesInFlight=new Map,this.variants=new r({graphModel:this.graphModel,getNodeScope:()=>this.rootComponent?this.rootComponent.nodeScope:null}),this.editorConnection&&(this.editorConnection.on("debugInspectorsUpdated",(e=>{this.onDebugInspectorsUpdated(e)})),this.editorConnection.on("getConnectionValue",(({clientId:e,connectionId:t})=>{if(this.editorConnection.clientId!==e)return;const n=this._outputHistory[t];this.editorConnection.sendConnectionValue(t,n?n.value:void 0)})))}a.prototype.setRootComponent=function(e){this.rootComponent=e},a.prototype.getCurrentTime=function(){return this.platform.getCurrentTime()},a.prototype.onDebugInspectorsUpdated=function(e){this.debugInspectorsEnabled&&(e=e.map((e=>{if("connection"===e.type){const t=e.connection;e.id=t.fromId+t.fromProperty}else"node"===e.type&&(e.id=e.nodeId);return e})),this.debugInspectors={},e.forEach((e=>this.debugInspectors[e.id]=e)),this.sendDebugInspectorValues())},a.prototype.updateDirtyNodes=function(){var e,t,n=!0,o=0;for(this.updateIteration++,this.isUpdating=!0;n&&o<10;){var i=this._dirtyNodes;for(this._dirtyNodes=[],e=0,t=i.length;e0||this._dirtyNodes.length>0,o++}this.isUpdating=!1},a.prototype.update=function(){this.frameNumber++,this.updateDirtyNodes(),this.timerScheduler.hasPendingTimers()&&(this.scheduleUpdate(),this.timerScheduler.runTimers(this.currentFrameTime)),this.debugInspectorsEnabled&&this.sendDebugInspectorValues()},a.prototype.reset=function(){this.eventEmitter.emit("applicationDataReloaded");var e=this.eventEmitter;["frameStart","frameEnd"].forEach((function(t){e.removeAllListeners(t)})),this.globalValues={},this._dirtyNodes.length=0,this.callbacksAfterUpdate.length=0,this.timerScheduler.runningTimers=[],this.timerScheduler.newTimers=[],this.rootComponent=void 0,this.clearDebugInspectors()},a.prototype.nodeIsDirty=function(e){this._dirtyNodes.push(e),this.scheduleUpdate()},a.prototype.scheduleUpdate=function(){this.eventEmitter.emit("scheduleUpdate")},a.prototype.scheduleAfterUpdate=function(e){this.callbacksAfterUpdate.push(e),this.scheduleUpdate()},a.prototype.scheduleNextFrame=function(e){this.eventEmitter.once("frameStart",e),this.scheduleUpdate()},a.prototype.setGlobalValue=function(e,t){this.globalValues[e]=t,this.globalsEventEmitter.emit(e)},a.prototype.getGlobalValue=function(e){return this.globalValues[e]},a.prototype.registerComponentModel=function(e){if(this.componentModels.hasOwnProperty(e.name))throw new Error("Duplicate component name "+e.name);this.componentModels[e.name]=e;var t=this;e.on("renamed",(function(n){delete t.componentModels[n.oldName],t.componentModels[n.newName]=e}),this)},a.prototype.deregisterComponentModel=function(e){this.componentModels.hasOwnProperty(e.name)&&(this.componentModels[e.name].removeListenersWithRef(this),delete this.componentModels[e.name])},a.prototype.fetchComponentBundle=async function(e){const t=async e=>{let t=`${Noodl.Env.BaseUrl||"/"}noodl_bundles/${e}.json`;const n=await fetch(t);if(404===n.status)throw new Error("Component not found "+e);const o=await n.json();for(const e of o)!1===this.graphModel.hasComponentWithName(e.name)&&await this.graphModel.importComponentFromEditorData(e)};if(this.bundleFetchesInFlight.has(e))await this.bundleFetchesInFlight.get(e);else{const n=t(e);this.bundleFetchesInFlight.set(e,n),await n}},a.prototype.getComponentModel=async function(e){if(!e)throw new Error("Component instance must have a name");if(!1===this.componentModels.hasOwnProperty(e)){const t=this.graphModel.getBundleContainingComponent(e);if(!t)throw new Error("Can't find component model for "+e);for(const e of this.graphModel.getBundleDependencies(t))this.fetchComponentBundle(e);await this.fetchComponentBundle(t)}return this.componentModels[e]},a.prototype.hasComponentModelWithName=function(e){return this.componentModels.hasOwnProperty(e)},a.prototype.createComponentInstanceNode=async function(e,t,o,i){var s=new(n(3657))(this,t,o);s.name=e;for(const e in i)s[e]=i[e];const r=await this.getComponentModel(e);return await s.setComponentModel(r),s},a.prototype._formatConnectionValue=function(e){if("object"==typeof e&&e&&e.constructor&&"Node"===e.constructor.name)e=" "+e.name;else if("object"==typeof e&&"undefined"!=typeof window&&e instanceof HTMLElement)e=`DOM Node <${e.tagName}>`;else{if("string"==typeof e&&!e.startsWith("[Signal]"))return'"'+e+'"';if(Number.isNaN(e))return"NaN"}return e},a.prototype.connectionSentValue=function(e,t){if(!this.editorConnection||!this.editorConnection.isConnected()||!this.debugInspectorsEnabled)return;const n=this.getCurrentTime();if(this._outputHistory[e.id]={value:t,timestamp:n},this.connectionsToPulse.hasOwnProperty(e.id))return void(this.connectionsToPulse[e.id].timestamp=n);const o=[];e.connections.forEach((t=>{o.push(e.owner.id+e.name+t.node.id+t.inputPortName)})),this.connectionsToPulse[e.id]={timestamp:n,connections:o},this.connectionsToPulseChanged=!0,!1===this.connectionPulsingCallbackScheduled&&(this.connectionPulsingCallbackScheduled=!0,setTimeout(this.clearOldConnectionPulsing.bind(this),100))},a.prototype.connectionSentSignal=function(e){const t=e.id;this._signalHistory.hasOwnProperty(t)||(this._signalHistory[t]={count:0}),this._signalHistory[t].count++,this.connectionSentValue(e,"[Signal] Trigger count "+this._signalHistory[t].count)},a.prototype.clearDebugInspectors=function(){this.debugInspectors={},this.connectionsToPulse={},this.editorConnection.sendPulsingConnections(this.connectionsToPulse)},a.prototype.clearOldConnectionPulsing=function(){this.connectionPulsingCallbackScheduled=!1;var e=this.getCurrentTime(),t=this;Object.keys(this.connectionsToPulse).forEach((function(n){var o=t.connectionsToPulse[n];e-o.timestamp>100&&(t.connectionsToPulseChanged=!0,delete t.connectionsToPulse[n])})),this.connectionsToPulseChanged&&(this.connectionsToPulseChanged=!1,this.editorConnection.sendPulsingConnections(this.connectionsToPulse)),Object.keys(this.connectionsToPulse).length>0&&(this.connectionPulsingCallbackScheduled=!0,setTimeout(this.clearOldConnectionPulsing.bind(this),500))},a.prototype._getDebugInspectorValueForNode=function(e){if(!this.rootComponent)return;const t=this.rootComponent.nodeScope.getNodesWithIdRecursive(e),n=t[t.length-1];if(n&&n.getInspectInfo){const t=n.getInspectInfo();if(void 0!==t)return{type:"node",id:e,value:t}}},a.prototype.sendDebugInspectorValues=function(){const e=[];for(const t in this.debugInspectors){const n=this.debugInspectors[t];if("connection"===n.type&&this._outputHistory.hasOwnProperty(t)){const n=this._outputHistory[t].value;e.push({type:"connection",id:t,value:this._formatConnectionValue(n)})}else if("node"===n.type){const n=this._getDebugInspectorValueForNode(t);n&&e.push(n)}}e.length>0&&this.editorConnection.sendDebugInspectorValues(e),this.connectionsToPulseChanged&&(this.connectionsToPulseChanged=!1,this.editorConnection.sendPulsingConnections(this.connectionsToPulse))},a.prototype.setDebugInspectorsEnabled=function(e){this.debugInspectorsEnabled=e,this.editorConnection.debugInspectorsEnabled=e,e&&this.sendDebugInspectorValues()},a.prototype.sendGlobalEventFromEventSender=function(e,t){this.eventSenderEmitter.emit(e,t)},a.prototype.setPopupCallbacks=function({onShow:e,onClose:t}){this.onShowPopup=e,this.onClosePopup=t},a.prototype.showPopup=async function(e,t,n){if(!this.onShowPopup)return;const o=this.rootComponent.nodeScope,i=await o.createNode(e);for(const e in t)i.setInputValue(e,t[e]);i.popupParent=n?.senderNode||null;const s=o.createPrimitiveNode("Group");s.setInputValue("flexDirection","node"),s.setInputValue("cssClassName","noodl-popup");const r=this.graphModel.getSettings().bodyScroll;s.setInputValue("position",r?"fixed":"absolute");var a=i.nodeScope.getNodesWithType("NavigationClosePopup");if(a&&a.length>0)for(var u=0;u{this.scheduleNextFrame((()=>{o.hasNodeWithId(s.id)&&(this.onClosePopup(s),o.deleteNode(s),n&&n.onClosePopup&&n.onClosePopup(e,t))}))}));this.onShowPopup(s),requestAnimationFrame((()=>{s.addChild(i)}))},a.prototype.setWarningTypes=function(e){Object.assign(this.warningTypes,e)},a.prototype.isWarningTypeEnabled=function(e){return!this.warningTypes.hasOwnProperty(e)||!!this.warningTypes[e]},a.prototype.getDefaultValueForInput=function(e,t){if(!1===this.nodeRegister.hasNode(e))return;const n=this.nodeRegister.getNodeMetadata(e).inputs[t];return n?n.type.defaultUnit?{value:n.default,unit:n.type.defaultUnit}:n.default:void 0},e.exports=a},3157:(e,t,n)=>{const o=n(2487),i=n(6607);function s(e,t,n){const o=e.registerInputIfNeeded;e.registerInputIfNeeded=function(i){if(o&&o.call(e,i),e.hasInput(i)||!i.startsWith(t))return;const s=Number(i.slice(t.length+1));e.registerInput(i,{type:n.type,set:n.createSetter.call(e,s)})}}e.exports={defineNode:function(e){if(!e.category)throw new Error("Node must have a category");if(!e.name)throw new Error("Node must have a name");const t={inputs:{},outputs:{},category:e.category,dynamicports:e.dynamicports,exportDynamicPorts:e.exportDynamicPorts,useVariants:e.useVariants,allowChildren:e.allowChildren,allowChildrenWithCategory:e.allowChildrenWithCategory,singleton:e.singleton,connectionPanel:e.connectionPanel,allowAsChild:e.allowAsChild,visualStates:e.visualStates,panels:e.panels,color:e.color,usePortAsLabel:e.usePortAsLabel,portLabelTruncationMode:e.portLabelTruncationMode,name:e.name,displayNodeName:e.displayNodeName||e.displayName,deprecated:e.deprecated,haveComponentPorts:e.haveComponentPorts,version:e.version,module:e.module,docs:e.docs,allowAsExportRoot:e.allowAsExportRoot,nodeDoubleClickAction:e.nodeDoubleClickAction,searchTags:e.searchTags};e._internal=e._internal||{},e.prototypeExtensions=e.methods||e.prototypeExtensions||{},e.inputs=e.inputs||{},e.outputs=e.outputs||{},e.initialize=e.initialize||function(){};let n={};function r(e,t){o.call(this,e,t)}(function(e,t,n){Object.keys(n).forEach((function(o){!function(e,t,n,o){if(e.hasOwnProperty(n))throw new Error("Input property "+n+" already registered");o.set||o.valueChangedToTrue||(o.set=()=>{}),o.set&&(e[n]={set:o.set},["color","textStyle","array"].forEach((t=>{!o.type||o.type!==t&&o.type.name!==t||(e[n].type=t)}))),o.setUnitType&&(e[n].setUnitType=o.setUnitType),t.inputs[n]={displayName:o.displayName,editorName:o.editorName,group:o.group,type:o.type,default:o.default,index:o.index,exportToEditor:!o.hasOwnProperty("exportToEditor")||o.exportToEditor,inputPriority:o.inputPriority||0,tooltip:o.tooltip,tab:o.tab,popout:o.popout,allowVisualStates:o.allowVisualStates,nodeDoubleClickAction:o.nodeDoubleClickAction},o.valueChangedToTrue&&(t.inputs[n].type={name:"signal",allowConnectionsOnly:!0})}(e,t,o,n[o])}))})(n,t,e.inputs),function(e,t){Object.keys(t).forEach((function(n){var o=t[n];e.outputs[n]={displayName:o.displayName,editorName:o.editorName,group:o.group,type:o.type,index:o.index,exportToEditor:!o.hasOwnProperty("exportToEditor")||o.exportToEditor}}))}(t,e.outputs),Object.keys(e.prototypeExtensions).forEach((function(t){e.prototypeExtensions[t].value||(e.prototypeExtensions[t]={value:e.prototypeExtensions[t]})})),r.prototype=Object.create(o.prototype,e.prototypeExtensions),Object.defineProperty(r.prototype,"name",{value:e.name}),e.getInspectInfo&&(r.prototype.getInspectInfo=e.getInspectInfo),e.nodeScopeDidInitialize&&(r.prototype.nodeScopeDidInitialize=e.nodeScopeDidInitialize);const a=function(o,a,u){const c=new r(o,a);var l,d;return c._inputs=Object.create(n),Object.keys(e.inputs).forEach((function(t){var n=e.inputs[t];n.valueChangedToTrue&&(c._inputs[t]={set:i.createSetter({valueChangedToTrue:n.valueChangedToTrue})})})),Object.keys(e.outputs).forEach((function(t){var n=e.outputs[t];"signal"===n.type?c.registerOutput(t,{getter:function(){}}):c.registerOutput(t,n)})),e.numberedInputs&&function(e,t){for(const n of Object.keys(t))s(e,n,t[n])}(c,e.numberedInputs),c.nodeScope=u,l=c._inputValues,d=t.inputs,Object.keys(d).forEach((e=>{const t=d[e].default;void 0!==t&&(d[e].type.defaultUnit?l[e]={unit:d[e].type.defaultUnit,value:t}:l[e]=t)})),e.initialize.call(c),c};return a.metadata=t,e.numberedInputs&&function(e,t,n){const o=Object.keys(n);o.length&&(e.setupNumberedInputDynamicPorts=function(e,i){const s=e.editorConnection;function r(e){const t=o.map((t=>function(e,t,n){const o=e.component.getConnectionsTo(e.id).map((e=>e.targetPort)),i=Object.keys(e.parameters).concat(o).filter((e=>e.startsWith(t+" "))),s=(i.length?1+Math.max(...i.map((e=>Number(e.slice(t.length+1))))):0)+1,r=[];for(let e=0;e{r(e),e.on("parameterUpdated",(()=>{r(e)})),e.on("inputConnectionAdded",(()=>{r(e)})),e.on("inputConnectionRemoved",(()=>{r(e)}))}))})}(a,e.name,e.numberedInputs),a},extend:function e(t,n){for(var o in n)if("initialize"===o&&t.initialize){var i=t.initialize;t.initialize=function(){i.call(this),n.initialize.call(this)}}else n[o]&&n[o].constructor===Object?t[o]=e(t[o]||{},n[o]):n[o]&&n[o].constructor===Array&&t[o]&&t[o].constructor==Array?t[o]=t[o].concat(n[o]):t[o]=n[o];return t}}},511:e=>{"use strict";function t(e,t,n){var o={name:e,type:t.type,plug:n};return t.group&&(o.group=t.group),t.displayName&&(o.displayName=t.displayName),t.description&&(o.description=t.description),t.editorName&&(o.editorName=t.editorName),void 0!==t.default&&(o.default=t.default),t.hasOwnProperty("index")&&(o.index=t.index),t.tooltip&&(o.tooltip=t.tooltip),t.tab&&(o.tab=t.tab),t.popout&&(o.popout=t.popout),t.allowVisualStates&&(o.allowVisualStates=t.allowVisualStates),o}e.exports=function(e){var n={typecasts:[{from:"string",to:["number","boolean","image","color","enum","textStyle","dimension","array","object"]},{from:"boolean",to:["number","string","signal"]},{from:"number",to:["boolean","string","dimension"]},{from:"date",to:["string"]},{from:"signal",to:["boolean","number"]},{from:"image",to:[]},{from:"cloudfile",to:["string","image"]},{from:"color",to:[]},{from:"enum",to:[]},{from:"object",to:[]},{from:"domelement",to:[]},{from:"reference",to:[]},{from:"font",to:[]},{from:"textStyle",to:["string"]},{from:"collection",to:["array"]},{from:"array",to:["collection"]}],dynamicports:[{type:"conditionalports",name:"basic"},{type:"expand",name:"basic"}],colors:{nodes:{component:{base:"#643D8B",baseHighlighted:"#79559b",header:"#4E2877",headerHighlighted:"#643d8b",outline:"#4E2877",outlineHighlighted:"#b58900",text:"#dbd0e4"},visual:{base:"#315272",baseHighlighted:"#4d6784",header:"#173E5D",headerHighlighted:"#315272",outline:"#173E5D",outlineHighlighted:"#b58900",text:"#cfd5de"},data:{base:"#465524",baseHighlighted:"#5b6a37",header:"#314110",headerHighlighted:"#465524",outline:"#314110",outlineHighlighted:"#b58900",text:"#d2d6c5"},javascript:{base:"#7E3660",baseHighlighted:"#944e74",header:"#67214B",headerHighlighted:"#7e3660",outline:"#67214B",outlineHighlighted:"#d57bab",text:"#e4cfd9"},default:{base:"#4C4F59",baseHighlighted:"#62656e",header:"#373B45",headerHighlighted:"#4c4f59",outline:"#373B45",outlineHighlighted:"#b58900",text:"#d3d4d6"}},connections:{signal:{normal:"#006f82",highlighted:"#7ec2cf",pulsing:"#ffffff"},default:{normal:"#875d00",highlighted:"#e5ae32",pulsing:"#ffffff"}}},nodetypes:[{name:"Component Children",shortDesc:"This node is a placeholder for where children of this component will be inserted.",docs:"https://docs.noodl.net/nodes/component-utilities/component-children",color:"component",allowAsChild:!0,category:"Visual",haveComponentChildren:["Visual"]}]},o=Object.keys(e._constructors);o.forEach((function(o){var i=e._constructors[o].metadata,s={name:o,searchTags:i.searchTags};n.nodetypes.push(s),i.version&&(s.version=i.version),i.displayNodeName&&(s.displayNodeName=i.displayNodeName),i.nodeDoubleClickAction&&(s.nodeDoubleClickAction=i.nodeDoubleClickAction),i.shortDesc&&(s.shortDesc=i.shortDesc),i.module&&(s.module=i.module),i.deprecated&&(s.deprecated=!0),i.haveComponentPorts&&(s.haveComponentPorts=!0),"Visual"===i.category&&(s.allowAsChild=!0,s.allowAsExportRoot=!0,s.color="visual"),void 0!==i.allowAsExportRoot&&(s.allowAsExportRoot=i.allowAsExportRoot),i.allowChildren&&(s.allowChildrenWithCategory=["Visual"],s.color="visual"),i.allowChildrenWithCategory&&(s.allowChildrenWithCategory=i.allowChildrenWithCategory),i.singleton&&(s.singleton=!0),i.allowAsChild&&(s.allowAsChild=!0),i.docs&&(s.docs=i.docs),i.shortDocs?s.shortDocs=i.shortDocs:i.docs&&0===i.docs.indexOf("https://docs.noodl.net")&&(s.shortDocs=i.docs.replace("/#","")+"-short.md"),s.category=i.category,i.panels&&(s.panels=i.panels),i.usePortAsLabel&&(s.usePortAsLabel=i.usePortAsLabel,s.portLabelTruncationMode=i.portLabelTruncationMode),i.color&&(s.color=i.color),i.dynamicports&&(s.dynamicports=function(e){const n=[];for(const o of e.dynamicports)if(o.ports||o.template||o.port||o.channelPort)n.push(o);else if(o.inputs||o.outputs){const i=[];if(o.inputs)for(const n of o.inputs)i.push(t(n,e.inputs[n],"input"));if(o.outputs)for(const n of o.outputs)i.push(t(n,e.outputs[n],"output"));const s={name:o.name||"conditionalports/basic",condition:o.condition,ports:i};n.push(s)}return n}(i)),i.exportDynamicPorts&&(s.exportDynamicPorts=i.exportDynamicPorts),i.visualStates&&(s.visualStates=i.visualStates),i.useVariants&&(s.useVariants=i.useVariants),i.connectionPanel&&(s.connectionPanel=i.connectionPanel),s.ports=[];var r=s.dynamicports||[],a={},u={};r.filter((e=>void 0!==e.channelPort)).forEach((e=>{u[e.channelPort.plug+"/"+e.channelPort.name]=!0})),r.length&&(s.dynamicports=r),Object.keys(i.inputs).forEach((function(e){if(!a.hasOwnProperty("input/"+e)&&!u.hasOwnProperty("input/"+e)){var n=i.inputs[e];!1!==n.exportToEditor&&s.ports.push(t(e,n,"input"))}})),Object.keys(i.outputs).forEach((function(e){var t,n,o;a.hasOwnProperty("output/"+e)||u.hasOwnProperty("output/"+e)||(t=e,n=i.outputs[e],o={name:t,type:n.type,plug:"output"},n.group&&(o.group=n.group),n.displayName&&(o.displayName=n.displayName),n.editorName&&(o.editorName=n.editorName),n.hasOwnProperty("index")&&(o.index=n.index),s.ports.push(o))}))})),n.nodeIndex={coreNodes:[{name:"UI Elements",description:"Buttons, inputs, containers, media",type:"visual",subCategories:[{name:"Basic Elements",items:["Group","net.noodl.visual.columns","Text","Image","Video","Circle","net.noodl.visual.icon"]},{name:"UI Controls",items:["net.noodl.controls.button","net.noodl.controls.checkbox","net.noodl.controls.options","net.noodl.controls.radiobutton","Radio Button Group","net.noodl.controls.range","net.noodl.controls.textinput"]}]},{name:"Navigation & Popups",description:"Page routing, navigation, popups",type:"logic",subCategories:[{name:"Navigation",items:["Router","RouterNavigate","PageInputs","net.noodl.externallink","PageStackNavigateToPath"]},{name:"Component Stack",items:["Page Stack","PageStackNavigate","PageStackNavigateBack"]},{name:"Popups",items:["NavigationShowPopup","NavigationClosePopup"]}]},{name:"Logic & Utilities",description:"Logic, events, string manipulation",type:"logic",subCategories:[{name:"General Utils",items:["States","Value Changed","Timer","Color Blend","Number Remapper","Counter","Drag","net.noodl.animatetovalue"]},{name:"Logic",items:["Boolean To String","Switch","And","Or","Condition","Inverter"]},{name:"Events",items:["Event Sender","Event Receiver"]},{name:"String Manipulation",items:["Substring","String Mapper","String Format","Date To String","Unique Id"]},{name:"System",items:["Screen Resolution","Open File Picker"]},{name:"Variables",items:["String","Boolean","Color","Number"]}]},{name:"Component Utilities",description:"Component inputs, outputs & object",type:"component",subCategories:[{name:"",items:["Component Inputs","Component Outputs","Component Children","net.noodl.ComponentObject","net.noodl.ParentComponentObject","net.noodl.SetComponentObjectProperties","net.noodl.SetParentComponentObjectProperties"]}]},{name:"Read & Write Data",description:"Arrays, objects, cloud data",type:"data",subCategories:[{name:"",items:["RunTasks","For Each","For Each Actions","Model2","SetModelProperties","NewModel","Set Variable","Variable2"]},{name:"Array",items:["Collection2","CollectionNew","CollectionRemove","CollectionClear","CollectionInsert","Filter Collection","Map Collection","Static Data"]},{name:"Cloud Data",items:["DbModel2","NewDbModelProperties","FilterDBModels","SetDbModelProperties","DbCollection2","DeleteDbModelProperties","AddDbModelRelation","RemoveDbModelRelation","Cloud File","Upload File","CloudFunction2","DbConfig"]},{name:"User",items:["net.noodl.user.LogIn","net.noodl.user.LogOut","net.noodl.user.SignUp","net.noodl.user.User","net.noodl.user.SetUserProperties","net.noodl.user.VerifyEmail","net.noodl.user.SendEmailVerification","net.noodl.user.ResetPassword","net.noodl.user.RequestPasswordReset"]},{name:"External Data",items:["REST2"]}]},{name:"Custom Code",description:"Custom JavaScript and CSS",type:"javascript",subCategories:[{name:"",items:["Expression","JavaScriptFunction","Javascript2","CSS Definition"]}]},{name:"Cloud Functions",description:"Nodes to be used in cloud functions",type:"data",subCategories:[{name:"",items:["noodl.cloud.request","noodl.cloud.response"]},{name:"Cloud Data",items:["noodl.cloud.aggregate"]}]}]};const i=[];return o.forEach((t=>{e._constructors[t].metadata.module&&i.push(t)})),i.length&&(n.nodeIndex.moduleNodes=[{name:"",items:i}]),n}},6365:e=>{"use strict";function t(e){this._constructors={},this.context=e}t.prototype.register=function(e){var t=e.metadata.name;this._constructors[t]=e},t.prototype.createNode=function(e,t,n){if(!1===this._constructors.hasOwnProperty(e))throw new Error("Unknown node type with name "+e);return this._constructors[e](this.context,t,n)},t.prototype.getNodeMetadata=function(e){if(!1===this._constructors.hasOwnProperty(e))throw new Error("Unknown node type with name "+e);return this._constructors[e].metadata},t.prototype.hasNode=function(e){return this._constructors.hasOwnProperty(e)},t.prototype.getInputType=function(e,t){const n=this.getNodeMetadata(e);return n.inputs[t]&&n.inputs[t].type},e.exports=t},8197:e=>{"use strict";e.exports={node:{name:"Component Inputs",shortDesc:"This node is used to define the inputs of a component.",docs:"https://docs.noodl.net/nodes/component-utilities/component-inputs",panels:[{name:"PortEditor",context:["select","connectFrom"],title:"Inputs",plug:"output",type:{name:"*"},canArrangeInGroups:!0},{name:"PropertyEditor",hidden:!0}],getInspectInfo(){return{type:"value",value:this.nodeScope.componentOwner._internal.inputValues}},color:"component",haveComponentPorts:!0,category:"Component Utilities",methods:{registerOutputIfNeeded:function(e){this.hasOutput(e)||this.registerOutput(e,{getter:function(){return this.nodeScope.componentOwner._internal.inputValues[e]}})},_updateDependencies:function(){this.nodeScope.componentOwner.update()}}}}},3657:(e,t,n)=>{"use strict";var o=n(2487),i=n(61);let s=0;function r(e,t,n){o.call(this,e,t),this.nodeScope=new i(e,this),this.parentNodeScope=n,this._internal.childRoot=null,this._internal.componentOutputValues={},this._internal.componentOutputs=[],this._internal.componentInputs=[],this._internal.inputValues={},this._internal.roots=[],this._internal.instanceId="__$ndl_componentInstaceId"+s,this.nodeScope.modelScope=n?n.modelScope:void 0,s++}r.prototype=Object.create(o.prototype,{setComponentModel:{value:async function(e){this.componentModel=e;var t=this;await this.nodeScope.setComponentModel(e),this._internal.componentInputs=this.nodeScope.getNodesWithType("Component Inputs"),this._internal.componentOutputs=this.nodeScope.getNodesWithType("Component Outputs"),Object.values(e.getInputPorts()).forEach(this.registerComponentInputPort.bind(this)),Object.values(e.getOutputPorts()).forEach(this.registerComponentOutputPort.bind(this));const n=e.roots||[];this._internal.roots=n.map((e=>this.nodeScope.getNodeWithId(e))),e.on("rootAdded",(e=>{this._internal.roots.push(this.nodeScope.getNodeWithId(e)),this.forceUpdate()}),this),e.on("rootRemoved",(function(e){const t=this._internal.roots.findIndex((t=>t.id===e));-1!==t&&this._internal.roots.splice(t,1),this.forceUpdate()}),this),e.on("inputPortAdded",this.registerComponentInputPort.bind(this),this),e.on("outputPortAdded",this.registerComponentOutputPort.bind(this),this),e.on("inputPortRemoved",(function(e){t.hasInput(e.name)&&t.deregisterInput(e.name)}),this),e.on("outputPortRemoved",(function(e){this.hasOutput(e.name)&&t.deregisterOutput(e.name)}),this),e.on("nodeAdded",(function(e){"Component Inputs"===e.type?t._internal.componentInputs.push(t.nodeScope.getNodeWithId(e.id)):"Component Outputs"===e.type&&t._internal.componentOutputs.push(t.nodeScope.getNodeWithId(e.id))}),this),e.on("nodeRemoved",(function(e){function n(e,t){return e.filter((e=>e.id!==t))}"Component Inputs"===e.type?t._internal.componentInputs=n(t._internal.componentInputs,e.id):"Component Outputs"===e.type&&(t._internal.componentOutputs=n(t._internal.componentOutputs,e.id))}),this),e.on("renamed",(function(e){t.name=e.newName}),this)}},_onNodeDeleted:{value:function(){this.componentModel&&(this.componentModel.removeListenersWithRef(this),this.componentModel=void 0),this.nodeScope.reset(),o.prototype._onNodeDeleted.call(this)}},registerComponentInputPort:{value:function(e){this.registerInput(e.name,{set:function(t){this._internal.inputValues[e.name]=t,this._internal.componentInputs.forEach((function(t){t.registerOutputIfNeeded(e.name),t.flagOutputDirty(e.name)}))}})}},registerComponentOutputPort:{value:function(e){this.registerOutput(e.name,{getter:function(){return this._internal.componentOutputValues[e.name]}})}},setOutputFromComponentOutput:{value:function(e,t){!1!==this.hasOutput(e)&&(this._internal.creatorCallbacks&&this._internal.creatorCallbacks.onOutputChanged&&this._internal.creatorCallbacks.onOutputChanged(e,t,this._internal.componentOutputValues[e]),this._internal.componentOutputValues[e]=t,this.flagOutputDirty(e))}},setChildRoot:{value:function(e){const t=this._internal.childRoot,n=e;if(this._internal.childRoot=n,this.model&&this.model.children){const e=this.parentNodeScope,o=this.model.children.filter((e=>"Component Children"!==e.type)).map((t=>e.getNodeWithId(t.id)));if(t)for(let e=0;e{e.triggerDidMount&&e.triggerDidMount()}))}},render:{value:function(){return 0===this._internal.roots.length?null:this._internal.roots[0].render()}},setChildIndex:{value:function(e){this.getRoots().forEach((t=>t.setChildIndex&&t.setChildIndex(e)))}},addChild:{value:function(e,t){this.getChildRoot().addChild(e,t+this.getChildRootIndex())}},removeChild:{value:function(e){this.getChildRoot().removeChild(e)}},getChildren:{value:function(e){const t=this.getChildRoot();return t?t.getChildren():[]}},isChild:{value:function(e){return!!this.getChildRoot()&&this.getChildRoot().isChild(e)}},contains:{value:function(e){return this.getRoots().some((t=>t.contains&&t.contains(e)))}},_performDirtyUpdate:{value:function(){o.prototype._performDirtyUpdate.call(this);for(var e=this._internal.componentInputs,t=0,n=e.length;t{"use strict";e.exports={node:{category:"Component Utilities",name:"Component Outputs",shortDesc:"This node is used to define the outputs of a component.",docs:"https://docs.noodl.net/nodes/component-utilities/component-outputs",panels:[{name:"PortEditor",context:["select","connectTo"],title:"Outputs",plug:"input",type:{name:"*"},canArrangeInGroups:!0},{name:"PropertyEditor",hidden:!0}],color:"component",haveComponentPorts:!0,prototypeExtensions:{registerInputIfNeeded:function(e){this.hasInput(e)||this.registerInput(e,{set:function(t){this.nodeScope.componentOwner.setOutputFromComponentOutput(e,t)}})}}}}},3113:e=>{"use strict";const t={name:"And",docs:"https://docs.noodl.net/nodes/logic/and",category:"Logic",initialize:function(){this._internal.inputs=[]},getInspectInfo(){return n(this._internal.inputs)},numberedInputs:{input:{displayPrefix:"Input",type:"boolean",createSetter:e=>function(t){if(t=!!t,this._internal.inputs[e]===t)return;this._internal.inputs[e]=t;const o=n(this._internal.inputs);this._internal.result!==o&&(this._internal.result=o,this.flagOutputDirty("result"))}}},outputs:{result:{type:"boolean",displayName:"Result",get(){return this._internal.result}}}};function n(e){return e.length>0&&!1===e.some((e=>!e))}e.exports={node:t}},5010:e=>{"use strict";e.exports={node:{name:"Boolean To String",docs:"https://docs.noodl.net/nodes/utilities/boolean-to-string",category:"Utilities",initialize:function(){this._internal.inputs=[],this._internal.currentSelectedIndex=0,this._internal.indexChanged=!1,this._internal.trueString="",this._internal.falseString=""},inputs:{trueString:{displayName:"String for true",type:"string",set:function(e){this._internal.trueString!==e&&(this._internal.trueString=e,this._internal.currentInput&&this.flagOutputDirty("currentValue"))}},falseString:{displayName:"String for false",type:"string",set:function(e){this._internal.falseString!==e&&(this._internal.falseString=e,this._internal.currentInput||this.flagOutputDirty("currentValue"))}},input:{type:{name:"boolean"},displayName:"Selector",set:function(e){this._internal.currentInput!==e&&(this._internal.currentInput=e,this.flagOutputDirty("currentValue"),this.sendSignalOnOutput("inputChanged"))}}},outputs:{currentValue:{type:"string",displayName:"Current Value",group:"Value",getter:function(){return this._internal.currentInput?this._internal.trueString:this._internal.falseString}},inputChanged:{type:"signal",displayName:"Selector Changed",group:"Signals"}}}}},1665:e=>{"use strict";const t={name:"Condition",docs:"https://docs.noodl.net/nodes/utilities/logic/condition",category:"Logic",initialize:function(){},getInspectInfo(){const e=this.getInputValue("condition");let t;return void 0===e&&(t="[No input]"),t=e,[{type:"value",value:t}]},inputs:{condition:{type:"boolean",displayName:"Condition",group:"General",set(e){this.isInputConnected("eval")||this.scheduleEvaluate()}},eval:{type:"signal",displayName:"Evaluate",group:"Actions",valueChangedToTrue(){this.scheduleEvaluate()}}},outputs:{ontrue:{type:"signal",displayName:"On True",group:"Events"},onfalse:{type:"signal",displayName:"On False",group:"Events"},result:{type:"boolean",displayName:"Is True",group:"Booleans",get(){return!!this.getInputValue("condition")}},isfalse:{type:"boolean",displayName:"Is False",group:"Booleans",get(){return!this.getInputValue("condition")}}},methods:{scheduleEvaluate(){this.scheduleAfterInputsHaveUpdated((()=>{this.flagOutputDirty("result"),this.flagOutputDirty("isfalse");const e=this.getInputValue("condition");this.sendSignalOnOutput(e?"ontrue":"onfalse")}))}}};e.exports={node:t}},3843:e=>{"use strict";const t={name:"Counter",docs:"https://docs.noodl.net/nodes/math/counter",category:"Math",initialize:function(){this._internal.currentValue=0,this._internal.startValue=0,this._internal.startValueSet=!1,this._internal.limitsEnabled=!1,this._internal.limitsMin=0,this._internal.limitsMax=0},getInspectInfo(){return"Count: "+this._internal.currentValue},inputs:{increase:{group:"Actions",displayName:"Increase Count",valueChangedToTrue:function(){this._internal.limitsEnabled&&this._internal.currentValue>=this._internal.limitsMax||(this._internal.currentValue++,this.flagOutputDirty("currentCount"),this.sendSignalOnOutput("countChanged"))}},decrease:{group:"Actions",displayName:"Decrease Count",valueChangedToTrue:function(){this._internal.limitsEnabled&&this._internal.currentValue<=this._internal.limitsMin||(this._internal.currentValue--,this.flagOutputDirty("currentCount"),this.sendSignalOnOutput("countChanged"))}},reset:{group:"Actions",displayName:"Reset To Start",valueChangedToTrue:function(){0!==this.currentValue&&(this._internal.currentValue=this._internal.startValue,this.flagOutputDirty("currentCount"),this.sendSignalOnOutput("countChanged"))}},startValue:{type:"number",displayName:"Start Value",default:0,set:function(e){this._internal.startValue=Number(e),!1===this._internal.startValueSet&&(this._internal.startValueSet=!0,this._internal.currentValue=this._internal.startValue,this.flagOutputDirty("currentCount"),this.sendSignalOnOutput("countChanged"))}},limitsMin:{type:{name:"number"},displayName:"Min Value",group:"Limits",default:0,set:function(e){this._internal.limitsMin=Number(e)}},limitsMax:{type:{name:"number"},displayName:"Max Value",group:"Limits",default:0,set:function(e){this._internal.limitsMax=Number(e)}},limitsEnabled:{type:{name:"boolean"},displayName:"Limits Enabled",group:"Limits",default:!1,set:function(e){this._internal.limitsEnabled=!!e}}},outputs:{currentCount:{displayName:"Current Count",type:"number",getter:function(){return this._internal.currentValue}},countChanged:{displayName:"Count Changed",type:"signal"}}};e.exports={node:t}},8022:(e,t,n)=>{const o=n(4497),i={name:"Cloud File",docs:"https://docs.noodl.net/nodes/data/cloud-data/cloud-file",category:"Cloud Services",color:"data",getInspectInfo(){return this._internal.cloudFile&&this._internal.cloudFile.getUrl()},outputs:{url:{type:"string",displayName:"URL",group:"General",get(){return this._internal.cloudFile&&this._internal.cloudFile.getUrl()}},name:{type:"string",displayName:"Name",group:"General",get(){if(!this._internal.cloudFile)return;const e=this._internal.cloudFile.getName().split("_");return 1===e.length?e[0]:e.slice(1).join("_")}}},inputs:{file:{type:"cloudfile",displayName:"Cloud File",group:"General",set(e){e instanceof o!=0&&(this._internal.cloudFile=e,this.flagOutputDirty("name"),this.flagOutputDirty("url"))}}}};e.exports={node:i}},3690:(e,t,n)=>{const{Node:o,EdgeTriggeredInput:i}=n(3948),s=n(3839),r=n(9160),a=n(4007),u=n(5995),c=n(5802);var l={name:"DbCollection2",docs:"https://docs.noodl.net/nodes/data/cloud-data/query-records",displayName:"Query Records",category:"Cloud Services",usePortAsLabel:"collectionName",color:"data",initialize:function(){var e=this;this._internal.queryParameters={};var t=!1;this._internal.collectionChangedCallback=function(){t||(t=!0,e.scheduleAfterInputsHaveUpdated((function(){e.flagOutputDirty("count"),e.flagOutputDirty("firstItemId"),e.flagOutputDirty("isEmpty"),t=!1})))},this._internal.cloudStoreEvents=function(t){if(!0!==e.isInputConnected("storageFetch")&&void 0!==e._internal.collection&&t.collection===e._internal.name)if("create"===t.type){const o=s.get(t.object.objectId);void 0!==o&&c.matchesQuery(o,e._internal.currentQuery.where)&&n(o)}else if("save"===t.type){const o=s.get(t.objectId);if(void 0!==o){const t=c.matchesQuery(o,e._internal.currentQuery.where);!t&&e._internal.collection.contains(o)?(e._internal.collection.remove(o),e.flagOutputDirty("items"),e.flagOutputDirty("count"),e.flagOutputDirty("firstItemId"),e.flagOutputDirty("isEmpty")):t&&!e._internal.collection.contains(o)&&n(o)}}else if("delete"===t.type){const n=s.get(t.objectId);void 0!==n&&(e._internal.collection.remove(n),e.flagOutputDirty("items"),e.flagOutputDirty("count"),e.flagOutputDirty("firstItemId"),e.flagOutputDirty("isEmpty"))}function n(t){if(void 0!==e._internal.currentQuery.sort){for(var n=0;n0);n++);e._internal.collection.addAtIndex(t,n)}else e._internal.collection.add(t);let o=e._internal.collection.size();void 0!==e._internal.currentQuery.limit&&o>e._internal.currentQuery.limit&&e._internal.collection.remove(e._internal.collection.get(void 0!==e._internal.currentQuery.sort&&"-"===e._internal.currentQuery.sort[0][0]?o-1:0)),e.flagOutputDirty("items"),e.flagOutputDirty("count"),e.flagOutputDirty("firstItemId"),e.flagOutputDirty("isEmpty")}};const n=a.forScope(this.nodeScope.modelScope);n.on("save",this._internal.cloudStoreEvents),n.on("create",this._internal.cloudStoreEvents),n.on("delete",this._internal.cloudStoreEvents),this._internal.storageSettings={}},getInspectInfo(){const e=this._internal.collection;return e?[{type:"value",value:e.items}]:{type:"text",value:"[Not executed yet]"}},inputs:{},outputs:{items:{type:"array",displayName:"Items",group:"General",getter:function(){return this._internal.collection}},firstItemId:{type:"string",displayName:"First Record Id",group:"General",getter:function(){if(this._internal.collection){var e=this._internal.collection.get(0);if(void 0!==e)return e.getId()}}},isEmpty:{type:"boolean",displayName:"Is Empty",group:"General",getter:function(){return!this._internal.collection||0===this._internal.collection.size()}},count:{type:"number",displayName:"Count",group:"General",getter:function(){return this._internal.collection?this._internal.collection.size():0}},fetched:{group:"Events",type:"signal",displayName:"Success"},failure:{group:"Events",type:"signal",displayName:"Failure"},error:{type:"string",displayName:"Error",group:"Error",getter:function(){return this._internal.error}}},prototypeExtensions:{setCollectionName:function(e){this._internal.name=e,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()},setCollection:function(e){this.bindCollection(e),this.flagOutputDirty("firstItemId"),this.flagOutputDirty("isEmpty"),this.flagOutputDirty("items"),this.flagOutputDirty("count")},unbindCurrentCollection:function(){var e=this._internal.collection;e&&(e.off("change",this._internal.collectionChangedCallback),this._internal.collection=void 0)},bindCollection:function(e){this.unbindCurrentCollection(),this._internal.collection=e,e&&e.on("change",this._internal.collectionChangedCallback)},_onNodeDeleted:function(){o.prototype._onNodeDeleted.call(this),this.unbindCurrentCollection();const e=a.forScope(this.nodeScope.modelScope);e.off("insert",this._internal.cloudStoreEvents),e.off("delete",this._internal.cloudStoreEvents),e.off("save",this._internal.cloudStoreEvents)},setError:function(e){this._internal.err=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure")},scheduleFetch:function(){var e=this._internal;e.fetchScheduled||(e.fetchScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{e.fetchScheduled=!1,this.fetch()})))},fetch:function(){this.context.editorConnection&&(void 0===this._internal.name?this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"query-collection",{message:"No collection specified for query"}):this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"query-collection"));const e=r.get(),t=this.getStorageFilter(),n=this.getStorageLimit(),o=this.getStorageSkip(),i=this.getStorageFetchTotalCount();this._internal.currentQuery={where:t.where,sort:t.sort,limit:n,skip:o},a.forScope(this.nodeScope.modelScope).query({collection:this._internal.name,where:t.where,sort:t.sort,limit:n,skip:o,count:i,success:(t,n)=>{void 0!==t&&e.set(t.map((e=>a._fromJSON(e,this._internal.name,this.nodeScope.modelScope)))),void 0!==n&&(this._internal.storageSettings.storageTotalCount=n,this.hasOutput("storageTotalCount")&&this.flagOutputDirty("storageTotalCount")),this.setCollection(e),this.sendSignalOnOutput("fetched")},error:t=>{this.setCollection(e),this.setError(t||"Failed to fetch.")}})},getStorageFilter:function(){const e=this._internal.storageSettings;if(void 0===e.storageFilterType||"simple"===e.storageFilterType)return{where:void 0!==this._internal.visualFilter?c.convertVisualFilter(this._internal.visualFilter,{queryParameters:this._internal.queryParameters,collectionName:this._internal.name}):void 0,sort:void 0!==this._internal.visualSorting?c.convertVisualSorting(this._internal.visualSorting):void 0};if("json"===e.storageFilterType){if(!this._internal.filterFunc)try{var t=e.storageJSONFilter;t=t.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,""),this._internal.filterVariables=t.match(/\$[A-Za-z0-9]+/g)||[];var n=["filter","where","sort","Inputs"].concat(this._internal.filterVariables).concat([t]);this._internal.filterFunc=Function.apply(null,n)}catch(e){this._internal.filterFunc=void 0,console.log("Error while parsing filter script: "+e)}if(!this._internal.filterFunc)return;var o={},i=[],s=this,r=function(e){o=c.convertFilterOp(e,{collectionName:s._internal.name,error:function(e){s.context.editorConnection.sendWarning(s.nodeScope.componentOwner.name,s.id,"query-collection-filter",{message:e})}})};const u={};for(let t in e)t.startsWith("storageFilterValue-")&&(u[t.substring(19)]=e[t]);var a=[r,r,function(e){i=e},u];this._internal.filterVariables.forEach((t=>{a.push(e["storageFilterValue-"+t.substring(1)])}));try{this._internal.filterFunc.apply(this,a)}catch(e){console.log("Error while running filter script: "+e)}return{where:o,sort:i}}},getStorageLimit:function(){const e=this._internal.storageSettings;return e.storageEnableLimit?e.storageLimit||10:void 0},getStorageSkip:function(){const e=this._internal.storageSettings;return e.storageEnableLimit?e.storageSkip||0:void 0},getStorageFetchTotalCount:function(){return!!this._internal.storageSettings.storageEnableCount},registerOutputIfNeeded:function(e){this.hasOutput(e)||this.registerOutput(e,{getter:d.bind(this,e)})},setVisualFilter:function(e){this._internal.visualFilter=e,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()},setVisualSorting:function(e){this._internal.visualSorting=e,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()},setQueryParameter:function(e,t){this._internal.queryParameters[e]=t,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()},registerInputIfNeeded:function(e){if(this.hasInput(e))return;if(e.startsWith("qp-"))return this.registerInput(e,{set:this.setQueryParameter.bind(this,e.substring(3))});const t={storageFetch:this.scheduleFetch.bind(this)};if(t[e])return this.registerInput(e,{set:i.createSetter({valueChangedToTrue:t[e]})});const n={collectionName:this.setCollectionName.bind(this),visualFilter:this.setVisualFilter.bind(this),visualSort:this.setVisualSorting.bind(this)};if(n[e])return this.registerInput(e,{set:n[e]});this.registerInput(e,{set:p.bind(this,e)})}}};function d(e){return this._internal.storageSettings[e]}function p(e,t){this._internal.storageSettings[e]=t,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()}function h(e,t,n,o){var i=[];const s=o.getMetaData("dbCollections"),r=o.getMetaData("systemCollections");if(i.push({name:"collectionName",type:{name:"enum",enums:[{label:"User",value:"_User"},{label:"Role",value:"_Role"}].concat(void 0!==s?s.map((e=>({value:e.name,label:e.name}))):[]),allowEditOnly:!0},displayName:"Class",plug:"input",group:"General"}),i.push({name:"storageFilterType",type:{name:"enum",allowEditOnly:!0,enums:[{value:"simple",label:"Visual"},{value:"json",label:"Javascript"}]},displayName:"Filter",default:"simple",plug:"input",group:"General"}),i.push({type:"boolean",plug:"input",group:"Limit",name:"storageEnableLimit",displayName:"Use limit"}),t.storageEnableLimit&&(i.push({type:"number",default:10,plug:"input",group:"Limit",name:"storageLimit",displayName:"Limit"}),i.push({type:"number",default:0,plug:"input",group:"Limit",name:"storageSkip",displayName:"Skip"})),i.push({type:"signal",plug:"input",group:"Actions",name:"storageFetch",displayName:"Do"}),i.push({type:"boolean",plug:"input",group:"Total Count",name:"storageEnableCount",displayName:"Fetch total count"}),t.storageEnableCount&&i.push({type:"number",plug:"output",group:"General",name:"storageTotalCount",displayName:"Total Count"}),void 0===t.storageFilterType||"simple"===t.storageFilterType){if(void 0!==t.collectionName){var a=s&&s.find((e=>e.name===t.collectionName));if(void 0===a&&r&&(a=r.find((e=>e.name===t.collectionName))),a&&a.schema&&a.schema.properties){const p=JSON.parse(JSON.stringify(a.schema));function c(e){if(void 0!==e.schema&&void 0!==e.schema.properties)for(var n in e.schema.properties){var o=e.schema.properties[n];"Relation"===o.type&&o.targetClass===t.collectionName&&(void 0===p.relations&&(p.relations={}),void 0===p.relations[e.name]&&(p.relations[e.name]=[]),p.relations[e.name].push({property:n}))}}s&&s.forEach(c),r&&r.forEach(c),i.push({name:"visualFilter",plug:"input",type:{name:"query-filter",schema:p,allowEditOnly:!0},displayName:"Filter",group:"Filter"}),i.push({name:"visualSort",plug:"input",type:{name:"query-sorting",schema:p,allowEditOnly:!0},displayName:"Sort",group:"Sorting"})}if(void 0!==t.visualFilter){const h={};!function e(t){void 0!==t&&(void 0!==t.rules?t.rules.forEach((t=>e(t))):void 0!==t.input&&(h[t.input]=!0))}(t.visualFilter),Object.keys(h).forEach((e=>{i.push({name:"qp-"+e,plug:"input",type:"*",displayName:e,group:"Query Parameters"})}))}}}else if("json"===t.storageFilterType){i.push({type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},plug:"input",group:"Filter",name:"storageJSONFilter",default:"// Write your query script here, check out the reference documentation for examples\nwhere({ })\n",displayName:"Filter"});var l=t.storageJSONFilter;if(l){var d=(l=l.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,"")).match(/\$[A-Za-z0-9]+/g);if(d){const m={};d.forEach((e=>{m[e]=!0})),Object.keys(m).forEach((e=>{i.push({name:"storageFilterValue-"+e.substring(1),displayName:e.substring(1),group:"Filter Values",plug:"input",type:{name:"*",allowConnectionsOnly:!0}})}))}u.parseAndAddPortsFromScript(l,i,{inputPrefix:"storageFilterValue-",inputGroup:"Filter Values",inputType:{name:"*",allowConnectionsOnly:!0},skipOutputs:!0})}}n.sendDynamicPorts(e,i)}e.exports={node:l,setup:function(e,t){function n(n){h(n.id,n.parameters,e.editorConnection,t),n.on("parameterUpdated",(function(o){(o.name.startsWith("storage")||"visualFilter"===o.name||"collectionName"===o.name)&&h(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.dbCollections",(function(o){a.invalidateCollections(),h(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.systemCollections",(function(o){a.invalidateCollections(),h(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.cloudservices",(function(e){a.instance._initCloudServices()}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.DbCollection2",(function(e){n(e)}));for(const e of t.getNodesWithType("DbCollection2"))n(e)}))}}},6204:(e,t,n)=>{"use strict";const o=n(1458);var i={name:"DbConfig",docs:"https://docs.noodl.net/nodes/data/cloud-data/config",displayNodeName:"Config",category:"Cloud Services",usePortAsLabel:"configKey",color:"data",initialize:function(){var e=this._internal;o.instance.getConfig().then((t=>{e.config=t,this.hasOutput("value")&&this.flagOutputDirty("value")}))},getInspectInfo(){const e=this.getValue();return void 0===e?"[No Value]":[{type:"value",value:e}]},inputs:{},outputs:{},methods:{getValue:function(){const e=this._internal;return e.useDevValue&&this.context.editorConnection&&this.context.editorConnection.isRunningLocally()?e.devValue:void 0!==e.config&&void 0!==e.configKey?e.config[e.configKey]:void 0},setInternal:function(e,t){this._internal[e]=t,this.hasOutput("value")&&this.flagOutputDirty("value")},registerOutputIfNeeded:function(e){if(!this.hasOutput(e))return"value"===e?this.registerOutput(e,{getter:this.getValue.bind(this)}):void 0},registerInputIfNeeded:function(e){if(!this.hasInput(e))return"configKey"===e||"useDevValue"===e||"devValue"===e?this.registerInput(e,{set:this.setInternal.bind(this,e)}):void 0}}};e.exports={node:i,setup:function(e,t){function n(n){var o=[];e.editorConnection.clearWarning(n.component.name,n.id,"dbconfig-warning");const i=t.getMetaData("dbConfigSchema");let s;if(i){const t=void 0!==_noodl_cloud_runtime_version;o.push({name:"configKey",displayName:"Parameter",group:"General",type:{name:"enum",enums:Object.keys(i).filter((e=>t||!i[e].masterKeyOnly)).map((e=>({value:e,label:e}))),allowEditOnly:!0},plug:"input"}),void 0!==n.parameters.configKey&&i&&i[n.parameters.configKey]?(s=i[n.parameters.configKey].type,"string"!==s&&"boolean"!==s&&"number"!==s&&"object"!==s&&"array"!==s||(o.push({name:"useDevValue",displayName:"Enable",group:"Local Override",type:"boolean",default:!1,plug:"input"}),!0===n.parameters.useDevValue&&o.push({name:"devValue",displayName:"Value",group:"Local Override",type:s,plug:"input"}))):void 0!==n.parameters.configKey&&e.editorConnection.sendWarning(n.component.name,n.id,"dbconfig-warning",{showGlobally:!0,message:n.parameters.configKey+" config parameter is missing, add it to your cloud service."})}else e.editorConnection.sendWarning(n.component.name,n.id,"dbconfig-warning",{showGlobally:!0,message:"You need an active cloud service."});o.push({name:"value",displayName:"Value",group:"General",type:s||"*",plug:"output"}),e.editorConnection.sendDynamicPorts(n.id,o)}function i(e){n(e),e.on("parameterUpdated",(function(t){n(e)})),t.on("metadataChanged.dbConfigSchema",(function(t){o.instance.clearCache(),n(e)}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.DbConfig",(function(e){i(e)}));for(const e of t.getNodesWithType("DbConfig"))i(e)}))}}},464:(e,t,n)=>{"use strict";const o=n(3839),i=n(4007);e.exports={addInputProperties:function(e){var t={node:Object.assign({},e.node),setup:e.setup},n=Object.assign({},e.node.methods);Object.assign(e.node,{inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),Object.assign(e.node,{initialize:function(){this._internal.inputValues={},t.node.initialize&&t.node.initialize.call(this)}}),Object.assign(e.node.outputs,{}),Object.assign(e.node.inputs,{}),Object.assign(e.node.methods,{registerInputIfNeeded:function(e){this.hasInput(e)||(e.startsWith("prop-")&&this.registerInput(e,{set:this._setInputValue.bind(this,e.substring(5))}),n&&n.registerInputIfNeeded&&n.registerInputIfNeeded.call(this,e))},_setInputValue:function(e,t){this._internal.inputValues[e]=t}})},addModelId:function(e,t){Object.assign({},e.node),e.setup;var n=Object.assign({},e.node.methods);const i=void 0===t||t.includeInputs,s=void 0===t||t.includeOutputs;Object.assign(e.node,{inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),i&&(Object.assign(e.node,{usePortAsLabel:"collectionName"}),e.node.dynamicports=(e.node.dynamicports||[]).concat([{name:"conditionalports/extended",condition:"idSource = explicit OR idSource NOT SET",inputs:["modelId"]}]),Object.assign(e.node.inputs,{idSource:{type:{name:"enum",enums:[{label:"Specify explicitly",value:"explicit"},{label:"From repeater",value:"foreach"}],allowEditOnly:!0},default:"explicit",displayName:"Id Source",group:"General",tooltip:"Choose if you want to specify the Id explicitly, \n or if you want it to be that of the current record in a repeater.",set:function(e){"foreach"===e&&this.scheduleAfterInputsHaveUpdated((()=>{for(var e=this.nodeScope.componentOwner;void 0!==e&&void 0===e._forEachModel&&e.parentNodeScope;)e=e.parentNodeScope.componentOwner;this.setModel(void 0!==e?e._forEachModel:void 0)}))}},modelId:{type:{name:"string",identifierOf:"ModelName",identifierDisplayName:"Object Ids"},displayName:"Id",group:"General",set:function(e){e instanceof o&&(e=e.getId()),this._internal.modelId=e,this.setModelID(e)}}})),s&&Object.assign(e.node.outputs,{id:{type:"string",displayName:"Id",group:"General",getter:function(){return this._internal.model?this._internal.model.getId():this._internal.modelId}}}),Object.assign(e.node.methods,{setCollectionID:function(e){this._internal.collectionId=e,this.clearWarnings()},setModelID:function(e){var t=(this.nodeScope.modelScope||o).get(e);this.setModel(t)},setModel:function(e){this._internal.model=e,this.flagOutputDirty("id")},registerInputIfNeeded:function(e){this.hasInput(e)||("collectionName"===e&&this.registerInput(e,{set:this.setCollectionID.bind(this)}),n&&n.registerInputIfNeeded&&n.registerInputIfNeeded.call(this,e))}})},addBaseInfo:function(e,t){const n=void 0===t||t.includeInputProperties,o=void 0!==t&&t.includeRelations;Object.assign(e.node,{category:"Data",color:"data",inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),Object.assign(e.node.outputs,{failure:{type:"signal",displayName:"Failure",group:"Events"},error:{type:"string",displayName:"Error",group:"Error",getter:function(){return this._internal.error}}}),Object.assign(e.node.methods,{scheduleOnce:function(e,t){const n=this,o="hasScheduled"+e;this._internal[o]||(this._internal[o]=!0,this.scheduleAfterInputsHaveUpdated((function(){n._internal[o]=!1,t()})))},checkWarningsBeforeCloudOp(){return this.clearWarnings(),!!this._internal.collectionId||(this.setError("No class name specified"),!1)},setError:function(e){this._internal.error=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure"),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"storage-op-warning",{message:e,showGlobally:!0})},clearWarnings(){this.context.editorConnection&&this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"storage-op-warning")}}),Object.assign(e,{setup:function(t,s){function r(r){function a(){var i=[];const a=s.getMetaData("dbCollections"),u=s.getMetaData("systemCollections"),c=r.parameters;if(i.push({name:"collectionName",displayName:"Class",group:"General",type:{name:"enum",enums:[{label:"User",value:"_User"},{label:"Role",value:"_Role"}].concat(void 0!==a?a.map((e=>({value:e.name,label:e.name}))):[]),allowEditOnly:!0},plug:"input"}),o&&c.collectionName&&a&&(void 0===(l=a.find((e=>e.name===c.collectionName)))&&u&&(l=u.find((e=>e.name===c.collectionName))),l&&l.schema&&l.schema.properties)){const e=l.schema.properties,t=Object.keys(e).filter((t=>"Relation"===e[t].type)).map((e=>({label:e,value:e})));i.push({name:"relationProperty",displayName:"Relation",group:"General",type:{name:"enum",enums:t,allowEditOnly:!0},plug:"input"})}if(n&&c.collectionName&&a){const e={String:"string",Boolean:"boolean",Number:"number",Date:"date"};var l;if(void 0===(l=a.find((e=>e.name===c.collectionName)))&&u&&(l=u.find((e=>e.name===c.collectionName))),l&&l.schema&&l.schema.properties){var d=l.schema.properties;for(var p in d){var h=d[p];i.find((e=>e.name===p))||i.push({type:{name:e[h.type]?e[h.type]:"*"},plug:"input",group:"Properties",name:"prop-"+p,displayName:p})}}}e._additionalDynamicPorts&&e._additionalDynamicPorts(r,i,s),t.editorConnection.sendDynamicPorts(r.id,i)}a(),r.on("parameterUpdated",(function(e){a()})),s.on("metadataChanged.dbCollections",(function(e){i.invalidateCollections(),a()})),s.on("metadataChanged.systemCollections",(function(e){i.invalidateCollections(),a()}))}t.editorConnection&&t.editorConnection.isRunningLocally()&&s.on("editorImportComplete",(()=>{s.on("nodeAdded."+e.node.name,(function(e){r(e)}));for(const t of s.getNodesWithType(e.node.name))r(t)}))}})},addRelationProperty:function(e){Object.assign({},e.node),e.setup;var t=Object.assign({},e.node.methods);Object.assign(e.node,{inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),Object.assign(e.node.inputs,{targetId:{type:{name:"string",allowConnectionsOnly:!0},displayName:"Target Record Id",group:"General",set:function(e){this._internal.targetModelId=e}}}),Object.assign(e.node.methods,{registerInputIfNeeded:function(e){this.hasInput(e)||("relationProperty"===e&&this.registerInput(e,{set:this.setRelationProperty.bind(this)}),t&&t.registerInputIfNeeded&&t.registerInputIfNeeded.call(this,e))},setRelationProperty:function(e){this._internal.relationProperty=e}})},addAccessControl:function(e){var t={node:Object.assign({},e.node),setup:e.setup},n=Object.assign({},e.node.methods);Object.assign(e.node,{inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),Object.assign(e.node,{initialize:function(){this._internal.accessControl={},t.node.initialize&&t.node.initialize.call(this)}}),Object.assign(e.node.inputs,{accessControl:{type:{name:"proplist",autoName:"Rule",allowEditOnly:!0},index:1e3,displayName:"Access Control Rules",group:"Access Control Rules",set:function(e){this._internal.accessControlRules=e}}});const o=e._additionalDynamicPorts;e._additionalDynamicPorts=function(e,t,n){void 0!==e.parameters.accessControl&&e.parameters.accessControl.length>0&&e.parameters.accessControl.forEach((n=>{const o="acl-"+n.id;t.push({name:o+"-target",displayName:"Target",editorName:n.label+" | Target",plug:"input",type:{name:"enum",enums:[{value:"user",label:"User"},{value:"everyone",label:"Everyone"},{value:"role",label:"Role"}],allowEditOnly:!0},group:n.label+" Access Rule",default:"user",parent:"accessControl",parentItemId:n.id}),"role"===e.parameters[o+"-target"]?t.push({name:o+"-role",displayName:"Role",editorName:n.label+" | Role",group:n.label+" Access Rule",plug:"input",type:"string",parent:"accessControl",parentItemId:n.id}):void 0!==e.parameters[o+"-target"]&&"user"!==e.parameters[o+"-target"]||t.push({name:o+"-userid",displayName:"User Id",group:n.label+" Access Rule",editorName:n.label+" | User Id",plug:"input",type:{name:"string",allowConnectionsOnly:!0},parent:"accessControl",parentItemId:n.id}),t.push({name:o+"-read",displayName:"Read",editorName:n.label+" | Read",group:n.label+" Access Rule",plug:"input",type:{name:"boolean"},default:!0,parent:"accessControl",parentItemId:n.id}),t.push({name:o+"-write",displayName:"Write",editorName:n.label+" | Write",group:n.label+" Access Rule",plug:"input",type:{name:"boolean"},default:!0,parent:"accessControl",parentItemId:n.id})})),o&&o(e,t,n)},Object.assign(e.node.methods,{registerInputIfNeeded:function(e){this.hasInput(e)||(e.startsWith("acl-")&&this.registerInput(e,{set:this.setAccessControl.bind(this,e)}),n&&n.registerInputIfNeeded&&n.registerInputIfNeeded.call(this,e))},_getACL:function(){let e={};function t(e){return{read:void 0===e.read||e.read,write:void 0===e.write||e.write}}const n=function(e){if(void 0!==_noodl_cloud_runtime_version)return e.get("Request").UserId;var t=localStorage["Parse/"+i.instance.appId+"/currentUser"];if(void 0!==t){let e;try{e=JSON.parse(t)}catch(e){}return void 0!==e?e.objectId:void 0}}(this.nodeScope.modelScope);return void 0!==this._internal.accessControlRules&&this._internal.accessControlRules.forEach((o=>{const i=this._internal.accessControl[o.id];if(void 0===i)void 0!==n&&(e[n]={write:!0,read:!0});else if("everyone"===i.target)e["*"]=t(i);else if("user"===i.target){const o=i.userid||n;e[o]=t(i)}else"role"===i.target&&(e["role:"+i.role]=t(i))})),Object.keys(e).length>0?e:void 0},setAccessControl:function(e,t){const n=e.split("-");void 0===this._internal.accessControl[n[1]]&&(this._internal.accessControl[n[1]]={}),this._internal.accessControl[n[1]][n[2]]=t}})}}},3421:(e,t,n)=>{"use strict";var o=n(3839),i=n(464);const s=n(4007);var r={node:{name:"AddDbModelRelation",docs:"https://docs.noodl.net/nodes/data/cloud-data/add-record-relation",displayNodeName:"Add Record Relation",usePortAsLabel:"collectionName",inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue:function(){this.scheduleAddRelation()}}},outputs:{relationAdded:{type:"signal",displayName:"Success",group:"Events"}},methods:{validateInputs:function(){if(!this.context.editorConnection)return;const e=e=>{this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"add-relation",{message:e})};void 0===this._internal.collectionId?e("No class specified"):void 0===this._internal.relationProperty?e("No relation property specified"):void 0===this._internal.targetModelId?e("No target record Id (the record to add a relation to) specified"):void 0===this._internal.model?e("No record Id specified (the record that should get the relation)"):this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"add-relation")},scheduleAddRelation:function(e){const t=this,n=this._internal;this.scheduleOnce("StorageAddRelation",(function(){if(t.validateInputs(),n.model){var e=n.model,i=n.targetModelId;void 0!==i&&s.forScope(t.nodeScope.modelScope).addRelation({collection:n.collectionId,objectId:e.getId(),key:n.relationProperty,targetObjectId:i,targetClass:(t.nodeScope.modelScope||o).get(i)._class,success:function(n){for(var o in n)e.set(o,n[o]);t.sendSignalOnOutput("relationAdded")},error:function(e){t.setError(e||"Failed to add relation.")}})}}))}}}};i.addBaseInfo(r,{includeRelations:!0}),i.addModelId(r),i.addRelationProperty(r),e.exports=r},1421:(e,t,n)=>{"use strict";var o=n(3839),i=n(464);const s=n(4007);var r={node:{name:"RemoveDbModelRelation",docs:"https://docs.noodl.net/nodes/data/cloud-data/remove-record-relation",displayName:"Remove Record Relation",usePortAsLabel:"collectionName",inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue:function(){this.scheduleRemoveRelation()}}},outputs:{relationRemoved:{type:"signal",displayName:"Success",group:"Events"}},methods:{validateInputs:function(){if(!this.context.editorConnection)return;const e=e=>{this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"add-relation",{message:e})};void 0===this._internal.collectionId?e("No class specified"):void 0===this._internal.relationProperty?e("No relation property specified"):void 0===this._internal.targetModelId?e("No target record Id (the record to add a relation to) specified"):void 0===this._internal.model?e("No record Id specified (the record that should get the relation)"):this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"add-relation")},scheduleRemoveRelation:function(e){const t=this,n=this._internal;this.scheduleOnce("StorageRemoveRelation",(function(){if(t.validateInputs(),n.model){var e=n.model,i=n.targetModelId;void 0!==i&&s.forScope(t.nodeScope.modelScope).removeRelation({collection:n.collectionId,objectId:e.getId(),key:n.relationProperty,targetObjectId:i,targetClass:(t.nodeScope.modelScope||o).get(i)._class,success:function(n){for(var o in n)e.set(o,n[o]);t.sendSignalOnOutput("relationRemoved")},error:function(e){t.setError(e||"Failed to remove relation.")}})}}))}}}};i.addBaseInfo(r,{includeRelations:!0}),i.addModelId(r),i.addRelationProperty(r),e.exports=r},9:(e,t,n)=>{"use strict";const{Node:o,EdgeTriggeredInput:i}=n(3948),s=n(3839),r=n(4007),a={name:"DbModel2",docs:"https://docs.noodl.net/nodes/data/cloud-data/record",displayNodeName:"Record",shortDesc:"Database model",category:"Cloud Services",usePortAsLabel:"collectionName",color:"data",dynamicports:[{name:"conditionalports/extended",condition:"idSource = explicit OR idSource NOT SET",inputs:["modelId"]}],initialize:function(){const e=this._internal;e.inputValues={},e.relationModelIds={};const t=this;this._internal.onModelChangedCallback=function(e){t.isInputConnected("fetch")||(t.hasOutput("prop-"+e.name)&&t.flagOutputDirty("prop-"+e.name),t.hasOutput("changed-"+e.name)&&t.sendSignalOnOutput("changed-"+e.name),t.sendSignalOnOutput("changed"))}},getInspectInfo(){const e=this._internal.model;return e?[{type:"text",value:"Id: "+e.getId()},{type:"value",value:e.data}]:"[No Record]"},outputs:{id:{type:"string",displayName:"Id",group:"General",getter:function(){return this._internal.model?this._internal.model.getId():this._internal.modelId}},fetched:{type:"signal",displayName:"Fetched",group:"Events"},changed:{type:"signal",displayName:"Changed",group:"Events"},failure:{type:"signal",displayName:"Failure",group:"Events"},error:{type:"string",displayName:"Error",group:"Error",getter:function(){return this._internal.error}}},inputs:{idSource:{type:{name:"enum",enums:[{label:"Specify explicitly",value:"explicit"},{label:"From repeater",value:"foreach"}],allowEditOnly:!0},default:"explicit",displayName:"Id Source",group:"General",set:function(e){"foreach"===e&&this.scheduleAfterInputsHaveUpdated((()=>{for(var e=this.nodeScope.componentOwner;void 0!==e&&void 0===e._forEachModel&&e.parentNodeScope;)e=e.parentNodeScope.componentOwner;this.setModel(void 0!==e?e._forEachModel:void 0)}))}},modelId:{type:{name:"string",allowConnectionsOnly:!0},displayName:"Id",group:"General",set:function(e){e instanceof s?e=e.getId():"object"==typeof e&&(e=s.create(e).getId()),this._internal.modelId=e,!1===this.isInputConnected("fetch")?this.setModelID(e):this.flagOutputDirty("id")}},fetch:{displayName:"Fetch",group:"Actions",valueChangedToTrue:function(){this.scheduleFetch()}}},methods:{setCollectionID:function(e){this._internal.collectionId=e},setModelID:function(e){var t=(this.nodeScope.modelScope||s).get(e);this.setModel(t)},setModel:function(e){for(var t in this._internal.model&&this._internal.model.off("change",this._internal.onModelChangedCallback),this._internal.model=e,this.flagOutputDirty("id"),e.on("change",this._internal.onModelChangedCallback),e.data)this.hasOutput("prop-"+t)&&this.flagOutputDirty("prop-"+t);this.sendSignalOnOutput("fetched")},_onNodeDeleted:function(){o.prototype._onNodeDeleted.call(this),this._internal.model&&this._internal.model.off("change",this._internal.onModelChangedCallback)},scheduleOnce:function(e,t){const n=this,o="hasScheduled"+e;this._internal[o]||(this._internal[o]=!0,this.scheduleAfterInputsHaveUpdated((function(){n._internal[o]=!1,t()})))},setError:function(e){this._internal.error=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure"),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"storage-op-warning",{message:e,showGlobally:!0})},clearWarnings(){this.context.editorConnection&&this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"storage-op-warning")},scheduleFetch:function(){const e=this,t=this._internal;this.scheduleOnce("Fetch",(function(){if(void 0===t.modelId||""===t.modelId)return void e.setError("Missing Id.");const n=r.forScope(e.nodeScope.modelScope);n.fetch({collection:t.collectionId,objectId:t.modelId,success:function(o){const i=n._fromJSON(o,t.collectionId);t.model!==i&&(t.model&&t.model.off("change",t.onModelChangedCallback),t.model=i,i.on("change",t.onModelChangedCallback)),e.flagOutputDirty("id"),delete o.objectId;for(const t in o)e.hasOutput("prop-"+t)&&e.flagOutputDirty("prop-"+t);e.sendSignalOnOutput("fetched")},error:function(t){e.setError(t||"Failed to fetch.")}})}))},scheduleStore:function(){var e=this._internal;e.model&&this.scheduleOnce("Store",(function(){for(var t in e.inputValues)e.model.set(t,e.inputValues[t],{resolve:!0})}))},registerOutputIfNeeded:function(e){this.hasOutput(e)||e.startsWith("prop-")&&this.registerOutput(e,{getter:u.bind(this,e.substring(5))})},registerInputIfNeeded:function(e){if(this.hasInput(e))return;const t={};if(t[e])return this.registerInput(e,{set:i.createSetter({valueChangedToTrue:t[e]})});const n={collectionName:this.setCollectionID.bind(this)};if(n[e])return this.registerInput(e,{set:n[e]});e.startsWith("prop-")&&this.registerInput(e,{set:c.bind(this,e.substring(5))})}}};function u(e){return this._internal.model?this._internal.model.get(e,{resolve:!0}):void 0}function c(e,t){this._internal.inputValues[e]=t}function l(e,t,n,o){var i=[];const s=o.getMetaData("dbCollections"),r=o.getMetaData("systemCollections");if(i.push({name:"collectionName",displayName:"Class",group:"General",type:{name:"enum",enums:[{label:"User",value:"_User"},{label:"Role",value:"_Role"}].concat(void 0!==s?s.map((e=>({value:e.name,label:e.name}))):[]),allowEditOnly:!0},plug:"input"}),t.collectionName&&s){var a=s.find((e=>e.name===t.collectionName));if(void 0===a&&r&&(a=r.find((e=>e.name===t.collectionName))),a&&a.schema&&a.schema.properties){var u=a.schema.properties;for(var c in u){var l=u[c];if(!i.find((e=>e.name===c))&&"Relation"!==l.type){const e={String:"string",Boolean:"boolean",Number:"number",Date:"date"};i.push({type:{name:e[l.type]?e[l.type]:"*"},plug:"output",group:"Properties",name:"prop-"+c,displayName:c}),i.push({type:"signal",plug:"output",group:"Changed Events",displayName:c+" Changed",name:"changed-"+c})}}}}n.sendDynamicPorts(e,i)}e.exports={node:a,setup:function(e,t){function n(n){l(n.id,n.parameters,e.editorConnection,t),n.on("parameterUpdated",(function(){l(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.dbCollections",(function(){r.invalidateCollections(),l(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.systemCollections",(function(){r.invalidateCollections(),l(n.id,n.parameters,e.editorConnection,t)}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.DbModel2",(function(e){n(e)}));for(const e of t.getNodesWithType("DbModel2"))n(e)}))}}},8865:(e,t,n)=>{"use strict";var o=n(464);const i=n(4007);var s={node:{name:"DeleteDbModelProperties",docs:"https://docs.noodl.net/nodes/data/cloud-data/delete-record",displayNodeName:"Delete Record",shortDesc:"Stores any amount of properties and can be used standalone or together with Collections and For Each nodes.",inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue:function(){this.storageDelete()}}},outputs:{deleted:{type:"signal",displayName:"Success",group:"Events"}},methods:{storageDelete:function(){const e=this,t=this._internal;this.checkWarningsBeforeCloudOp()&&this.scheduleOnce("StorageDelete",(function(){t.model?i.forScope(e.nodeScope.ModelScope).delete({collection:t.collectionId,objectId:t.model.getId(),success:function(){t.model.notify("delete"),e.sendSignalOnOutput("deleted")},error:function(t){e.setError(t||"Failed to delete.")}}):e.setError("Missing Record Id")}))}}}};o.addBaseInfo(s,{includeInputProperties:!1}),o.addModelId(s),e.exports=s},5962:(e,t,n)=>{"use strict";const{Node:o}=n(3948),i=n(9160),s=n(3839),r=n(4007),a=n(5802);var u={name:"FilterDBModels",docs:"https://docs.noodl.net/nodes/data/cloud-data/filter-records",displayNodeName:"Filter Records",shortDesc:"Filter, sort and limit array",category:"Data",color:"data",initialize:function(){var e=this;this._internal.collectionChangedCallback=function(){!0!==e.isInputConnected("filter")&&e.scheduleFilter()},this._internal.cloudStoreEvents=function(t){!0!==e.isInputConnected("filter")&&void 0!==e._internal.visualFilter&&void 0!==e._internal.collection&&t.collection===e._internal.collectionName&&void 0!==t.objectId&&e._internal.collection.contains(s.get(t.objectId))&&e.scheduleFilter()},r.instance.on("save",this._internal.cloudStoreEvents),this._internal.enabled=!0,this._internal.filterSettings={},this._internal.filterParameters={}},getInspectInfo(){const e=this._internal.filteredCollection;return e?[{type:"text",value:"Id: "+e.getId()},{type:"value",value:e.items}]:{type:"text",value:"[Not executed yet]"}},inputs:{items:{type:"array",displayName:"Items",group:"General",set(e){this.bindCollection(e),!1===this.isInputConnected("filter")&&this.scheduleFilter()}},enabled:{type:"boolean",group:"General",displayName:"Enabled",default:!0,set:function(e){this._internal.enabled=e,!1===this.isInputConnected("filter")&&this.scheduleFilter()}},filter:{type:"signal",group:"Actions",displayName:"Filter",valueChangedToTrue:function(){this.scheduleFilter()}}},outputs:{items:{type:"array",displayName:"Items",group:"General",getter:function(){return this._internal.filteredCollection}},firstItemId:{type:"string",displayName:"First Record Id",group:"General",getter:function(){if(void 0!==this._internal.filteredCollection){const e=this._internal.filteredCollection.get(0);if(void 0!==e)return e.getId()}}},count:{type:"number",displayName:"Count",group:"General",getter:function(){return this._internal.filteredCollection?this._internal.filteredCollection.size():0}},modified:{group:"Events",type:"signal",displayName:"Filtered"}},prototypeExtensions:{unbindCurrentCollection:function(){var e=this._internal.collection;e&&(e.off("change",this._internal.collectionChangedCallback),this._internal.collection=void 0)},bindCollection:function(e){this.unbindCurrentCollection(),this._internal.collection=e,e&&e.on("change",this._internal.collectionChangedCallback)},_onNodeDeleted:function(){o.prototype._onNodeDeleted.call(this),this.unbindCurrentCollection(),r.instance.off("save",this._internal.cloudStoreEvents)},getLimit:function(){const e=this._internal.filterSettings;return e.filterEnableLimit?e.filterLimit||10:void 0},getSkip:function(){const e=this._internal.filterSettings;return e.filterEnableLimit?e.filterSkip||0:void 0},scheduleFilter:function(){this.collectionChangedScheduled||(this.collectionChangedScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{if(this.collectionChangedScheduled=!1,this._internal.collection){var e=[].concat(this._internal.collection.items);if(this._internal.enabled){const i=this._internal.visualFilter;if(void 0!==i){var t=a.convertVisualFilter(i,{queryParameters:this._internal.filterParameters,collectionName:this._internal.collectionName});t&&(e=e.filter((e=>a.matchesQuery(e,t))))}var n=this._internal.visualSorting;if(void 0!==n&&n.length>0)var o=a.convertVisualSorting(n);o&&e.sort(a.compareObjects.bind(this,o));var s=this.getSkip();s&&(e=e.slice(s,e.length));var r=this.getLimit();r&&(e=e.slice(0,r))}this._internal.filteredCollection=i.create(e),this.sendSignalOnOutput("modified"),this.flagOutputDirty("firstItemId"),this.flagOutputDirty("items"),this.flagOutputDirty("count")}})))},setCollectionName:function(e){this._internal.collectionName=e},setVisualFilter:function(e){this._internal.visualFilter=e,!1===this.isInputConnected("filter")&&this.scheduleFilter()},setVisualSorting:function(e){this._internal.visualSorting=e,!1===this.isInputConnected("filter")&&this.scheduleFilter()},setFilterParameter:function(e,t){this._internal.filterParameters[e]=t,!1===this.isInputConnected("filter")&&this.scheduleFilter()},registerInputIfNeeded:function(e){if(!this.hasInput(e))return"collectionName"===e?this.registerInput(e,{set:this.setCollectionName.bind(this)}):"visualFilter"===e?this.registerInput(e,{set:this.setVisualFilter.bind(this)}):"visualSorting"===e?this.registerInput(e,{set:this.setVisualSorting.bind(this)}):e.startsWith("fp-")?this.registerInput(e,{set:this.setFilterParameter.bind(this,e.substring(3))}):void this.registerInput(e,{set:c.bind(this,e)})}}};function c(e,t){this._internal.filterSettings[e]=t,!1===this.isInputConnected("filter")&&this.scheduleFilter()}function l(e,t,n,o){var i=[];if(i.push({name:"collectionName",type:{name:"enum",enums:void 0!==o?o.map((e=>({value:e.name,label:e.name}))):[],allowEditOnly:!0},displayName:"Class",plug:"input",group:"General"}),i.push({type:"boolean",plug:"input",group:"Limit",name:"filterEnableLimit",displayName:"Use limit"}),t.filterEnableLimit&&(i.push({type:"number",default:10,plug:"input",group:"Limit",name:"filterLimit",displayName:"Limit"}),i.push({type:"number",default:0,plug:"input",group:"Limit",name:"filterSkip",displayName:"Skip"})),void 0!==t.collectionName){var s=o.find((e=>e.name===t.collectionName));if(s&&s.schema&&s.schema.properties){const a=JSON.parse(JSON.stringify(s.schema)),u={Boolean:!0,String:!0,Date:!0,Number:!0,Pointer:!0};for(var r in a.properties)u[a.properties[r].type]||delete a.properties[r];i.push({name:"visualFilter",plug:"input",type:{name:"query-filter",schema:a,allowEditOnly:!0},displayName:"Filter",group:"Filter"}),i.push({name:"visualSorting",plug:"input",type:{name:"query-sorting",schema:a,allowEditOnly:!0},displayName:"Sorting",group:"Sorting"})}if(void 0!==t.visualFilter){const c={};function l(e){void 0!==e&&(void 0!==e.rules?e.rules.forEach((e=>l(e))):void 0!==e.input&&(c[e.input]=!0))}l(t.visualFilter),Object.keys(c).forEach((e=>{i.push({name:"fp-"+e,plug:"input",type:"*",displayName:e,group:"Filter Parameters"})}))}}n.sendDynamicPorts(e,i)}e.exports={node:u,setup:function(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("nodeAdded.FilterDBModels",(function(n){l(n.id,n.parameters,e.editorConnection,t.getMetaData("dbCollections")),n.on("parameterUpdated",(function(o){l(n.id,n.parameters,e.editorConnection,t.getMetaData("dbCollections"))})),t.on("metadataChanged.dbCollections",(function(t){r.invalidateCollections(),l(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.systemCollections",(function(t){r.invalidateCollections(),l(n.id,n.parameters,e.editorConnection,t)}))}))}}},9672:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";const Collection=__webpack_require__(9160),Model=__webpack_require__(3839);function _addBaseInfo(e){Object.assign(e.node,{category:"Data",color:"data"})}function _addModelId(e,t){const n=void 0===t||t.includeInputs,o=void 0===t||t.includeOutputs;Object.assign(e.node,{inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),n&&(Object.assign(e.node,{usePortAsLabel:"modelId"}),e.node.dynamicports=(e.node.dynamicports||[]).concat([{name:"conditionalports/extended",condition:"idSource = explicit OR idSource NOT SET",inputs:["modelId"]}]),Object.assign(e.node.inputs,{idSource:{type:{name:"enum",enums:[{label:"Specify explicitly",value:"explicit"},{label:"From repeater",value:"foreach"}],allowEditOnly:!0},default:"explicit",displayName:"Id Source",group:"General",set:function(e){"foreach"===e&&this.scheduleAfterInputsHaveUpdated((()=>{for(var e=this.nodeScope.componentOwner;void 0!==e&&void 0===e._forEachModel&&e.parentNodeScope;)e=e.parentNodeScope.componentOwner;this.setModel(void 0!==e?e._forEachModel:void 0)}))}},modelId:{type:{name:"string",identifierOf:"ModelName",identifierDisplayName:"Object Ids"},displayName:"Id",group:"General",set:function(e){e instanceof Model&&(e=e.getId()),this._internal.modelId=e,this.setModelID(e)}}})),o&&Object.assign(e.node.outputs,{id:{type:"string",displayName:"Id",group:"General",getter:function(){return this._internal.model?this._internal.model.getId():this._internal.modelId}}}),Object.assign(e.node.methods,{setModelID:function(e){var t=(this.nodeScope.modelScope||Model).get(e);this.setModel(t)},setModel:function(e){this._internal.model=e,this.flagOutputDirty("id")}}),e.node.getInspectInfo||(e.node.getInspectInfo=function(){const e=this._internal.model;return e?[{type:"text",value:"Id: "+e.getId()},{type:"value",value:e.data}]:"[No Object]"})}function _addInputProperties(def){var _def={node:Object.assign({},def.node),setup:def.setup},_methods=Object.assign({},def.node.methods);Object.assign(def.node,{inputs:def.node.inputs||{},outputs:def.node.outputs||{},methods:def.node.methods||{}}),Object.assign(def,{setup:function(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&(t.on("nodeAdded."+def.node.name,(function(t){function n(){var n=[];const o=[{label:"String",value:"string"},{label:"Boolean",value:"boolean"},{label:"Number",value:"number"},{label:"Date",value:"date"},{label:"Array",value:"array"},{label:"Object",value:"object"},{label:"Any",value:"*"}];var i=t.parameters.properties;if(i)for(var s in i=i?i.split(","):void 0){var r=i[s];n.push({type:{name:void 0===t.parameters["type-"+r]?"*":t.parameters["type-"+r]},plug:"input",group:"Property Values",displayName:r,name:"prop-"+r}),n.push({type:{name:"enum",enums:o,allowEditOnly:!0},plug:"input",group:"Property Types",displayName:r,default:"*",name:"type-"+r})}e.editorConnection.sendDynamicPorts(t.id,n,{detectRenamed:{plug:"input"}})}n(),t.on("parameterUpdated",(function(e){n()}))})),_def.setup&&_def.setup(e,t))}}),Object.assign(def.node,{initialize:function(){var e=this._internal;e.inputValues={},e.inputTypes={},_def.node.initialize&&_def.node.initialize.call(this)}}),Object.assign(def.node.outputs,{}),Object.assign(def.node.inputs,{properties:{type:{name:"stringlist",allowEditOnly:!0},displayName:"Properties",group:"Properties to set",set:function(e){}}}),Object.assign(def.node.methods,{_pushInputValues:function(model){var internal=this._internal;const _defaultValueForType={boolean:!1,string:"",number:0,date:new Date},_allKeys={};for(const e in internal.inputTypes)_allKeys[e]=!0;for(const e in internal.inputValues)_allKeys[e]=!0;const properties=this.model.parameters.properties||"",validProperties=properties.split(","),keysToSet=Object.keys(_allKeys).filter((e=>-1!==validProperties.indexOf(e)));for(const i of keysToSet){var value=internal.inputValues[i];if(void 0!==value){if(void 0!==internal.inputTypes[i]&&"array"===internal.inputTypes[i]&&"string"==typeof value){this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"invalid-array-"+i);try{value=eval(value)}catch(e){-1!==value.indexOf("[")||-1!==value.indexOf("{")?(this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"invalid-array-"+i,{showGlobally:!0,message:"Invalid array
"+e.toString()}),value=[]):value=Collection.get(value)}}void 0!==internal.inputTypes[i]&&"object"===internal.inputTypes[i]&&"string"==typeof value&&(value=(this.nodeScope.modelScope||Model).get(value)),model.set(i,value,{resolve:!0})}else model.set(i,_defaultValueForType[internal.inputTypes[i]],{resolve:!0})}},scheduleStore:function(){if(!this.hasScheduledStore){this.hasScheduledStore=!0;var e=this._internal;this.scheduleAfterInputsHaveUpdated((()=>{this.hasScheduledStore=!1,e.model&&(this._pushInputValues(e.model),this.sendSignalOnOutput("stored"))}))}},registerInputIfNeeded:function(e){this.hasInput(e)||(e.startsWith("prop-")&&this.registerInput(e,{set:this._setInputValue.bind(this,e.substring(5))}),e.startsWith("type-")&&this.registerInput(e,{set:this._setInputType.bind(this,e.substring(5))}),_methods&&_methods.registerInputIfNeeded&&_def.node.methods.registerInputIfNeeded.call(this,e))},_setInputValue:function(e,t){this._internal.inputValues[e]=t},_setInputType:function(e,t){this._internal.inputTypes[e]=t}})}module.exports={addInputProperties:_addInputProperties,addModelId:_addModelId,addBaseInfo:_addBaseInfo}},5271:(e,t,n)=>{"use strict";const{Node:o}=n(3948);var i=n(3839),s={name:"Model2",docs:"https://docs.noodl.net/nodes/data/object/object-node",displayNodeName:"Object",shortDesc:"Stores any amount of properties and can be used standalone or together with Collections and For Each nodes.",category:"Data",usePortAsLabel:"modelId",color:"data",dynamicports:[{name:"conditionalports/extended",condition:"idSource = explicit OR idSource NOT SET",inputs:["modelId"]}],initialize:function(){var e=this._internal;e.inputValues={},e.dirtyValues={};var t=this;this._internal.onModelChangedCallback=function(e){!0!==t.isInputConnected("fetch")&&(t.hasOutput("prop-"+e.name)&&t.flagOutputDirty("prop-"+e.name),t.hasOutput("changed-"+e.name)&&t.sendSignalOnOutput("changed-"+e.name),t.sendSignalOnOutput("changed"))}},getInspectInfo(){const e=this._internal.model;return e?[{type:"text",value:"Id: "+e.getId()},{type:"value",value:e.data}]:"[No Object]"},outputs:{id:{type:"string",displayName:"Id",group:"General",getter:function(){return this._internal.model?this._internal.model.getId():this._internal.modelId}},changed:{type:"signal",displayName:"Changed",group:"Events"},fetched:{type:"signal",displayName:"Fetched",group:"Events"}},inputs:{idSource:{type:{name:"enum",enums:[{label:"Specify explicitly",value:"explicit"},{label:"From repeater",value:"foreach"}],allowEditOnly:!0},default:"explicit",displayName:"Get Id from",group:"General",set:function(e){"foreach"===e&&this.scheduleAfterInputsHaveUpdated((()=>{for(var e=this.nodeScope.componentOwner;void 0!==e&&void 0===e._forEachModel&&e.parentNodeScope;)e=e.parentNodeScope.componentOwner;this.setModel(void 0!==e?e._forEachModel:void 0)}))}},modelId:{type:{name:"string",identifierOf:"ModelName",identifierDisplayName:"Object Ids"},displayName:"Id",group:"General",set:function(e){e instanceof i?e=e.getId():"object"==typeof e&&(e=i.create(e).getId()),this._internal.modelId=e,!1===this.isInputConnected("fetch")?this.setModelID(e):this.flagOutputDirty("id")}},properties:{type:{name:"stringlist",allowEditOnly:!0},displayName:"Properties",group:"Properties",set:function(e){}},fetch:{displayName:"Fetch",group:"Actions",valueChangedToTrue:function(){this.scheduleSetModel()}}},prototypeExtensions:{scheduleStore:function(){if(!this.hasScheduledStore){this.hasScheduledStore=!0;var e=this._internal;this.scheduleAfterInputsHaveUpdated((()=>{if(this.hasScheduledStore=!1,e.model){for(var t in e.dirtyValues)e.model.set(t,e.inputValues[t],{resolve:!0});e.dirtyValues={}}}))}},scheduleSetModel:function(){this.hasScheduledSetModel||(this.hasScheduledSetModel=!0,this._internal,this.scheduleAfterInputsHaveUpdated((()=>{this.hasScheduledSetModel=!1,this.setModelID(this._internal.modelId)})))},setModelID:function(e){var t=(this.nodeScope.modelScope||i).get(e);this.setModel(t),this.sendSignalOnOutput("fetched")},setModel:function(e){if(this._internal.model&&this._internal.model.off("change",this._internal.onModelChangedCallback),this._internal.model=e,this.flagOutputDirty("id"),e)for(var t in e.on("change",this._internal.onModelChangedCallback),e.data)this.hasOutput("prop-"+t)&&this.flagOutputDirty("prop-"+t)},_onNodeDeleted:function(){o.prototype._onNodeDeleted.call(this),this._internal.model&&this._internal.model.off("change",this._internal.onModelChangedCallback)},registerOutputIfNeeded:function(e){this.hasOutput(e)||e.startsWith("prop-")&&this.registerOutput(e,{getter:r.bind(this,e.substring(5))})},registerInputIfNeeded:function(e){this.hasInput(e)||e.startsWith("prop-")&&this.registerInput(e,{set:a.bind(this,e.substring(5))})}}};function r(e){return this._internal.model?this._internal.model.get(e,{resolve:!0}):void 0}function a(e,t){this._internal.inputValues[e]=t;const n=this._internal.model;(!n||n.get(e)!==t)&&(this._internal.dirtyValues[e]=!0,this.scheduleStore())}function u(e,t,n){var o=[],i=t.properties;if(i)for(var s in i=i?i.split(","):void 0){var r=i[s];o.push({type:{name:"*",allowConnectionsOnly:!0},plug:"input/output",group:"Properties",name:"prop-"+r,displayName:r}),o.push({type:"signal",plug:"output",group:"Changed Events",displayName:r+" Changed",name:"changed-"+r})}n.sendDynamicPorts(e,o,{detectRenamed:{plug:"input/output"}})}e.exports={node:s,setup:function(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("nodeAdded.Model2",(function(t){u(t.id,t.parameters,e.editorConnection),t.on("parameterUpdated",(function(n){u(t.id,t.parameters,e.editorConnection)}))}))}}},4763:(e,t,n)=>{"use strict";var o=n(3839),i=n(464);const s=n(4007);var r={node:{name:"NewDbModelProperties",docs:"https://docs.noodl.net/nodes/data/cloud-data/create-new-record",displayName:"Create New Record",usePortAsLabel:"collectionName",inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue:function(){this.storageInsert()}},sourceObjectId:{type:{name:"string",allowConnectionsOnly:!0},displayName:"Source Object Id",group:"General",set:function(e){e instanceof o&&(e=e.getId()),this._internal.sourceObjectId=e}}},outputs:{created:{type:"signal",displayName:"Success",group:"Events"}},methods:{storageInsert:function(){const e=this._internal;this.checkWarningsBeforeCloudOp()&&this.scheduleOnce("StorageInsert",(()=>{const t=Object.assign({},e.sourceObjectId?(this.nodeScope.modelScope||o).get(e.sourceObjectId).data:{},e.inputValues),n=s.forScope(this.nodeScope.modelScope);n.create({collection:e.collectionId,data:t,acl:this._getACL(),success:t=>{const o=n._fromJSON(t,e.collectionId);this.setModel(o),this.sendSignalOnOutput("created")},error:e=>{this.setError(e||"Failed to insert.")}})}))}}}};i.addBaseInfo(r),i.addModelId(r,{includeOutputs:!0}),i.addInputProperties(r),i.addAccessControl(r),e.exports=r},9780:(e,t,n)=>{"use strict";var o=n(3839),i=n(9672),s={node:{name:"NewModel",docs:"https://docs.noodl.net/nodes/data/object/create-new-object",displayNodeName:"Create New Object",inputs:{new:{displayName:"Do",group:"Actions",valueChangedToTrue:function(){this.scheduleNew()}}},outputs:{created:{type:"signal",displayName:"Done",group:"Events"}},methods:{scheduleNew:function(){this.hasScheduledNew||(this.hasScheduledNew=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.hasScheduledNew=!1;const e=(this.nodeScope.modelScope||o).get();this._pushInputValues(e),this.setModel(e),this.sendSignalOnOutput("created")})))}}}};i.addBaseInfo(s),i.addModelId(s,{includeOutputs:!0}),i.addInputProperties(s),e.exports=s},6430:e=>{var t={name:"REST2",displayNodeName:"REST",docs:"https://docs.noodl.net/nodes/data/rest",category:"Data",color:"data",searchTags:["http","request","fetch"],initialize:function(){this._internal.inputValues={},this._internal.outputValues={},this._internal.outputValuesProxy=new Proxy(this._internal.outputValues,{set:(e,t,n)=>(n!==this._internal.outputValues[t]&&(this.registerOutputIfNeeded("out-"+t),this._internal.outputValues[t]=n,this.flagOutputDirty("out-"+t)),!0)}),this._internal.self={}},getInspectInfo(){return this._internal.inspectData?{type:"value",value:this._internal.inspectData}:{type:"text",value:"[Not executed yet]"}},inputs:{resource:{type:"string",displayName:"Resource",group:"Request",default:"/",set:function(e){this._internal.resource=e}},method:{type:{name:"enum",enums:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"},{label:"DELETE",value:"DELETE"}]},displayName:"Method",group:"Request",default:"GET",set:function(e){this._internal.method=e}},requestScript:{type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},displayName:"Request",default:"//Add custom code to setup the request object before the request\n//is made.\n//\n//*Request.resource contains the resource path of the request.\n//*Request.method contains the method, GET, POST, PUT or DELETE.\n//*Request.headers is a map where you can add additional headers.\n//*Request.parameters is a map the parameters that will be appended\n// to the url.\n//*Request.content contains the content of the request as a javascript\n// object.\n//\n",group:"Scripts",set:function(e){try{this._internal.requestFunc=new Function("Inputs","Outputs","Request",e)}catch(e){console.log(e)}}},responseScript:{type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},displayName:"Response",default:"// Add custom code to convert the response content to outputs\n//\n//*Response.status The status code of the response\n//*Response.content The content of the response as a javascript\n// object.\n//*Response.request The request object that resulted in the response.\n//\n//*Inputs and *Outputs contain the inputs and outputs of the node.\n",group:"Scripts",set:function(e){try{this._internal.responseFunc=new Function("Inputs","Outputs","Response",e)}catch(e){console.log(e)}}},fetch:{type:"signal",displayName:"Fetch",group:"Actions",valueChangedToTrue:function(){this.scheduleFetch()}},cancel:{type:"signal",displayName:"Cancel",group:"Actions",valueChangedToTrue:function(){this.cancelFetch()}}},outputs:{failure:{type:"signal",displayName:"Failure",group:"Events"},success:{type:"signal",displayName:"Success",group:"Events"},canceled:{type:"signal",displayName:"Canceled",group:"Events"}},prototypeExtensions:{getScriptOutputValue:function(e){return this._internal.outputValues[e]},setScriptInputValue:function(e,t){return this._internal.inputValues[e]=t},registerOutputIfNeeded:function(e){if(!this.hasOutput(e))return e.startsWith("out-")?this.registerOutput(e,{getter:this.getScriptOutputValue.bind(this,e.substring(4))}):void 0},registerInputIfNeeded:function(e){if(!this.hasInput(e))return e.startsWith("in-")?this.registerInput(e,{set:this.setScriptInputValue.bind(this,e.substring(3))}):void 0},scheduleFetch:function(){var e=this._internal;e.hasScheduledFetch||(e.hasScheduledFetch=!0,this.scheduleAfterInputsHaveUpdated(this.doFetch.bind(this)))},doResponse:function(e,t,n){this._internal.responseFunc&&this._internal.responseFunc.apply(this._internal.self,[this._internal.inputValues,this._internal.outputValuesProxy,{status:e,content:t,request:n}]),this._internal.inspectData={status:e,content:t},e>=200&&e<300?this.sendSignalOnOutput("success"):this.sendSignalOnOutput("failure")},doExternalFetch:function(e){var t=e.resource;if(Object.keys(e.parameters).length>0){var n=Object.keys(e.parameters).map((function(t){return t+"="+encodeURIComponent(e.parameters[t])}));t+="?"+n.join("&")}if(void 0===_noodl_cloud_runtime_version){var o=this,i=new window.XMLHttpRequest;for(var s in this._xhr=i,i.open(e.method,t,!0),e.headers)i.setRequestHeader(s,e.headers[s]);i.onreadystatechange=function(){var t=!1;if(4===this.readyState||this.readyState===XMLHttpRequest.DONE){var n=this.status,i=this.getResponseHeader("content-type"),s=this.response;if(delete this._xhr,i){const r=-1!==(i=i.toLowerCase()).indexOf("json")?JSON.parse(s):s;o.doResponse(n,r,e),t=!0}!1===t&&o.doResponse(n,s,e)}},i.onerror=function(e){delete this._xhr,o.sendSignalOnOutput("failure")},i.onabort=function(){delete this._xhr,o.sendSignalOnOutput("canceled")},e.content?(i.setRequestHeader("Content-Type","application/json"),i.send(JSON.stringify(e.content))):i.send()}else{const n=Object.assign({},e.headers,e.content?{"Content-Type":"application/json"}:{});fetch(t,{method:e.method,headers:n,body:e.content?JSON.stringify(e.content):void 0}).then((t=>{const n=t.headers.get("content-type");n?-1!==n.indexOf("/json")?t.json().then((n=>{this.doResponse(t.status,n,e)})):this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"rest-run-waring-",{message:"REST only supports json content type in response."}):t.text().then((n=>{this.doResponse(t.status,n,e)}))})).catch((e=>{console.log("REST: Failed to request",t),console.log(e),this.sendSignalOnOutput("failure")}))}},doFetch:function(){this._internal.hasScheduledFetch=!1;var e=this._internal.resource;if(e)for(var t in this._internal.inputValues)e=e.replace("{"+t+"}",this._internal.inputValues[t]);var n={resource:e,headers:{},method:void 0!==this._internal.method?this._internal.method:"GET",parameters:{}};this._internal.requestFunc&&this._internal.requestFunc.apply(this._internal.self,[this._internal.inputValues,this._internal.outputValuesProxy,n]),this.doExternalFetch(n)},cancelFetch:function(){void 0===_noodl_cloud_runtime_version?this._xhr&&this._xhr.abort():this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"rest-run-waring-",{message:"REST doesn't support cancel in cloud functions."})}}};function n(e,t,n,o,i,s){if(i.editorConnection.clearWarning(o.component.name,o.id,"rest-run-waring-"+n),void 0===e)return void i.editorConnection.clearWarning(o.component.name,o.id,"rest-parse-waring-"+n);try{new Function(...t,e),i.editorConnection.clearWarning(o.component.name,o.id,"rest-parse-waring-"+n)}catch(e){i.editorConnection.sendWarning(o.component.name,o.id,"rest-parse-waring-"+n,{message:""+n+": "+e.message,showGlobally:!0})}function r(e){return void 0!==s.find((t=>t.name===e))}const a=e.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,""),u=a.match(/Inputs\.[A-Za-z0-9]+/g);if(u){const e={};u.forEach((t=>{e[t.substring(7)]=!0})),Object.keys(e).forEach((e=>{r("in-"+e)||s.push({name:"in-"+e,displayName:e,plug:"input",type:"*",group:"Inputs"})}))}const c=a.match(/Outputs\.[A-Za-z0-9]+/g);if(c){const e={};c.forEach((t=>{e[t.substring(8)]=!0})),Object.keys(e).forEach((e=>{r("out-"+e)||s.push({name:"out-"+e,displayName:e,plug:"output",type:"*",group:"Outputs"})}))}}e.exports={node:t,setup:function(e,t){function o(t){function o(){if(t.parameters){var o=[];if(t.parameters.resource){var i=t.parameters.resource.match(/\{[A-Za-z0-9_]*\}/g);for(var s in i){var r=i[s].replace("{","").replace("}","");a("in-"+r)||o.push({name:"in-"+r,displayName:r,type:"string",plug:"input",group:"Inputs"})}}t.parameters.requestScript&&n(t.parameters.requestScript,["Inputs","Outputs","Request"],"Request script",t,e,o),t.parameters.responseScript&&n(t.parameters.responseScript,["Inputs","Outputs","Response"],"Response script",t,e,o),e.editorConnection.sendDynamicPorts(t.id,o)}function a(e){for(var t=0;t{t.on("nodeAdded.REST2",(function(e){o(e)}));for(const e of t.getNodesWithType("REST2"))o(e)}))}}},6280:(e,t,n)=>{"use strict";var o=n(464);const i=n(4007);var s={node:{name:"SetDbModelProperties",docs:"https://docs.noodl.net/nodes/data/cloud-data/set-record-properties",displayNodeName:"Set Record Properties",usePortAsLabel:"collectionName",dynamicports:[{name:"conditionalports/extended",condition:"storeType = cloud OR storeType NOT SET",inputs:["storeProperties"]}],inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue:function(){void 0===this._internal.storeType||"cloud"===this._internal.storeType?this.scheduleSave():this.scheduleStore()}},storeProperties:{displayName:"Properties to store",group:"General",type:{name:"enum",enums:[{label:"Only specified",value:"specified"},{label:"All",value:"all"}]},default:"specified",set:function(e){this._internal.storeProperties=e}},storeType:{displayName:"Store to",group:"General",type:{name:"enum",enums:[{label:"Cloud and local",value:"cloud"},{label:"Local only",value:"local"}]},default:"cloud",set:function(e){this._internal.storeType=e}}},outputs:{stored:{type:"signal",displayName:"Success",group:"Events"}},methods:{scheduleSave:function(){const e=this,t=this._internal;this.checkWarningsBeforeCloudOp()&&this.scheduleOnce("StorageSave",(function(){if(!t.model)return void e.setError("Missing Record Id");const n=t.model;for(const e in t.inputValues)n.set(e,t.inputValues[e],{resolve:!0});i.forScope(e.nodeScope.modelScope).save({collection:t.collectionId,objectId:n.getId(),data:"all"===t.storeProperties?n.data:t.inputValues,acl:e._getACL(),success:function(t){for(var o in t)n.set(o,t[o]);e.sendSignalOnOutput("stored")},error:function(t){e.setError(t||"Failed to save.")}})}))},scheduleStore:function(){if(!this.hasScheduledStore){this.hasScheduledStore=!0;var e=this._internal;this.scheduleAfterInputsHaveUpdated((()=>{if(this.hasScheduledStore=!1,e.model){for(var t in e.inputValues)e.model.set(t,e.inputValues[t],{resolve:!0});this.sendSignalOnOutput("stored")}}))}}}}};o.addBaseInfo(s),o.addModelId(s),o.addInputProperties(s),o.addAccessControl(s),e.exports=s},2474:(e,t,n)=>{"use strict";var o=n(9672),i={node:{name:"SetModelProperties",docs:"https://docs.noodl.net/nodes/data/object/set-object-properties",displayNodeName:"Set Object Properties",inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue:function(){this.scheduleStore()}}},outputs:{stored:{type:"signal",displayName:"Done",group:"Events"}}}};o.addBaseInfo(i),o.addModelId(i),o.addInputProperties(i),e.exports=i},8911:e=>{"use strict";const t={name:"Date To String",docs:"https://docs.noodl.net/nodes/utilities/date-to-string",category:"Utilities",initialize:function(){this._internal.formatString="{year}-{month}-{date}"},inputs:{formatString:{displayName:"Format",type:"string",default:"{year}-{month}-{date}",set:function(e){this._internal.formatString!==e&&(this._internal.formatString=e,void 0!==this._internal.currentInput&&(this._format(),this.flagOutputDirty("currentValue")))}},input:{type:{name:"date"},displayName:"Date",set:function(e){const t="string"==typeof e?new Date(e):e;this._internal.currentInput!==t&&(this._internal.currentInput=t,this._format())}}},outputs:{currentValue:{type:"string",displayName:"Date String",group:"Value",getter:function(){return this._internal.dateString}},inputChanged:{type:"signal",displayName:"Date Changed",group:"Signals"},onError:{type:"signal",displayName:"Invalid Date",group:"Signals"}},methods:{_format(){try{const e=this._internal.currentInput,t=this._internal.formatString,n=("0"+e.getDate()).slice(-2),o=("0"+(e.getMonth()+1)).slice(-2),i=new Intl.DateTimeFormat("en-US",{month:"short"}).format(e),s=e.getFullYear(),r=s.toString().substring(2),a=("0"+e.getHours()).slice(-2),u=("0"+e.getMinutes()).slice(-2),c=("0"+e.getSeconds()).slice(-2);this._internal.dateString=t.replace(/\{date\}/g,n).replace(/\{month\}/g,o).replace(/\{monthShort\}/g,i).replace(/\{year\}/g,s).replace(/\{yearShort\}/g,r).replace(/\{hours\}/g,a).replace(/\{minutes\}/g,u).replace(/\{seconds\}/g,c)}catch(e){this._internal.dateString="",this.flagOutputDirty("onError")}this.flagOutputDirty("currentValue"),this.sendSignalOnOutput("inputChanged")}}};e.exports={node:t}},8675:(e,t,n)=>{"use strict";const o=n(2806),i={name:"Expression",docs:"https://docs.noodl.net/nodes/math/expression",usePortAsLabel:"expression",category:"CustomCode",color:"javascript",nodeDoubleClickAction:{focusPort:"Expression"},searchTags:["javascript"],initialize:function(){var e=this._internal;e.scope={},e.hasScheduledEvaluation=!1,e.code=void 0,e.cachedValue=0,e.currentExpression="",e.compiledFunction=void 0,e.inputNames=[],e.inputValues=[]},getInspectInfo(){return this._internal.cachedValue},inputs:{expression:{group:"General",inputPriority:1,type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},displayName:"Expression",set:function(e){var t=this._internal;t.currentExpression=s+"return ("+e+");",t.compiledFunction=void 0;var n=u(e),i=o(n,t.inputNames),r=o(t.inputNames,n),a=this;r.forEach((function(e){a.deregisterInput(e),delete t.scope[e]})),i.forEach((function(e){a.hasInput(e)||(a.registerInput(e,{set:function(n){t.scope[e]=n,this.isInputConnected("run")||this._scheduleEvaluateExpression()}}),t.scope[e]=0,a._inputValues[e]=0)})),t.inputNames=Object.keys(t.scope),this.isInputConnected("run")||this._scheduleEvaluateExpression()}},run:{group:"Actions",displayName:"Run",type:"signal",valueChangedToTrue:function(){this._scheduleEvaluateExpression()}}},outputs:{result:{group:"Result",type:"*",displayName:"Result",getter:function(){return this._internal.currentExpression?this._internal.cachedValue:0}},isTrue:{group:"Result",type:"boolean",displayName:"Is True",getter:function(){return!!this._internal.currentExpression&&!!this._internal.cachedValue}},isFalse:{group:"Result",type:"boolean",displayName:"Is False",getter:function(){return!this._internal.currentExpression||!this._internal.cachedValue}},isTrueEv:{group:"Events",type:"signal",displayName:"On True"},isFalseEv:{group:"Events",type:"signal",displayName:"On False"}},prototypeExtensions:{registerInputIfNeeded:{value:function(e){this.hasInput(e)||(this._internal.scope[e]=0,this._inputValues[e]=0,this.registerInput(e,{set:function(t){this._internal.scope[e]=t,this.isInputConnected("run")||this._scheduleEvaluateExpression()}}))}},_scheduleEvaluateExpression:{value:function(){var e=this._internal;!1===e.hasScheduledEvaluation&&(e.hasScheduledEvaluation=!0,this.flagDirty(),this.scheduleAfterInputsHaveUpdated((function(){var t=e.cachedValue;e.cachedValue=this._calculateExpression(),t!==e.cachedValue&&(this.flagOutputDirty("result"),this.flagOutputDirty("isTrue"),this.flagOutputDirty("isFalse")),e.cachedValue?this.sendSignalOnOutput("isTrueEv"):this.sendSignalOnOutput("isFalseEv"),e.hasScheduledEvaluation=!1})))}},_calculateExpression:{value:function(){var e=this._internal;e.compiledFunction||(e.compiledFunction=this._compileFunction());for(var t=0;t{"use strict";function t(e){if(void 0!==e)return!e}const n={name:"Inverter",docs:"https://docs.noodl.net/nodes/logic/inverter",category:"Logic",initialize:function(){this._internal.currentValue=void 0},getInspectInfo(){return String(t(this._internal.currentValue))},inputs:{value:{type:{name:"boolean"},displayName:"Value",set:function(e){this._internal.currentValue=e,this.flagOutputDirty("result")}}},outputs:{result:{type:"boolean",displayName:"Result",getter:function(){return t(this._internal.currentValue)}}}};e.exports={node:n}},6307:e=>{"use strict";const t={name:"Or",docs:"https://docs.noodl.net/nodes/logic/or",category:"Logic",initialize:function(){this._internal.inputs=[]},getInspectInfo(){return this._internal.inputs.some(n)},numberedInputs:{input:{type:"boolean",displayPrefix:"Input",createSetter:e=>function(t){this._internal.inputs[e]!==t&&(this._internal.inputs[e]=t,this.flagOutputDirty("result"))}}},outputs:{result:{type:"boolean",displayName:"Result",getter:function(){return this._internal.inputs.some(n)}}}};function n(e){return!!e}e.exports={node:t}},3734:(e,t,n)=>{const{Node:o}=n(3948),i=n(7662),s=n(3839),r={name:"RunTasks",displayNodeName:"Run Tasks",docs:"https://docs.noodl.net/nodes/data/run-tasks",color:"data",category:"Data",initialize(){this._internal.queuedOperations=[],this._internal.state="idle",this._internal.maxRunningTasks=10,this._internal.activeTasks=new Map},inputs:{items:{group:"Data",displayName:"Items",type:"array",set:function(e){e&&e!==this._internal.items&&(this._internal.items=e)}},stopOnFailure:{group:"General",displayName:"Stop On Failure",type:"boolean",default:!1,set:function(e){this._internal.stopOnFailure=e}},maxRunningTasks:{group:"General",displayName:"Max Running Tasks",type:"number",default:10,set:function(e){this._internal.maxRunningTasks=e}},taskTemplate:{type:"component",displayName:"Template",group:"General",set:function(e){this._internal.template=e}},run:{group:"General",displayName:"Do",type:"signal",valueChangedToTrue:function(){this.scheduleRun()}},abort:{group:"General",displayName:"Abort",type:"signal",valueChangedToTrue:function(){this.scheduleAbort()}}},outputs:{success:{type:"signal",group:"Events",displayName:"Success"},failure:{type:"signal",group:"Events",displayName:"Failure"},done:{type:"signal",group:"Events",displayName:"Done"},aborted:{type:"signal",group:"Events",displayName:"Aborted"}},methods:{scheduleRun(){var e=this._internal;e.hasScheduledRun||(e.hasScheduledRun=!0,this.scheduleAfterInputsHaveUpdated((()=>{this._queueOperation((()=>{e.hasScheduledRun=!1,this.run()}))})))},scheduleAbort(){var e=this._internal;e.hasScheduledAbort||(e.hasScheduledAbort=!0,this.scheduleAfterInputsHaveUpdated((()=>{this._queueOperation((()=>{e.hasScheduledAbort=!1,this.abort()}))})))},async createTaskComponent(e){const t=this._internal,n=(this.nodeScope.modelScope||s).create(e);var o=await this.nodeScope.createNode(t.template,i(),{_forEachModel:n,_forEachNode:this});const r=o.isInputConnected.bind(o);for(var a in o.isInputConnected=e=>"Do"===e||r(e),o.hasInput("Id")&&o.setInputValue("Id",n.getId()),o.hasInput("id")&&o.setInputValue("id",n.getId()),o._inputs)void 0!==n.data[a]&&o.setInputValue(a,n.data[a]);return o._internal.creatorCallbacks={onOutputChanged:(e,t,i)=>{!1!==i&&void 0!==i||!0!==t||this.itemOutputSignalTriggered(e,n,o)}},o},async startTask(e){const t=this._internal;try{const o=await this.createTaskComponent(e);t.runningTasks++,"Do",(n=o).queueInput("Do",!0),n.queueInput("Do",!1),t.activeTasks.set(o.id,o)}catch(e){console.log(e)}var n},async run(){const e=this._internal;if(this.context.editorConnection&&("idle"!==e.state?this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"run-tasks",{message:"Cannot start when not in idle mode"}):e.template?e.items?this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"run-tasks"):this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"run-tasks",{message:"No items array provided."}):this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"run-tasks",{message:"No task template specified."})),"idle"===e.state&&e.template&&e.items){e.state="running",e.numTasks=e.items.length,e.failedTasks=0,e.completedTasks=0,e.queuedTasks=[].concat(e.items),e.runningTasks=0,0===e.items.length&&(this.sendSignalOnOutput("success"),e.state="idle");for(let t=0;t{if("aborted"===o.state)return this.sendSignalOnOutput("aborted"),void(o.state="idle");if(o.completedTasks===o.numTasks)0===o.failedTasks?this.sendSignalOnOutput("success"):this.sendSignalOnOutput("failure"),this.sendSignalOnOutput("done"),o.state="idle";else if(o.stopOnFailure)if(0===o.failedTasks){o.runningTasks++;const e=o.queuedTasks.shift();e&&this.startTask(e)}else this.sendSignalOnOutput("failure"),this.sendSignalOnOutput("aborted");else{o.runningTasks++;const e=o.queuedTasks.shift();e&&this.startTask(e)}};"Success"===e?(o.completedTasks++,o.runningTasks--,i()):"Failure"===e&&(o.completedTasks++,o.failedTasks++,o.runningTasks--,i()),o.activeTasks.delete(n.id),this.nodeScope.deleteNode(n)},_queueOperation(e){this._internal.queuedOperations.push(e),this._runQueueOperations()},async _runQueueOperations(){if(!this.runningOperations){for(this.runningOperations=!0;this._internal.queuedOperations.length;){const e=this._internal.queuedOperations.shift();await e()}this.runningOperations=!1}}},_deleteAllTasks(){for(const e of this._internal.activeTasks)this.nodeScope.deleteNode(e);this._internal.activeTasks.clear()},_onNodeDeleted:function(){o.prototype._onNodeDeleted.call(this),this._deleteAllTasks()}};e.exports={node:r}},9222:(e,t,n)=>{const o=n(5995),{logJavaScriptNodeError:i}=n(5722),s={name:"JavaScriptFunction",displayNodeName:"Function",docs:"https://docs.noodl.net/nodes/javascript/function",category:"CustomCode",color:"javascript",nodeDoubleClickAction:{focusPort:"Script"},searchTags:["javascript"],exportDynamicPorts:!0,initialize:function(){this._internal.inputValues={},this._internal.outputValues={},this._internal.outputValuesProxy=new Proxy(this._internal.outputValues,{set:(e,t,n)=>{if(!this._deleted)return n!==this._internal.outputValues[t]&&(this.registerOutputIfNeeded("out-"+t),this._internal.outputValues[t]=n,this.flagOutputDirty("out-"+t)),!0}}),this._internal._this={}},getInspectInfo(){return[{type:"value",value:{inputs:this._internal.inputValues,outputs:this._internal.outputValues}}]},inputs:{scriptInputs:{type:{name:"proplist",allowEditOnly:!0},group:"Script Inputs",set(e){}},scriptOutputs:{type:{name:"proplist",allowEditOnly:!0},group:"Script Outputs",set(e){}},functionScript:{displayName:"Script",plug:"input",type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},group:"General",set(e){void 0!==e?(this._internal.func=this.parseScript(e),this.isInputConnected("run")||this.scheduleRun()):this._internal.func=void 0}},run:{type:"signal",displayName:"Run",group:"Actions",valueChangedToTrue:function(){this.scheduleRun()}}},outputs:{},methods:{scheduleRun:function(){this.runScheduled||(this.runScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.runScheduled=!1,this._deleted||this.runScript()})))},runScript:async function(){const e=this._internal.func;if(void 0===e)return;const t=this._internal.inputValues,n=this._internal.outputValuesProxy;for(const e in this.model.outputPorts)if(this._isSignalType(e)){const t=()=>{this.hasOutput(e)&&this.sendSignalOnOutput(e)};this._internal.outputValues[e.substring(4)]=t,this._internal.outputValues[e.substring(4)].send=t}try{await e.apply(this._internal._this,[t,n,o.createNoodlAPI(this.nodeScope.modelScope),o.getComponentScopeForNode(this)])}catch(e){i(e),this.context.editorConnection&&this.context.isWarningTypeEnabled("javascriptExecution")&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"js-function-run-waring",{showGlobally:!0,message:e.message,stack:e.stack})}},setScriptInputValue:function(e,t){this._internal.inputValues[e]=t,this.isInputConnected("run")||this.scheduleRun()},getScriptOutputValue:function(e){if(!this._isSignalType(e))return this._internal.outputValues[e]},setScriptInputType:function(e,t){this._internal.inputTypes[e]=t},setScriptOutputType:function(e,t){this._internal.outputTypes[e]=t},parseScript:function(e){var t;try{t=new(0,Object.getPrototypeOf((async function(){})).constructor)("Inputs","Outputs","Noodl","Component",o.getCodePrefix()+e)}catch(e){console.log("Error while parsing action script: "+e)}return t},_isSignalType:function(e){return this.model.outputPorts[e]&&"signal"===this.model.outputPorts[e].type},registerInputIfNeeded:function(e){if(!this.hasInput(e)){if(e.startsWith("in-")){const t=e.substring(3),n={set:this.setScriptInputValue.bind(this,t)};this.model&&this.model.parameters["intype-"+t]&&(n.type=this.model.parameters["intype-"+t]),this.registerInput(e,n)}if(e.startsWith("intype-")){const t=e.substring(7);this.registerInput(e,{set(e){this.hasInput("in"+t)&&(this.getInput("in"+t).type=e)}})}e.startsWith("outtype-")&&this.registerInput(e,{set(){}})}},registerOutputIfNeeded:function(e){if(!this.hasOutput(e))return e.startsWith("out-")?this.registerOutput(e,{getter:this.getScriptOutputValue.bind(this,e.substring(4))}):void 0}}},r=[{value:"string",label:"String"},{value:"boolean",label:"Boolean"},{value:"number",label:"Number"},{value:"object",label:"Object"},{value:"date",label:"Date"},{value:"array",label:"Array"},{value:"color",label:"Color"}];e.exports={node:s,setup:function(e,t){function n(t){function n(){var n=[];const i=r.concat([{value:"signal",label:"Signal"}]);void 0!==t.parameters.scriptOutputs&&t.parameters.scriptOutputs.length>0&&t.parameters.scriptOutputs.forEach((e=>{n.push({name:"outtype-"+e.label,displayName:"Type",editorName:e.label+" | Type",plug:"input",type:{name:"enum",enums:i,allowEditOnly:!0},default:"string",parent:"scriptOutputs",parentItemId:e.id}),n.push({name:"out-"+e.label,displayName:e.label,plug:"output",type:t.parameters["outtype-"+e.label]||"*",group:"Outputs"})})),void 0!==t.parameters.scriptInputs&&t.parameters.scriptInputs.length>0&&t.parameters.scriptInputs.forEach((e=>{n.push({name:"intype-"+e.label,displayName:"Type",editorName:e.label+" | Type",plug:"input",type:{name:"enum",enums:r,allowEditOnly:!0},default:"string",parent:"scriptInputs",parentItemId:e.id}),n.push({name:"in-"+e.label,displayName:e.label,plug:"input",type:t.parameters["intype-"+e.label]||"string",group:"Inputs"})})),function(e,t,n,i,s){if(i.editorConnection.clearWarning(n.component.name,n.id,"js-function-run-waring"),void 0!==e){try{new(0,Object.getPrototypeOf((async function(){})).constructor)("Inputs","Outputs","Noodl","Component",e),i.editorConnection.clearWarning(n.component.name,n.id,"js-function-parse-waring")}catch(e){i.editorConnection.sendWarning(n.component.name,n.id,"js-function-parse-waring",{showGlobally:!0,message:e.message})}o.parseAndAddPortsFromScript(e,s,{inputPrefix:"in-",outputPrefix:"out-"})}else i.editorConnection.clearWarning(n.component.name,n.id,"js-function-parse-waring")}(t.parameters.functionScript,0,t,e,n),n.forEach((e=>{"signal"===e.type&&"output"===e.plug&&(t.outputPorts[e.name]=e)})),e.editorConnection.sendDynamicPorts(t.id,n)}n(),t.on("parameterUpdated",(function(e){n()}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.JavaScriptFunction",(function(e){n(e)}));for(const e of t.getNodesWithType("JavaScriptFunction"))n(e)}))}}},5533:e=>{const t={name:"String Format",docs:"https://docs.noodl.net/nodes/string-manipulation/string-format",category:"String Manipulation",usePortAsLabel:"format",portLabelTruncationMode:"length",initialize(){const e=this._internal;e.format="",e.cachedResult="",e.resultDirty=!1,e.inputValues={}},getInspectInfo(){return this.formatValue()},inputs:{format:{type:{name:"string",multiline:!0},displayName:"Format",set(e){this._internal.format!==e&&(this._internal.format=e,this._internal.resultDirty=!0,this.scheduleFormat())}}},outputs:{formatted:{type:"string",displayName:"Formatted",get(){return this.formatValue()}}},methods:{formatValue(){var e=this._internal;if(e.resultDirty){var t=e.format,n=e.format.match(/\{[A-Za-z0-9_]*\}/g),o=[];n&&(o=n.map((function(e){return e.replace("{","").replace("}","")}))),o.forEach((function(n){var o=e.inputValues[n];t=t.replace("{"+n+"}",void 0!==o?o:"")})),e.cachedResult=t,e.resultDirty=!1}return e.cachedResult},registerInputIfNeeded(e){this.hasInput(e)||this.registerInput(e,{set:n.bind(this,e)})},scheduleFormat(){this.formatScheduled||(this.formatScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.formatValue(),this.flagOutputDirty("formatted"),this.formatScheduled=!1})))}}};function n(e,t){this._internal.inputValues[e]!==t&&(this._internal.inputValues[e]=t,this._internal.resultDirty=!0,this.scheduleFormat())}function o(e,t,n){var o=(t.match(/\{[A-Za-z0-9_]*\}/g)||[]).map((function(e){return e.replace("{","").replace("}","")})).filter((function(e,t,n){return n.indexOf(e)===t})).map((function(e){return{name:e,type:"string",plug:"input"}}));n.sendDynamicPorts(e,o)}e.exports={node:t,setup:function(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("nodeAdded.String Format",(function(t){t.parameters.format&&o(t.id,t.parameters.format,e.editorConnection),t.on("parameterUpdated",(function(n){"format"===n.name&&o(t.id,t.parameters.format,e.editorConnection)}))}))}}},461:e=>{const t={name:"String Mapper",docs:"https://docs.noodl.net/nodes/string-manipulation/string-mapper",category:"Utilities",initialize:function(){this._internal.inputs=[],this._internal.mappings=[]},getInspectInfo(){return this._internal.mappedString},numberedInputs:{input:{type:"string",displayPrefix:"Input",group:"Inputs",index:10,createSetter:e=>function(t){t=void 0===t?"":t.toString(),this._internal.inputs[e]=t,this.scheduleMapping()}},output:{type:"string",displayPrefix:"Mapping",index:1001,group:"Mappings",createSetter:e=>function(t){t=void 0===t?"":t.toString(),this._internal.mappings[e]=t,this.scheduleMapping()}}},inputs:{inputString:{type:{name:"string"},index:1,displayName:"Input String",set:function(e){this._internal.currentInputString=void 0!==e?e.toString():void 0,this.scheduleMapping()}},defaultMapping:{type:"string",displayName:"Default",index:1e3,group:"Mappings",set:function(e){this._internal.defaultMapping=e,this.scheduleMapping()}}},outputs:{mappedString:{type:"string",displayName:"Mapped String",group:"Value",getter:function(){return this._internal.mappedString}}},prototypeExtensions:{doMapping:function(){this._internal.hasScheduledFetch=!1;var e=this._internal.inputs.indexOf(this._internal.currentInputString);this._internal.mappedString=-1!==e?this._internal.mappings[e]:this._internal.defaultMapping,this.flagOutputDirty("mappedString")},scheduleMapping:function(){var e=this._internal;e.hasScheduledFetch||(e.hasScheduledFetch=!0,this.scheduleAfterInputsHaveUpdated(this.doMapping.bind(this)))}}};e.exports={node:t}},2283:e=>{"use strict";e.exports={node:{name:"Substring",docs:"https://docs.noodl.net/nodes/string-manipulation/substring",category:"String Manipulation",initialize:function(){var e=this._internal;e.startIndex=0,e.endIndex=-1,e.cachedResult="",e.inputString="",e.resultDirty=!1},inputs:{start:{type:"number",displayName:"Start",default:0,set:function(e){this._internal.startIndex=e,this._internal.resultDirty=!0,this.flagOutputDirty("result")}},end:{type:"number",displayName:"End",default:0,set:function(e){this._internal.endIndex=e,this._internal.resultDirty=!0,this.flagOutputDirty("result")}},string:{type:{name:"string"},displayName:"String",default:"",set:function(e){e=e.toString(),this._internal.inputString=e,this._internal.resultDirty=!0,this.flagOutputDirty("result")}}},outputs:{result:{type:"string",displayName:"Result",getter:function(){var e=this._internal;return e.resultDirty&&(-1===e.endIndex?e.cachedResult=e.inputString.substr(e.startIndex):e.cachedResult=e.inputString.substr(e.startIndex,e.endIndex-e.startIndex),e.resultDirty=!1),e.cachedResult}}}}}},6969:(e,t,n)=>{"use strict";const o=n(3839),i={name:"Unique Id",docs:"https://docs.noodl.net/nodes/utilities/unique-id",category:"String Manipulation",initialize:function(){this._internal.guid=o.guid()},getInspectInfo(){return this._internal.guid},inputs:{new:{displayName:"New",valueChangedToTrue:function(){this._internal.guid=o.guid(),this.flagOutputDirty("guid")}}},outputs:{guid:{type:"string",displayName:"Id",getter:function(){return this._internal.guid}}},prototypeExtensions:{}};e.exports={node:i}},7425:(e,t,n)=>{"use strict";const o=n(3948);var i={name:"net.noodl.user.SetUserProperties",docs:"https://docs.noodl.net/nodes/data/user/set-user-properties",displayNodeName:"Set User Properties",category:"Cloud Services",color:"data",initialize:function(){this._internal.userProperties={}},getInspectInfo(){},outputs:{success:{type:"signal",displayName:"Success",group:"Events"},failure:{type:"signal",displayName:"Failure",group:"Events"},error:{type:"string",displayName:"Error",group:"Error",getter:function(){return this._internal.error}}},inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue:function(){this.scheduleStore()}},email:{displayName:"Email",type:"string",group:"General",set:function(e){this._internal.email=e}},username:{displayName:"Username",type:"string",group:"General",set:function(e){this._internal.username=e}}},methods:{setError:function(e){this._internal.error=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure"),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"user-set-warning",{message:e,showGlobally:!0})},clearWarnings(){this.context.editorConnection&&this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"user-set-warning")},scheduleStore:function(){const e=this._internal;!0!==this.storeScheduled&&(this.storeScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.storeScheduled=!1,o.Services.UserService.forScope(this.nodeScope.modelScope).setUserProperties({email:this._internal.email,username:this._internal.username,properties:e.userProperties,success:()=>{this.sendSignalOnOutput("success")},error:e=>{this.setError(e)}})})))},setUserProperty:function(e,t){this._internal.userProperties[e]=t},registerInputIfNeeded:function(e){if(!this.hasInput(e))return e.startsWith("prop-")?this.registerInput(e,{set:this.setUserProperty.bind(this,e.substring(5))}):void 0}}};function s(e,t,n,o){var i=[];if(o){var s=o.find((e=>"_User"===e.name));if(s&&s.schema&&s.schema.properties){var r=s.schema.properties;const e=void 0===_noodl_cloud_runtime_version?["authData","createdAt","updatedAt","email","username","emailVerified","password"]:["authData","createdAt","updatedAt","email","username"];for(var a in r)if(-1===e.indexOf(a)){var u=r[a];if(!i.find((e=>e.name===a)))if("Relation"===u.type);else{const e={String:"string",Boolean:"boolean",Number:"number",Date:"date"};i.push({type:{name:e[u.type]?e[u.type]:"*"},plug:"input",group:"Properties",name:"prop-"+a,displayName:a})}}}}n.sendDynamicPorts(e,i)}e.exports={node:i,setup:function(e,t){function n(n){s(n.id,n.parameters,e.editorConnection,t.getMetaData("systemCollections")),n.on("parameterUpdated",(function(o){s(n.id,n.parameters,e.editorConnection,t.getMetaData("systemCollections"))})),t.on("metadataChanged.systemCollections",(function(t){s(n.id,n.parameters,e.editorConnection,t)}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.net.noodl.user.SetUserProperties",(function(e){n(e)}));for(const e of t.getNodesWithType("net.noodl.user.SetUserProperties"))n(e)}))}}},6736:(e,t,n)=>{"use strict";const o=n(3948),{Node:i}=n(3948);var s={name:"net.noodl.user.User",docs:"https://docs.noodl.net/nodes/data/user/user-node",displayNodeName:"User",category:"Cloud Services",color:"data",initialize:function(){var e=this;this._internal.onModelChangedCallback=function(t){e.isInputConnected("fetch")||(e.hasOutput("prop-"+t.name)&&e.flagOutputDirty("prop-"+t.name),e.hasOutput("changed-"+t.name)&&e.sendSignalOnOutput("changed-"+t.name),e.sendSignalOnOutput("changed"))};const t=o.Services.UserService.forScope(this.nodeScope.modelScope);this.setUserModel(t.current),t.on("loggedIn",(()=>{this.setUserModel(t.current),this.hasOutput("loggedIn")&&this.sendSignalOnOutput("loggedIn")})),t.on("sessionGained",(()=>{this.setUserModel(t.current)})),t.on("loggedOut",(()=>{this.setUserModel(void 0),this.hasOutput("loggedOut")&&this.sendSignalOnOutput("loggedOut")})),t.on("sessionLost",(()=>{this.setUserModel(void 0),this.hasOutput("sessionLost")&&this.sendSignalOnOutput("sessionLost")}))},getInspectInfo(){const e=this._internal.model;return e?[{type:"text",value:"Id: "+e.getId()},{type:"value",value:this._internal.model.data}]:"[No Model]"},outputs:{id:{type:"string",displayName:"Id",group:"General",getter:function(){return void 0!==this._internal.model?this._internal.model.getId():void 0}},fetched:{type:"signal",displayName:"Fetched",group:"Events"},changed:{type:"signal",displayName:"Changed",group:"Events"},failure:{type:"signal",displayName:"Failure",group:"Events"},error:{type:"string",displayName:"Error",group:"Error",getter:function(){return this._internal.error}},username:{type:"string",displayName:"Username",group:"General",getter:function(){return void 0!==this._internal.model?this._internal.model.get("username"):void 0}},email:{type:"string",displayName:"Email",group:"General",getter:function(){return void 0!==this._internal.model?this._internal.model.get("email"):void 0}},authenticated:{type:"boolean",displayName:"Authenticated",group:"General",getter:function(){return void 0!==this._internal.model}}},inputs:{fetch:{displayName:"Fetch",group:"Actions",valueChangedToTrue:function(){this.scheduleFetch()}}},methods:{_onNodeDeleted:function(){i.prototype._onNodeDeleted.call(this),this._internal.model&&this._internal.model.off("change",this._internal.onModelChangedCallback)},scheduleOnce:function(e,t){const n=this,o="hasScheduled"+e;this._internal[o]||(this._internal[o]=!0,this.scheduleAfterInputsHaveUpdated((function(){n._internal[o]=!1,t()})))},setError:function(e){this._internal.error=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure"),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"user-warning",{message:e,showGlobally:!0})},clearWarnings(){this.context.editorConnection&&this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"user-warning")},setUserModel(e){const t=this._internal;if(t.model!==e&&(t.model&&t.model.off("change",t.onModelChangedCallback),t.model=e,e&&e.on("change",t.onModelChangedCallback)),this.flagOutputDirty("id"),this.flagOutputDirty("authenticated"),this.flagOutputDirty("email"),this.flagOutputDirty("username"),e)for(var n in e.data)this.hasOutput("prop-"+n)&&this.flagOutputDirty("prop-"+n)},scheduleFetch:function(){this._internal,this.scheduleOnce("Fetch",(()=>{const e=o.Services.UserService.forScope(this.nodeScope.modelScope);e.fetchCurrentUser({success:t=>{this.setUserModel(e.current),this.sendSignalOnOutput("fetched")},error:e=>{this.setError(e||"Failed to fetch.")}})}))},registerOutputIfNeeded:function(e){this.hasOutput(e)||("loggedOut"!==e&&"loggedIn"!==e&&"sessionLost"!==e?e.startsWith("prop-")&&this.registerOutput(e,{getter:this.getUserProperty.bind(this,e.substring(5))}):this.registerOutput(e,{getter:()=>{}}))},getUserProperty:function(e){return void 0!==this._internal.model?this._internal.model.get(e):void 0}}};function r(e,t,n,o){var i=[];if(o){var s=o.find((e=>"_User"===e.name));if(s&&s.schema&&s.schema.properties){var r=s.schema.properties;const e=["authData","password","username","email"];for(var a in r)if(-1===e.indexOf(a)){var u=r[a];if(!i.find((e=>e.name===a)))if("Relation"===u.type);else{const e={String:"string",Boolean:"boolean",Number:"number",Date:"date"};i.push({type:{name:e[u.type]?e[u.type]:"*"},plug:"output",group:"Properties",name:"prop-"+a,displayName:a}),i.push({type:"signal",plug:"output",group:"Changed Events",displayName:a+" Changed",name:"changed-"+a})}}}}void 0===_noodl_cloud_runtime_version&&(i.push({plug:"output",name:"loggedIn",type:"signal",displayName:"Logged In",group:"Events"}),i.push({plug:"output",name:"loggedOut",type:"signal",displayName:"Logged Out",group:"Events"}),i.push({plug:"output",name:"sessionLost",type:"signal",displayName:"Session Lost",group:"Events"})),n.sendDynamicPorts(e,i)}e.exports={node:s,setup:function(e,t){function n(n){r(n.id,n.parameters,e.editorConnection,t.getMetaData("systemCollections")),n.on("parameterUpdated",(function(o){r(n.id,n.parameters,e.editorConnection,t.getMetaData("systemCollections"))})),t.on("metadataChanged.systemCollections",(function(t){r(n.id,n.parameters,e.editorConnection,t)}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.net.noodl.user.User",(function(e){n(e)}));for(const e of t.getNodesWithType("net.noodl.user.User"))n(e)}))}}},3033:(e,t,n)=>{"use strict";const o=n(2887).createDefinition({name:"Boolean",docs:"https://docs.noodl.net/nodes/data/boolean",startValue:!1,type:{name:"boolean"},cast:function(e){return Boolean(e)}});e.exports={node:o}},7383:(e,t,n)=>{"use strict";const o=n(2887).createDefinition({name:"Number",docs:"https://docs.noodl.net/nodes/data/number",startValue:0,nodeDoubleClickAction:{focusPort:"value"},type:{name:"number"},cast:function(e){return Number(e)}});e.exports={node:o}},4950:(e,t,n)=>{"use strict";const o=n(2887),{NodeDefinition:i}=n(3948),s=o.createDefinition({name:"String",docs:"https://docs.noodl.net/nodes/data/string",shortDesc:"Contains a string (text).",startValue:"",nodeDoubleClickAction:{focusPort:"value"},type:{name:"string"},cast:function(e){return String(e)},onChanged:function(){this.flagOutputDirty("length")}});i.extend(s,{usePortAsLabel:"value",portLabelTruncationMode:"length",outputs:{length:{type:"number",displayName:"Length",getter:function(){return this._internal.currentValue.length}}}}),e.exports={node:s}},2887:e=>{"use strict";e.exports={createDefinition:function(e){return{name:e.name,docs:e.docs,shortDesc:e.shortDesc,nodeDoubleClickAction:e.nodeDoubleClickAction,category:"Variables",initialize:function(){this._internal.currentValue=e.startValue,this._internal.latestValue=0},getInspectInfo(){return[{type:"color"===e.type.name?"color":"text",value:this._internal.currentValue}]},inputs:{value:{type:e.type,displayName:"Value",default:e.startValue,set:function(e){!1===this.isInputConnected("saveValue")?this.setValueTo(e):this._internal.latestValue=e}},saveValue:{displayName:"Set",valueChangedToTrue:function(){this.scheduleAfterInputsHaveUpdated((function(){this.setValueTo(this._internal.latestValue),this.sendSignalOnOutput("stored")}))}}},outputs:{savedValue:{type:e.type.name,displayName:"Value",getter:function(){return this._internal.currentValue}},changed:{type:"signal",displayName:"Changed"},stored:{type:"signal",displayName:"Stored"}},prototypeExtensions:{setValueTo:function(t){t=e.cast(t);const n=this._internal.currentValue!==t;this._internal.currentValue=t,n&&(this.flagOutputDirty("savedValue"),this.sendSignalOnOutput("changed"),e.onChanged&&e.onChanged.call(this))}}}}}},61:(e,t,n)=>{"use strict";const o=n(7662);function i(e,t){this.context=e,this.nodes={},this.componentOwner=t,this.componentInstanceChildren={}}i.prototype.addConnection=function(e){try{t=e,["sourceId","sourcePort","targetId","targetPort"].forEach((function(e){if(!t[e])throw new Error("Missing "+e)}))}catch(e){throw new Error("Error in connection: "+e.message)}var t;try{var n=this.getNodeWithId(e.sourceId),o=this.getNodeWithId(e.targetId);o.registerInputIfNeeded(e.targetPort),n.registerOutputIfNeeded(e.sourcePort),o.connectInput(e.targetPort,n,e.sourcePort)}catch(e){console.error(e.message)}},i.prototype.setNodeParameters=function(e,t){const n=this.context.variants.getVariant(t.type,t.variant);if(n)e.setVariant(n);else{const n=t.parameters;var o=Object.keys(n);if(this.context.nodeRegister.hasNode(e.name)){var i=this.context.nodeRegister.getNodeMetadata(e.name);o.sort((function(e,t){var n=i.inputs[e],o=i.inputs[t];return(o?o.inputPriority:0)-(n?n.inputPriority:0)}))}o.forEach((t=>{e.registerInputIfNeeded(t),!1!==e.hasInput(t)&&e.queueInput(t,n[t])}))}},i.prototype.createNodeFromModel=async function(e,t){if("Component Children"!==e.type){var n;try{(n=await this.createNode(e.type,e.id)).updateOnDirtyFlagging=!1!==t,n.setNodeModel(e)}catch(t){return console.error(t.message),void(this.context.editorConnection&&this.context.isWarningTypeEnabled("nodescope")&&this.context.editorConnection.sendWarning(this.componentOwner.name,e.id,"nodelibrary-unknown-node",{message:t.message,showGlobally:!0}))}return e.variant&&n.setVariant&&n.setVariant(e.variant),this.setNodeParameters(n,e),e.parent&&this.insertNodeInTree(n,e),n}if(e.parent){var o=this.getNodeWithId(e.parent.id);this.componentOwner.setChildRoot(o)}},i.prototype.insertNodeInTree=function(e,t){var n=this.getNodeWithId(t.parent.id),o=t.parent.children.indexOf(t);if(!n.addChild)throw new Error("Node "+n.id+" of type "+n.constructor.name+" can't have children");n.addChild(e,o)},i.prototype.getNodeWithId=function(e){if(!1===this.nodes.hasOwnProperty(e))throw new Error("Unknown node id "+e);return this.nodes[e]},i.prototype.hasNodeWithId=function(e){return this.nodes.hasOwnProperty(e)},i.prototype.createPrimitiveNode=function(e,t,n){if(t||(t=o()),this.nodes.hasOwnProperty(t))throw Error("duplicate id "+t);const i=this.context.nodeRegister.createNode(e,t,this);if(n)for(const e in n)i[e]=n[e];return this.nodes[t]=i,i},i.prototype.createNode=async function(e,t,n){if(t||(t=o()),this.nodes.hasOwnProperty(t))throw Error("duplicate id "+t);let i;if(this.context.nodeRegister.hasNode(e)){if(i=this.context.nodeRegister.createNode(e,t,this),n)for(const e in n)i[e]=n[e]}else i=await this.context.createComponentInstanceNode(e,t,this,n),this.componentInstanceChildren[t]=i;return this.nodes[t]=i,i},i.prototype.getNodesWithIdRecursive=function(e){var t=n(3657),o=[];return function e(n,o,i){n.nodes.hasOwnProperty(o)&&i.push(n.nodes[o]),Object.keys(n.nodes).filter((function(e){return n.nodes[e]instanceof t})).forEach((function(t){e(n.nodes[t].nodeScope,o,i)}))}(this,e,o),o},i.prototype.getNodesWithType=function(e){var t=this;return Object.keys(this.nodes).filter((function(n){return t.nodes[n].name===e})).map((function(e){return t.nodes[e]}))},i.prototype.getNodesWithTypeRecursive=function(e){var t=n(3657),o=this,i=[];return i=i.concat(o.getNodesWithType(e)),Object.keys(o.nodes).filter((function(e){return o.nodes[e]instanceof t})).forEach((function(t){var n=o.nodes[t].nodeScope.getNodesWithTypeRecursive(e);i=i.concat(n)})),i},i.prototype.getAllNodesRecursive=function(){var e=n(3657);let t=[];return(()=>{t=t.concat(Object.values(this.nodes)),Object.keys(this.nodes).filter((t=>this.nodes[t]instanceof e)).forEach((e=>{var n=this.nodes[e].nodeScope.getAllNodesRecursive();t=t.concat(n)}))})(),t},i.prototype.getAllNodesWithVariantRecursive=function(e){return this.getAllNodesRecursive().filter((t=>t.variant===e))},i.prototype.onNodeModelRemoved=function(e){var t=this.getNodeWithId(e.id);e.parent&&this.getNodeWithId(e.parent.id).removeChild(t),t._onNodeDeleted(),delete this.nodes[t.id],delete this.componentInstanceChildren[t.id]},i.prototype.removeConnection=function(e){this.getNodeWithId(e.targetId).removeInputConnection(e.targetPort,e.sourceId,e.sourcePort)},i.prototype.setComponentModel=async function(e){this.componentModel=e;const t=[];for(const n of e.getAllNodes()){const e=await this.createNodeFromModel(n,!1);e&&t.push(e)}e.getAllConnections().forEach((e=>this.addConnection(e))),t.forEach((e=>e.updateOnDirtyFlagging=!0)),t.forEach((e=>{e._dirty&&e._performDirtyUpdate()})),e.on("connectionAdded",(e=>this.addConnection(e)),this),e.on("connectionRemoved",this.removeConnection,this),e.on("nodeAdded",this.createNodeFromModel,this);var n=this;e.on("nodeParentWillBeRemoved",(function(e){if("Component Children"===e.type)return void(e.parent&&this.componentOwner.setChildRoot(null));const t=n.getNodeWithId(e.id);t.parent&&t.parent.removeChild(t)}),this),e.on("nodeParentUpdated",(function(e){if("Component Children"===e.type){var t=this.getNodeWithId(e.parent.id);this.componentOwner.setChildRoot(t)}else{var o=n.getNodeWithId(e.id);n.insertNodeInTree(o,e)}}),this),e.on("nodeRemoved",(function(e){"Component Children"!==e.type&&n.onNodeModelRemoved(e)}),this);for(const e in this.nodes){const t=this.nodes[e];t.nodeScopeDidInitialize&&t.nodeScopeDidInitialize()}},i.prototype.reset=function(){this.componentModel&&(this.componentModel.removeListenersWithRef(this),this.componentModel=void 0),Object.keys(this.nodes).forEach((e=>{this.nodes.hasOwnProperty(e)&&this.deleteNode(this.nodes[e])}))},i.prototype.deleteNode=function(e){if(!1!==this.nodes.hasOwnProperty(e.id)){if(e.parent&&e.parent.removeChild(e),e.getChildren&&e.getChildren().forEach((t=>{e.removeChild(t),(t.parentNodeScope||t.nodeScope).deleteNode(t)})),this.componentModel){const t=this.componentModel.getConnectionsFrom(e.id),n=this.componentModel.getConnectionsTo(e.id);t.concat(n).forEach((e=>{this.nodes.hasOwnProperty(e.targetId)&&this.nodes.hasOwnProperty(e.sourceId)&&this.removeConnection(e)}))}e._onNodeDeleted(),delete this.nodes[e.id],delete this.componentInstanceChildren[e.id]}else console.error("Node doesn't belong to this scope",e.id,e.name)},i.prototype.sendEventFromThisScope=function(e,t,n,o,i){if(o)for(var s=this.getNodesWithType("Event Receiver").filter((function(t){return t.getChannelName()===e})),r=0;r{if(o.name&&this.context.hasComponentModelWithName(o.name)&&o.nodeScope.sendEventFromThisScope(e,t,n,!0))return!0}))}else if("siblings"===n){let n;if(n=this.componentOwner.parent?this.componentOwner.parent.nodeScope:this.componentOwner.parentNodeScope,!n)return;for(var u in a=n.nodes){var c;(c=a[u].children)&&c.filter((e=>e.name&&this.context.hasComponentModelWithName(e.name)&&e.nodeScope!==this)).forEach((n=>{if(n.nodeScope.sendEventFromThisScope(e,t,null,!0))return!0}))}}return!1},e.exports=i},6454:e=>{"use strict";function t(e){if(!e.owner)throw new Error("Owner must be set");this.getter=e.getter,this.connections=[],this.owner=e.owner,this.name=e.name,this.onFirstConnectionAdded=e.onFirstConnectionAdded,this.onLastConnectionRemoved=e.onLastConnectionRemoved,this._id=void 0}Object.defineProperties(t.prototype,{value:{get:function(){return this.getter.call(this.owner)}},id:{get:function(){return this._id||(this._id=this.owner.id+this.name),this._id}},registerConnection:{value:function(e,t){this.connections.push({node:e,inputPortName:t}),1===this.connections.length&&this.onFirstConnectionAdded&&this.onFirstConnectionAdded.call(this.owner)}},deregisterConnection:{value:function(e,t){for(var n=0;n500&&(this.owner._cyclicLoop=!0);for(var t=0,n=this.connections.length;t0}}}),e.exports=t},4190:e=>{"use strict";e.exports={generateProjectSettings:function(e,t){const n={dynamicports:[],ports:[]};return function(e,t){for(var n=0;n{var o=n(5627);function i(){}i.events=new o,e.exports=i},3187:e=>{"use strict";function t(e,t){for(var n in this.duration=t.duration||0,this._isRunning=!1,this._hasCalledOnStart=!1,this.scheduler=e,this.repeatCount=1,this.delay=0,t)this[n]=t[n]}function n(e){this.requestFrame=e,this.runningTimers=[],this.newTimers=[]}t.prototype.start=function(){return this._isRunning&&this.stop(),this.scheduler.scheduleTimer(this),this},t.prototype.stop=function(){this.scheduler.stopTimer(this),this._hasCalledOnStart=!1,this._isRunning=!1,this._wasStopped=!0},t.prototype.isRunning=function(){return this._isRunning},t.prototype.durationLeft=function(){return this._durationLeft},n.prototype.createTimer=function(e){return new t(this,e)},n.prototype.scheduleTimer=function(e){-1===this.newTimers.indexOf(e)&&(0===e.repeatCount&&(e.repeatCount=1e5),this.newTimers.push(e),this.requestFrame())},n.prototype.stopTimer=function(e){var t;e._isRunning?(-1!==(t=this.runningTimers.indexOf(e))&&this.runningTimers.splice(t,1),e.onStop&&!e._wasStopped&&e.onStop()):-1!==(t=this.newTimers.indexOf(e))&&this.newTimers.splice(t,1)},n.prototype.runTimers=function(e){var t,n,o=[],i=[],s=[],r=this.runningTimers.length;for(t=0;t=n._start){var a;!1===n._hasCalledOnStart&&n.onStart&&(n.onStart(),n._hasCalledOnStart=!0),a=n.duration>0?(e-n._start)/(n.duration*n.repeatCount):1,n._durationLeft=n.duration*(1-a);var u=a*n.repeatCount-Math.floor(a*n.repeatCount);a>=1&&(u=1),n.onRunning&&n.onRunning(u),a<1&&n._isRunning?o.push(n):n._wasStopped||i.push(n)}else o.push(n);for(this.runningTimers=o,t=0;t0){for(t=0;t0||this.newTimers.length>0},e.exports=n},5722:e=>{e.exports={getAbsoluteUrl:function(e){const t=String(e);return!t||"/"===t[0]||t.includes("://")||t.startsWith("data:")?t:(Noodl.baseUrl||"/")+t},logJavaScriptNodeError:function(e){"string"==typeof e?console.log("Error in JS node run code.",e):console.log("Error in JS node run code.",Object.getPrototypeOf(e).constructor.name+": "+e.message,e.stack)}}},84:e=>{e.exports=class{constructor({graphModel:e,getNodeScope:t}){this.getNodeScope=t,e&&(this.graphModel=e,e.on("variantUpdated",(e=>this.onVariantUpdated(e))))}getVariant(e,t){if(this.graphModel)return this.graphModel.getVariant(e,t)}onVariantUpdated(e){const t=this.getNodeScope();if(!t)return;const n=t.getNodesWithTypeRecursive(e.typename).filter((t=>t.variant?t.variant.name===e.name:t.model&&t.model.variant===e.name));for(const t of n)t.setVariant(e)}}},9597:(e,t,n)=>{const o=n(4007),i={delete:async e=>new Promise(((t,n)=>{o.instance.deleteFile({file:{name:e},success:e=>{t()},error:e=>{n(e)}})}))};e.exports=i},1651:(e,t,n)=>{const o=n(3839),i=n(4007),s=n(3948),r=n(4552);e.exports=function(e){let t;const n=()=>(t||(t=new i(e)),t),a=r(e),u={async logIn(t,n){if("object"==typeof t&&void 0===n){const e=t;t=e.username,n=e.password}return new Promise(((o,i)=>{s.Services.UserService.forScope(e).logIn({username:t,password:n,success:e=>{o(e)},error:e=>{i(Error(e))}})}))},async impersonate(t,n){const i=await a.query("_User",{username:{equalTo:t}});if(!i||1!==i.length)throw Error("Could not find user.");const r=i[0],u={and:[{user:{pointsTo:r.id}},{expiresAt:{greaterThan:new Date}}]};n&&n.installationId&&u.and.push({installationId:{equalTo:n.installationId}});const c=await a.query("_Session",u);async function l(t){return new Promise(((n,o)=>{s.Services.UserService.forScope(e).fetchUser({sessionToken:t,success:e=>n(e),error:e=>o(Error(e))})}))}return c&&0!==c.length?l(c[0].sessionToken):l((await a.create("_Session",{user:r.id,installationId:n?n.installationId:void 0,sessionToken:"r:"+o.guid()+o.guid(),expiresAt:new Date(Date.now()+(n&&void 0!==n.duration?n.duration:864e5)),restricted:!1})).sessionToken)}};return Object.defineProperty(u,"Current",{get:function(){const t=(e||o).get("Request").get("UserId");if(t)return{UserId:t,Properties:(e||o).get(t),save:async i=>new Promise(((s,r)=>{n().save({collection:"_User",objectId:t,data:(e||o).get(t).data,acl:i?i.acl:void 0,success:e=>{s()},error:e=>{r(Error(e||"Failed to save."))}})})),fetch:async()=>new Promise(((e,o)=>{n().fetch({collection:"_User",objectId:t,success:function(t){var o=n()._fromJSON(t,"_User");e(o)},error:function(e){o(Error(e||"Failed to fetch."))}})}))}}}),u}},6011:(e,t,n)=>{const{Node:o,EdgeTriggeredInput:i}=n(3948),s=n(4007),r=n(5995),a=n(5802);var u={name:"noodl.cloud.aggregate",docs:"https://docs.noodl.net/nodes/cloud-functions/cloud-data/aggregate-records",displayName:"Aggregate Records",category:"Cloud Services",usePortAsLabel:"collectionName",color:"data",initialize:function(){this._internal.queryParameters={},this._internal.storageSettings={},this._internal.aggregates={}},getInspectInfo(){const e=this._internal.aggregateValues;return e?[{type:"value",value:e}]:{type:"text",value:"[Not executed yet]"}},inputs:{aggregates:{index:100,group:"Aggregates",type:{name:"stringlist",allowEditOnly:!0},displayName:"Aggregates",set:function(e){this._internal.aggregatesList=e}}},outputs:{fetched:{group:"Events",type:"signal",displayName:"Success"},failure:{group:"Events",type:"signal",displayName:"Failure"},error:{type:"string",displayName:"Error",group:"Error",getter:function(){return this._internal.error}}},prototypeExtensions:{setCollectionName:function(e){this._internal.name=e,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()},_onNodeDeleted:function(){o.prototype._onNodeDeleted.call(this)},setError:function(e){this._internal.err=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure")},scheduleFetch:function(){var e=this._internal;e.fetchScheduled||(e.fetchScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{e.fetchScheduled=!1,this.fetch()})))},fetch:function(){if(this.context.editorConnection){let e=!0;this._internal.aggregatesList&&this._internal.aggregatesList.split(",").forEach((t=>{-1!==t.indexOf(" ")&&(e=!1)})),void 0===this._internal.name?this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"aggregate-node",{message:"No class specified for aggregate."}):void 0===this._internal.aggregatesList?this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"aggregate-node",{message:"No aggregates specified."}):e?this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"aggregate-node"):this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"aggregate-node",{message:"Invalid aggregate names, dont use space and special characters."})}const e=this.getStorageFilter();this._internal.currentQuery={where:e.where},s.forScope(this.nodeScope.modelScope).aggregate({collection:this._internal.name,where:e.where,group:this.getAggregates(),success:e=>{this._internal.aggregateValues=e;for(const t in e)this.hasOutput("agg-"+t)&&this.flagOutputDirty("agg-"+t);this.sendSignalOnOutput("fetched")},error:e=>{this.setError(e||"Failed to aggregate.")}})},getStorageFilter:function(){const e=this._internal.storageSettings;if(void 0===e.storageFilterType||"simple"===e.storageFilterType)return{where:void 0!==this._internal.visualFilter?a.convertVisualFilter(this._internal.visualFilter,{queryParameters:this._internal.queryParameters,collectionName:this._internal.name}):void 0};if("json"===e.storageFilterType){if(!this._internal.filterFunc)try{var t=e.storageJSONFilter;t=t.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,""),this._internal.filterVariables=t.match(/\$[A-Za-z0-9]+/g)||[];var n=["where","Inputs"].concat(this._internal.filterVariables).concat([t]);this._internal.filterFunc=Function.apply(null,n)}catch(e){this._internal.filterFunc=void 0,console.log("Error while parsing filter script: "+e)}if(!this._internal.filterFunc)return;var o={},i=this;const r={};for(let t in e)t.startsWith("storageFilterValue-")&&(r[t.substring(19)]=e[t]);var s=[function(e){o=a.convertFilterOp(e,{collectionName:i._internal.name,error:function(e){i.context.editorConnection.sendWarning(i.nodeScope.componentOwner.name,i.id,"aggregate-node-filter",{message:e})}})},r];this._internal.filterVariables.forEach((t=>{s.push(e["storageFilterValue-"+t.substring(1)])}));try{this._internal.filterFunc.apply(this,s)}catch(e){console.log("Error while running filter script: "+e)}return{where:o}}},getAggregates:function(){if(!this._internal.aggregatesList)return{};if(!this._internal.aggregates)return{};const e=s._collections[this._internal.name];if(!e||!e.schema||!e.schema.properties)return{};const t=this._internal.aggregates,n={};return this._internal.aggregatesList.split(",").forEach((o=>{if(void 0===t[o].prop)return;const i=e.schema.properties[t[o].prop];if(void 0===i)return;const s={},r="String"===i.type?"distinct":"avg";s[t[o].op||r]=t[o].prop,n[o]=s})),n},getAggregateValue:function(e){if(this._internal.aggregateValues)return this._internal.aggregateValues[e]},registerOutputIfNeeded:function(e){this.hasOutput(e)||e.startsWith("agg-")&&this.registerOutput(e,{getter:this.getAggregateValue.bind(this,e.substring(4))})},setVisualFilter:function(e){this._internal.visualFilter=e,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()},setQueryParameter:function(e,t){this._internal.queryParameters[e]=t,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()},setAggregateParameter:function(e,t){const n=this._internal.aggregates;if(e.startsWith("aggprop-")){const o=e.substring(8);n[o]||(n[o]={}),n[o].prop=t}else if(e.startsWith("aggop-")){const o=e.substring(6);n[o]||(n[o]={}),n[o].op=t}},registerInputIfNeeded:function(e){if(this.hasInput(e))return;if(e.startsWith("agg"))return this.registerInput(e,{set:this.setAggregateParameter.bind(this,e)});if(e.startsWith("qp-"))return this.registerInput(e,{set:this.setQueryParameter.bind(this,e.substring(3))});const t={storageFetch:this.scheduleFetch.bind(this)};if(t[e])return this.registerInput(e,{set:i.createSetter({valueChangedToTrue:t[e]})});const n={collectionName:this.setCollectionName.bind(this),visualFilter:this.setVisualFilter.bind(this)};if(n[e])return this.registerInput(e,{set:n[e]});this.registerInput(e,{set:c.bind(this,e)})}}};function c(e,t){this._internal.storageSettings[e]=t,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()}function l(e,t,n,o){var i=[];const s=o.getMetaData("dbCollections"),a=o.getMetaData("systemCollections");if(i.push({name:"collectionName",type:{name:"enum",enums:[{label:"User",value:"_User"},{label:"Role",value:"_Role"}].concat(void 0!==s?s.map((e=>({value:e.name,label:e.name}))):[]),allowEditOnly:!0},displayName:"Class",plug:"input",group:"General"}),i.push({name:"storageFilterType",type:{name:"enum",allowEditOnly:!0,enums:[{value:"simple",label:"Visual"},{value:"json",label:"Javascript"}]},displayName:"Filter",default:"simple",plug:"input",group:"General"}),i.push({type:"signal",plug:"input",group:"Actions",name:"storageFetch",displayName:"Do"}),void 0!==t.aggregates&&void 0!==t.collectionName&&(void 0===(u=s&&s.find((e=>e.name===t.collectionName)))&&a&&(u=a.find((e=>e.name===t.collectionName))),u&&u.schema&&u.schema.properties)){const p=t.aggregates.split(","),h=Object.keys(u.schema.properties).filter((e=>"Number"===u.schema.properties[e].type||"String"===u.schema.properties[e].type));p.forEach((e=>{if(i.push({index:101,name:"aggprop-"+e,plug:"input",type:{name:"enum",enums:h.map((e=>({value:e,label:e}))),allowEditOnly:!0},displayName:"Property",group:e}),void 0!==t["aggprop-"+e]){const n=t["aggprop-"+e],o=u.schema.properties[n];o&&"Number"===o.type?(i.push({index:102,name:"aggop-"+e,plug:"input",type:{name:"enum",enums:[{value:"min",label:"Min"},{value:"max",label:"Max"},{value:"sum",label:"Sum"},{value:"avg",label:"Avg"}],allowEditOnly:!0},default:"avg",displayName:"Operation",group:e}),i.push({name:"agg-"+e,plug:"output",type:"number",displayName:e,group:"Aggregates"})):o&&"String"===o.type&&(i.push({index:102,name:"aggop-"+e,plug:"input",type:{name:"enum",enums:[{value:"distinct",label:"Distinct"}],allowEditOnly:!0},default:"distinct",displayName:"Operation",group:e}),i.push({name:"agg-"+e,plug:"output",type:"string",displayName:e,group:"Aggregates"}))}}))}if(void 0===t.storageFilterType||"simple"===t.storageFilterType){if(void 0!==t.collectionName){var u;if(void 0===(u=s&&s.find((e=>e.name===t.collectionName)))&&a&&(u=a.find((e=>e.name===t.collectionName))),u&&u.schema&&u.schema.properties){const m=JSON.parse(JSON.stringify(u.schema));function c(e){if(void 0!==e.schema&&void 0!==e.schema.properties)for(var n in e.schema.properties){var o=e.schema.properties[n];"Relation"===o.type&&o.targetClass===t.collectionName&&(void 0===m.relations&&(m.relations={}),void 0===m.relations[e.name]&&(m.relations[e.name]=[]),m.relations[e.name].push({property:n}))}}s&&s.forEach(c),a&&a.forEach(c),i.push({name:"visualFilter",plug:"input",type:{name:"query-filter",schema:m,allowEditOnly:!0},displayName:"Filter",group:"Filter"})}if(void 0!==t.visualFilter){const f={};!function e(t){void 0!==t&&(void 0!==t.rules?t.rules.forEach((t=>e(t))):void 0!==t.input&&(f[t.input]=!0))}(t.visualFilter),Object.keys(f).forEach((e=>{i.push({name:"qp-"+e,plug:"input",type:"*",displayName:e,group:"Query Parameters"})}))}}}else if("json"===t.storageFilterType){i.push({type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},plug:"input",group:"Filter",name:"storageJSONFilter",default:"// Write your query script here, check out the reference documentation for examples\nwhere({ })\n",displayName:"Filter"});var l=t.storageJSONFilter;if(l){var d=(l=l.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,"")).match(/\$[A-Za-z0-9]+/g);if(d){const g={};d.forEach((e=>{g[e]=!0})),Object.keys(g).forEach((e=>{i.push({name:"storageFilterValue-"+e.substring(1),displayName:e.substring(1),group:"Filter Values",plug:"input",type:{name:"*",allowConnectionsOnly:!0}})}))}r.parseAndAddPortsFromScript(l,i,{inputPrefix:"storageFilterValue-",inputGroup:"Filter Values",inputType:{name:"*",allowConnectionsOnly:!0},skipOutputs:!0})}}n.sendDynamicPorts(e,i)}e.exports={node:u,setup:function(e,t){function n(n){l(n.id,n.parameters,e.editorConnection,t),n.on("parameterUpdated",(function(o){(o.name.startsWith("storage")||"visualFilter"===o.name||"collectionName"===o.name||o.name.startsWith("agg"))&&l(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.dbCollections",(function(o){s.invalidateCollections(),l(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.systemCollections",(function(o){s.invalidateCollections(),l(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.cloudservices",(function(e){s.instance._initCloudServices()}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.noodl.cloud.aggregate",(function(e){n(e)}));for(const e of t.getNodesWithType("noodl.cloud.aggregate"))n(e)}))}}},4067:(e,t,n)=>{"use strict";const o=n(3839),i=n(3948),s=n(5995),r={};s.getComponentScopeForNode=function(){return r},s.createNoodlAPI=function(e){return{getProjectSettings:i.instance.getProjectSettings.bind(i.instance),getMetaData:i.instance.getMetaData.bind(i.instance),Object:e||o,Variables:(e||o).get("--ndl--global-variables"),Records:n(4552)(e),Users:n(1651)(e),Files:n(9597),Objects:new Proxy(e||o,{get:(t,n,i)=>(e||o).get(n),set(t,n,i){(e||o).get(n).setAll(i)}})}}},8715:(e,t,n)=>{const o=n(3948),i=n(5627),s=n(3839),r=n(4007);class a{constructor(e){this.events=new i,this.events.setMaxListeners(1e5);const t=(e||s).get("Request");if(void 0!==t.UserId){const n=(e||s).get(t.UserId);this.current=n}this.modelScope=e}on(){this.events.on.apply(this.events,arguments)}off(){this.events.off.apply(this.events,arguments)}_makeRequest(e,t){if("undefined"==typeof _noodl_cloudservices)return void(t.error&&t.error({error:"No active cloud service",status:0}));const n=_noodl_cloudservices;fetch(n.endpoint+e,{method:t.method||"GET",headers:{"X-Parse-Application-Id":n.appId,"X-Parse-Master-Key":n.masterKey,"content-type":"application/json","X-Parse-Session-Token":t.sessionToken},body:JSON.stringify(t.content)}).then((e=>{e.ok?e.json().then((e=>t.success(e))):e.json().then((n=>t.error({error:n.error,status:e.status})))})).catch((e=>{t.error({error:e.message})}))}setUserProperties(e){if(void 0!==this.current){const t=r._serializeObject({...e.properties},"_User",this.modelScope||s),n=Object.assign({},{email:e.email,username:e.username},t);delete n.createdAt,delete n.updatedAt,this._makeRequest("/users/"+this.current.getId(),{method:"PUT",content:n,success:t=>{for(let e in n)this.current.set(e,n[e]);e.success(t)},error:t=>{e.error(t.error)}})}}logIn(e){this._makeRequest("/login",{method:"POST",content:{username:e.username,password:e.password,method:"GET"},success:t=>{delete t.ACL,delete t.className,delete t.__type;const n=r._fromJSON(t,"_User",this.modelScope||s);e.success(n)},error:t=>{e.error(t.error)}})}fetchUser(e){this._makeRequest("/users/me",{method:"GET",sessionToken:e.sessionToken,success:t=>{delete t.ACL,delete t.className,delete t.__type;const n=r._fromJSON(t,"_User",this.modelScope||s);e.success(n)},error:t=>{e.error(t.error)}})}fetchCurrentUser(e){e.sessionToken?this._makeRequest("/users/me",{method:"GET",sessionToken:e.sessionToken,success:t=>{delete t.ACL,delete t.className,delete t.__type,this.current=r._fromJSON(t,"_User",this.modelScope||s),this.events.emit("sessionGained"),e.success(this.current)},error:t=>{e.error(t.error)}}):void 0!==this.current&&this._makeRequest("/users/"+this.current.getId(),{method:"GET",success:t=>{delete t.ACL,delete t.className,delete t.__type,this.current=r._fromJSON(t,"_User",this.modelScope||s),e.success(this.current)},error:t=>{e.error(t.error)}})}}var u;a.forScope=e=>void 0===e?a.instance:(e._userService||(e._userService=new a(e)),e._userService),Object.defineProperty(a,"instance",{get:function(){return void 0===u&&(u=new a),u}}),o.Services.UserService=a,e.exports=a}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(n.exports,n,n.exports,__webpack_require__),n.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var __webpack_exports__={};(()=>{"use strict";var e=__webpack_require__(1920);console.log("Noodl Editor Cloud Runtime!"),console.log("Version: "+_noodl_cloud_runtime_version);const t=new e.CloudRunner({webSocketClass:WebSocket,connectToEditor:!0,editorAddress:"ws://localhost:8574",enableDebugInspectors:!0});t.runtime.graphModel.on("editorImportComplete",(()=>{ipcRenderer.send("noodl-cf-has-loaded-project")}));const n=[];let o=!1;const i=()=>{for(o=!1;n.length>0;)n.shift()()},s=window.setImmediate;window.setImmediate=e=>{n.push(e),o||(o=!0,s(i))};const r={},a=window.fetch;window.fetch=function(e,t){return t&&"node"===t.platform?new Promise(((n,o)=>{const i=Math.random().toString(26).slice(2);r[i]=e=>{if(void 0===e.error){const t={body:e.body,status:e.status,headers:e.headers,ok:200===e.status||201===e.status,json:()=>{try{return Promise.resolve(JSON.parse(t.body))}catch(e){return Promise.reject("Failed to parse JSON response")}},text:()=>Promise.resolve(t.body)};n(t)}else o(e.error)},ipcRenderer.send("noodl-cf-fetch",{url:e,method:t.method,token:i,headers:JSON.parse(JSON.stringify(t.headers)),body:t.body})})):a(e,t)},ipcRenderer.on("noodl-cf-fetch-response",(async function(e,t){"function"==typeof r[t.token]&&(r[t.token](t),delete r[t.token])})),ipcRenderer.on("noodl-cf-request",(async function(e,n){n.cloudService&&(window._noodl_cloudservices={endpoint:n.cloudService.endpoint,appId:n.cloudService.appId,masterKey:n.cloudService.masterKey}),console.info(`Cloud function ${n.function} called`);try{const o=await(async(e,n)=>await t.run(e,n))(n.function,{body:n.body,headers:n.headers});console.info(`Cloud function ${n.function} response [${o.statusCode}]`),e.sender.send("noodl-cf-response",Object.assign({},o,{token:n.token}))}catch(t){console.error(`Cloud function ${n.function} response [400] message: ${t.message}`),e.sender.send("noodl-cf-response",{token:n.token,statusCode:400,body:JSON.stringify({error:t.message})})}}))})()})(); +//# sourceMappingURL=sandbox.viewer.bundle.js.map \ No newline at end of file diff --git a/packages/noodl-editor/src/external/cloudruntime/sandbox.viewer.bundle.js.map b/packages/noodl-editor/src/external/cloudruntime/sandbox.viewer.bundle.js.map new file mode 100644 index 0000000..9b6386e --- /dev/null +++ b/packages/noodl-editor/src/external/cloudruntime/sandbox.viewer.bundle.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sandbox.viewer.bundle.js","mappings":"wIAUA,IAGIA,EAAiB,4BAGjBC,EAAmB,iBAGnBC,EAAU,qBACVC,EAAU,oBACVC,EAAS,6BASTC,EAAe,8BAGfC,EAA8B,iBAAV,EAAAC,GAAsB,EAAAA,GAAU,EAAAA,EAAOC,SAAWA,QAAU,EAAAD,EAGhFE,EAA0B,iBAARC,MAAoBA,MAAQA,KAAKF,SAAWA,QAAUE,KAGxEC,EAAOL,GAAcG,GAAYG,SAAS,cAATA,GA+BrC,SAASC,EAAcC,EAAOC,GAE5B,SADaD,IAAQA,EAAME,SAgG7B,SAAqBF,EAAOC,EAAO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UAC5BkiD,EAAQ35B,IAAI7sB,EAAcsE,GAsFnB6iD,CAAc5pD,EAAK2pD,SAAU,CAC7CziD,KAAMlH,EAAKkH,KACXF,QAAShH,EAAKgH,UAGhB0Y,QAAQuhB,KAAK,kBAAkBjhC,EAAK2pD,sBAAsBz1C,EAAI/K,eAE9DR,EAAMkhD,OAAO7gD,KAAK,oBAAqB1P,OAAO8W,OAAO,CAAC,EAAG8D,EAAK,CAAEyO,MAAO3iB,EAAK2iB,QAC9E,CAAE,MAAOlkB,GACPihB,QAAQ5Y,MAAM,kBAAkB9G,EAAK2pD,oCAAoClrD,EAAE2Q,WAE3EzG,EAAMkhD,OAAO7gD,KAAK,oBAAqB,CACrC2Z,MAAO3iB,EAAK2iB,MACZxZ,WAAY,IACZjC,KAAM5F,KAAKC,UAAU,CAAEuF,MAAOrI,EAAE2Q,WAEpC,CACF,G","sources":["webpack://@noodl/cloud-runtime/../../node_modules/lodash.difference/index.js","webpack://@noodl/cloud-runtime/./src/index.ts","webpack://@noodl/cloud-runtime/./src/nodes/cloud/request.ts","webpack://@noodl/cloud-runtime/./src/nodes/cloud/response.ts","webpack://@noodl/cloud-runtime/./src/nodes/index.ts","webpack://@noodl/cloud-runtime/../noodl-runtime/noodl-runtime.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/api/cloudfile.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/api/cloudstore.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/api/configservice.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/api/queryutils.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/api/records.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/async-pool.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/collection.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/edgetriggeredinput.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/editorconnection.activewarnings.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/editorconnection.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/editormodeleventshandler.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/events.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/eventsender.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/guid.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/javascriptnodeparser.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/model.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/models/componentmodel.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/models/graphmodel.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/models/nodemodel.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/node.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodecontext.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodedefinition.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodelibraryexport.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/noderegister.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/componentinputs.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/componentinstance.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/componentoutputs.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/and.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/booleantostring.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/condition.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/counter.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/data/cloudfilenode.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/data/dbcollectionnode2.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/data/dbconfig.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/data/dbmodelcrudbase.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/data/dbmodelnode-addrelation.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/data/dbmodelnode-removerelation.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/data/dbmodelnode2.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/data/deletedbmodelpropertiesnode.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/data/filterdbmodelsnode.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/data/modelcrudbase.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/data/modelnode2.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/data/newdbmodelpropertiesnode.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/data/newmodelnode.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/data/restnode.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/data/setdbmodelpropertiesnode.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/data/setmodelpropertiesnode.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/datetostring.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/expression.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/inverter.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/or.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/runtasks.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/simplejavascript.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/stringformat.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/stringmapper.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/substring.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/uniqueid.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/user/setuserproperties.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/user/user.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/variables/boolean.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/variables/number.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/variables/string.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodes/std-library/variables/variablebase.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/nodescope.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/outputproperty.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/projectsettings.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/services/services.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/timerscheduler.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/utils.js","webpack://@noodl/cloud-runtime/../noodl-runtime/src/variants.js","webpack://@noodl/cloud-runtime/./src/api/files.js","webpack://@noodl/cloud-runtime/./src/api/users.js","webpack://@noodl/cloud-runtime/./src/nodes/data/aggregatenode.js","webpack://@noodl/cloud-runtime/./src/noodl-js-api.js","webpack://@noodl/cloud-runtime/./src/services/userservice.js","webpack://@noodl/cloud-runtime/webpack/bootstrap","webpack://@noodl/cloud-runtime/webpack/runtime/compat get default export","webpack://@noodl/cloud-runtime/webpack/runtime/define property getters","webpack://@noodl/cloud-runtime/webpack/runtime/global","webpack://@noodl/cloud-runtime/webpack/runtime/hasOwnProperty shorthand","webpack://@noodl/cloud-runtime/./src/sandbox.viewer.js"],"sourcesContent":["/**\n * lodash (Custom Build) \n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright jQuery Foundation and other contributors \n * Released under MIT license \n * Based on Underscore.js 1.8.3 \n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as the size to enable large array optimizations. */\nvar LARGE_ARRAY_SIZE = 200;\n\n/** Used to stand-in for `undefined` hash values. */\nvar HASH_UNDEFINED = '__lodash_hash_undefined__';\n\n/** Used as references for various `Number` constants. */\nvar MAX_SAFE_INTEGER = 9007199254740991;\n\n/** `Object#toString` result references. */\nvar argsTag = '[object Arguments]',\n funcTag = '[object Function]',\n genTag = '[object GeneratorFunction]';\n\n/**\n * Used to match `RegExp`\n * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).\n */\nvar reRegExpChar = /[\\\\^$.*+?()[\\]{}|]/g;\n\n/** Used to detect host constructors (Safari). */\nvar reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\n/**\n * A faster alternative to `Function#apply`, this function invokes `func`\n * with the `this` binding of `thisArg` and the arguments of `args`.\n *\n * @private\n * @param {Function} func The function to invoke.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {Array} args The arguments to invoke `func` with.\n * @returns {*} Returns the result of `func`.\n */\nfunction apply(func, thisArg, args) {\n switch (args.length) {\n case 0: return func.call(thisArg);\n case 1: return func.call(thisArg, args[0]);\n case 2: return func.call(thisArg, args[0], args[1]);\n case 3: return func.call(thisArg, args[0], args[1], args[2]);\n }\n return func.apply(thisArg, args);\n}\n\n/**\n * A specialized version of `_.includes` for arrays without support for\n * specifying an index to search from.\n *\n * @private\n * @param {Array} [array] The array to inspect.\n * @param {*} target The value to search for.\n * @returns {boolean} Returns `true` if `target` is found, else `false`.\n */\nfunction arrayIncludes(array, value) {\n var length = array ? array.length : 0;\n return !!length && baseIndexOf(array, value, 0) > -1;\n}\n\n/**\n * This function is like `arrayIncludes` except that it accepts a comparator.\n *\n * @private\n * @param {Array} [array] The array to inspect.\n * @param {*} target The value to search for.\n * @param {Function} comparator The comparator invoked per element.\n * @returns {boolean} Returns `true` if `target` is found, else `false`.\n */\nfunction arrayIncludesWith(array, value, comparator) {\n var index = -1,\n length = array ? array.length : 0;\n\n while (++index < length) {\n if (comparator(value, array[index])) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * A specialized version of `_.map` for arrays without support for iteratee\n * shorthands.\n *\n * @private\n * @param {Array} [array] The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n */\nfunction arrayMap(array, iteratee) {\n var index = -1,\n length = array ? array.length : 0,\n result = Array(length);\n\n while (++index < length) {\n result[index] = iteratee(array[index], index, array);\n }\n return result;\n}\n\n/**\n * Appends the elements of `values` to `array`.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {Array} values The values to append.\n * @returns {Array} Returns `array`.\n */\nfunction arrayPush(array, values) {\n var index = -1,\n length = values.length,\n offset = array.length;\n\n while (++index < length) {\n array[offset + index] = values[index];\n }\n return array;\n}\n\n/**\n * The base implementation of `_.findIndex` and `_.findLastIndex` without\n * support for iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Function} predicate The function invoked per iteration.\n * @param {number} fromIndex The index to search from.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction baseFindIndex(array, predicate, fromIndex, fromRight) {\n var length = array.length,\n index = fromIndex + (fromRight ? 1 : -1);\n\n while ((fromRight ? index-- : ++index < length)) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n return -1;\n}\n\n/**\n * The base implementation of `_.indexOf` without `fromIndex` bounds checks.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} value The value to search for.\n * @param {number} fromIndex The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction baseIndexOf(array, value, fromIndex) {\n if (value !== value) {\n return baseFindIndex(array, baseIsNaN, fromIndex);\n }\n var index = fromIndex - 1,\n length = array.length;\n\n while (++index < length) {\n if (array[index] === value) {\n return index;\n }\n }\n return -1;\n}\n\n/**\n * The base implementation of `_.isNaN` without support for number objects.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.\n */\nfunction baseIsNaN(value) {\n return value !== value;\n}\n\n/**\n * The base implementation of `_.unary` without support for storing metadata.\n *\n * @private\n * @param {Function} func The function to cap arguments for.\n * @returns {Function} Returns the new capped function.\n */\nfunction baseUnary(func) {\n return function(value) {\n return func(value);\n };\n}\n\n/**\n * Checks if a cache value for `key` exists.\n *\n * @private\n * @param {Object} cache The cache to query.\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction cacheHas(cache, key) {\n return cache.has(key);\n}\n\n/**\n * Gets the value at `key` of `object`.\n *\n * @private\n * @param {Object} [object] The object to query.\n * @param {string} key The key of the property to get.\n * @returns {*} Returns the property value.\n */\nfunction getValue(object, key) {\n return object == null ? undefined : object[key];\n}\n\n/**\n * Checks if `value` is a host object in IE < 9.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a host object, else `false`.\n */\nfunction isHostObject(value) {\n // Many host objects are `Object` objects that can coerce to strings\n // despite having improperly defined `toString` methods.\n var result = false;\n if (value != null && typeof value.toString != 'function') {\n try {\n result = !!(value + '');\n } catch (e) {}\n }\n return result;\n}\n\n/** Used for built-in method references. */\nvar arrayProto = Array.prototype,\n funcProto = Function.prototype,\n objectProto = Object.prototype;\n\n/** Used to detect overreaching core-js shims. */\nvar coreJsData = root['__core-js_shared__'];\n\n/** Used to detect methods masquerading as native. */\nvar maskSrcKey = (function() {\n var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');\n return uid ? ('Symbol(src)_1.' + uid) : '';\n}());\n\n/** Used to resolve the decompiled source of functions. */\nvar funcToString = funcProto.toString;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar objectToString = objectProto.toString;\n\n/** Used to detect if a method is native. */\nvar reIsNative = RegExp('^' +\n funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n);\n\n/** Built-in value references. */\nvar Symbol = root.Symbol,\n propertyIsEnumerable = objectProto.propertyIsEnumerable,\n splice = arrayProto.splice,\n spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max;\n\n/* Built-in method references that are verified to be native. */\nvar Map = getNative(root, 'Map'),\n nativeCreate = getNative(Object, 'create');\n\n/**\n * Creates a hash object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction Hash(entries) {\n var index = -1,\n length = entries ? entries.length : 0;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the hash.\n *\n * @private\n * @name clear\n * @memberOf Hash\n */\nfunction hashClear() {\n this.__data__ = nativeCreate ? nativeCreate(null) : {};\n}\n\n/**\n * Removes `key` and its value from the hash.\n *\n * @private\n * @name delete\n * @memberOf Hash\n * @param {Object} hash The hash to modify.\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction hashDelete(key) {\n return this.has(key) && delete this.__data__[key];\n}\n\n/**\n * Gets the hash value for `key`.\n *\n * @private\n * @name get\n * @memberOf Hash\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction hashGet(key) {\n var data = this.__data__;\n if (nativeCreate) {\n var result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n return hasOwnProperty.call(data, key) ? data[key] : undefined;\n}\n\n/**\n * Checks if a hash value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf Hash\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction hashHas(key) {\n var data = this.__data__;\n return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);\n}\n\n/**\n * Sets the hash `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf Hash\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the hash instance.\n */\nfunction hashSet(key, value) {\n var data = this.__data__;\n data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;\n return this;\n}\n\n// Add methods to `Hash`.\nHash.prototype.clear = hashClear;\nHash.prototype['delete'] = hashDelete;\nHash.prototype.get = hashGet;\nHash.prototype.has = hashHas;\nHash.prototype.set = hashSet;\n\n/**\n * Creates an list cache object.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction ListCache(entries) {\n var index = -1,\n length = entries ? entries.length : 0;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the list cache.\n *\n * @private\n * @name clear\n * @memberOf ListCache\n */\nfunction listCacheClear() {\n this.__data__ = [];\n}\n\n/**\n * Removes `key` and its value from the list cache.\n *\n * @private\n * @name delete\n * @memberOf ListCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction listCacheDelete(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n var lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n splice.call(data, index, 1);\n }\n return true;\n}\n\n/**\n * Gets the list cache value for `key`.\n *\n * @private\n * @name get\n * @memberOf ListCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction listCacheGet(key) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n return index < 0 ? undefined : data[index][1];\n}\n\n/**\n * Checks if a list cache value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf ListCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction listCacheHas(key) {\n return assocIndexOf(this.__data__, key) > -1;\n}\n\n/**\n * Sets the list cache `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf ListCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the list cache instance.\n */\nfunction listCacheSet(key, value) {\n var data = this.__data__,\n index = assocIndexOf(data, key);\n\n if (index < 0) {\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n}\n\n// Add methods to `ListCache`.\nListCache.prototype.clear = listCacheClear;\nListCache.prototype['delete'] = listCacheDelete;\nListCache.prototype.get = listCacheGet;\nListCache.prototype.has = listCacheHas;\nListCache.prototype.set = listCacheSet;\n\n/**\n * Creates a map cache object to store key-value pairs.\n *\n * @private\n * @constructor\n * @param {Array} [entries] The key-value pairs to cache.\n */\nfunction MapCache(entries) {\n var index = -1,\n length = entries ? entries.length : 0;\n\n this.clear();\n while (++index < length) {\n var entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n}\n\n/**\n * Removes all key-value entries from the map.\n *\n * @private\n * @name clear\n * @memberOf MapCache\n */\nfunction mapCacheClear() {\n this.__data__ = {\n 'hash': new Hash,\n 'map': new (Map || ListCache),\n 'string': new Hash\n };\n}\n\n/**\n * Removes `key` and its value from the map.\n *\n * @private\n * @name delete\n * @memberOf MapCache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed, else `false`.\n */\nfunction mapCacheDelete(key) {\n return getMapData(this, key)['delete'](key);\n}\n\n/**\n * Gets the map value for `key`.\n *\n * @private\n * @name get\n * @memberOf MapCache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the entry value.\n */\nfunction mapCacheGet(key) {\n return getMapData(this, key).get(key);\n}\n\n/**\n * Checks if a map value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf MapCache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\nfunction mapCacheHas(key) {\n return getMapData(this, key).has(key);\n}\n\n/**\n * Sets the map `key` to `value`.\n *\n * @private\n * @name set\n * @memberOf MapCache\n * @param {string} key The key of the value to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns the map cache instance.\n */\nfunction mapCacheSet(key, value) {\n getMapData(this, key).set(key, value);\n return this;\n}\n\n// Add methods to `MapCache`.\nMapCache.prototype.clear = mapCacheClear;\nMapCache.prototype['delete'] = mapCacheDelete;\nMapCache.prototype.get = mapCacheGet;\nMapCache.prototype.has = mapCacheHas;\nMapCache.prototype.set = mapCacheSet;\n\n/**\n *\n * Creates an array cache object to store unique values.\n *\n * @private\n * @constructor\n * @param {Array} [values] The values to cache.\n */\nfunction SetCache(values) {\n var index = -1,\n length = values ? values.length : 0;\n\n this.__data__ = new MapCache;\n while (++index < length) {\n this.add(values[index]);\n }\n}\n\n/**\n * Adds `value` to the array cache.\n *\n * @private\n * @name add\n * @memberOf SetCache\n * @alias push\n * @param {*} value The value to cache.\n * @returns {Object} Returns the cache instance.\n */\nfunction setCacheAdd(value) {\n this.__data__.set(value, HASH_UNDEFINED);\n return this;\n}\n\n/**\n * Checks if `value` is in the array cache.\n *\n * @private\n * @name has\n * @memberOf SetCache\n * @param {*} value The value to search for.\n * @returns {number} Returns `true` if `value` is found, else `false`.\n */\nfunction setCacheHas(value) {\n return this.__data__.has(value);\n}\n\n// Add methods to `SetCache`.\nSetCache.prototype.add = SetCache.prototype.push = setCacheAdd;\nSetCache.prototype.has = setCacheHas;\n\n/**\n * Gets the index at which the `key` is found in `array` of key-value pairs.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {*} key The key to search for.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\nfunction assocIndexOf(array, key) {\n var length = array.length;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n}\n\n/**\n * The base implementation of methods like `_.difference` without support\n * for excluding multiple arrays or iteratee shorthands.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Array} values The values to exclude.\n * @param {Function} [iteratee] The iteratee invoked per element.\n * @param {Function} [comparator] The comparator invoked per element.\n * @returns {Array} Returns the new array of filtered values.\n */\nfunction baseDifference(array, values, iteratee, comparator) {\n var index = -1,\n includes = arrayIncludes,\n isCommon = true,\n length = array.length,\n result = [],\n valuesLength = values.length;\n\n if (!length) {\n return result;\n }\n if (iteratee) {\n values = arrayMap(values, baseUnary(iteratee));\n }\n if (comparator) {\n includes = arrayIncludesWith;\n isCommon = false;\n }\n else if (values.length >= LARGE_ARRAY_SIZE) {\n includes = cacheHas;\n isCommon = false;\n values = new SetCache(values);\n }\n outer:\n while (++index < length) {\n var value = array[index],\n computed = iteratee ? iteratee(value) : value;\n\n value = (comparator || value !== 0) ? value : 0;\n if (isCommon && computed === computed) {\n var valuesIndex = valuesLength;\n while (valuesIndex--) {\n if (values[valuesIndex] === computed) {\n continue outer;\n }\n }\n result.push(value);\n }\n else if (!includes(values, computed, comparator)) {\n result.push(value);\n }\n }\n return result;\n}\n\n/**\n * The base implementation of `_.flatten` with support for restricting flattening.\n *\n * @private\n * @param {Array} array The array to flatten.\n * @param {number} depth The maximum recursion depth.\n * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.\n * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.\n * @param {Array} [result=[]] The initial result value.\n * @returns {Array} Returns the new flattened array.\n */\nfunction baseFlatten(array, depth, predicate, isStrict, result) {\n var index = -1,\n length = array.length;\n\n predicate || (predicate = isFlattenable);\n result || (result = []);\n\n while (++index < length) {\n var value = array[index];\n if (depth > 0 && predicate(value)) {\n if (depth > 1) {\n // Recursively flatten arrays (susceptible to call stack limits).\n baseFlatten(value, depth - 1, predicate, isStrict, result);\n } else {\n arrayPush(result, value);\n }\n } else if (!isStrict) {\n result[result.length] = value;\n }\n }\n return result;\n}\n\n/**\n * The base implementation of `_.isNative` without bad shim checks.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function,\n * else `false`.\n */\nfunction baseIsNative(value) {\n if (!isObject(value) || isMasked(value)) {\n return false;\n }\n var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;\n return pattern.test(toSource(value));\n}\n\n/**\n * The base implementation of `_.rest` which doesn't validate or coerce arguments.\n *\n * @private\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @returns {Function} Returns the new function.\n */\nfunction baseRest(func, start) {\n start = nativeMax(start === undefined ? (func.length - 1) : start, 0);\n return function() {\n var args = arguments,\n index = -1,\n length = nativeMax(args.length - start, 0),\n array = Array(length);\n\n while (++index < length) {\n array[index] = args[start + index];\n }\n index = -1;\n var otherArgs = Array(start + 1);\n while (++index < start) {\n otherArgs[index] = args[index];\n }\n otherArgs[start] = array;\n return apply(func, this, otherArgs);\n };\n}\n\n/**\n * Gets the data for `map`.\n *\n * @private\n * @param {Object} map The map to query.\n * @param {string} key The reference key.\n * @returns {*} Returns the map data.\n */\nfunction getMapData(map, key) {\n var data = map.__data__;\n return isKeyable(key)\n ? data[typeof key == 'string' ? 'string' : 'hash']\n : data.map;\n}\n\n/**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\nfunction getNative(object, key) {\n var value = getValue(object, key);\n return baseIsNative(value) ? value : undefined;\n}\n\n/**\n * Checks if `value` is a flattenable `arguments` object or array.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.\n */\nfunction isFlattenable(value) {\n return isArray(value) || isArguments(value) ||\n !!(spreadableSymbol && value && value[spreadableSymbol]);\n}\n\n/**\n * Checks if `value` is suitable for use as unique object key.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is suitable, else `false`.\n */\nfunction isKeyable(value) {\n var type = typeof value;\n return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n}\n\n/**\n * Checks if `func` has its source masked.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` is masked, else `false`.\n */\nfunction isMasked(func) {\n return !!maskSrcKey && (maskSrcKey in func);\n}\n\n/**\n * Converts `func` to its source code.\n *\n * @private\n * @param {Function} func The function to process.\n * @returns {string} Returns the source code.\n */\nfunction toSource(func) {\n if (func != null) {\n try {\n return funcToString.call(func);\n } catch (e) {}\n try {\n return (func + '');\n } catch (e) {}\n }\n return '';\n}\n\n/**\n * Creates an array of `array` values not included in the other given arrays\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * for equality comparisons. The order of result values is determined by the\n * order they occur in the first array.\n *\n * **Note:** Unlike `_.pullAll`, this method returns a new array.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {...Array} [values] The values to exclude.\n * @returns {Array} Returns the new array of filtered values.\n * @see _.without, _.xor\n * @example\n *\n * _.difference([2, 1], [2, 3]);\n * // => [1]\n */\nvar difference = baseRest(function(array, values) {\n return isArrayLikeObject(array)\n ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))\n : [];\n});\n\n/**\n * Performs a\n * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)\n * comparison between two values to determine if they are equivalent.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'a': 1 };\n * var other = { 'a': 1 };\n *\n * _.eq(object, object);\n * // => true\n *\n * _.eq(object, other);\n * // => false\n *\n * _.eq('a', 'a');\n * // => true\n *\n * _.eq('a', Object('a'));\n * // => false\n *\n * _.eq(NaN, NaN);\n * // => true\n */\nfunction eq(value, other) {\n return value === other || (value !== value && other !== other);\n}\n\n/**\n * Checks if `value` is likely an `arguments` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an `arguments` object,\n * else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\nfunction isArguments(value) {\n // Safari 8.1 makes `arguments.callee` enumerable in strict mode.\n return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&\n (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);\n}\n\n/**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(document.body.children);\n * // => false\n *\n * _.isArray('abc');\n * // => false\n *\n * _.isArray(_.noop);\n * // => false\n */\nvar isArray = Array.isArray;\n\n/**\n * Checks if `value` is array-like. A value is considered array-like if it's\n * not a function and has a `value.length` that's an integer greater than or\n * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n * @example\n *\n * _.isArrayLike([1, 2, 3]);\n * // => true\n *\n * _.isArrayLike(document.body.children);\n * // => true\n *\n * _.isArrayLike('abc');\n * // => true\n *\n * _.isArrayLike(_.noop);\n * // => false\n */\nfunction isArrayLike(value) {\n return value != null && isLength(value.length) && !isFunction(value);\n}\n\n/**\n * This method is like `_.isArrayLike` except that it also checks if `value`\n * is an object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an array-like object,\n * else `false`.\n * @example\n *\n * _.isArrayLikeObject([1, 2, 3]);\n * // => true\n *\n * _.isArrayLikeObject(document.body.children);\n * // => true\n *\n * _.isArrayLikeObject('abc');\n * // => false\n *\n * _.isArrayLikeObject(_.noop);\n * // => false\n */\nfunction isArrayLikeObject(value) {\n return isObjectLike(value) && isArrayLike(value);\n}\n\n/**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a function, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\nfunction isFunction(value) {\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in Safari 8-9 which returns 'object' for typed array and other constructors.\n var tag = isObject(value) ? objectToString.call(value) : '';\n return tag == funcTag || tag == genTag;\n}\n\n/**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This method is loosely based on\n * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n * @example\n *\n * _.isLength(3);\n * // => true\n *\n * _.isLength(Number.MIN_VALUE);\n * // => false\n *\n * _.isLength(Infinity);\n * // => false\n *\n * _.isLength('3');\n * // => false\n */\nfunction isLength(value) {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return !!value && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return !!value && typeof value == 'object';\n}\n\nmodule.exports = difference;\n","// We need to import this so it's available in NoodlRuntime.Services\r\n\r\n//import WebSocket from 'ws';\r\nimport { NoodlRequest, NoodlResponse } from './bridge';\r\nimport { registerNodes } from './nodes';\r\nimport NoodlRuntime from '@noodl/runtime';\r\nimport Model from '@noodl/runtime/src/model';\r\nimport NodeScope from '@noodl/runtime/src/nodescope';\r\nimport './noodl-js-api';\r\n\r\nrequire('./services/userservice');\r\n\r\nexport class CloudRunner {\r\n private runtime: NoodlRuntime;\r\n\r\n constructor(options: {\r\n webSocketClass?: any;\r\n enableDebugInspectors?: boolean;\r\n connectToEditor?: boolean;\r\n editorAddress?: string;\r\n }) {\r\n this.runtime = new NoodlRuntime({\r\n type: 'cloud',\r\n platform: {\r\n requestUpdate: (f: any) => setImmediate(f),\r\n getCurrentTime: () => new Date().getTime(),\r\n objectToString: (o: any) => JSON.stringify(o, null, 2),\r\n webSocketClass: options.webSocketClass,\r\n isRunningLocally: () => options.connectToEditor\r\n },\r\n componentFilter: (c) => c.name.startsWith('/#__cloud__/'),\r\n dontCreateRootComponent: true\r\n });\r\n\r\n registerNodes(this.runtime);\r\n\r\n this.runtime.setDebugInspectorsEnabled(options.enableDebugInspectors);\r\n\r\n if (options.connectToEditor && options.editorAddress) {\r\n this.runtime.connectToEditor(options.editorAddress);\r\n }\r\n }\r\n\r\n public async load(exportData: any, projectSettings?: any) {\r\n await this.runtime.setData(exportData);\r\n\r\n if (projectSettings) this.runtime.setProjectSettings(projectSettings);\r\n }\r\n\r\n public async run(functionName: string, request: NoodlRequest): Promise {\r\n return new Promise((resolve, reject) => {\r\n const requestId = Math.random().toString(26).slice(2);\r\n\r\n const requestScope = new NodeScope(this.runtime.context);\r\n requestScope.modelScope = new Model.Scope();\r\n\r\n this.runtime.context\r\n .createComponentInstanceNode('/#__cloud__/' + functionName, requestId + '-' + functionName, requestScope)\r\n .then((functionComponent) => {\r\n // Look for the first request node (should only be one)\r\n const requestNode = functionComponent.nodeScope.getNodesWithType('noodl.cloud.request')[0];\r\n if (requestNode) {\r\n // Look for all response nodes\r\n let hasResponded = false;\r\n const responseNodes = functionComponent.nodeScope.getNodesWithTypeRecursive('noodl.cloud.response');\r\n responseNodes.forEach((resp) => {\r\n resp._internal._sendResponseCallback = (resp) => {\r\n if (hasResponded) return;\r\n hasResponded = true;\r\n\r\n //the functionComponent is \"manually\" created outside of a scope, so call the delete function directly\r\n functionComponent._onNodeDeleted();\r\n requestScope.reset(); //this deletes any remaining nodes, although there shouldn't be any at this point\r\n\r\n //clean upp all models\r\n requestScope.modelScope.reset();\r\n\r\n resolve(resp);\r\n };\r\n });\r\n\r\n setImmediate(() => {\r\n try {\r\n requestNode.sendRequest(request).catch(reject);\r\n } catch (e) {\r\n reject(e);\r\n }\r\n });\r\n } else {\r\n reject(Error('Could not find request node for function'));\r\n }\r\n })\r\n .catch((e) => {\r\n // Failed creating component\r\n reject(e);\r\n });\r\n });\r\n }\r\n}\r\n","//import CloudStore from '@noodl/runtime/src/api/cloudstore'\r\nimport Model from '@noodl/runtime/src/model';\r\nimport NoodlRuntime from '@noodl/runtime';\r\nimport ConfigService from '@noodl/runtime/src/api/configservice'\r\n\r\nexport const node = {\r\n name: 'noodl.cloud.request',\r\n displayNodeName: 'Request',\r\n category: 'Cloud',\r\n docs: 'https://docs.noodl.net/nodes/cloud-functions/request',\r\n useVariants: false,\r\n mountedInput: false,\r\n allowAsExportRoot: false,\r\n singleton: true,\r\n color: 'data',\r\n connectionPanel: {\r\n groupPriority: ['General', 'Mounted']\r\n },\r\n outputs: {\r\n receive: {\r\n displayName: 'Received',\r\n type: 'signal',\r\n group: 'General'\r\n },\r\n auth: {\r\n displayName: 'Authenticated',\r\n type: 'boolean',\r\n group: 'Request',\r\n getter: function () {\r\n return !!this._internal.authenticated;\r\n }\r\n },\r\n userId: {\r\n displayName: 'User Id',\r\n type: 'boolean',\r\n group: 'Request',\r\n getter: function () {\r\n return this._internal.authUserId;\r\n }\r\n }\r\n },\r\n inputs: {\r\n allowNoAuth: {\r\n group: 'General',\r\n type: 'boolean',\r\n displayName: 'Allow Unauthenticated',\r\n default: false,\r\n set: function (value) {\r\n this._internal.allowNoAuth = value;\r\n }\r\n },\r\n params: {\r\n group: 'Parameters',\r\n type: { name: 'stringlist', allowEditOnly: true },\r\n set: function (value) {\r\n this._internal.params = value;\r\n }\r\n }\r\n },\r\n initialize: function () {\r\n this._internal.allowNoAuth = false;\r\n this._internal.requestParameters = {};\r\n this._internal.userProperties = {\r\n Authenticated: false\r\n };\r\n },\r\n methods: {\r\n getRequestParameter: function (name) {\r\n return this._internal.requestParameters[name];\r\n },\r\n setRequestParameter: function (name, value) {\r\n this._internal.requestParameters[name] = value;\r\n if (this.hasOutput('pm-' + name)) this.flagOutputDirty('pm-' + name);\r\n },\r\n fetchCurrentUser: async function (sessionToken) {\r\n return new Promise((resolve, reject) => {\r\n const userService = NoodlRuntime.Services.UserService.forScope(this.nodeScope.modelScope);\r\n userService.fetchCurrentUser({\r\n sessionToken,\r\n success: resolve,\r\n error: reject\r\n });\r\n });\r\n },\r\n sendRequest: async function (req) {\r\n const sessionToken = req.headers['x-parse-session-token'];\r\n let params = {};\r\n try {\r\n params = JSON.parse(req.body);\r\n } catch (e) {}\r\n\r\n if (sessionToken) {\r\n // There is a user token, fetch user\r\n try {\r\n await this.fetchCurrentUser(sessionToken);\r\n\r\n const userService = NoodlRuntime.Services.UserService.forScope(this.nodeScope.modelScope);\r\n const userModel = userService.current;\r\n\r\n this._internal.authenticated = true;\r\n this._internal.authUserId = userModel.getId();\r\n this.flagOutputDirty('userId');\r\n } catch (e) {\r\n // User could not be fetched\r\n if (!this._internal.allowNoAuth) throw Error('Unauthenticated requests not accepted.');\r\n }\r\n } else if (!this._internal.allowNoAuth) throw Error('Unauthenticated requests not accepted.');\r\n\r\n // Make sure config is cached before processing request\r\n await ConfigService.instance.getConfig()\r\n\r\n // Create request object\r\n const requestModel = (this.nodeScope.modelScope || Model).get('Request');\r\n requestModel.set('Authenticated', !!this._internal.authenticated);\r\n requestModel.set('UserId', this._internal.authUserId);\r\n requestModel.set('Parameters', params);\r\n requestModel.set('Headers', req.headers);\r\n\r\n this.flagOutputDirty('auth');\r\n\r\n for (let key in params) {\r\n this.setRequestParameter(key, params[key]);\r\n }\r\n this.sendSignalOnOutput('receive');\r\n },\r\n registerOutputIfNeeded: function (name) {\r\n if (this.hasOutput(name)) {\r\n return;\r\n }\r\n\r\n if (name.startsWith('pm-'))\r\n this.registerOutput(name, {\r\n getter: this.getRequestParameter.bind(this, name.substring('pm-'.length))\r\n });\r\n }\r\n }\r\n};\r\n\r\nexport function setup(context, graphModel) {\r\n if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {\r\n return;\r\n }\r\n\r\n function _managePortsForNode(node) {\r\n function _updatePorts() {\r\n var ports = [];\r\n\r\n // Add params outputs\r\n var params = node.parameters.params;\r\n if (params !== undefined) {\r\n params = params.split(',');\r\n for (var i in params) {\r\n var p = params[i];\r\n\r\n ports.push({\r\n type: '*',\r\n plug: 'output',\r\n group: 'Parameters',\r\n name: 'pm-' + p,\r\n displayName: p\r\n });\r\n }\r\n }\r\n\r\n context.editorConnection.sendDynamicPorts(node.id, ports);\r\n }\r\n\r\n _updatePorts();\r\n node.on('parameterUpdated', function (event) {\r\n if (event.name === 'params') {\r\n _updatePorts();\r\n }\r\n });\r\n }\r\n\r\n graphModel.on('editorImportComplete', () => {\r\n graphModel.on('nodeAdded.noodl.cloud.request', function (node) {\r\n _managePortsForNode(node);\r\n });\r\n\r\n for (const node of graphModel.getNodesWithType('noodl.cloud.request')) {\r\n _managePortsForNode(node);\r\n }\r\n });\r\n}\r\n","export const node = {\r\n name: 'noodl.cloud.response',\r\n displayNodeName: 'Response',\r\n category: 'Cloud',\r\n docs: 'https://docs.noodl.net/nodes/cloud-functions/response',\r\n useVariants: false,\r\n mountedInput: false,\r\n allowAsExportRoot: false,\r\n color: \"data\",\r\n connectionPanel: {\r\n groupPriority: ['General', 'Mounted']\r\n },\r\n dynamicports:[\r\n {\r\n name:'conditionalports/extended',\r\n condition:\"status = success OR status NOT SET\",\r\n inputs:['params']\r\n },\r\n {\r\n name:'conditionalports/extended',\r\n condition:\"status = failure\",\r\n inputs:['errorMessage']\r\n }\r\n ],\r\n initialize:function() {\r\n this._internal.responseParameters = {}\r\n },\r\n inputs: {\r\n params: {\r\n group: 'Parameters',\r\n type:{name:'stringlist',allowEditOnly:true},\r\n set: function (value) {\r\n this._internal.params = value;\r\n }\r\n },\r\n errorMessage: {\r\n group: 'General',\r\n type: 'string',\r\n displayName:'Error Message',\r\n set: function (value) {\r\n this._internal.errorMessage = value;\r\n }\r\n },\r\n send: {\r\n displayName: 'Send',\r\n type: 'signal',\r\n group: 'General',\r\n valueChangedToTrue: function () {\r\n if(this._internal.status === undefined || this._internal.status === 'success') {\r\n this._internal._sendResponseCallback({\r\n statusCode: 200,\r\n body: JSON.stringify({result:this._internal.responseParameters})\r\n })\r\n }\r\n else {\r\n this._internal._sendResponseCallback({\r\n statusCode: 400,\r\n body: JSON.stringify({error:this._internal.errorMessage})\r\n })\r\n }\r\n }\r\n },\r\n status: {\r\n group: 'General',\r\n displayName:'Status',\r\n type: {\r\n name: 'enum',\r\n enums: [\r\n {\r\n label: 'Success',\r\n value: 'success'\r\n },\r\n {\r\n label: 'Failure',\r\n value: 'failure'\r\n }\r\n ]\r\n },\r\n default:'success',\r\n set: function(value) {\r\n this._internal.status = value;\r\n }\r\n }\r\n },\r\n methods:{\r\n setResponseParameter:function(name,value) {\r\n this._internal.responseParameters[name] = value\r\n },\r\n registerInputIfNeeded: function(name) {\r\n if(this.hasInput(name)) {\r\n return;\r\n }\r\n\r\n if(name.startsWith('pm-')) this.registerInput(name, {\r\n set: this.setResponseParameter.bind(this, name.substring('pm-'.length))\r\n })\r\n },\r\n }\r\n};\r\n\r\nexport function setup(context, graphModel) {\r\n if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {\r\n return;\r\n }\r\n\r\n function _managePortsForNode(node) {\r\n function _updatePorts() {\r\n var ports = []\r\n\r\n // Add params outputs\r\n if(node.parameters.status === 'success' || node.parameters.status === undefined) {\r\n var params = node.parameters.params;\r\n if (params !== undefined) {\r\n params = params.split(',');\r\n for (var i in params) {\r\n var p = params[i];\r\n\r\n ports.push({\r\n type: '*',\r\n plug: 'input',\r\n group: 'Parameters',\r\n name: 'pm-' + p,\r\n displayName: p\r\n })\r\n }\r\n }\r\n }\r\n\r\n context.editorConnection.sendDynamicPorts(node.id, ports);\r\n }\r\n\r\n _updatePorts();\r\n node.on(\"parameterUpdated\", function (event) {\r\n if (event.name === 'params') {\r\n _updatePorts();\r\n }\r\n });\r\n }\r\n\r\n graphModel.on(\"editorImportComplete\", () => {\r\n graphModel.on(\"nodeAdded.noodl.cloud.response\", function (node) {\r\n _managePortsForNode(node)\r\n })\r\n\r\n for (const node of graphModel.getNodesWithType('noodl.cloud.response')) {\r\n _managePortsForNode(node)\r\n }\r\n })\r\n}\r\n","import NoodlRuntime from '@noodl/runtime';\r\n\r\nexport function registerNodes(runtime: NoodlRuntime) {\r\n [require('./cloud/request'), \r\n require('./cloud/response'),\r\n require('./data/aggregatenode')]\r\n .forEach(function (nodeDefinition) {\r\n runtime.registerNode(nodeDefinition);\r\n });\r\n}\r\n","'use strict';\r\n\r\nconst NodeContext = require('./src/nodecontext');\r\nconst EditorConnection = require('./src/editorconnection');\r\nconst generateNodeLibrary = require('./src/nodelibraryexport');\r\nconst ProjectSettings = require('./src/projectsettings');\r\nconst GraphModel = require('./src/models/graphmodel');\r\nconst NodeDefinition = require('./src/nodedefinition');\r\nconst Node = require('./src/node');\r\nconst EditorModelEventsHandler = require('./src/editormodeleventshandler');\r\nconst Services = require('./src/services/services');\r\nconst EdgeTriggeredInput = require('./src/edgetriggeredinput');\r\n\r\nconst EventEmitter = require('./src/events');\r\nconst asyncPool = require('./src/async-pool');\r\n\r\nfunction registerNodes(noodlRuntime) {\r\n [\r\n require('./src/nodes/componentinputs'),\r\n require('./src/nodes/componentoutputs'),\r\n\r\n require('./src/nodes/std-library/runtasks'),\r\n\r\n // Data\r\n require('./src/nodes/std-library/data/restnode'),\r\n\r\n // Custom code\r\n require('./src/nodes/std-library/expression'),\r\n require('./src/nodes/std-library/simplejavascript'),\r\n\r\n // Records\r\n require('./src/nodes/std-library/data/dbcollectionnode2'),\r\n require('./src/nodes/std-library/data/dbmodelnode2'),\r\n require('./src/nodes/std-library/data/setdbmodelpropertiesnode'),\r\n require('./src/nodes/std-library/data/deletedbmodelpropertiesnode'),\r\n require('./src/nodes/std-library/data/newdbmodelpropertiesnode'),\r\n require('./src/nodes/std-library/data/dbmodelnode-addrelation'),\r\n require('./src/nodes/std-library/data/dbmodelnode-removerelation'),\r\n require('./src/nodes/std-library/data/filterdbmodelsnode'),\r\n\r\n // Object\r\n require('./src/nodes/std-library/data/modelnode2'),\r\n require('./src/nodes/std-library/data/setmodelpropertiesnode'),\r\n require('./src/nodes/std-library/data/newmodelnode'),\r\n\r\n // Cloud\r\n require('./src/nodes/std-library/data/cloudfilenode'),\r\n require('./src/nodes/std-library/data/dbconfig'),\r\n\r\n // Variables\r\n require('./src/nodes/std-library/variables/number'),\r\n require('./src/nodes/std-library/variables/string'),\r\n require('./src/nodes/std-library/variables/boolean'),\r\n\r\n // Utils\r\n require('./src/nodes/std-library/condition'),\r\n require('./src/nodes/std-library/and'),\r\n require('./src/nodes/std-library/or'),\r\n require('./src/nodes/std-library/booleantostring'),\r\n require('./src/nodes/std-library/datetostring'),\r\n require('./src/nodes/std-library/stringmapper'),\r\n require('./src/nodes/std-library/inverter'),\r\n require('./src/nodes/std-library/substring'),\r\n require('./src/nodes/std-library/stringformat'),\r\n require('./src/nodes/std-library/counter'),\r\n require('./src/nodes/std-library/uniqueid'),\r\n\r\n // User\r\n require('./src/nodes/std-library/user/setuserproperties'),\r\n require('./src/nodes/std-library/user/user')\r\n ].forEach((node) => noodlRuntime.registerNode(node));\r\n}\r\n\r\nfunction NoodlRuntime(args) {\r\n args = args || {};\r\n args.platform = args.platform || {};\r\n NoodlRuntime.instance = this;\r\n\r\n this.type = args.type || 'browser';\r\n this.noodlModules = [];\r\n this.eventEmitter = new EventEmitter();\r\n this.updateScheduled = false;\r\n this.rootComponent = null;\r\n this._currentLoadedData = null;\r\n this.isWaitingForExport = true;\r\n this.graphModel = new GraphModel();\r\n this.errorHandlers = [];\r\n this.frameNumber = 0;\r\n this.dontCreateRootComponent = !!args.dontCreateRootComponent;\r\n this.componentFilter = args.componentFilter;\r\n\r\n this.runningInEditor = args.runDeployed ? false : true;\r\n\r\n this.platform = {\r\n requestUpdate: args.platform.requestUpdate,\r\n getCurrentTime: args.platform.getCurrentTime,\r\n webSocketOptions: args.platform.webSocketOptions,\r\n objectToString: args.platform.objectToString\r\n };\r\n\r\n if (!args.platform.requestUpdate) {\r\n throw new Error('platform.requestUpdate must be set');\r\n }\r\n\r\n if (!args.platform.getCurrentTime) {\r\n throw new Error('platform.getCurrentTime must be set');\r\n }\r\n\r\n //Create an editor connection even if we're running deployed.\r\n //If won't connect and act as a \"noop\" in deployed mode,\r\n // and reduce the need for lots of if(editorConnection)\r\n this.editorConnection = new EditorConnection({\r\n platform: args.platform,\r\n runtimeType: this.type\r\n });\r\n\r\n this.context = new NodeContext({\r\n runningInEditor: args.runDeployed ? false : true,\r\n editorConnection: this.editorConnection,\r\n platform: this.platform,\r\n graphModel: this.graphModel\r\n });\r\n\r\n this.context.eventEmitter.on('scheduleUpdate', this.scheduleUpdate.bind(this));\r\n\r\n if (!args.runDeployed) {\r\n this._setupEditorCommunication(args);\r\n }\r\n\r\n this.registerGraphModelListeners();\r\n\r\n registerNodes(this);\r\n}\r\n\r\nNoodlRuntime.prototype.prefetchBundles = async function (bundleNames, numParallelFetches) {\r\n await asyncPool(numParallelFetches, bundleNames, async (name) => {\r\n await this.context.fetchComponentBundle(name);\r\n });\r\n};\r\n\r\nNoodlRuntime.prototype._setupEditorCommunication = function (args) {\r\n function objectEquals(x, y) {\r\n if (x === null || x === undefined || y === null || y === undefined) {\r\n return x === y;\r\n }\r\n if (x === y) {\r\n return true;\r\n }\r\n if (Array.isArray(x) && x.length !== y.length) {\r\n return false;\r\n }\r\n\r\n // if they are strictly equal, they both need to be object at least\r\n if (!(x instanceof Object)) {\r\n return false;\r\n }\r\n if (!(y instanceof Object)) {\r\n return false;\r\n }\r\n\r\n // recursive object equality check\r\n var p = Object.keys(x);\r\n return (\r\n Object.keys(y).every(function (i) {\r\n return p.indexOf(i) !== -1;\r\n }) &&\r\n p.every(function (i) {\r\n return objectEquals(x[i], y[i]);\r\n })\r\n );\r\n }\r\n\r\n this.editorConnection.on('exportDataFull', async (exportData) => {\r\n if (this.graphModel.isEmpty() === false) {\r\n this.reload();\r\n return;\r\n }\r\n\r\n this.isWaitingForExport = false;\r\n if (objectEquals(this._currentLoadedData, exportData) === false) {\r\n if (this.componentFilter) {\r\n exportData.components = exportData.components.filter((c) => this.componentFilter(c));\r\n }\r\n\r\n await this.setData(exportData);\r\n\r\n //get the rest of the components\r\n //important to get all the dynamic ports evaluated\r\n if (exportData.componentIndex) {\r\n const allBundles = Object.keys(exportData.componentIndex);\r\n await this.prefetchBundles(allBundles, 2);\r\n }\r\n\r\n this.graphModel.emit('editorImportComplete');\r\n }\r\n });\r\n\r\n this.editorConnection.on('reload', this.reload.bind(this));\r\n this.editorConnection.on('modelUpdate', this.onModelUpdateReceived.bind(this));\r\n this.editorConnection.on('metadataUpdate', this.onMetaDataUpdateReceived.bind(this));\r\n\r\n this.editorConnection.on('connected', () => {\r\n this.sendNodeLibrary();\r\n });\r\n};\r\n\r\nNoodlRuntime.prototype.setDebugInspectorsEnabled = function (enabled) {\r\n this.context.setDebugInspectorsEnabled(enabled);\r\n};\r\n\r\nNoodlRuntime.prototype.registerModule = function (module) {\r\n if (module.nodes) {\r\n for (let nodeDefinition of module.nodes) {\r\n if (!nodeDefinition.node) nodeDefinition = { node: nodeDefinition };\r\n nodeDefinition.node.module = module.name || 'Unknown Module';\r\n this.registerNode(nodeDefinition);\r\n }\r\n }\r\n\r\n this.noodlModules.push(module);\r\n};\r\n\r\nNoodlRuntime.prototype.registerGraphModelListeners = function () {\r\n var self = this;\r\n\r\n this.graphModel.on(\r\n 'componentAdded',\r\n function (component) {\r\n self.context.registerComponentModel(component);\r\n },\r\n this\r\n );\r\n\r\n this.graphModel.on(\r\n 'componentRemoved',\r\n function (component) {\r\n self.context.deregisterComponentModel(component);\r\n },\r\n this\r\n );\r\n};\r\n\r\nNoodlRuntime.prototype.reload = function () {\r\n location.reload();\r\n};\r\n\r\nNoodlRuntime.prototype.registerNode = function (nodeDefinition) {\r\n if (nodeDefinition.node) {\r\n const definedNode = NodeDefinition.defineNode(nodeDefinition.node);\r\n this.context.nodeRegister.register(definedNode);\r\n\r\n definedNode.setupNumberedInputDynamicPorts &&\r\n definedNode.setupNumberedInputDynamicPorts(this.context, this.graphModel);\r\n } else {\r\n this.context.nodeRegister.register(nodeDefinition);\r\n }\r\n\r\n nodeDefinition.setup && nodeDefinition.setup(this.context, this.graphModel);\r\n};\r\n\r\nNoodlRuntime.prototype._setRootComponent = async function (rootComponentName) {\r\n if (this.rootComponent && this.rootComponent.name === rootComponentName) return;\r\n\r\n if (this.rootComponent) {\r\n this.rootComponent.model && this.rootComponent.model.removeListenersWithRef(this);\r\n this.rootComponent = undefined;\r\n }\r\n\r\n if (rootComponentName) {\r\n this.rootComponent = await this.context.createComponentInstanceNode(rootComponentName, 'rootComponent');\r\n\r\n this.rootComponent.componentModel.on('rootAdded', () => this.eventEmitter.emit('rootComponentUpdated'), this);\r\n this.rootComponent.componentModel.on('rootRemoved', () => this.eventEmitter.emit('rootComponentUpdated'), this);\r\n\r\n this.context.setRootComponent(this.rootComponent);\r\n }\r\n\r\n this.eventEmitter.emit('rootComponentUpdated');\r\n};\r\n\r\nNoodlRuntime.prototype.setData = async function (graphData) {\r\n // Added for SSR Support\r\n // In SSR, we re-load the graphData and when we render the componet it will\r\n // invoke this method again, which will cause a duplicate node exception.\r\n // To avoid this, we flag the runtime to not load again.\r\n if (this._disableLoad) return;\r\n\r\n this._currentLoadedData = graphData;\r\n await this.graphModel.importEditorData(graphData);\r\n\r\n // Run setup on all modules\r\n for (const module of this.noodlModules) {\r\n typeof module.setup === 'function' && module.setup.apply(module);\r\n }\r\n\r\n if (this.dontCreateRootComponent !== true) {\r\n await this._setRootComponent(this.graphModel.rootComponent);\r\n\r\n //listen to delta updates on the root component\r\n this.graphModel.on('rootComponentNameUpdated', (name) => {\r\n this._setRootComponent(name);\r\n });\r\n\r\n //check if the root component was deleted\r\n this.graphModel.on('componentRemoved', (componentModel) => {\r\n if (this.rootComponent && this.rootComponent.name === componentModel.name) {\r\n this._setRootComponent(null);\r\n }\r\n });\r\n\r\n //check if the root component was added when it previously didn't exist (e.g. when user deletes it and then hits undo)\r\n this.graphModel.on('componentAdded', (componentModel) => {\r\n setTimeout(() => {\r\n if (!this.rootComponent && this.graphModel.rootComponent === componentModel.name) {\r\n this._setRootComponent(componentModel.name);\r\n }\r\n }, 1);\r\n });\r\n }\r\n\r\n this.scheduleUpdate();\r\n};\r\n\r\nNoodlRuntime.prototype.scheduleUpdate = function () {\r\n if (this.updateScheduled) {\r\n return;\r\n }\r\n\r\n this.updateScheduled = true;\r\n this.platform.requestUpdate(NoodlRuntime.prototype._doUpdate.bind(this));\r\n};\r\n\r\nNoodlRuntime.prototype._doUpdate = function () {\r\n this.updateScheduled = false;\r\n\r\n this.context.currentFrameTime = this.platform.getCurrentTime();\r\n\r\n this.context.eventEmitter.emit('frameStart');\r\n\r\n this.context.update();\r\n\r\n this.context.eventEmitter.emit('frameEnd');\r\n\r\n this.frameNumber++;\r\n};\r\n\r\nNoodlRuntime.prototype.setProjectSettings = function (settings) {\r\n this.projectSettings = settings;\r\n};\r\n\r\nNoodlRuntime.prototype.getNodeLibrary = function () {\r\n var projectSettings = ProjectSettings.generateProjectSettings(this.graphModel.getSettings(), this.noodlModules);\r\n\r\n if (this.projectSettings) {\r\n this.projectSettings.ports && (projectSettings.ports = projectSettings.ports.concat(this.projectSettings.ports));\r\n this.projectSettings.dynamicports &&\r\n (projectSettings.dynamicports = projectSettings.ports.concat(this.projectSettings.dynamicports));\r\n }\r\n\r\n var nodeLibrary = generateNodeLibrary(this.context.nodeRegister);\r\n nodeLibrary.projectsettings = projectSettings;\r\n return JSON.stringify(nodeLibrary, null, 3);\r\n};\r\n\r\nNoodlRuntime.prototype.sendNodeLibrary = function () {\r\n const nodeLibrary = this.getNodeLibrary();\r\n if (this.lastSentNodeLibrary !== nodeLibrary) {\r\n this.lastSentNodeLibrary = nodeLibrary;\r\n this.editorConnection.sendNodeLibrary(nodeLibrary);\r\n }\r\n};\r\n\r\nNoodlRuntime.prototype.connectToEditor = function (address) {\r\n this.editorConnection.connect(address);\r\n};\r\n\r\nNoodlRuntime.prototype.onMetaDataUpdateReceived = function (event) {\r\n if (!this.graphModel.isEmpty()) {\r\n EditorMetaDataEventsHandler.handleEvent(this.context, this.graphModel, event);\r\n }\r\n};\r\n\r\nNoodlRuntime.prototype.onModelUpdateReceived = async function (event) {\r\n if (this.isWaitingForExport) {\r\n return;\r\n }\r\n\r\n if (event.type === 'projectInstanceChanged') {\r\n this.reload();\r\n }\r\n //wait for data to load before applying model changes\r\n else if (this.graphModel.isEmpty() === false) {\r\n await EditorModelEventsHandler.handleEvent(this.context, this.graphModel, event);\r\n }\r\n};\r\n\r\nNoodlRuntime.prototype.addErrorHandler = function (callback) {\r\n this.errorHandlers.push(callback);\r\n};\r\n\r\nNoodlRuntime.prototype.reportError = function (message) {\r\n this.errorHandlers.forEach(function (eh) {\r\n eh(message);\r\n });\r\n};\r\n\r\nNoodlRuntime.prototype.getProjectSettings = function () {\r\n return this.graphModel.getSettings();\r\n};\r\n\r\nNoodlRuntime.prototype.getMetaData = function (key) {\r\n return this.graphModel.getMetaData(key);\r\n};\r\n\r\nNoodlRuntime.Services = Services;\r\nNoodlRuntime.Node = Node;\r\nNoodlRuntime.NodeDefinition = NodeDefinition;\r\nNoodlRuntime.EdgeTriggeredInput = EdgeTriggeredInput;\r\n\r\nmodule.exports = NoodlRuntime;\r\n","class CloudFile {\r\n constructor({ name, url }) {\r\n this.name = name;\r\n this.url = url;\r\n }\r\n\r\n getUrl() {\r\n return this.url;\r\n }\r\n\r\n getName() {\r\n return this.name;\r\n }\r\n\r\n toString() {\r\n return this.url;\r\n }\r\n}\r\n\r\nmodule.exports = CloudFile;\r\n","const NoodlRuntime = require('../../noodl-runtime');\r\nconst Model = require('../model');\r\nconst Collection = require('../collection');\r\nconst CloudFile = require('./cloudfile');\r\nconst EventEmitter = require('../events');\r\n\r\nconst _protectedFields = {\r\n _common: ['_createdAt', '_updatedAt', 'objectId'],\r\n _User: ['_email_verify_token']\r\n};\r\n\r\nfunction _removeProtectedFields(data, className) {\r\n const _data = Object.assign({}, data);\r\n _protectedFields._common.forEach((f) => delete _data[f]);\r\n if (className && _protectedFields[className]) _protectedFields[className].forEach((f) => delete _data[f]);\r\n\r\n return _data;\r\n}\r\n\r\nclass CloudStore {\r\n constructor(modelScope) {\r\n this._initCloudServices();\r\n\r\n this.events = new EventEmitter();\r\n this.events.setMaxListeners(10000);\r\n this.modelScope = modelScope;\r\n\r\n this._fromJSON = (item, collectionName) => CloudStore._fromJSON(item, collectionName, modelScope);\r\n this._deserializeJSON = (data, type) => CloudStore._deserializeJSON(data, type, modelScope);\r\n this._serializeObject = (data, collectionName) => CloudStore._serializeObject(data, collectionName, modelScope);\r\n }\r\n\r\n _initCloudServices() {\r\n _collections = undefined; // clear collection cache, so it's refetched\r\n\r\n const cloudServices = NoodlRuntime.instance.getMetaData('cloudservices');\r\n if (cloudServices) {\r\n this.appId = cloudServices.appId;\r\n this.endpoint = cloudServices.endpoint;\r\n }\r\n\r\n const dbVersionMajor = NoodlRuntime.instance.getMetaData('dbVersionMajor');\r\n this.dbVersionMajor = dbVersionMajor;\r\n }\r\n\r\n on() {\r\n this.events.on.apply(this.events, arguments);\r\n }\r\n\r\n off() {\r\n this.events.off.apply(this.events, arguments);\r\n }\r\n\r\n _makeRequest(path, options) {\r\n if (typeof _noodl_cloud_runtime_version === 'undefined') {\r\n // Running in browser\r\n var xhr = new XMLHttpRequest();\r\n\r\n xhr.onreadystatechange = function () {\r\n if (xhr.readyState === 4) {\r\n var json;\r\n try {\r\n // In SSR, we dont have xhr.response\r\n json = JSON.parse(xhr.response || xhr.responseText);\r\n } catch (e) {}\r\n\r\n if (xhr.status === 200 || xhr.status === 201) {\r\n options.success(json);\r\n } else options.error(json || { error: xhr.responseText, status: xhr.status });\r\n }\r\n };\r\n\r\n xhr.open(options.method || 'GET', this.endpoint + path, true);\r\n\r\n xhr.setRequestHeader('X-Parse-Application-Id', this.appId);\r\n if (typeof _noodl_cloudservices !== 'undefined') {\r\n xhr.setRequestHeader('X-Parse-Master-Key', _noodl_cloudservices.masterKey);\r\n }\r\n\r\n // Check for current users\r\n var _cu = localStorage['Parse/' + this.appId + '/currentUser'];\r\n if (_cu !== undefined) {\r\n try {\r\n const currentUser = JSON.parse(_cu);\r\n xhr.setRequestHeader('X-Parse-Session-Token', currentUser.sessionToken);\r\n } catch (e) {\r\n // Failed to extract session token\r\n }\r\n }\r\n\r\n if (options.onUploadProgress) {\r\n xhr.upload.onprogress = (pe) => options.onUploadProgress(pe);\r\n }\r\n\r\n if (options.content instanceof File) {\r\n xhr.send(options.content);\r\n } else {\r\n xhr.setRequestHeader('Content-Type', 'application/json');\r\n xhr.send(JSON.stringify(options.content));\r\n }\r\n } else {\r\n // Running in cloud runtime\r\n const endpoint = typeof _noodl_cloudservices !== 'undefined' ? _noodl_cloudservices.endpoint : this.endpoint;\r\n const appId = typeof _noodl_cloudservices !== 'undefined' ? _noodl_cloudservices.appId : this.appId;\r\n const masterKey = typeof _noodl_cloudservices !== 'undefined' ? _noodl_cloudservices.masterKey : undefined;\r\n\r\n fetch(endpoint + path, {\r\n method: options.method || 'GET',\r\n headers: {\r\n 'X-Parse-Application-Id': appId,\r\n 'X-Parse-Master-Key': masterKey,\r\n 'Content-Type': 'application/json'\r\n },\r\n body: JSON.stringify(options.content)\r\n })\r\n .then((r) => {\r\n if (r.status === 200 || r.status === 201) {\r\n if (options.method === 'DELETE') {\r\n options.success(undefined);\r\n } else {\r\n r.json()\r\n .then((json) => options.success(json))\r\n .catch((e) =>\r\n options.error({\r\n error: 'CloudStore: Failed to get json result.'\r\n })\r\n );\r\n }\r\n } else {\r\n if (options.method === 'DELETE') {\r\n options.error({ error: 'Failed to delete.' });\r\n } else {\r\n r.json()\r\n .then((json) => options.error(json))\r\n .catch((e) => options.error({ error: 'Failed to fetch.' }));\r\n }\r\n }\r\n })\r\n .catch((e) => {\r\n options.error({ error: e.message });\r\n });\r\n }\r\n }\r\n\r\n query(options) {\r\n this._makeRequest('/classes/' + options.collection, {\r\n method: 'POST',\r\n content: {\r\n _method: 'GET',\r\n where: options.where,\r\n limit: options.limit,\r\n skip: options.skip,\r\n include: Array.isArray(options.include) ? options.include.join(',') : options.include,\r\n keys: Array.isArray(options.select) ? options.select.join(',') : options.select,\r\n order: Array.isArray(options.sort) ? options.sort.join(',') : options.sort,\r\n count: options.count\r\n },\r\n success: function (response) {\r\n options.success(response.results, response.count);\r\n },\r\n error: function () {\r\n options.error();\r\n }\r\n });\r\n }\r\n\r\n aggregate(options) {\r\n const args = [];\r\n\r\n if (!options.group) {\r\n options.error('You need to provide group option.');\r\n return;\r\n }\r\n\r\n if (options.limit) args.push('limit=' + options.limit);\r\n if (options.skip) args.push('skip=' + options.skip);\r\n\r\n const grouping = {};\r\n\r\n Object.keys(options.group).forEach((k) => {\r\n const _g = {};\r\n const group = options.group[k];\r\n if (group['avg'] !== undefined) _g['$avg'] = '$' + group['avg'];\r\n else if (group['sum'] !== undefined) _g['$sum'] = '$' + group['sum'];\r\n else if (group['max'] !== undefined) _g['$max'] = '$' + group['max'];\r\n else if (group['min'] !== undefined) _g['$min'] = '$' + group['min'];\r\n else if (group['distinct'] !== undefined) _g['$addToSet'] = '$' + group['distinct'];\r\n\r\n grouping[k] = _g;\r\n });\r\n\r\n // I don't know which version the API was changed, lets just say above 4 for now.\r\n if (this.dbVersionMajor && this.dbVersionMajor > 4) {\r\n grouping._id = null;\r\n\r\n if (options.where) args.push('$match=' + encodeURIComponent(JSON.stringify(options.where)));\r\n\r\n args.push('$group=' + JSON.stringify(grouping));\r\n } else {\r\n grouping.objectId = null;\r\n\r\n if (options.where) args.push('match=' + encodeURIComponent(JSON.stringify(options.where)));\r\n\r\n args.push('group=' + JSON.stringify(grouping));\r\n }\r\n\r\n this._makeRequest('/aggregate/' + options.collection + (args.length > 0 ? '?' + args.join('&') : ''), {\r\n success: function (response) {\r\n const res = {};\r\n\r\n if (!response.results || response.results.length !== 1) {\r\n options.success({}); // No result\r\n return;\r\n }\r\n\r\n Object.keys(options.group).forEach((k) => {\r\n res[k] = response.results[0][k];\r\n });\r\n\r\n options.success(res);\r\n },\r\n error: function () {\r\n options.error();\r\n }\r\n });\r\n }\r\n\r\n count(options) {\r\n const args = [];\r\n\r\n if (options.where) args.push('where=' + encodeURIComponent(JSON.stringify(options.where)));\r\n args.push('limit=0');\r\n args.push('count=1');\r\n\r\n this._makeRequest('/classes/' + options.collection + (args.length > 0 ? '?' + args.join('&') : ''), {\r\n success: function (response) {\r\n options.success(response.count);\r\n },\r\n error: function () {\r\n options.error();\r\n }\r\n });\r\n }\r\n\r\n distinct(options) {\r\n const args = [];\r\n\r\n if (options.where) args.push('where=' + encodeURIComponent(JSON.stringify(options.where)));\r\n args.push('distinct=' + options.property);\r\n\r\n this._makeRequest('/aggregate/' + options.collection + (args.length > 0 ? '?' + args.join('&') : ''), {\r\n success: function (response) {\r\n options.success(response.results);\r\n },\r\n error: function () {\r\n options.error();\r\n }\r\n });\r\n }\r\n\r\n /**\r\n *\r\n * @param {{\r\n * objectId: string;\r\n * collection: string;\r\n * keys?: string[] | string;\r\n * include?: string[] | string;\r\n * excludeKeys?: string[] | string;\r\n * success: (data: unknown) => void;\r\n * error: (error: unknown) => void;\r\n * }} options\r\n */\r\n fetch(options) {\r\n const args = [];\r\n\r\n if (options.include) {\r\n args.push('include=' + (Array.isArray(options.include) ? options.include.join(',') : options.include));\r\n }\r\n\r\n if (options.keys) {\r\n args.push('keys=' + (Array.isArray(options.keys) ? options.keys.join(',') : options.keys));\r\n }\r\n\r\n if (options.excludeKeys) {\r\n args.push(\r\n 'excludeKeys=' + (Array.isArray(options.excludeKeys) ? options.excludeKeys.join(',') : options.excludeKeys)\r\n );\r\n }\r\n\r\n this._makeRequest(\r\n '/classes/' + options.collection + '/' + options.objectId + (args.length > 0 ? '?' + args.join('&') : ''),\r\n {\r\n method: 'GET',\r\n success: (response) => {\r\n options.success(response);\r\n this.events.emit('fetch', {\r\n type: 'fetch',\r\n objectId: options.objectId,\r\n object: response,\r\n collection: options.collection\r\n });\r\n },\r\n error: function (res) {\r\n options.error(res.error);\r\n }\r\n }\r\n );\r\n }\r\n\r\n create(options) {\r\n this._makeRequest('/classes/' + options.collection, {\r\n method: 'POST',\r\n content: Object.assign(\r\n _removeProtectedFields(_serializeObject(options.data, options.collection), options.collection),\r\n { ACL: options.acl }\r\n ),\r\n success: (response) => {\r\n const _obj = Object.assign({}, options.data, response);\r\n options.success(_obj);\r\n this.events.emit('create', {\r\n type: 'create',\r\n objectId: options.objectId,\r\n object: _obj,\r\n collection: options.collection\r\n });\r\n },\r\n error: function (res) {\r\n options.error(res.error);\r\n }\r\n });\r\n }\r\n\r\n increment(options) {\r\n const data = {};\r\n\r\n for (let key in options.properties) {\r\n data[key] = { __op: 'Increment', amount: options.properties[key] };\r\n }\r\n\r\n this._makeRequest('/classes/' + options.collection + '/' + options.objectId, {\r\n method: 'PUT',\r\n content: data,\r\n success: (response) => {\r\n options.success(response);\r\n },\r\n error: function (res) {\r\n options.error(res.error);\r\n }\r\n });\r\n }\r\n\r\n save(options) {\r\n const _data = Object.assign({}, options.data);\r\n delete _data.createdAt;\r\n delete _data.updatedAt;\r\n\r\n this._makeRequest('/classes/' + options.collection + '/' + options.objectId, {\r\n method: 'PUT',\r\n content: Object.assign(_removeProtectedFields(_serializeObject(_data, options.collection), options.collection), {\r\n ACL: options.acl\r\n }),\r\n success: (response) => {\r\n options.success(response);\r\n this.events.emit('save', {\r\n type: 'save',\r\n objectId: options.objectId,\r\n object: Object.assign({}, options.data, response),\r\n collection: options.collection\r\n });\r\n },\r\n error: function (res) {\r\n options.error(res.error);\r\n }\r\n });\r\n }\r\n\r\n delete(options) {\r\n this._makeRequest('/classes/' + options.collection + '/' + options.objectId, {\r\n method: 'DELETE',\r\n success: () => {\r\n options.success();\r\n this.events.emit('delete', {\r\n type: 'delete',\r\n objectId: options.objectId,\r\n collection: options.collection\r\n });\r\n },\r\n error: function (res) {\r\n options.error(res.error);\r\n }\r\n });\r\n }\r\n\r\n addRelation(options) {\r\n const _content = {};\r\n _content[options.key] = {\r\n __op: 'AddRelation',\r\n objects: [\r\n {\r\n __type: 'Pointer',\r\n objectId: options.targetObjectId,\r\n className: options.targetClass\r\n }\r\n ]\r\n };\r\n this._makeRequest('/classes/' + options.collection + '/' + options.objectId, {\r\n method: 'PUT',\r\n content: _content,\r\n success: function (response) {\r\n options.success(response);\r\n },\r\n error: function (res) {\r\n options.error(res.error);\r\n }\r\n });\r\n }\r\n\r\n removeRelation(options) {\r\n const _content = {};\r\n _content[options.key] = {\r\n __op: 'RemoveRelation',\r\n objects: [\r\n {\r\n __type: 'Pointer',\r\n objectId: options.targetObjectId,\r\n className: options.targetClass\r\n }\r\n ]\r\n };\r\n this._makeRequest('/classes/' + options.collection + '/' + options.objectId, {\r\n method: 'PUT',\r\n content: _content,\r\n success: function (response) {\r\n options.success(response);\r\n },\r\n error: function (res) {\r\n options.error(res.error);\r\n }\r\n });\r\n }\r\n\r\n uploadFile(options) {\r\n this._makeRequest('/files/' + options.file.name, {\r\n method: 'POST',\r\n content: options.file,\r\n contentType: options.file.type,\r\n success: (response) => options.success(Object.assign({}, options.data, response)),\r\n error: (err) => options.error(err),\r\n onUploadProgress: options.onUploadProgress\r\n });\r\n }\r\n\r\n /**\r\n * Users holding the master key are allowed to delete files\r\n *\r\n * @param {{\r\n * file: {\r\n * name: string;\r\n * }\r\n * success: (data: unknown) => void;\r\n * error: (error: unknown) => void;\r\n * }} options\r\n */\r\n deleteFile(options) {\r\n this._makeRequest('/files/' + options.file.name, {\r\n method: 'DELETE',\r\n success: (response) => options.success(Object.assign({}, options.data, response)),\r\n error: (err) => options.error(err)\r\n });\r\n }\r\n}\r\n\r\nfunction _isArrayOfObjects(a) {\r\n if (!Array.isArray(a)) return false;\r\n for (var i = 0; i < a.length; i++) if (typeof a[i] !== 'object' || a[i] === null) return false;\r\n\r\n return true;\r\n}\r\n\r\nfunction _toJSON(obj) {\r\n if (obj instanceof Model) {\r\n var res = {};\r\n for (var key in obj.data) {\r\n res[key] = _toJSON(obj.data[key]);\r\n }\r\n return res;\r\n } else if (obj instanceof Collection) {\r\n var res = [];\r\n obj.items.forEach((m) => {\r\n res.push(_toJSON(m));\r\n });\r\n return res;\r\n }\r\n return obj;\r\n}\r\n\r\nfunction _serializeObject(data, collectionName, modelScope) {\r\n if (CloudStore._collections[collectionName]) var schema = CloudStore._collections[collectionName].schema;\r\n\r\n for (var key in data) {\r\n var _type = schema && schema.properties && schema.properties[key] ? schema.properties[key].type : undefined;\r\n\r\n if (data[key] === undefined || data[key] === null) {\r\n // Keep null and undefined as is\r\n } else if (_type === 'Pointer' && typeof data[key] === 'string') {\r\n // This is a string pointer to an object\r\n data[key] = {\r\n __type: 'Pointer',\r\n className: schema.properties[key].targetClass,\r\n objectId: data[key]\r\n };\r\n } else if (_type === 'Pointer' && typeof data[key] === 'object' && (modelScope || Model).instanceOf(data[key])) {\r\n // This is an embedded object that should be stored as pointer\r\n data[key] = {\r\n __type: 'Pointer',\r\n className: schema.properties[key].targetClass,\r\n objectId: data[key].getId()\r\n };\r\n } else if (_type === 'Date' && (typeof data[key] === 'string' || data[key] instanceof Date)) {\r\n data[key] = {\r\n __type: 'Date',\r\n iso: data[key] instanceof Date ? data[key].toISOString() : data[key]\r\n };\r\n } else if (_type === 'File' && data[key] instanceof CloudFile) {\r\n const cloudFile = data[key];\r\n data[key] = {\r\n __type: 'File',\r\n url: cloudFile.getUrl(),\r\n name: cloudFile.getName()\r\n };\r\n } else if (_type === 'Array' && typeof data[key] === 'string' && Collection.exists(data[key])) {\r\n data[key] = _toJSON(Collection.get(data[key]));\r\n } else if (_type === 'Object' && typeof data[key] === 'string' && (modelScope || Model).exists(data[key])) {\r\n data[key] = _toJSON((modelScope || Model).get(data[key]));\r\n } else if (_type === 'GeoPoint' && typeof data[key] === 'object') {\r\n data[key] = {\r\n __type: 'GeoPoint',\r\n latitude: Number(data[key].latitude),\r\n longitude: Number(data[key].longitude)\r\n };\r\n } else data[key] = _toJSON(data[key]);\r\n }\r\n\r\n return data;\r\n}\r\n\r\nfunction _deserializeJSON(data, type, modelScope) {\r\n if (data === undefined) return;\r\n if (data === null) return null;\r\n\r\n if (type === 'Relation' && data.__type === 'Relation') {\r\n return undefined; // Ignore relation fields\r\n } else if (type === 'Pointer' && data.__type === 'Pointer') {\r\n // This is a pointer type, resolve into id\r\n return data.objectId;\r\n } else if (type === 'Date' && data.__type === 'Date') {\r\n return new Date(data.iso);\r\n } else if (type === 'Date' && typeof data === 'string') {\r\n return new Date(data);\r\n } else if (type === 'File' && data.__type === 'File') {\r\n return new CloudFile(data);\r\n } else if (type === 'GeoPoint' && data.__type === 'GeoPoint') {\r\n return {\r\n latitude: data.latitude,\r\n longitude: data.longitude\r\n };\r\n } else if (_isArrayOfObjects(data)) {\r\n var a = [];\r\n for (var i = 0; i < data.length; i++) {\r\n a.push(_deserializeJSON(data[i], undefined, modelScope));\r\n }\r\n var c = Collection.get();\r\n c.set(a);\r\n return c;\r\n } else if (Array.isArray(data)) return data;\r\n // This is an array with mixed data, just return it\r\n else if (data && data.__type === 'Object' && data.className !== undefined && data.objectId !== undefined) {\r\n const _data = Object.assign({}, data);\r\n delete _data.className;\r\n delete _data.__type;\r\n return _fromJSON(_data, data.className, modelScope);\r\n } else if (typeof data === 'object' && data !== null) {\r\n var m = (modelScope || Model).get();\r\n for (var key in data) {\r\n m.set(key, _deserializeJSON(data[key], undefined, modelScope));\r\n }\r\n return m;\r\n } else return data;\r\n}\r\n\r\nfunction _fromJSON(item, collectionName, modelScope) {\r\n const modelStore = modelScope || Model;\r\n\r\n const model = modelStore.get(item.objectId);\r\n model._class = collectionName;\r\n\r\n let schema = undefined;\r\n if (collectionName !== undefined && CloudStore._collections[collectionName] !== undefined) {\r\n schema = CloudStore._collections[collectionName].schema;\r\n }\r\n\r\n for (const key in item) {\r\n if (key === 'objectId' || key === 'ACL') {\r\n continue;\r\n }\r\n\r\n const _type = schema && schema.properties && schema.properties[key] ? schema.properties[key].type : undefined;\r\n model.set(key, _deserializeJSON(item[key], _type, modelScope));\r\n }\r\n\r\n return model;\r\n}\r\n\r\nCloudStore._fromJSON = _fromJSON;\r\nCloudStore._deserializeJSON = _deserializeJSON;\r\nCloudStore._serializeObject = _serializeObject;\r\n\r\nCloudStore.forScope = (modelScope) => {\r\n if (modelScope === undefined) return CloudStore.instance;\r\n if (modelScope._cloudStore) return modelScope._cloudStore;\r\n\r\n modelScope._cloudStore = new CloudStore(modelScope);\r\n return modelScope._cloudStore;\r\n};\r\n\r\nvar _instance;\r\nObject.defineProperty(CloudStore, 'instance', {\r\n get: function () {\r\n if (_instance === undefined) _instance = new CloudStore();\r\n return _instance;\r\n }\r\n});\r\n\r\nvar _collections;\r\nObject.defineProperty(CloudStore, '_collections', {\r\n get: function () {\r\n if (_collections === undefined) {\r\n _collections = {};\r\n const dbCollections = NoodlRuntime.instance.getMetaData('dbCollections') || [];\r\n dbCollections.forEach((c) => {\r\n _collections[c.name] = c;\r\n });\r\n\r\n const systemCollections = NoodlRuntime.instance.getMetaData('systemCollections') || [];\r\n systemCollections.forEach((c) => {\r\n _collections[c.name] = c;\r\n });\r\n }\r\n return _collections;\r\n }\r\n});\r\n\r\nCloudStore.invalidateCollections = () => {\r\n _collections = undefined;\r\n};\r\n\r\nmodule.exports = CloudStore;\r\n","const NoodlRuntime = require('../../../noodl-runtime');\r\n\r\nclass ConfigService {\r\n constructor() {\r\n this.cacheDuration = 15 * 60 * 1000; // 15 min cache\r\n }\r\n\r\n _makeRequest(path, options) {\r\n if (typeof _noodl_cloud_runtime_version === 'undefined') {\r\n // Running in browser\r\n var xhr = new XMLHttpRequest();\r\n\r\n xhr.onreadystatechange = function () {\r\n if (xhr.readyState === 4) {\r\n var json;\r\n try {\r\n json = JSON.parse(xhr.response);\r\n } catch (e) {}\r\n\r\n if (xhr.status === 200 || xhr.status === 201) {\r\n options.success(json);\r\n } else options.error(json || { error: xhr.responseText, status: xhr.status });\r\n }\r\n };\r\n\r\n const cloudServices = NoodlRuntime.instance.getMetaData('cloudservices');\r\n const appId = cloudServices.appId;\r\n const endpoint = cloudServices.endpoint;\r\n xhr.open('GET', endpoint + path, true);\r\n\r\n xhr.setRequestHeader('X-Parse-Application-Id', appId);\r\n\r\n xhr.send();\r\n } else {\r\n // Running in cloud runtime\r\n const endpoint = typeof _noodl_cloudservices !== 'undefined' ? _noodl_cloudservices.endpoint : this.endpoint;\r\n const appId = typeof _noodl_cloudservices !== 'undefined' ? _noodl_cloudservices.appId : this.appId;\r\n const masterKey = typeof _noodl_cloudservices !== 'undefined' ? _noodl_cloudservices.masterKey : undefined;\r\n\r\n fetch(endpoint + path, {\r\n method: 'GET',\r\n headers: {\r\n 'X-Parse-Application-Id': appId,\r\n 'X-Parse-Master-Key': masterKey\r\n }\r\n })\r\n .then((r) => {\r\n if (r.status === 200 || r.status === 201) {\r\n r.json()\r\n .then((json) => options.success(json))\r\n .catch((e) =>\r\n options.error({\r\n error: 'Config: Failed to get json result.'\r\n })\r\n );\r\n } else {\r\n r.json()\r\n .then((json) => options.error(json))\r\n .catch((e) => options.error({ error: 'Failed to fetch.' }));\r\n }\r\n })\r\n .catch((e) => {\r\n options.error({ error: e.message });\r\n });\r\n }\r\n }\r\n\r\n _getConfig() {\r\n return new Promise((resolve, reject) => {\r\n this._makeRequest('/config', {\r\n success: (config) => {\r\n resolve(config.params || {});\r\n },\r\n error: (err) => {\r\n reject(err);\r\n }\r\n });\r\n });\r\n }\r\n\r\n async getConfig() {\r\n if (this.configCachePending) return this.configCachePending;\r\n\r\n if (!this.configCache) {\r\n this.configCachePending = this._getConfig();\r\n\r\n this.configCache = await this.configCachePending;\r\n delete this.configCachePending;\r\n this.ttl = Date.now() + this.cacheDuration;\r\n return this.configCache;\r\n } else {\r\n // Update cache if ttl has passed\r\n if (Date.now() > this.ttl) {\r\n this._getConfig().then((config) => {\r\n this.configCache = config;\r\n this.ttl = Date.now() + this.cacheDuration;\r\n });\r\n }\r\n\r\n // But return currently cached\r\n return this.configCache;\r\n }\r\n }\r\n\r\n clearCache() {\r\n delete this.configCache;\r\n }\r\n}\r\n\r\nConfigService.instance = new ConfigService();\r\n\r\nmodule.exports = ConfigService;\r\n","const CloudStore = require('./cloudstore');\r\nconst Model = require('../model');\r\n\r\nfunction convertVisualFilter(query, options) {\r\n var inputs = options.queryParameters;\r\n\r\n if (query.combinator !== undefined && query.rules !== undefined) {\r\n if (query.rules.length === 0) return;\r\n else if (query.rules.length === 1) return convertVisualFilter(query.rules[0], options);\r\n else {\r\n const _res = {};\r\n const _op = '$' + query.combinator;\r\n _res[_op] = [];\r\n query.rules.forEach((r) => {\r\n var cond = convertVisualFilter(r, options);\r\n if (cond !== undefined) _res[_op].push(cond);\r\n });\r\n\r\n return _res;\r\n }\r\n } else if (query.operator === 'related to') {\r\n var value = query.input !== undefined ? inputs[query.input] : undefined;\r\n if (value === undefined) return;\r\n\r\n return {\r\n $relatedTo: {\r\n object: {\r\n __type: 'Pointer',\r\n objectId: value,\r\n className: query.relatedTo\r\n },\r\n key: query.relationProperty\r\n }\r\n };\r\n } else {\r\n const _res = {};\r\n var cond;\r\n var value = query.input !== undefined ? inputs[query.input] : query.value;\r\n\r\n if (query.operator === 'exist') {\r\n _res[query.property] = { $exists: true };\r\n return _res;\r\n } else if (query.operator === 'not exist') {\r\n _res[query.property] = { $exists: false };\r\n return _res;\r\n }\r\n\r\n if (value === undefined) return;\r\n\r\n if (CloudStore._collections[options.collectionName])\r\n var schema = CloudStore._collections[options.collectionName].schema;\r\n\r\n var propertyType =\r\n schema && schema.properties && schema.properties[query.property]\r\n ? schema.properties[query.property].type\r\n : undefined;\r\n\r\n if (propertyType === 'Date') {\r\n if (!(value instanceof Date)) value = new Date(value.toString());\r\n value = { __type: 'Date', iso: value.toISOString() };\r\n }\r\n\r\n if (query.operator === 'greater than') cond = { $gt: value };\r\n else if (query.operator === 'greater than or equal to') cond = { $gte: value };\r\n else if (query.operator === 'less than') cond = { $lt: value };\r\n else if (query.operator === 'less than or equal to') cond = { $lte: value };\r\n else if (query.operator === 'equal to') cond = { $eq: value };\r\n else if (query.operator === 'not equal to') cond = { $ne: value };\r\n else if (query.operator === 'points to') {\r\n var targetClass =\r\n schema && schema.properties && schema.properties[query.property]\r\n ? schema.properties[query.property].targetClass\r\n : undefined;\r\n\r\n cond = {\r\n $eq: { __type: 'Pointer', objectId: value, className: targetClass }\r\n };\r\n } else if (query.operator === 'contain') {\r\n cond = { $regex: value, $options: 'i' };\r\n }\r\n\r\n _res[query.property] = cond;\r\n\r\n return _res;\r\n }\r\n}\r\n\r\nfunction matchesQuery(model, query) {\r\n var match = true;\r\n\r\n if (query === undefined) return true;\r\n\r\n if (query['$and'] !== undefined) {\r\n query['$and'].forEach((q) => {\r\n match &= matchesQuery(model, q);\r\n });\r\n } else if (query['$or'] !== undefined) {\r\n match = false;\r\n query['$or'].forEach((q) => {\r\n match |= matchesQuery(model, q);\r\n });\r\n } else {\r\n var keys = Object.keys(query);\r\n keys.forEach((k) => {\r\n if (k === 'objectId') {\r\n if (query[k]['$eq'] !== undefined) match &= model.getId() === query[k]['$eq'];\r\n else if (query[k]['$in'] !== undefined) match &= query[k]['$in'].indexOf(model.getId()) !== -1;\r\n } else if (k === '$relatedTo') {\r\n match = false; // cannot resolve relation queries locally\r\n } else {\r\n var value = model.get(k);\r\n if (query[k]['$eq'] !== undefined && query[k]['$eq'].__type === 'Pointer')\r\n match &= value === query[k]['$eq'].objectId;\r\n else if (query[k]['$eq'] !== undefined) match &= value == query[k]['$eq'];\r\n else if (query[k]['$ne'] !== undefined) match &= value != query[k]['$ne'];\r\n else if (query[k]['$lt'] !== undefined) match &= value < query[k]['$lt'];\r\n else if (query[k]['$lte'] !== undefined) match &= value <= query[k]['$lt'];\r\n else if (query[k]['$gt'] !== undefined) match &= value > query[k]['$gt'];\r\n else if (query[k]['$gte'] !== undefined) match &= value >= query[k]['$gte'];\r\n else if (query[k]['$exists'] !== undefined) match &= value !== undefined;\r\n else if (query[k]['$in'] !== undefined) match &= query[k]['$in'].indexOf(value) !== -1;\r\n else if (query[k]['$nin'] !== undefined) match &= query[k]['$in'].indexOf(value) === -1;\r\n else if (query[k]['$regex'] !== undefined)\r\n match &= new RegExp(query[k]['$regex'], query[k]['$options']).test(value);\r\n }\r\n });\r\n }\r\n return match;\r\n}\r\n\r\nfunction compareObjects(sort, a, b) {\r\n for (var i = 0; i < sort.length; i++) {\r\n let _s = sort[i];\r\n if (_s[0] === '-') {\r\n // Descending\r\n let prop = _s.substring(1);\r\n if (a.get(prop) > b.get(prop)) return -1;\r\n else if (a.get(prop) < b.get(prop)) return 1;\r\n } else {\r\n // Ascending\r\n if (a.get(_s) > b.get(_s)) return 1;\r\n else if (a.get(_s) < b.get(_s)) return -1;\r\n }\r\n }\r\n return 0;\r\n}\r\n\r\nfunction convertVisualSorting(sorting) {\r\n return sorting.map((s) => {\r\n return (s.order === 'descending' ? '-' : '') + s.property;\r\n });\r\n}\r\n\r\nfunction _value(v) {\r\n if (v instanceof Date && typeof v.toISOString === 'function') {\r\n return {\r\n __type: 'Date',\r\n iso: v.toISOString()\r\n };\r\n }\r\n return v;\r\n}\r\n\r\n/**\r\n *\r\n * @param {Record} filter\r\n * @param {{\r\n * collectionName?: string;\r\n * modelScope?: unknown;\r\n * error: (error: string) => void;\r\n * }} options\r\n * @returns\r\n */\r\nfunction convertFilterOp(filter, options) {\r\n const keys = Object.keys(filter);\r\n if (keys.length === 0) return {};\r\n if (keys.length !== 1) {\r\n return options.error('Filter must only have one key found ' + keys.join(','));\r\n }\r\n\r\n const res = {};\r\n const key = keys[0];\r\n if (filter['and'] !== undefined && Array.isArray(filter['and'])) {\r\n res['$and'] = filter['and'].map((f) => convertFilterOp(f, options));\r\n } else if (filter['or'] !== undefined && Array.isArray(filter['or'])) {\r\n res['$or'] = filter['or'].map((f) => convertFilterOp(f, options));\r\n } else if (filter['idEqualTo'] !== undefined) {\r\n res['objectId'] = { $eq: filter['idEqualTo'] };\r\n } else if (filter['idContainedIn'] !== undefined) {\r\n res['objectId'] = { $in: filter['idContainedIn'] };\r\n } else if (filter['relatedTo'] !== undefined) {\r\n const modelId = filter['relatedTo']['id'];\r\n if (modelId === undefined) {\r\n return options.error('Must provide id in relatedTo filter');\r\n }\r\n\r\n const relationKey = filter['relatedTo']['key'];\r\n if (relationKey === undefined) {\r\n return options.error('Must provide key in relatedTo filter');\r\n }\r\n\r\n const className = filter['relatedTo']['className'] || (options.modelScope || Model).get(modelId)?._class;\r\n if (typeof className === 'undefined') {\r\n // Either the pointer is loaded as an object or we allow passing in the className.\r\n return options.error('Must preload the Pointer or include className');\r\n }\r\n\r\n res['$relatedTo'] = {\r\n object: {\r\n __type: 'Pointer',\r\n objectId: modelId,\r\n className\r\n },\r\n key: relationKey\r\n };\r\n } else if (typeof filter[key] === 'object') {\r\n const opAndValue = filter[key];\r\n if (opAndValue['equalTo'] !== undefined) res[key] = { $eq: _value(opAndValue['equalTo']) };\r\n else if (opAndValue['notEqualTo'] !== undefined) res[key] = { $ne: _value(opAndValue['notEqualTo']) };\r\n else if (opAndValue['lessThan'] !== undefined) res[key] = { $lt: _value(opAndValue['lessThan']) };\r\n else if (opAndValue['greaterThan'] !== undefined) res[key] = { $gt: _value(opAndValue['greaterThan']) };\r\n else if (opAndValue['lessThanOrEqualTo'] !== undefined)\r\n res[key] = { $lte: _value(opAndValue['lessThanOrEqualTo']) };\r\n else if (opAndValue['greaterThanOrEqualTo'] !== undefined)\r\n res[key] = { $gte: _value(opAndValue['greaterThanOrEqualTo']) };\r\n else if (opAndValue['exists'] !== undefined) res[key] = { $exists: opAndValue['exists'] };\r\n else if (opAndValue['containedIn'] !== undefined) res[key] = { $in: opAndValue['containedIn'] };\r\n else if (opAndValue['notContainedIn'] !== undefined) res[key] = { $nin: opAndValue['notContainedIn'] };\r\n else if (opAndValue['pointsTo'] !== undefined) {\r\n let schema = null;\r\n if (CloudStore._collections[options.collectionName]) {\r\n schema = CloudStore._collections[options.collectionName].schema;\r\n }\r\n\r\n const targetClass =\r\n schema && schema.properties && schema.properties[key] ? schema.properties[key].targetClass : undefined;\r\n const type = schema && schema.properties && schema.properties[key] ? schema.properties[key].type : undefined;\r\n\r\n if (type === 'Relation') {\r\n res[key] = {\r\n __type: 'Pointer',\r\n objectId: opAndValue['pointsTo'],\r\n className: targetClass\r\n };\r\n } else {\r\n if (Array.isArray(opAndValue['pointsTo'])) {\r\n res[key] = {\r\n $in: opAndValue['pointsTo'].map((v) => {\r\n return { __type: 'Pointer', objectId: v, className: targetClass };\r\n })\r\n };\r\n } else {\r\n res[key] = {\r\n $eq: {\r\n __type: 'Pointer',\r\n objectId: opAndValue['pointsTo'],\r\n className: targetClass\r\n }\r\n };\r\n }\r\n }\r\n } else if (opAndValue['matchesRegex'] !== undefined) {\r\n res[key] = {\r\n $regex: opAndValue['matchesRegex'],\r\n $options: opAndValue['options']\r\n };\r\n } else if (opAndValue['text'] !== undefined && opAndValue['text']['search'] !== undefined) {\r\n var _v = opAndValue['text']['search'];\r\n if (typeof _v === 'string') res[key] = { $text: { $search: { $term: _v, $caseSensitive: false } } };\r\n else\r\n res[key] = {\r\n $text: {\r\n $search: {\r\n $term: _v.term,\r\n $language: _v.language,\r\n $caseSensitive: _v.caseSensitive,\r\n $diacriticSensitive: _v.diacriticSensitive\r\n }\r\n }\r\n };\r\n // Geo points\r\n } else if (opAndValue['nearSphere'] !== undefined) {\r\n var _v = opAndValue['nearSphere'];\r\n res[key] = {\r\n $nearSphere: {\r\n __type: 'GeoPoint',\r\n latitude: _v.latitude,\r\n longitude: _v.longitude\r\n },\r\n $maxDistanceInMiles: _v.$maxDistanceInMiles,\r\n $maxDistanceInKilometers: _v.maxDistanceInKilometers,\r\n $maxDistanceInRadians: _v.maxDistanceInRadians\r\n };\r\n } else if (opAndValue['withinBox'] !== undefined) {\r\n var _v = opAndValue['withinBox'];\r\n res[key] = {\r\n $within: {\r\n $box: _v.map((gp) => ({\r\n __type: 'GeoPoint',\r\n latitude: gp.latitude,\r\n longitude: gp.longitude\r\n }))\r\n }\r\n };\r\n } else if (opAndValue['withinPolygon'] !== undefined) {\r\n var _v = opAndValue['withinPolygon'];\r\n res[key] = {\r\n $geoWithin: {\r\n $polygon: _v.map((gp) => ({\r\n __type: 'GeoPoint',\r\n latitude: gp.latitude,\r\n longitude: gp.longitude\r\n }))\r\n }\r\n };\r\n }\r\n } else {\r\n options.error('Unrecognized filter keys ' + keys.join(','));\r\n }\r\n\r\n return res;\r\n}\r\n\r\nmodule.exports = {\r\n convertVisualFilter,\r\n compareObjects,\r\n matchesQuery,\r\n convertVisualSorting,\r\n convertFilterOp\r\n};\r\n","const CloudStore = require('./cloudstore');\r\nconst QueryUtils = require('./queryutils');\r\nconst Model = require('../model');\r\n\r\nfunction createRecordsAPI(modelScope) {\r\n let _cloudstore;\r\n const cloudstore = () => {\r\n // We must create the cloud store just in time so all meta data is loaded\r\n if (!_cloudstore) _cloudstore = new CloudStore(modelScope);\r\n return _cloudstore;\r\n };\r\n\r\n return {\r\n async query(className, query, options) {\r\n if (typeof className === 'undefined') throw new Error(\"'className' is undefined\");\r\n return new Promise((resolve, reject) => {\r\n cloudstore().query({\r\n collection: className,\r\n where: QueryUtils.convertFilterOp(query || {}, {\r\n collectionName: className,\r\n error: (e) => reject(e),\r\n modelScope\r\n }),\r\n limit: options ? options.limit : undefined,\r\n sort: options ? options.sort : undefined,\r\n skip: options ? options.skip : undefined,\r\n include: options ? options.include : undefined,\r\n select: options ? options.select : undefined,\r\n count: options ? options.count : undefined,\r\n success: (results, count) => {\r\n const _results = results.map((r) => cloudstore()._fromJSON(r, className));\r\n if (count !== undefined) resolve({ results: _results, count });\r\n else resolve(_results);\r\n },\r\n error: (err) => {\r\n reject(Error(err || 'Failed to query.'));\r\n }\r\n });\r\n });\r\n },\r\n\r\n async count(className, query) {\r\n if (typeof className === 'undefined') throw new Error(\"'className' is undefined\");\r\n return new Promise((resolve, reject) => {\r\n cloudstore().count({\r\n collection: className,\r\n where: query\r\n ? QueryUtils.convertFilterOp(query || {}, {\r\n collectionName: className,\r\n error: (e) => reject(e),\r\n modelScope\r\n })\r\n : undefined,\r\n success: (count) => {\r\n resolve(count);\r\n },\r\n error: (err) => {\r\n reject(Error(err || 'Failed to query.'));\r\n }\r\n });\r\n });\r\n },\r\n\r\n async distinct(className, property, query) {\r\n if (typeof className === 'undefined') throw new Error(\"'className' is undefined\");\r\n return new Promise((resolve, reject) => {\r\n cloudstore().distinct({\r\n collection: className,\r\n property,\r\n where: query\r\n ? QueryUtils.convertFilterOp(query || {}, {\r\n collectionName: className,\r\n error: (e) => reject(e),\r\n modelScope\r\n })\r\n : undefined,\r\n success: (results) => {\r\n resolve(results);\r\n },\r\n error: (err) => {\r\n reject(Error(err || 'Failed to query.'));\r\n }\r\n });\r\n });\r\n },\r\n\r\n async aggregate(className, group, query) {\r\n if (typeof className === 'undefined') throw new Error(\"'className' is undefined\");\r\n return new Promise((resolve, reject) => {\r\n cloudstore().aggregate({\r\n collection: className,\r\n group,\r\n where: query\r\n ? QueryUtils.convertFilterOp(query || {}, {\r\n collectionName: className,\r\n error: (e) => reject(e),\r\n modelScope\r\n })\r\n : undefined,\r\n success: (results) => {\r\n resolve(results);\r\n },\r\n error: (err) => {\r\n reject(Error(err || 'Failed to aggregate.'));\r\n }\r\n });\r\n });\r\n },\r\n\r\n /**\r\n *\r\n * @param {string | { getId(): string; }} objectOrId\r\n * @param {{\r\n * className: string;\r\n * keys?: string[] | string;\r\n * include?: string[] | string;\r\n * excludeKeys?: string[] | string;\r\n * }} options\r\n * @returns {Promise}\r\n */\r\n async fetch(objectOrId, options) {\r\n if (typeof objectOrId === 'undefined') return Promise.reject(new Error(\"'objectOrId' is undefined.\"));\r\n if (typeof objectOrId !== 'string') objectOrId = objectOrId.getId();\r\n const className = (options ? options.className : undefined) || (modelScope || Model).get(objectOrId)._class;\r\n\r\n return new Promise((resolve, reject) => {\r\n if (!className) {\r\n return reject('No class name specified');\r\n }\r\n\r\n cloudstore().fetch({\r\n collection: className,\r\n objectId: objectOrId,\r\n keys: options?.keys,\r\n include: options?.include,\r\n excludeKeys: options?.excludeKeys,\r\n success: function (response) {\r\n const record = cloudstore()._fromJSON(response, className);\r\n resolve(record);\r\n },\r\n error: function (err) {\r\n reject(Error(err || 'Failed to fetch.'));\r\n }\r\n });\r\n });\r\n },\r\n\r\n async increment(objectOrId, properties, options) {\r\n if (typeof objectOrId === 'undefined') return Promise.reject(new Error(\"'objectOrId' is undefined.\"));\r\n if (typeof objectOrId !== 'string') objectOrId = objectOrId.getId();\r\n const className = (options ? options.className : undefined) || (modelScope || Model).get(objectOrId)._class;\r\n\r\n return new Promise((resolve, reject) => {\r\n if (!className) return reject('No class name specified');\r\n\r\n cloudstore().increment({\r\n collection: className,\r\n objectId: objectOrId,\r\n properties,\r\n success: (response) => {\r\n cloudstore()._fromJSON(Object.assign({ objectId: objectOrId }, response), className); // Update values\r\n\r\n resolve();\r\n },\r\n error: (err) => {\r\n reject(Error(err || 'Failed to increment.'));\r\n }\r\n });\r\n });\r\n },\r\n\r\n async save(objectOrId, properties, options) {\r\n if (typeof objectOrId === 'undefined') return Promise.reject(new Error(\"'objectOrId' is undefined.\"));\r\n if (typeof objectOrId !== 'string') objectOrId = objectOrId.getId();\r\n const className = (options ? options.className : undefined) || (modelScope || Model).get(objectOrId)._class;\r\n\r\n const model = (modelScope || Model).get(objectOrId);\r\n if (properties) {\r\n Object.keys(properties).forEach((p) => {\r\n model.set(p, properties[p]);\r\n });\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n if (!className) return reject('No class name specified');\r\n\r\n cloudstore().save({\r\n collection: className,\r\n objectId: objectOrId,\r\n data: properties || model.data,\r\n acl: options ? options.acl : undefined,\r\n success: (response) => {\r\n cloudstore()._fromJSON(Object.assign({ objectId: objectOrId }, response), className); // Assign updated at\r\n resolve();\r\n },\r\n error: (err) => {\r\n reject(Error(err || 'Failed to save.'));\r\n }\r\n });\r\n });\r\n },\r\n\r\n async create(className, properties, options) {\r\n if (typeof className === 'undefined') throw new Error(\"'className' is undefined\");\r\n return new Promise((resolve, reject) => {\r\n cloudstore().create({\r\n collection: className,\r\n data: properties,\r\n acl: options ? options.acl : undefined,\r\n success: (data) => {\r\n // Successfully created\r\n const m = cloudstore()._fromJSON(data, className);\r\n resolve(m);\r\n },\r\n error: (err) => {\r\n reject(Error(err || 'Failed to insert.'));\r\n }\r\n });\r\n });\r\n },\r\n\r\n async delete(objectOrId, options) {\r\n if (typeof objectOrId === 'undefined') return Promise.reject(new Error(\"'objectOrId' is undefined.\"));\r\n if (typeof objectOrId !== 'string') objectOrId = objectOrId.getId();\r\n const className = (options ? options.className : undefined) || (modelScope || Model).get(objectOrId)._class;\r\n\r\n return new Promise((resolve, reject) => {\r\n if (!className) return reject('No class name specified');\r\n\r\n cloudstore().delete({\r\n collection: className,\r\n objectId: objectOrId,\r\n success: () => {\r\n (modelScope || Model).get(objectOrId).notify('delete');\r\n resolve();\r\n },\r\n error: (err) => {\r\n reject(Error(err || 'Failed to delete.'));\r\n }\r\n });\r\n });\r\n },\r\n\r\n async addRelation(options) {\r\n const recordId = options.recordId || options.record.getId();\r\n const className = options.className || (modelScope || Model).get(recordId)._class;\r\n\r\n const targetRecordId = options.targetRecordId || options.targetRecord.getId();\r\n const targetClassName = options.targetClassName || (modelScope || Model).get(targetRecordId)._class;\r\n\r\n return new Promise((resolve, reject) => {\r\n if (!className) return reject('No class name specified');\r\n if (!targetClassName) return reject('No target class name specified');\r\n\r\n cloudstore().addRelation({\r\n collection: className,\r\n objectId: recordId,\r\n key: options.key,\r\n targetObjectId: targetRecordId,\r\n targetClass: targetClassName,\r\n success: (response) => {\r\n resolve();\r\n },\r\n error: (err) => {\r\n reject(Error(err || 'Failed to add relation.'));\r\n }\r\n });\r\n });\r\n },\r\n\r\n async removeRelation(options) {\r\n const recordId = options.recordId || options.record.getId();\r\n const className = options.className || (modelScope || Model).get(recordId)._class;\r\n\r\n const targetRecordId = options.targetRecordId || options.targetRecord.getId();\r\n const targetClassName = options.targetClassName || (modelScope || Model).get(targetRecordId)._class;\r\n\r\n return new Promise((resolve, reject) => {\r\n if (!className) return reject('No class name specified');\r\n if (!targetClassName) return reject('No target class name specified');\r\n\r\n cloudstore().removeRelation({\r\n collection: className,\r\n objectId: recordId,\r\n key: options.key,\r\n targetObjectId: targetRecordId,\r\n targetClass: targetClassName,\r\n success: (response) => {\r\n resolve();\r\n },\r\n error: (err) => {\r\n reject(Error(err || 'Failed to add relation.'));\r\n }\r\n });\r\n });\r\n }\r\n };\r\n}\r\n\r\nmodule.exports = createRecordsAPI;\r\n","async function asyncPool(poolLimit, values, iteratorFn) {\r\n const ret = [];\r\n const executing = [];\r\n for (const item of values) {\r\n const p = Promise.resolve().then(() => iteratorFn(item, values));\r\n ret.push(p);\r\n \r\n if (poolLimit <= values.length) {\r\n const e = p.then(() => executing.splice(executing.indexOf(e), 1));\r\n executing.push(e);\r\n if (executing.length >= poolLimit) {\r\n await Promise.race(executing);\r\n }\r\n }\r\n }\r\n \r\n return Promise.all(ret);\r\n }\r\n \r\n module.exports = asyncPool;","'use strict';\r\n\r\nvar Model = require('./model');\r\n\r\n// Get and set proxy\r\n/*const proxies = {}\r\nconst _collectionProxyHandler = {\r\n get: function(target,prop,receiver) {\r\n if(typeof target[prop] === 'function')\r\n return target[prop].bind(target);\r\n else if(prop === 'length')\r\n return target.size()\r\n else if(target.items[prop] !== undefined)\r\n return target.get(prop)\r\n else\r\n return Reflect.get(target,prop,receiver)\r\n },\r\n set: function(obj,prop,value) {\r\n if(prop === 'id') {\r\n console.log(`Noodl.Object warning: id is readonly (Id is ${obj.id}, trying to set to ${value})`);\r\n return true; //if a proxy doesn't return true an exception will be thrown\r\n }\r\n else\r\n return Reflect.set(target,prop,receiver)\r\n }\r\n}\r\n\r\nfunction Collection(id) {\r\n this.id = id;\r\n this.items = [];\r\n}\r\n\r\nvar collections = Collection._collections = {};\r\n\r\nCollection.create = function(items) {\r\n const name = Model.guid();\r\n collections[name] = new Collection(name);\r\n if(items) {\r\n collections[name].set(items);\r\n }\r\n return collections[name];\r\n}\r\n\r\nCollection.get = function(name) {\r\n if(name === undefined) name = Model.guid();\r\n if(!collections[name]) {\r\n collections[name] = new Collection(name);\r\n proxies[name] = new Proxy(collections[name],_collectionProxyHandler);\r\n }\r\n return proxies[name];\r\n}\r\n\r\nCollection.instanceOf = function(collection) {\r\n return collection && (collection instanceof Collection || collection.target instanceof Collection);\r\n}\r\n\r\nCollection.exists = function(name) {\r\n return collections[name] !== undefined;\r\n}\r\n\r\nCollection.prototype.getId = function() {\r\n return this.id;\r\n}\r\n\r\nCollection.prototype.on = function(event,listener) {\r\n if(!this.listeners) this.listeners = {};\r\n if(!this.listeners[event]) this.listeners[event] = [];\r\n this.listeners[event].push(listener);\r\n}\r\n\r\nCollection.prototype.off = function(event,listener) {\r\n if(!this.listeners) return;\r\n if(!this.listeners[event]) return;\r\n var idx = this.listeners[event].indexOf(listener);\r\n if(idx!==-1) this.listeners[event].splice(idx,1);\r\n}\r\n\r\nCollection.prototype.notify = async function(event,args) {\r\n if(!this.listeners) return;\r\n if(!this.listeners[event]) return;\r\n \r\n var l = this.listeners[event].slice(); //clone in case listeners array is modified in the callbacks\r\n for(var i = 0; i < l.length; i++) {\r\n await l[i](args);\r\n } \r\n}\r\n\r\nCollection.prototype.set = function(src) {\r\n var length,i;\r\n \r\n if(src === this) return;\r\n \r\n function keyIndex(a) {\r\n var keys = {};\r\n var length = a.length;\r\n for(var i = 0; i < length; i++) { \r\n var item = a[i]; \r\n keys[item.getId()] = item;\r\n }\r\n return keys;\r\n }\r\n \r\n // Src can be a collection, or an array\r\n var src = Collection.instanceOf(src)?src.items:src;\r\n var bItems = [];\r\n length = src.length;\r\n for(i = 0; i < length; i++) {\r\n var item = src[i];\r\n if(Model.instanceOf(item))\r\n bItems.push(item);\r\n else\r\n bItems.push(Model.create(item));\r\n }\r\n \r\n var aItems = this.items; \r\n var aKeys = keyIndex(aItems);\r\n var bKeys = keyIndex(bItems);\r\n \r\n // First remove all items not in the new collection\r\n length = aItems.length;\r\n for(i = 0; i < length; i++) {\r\n if(!bKeys.hasOwnProperty(aItems[i].getId())) {\r\n // This item is not present in new collection, remove it\r\n this.removeAtIndex(i);\r\n i--;\r\n length--;\r\n }\r\n }\r\n \r\n // Reorder items\r\n for(i = 0; i < Math.min(aItems.length,bItems.length); i++) {\r\n if(aItems[i] !== bItems[i]) {\r\n if(aKeys.hasOwnProperty(bItems[i].getId())) { \r\n // The bItem exist in the collection but is in the wrong place\r\n this.remove(bItems[i]);\r\n }\r\n\r\n // This is a new item, add it at correct index\r\n this.addAtIndex(bItems[i],i);\r\n } \r\n }\r\n \r\n // Add remaining items\r\n for(i = aItems.length; i < bItems.length; i++) {\r\n this.add(bItems[i]);\r\n }\r\n \r\n}\r\n\r\nCollection.prototype.contains = function(item) {\r\n return this.items.indexOf(item)!==-1;\r\n}\r\n\r\nCollection.prototype.add = async function(item) {\r\n if(this.contains(item)) return; // Already contains item\r\n \r\n this.items.push(item);\r\n await this.notify('add',{item:item,index:this.items.length-1});\r\n await this.notify('change');\r\n await item.notify('add',{collection:this});\r\n}\r\n\r\nCollection.prototype.addAtIndex = async function(item,index) {\r\n if(this.contains(item)) return; // Already contains item\r\n\r\n this.items.splice(index,0,item);\r\n await this.notify('add',{item:item,index:index});\r\n await this.notify('change');\r\n await item.notify('add',{collection:this,index:index});\r\n}\r\n\r\nCollection.prototype.removeAtIndex = async function(idx) {\r\n var item = this.items[idx];\r\n this.items.splice(idx,1);\r\n await this.notify('remove',{item:item,index:idx});\r\n await this.notify('change');\r\n await item.notify('remove',{collection:this}); \r\n}\r\n\r\nCollection.prototype.remove = function(item) {\r\n var idx = this.items.indexOf(item);\r\n if(idx !== -1) this.removeAtIndex(idx);\r\n}\r\n\r\nCollection.prototype.size = function() {\r\n return this.items.length;\r\n}\r\n\r\nCollection.prototype.get = function(index) {\r\n return this.items[index];\r\n}\r\n\r\nCollection.prototype.each = function(callback) {\r\n for(var i = 0; i < this.items.length; i++) {\r\n callback(this.items[i],i);\r\n }\r\n}\r\n\r\nCollection.prototype.forEach = Collection.prototype.each;\r\n\r\nCollection.prototype.map = function(fn) {\r\n return this.items.map(fn);\r\n}\r\n\r\nCollection.prototype.filter = function(fn) {\r\n return this.items.filter(fn);\r\n}\r\n\r\nCollection.prototype.find = function(predicate, thisArg) {\r\n return this.items.find(predicate, thisArg);\r\n}\r\n\r\nCollection.prototype.findIndex = function(predicate, thisArg) {\r\n return this.items.findIndex(predicate, thisArg);\r\n} \r\n\r\nCollection.prototype.toJSON = function() {\r\n return this.map(function(m) {\r\n return m.toJSON()\r\n })\r\n}*/\r\n\r\n// ----\r\nObject.defineProperty(Array.prototype, 'items', {\r\n enumerable: false,\r\n get() {\r\n return this;\r\n },\r\n set(data) {\r\n this.set(data);\r\n }\r\n});\r\nObject.defineProperty(Array.prototype, 'each', {\r\n enumerable: false,\r\n writable: false,\r\n value: Array.prototype.forEach\r\n});\r\nObject.defineProperty(Array.prototype, 'size', {\r\n enumerable: false,\r\n writable: false,\r\n value: function () {\r\n return this.length;\r\n }\r\n});\r\nObject.defineProperty(Array.prototype, 'get', {\r\n enumerable: false,\r\n writable: false,\r\n value: function (index) {\r\n return this[index];\r\n }\r\n});\r\nObject.defineProperty(Array.prototype, 'getId', {\r\n enumerable: false,\r\n writable: false,\r\n value: function () {\r\n return this._id;\r\n }\r\n});\r\nObject.defineProperty(Array.prototype, 'id', {\r\n enumerable: false,\r\n get() {\r\n return this.getId();\r\n }\r\n});\r\nObject.defineProperty(Array.prototype, 'set', {\r\n enumerable: false,\r\n writable: false,\r\n value: function (src) {\r\n var length, i;\r\n\r\n if (src === this) return;\r\n\r\n src = src || []; //handle if src is undefined\r\n\r\n function keyIndex(a) {\r\n var keys = {};\r\n var length = a.length;\r\n for (var i = 0; i < length; i++) {\r\n var item = a[i];\r\n keys[item.getId()] = item;\r\n }\r\n return keys;\r\n }\r\n\r\n // Src can be a collection, or an array\r\n var bItems = [];\r\n length = src.length;\r\n for (i = 0; i < length; i++) {\r\n var item = src[i];\r\n if (Model.instanceOf(item)) bItems.push(item);\r\n else bItems.push(Model.create(item));\r\n }\r\n\r\n var aItems = this.items;\r\n var aKeys = keyIndex(aItems);\r\n var bKeys = keyIndex(bItems);\r\n\r\n // First remove all items not in the new collection\r\n length = aItems.length;\r\n for (i = 0; i < length; i++) {\r\n if (!bKeys.hasOwnProperty(aItems[i].getId())) {\r\n // This item is not present in new collection, remove it\r\n this.removeAtIndex(i);\r\n i--;\r\n length--;\r\n }\r\n }\r\n\r\n // Reorder items\r\n for (i = 0; i < Math.min(aItems.length, bItems.length); i++) {\r\n if (aItems[i] !== bItems[i]) {\r\n if (aKeys.hasOwnProperty(bItems[i].getId())) {\r\n // The bItem exist in the collection but is in the wrong place\r\n this.remove(bItems[i]);\r\n }\r\n\r\n // This is a new item, add it at correct index\r\n this.addAtIndex(bItems[i], i);\r\n }\r\n }\r\n\r\n // Add remaining items\r\n for (i = aItems.length; i < bItems.length; i++) {\r\n this.add(bItems[i]);\r\n }\r\n }\r\n});\r\n\r\nObject.defineProperty(Array.prototype, 'notify', {\r\n enumerable: false,\r\n writable: false,\r\n value: async function (event, args) {\r\n if (!this._listeners) return;\r\n if (!this._listeners[event]) return;\r\n\r\n var l = this._listeners[event].slice(); //clone in case listeners array is modified in the callbacks\r\n for (var i = 0; i < l.length; i++) {\r\n await l[i](args);\r\n }\r\n }\r\n});\r\n\r\nObject.defineProperty(Array.prototype, 'contains', {\r\n enumerable: false,\r\n writable: false,\r\n value: function (item) {\r\n return this.indexOf(item) !== -1;\r\n }\r\n});\r\n\r\nObject.defineProperty(Array.prototype, 'add', {\r\n enumerable: false,\r\n writable: false,\r\n value: async function (item) {\r\n if (this.contains(item)) return; // Already contains item\r\n\r\n this.items.push(item);\r\n await this.notify('add', { item: item, index: this.items.length - 1 });\r\n await this.notify('change');\r\n await item.notify('add', { collection: this });\r\n }\r\n});\r\n\r\nObject.defineProperty(Array.prototype, 'remove', {\r\n enumerable: false,\r\n writable: false,\r\n value: function (item) {\r\n var idx = this.items.indexOf(item);\r\n if (idx !== -1) this.removeAtIndex(idx);\r\n }\r\n});\r\n\r\nObject.defineProperty(Array.prototype, 'addAtIndex', {\r\n enumerable: false,\r\n writable: false,\r\n value: async function (item, index) {\r\n if (this.contains(item)) return; // Already contains item\r\n\r\n this.items.splice(index, 0, item);\r\n await this.notify('add', { item: item, index: index });\r\n await this.notify('change');\r\n await item.notify('add', { collection: this, index: index });\r\n }\r\n});\r\n\r\nObject.defineProperty(Array.prototype, 'removeAtIndex', {\r\n enumerable: false,\r\n writable: false,\r\n value: async function (idx) {\r\n var item = this.items[idx];\r\n this.items.splice(idx, 1);\r\n await this.notify('remove', { item: item, index: idx });\r\n await this.notify('change');\r\n await item.notify('remove', { collection: this });\r\n }\r\n});\r\n\r\nObject.defineProperty(Array.prototype, 'on', {\r\n enumerable: false,\r\n writable: false,\r\n value: function (event, listener) {\r\n if (!this._listeners)\r\n Object.defineProperty(this, '_listeners', {\r\n enumerable: false,\r\n writable: false,\r\n value: {}\r\n });\r\n if (!this._listeners[event]) this._listeners[event] = [];\r\n this._listeners[event].push(listener);\r\n }\r\n});\r\n\r\nObject.defineProperty(Array.prototype, 'off', {\r\n enumerable: false,\r\n writable: false,\r\n value: function (event, listener) {\r\n if (!this._listeners) return;\r\n if (!this._listeners[event]) return;\r\n var idx = this._listeners[event].indexOf(listener);\r\n if (idx !== -1) this._listeners[event].splice(idx, 1);\r\n }\r\n});\r\n\r\nclass Collection extends Array {}\r\n\r\nconst collections = (Collection._collections = {});\r\n\r\nCollection.create = function (items) {\r\n const name = Model.guid();\r\n collections[name] = new Collection();\r\n Object.defineProperty(collections[name], '_id', {\r\n enumerable: false,\r\n writable: false,\r\n value: name\r\n });\r\n if (items) {\r\n collections[name].set(items);\r\n }\r\n return collections[name];\r\n};\r\n\r\n/**\r\n * @param {string} name\r\n * @returns {Collection}\r\n */\r\nCollection.get = function (name) {\r\n if (name === undefined) name = Model.guid();\r\n if (!collections[name]) {\r\n collections[name] = new Collection();\r\n Object.defineProperty(collections[name], '_id', {\r\n enumerable: false,\r\n writable: false,\r\n value: name\r\n });\r\n }\r\n\r\n return collections[name];\r\n};\r\n\r\nCollection.instanceOf = function (collection) {\r\n return collection instanceof Collection;\r\n};\r\n\r\nCollection.exists = function (name) {\r\n return collections[name] !== undefined;\r\n};\r\n\r\nmodule.exports = Collection;\r\n","\"use strict\";\r\n\r\nfunction createSetter(args) {\r\n\r\n var currentValue = false;\r\n\r\n return function(value) {\r\n value = value ? true : false;\r\n //value changed from false to true\r\n if(value && currentValue === false) {\r\n args.valueChangedToTrue.call(this);\r\n }\r\n currentValue = value;\r\n };\r\n}\r\n\r\nmodule.exports = {\r\n createSetter: createSetter\r\n};","//used to optimize warnings so we're not sending unneccessary warnings.\r\n//Improves editor performance, especially in larger projects\r\n\r\nclass ActiveWarnings {\r\n constructor() {\r\n this.currentWarnings = new Map();\r\n }\r\n\r\n setWarning(nodeId, key, warning) {\r\n //Check if we've already sent this warning\r\n if (this.currentWarnings.has(nodeId)) {\r\n //we have sent warnings to this node before, check if we've sent this particular one before\r\n const warningKeys = this.currentWarnings.get(nodeId);\r\n if (warningKeys[key] === warning) {\r\n //we've already sent this warning, no need to send it again\r\n return false;\r\n }\r\n\r\n //new warning, remember that we sent it\r\n warningKeys[key] = warning;\r\n return true;\r\n } else {\r\n //new warning, we havent sent any warnings to this node before\r\n //Remember that we sent it\r\n this.currentWarnings.set(nodeId, { [key]: warning });\r\n return true;\r\n }\r\n }\r\n\r\n clearWarning(nodeId, key) {\r\n const warningKeys = this.currentWarnings.get(nodeId);\r\n\r\n if (!warningKeys || !warningKeys[key]) {\r\n //There are no warnings that we've sent on this node.\r\n //Save some performance by not sending an uneccesary message to the editor\r\n return false;\r\n }\r\n\r\n delete warningKeys[key];\r\n if (Object.keys(warningKeys).length === 0) {\r\n delete this.currentWarnings.delete(nodeId);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n clearWarnings(nodeId) {\r\n if (this.currentWarnings.has(nodeId) === false) {\r\n //no warnings on this node, save some performance by not sending a message to the editor\r\n return false;\r\n }\r\n\r\n //no warnings for this node anymore\r\n this.currentWarnings.delete(nodeId);\r\n return true;\r\n }\r\n}\r\n\r\nmodule.exports = ActiveWarnings;\r\n","'use strict';\r\n\r\nvar EventSender = require('./eventsender'),\r\n Services = require('./services/services'),\r\n guid = require('./guid');\r\n\r\nconst ActiveWarnings = require('./editorconnection.activewarnings');\r\nfunction EditorConnection(opts) {\r\n var _opts = opts || {};\r\n\r\n EventSender.call(this);\r\n\r\n this.runtimeType = _opts.runtimeType;\r\n this.platform = _opts.platform;\r\n this.ws =\r\n (_opts.platform && _opts.platform.webSocketClass) || (typeof WebSocket !== 'undefined' ? WebSocket : undefined);\r\n this.wsOptions = (_opts.platform && _opts.platform.webSocketOptions) || undefined;\r\n this.reconnectOnClose = true;\r\n this.enableDebugger = false;\r\n\r\n this.lastSendTimestamp = 0;\r\n this.sendQueue = [];\r\n this.sendTimer = undefined;\r\n\r\n //used to optimize warnings so we're not sending unneccessary warnings.\r\n //Clan slow down the editor in large projects\r\n this.activeWarnings = new ActiveWarnings();\r\n}\r\n\r\nEditorConnection.prototype = Object.create(EventSender.prototype);\r\nEditorConnection.prototype.constructor = EditorConnection;\r\n\r\nEditorConnection.prototype.isRunningLocally = function () {\r\n var runningLocallyInBrowser =\r\n (this.platform.isRunningLocally && this.platform.isRunningLocally()) ||\r\n (typeof document !== 'undefined' &&\r\n (document.location.hostname === 'localhost' || document.location.hostname === '127.0.0.1'));\r\n return runningLocallyInBrowser;\r\n};\r\n\r\nEditorConnection.prototype.connect = function (address) {\r\n this.socket = this.wsOptions ? new this.ws(address, this.wsOptions) : new this.ws(address);\r\n\r\n var self = this;\r\n\r\n this.socket.addEventListener('open', function () {\r\n self.clientId = guid();\r\n self.socket.send(\r\n JSON.stringify({\r\n cmd: 'register',\r\n type: 'viewer',\r\n clientId: self.clientId\r\n })\r\n );\r\n self.emit('connected');\r\n });\r\n\r\n this.socket.addEventListener('close', function (event) {\r\n if (self.reconnectOnClose) {\r\n self.reconnect(address);\r\n }\r\n console.log('Editor connection closed', event.code, event.reason);\r\n self.emit('connectionClosed');\r\n });\r\n\r\n this.socket.addEventListener('error', function (evt) {\r\n console.log('Editor connection error, trying to reconnect');\r\n });\r\n\r\n this.socket.addEventListener('message', async (e) => {\r\n // NOTE: When the data is too big it seems to change from string to a blob\r\n const text = typeof e.data === 'string' ? e.data : await e.data.text();\r\n const message = JSON.parse(text);\r\n\r\n let content;\r\n\r\n if (message.cmd === 'registered') {\r\n //ignore\r\n } else if (message.cmd === 'export') {\r\n content = JSON.parse(message.content);\r\n if (message.type === 'full' && message.target === this.clientId) {\r\n self.emit('exportDataFull', content);\r\n }\r\n } else if (message.cmd === 'hoverStart') {\r\n self.emit('hoverStart', message.content.id);\r\n } else if (message.cmd === 'hoverEnd') {\r\n self.emit('hoverEnd', message.content.id);\r\n } else if (message.cmd === 'refresh') {\r\n self.emit('reload');\r\n } else if (message.cmd === 'debugInspectors') {\r\n if (this.debugInspectorsEnabled) {\r\n content = JSON.parse(message.content);\r\n self.emit('debugInspectorsUpdated', content.inspectors);\r\n }\r\n } else if (message.cmd === 'debuggingEnabled') {\r\n if (self.isRunningLocally()) {\r\n content = JSON.parse(message.content);\r\n self.emit('debuggingEnabledChanged', content.enabled);\r\n }\r\n } else if (message.cmd === 'getConnectionValue') {\r\n if (self.isRunningLocally()) {\r\n content = JSON.parse(message.content);\r\n await self.emit('getConnectionValue', { clientId: content.clientId, connectionId: content.connectionId });\r\n }\r\n } else if (message.cmd === 'modelUpdate') {\r\n await self.emit('modelUpdate', message.content);\r\n } else if (message.cmd === 'publish') {\r\n Services.pubsub.routeMessage(message); // Publish a message from the pubsub service\r\n } else if (message.cmd === 'noodlModules') {\r\n self.emit('noodlModules', JSON.parse(message.content));\r\n } else if (message.cmd === 'mqttUpdate') {\r\n self.emit('mqttUpdate', message.content);\r\n } else if (message.cmd === 'activeComponentChanged') {\r\n self.emit('activeComponentChanged', message.component);\r\n } else {\r\n console.log('Command not implemented', message);\r\n }\r\n });\r\n};\r\n\r\nEditorConnection.prototype.reconnect = function (address) {\r\n var self = this;\r\n\r\n setTimeout(function () {\r\n self.connect(address);\r\n }, 2000);\r\n};\r\n\r\nEditorConnection.prototype.isConnected = function () {\r\n return this.socket !== undefined && this.socket.readyState === this.ws.OPEN;\r\n};\r\n\r\n//JSON replacer to make cyclic objects non-cyclic.\r\n//Using this example: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value#examples\r\nconst getCircularReplacer = () => {\r\n const seen = new WeakSet();\r\n return (key, value) => {\r\n if (typeof value === 'object' && value !== null) {\r\n if (seen.has(value)) {\r\n return '[Circular]';\r\n }\r\n seen.add(value);\r\n }\r\n return value;\r\n };\r\n};\r\n\r\nEditorConnection.prototype.send = function (data) {\r\n const now = this.platform.getCurrentTime();\r\n const dt = now - this.lastSendTimestamp;\r\n\r\n //Send objects as json and capture exceptions\r\n const trySend = (msg) => {\r\n try {\r\n this.socket.send(JSON.stringify(msg));\r\n } catch (e) {\r\n if (e.message && e.message.startsWith('Converting circular')) {\r\n //the object is circular, try to address it\r\n try {\r\n this.socket.send(JSON.stringify(msg, getCircularReplacer()));\r\n } catch (e) {\r\n //still failed, give up\r\n console.log('failed to send message to editor', msg, e);\r\n }\r\n } else {\r\n //message couldn't be serialized to json\r\n console.log('failed to send message to editor', msg, e);\r\n }\r\n }\r\n };\r\n\r\n //batch messages so they're only sent at most every 200ms\r\n //note that the first message will always be sent immediately, and the ones for 200ms after\r\n //that one will be queued. So initial message response time is as low as possible (for hover etc)\r\n if (dt < 200 || this.sendTimer || !this.isConnected()) {\r\n this.sendQueue.push(data);\r\n if (!this.sendTimer) {\r\n this.sendTimer = setTimeout(() => {\r\n if (this.isConnected() === false) {\r\n return;\r\n }\r\n\r\n //send messages in chunks. If we send too many at once the editor UI can freeze for a while\r\n //since it's handling these in the renderer process\r\n const chunkSize = 50;\r\n for (let i = 0; i < this.sendQueue.length; i += chunkSize) {\r\n const chunk = this.sendQueue.slice(i, i + chunkSize);\r\n trySend(chunk);\r\n }\r\n\r\n this.sendQueue = [];\r\n this.sendTimer = undefined;\r\n this.lastSendTimestamp = this.platform.getCurrentTime();\r\n }, 100);\r\n }\r\n } else {\r\n this.lastSendTimestamp = now;\r\n trySend(data);\r\n }\r\n};\r\n\r\nEditorConnection.prototype.sendInspectId = function (id) {\r\n this.send({\r\n cmd: 'select',\r\n type: 'viewer',\r\n content: JSON.stringify({ id: id })\r\n });\r\n};\r\n\r\nEditorConnection.prototype.sendSelectComponent = function (componentName) {\r\n this.send({\r\n cmd: 'select',\r\n type: 'viewer',\r\n content: JSON.stringify({ componentName })\r\n });\r\n};\r\n\r\nEditorConnection.prototype.sendPulsingConnections = function (connectionMap) {\r\n var connectionsToPulse = [];\r\n Object.keys(connectionMap).forEach(function (c) {\r\n var connection = connectionMap[c];\r\n connectionsToPulse = connectionsToPulse.concat(connection.connections);\r\n });\r\n\r\n this.send({\r\n cmd: 'connectiondebugpulse',\r\n type: 'viewer',\r\n content: JSON.stringify({\r\n connectionsToPulse: connectionsToPulse\r\n })\r\n });\r\n};\r\n\r\nEditorConnection.prototype.sendDebugInspectorValues = function (inspectors) {\r\n this.send({\r\n cmd: 'debuginspectorvalues',\r\n type: 'viewer',\r\n content: { inspectors }\r\n });\r\n};\r\n\r\nEditorConnection.prototype.sendConnectionValue = function (connectionId, value) {\r\n this.send({\r\n cmd: 'connectionValue',\r\n type: 'viewer',\r\n content: { connectionId, value }\r\n });\r\n};\r\n\r\nconst dynamicPortsHash = {};\r\n\r\nfunction _detectRename(before, after) {\r\n if (!before || !after) return;\r\n\r\n if (before.length !== after.length) return; // Must be of same length\r\n\r\n var res = {};\r\n for (var i = 0; i < before.length; i++) {\r\n if (after.indexOf(before[i]) === -1) {\r\n if (res.before) return; // Can only be one from before that is missing\r\n res.before = before[i];\r\n }\r\n\r\n if (before.indexOf(after[i]) === -1) {\r\n if (res.after) return; // Only one can be missing,otherwise we cannot match\r\n res.after = after[i];\r\n }\r\n }\r\n\r\n return res.before && res.after ? res : undefined;\r\n}\r\n\r\nEditorConnection.prototype.sendDynamicPorts = function (id, ports, options) {\r\n var hash = JSON.stringify(ports);\r\n if (dynamicPortsHash[id] === hash) {\r\n // Make sure we don't resend the same port data\r\n return;\r\n }\r\n\r\n if (dynamicPortsHash[id] && ports && options && options.detectRenamed) {\r\n var detectRenamed = Array.isArray(options.detectRenamed) ? options.detectRenamed : [options.detectRenamed];\r\n\r\n var renamed = [];\r\n detectRenamed.forEach((d) => {\r\n var before = JSON.parse(dynamicPortsHash[id]),\r\n after = [].concat(ports);\r\n\r\n // Filter ports with correct prefix and plug\r\n if (d.prefix) {\r\n before = before.filter((p) => p.name.startsWith(d.prefix));\r\n after = after.filter((p) => p.name.startsWith(d.prefix));\r\n }\r\n\r\n if (d.plug) {\r\n before = before.filter((p) => p.plug === d.plug);\r\n after = after.filter((p) => p.plug === d.plug);\r\n }\r\n\r\n // Remove the prefix\r\n after = after.map((p) => p.name.substring((d.prefix || '').length));\r\n before = before.map((p) => p.name.substring((d.prefix || '').length));\r\n\r\n // Find the one that is renamed (if any)\r\n var res = _detectRename(before, after);\r\n if (res) {\r\n renamed.push({\r\n plug: d.plug,\r\n patterns: [(d.prefix || '') + '{{*}}'],\r\n before: res.before,\r\n after: res.after\r\n });\r\n }\r\n });\r\n if (renamed.length > 0) options.renamed = renamed;\r\n\r\n delete options.detectRenamed;\r\n }\r\n\r\n dynamicPortsHash[id] = hash;\r\n\r\n this.send({\r\n cmd: 'instanceports',\r\n type: 'viewer',\r\n content: JSON.stringify({\r\n nodeid: id,\r\n ports: ports,\r\n options: options\r\n })\r\n });\r\n};\r\n\r\nEditorConnection.prototype.sendWarning = function (componentName, nodeId, key, warning) {\r\n const isNewWarning = this.activeWarnings.setWarning(nodeId, key, warning);\r\n\r\n if (isNewWarning) {\r\n this.send({\r\n cmd: 'showwarning',\r\n type: 'viewer',\r\n content: JSON.stringify({\r\n componentName: componentName,\r\n nodeId: nodeId,\r\n key: key,\r\n warning: warning\r\n })\r\n });\r\n }\r\n};\r\n\r\nEditorConnection.prototype.clearWarning = function (componentName, nodeId, key) {\r\n const hasWarning = this.activeWarnings.clearWarning(nodeId, key);\r\n\r\n if (hasWarning) {\r\n this.send({\r\n cmd: 'showwarning',\r\n type: 'viewer',\r\n content: JSON.stringify({\r\n componentName: componentName,\r\n nodeId: nodeId,\r\n key: key,\r\n warning: undefined\r\n })\r\n });\r\n }\r\n};\r\n\r\nEditorConnection.prototype.clearWarnings = function (componentName, nodeId) {\r\n const hasWarnings = this.activeWarnings.clearWarnings(nodeId);\r\n\r\n if (hasWarnings) {\r\n this.send({\r\n cmd: 'clearwarnings',\r\n type: 'viewer',\r\n content: JSON.stringify({\r\n componentName: componentName,\r\n nodeId: nodeId\r\n })\r\n });\r\n }\r\n};\r\n\r\nEditorConnection.prototype.sendPatches = function (patches) {\r\n this.send({\r\n cmd: 'patchproject',\r\n type: 'viewer',\r\n content: JSON.stringify(patches)\r\n });\r\n};\r\n\r\nEditorConnection.prototype.requestFullExport = function () {\r\n this.send({\r\n cmd: 'register',\r\n type: 'viewer'\r\n });\r\n};\r\n\r\nEditorConnection.prototype.requestNoodlModules = function () {\r\n this.send({\r\n cmd: 'getNoodlModules',\r\n type: 'viewer'\r\n });\r\n};\r\n\r\nvar serviceRequests = {};\r\nEditorConnection.prototype.sendServiceRequest = function (request, callback) {\r\n request.token = guid();\r\n request.clientId = this.clientId;\r\n serviceRequests[request.token] = callback;\r\n this.send(request);\r\n};\r\n\r\nEditorConnection.prototype.close = function () {\r\n this.reconnectOnClose = false;\r\n\r\n if (this.isConnected() === false) {\r\n return;\r\n }\r\n\r\n this.socket.close();\r\n};\r\n\r\nEditorConnection.prototype.sendNodeLibrary = function (nodelibrary) {\r\n this.send({\r\n cmd: 'nodelibrary',\r\n type: 'viewer',\r\n runtimeType: this.runtimeType,\r\n content: nodelibrary,\r\n clientId: this.clientId\r\n });\r\n};\r\n\r\nEditorConnection.prototype.sendComponentMetadata = function (componentName, key, data) {\r\n this.send({\r\n cmd: 'componentMetadata',\r\n type: 'viewer',\r\n content: JSON.stringify({\r\n componentName,\r\n key,\r\n data\r\n })\r\n });\r\n};\r\n\r\nEditorConnection.prototype.sendProjectMetadata = function (key, data) {\r\n this.send({\r\n cmd: 'projectMetadata',\r\n type: 'viewer',\r\n content: JSON.stringify({\r\n key,\r\n data\r\n })\r\n });\r\n};\r\n\r\nmodule.exports = EditorConnection;\r\n","\"use strict\";\r\n\r\nfunction difference(array1, array2) {\r\n const valueSet = new Set(array2);\r\n return array1.filter(e => !valueSet.has(e));\r\n}\r\n\r\nasync function handleEvent(context, graphModel, event) {\r\n\r\n function applyPortDelta(nodeModel, newPorts) {\r\n var inputPorts = {};\r\n var outputPorts = {};\r\n\r\n newPorts.forEach(function(port) {\r\n //some ports are incorrectly named outputs instead of output, patch it here so\r\n //the rest of the code doesn't need to care\r\n if(port && port.plug === \"outputs\") {\r\n port.plug = \"output\";\r\n }\r\n\r\n if(port.plug === 'input' || port.plug === 'input/output') {\r\n inputPorts[port.name] = port;\r\n }\r\n if(port.plug === 'output' || port.plug === 'input/output') {\r\n outputPorts[port.name] = port;\r\n }\r\n });\r\n\r\n var existingInputs = Object.keys(nodeModel.getInputPorts());\r\n\r\n var inputPortsToRemove = difference(existingInputs, Object.keys(inputPorts));\r\n var inputPortsToAdd = difference(Object.keys(inputPorts), existingInputs);\r\n \r\n // Update port types if it has changed\r\n nodeModel.updateInputPortTypes(inputPorts);\r\n\r\n // Remove and add input ports\r\n inputPortsToRemove.forEach(nodeModel.removeInputPortWithName.bind(nodeModel));\r\n inputPortsToAdd.forEach(function(portName) {\r\n nodeModel.addInputPort(inputPorts[portName]);\r\n if(nodeModel.parameters && nodeModel.parameters.hasOwnProperty(portName)) {\r\n setInputValueOnNodeInstancesWithModel(context.rootComponent.nodeScope, nodeModel, portName, nodeModel.parameters[portName]);\r\n }\r\n });\r\n\r\n // Update port types if it has changed\r\n nodeModel.updateOutputPortTypes(outputPorts);\r\n\r\n // Remove and add output ports\r\n var existingOutputs = Object.keys(nodeModel.getOutputPorts());\r\n\r\n var outputPortsToRemove = difference(existingOutputs, Object.keys(outputPorts));\r\n var outputPortsToAdd = difference(Object.keys(outputPorts), existingOutputs);\r\n\r\n outputPortsToRemove.forEach(nodeModel.removeOutputPortWithName.bind(nodeModel));\r\n outputPortsToAdd.forEach(function(portName) {\r\n nodeModel.addOutputPort(outputPorts[portName]);\r\n });\r\n }\r\n\r\n function setInputValueOnNodeInstancesWithModel(nodeScope, nodeModel, port, value) {\r\n var nodes = nodeScope.getNodesWithIdRecursive(nodeModel.id);\r\n nodes.forEach(function(node) {\r\n node.queueInput(port, value);\r\n });\r\n }\r\n\r\n var componentModel;\r\n if(event.componentName) {\r\n componentModel = graphModel.getComponentWithName(event.componentName);\r\n if(!componentModel) {\r\n //if we haven't received this component yet, just ignore the delta update\r\n return;\r\n }\r\n }\r\n\r\n //some ports are incorrectly named outputs instead of output, patch it here so\r\n //the rest of the code doesn't need to care\r\n if(event.port && event.port.plug === \"outputs\") {\r\n event.port.plug = \"output\";\r\n }\r\n\r\n var eventHandlers = {\r\n nodeAdded: function(event) {\r\n componentModel.importEditorNodeData(event.model, event.parentId, event.childIndex);\r\n },\r\n nodeRemoved: async function(event) {\r\n if(componentModel.hasNodeWithId(event.model.id)) {\r\n await componentModel.removeNodeWithId(event.model.id);\r\n }\r\n },\r\n connectionAdded: function(event) {\r\n componentModel.addConnection(event.model);\r\n },\r\n connectionRemoved: function(event) {\r\n componentModel.removeConnection(event.model);\r\n\r\n //revert to default value or parameter if this was the last connection to that port\r\n var targetNodeModel = componentModel.getNodeWithId(event.model.targetId);\r\n if(componentModel.getConnectionsToPort(targetNodeModel.id, event.model.targetId).length === 0) {\r\n var value = targetNodeModel.parameters[event.model.targetPort];\r\n if(value === undefined) {\r\n value = context.getDefaultValueForInput(targetNodeModel.type, event.model.targetPort);\r\n }\r\n\r\n setInputValueOnNodeInstancesWithModel(context.rootComponent.nodeScope, targetNodeModel, event.model.targetPort, value);\r\n }\r\n\r\n },\r\n parameterChanged: function(event) {\r\n\r\n const nodeModel = componentModel.getNodeWithId(event.nodeId);\r\n if(nodeModel === undefined) {\r\n console.log(\"parameterChanged: Unknown node id\",event);\r\n return;\r\n }\r\n\r\n //did we get a bunch of parameters at once?\r\n if(event.parameters) {\r\n //note: some props might be deleted, then they only exist in oldParameters\r\n const allParams = new Set(Object.keys(event.parameters).concat(Object.keys(event.oldParameters)));\r\n for(const param of allParams) {\r\n nodeModel.setParameter(param, event.parameters[param]);\r\n }\r\n }\r\n \r\n //did we get a single parameters?\r\n if(event.parameterName) {\r\n nodeModel.setParameter(event.parameterName, event.parameterValue, event.state);\r\n }\r\n },\r\n nodeAttached: function(event) {\r\n componentModel.setNodeParent(componentModel.getNodeWithId(event.nodeId), componentModel.getNodeWithId(event.parentId), event.childIndex);\r\n },\r\n nodeDetached: function(event) {\r\n componentModel.setNodeParent(componentModel.getNodeWithId(event.nodeId), null);\r\n componentModel.addRootId(event.nodeId);\r\n },\r\n componentAdded: function(event) {\r\n graphModel.importComponentFromEditorData(event.model);\r\n },\r\n componentRemoved: async function(event) {\r\n await graphModel.removeComponentWithName(event.componentName);\r\n },\r\n rootAdded: function(event) {\r\n componentModel.addRootId(event.nodeId);\r\n },\r\n portAdded: function(event) {\r\n var nodeModel = componentModel.getNodeWithId(event.nodeId);\r\n if(event.port.plug === \"input\" || event.port.plug === \"input/output\") {\r\n nodeModel.addInputPort(event.port);\r\n\r\n //if node already has an old value for this port, set that value on all instances of the node\r\n //example: expression a+b, a=1, b=2. User removes b and then adds it again, the value 2 should be restored since it's still in the model\r\n if(nodeModel.parameters.hasOwnProperty(event.port)) {\r\n setInputValueOnNodeInstancesWithModel(context.rootComponent.nodeScope, nodeModel, event.port, nodeModel.parameters[event.port]);\r\n }\r\n }\r\n if(event.port.plug === \"output\" || event.port.plug === \"input/output\") {\r\n nodeModel.addOutputPort(event.port);\r\n }\r\n },\r\n portRemoved: function(event) {\r\n var nodeModel = componentModel.getNodeWithId(event.nodeId);\r\n if(event.port.plug === \"input\" || event.port.plug === \"input/output\") {\r\n nodeModel.removeInputPortWithName(event.port.name);\r\n }\r\n if(event.port.plug === \"output\" || event.port.plug === \"input/output\") {\r\n nodeModel.removeOutputPortWithName(event.port.name);\r\n }\r\n },\r\n nodePortRenamed: function(event) {\r\n if(event.port.plug === \"input\" || event.port.plug === \"input/output\") {\r\n componentModel.renameInputPortOnNodeWithId(event.nodeId, event.oldName, event.port.name);\r\n }\r\n if(event.port.plug === \"output\" || event.port.plug === \"input/output\") {\r\n componentModel.renameOutputPortOnNodeWithId(event.nodeId, event.oldName, event.port.name);\r\n }\r\n var node = componentModel.getNodeWithId(event.nodeId);\r\n if(node.type === \"Component Inputs\") {\r\n componentModel.addInputPort(event.port);\r\n graphModel.getNodesWithType(componentModel.name).forEach(function(componentInstance) {\r\n componentInstance.component.renameInputPortOnNodeWithId(componentInstance.id, event.oldName, event.port.name);\r\n });\r\n componentModel.removeInputPortWithName(event.oldName);\r\n }\r\n else if(node.type === \"Component Outputs\") {\r\n componentModel.addOutputPort(event.port);\r\n graphModel.getNodesWithType(componentModel.name).forEach(function(componentInstance) {\r\n componentInstance.component.renameOutputPortOnNodeWithId(componentInstance.id, event.oldName, event.port.name);\r\n });\r\n componentModel.removeOutputPortWithName(event.oldName);\r\n }\r\n },\r\n componentPortsUpdated: function(event) {\r\n applyPortDelta(componentModel, event.ports);\r\n },\r\n instancePortsChanged: function(event) {\r\n if(!componentModel.hasNodeWithId(event.nodeId)) return;\r\n var nodeModel = componentModel.getNodeWithId(event.nodeId);\r\n applyPortDelta(nodeModel, event.ports);\r\n },\r\n componentRenamed: function(event) {\r\n graphModel.renameComponent(event.oldName, event.newName);\r\n },\r\n settingsChanged: function(event) {\r\n graphModel.setSettings(event.settings);\r\n },\r\n metadataChanged: function(event) {\r\n graphModel.setMetaData(event.key,event.data);\r\n },\r\n componentMetadataChanged: function(event) {\r\n const c = graphModel.getComponentWithName(event.componentName);\r\n if(!c) return;\r\n c.setMetadata(event.key, event.data);\r\n },\r\n variantParametersChanged: function(event) {\r\n if(event.variant) {\r\n //we got the whole variant\r\n graphModel.updateVariant(event.variant);\r\n }\r\n else {\r\n //we got a specific value to update\r\n graphModel.updateVariantParameter(event.variantName, event.variantTypeName, event.parameterName, event.parameterValue, event.state);\r\n\r\n //check if value has been deleted from the variant\r\n if(event.parameterValue === undefined) {\r\n //all active nodes with this variant will have to revert back to the default value, if they don't have local overrides\r\n const variant = graphModel.getVariant(event.variantTypeName, event.variantName);\r\n const nodes = context.rootComponent.nodeScope.getAllNodesWithVariantRecursive(variant);\r\n nodes.forEach(node => {\r\n node.queueInput(event.parameterName, node.getParameter(event.parameterName));\r\n });\r\n }\r\n }\r\n },\r\n variantDeleted: function(event) {\r\n graphModel.deleteVariant(event.variantTypeName, event.variantName);\r\n },\r\n variantChanged: function(event) {\r\n const nodeModel = componentModel.getNodeWithId(event.nodeId);\r\n const variant = graphModel.getVariant(nodeModel.type, event.variantName);\r\n\r\n nodeModel.setVariant(variant);\r\n },\r\n variantRenamed: function(event) {\r\n const variant = graphModel.getVariant(event.variantTypeName, event.oldVariantName);\r\n if(variant) {\r\n variant.name = variant.variantName;\r\n }\r\n },\r\n defaultStateTransitionChanged: function(event) {\r\n const nodeModel = componentModel.getNodeWithId(event.nodeId);\r\n nodeModel.setDefaultStateTransition(event.curve, event.state);\r\n },\r\n stateTransitionsChanged: function(event) {\r\n const nodeModel = componentModel.getNodeWithId(event.nodeId);\r\n if(event.parameterName) {\r\n nodeModel.setStateTransitionParamter(event.parameterName, event.curve, event.state);\r\n } \r\n },\r\n variantDefaultStateTransitionChanged: function(event) {\r\n graphModel.updateVariantDefaultStateTransition(event.variantName, event.variantTypeName, event.curve, event.state);\r\n },\r\n variantStateTransitionsChanged: function(event) {\r\n graphModel.updateVariantStateTransition(event);\r\n },\r\n routerIndexChanged: function(event) {\r\n graphModel.routerIndex = event.data;\r\n }\r\n };\r\n\r\n if(eventHandlers.hasOwnProperty(event.type)) {\r\n await eventHandlers[event.type](event);\r\n context.scheduleUpdate();\r\n }\r\n else {\r\n console.log('Unknown event', event);\r\n }\r\n}\r\n\r\nmodule.exports = {\r\n handleEvent: handleEvent\r\n};\r\n","// Copyright Joyent, Inc. and other Node contributors.\r\n//\r\n// Permission is hereby granted, free of charge, to any person obtaining a\r\n// copy of this software and associated documentation files (the\r\n// \"Software\"), to deal in the Software without restriction, including\r\n// without limitation the rights to use, copy, modify, merge, publish,\r\n// distribute, sublicense, and/or sell copies of the Software, and to permit\r\n// persons to whom the Software is furnished to do so, subject to the\r\n// following conditions:\r\n//\r\n// The above copyright notice and this permission notice shall be included\r\n// in all copies or substantial portions of the Software.\r\n//\r\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\r\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\r\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\r\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\r\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n\r\n'use strict';\r\n\r\nvar R = typeof Reflect === 'object' ? Reflect : null\r\nvar ReflectApply = R && typeof R.apply === 'function'\r\n ? R.apply\r\n : function ReflectApply(target, receiver, args) {\r\n return Function.prototype.apply.call(target, receiver, args);\r\n }\r\n\r\nvar ReflectOwnKeys\r\nif (R && typeof R.ownKeys === 'function') {\r\n ReflectOwnKeys = R.ownKeys\r\n} else if (Object.getOwnPropertySymbols) {\r\n ReflectOwnKeys = function ReflectOwnKeys(target) {\r\n return Object.getOwnPropertyNames(target)\r\n .concat(Object.getOwnPropertySymbols(target));\r\n };\r\n} else {\r\n ReflectOwnKeys = function ReflectOwnKeys(target) {\r\n return Object.getOwnPropertyNames(target);\r\n };\r\n}\r\n\r\nfunction ProcessEmitWarning(warning) {\r\n if (console && console.warn) console.warn(warning);\r\n}\r\n\r\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\r\n return value !== value;\r\n}\r\n\r\nfunction EventEmitter() {\r\n EventEmitter.init.call(this);\r\n}\r\nmodule.exports = EventEmitter;\r\nmodule.exports.once = once;\r\n\r\n// Backwards-compat with node 0.10.x\r\nEventEmitter.EventEmitter = EventEmitter;\r\n\r\nEventEmitter.prototype._events = undefined;\r\nEventEmitter.prototype._eventsCount = 0;\r\nEventEmitter.prototype._maxListeners = undefined;\r\n\r\n// By default EventEmitters will print a warning if more than 10 listeners are\r\n// added to it. This is a useful default which helps finding memory leaks.\r\nvar defaultMaxListeners = 10;\r\n\r\nfunction checkListener(listener) {\r\n if (typeof listener !== 'function') {\r\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\r\n }\r\n}\r\n\r\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\r\n enumerable: true,\r\n get: function() {\r\n return defaultMaxListeners;\r\n },\r\n set: function(arg) {\r\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\r\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\r\n }\r\n defaultMaxListeners = arg;\r\n }\r\n});\r\n\r\nEventEmitter.init = function() {\r\n\r\n if (this._events === undefined ||\r\n this._events === Object.getPrototypeOf(this)._events) {\r\n this._events = Object.create(null);\r\n this._eventsCount = 0;\r\n }\r\n\r\n this._maxListeners = this._maxListeners || undefined;\r\n};\r\n\r\n// Obviously not all Emitters should be limited to 10. This function allows\r\n// that to be increased. Set to zero for unlimited.\r\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\r\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\r\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\r\n }\r\n this._maxListeners = n;\r\n return this;\r\n};\r\n\r\nfunction _getMaxListeners(that) {\r\n if (that._maxListeners === undefined)\r\n return EventEmitter.defaultMaxListeners;\r\n return that._maxListeners;\r\n}\r\n\r\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\r\n return _getMaxListeners(this);\r\n};\r\n\r\nEventEmitter.prototype.emit = function emit(type) {\r\n var args = [];\r\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\r\n var doError = (type === 'error');\r\n\r\n var events = this._events;\r\n if (events !== undefined)\r\n doError = (doError && events.error === undefined);\r\n else if (!doError)\r\n return false;\r\n\r\n // If there is no 'error' event listener then throw.\r\n if (doError) {\r\n var er;\r\n if (args.length > 0)\r\n er = args[0];\r\n if (er instanceof Error) {\r\n // Note: The comments on the `throw` lines are intentional, they show\r\n // up in Node's output if this results in an unhandled exception.\r\n throw er; // Unhandled 'error' event\r\n }\r\n // At least give some kind of context to the user\r\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\r\n err.context = er;\r\n throw err; // Unhandled 'error' event\r\n }\r\n\r\n var handler = events[type];\r\n\r\n if (handler === undefined)\r\n return false;\r\n\r\n if (typeof handler === 'function') {\r\n ReflectApply(handler, this, args);\r\n } else {\r\n var len = handler.length;\r\n var listeners = arrayClone(handler, len);\r\n for (var i = 0; i < len; ++i)\r\n ReflectApply(listeners[i], this, args);\r\n }\r\n\r\n return true;\r\n};\r\n\r\nfunction _addListener(target, type, listener, prepend) {\r\n var m;\r\n var events;\r\n var existing;\r\n\r\n checkListener(listener);\r\n\r\n events = target._events;\r\n if (events === undefined) {\r\n events = target._events = Object.create(null);\r\n target._eventsCount = 0;\r\n } else {\r\n // To avoid recursion in the case that type === \"newListener\"! Before\r\n // adding it to the listeners, first emit \"newListener\".\r\n if (events.newListener !== undefined) {\r\n target.emit('newListener', type,\r\n listener.listener ? listener.listener : listener);\r\n\r\n // Re-assign `events` because a newListener handler could have caused the\r\n // this._events to be assigned to a new object\r\n events = target._events;\r\n }\r\n existing = events[type];\r\n }\r\n\r\n if (existing === undefined) {\r\n // Optimize the case of one listener. Don't need the extra array object.\r\n existing = events[type] = listener;\r\n ++target._eventsCount;\r\n } else {\r\n if (typeof existing === 'function') {\r\n // Adding the second element, need to change to array.\r\n existing = events[type] =\r\n prepend ? [listener, existing] : [existing, listener];\r\n // If we've already got an array, just append.\r\n } else if (prepend) {\r\n existing.unshift(listener);\r\n } else {\r\n existing.push(listener);\r\n }\r\n\r\n // Check for listener leak\r\n m = _getMaxListeners(target);\r\n if (m > 0 && existing.length > m && !existing.warned) {\r\n existing.warned = true;\r\n // No error code for this since it is a Warning\r\n // eslint-disable-next-line no-restricted-syntax\r\n var w = new Error('Possible EventEmitter memory leak detected. ' +\r\n existing.length + ' ' + String(type) + ' listeners ' +\r\n 'added. Use emitter.setMaxListeners() to ' +\r\n 'increase limit');\r\n w.name = 'MaxListenersExceededWarning';\r\n w.emitter = target;\r\n w.type = type;\r\n w.count = existing.length;\r\n ProcessEmitWarning(w);\r\n }\r\n }\r\n\r\n return target;\r\n}\r\n\r\nEventEmitter.prototype.addListener = function addListener(type, listener) {\r\n return _addListener(this, type, listener, false);\r\n};\r\n\r\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\r\n\r\nEventEmitter.prototype.prependListener =\r\n function prependListener(type, listener) {\r\n return _addListener(this, type, listener, true);\r\n };\r\n\r\nfunction onceWrapper() {\r\n if (!this.fired) {\r\n this.target.removeListener(this.type, this.wrapFn);\r\n this.fired = true;\r\n if (arguments.length === 0)\r\n return this.listener.call(this.target);\r\n return this.listener.apply(this.target, arguments);\r\n }\r\n}\r\n\r\nfunction _onceWrap(target, type, listener) {\r\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\r\n var wrapped = onceWrapper.bind(state);\r\n wrapped.listener = listener;\r\n state.wrapFn = wrapped;\r\n return wrapped;\r\n}\r\n\r\nEventEmitter.prototype.once = function once(type, listener) {\r\n checkListener(listener);\r\n this.on(type, _onceWrap(this, type, listener));\r\n return this;\r\n};\r\n\r\nEventEmitter.prototype.prependOnceListener =\r\n function prependOnceListener(type, listener) {\r\n checkListener(listener);\r\n this.prependListener(type, _onceWrap(this, type, listener));\r\n return this;\r\n };\r\n\r\n// Emits a 'removeListener' event if and only if the listener was removed.\r\nEventEmitter.prototype.removeListener =\r\n function removeListener(type, listener) {\r\n var list, events, position, i, originalListener;\r\n\r\n checkListener(listener);\r\n\r\n events = this._events;\r\n if (events === undefined)\r\n return this;\r\n\r\n list = events[type];\r\n if (list === undefined)\r\n return this;\r\n\r\n if (list === listener || list.listener === listener) {\r\n if (--this._eventsCount === 0)\r\n this._events = Object.create(null);\r\n else {\r\n delete events[type];\r\n if (events.removeListener)\r\n this.emit('removeListener', type, list.listener || listener);\r\n }\r\n } else if (typeof list !== 'function') {\r\n position = -1;\r\n\r\n for (i = list.length - 1; i >= 0; i--) {\r\n if (list[i] === listener || list[i].listener === listener) {\r\n originalListener = list[i].listener;\r\n position = i;\r\n break;\r\n }\r\n }\r\n\r\n if (position < 0)\r\n return this;\r\n\r\n if (position === 0)\r\n list.shift();\r\n else {\r\n spliceOne(list, position);\r\n }\r\n\r\n if (list.length === 1)\r\n events[type] = list[0];\r\n\r\n if (events.removeListener !== undefined)\r\n this.emit('removeListener', type, originalListener || listener);\r\n }\r\n\r\n return this;\r\n };\r\n\r\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\r\n\r\nEventEmitter.prototype.removeAllListeners =\r\n function removeAllListeners(type) {\r\n var listeners, events, i;\r\n\r\n events = this._events;\r\n if (events === undefined)\r\n return this;\r\n\r\n // not listening for removeListener, no need to emit\r\n if (events.removeListener === undefined) {\r\n if (arguments.length === 0) {\r\n this._events = Object.create(null);\r\n this._eventsCount = 0;\r\n } else if (events[type] !== undefined) {\r\n if (--this._eventsCount === 0)\r\n this._events = Object.create(null);\r\n else\r\n delete events[type];\r\n }\r\n return this;\r\n }\r\n\r\n // emit removeListener for all listeners on all events\r\n if (arguments.length === 0) {\r\n var keys = Object.keys(events);\r\n var key;\r\n for (i = 0; i < keys.length; ++i) {\r\n key = keys[i];\r\n if (key === 'removeListener') continue;\r\n this.removeAllListeners(key);\r\n }\r\n this.removeAllListeners('removeListener');\r\n this._events = Object.create(null);\r\n this._eventsCount = 0;\r\n return this;\r\n }\r\n\r\n listeners = events[type];\r\n\r\n if (typeof listeners === 'function') {\r\n this.removeListener(type, listeners);\r\n } else if (listeners !== undefined) {\r\n // LIFO order\r\n for (i = listeners.length - 1; i >= 0; i--) {\r\n this.removeListener(type, listeners[i]);\r\n }\r\n }\r\n\r\n return this;\r\n };\r\n\r\nfunction _listeners(target, type, unwrap) {\r\n var events = target._events;\r\n\r\n if (events === undefined)\r\n return [];\r\n\r\n var evlistener = events[type];\r\n if (evlistener === undefined)\r\n return [];\r\n\r\n if (typeof evlistener === 'function')\r\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\r\n\r\n return unwrap ?\r\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\r\n}\r\n\r\nEventEmitter.prototype.listeners = function listeners(type) {\r\n return _listeners(this, type, true);\r\n};\r\n\r\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\r\n return _listeners(this, type, false);\r\n};\r\n\r\nEventEmitter.listenerCount = function(emitter, type) {\r\n if (typeof emitter.listenerCount === 'function') {\r\n return emitter.listenerCount(type);\r\n } else {\r\n return listenerCount.call(emitter, type);\r\n }\r\n};\r\n\r\nEventEmitter.prototype.listenerCount = listenerCount;\r\nfunction listenerCount(type) {\r\n var events = this._events;\r\n\r\n if (events !== undefined) {\r\n var evlistener = events[type];\r\n\r\n if (typeof evlistener === 'function') {\r\n return 1;\r\n } else if (evlistener !== undefined) {\r\n return evlistener.length;\r\n }\r\n }\r\n\r\n return 0;\r\n}\r\n\r\nEventEmitter.prototype.eventNames = function eventNames() {\r\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\r\n};\r\n\r\nfunction arrayClone(arr, n) {\r\n var copy = new Array(n);\r\n for (var i = 0; i < n; ++i)\r\n copy[i] = arr[i];\r\n return copy;\r\n}\r\n\r\nfunction spliceOne(list, index) {\r\n for (; index + 1 < list.length; index++)\r\n list[index] = list[index + 1];\r\n list.pop();\r\n}\r\n\r\nfunction unwrapListeners(arr) {\r\n var ret = new Array(arr.length);\r\n for (var i = 0; i < ret.length; ++i) {\r\n ret[i] = arr[i].listener || arr[i];\r\n }\r\n return ret;\r\n}\r\n\r\nfunction once(emitter, name) {\r\n return new Promise(function (resolve, reject) {\r\n function errorListener(err) {\r\n emitter.removeListener(name, resolver);\r\n reject(err);\r\n }\r\n\r\n function resolver() {\r\n if (typeof emitter.removeListener === 'function') {\r\n emitter.removeListener('error', errorListener);\r\n }\r\n resolve([].slice.call(arguments));\r\n };\r\n\r\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\r\n if (name !== 'error') {\r\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\r\n }\r\n });\r\n}\r\n\r\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\r\n if (typeof emitter.on === 'function') {\r\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\r\n }\r\n}\r\n\r\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\r\n if (typeof emitter.on === 'function') {\r\n if (flags.once) {\r\n emitter.once(name, listener);\r\n } else {\r\n emitter.on(name, listener);\r\n }\r\n } else if (typeof emitter.addEventListener === 'function') {\r\n // EventTarget does not have `error` event semantics like Node\r\n // EventEmitters, we do not listen for `error` events here.\r\n emitter.addEventListener(name, function wrapListener(arg) {\r\n // IE does not have builtin `{ once: true }` support so we\r\n // have to do it manually.\r\n if (flags.once) {\r\n emitter.removeEventListener(name, wrapListener);\r\n }\r\n listener(arg);\r\n });\r\n } else {\r\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\r\n }\r\n}","'use strict';\r\n\r\nfunction EventSender() {\r\n this.listeners = {};\r\n this.listenersWithRefs = {};\r\n}\r\n\r\nEventSender.prototype.on = function (eventName, callback, ref) {\r\n if (ref) {\r\n if (!this.listenersWithRefs.hasOwnProperty(eventName)) {\r\n this.listenersWithRefs[eventName] = new Map();\r\n }\r\n\r\n if (!this.listenersWithRefs[eventName].get(ref)) {\r\n this.listenersWithRefs[eventName].set(ref, []);\r\n }\r\n\r\n this.listenersWithRefs[eventName].get(ref).push(callback);\r\n } else {\r\n if (!this.listeners.hasOwnProperty(eventName)) {\r\n this.listeners[eventName] = [];\r\n }\r\n\r\n this.listeners[eventName].push(callback);\r\n }\r\n};\r\n\r\nEventSender.prototype.removeListenersWithRef = function (ref) {\r\n Object.keys(this.listenersWithRefs).forEach((eventName) => {\r\n const listeners = this.listenersWithRefs[eventName];\r\n if (listeners.has(ref)) {\r\n listeners.delete(ref);\r\n }\r\n });\r\n};\r\n\r\nEventSender.prototype.removeAllListeners = function (eventName) {\r\n if (eventName) {\r\n delete this.listeners[eventName];\r\n delete this.listenersWithRefs[eventName];\r\n } else {\r\n this.listeners = {};\r\n this.listenersWithRefs = {};\r\n }\r\n};\r\n\r\nEventSender.prototype.emit = async function (eventName, data) {\r\n const array = this.listeners[eventName];\r\n\r\n if (array) {\r\n for (let i = 0; i < array.length; i++) {\r\n const callback = array[i];\r\n await Promise.resolve(callback.call(null, data));\r\n }\r\n }\r\n\r\n const map = this.listenersWithRefs[eventName];\r\n\r\n if (map) {\r\n for (const [ref, callbacks] of map) {\r\n for (const callback of callbacks) {\r\n await Promise.resolve(callback.call(ref, data));\r\n }\r\n }\r\n }\r\n};\r\n\r\nmodule.exports = EventSender;\r\n","//adapted from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript\r\nfunction guid() {\r\n function s4() {\r\n return Math.floor((1 + Math.random()) * 0x10000) .toString(16) .substring(1);\r\n }\r\n return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();\r\n}\r\n\r\nmodule.exports = guid;\r\n","'use strict';\r\n\r\nconst Model = require('./model');\r\nconst { getAbsoluteUrl } = require('./utils');\r\n\r\nvar userFunctionsCache = {};\r\n\r\nfunction JavascriptNodeParser(code, options) {\r\n this.inputs = {};\r\n this.outputs = {};\r\n this.error = undefined;\r\n this.code = code;\r\n\r\n const node = options ? options.node : undefined;\r\n this._initializeAPIs();\r\n\r\n var userCode = userFunctionsCache[code];\r\n if (!userCode) {\r\n try {\r\n userCode = new Function(['define', 'script', 'Node', 'Component'], JavascriptNodeParser.getCodePrefix() + code);\r\n userFunctionsCache[code] = userCode;\r\n } catch (e) {\r\n this.error = e.message;\r\n console.error(e);\r\n }\r\n }\r\n if (userCode) {\r\n try {\r\n userCode(\r\n this.define.bind(this),\r\n this.script.bind(this),\r\n this.apis.Node,\r\n node ? JavascriptNodeParser.getComponentScopeForNode(node) : {}\r\n ); //noodlJavascriptAPI);\r\n\r\n this._afterSourced();\r\n } catch (e) {\r\n this.error = e.message;\r\n console.error(e);\r\n }\r\n }\r\n}\r\n\r\n// First generation API\r\nJavascriptNodeParser.prototype.define = function (userObject) {\r\n this.inputs = userObject.inputs || {};\r\n this.outputs = userObject.outputs || {};\r\n this.setup = userObject.setup;\r\n this.change = userObject.run || userObject.change;\r\n this.destroy = userObject.destroy;\r\n\r\n this.definedObject = userObject;\r\n};\r\n\r\n// Second generation API\r\nfunction _scriptExtend(_this) {\r\n var _extended = {\r\n inputs: _this.inputs || {},\r\n outputs: _this.outputs || {},\r\n\r\n setup: function (inputs, outputs) {\r\n this.inputs = inputs;\r\n this.outputs = outputs;\r\n\r\n this.setOutputs = function (states) {\r\n for (var key in states) {\r\n this.outputs[key] = states[key];\r\n this.flagOutputDirty(key);\r\n }\r\n };\r\n\r\n if (_this.methods) {\r\n for (var key in _this.methods) {\r\n this[key] = _this.methods[key];\r\n }\r\n }\r\n\r\n _this.setup && _this.setup.apply(this);\r\n },\r\n\r\n destroy: function (inputs, outputs) {\r\n this.inputs = inputs;\r\n this.outputs = outputs;\r\n\r\n _this.destroy && _this.destroy.apply(this);\r\n },\r\n\r\n change: function (inputs, outputs) {\r\n this.inputs = inputs;\r\n this.outputs = outputs;\r\n\r\n // Detect property changed\r\n var old = this._oldInputs || {};\r\n\r\n if (_this.changed) {\r\n for (var key in inputs) {\r\n if (inputs[key] !== old[key]) {\r\n var changedFunction = _this.changed[key];\r\n if (typeof changedFunction === 'function') changedFunction.apply(this, [inputs[key], old[key]]);\r\n }\r\n }\r\n }\r\n\r\n this._oldInputs = Object.assign({}, inputs);\r\n }\r\n };\r\n\r\n if (_this.signals) {\r\n for (var key in _this.signals) {\r\n _extended[key] = _this.signals[key];\r\n\r\n _extended.inputs[key] = 'signal';\r\n }\r\n }\r\n\r\n return _extended;\r\n}\r\n\r\nJavascriptNodeParser.prototype.script = function (userObject) {\r\n var _userObjectExtended = _scriptExtend(userObject);\r\n this.inputs = _userObjectExtended.inputs || {};\r\n this.outputs = _userObjectExtended.outputs || {};\r\n this.setup = _userObjectExtended.setup;\r\n this.change = _userObjectExtended.run || _userObjectExtended.change;\r\n this.destroy = _userObjectExtended.destroy;\r\n\r\n this.definedObject = _userObjectExtended;\r\n};\r\n\r\n// Third generation API\r\n\r\n// Node.Setters.Hej = function(value) {...}\r\n// Node.OnInputsChanged = function() {...}\r\n// Node.Signals.Hej = function(value) {...}\r\n// Node.OnInit = function() {...}\r\n// Node.OnDestroy = function() {...}\r\n// Node.Inputs.A\r\n// Node.Outputs.A = 10;\r\n// Node.Outputs.Done()\r\n// Node.setOutputs({...})\r\n// Component.Object, Component.ParentObject\r\nJavascriptNodeParser.prototype._initializeAPIs = function () {\r\n this.apis = {};\r\n\r\n this.apis.Node = {\r\n Inputs: {},\r\n Outputs: {},\r\n Signals: {},\r\n Setters: {}\r\n };\r\n};\r\n\r\nJavascriptNodeParser.prototype._afterSourced = function () {\r\n if (this.definedObject !== undefined) return; // a legacy API have been used\r\n\r\n var _Node = this.apis.Node;\r\n\r\n // Merge inputs and outputs from node extension\r\n this.inputs = Object.assign({}, _Node.Inputs || {});\r\n this.outputs = Object.assign({}, _Node.Outputs || {});\r\n\r\n this.setup = function (inputs, outputs) {\r\n const _this = this;\r\n\r\n _Node.setOutputs = function (_outputs) {\r\n for (var key in _outputs) {\r\n outputs[key] = _outputs[key];\r\n _this.flagOutputDirty(key);\r\n }\r\n };\r\n\r\n _Node.OnInit && _Node.OnInit.apply(this);\r\n };\r\n\r\n this.destroy = _Node.OnDestroy || this.destory;\r\n this.change = (inputs, outputs, changedInputs) => {\r\n for (var key in changedInputs) {\r\n if (typeof _Node.Setters[key] === 'function') {\r\n _Node.Setters[key](inputs[key]);\r\n }\r\n }\r\n\r\n if (typeof _Node.OnInputsChanged === 'function') {\r\n _Node.OnInputsChanged();\r\n }\r\n };\r\n\r\n this.definedObject = {\r\n inputs: this.inputs,\r\n outputs: this.outputs,\r\n setup: this.setup,\r\n destroy: this.destroy,\r\n change: this.change\r\n };\r\n\r\n // Set all signals as signal inputs\r\n if (_Node.Signals !== undefined) {\r\n for (var key in _Node.Signals) {\r\n if (typeof _Node.Signals[key] === 'function') {\r\n this.inputs[key] = 'signal';\r\n\r\n this.definedObject[key] = _Node.Signals[key];\r\n }\r\n }\r\n }\r\n};\r\n\r\nJavascriptNodeParser.createFromCode = function (code, options) {\r\n return new JavascriptNodeParser(code, options);\r\n};\r\n\r\nJavascriptNodeParser.createFromURL = function (url, callback, options) {\r\n url = getAbsoluteUrl(url);\r\n\r\n var xhr = new window.XMLHttpRequest();\r\n xhr.open('GET', url, true);\r\n xhr.onreadystatechange = function () {\r\n // XMLHttpRequest.DONE = 4, but torped runtime doesn't support enum\r\n if (this.readyState === 4 || this.readyState === XMLHttpRequest.DONE) {\r\n callback(new JavascriptNodeParser(this.response));\r\n }\r\n };\r\n xhr.onerror = function () {\r\n console.log('Failed to request', url);\r\n };\r\n xhr.send();\r\n};\r\n\r\nJavascriptNodeParser.parseAndAddPortsFromScript = function (script, ports, options) {\r\n // Extract inputs and outputs\r\n function _exists(port) {\r\n if (typeof port === 'string') return ports.find((p) => p.name === port) !== undefined;\r\n else return ports.find((p) => p.name === port.name && p.plug === port.plug) !== undefined;\r\n }\r\n\r\n function _addPortsFromMatch(match, options) {\r\n if (match === undefined || match === null) return;\r\n\r\n const unique = {};\r\n for (const _s of match) {\r\n let name = _s[1];\r\n if (name === undefined) continue;\r\n\r\n unique[name] = true;\r\n }\r\n\r\n Object.keys(unique).forEach((p) => {\r\n if (\r\n _exists({\r\n name: options.prefix + p,\r\n plug: options.plug\r\n })\r\n )\r\n return;\r\n\r\n ports.push({\r\n name: options.prefix + p,\r\n displayName: p,\r\n plug: options.plug,\r\n type: options.type,\r\n group: options.group\r\n });\r\n });\r\n }\r\n\r\n // const scriptWithoutComments = script.replace(/\\/\\*[\\s\\S]*?\\*\\/|\\/\\/.*/g,''); // Remove comments\r\n\r\n // Regular Inputs. notation\r\n if (!options.skipInputs) {\r\n _addPortsFromMatch(script.matchAll(/Inputs\\.([A-Za-z0-9_]+)/g), {\r\n type: options.inputType || '*',\r\n plug: 'input',\r\n group: options.inputGroup || 'Inputs',\r\n prefix: options.inputPrefix || ''\r\n });\r\n\r\n // Inputs with Inputs[\"A\"] notation\r\n _addPortsFromMatch(script.matchAll(/Inputs\\s*\\[\\s*(?:'|\")(.*)(?:'|\")\\s*\\]/g), {\r\n type: options.inputType || '*',\r\n plug: 'inputs',\r\n group: options.inputGroup || 'Inputs',\r\n prefix: options.inputPrefix || ''\r\n });\r\n }\r\n\r\n if (!options.skipOutputs) {\r\n if (!options.skipOutputSignals) {\r\n // Output signals, Output.Done()\r\n _addPortsFromMatch(script.matchAll(/Outputs\\.([A-Za-z0-9]+)\\s*\\(\\s*\\)/g), {\r\n type: 'signal',\r\n plug: 'output',\r\n group: 'Outputs',\r\n prefix: options.outputPrefix || ''\r\n });\r\n\r\n // Output signals, Outputs[\"Done\"]()\r\n _addPortsFromMatch(script.matchAll(/Outputs\\s*\\[\\s*(?:'|\")(.*)(?:'|\")\\s*\\]\\(\\s*\\)/g), {\r\n type: 'signal',\r\n plug: 'output',\r\n group: 'Outputs',\r\n prefix: options.outputPrefix || ''\r\n });\r\n }\r\n\r\n if (!options.skipRegularOutputs) {\r\n // Regular output Outputs. notation\r\n _addPortsFromMatch(script.matchAll(/Outputs\\.([A-Za-z0-9_]+)/g), {\r\n type: '*',\r\n plug: 'output',\r\n group: 'Outputs',\r\n prefix: options.outputPrefix || ''\r\n });\r\n\r\n // Outputs with Outputs[\"A\"] notation\r\n _addPortsFromMatch(script.matchAll(/Outputs\\s*\\[\\s*\\\"([^\\\"]*)\\\"\\s*\\]/g), {\r\n type: '*',\r\n plug: 'output',\r\n group: 'Outputs',\r\n prefix: options.outputPrefix || ''\r\n });\r\n }\r\n }\r\n};\r\n\r\nJavascriptNodeParser.prototype.getPorts = function () {\r\n var ports = [];\r\n\r\n var self = this;\r\n\r\n Object.keys(this.inputs).forEach(function (name) {\r\n var inputPort = self.inputs[name];\r\n\r\n var port = {\r\n name: name,\r\n plug: 'input'\r\n };\r\n if (typeof inputPort === 'string') {\r\n port.type = {\r\n name: inputPort\r\n };\r\n port.group = 'Inputs';\r\n } else {\r\n for (var p in inputPort) {\r\n port[p] = inputPort[p];\r\n }\r\n }\r\n\r\n ports.push(port);\r\n });\r\n\r\n Object.keys(this.outputs).forEach(function (name) {\r\n ports.push({\r\n name: name,\r\n type: {\r\n name: self.outputs[name]\r\n },\r\n plug: 'output',\r\n group: 'Outputs'\r\n });\r\n });\r\n\r\n JavascriptNodeParser.parseAndAddPortsFromScript(this.code, ports, {});\r\n\r\n return ports;\r\n};\r\n\r\nconst _componentScopes = {};\r\n\r\nfunction _findParentComponentStateModelId(node) {\r\n function getParentComponent(component) {\r\n let parent;\r\n if (component.getRoots().length > 0) {\r\n //visual\r\n const root = component.getRoots()[0];\r\n\r\n if (root.getVisualParentNode) {\r\n //regular visual node\r\n if (root.getVisualParentNode()) {\r\n parent = root.getVisualParentNode().nodeScope.componentOwner;\r\n }\r\n } else if (root.parentNodeScope) {\r\n //component instance node\r\n parent = component.parentNodeScope.componentOwner;\r\n }\r\n } else if (component.parentNodeScope) {\r\n parent = component.parentNodeScope.componentOwner;\r\n }\r\n\r\n //check that a parent exists and that the component is different\r\n if (parent && parent.nodeScope && parent.nodeScope.componentOwner !== component) {\r\n //check if parent has a Component State node\r\n if (parent.nodeScope.getNodesWithType('net.noodl.ComponentObject').length > 0) {\r\n return parent;\r\n }\r\n\r\n if (parent.nodeScope.getNodesWithType('Component State').length > 0) {\r\n return parent;\r\n }\r\n\r\n //if not, continue searching up the tree\r\n return getParentComponent(parent);\r\n }\r\n }\r\n\r\n const parent = getParentComponent(node.nodeScope.componentOwner);\r\n if (!parent) return;\r\n\r\n //this._internal.parentComponentName = parent.name;\r\n\r\n return 'componentState' + parent.getInstanceId();\r\n}\r\n\r\nfunction _findForEachModel(node) {\r\n var component = node.nodeScope.componentOwner;\r\n while (component !== undefined && component._forEachModel === undefined && component.parentNodeScope) {\r\n component = component.parentNodeScope.componentOwner;\r\n }\r\n return component !== undefined ? component._forEachModel : undefined;\r\n}\r\n\r\nJavascriptNodeParser.getComponentScopeForNode = function (node) {\r\n const componentId = node.nodeScope.componentOwner.getInstanceId();\r\n\r\n if (_componentScopes[componentId] === undefined) {\r\n _componentScopes[componentId] = {};\r\n\r\n const componentObject = (node.nodeScope.modelScope || Model).get('componentState' + componentId);\r\n\r\n _componentScopes[componentId].Object = componentObject;\r\n }\r\n\r\n // This should be done each time, since the component can be moved\r\n const parentComponentObjectId = _findParentComponentStateModelId(node);\r\n const parentComponentObject =\r\n parentComponentObjectId !== undefined\r\n ? (node.nodeScope.modelScope || Model).get(parentComponentObjectId)\r\n : undefined;\r\n\r\n _componentScopes[componentId].ParentObject = parentComponentObject;\r\n\r\n // Set the for each model\r\n _componentScopes[componentId].RepeaterObject = _findForEachModel(node);\r\n\r\n return _componentScopes[componentId];\r\n};\r\n\r\nJavascriptNodeParser.getCodePrefix = function () {\r\n // API\r\n return \"const Script = (typeof Node !== 'undefined')?Node:undefined;\\n\";\r\n};\r\n\r\nJavascriptNodeParser.createNoodlAPI = function () {\r\n // If we are running in browser mode and there is a global Noodl API object, use it. If not\r\n // create a new one for this scope.\r\n return typeof window !== 'undefined' && window.Noodl !== undefined ? window.Noodl : {};\r\n};\r\n\r\nmodule.exports = JavascriptNodeParser;\r\n","// ------------------------------------------------------------------------------\r\n// Model\r\n// ------------------------------------------------------------------------------\r\nfunction Model(id, data) {\r\n this.id = id;\r\n this.data = data;\r\n}\r\n\r\nconst models = (Model._models = {});\r\nconst proxies = {};\r\n\r\n// Get and set proxy\r\nconst _modelProxyHandler = {\r\n get: function (target, prop, receiver) {\r\n if (typeof target[prop] === 'function') return target[prop].bind(target);\r\n else if (prop in target) return Reflect.get(target, prop, receiver);\r\n else return target.get(prop);\r\n },\r\n set: function (obj, prop, value) {\r\n if (prop === '_class') {\r\n obj._class = value;\r\n } else if (prop === 'id') {\r\n console.log(`Noodl.Object warning: id is readonly (Id is ${obj.id}, trying to set to ${value})`);\r\n return true; //if a proxy doesn't return true an exception will be thrown\r\n } else {\r\n obj.set(prop, value);\r\n }\r\n return true;\r\n },\r\n ownKeys(target) {\r\n return Reflect.ownKeys(target.data);\r\n },\r\n getOwnPropertyDescriptor(target, prop) {\r\n return Object.getOwnPropertyDescriptor(target.data, prop);\r\n }\r\n};\r\n\r\n/**\r\n *\r\n * @param {*} id\r\n * @returns {Model}\r\n */\r\nModel.get = function (id) {\r\n if (id === undefined) id = Model.guid();\r\n if (!models[id]) {\r\n models[id] = new Model(id, {});\r\n proxies[id] = new Proxy(models[id], _modelProxyHandler);\r\n }\r\n return proxies[id];\r\n};\r\n\r\nModel.create = function (data) {\r\n var modelData = data ? data : {};\r\n var m = Model.get(modelData.id);\r\n for (var key in modelData) {\r\n if (key === 'id') continue;\r\n m.set(key, modelData[key]);\r\n }\r\n\r\n return m;\r\n};\r\n\r\nModel.exists = function (id) {\r\n return models[id] !== undefined;\r\n};\r\n\r\nModel.instanceOf = function (collection) {\r\n return collection instanceof Model || collection.target instanceof Model;\r\n};\r\n\r\nfunction _randomString(size) {\r\n if (size === 0) {\r\n throw new Error('Zero-length randomString is useless.');\r\n }\r\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + 'abcdefghijklmnopqrstuvwxyz' + '0123456789';\r\n let objectId = '';\r\n for (let i = 0; i < size; ++i) {\r\n objectId += chars[Math.floor((1 + Math.random()) * 0x10000) % chars.length];\r\n }\r\n return objectId;\r\n}\r\n\r\nModel.guid = function guid() {\r\n return _randomString(10);\r\n};\r\n\r\nModel.prototype.on = function (event, listener) {\r\n if (!this.listeners) this.listeners = {};\r\n if (!this.listeners[event]) this.listeners[event] = [];\r\n this.listeners[event].push(listener);\r\n};\r\n\r\nModel.prototype.off = function (event, listener) {\r\n if (!this.listeners) return;\r\n if (!this.listeners[event]) return;\r\n var idx = this.listeners[event].indexOf(listener);\r\n if (idx !== -1) this.listeners[event].splice(idx, 1);\r\n};\r\n\r\nModel.prototype.notify = function (event, args) {\r\n if (!this.listeners) return;\r\n if (!this.listeners[event]) return;\r\n\r\n var l = this.listeners[event].slice(); //clone in case listeners array is modified in the callbacks\r\n for (var i = 0; i < l.length; i++) {\r\n l[i](args);\r\n }\r\n};\r\n\r\nModel.prototype.setAll = function (obj) {\r\n for (var i in obj) {\r\n if (i === 'id') continue; // Skip id\r\n if (this.data[i] !== obj[i]) {\r\n var old = this.data[i];\r\n this.data[i] = obj[i];\r\n this.notify('change', { name: i, value: obj[i], old: old });\r\n }\r\n }\r\n};\r\n\r\nModel.prototype.fill = function (value = null) {\r\n for (const key in this.data) {\r\n if (key === 'id') continue; // Skip id\r\n const temp = this.data[key];\r\n this.data[key] = value;\r\n this.notify('change', { name: key, value: this.data[key], old: temp });\r\n }\r\n};\r\n\r\n/**\r\n * @param {string} name\r\n * @param {unknown} value\r\n * @param {{\r\n * resolve?: boolean;\r\n * forceChange?: boolean;\r\n * silent?: boolean;\r\n * }} args\r\n */\r\nModel.prototype.set = function (name, value, args) {\r\n if (args && args.resolve && name.indexOf('.') !== -1) {\r\n // We should resolve path references\r\n const path = name.split('.');\r\n let model = this;\r\n for (let i = 0; i < path.length - 1; i++) {\r\n const v = model.get(path[i]);\r\n if (Model.instanceOf(v)) model = v;\r\n else return; // Path resolve failed\r\n }\r\n model.set(path[path.length - 1], value);\r\n return;\r\n }\r\n\r\n const forceChange = args && args.forceChange;\r\n\r\n const oldValue = this.data[name];\r\n this.data[name] = value;\r\n\r\n if ((forceChange || oldValue !== value) && (!args || !args.silent)) {\r\n this.notify('change', { name: name, value: value, old: oldValue });\r\n }\r\n};\r\n\r\n/**\r\n * @returns {string}\r\n */\r\nModel.prototype.getId = function () {\r\n return this.id;\r\n};\r\n\r\n/**\r\n * @param {string} name\r\n * @param {{\r\n * resolve?: boolean;\r\n * }} args\r\n * @returns {unknown}\r\n */\r\nModel.prototype.get = function (name, args) {\r\n if (args && args.resolve && name.indexOf('.') !== -1) {\r\n // We should resolve path references\r\n const path = name.split('.');\r\n let model = this;\r\n for (let i = 0; i < path.length - 1; i++) {\r\n const v = model.get(path[i]);\r\n if (Model.instanceOf(v)) model = v;\r\n else return; // Path resolve failed\r\n }\r\n return model.get(path[path.length - 1]);\r\n }\r\n\r\n return this.data[name];\r\n};\r\n\r\nModel.prototype.toJSON = function () {\r\n return Object.assign({}, this.data, { id: this.id });\r\n};\r\n\r\nModel.Scope = function () {\r\n this.models = {};\r\n this.proxies = {};\r\n};\r\n\r\nModel.Scope.prototype.get = function (id) {\r\n if (id === undefined) id = Model.guid();\r\n if (!this.models[id]) {\r\n this.models[id] = new Model(id, {});\r\n this.proxies[id] = new Proxy(this.models[id], _modelProxyHandler);\r\n }\r\n return this.proxies[id];\r\n};\r\n\r\nModel.Scope.prototype.create = function (data) {\r\n var modelData = data ? data : {};\r\n var m = this.get(modelData.id);\r\n for (var key in modelData) {\r\n if (key === 'id') continue;\r\n m.set(key, modelData[key]);\r\n }\r\n\r\n return m;\r\n};\r\n\r\nModel.Scope.prototype.exists = function (id) {\r\n return this.models[id] !== undefined;\r\n};\r\n\r\nModel.Scope.prototype.instanceOf = function (collection) {\r\n return collection instanceof Model || collection.target instanceof Model;\r\n};\r\n\r\nModel.Scope.prototype.guid = function guid() {\r\n return _randomString(10);\r\n};\r\n\r\nModel.Scope.prototype.reset = function () {\r\n this.models = {};\r\n this.proxies = {};\r\n delete this._cloudStore;\r\n};\r\n\r\nmodule.exports = Model;\r\n","\"use strict\";\r\n\r\nvar NodeModel = require('./nodemodel');\r\nvar EventSender = require('../eventsender');\r\n\r\nfunction ComponentModel(name) {\r\n EventSender.call(this);\r\n\r\n this.name = name;\r\n this.nodes = [];\r\n this.connections = [];\r\n this.roots = [];\r\n this.inputPorts = {};\r\n this.outputPorts = {};\r\n this.metadata = {};\r\n}\r\n\r\nComponentModel.prototype = Object.create(EventSender.prototype);\r\n\r\nComponentModel.prototype.addNode = async function(node) {\r\n node.component = this;\r\n this.nodes[node.id] = node;\r\n await this.emit(\"nodeAdded\", node);\r\n};\r\n\r\nComponentModel.prototype.hasNodeWithId = function(id) {\r\n return this.getNodeWithId(id) !== undefined;\r\n};\r\n\r\nComponentModel.prototype.getNodeWithId = function(id) {\r\n return this.nodes[id];\r\n};\r\n\r\nComponentModel.prototype.getAllNodes = function() {\r\n return Object.values(this.nodes);\r\n};\r\n\r\nComponentModel.prototype.getNodesWithType = function(type) {\r\n var nodes = [];\r\n var self = this;\r\n Object.keys(this.nodes).forEach(function(id) {\r\n var node = self.nodes[id];\r\n if(node.type === type) {\r\n nodes.push(node);\r\n }\r\n });\r\n\r\n return nodes;\r\n};\r\n\r\nComponentModel.prototype.addConnection = function(connection) {\r\n this.connections.push(connection);\r\n this.emit(\"connectionAdded\", connection);\r\n \r\n //emit an event on the target node model\r\n //used by numbered inputs\r\n if(connection.targetId) {\r\n const node = this.getNodeWithId(connection.targetId);\r\n if(node) {\r\n node.emit(\"inputConnectionAdded\", connection);\r\n }\r\n }\r\n};\r\n\r\nComponentModel.prototype.removeConnection = function(connection) {\r\n const index = this.connections.findIndex(con => {\r\n return con.sourceId === connection.sourceId &&\r\n con.sourcePort === connection.sourcePort &&\r\n con.targetId === connection.targetId &&\r\n con.targetPort === connection.targetPort;\r\n });\r\n\r\n if(index === -1) {\r\n console.log(\"Connection doesn't exist\", connection);\r\n return;\r\n }\r\n\r\n this.connections.splice(index, 1);\r\n this.emit(\"connectionRemoved\", connection);\r\n\r\n //emit an event on the target node model\r\n //used by numbered inputs\r\n if(connection.targetId) {\r\n const node = this.getNodeWithId(connection.targetId);\r\n if(node) {\r\n node.emit(\"inputConnectionRemoved\", connection);\r\n }\r\n }\r\n};\r\n\r\nComponentModel.prototype.getConnectionsFromPort = function(nodeId, sourcePortName) {\r\n return this.connections.filter(function(connection) {\r\n return connection.sourceId === nodeId && connection.sourcePort === sourcePortName;\r\n })\r\n};\r\n\r\nComponentModel.prototype.getConnectionsToPort = function(nodeId, targetPortName) {\r\n return this.connections.filter(function(connection) {\r\n return connection.targetId === nodeId && connection.targetPort === targetPortName;\r\n })\r\n};\r\n\r\nComponentModel.prototype.getConnectionsFrom = function(nodeId) {\r\n return this.connections.filter(function(connection) {\r\n return connection.sourceId === nodeId;\r\n })\r\n};\r\n\r\nComponentModel.prototype.getConnectionsTo = function(nodeId) {\r\n return this.connections.filter(function(connection) {\r\n return connection.targetId === nodeId;\r\n })\r\n};\r\n\r\nComponentModel.prototype.addRootId = function(rootId) {\r\n if(this.roots.indexOf(rootId) !== -1) {\r\n return;\r\n }\r\n this.roots.push(rootId);\r\n this.emit(\"rootAdded\", rootId);\r\n};\r\n\r\nComponentModel.prototype.removeRootId = function(rootId) {\r\n const index = this.roots.indexOf(rootId);\r\n if(index !== -1) {\r\n this.roots.splice(index, 1);\r\n this.emit(\"rootRemoved\", rootId);\r\n }\r\n};\r\n\r\nComponentModel.prototype.getRoots = function() {\r\n return this.roots;\r\n}\r\n\r\nComponentModel.prototype.removeNodeWithId = async function(id) {\r\n const node = this.getNodeWithId(id);\r\n\r\n if (!node) {\r\n console.warn(\"ERROR: Attempted to remove non-existing node with ID:\", id);\r\n return false;\r\n }\r\n\r\n //remove children first\r\n while(node.children.length > 0) {\r\n const child = node.children[0];\r\n const childRemoved = await this.removeNodeWithId(child.id);\r\n if (!childRemoved) {\r\n // Workaround for corrupt node trees, should never happen, a remove should always be successful\r\n node.children.shift();\r\n }\r\n }\r\n\r\n const connections = this.getConnectionsTo(id).concat(this.getConnectionsFrom(id));\r\n\r\n for(let i=0; i 0) {\r\n throw new Error(\"Not all nodes were removed during a reset\");\r\n }\r\n\r\n if(this.connections.length > 0) {\r\n throw new Error(\"Not all connections were removed during a reset\");\r\n }\r\n};\r\n\r\nComponentModel.prototype.rename = function(newName) {\r\n var oldName = this.name;\r\n this.name = newName;\r\n this.emit(\"renamed\", {oldName: oldName, newName: newName});\r\n};\r\n\r\nComponentModel.prototype.setMetadata = function(key, data) {\r\n this.metadata[key] = data;\r\n};\r\n\r\nComponentModel.prototype.getMetadata = function(key) {\r\n if(!key) return this.metadata;\r\n return this.metadata[key];\r\n};\r\n\r\nComponentModel.createFromExportData = async function(componentData) {\r\n\r\n var componentModel = new ComponentModel(componentData.name);\r\n\r\n if(componentData.metadata) {\r\n for(const key in componentData.metadata) {\r\n componentModel.setMetadata(key, componentData.metadata[key]);\r\n }\r\n }\r\n\r\n componentData.ports && componentData.ports.forEach(function(port) {\r\n if(port.plug === \"input\" || port.plug === \"input/output\") {\r\n componentModel.addInputPort(port);\r\n }\r\n if(port.plug === \"output\" || port.plug === \"input/output\") {\r\n componentModel.addOutputPort(port);\r\n }\r\n });\r\n\r\n if(componentData.nodes) {\r\n for(const node of componentData.nodes) {\r\n await componentModel.importEditorNodeData(node);\r\n }\r\n }\r\n\r\n componentData.connections && componentData.connections.forEach(connection => componentModel.addConnection(connection));\r\n componentData.roots && componentData.roots.forEach(root => componentModel.addRootId(root));\r\n\r\n return componentModel;\r\n};\r\n\r\nmodule.exports = ComponentModel;\r\n","'use strict';\r\n\r\nvar ComponentModel = require('./componentmodel');\r\nvar EventSender = require('../eventsender');\r\n\r\nfunction GraphModel() {\r\n EventSender.call(this);\r\n this.components = {};\r\n\r\n this.settings = {};\r\n\r\n this.metadata = {};\r\n}\r\n\r\nGraphModel.prototype = Object.create(EventSender.prototype);\r\n\r\nGraphModel.prototype.importComponentFromEditorData = async function (componentData) {\r\n var componentModel = await ComponentModel.createFromExportData(componentData);\r\n this.addComponent(componentModel);\r\n};\r\n\r\nGraphModel.prototype.getBundleContainingComponent = function (name) {\r\n return this.componentToBundleMap.get(name);\r\n};\r\n\r\nGraphModel.prototype.getBundlesContainingSheet = function (sheetName) {\r\n const bundles = new Set();\r\n for (const name of this.componentToBundleMap.keys()) {\r\n const isOnDefaultSheet = name.indexOf('/#') !== 0;\r\n\r\n const isMatch =\r\n (isOnDefaultSheet && sheetName === 'Default') || (!isOnDefaultSheet && name.indexOf('/#' + sheetName) === 0);\r\n\r\n if (isMatch) {\r\n bundles.add(this.componentToBundleMap.get(name));\r\n }\r\n }\r\n return Array.from(bundles);\r\n};\r\n\r\nGraphModel.prototype.getBundleDependencies = function (bundleName) {\r\n const result = new Set();\r\n\r\n const recurse = (name) => {\r\n const bundle = this.componentIndex[name];\r\n for (const dep of bundle.dependencies) {\r\n if (!result.has(dep)) {\r\n result.add(dep);\r\n recurse(dep);\r\n }\r\n }\r\n };\r\n\r\n recurse(bundleName);\r\n\r\n return Array.from(result);\r\n};\r\n\r\nGraphModel.prototype.importEditorData = async function (exportData) {\r\n this.componentIndex = exportData.componentIndex;\r\n this.routerIndex = exportData.routerIndex;\r\n\r\n this.componentToBundleMap = new Map();\r\n\r\n for (const bundleName in exportData.componentIndex) {\r\n const bundle = exportData.componentIndex[bundleName];\r\n\r\n for (const componentName of bundle.components) {\r\n this.componentToBundleMap.set(componentName, bundleName);\r\n }\r\n }\r\n\r\n this.variants = exportData.variants || [];\r\n\r\n exportData.settings && this.setSettings(exportData.settings);\r\n\r\n exportData.metadata && this.setAllMetaData(exportData.metadata);\r\n\r\n for (const component of exportData.components) {\r\n await this.importComponentFromEditorData(component);\r\n }\r\n\r\n this.setRootComponentName(exportData.rootComponent);\r\n};\r\n\r\nGraphModel.prototype.setRootComponentName = function (componentName) {\r\n this.rootComponent = componentName;\r\n this.emit('rootComponentNameUpdated', componentName);\r\n};\r\n\r\nGraphModel.prototype.getNodesWithType = function (type) {\r\n var nodes = [];\r\n\r\n var componentNames = Object.keys(this.components);\r\n for (var i = 0; i < componentNames.length; i++) {\r\n var component = this.components[componentNames[i]];\r\n nodes = nodes.concat(component.getNodesWithType(type));\r\n }\r\n return nodes;\r\n};\r\n\r\nGraphModel.prototype.getComponentWithName = function (type) {\r\n return this.components[type];\r\n};\r\n\r\nGraphModel.prototype.hasComponentWithName = function (type) {\r\n return this.components[type] ? true : false;\r\n};\r\n\r\nGraphModel.prototype.getAllComponents = function () {\r\n return Object.keys(this.components).map((name) => {\r\n return this.components[name];\r\n });\r\n};\r\n\r\nGraphModel.prototype.getAllNodes = function () {\r\n var nodes = [];\r\n\r\n var componentNames = Object.keys(this.components);\r\n for (var i = 0; i < componentNames.length; i++) {\r\n var component = this.components[componentNames[i]];\r\n nodes = nodes.concat(component.getAllNodes());\r\n }\r\n\r\n return nodes;\r\n};\r\n\r\nGraphModel.prototype.addComponent = function (component) {\r\n this.components[component.name] = component;\r\n\r\n //nodes that are already added are missing component input/output ports if the component is registered after the nodes\r\n //now when we have the component info, add them to the node instance models\r\n this.getNodesWithType(component.name).forEach(this._addComponentPorts.bind(this));\r\n\r\n //emit the \"nodeAdded\" event for every node already in the component\r\n component.getAllNodes().forEach(this._onNodeAdded.bind(this));\r\n\r\n //emit the same event for future nodes that will be added\r\n component.on('nodeAdded', this._onNodeAdded.bind(this), this);\r\n\r\n //and for nodes that are removed\r\n component.on('nodeRemoved', this._onNodeRemoved.bind(this), this);\r\n component.on('nodeWasRemoved', this._onNodeWasRemoved.bind(this), this);\r\n\r\n this.emit('componentAdded', component);\r\n};\r\n\r\nGraphModel.prototype.removeComponentWithName = async function (componentName) {\r\n if (this.components.hasOwnProperty(componentName) === false) {\r\n console.error('GraphModel: Component with name ' + componentName + ' not in graph');\r\n return;\r\n }\r\n\r\n var component = this.components[componentName];\r\n await component.reset();\r\n\r\n component.removeAllListeners();\r\n delete this.components[component.name];\r\n\r\n this.emit('componentRemoved', component);\r\n};\r\n\r\nGraphModel.prototype.renameComponent = function (componentName, newName) {\r\n if (this.components.hasOwnProperty(componentName) === false) {\r\n console.error('GraphModel: Component with name ' + componentName + ' not in graph');\r\n return;\r\n }\r\n\r\n this.getNodesWithType(componentName).forEach(function (nodeModel) {\r\n nodeModel.type = newName;\r\n });\r\n\r\n var component = this.components[componentName];\r\n component.rename(newName);\r\n\r\n delete this.components[componentName];\r\n this.components[newName] = component;\r\n\r\n this.emit('componentRenamed', component);\r\n};\r\n\r\nGraphModel.prototype._addComponentPorts = function (node) {\r\n //check if this node is a known component and add port to the model\r\n if (this.components.hasOwnProperty(node.type)) {\r\n //a component was created, add component ports to model\r\n var component = this.components[node.type];\r\n\r\n const inputPorts = component.getInputPorts();\r\n const outputPorts = component.getOutputPorts();\r\n\r\n Object.keys(inputPorts).forEach((portName) => {\r\n node.addInputPort(inputPorts[portName]);\r\n });\r\n\r\n Object.keys(outputPorts).forEach((portName) => {\r\n node.addOutputPort(outputPorts[portName]);\r\n });\r\n }\r\n};\r\n\r\nGraphModel.prototype._onNodeAdded = function (node) {\r\n this._addComponentPorts(node);\r\n\r\n this.emit('nodeAdded', node);\r\n this.emit('nodeAdded.' + node.type, node);\r\n};\r\n\r\nGraphModel.prototype._onNodeRemoved = function (node) {\r\n this.emit('nodeRemoved', node);\r\n this.emit('nodeRemoved.' + node.type, node);\r\n};\r\n\r\nGraphModel.prototype._onNodeWasRemoved = function (node) {\r\n this.emit('nodeWasRemoved', node);\r\n this.emit('nodeWasRemoved.' + node.type, node);\r\n};\r\n\r\nGraphModel.prototype.reset = async function () {\r\n for (const componentName of Object.keys(this.components)) {\r\n await this.removeComponentWithName(componentName);\r\n }\r\n this.setSettings({});\r\n};\r\n\r\nGraphModel.prototype.isEmpty = function () {\r\n return Object.keys(this.components).length === 0;\r\n};\r\n\r\nGraphModel.prototype.setSettings = function (settings) {\r\n this.settings = settings;\r\n this.emit('projectSettingsChanged', settings);\r\n};\r\n\r\nGraphModel.prototype.getSettings = function () {\r\n return this.settings;\r\n};\r\n\r\nGraphModel.prototype.setAllMetaData = function (metadata) {\r\n for (const p in metadata) {\r\n this.setMetaData(p, metadata[p]);\r\n }\r\n};\r\n\r\nGraphModel.prototype.setMetaData = function (key, data) {\r\n //metadata changes can trigger lots of ports to evaluate (e.g. when a database model has been changed)\r\n //check if the data actually has been updated before since the editor can send the same data multiple times\r\n if (this.metadata[key] && JSON.stringify(this.metadata[key]) === JSON.stringify(data)) {\r\n return;\r\n }\r\n\r\n this.metadata[key] = data;\r\n this.emit('metadataChanged', { key, data });\r\n this.emit('metadataChanged.' + key, data);\r\n};\r\n\r\nGraphModel.prototype.getMetaData = function (key) {\r\n if (key) return this.metadata[key];\r\n return this.metadata;\r\n};\r\n\r\nGraphModel.prototype.getVariants = function () {\r\n return this.variants || [];\r\n};\r\n\r\nGraphModel.prototype.getVariant = function (typename, name) {\r\n return this.variants.find((v) => v.name === name && v.typename === typename);\r\n};\r\n\r\nGraphModel.prototype.updateVariant = function (variant) {\r\n const i = this.variants.findIndex((v) => v.name === variant.name && v.typename === variant.typename);\r\n if (i !== -1) this.variants.splice(i, 1);\r\n this.variants.push(variant);\r\n\r\n this.emit('variantUpdated', variant);\r\n};\r\n\r\nGraphModel.prototype.updateVariantParameter = function (\r\n variantName,\r\n variantTypeName,\r\n parameterName,\r\n parameterValue,\r\n state\r\n) {\r\n const variant = this.getVariant(variantTypeName, variantName);\r\n if (!variant) {\r\n console.log(\"updateVariantParameter: can't find variant\", variantName, variantTypeName);\r\n return;\r\n }\r\n\r\n if (!state) {\r\n if (parameterValue === undefined) {\r\n delete variant.parameters[parameterName];\r\n } else {\r\n variant.parameters[parameterName] = parameterValue;\r\n }\r\n } else {\r\n if (!variant.stateParameters.hasOwnProperty(state)) {\r\n variant.stateParameters[state] = {};\r\n }\r\n\r\n if (parameterValue === undefined) {\r\n delete variant.stateParameters[state][parameterName];\r\n } else {\r\n variant.stateParameters[state][parameterName] = parameterValue;\r\n }\r\n }\r\n\r\n this.emit('variantUpdated', variant);\r\n};\r\n\r\nGraphModel.prototype.updateVariantDefaultStateTransition = function (variantName, variantTypeName, transition, state) {\r\n const variant = this.getVariant(variantTypeName, variantName);\r\n if (!variant) return;\r\n\r\n variant.defaultStateTransitions[state] = transition;\r\n this.emit('variantUpdated', variant);\r\n};\r\n\r\nGraphModel.prototype.updateVariantStateTransition = function (args) {\r\n const { variantTypeName, variantName, state, parameterName, curve } = args;\r\n\r\n const variant = this.getVariant(variantTypeName, variantName);\r\n if (!variant) return;\r\n\r\n if (!variant.stateTransitions[state]) {\r\n variant.stateTransitions[state] = {};\r\n }\r\n\r\n variant.stateTransitions[state][parameterName] = curve;\r\n};\r\n\r\nGraphModel.prototype.deleteVariant = function (typename, name) {\r\n const i = this.variants.findIndex((v) => v.name === name && v.typename === typename);\r\n if (i !== -1) this.variants.splice(i, 1);\r\n};\r\n\r\nmodule.exports = GraphModel;\r\n","\"use strict\";\r\n\r\nvar EventSender = require('../eventsender');\r\n\r\nfunction NodeModel(id, type) {\r\n EventSender.call(this);\r\n\r\n this.id = id;\r\n this.type = type;\r\n\r\n this.inputs = [];\r\n this.outputs = [];\r\n this.children = [];\r\n this.parameters = {};\r\n this.inputPorts = {};\r\n this.outputPorts = {};\r\n}\r\n\r\nNodeModel.prototype = Object.create(EventSender.prototype);\r\n\r\nNodeModel.prototype.setParameter = function(name, value, state) {\r\n if(state) {\r\n if(!this.stateParameters) this.stateParameters = {};\r\n if(!this.stateParameters[state]) this.stateParameters[state] = {};\r\n\r\n if(value === undefined) {\r\n delete this.stateParameters[state][name];\r\n }\r\n else {\r\n this.stateParameters[state][name] = value;\r\n }\r\n }\r\n else {\r\n if(value === undefined) {\r\n delete this.parameters[name];\r\n }\r\n else {\r\n this.parameters[name] = value;\r\n }\r\n }\r\n\r\n this.emit(\"parameterUpdated\", {name, value, state});\r\n};\r\n\r\nNodeModel.prototype.setParameters = function(parameters) {\r\n Object.keys(parameters).forEach(name => {\r\n this.setParameter(name, parameters[name]);\r\n });\r\n};\r\n\r\nNodeModel.prototype.setStateParameters = function(parameters) {\r\n this.stateParameters = parameters;\r\n};\r\n\r\nNodeModel.prototype.setStateTransitions = function(stateTransitions) {\r\n this.stateTransitions = stateTransitions;\r\n};\r\n\r\nNodeModel.prototype.setStateTransitionParamter = function(parameter, curve, state) {\r\n if(!this.stateTransitions) {\r\n this.stateTransitions = {};\r\n }\r\n\r\n if(curve) {\r\n this.stateTransitions[state][parameter] = curve;\r\n }\r\n else {\r\n delete this.stateTransitions[state][parameter];\r\n }\r\n};\r\n\r\nNodeModel.prototype.setDefaultStateTransition = function(stateTransition, state) {\r\n if(!this.defaultStateTransitions) {\r\n this.defaultStateTransitions = {};\r\n }\r\n this.defaultStateTransitions[state] = stateTransition;\r\n};\r\n\r\nNodeModel.prototype.addInputPort = function(port) {\r\n this.inputPorts[port.name] = port;\r\n this.emit(\"inputPortAdded\", port);\r\n};\r\n\r\nNodeModel.prototype.getInputPort = function(portName) {\r\n return this.inputPorts[portName];\r\n};\r\n\r\nNodeModel.prototype.getInputPorts = function() {\r\n return this.inputPorts;\r\n};\r\n\r\nNodeModel.prototype.removeInputPortWithName = function(portName) {\r\n if(this.inputPorts.hasOwnProperty(portName)) {\r\n var port = this.inputPorts[portName];\r\n delete this.inputPorts[portName];\r\n this.emit(\"inputPortRemoved\", port);\r\n }\r\n};\r\n\r\nNodeModel.prototype.updateInputPortTypes = function(ports) {\r\n var changed = false;\r\n for(var key in ports) {\r\n if(this.inputPorts[key] !== undefined) {\r\n this.inputPorts[key].type = ports[key].type;\r\n changed = true;\r\n }\r\n }\r\n changed && this.emit(\"inputPortTypesUpdated\");\r\n}\r\n\r\nNodeModel.prototype.addOutputPort = function(port) {\r\n this.outputPorts[port.name] = port;\r\n this.emit(\"outputPortAdded\", port);\r\n};\r\n\r\nNodeModel.prototype.getOutputPort = function(portName) {\r\n return this.outputPorts[portName];\r\n};\r\n\r\nNodeModel.prototype.getOutputPorts = function() {\r\n return this.outputPorts;\r\n};\r\n\r\nNodeModel.prototype.removeOutputPortWithName = function(portName) {\r\n if(this.outputPorts.hasOwnProperty(portName)) {\r\n var port = this.outputPorts[portName];\r\n delete this.outputPorts[portName];\r\n this.emit(\"outputPortRemoved\", port);\r\n }\r\n};\r\n\r\nNodeModel.prototype.updateOutputPortTypes = function(ports) {\r\n var changed = false;\r\n for(var key in ports) {\r\n if(this.outputPorts[key] !== undefined) {\r\n this.outputPorts[key].type = ports[key].type;\r\n changed = true;\r\n }\r\n }\r\n changed && this.emit(\"outputPortTypesUpdated\");\r\n}\r\n\r\nNodeModel.prototype.addChild = function(child, index) {\r\n child.parent = this;\r\n if(index === undefined) {\r\n this.children.push(child);\r\n }\r\n else {\r\n this.children.splice(index, 0, child);\r\n }\r\n this.emit(\"childAdded\", child);\r\n};\r\n\r\nNodeModel.prototype.removeChild = function(child) {\r\n child.parent = undefined;\r\n var index = this.children.indexOf(child);\r\n this.children.splice(index, 1);\r\n this.emit(\"childRemoved\", child);\r\n};\r\n\r\nNodeModel.prototype.reset = function() {\r\n this.removeAllListeners();\r\n};\r\n\r\nNodeModel.prototype.setVariant = function(variant) {\r\n this.variant = variant;\r\n this.emit(\"variantUpdated\", variant);\r\n};\r\n\r\nNodeModel.createFromExportData = function(nodeData) {\r\n var node = new NodeModel(nodeData.id, nodeData.type);\r\n nodeData.parameters && node.setParameters(nodeData.parameters);\r\n nodeData.stateParameters && node.setStateParameters(nodeData.stateParameters);\r\n nodeData.stateTransitions && node.setStateTransitions(nodeData.stateTransitions);\r\n \r\n if(nodeData.defaultStateTransitions) {\r\n for(const state in nodeData.defaultStateTransitions) {\r\n node.setDefaultStateTransition(nodeData.defaultStateTransitions[state], state);\r\n }\r\n }\r\n \r\n nodeData.ports && nodeData.ports.forEach(function(port) {\r\n\r\n //some ports are incorrectly named outputs instead of output, patch it here so\r\n //the rest of the code doesn't need to care\r\n if(port.plug === \"outputs\") {\r\n port.plug = \"output\";\r\n }\r\n\r\n if(port.plug === \"input\" || port.plug === \"input/output\") {\r\n node.addInputPort(port);\r\n }\r\n if(port.plug === \"output\" || port.plug === \"input/output\") {\r\n node.addOutputPort(port);\r\n }\r\n });\r\n\r\n nodeData.variant && node.setVariant(nodeData.variant);\r\n\r\n return node;\r\n};\r\n\r\nmodule.exports = NodeModel;","const OutputProperty = require('./outputproperty');\r\n\r\n/**\r\n * Base class for all Nodes\r\n * @constructor\r\n */\r\nfunction Node(context, id) {\r\n this.id = id;\r\n this.context = context;\r\n this._dirty = false;\r\n\r\n this._inputs = {};\r\n this._inputValues = {};\r\n this._outputs = {};\r\n\r\n this._inputConnections = {};\r\n this._outputList = [];\r\n this._isUpdating = false;\r\n this._inputValuesQueue = {};\r\n this._afterInputsHaveUpdatedCallbacks = [];\r\n\r\n this._internal = {};\r\n this._signalsSentThisUpdate = {};\r\n\r\n this._deleted = false;\r\n this._deleteListeners = [];\r\n this._isFirstUpdate = true;\r\n\r\n this._valuesFromConnections = {};\r\n this.updateOnDirtyFlagging = true;\r\n}\r\n\r\nNode.prototype.getInputValue = function (name) {\r\n return this._inputValues[name];\r\n};\r\n\r\nNode.prototype.registerInput = function (name, input) {\r\n if (this.hasInput(name)) {\r\n throw new Error('Input property ' + name + ' already registered');\r\n }\r\n\r\n this._inputs[name] = input;\r\n\r\n if (input.type && input.type.units) {\r\n const defaultUnit = input.type.defaultUnit || input.type.units[0];\r\n this._inputValues[name] = {\r\n value: input.default,\r\n type: defaultUnit\r\n };\r\n } else if (input.hasOwnProperty('default')) {\r\n this._inputValues[name] = input.default;\r\n }\r\n};\r\n\r\nNode.prototype.deregisterInput = function (name) {\r\n if (this.hasInput(name) === false) {\r\n throw new Error('Input property ' + name + \" doesn't exist\");\r\n }\r\n delete this._inputs[name];\r\n delete this._inputValues[name];\r\n};\r\n\r\nNode.prototype.registerInputs = function (inputs) {\r\n for (const name in inputs) {\r\n this.registerInput(name, inputs[name]);\r\n }\r\n};\r\n\r\nNode.prototype.getInput = function (name) {\r\n if (this.hasInput(name) === false) {\r\n console.log('Node ' + this.name + ': Invalid input property ' + name);\r\n return undefined;\r\n }\r\n\r\n return this._inputs[name];\r\n};\r\n\r\nNode.prototype.hasInput = function (name) {\r\n return name in this._inputs;\r\n};\r\n\r\nNode.prototype.registerInputIfNeeded = function () {\r\n //noop, can be overriden by subclasses\r\n};\r\n\r\nNode.prototype.setInputValue = function (name, value) {\r\n const input = this.getInput(name);\r\n if (!input) {\r\n console.log(\"node doesn't have input\", name);\r\n return;\r\n }\r\n\r\n //inputs with units always expect objects in the shape of {value, unit, ...}\r\n //these inputs might sometimes get raw numbers without units, and in those cases\r\n //Noodl should just update the value and not the other parameters\r\n const currentInputValue = this._inputValues[name];\r\n\r\n if (isNaN(value) === false && currentInputValue && currentInputValue.unit) {\r\n //update the value, and keep the other parameters\r\n const newValue = Object.assign({}, currentInputValue); //copy it, so we don't modify the original object (e.g. it might come from a variant)\r\n newValue.value = value;\r\n value = newValue;\r\n }\r\n\r\n //Save the current input value. Save it before resolving color styles so delta updates on color styles work correctly\r\n this._inputValues[name] = value;\r\n\r\n if (input.type === 'color' && this.context && this.context.styles) {\r\n value = this.context.styles.resolveColor(value);\r\n } else if (input.type === 'array' && typeof value === 'string') {\r\n try {\r\n value = eval(value);\r\n this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'invalid-array-' + name);\r\n } catch (e) {\r\n value = [];\r\n console.log(e);\r\n if (this.context.editorConnection) {\r\n this.context.editorConnection.sendWarning(\r\n this.nodeScope.componentOwner.name,\r\n this.id,\r\n 'invalid-array-' + name,\r\n {\r\n showGlobally: true,\r\n message: 'Invalid array
' + e.toString()\r\n }\r\n );\r\n }\r\n }\r\n }\r\n\r\n input.set.call(this, value);\r\n};\r\n\r\nNode.prototype.hasOutput = function (name) {\r\n return name in this._outputs;\r\n};\r\n\r\nNode.prototype.registerOutput = function (name, output) {\r\n if (this.hasOutput(name)) {\r\n throw new Error('Output property ' + name + ' already registered');\r\n }\r\n\r\n const newOutput = new OutputProperty({\r\n owner: this,\r\n getter: output.get || output.getter,\r\n name: name,\r\n onFirstConnectionAdded: output.onFirstConnectionAdded,\r\n onLastConnectionRemoved: output.onLastConnectionRemoved\r\n });\r\n\r\n this._outputs[name] = newOutput;\r\n this._outputList.push(newOutput);\r\n};\r\n\r\nNode.prototype.deregisterOutput = function (name) {\r\n if (this.hasOutput(name) === false) {\r\n throw new Error('Output property ' + name + \" isn't registered\");\r\n }\r\n\r\n const output = this._outputs[name];\r\n\r\n if (output.hasConnections()) {\r\n throw new Error('Output property ' + name + \" has connections and can't be removed\");\r\n }\r\n\r\n delete this._outputs[name];\r\n var index = this._outputList.indexOf(output);\r\n this._outputList.splice(index, 1);\r\n};\r\n\r\nNode.prototype.registerOutputs = function (outputs) {\r\n for (var name in outputs) {\r\n this.registerOutput(name, outputs[name]);\r\n }\r\n};\r\n\r\nNode.prototype.registerOutputIfNeeded = function () {\r\n //noop, can be overriden by subclasses\r\n};\r\n\r\nNode.prototype.getOutput = function (name) {\r\n if (this.hasOutput(name) === false) {\r\n throw new Error('Node ' + this.name + \" doesn't have a port named \" + name);\r\n }\r\n return this._outputs[name];\r\n};\r\n\r\nNode.prototype.connectInput = function (inputName, sourceNode, sourcePortName) {\r\n if (this.hasInput(inputName) === false) {\r\n throw new Error(\r\n \"Invalid connection, input doesn't exist. Trying to connect from \" +\r\n sourceNode.name +\r\n ' output ' +\r\n sourcePortName +\r\n ' to ' +\r\n this.name +\r\n ' input ' +\r\n inputName\r\n );\r\n }\r\n\r\n var sourcePort = sourceNode.getOutput(sourcePortName);\r\n sourcePort.registerConnection(this, inputName);\r\n\r\n if (!this._inputConnections[inputName]) {\r\n this._inputConnections[inputName] = [];\r\n }\r\n\r\n this._inputConnections[inputName].push(sourcePort);\r\n\r\n if (sourceNode._signalsSentThisUpdate[sourcePortName]) {\r\n this._setValueFromConnection(inputName, true);\r\n this._setValueFromConnection(inputName, false);\r\n } else {\r\n var outputValue = sourcePort.value;\r\n if (outputValue !== undefined) {\r\n this._setValueFromConnection(inputName, outputValue);\r\n\r\n if (this.context) {\r\n // Send value to editor for connection debugging.\r\n // Conceptually the value has already been sent,\r\n // but the editor needs to be notified after a connection is created\r\n this.context.connectionSentValue(sourcePort, sourcePort.value);\r\n }\r\n }\r\n }\r\n\r\n this.flagDirty();\r\n};\r\n\r\nNode.prototype.removeInputConnection = function (inputName, sourceNodeId, sourcePortName) {\r\n if (!this._inputConnections[inputName]) {\r\n throw new Error(\"Node removeInputConnection: Input doesn't exist\");\r\n }\r\n\r\n const inputsToPort = this._inputConnections[inputName];\r\n\r\n for (let i = 0; i < inputsToPort.length; i++) {\r\n const sourcePort = inputsToPort[i];\r\n if (sourcePort.owner.id === sourceNodeId && sourcePort.name === sourcePortName) {\r\n inputsToPort.splice(i, 1);\r\n\r\n //remove the output from the source node\r\n const output = sourcePort.owner.getOutput(sourcePortName);\r\n output.deregisterConnection(this, inputName);\r\n break;\r\n }\r\n }\r\n\r\n if (inputsToPort.length === 0) {\r\n //no inputs left, remove the bookkeeping that traces values sent to this node as inputs\r\n delete this._valuesFromConnections[inputName];\r\n }\r\n};\r\n\r\nNode.prototype.isInputConnected = function (inputName) {\r\n if (!this._inputConnections.hasOwnProperty(inputName)) {\r\n return false;\r\n }\r\n\r\n //We have connections, but they might be from non-connected component inputs.\r\n // If they are from a component input then check the input on the component instance.\r\n return this._inputConnections[inputName].some((c) => {\r\n //if this is not a component input, then we have a proper connection\r\n if (c.owner.name !== 'Component Inputs') return true;\r\n\r\n //the name of the output from the component input, is the same as the component instance input\r\n const component = c.owner.nodeScope.componentOwner;\r\n return component.isInputConnected(c.name);\r\n });\r\n};\r\n\r\nNode.prototype.update = function () {\r\n if (this._isUpdating || this._dirty === false) {\r\n return;\r\n }\r\n\r\n if (this._updatedAtIteration !== this.context.updateIteration) {\r\n this._updatedAtIteration = this.context.updateIteration;\r\n this._updateIteration = 0;\r\n if (this._cyclicLoop) this._cyclicLoop = false;\r\n }\r\n\r\n this._isUpdating = true;\r\n const maxUpdateIterations = 100;\r\n\r\n try {\r\n while (this._dirty && !this._cyclicLoop) {\r\n this._updateDependencies();\r\n\r\n //all inputs are now updated, flag as not dirty\r\n this._dirty = false;\r\n\r\n const inputNames = Object.keys(this._inputValuesQueue);\r\n\r\n let hasMoreInputs = true;\r\n\r\n while (hasMoreInputs && !this._cyclicLoop) {\r\n hasMoreInputs = false;\r\n\r\n for (let i = 0; i < inputNames.length; i++) {\r\n const inputName = inputNames[i];\r\n const queue = this._inputValuesQueue[inputName];\r\n if (queue.length > 0) {\r\n this.setInputValue(inputName, queue.shift());\r\n if (queue.length > 0) {\r\n hasMoreInputs = true;\r\n }\r\n }\r\n }\r\n\r\n const afterInputCallbacks = this._afterInputsHaveUpdatedCallbacks;\r\n this._afterInputsHaveUpdatedCallbacks = [];\r\n for (let i = 0; i < afterInputCallbacks.length; i++) {\r\n afterInputCallbacks[i].call(this);\r\n }\r\n }\r\n this._updateIteration++;\r\n\r\n if (this._updateIteration >= maxUpdateIterations) {\r\n this._cyclicLoop = true;\r\n }\r\n }\r\n } catch (e) {\r\n this._isUpdating = false;\r\n throw e;\r\n }\r\n\r\n if (this._cyclicLoop) {\r\n //flag the node as dirty again to let it contiune next frame so we don't just stop it\r\n //This will allow the browser a chance to render and run other code\r\n this.context.scheduleNextFrame(() => {\r\n this.context.nodeIsDirty(this);\r\n });\r\n\r\n if (this.context.editorConnection && !this._cyclicWarningSent && this.context.isWarningTypeEnabled('cyclicLoops')) {\r\n this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name, this.id, 'cyclic-loop', {\r\n showGlobally: true,\r\n message: 'Cyclic loop detected'\r\n });\r\n this._cyclicWarningSent = true;\r\n console.log('cycle detected', {\r\n id: this.id,\r\n name: this.name,\r\n component: this.nodeScope.componentOwner.name\r\n });\r\n }\r\n }\r\n\r\n this._isFirstUpdate = false;\r\n this._isUpdating = false;\r\n};\r\n\r\nNode.prototype._updateDependencies = function () {\r\n for (var inputName in this._inputConnections) {\r\n var connectedPorts = this._inputConnections[inputName];\r\n for (var i = 0; i < connectedPorts.length; ++i) {\r\n connectedPorts[i].owner.update();\r\n }\r\n }\r\n};\r\n\r\nNode.prototype.flagDirty = function () {\r\n if (this._dirty) {\r\n return;\r\n }\r\n\r\n this._dirty = true;\r\n\r\n //a hack to not update nodes as a component is being created.\r\n //Nodes should update once all connections are in place, so inputs that rely on connections, e.g. \"Run\" on a Function node, have the correct context before running.\r\n //This flag is being updated externally by the NodeScope and _performDirtyUpdate will be called when the component setup is done\r\n if (this.updateOnDirtyFlagging) {\r\n this._performDirtyUpdate();\r\n }\r\n};\r\n\r\nNode.prototype._performDirtyUpdate = function () {\r\n this.context && this.context.nodeIsDirty(this);\r\n\r\n for (var i = 0; i < this._outputList.length; ++i) {\r\n this._outputList[i].flagDependeesDirty();\r\n }\r\n};\r\n\r\nNode.prototype.sendValue = function (name, value) {\r\n if (this.hasOutput(name) === false) {\r\n console.log('Error: Node', this.name, \"doesn't have a output named\", name);\r\n return;\r\n }\r\n\r\n if (value === undefined) {\r\n return;\r\n }\r\n\r\n const output = this.getOutput(name);\r\n output.sendValue(value);\r\n\r\n if (this.context) {\r\n this.context.connectionSentValue(output, value);\r\n }\r\n};\r\n\r\nNode.prototype.flagOutputDirty = function (name) {\r\n const output = this.getOutput(name);\r\n this.sendValue(name, output.value);\r\n};\r\n\r\nNode.prototype.flagAllOutputsDirty = function () {\r\n for (const output of this._outputList) {\r\n this.sendValue(output.name, output.value);\r\n }\r\n};\r\n\r\nNode.prototype.sendSignalOnOutput = function (outputName) {\r\n if (this.hasOutput(outputName) === false) {\r\n console.log('Error: Node', this.name, \"doesn't have a output named\", outputName);\r\n return;\r\n }\r\n\r\n const output = this.getOutput(outputName);\r\n output.sendValue(true);\r\n output.sendValue(false);\r\n\r\n this._signalsSentThisUpdate[outputName] = true;\r\n this.scheduleAfterInputsHaveUpdated(function () {\r\n this._signalsSentThisUpdate[outputName] = false;\r\n });\r\n\r\n if (this.context) {\r\n this.context.connectionSentSignal(output);\r\n }\r\n};\r\n\r\nNode.prototype._setValueFromConnection = function (inputName, value) {\r\n this._valuesFromConnections[inputName] = value;\r\n this.queueInput(inputName, value);\r\n};\r\n\r\nNode.prototype._hasInputBeenSetFromAConnection = function (inputName) {\r\n return this._valuesFromConnections.hasOwnProperty(inputName);\r\n};\r\n\r\nNode.prototype.queueInput = function (inputName, value) {\r\n if (!this._inputValuesQueue[inputName]) {\r\n this._inputValuesQueue[inputName] = [];\r\n }\r\n\r\n //when values are queued during the very first update, make the last value overwrite previous ones\r\n //so a chain with multiple nodes with values that connect to each other all\r\n //consolidate to a single value, instead of piling up in the queue\r\n if (this._isFirstUpdate) {\r\n //signals need two values, so make sure we don't suppress the 'false' that comes directly\r\n //after a 'true'\r\n const queueValue = this._inputValuesQueue[inputName][0];\r\n const isSignal = queueValue === true; // && value === true;\r\n if (!isSignal) {\r\n //default units are set as an object {value, unit}\r\n //subsequent inputs can be unitless. and will will then overwrite those\r\n //and the node will get a value without ever getting a unit.\r\n //To make sure that doesn't happen, look at the value being overwritten\r\n //and use the unit from that before overwriting\r\n if (queueValue instanceof Object && queueValue.unit && value instanceof Object === false) {\r\n value = {\r\n value,\r\n unit: queueValue.unit\r\n };\r\n }\r\n\r\n this._inputValuesQueue[inputName].length = 0;\r\n }\r\n }\r\n\r\n this._inputValuesQueue[inputName].push(value);\r\n this.flagDirty();\r\n};\r\n\r\nNode.prototype.scheduleAfterInputsHaveUpdated = function (callback) {\r\n this._afterInputsHaveUpdatedCallbacks.push(callback);\r\n this.flagDirty();\r\n};\r\n\r\nNode.prototype.setNodeModel = function (nodeModel) {\r\n this.model = nodeModel;\r\n nodeModel.on('parameterUpdated', this._onNodeModelParameterUpdated, this);\r\n nodeModel.on('variantUpdated', this._onNodeModelVariantUpdated, this);\r\n\r\n nodeModel.on(\r\n 'inputPortRemoved',\r\n (port) => {\r\n if (this.hasInput(port.name)) {\r\n this.deregisterInput(port.name);\r\n }\r\n },\r\n this\r\n );\r\n\r\n nodeModel.on(\r\n 'outputPortRemoved',\r\n (port) => {\r\n if (this.hasOutput(port.name)) {\r\n this.deregisterOutput(port.name);\r\n }\r\n },\r\n this\r\n );\r\n};\r\n\r\nNode.prototype.addDeleteListener = function (listener) {\r\n this._deleteListeners.push(listener);\r\n};\r\n\r\nNode.prototype._onNodeDeleted = function () {\r\n if (this.model) {\r\n this.model.removeListenersWithRef(this);\r\n this.model = undefined;\r\n }\r\n\r\n this._deleted = true;\r\n\r\n for (const deleteListener of this._deleteListeners) {\r\n deleteListener.call(this);\r\n }\r\n};\r\n\r\nNode.prototype._onNodeModelParameterUpdated = function (event) {\r\n this.registerInputIfNeeded(event.name);\r\n\r\n if (event.value !== undefined) {\r\n if (event.state) {\r\n //this parameter is only used in a certain visual state\r\n //make sure we are in that state before setting it\r\n\r\n if (!this._getVisualStates) {\r\n console.log('Node has nos visual states, but got a parameter for state', event.state);\r\n return;\r\n }\r\n\r\n const states = this._getVisualStates();\r\n if (states.indexOf(event.state) !== -1) {\r\n this.queueInput(event.name, event.value);\r\n }\r\n } else {\r\n this.queueInput(event.name, event.value);\r\n }\r\n } else {\r\n //parameter is undefined, that means it has been removed and we should reset to default\r\n let defaultValue;\r\n\r\n const variant = this.variant;\r\n\r\n if (event.state) {\r\n //local value has been reset, check the variant first\r\n if (\r\n variant &&\r\n variant.stateParameters.hasOwnProperty(event.state) &&\r\n variant.stateParameters[event.state].hasOwnProperty(event.name)\r\n ) {\r\n defaultValue = variant.stateParameters[event.state][event.name];\r\n }\r\n //and if variant has no value in that state, check for local values in the neutral state\r\n else if (this.model.parameters.hasOwnProperty(event.name)) {\r\n defaultValue = this.model.parameters[event.name];\r\n }\r\n //and then look in the variant neutral values\r\n else if (variant && variant.parameters.hasOwnProperty(event.name)) {\r\n defaultValue = variant.parameters[event.name];\r\n }\r\n } else if (variant && variant.parameters.hasOwnProperty(event.name)) {\r\n defaultValue = variant.parameters[event.name];\r\n }\r\n\r\n if (defaultValue === undefined) {\r\n //get the default value for the port\r\n defaultValue = this.context.getDefaultValueForInput(this.model.type, event.name);\r\n\r\n //when a paramter that's used by a text style is reset, Noodl will modify the original dom node, outside of React\r\n //React will then re-render, and should apply the values from the text style, but won't see any delta in the virtual dom,\r\n //even though there is a diff to the real dom.\r\n //to fix that, we just force React to re-render the entire node\r\n this._resetReactVirtualDOM && this._resetReactVirtualDOM();\r\n }\r\n\r\n this.queueInput(event.name, defaultValue);\r\n }\r\n};\r\n\r\nNode.prototype._onNodeModelVariantUpdated = function (variant) {\r\n this.setVariant(variant);\r\n};\r\n\r\nmodule.exports = Node;\r\n","'use strict';\r\n\r\nvar EventEmitter = require('./events');\r\nvar NodeRegister = require('./noderegister');\r\nvar TimerScheduler = require('./timerscheduler');\r\nconst Variants = require('./variants');\r\n\r\nfunction NodeContext(args) {\r\n args = args || {};\r\n args.runningInEditor = args.hasOwnProperty('runningInEditor') ? args.runningInEditor : false;\r\n\r\n this._dirtyNodes = [];\r\n this.callbacksAfterUpdate = [];\r\n\r\n this.graphModel = args.graphModel;\r\n\r\n this.platform = args.platform;\r\n\r\n this.eventEmitter = new EventEmitter();\r\n this.eventEmitter.setMaxListeners(1000000);\r\n\r\n this.eventSenderEmitter = new EventEmitter(); //used by event senders and receivers\r\n this.eventSenderEmitter.setMaxListeners(1000000);\r\n\r\n this.globalValues = {};\r\n this.globalsEventEmitter = new EventEmitter();\r\n this.globalsEventEmitter.setMaxListeners(1000000);\r\n\r\n this.runningInEditor = args.runningInEditor;\r\n this.currentFrameTime = 0;\r\n this.frameNumber = 0;\r\n this.updateIteration = 0;\r\n\r\n this.nodeRegister = new NodeRegister(this);\r\n this.timerScheduler = new TimerScheduler(this.scheduleUpdate.bind(this));\r\n\r\n this.componentModels = {};\r\n this.debugInspectorsEnabled = false;\r\n this.connectionsToPulse = {};\r\n this.connectionsToPulseChanged = false;\r\n\r\n this.debugInspectors = {};\r\n\r\n this.connectionPulsingCallbackScheduled = false;\r\n\r\n this.editorConnection = args.editorConnection;\r\n\r\n this.rootComponent = undefined;\r\n\r\n this._outputHistory = {};\r\n this._signalHistory = {};\r\n\r\n this.warningTypes = {}; //default is to send all warning types\r\n\r\n this.bundleFetchesInFlight = new Map();\r\n\r\n this.variants = new Variants({\r\n graphModel: this.graphModel,\r\n getNodeScope: () => (this.rootComponent ? this.rootComponent.nodeScope : null)\r\n });\r\n\r\n if (this.editorConnection) {\r\n this.editorConnection.on('debugInspectorsUpdated', (inspectors) => {\r\n this.onDebugInspectorsUpdated(inspectors);\r\n });\r\n\r\n this.editorConnection.on('getConnectionValue', ({ clientId, connectionId }) => {\r\n if (this.editorConnection.clientId !== clientId) return;\r\n const connection = this._outputHistory[connectionId];\r\n this.editorConnection.sendConnectionValue(connectionId, connection ? connection.value : undefined);\r\n });\r\n }\r\n}\r\n\r\nNodeContext.prototype.setRootComponent = function (rootComponent) {\r\n this.rootComponent = rootComponent;\r\n};\r\n\r\nNodeContext.prototype.getCurrentTime = function () {\r\n return this.platform.getCurrentTime();\r\n};\r\n\r\nNodeContext.prototype.onDebugInspectorsUpdated = function (inspectors) {\r\n if (!this.debugInspectorsEnabled) return;\r\n\r\n inspectors = inspectors.map((inspector) => {\r\n if (inspector.type === 'connection') {\r\n const connection = inspector.connection;\r\n inspector.id = connection.fromId + connection.fromProperty;\r\n } else if (inspector.type === 'node') {\r\n inspector.id = inspector.nodeId;\r\n }\r\n return inspector;\r\n });\r\n\r\n this.debugInspectors = {};\r\n inspectors.forEach((inspector) => (this.debugInspectors[inspector.id] = inspector));\r\n\r\n this.sendDebugInspectorValues();\r\n};\r\n\r\nNodeContext.prototype.updateDirtyNodes = function () {\r\n var i, len;\r\n\r\n var loop = true,\r\n iterations = 0;\r\n\r\n this.updateIteration++;\r\n\r\n this.isUpdating = true;\r\n\r\n while (loop && iterations < 10) {\r\n var dirtyNodes = this._dirtyNodes;\r\n this._dirtyNodes = [];\r\n for (i = 0, len = dirtyNodes.length; i < len; ++i) {\r\n try {\r\n if (!dirtyNodes[i]._deleted) {\r\n dirtyNodes[i].update();\r\n }\r\n } catch (e) {\r\n console.error(e, e.stack);\r\n }\r\n }\r\n\r\n //make a new reference and reset array in case new callbacks are scheduled\r\n //by the current callbacks\r\n var callbacks = this.callbacksAfterUpdate;\r\n this.callbacksAfterUpdate = [];\r\n for (i = 0, len = callbacks.length; i < len; i++) {\r\n try {\r\n callbacks[i]();\r\n } catch (e) {\r\n console.error(e);\r\n }\r\n }\r\n\r\n loop = this.callbacksAfterUpdate.length > 0 || this._dirtyNodes.length > 0;\r\n iterations++;\r\n }\r\n\r\n this.isUpdating = false;\r\n};\r\n\r\nNodeContext.prototype.update = function () {\r\n this.frameNumber++;\r\n\r\n this.updateDirtyNodes();\r\n\r\n if (this.timerScheduler.hasPendingTimers()) {\r\n this.scheduleUpdate();\r\n this.timerScheduler.runTimers(this.currentFrameTime);\r\n }\r\n\r\n if (this.debugInspectorsEnabled) {\r\n this.sendDebugInspectorValues();\r\n }\r\n};\r\n\r\nNodeContext.prototype.reset = function () {\r\n //removes listeners like device orientation, websockets and more\r\n this.eventEmitter.emit('applicationDataReloaded');\r\n\r\n var eventEmitter = this.eventEmitter;\r\n ['frameStart', 'frameEnd'].forEach(function (name) {\r\n eventEmitter.removeAllListeners(name);\r\n });\r\n\r\n this.globalValues = {};\r\n this._dirtyNodes.length = 0;\r\n this.callbacksAfterUpdate.length = 0;\r\n\r\n this.timerScheduler.runningTimers = [];\r\n this.timerScheduler.newTimers = [];\r\n this.rootComponent = undefined;\r\n\r\n this.clearDebugInspectors();\r\n};\r\n\r\nNodeContext.prototype.nodeIsDirty = function (node) {\r\n this._dirtyNodes.push(node);\r\n this.scheduleUpdate();\r\n};\r\n\r\nNodeContext.prototype.scheduleUpdate = function () {\r\n this.eventEmitter.emit('scheduleUpdate');\r\n};\r\n\r\nNodeContext.prototype.scheduleAfterUpdate = function (func) {\r\n this.callbacksAfterUpdate.push(func);\r\n this.scheduleUpdate();\r\n};\r\n\r\nNodeContext.prototype.scheduleNextFrame = function (func) {\r\n this.eventEmitter.once('frameStart', func);\r\n this.scheduleUpdate();\r\n};\r\n\r\nNodeContext.prototype.setGlobalValue = function (name, value) {\r\n this.globalValues[name] = value;\r\n this.globalsEventEmitter.emit(name);\r\n};\r\n\r\nNodeContext.prototype.getGlobalValue = function (name) {\r\n return this.globalValues[name];\r\n};\r\n\r\nNodeContext.prototype.registerComponentModel = function (componentModel) {\r\n if (this.componentModels.hasOwnProperty(componentModel.name)) {\r\n throw new Error('Duplicate component name ' + componentModel.name);\r\n }\r\n this.componentModels[componentModel.name] = componentModel;\r\n\r\n var self = this;\r\n componentModel.on(\r\n 'renamed',\r\n function (event) {\r\n delete self.componentModels[event.oldName];\r\n self.componentModels[event.newName] = componentModel;\r\n },\r\n this\r\n );\r\n};\r\n\r\nNodeContext.prototype.deregisterComponentModel = function (componentModel) {\r\n if (this.componentModels.hasOwnProperty(componentModel.name)) {\r\n this.componentModels[componentModel.name].removeListenersWithRef(this);\r\n delete this.componentModels[componentModel.name];\r\n }\r\n};\r\n\r\nNodeContext.prototype.fetchComponentBundle = async function (name) {\r\n const fetchBundle = async (name) => {\r\n let baseUrl = Noodl.Env['BaseUrl'] || '/';\r\n let bundleUrl = `${baseUrl}noodl_bundles/${name}.json`;\r\n\r\n const response = await fetch(bundleUrl);\r\n if (response.status === 404) {\r\n throw new Error('Component not found ' + name);\r\n }\r\n\r\n const data = await response.json();\r\n for (const component of data) {\r\n if (this.graphModel.hasComponentWithName(component.name) === false) {\r\n await this.graphModel.importComponentFromEditorData(component);\r\n }\r\n }\r\n };\r\n\r\n if (this.bundleFetchesInFlight.has(name)) {\r\n await this.bundleFetchesInFlight.get(name);\r\n } else {\r\n const promise = fetchBundle(name);\r\n this.bundleFetchesInFlight.set(name, promise);\r\n await promise;\r\n //the promise is kept in bundleFetchesInFlight to mark what bundles have been downloaded\r\n //so eventual future requests will just await the resolved promise and resolve immediately\r\n }\r\n};\r\n\r\nNodeContext.prototype.getComponentModel = async function (name) {\r\n if (!name) {\r\n throw new Error('Component instance must have a name');\r\n }\r\n\r\n if (this.componentModels.hasOwnProperty(name) === false) {\r\n const bundleName = this.graphModel.getBundleContainingComponent(name);\r\n if (!bundleName) {\r\n throw new Error(\"Can't find component model for \" + name);\r\n }\r\n\r\n //start fetching dependencies in the background\r\n for (const bundleDep of this.graphModel.getBundleDependencies(bundleName)) {\r\n this.fetchComponentBundle(bundleDep);\r\n }\r\n\r\n //and wait for the bundle that has the component we need\r\n await this.fetchComponentBundle(bundleName);\r\n }\r\n\r\n return this.componentModels[name];\r\n};\r\n\r\nNodeContext.prototype.hasComponentModelWithName = function (name) {\r\n return this.componentModels.hasOwnProperty(name);\r\n};\r\n\r\nNodeContext.prototype.createComponentInstanceNode = async function (componentName, id, nodeScope, extraProps) {\r\n var ComponentInstanceNode = require('./nodes/componentinstance');\r\n var node = new ComponentInstanceNode(this, id, nodeScope);\r\n node.name = componentName;\r\n\r\n for (const prop in extraProps) {\r\n node[prop] = extraProps[prop];\r\n }\r\n\r\n const componentModel = await this.getComponentModel(componentName);\r\n await node.setComponentModel(componentModel);\r\n\r\n return node;\r\n};\r\n\r\nNodeContext.prototype._formatConnectionValue = function (value) {\r\n if (typeof value === 'object' && value && value.constructor && value.constructor.name === 'Node') {\r\n value = ' ' + value.name;\r\n } else if (typeof value === 'object' && typeof window !== 'undefined' && value instanceof HTMLElement) {\r\n value = `DOM Node <${value.tagName}>`;\r\n } else if (typeof value === 'string' && !value.startsWith('[Signal]')) {\r\n return '\"' + value + '\"';\r\n } else if (Number.isNaN(value)) {\r\n return 'NaN';\r\n }\r\n\r\n return value;\r\n};\r\n\r\nNodeContext.prototype.connectionSentValue = function (output, value) {\r\n if (!this.editorConnection || !this.editorConnection.isConnected() || !this.debugInspectorsEnabled) {\r\n return;\r\n }\r\n\r\n const timestamp = this.getCurrentTime();\r\n\r\n this._outputHistory[output.id] = {\r\n value,\r\n timestamp\r\n };\r\n\r\n if (this.connectionsToPulse.hasOwnProperty(output.id)) {\r\n this.connectionsToPulse[output.id].timestamp = timestamp;\r\n return;\r\n }\r\n\r\n const connections = [];\r\n\r\n output.connections.forEach((connection) => {\r\n connections.push(output.owner.id + output.name + connection.node.id + connection.inputPortName);\r\n });\r\n\r\n this.connectionsToPulse[output.id] = {\r\n timestamp,\r\n connections: connections\r\n };\r\n\r\n this.connectionsToPulseChanged = true;\r\n\r\n if (this.connectionPulsingCallbackScheduled === false) {\r\n this.connectionPulsingCallbackScheduled = true;\r\n setTimeout(this.clearOldConnectionPulsing.bind(this), 100);\r\n }\r\n};\r\n\r\nNodeContext.prototype.connectionSentSignal = function (output) {\r\n const id = output.id;\r\n if (!this._signalHistory.hasOwnProperty(id)) {\r\n this._signalHistory[id] = {\r\n count: 0\r\n };\r\n }\r\n\r\n this._signalHistory[id].count++;\r\n\r\n this.connectionSentValue(output, '[Signal] Trigger count ' + this._signalHistory[id].count);\r\n};\r\n\r\nNodeContext.prototype.clearDebugInspectors = function () {\r\n this.debugInspectors = {};\r\n this.connectionsToPulse = {};\r\n\r\n this.editorConnection.sendPulsingConnections(this.connectionsToPulse);\r\n};\r\n\r\nNodeContext.prototype.clearOldConnectionPulsing = function () {\r\n this.connectionPulsingCallbackScheduled = false;\r\n\r\n var now = this.getCurrentTime();\r\n var self = this;\r\n\r\n var connectionIds = Object.keys(this.connectionsToPulse);\r\n connectionIds.forEach(function (id) {\r\n var con = self.connectionsToPulse[id];\r\n if (now - con.timestamp > 100) {\r\n self.connectionsToPulseChanged = true;\r\n delete self.connectionsToPulse[id];\r\n }\r\n });\r\n\r\n if (this.connectionsToPulseChanged) {\r\n this.connectionsToPulseChanged = false;\r\n this.editorConnection.sendPulsingConnections(this.connectionsToPulse);\r\n }\r\n\r\n if (Object.keys(this.connectionsToPulse).length > 0) {\r\n this.connectionPulsingCallbackScheduled = true;\r\n setTimeout(this.clearOldConnectionPulsing.bind(this), 500);\r\n }\r\n};\r\n\r\nNodeContext.prototype._getDebugInspectorValueForNode = function (id) {\r\n if (!this.rootComponent) return;\r\n const nodes = this.rootComponent.nodeScope.getNodesWithIdRecursive(id);\r\n const node = nodes[nodes.length - 1];\r\n\r\n if (node && node.getInspectInfo) {\r\n const info = node.getInspectInfo();\r\n if (info !== undefined) {\r\n return { type: 'node', id, value: info };\r\n }\r\n }\r\n};\r\n\r\nNodeContext.prototype.sendDebugInspectorValues = function () {\r\n const valuesToSend = [];\r\n\r\n for (const id in this.debugInspectors) {\r\n const inspector = this.debugInspectors[id];\r\n\r\n if (inspector.type === 'connection' && this._outputHistory.hasOwnProperty(id)) {\r\n const value = this._outputHistory[id].value;\r\n\r\n valuesToSend.push({\r\n type: 'connection',\r\n id,\r\n value: this._formatConnectionValue(value)\r\n });\r\n } else if (inspector.type === 'node') {\r\n const inspectorValue = this._getDebugInspectorValueForNode(id);\r\n inspectorValue && valuesToSend.push(inspectorValue);\r\n }\r\n }\r\n\r\n if (valuesToSend.length > 0) {\r\n this.editorConnection.sendDebugInspectorValues(valuesToSend);\r\n }\r\n\r\n if (this.connectionsToPulseChanged) {\r\n this.connectionsToPulseChanged = false;\r\n this.editorConnection.sendPulsingConnections(this.connectionsToPulse);\r\n }\r\n};\r\n\r\nNodeContext.prototype.setDebugInspectorsEnabled = function (enabled) {\r\n this.debugInspectorsEnabled = enabled;\r\n this.editorConnection.debugInspectorsEnabled = enabled;\r\n if (enabled) {\r\n this.sendDebugInspectorValues();\r\n }\r\n};\r\n\r\nNodeContext.prototype.sendGlobalEventFromEventSender = function (channelName, inputValues) {\r\n this.eventSenderEmitter.emit(channelName, inputValues);\r\n};\r\n\r\nNodeContext.prototype.setPopupCallbacks = function ({ onShow, onClose }) {\r\n this.onShowPopup = onShow;\r\n this.onClosePopup = onClose;\r\n};\r\n\r\n/**\r\n * @param {string} popupComponent\r\n * @param {Record} params\r\n * @param {{\r\n * senderNode?: unknown;\r\n * onClosePopup?: (action?: string, results: object) => void;\r\n * }} args\r\n * @returns\r\n */\r\nNodeContext.prototype.showPopup = async function (popupComponent, params, args) {\r\n if (!this.onShowPopup) return;\r\n\r\n const nodeScope = this.rootComponent.nodeScope;\r\n\r\n const popupNode = await nodeScope.createNode(popupComponent);\r\n for (const inputKey in params) {\r\n popupNode.setInputValue(inputKey, params[inputKey]);\r\n }\r\n\r\n popupNode.popupParent = args?.senderNode || null;\r\n\r\n // Create container group\r\n const group = nodeScope.createPrimitiveNode('Group');\r\n group.setInputValue('flexDirection', 'node');\r\n group.setInputValue('cssClassName', 'noodl-popup');\r\n\r\n const bodyScroll = this.graphModel.getSettings().bodyScroll;\r\n\r\n //if the body can scroll the position of the popup needs to be fixed.\r\n group.setInputValue('position', bodyScroll ? 'fixed' : 'absolute');\r\n\r\n var closePopupNodes = popupNode.nodeScope.getNodesWithType('NavigationClosePopup');\r\n if (closePopupNodes && closePopupNodes.length > 0) {\r\n for (var j = 0; j < closePopupNodes.length; j++) {\r\n closePopupNodes[j]._setCloseCallback((action, results) => {\r\n //close next frame so all nodes have a chance to update before being deleted\r\n this.scheduleNextFrame(() => {\r\n //avoid double callbacks\r\n if (!nodeScope.hasNodeWithId(group.id)) return;\r\n\r\n this.onClosePopup(group);\r\n nodeScope.deleteNode(group);\r\n args && args.onClosePopup && args.onClosePopup(action, results);\r\n });\r\n });\r\n }\r\n }\r\n\r\n this.onShowPopup(group);\r\n\r\n requestAnimationFrame(() => {\r\n //hack to make the react components have the right props\r\n //TODO: figure out why this requestAnimationFrame is necessary\r\n group.addChild(popupNode);\r\n });\r\n};\r\n\r\nNodeContext.prototype.setWarningTypes = function (warningTypes) {\r\n Object.assign(this.warningTypes, warningTypes);\r\n};\r\n\r\nNodeContext.prototype.isWarningTypeEnabled = function (warning) {\r\n if (!this.warningTypes.hasOwnProperty(warning)) {\r\n //if a level isn't set, default to true\r\n return true;\r\n }\r\n\r\n return this.warningTypes[warning] ? true : false;\r\n};\r\n\r\nNodeContext.prototype.getDefaultValueForInput = function (nodeType, inputName) {\r\n if (this.nodeRegister.hasNode(nodeType) === false) {\r\n return undefined;\r\n }\r\n\r\n const nodeMetadata = this.nodeRegister.getNodeMetadata(nodeType);\r\n const inputMetadata = nodeMetadata.inputs[inputName];\r\n\r\n if (!inputMetadata) {\r\n return undefined;\r\n }\r\n\r\n if (inputMetadata.type.defaultUnit) {\r\n return {\r\n value: inputMetadata.default,\r\n unit: inputMetadata.type.defaultUnit\r\n };\r\n }\r\n\r\n return inputMetadata.default;\r\n};\r\n\r\nmodule.exports = NodeContext;\r\n","const Node = require('./node'),\r\n EdgeTriggeredInput = require('./edgetriggeredinput');\r\n\r\nfunction registerInput(object, metadata, name, input) {\r\n if (object.hasOwnProperty(name)) {\r\n throw new Error('Input property ' + name + ' already registered');\r\n }\r\n\r\n if (!input.set && !input.valueChangedToTrue) {\r\n input.set = () => {};\r\n }\r\n\r\n if (input.set) {\r\n object[name] = {\r\n set: input.set\r\n };\r\n\r\n //types to keep in the input on the node instances\r\n //color and textStyles are used for style updates\r\n //array is for supporting eval:ing strings\r\n const typesToSaveInInput = ['color', 'textStyle', 'array'];\r\n\r\n typesToSaveInInput.forEach((type) => {\r\n if (input.type && (input.type === type || input.type.name === type)) {\r\n object[name].type = type;\r\n }\r\n });\r\n }\r\n\r\n if (input.setUnitType) {\r\n object[name].setUnitType = input.setUnitType;\r\n }\r\n\r\n metadata.inputs[name] = {\r\n displayName: input.displayName,\r\n editorName: input.editorName,\r\n group: input.group,\r\n type: input.type,\r\n default: input.default,\r\n index: input.index,\r\n exportToEditor: input.hasOwnProperty('exportToEditor') ? input.exportToEditor : true,\r\n inputPriority: input.inputPriority || 0,\r\n tooltip: input.tooltip,\r\n tab: input.tab,\r\n popout: input.popout,\r\n allowVisualStates: input.allowVisualStates,\r\n nodeDoubleClickAction: input.nodeDoubleClickAction\r\n };\r\n\r\n if (input.valueChangedToTrue) {\r\n metadata.inputs[name].type = {\r\n name: 'signal',\r\n allowConnectionsOnly: true\r\n };\r\n }\r\n}\r\n\r\nfunction registerInputs(object, metadata, inputs) {\r\n Object.keys(inputs).forEach(function (inputName) {\r\n registerInput(object, metadata, inputName, inputs[inputName]);\r\n });\r\n}\r\n\r\nfunction registerNumberedInputs(node, numberedInputs) {\r\n for (const inputName of Object.keys(numberedInputs)) {\r\n registerNumberedInput(node, inputName, numberedInputs[inputName]);\r\n }\r\n}\r\n\r\nfunction registerNumberedInput(node, name, input) {\r\n const oldRegisterInputIfNeeded = node.registerInputIfNeeded;\r\n\r\n node.registerInputIfNeeded = function (inputName) {\r\n if (oldRegisterInputIfNeeded) {\r\n oldRegisterInputIfNeeded.call(node, inputName);\r\n }\r\n\r\n if (node.hasInput(inputName) || !inputName.startsWith(name)) {\r\n return;\r\n }\r\n\r\n const index = Number(inputName.slice(name.length + 1)); // inputName is \"nameOfInput xxx\" where xxx is the index\r\n\r\n node.registerInput(inputName, {\r\n type: input.type,\r\n set: input.createSetter.call(node, index)\r\n });\r\n };\r\n}\r\n\r\nfunction registerOutputsMetadata(metadata, outputs) {\r\n Object.keys(outputs).forEach(function (name) {\r\n var output = outputs[name];\r\n\r\n metadata.outputs[name] = {\r\n displayName: output.displayName,\r\n editorName: output.editorName,\r\n group: output.group,\r\n type: output.type,\r\n index: output.index,\r\n exportToEditor: output.hasOwnProperty('exportToEditor') ? output.exportToEditor : true\r\n };\r\n });\r\n}\r\n\r\nfunction initializeDefaultValues(defaultValues, inputsMetadata) {\r\n Object.keys(inputsMetadata).forEach((name) => {\r\n const defaultValue = inputsMetadata[name].default;\r\n if (defaultValue === undefined) return;\r\n\r\n if (inputsMetadata[name].type.defaultUnit) {\r\n defaultValues[name] = {\r\n unit: inputsMetadata[name].type.defaultUnit,\r\n value: defaultValue\r\n };\r\n } else {\r\n defaultValues[name] = defaultValue;\r\n }\r\n });\r\n}\r\n\r\nfunction defineNode(opts) {\r\n if (!opts.category) {\r\n throw new Error('Node must have a category');\r\n }\r\n\r\n if (!opts.name) {\r\n throw new Error('Node must have a name');\r\n }\r\n\r\n const metadata = {\r\n inputs: {},\r\n outputs: {},\r\n category: opts.category,\r\n dynamicports: opts.dynamicports,\r\n exportDynamicPorts: opts.exportDynamicPorts,\r\n useVariants: opts.useVariants,\r\n allowChildren: opts.allowChildren,\r\n allowChildrenWithCategory: opts.allowChildrenWithCategory,\r\n singleton: opts.singleton,\r\n connectionPanel: opts.connectionPanel,\r\n allowAsChild: opts.allowAsChild,\r\n visualStates: opts.visualStates,\r\n panels: opts.panels,\r\n color: opts.color,\r\n usePortAsLabel: opts.usePortAsLabel,\r\n portLabelTruncationMode: opts.portLabelTruncationMode,\r\n name: opts.name,\r\n displayNodeName: opts.displayNodeName || opts.displayName,\r\n deprecated: opts.deprecated,\r\n haveComponentPorts: opts.haveComponentPorts,\r\n version: opts.version,\r\n module: opts.module,\r\n docs: opts.docs,\r\n allowAsExportRoot: opts.allowAsExportRoot,\r\n nodeDoubleClickAction: opts.nodeDoubleClickAction,\r\n searchTags: opts.searchTags\r\n };\r\n\r\n opts._internal = opts._internal || {};\r\n\r\n //prototypeExtensions - old API\r\n //methods - new API\r\n opts.prototypeExtensions = opts.methods || opts.prototypeExtensions || {};\r\n opts.inputs = opts.inputs || {};\r\n opts.outputs = opts.outputs || {};\r\n opts.initialize = opts.initialize || function () {};\r\n\r\n let inputs = {};\r\n\r\n registerInputs(inputs, metadata, opts.inputs);\r\n registerOutputsMetadata(metadata, opts.outputs);\r\n function NodeConstructor(context, id) {\r\n Node.call(this, context, id);\r\n }\r\n\r\n Object.keys(opts.prototypeExtensions).forEach(function (propName) {\r\n if (!opts.prototypeExtensions[propName].value) {\r\n opts.prototypeExtensions[propName] = {\r\n value: opts.prototypeExtensions[propName]\r\n };\r\n }\r\n });\r\n\r\n NodeConstructor.prototype = Object.create(Node.prototype, opts.prototypeExtensions);\r\n Object.defineProperty(NodeConstructor.prototype, 'name', {\r\n value: opts.name\r\n });\r\n\r\n if (opts.getInspectInfo) NodeConstructor.prototype.getInspectInfo = opts.getInspectInfo;\r\n if (opts.nodeScopeDidInitialize) NodeConstructor.prototype.nodeScopeDidInitialize = opts.nodeScopeDidInitialize;\r\n\r\n const nodeDefinition = function (context, id, nodeScope) {\r\n const node = new NodeConstructor(context, id);\r\n\r\n //create all inputs. Use the inputs object for setters that don't have state and can be shared\r\n node._inputs = Object.create(inputs);\r\n\r\n //all inputs that use the valueChangedToTrue have state and need to be instanced\r\n Object.keys(opts.inputs).forEach(function (name) {\r\n var input = opts.inputs[name];\r\n if (input.valueChangedToTrue) {\r\n node._inputs[name] = {\r\n set: EdgeTriggeredInput.createSetter({\r\n valueChangedToTrue: input.valueChangedToTrue\r\n })\r\n };\r\n }\r\n });\r\n\r\n Object.keys(opts.outputs).forEach(function (name) {\r\n var output = opts.outputs[name];\r\n if (output.type === 'signal') {\r\n node.registerOutput(name, {\r\n getter: function () {\r\n //signals are always emitted as a sequence of false, true, so this getter is never used\r\n return undefined;\r\n }\r\n });\r\n } else {\r\n node.registerOutput(name, output);\r\n }\r\n });\r\n\r\n opts.numberedInputs && registerNumberedInputs(node, opts.numberedInputs);\r\n\r\n node.nodeScope = nodeScope;\r\n initializeDefaultValues(node._inputValues, metadata.inputs);\r\n\r\n opts.initialize.call(node);\r\n\r\n return node;\r\n };\r\n\r\n nodeDefinition.metadata = metadata;\r\n\r\n if (opts.numberedInputs) registerSetupFunctionForNumberedInputs(nodeDefinition, opts.name, opts.numberedInputs);\r\n\r\n return nodeDefinition;\r\n}\r\n\r\nfunction registerSetupFunctionForNumberedInputs(nodeDefinition, nodeType, numberedInputs) {\r\n const inputNames = Object.keys(numberedInputs);\r\n\r\n if (!inputNames.length) return;\r\n\r\n nodeDefinition.setupNumberedInputDynamicPorts = function (context, graphModel) {\r\n const editorConnection = context.editorConnection;\r\n\r\n if (!editorConnection || !editorConnection.isRunningLocally()) {\r\n return;\r\n }\r\n\r\n function collectPorts(node, inputName, input) {\r\n const connections = node.component.getConnectionsTo(node.id).map((c) => c.targetPort);\r\n\r\n const allPortNames = Object.keys(node.parameters).concat(connections);\r\n const portNames = allPortNames.filter((p) => p.startsWith(inputName + ' '));\r\n\r\n //Figure out how many we need to create\r\n //It needs to be the highest index + 1\r\n //Only parameters with values are present, e.g. input 3 can be missing even if input 4 is defined\r\n const maxIndex = portNames.length\r\n ? 1 + Math.max(...portNames.map((p) => Number(p.slice(inputName.length + 1))))\r\n : 0;\r\n const numPorts = maxIndex + 1;\r\n\r\n const ports = [];\r\n\r\n for (let i = 0; i < numPorts; i++) {\r\n const port = {\r\n name: inputName + ' ' + i,\r\n displayName: (input.displayPrefix || inputName) + ' ' + i,\r\n type: input.type,\r\n plug: 'input',\r\n group: input.group\r\n };\r\n\r\n if (input.hasOwnProperty('index')) {\r\n port.index = input.index + i;\r\n }\r\n\r\n ports.push(port);\r\n }\r\n\r\n return ports;\r\n }\r\n\r\n function updatePorts(node) {\r\n const ports = inputNames.map((inputName) => collectPorts(node, inputName, numberedInputs[inputName])).flat();\r\n editorConnection.sendDynamicPorts(node.id, ports);\r\n }\r\n\r\n graphModel.on('nodeAdded.' + nodeType, (node) => {\r\n updatePorts(node);\r\n node.on('parameterUpdated', () => {\r\n updatePorts(node);\r\n });\r\n\r\n node.on('inputConnectionAdded', () => {\r\n updatePorts(node);\r\n });\r\n\r\n node.on('inputConnectionRemoved', () => {\r\n updatePorts(node);\r\n });\r\n });\r\n };\r\n}\r\n\r\nfunction extend(obj1, obj2) {\r\n for (var p in obj2) {\r\n if (p === 'initialize' && obj1.initialize) {\r\n var oldInit = obj1.initialize;\r\n obj1.initialize = function () {\r\n oldInit.call(this);\r\n obj2.initialize.call(this);\r\n };\r\n } else if (obj2[p] && obj2[p].constructor === Object) {\r\n obj1[p] = extend(obj1[p] || {}, obj2[p]);\r\n } else if (obj2[p] && obj2[p].constructor === Array && obj1[p] && obj1[p].constructor == Array) {\r\n obj1[p] = obj1[p].concat(obj2[p]);\r\n } else {\r\n obj1[p] = obj2[p];\r\n }\r\n }\r\n return obj1;\r\n}\r\n\r\nmodule.exports = {\r\n defineNode: defineNode,\r\n extend: extend\r\n};\r\n","'use strict';\r\n\r\nfunction formatDynamicPorts(nodeMetadata) {\r\n const dynamicports = [];\r\n\r\n for (const dp of nodeMetadata.dynamicports) {\r\n if (dp.ports || dp.template || dp.port || dp.channelPort) {\r\n //same format as editor expects, no need to transform it\r\n dynamicports.push(dp);\r\n } else if (dp.inputs || dp.outputs) {\r\n //inputs and outputs is just list of names\r\n //need to pull the metadata from the inputs/outputs since they\r\n //won't be registered by the editor (it's either a regular port\r\n // or a dynamic port, can't register both)\r\n const ports = [];\r\n\r\n if (dp.inputs) {\r\n for (const inputName of dp.inputs) {\r\n ports.push(formatPort(inputName, nodeMetadata.inputs[inputName], 'input'));\r\n }\r\n }\r\n\r\n if (dp.outputs) {\r\n for (const outputName of dp.outputs) {\r\n ports.push(formatPort(outputName, nodeMetadata.outputs[outputName], 'output'));\r\n }\r\n }\r\n\r\n const dynamicPortGroup = {\r\n name: dp.name || 'conditionalports/basic',\r\n condition: dp.condition,\r\n ports\r\n };\r\n\r\n dynamicports.push(dynamicPortGroup);\r\n }\r\n }\r\n\r\n return dynamicports;\r\n}\r\n\r\nfunction formatPort(portName, portData, plugType) {\r\n var port = {\r\n name: portName,\r\n type: portData.type,\r\n plug: plugType\r\n };\r\n if (portData.group) {\r\n port.group = portData.group;\r\n }\r\n if (portData.displayName) {\r\n port.displayName = portData.displayName;\r\n }\r\n if (portData.description) {\r\n port.description = portData.description;\r\n }\r\n if (portData.editorName) {\r\n port.editorName = portData.editorName;\r\n }\r\n if (portData.default !== undefined) {\r\n port.default = portData.default;\r\n }\r\n if (portData.hasOwnProperty('index')) {\r\n port.index = portData.index;\r\n }\r\n if (portData.tooltip) {\r\n port.tooltip = portData.tooltip;\r\n }\r\n if (portData.tab) {\r\n port.tab = portData.tab;\r\n }\r\n if (portData.popout) {\r\n port.popout = portData.popout;\r\n }\r\n if (portData.allowVisualStates) {\r\n port.allowVisualStates = portData.allowVisualStates;\r\n }\r\n return port;\r\n}\r\n\r\nfunction generateNodeLibrary(nodeRegister) {\r\n var obj = {\r\n //note: needs to include ALL types\r\n typecasts: [\r\n {\r\n from: 'string',\r\n to: ['number', 'boolean', 'image', 'color', 'enum', 'textStyle', 'dimension', 'array', 'object']\r\n },\r\n {\r\n from: 'boolean',\r\n to: ['number', 'string', 'signal']\r\n },\r\n {\r\n from: 'number',\r\n to: ['boolean', 'string', 'dimension']\r\n },\r\n {\r\n from: 'date',\r\n to: ['string']\r\n },\r\n {\r\n from: 'signal',\r\n to: ['boolean', 'number']\r\n },\r\n {\r\n from: 'image',\r\n to: []\r\n },\r\n {\r\n from: 'cloudfile',\r\n to: ['string', 'image']\r\n },\r\n {\r\n from: 'color',\r\n to: []\r\n },\r\n {\r\n from: 'enum',\r\n to: []\r\n },\r\n {\r\n from: 'object',\r\n to: []\r\n },\r\n {\r\n from: 'domelement',\r\n to: []\r\n },\r\n {\r\n from: 'reference',\r\n to: []\r\n },\r\n {\r\n from: 'font',\r\n to: []\r\n },\r\n {\r\n from: 'textStyle',\r\n to: ['string']\r\n },\r\n {\r\n // Collection is deprecated but supported via typecasts\r\n from: 'collection',\r\n to: ['array']\r\n },\r\n {\r\n from: 'array',\r\n to: ['collection']\r\n }\r\n ],\r\n dynamicports: [\r\n {\r\n type: 'conditionalports',\r\n name: 'basic'\r\n },\r\n {\r\n type: 'expand',\r\n name: 'basic'\r\n }\r\n ],\r\n colors: {\r\n nodes: {\r\n component: {\r\n base: '#643D8B',\r\n baseHighlighted: '#79559b',\r\n header: '#4E2877',\r\n headerHighlighted: '#643d8b',\r\n outline: '#4E2877',\r\n outlineHighlighted: '#b58900',\r\n text: '#dbd0e4'\r\n },\r\n visual: {\r\n base: '#315272',\r\n baseHighlighted: '#4d6784',\r\n header: '#173E5D',\r\n headerHighlighted: '#315272',\r\n outline: '#173E5D',\r\n outlineHighlighted: '#b58900',\r\n text: '#cfd5de'\r\n },\r\n data: {\r\n base: '#465524',\r\n baseHighlighted: '#5b6a37',\r\n header: '#314110',\r\n headerHighlighted: '#465524',\r\n outline: '#314110',\r\n outlineHighlighted: '#b58900',\r\n text: '#d2d6c5'\r\n },\r\n javascript: {\r\n base: '#7E3660',\r\n baseHighlighted: '#944e74',\r\n header: '#67214B',\r\n headerHighlighted: '#7e3660',\r\n outline: '#67214B',\r\n outlineHighlighted: '#d57bab',\r\n text: '#e4cfd9'\r\n },\r\n default: {\r\n base: '#4C4F59',\r\n baseHighlighted: '#62656e',\r\n header: '#373B45',\r\n headerHighlighted: '#4c4f59',\r\n outline: '#373B45',\r\n outlineHighlighted: '#b58900',\r\n text: '#d3d4d6'\r\n }\r\n },\r\n connections: {\r\n signal: {\r\n normal: '#006f82',\r\n highlighted: '#7ec2cf',\r\n pulsing: '#ffffff'\r\n },\r\n default: {\r\n normal: '#875d00',\r\n highlighted: '#e5ae32',\r\n pulsing: '#ffffff'\r\n }\r\n }\r\n },\r\n nodetypes: [\r\n {\r\n name: 'Component Children',\r\n shortDesc: 'This node is a placeholder for where children of this component will be inserted.',\r\n docs: 'https://docs.noodl.net/nodes/component-utilities/component-children',\r\n color: 'component',\r\n allowAsChild: true,\r\n category: 'Visual',\r\n haveComponentChildren: ['Visual']\r\n }\r\n ]\r\n };\r\n\r\n var nodeTypes = Object.keys(nodeRegister._constructors);\r\n\r\n nodeTypes.forEach(function (type) {\r\n var nodeMetadata = nodeRegister._constructors[type].metadata;\r\n\r\n var nodeObj = {\r\n name: type,\r\n searchTags: nodeMetadata.searchTags\r\n };\r\n obj.nodetypes.push(nodeObj);\r\n\r\n if (nodeMetadata.version) {\r\n nodeObj.version = nodeMetadata.version;\r\n }\r\n if (nodeMetadata.displayNodeName) {\r\n nodeObj.displayNodeName = nodeMetadata.displayNodeName;\r\n }\r\n if (nodeMetadata.nodeDoubleClickAction) {\r\n nodeObj.nodeDoubleClickAction = nodeMetadata.nodeDoubleClickAction;\r\n }\r\n if (nodeMetadata.shortDesc) {\r\n nodeObj.shortDesc = nodeMetadata.shortDesc;\r\n }\r\n if (nodeMetadata.module) {\r\n nodeObj.module = nodeMetadata.module;\r\n }\r\n if (nodeMetadata.deprecated) {\r\n nodeObj.deprecated = true;\r\n }\r\n if (nodeMetadata.haveComponentPorts) {\r\n nodeObj.haveComponentPorts = true;\r\n }\r\n if (nodeMetadata.category === 'Visual') {\r\n nodeObj.allowAsChild = true;\r\n nodeObj.allowAsExportRoot = true;\r\n nodeObj.color = 'visual';\r\n }\r\n\r\n if (nodeMetadata.allowAsExportRoot !== undefined) {\r\n nodeObj.allowAsExportRoot = nodeMetadata.allowAsExportRoot;\r\n }\r\n\r\n if (nodeMetadata.allowChildren) {\r\n nodeObj.allowChildrenWithCategory = ['Visual'];\r\n nodeObj.color = 'visual';\r\n }\r\n if (nodeMetadata.allowChildrenWithCategory) {\r\n nodeObj.allowChildrenWithCategory = nodeMetadata.allowChildrenWithCategory;\r\n }\r\n if (nodeMetadata.singleton) {\r\n nodeObj.singleton = true;\r\n }\r\n if (nodeMetadata.allowAsChild) {\r\n nodeObj.allowAsChild = true;\r\n }\r\n if (nodeMetadata.docs) {\r\n nodeObj.docs = nodeMetadata.docs;\r\n }\r\n if (nodeMetadata.shortDocs) {\r\n nodeObj.shortDocs = nodeMetadata.shortDocs;\r\n } else if (nodeMetadata.docs && nodeMetadata.docs.indexOf('https://docs.noodl.net') === 0) {\r\n nodeObj.shortDocs = nodeMetadata.docs.replace('/#', '') + '-short.md';\r\n }\r\n nodeObj.category = nodeMetadata.category;\r\n\r\n if (nodeMetadata.panels) {\r\n nodeObj.panels = nodeMetadata.panels;\r\n }\r\n if (nodeMetadata.usePortAsLabel) {\r\n nodeObj.usePortAsLabel = nodeMetadata.usePortAsLabel;\r\n nodeObj.portLabelTruncationMode = nodeMetadata.portLabelTruncationMode;\r\n }\r\n if (nodeMetadata.color) {\r\n nodeObj.color = nodeMetadata.color;\r\n }\r\n if (nodeMetadata.dynamicports) {\r\n nodeObj.dynamicports = formatDynamicPorts(nodeMetadata);\r\n }\r\n if (nodeMetadata.exportDynamicPorts) {\r\n nodeObj.exportDynamicPorts = nodeMetadata.exportDynamicPorts;\r\n }\r\n if (nodeMetadata.visualStates) {\r\n nodeObj.visualStates = nodeMetadata.visualStates;\r\n }\r\n if (nodeMetadata.useVariants) {\r\n nodeObj.useVariants = nodeMetadata.useVariants;\r\n }\r\n if (nodeMetadata.connectionPanel) {\r\n nodeObj.connectionPanel = nodeMetadata.connectionPanel;\r\n }\r\n nodeObj.ports = [];\r\n\r\n var dynamicports = nodeObj.dynamicports || [];\r\n var selectorNames = {};\r\n var conditionalPortNames = {};\r\n\r\n //flag conditional ports so they don't get added from the normal ports, making them appear twice in the export\r\n /* dynamicports.filter(d=> d.name === 'conditionalports/basic')\r\n .forEach(d=> {\r\n d.ports.forEach(port=> {\r\n conditionalPortNames[port.plug + '/' + port.name] = true;\r\n });\r\n });*/\r\n\r\n //same for channel ports\r\n dynamicports\r\n .filter((d) => d.channelPort !== undefined)\r\n .forEach((port) => {\r\n conditionalPortNames[port.channelPort.plug + '/' + port.channelPort.name] = true;\r\n });\r\n\r\n if (dynamicports.length) {\r\n nodeObj.dynamicports = dynamicports;\r\n }\r\n\r\n Object.keys(nodeMetadata.inputs).forEach(function (inputName) {\r\n if (\r\n selectorNames.hasOwnProperty('input/' + inputName) ||\r\n conditionalPortNames.hasOwnProperty('input/' + inputName)\r\n ) {\r\n //this is a selector or dynamic port. It's already been registered\r\n return;\r\n }\r\n var port = nodeMetadata.inputs[inputName];\r\n if (port.exportToEditor === false) {\r\n return;\r\n }\r\n\r\n nodeObj.ports.push(formatPort(inputName, port, 'input'));\r\n });\r\n\r\n function exportOutput(name, output) {\r\n var port = {\r\n name: name,\r\n type: output.type,\r\n plug: 'output'\r\n };\r\n if (output.group) {\r\n port.group = output.group;\r\n }\r\n if (output.displayName) {\r\n port.displayName = output.displayName;\r\n }\r\n if (output.editorName) {\r\n port.editorName = output.editorName;\r\n }\r\n if (output.hasOwnProperty('index')) {\r\n port.index = output.index;\r\n }\r\n nodeObj.ports.push(port);\r\n }\r\n\r\n Object.keys(nodeMetadata.outputs).forEach(function (prop) {\r\n if (selectorNames.hasOwnProperty('output/' + prop) || conditionalPortNames.hasOwnProperty('output/' + prop)) {\r\n //this is a selector or dynamic port. It's already been registered\r\n return;\r\n }\r\n\r\n var output = nodeMetadata.outputs[prop];\r\n exportOutput(prop, output);\r\n });\r\n });\r\n\r\n const coreNodes = [\r\n {\r\n name: 'UI Elements',\r\n description: 'Buttons, inputs, containers, media',\r\n type: 'visual',\r\n subCategories: [\r\n {\r\n name: 'Basic Elements',\r\n items: ['Group', 'net.noodl.visual.columns', 'Text', 'Image', 'Video', 'Circle', 'net.noodl.visual.icon']\r\n },\r\n {\r\n name: 'UI Controls',\r\n items: [\r\n 'net.noodl.controls.button',\r\n 'net.noodl.controls.checkbox',\r\n 'net.noodl.controls.options',\r\n 'net.noodl.controls.radiobutton',\r\n 'Radio Button Group',\r\n 'net.noodl.controls.range',\r\n 'net.noodl.controls.textinput'\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n name: 'Navigation & Popups',\r\n description: 'Page routing, navigation, popups',\r\n type: 'logic',\r\n subCategories: [\r\n {\r\n name: 'Navigation',\r\n items: ['Router', 'RouterNavigate', 'PageInputs', 'net.noodl.externallink', 'PageStackNavigateToPath']\r\n },\r\n {\r\n name: 'Component Stack',\r\n items: ['Page Stack', 'PageStackNavigate', 'PageStackNavigateBack']\r\n },\r\n {\r\n name: 'Popups',\r\n items: ['NavigationShowPopup', 'NavigationClosePopup']\r\n }\r\n ]\r\n },\r\n {\r\n name: 'Logic & Utilities',\r\n description: 'Logic, events, string manipulation',\r\n type: 'logic',\r\n subCategories: [\r\n {\r\n name: 'General Utils',\r\n items: [\r\n 'States',\r\n 'Value Changed',\r\n 'Timer',\r\n 'Color Blend',\r\n 'Number Remapper',\r\n 'Counter',\r\n 'Drag',\r\n 'net.noodl.animatetovalue'\r\n ]\r\n },\r\n {\r\n name: 'Logic',\r\n items: ['Boolean To String', 'Switch', 'And', 'Or', 'Condition', 'Inverter']\r\n },\r\n {\r\n name: 'Events',\r\n items: ['Event Sender', 'Event Receiver']\r\n },\r\n {\r\n name: 'String Manipulation',\r\n items: ['Substring', 'String Mapper', 'String Format', 'Date To String', 'Unique Id']\r\n },\r\n {\r\n name: 'System',\r\n items: ['Screen Resolution', 'Open File Picker']\r\n },\r\n {\r\n name: 'Variables',\r\n items: ['String', 'Boolean', 'Color', 'Number']\r\n }\r\n ]\r\n },\r\n {\r\n name: 'Component Utilities',\r\n description: 'Component inputs, outputs & object',\r\n type: 'component',\r\n subCategories: [\r\n {\r\n name: '',\r\n items: [\r\n 'Component Inputs',\r\n 'Component Outputs',\r\n 'Component Children',\r\n 'net.noodl.ComponentObject',\r\n 'net.noodl.ParentComponentObject',\r\n 'net.noodl.SetComponentObjectProperties',\r\n 'net.noodl.SetParentComponentObjectProperties'\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n name: 'Read & Write Data',\r\n description: 'Arrays, objects, cloud data',\r\n type: 'data',\r\n subCategories: [\r\n {\r\n name: '',\r\n items: [\r\n 'RunTasks',\r\n 'For Each',\r\n 'For Each Actions',\r\n 'Model2',\r\n 'SetModelProperties',\r\n 'NewModel',\r\n 'Set Variable',\r\n 'Variable2'\r\n ]\r\n },\r\n {\r\n name: 'Array',\r\n items: [\r\n 'Collection2',\r\n 'CollectionNew',\r\n 'CollectionRemove',\r\n 'CollectionClear',\r\n 'CollectionInsert',\r\n 'Filter Collection',\r\n 'Map Collection',\r\n 'Static Data'\r\n ]\r\n },\r\n {\r\n name: 'Cloud Data',\r\n items: [\r\n 'DbModel2',\r\n 'NewDbModelProperties',\r\n 'FilterDBModels',\r\n 'SetDbModelProperties',\r\n 'DbCollection2',\r\n 'DeleteDbModelProperties',\r\n 'AddDbModelRelation',\r\n 'RemoveDbModelRelation',\r\n 'Cloud File',\r\n 'Upload File',\r\n 'CloudFunction2',\r\n 'DbConfig'\r\n ]\r\n },\r\n {\r\n name: 'User',\r\n items: [\r\n 'net.noodl.user.LogIn',\r\n 'net.noodl.user.LogOut',\r\n 'net.noodl.user.SignUp',\r\n 'net.noodl.user.User',\r\n 'net.noodl.user.SetUserProperties',\r\n 'net.noodl.user.VerifyEmail',\r\n 'net.noodl.user.SendEmailVerification',\r\n 'net.noodl.user.ResetPassword',\r\n 'net.noodl.user.RequestPasswordReset'\r\n ]\r\n },\r\n {\r\n name: 'External Data',\r\n items: ['REST2']\r\n }\r\n ]\r\n },\r\n {\r\n name: 'Custom Code',\r\n description: 'Custom JavaScript and CSS',\r\n type: 'javascript',\r\n subCategories: [\r\n {\r\n name: '',\r\n items: ['Expression', 'JavaScriptFunction', 'Javascript2', 'CSS Definition']\r\n }\r\n ]\r\n },\r\n {\r\n name: 'Cloud Functions',\r\n description: 'Nodes to be used in cloud functions',\r\n type: 'data',\r\n subCategories: [\r\n {\r\n name: '',\r\n items: ['noodl.cloud.request', 'noodl.cloud.response']\r\n },\r\n {\r\n name: 'Cloud Data',\r\n items: ['noodl.cloud.aggregate']\r\n }\r\n ]\r\n }\r\n ];\r\n\r\n obj.nodeIndex = {\r\n coreNodes\r\n };\r\n\r\n const moduleNodes = [];\r\n\r\n nodeTypes.forEach((type) => {\r\n const nodeMetadata = nodeRegister._constructors[type].metadata;\r\n if (nodeMetadata.module) {\r\n moduleNodes.push(type);\r\n }\r\n });\r\n\r\n if (moduleNodes.length) {\r\n obj.nodeIndex.moduleNodes = [\r\n {\r\n name: '',\r\n items: moduleNodes\r\n }\r\n ];\r\n }\r\n\r\n return obj;\r\n}\r\n\r\nmodule.exports = generateNodeLibrary;\r\n","\"use strict\";\r\n\r\nfunction NodeRegister(context) {\r\n this._constructors = {};\r\n this.context = context;\r\n}\r\n\r\nNodeRegister.prototype.register = function(nodeDefinition) {\r\n var name = nodeDefinition.metadata.name;\r\n\r\n this._constructors[name] = nodeDefinition;\r\n};\r\n\r\nNodeRegister.prototype.createNode = function(name, id, nodeScope) {\r\n if(this._constructors.hasOwnProperty(name) === false) {\r\n throw new Error(\"Unknown node type with name \" + name);\r\n }\r\n\r\n return this._constructors[name](this.context, id, nodeScope);\r\n};\r\n\r\nNodeRegister.prototype.getNodeMetadata = function(type) {\r\n if(this._constructors.hasOwnProperty(type) === false) {\r\n throw new Error(\"Unknown node type with name \" + type);\r\n }\r\n\r\n return this._constructors[type].metadata;\r\n};\r\n\r\nNodeRegister.prototype.hasNode = function(type) {\r\n return this._constructors.hasOwnProperty(type);\r\n};\r\n\r\nNodeRegister.prototype.getInputType = function(type, inputName) {\r\n const metadata = this.getNodeMetadata(type);\r\n return metadata.inputs[inputName] && metadata.inputs[inputName].type;\r\n}\r\n\r\nmodule.exports = NodeRegister;","'use strict';\r\n\r\nmodule.exports = {\r\n node: {\r\n name: 'Component Inputs',\r\n shortDesc: 'This node is used to define the inputs of a component.',\r\n docs: 'https://docs.noodl.net/nodes/component-utilities/component-inputs',\r\n panels: [\r\n {\r\n name: 'PortEditor',\r\n context: ['select', 'connectFrom'],\r\n title: 'Inputs',\r\n plug: 'output',\r\n type: {\r\n name: '*'\r\n },\r\n canArrangeInGroups: true\r\n },\r\n {\r\n name: 'PropertyEditor',\r\n hidden: true\r\n }\r\n ],\r\n getInspectInfo() {\r\n return { type: 'value', value: this.nodeScope.componentOwner._internal.inputValues };\r\n },\r\n color: 'component',\r\n haveComponentPorts: true,\r\n category: 'Component Utilities',\r\n methods: {\r\n registerOutputIfNeeded: function (name) {\r\n if (this.hasOutput(name)) {\r\n return;\r\n }\r\n\r\n this.registerOutput(name, {\r\n getter: function () {\r\n return this.nodeScope.componentOwner._internal.inputValues[name];\r\n }\r\n });\r\n },\r\n _updateDependencies: function () {\r\n this.nodeScope.componentOwner.update();\r\n }\r\n }\r\n }\r\n};\r\n","'use strict';\r\n\r\nvar Node = require('../node');\r\nvar NodeScope = require('../nodescope');\r\n\r\nlet componentIdCounter = 0;\r\n\r\nfunction ComponentInstanceNode(context, id, parentNodeScope) {\r\n Node.call(this, context, id);\r\n\r\n this.nodeScope = new NodeScope(context, this);\r\n this.parentNodeScope = parentNodeScope;\r\n this._internal.childRoot = null;\r\n this._internal.componentOutputValues = {};\r\n this._internal.componentOutputs = [];\r\n this._internal.componentInputs = [];\r\n this._internal.inputValues = {};\r\n this._internal.roots = [];\r\n\r\n this._internal.instanceId = '__$ndl_componentInstaceId' + componentIdCounter;\r\n\r\n this.nodeScope.modelScope = parentNodeScope ? parentNodeScope.modelScope : undefined;\r\n\r\n componentIdCounter++;\r\n}\r\n\r\nComponentInstanceNode.prototype = Object.create(Node.prototype, {\r\n setComponentModel: {\r\n value: async function (componentModel) {\r\n this.componentModel = componentModel;\r\n var self = this;\r\n\r\n await this.nodeScope.setComponentModel(componentModel);\r\n\r\n this._internal.componentInputs = this.nodeScope.getNodesWithType('Component Inputs');\r\n this._internal.componentOutputs = this.nodeScope.getNodesWithType('Component Outputs');\r\n\r\n Object.values(componentModel.getInputPorts()).forEach(this.registerComponentInputPort.bind(this));\r\n Object.values(componentModel.getOutputPorts()).forEach(this.registerComponentOutputPort.bind(this));\r\n\r\n const roots = componentModel.roots || [];\r\n this._internal.roots = roots.map((id) => this.nodeScope.getNodeWithId(id));\r\n\r\n componentModel.on(\r\n 'rootAdded',\r\n (id) => {\r\n this._internal.roots.push(this.nodeScope.getNodeWithId(id));\r\n this.forceUpdate();\r\n },\r\n this\r\n );\r\n\r\n componentModel.on(\r\n 'rootRemoved',\r\n function (id) {\r\n const index = this._internal.roots.findIndex((root) => root.id === id);\r\n if (index !== -1) {\r\n this._internal.roots.splice(index, 1);\r\n }\r\n this.forceUpdate();\r\n },\r\n this\r\n );\r\n\r\n componentModel.on('inputPortAdded', this.registerComponentInputPort.bind(this), this);\r\n componentModel.on('outputPortAdded', this.registerComponentOutputPort.bind(this), this);\r\n\r\n componentModel.on(\r\n 'inputPortRemoved',\r\n function (port) {\r\n if (self.hasInput(port.name)) {\r\n self.deregisterInput(port.name);\r\n }\r\n },\r\n this\r\n );\r\n componentModel.on(\r\n 'outputPortRemoved',\r\n function (port) {\r\n if (this.hasOutput(port.name)) {\r\n self.deregisterOutput(port.name);\r\n }\r\n },\r\n this\r\n );\r\n\r\n componentModel.on(\r\n 'nodeAdded',\r\n function (node) {\r\n if (node.type === 'Component Inputs') {\r\n self._internal.componentInputs.push(self.nodeScope.getNodeWithId(node.id));\r\n } else if (node.type === 'Component Outputs') {\r\n self._internal.componentOutputs.push(self.nodeScope.getNodeWithId(node.id));\r\n }\r\n },\r\n this\r\n );\r\n\r\n componentModel.on(\r\n 'nodeRemoved',\r\n function (node) {\r\n function removeNodesWithId(array, id) {\r\n return array.filter((e) => e.id !== id);\r\n }\r\n if (node.type === 'Component Inputs') {\r\n self._internal.componentInputs = removeNodesWithId(self._internal.componentInputs, node.id);\r\n } else if (node.type === 'Component Outputs') {\r\n self._internal.componentOutputs = removeNodesWithId(self._internal.componentOutputs, node.id);\r\n }\r\n },\r\n this\r\n );\r\n\r\n componentModel.on(\r\n 'renamed',\r\n function (event) {\r\n self.name = event.newName;\r\n },\r\n this\r\n );\r\n }\r\n },\r\n _onNodeDeleted: {\r\n value: function () {\r\n if (this.componentModel) {\r\n this.componentModel.removeListenersWithRef(this);\r\n this.componentModel = undefined;\r\n }\r\n\r\n this.nodeScope.reset();\r\n Node.prototype._onNodeDeleted.call(this);\r\n }\r\n },\r\n registerComponentInputPort: {\r\n value: function (port) {\r\n this.registerInput(port.name, {\r\n set: function (value) {\r\n this._internal.inputValues[port.name] = value;\r\n this._internal.componentInputs.forEach(function (componentInput) {\r\n componentInput.registerOutputIfNeeded(port.name);\r\n componentInput.flagOutputDirty(port.name);\r\n });\r\n }\r\n });\r\n }\r\n },\r\n registerComponentOutputPort: {\r\n value: function (port) {\r\n this.registerOutput(port.name, {\r\n getter: function () {\r\n return this._internal.componentOutputValues[port.name];\r\n }\r\n });\r\n }\r\n },\r\n setOutputFromComponentOutput: {\r\n value: function (name, value) {\r\n if (this.hasOutput(name) === false) {\r\n return;\r\n }\r\n\r\n this._internal.creatorCallbacks &&\r\n this._internal.creatorCallbacks.onOutputChanged &&\r\n this._internal.creatorCallbacks.onOutputChanged(name, value, this._internal.componentOutputValues[name]);\r\n\r\n this._internal.componentOutputValues[name] = value;\r\n this.flagOutputDirty(name);\r\n }\r\n },\r\n setChildRoot: {\r\n value: function (node) {\r\n const prevChildRoot = this._internal.childRoot;\r\n const newChildRoot = node;\r\n\r\n this._internal.childRoot = newChildRoot;\r\n\r\n if (this.model && this.model.children) {\r\n const parentNodeScope = this.parentNodeScope;\r\n\r\n const children = this.model.children\r\n .filter((child) => child.type !== 'Component Children')\r\n .map((child) => parentNodeScope.getNodeWithId(child.id));\r\n\r\n if (prevChildRoot) {\r\n for (let i = 0; i < children.length; i++) {\r\n if (prevChildRoot.isChild(children[i])) {\r\n prevChildRoot.removeChild(children[i]);\r\n }\r\n }\r\n }\r\n\r\n if (newChildRoot) {\r\n for (let i = 0; i < children.length; i++) {\r\n const child = children[i];\r\n const index = child.model.parent.children.indexOf(child.model);\r\n this.addChild(child, index);\r\n }\r\n }\r\n }\r\n }\r\n },\r\n getChildRootIndex: {\r\n value: function () {\r\n if (!this._internal.childRoot || !this._internal.childRoot.model || !this._internal.childRoot.model.children) {\r\n return 0;\r\n }\r\n\r\n var children = this._internal.childRoot.model.children;\r\n\r\n for (var i = 0; i < children.length; i++) {\r\n if (children[i].type === 'Component Children') {\r\n return i;\r\n }\r\n }\r\n\r\n return 0;\r\n }\r\n },\r\n getChildRoot: {\r\n value: function () {\r\n if (this._internal.childRoot) {\r\n return this._internal.childRoot;\r\n }\r\n return null;\r\n }\r\n },\r\n getRoots: {\r\n value: function () {\r\n return this._internal.roots;\r\n }\r\n },\r\n /** Added for SSR Support */\r\n triggerDidMount: {\r\n value: function () {\r\n this._internal.roots.forEach((root) => {\r\n root.triggerDidMount && root.triggerDidMount();\r\n });\r\n }\r\n },\r\n render: {\r\n value: function () {\r\n if (this._internal.roots.length === 0) {\r\n return null;\r\n }\r\n\r\n return this._internal.roots[0].render();\r\n }\r\n },\r\n setChildIndex: {\r\n value: function (childIndex) {\r\n // NOTE: setChildIndex can be undefined when it is not a React node,\r\n // but still a visual node like the foreach (Repeater) node.\r\n this.getRoots().forEach((root) => root.setChildIndex && root.setChildIndex(childIndex));\r\n }\r\n },\r\n addChild: {\r\n value: function (child, index) {\r\n this.getChildRoot().addChild(child, index + this.getChildRootIndex());\r\n }\r\n },\r\n removeChild: {\r\n value: function (child) {\r\n this.getChildRoot().removeChild(child);\r\n }\r\n },\r\n getChildren: {\r\n value: function (child) {\r\n const childRoot = this.getChildRoot();\r\n return childRoot ? childRoot.getChildren() : [];\r\n }\r\n },\r\n isChild: {\r\n value: function (child) {\r\n if (!this.getChildRoot()) {\r\n return false;\r\n }\r\n\r\n return this.getChildRoot().isChild(child);\r\n }\r\n },\r\n contains: {\r\n value: function (node) {\r\n return this.getRoots().some((root) => root.contains && root.contains(node));\r\n }\r\n },\r\n _performDirtyUpdate: {\r\n value: function () {\r\n Node.prototype._performDirtyUpdate.call(this);\r\n\r\n var componentInputs = this._internal.componentInputs;\r\n for (var i = 0, len = componentInputs.length; i < len; i++) {\r\n componentInputs[i].flagDirty();\r\n }\r\n\r\n this._internal.componentOutputs.forEach(function (componentOutput) {\r\n componentOutput.flagDirty();\r\n });\r\n }\r\n },\r\n getRef: {\r\n value: function () {\r\n const root = this._internal.roots[0];\r\n return root ? root.getRef() : undefined;\r\n }\r\n },\r\n update: {\r\n value: function () {\r\n Node.prototype.update.call(this);\r\n\r\n this._internal.componentOutputs.forEach(function (componentOutput) {\r\n componentOutput.update();\r\n });\r\n }\r\n },\r\n forceUpdate: {\r\n //this is only used when roots are added or removed\r\n value: function () {\r\n if (!this.parent) return;\r\n\r\n //the parent will need to re-render the roots of this component instance\r\n //TODO: make this use a cleaner API, and only invalidate the affected child, instead of all children\r\n this.parent.cachedChildren = undefined;\r\n this.parent.forceUpdate();\r\n }\r\n },\r\n getInstanceId: {\r\n value() {\r\n return this._internal.instanceId;\r\n }\r\n }\r\n});\r\n\r\nComponentInstanceNode.prototype.constructor = ComponentInstanceNode;\r\nmodule.exports = ComponentInstanceNode;\r\n","'use strict';\r\n\r\nmodule.exports = {\r\n node: {\r\n category: 'Component Utilities',\r\n name: 'Component Outputs',\r\n shortDesc: 'This node is used to define the outputs of a component.',\r\n docs: 'https://docs.noodl.net/nodes/component-utilities/component-outputs',\r\n panels: [\r\n {\r\n name: 'PortEditor',\r\n context: ['select', 'connectTo'],\r\n title: 'Outputs',\r\n plug: 'input',\r\n type: {\r\n name: '*'\r\n },\r\n canArrangeInGroups: true\r\n },\r\n {\r\n name: 'PropertyEditor',\r\n hidden: true\r\n }\r\n ],\r\n color: 'component',\r\n haveComponentPorts: true,\r\n prototypeExtensions: {\r\n registerInputIfNeeded: function (name) {\r\n if (this.hasInput(name)) {\r\n return;\r\n }\r\n\r\n this.registerInput(name, {\r\n set: function (value) {\r\n this.nodeScope.componentOwner.setOutputFromComponentOutput(name, value);\r\n }\r\n });\r\n }\r\n }\r\n }\r\n};\r\n","'use strict';\r\n\r\nconst AndNode = {\r\n name: 'And',\r\n docs: 'https://docs.noodl.net/nodes/logic/and',\r\n category: 'Logic',\r\n initialize: function () {\r\n this._internal.inputs = [];\r\n },\r\n getInspectInfo() {\r\n return and(this._internal.inputs);\r\n },\r\n numberedInputs: {\r\n input: {\r\n displayPrefix: 'Input',\r\n type: 'boolean',\r\n createSetter(index) {\r\n return function (value) {\r\n value = value ? true : false;\r\n\r\n if (this._internal.inputs[index] === value) {\r\n return;\r\n }\r\n\r\n this._internal.inputs[index] = value;\r\n const result = and(this._internal.inputs);\r\n\r\n if (this._internal.result !== result) {\r\n this._internal.result = result;\r\n this.flagOutputDirty('result');\r\n }\r\n };\r\n }\r\n }\r\n },\r\n outputs: {\r\n result: {\r\n type: 'boolean',\r\n displayName: 'Result',\r\n get() {\r\n return this._internal.result;\r\n }\r\n }\r\n }\r\n};\r\n\r\nmodule.exports = {\r\n node: AndNode\r\n};\r\n\r\nfunction and(values) {\r\n //if none are false, then return true\r\n return values.length > 0 && values.some((v) => !v) === false;\r\n}\r\n","'use strict';\r\n\r\nconst BooleanToStringNode = {\r\n name: 'Boolean To String',\r\n docs: 'https://docs.noodl.net/nodes/utilities/boolean-to-string',\r\n category: 'Utilities',\r\n initialize: function () {\r\n this._internal.inputs = [];\r\n this._internal.currentSelectedIndex = 0;\r\n this._internal.indexChanged = false;\r\n\r\n this._internal.trueString = '';\r\n this._internal.falseString = '';\r\n },\r\n inputs: {\r\n trueString: {\r\n displayName: 'String for true',\r\n type: 'string',\r\n set: function (value) {\r\n if (this._internal.trueString === value) return;\r\n this._internal.trueString = value;\r\n\r\n if (this._internal.currentInput) {\r\n this.flagOutputDirty('currentValue');\r\n }\r\n }\r\n },\r\n falseString: {\r\n displayName: 'String for false',\r\n type: 'string',\r\n set: function (value) {\r\n if (this._internal.falseString === value) return;\r\n this._internal.falseString = value;\r\n\r\n if (!this._internal.currentInput) {\r\n this.flagOutputDirty('currentValue');\r\n }\r\n }\r\n },\r\n input: {\r\n type: { name: 'boolean' },\r\n displayName: 'Selector',\r\n set: function (value) {\r\n if (this._internal.currentInput === value) return;\r\n\r\n this._internal.currentInput = value;\r\n this.flagOutputDirty('currentValue');\r\n this.sendSignalOnOutput('inputChanged');\r\n }\r\n }\r\n },\r\n outputs: {\r\n currentValue: {\r\n type: 'string',\r\n displayName: 'Current Value',\r\n group: 'Value',\r\n getter: function () {\r\n return this._internal.currentInput ? this._internal.trueString : this._internal.falseString;\r\n }\r\n },\r\n inputChanged: {\r\n type: 'signal',\r\n displayName: 'Selector Changed',\r\n group: 'Signals'\r\n }\r\n }\r\n};\r\n\r\nmodule.exports = {\r\n node: BooleanToStringNode\r\n};\r\n","'use strict';\r\n\r\nconst ConditionNode = {\r\n name: 'Condition',\r\n docs: 'https://docs.noodl.net/nodes/utilities/logic/condition',\r\n category: 'Logic',\r\n initialize: function () {},\r\n getInspectInfo() {\r\n const condition = this.getInputValue('condition');\r\n let value;\r\n if (condition === undefined) {\r\n value = '[No input]';\r\n }\r\n value = condition;\r\n return [\r\n {\r\n type: 'value',\r\n value\r\n }\r\n ];\r\n },\r\n inputs: {\r\n condition: {\r\n type: 'boolean',\r\n displayName: 'Condition',\r\n group: 'General',\r\n set(value) {\r\n if (!this.isInputConnected('eval')) {\r\n // Evaluate right away\r\n this.scheduleEvaluate();\r\n }\r\n }\r\n },\r\n eval: {\r\n type: 'signal',\r\n displayName: 'Evaluate',\r\n group: 'Actions',\r\n valueChangedToTrue() {\r\n this.scheduleEvaluate();\r\n }\r\n }\r\n },\r\n outputs: {\r\n ontrue: {\r\n type: 'signal',\r\n displayName: 'On True',\r\n group: 'Events'\r\n },\r\n onfalse: {\r\n type: 'signal',\r\n displayName: 'On False',\r\n group: 'Events'\r\n },\r\n result: {\r\n type: 'boolean',\r\n displayName: 'Is True',\r\n group: 'Booleans',\r\n get() {\r\n return !!this.getInputValue('condition');\r\n }\r\n },\r\n isfalse: {\r\n type: 'boolean',\r\n displayName: 'Is False',\r\n group: 'Booleans',\r\n get() {\r\n return !this.getInputValue('condition');\r\n }\r\n }\r\n },\r\n methods: {\r\n scheduleEvaluate() {\r\n this.scheduleAfterInputsHaveUpdated(() => {\r\n this.flagOutputDirty('result');\r\n this.flagOutputDirty('isfalse');\r\n\r\n const condition = this.getInputValue('condition');\r\n this.sendSignalOnOutput(condition ? 'ontrue' : 'onfalse');\r\n });\r\n }\r\n }\r\n};\r\n\r\nmodule.exports = {\r\n node: ConditionNode\r\n};\r\n","'use strict';\r\n\r\nconst CounterNode = {\r\n name: 'Counter',\r\n docs: 'https://docs.noodl.net/nodes/math/counter',\r\n category: 'Math',\r\n initialize: function () {\r\n this._internal.currentValue = 0;\r\n this._internal.startValue = 0;\r\n this._internal.startValueSet = false;\r\n\r\n this._internal.limitsEnabled = false;\r\n this._internal.limitsMin = 0;\r\n this._internal.limitsMax = 0;\r\n },\r\n getInspectInfo() {\r\n return 'Count: ' + this._internal.currentValue;\r\n },\r\n inputs: {\r\n increase: {\r\n group: 'Actions',\r\n displayName: 'Increase Count',\r\n valueChangedToTrue: function () {\r\n if (this._internal.limitsEnabled && this._internal.currentValue >= this._internal.limitsMax) {\r\n return;\r\n }\r\n\r\n this._internal.currentValue++;\r\n this.flagOutputDirty('currentCount');\r\n this.sendSignalOnOutput('countChanged');\r\n }\r\n },\r\n decrease: {\r\n group: 'Actions',\r\n displayName: 'Decrease Count',\r\n valueChangedToTrue: function () {\r\n if (this._internal.limitsEnabled && this._internal.currentValue <= this._internal.limitsMin) {\r\n return;\r\n }\r\n\r\n this._internal.currentValue--;\r\n this.flagOutputDirty('currentCount');\r\n this.sendSignalOnOutput('countChanged');\r\n }\r\n },\r\n reset: {\r\n group: 'Actions',\r\n displayName: 'Reset To Start',\r\n valueChangedToTrue: function () {\r\n if (this.currentValue === 0) {\r\n return;\r\n }\r\n this._internal.currentValue = this._internal.startValue;\r\n this.flagOutputDirty('currentCount');\r\n this.sendSignalOnOutput('countChanged');\r\n }\r\n },\r\n startValue: {\r\n type: 'number',\r\n displayName: 'Start Value',\r\n default: 0,\r\n set: function (value) {\r\n this._internal.startValue = Number(value);\r\n\r\n if (this._internal.startValueSet === false) {\r\n this._internal.startValueSet = true;\r\n this._internal.currentValue = this._internal.startValue;\r\n this.flagOutputDirty('currentCount');\r\n this.sendSignalOnOutput('countChanged');\r\n }\r\n }\r\n },\r\n limitsMin: {\r\n type: {\r\n name: 'number'\r\n },\r\n displayName: 'Min Value',\r\n group: 'Limits',\r\n default: 0,\r\n set: function (value) {\r\n this._internal.limitsMin = Number(value);\r\n }\r\n },\r\n limitsMax: {\r\n type: {\r\n name: 'number'\r\n },\r\n displayName: 'Max Value',\r\n group: 'Limits',\r\n default: 0,\r\n set: function (value) {\r\n this._internal.limitsMax = Number(value);\r\n }\r\n },\r\n limitsEnabled: {\r\n type: {\r\n name: 'boolean'\r\n },\r\n displayName: 'Limits Enabled',\r\n group: 'Limits',\r\n default: false,\r\n set: function (value) {\r\n this._internal.limitsEnabled = value ? true : false;\r\n }\r\n }\r\n },\r\n outputs: {\r\n currentCount: {\r\n displayName: 'Current Count',\r\n type: 'number',\r\n getter: function () {\r\n return this._internal.currentValue;\r\n }\r\n },\r\n countChanged: {\r\n displayName: 'Count Changed',\r\n type: 'signal'\r\n }\r\n }\r\n};\r\n\r\nmodule.exports = {\r\n node: CounterNode\r\n};\r\n","const CloudFile = require('../../../api/cloudfile');\r\n\r\nconst CloudFileNode = {\r\n name: 'Cloud File',\r\n docs: 'https://docs.noodl.net/nodes/data/cloud-data/cloud-file',\r\n category: 'Cloud Services',\r\n color: 'data',\r\n getInspectInfo() {\r\n return this._internal.cloudFile && this._internal.cloudFile.getUrl();\r\n },\r\n outputs: {\r\n url: {\r\n type: 'string',\r\n displayName: 'URL',\r\n group: 'General',\r\n get() {\r\n return this._internal.cloudFile && this._internal.cloudFile.getUrl();\r\n }\r\n },\r\n name: {\r\n type: 'string',\r\n displayName: 'Name',\r\n group: 'General',\r\n get() {\r\n if (!this._internal.cloudFile) return;\r\n\r\n //parse prefixes the file with a guid_\r\n //remove it so the name is the same as the original file name\r\n const n = this._internal.cloudFile.getName().split('_');\r\n return n.length === 1 ? n[0] : n.slice(1).join('_');\r\n }\r\n }\r\n },\r\n inputs: {\r\n file: {\r\n type: 'cloudfile',\r\n displayName: 'Cloud File',\r\n group: 'General',\r\n set(value) {\r\n if (value instanceof CloudFile === false) {\r\n return;\r\n }\r\n this._internal.cloudFile = value;\r\n this.flagOutputDirty('name');\r\n this.flagOutputDirty('url');\r\n }\r\n }\r\n }\r\n};\r\n\r\nmodule.exports = {\r\n node: CloudFileNode\r\n};\r\n","const { Node, EdgeTriggeredInput } = require('../../../../noodl-runtime');\r\n\r\nconst Model = require('../../../model'),\r\n Collection = require('../../../collection'),\r\n CloudStore = require('../../../api/cloudstore'),\r\n JavascriptNodeParser = require('../../../javascriptnodeparser'),\r\n QueryUtils = require('../../../api/queryutils');\r\n\r\nvar DbCollectionNode = {\r\n name: 'DbCollection2',\r\n docs: 'https://docs.noodl.net/nodes/data/cloud-data/query-records',\r\n displayName: 'Query Records',\r\n /* shortDesc: \"A database collection.\",*/\r\n category: 'Cloud Services',\r\n usePortAsLabel: 'collectionName',\r\n color: 'data',\r\n initialize: function () {\r\n var _this = this;\r\n this._internal.queryParameters = {};\r\n\r\n var collectionChangedScheduled = false;\r\n this._internal.collectionChangedCallback = function () {\r\n //this can be called multiple times when adding/removing more than one item\r\n //so optimize by only updating outputs once\r\n if (collectionChangedScheduled) return;\r\n collectionChangedScheduled = true;\r\n\r\n _this.scheduleAfterInputsHaveUpdated(function () {\r\n _this.flagOutputDirty('count');\r\n _this.flagOutputDirty('firstItemId');\r\n _this.flagOutputDirty('isEmpty');\r\n collectionChangedScheduled = false;\r\n });\r\n };\r\n\r\n this._internal.cloudStoreEvents = function (args) {\r\n if (_this.isInputConnected('storageFetch') === true) return;\r\n\r\n if (_this._internal.collection === undefined) return;\r\n if (args.collection !== _this._internal.name) return;\r\n\r\n function _addModelAtCorrectIndex(m) {\r\n if (_this._internal.currentQuery.sort !== undefined) {\r\n // We need to add it at the right index\r\n for (var i = 0; i < _this._internal.collection.size(); i++)\r\n if (QueryUtils.compareObjects(_this._internal.currentQuery.sort, _this._internal.collection.get(i), m) > 0)\r\n break;\r\n\r\n _this._internal.collection.addAtIndex(m, i);\r\n } else {\r\n _this._internal.collection.add(m);\r\n }\r\n\r\n // Make sure we don't exceed limit\r\n let size = _this._internal.collection.size();\r\n if (_this._internal.currentQuery.limit !== undefined && size > _this._internal.currentQuery.limit)\r\n _this._internal.collection.remove(\r\n _this._internal.collection.get(\r\n _this._internal.currentQuery.sort !== undefined && _this._internal.currentQuery.sort[0][0] === '-'\r\n ? size - 1\r\n : 0\r\n )\r\n );\r\n\r\n //Send the array again over the items output to trigger function nodes etc that might be connected\r\n _this.flagOutputDirty('items');\r\n\r\n _this.flagOutputDirty('count');\r\n _this.flagOutputDirty('firstItemId');\r\n _this.flagOutputDirty('isEmpty');\r\n }\r\n\r\n if (args.type === 'create') {\r\n const m = Model.get(args.object.objectId);\r\n if (m !== undefined) {\r\n // Check if the object matches the current query\r\n if (QueryUtils.matchesQuery(m, _this._internal.currentQuery.where)) {\r\n // If matches the query, add the item to results\r\n _addModelAtCorrectIndex(m);\r\n }\r\n }\r\n } else if (args.type === 'save') {\r\n const m = Model.get(args.objectId);\r\n if (m !== undefined) {\r\n const matchesQuery = QueryUtils.matchesQuery(m, _this._internal.currentQuery.where);\r\n\r\n if (!matchesQuery && _this._internal.collection.contains(m)) {\r\n // The record no longer matches the filter, remove it\r\n _this._internal.collection.remove(m);\r\n\r\n //Send the array again over the items output to trigger function nodes etc that might be connected\r\n _this.flagOutputDirty('items');\r\n\r\n _this.flagOutputDirty('count');\r\n _this.flagOutputDirty('firstItemId');\r\n _this.flagOutputDirty('isEmpty');\r\n } else if (matchesQuery && !_this._internal.collection.contains(m)) {\r\n // It's not part of the result collection but now matches they query, add it and resort\r\n _addModelAtCorrectIndex(m);\r\n }\r\n }\r\n } else if (args.type === 'delete') {\r\n const m = Model.get(args.objectId);\r\n if (m !== undefined) {\r\n _this._internal.collection.remove(m);\r\n\r\n //Send the array again over the items output to trigger function nodes etc that might be connected\r\n _this.flagOutputDirty('items');\r\n\r\n _this.flagOutputDirty('count');\r\n _this.flagOutputDirty('firstItemId');\r\n _this.flagOutputDirty('isEmpty');\r\n }\r\n }\r\n };\r\n\r\n // Listening to cloud store events is only for the global model scope, only valid in browser\r\n // in cloud runtime its a nop\r\n const cloudstore = CloudStore.forScope(this.nodeScope.modelScope);\r\n cloudstore.on('save', this._internal.cloudStoreEvents);\r\n cloudstore.on('create', this._internal.cloudStoreEvents);\r\n cloudstore.on('delete', this._internal.cloudStoreEvents);\r\n\r\n this._internal.storageSettings = {};\r\n },\r\n getInspectInfo() {\r\n const collection = this._internal.collection;\r\n if (!collection) {\r\n return { type: 'text', value: '[Not executed yet]' };\r\n }\r\n\r\n return [\r\n {\r\n type: 'value',\r\n value: collection.items\r\n }\r\n ];\r\n },\r\n inputs: {},\r\n outputs: {\r\n items: {\r\n type: 'array',\r\n displayName: 'Items',\r\n group: 'General',\r\n getter: function () {\r\n return this._internal.collection;\r\n }\r\n },\r\n firstItemId: {\r\n type: 'string',\r\n displayName: 'First Record Id',\r\n group: 'General',\r\n getter: function () {\r\n if (this._internal.collection) {\r\n var firstItem = this._internal.collection.get(0);\r\n if (firstItem !== undefined) return firstItem.getId();\r\n }\r\n }\r\n },\r\n isEmpty: {\r\n type: 'boolean',\r\n displayName: 'Is Empty',\r\n group: 'General',\r\n getter: function () {\r\n if (this._internal.collection) {\r\n return this._internal.collection.size() === 0;\r\n }\r\n return true;\r\n }\r\n },\r\n count: {\r\n type: 'number',\r\n displayName: 'Count',\r\n group: 'General',\r\n getter: function () {\r\n return this._internal.collection ? this._internal.collection.size() : 0;\r\n }\r\n },\r\n fetched: {\r\n group: 'Events',\r\n type: 'signal',\r\n displayName: 'Success'\r\n },\r\n failure: {\r\n group: 'Events',\r\n type: 'signal',\r\n displayName: 'Failure'\r\n },\r\n error: {\r\n type: 'string',\r\n displayName: 'Error',\r\n group: 'Error',\r\n getter: function () {\r\n return this._internal.error;\r\n }\r\n }\r\n },\r\n prototypeExtensions: {\r\n setCollectionName: function (name) {\r\n this._internal.name = name;\r\n\r\n if (this.isInputConnected('storageFetch') === false) this.scheduleFetch();\r\n },\r\n setCollection: function (collection) {\r\n this.bindCollection(collection);\r\n this.flagOutputDirty('firstItemId');\r\n this.flagOutputDirty('isEmpty');\r\n this.flagOutputDirty('items');\r\n this.flagOutputDirty('count');\r\n },\r\n unbindCurrentCollection: function () {\r\n var collection = this._internal.collection;\r\n if (!collection) return;\r\n collection.off('change', this._internal.collectionChangedCallback);\r\n this._internal.collection = undefined;\r\n },\r\n bindCollection: function (collection) {\r\n this.unbindCurrentCollection();\r\n this._internal.collection = collection;\r\n collection && collection.on('change', this._internal.collectionChangedCallback);\r\n },\r\n _onNodeDeleted: function () {\r\n Node.prototype._onNodeDeleted.call(this);\r\n this.unbindCurrentCollection();\r\n\r\n const cloudstore = CloudStore.forScope(this.nodeScope.modelScope);\r\n cloudstore.off('insert', this._internal.cloudStoreEvents);\r\n cloudstore.off('delete', this._internal.cloudStoreEvents);\r\n cloudstore.off('save', this._internal.cloudStoreEvents);\r\n },\r\n setError: function (err) {\r\n this._internal.err = err;\r\n this.flagOutputDirty('error');\r\n this.sendSignalOnOutput('failure');\r\n },\r\n scheduleFetch: function () {\r\n var internal = this._internal;\r\n\r\n if (internal.fetchScheduled) return;\r\n internal.fetchScheduled = true;\r\n this.scheduleAfterInputsHaveUpdated(() => {\r\n internal.fetchScheduled = false;\r\n\r\n this.fetch();\r\n });\r\n },\r\n fetch: function () {\r\n if (this.context.editorConnection) {\r\n if (this._internal.name === undefined) {\r\n this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name, this.id, 'query-collection', {\r\n message: 'No collection specified for query'\r\n });\r\n } else {\r\n this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'query-collection');\r\n }\r\n }\r\n\r\n const _c = Collection.get();\r\n const f = this.getStorageFilter();\r\n const limit = this.getStorageLimit();\r\n const skip = this.getStorageSkip();\r\n const count = this.getStorageFetchTotalCount();\r\n this._internal.currentQuery = {\r\n where: f.where,\r\n sort: f.sort,\r\n limit: limit,\r\n skip: skip\r\n };\r\n CloudStore.forScope(this.nodeScope.modelScope).query({\r\n collection: this._internal.name,\r\n where: f.where,\r\n sort: f.sort,\r\n limit: limit,\r\n skip: skip,\r\n count: count,\r\n success: (results, count) => {\r\n if (results !== undefined) {\r\n _c.set(\r\n results.map((i) => {\r\n var m = CloudStore._fromJSON(i, this._internal.name, this.nodeScope.modelScope);\r\n\r\n return m;\r\n })\r\n );\r\n }\r\n if (count !== undefined) {\r\n this._internal.storageSettings.storageTotalCount = count;\r\n if (this.hasOutput('storageTotalCount')) this.flagOutputDirty('storageTotalCount');\r\n }\r\n this.setCollection(_c);\r\n this.sendSignalOnOutput('fetched');\r\n },\r\n error: (err) => {\r\n this.setCollection(_c);\r\n this.setError(err || 'Failed to fetch.');\r\n }\r\n });\r\n },\r\n getStorageFilter: function () {\r\n const storageSettings = this._internal.storageSettings;\r\n if (storageSettings['storageFilterType'] === undefined || storageSettings['storageFilterType'] === 'simple') {\r\n // Create simple filter\r\n const _where =\r\n this._internal.visualFilter !== undefined\r\n ? QueryUtils.convertVisualFilter(this._internal.visualFilter, {\r\n queryParameters: this._internal.queryParameters,\r\n collectionName: this._internal.name\r\n })\r\n : undefined;\r\n\r\n const _sort =\r\n this._internal.visualSorting !== undefined\r\n ? QueryUtils.convertVisualSorting(this._internal.visualSorting)\r\n : undefined;\r\n\r\n return {\r\n where: _where,\r\n sort: _sort\r\n };\r\n } else if (storageSettings['storageFilterType'] === 'json') {\r\n // JSON filter\r\n if (!this._internal.filterFunc) {\r\n try {\r\n var filterCode = storageSettings['storageJSONFilter'];\r\n\r\n // Parse out variables\r\n filterCode = filterCode.replace(/\\/\\*[\\s\\S]*?\\*\\/|\\/\\/.*/g, ''); // Remove comments\r\n this._internal.filterVariables = filterCode.match(/\\$[A-Za-z0-9]+/g) || [];\r\n\r\n var args = ['filter', 'where', 'sort', 'Inputs']\r\n .concat(this._internal.filterVariables)\r\n .concat([filterCode]);\r\n this._internal.filterFunc = Function.apply(null, args);\r\n } catch (e) {\r\n this._internal.filterFunc = undefined;\r\n console.log('Error while parsing filter script: ' + e);\r\n }\r\n }\r\n\r\n if (!this._internal.filterFunc) return;\r\n\r\n var _filter = {},\r\n _sort = [],\r\n _this = this;\r\n\r\n // Collect filter variables\r\n var _filterCb = function (f) {\r\n _filter = QueryUtils.convertFilterOp(f, {\r\n collectionName: _this._internal.name,\r\n error: function (err) {\r\n _this.context.editorConnection.sendWarning(\r\n _this.nodeScope.componentOwner.name,\r\n _this.id,\r\n 'query-collection-filter',\r\n {\r\n message: err\r\n }\r\n );\r\n }\r\n });\r\n };\r\n var _sortCb = function (s) {\r\n _sort = s;\r\n };\r\n\r\n // Extract inputs\r\n const inputs = {};\r\n for (let key in storageSettings) {\r\n if (key.startsWith('storageFilterValue-'))\r\n inputs[key.substring('storageFilterValue-'.length)] = storageSettings[key];\r\n }\r\n\r\n var filterFuncArgs = [_filterCb, _filterCb, _sortCb, inputs]; // One for filter, one for where\r\n\r\n this._internal.filterVariables.forEach((v) => {\r\n filterFuncArgs.push(storageSettings['storageFilterValue-' + v.substring(1)]);\r\n });\r\n\r\n // Run the code to get the filter\r\n try {\r\n this._internal.filterFunc.apply(this, filterFuncArgs);\r\n } catch (e) {\r\n console.log('Error while running filter script: ' + e);\r\n }\r\n\r\n return { where: _filter, sort: _sort };\r\n }\r\n },\r\n getStorageLimit: function () {\r\n const storageSettings = this._internal.storageSettings;\r\n\r\n if (!storageSettings['storageEnableLimit']) return;\r\n else return storageSettings['storageLimit'] || 10;\r\n },\r\n getStorageSkip: function () {\r\n const storageSettings = this._internal.storageSettings;\r\n\r\n if (!storageSettings['storageEnableLimit']) return;\r\n else return storageSettings['storageSkip'] || 0;\r\n },\r\n getStorageFetchTotalCount: function () {\r\n const storageSettings = this._internal.storageSettings;\r\n\r\n return !!storageSettings['storageEnableCount'];\r\n },\r\n registerOutputIfNeeded: function (name) {\r\n if (this.hasOutput(name)) {\r\n return;\r\n }\r\n\r\n this.registerOutput(name, {\r\n getter: userOutputGetter.bind(this, name)\r\n });\r\n },\r\n setVisualFilter: function (value) {\r\n this._internal.visualFilter = value;\r\n\r\n if (this.isInputConnected('storageFetch') === false) this.scheduleFetch();\r\n },\r\n setVisualSorting: function (value) {\r\n this._internal.visualSorting = value;\r\n\r\n if (this.isInputConnected('storageFetch') === false) this.scheduleFetch();\r\n },\r\n setQueryParameter: function (name, value) {\r\n this._internal.queryParameters[name] = value;\r\n\r\n if (this.isInputConnected('storageFetch') === false) this.scheduleFetch();\r\n },\r\n registerInputIfNeeded: function (name) {\r\n var _this = this;\r\n\r\n if (this.hasInput(name)) {\r\n return;\r\n }\r\n\r\n if (name.startsWith('qp-'))\r\n return this.registerInput(name, {\r\n set: this.setQueryParameter.bind(this, name.substring('qp-'.length))\r\n });\r\n\r\n const dynamicSignals = {\r\n storageFetch: this.scheduleFetch.bind(this)\r\n };\r\n\r\n if (dynamicSignals[name])\r\n return this.registerInput(name, {\r\n set: EdgeTriggeredInput.createSetter({\r\n valueChangedToTrue: dynamicSignals[name]\r\n })\r\n });\r\n\r\n const dynamicSetters = {\r\n collectionName: this.setCollectionName.bind(this),\r\n visualFilter: this.setVisualFilter.bind(this),\r\n visualSort: this.setVisualSorting.bind(this)\r\n };\r\n\r\n if (dynamicSetters[name])\r\n return this.registerInput(name, {\r\n set: dynamicSetters[name]\r\n });\r\n\r\n this.registerInput(name, {\r\n set: userInputSetter.bind(this, name)\r\n });\r\n }\r\n }\r\n};\r\n\r\nfunction userOutputGetter(name) {\r\n /* jshint validthis:true */\r\n return this._internal.storageSettings[name];\r\n}\r\n\r\nfunction userInputSetter(name, value) {\r\n /* jshint validthis:true */\r\n this._internal.storageSettings[name] = value;\r\n\r\n if (this.isInputConnected('storageFetch') === false) this.scheduleFetch();\r\n}\r\n\r\nconst _defaultJSONQuery =\r\n '// Write your query script here, check out the reference documentation for examples\\n' + 'where({ })\\n';\r\n\r\nfunction updatePorts(nodeId, parameters, editorConnection, graphModel) {\r\n var ports = [];\r\n\r\n const dbCollections = graphModel.getMetaData('dbCollections');\r\n const systemCollections = graphModel.getMetaData('systemCollections');\r\n\r\n const _systemClasses = [\r\n { label: 'User', value: '_User' },\r\n { label: 'Role', value: '_Role' }\r\n ];\r\n ports.push({\r\n name: 'collectionName',\r\n type: {\r\n name: 'enum',\r\n enums: _systemClasses.concat(\r\n dbCollections !== undefined\r\n ? dbCollections.map((c) => {\r\n return { value: c.name, label: c.name };\r\n })\r\n : []\r\n ),\r\n allowEditOnly: true\r\n },\r\n displayName: 'Class',\r\n plug: 'input',\r\n group: 'General'\r\n });\r\n\r\n ports.push({\r\n name: 'storageFilterType',\r\n type: {\r\n name: 'enum',\r\n allowEditOnly: true,\r\n enums: [\r\n { value: 'simple', label: 'Visual' },\r\n { value: 'json', label: 'Javascript' }\r\n ]\r\n },\r\n displayName: 'Filter',\r\n default: 'simple',\r\n plug: 'input',\r\n group: 'General'\r\n });\r\n\r\n // Limit\r\n ports.push({\r\n type: 'boolean',\r\n plug: 'input',\r\n group: 'Limit',\r\n name: 'storageEnableLimit',\r\n displayName: 'Use limit'\r\n });\r\n\r\n if (parameters['storageEnableLimit']) {\r\n ports.push({\r\n type: 'number',\r\n default: 10,\r\n plug: 'input',\r\n group: 'Limit',\r\n name: 'storageLimit',\r\n displayName: 'Limit'\r\n });\r\n\r\n ports.push({\r\n type: 'number',\r\n default: 0,\r\n plug: 'input',\r\n group: 'Limit',\r\n name: 'storageSkip',\r\n displayName: 'Skip'\r\n });\r\n }\r\n\r\n ports.push({\r\n type: 'signal',\r\n plug: 'input',\r\n group: 'Actions',\r\n name: 'storageFetch',\r\n displayName: 'Do'\r\n });\r\n\r\n // Total Count\r\n ports.push({\r\n type: 'boolean',\r\n plug: 'input',\r\n group: 'Total Count',\r\n name: 'storageEnableCount',\r\n displayName: 'Fetch total count'\r\n });\r\n\r\n if (parameters['storageEnableCount']) {\r\n ports.push({\r\n type: 'number',\r\n plug: 'output',\r\n group: 'General',\r\n name: 'storageTotalCount',\r\n displayName: 'Total Count'\r\n });\r\n }\r\n\r\n // Simple query\r\n if (parameters['storageFilterType'] === undefined || parameters['storageFilterType'] === 'simple') {\r\n if (parameters.collectionName !== undefined) {\r\n var c = dbCollections && dbCollections.find((c) => c.name === parameters.collectionName);\r\n if (c === undefined && systemCollections) c = systemCollections.find((c) => c.name === parameters.collectionName);\r\n if (c && c.schema && c.schema.properties) {\r\n const schema = JSON.parse(JSON.stringify(c.schema));\r\n\r\n // Find all records that have a relation with this type\r\n function _findRelations(c) {\r\n if (c.schema !== undefined && c.schema.properties !== undefined)\r\n for (var key in c.schema.properties) {\r\n var p = c.schema.properties[key];\r\n if (p.type === 'Relation' && p.targetClass === parameters.collectionName) {\r\n if (schema.relations === undefined) schema.relations = {};\r\n if (schema.relations[c.name] === undefined) schema.relations[c.name] = [];\r\n\r\n schema.relations[c.name].push({ property: key });\r\n }\r\n }\r\n }\r\n\r\n dbCollections && dbCollections.forEach(_findRelations);\r\n systemCollections && systemCollections.forEach(_findRelations);\r\n\r\n ports.push({\r\n name: 'visualFilter',\r\n plug: 'input',\r\n type: { name: 'query-filter', schema: schema, allowEditOnly: true },\r\n displayName: 'Filter',\r\n group: 'Filter'\r\n });\r\n\r\n ports.push({\r\n name: 'visualSort',\r\n plug: 'input',\r\n type: { name: 'query-sorting', schema: schema, allowEditOnly: true },\r\n displayName: 'Sort',\r\n group: 'Sorting'\r\n });\r\n }\r\n\r\n if (parameters.visualFilter !== undefined) {\r\n // Find all input ports\r\n const uniqueInputs = {};\r\n function _collectInputs(query) {\r\n if (query === undefined) return;\r\n if (query.rules !== undefined) query.rules.forEach((r) => _collectInputs(r));\r\n else if (query.input !== undefined) uniqueInputs[query.input] = true;\r\n }\r\n\r\n _collectInputs(parameters.visualFilter);\r\n Object.keys(uniqueInputs).forEach((input) => {\r\n ports.push({\r\n name: 'qp-' + input,\r\n plug: 'input',\r\n type: '*',\r\n displayName: input,\r\n group: 'Query Parameters'\r\n });\r\n });\r\n }\r\n }\r\n }\r\n // JSON query\r\n else if (parameters['storageFilterType'] === 'json') {\r\n ports.push({\r\n type: { name: 'string', allowEditOnly: true, codeeditor: 'javascript' },\r\n plug: 'input',\r\n group: 'Filter',\r\n name: 'storageJSONFilter',\r\n default: _defaultJSONQuery,\r\n displayName: 'Filter'\r\n });\r\n\r\n var filter = parameters['storageJSONFilter'];\r\n if (filter) {\r\n filter = filter.replace(/\\/\\*[\\s\\S]*?\\*\\/|\\/\\/.*/g, ''); // Remove comments\r\n var variables = filter.match(/\\$[A-Za-z0-9]+/g);\r\n\r\n if (variables) {\r\n const unique = {};\r\n variables.forEach((v) => {\r\n unique[v] = true;\r\n });\r\n\r\n Object.keys(unique).forEach((p) => {\r\n ports.push({\r\n name: 'storageFilterValue-' + p.substring(1),\r\n displayName: p.substring(1),\r\n group: 'Filter Values',\r\n plug: 'input',\r\n type: { name: '*', allowConnectionsOnly: true }\r\n });\r\n });\r\n }\r\n\r\n // Support variables with the \"Inputs.\"\" syntax\r\n JavascriptNodeParser.parseAndAddPortsFromScript(filter, ports, {\r\n inputPrefix: 'storageFilterValue-',\r\n inputGroup: 'Filter Values',\r\n inputType: { name: '*', allowConnectionsOnly: true },\r\n skipOutputs: true\r\n });\r\n }\r\n }\r\n\r\n editorConnection.sendDynamicPorts(nodeId, ports);\r\n}\r\n\r\nmodule.exports = {\r\n node: DbCollectionNode,\r\n setup: function (context, graphModel) {\r\n if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {\r\n return;\r\n }\r\n\r\n function _managePortsForNode(node) {\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel);\r\n\r\n node.on('parameterUpdated', function (event) {\r\n if (event.name.startsWith('storage') || event.name === 'visualFilter' || event.name === 'collectionName') {\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel);\r\n }\r\n });\r\n\r\n graphModel.on('metadataChanged.dbCollections', function (data) {\r\n CloudStore.invalidateCollections();\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel);\r\n });\r\n\r\n graphModel.on('metadataChanged.systemCollections', function (data) {\r\n CloudStore.invalidateCollections();\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel);\r\n });\r\n\r\n graphModel.on('metadataChanged.cloudservices', function (data) {\r\n CloudStore.instance._initCloudServices();\r\n });\r\n }\r\n\r\n graphModel.on('editorImportComplete', () => {\r\n graphModel.on('nodeAdded.DbCollection2', function (node) {\r\n _managePortsForNode(node);\r\n });\r\n\r\n for (const node of graphModel.getNodesWithType('DbCollection2')) {\r\n _managePortsForNode(node);\r\n }\r\n });\r\n }\r\n};\r\n","'use strict';\r\n\r\nconst ConfigService = require('../../../api/configservice');\r\n\r\nvar ConfigNodeDefinition = {\r\n name: 'DbConfig',\r\n docs: 'https://docs.noodl.net/nodes/data/cloud-data/config',\r\n displayNodeName: 'Config',\r\n category: 'Cloud Services',\r\n usePortAsLabel: 'configKey',\r\n color: 'data',\r\n initialize: function () {\r\n var internal = this._internal;\r\n\r\n ConfigService.instance.getConfig().then((config) => {\r\n internal.config = config;\r\n if (this.hasOutput('value')) this.flagOutputDirty('value');\r\n });\r\n },\r\n getInspectInfo() {\r\n const value = this.getValue();\r\n\r\n if (value === undefined) return '[No Value]';\r\n\r\n return [{ type: 'value', value: value }];\r\n },\r\n inputs: {},\r\n outputs: {},\r\n methods: {\r\n getValue: function () {\r\n const internal = this._internal;\r\n if (internal.useDevValue && this.context.editorConnection && this.context.editorConnection.isRunningLocally()) {\r\n return internal.devValue;\r\n } else if (internal.config !== undefined && internal.configKey !== undefined) {\r\n return internal.config[internal.configKey];\r\n }\r\n },\r\n setInternal: function (key, value) {\r\n this._internal[key] = value;\r\n if (this.hasOutput('value')) this.flagOutputDirty('value');\r\n },\r\n registerOutputIfNeeded: function (name) {\r\n if (this.hasOutput(name)) {\r\n return;\r\n }\r\n\r\n if (name === 'value')\r\n return this.registerOutput(name, {\r\n getter: this.getValue.bind(this)\r\n });\r\n },\r\n registerInputIfNeeded: function (name) {\r\n if (this.hasInput(name)) {\r\n return;\r\n }\r\n\r\n if (name === 'configKey' || name === 'useDevValue' || name === 'devValue')\r\n return this.registerInput(name, {\r\n set: this.setInternal.bind(this, name)\r\n });\r\n }\r\n }\r\n};\r\n\r\nmodule.exports = {\r\n node: ConfigNodeDefinition,\r\n setup: function (context, graphModel) {\r\n if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {\r\n return;\r\n }\r\n\r\n function updatePorts(node) {\r\n var ports = [];\r\n\r\n context.editorConnection.clearWarning(node.component.name, node.id, 'dbconfig-warning');\r\n\r\n const configSchema = graphModel.getMetaData('dbConfigSchema');\r\n let valueType;\r\n\r\n if (configSchema) {\r\n const isCloud = typeof _noodl_cloud_runtime_version !== 'undefined';\r\n ports.push({\r\n name: 'configKey',\r\n displayName: 'Parameter',\r\n group: 'General',\r\n type: {\r\n name: 'enum',\r\n enums: Object.keys(configSchema)\r\n .filter((k) => isCloud || !configSchema[k].masterKeyOnly)\r\n .map((k) => ({ value: k, label: k })),\r\n allowEditOnly: true\r\n },\r\n plug: 'input'\r\n });\r\n\r\n if (node.parameters['configKey'] !== undefined && configSchema && configSchema[node.parameters['configKey']]) {\r\n valueType = configSchema[node.parameters['configKey']].type;\r\n\r\n if (\r\n valueType === 'string' ||\r\n valueType === 'boolean' ||\r\n valueType === 'number' ||\r\n valueType === 'object' ||\r\n valueType === 'array'\r\n ) {\r\n ports.push({\r\n name: 'useDevValue',\r\n displayName: 'Enable',\r\n group: 'Local Override',\r\n type: 'boolean',\r\n default: false,\r\n plug: 'input'\r\n });\r\n\r\n if (node.parameters['useDevValue'] === true) {\r\n ports.push({\r\n name: 'devValue',\r\n displayName: 'Value',\r\n group: 'Local Override',\r\n type: valueType,\r\n plug: 'input'\r\n });\r\n }\r\n }\r\n } else if (node.parameters['configKey'] !== undefined) {\r\n context.editorConnection.sendWarning(node.component.name, node.id, 'dbconfig-warning', {\r\n showGlobally: true,\r\n message: node.parameters['configKey'] + ' config parameter is missing, add it to your cloud service.'\r\n });\r\n }\r\n } else {\r\n context.editorConnection.sendWarning(node.component.name, node.id, 'dbconfig-warning', {\r\n showGlobally: true,\r\n message: 'You need an active cloud service.'\r\n });\r\n }\r\n\r\n ports.push({\r\n name: 'value',\r\n displayName: 'Value',\r\n group: 'General',\r\n type: valueType || '*',\r\n plug: 'output'\r\n });\r\n\r\n context.editorConnection.sendDynamicPorts(node.id, ports);\r\n }\r\n\r\n function _managePortsForNode(node) {\r\n updatePorts(node);\r\n\r\n node.on('parameterUpdated', function (event) {\r\n updatePorts(node);\r\n });\r\n\r\n graphModel.on('metadataChanged.dbConfigSchema', function (data) {\r\n ConfigService.instance.clearCache();\r\n updatePorts(node);\r\n });\r\n }\r\n\r\n graphModel.on('editorImportComplete', () => {\r\n graphModel.on('nodeAdded.DbConfig', function (node) {\r\n _managePortsForNode(node);\r\n });\r\n\r\n for (const node of graphModel.getNodesWithType('DbConfig')) {\r\n _managePortsForNode(node);\r\n }\r\n });\r\n }\r\n};\r\n","'use strict';\r\n\r\nconst Model = require('../../../model');\r\nconst CloudStore = require('../../../api/cloudstore');\r\n\r\nfunction _addBaseInfo(def, opts) {\r\n const _includeInputProperties = opts === undefined || opts.includeInputProperties;\r\n const _includeRelations = opts !== undefined && opts.includeRelations;\r\n\r\n Object.assign(def.node, {\r\n category: 'Data',\r\n color: 'data',\r\n inputs: def.node.inputs || {},\r\n outputs: def.node.outputs || {},\r\n methods: def.node.methods || {}\r\n });\r\n\r\n // Outputs\r\n Object.assign(def.node.outputs, {\r\n failure: {\r\n type: 'signal',\r\n displayName: 'Failure',\r\n group: 'Events'\r\n },\r\n error: {\r\n type: 'string',\r\n displayName: 'Error',\r\n group: 'Error',\r\n getter: function () {\r\n return this._internal.error;\r\n }\r\n }\r\n });\r\n\r\n // Methods\r\n Object.assign(def.node.methods, {\r\n scheduleOnce: function (type, cb) {\r\n const _this = this;\r\n const _type = 'hasScheduled' + type;\r\n if (this._internal[_type]) return;\r\n this._internal[_type] = true;\r\n this.scheduleAfterInputsHaveUpdated(function () {\r\n _this._internal[_type] = false;\r\n cb();\r\n });\r\n },\r\n checkWarningsBeforeCloudOp() {\r\n //clear all errors first\r\n this.clearWarnings();\r\n\r\n if (!this._internal.collectionId) {\r\n this.setError('No class name specified');\r\n return false;\r\n }\r\n\r\n return true;\r\n },\r\n setError: function (err) {\r\n this._internal.error = err;\r\n this.flagOutputDirty('error');\r\n this.sendSignalOnOutput('failure');\r\n\r\n if (this.context.editorConnection) {\r\n this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name, this.id, 'storage-op-warning', {\r\n message: err,\r\n showGlobally: true\r\n });\r\n }\r\n },\r\n clearWarnings() {\r\n if (this.context.editorConnection) {\r\n this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'storage-op-warning');\r\n }\r\n }\r\n });\r\n\r\n // Setup\r\n Object.assign(def, {\r\n setup: function (context, graphModel) {\r\n if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {\r\n return;\r\n }\r\n\r\n function _managePortsForNode(node) {\r\n function _updatePorts() {\r\n var ports = [];\r\n\r\n const dbCollections = graphModel.getMetaData('dbCollections');\r\n const systemCollections = graphModel.getMetaData('systemCollections');\r\n\r\n const _systemClasses = [\r\n { label: 'User', value: '_User' },\r\n { label: 'Role', value: '_Role' }\r\n ];\r\n\r\n const parameters = node.parameters;\r\n\r\n ports.push({\r\n name: 'collectionName',\r\n displayName: 'Class',\r\n group: 'General',\r\n type: {\r\n name: 'enum',\r\n enums: _systemClasses.concat(\r\n dbCollections !== undefined\r\n ? dbCollections.map((c) => {\r\n return { value: c.name, label: c.name };\r\n })\r\n : []\r\n ),\r\n allowEditOnly: true\r\n },\r\n plug: 'input'\r\n });\r\n\r\n if (_includeRelations && parameters.collectionName && dbCollections) {\r\n // Fetch ports from collection keys\r\n var c = dbCollections.find((c) => c.name === parameters.collectionName);\r\n if (c === undefined && systemCollections)\r\n c = systemCollections.find((c) => c.name === parameters.collectionName);\r\n if (c && c.schema && c.schema.properties) {\r\n const props = c.schema.properties;\r\n const enums = Object.keys(props)\r\n .filter((key) => props[key].type === 'Relation')\r\n .map((key) => ({ label: key, value: key }));\r\n\r\n ports.push({\r\n name: 'relationProperty',\r\n displayName: 'Relation',\r\n group: 'General',\r\n type: { name: 'enum', enums: enums, allowEditOnly: true },\r\n plug: 'input'\r\n });\r\n }\r\n }\r\n\r\n if (_includeInputProperties && parameters.collectionName && dbCollections) {\r\n const _typeMap = {\r\n String: 'string',\r\n Boolean: 'boolean',\r\n Number: 'number',\r\n Date: 'date'\r\n };\r\n\r\n // Fetch ports from collection keys\r\n var c = dbCollections.find((c) => c.name === parameters.collectionName);\r\n if (c === undefined && systemCollections)\r\n c = systemCollections.find((c) => c.name === parameters.collectionName);\r\n if (c && c.schema && c.schema.properties) {\r\n var props = c.schema.properties;\r\n for (var key in props) {\r\n var p = props[key];\r\n if (ports.find((_p) => _p.name === key)) continue;\r\n\r\n ports.push({\r\n type: {\r\n name: _typeMap[p.type] ? _typeMap[p.type] : '*'\r\n },\r\n plug: 'input',\r\n group: 'Properties',\r\n name: 'prop-' + key,\r\n displayName: key\r\n });\r\n }\r\n }\r\n }\r\n\r\n def._additionalDynamicPorts && def._additionalDynamicPorts(node, ports, graphModel);\r\n\r\n context.editorConnection.sendDynamicPorts(node.id, ports);\r\n }\r\n\r\n _updatePorts();\r\n\r\n node.on('parameterUpdated', function (event) {\r\n _updatePorts();\r\n });\r\n\r\n graphModel.on('metadataChanged.dbCollections', function (data) {\r\n CloudStore.invalidateCollections();\r\n _updatePorts();\r\n });\r\n\r\n graphModel.on('metadataChanged.systemCollections', function (data) {\r\n CloudStore.invalidateCollections();\r\n _updatePorts();\r\n });\r\n }\r\n\r\n graphModel.on('editorImportComplete', () => {\r\n graphModel.on('nodeAdded.' + def.node.name, function (node) {\r\n _managePortsForNode(node);\r\n });\r\n\r\n for (const node of graphModel.getNodesWithType(def.node.name)) {\r\n _managePortsForNode(node);\r\n }\r\n });\r\n }\r\n });\r\n}\r\n\r\nfunction _addModelId(def, opts) {\r\n var _def = { node: Object.assign({}, def.node), setup: def.setup };\r\n var _methods = Object.assign({}, def.node.methods);\r\n\r\n const _includeInputs = opts === undefined || opts.includeInputs;\r\n const _includeOutputs = opts === undefined || opts.includeOutputs;\r\n\r\n Object.assign(def.node, {\r\n inputs: def.node.inputs || {},\r\n outputs: def.node.outputs || {},\r\n methods: def.node.methods || {}\r\n });\r\n\r\n if (_includeInputs) {\r\n Object.assign(def.node, {\r\n usePortAsLabel: 'collectionName'\r\n });\r\n\r\n def.node.dynamicports = (def.node.dynamicports || []).concat([\r\n {\r\n name: 'conditionalports/extended',\r\n condition: 'idSource = explicit OR idSource NOT SET',\r\n inputs: ['modelId']\r\n }\r\n ]);\r\n\r\n // Inputs\r\n Object.assign(def.node.inputs, {\r\n idSource: {\r\n type: {\r\n name: 'enum',\r\n enums: [\r\n { label: 'Specify explicitly', value: 'explicit' },\r\n { label: 'From repeater', value: 'foreach' }\r\n ],\r\n allowEditOnly: true\r\n },\r\n default: 'explicit',\r\n displayName: 'Id Source',\r\n group: 'General',\r\n tooltip:\r\n 'Choose if you want to specify the Id explicitly, \\n or if you want it to be that of the current record in a repeater.',\r\n set: function (value) {\r\n if (value === 'foreach') {\r\n this.scheduleAfterInputsHaveUpdated(() => {\r\n // Find closest nodescope that have a _forEachModel\r\n var component = this.nodeScope.componentOwner;\r\n while (component !== undefined && component._forEachModel === undefined && component.parentNodeScope) {\r\n component = component.parentNodeScope.componentOwner;\r\n }\r\n this.setModel(component !== undefined ? component._forEachModel : undefined);\r\n });\r\n }\r\n }\r\n },\r\n modelId: {\r\n type: {\r\n name: 'string',\r\n identifierOf: 'ModelName',\r\n identifierDisplayName: 'Object Ids'\r\n },\r\n displayName: 'Id',\r\n group: 'General',\r\n set: function (value) {\r\n if (value instanceof Model) value = value.getId(); // Can be passed as model as well\r\n this._internal.modelId = value; // Wait to fetch data\r\n this.setModelID(value);\r\n }\r\n }\r\n });\r\n }\r\n\r\n // Outputs\r\n if (_includeOutputs) {\r\n Object.assign(def.node.outputs, {\r\n id: {\r\n type: 'string',\r\n displayName: 'Id',\r\n group: 'General',\r\n getter: function () {\r\n return this._internal.model ? this._internal.model.getId() : this._internal.modelId;\r\n }\r\n }\r\n });\r\n }\r\n\r\n // Methods\r\n Object.assign(def.node.methods, {\r\n setCollectionID: function (id) {\r\n this._internal.collectionId = id;\r\n this.clearWarnings();\r\n },\r\n setModelID: function (id) {\r\n var model = (this.nodeScope.modelScope || Model).get(id);\r\n this.setModel(model);\r\n },\r\n setModel: function (model) {\r\n this._internal.model = model;\r\n this.flagOutputDirty('id');\r\n },\r\n registerInputIfNeeded: function (name) {\r\n if (this.hasInput(name)) {\r\n return;\r\n }\r\n\r\n if (name === 'collectionName')\r\n this.registerInput(name, {\r\n set: this.setCollectionID.bind(this)\r\n });\r\n\r\n _methods && _methods.registerInputIfNeeded && _methods.registerInputIfNeeded.call(this, name);\r\n }\r\n });\r\n}\r\n\r\nfunction _addInputProperties(def) {\r\n var _def = { node: Object.assign({}, def.node), setup: def.setup };\r\n var _methods = Object.assign({}, def.node.methods);\r\n\r\n Object.assign(def.node, {\r\n inputs: def.node.inputs || {},\r\n outputs: def.node.outputs || {},\r\n methods: def.node.methods || {}\r\n });\r\n\r\n Object.assign(def.node, {\r\n initialize: function () {\r\n var internal = this._internal;\r\n internal.inputValues = {};\r\n\r\n _def.node.initialize && _def.node.initialize.call(this);\r\n }\r\n });\r\n\r\n // Outputs\r\n Object.assign(def.node.outputs, {});\r\n\r\n // Inputs\r\n Object.assign(def.node.inputs, {});\r\n\r\n // Methods\r\n Object.assign(def.node.methods, {\r\n registerInputIfNeeded: function (name) {\r\n if (this.hasInput(name)) {\r\n return;\r\n }\r\n\r\n if (name.startsWith('prop-'))\r\n this.registerInput(name, {\r\n set: this._setInputValue.bind(this, name.substring('prop-'.length))\r\n });\r\n\r\n _methods && _methods.registerInputIfNeeded && _methods.registerInputIfNeeded.call(this, name);\r\n },\r\n _setInputValue: function (name, value) {\r\n this._internal.inputValues[name] = value;\r\n }\r\n });\r\n}\r\n\r\nfunction _addRelationProperty(def) {\r\n var _def = { node: Object.assign({}, def.node), setup: def.setup };\r\n var _methods = Object.assign({}, def.node.methods);\r\n\r\n Object.assign(def.node, {\r\n inputs: def.node.inputs || {},\r\n outputs: def.node.outputs || {},\r\n methods: def.node.methods || {}\r\n });\r\n\r\n // Inputs\r\n Object.assign(def.node.inputs, {\r\n targetId: {\r\n type: { name: 'string', allowConnectionsOnly: true },\r\n displayName: 'Target Record Id',\r\n group: 'General',\r\n set: function (value) {\r\n this._internal.targetModelId = value;\r\n }\r\n }\r\n });\r\n\r\n // Methods\r\n Object.assign(def.node.methods, {\r\n registerInputIfNeeded: function (name) {\r\n if (this.hasInput(name)) {\r\n return;\r\n }\r\n\r\n if (name === 'relationProperty')\r\n this.registerInput(name, {\r\n set: this.setRelationProperty.bind(this)\r\n });\r\n\r\n _methods && _methods.registerInputIfNeeded && _methods.registerInputIfNeeded.call(this, name);\r\n },\r\n setRelationProperty: function (value) {\r\n this._internal.relationProperty = value;\r\n }\r\n });\r\n}\r\n\r\nfunction _getCurrentUser(modelScope) {\r\n if (typeof _noodl_cloud_runtime_version === 'undefined') {\r\n // We are running in browser, try to find the current user\r\n\r\n var _cu = localStorage['Parse/' + CloudStore.instance.appId + '/currentUser'];\r\n if (_cu !== undefined) {\r\n let cu;\r\n try {\r\n cu = JSON.parse(_cu);\r\n } catch (e) {}\r\n\r\n return cu !== undefined ? cu.objectId : undefined;\r\n }\r\n } else {\r\n // Assume we are running in cloud runtime\r\n const request = modelScope.get('Request');\r\n return request.UserId;\r\n }\r\n}\r\n\r\nfunction _addAccessControl(def) {\r\n var _def = { node: Object.assign({}, def.node), setup: def.setup };\r\n var _methods = Object.assign({}, def.node.methods);\r\n\r\n Object.assign(def.node, {\r\n inputs: def.node.inputs || {},\r\n outputs: def.node.outputs || {},\r\n methods: def.node.methods || {}\r\n });\r\n\r\n Object.assign(def.node, {\r\n initialize: function () {\r\n var internal = this._internal;\r\n internal.accessControl = {};\r\n\r\n _def.node.initialize && _def.node.initialize.call(this);\r\n }\r\n });\r\n\r\n // Inputs\r\n Object.assign(def.node.inputs, {\r\n accessControl: {\r\n type: { name: 'proplist', autoName: 'Rule', allowEditOnly: true },\r\n index: 1000,\r\n displayName: 'Access Control Rules',\r\n group: 'Access Control Rules',\r\n set: function (value) {\r\n this._internal.accessControlRules = value;\r\n }\r\n }\r\n });\r\n\r\n // Dynamic ports\r\n const _super = def._additionalDynamicPorts;\r\n def._additionalDynamicPorts = function (node, ports, graphModel) {\r\n if (node.parameters['accessControl'] !== undefined && node.parameters['accessControl'].length > 0) {\r\n node.parameters['accessControl'].forEach((ac) => {\r\n const prefix = 'acl-' + ac.id;\r\n // User or role?\r\n ports.push({\r\n name: prefix + '-target',\r\n displayName: 'Target',\r\n editorName: ac.label + ' | Target',\r\n plug: 'input',\r\n type: {\r\n name: 'enum',\r\n enums: [\r\n { value: 'user', label: 'User' },\r\n { value: 'everyone', label: 'Everyone' },\r\n { value: 'role', label: 'Role' }\r\n ],\r\n allowEditOnly: true\r\n },\r\n group: ac.label + ' Access Rule',\r\n default: 'user',\r\n parent: 'accessControl',\r\n parentItemId: ac.id\r\n });\r\n\r\n if (node.parameters[prefix + '-target'] === 'role') {\r\n ports.push({\r\n name: prefix + '-role',\r\n displayName: 'Role',\r\n editorName: ac.label + ' | Role',\r\n group: ac.label + ' Access Rule',\r\n plug: 'input',\r\n type: 'string',\r\n parent: 'accessControl',\r\n parentItemId: ac.id\r\n });\r\n } else if (\r\n node.parameters[prefix + '-target'] === undefined ||\r\n node.parameters[prefix + '-target'] === 'user'\r\n ) {\r\n ports.push({\r\n name: prefix + '-userid',\r\n displayName: 'User Id',\r\n group: ac.label + ' Access Rule',\r\n editorName: ac.label + ' | User Id',\r\n plug: 'input',\r\n type: { name: 'string', allowConnectionsOnly: true },\r\n parent: 'accessControl',\r\n parentItemId: ac.id\r\n });\r\n }\r\n\r\n // Read\r\n ports.push({\r\n name: prefix + '-read',\r\n displayName: 'Read',\r\n editorName: ac.label + ' | Read',\r\n group: ac.label + ' Access Rule',\r\n plug: 'input',\r\n type: { name: 'boolean' },\r\n default: true,\r\n parent: 'accessControl',\r\n parentItemId: ac.id\r\n });\r\n\r\n // Write\r\n ports.push({\r\n name: prefix + '-write',\r\n displayName: 'Write',\r\n editorName: ac.label + ' | Write',\r\n group: ac.label + ' Access Rule',\r\n plug: 'input',\r\n type: { name: 'boolean' },\r\n default: true,\r\n parent: 'accessControl',\r\n parentItemId: ac.id\r\n });\r\n });\r\n }\r\n\r\n _super && _super(node, ports, graphModel);\r\n };\r\n\r\n // Methods\r\n Object.assign(def.node.methods, {\r\n registerInputIfNeeded: function (name) {\r\n if (this.hasInput(name)) {\r\n return;\r\n }\r\n\r\n if (name.startsWith('acl-'))\r\n this.registerInput(name, {\r\n set: this.setAccessControl.bind(this, name)\r\n });\r\n\r\n _methods && _methods.registerInputIfNeeded && _methods.registerInputIfNeeded.call(this, name);\r\n },\r\n _getACL: function () {\r\n let acl = {};\r\n\r\n function _rule(rule) {\r\n return {\r\n read: rule.read === undefined ? true : rule.read,\r\n write: rule.write === undefined ? true : rule.write\r\n };\r\n }\r\n\r\n const currentUserId = _getCurrentUser(this.nodeScope.modelScope);\r\n\r\n if (this._internal.accessControlRules !== undefined) {\r\n this._internal.accessControlRules.forEach((r) => {\r\n const rule = this._internal.accessControl[r.id];\r\n\r\n if (rule === undefined) {\r\n const userId = currentUserId;\r\n if (userId !== undefined) acl[userId] = { write: true, read: true };\r\n } else if (rule.target === 'everyone') {\r\n acl['*'] = _rule(rule);\r\n } else if (rule.target === 'user') {\r\n const userId = rule.userid || currentUserId;\r\n acl[userId] = _rule(rule);\r\n } else if (rule.target === 'role') {\r\n acl['role:' + rule.role] = _rule(rule);\r\n }\r\n });\r\n }\r\n\r\n return Object.keys(acl).length > 0 ? acl : undefined;\r\n },\r\n setAccessControl: function (name, value) {\r\n const _parts = name.split('-');\r\n\r\n if (this._internal.accessControl[_parts[1]] === undefined) this._internal.accessControl[_parts[1]] = {};\r\n this._internal.accessControl[_parts[1]][_parts[2]] = value;\r\n }\r\n });\r\n}\r\n\r\nmodule.exports = {\r\n addInputProperties: _addInputProperties,\r\n addModelId: _addModelId,\r\n addBaseInfo: _addBaseInfo,\r\n addRelationProperty: _addRelationProperty,\r\n addAccessControl: _addAccessControl\r\n};\r\n","'use strict';\r\n\r\nvar Model = require('../../../model');\r\nvar DbModelCRUDBase = require('./dbmodelcrudbase');\r\nconst CloudStore = require('../../../api/cloudstore');\r\n\r\nvar AddDbModelRelationNodeDefinition = {\r\n node: {\r\n name: 'AddDbModelRelation',\r\n docs: 'https://docs.noodl.net/nodes/data/cloud-data/add-record-relation',\r\n displayNodeName: 'Add Record Relation',\r\n usePortAsLabel: 'collectionName',\r\n // shortDesc: \"Stores any amount of properties and can be used standalone or together with Collections and For Each nodes.\",\r\n inputs: {\r\n store: {\r\n displayName: 'Do',\r\n group: 'Actions',\r\n valueChangedToTrue: function () {\r\n this.scheduleAddRelation();\r\n }\r\n }\r\n },\r\n outputs: {\r\n relationAdded: {\r\n type: 'signal',\r\n displayName: 'Success',\r\n group: 'Events'\r\n }\r\n },\r\n methods: {\r\n validateInputs: function () {\r\n if (!this.context.editorConnection) return;\r\n\r\n const _warning = (message) => {\r\n this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name, this.id, 'add-relation', {\r\n message\r\n });\r\n };\r\n\r\n if (this._internal.collectionId === undefined) {\r\n _warning('No class specified');\r\n } else if (this._internal.relationProperty === undefined) {\r\n _warning('No relation property specified');\r\n } else if (this._internal.targetModelId === undefined) {\r\n _warning('No target record Id (the record to add a relation to) specified');\r\n } else if (this._internal.model === undefined) {\r\n _warning('No record Id specified (the record that should get the relation)');\r\n } else {\r\n this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'add-relation');\r\n }\r\n },\r\n scheduleAddRelation: function (key) {\r\n const _this = this;\r\n const internal = this._internal;\r\n\r\n this.scheduleOnce('StorageAddRelation', function () {\r\n _this.validateInputs();\r\n\r\n if (!internal.model) return;\r\n var model = internal.model;\r\n\r\n var targetModelId = internal.targetModelId;\r\n if (targetModelId === undefined) return;\r\n\r\n CloudStore.forScope(_this.nodeScope.modelScope).addRelation({\r\n collection: internal.collectionId,\r\n objectId: model.getId(),\r\n key: internal.relationProperty,\r\n targetObjectId: targetModelId,\r\n targetClass: (_this.nodeScope.modelScope || Model).get(targetModelId)._class,\r\n success: function (response) {\r\n for (var _key in response) {\r\n model.set(_key, response[_key]);\r\n }\r\n\r\n // Successfully added relation\r\n _this.sendSignalOnOutput('relationAdded');\r\n },\r\n error: function (err) {\r\n _this.setError(err || 'Failed to add relation.');\r\n }\r\n });\r\n });\r\n }\r\n }\r\n }\r\n};\r\n\r\nDbModelCRUDBase.addBaseInfo(AddDbModelRelationNodeDefinition, {\r\n includeRelations: true\r\n});\r\nDbModelCRUDBase.addModelId(AddDbModelRelationNodeDefinition);\r\nDbModelCRUDBase.addRelationProperty(AddDbModelRelationNodeDefinition);\r\n\r\nmodule.exports = AddDbModelRelationNodeDefinition;\r\n","'use strict';\r\n\r\nvar Model = require('../../../model');\r\nvar DbModelCRUDBase = require('./dbmodelcrudbase');\r\nconst CloudStore = require('../../../api/cloudstore');\r\n\r\nvar AddDbModelRelationNodeDefinition = {\r\n node: {\r\n name: 'RemoveDbModelRelation',\r\n docs: 'https://docs.noodl.net/nodes/data/cloud-data/remove-record-relation',\r\n displayName: 'Remove Record Relation',\r\n usePortAsLabel: 'collectionName',\r\n inputs: {\r\n store: {\r\n displayName: 'Do',\r\n group: 'Actions',\r\n valueChangedToTrue: function () {\r\n this.scheduleRemoveRelation();\r\n }\r\n }\r\n },\r\n outputs: {\r\n relationRemoved: {\r\n type: 'signal',\r\n displayName: 'Success',\r\n group: 'Events'\r\n }\r\n },\r\n methods: {\r\n validateInputs: function () {\r\n if (!this.context.editorConnection) return;\r\n\r\n const _warning = (message) => {\r\n this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name, this.id, 'add-relation', {\r\n message\r\n });\r\n };\r\n\r\n if (this._internal.collectionId === undefined) {\r\n _warning('No class specified');\r\n } else if (this._internal.relationProperty === undefined) {\r\n _warning('No relation property specified');\r\n } else if (this._internal.targetModelId === undefined) {\r\n _warning('No target record Id (the record to add a relation to) specified');\r\n } else if (this._internal.model === undefined) {\r\n _warning('No record Id specified (the record that should get the relation)');\r\n } else {\r\n this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'add-relation');\r\n }\r\n },\r\n scheduleRemoveRelation: function (key) {\r\n const _this = this;\r\n const internal = this._internal;\r\n\r\n this.scheduleOnce('StorageRemoveRelation', function () {\r\n _this.validateInputs();\r\n\r\n if (!internal.model) return;\r\n var model = internal.model;\r\n\r\n var targetModelId = internal.targetModelId;\r\n if (targetModelId === undefined) return;\r\n\r\n CloudStore.forScope(_this.nodeScope.modelScope).removeRelation({\r\n collection: internal.collectionId,\r\n objectId: model.getId(),\r\n key: internal.relationProperty,\r\n targetObjectId: targetModelId,\r\n targetClass: (_this.nodeScope.modelScope || Model).get(targetModelId)._class,\r\n success: function (response) {\r\n for (var _key in response) {\r\n model.set(_key, response[_key]);\r\n }\r\n\r\n // Successfully removed relation\r\n _this.sendSignalOnOutput('relationRemoved');\r\n },\r\n error: function (err) {\r\n _this.setError(err || 'Failed to remove relation.');\r\n }\r\n });\r\n });\r\n }\r\n }\r\n }\r\n};\r\n\r\nDbModelCRUDBase.addBaseInfo(AddDbModelRelationNodeDefinition, {\r\n includeRelations: true\r\n});\r\nDbModelCRUDBase.addModelId(AddDbModelRelationNodeDefinition);\r\nDbModelCRUDBase.addRelationProperty(AddDbModelRelationNodeDefinition);\r\n\r\nmodule.exports = AddDbModelRelationNodeDefinition;\r\n","'use strict';\r\n\r\nconst { Node, EdgeTriggeredInput } = require('../../../../noodl-runtime');\r\n\r\nconst Model = require('../../../model');\r\nconst CloudStore = require('../../../api/cloudstore');\r\n\r\nconst ModelNodeDefinition = {\r\n name: 'DbModel2',\r\n docs: 'https://docs.noodl.net/nodes/data/cloud-data/record',\r\n displayNodeName: 'Record',\r\n shortDesc: 'Database model',\r\n category: 'Cloud Services',\r\n usePortAsLabel: 'collectionName',\r\n color: 'data',\r\n dynamicports: [\r\n {\r\n name: 'conditionalports/extended',\r\n condition: 'idSource = explicit OR idSource NOT SET',\r\n inputs: ['modelId']\r\n }\r\n ],\r\n initialize: function () {\r\n const internal = this._internal;\r\n internal.inputValues = {};\r\n internal.relationModelIds = {};\r\n\r\n const _this = this;\r\n this._internal.onModelChangedCallback = function (args) {\r\n if (_this.isInputConnected('fetch')) return;\r\n\r\n if (_this.hasOutput('prop-' + args.name)) _this.flagOutputDirty('prop-' + args.name);\r\n\r\n if (_this.hasOutput('changed-' + args.name)) _this.sendSignalOnOutput('changed-' + args.name);\r\n\r\n _this.sendSignalOnOutput('changed');\r\n };\r\n },\r\n getInspectInfo() {\r\n const model = this._internal.model;\r\n if (!model) return '[No Record]';\r\n\r\n return [\r\n { type: 'text', value: 'Id: ' + model.getId() },\r\n { type: 'value', value: model.data }\r\n ];\r\n },\r\n outputs: {\r\n id: {\r\n type: 'string',\r\n displayName: 'Id',\r\n group: 'General',\r\n getter: function () {\r\n return this._internal.model ? this._internal.model.getId() : this._internal.modelId;\r\n }\r\n },\r\n fetched: {\r\n type: 'signal',\r\n displayName: 'Fetched',\r\n group: 'Events'\r\n },\r\n changed: {\r\n type: 'signal',\r\n displayName: 'Changed',\r\n group: 'Events'\r\n },\r\n failure: {\r\n type: 'signal',\r\n displayName: 'Failure',\r\n group: 'Events'\r\n },\r\n error: {\r\n type: 'string',\r\n displayName: 'Error',\r\n group: 'Error',\r\n getter: function () {\r\n return this._internal.error;\r\n }\r\n }\r\n },\r\n inputs: {\r\n idSource: {\r\n type: {\r\n name: 'enum',\r\n enums: [\r\n { label: 'Specify explicitly', value: 'explicit' },\r\n { label: 'From repeater', value: 'foreach' }\r\n ],\r\n allowEditOnly: true\r\n },\r\n default: 'explicit',\r\n displayName: 'Id Source',\r\n group: 'General',\r\n set: function (value) {\r\n if (value === 'foreach') {\r\n this.scheduleAfterInputsHaveUpdated(() => {\r\n // Find closest nodescope that have a _forEachModel\r\n var component = this.nodeScope.componentOwner;\r\n while (component !== undefined && component._forEachModel === undefined && component.parentNodeScope) {\r\n component = component.parentNodeScope.componentOwner;\r\n }\r\n this.setModel(component !== undefined ? component._forEachModel : undefined);\r\n });\r\n }\r\n }\r\n },\r\n modelId: {\r\n type: { name: 'string', allowConnectionsOnly: true },\r\n displayName: 'Id',\r\n group: 'General',\r\n set: function (value) {\r\n if (value instanceof Model) {\r\n // Can be passed as model as well\r\n value = value.getId();\r\n } else if (typeof value === 'object') {\r\n // If this is an js object, dereference it\r\n value = Model.create(value).getId();\r\n }\r\n\r\n this._internal.modelId = value; // Wait to fetch data\r\n if (this.isInputConnected('fetch') === false) {\r\n this.setModelID(value);\r\n } else {\r\n this.flagOutputDirty('id');\r\n }\r\n }\r\n },\r\n fetch: {\r\n displayName: 'Fetch',\r\n group: 'Actions',\r\n valueChangedToTrue: function () {\r\n this.scheduleFetch();\r\n }\r\n }\r\n },\r\n methods: {\r\n setCollectionID: function (id) {\r\n this._internal.collectionId = id;\r\n },\r\n setModelID: function (id) {\r\n var model = (this.nodeScope.modelScope || Model).get(id);\r\n // this._internal.modelIsNew = false;\r\n this.setModel(model);\r\n },\r\n setModel: function (model) {\r\n if (this._internal.model) {\r\n // Remove old listener if existing\r\n this._internal.model.off('change', this._internal.onModelChangedCallback);\r\n }\r\n\r\n this._internal.model = model;\r\n this.flagOutputDirty('id');\r\n model.on('change', this._internal.onModelChangedCallback);\r\n\r\n // We have a new model, mark all outputs as dirty\r\n for (var key in model.data) {\r\n if (this.hasOutput('prop-' + key)) {\r\n this.flagOutputDirty('prop-' + key);\r\n }\r\n }\r\n this.sendSignalOnOutput('fetched');\r\n },\r\n _onNodeDeleted: function () {\r\n Node.prototype._onNodeDeleted.call(this);\r\n if (this._internal.model) this._internal.model.off('change', this._internal.onModelChangedCallback);\r\n },\r\n scheduleOnce: function (type, cb) {\r\n const _this = this;\r\n const _type = 'hasScheduled' + type;\r\n if (this._internal[_type]) return;\r\n this._internal[_type] = true;\r\n this.scheduleAfterInputsHaveUpdated(function () {\r\n _this._internal[_type] = false;\r\n cb();\r\n });\r\n },\r\n setError: function (err) {\r\n this._internal.error = err;\r\n this.flagOutputDirty('error');\r\n this.sendSignalOnOutput('failure');\r\n\r\n if (this.context.editorConnection) {\r\n this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name, this.id, 'storage-op-warning', {\r\n message: err,\r\n showGlobally: true\r\n });\r\n }\r\n },\r\n clearWarnings() {\r\n if (this.context.editorConnection) {\r\n this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'storage-op-warning');\r\n }\r\n },\r\n scheduleFetch: function () {\r\n const _this = this;\r\n const internal = this._internal;\r\n\r\n this.scheduleOnce('Fetch', function () {\r\n // Don't do fetch if no id\r\n if (internal.modelId === undefined || internal.modelId === '') {\r\n _this.setError('Missing Id.');\r\n return;\r\n }\r\n\r\n const cloudstore = CloudStore.forScope(_this.nodeScope.modelScope);\r\n cloudstore.fetch({\r\n collection: internal.collectionId,\r\n objectId: internal.modelId, // Get the objectId part of the model id\r\n success: function (response) {\r\n const model = cloudstore._fromJSON(response, internal.collectionId);\r\n if (internal.model !== model) {\r\n // Check if we need to change model\r\n if (internal.model) {\r\n // Remove old listener if existing\r\n internal.model.off('change', internal.onModelChangedCallback);\r\n }\r\n\r\n internal.model = model;\r\n model.on('change', internal.onModelChangedCallback);\r\n }\r\n _this.flagOutputDirty('id');\r\n\r\n delete response.objectId;\r\n\r\n for (const key in response) {\r\n if (_this.hasOutput('prop-' + key)) {\r\n _this.flagOutputDirty('prop-' + key);\r\n }\r\n }\r\n\r\n _this.sendSignalOnOutput('fetched');\r\n },\r\n error: function (err) {\r\n _this.setError(err || 'Failed to fetch.');\r\n }\r\n });\r\n });\r\n },\r\n scheduleStore: function () {\r\n var internal = this._internal;\r\n if (!internal.model) return;\r\n\r\n this.scheduleOnce('Store', function () {\r\n for (var i in internal.inputValues) {\r\n internal.model.set(i, internal.inputValues[i], { resolve: true });\r\n }\r\n });\r\n },\r\n registerOutputIfNeeded: function (name) {\r\n if (this.hasOutput(name)) {\r\n return;\r\n }\r\n\r\n if (name.startsWith('prop-'))\r\n this.registerOutput(name, {\r\n getter: userOutputGetter.bind(this, name.substring('prop-'.length))\r\n });\r\n },\r\n registerInputIfNeeded: function (name) {\r\n if (this.hasInput(name)) {\r\n return;\r\n }\r\n\r\n const dynamicSignals = {};\r\n\r\n if (dynamicSignals[name])\r\n return this.registerInput(name, {\r\n set: EdgeTriggeredInput.createSetter({\r\n valueChangedToTrue: dynamicSignals[name]\r\n })\r\n });\r\n\r\n const dynamicSetters = {\r\n collectionName: this.setCollectionID.bind(this)\r\n };\r\n\r\n if (dynamicSetters[name])\r\n return this.registerInput(name, {\r\n set: dynamicSetters[name]\r\n });\r\n\r\n if (name.startsWith('prop-'))\r\n this.registerInput(name, {\r\n set: userInputSetter.bind(this, name.substring('prop-'.length))\r\n });\r\n }\r\n }\r\n};\r\n\r\nfunction userOutputGetter(name) {\r\n /* jshint validthis:true */\r\n return this._internal.model ? this._internal.model.get(name, { resolve: true }) : undefined;\r\n}\r\n\r\nfunction userInputSetter(name, value) {\r\n //console.log('dbmodel setter:',name,value)\r\n /* jshint validthis:true */\r\n this._internal.inputValues[name] = value;\r\n}\r\n\r\nfunction updatePorts(nodeId, parameters, editorConnection, graphModel) {\r\n var ports = [];\r\n\r\n const dbCollections = graphModel.getMetaData('dbCollections');\r\n const systemCollections = graphModel.getMetaData('systemCollections');\r\n\r\n const _systemClasses = [\r\n { label: 'User', value: '_User' },\r\n { label: 'Role', value: '_Role' }\r\n ];\r\n ports.push({\r\n name: 'collectionName',\r\n displayName: 'Class',\r\n group: 'General',\r\n type: {\r\n name: 'enum',\r\n enums: _systemClasses.concat(\r\n dbCollections !== undefined\r\n ? dbCollections.map((c) => {\r\n return { value: c.name, label: c.name };\r\n })\r\n : []\r\n ),\r\n allowEditOnly: true\r\n },\r\n plug: 'input'\r\n });\r\n\r\n if (parameters.collectionName && dbCollections) {\r\n // Fetch ports from collection keys\r\n var c = dbCollections.find((c) => c.name === parameters.collectionName);\r\n if (c === undefined && systemCollections) c = systemCollections.find((c) => c.name === parameters.collectionName);\r\n if (c && c.schema && c.schema.properties) {\r\n var props = c.schema.properties;\r\n for (var key in props) {\r\n var p = props[key];\r\n if (ports.find((_p) => _p.name === key)) continue;\r\n\r\n if (p.type !== 'Relation') {\r\n // Other schema type ports\r\n const _typeMap = {\r\n String: 'string',\r\n Boolean: 'boolean',\r\n Number: 'number',\r\n Date: 'date'\r\n };\r\n\r\n ports.push({\r\n type: {\r\n name: _typeMap[p.type] ? _typeMap[p.type] : '*'\r\n },\r\n plug: 'output',\r\n group: 'Properties',\r\n name: 'prop-' + key,\r\n displayName: key\r\n });\r\n\r\n ports.push({\r\n type: 'signal',\r\n plug: 'output',\r\n group: 'Changed Events',\r\n displayName: key + ' Changed',\r\n name: 'changed-' + key\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n editorConnection.sendDynamicPorts(nodeId, ports);\r\n}\r\n\r\nmodule.exports = {\r\n node: ModelNodeDefinition,\r\n setup: function (context, graphModel) {\r\n if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {\r\n return;\r\n }\r\n\r\n function _managePortsForNode(node) {\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel);\r\n\r\n node.on('parameterUpdated', function () {\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel);\r\n });\r\n\r\n graphModel.on('metadataChanged.dbCollections', function () {\r\n CloudStore.invalidateCollections();\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel);\r\n });\r\n\r\n graphModel.on('metadataChanged.systemCollections', function () {\r\n CloudStore.invalidateCollections();\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel);\r\n });\r\n }\r\n\r\n graphModel.on('editorImportComplete', () => {\r\n graphModel.on('nodeAdded.DbModel2', function (node) {\r\n _managePortsForNode(node);\r\n });\r\n\r\n for (const node of graphModel.getNodesWithType('DbModel2')) {\r\n _managePortsForNode(node);\r\n }\r\n });\r\n }\r\n};\r\n","'use strict';\r\n\r\nvar DbModelCRUDBase = require('./dbmodelcrudbase');\r\nconst CloudStore = require('../../../api/cloudstore');\r\n\r\nvar DeleteDbModelPropertiedNodeDefinition = {\r\n node: {\r\n name: 'DeleteDbModelProperties',\r\n docs: 'https://docs.noodl.net/nodes/data/cloud-data/delete-record',\r\n displayNodeName: 'Delete Record',\r\n shortDesc:\r\n 'Stores any amount of properties and can be used standalone or together with Collections and For Each nodes.',\r\n inputs: {\r\n store: {\r\n displayName: 'Do',\r\n group: 'Actions',\r\n valueChangedToTrue: function () {\r\n this.storageDelete();\r\n }\r\n }\r\n },\r\n outputs: {\r\n deleted: {\r\n type: 'signal',\r\n displayName: 'Success',\r\n group: 'Events'\r\n }\r\n },\r\n methods: {\r\n storageDelete: function () {\r\n const _this = this;\r\n const internal = this._internal;\r\n\r\n if (!this.checkWarningsBeforeCloudOp()) return;\r\n\r\n this.scheduleOnce('StorageDelete', function () {\r\n if (!internal.model) {\r\n _this.setError('Missing Record Id');\r\n return;\r\n }\r\n\r\n CloudStore.forScope(_this.nodeScope.ModelScope).delete({\r\n collection: internal.collectionId,\r\n objectId: internal.model.getId(), // Get the objectId part of the model id,\r\n success: function () {\r\n internal.model.notify('delete'); // Notify that this model has been deleted\r\n _this.sendSignalOnOutput('deleted');\r\n },\r\n error: function (err) {\r\n _this.setError(err || 'Failed to delete.');\r\n }\r\n });\r\n });\r\n }\r\n }\r\n }\r\n};\r\n\r\nDbModelCRUDBase.addBaseInfo(DeleteDbModelPropertiedNodeDefinition, {\r\n includeInputProperties: false\r\n});\r\nDbModelCRUDBase.addModelId(DeleteDbModelPropertiedNodeDefinition);\r\n\r\nmodule.exports = DeleteDbModelPropertiedNodeDefinition;\r\n","'use strict';\r\n\r\nconst { Node } = require('../../../../noodl-runtime');\r\n\r\nconst Collection = require('../../../collection'),\r\n Model = require('../../../model'),\r\n CloudStore = require('../../../api/cloudstore'),\r\n QueryUtils = require('../../../api/queryutils');\r\n\r\nvar FilterDBModelsNode = {\r\n name: 'FilterDBModels',\r\n docs: 'https://docs.noodl.net/nodes/data/cloud-data/filter-records',\r\n displayNodeName: 'Filter Records',\r\n shortDesc: 'Filter, sort and limit array',\r\n category: 'Data',\r\n color: 'data',\r\n initialize: function () {\r\n var _this = this;\r\n\r\n this._internal.collectionChangedCallback = function () {\r\n if (_this.isInputConnected('filter') === true) return;\r\n\r\n _this.scheduleFilter();\r\n };\r\n\r\n this._internal.cloudStoreEvents = function (args) {\r\n if (_this.isInputConnected('filter') === true) return;\r\n\r\n if (_this._internal.visualFilter === undefined) return;\r\n if (_this._internal.collection === undefined) return;\r\n if (args.collection !== _this._internal.collectionName) return;\r\n\r\n if (args.objectId !== undefined && _this._internal.collection.contains(Model.get(args.objectId)))\r\n _this.scheduleFilter();\r\n };\r\n\r\n CloudStore.instance.on('save', this._internal.cloudStoreEvents);\r\n\r\n this._internal.enabled = true;\r\n this._internal.filterSettings = {};\r\n this._internal.filterParameters = {};\r\n // this._internal.filteredCollection = Collection.get();\r\n },\r\n getInspectInfo() {\r\n const collection = this._internal.filteredCollection;\r\n\r\n if (!collection) {\r\n return { type: 'text', value: '[Not executed yet]' };\r\n }\r\n\r\n return [\r\n {\r\n type: 'text',\r\n value: 'Id: ' + collection.getId()\r\n },\r\n {\r\n type: 'value',\r\n value: collection.items\r\n }\r\n ];\r\n },\r\n inputs: {\r\n items: {\r\n type: 'array',\r\n displayName: 'Items',\r\n group: 'General',\r\n set(value) {\r\n this.bindCollection(value);\r\n if (this.isInputConnected('filter') === false) this.scheduleFilter();\r\n }\r\n },\r\n enabled: {\r\n type: 'boolean',\r\n group: 'General',\r\n displayName: 'Enabled',\r\n default: true,\r\n set: function (value) {\r\n this._internal.enabled = value;\r\n if (this.isInputConnected('filter') === false) this.scheduleFilter();\r\n }\r\n },\r\n filter: {\r\n type: 'signal',\r\n group: 'Actions',\r\n displayName: 'Filter',\r\n valueChangedToTrue: function () {\r\n this.scheduleFilter();\r\n }\r\n }\r\n },\r\n outputs: {\r\n items: {\r\n type: 'array',\r\n displayName: 'Items',\r\n group: 'General',\r\n getter: function () {\r\n return this._internal.filteredCollection;\r\n }\r\n },\r\n firstItemId: {\r\n type: 'string',\r\n displayName: 'First Record Id',\r\n group: 'General',\r\n getter: function () {\r\n if (this._internal.filteredCollection !== undefined) {\r\n const firstItem = this._internal.filteredCollection.get(0);\r\n if (firstItem !== undefined) return firstItem.getId();\r\n }\r\n }\r\n },\r\n /* firstItem:{\r\n type: 'object',\r\n displayName: 'First Item',\r\n group: 'General',\r\n getter: function () {\r\n if(this._internal.filteredCollection !== undefined) {\r\n return this._internal.filteredCollection.get(0);\r\n }\r\n } \r\n }, */\r\n count: {\r\n type: 'number',\r\n displayName: 'Count',\r\n group: 'General',\r\n getter: function () {\r\n return this._internal.filteredCollection ? this._internal.filteredCollection.size() : 0;\r\n }\r\n },\r\n modified: {\r\n group: 'Events',\r\n type: 'signal',\r\n displayName: 'Filtered'\r\n }\r\n },\r\n prototypeExtensions: {\r\n unbindCurrentCollection: function () {\r\n var collection = this._internal.collection;\r\n if (!collection) return;\r\n collection.off('change', this._internal.collectionChangedCallback);\r\n this._internal.collection = undefined;\r\n },\r\n bindCollection: function (collection) {\r\n this.unbindCurrentCollection();\r\n this._internal.collection = collection;\r\n collection && collection.on('change', this._internal.collectionChangedCallback);\r\n },\r\n _onNodeDeleted: function () {\r\n Node.prototype._onNodeDeleted.call(this);\r\n this.unbindCurrentCollection();\r\n\r\n CloudStore.instance.off('save', this._internal.cloudStoreEvents);\r\n },\r\n /* getFilter: function () {\r\n const filterSettings = this._internal.filterSettings;\r\n\r\n const options = ['case'] // List all supported options here\r\n\r\n if (filterSettings['filterFilter']) {\r\n const filters = filterSettings['filterFilter'].split(',');\r\n var _filter = {};\r\n filters.forEach(function (f) {\r\n var op = '$' + (filterSettings['filterFilterOp-' + f] || 'eq');\r\n _filter[f] = {};\r\n _filter[f][op] = filterSettings['filterFilterValue-' + f];\r\n\r\n options.forEach((o) => {\r\n var option = filterSettings['filterFilterOption-' + o + '-' + f];\r\n if(option) _filter[f]['$' + o] = option\r\n })\r\n })\r\n return _filter;\r\n }\r\n },\r\n getSort: function() {\r\n const filterSettings = this._internal.filterSettings;\r\n\r\n if (filterSettings['filterSort']) {\r\n const sort = filterSettings['filterSort'].split(',');\r\n var _sort = {};\r\n sort.forEach(function (s) {\r\n _sort[s] = filterSettings['filterSort-'+s] === 'descending'?-1:1;\r\n })\r\n return _sort;\r\n }\r\n },*/\r\n getLimit: function () {\r\n const filterSettings = this._internal.filterSettings;\r\n\r\n if (!filterSettings['filterEnableLimit']) return;\r\n else return filterSettings['filterLimit'] || 10;\r\n },\r\n getSkip: function () {\r\n const filterSettings = this._internal.filterSettings;\r\n\r\n if (!filterSettings['filterEnableLimit']) return;\r\n else return filterSettings['filterSkip'] || 0;\r\n },\r\n scheduleFilter: function () {\r\n if (this.collectionChangedScheduled) return;\r\n this.collectionChangedScheduled = true;\r\n\r\n this.scheduleAfterInputsHaveUpdated(() => {\r\n this.collectionChangedScheduled = false;\r\n if (!this._internal.collection) return;\r\n\r\n // Apply filter and write to output collection\r\n var filtered = [].concat(this._internal.collection.items);\r\n\r\n if (this._internal.enabled) {\r\n const _filter = this._internal.visualFilter;\r\n if (_filter !== undefined) {\r\n var filter = QueryUtils.convertVisualFilter(_filter, {\r\n queryParameters: this._internal.filterParameters,\r\n collectionName: this._internal.collectionName\r\n });\r\n if (filter) filtered = filtered.filter((m) => QueryUtils.matchesQuery(m, filter));\r\n }\r\n\r\n var _sort = this._internal.visualSorting;\r\n if (_sort !== undefined && _sort.length > 0) {\r\n var sort = QueryUtils.convertVisualSorting(_sort);\r\n }\r\n if (sort) filtered.sort(QueryUtils.compareObjects.bind(this, sort));\r\n\r\n var skip = this.getSkip();\r\n if (skip) filtered = filtered.slice(skip, filtered.length);\r\n\r\n var limit = this.getLimit();\r\n if (limit) filtered = filtered.slice(0, limit);\r\n }\r\n\r\n this._internal.filteredCollection = Collection.create(filtered);\r\n\r\n this.sendSignalOnOutput('modified');\r\n this.flagOutputDirty('firstItemId');\r\n this.flagOutputDirty('items');\r\n this.flagOutputDirty('count');\r\n });\r\n },\r\n setCollectionName: function (name) {\r\n this._internal.collectionName = name;\r\n },\r\n setVisualFilter: function (value) {\r\n this._internal.visualFilter = value;\r\n\r\n if (this.isInputConnected('filter') === false) this.scheduleFilter();\r\n },\r\n setVisualSorting: function (value) {\r\n this._internal.visualSorting = value;\r\n\r\n if (this.isInputConnected('filter') === false) this.scheduleFilter();\r\n },\r\n setFilterParameter: function (name, value) {\r\n this._internal.filterParameters[name] = value;\r\n\r\n if (this.isInputConnected('filter') === false) this.scheduleFilter();\r\n },\r\n registerInputIfNeeded: function (name) {\r\n var _this = this;\r\n\r\n if (this.hasInput(name)) {\r\n return;\r\n }\r\n\r\n if (name === 'collectionName')\r\n return this.registerInput(name, {\r\n set: this.setCollectionName.bind(this)\r\n });\r\n\r\n if (name === 'visualFilter')\r\n return this.registerInput(name, {\r\n set: this.setVisualFilter.bind(this)\r\n });\r\n\r\n if (name === 'visualSorting')\r\n return this.registerInput(name, {\r\n set: this.setVisualSorting.bind(this)\r\n });\r\n\r\n if (name.startsWith('fp-'))\r\n return this.registerInput(name, {\r\n set: this.setFilterParameter.bind(this, name.substring('fp-'.length))\r\n });\r\n\r\n this.registerInput(name, {\r\n set: userInputSetter.bind(this, name)\r\n });\r\n }\r\n }\r\n};\r\n\r\nfunction userInputSetter(name, value) {\r\n /* jshint validthis:true */\r\n this._internal.filterSettings[name] = value;\r\n if (this.isInputConnected('filter') === false) this.scheduleFilter();\r\n}\r\n\r\nfunction updatePorts(nodeId, parameters, editorConnection, dbCollections) {\r\n var ports = [];\r\n\r\n ports.push({\r\n name: 'collectionName',\r\n type: {\r\n name: 'enum',\r\n enums:\r\n dbCollections !== undefined\r\n ? dbCollections.map((c) => {\r\n return { value: c.name, label: c.name };\r\n })\r\n : [],\r\n allowEditOnly: true\r\n },\r\n displayName: 'Class',\r\n plug: 'input',\r\n group: 'General'\r\n });\r\n\r\n ports.push({\r\n type: 'boolean',\r\n plug: 'input',\r\n group: 'Limit',\r\n name: 'filterEnableLimit',\r\n displayName: 'Use limit'\r\n });\r\n\r\n if (parameters['filterEnableLimit']) {\r\n ports.push({\r\n type: 'number',\r\n default: 10,\r\n plug: 'input',\r\n group: 'Limit',\r\n name: 'filterLimit',\r\n displayName: 'Limit'\r\n });\r\n\r\n ports.push({\r\n type: 'number',\r\n default: 0,\r\n plug: 'input',\r\n group: 'Limit',\r\n name: 'filterSkip',\r\n displayName: 'Skip'\r\n });\r\n }\r\n\r\n if (parameters.collectionName !== undefined) {\r\n var c = dbCollections.find((c) => c.name === parameters.collectionName);\r\n if (c && c.schema && c.schema.properties) {\r\n const schema = JSON.parse(JSON.stringify(c.schema));\r\n\r\n const _supportedTypes = {\r\n Boolean: true,\r\n String: true,\r\n Date: true,\r\n Number: true,\r\n Pointer: true\r\n };\r\n for (var key in schema.properties) {\r\n if (!_supportedTypes[schema.properties[key].type]) delete schema.properties[key];\r\n }\r\n\r\n ports.push({\r\n name: 'visualFilter',\r\n plug: 'input',\r\n type: { name: 'query-filter', schema: schema, allowEditOnly: true },\r\n displayName: 'Filter',\r\n group: 'Filter'\r\n });\r\n\r\n ports.push({\r\n name: 'visualSorting',\r\n plug: 'input',\r\n type: { name: 'query-sorting', schema: schema, allowEditOnly: true },\r\n displayName: 'Sorting',\r\n group: 'Sorting'\r\n });\r\n }\r\n\r\n if (parameters.visualFilter !== undefined) {\r\n // Find all input ports\r\n const uniqueInputs = {};\r\n function _collectInputs(query) {\r\n if (query === undefined) return;\r\n if (query.rules !== undefined) query.rules.forEach((r) => _collectInputs(r));\r\n else if (query.input !== undefined) uniqueInputs[query.input] = true;\r\n }\r\n\r\n _collectInputs(parameters.visualFilter);\r\n Object.keys(uniqueInputs).forEach((input) => {\r\n ports.push({\r\n name: 'fp-' + input,\r\n plug: 'input',\r\n type: '*',\r\n displayName: input,\r\n group: 'Filter Parameters'\r\n });\r\n });\r\n }\r\n }\r\n\r\n /* ports.push({\r\n type: { name: 'stringlist', allowEditOnly: true },\r\n plug: 'input',\r\n group: 'Filter',\r\n name: 'filterFilter',\r\n displayName: 'Filter',\r\n })\r\n\r\n ports.push({\r\n type: { name: 'stringlist', allowEditOnly: true },\r\n plug: 'input',\r\n group: 'Sort',\r\n name: 'filterSort',\r\n displayName: 'Sort',\r\n }) \r\n\r\n const filterOps = {\r\n \"string\": [{ value: 'eq', label: 'Equals' }, { value: 'neq', label: 'Not Equals' },{value: 'regex', label: 'Matches RegEx'}],\r\n \"boolean\": [{ value: 'eq', label: 'Equals' }, { value: 'neq', label: 'Not Equals' }],\r\n \"number\": [{ value: 'eq', label: 'Equals' }, { value: 'neq', label: 'Not Equals' }, { value: 'lt', label: 'Less than' }, { value: 'gt', label: 'Greater than' },\r\n { value: 'gte', label: 'Greater than or equal' }, { value: 'lte', label: 'Less than or equal' }]\r\n }\r\n\r\n if (parameters['filterFilter']) {\r\n var filters = parameters['filterFilter'].split(',');\r\n filters.forEach((f) => {\r\n // Type\r\n ports.push({\r\n type: { name: 'enum', enums: [{ value: 'string', label: 'String' }, { value: 'number', label: 'Number' }, { value: 'boolean', label: 'Boolean' }] },\r\n default: 'string',\r\n plug: 'input',\r\n group: f + ' filter',\r\n displayName: 'Type',\r\n editorName: f + ' filter | Type',\r\n name: 'filterFilterType-' + f\r\n })\r\n\r\n var type = parameters['filterFilterType-' + f];\r\n\r\n // String filter type\r\n ports.push({\r\n type: { name: 'enum', enums: filterOps[type || 'string'] },\r\n default: 'eq',\r\n plug: 'input',\r\n group: f + ' filter',\r\n displayName: 'Op',\r\n editorName: f + ' filter| Op',\r\n name: 'filterFilterOp-' + f\r\n })\r\n\r\n // Case sensitivite option\r\n if(parameters['filterFilterOp-' + f] === 'regex') {\r\n ports.push({\r\n type: 'boolean',\r\n default: false,\r\n plug: 'input',\r\n group: f + ' filter',\r\n displayName: 'Case sensitive',\r\n editorName: f + ' filter| Case',\r\n name: 'filterFilterOption-case-' + f\r\n })\r\n }\r\n\r\n ports.push({\r\n type: type || 'string',\r\n plug: 'input',\r\n group: f + ' filter',\r\n displayName: 'Value',\r\n editorName: f + ' Filter Value',\r\n name: 'filterFilterValue-' + f\r\n })\r\n\r\n })\r\n }\r\n\r\n if (parameters['filterSort']) {\r\n var filters = parameters['filterSort'].split(',');\r\n filters.forEach((f) => {\r\n ports.push({\r\n type: { name: 'enum', enums: [{ value: 'ascending', label: 'Ascending' }, { value: 'descending', label: 'Descending' }] },\r\n default: 'ascending',\r\n plug: 'input',\r\n group: f + ' sort',\r\n displayName: 'Sort',\r\n editorName: f + ' sorting',\r\n name: 'filterSort-' + f\r\n })\r\n })\r\n }*/\r\n\r\n editorConnection.sendDynamicPorts(nodeId, ports);\r\n}\r\n\r\nmodule.exports = {\r\n node: FilterDBModelsNode,\r\n setup: function (context, graphModel) {\r\n if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {\r\n return;\r\n }\r\n\r\n graphModel.on('nodeAdded.FilterDBModels', function (node) {\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel.getMetaData('dbCollections'));\r\n\r\n node.on('parameterUpdated', function (event) {\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel.getMetaData('dbCollections'));\r\n });\r\n\r\n graphModel.on('metadataChanged.dbCollections', function (data) {\r\n CloudStore.invalidateCollections();\r\n updatePorts(node.id, node.parameters, context.editorConnection, data);\r\n });\r\n\r\n graphModel.on('metadataChanged.systemCollections', function (data) {\r\n CloudStore.invalidateCollections();\r\n updatePorts(node.id, node.parameters, context.editorConnection, data);\r\n });\r\n });\r\n }\r\n};\r\n","'use strict';\r\n\r\nconst Collection = require('../../../collection');\r\nconst Model = require('../../../model');\r\n\r\nfunction _addBaseInfo(def) {\r\n Object.assign(def.node, {\r\n category: 'Data',\r\n color: 'data'\r\n });\r\n}\r\n\r\nfunction _addModelId(def, opts) {\r\n const _includeInputs = opts === undefined || opts.includeInputs;\r\n const _includeOutputs = opts === undefined || opts.includeOutputs;\r\n\r\n Object.assign(def.node, {\r\n inputs: def.node.inputs || {},\r\n outputs: def.node.outputs || {},\r\n methods: def.node.methods || {}\r\n });\r\n\r\n if (_includeInputs) {\r\n Object.assign(def.node, {\r\n usePortAsLabel: 'modelId'\r\n });\r\n\r\n def.node.dynamicports = (def.node.dynamicports || []).concat([\r\n {\r\n name: 'conditionalports/extended',\r\n condition: 'idSource = explicit OR idSource NOT SET',\r\n inputs: ['modelId']\r\n }\r\n ]);\r\n\r\n // Inputs\r\n Object.assign(def.node.inputs, {\r\n idSource: {\r\n type: {\r\n name: 'enum',\r\n enums: [\r\n { label: 'Specify explicitly', value: 'explicit' },\r\n { label: 'From repeater', value: 'foreach' }\r\n ],\r\n allowEditOnly: true\r\n },\r\n default: 'explicit',\r\n displayName: 'Id Source',\r\n group: 'General',\r\n set: function (value) {\r\n if (value === 'foreach') {\r\n this.scheduleAfterInputsHaveUpdated(() => {\r\n // Find closest nodescope that have a _forEachModel\r\n var component = this.nodeScope.componentOwner;\r\n while (component !== undefined && component._forEachModel === undefined && component.parentNodeScope) {\r\n component = component.parentNodeScope.componentOwner;\r\n }\r\n this.setModel(component !== undefined ? component._forEachModel : undefined);\r\n });\r\n }\r\n }\r\n },\r\n modelId: {\r\n type: {\r\n name: 'string',\r\n identifierOf: 'ModelName',\r\n identifierDisplayName: 'Object Ids'\r\n },\r\n displayName: 'Id',\r\n group: 'General',\r\n set: function (value) {\r\n if (value instanceof Model) value = value.getId(); // Can be passed as model as well\r\n this._internal.modelId = value; // Wait to fetch data\r\n this.setModelID(value);\r\n }\r\n }\r\n });\r\n }\r\n\r\n // Outputs\r\n if (_includeOutputs) {\r\n Object.assign(def.node.outputs, {\r\n id: {\r\n type: 'string',\r\n displayName: 'Id',\r\n group: 'General',\r\n getter: function () {\r\n return this._internal.model ? this._internal.model.getId() : this._internal.modelId;\r\n }\r\n }\r\n });\r\n }\r\n\r\n // Methods\r\n Object.assign(def.node.methods, {\r\n setModelID: function (id) {\r\n var model = (this.nodeScope.modelScope || Model).get(id);\r\n this.setModel(model);\r\n },\r\n setModel: function (model) {\r\n this._internal.model = model;\r\n this.flagOutputDirty('id');\r\n }\r\n });\r\n\r\n //Inspect model\r\n if (!def.node.getInspectInfo) {\r\n def.node.getInspectInfo = function () {\r\n const model = this._internal.model;\r\n if (!model) return '[No Object]';\r\n\r\n return [\r\n { type: 'text', value: 'Id: ' + model.getId() },\r\n { type: 'value', value: model.data }\r\n ];\r\n };\r\n }\r\n}\r\n\r\nfunction _addInputProperties(def) {\r\n var _def = { node: Object.assign({}, def.node), setup: def.setup };\r\n var _methods = Object.assign({}, def.node.methods);\r\n\r\n Object.assign(def.node, {\r\n inputs: def.node.inputs || {},\r\n outputs: def.node.outputs || {},\r\n methods: def.node.methods || {}\r\n });\r\n\r\n Object.assign(def, {\r\n setup: function (context, graphModel) {\r\n if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {\r\n return;\r\n }\r\n\r\n graphModel.on('nodeAdded.' + def.node.name, function (node) {\r\n function _updatePorts() {\r\n var ports = [];\r\n\r\n const _types = [\r\n { label: 'String', value: 'string' },\r\n { label: 'Boolean', value: 'boolean' },\r\n { label: 'Number', value: 'number' },\r\n { label: 'Date', value: 'date' },\r\n { label: 'Array', value: 'array' },\r\n { label: 'Object', value: 'object' },\r\n { label: 'Any', value: '*' }\r\n ];\r\n\r\n // Add value outputs\r\n var properties = node.parameters.properties;\r\n if (properties) {\r\n properties = properties ? properties.split(',') : undefined;\r\n for (var i in properties) {\r\n var p = properties[i];\r\n\r\n // Property input\r\n ports.push({\r\n type: {\r\n name: node.parameters['type-' + p] === undefined ? '*' : node.parameters['type-' + p]\r\n },\r\n plug: 'input',\r\n group: 'Property Values',\r\n displayName: p,\r\n // editorName:p,\r\n name: 'prop-' + p\r\n });\r\n\r\n // Property type\r\n ports.push({\r\n type: {\r\n name: 'enum',\r\n enums: _types,\r\n allowEditOnly: true\r\n },\r\n plug: 'input',\r\n group: 'Property Types',\r\n displayName: p,\r\n default: '*',\r\n name: 'type-' + p\r\n });\r\n }\r\n }\r\n\r\n context.editorConnection.sendDynamicPorts(node.id, ports, {\r\n detectRenamed: {\r\n plug: 'input'\r\n }\r\n });\r\n }\r\n\r\n _updatePorts();\r\n\r\n node.on('parameterUpdated', function (event) {\r\n _updatePorts();\r\n });\r\n });\r\n\r\n _def.setup && _def.setup(context, graphModel);\r\n }\r\n });\r\n\r\n // Initilize\r\n Object.assign(def.node, {\r\n initialize: function () {\r\n var internal = this._internal;\r\n internal.inputValues = {};\r\n internal.inputTypes = {};\r\n\r\n _def.node.initialize && _def.node.initialize.call(this);\r\n }\r\n });\r\n\r\n // Outputs\r\n Object.assign(def.node.outputs, {});\r\n\r\n // Inputs\r\n Object.assign(def.node.inputs, {\r\n properties: {\r\n type: { name: 'stringlist', allowEditOnly: true },\r\n displayName: 'Properties',\r\n group: 'Properties to set',\r\n set: function (value) {}\r\n }\r\n });\r\n\r\n // Methods\r\n Object.assign(def.node.methods, {\r\n _pushInputValues: function (model) {\r\n var internal = this._internal;\r\n\r\n const _defaultValueForType = {\r\n boolean: false,\r\n string: '',\r\n number: 0,\r\n date: new Date()\r\n };\r\n\r\n const _allKeys = {};\r\n for (const key in internal.inputTypes) _allKeys[key] = true;\r\n for (const key in internal.inputValues) _allKeys[key] = true;\r\n\r\n const properties = this.model.parameters.properties || '';\r\n\r\n const validProperties = properties.split(',');\r\n\r\n const keysToSet = Object.keys(_allKeys).filter((key) => validProperties.indexOf(key) !== -1);\r\n\r\n for (const i of keysToSet) {\r\n var value = internal.inputValues[i];\r\n\r\n if (value !== undefined) {\r\n //Parse array types with string as javascript\r\n if (internal.inputTypes[i] !== undefined && internal.inputTypes[i] === 'array' && typeof value === 'string') {\r\n this.context.editorConnection.clearWarning(\r\n this.nodeScope.componentOwner.name,\r\n this.id,\r\n 'invalid-array-' + i\r\n );\r\n\r\n try {\r\n value = eval(value); //this might be static data in the form of javascript\r\n } catch (e) {\r\n if (value.indexOf('[') !== -1 || value.indexOf('{') !== -1) {\r\n this.context.editorConnection.sendWarning(\r\n this.nodeScope.componentOwner.name,\r\n this.id,\r\n 'invalid-array-' + i,\r\n {\r\n showGlobally: true,\r\n message: 'Invalid array
' + e.toString()\r\n }\r\n );\r\n value = [];\r\n } else {\r\n //backwards compability with how this node used to work\r\n value = Collection.get(value);\r\n }\r\n }\r\n }\r\n // Resolve object from IDs\r\n if (\r\n internal.inputTypes[i] !== undefined &&\r\n internal.inputTypes[i] === 'object' &&\r\n typeof value === 'string'\r\n ) {\r\n value = (this.nodeScope.modelScope || Model).get(value);\r\n }\r\n\r\n model.set(i, value, { resolve: true });\r\n } else {\r\n model.set(i, _defaultValueForType[internal.inputTypes[i]], {\r\n resolve: true\r\n });\r\n }\r\n }\r\n },\r\n scheduleStore: function () {\r\n if (this.hasScheduledStore) return;\r\n this.hasScheduledStore = true;\r\n\r\n var internal = this._internal;\r\n this.scheduleAfterInputsHaveUpdated(() => {\r\n this.hasScheduledStore = false;\r\n if (!internal.model) return;\r\n\r\n this._pushInputValues(internal.model);\r\n\r\n this.sendSignalOnOutput('stored');\r\n });\r\n },\r\n registerInputIfNeeded: function (name) {\r\n if (this.hasInput(name)) {\r\n return;\r\n }\r\n\r\n if (name.startsWith('prop-'))\r\n this.registerInput(name, {\r\n set: this._setInputValue.bind(this, name.substring('prop-'.length))\r\n });\r\n\r\n if (name.startsWith('type-'))\r\n this.registerInput(name, {\r\n set: this._setInputType.bind(this, name.substring('type-'.length))\r\n });\r\n\r\n _methods && _methods.registerInputIfNeeded && _def.node.methods.registerInputIfNeeded.call(this, name);\r\n },\r\n _setInputValue: function (name, value) {\r\n this._internal.inputValues[name] = value;\r\n },\r\n _setInputType: function (name, value) {\r\n this._internal.inputTypes[name] = value;\r\n }\r\n });\r\n}\r\n\r\nmodule.exports = {\r\n addInputProperties: _addInputProperties,\r\n addModelId: _addModelId,\r\n addBaseInfo: _addBaseInfo\r\n};\r\n","'use strict';\r\n\r\nconst { Node } = require('../../../../noodl-runtime');\r\n\r\nvar Model = require('../../../model');\r\n\r\nvar ModelNodeDefinition = {\r\n name: 'Model2',\r\n docs: 'https://docs.noodl.net/nodes/data/object/object-node',\r\n displayNodeName: 'Object',\r\n shortDesc:\r\n 'Stores any amount of properties and can be used standalone or together with Collections and For Each nodes.',\r\n category: 'Data',\r\n usePortAsLabel: 'modelId',\r\n color: 'data',\r\n dynamicports: [\r\n {\r\n name: 'conditionalports/extended',\r\n condition: 'idSource = explicit OR idSource NOT SET',\r\n inputs: ['modelId']\r\n }\r\n ],\r\n initialize: function () {\r\n var internal = this._internal;\r\n internal.inputValues = {};\r\n internal.dirtyValues = {};\r\n\r\n var _this = this;\r\n this._internal.onModelChangedCallback = function (args) {\r\n if (_this.isInputConnected('fetch') === true) return;\r\n\r\n if (_this.hasOutput('prop-' + args.name)) _this.flagOutputDirty('prop-' + args.name);\r\n\r\n if (_this.hasOutput('changed-' + args.name)) _this.sendSignalOnOutput('changed-' + args.name);\r\n\r\n _this.sendSignalOnOutput('changed');\r\n };\r\n },\r\n getInspectInfo() {\r\n const model = this._internal.model;\r\n if (!model) return '[No Object]';\r\n\r\n return [\r\n { type: 'text', value: 'Id: ' + model.getId() },\r\n { type: 'value', value: model.data }\r\n ];\r\n },\r\n outputs: {\r\n id: {\r\n type: 'string',\r\n displayName: 'Id',\r\n group: 'General',\r\n getter: function () {\r\n return this._internal.model ? this._internal.model.getId() : this._internal.modelId;\r\n }\r\n },\r\n changed: {\r\n type: 'signal',\r\n displayName: 'Changed',\r\n group: 'Events'\r\n },\r\n fetched: {\r\n type: 'signal',\r\n displayName: 'Fetched',\r\n group: 'Events'\r\n }\r\n },\r\n inputs: {\r\n idSource: {\r\n type: {\r\n name: 'enum',\r\n enums: [\r\n { label: 'Specify explicitly', value: 'explicit' },\r\n { label: 'From repeater', value: 'foreach' }\r\n ],\r\n allowEditOnly: true\r\n },\r\n default: 'explicit',\r\n displayName: 'Get Id from',\r\n group: 'General',\r\n set: function (value) {\r\n if (value === 'foreach') {\r\n this.scheduleAfterInputsHaveUpdated(() => {\r\n // Find closest nodescope that have a _forEachModel\r\n var component = this.nodeScope.componentOwner;\r\n while (component !== undefined && component._forEachModel === undefined && component.parentNodeScope) {\r\n component = component.parentNodeScope.componentOwner;\r\n }\r\n this.setModel(component !== undefined ? component._forEachModel : undefined);\r\n });\r\n }\r\n }\r\n },\r\n modelId: {\r\n type: {\r\n name: 'string',\r\n identifierOf: 'ModelName',\r\n identifierDisplayName: 'Object Ids'\r\n },\r\n displayName: 'Id',\r\n group: 'General',\r\n set: function (value) {\r\n if (value instanceof Model) value = value.getId();\r\n // Can be passed as model as well\r\n else if (typeof value === 'object') value = Model.create(value).getId(); // If this is an js object, dereference it\r\n\r\n this._internal.modelId = value; // Wait to fetch data\r\n if (this.isInputConnected('fetch') === false) this.setModelID(value);\r\n else {\r\n this.flagOutputDirty('id');\r\n }\r\n }\r\n },\r\n properties: {\r\n type: { name: 'stringlist', allowEditOnly: true },\r\n displayName: 'Properties',\r\n group: 'Properties',\r\n set: function (value) {}\r\n },\r\n fetch: {\r\n displayName: 'Fetch',\r\n group: 'Actions',\r\n valueChangedToTrue: function () {\r\n this.scheduleSetModel();\r\n }\r\n }\r\n },\r\n prototypeExtensions: {\r\n scheduleStore: function () {\r\n if (this.hasScheduledStore) return;\r\n this.hasScheduledStore = true;\r\n\r\n var internal = this._internal;\r\n this.scheduleAfterInputsHaveUpdated(() => {\r\n this.hasScheduledStore = false;\r\n if (!internal.model) return;\r\n\r\n for (var i in internal.dirtyValues) {\r\n internal.model.set(i, internal.inputValues[i], { resolve: true });\r\n }\r\n internal.dirtyValues = {}; // Reset dirty values\r\n });\r\n },\r\n scheduleSetModel: function () {\r\n if (this.hasScheduledSetModel) return;\r\n this.hasScheduledSetModel = true;\r\n\r\n var internal = this._internal;\r\n this.scheduleAfterInputsHaveUpdated(() => {\r\n this.hasScheduledSetModel = false;\r\n this.setModelID(this._internal.modelId);\r\n });\r\n },\r\n setModelID: function (id) {\r\n var model = (this.nodeScope.modelScope || Model).get(id);\r\n this.setModel(model);\r\n this.sendSignalOnOutput('fetched');\r\n },\r\n setModel: function (model) {\r\n if (this._internal.model)\r\n // Remove old listener if existing\r\n this._internal.model.off('change', this._internal.onModelChangedCallback);\r\n\r\n this._internal.model = model;\r\n this.flagOutputDirty('id');\r\n\r\n // In set idSource, we are calling setModel with undefined\r\n if (model) {\r\n model.on('change', this._internal.onModelChangedCallback);\r\n\r\n // We have a new model, mark all outputs as dirty\r\n for (var key in model.data) {\r\n if (this.hasOutput('prop-' + key)) this.flagOutputDirty('prop-' + key);\r\n }\r\n }\r\n },\r\n _onNodeDeleted: function () {\r\n Node.prototype._onNodeDeleted.call(this);\r\n if (this._internal.model) this._internal.model.off('change', this._internal.onModelChangedCallback);\r\n },\r\n registerOutputIfNeeded: function (name) {\r\n if (this.hasOutput(name)) {\r\n return;\r\n }\r\n\r\n if (name.startsWith('prop-'))\r\n this.registerOutput(name, {\r\n getter: userOutputGetter.bind(this, name.substring('prop-'.length))\r\n });\r\n },\r\n registerInputIfNeeded: function (name) {\r\n var _this = this;\r\n\r\n if (this.hasInput(name)) {\r\n return;\r\n }\r\n\r\n if (name.startsWith('prop-'))\r\n this.registerInput(name, {\r\n set: userInputSetter.bind(this, name.substring('prop-'.length))\r\n });\r\n }\r\n }\r\n};\r\n\r\nfunction userOutputGetter(name) {\r\n /* jshint validthis:true */\r\n return this._internal.model ? this._internal.model.get(name, { resolve: true }) : undefined;\r\n}\r\n\r\nfunction userInputSetter(name, value) {\r\n /* jshint validthis:true */\r\n this._internal.inputValues[name] = value;\r\n\r\n // Store on change if no connection to store or new\r\n const model = this._internal.model;\r\n const valueChanged = model ? model.get(name) !== value : true;\r\n if (valueChanged) {\r\n this._internal.dirtyValues[name] = true;\r\n this.scheduleStore();\r\n }\r\n}\r\n\r\nfunction updatePorts(nodeId, parameters, editorConnection) {\r\n var ports = [];\r\n\r\n // Add value outputs\r\n var properties = parameters.properties;\r\n if (properties) {\r\n properties = properties ? properties.split(',') : undefined;\r\n for (var i in properties) {\r\n var p = properties[i];\r\n\r\n ports.push({\r\n type: {\r\n name: '*',\r\n allowConnectionsOnly: true\r\n },\r\n plug: 'input/output',\r\n group: 'Properties',\r\n name: 'prop-' + p,\r\n displayName: p\r\n });\r\n\r\n ports.push({\r\n type: 'signal',\r\n plug: 'output',\r\n group: 'Changed Events',\r\n displayName: p + ' Changed',\r\n name: 'changed-' + p\r\n });\r\n }\r\n }\r\n\r\n editorConnection.sendDynamicPorts(nodeId, ports, {\r\n detectRenamed: {\r\n plug: 'input/output'\r\n }\r\n });\r\n}\r\n\r\nmodule.exports = {\r\n node: ModelNodeDefinition,\r\n setup: function (context, graphModel) {\r\n if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {\r\n return;\r\n }\r\n\r\n graphModel.on('nodeAdded.Model2', function (node) {\r\n updatePorts(node.id, node.parameters, context.editorConnection);\r\n\r\n node.on('parameterUpdated', function (event) {\r\n updatePorts(node.id, node.parameters, context.editorConnection);\r\n });\r\n });\r\n }\r\n};\r\n","'use strict';\r\n\r\nvar Model = require('../../../model');\r\nvar DbModelCRUDBase = require('./dbmodelcrudbase');\r\nconst CloudStore = require('../../../api/cloudstore');\r\n\r\nvar NewDbModelPropertiedNodeDefinition = {\r\n node: {\r\n name: 'NewDbModelProperties',\r\n docs: 'https://docs.noodl.net/nodes/data/cloud-data/create-new-record',\r\n displayName: 'Create New Record',\r\n usePortAsLabel: 'collectionName',\r\n inputs: {\r\n store: {\r\n displayName: 'Do',\r\n group: 'Actions',\r\n valueChangedToTrue: function () {\r\n this.storageInsert();\r\n }\r\n },\r\n sourceObjectId: {\r\n type: { name: 'string', allowConnectionsOnly: true },\r\n displayName: 'Source Object Id',\r\n group: 'General',\r\n set: function (value) {\r\n if (value instanceof Model) value = value.getId(); // Can be passed as model as well\r\n this._internal.sourceObjectId = value; // Wait to fetch data\r\n }\r\n }\r\n },\r\n outputs: {\r\n created: {\r\n type: 'signal',\r\n displayName: 'Success',\r\n group: 'Events'\r\n }\r\n },\r\n methods: {\r\n storageInsert: function () {\r\n const internal = this._internal;\r\n\r\n if (!this.checkWarningsBeforeCloudOp()) return;\r\n\r\n this.scheduleOnce('StorageInsert', () => {\r\n const initValues = Object.assign(\r\n {},\r\n internal.sourceObjectId ? (this.nodeScope.modelScope || Model).get(internal.sourceObjectId).data : {},\r\n internal.inputValues\r\n );\r\n\r\n const cloudstore = CloudStore.forScope(this.nodeScope.modelScope);\r\n cloudstore.create({\r\n collection: internal.collectionId,\r\n data: initValues,\r\n acl: this._getACL(),\r\n success: (data) => {\r\n // Successfully created\r\n const m = cloudstore._fromJSON(data, internal.collectionId);\r\n this.setModel(m);\r\n this.sendSignalOnOutput('created');\r\n },\r\n error: (err) => {\r\n this.setError(err || 'Failed to insert.');\r\n }\r\n });\r\n });\r\n }\r\n }\r\n }\r\n};\r\n\r\nDbModelCRUDBase.addBaseInfo(NewDbModelPropertiedNodeDefinition);\r\nDbModelCRUDBase.addModelId(NewDbModelPropertiedNodeDefinition, {\r\n includeOutputs: true\r\n});\r\nDbModelCRUDBase.addInputProperties(NewDbModelPropertiedNodeDefinition);\r\nDbModelCRUDBase.addAccessControl(NewDbModelPropertiedNodeDefinition);\r\n\r\nmodule.exports = NewDbModelPropertiedNodeDefinition;\r\n","'use strict';\r\n\r\nvar Model = require('../../../model');\r\nvar ModelCRUDBase = require('./modelcrudbase');\r\n\r\nvar NewModelNodeDefinition = {\r\n node: {\r\n name: 'NewModel',\r\n docs: 'https://docs.noodl.net/nodes/data/object/create-new-object',\r\n displayNodeName: 'Create New Object',\r\n inputs: {\r\n new: {\r\n displayName: 'Do',\r\n group: 'Actions',\r\n valueChangedToTrue: function () {\r\n this.scheduleNew();\r\n }\r\n }\r\n },\r\n outputs: {\r\n created: {\r\n type: 'signal',\r\n displayName: 'Done',\r\n group: 'Events'\r\n }\r\n },\r\n methods: {\r\n scheduleNew: function () {\r\n if (this.hasScheduledNew) return;\r\n this.hasScheduledNew = true;\r\n\r\n this.scheduleAfterInputsHaveUpdated(() => {\r\n this.hasScheduledNew = false;\r\n const newModel = (this.nodeScope.modelScope || Model).get();\r\n\r\n this._pushInputValues(newModel);\r\n\r\n this.setModel(newModel);\r\n\r\n this.sendSignalOnOutput('created');\r\n });\r\n }\r\n }\r\n }\r\n};\r\n\r\nModelCRUDBase.addBaseInfo(NewModelNodeDefinition);\r\nModelCRUDBase.addModelId(NewModelNodeDefinition, { includeOutputs: true });\r\nModelCRUDBase.addInputProperties(NewModelNodeDefinition);\r\n\r\nmodule.exports = NewModelNodeDefinition;\r\n","var defaultRequestScript =\r\n '' +\r\n '//Add custom code to setup the request object before the request\\n' +\r\n '//is made.\\n' +\r\n '//\\n' +\r\n '//*Request.resource contains the resource path of the request.\\n' +\r\n '//*Request.method contains the method, GET, POST, PUT or DELETE.\\n' +\r\n '//*Request.headers is a map where you can add additional headers.\\n' +\r\n '//*Request.parameters is a map the parameters that will be appended\\n' +\r\n '// to the url.\\n' +\r\n '//*Request.content contains the content of the request as a javascript\\n' +\r\n '// object.\\n' +\r\n '//\\n';\r\n('//*Inputs and *Outputs contain the inputs and outputs of the node.\\n');\r\n\r\nvar defaultResponseScript =\r\n '' +\r\n '// Add custom code to convert the response content to outputs\\n' +\r\n '//\\n' +\r\n '//*Response.status The status code of the response\\n' +\r\n '//*Response.content The content of the response as a javascript\\n' +\r\n '// object.\\n' +\r\n '//*Response.request The request object that resulted in the response.\\n' +\r\n '//\\n' +\r\n '//*Inputs and *Outputs contain the inputs and outputs of the node.\\n';\r\n\r\nvar RestNode = {\r\n name: 'REST2',\r\n displayNodeName: 'REST',\r\n docs: 'https://docs.noodl.net/nodes/data/rest',\r\n category: 'Data',\r\n color: 'data',\r\n searchTags: ['http', 'request', 'fetch'],\r\n initialize: function () {\r\n this._internal.inputValues = {};\r\n this._internal.outputValues = {};\r\n\r\n this._internal.outputValuesProxy = new Proxy(this._internal.outputValues, {\r\n set: (obj, prop, value) => {\r\n //only send outputs when they change.\r\n //Some Noodl projects rely on this behavior, so changing it breaks backwards compability\r\n if (value !== this._internal.outputValues[prop]) {\r\n this.registerOutputIfNeeded('out-' + prop);\r\n\r\n this._internal.outputValues[prop] = value;\r\n this.flagOutputDirty('out-' + prop);\r\n }\r\n return true;\r\n }\r\n });\r\n\r\n this._internal.self = {};\r\n },\r\n getInspectInfo() {\r\n return this._internal.inspectData\r\n ? { type: 'value', value: this._internal.inspectData }\r\n : { type: 'text', value: '[Not executed yet]' };\r\n },\r\n inputs: {\r\n resource: {\r\n type: 'string',\r\n displayName: 'Resource',\r\n group: 'Request',\r\n default: '/',\r\n set: function (value) {\r\n this._internal.resource = value;\r\n }\r\n },\r\n method: {\r\n type: {\r\n name: 'enum',\r\n enums: [\r\n { label: 'GET', value: 'GET' },\r\n { label: 'POST', value: 'POST' },\r\n { label: 'PUT', value: 'PUT' },\r\n { label: 'PATCH', value: 'PATCH' },\r\n { label: 'DELETE', value: 'DELETE' }\r\n ]\r\n },\r\n displayName: 'Method',\r\n group: 'Request',\r\n default: 'GET',\r\n set: function (value) {\r\n this._internal.method = value;\r\n }\r\n },\r\n /* scriptInputs: {\r\n type: { name: 'proplist', allowEditOnly: true },\r\n group: 'Inputs',\r\n set: function (value) {\r\n // this._internal.scriptInputs = value; \r\n }\r\n },\r\n scriptOutputs: {\r\n type: { name: 'proplist', allowEditOnly: true },\r\n group: 'Outputs',\r\n set: function (value) {\r\n // this._internal.scriptOutputs = value; \r\n }\r\n },*/\r\n requestScript: {\r\n type: {\r\n name: 'string',\r\n allowEditOnly: true,\r\n codeeditor: 'javascript'\r\n },\r\n displayName: 'Request',\r\n default: defaultRequestScript,\r\n group: 'Scripts',\r\n set: function (script) {\r\n try {\r\n this._internal.requestFunc = new Function('Inputs', 'Outputs', 'Request', script);\r\n } catch (e) {\r\n console.log(e);\r\n }\r\n }\r\n },\r\n responseScript: {\r\n type: {\r\n name: 'string',\r\n allowEditOnly: true,\r\n codeeditor: 'javascript'\r\n },\r\n displayName: 'Response',\r\n default: defaultResponseScript,\r\n group: 'Scripts',\r\n set: function (script) {\r\n try {\r\n this._internal.responseFunc = new Function('Inputs', 'Outputs', 'Response', script);\r\n } catch (e) {\r\n console.log(e);\r\n }\r\n }\r\n },\r\n fetch: {\r\n type: 'signal',\r\n displayName: 'Fetch',\r\n group: 'Actions',\r\n valueChangedToTrue: function () {\r\n this.scheduleFetch();\r\n }\r\n },\r\n cancel: {\r\n type: 'signal',\r\n displayName: 'Cancel',\r\n group: 'Actions',\r\n valueChangedToTrue: function () {\r\n this.cancelFetch();\r\n }\r\n }\r\n },\r\n outputs: {\r\n failure: {\r\n type: 'signal',\r\n displayName: 'Failure',\r\n group: 'Events'\r\n },\r\n success: {\r\n type: 'signal',\r\n displayName: 'Success',\r\n group: 'Events'\r\n },\r\n canceled: {\r\n type: 'signal',\r\n displayName: 'Canceled',\r\n group: 'Events'\r\n }\r\n },\r\n prototypeExtensions: {\r\n getScriptOutputValue: function (name) {\r\n return this._internal.outputValues[name];\r\n },\r\n setScriptInputValue: function (name, value) {\r\n return (this._internal.inputValues[name] = value);\r\n },\r\n registerOutputIfNeeded: function (name) {\r\n if (this.hasOutput(name)) {\r\n return;\r\n }\r\n\r\n if (name.startsWith('out-'))\r\n return this.registerOutput(name, {\r\n getter: this.getScriptOutputValue.bind(this, name.substring('out-'.length))\r\n });\r\n },\r\n registerInputIfNeeded: function (name) {\r\n if (this.hasInput(name)) {\r\n return;\r\n }\r\n\r\n if (name.startsWith('in-'))\r\n return this.registerInput(name, {\r\n set: this.setScriptInputValue.bind(this, name.substring('in-'.length))\r\n });\r\n\r\n /* if (name.startsWith('intype-')) return this.registerInput(name, {\r\n set: function() {} // Ignore input type\r\n })\r\n\r\n if (name.startsWith('outtype-')) return this.registerInput(name, {\r\n set: function() {} // Ignore output type\r\n })*/\r\n },\r\n scheduleFetch: function () {\r\n var internal = this._internal;\r\n if (!internal.hasScheduledFetch) {\r\n internal.hasScheduledFetch = true;\r\n this.scheduleAfterInputsHaveUpdated(this.doFetch.bind(this));\r\n }\r\n },\r\n doResponse: function (status, response, request) {\r\n // Process the response content with the response function\r\n if (this._internal.responseFunc) {\r\n this._internal.responseFunc.apply(this._internal.self, [\r\n this._internal.inputValues,\r\n this._internal.outputValuesProxy,\r\n { status: status, content: response, request: request }\r\n ]);\r\n }\r\n\r\n this._internal.inspectData = { status: status, content: response };\r\n\r\n // Flag status\r\n if (status >= 200 && status < 300) {\r\n this.sendSignalOnOutput('success');\r\n } else {\r\n this.sendSignalOnOutput('failure');\r\n }\r\n },\r\n doExternalFetch: function (request) {\r\n var url = request.resource;\r\n\r\n // Append parameters from request as query\r\n if (Object.keys(request.parameters).length > 0) {\r\n var parameters = Object.keys(request.parameters).map(function (p) {\r\n return p + '=' + encodeURIComponent(request.parameters[p]);\r\n });\r\n url += '?' + parameters.join('&');\r\n }\r\n\r\n if (typeof _noodl_cloud_runtime_version === 'undefined') {\r\n // Running in browser\r\n var _this = this;\r\n var xhr = new window.XMLHttpRequest();\r\n this._xhr = xhr;\r\n\r\n xhr.open(request.method, url, true);\r\n for (var header in request.headers) {\r\n xhr.setRequestHeader(header, request.headers[header]);\r\n }\r\n xhr.onreadystatechange = function () {\r\n // XMLHttpRequest.DONE = 4, but torped runtime doesn't support enum\r\n\r\n var sentResponse = false;\r\n\r\n if (this.readyState === 4 || this.readyState === XMLHttpRequest.DONE) {\r\n var statusCode = this.status;\r\n var responseType = this.getResponseHeader('content-type');\r\n var rawResponse = this.response;\r\n delete this._xhr;\r\n\r\n if (responseType) {\r\n responseType = responseType.toLowerCase();\r\n const responseData = responseType.indexOf('json') !== -1 ? JSON.parse(rawResponse) : rawResponse;\r\n\r\n _this.doResponse(statusCode, responseData, request);\r\n sentResponse = true;\r\n }\r\n\r\n if (sentResponse === false) {\r\n _this.doResponse(statusCode, rawResponse, request);\r\n }\r\n }\r\n };\r\n xhr.onerror = function (e) {\r\n //console.log('REST: Failed to request', url);\r\n delete this._xhr;\r\n _this.sendSignalOnOutput('failure');\r\n };\r\n\r\n xhr.onabort = function () {\r\n delete this._xhr;\r\n _this.sendSignalOnOutput('canceled');\r\n };\r\n\r\n if (request.content) {\r\n xhr.setRequestHeader('Content-Type', 'application/json');\r\n xhr.send(JSON.stringify(request.content));\r\n } else {\r\n xhr.send();\r\n }\r\n } else {\r\n // Running in cloud runtime\r\n const headers = Object.assign(\r\n {},\r\n request.headers,\r\n request.content\r\n ? {\r\n 'Content-Type': 'application/json'\r\n }\r\n : {}\r\n );\r\n fetch(url, {\r\n method: request.method,\r\n headers,\r\n body: request.content ? JSON.stringify(request.content) : undefined\r\n })\r\n .then((response) => {\r\n const responseType = response.headers.get('content-type');\r\n if (responseType) {\r\n if (responseType.indexOf('/json') !== -1) {\r\n response.json().then((json) => {\r\n this.doResponse(response.status, json, request);\r\n });\r\n } else {\r\n if (this.context.editorConnection) {\r\n this.context.editorConnection.sendWarning(\r\n this.nodeScope.componentOwner.name,\r\n this.id,\r\n 'rest-run-waring-',\r\n {\r\n message: 'REST only supports json content type in response.'\r\n }\r\n );\r\n }\r\n }\r\n } else {\r\n response.text().then((raw) => {\r\n this.doResponse(response.status, raw, request);\r\n });\r\n }\r\n })\r\n .catch((e) => {\r\n console.log('REST: Failed to request', url);\r\n console.log(e);\r\n this.sendSignalOnOutput('failure');\r\n });\r\n }\r\n },\r\n doFetch: function () {\r\n this._internal.hasScheduledFetch = false;\r\n\r\n // Format resource path\r\n var resource = this._internal.resource;\r\n if (resource) {\r\n for (var key in this._internal.inputValues) {\r\n resource = resource.replace('{' + key + '}', this._internal.inputValues[key]);\r\n }\r\n }\r\n\r\n // Setup the request\r\n var request = {\r\n resource: resource,\r\n headers: {},\r\n method: this._internal.method !== undefined ? this._internal.method : 'GET',\r\n parameters: {}\r\n };\r\n\r\n // Process the request content with the preprocess function\r\n if (this._internal.requestFunc) {\r\n this._internal.requestFunc.apply(this._internal.self, [\r\n this._internal.inputValues,\r\n this._internal.outputValuesProxy,\r\n request\r\n ]);\r\n }\r\n\r\n // Perform request\r\n this.doExternalFetch(request);\r\n },\r\n cancelFetch: function () {\r\n if (typeof _noodl_cloud_runtime_version === 'undefined') {\r\n this._xhr && this._xhr.abort();\r\n } else {\r\n if (this.context.editorConnection) {\r\n this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name, this.id, 'rest-run-waring-', {\r\n message: \"REST doesn't support cancel in cloud functions.\"\r\n });\r\n }\r\n }\r\n }\r\n }\r\n};\r\n\r\nfunction _parseScriptForErrors(script, args, name, node, context, ports) {\r\n // Clear run warnings if the script is edited\r\n context.editorConnection.clearWarning(node.component.name, node.id, 'rest-run-waring-' + name);\r\n\r\n if (script === undefined) {\r\n context.editorConnection.clearWarning(node.component.name, node.id, 'rest-parse-waring-' + name);\r\n return;\r\n }\r\n\r\n try {\r\n new Function(...args, script);\r\n\r\n context.editorConnection.clearWarning(node.component.name, node.id, 'rest-parse-waring-' + name);\r\n } catch (e) {\r\n context.editorConnection.sendWarning(node.component.name, node.id, 'rest-parse-waring-' + name, {\r\n message: '' + name + ': ' + e.message,\r\n showGlobally: true\r\n });\r\n }\r\n\r\n // Extract inputs and outputs\r\n function _exists(port) {\r\n return ports.find((p) => p.name === port) !== undefined;\r\n }\r\n\r\n const scriptWithoutComments = script.replace(/\\/\\*[\\s\\S]*?\\*\\/|\\/\\/.*/g, ''); // Remove comments\r\n const inputs = scriptWithoutComments.match(/Inputs\\.[A-Za-z0-9]+/g);\r\n if (inputs) {\r\n const unique = {};\r\n inputs.forEach((v) => {\r\n unique[v.substring('Inputs.'.length)] = true;\r\n });\r\n\r\n Object.keys(unique).forEach((p) => {\r\n if (_exists('in-' + p)) return;\r\n\r\n ports.push({\r\n name: 'in-' + p,\r\n displayName: p,\r\n plug: 'input',\r\n type: '*',\r\n group: 'Inputs'\r\n });\r\n });\r\n }\r\n\r\n const outputs = scriptWithoutComments.match(/Outputs\\.[A-Za-z0-9]+/g);\r\n if (outputs) {\r\n const unique = {};\r\n outputs.forEach((v) => {\r\n unique[v.substring('Outputs.'.length)] = true;\r\n });\r\n\r\n Object.keys(unique).forEach((p) => {\r\n if (_exists('out-' + p)) return;\r\n\r\n ports.push({\r\n name: 'out-' + p,\r\n displayName: p,\r\n plug: 'output',\r\n type: '*',\r\n group: 'Outputs'\r\n });\r\n });\r\n }\r\n}\r\n\r\nmodule.exports = {\r\n node: RestNode,\r\n setup: function (context, graphModel) {\r\n if (!context.editorConnection) {\r\n return;\r\n }\r\n\r\n function _managePortsForNode(node) {\r\n function _updatePorts() {\r\n if (!node.parameters) {\r\n return;\r\n }\r\n\r\n var ports = [];\r\n function exists(name) {\r\n for (var i = 0; i < ports.length; i++) if (ports[i].name === name && ports[i].plug === 'input') return true;\r\n return false;\r\n }\r\n\r\n /* const _typeEnums = [{value:'string',label:'String'},\r\n {value:'boolean',label:'Boolean'},\r\n {value:'number',label:'Number'},\r\n {value:'color',label:'Color'},\r\n {value:'object',label:'Object'},\r\n {value:'array',label:'Array'}]*/\r\n\r\n // Inputs\r\n /* if (node.parameters['scriptInputs'] !== undefined && node.parameters['scriptInputs'].length > 0) {\r\n node.parameters['scriptInputs'].forEach((p) => {\r\n // Type for input\r\n ports.push({\r\n name: 'intype-' + p.label,\r\n displayName: 'Type',\r\n plug: 'input',\r\n type: { name: 'enum', enums: _typeEnums, allowEditOnly: true },\r\n default: 'string',\r\n parent: 'scriptInputs',\r\n parentItemId: p.id\r\n })\r\n \r\n // Default Value for input\r\n ports.push({\r\n name: 'in-' + p.label,\r\n displayName: p.label,\r\n plug: 'input',\r\n type: node.parameters['intype-' + p.label] || 'string',\r\n group: 'Input Values'\r\n })\r\n })\r\n }*/\r\n\r\n // Outputs\r\n /* if (node.parameters['scriptOutputs'] !== undefined && node.parameters['scriptOutputs'].length > 0) {\r\n node.parameters['scriptOutputs'].forEach((p) => {\r\n // Type for output\r\n ports.push({\r\n name: 'outtype-' + p.label,\r\n displayName: 'Type',\r\n plug: 'input',\r\n type: { name: 'enum', enums: _typeEnums, allowEditOnly: true },\r\n default: 'string',\r\n parent: 'scriptOutputs',\r\n parentItemId: p.id\r\n })\r\n \r\n // Value for output\r\n ports.push({\r\n name: 'out-' + p.label,\r\n displayName: p.label,\r\n plug: 'output',\r\n type: node.parameters['outtype-' + p.label] || '*',\r\n group: 'Outputs',\r\n })\r\n })\r\n }*/\r\n\r\n // Parse resource path inputs\r\n if (node.parameters.resource) {\r\n var inputs = node.parameters.resource.match(/\\{[A-Za-z0-9_]*\\}/g);\r\n for (var i in inputs) {\r\n var def = inputs[i];\r\n var name = def.replace('{', '').replace('}', '');\r\n if (exists('in-' + name)) continue;\r\n\r\n ports.push({\r\n name: 'in-' + name,\r\n displayName: name,\r\n type: 'string',\r\n plug: 'input',\r\n group: 'Inputs'\r\n });\r\n }\r\n }\r\n\r\n if (node.parameters['requestScript']) {\r\n _parseScriptForErrors(\r\n node.parameters['requestScript'],\r\n ['Inputs', 'Outputs', 'Request'],\r\n 'Request script',\r\n node,\r\n context,\r\n ports\r\n );\r\n }\r\n\r\n if (node.parameters['responseScript']) {\r\n _parseScriptForErrors(\r\n node.parameters['responseScript'],\r\n ['Inputs', 'Outputs', 'Response'],\r\n 'Response script',\r\n node,\r\n context,\r\n ports\r\n );\r\n }\r\n\r\n context.editorConnection.sendDynamicPorts(node.id, ports);\r\n }\r\n\r\n _updatePorts();\r\n node.on('parameterUpdated', function () {\r\n _updatePorts();\r\n });\r\n }\r\n\r\n graphModel.on('editorImportComplete', () => {\r\n graphModel.on('nodeAdded.REST2', function (node) {\r\n _managePortsForNode(node);\r\n });\r\n\r\n for (const node of graphModel.getNodesWithType('REST2')) {\r\n _managePortsForNode(node);\r\n }\r\n });\r\n }\r\n};\r\n","'use strict';\r\n\r\nvar DbModelCRUDBase = require('./dbmodelcrudbase');\r\nconst CloudStore = require('../../../api/cloudstore');\r\n\r\nvar SetDbModelPropertiedNodeDefinition = {\r\n node: {\r\n name: 'SetDbModelProperties',\r\n docs: 'https://docs.noodl.net/nodes/data/cloud-data/set-record-properties',\r\n displayNodeName: 'Set Record Properties',\r\n usePortAsLabel: 'collectionName',\r\n dynamicports: [\r\n {\r\n name: 'conditionalports/extended',\r\n condition: 'storeType = cloud OR storeType NOT SET',\r\n inputs: ['storeProperties']\r\n }\r\n ],\r\n inputs: {\r\n store: {\r\n displayName: 'Do',\r\n group: 'Actions',\r\n valueChangedToTrue: function () {\r\n if (this._internal.storeType === undefined || this._internal.storeType === 'cloud') this.scheduleSave();\r\n else this.scheduleStore();\r\n }\r\n },\r\n storeProperties: {\r\n displayName: 'Properties to store',\r\n group: 'General',\r\n type: {\r\n name: 'enum',\r\n enums: [\r\n { label: 'Only specified', value: 'specified' },\r\n { label: 'All', value: 'all' }\r\n ]\r\n },\r\n default: 'specified',\r\n set: function (value) {\r\n this._internal.storeProperties = value;\r\n }\r\n },\r\n storeType: {\r\n displayName: 'Store to',\r\n group: 'General',\r\n type: {\r\n name: 'enum',\r\n enums: [\r\n { label: 'Cloud and local', value: 'cloud' },\r\n { label: 'Local only', value: 'local' }\r\n ]\r\n },\r\n default: 'cloud',\r\n set: function (value) {\r\n this._internal.storeType = value;\r\n }\r\n }\r\n },\r\n outputs: {\r\n stored: {\r\n type: 'signal',\r\n displayName: 'Success',\r\n group: 'Events'\r\n }\r\n },\r\n methods: {\r\n scheduleSave: function () {\r\n const _this = this;\r\n const internal = this._internal;\r\n\r\n if (!this.checkWarningsBeforeCloudOp()) return;\r\n\r\n this.scheduleOnce('StorageSave', function () {\r\n if (!internal.model) {\r\n _this.setError('Missing Record Id');\r\n return;\r\n }\r\n \r\n const model = internal.model;\r\n for (const key in internal.inputValues) {\r\n model.set(key, internal.inputValues[key], { resolve: true });\r\n }\r\n \r\n CloudStore.forScope(_this.nodeScope.modelScope).save({\r\n collection: internal.collectionId,\r\n objectId: model.getId(), // Get the objectId part of the model id\r\n data: internal.storeProperties === 'all' ? model.data : internal.inputValues, // Only store input values by default, if not explicitly specified\r\n acl: _this._getACL(),\r\n success: function (response) {\r\n for (var key in response) {\r\n model.set(key, response[key]);\r\n }\r\n\r\n _this.sendSignalOnOutput('stored');\r\n },\r\n error: function (err) {\r\n _this.setError(err || 'Failed to save.');\r\n }\r\n });\r\n });\r\n },\r\n scheduleStore: function () {\r\n if (this.hasScheduledStore) return;\r\n this.hasScheduledStore = true;\r\n\r\n var internal = this._internal;\r\n this.scheduleAfterInputsHaveUpdated(() => {\r\n this.hasScheduledStore = false;\r\n if (!internal.model) return;\r\n\r\n for (var i in internal.inputValues) {\r\n internal.model.set(i, internal.inputValues[i], { resolve: true });\r\n }\r\n this.sendSignalOnOutput('stored');\r\n });\r\n }\r\n }\r\n }\r\n};\r\n\r\nDbModelCRUDBase.addBaseInfo(SetDbModelPropertiedNodeDefinition);\r\nDbModelCRUDBase.addModelId(SetDbModelPropertiedNodeDefinition);\r\nDbModelCRUDBase.addInputProperties(SetDbModelPropertiedNodeDefinition);\r\nDbModelCRUDBase.addAccessControl(SetDbModelPropertiedNodeDefinition);\r\n\r\nmodule.exports = SetDbModelPropertiedNodeDefinition;\r\n","'use strict';\r\n\r\nvar ModelCRUDBase = require('./modelcrudbase');\r\n\r\nvar SetModelPropertiedNodeDefinition = {\r\n node: {\r\n name: 'SetModelProperties',\r\n docs: 'https://docs.noodl.net/nodes/data/object/set-object-properties',\r\n displayNodeName: 'Set Object Properties',\r\n inputs: {\r\n store: {\r\n displayName: 'Do',\r\n group: 'Actions',\r\n valueChangedToTrue: function () {\r\n this.scheduleStore();\r\n }\r\n }\r\n },\r\n outputs: {\r\n stored: {\r\n type: 'signal',\r\n displayName: 'Done',\r\n group: 'Events'\r\n }\r\n }\r\n }\r\n};\r\n\r\nModelCRUDBase.addBaseInfo(SetModelPropertiedNodeDefinition);\r\nModelCRUDBase.addModelId(SetModelPropertiedNodeDefinition);\r\nModelCRUDBase.addInputProperties(SetModelPropertiedNodeDefinition);\r\n\r\nmodule.exports = SetModelPropertiedNodeDefinition;\r\n","'use strict';\n\nconst DateToStringNode = {\n name: 'Date To String',\n docs: 'https://docs.noodl.net/nodes/utilities/date-to-string',\n category: 'Utilities',\n initialize: function () {\n this._internal.formatString = '{year}-{month}-{date}';\n },\n inputs: {\n formatString: {\n displayName: 'Format',\n type: 'string',\n default: '{year}-{month}-{date}',\n set: function (value) {\n if (this._internal.formatString === value) return;\n this._internal.formatString = value;\n\n if (this._internal.currentInput !== undefined) {\n this._format();\n this.flagOutputDirty('currentValue');\n }\n }\n },\n input: {\n type: { name: 'date' },\n displayName: 'Date',\n set: function (value) {\n const _value = typeof value === 'string' ? new Date(value) : value;\n if (this._internal.currentInput === _value) return;\n\n this._internal.currentInput = _value;\n this._format();\n }\n }\n },\n outputs: {\n currentValue: {\n type: 'string',\n displayName: 'Date String',\n group: 'Value',\n getter: function () {\n return this._internal.dateString;\n }\n },\n inputChanged: {\n type: 'signal',\n displayName: 'Date Changed',\n group: 'Signals'\n },\n onError: {\n type: 'signal',\n displayName: 'Invalid Date',\n group: 'Signals'\n }\n },\n methods: {\n _format() {\n try {\n const t = this._internal.currentInput;\n const format = this._internal.formatString;\n const date = ('0' + t.getDate()).slice(-2);\n const month = ('0' + (t.getMonth() + 1)).slice(-2);\n const monthShort = new Intl.DateTimeFormat('en-US', { month: 'short' }).format(t);\n const year = t.getFullYear();\n const yearShort = year.toString().substring(2);\n const hours = ('0' + t.getHours()).slice(-2);\n const minutes = ('0' + t.getMinutes()).slice(-2);\n const seconds = ('0' + t.getSeconds()).slice(-2);\n\n this._internal.dateString = format\n .replace(/\\{date\\}/g, date)\n .replace(/\\{month\\}/g, month)\n .replace(/\\{monthShort\\}/g, monthShort)\n .replace(/\\{year\\}/g, year)\n .replace(/\\{yearShort\\}/g, yearShort)\n .replace(/\\{hours\\}/g, hours)\n .replace(/\\{minutes\\}/g, minutes)\n .replace(/\\{seconds\\}/g, seconds);\n } catch (error) {\n // Set the output to be blank, makes it easier to handle.\n this._internal.dateString = '';\n this.flagOutputDirty('onError');\n }\n\n // Flag that the value have changed\n this.flagOutputDirty('currentValue');\n this.sendSignalOnOutput('inputChanged');\n }\n }\n};\n\nmodule.exports = {\n node: DateToStringNode\n};\n","'use strict';\r\n\r\nconst difference = require('lodash.difference');\r\n\r\n//const Model = require('./data/model');\r\n\r\nconst ExpressionNode = {\r\n name: 'Expression',\r\n docs: 'https://docs.noodl.net/nodes/math/expression',\r\n usePortAsLabel: 'expression',\r\n category: 'CustomCode',\r\n color: 'javascript',\r\n nodeDoubleClickAction: {\r\n focusPort: 'Expression'\r\n },\r\n searchTags: ['javascript'],\r\n initialize: function () {\r\n var internal = this._internal;\r\n\r\n internal.scope = {};\r\n internal.hasScheduledEvaluation = false;\r\n\r\n internal.code = undefined;\r\n internal.cachedValue = 0;\r\n internal.currentExpression = '';\r\n internal.compiledFunction = undefined;\r\n internal.inputNames = [];\r\n internal.inputValues = [];\r\n },\r\n getInspectInfo() {\r\n return this._internal.cachedValue;\r\n },\r\n inputs: {\r\n expression: {\r\n group: 'General',\r\n inputPriority: 1,\r\n type: {\r\n name: 'string',\r\n allowEditOnly: true,\r\n codeeditor: 'javascript'\r\n },\r\n displayName: 'Expression',\r\n set: function (value) {\r\n var internal = this._internal;\r\n internal.currentExpression = functionPreamble + 'return (' + value + ');';\r\n internal.compiledFunction = undefined;\r\n\r\n var newInputs = parsePorts(value);\r\n\r\n var inputsToAdd = difference(newInputs, internal.inputNames);\r\n var inputsToRemove = difference(internal.inputNames, newInputs);\r\n\r\n var self = this;\r\n inputsToRemove.forEach(function (name) {\r\n self.deregisterInput(name);\r\n delete internal.scope[name];\r\n });\r\n\r\n inputsToAdd.forEach(function (name) {\r\n if (self.hasInput(name)) {\r\n return;\r\n }\r\n\r\n self.registerInput(name, {\r\n set: function (value) {\r\n internal.scope[name] = value;\r\n if (!this.isInputConnected('run')) this._scheduleEvaluateExpression();\r\n }\r\n });\r\n\r\n internal.scope[name] = 0;\r\n self._inputValues[name] = 0;\r\n });\r\n\r\n /* if(value.indexOf('Vars') !== -1 || value.indexOf('Variables') !== -1) {\r\n // This expression is using variables, it should listen for changes\r\n this._internal.onVariablesChangedCallback = (args) => {\r\n this._scheduleEvaluateExpression()\r\n }\r\n\r\n Model.get('--ndl--global-variables').off('change',this._internal.onVariablesChangedCallback)\r\n Model.get('--ndl--global-variables').on('change',this._internal.onVariablesChangedCallback)\r\n }*/\r\n\r\n internal.inputNames = Object.keys(internal.scope);\r\n if (!this.isInputConnected('run')) this._scheduleEvaluateExpression();\r\n }\r\n },\r\n run: {\r\n group: 'Actions',\r\n displayName: 'Run',\r\n type: 'signal',\r\n valueChangedToTrue: function () {\r\n this._scheduleEvaluateExpression();\r\n }\r\n }\r\n },\r\n outputs: {\r\n result: {\r\n group: 'Result',\r\n type: '*',\r\n displayName: 'Result',\r\n getter: function () {\r\n if (!this._internal.currentExpression) {\r\n return 0;\r\n }\r\n\r\n return this._internal.cachedValue;\r\n }\r\n },\r\n isTrue: {\r\n group: 'Result',\r\n type: 'boolean',\r\n displayName: 'Is True',\r\n getter: function () {\r\n if (!this._internal.currentExpression) {\r\n return false;\r\n }\r\n\r\n return !!this._internal.cachedValue;\r\n }\r\n },\r\n isFalse: {\r\n group: 'Result',\r\n type: 'boolean',\r\n displayName: 'Is False',\r\n getter: function () {\r\n if (!this._internal.currentExpression) {\r\n return true;\r\n }\r\n\r\n return !this._internal.cachedValue;\r\n }\r\n },\r\n isTrueEv: {\r\n group: 'Events',\r\n type: 'signal',\r\n displayName: 'On True'\r\n },\r\n isFalseEv: {\r\n group: 'Events',\r\n type: 'signal',\r\n displayName: 'On False'\r\n }\r\n },\r\n prototypeExtensions: {\r\n registerInputIfNeeded: {\r\n value: function (name) {\r\n if (this.hasInput(name)) {\r\n return;\r\n }\r\n\r\n this._internal.scope[name] = 0;\r\n this._inputValues[name] = 0;\r\n\r\n this.registerInput(name, {\r\n set: function (value) {\r\n this._internal.scope[name] = value;\r\n if (!this.isInputConnected('run')) this._scheduleEvaluateExpression();\r\n }\r\n });\r\n }\r\n },\r\n _scheduleEvaluateExpression: {\r\n value: function () {\r\n var internal = this._internal;\r\n if (internal.hasScheduledEvaluation === false) {\r\n internal.hasScheduledEvaluation = true;\r\n this.flagDirty();\r\n this.scheduleAfterInputsHaveUpdated(function () {\r\n var lastValue = internal.cachedValue;\r\n internal.cachedValue = this._calculateExpression();\r\n if (lastValue !== internal.cachedValue) {\r\n this.flagOutputDirty('result');\r\n this.flagOutputDirty('isTrue');\r\n this.flagOutputDirty('isFalse');\r\n }\r\n if (internal.cachedValue) this.sendSignalOnOutput('isTrueEv');\r\n else this.sendSignalOnOutput('isFalseEv');\r\n internal.hasScheduledEvaluation = false;\r\n });\r\n }\r\n }\r\n },\r\n _calculateExpression: {\r\n value: function () {\r\n var internal = this._internal;\r\n\r\n if (!internal.compiledFunction) {\r\n internal.compiledFunction = this._compileFunction();\r\n }\r\n for (var i = 0; i < internal.inputNames.length; ++i) {\r\n var inputValue = internal.scope[internal.inputNames[i]];\r\n internal.inputValues[i] = inputValue;\r\n }\r\n try {\r\n return internal.compiledFunction.apply(null, internal.inputValues);\r\n } catch (e) {\r\n console.error('Error in expression:', e.message);\r\n }\r\n return 0;\r\n }\r\n },\r\n _compileFunction: {\r\n value: function () {\r\n var expression = this._internal.currentExpression;\r\n var args = Object.keys(this._internal.scope);\r\n\r\n var key = expression + args.join(' ');\r\n\r\n if (compiledFunctionsCache.hasOwnProperty(key) === false) {\r\n args.push(expression);\r\n\r\n try {\r\n compiledFunctionsCache[key] = construct(Function, args);\r\n } catch (e) {\r\n console.error('Failed to compile JS function', e.message);\r\n }\r\n }\r\n return compiledFunctionsCache[key];\r\n }\r\n }\r\n }\r\n};\r\n\r\nvar functionPreamble = [\r\n 'var min = Math.min,' +\r\n ' max = Math.max,' +\r\n ' cos = Math.cos,' +\r\n ' sin = Math.sin,' +\r\n ' tan = Math.tan,' +\r\n ' sqrt = Math.sqrt,' +\r\n ' pi = Math.PI,' +\r\n ' round = Math.round,' +\r\n ' floor = Math.floor,' +\r\n ' ceil = Math.ceil,' +\r\n ' abs = Math.abs,' +\r\n ' random = Math.random;'\r\n /* ' Vars = Variables = Noodl.Object.get(\"--ndl--global-variables\");' */\r\n].join('');\r\n\r\n//Since apply cannot be used on constructors (i.e. new Something) we need this hax\r\n//see http://stackoverflow.com/questions/1606797/use-of-apply-with-new-operator-is-this-possible\r\nfunction construct(constructor, args) {\r\n function F() {\r\n return constructor.apply(this, args);\r\n }\r\n F.prototype = constructor.prototype;\r\n return new F();\r\n}\r\n\r\nvar compiledFunctionsCache = {};\r\n\r\nvar portsToIgnore = [\r\n 'min',\r\n 'max',\r\n 'cos',\r\n 'sin',\r\n 'tan',\r\n 'sqrt',\r\n 'pi',\r\n 'round',\r\n 'floor',\r\n 'ceil',\r\n 'abs',\r\n 'random',\r\n 'Math',\r\n 'window',\r\n 'document',\r\n 'undefined',\r\n 'Vars',\r\n 'true',\r\n 'false',\r\n 'null',\r\n 'Boolean'\r\n];\r\n\r\nfunction parsePorts(expression) {\r\n var ports = [];\r\n\r\n function addPort(name) {\r\n if (portsToIgnore.indexOf(name) !== -1) return;\r\n if (\r\n ports.some(function (p) {\r\n return p === name;\r\n })\r\n )\r\n return;\r\n\r\n ports.push(name);\r\n }\r\n\r\n // First remove all strings\r\n expression = expression.replace(/\\\"([^\\\"]*)\\\"/g, '').replace(/\\'([^\\']*)\\'/g, '');\r\n\r\n // Extract identifiers\r\n var identifiers = expression.matchAll(/[a-zA-Z\\_\\$][a-zA-Z0-9\\.\\_\\$]*/g);\r\n for (const _id of identifiers) {\r\n var name = _id[0];\r\n if (name.indexOf('.') !== -1) {\r\n name = name.split('.')[0]; // Take first symbol on \".\" sequence\r\n }\r\n\r\n addPort(name);\r\n }\r\n\r\n return ports;\r\n}\r\n\r\nfunction updatePorts(nodeId, expression, editorConnection) {\r\n var portNames = parsePorts(expression);\r\n\r\n var ports = portNames.map(function (name) {\r\n return {\r\n group: 'Parameters',\r\n name: name,\r\n type: {\r\n name: '*',\r\n editAsType: 'string'\r\n },\r\n plug: 'input'\r\n };\r\n });\r\n\r\n editorConnection.sendDynamicPorts(nodeId, ports);\r\n}\r\n\r\nfunction evalCompileWarnings(editorConnection, node) {\r\n try {\r\n new Function(node.parameters.expression);\r\n editorConnection.clearWarning(node.component.name, node.id, 'expression-compile-error');\r\n } catch (e) {\r\n editorConnection.sendWarning(node.component.name, node.id, 'expression-compile-error', {\r\n message: e.message\r\n });\r\n }\r\n}\r\n\r\nmodule.exports = {\r\n node: ExpressionNode,\r\n setup: function (context, graphModel) {\r\n if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {\r\n return;\r\n }\r\n\r\n graphModel.on('nodeAdded.Expression', function (node) {\r\n if (node.parameters.expression) {\r\n updatePorts(node.id, node.parameters.expression, context.editorConnection);\r\n evalCompileWarnings(context.editorConnection, node);\r\n }\r\n node.on('parameterUpdated', function (event) {\r\n if (event.name === 'expression') {\r\n updatePorts(node.id, node.parameters.expression, context.editorConnection);\r\n evalCompileWarnings(context.editorConnection, node);\r\n }\r\n });\r\n });\r\n }\r\n};\r\n","'use strict';\r\n\r\nfunction invert(value) {\r\n if (value === undefined) {\r\n return undefined;\r\n }\r\n return !value;\r\n}\r\n\r\nconst InverterNode = {\r\n name: 'Inverter',\r\n docs: 'https://docs.noodl.net/nodes/logic/inverter',\r\n category: 'Logic',\r\n initialize: function () {\r\n this._internal.currentValue = undefined;\r\n },\r\n getInspectInfo() {\r\n return String(invert(this._internal.currentValue));\r\n },\r\n inputs: {\r\n value: {\r\n type: {\r\n name: 'boolean'\r\n },\r\n displayName: 'Value',\r\n set: function (value) {\r\n this._internal.currentValue = value;\r\n this.flagOutputDirty('result');\r\n }\r\n }\r\n },\r\n outputs: {\r\n result: {\r\n type: 'boolean',\r\n displayName: 'Result',\r\n getter: function () {\r\n return invert(this._internal.currentValue);\r\n }\r\n }\r\n }\r\n};\r\n\r\nmodule.exports = {\r\n node: InverterNode\r\n};\r\n","'use strict';\r\n\r\nconst OrNode = {\r\n name: 'Or',\r\n docs: 'https://docs.noodl.net/nodes/logic/or',\r\n category: 'Logic',\r\n initialize: function () {\r\n this._internal.inputs = [];\r\n },\r\n getInspectInfo() {\r\n return this._internal.inputs.some(isTrue);\r\n },\r\n numberedInputs: {\r\n input: {\r\n type: 'boolean',\r\n displayPrefix: 'Input',\r\n createSetter(index) {\r\n return function (value) {\r\n if (this._internal.inputs[index] === value) {\r\n return;\r\n }\r\n\r\n this._internal.inputs[index] = value;\r\n this.flagOutputDirty('result');\r\n };\r\n }\r\n }\r\n },\r\n outputs: {\r\n result: {\r\n type: 'boolean',\r\n displayName: 'Result',\r\n getter: function () {\r\n return this._internal.inputs.some(isTrue);\r\n }\r\n }\r\n }\r\n};\r\n\r\nmodule.exports = {\r\n node: OrNode\r\n};\r\n\r\nfunction isTrue(value) {\r\n return value ? true : false;\r\n}\r\n","const { Node } = require('../../../noodl-runtime');\r\nconst guid = require('../../guid');\r\nconst Model = require('../../model');\r\n\r\nfunction sendSignalOnInput(itemNode, name) {\r\n itemNode.queueInput(name, true); // send signal\r\n itemNode.queueInput(name, false);\r\n}\r\n\r\nconst RunTasksDefinition = {\r\n name: 'RunTasks',\r\n displayNodeName: 'Run Tasks',\r\n docs: 'https://docs.noodl.net/nodes/data/run-tasks',\r\n color: 'data',\r\n category: 'Data',\r\n initialize() {\r\n this._internal.queuedOperations = [];\r\n this._internal.state = 'idle';\r\n this._internal.maxRunningTasks = 10;\r\n this._internal.activeTasks = new Map(); //id => ComponentInstanceNode\r\n },\r\n inputs: {\r\n items: {\r\n group: 'Data',\r\n displayName: 'Items',\r\n type: 'array',\r\n set: function (value) {\r\n if (!value) return;\r\n if (value === this._internal.items) return;\r\n\r\n this._internal.items = value;\r\n }\r\n },\r\n stopOnFailure: {\r\n group: 'General',\r\n displayName: 'Stop On Failure',\r\n type: 'boolean',\r\n default: false,\r\n set: function (value) {\r\n this._internal.stopOnFailure = value;\r\n }\r\n },\r\n maxRunningTasks: {\r\n group: 'General',\r\n displayName: 'Max Running Tasks',\r\n type: 'number',\r\n default: 10,\r\n set: function (value) {\r\n this._internal.maxRunningTasks = value;\r\n }\r\n },\r\n taskTemplate: {\r\n type: 'component',\r\n displayName: 'Template',\r\n group: 'General',\r\n set: function (value) {\r\n this._internal.template = value;\r\n }\r\n },\r\n run: {\r\n group: 'General',\r\n displayName: 'Do',\r\n type: 'signal',\r\n valueChangedToTrue: function () {\r\n this.scheduleRun();\r\n }\r\n },\r\n abort: {\r\n group: 'General',\r\n displayName: 'Abort',\r\n type: 'signal',\r\n valueChangedToTrue: function () {\r\n this.scheduleAbort();\r\n }\r\n }\r\n },\r\n outputs: {\r\n success: {\r\n type: 'signal',\r\n group: 'Events',\r\n displayName: 'Success'\r\n },\r\n failure: {\r\n type: 'signal',\r\n group: 'Events',\r\n displayName: 'Failure'\r\n },\r\n done: {\r\n type: 'signal',\r\n group: 'Events',\r\n displayName: 'Done'\r\n },\r\n aborted: {\r\n type: 'signal',\r\n group: 'Events',\r\n displayName: 'Aborted'\r\n }\r\n },\r\n methods: {\r\n scheduleRun() {\r\n var internal = this._internal;\r\n if (!internal.hasScheduledRun) {\r\n internal.hasScheduledRun = true;\r\n this.scheduleAfterInputsHaveUpdated(() => {\r\n this._queueOperation(() => {\r\n internal.hasScheduledRun = false;\r\n this.run();\r\n });\r\n });\r\n }\r\n },\r\n scheduleAbort() {\r\n var internal = this._internal;\r\n if (!internal.hasScheduledAbort) {\r\n internal.hasScheduledAbort = true;\r\n this.scheduleAfterInputsHaveUpdated(() => {\r\n this._queueOperation(() => {\r\n internal.hasScheduledAbort = false;\r\n this.abort();\r\n });\r\n });\r\n }\r\n },\r\n async createTaskComponent(item) {\r\n const internal = this._internal;\r\n\r\n const modelScope = this.nodeScope.modelScope || Model;\r\n const model = modelScope.create(item);\r\n\r\n var itemNode = await this.nodeScope.createNode(internal.template, guid(), {\r\n _forEachModel: model,\r\n _forEachNode: this\r\n });\r\n\r\n // This is needed to make sure any action connected to \"Do\"\r\n // is not run directly\r\n const _isInputConnected = itemNode.isInputConnected.bind(itemNode);\r\n itemNode.isInputConnected = (name) => {\r\n if (name === 'Do') return true;\r\n return _isInputConnected(name);\r\n };\r\n\r\n // Set the Id as an input\r\n if (itemNode.hasInput('Id')) {\r\n itemNode.setInputValue('Id', model.getId());\r\n }\r\n if (itemNode.hasInput('id')) {\r\n itemNode.setInputValue('id', model.getId());\r\n }\r\n\r\n // Push all other values also as inputs\r\n // if they exist as component inputs\r\n for (var inputKey in itemNode._inputs) {\r\n if (model.data[inputKey] !== undefined) itemNode.setInputValue(inputKey, model.data[inputKey]);\r\n }\r\n\r\n // capture signals\r\n itemNode._internal.creatorCallbacks = {\r\n onOutputChanged: (name, value, oldValue) => {\r\n if ((oldValue === false || oldValue === undefined) && value === true) {\r\n this.itemOutputSignalTriggered(name, model, itemNode);\r\n }\r\n }\r\n };\r\n\r\n return itemNode;\r\n },\r\n async startTask(task) {\r\n const internal = this._internal;\r\n\r\n try {\r\n const taskComponent = await this.createTaskComponent(task);\r\n internal.runningTasks++;\r\n sendSignalOnInput(taskComponent, 'Do');\r\n internal.activeTasks.set(taskComponent.id, taskComponent);\r\n } catch (e) {\r\n // Something went wrong starting the task\r\n console.log(e);\r\n }\r\n },\r\n async run() {\r\n const internal = this._internal;\r\n\r\n if (this.context.editorConnection) {\r\n if (internal.state !== 'idle') {\r\n this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name, this.id, 'run-tasks', {\r\n message: 'Cannot start when not in idle mode'\r\n });\r\n } else if (!internal.template) {\r\n this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name, this.id, 'run-tasks', {\r\n message: 'No task template specified.'\r\n });\r\n } else if (!internal.items) {\r\n this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name, this.id, 'run-tasks', {\r\n message: 'No items array provided.'\r\n });\r\n } else {\r\n this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'run-tasks');\r\n }\r\n }\r\n\r\n if (internal.state !== 'idle') {\r\n return;\r\n }\r\n\r\n if (!internal.template) {\r\n return;\r\n }\r\n\r\n if (!internal.items) {\r\n return;\r\n }\r\n\r\n internal.state = 'running';\r\n internal.numTasks = internal.items.length;\r\n internal.failedTasks = 0;\r\n internal.completedTasks = 0;\r\n internal.queuedTasks = [].concat(internal.items);\r\n internal.runningTasks = 0;\r\n\r\n // No tasks\r\n if (internal.items.length === 0) {\r\n this.sendSignalOnOutput('success');\r\n internal.state = 'idle';\r\n }\r\n\r\n // Start tasks\r\n for (let i = 0; i < Math.min(internal.maxRunningTasks, internal.queuedTasks.length); i++) {\r\n const task = internal.queuedTasks.shift();\r\n if (!task) break;\r\n\r\n this.startTask(task);\r\n }\r\n },\r\n abort: function () {\r\n const internal = this._internal;\r\n\r\n internal.state = 'aborted';\r\n },\r\n itemOutputSignalTriggered: function (name, model, itemNode) {\r\n const internal = this._internal;\r\n\r\n if (internal.state === 'idle') {\r\n // Signal while we are not running is ignored\r\n return;\r\n }\r\n\r\n const checkDone = () => {\r\n if (internal.state === 'aborted') {\r\n this.sendSignalOnOutput('aborted');\r\n internal.state = 'idle';\r\n return;\r\n }\r\n\r\n if (internal.completedTasks === internal.numTasks) {\r\n if (internal.failedTasks === 0) this.sendSignalOnOutput('success');\r\n else this.sendSignalOnOutput('failure');\r\n this.sendSignalOnOutput('done');\r\n internal.state = 'idle';\r\n } else {\r\n if (internal.stopOnFailure) {\r\n // Only continue if there are no failed tasks, otherwise aborted\r\n if (internal.failedTasks === 0) {\r\n internal.runningTasks++;\r\n const task = internal.queuedTasks.shift();\r\n if (task) this.startTask(task);\r\n } else {\r\n this.sendSignalOnOutput('failure');\r\n this.sendSignalOnOutput('aborted');\r\n }\r\n } else {\r\n internal.runningTasks++;\r\n const task = internal.queuedTasks.shift();\r\n if (task) this.startTask(task);\r\n }\r\n }\r\n };\r\n\r\n if (name === 'Success') {\r\n internal.completedTasks++;\r\n internal.runningTasks--;\r\n checkDone();\r\n } else if (name === 'Failure') {\r\n internal.completedTasks++;\r\n internal.failedTasks++;\r\n internal.runningTasks--;\r\n checkDone();\r\n }\r\n\r\n internal.activeTasks.delete(itemNode.id);\r\n this.nodeScope.deleteNode(itemNode);\r\n },\r\n _queueOperation(op) {\r\n this._internal.queuedOperations.push(op);\r\n this._runQueueOperations();\r\n },\r\n async _runQueueOperations() {\r\n if (this.runningOperations) {\r\n return;\r\n }\r\n this.runningOperations = true;\r\n\r\n while (this._internal.queuedOperations.length) {\r\n const op = this._internal.queuedOperations.shift();\r\n await op();\r\n }\r\n\r\n this.runningOperations = false;\r\n }\r\n },\r\n _deleteAllTasks() {\r\n for (const taskComponent of this._internal.activeTasks) {\r\n this.nodeScope.deleteNode(taskComponent);\r\n }\r\n this._internal.activeTasks.clear();\r\n },\r\n _onNodeDeleted: function () {\r\n Node.prototype._onNodeDeleted.call(this);\r\n this._deleteAllTasks();\r\n }\r\n};\r\n\r\nmodule.exports = {\r\n node: RunTasksDefinition\r\n};\r\n","const JavascriptNodeParser = require('../../javascriptnodeparser');\r\nconst { logJavaScriptNodeError } = require('../../utils');\r\n\r\nconst SimpleJavascriptNode = {\r\n name: 'JavaScriptFunction',\r\n displayNodeName: 'Function',\r\n docs: 'https://docs.noodl.net/nodes/javascript/function',\r\n category: 'CustomCode',\r\n color: 'javascript',\r\n nodeDoubleClickAction: {\r\n focusPort: 'Script'\r\n },\r\n searchTags: ['javascript'],\r\n exportDynamicPorts: true,\r\n initialize: function () {\r\n this._internal.inputValues = {};\r\n this._internal.outputValues = {};\r\n\r\n this._internal.outputValuesProxy = new Proxy(this._internal.outputValues, {\r\n set: (obj, prop, value) => {\r\n //a function node can continue running after it has been deleted. E.g. with timeouts or event listeners that hasn't been removed.\r\n //if the node is deleted, just do nothing\r\n if (this._deleted) {\r\n return;\r\n }\r\n\r\n //only send outputs when they change.\r\n //Some Noodl projects rely on this behavior, so changing it breaks backwards compability\r\n if (value !== this._internal.outputValues[prop]) {\r\n this.registerOutputIfNeeded('out-' + prop);\r\n\r\n this._internal.outputValues[prop] = value;\r\n this.flagOutputDirty('out-' + prop);\r\n }\r\n return true;\r\n }\r\n });\r\n\r\n this._internal._this = {};\r\n },\r\n getInspectInfo() {\r\n return [\r\n {\r\n type: 'value',\r\n value: {\r\n inputs: this._internal.inputValues,\r\n outputs: this._internal.outputValues\r\n }\r\n }\r\n ];\r\n },\r\n inputs: {\r\n scriptInputs: {\r\n type: {\r\n name: 'proplist',\r\n allowEditOnly: true\r\n },\r\n group: 'Script Inputs',\r\n set(value) {\r\n // ignore\r\n }\r\n },\r\n scriptOutputs: {\r\n type: {\r\n name: 'proplist',\r\n allowEditOnly: true\r\n },\r\n group: 'Script Outputs',\r\n set(value) {\r\n // ignore\r\n }\r\n },\r\n functionScript: {\r\n displayName: 'Script',\r\n plug: 'input',\r\n type: {\r\n name: 'string',\r\n allowEditOnly: true,\r\n codeeditor: 'javascript'\r\n },\r\n group: 'General',\r\n set(script) {\r\n if (script === undefined) {\r\n this._internal.func = undefined;\r\n return;\r\n }\r\n\r\n this._internal.func = this.parseScript(script);\r\n\r\n if (!this.isInputConnected('run')) this.scheduleRun();\r\n }\r\n },\r\n run: {\r\n type: 'signal',\r\n displayName: 'Run',\r\n group: 'Actions',\r\n valueChangedToTrue: function () {\r\n this.scheduleRun();\r\n }\r\n }\r\n },\r\n outputs: {},\r\n methods: {\r\n scheduleRun: function () {\r\n if (this.runScheduled) return;\r\n this.runScheduled = true;\r\n\r\n this.scheduleAfterInputsHaveUpdated(() => {\r\n this.runScheduled = false;\r\n\r\n if (!this._deleted) {\r\n this.runScript();\r\n }\r\n });\r\n },\r\n runScript: async function () {\r\n const func = this._internal.func;\r\n\r\n if (func === undefined) return;\r\n\r\n const inputs = this._internal.inputValues;\r\n const outputs = this._internal.outputValuesProxy;\r\n\r\n // Prepare send signal functions\r\n for (const key in this.model.outputPorts) {\r\n if (this._isSignalType(key)) {\r\n const _sendSignal = () => {\r\n if (this.hasOutput(key)) this.sendSignalOnOutput(key);\r\n };\r\n this._internal.outputValues[key.substring('out-'.length)] = _sendSignal;\r\n this._internal.outputValues[key.substring('out-'.length)].send = _sendSignal;\r\n }\r\n }\r\n\r\n try {\r\n await func.apply(this._internal._this, [\r\n inputs,\r\n outputs,\r\n JavascriptNodeParser.createNoodlAPI(this.nodeScope.modelScope),\r\n JavascriptNodeParser.getComponentScopeForNode(this)\r\n ]);\r\n } catch (e) {\r\n logJavaScriptNodeError(e);\r\n\r\n if (this.context.editorConnection && this.context.isWarningTypeEnabled('javascriptExecution')) {\r\n this.context.editorConnection.sendWarning(\r\n this.nodeScope.componentOwner.name,\r\n this.id,\r\n 'js-function-run-waring',\r\n {\r\n showGlobally: true,\r\n message: e.message,\r\n stack: e.stack\r\n }\r\n );\r\n }\r\n }\r\n },\r\n setScriptInputValue: function (name, value) {\r\n this._internal.inputValues[name] = value;\r\n\r\n if (!this.isInputConnected('run')) this.scheduleRun();\r\n },\r\n getScriptOutputValue: function (name) {\r\n if (this._isSignalType(name)) {\r\n return undefined;\r\n }\r\n return this._internal.outputValues[name];\r\n },\r\n setScriptInputType: function (name, type) {\r\n this._internal.inputTypes[name] = type;\r\n },\r\n setScriptOutputType: function (name, type) {\r\n this._internal.outputTypes[name] = type;\r\n },\r\n parseScript: function (script) {\r\n var func;\r\n try {\r\n const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;\r\n func = new AsyncFunction(\r\n 'Inputs',\r\n 'Outputs',\r\n 'Noodl',\r\n 'Component',\r\n JavascriptNodeParser.getCodePrefix() + script\r\n );\r\n } catch (e) {\r\n console.log('Error while parsing action script: ' + e);\r\n }\r\n\r\n return func;\r\n },\r\n _isSignalType: function (name) {\r\n // This will catch signals in script that may not have been delivered by the editor yet\r\n return this.model.outputPorts[name] && this.model.outputPorts[name].type === 'signal';\r\n },\r\n registerInputIfNeeded: function (name) {\r\n if (this.hasInput(name)) {\r\n return;\r\n }\r\n\r\n if (name.startsWith('in-')) {\r\n const n = name.substring('in-'.length);\r\n\r\n const input = {\r\n set: this.setScriptInputValue.bind(this, n)\r\n };\r\n\r\n //make sure we register the type as well, so Noodl resolves types like color styles to an actual color\r\n if (this.model && this.model.parameters['intype-' + n]) {\r\n input.type = this.model.parameters['intype-' + n];\r\n }\r\n\r\n this.registerInput(name, input);\r\n }\r\n\r\n if (name.startsWith('intype-')) {\r\n const n = name.substring('intype-'.length);\r\n\r\n this.registerInput(name, {\r\n set(value) {\r\n //make sure we register the type as well, so Noodl resolves types like color styles to an actual color\r\n if (this.hasInput('in' + n)) {\r\n this.getInput('in' + n).type = value;\r\n }\r\n }\r\n });\r\n }\r\n\r\n if (name.startsWith('outtype-')) {\r\n this.registerInput(name, {\r\n set() {} // Ignore\r\n });\r\n }\r\n },\r\n registerOutputIfNeeded: function (name) {\r\n if (this.hasOutput(name)) {\r\n return;\r\n }\r\n\r\n if (name.startsWith('out-'))\r\n return this.registerOutput(name, {\r\n getter: this.getScriptOutputValue.bind(this, name.substring('out-'.length))\r\n });\r\n }\r\n }\r\n};\r\n\r\nfunction _parseScriptForErrorsAndPorts(script, name, node, context, ports) {\r\n // Clear run warnings if the script is edited\r\n context.editorConnection.clearWarning(node.component.name, node.id, 'js-function-run-waring');\r\n\r\n if (script === undefined) {\r\n context.editorConnection.clearWarning(node.component.name, node.id, 'js-function-parse-waring');\r\n return;\r\n }\r\n\r\n try {\r\n const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;\r\n new AsyncFunction('Inputs', 'Outputs', 'Noodl', 'Component', script);\r\n\r\n context.editorConnection.clearWarning(node.component.name, node.id, 'js-function-parse-waring');\r\n } catch (e) {\r\n context.editorConnection.sendWarning(node.component.name, node.id, 'js-function-parse-waring', {\r\n showGlobally: true,\r\n message: e.message\r\n });\r\n }\r\n\r\n JavascriptNodeParser.parseAndAddPortsFromScript(script, ports, {\r\n inputPrefix: 'in-',\r\n outputPrefix: 'out-'\r\n });\r\n}\r\n\r\nconst inputTypeEnums = [\r\n {\r\n value: 'string',\r\n label: 'String'\r\n },\r\n {\r\n value: 'boolean',\r\n label: 'Boolean'\r\n },\r\n {\r\n value: 'number',\r\n label: 'Number'\r\n },\r\n {\r\n value: 'object',\r\n label: 'Object'\r\n },\r\n {\r\n value: 'date',\r\n label: 'Date'\r\n },\r\n {\r\n value: 'array',\r\n label: 'Array'\r\n },\r\n {\r\n value: 'color',\r\n label: 'Color'\r\n }\r\n];\r\n\r\nmodule.exports = {\r\n node: SimpleJavascriptNode,\r\n setup: function (context, graphModel) {\r\n if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {\r\n return;\r\n }\r\n\r\n function _managePortsForNode(node) {\r\n function _updatePorts() {\r\n var ports = [];\r\n\r\n const _outputTypeEnums = inputTypeEnums.concat([\r\n {\r\n value: 'signal',\r\n label: 'Signal'\r\n }\r\n ]);\r\n\r\n // Outputs\r\n if (node.parameters['scriptOutputs'] !== undefined && node.parameters['scriptOutputs'].length > 0) {\r\n node.parameters['scriptOutputs'].forEach((p) => {\r\n // Type for output\r\n ports.push({\r\n name: 'outtype-' + p.label,\r\n displayName: 'Type',\r\n editorName: p.label + ' | Type',\r\n plug: 'input',\r\n type: {\r\n name: 'enum',\r\n enums: _outputTypeEnums,\r\n allowEditOnly: true\r\n },\r\n default: 'string',\r\n parent: 'scriptOutputs',\r\n parentItemId: p.id\r\n });\r\n\r\n // Value for output\r\n ports.push({\r\n name: 'out-' + p.label,\r\n displayName: p.label,\r\n plug: 'output',\r\n type: node.parameters['outtype-' + p.label] || '*',\r\n group: 'Outputs'\r\n });\r\n });\r\n }\r\n\r\n // Inputs\r\n if (node.parameters['scriptInputs'] !== undefined && node.parameters['scriptInputs'].length > 0) {\r\n node.parameters['scriptInputs'].forEach((p) => {\r\n // Type for input\r\n ports.push({\r\n name: 'intype-' + p.label,\r\n displayName: 'Type',\r\n editorName: p.label + ' | Type',\r\n plug: 'input',\r\n type: {\r\n name: 'enum',\r\n enums: inputTypeEnums,\r\n allowEditOnly: true\r\n },\r\n default: 'string',\r\n parent: 'scriptInputs',\r\n parentItemId: p.id\r\n });\r\n\r\n // Default Value for input\r\n ports.push({\r\n name: 'in-' + p.label,\r\n displayName: p.label,\r\n plug: 'input',\r\n type: node.parameters['intype-' + p.label] || 'string',\r\n group: 'Inputs'\r\n });\r\n });\r\n }\r\n\r\n _parseScriptForErrorsAndPorts(node.parameters['functionScript'], 'Script ', node, context, ports);\r\n\r\n // Push output ports that are signals directly to the model, it's needed by the initial run of\r\n // the script function\r\n ports.forEach((p) => {\r\n if (p.type === 'signal' && p.plug === 'output') {\r\n node.outputPorts[p.name] = p;\r\n }\r\n });\r\n\r\n context.editorConnection.sendDynamicPorts(node.id, ports);\r\n }\r\n\r\n _updatePorts();\r\n node.on('parameterUpdated', function (ev) {\r\n _updatePorts();\r\n });\r\n }\r\n\r\n graphModel.on('editorImportComplete', () => {\r\n graphModel.on('nodeAdded.JavaScriptFunction', function (node) {\r\n _managePortsForNode(node);\r\n });\r\n\r\n for (const node of graphModel.getNodesWithType('JavaScriptFunction')) {\r\n _managePortsForNode(node);\r\n }\r\n });\r\n }\r\n};\r\n","const StringFormatDefinition = {\n name: 'String Format',\n docs: 'https://docs.noodl.net/nodes/string-manipulation/string-format',\n category: 'String Manipulation',\n usePortAsLabel: 'format',\n portLabelTruncationMode: 'length',\n initialize() {\n const internal = this._internal;\n internal.format = '';\n internal.cachedResult = '';\n internal.resultDirty = false;\n internal.inputValues = {};\n },\n getInspectInfo() {\n return this.formatValue();\n },\n inputs: {\n format: {\n type: { name: 'string', multiline: true },\n displayName: 'Format',\n set(value) {\n if (this._internal.format === value) return;\n\n this._internal.format = value;\n this._internal.resultDirty = true;\n this.scheduleFormat();\n }\n }\n },\n outputs: {\n formatted: {\n type: 'string',\n displayName: 'Formatted',\n get() {\n return this.formatValue();\n }\n }\n },\n methods: {\n formatValue() {\n var internal = this._internal;\n\n if (internal.resultDirty) {\n var formatted = internal.format;\n\n var matches = internal.format.match(/\\{[A-Za-z0-9_]*\\}/g);\n var inputs = [];\n if (matches) {\n inputs = matches.map(function (name) {\n return name.replace('{', '').replace('}', '');\n });\n }\n\n inputs.forEach(function (name) {\n var v = internal.inputValues[name];\n formatted = formatted.replace('{' + name + '}', v !== undefined ? v : '');\n });\n\n internal.cachedResult = formatted;\n internal.resultDirty = false;\n }\n\n return internal.cachedResult;\n },\n registerInputIfNeeded(name) {\n if (this.hasInput(name)) {\n return;\n }\n\n this.registerInput(name, {\n set: userInputSetter.bind(this, name)\n });\n },\n scheduleFormat() {\n if (this.formatScheduled) return;\n\n this.formatScheduled = true;\n this.scheduleAfterInputsHaveUpdated(() => {\n this.formatValue();\n this.flagOutputDirty('formatted');\n this.formatScheduled = false;\n });\n }\n }\n};\n\nfunction userInputSetter(name, value) {\n /* jshint validthis:true */\n if (this._internal.inputValues[name] === value) return;\n\n this._internal.inputValues[name] = value;\n this._internal.resultDirty = true;\n this.scheduleFormat();\n}\n\nfunction updatePorts(id, format, editorConnection) {\n var inputs = format.match(/\\{[A-Za-z0-9_]*\\}/g) || [];\n var portsNames = inputs.map(function (def) {\n return def.replace('{', '').replace('}', '');\n });\n\n var ports = portsNames\n //get unique names\n .filter(function (value, index, self) {\n return self.indexOf(value) === index;\n })\n //and map names to ports\n .map(function (name) {\n return {\n name: name,\n type: 'string',\n plug: 'input'\n };\n });\n\n editorConnection.sendDynamicPorts(id, ports);\n}\n\nmodule.exports = {\n node: StringFormatDefinition,\n setup: function (context, graphModel) {\n if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {\n return;\n }\n\n graphModel.on('nodeAdded.String Format', function (node) {\n if (node.parameters.format) {\n updatePorts(node.id, node.parameters.format, context.editorConnection);\n }\n node.on('parameterUpdated', function (event) {\n if (event.name === 'format') {\n updatePorts(node.id, node.parameters.format, context.editorConnection);\n }\n });\n });\n }\n};\n","const StringMapperNode = {\r\n name: 'String Mapper',\r\n docs: 'https://docs.noodl.net/nodes/string-manipulation/string-mapper',\r\n category: 'Utilities',\r\n initialize: function () {\r\n this._internal.inputs = [];\r\n this._internal.mappings = [];\r\n },\r\n getInspectInfo() {\r\n return this._internal.mappedString;\r\n },\r\n numberedInputs: {\r\n input: {\r\n type: 'string',\r\n displayPrefix: 'Input',\r\n group: 'Inputs',\r\n index: 10,\r\n createSetter(index) {\r\n return function (value) {\r\n value = value === undefined ? '' : value.toString();\r\n this._internal.inputs[index] = value;\r\n this.scheduleMapping();\r\n };\r\n }\r\n },\r\n output: {\r\n type: 'string',\r\n displayPrefix: 'Mapping',\r\n index: 1001,\r\n group: 'Mappings',\r\n createSetter(index) {\r\n return function (value) {\r\n value = value === undefined ? '' : value.toString();\r\n this._internal.mappings[index] = value;\r\n this.scheduleMapping();\r\n };\r\n }\r\n }\r\n },\r\n inputs: {\r\n inputString: {\r\n type: {\r\n name: 'string'\r\n },\r\n index: 1,\r\n displayName: 'Input String',\r\n set: function (value) {\r\n this._internal.currentInputString = value !== undefined ? value.toString() : undefined;\r\n this.scheduleMapping();\r\n }\r\n },\r\n defaultMapping: {\r\n type: 'string',\r\n displayName: 'Default',\r\n index: 1000,\r\n group: 'Mappings',\r\n set: function (value) {\r\n this._internal.defaultMapping = value;\r\n this.scheduleMapping();\r\n }\r\n }\r\n },\r\n outputs: {\r\n mappedString: {\r\n type: 'string',\r\n displayName: 'Mapped String',\r\n group: 'Value',\r\n getter: function () {\r\n return this._internal.mappedString;\r\n }\r\n }\r\n },\r\n prototypeExtensions: {\r\n doMapping: function () {\r\n this._internal.hasScheduledFetch = false;\r\n var idx = this._internal.inputs.indexOf(this._internal.currentInputString);\r\n if (idx !== -1) this._internal.mappedString = this._internal.mappings[idx];\r\n else this._internal.mappedString = this._internal.defaultMapping;\r\n\r\n this.flagOutputDirty('mappedString');\r\n },\r\n scheduleMapping: function () {\r\n var internal = this._internal;\r\n if (!internal.hasScheduledFetch) {\r\n internal.hasScheduledFetch = true;\r\n this.scheduleAfterInputsHaveUpdated(this.doMapping.bind(this));\r\n }\r\n }\r\n }\r\n};\r\n\r\nmodule.exports = {\r\n node: StringMapperNode\r\n};\r\n","'use strict';\r\n\r\nconst SubStringNode = {\r\n name: 'Substring',\r\n docs: 'https://docs.noodl.net/nodes/string-manipulation/substring',\r\n category: 'String Manipulation',\r\n initialize: function () {\r\n var internal = this._internal;\r\n internal.startIndex = 0;\r\n internal.endIndex = -1;\r\n internal.cachedResult = '';\r\n internal.inputString = '';\r\n internal.resultDirty = false;\r\n },\r\n inputs: {\r\n start: {\r\n type: 'number',\r\n displayName: 'Start',\r\n default: 0,\r\n set: function (value) {\r\n this._internal.startIndex = value;\r\n this._internal.resultDirty = true;\r\n this.flagOutputDirty('result');\r\n }\r\n },\r\n end: {\r\n type: 'number',\r\n displayName: 'End',\r\n default: 0,\r\n set: function (value) {\r\n this._internal.endIndex = value;\r\n this._internal.resultDirty = true;\r\n this.flagOutputDirty('result');\r\n }\r\n },\r\n string: {\r\n type: {\r\n name: 'string'\r\n },\r\n displayName: 'String',\r\n default: '',\r\n set: function (value) {\r\n value = value.toString();\r\n this._internal.inputString = value;\r\n this._internal.resultDirty = true;\r\n this.flagOutputDirty('result');\r\n }\r\n }\r\n },\r\n outputs: {\r\n result: {\r\n type: 'string',\r\n displayName: 'Result',\r\n getter: function () {\r\n var internal = this._internal;\r\n\r\n if (internal.resultDirty) {\r\n if (internal.endIndex === -1) {\r\n internal.cachedResult = internal.inputString.substr(internal.startIndex);\r\n } else {\r\n internal.cachedResult = internal.inputString.substr(\r\n internal.startIndex,\r\n internal.endIndex - internal.startIndex\r\n );\r\n }\r\n internal.resultDirty = false;\r\n }\r\n return internal.cachedResult;\r\n }\r\n }\r\n }\r\n};\r\n\r\nmodule.exports = {\r\n node: SubStringNode\r\n};\r\n","'use strict';\r\n\r\nconst Model = require('../../model');\r\n\r\nconst UniqueIdNode = {\r\n name: 'Unique Id',\r\n docs: 'https://docs.noodl.net/nodes/utilities/unique-id',\r\n category: 'String Manipulation',\r\n initialize: function () {\r\n var internal = this._internal;\r\n internal.guid = Model.guid();\r\n },\r\n getInspectInfo() {\r\n return this._internal.guid;\r\n },\r\n inputs: {\r\n new: {\r\n displayName: 'New',\r\n valueChangedToTrue: function () {\r\n var internal = this._internal;\r\n internal.guid = Model.guid();\r\n this.flagOutputDirty('guid');\r\n }\r\n }\r\n },\r\n outputs: {\r\n guid: {\r\n type: 'string',\r\n displayName: 'Id',\r\n getter: function () {\r\n var internal = this._internal;\r\n return internal.guid;\r\n }\r\n }\r\n },\r\n prototypeExtensions: {}\r\n};\r\n\r\nmodule.exports = {\r\n node: UniqueIdNode\r\n};\r\n","'use strict';\r\n\r\nconst NoodlRuntime = require('../../../../noodl-runtime');\r\n\r\nvar SetUserPropertiesNodeDefinition = {\r\n name: 'net.noodl.user.SetUserProperties',\r\n docs: 'https://docs.noodl.net/nodes/data/user/set-user-properties',\r\n displayNodeName: 'Set User Properties',\r\n category: 'Cloud Services',\r\n color: 'data',\r\n initialize: function () {\r\n var internal = this._internal;\r\n\r\n internal.userProperties = {};\r\n },\r\n getInspectInfo() {},\r\n outputs: {\r\n success: {\r\n type: 'signal',\r\n displayName: 'Success',\r\n group: 'Events'\r\n },\r\n failure: {\r\n type: 'signal',\r\n displayName: 'Failure',\r\n group: 'Events'\r\n },\r\n error: {\r\n type: 'string',\r\n displayName: 'Error',\r\n group: 'Error',\r\n getter: function () {\r\n return this._internal.error;\r\n }\r\n }\r\n },\r\n inputs: {\r\n store: {\r\n displayName: 'Do',\r\n group: 'Actions',\r\n valueChangedToTrue: function () {\r\n this.scheduleStore();\r\n }\r\n },\r\n email: {\r\n displayName: 'Email',\r\n type: 'string',\r\n group: 'General',\r\n set: function (value) {\r\n this._internal.email = value;\r\n }\r\n },\r\n username: {\r\n displayName: 'Username',\r\n type: 'string',\r\n group: 'General',\r\n set: function (value) {\r\n this._internal.username = value;\r\n }\r\n }\r\n },\r\n methods: {\r\n setError: function (err) {\r\n this._internal.error = err;\r\n this.flagOutputDirty('error');\r\n this.sendSignalOnOutput('failure');\r\n\r\n if (this.context.editorConnection) {\r\n this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name, this.id, 'user-set-warning', {\r\n message: err,\r\n showGlobally: true\r\n });\r\n }\r\n },\r\n clearWarnings() {\r\n if (this.context.editorConnection) {\r\n this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'user-set-warning');\r\n }\r\n },\r\n scheduleStore: function () {\r\n const internal = this._internal;\r\n\r\n if (this.storeScheduled === true) return;\r\n this.storeScheduled = true;\r\n\r\n this.scheduleAfterInputsHaveUpdated(() => {\r\n this.storeScheduled = false;\r\n\r\n const UserService = NoodlRuntime.Services.UserService;\r\n UserService.forScope(this.nodeScope.modelScope).setUserProperties({\r\n email: this._internal.email,\r\n username: this._internal.username,\r\n properties: internal.userProperties,\r\n success: () => {\r\n this.sendSignalOnOutput('success');\r\n },\r\n error: (e) => {\r\n this.setError(e);\r\n }\r\n });\r\n });\r\n },\r\n setUserProperty: function (name, value) {\r\n this._internal.userProperties[name] = value;\r\n },\r\n registerInputIfNeeded: function (name) {\r\n if (this.hasInput(name)) {\r\n return;\r\n }\r\n\r\n if (name.startsWith('prop-'))\r\n return this.registerInput(name, {\r\n set: this.setUserProperty.bind(this, name.substring('prop-'.length))\r\n });\r\n }\r\n }\r\n};\r\n\r\nfunction updatePorts(nodeId, parameters, editorConnection, systemCollections) {\r\n var ports = [];\r\n\r\n if (systemCollections) {\r\n // Fetch ports from collection keys\r\n var c = systemCollections.find((c) => c.name === '_User');\r\n if (c && c.schema && c.schema.properties) {\r\n var props = c.schema.properties;\r\n\r\n const _ignoreKeys =\r\n typeof _noodl_cloud_runtime_version === 'undefined'\r\n ? ['authData', 'createdAt', 'updatedAt', 'email', 'username', 'emailVerified', 'password']\r\n : ['authData', 'createdAt', 'updatedAt', 'email', 'username'];\r\n\r\n for (var key in props) {\r\n if (_ignoreKeys.indexOf(key) !== -1) continue;\r\n\r\n var p = props[key];\r\n if (ports.find((_p) => _p.name === key)) continue;\r\n\r\n if (p.type === 'Relation') {\r\n } else {\r\n // Other schema type ports\r\n const _typeMap = {\r\n String: 'string',\r\n Boolean: 'boolean',\r\n Number: 'number',\r\n Date: 'date'\r\n };\r\n\r\n ports.push({\r\n type: {\r\n name: _typeMap[p.type] ? _typeMap[p.type] : '*'\r\n },\r\n plug: 'input',\r\n group: 'Properties',\r\n name: 'prop-' + key,\r\n displayName: key\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n editorConnection.sendDynamicPorts(nodeId, ports);\r\n}\r\n\r\nmodule.exports = {\r\n node: SetUserPropertiesNodeDefinition,\r\n setup: function (context, graphModel) {\r\n if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {\r\n return;\r\n }\r\n\r\n function _managePortsForNode(node) {\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel.getMetaData('systemCollections'));\r\n\r\n node.on('parameterUpdated', function (event) {\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel.getMetaData('systemCollections'));\r\n });\r\n\r\n graphModel.on('metadataChanged.systemCollections', function (data) {\r\n updatePorts(node.id, node.parameters, context.editorConnection, data);\r\n });\r\n }\r\n\r\n graphModel.on('editorImportComplete', () => {\r\n graphModel.on('nodeAdded.net.noodl.user.SetUserProperties', function (node) {\r\n _managePortsForNode(node);\r\n });\r\n\r\n for (const node of graphModel.getNodesWithType('net.noodl.user.SetUserProperties')) {\r\n _managePortsForNode(node);\r\n }\r\n });\r\n }\r\n};\r\n","'use strict';\r\n\r\nconst NoodlRuntime = require('../../../../noodl-runtime');\r\nconst { Node } = require('../../../../noodl-runtime');\r\n\r\nvar UserNodeDefinition = {\r\n name: 'net.noodl.user.User',\r\n docs: 'https://docs.noodl.net/nodes/data/user/user-node',\r\n displayNodeName: 'User',\r\n category: 'Cloud Services',\r\n color: 'data',\r\n initialize: function () {\r\n var _this = this;\r\n this._internal.onModelChangedCallback = function (args) {\r\n if (_this.isInputConnected('fetch')) return;\r\n\r\n if (_this.hasOutput('prop-' + args.name)) _this.flagOutputDirty('prop-' + args.name);\r\n\r\n if (_this.hasOutput('changed-' + args.name)) _this.sendSignalOnOutput('changed-' + args.name);\r\n\r\n _this.sendSignalOnOutput('changed');\r\n };\r\n\r\n const userService = NoodlRuntime.Services.UserService.forScope(this.nodeScope.modelScope);\r\n\r\n this.setUserModel(userService.current);\r\n userService.on('loggedIn', () => {\r\n this.setUserModel(userService.current);\r\n\r\n if (this.hasOutput('loggedIn')) this.sendSignalOnOutput('loggedIn');\r\n });\r\n\r\n userService.on('sessionGained', () => {\r\n this.setUserModel(userService.current);\r\n });\r\n\r\n userService.on('loggedOut', () => {\r\n this.setUserModel(undefined);\r\n if (this.hasOutput('loggedOut')) this.sendSignalOnOutput('loggedOut');\r\n });\r\n\r\n userService.on('sessionLost', () => {\r\n this.setUserModel(undefined);\r\n if (this.hasOutput('sessionLost')) this.sendSignalOnOutput('sessionLost');\r\n });\r\n },\r\n getInspectInfo() {\r\n const model = this._internal.model;\r\n if (!model) return '[No Model]';\r\n\r\n return [\r\n { type: 'text', value: 'Id: ' + model.getId() },\r\n { type: 'value', value: this._internal.model.data }\r\n ];\r\n },\r\n outputs: {\r\n id: {\r\n type: 'string',\r\n displayName: 'Id',\r\n group: 'General',\r\n getter: function () {\r\n return this._internal.model !== undefined ? this._internal.model.getId() : undefined;\r\n }\r\n },\r\n fetched: {\r\n type: 'signal',\r\n displayName: 'Fetched',\r\n group: 'Events'\r\n },\r\n changed: {\r\n type: 'signal',\r\n displayName: 'Changed',\r\n group: 'Events'\r\n },\r\n failure: {\r\n type: 'signal',\r\n displayName: 'Failure',\r\n group: 'Events'\r\n },\r\n error: {\r\n type: 'string',\r\n displayName: 'Error',\r\n group: 'Error',\r\n getter: function () {\r\n return this._internal.error;\r\n }\r\n },\r\n username: {\r\n type: 'string',\r\n displayName: 'Username',\r\n group: 'General',\r\n getter: function () {\r\n return this._internal.model !== undefined ? this._internal.model.get('username') : undefined;\r\n }\r\n },\r\n email: {\r\n type: 'string',\r\n displayName: 'Email',\r\n group: 'General',\r\n getter: function () {\r\n return this._internal.model !== undefined ? this._internal.model.get('email') : undefined;\r\n }\r\n },\r\n authenticated: {\r\n type: 'boolean',\r\n displayName: 'Authenticated',\r\n group: 'General',\r\n getter: function () {\r\n return this._internal.model !== undefined;\r\n }\r\n }\r\n /* loggedIn:{\r\n type:'signal',\r\n displayName:'Logged In',\r\n group:'Events'\r\n },\r\n loggedOut:{\r\n type:'signal',\r\n displayName:'Logged Out',\r\n group:'Events'\r\n },\r\n sessionLost:{\r\n type:'signal',\r\n displayName:'Session Lost',\r\n group:'Events'\r\n }, */\r\n },\r\n inputs: {\r\n fetch: {\r\n displayName: 'Fetch',\r\n group: 'Actions',\r\n valueChangedToTrue: function () {\r\n this.scheduleFetch();\r\n }\r\n }\r\n },\r\n methods: {\r\n _onNodeDeleted: function () {\r\n Node.prototype._onNodeDeleted.call(this);\r\n if (this._internal.model) this._internal.model.off('change', this._internal.onModelChangedCallback);\r\n },\r\n scheduleOnce: function (type, cb) {\r\n const _this = this;\r\n const _type = 'hasScheduled' + type;\r\n if (this._internal[_type]) return;\r\n this._internal[_type] = true;\r\n this.scheduleAfterInputsHaveUpdated(function () {\r\n _this._internal[_type] = false;\r\n cb();\r\n });\r\n },\r\n setError: function (err) {\r\n this._internal.error = err;\r\n this.flagOutputDirty('error');\r\n this.sendSignalOnOutput('failure');\r\n\r\n if (this.context.editorConnection) {\r\n this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name, this.id, 'user-warning', {\r\n message: err,\r\n showGlobally: true\r\n });\r\n }\r\n },\r\n clearWarnings() {\r\n if (this.context.editorConnection) {\r\n this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'user-warning');\r\n }\r\n },\r\n setUserModel(model) {\r\n const internal = this._internal;\r\n\r\n if (internal.model !== model) {\r\n // Check if we need to change model\r\n if (internal.model)\r\n // Remove old listener if existing\r\n internal.model.off('change', internal.onModelChangedCallback);\r\n\r\n internal.model = model;\r\n if (model) model.on('change', internal.onModelChangedCallback);\r\n }\r\n this.flagOutputDirty('id');\r\n this.flagOutputDirty('authenticated');\r\n this.flagOutputDirty('email');\r\n this.flagOutputDirty('username');\r\n\r\n // Notify all properties changed\r\n if (model)\r\n for (var key in model.data) {\r\n if (this.hasOutput('prop-' + key)) this.flagOutputDirty('prop-' + key);\r\n }\r\n },\r\n scheduleFetch: function () {\r\n const internal = this._internal;\r\n\r\n this.scheduleOnce('Fetch', () => {\r\n const userService = NoodlRuntime.Services.UserService.forScope(this.nodeScope.modelScope);\r\n userService.fetchCurrentUser({\r\n success: (response) => {\r\n this.setUserModel(userService.current);\r\n\r\n this.sendSignalOnOutput('fetched');\r\n },\r\n error: (err) => {\r\n this.setError(err || 'Failed to fetch.');\r\n }\r\n });\r\n });\r\n },\r\n registerOutputIfNeeded: function (name) {\r\n if (this.hasOutput(name)) {\r\n return;\r\n }\r\n\r\n if (name === 'loggedOut' || name === 'loggedIn' || name === 'sessionLost') {\r\n this.registerOutput(name, {\r\n getter: () => {} /* No getter needed, signal */\r\n });\r\n return;\r\n }\r\n\r\n if (name.startsWith('prop-'))\r\n this.registerOutput(name, {\r\n getter: this.getUserProperty.bind(this, name.substring('prop-'.length))\r\n });\r\n },\r\n getUserProperty: function (name) {\r\n return this._internal.model !== undefined ? this._internal.model.get(name) : undefined;\r\n }\r\n }\r\n};\r\n\r\nfunction updatePorts(nodeId, parameters, editorConnection, systemCollections) {\r\n var ports = [];\r\n\r\n if (systemCollections) {\r\n // Fetch ports from collection keys\r\n var c = systemCollections.find((c) => c.name === '_User');\r\n if (c && c.schema && c.schema.properties) {\r\n var props = c.schema.properties;\r\n const _ignoreKeys = ['authData', 'password', 'username', 'email'];\r\n for (var key in props) {\r\n if (_ignoreKeys.indexOf(key) !== -1) continue;\r\n\r\n var p = props[key];\r\n if (ports.find((_p) => _p.name === key)) continue;\r\n\r\n if (p.type === 'Relation') {\r\n } else {\r\n // Other schema type ports\r\n const _typeMap = {\r\n String: 'string',\r\n Boolean: 'boolean',\r\n Number: 'number',\r\n Date: 'date'\r\n };\r\n\r\n ports.push({\r\n type: {\r\n name: _typeMap[p.type] ? _typeMap[p.type] : '*'\r\n },\r\n plug: 'output',\r\n group: 'Properties',\r\n name: 'prop-' + key,\r\n displayName: key\r\n });\r\n\r\n ports.push({\r\n type: 'signal',\r\n plug: 'output',\r\n group: 'Changed Events',\r\n displayName: key + ' Changed',\r\n name: 'changed-' + key\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (typeof _noodl_cloud_runtime_version === 'undefined') {\r\n // On the client we have some extra outputs\r\n ports.push({\r\n plug: 'output',\r\n name: 'loggedIn',\r\n type: 'signal',\r\n displayName: 'Logged In',\r\n group: 'Events'\r\n });\r\n\r\n ports.push({\r\n plug: 'output',\r\n name: 'loggedOut',\r\n type: 'signal',\r\n displayName: 'Logged Out',\r\n group: 'Events'\r\n });\r\n\r\n ports.push({\r\n plug: 'output',\r\n name: 'sessionLost',\r\n type: 'signal',\r\n displayName: 'Session Lost',\r\n group: 'Events'\r\n });\r\n }\r\n\r\n editorConnection.sendDynamicPorts(nodeId, ports);\r\n}\r\n\r\nmodule.exports = {\r\n node: UserNodeDefinition,\r\n setup: function (context, graphModel) {\r\n if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {\r\n return;\r\n }\r\n\r\n function _managePortsForNode(node) {\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel.getMetaData('systemCollections'));\r\n\r\n node.on('parameterUpdated', function (event) {\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel.getMetaData('systemCollections'));\r\n });\r\n\r\n graphModel.on('metadataChanged.systemCollections', function (data) {\r\n updatePorts(node.id, node.parameters, context.editorConnection, data);\r\n });\r\n }\r\n\r\n graphModel.on('editorImportComplete', () => {\r\n graphModel.on('nodeAdded.net.noodl.user.User', function (node) {\r\n _managePortsForNode(node);\r\n });\r\n\r\n for (const node of graphModel.getNodesWithType('net.noodl.user.User')) {\r\n _managePortsForNode(node);\r\n }\r\n });\r\n }\r\n};\r\n","'use strict';\r\n\r\nconst VariableBase = require('./variablebase');\r\n\r\nconst BooleanNode = VariableBase.createDefinition({\r\n name: 'Boolean',\r\n docs: 'https://docs.noodl.net/nodes/data/boolean',\r\n startValue: false,\r\n type: {\r\n name: 'boolean'\r\n },\r\n cast: function (value) {\r\n return Boolean(value);\r\n }\r\n});\r\n\r\nmodule.exports = {\r\n node: BooleanNode\r\n};\r\n","'use strict';\r\n\r\nconst VariableBase = require('./variablebase');\r\n\r\nconst NumberNode = VariableBase.createDefinition({\r\n name: 'Number',\r\n docs: 'https://docs.noodl.net/nodes/data/number',\r\n startValue: 0,\r\n nodeDoubleClickAction: {\r\n focusPort: 'value'\r\n },\r\n type: {\r\n name: 'number'\r\n },\r\n cast: function (value) {\r\n return Number(value);\r\n }\r\n});\r\n\r\nmodule.exports = {\r\n node: NumberNode\r\n};\r\n","'use strict';\r\n\r\nconst VariableBase = require('./variablebase');\r\nconst { NodeDefinition } = require('../../../../noodl-runtime');\r\n\r\nconst StringNode = VariableBase.createDefinition({\r\n name: 'String',\r\n docs: 'https://docs.noodl.net/nodes/data/string',\r\n shortDesc: 'Contains a string (text).',\r\n startValue: '',\r\n nodeDoubleClickAction: {\r\n focusPort: 'value'\r\n },\r\n type: {\r\n name: 'string'\r\n },\r\n cast: function (value) {\r\n return String(value);\r\n },\r\n onChanged: function () {\r\n this.flagOutputDirty('length');\r\n }\r\n});\r\n\r\nNodeDefinition.extend(StringNode, {\r\n usePortAsLabel: 'value',\r\n portLabelTruncationMode: 'length',\r\n outputs: {\r\n length: {\r\n type: 'number',\r\n displayName: 'Length',\r\n getter: function () {\r\n return this._internal.currentValue.length;\r\n }\r\n }\r\n }\r\n});\r\n\r\nmodule.exports = {\r\n node: StringNode\r\n};\r\n","'use strict';\r\n\r\nfunction createDefinition(args) {\r\n return {\r\n name: args.name,\r\n docs: args.docs,\r\n shortDesc: args.shortDesc,\r\n nodeDoubleClickAction: args.nodeDoubleClickAction,\r\n category: 'Variables',\r\n initialize: function () {\r\n this._internal.currentValue = args.startValue;\r\n this._internal.latestValue = 0;\r\n },\r\n getInspectInfo() {\r\n const type = args.type.name === 'color' ? 'color' : 'text';\r\n return [{ type, value: this._internal.currentValue }];\r\n },\r\n inputs: {\r\n value: {\r\n type: args.type,\r\n displayName: 'Value',\r\n default: args.startValue,\r\n set: function (value) {\r\n if (this.isInputConnected('saveValue') === false) {\r\n this.setValueTo(value);\r\n } else {\r\n this._internal.latestValue = value;\r\n }\r\n }\r\n },\r\n saveValue: {\r\n displayName: 'Set',\r\n valueChangedToTrue: function () {\r\n this.scheduleAfterInputsHaveUpdated(function () {\r\n this.setValueTo(this._internal.latestValue);\r\n this.sendSignalOnOutput('stored');\r\n });\r\n }\r\n }\r\n },\r\n outputs: {\r\n savedValue: {\r\n type: args.type.name,\r\n displayName: 'Value',\r\n getter: function () {\r\n return this._internal.currentValue;\r\n }\r\n },\r\n changed: {\r\n type: 'signal',\r\n displayName: 'Changed'\r\n },\r\n stored: {\r\n type: 'signal',\r\n displayName: 'Stored'\r\n }\r\n },\r\n prototypeExtensions: {\r\n setValueTo: function (value) {\r\n value = args.cast(value);\r\n const changed = this._internal.currentValue !== value;\r\n this._internal.currentValue = value;\r\n\r\n if (changed) {\r\n this.flagOutputDirty('savedValue');\r\n this.sendSignalOnOutput('changed');\r\n args.onChanged && args.onChanged.call(this);\r\n }\r\n }\r\n }\r\n };\r\n}\r\n\r\nmodule.exports = {\r\n createDefinition: createDefinition\r\n};\r\n","'use strict';\r\n\r\nconst guid = require('./guid');\r\n\r\nfunction NodeScope(context, componentOwner) {\r\n this.context = context;\r\n this.nodes = {};\r\n this.componentOwner = componentOwner; //Component Instance that owns this NodeScope\r\n this.componentInstanceChildren = {};\r\n}\r\n\r\nfunction verifyData(data, requiredKeys) {\r\n requiredKeys.forEach(function (key) {\r\n if (!data[key]) {\r\n throw new Error('Missing ' + key);\r\n }\r\n });\r\n}\r\n\r\nNodeScope.prototype.addConnection = function (connectionData) {\r\n try {\r\n verifyData(connectionData, ['sourceId', 'sourcePort', 'targetId', 'targetPort']);\r\n } catch (e) {\r\n throw new Error('Error in connection: ' + e.message);\r\n }\r\n\r\n try {\r\n var sourceNode = this.getNodeWithId(connectionData.sourceId),\r\n targetNode = this.getNodeWithId(connectionData.targetId);\r\n\r\n targetNode.registerInputIfNeeded(connectionData.targetPort);\r\n sourceNode.registerOutputIfNeeded(connectionData.sourcePort);\r\n targetNode.connectInput(connectionData.targetPort, sourceNode, connectionData.sourcePort);\r\n } catch (e) {\r\n console.error(e.message);\r\n }\r\n};\r\n\r\nNodeScope.prototype.setNodeParameters = function (node, nodeModel) {\r\n const variant = this.context.variants.getVariant(nodeModel.type, nodeModel.variant);\r\n\r\n if (variant) {\r\n //apply the variant (this will also apply the parameters)\r\n node.setVariant(variant);\r\n } else {\r\n const parameters = nodeModel.parameters;\r\n\r\n var inputNames = Object.keys(parameters);\r\n\r\n if (this.context.nodeRegister.hasNode(node.name)) {\r\n var metadata = this.context.nodeRegister.getNodeMetadata(node.name);\r\n inputNames.sort(function (a, b) {\r\n var inputA = metadata.inputs[a];\r\n var inputB = metadata.inputs[b];\r\n return (inputB ? inputB.inputPriority : 0) - (inputA ? inputA.inputPriority : 0);\r\n });\r\n }\r\n\r\n inputNames.forEach((inputName) => {\r\n node.registerInputIfNeeded(inputName);\r\n\r\n //protect against obsolete parameters\r\n if (node.hasInput(inputName) === false) {\r\n return;\r\n }\r\n\r\n node.queueInput(inputName, parameters[inputName]);\r\n });\r\n }\r\n};\r\n\r\nNodeScope.prototype.createNodeFromModel = async function (nodeModel, updateOnDirtyFlagging) {\r\n if (nodeModel.type === 'Component Children') {\r\n if (nodeModel.parent) {\r\n var parentInstance = this.getNodeWithId(nodeModel.parent.id);\r\n this.componentOwner.setChildRoot(parentInstance);\r\n }\r\n return;\r\n }\r\n\r\n var node;\r\n try {\r\n node = await this.createNode(nodeModel.type, nodeModel.id);\r\n node.updateOnDirtyFlagging = updateOnDirtyFlagging === false ? false : true;\r\n node.setNodeModel(nodeModel);\r\n } catch (e) {\r\n console.error(e.message);\r\n if (this.context.editorConnection && this.context.isWarningTypeEnabled('nodescope')) {\r\n this.context.editorConnection.sendWarning(this.componentOwner.name, nodeModel.id, 'nodelibrary-unknown-node', {\r\n message: e.message,\r\n showGlobally: true\r\n });\r\n }\r\n return;\r\n }\r\n\r\n if (nodeModel.variant && node.setVariant) node.setVariant(nodeModel.variant);\r\n this.setNodeParameters(node, nodeModel);\r\n\r\n if (nodeModel.parent) {\r\n this.insertNodeInTree(node, nodeModel);\r\n }\r\n\r\n return node;\r\n};\r\n\r\nNodeScope.prototype.insertNodeInTree = function (nodeInstance, nodeModel) {\r\n var parentInstance = this.getNodeWithId(nodeModel.parent.id);\r\n var childIndex = nodeModel.parent.children.indexOf(nodeModel);\r\n\r\n if (!parentInstance.addChild) {\r\n throw new Error(\r\n 'Node ' + parentInstance.id + ' of type ' + parentInstance.constructor.name + \" can't have children\"\r\n );\r\n }\r\n\r\n parentInstance.addChild(nodeInstance, childIndex);\r\n};\r\n\r\nNodeScope.prototype.getNodeWithId = function (id) {\r\n if (this.nodes.hasOwnProperty(id) === false) {\r\n throw new Error('Unknown node id ' + id);\r\n }\r\n return this.nodes[id];\r\n};\r\n\r\nNodeScope.prototype.hasNodeWithId = function (id) {\r\n return this.nodes.hasOwnProperty(id);\r\n};\r\n\r\nNodeScope.prototype.createPrimitiveNode = function (name, id, extraProps) {\r\n if (!id) id = guid();\r\n\r\n if (this.nodes.hasOwnProperty(id)) {\r\n throw Error('duplicate id ' + id);\r\n }\r\n\r\n const node = this.context.nodeRegister.createNode(name, id, this);\r\n if (extraProps) {\r\n for (const prop in extraProps) {\r\n node[prop] = extraProps[prop];\r\n }\r\n }\r\n\r\n this.nodes[id] = node;\r\n return node;\r\n};\r\n\r\nNodeScope.prototype.createNode = async function (name, id, extraProps) {\r\n if (!id) id = guid();\r\n\r\n if (this.nodes.hasOwnProperty(id)) {\r\n throw Error('duplicate id ' + id);\r\n }\r\n\r\n let node;\r\n\r\n if (this.context.nodeRegister.hasNode(name)) {\r\n node = this.context.nodeRegister.createNode(name, id, this);\r\n if (extraProps) {\r\n for (const prop in extraProps) {\r\n node[prop] = extraProps[prop];\r\n }\r\n }\r\n } else {\r\n node = await this.context.createComponentInstanceNode(name, id, this, extraProps);\r\n this.componentInstanceChildren[id] = node;\r\n }\r\n\r\n this.nodes[id] = node;\r\n return node;\r\n};\r\n\r\nNodeScope.prototype.getNodesWithIdRecursive = function (id) {\r\n var ComponentInstanceNode = require('./nodes/componentinstance');\r\n\r\n function findNodesWithIdRec(scope, id, result) {\r\n if (scope.nodes.hasOwnProperty(id)) {\r\n result.push(scope.nodes[id]);\r\n }\r\n\r\n var componentIds = Object.keys(scope.nodes).filter(function (nodeId) {\r\n return scope.nodes[nodeId] instanceof ComponentInstanceNode;\r\n });\r\n\r\n componentIds.forEach(function (componentId) {\r\n findNodesWithIdRec(scope.nodes[componentId].nodeScope, id, result);\r\n });\r\n }\r\n\r\n var result = [];\r\n findNodesWithIdRec(this, id, result);\r\n return result;\r\n};\r\n\r\nNodeScope.prototype.getNodesWithType = function (name) {\r\n var self = this;\r\n var ids = Object.keys(this.nodes).filter(function (id) {\r\n return self.nodes[id].name === name;\r\n });\r\n return ids.map(function (id) {\r\n return self.nodes[id];\r\n });\r\n};\r\n\r\nNodeScope.prototype.getNodesWithTypeRecursive = function (name) {\r\n var ComponentInstanceNode = require('./nodes/componentinstance');\r\n\r\n var self = this;\r\n function findNodesWithTypeRec() {\r\n result = result.concat(self.getNodesWithType(name));\r\n\r\n var componentIds = Object.keys(self.nodes).filter(function (nodeId) {\r\n return self.nodes[nodeId] instanceof ComponentInstanceNode;\r\n });\r\n\r\n componentIds.forEach(function (componentId) {\r\n var res = self.nodes[componentId].nodeScope.getNodesWithTypeRecursive(name);\r\n result = result.concat(res);\r\n });\r\n }\r\n\r\n var result = [];\r\n findNodesWithTypeRec(result);\r\n return result;\r\n};\r\n\r\nNodeScope.prototype.getAllNodesRecursive = function () {\r\n var ComponentInstanceNode = require('./nodes/componentinstance');\r\n\r\n let result = [];\r\n\r\n const getAllNodesRec = () => {\r\n result = result.concat(Object.values(this.nodes));\r\n\r\n var componentIds = Object.keys(this.nodes).filter((nodeId) => {\r\n return this.nodes[nodeId] instanceof ComponentInstanceNode;\r\n });\r\n\r\n componentIds.forEach((componentId) => {\r\n var res = this.nodes[componentId].nodeScope.getAllNodesRecursive();\r\n result = result.concat(res);\r\n });\r\n };\r\n\r\n getAllNodesRec(result);\r\n return result;\r\n};\r\n\r\nNodeScope.prototype.getAllNodesWithVariantRecursive = function (variant) {\r\n const nodes = this.getAllNodesRecursive();\r\n return nodes.filter((node) => node.variant === variant);\r\n};\r\n\r\nNodeScope.prototype.onNodeModelRemoved = function (nodeModel) {\r\n var nodeInstance = this.getNodeWithId(nodeModel.id);\r\n\r\n if (nodeModel.parent) {\r\n var parentInstance = this.getNodeWithId(nodeModel.parent.id);\r\n parentInstance.removeChild(nodeInstance);\r\n }\r\n\r\n nodeInstance._onNodeDeleted();\r\n delete this.nodes[nodeInstance.id];\r\n delete this.componentInstanceChildren[nodeInstance.id];\r\n};\r\n\r\nNodeScope.prototype.removeConnection = function (connectionModel) {\r\n var targetNode = this.getNodeWithId(connectionModel.targetId);\r\n targetNode.removeInputConnection(connectionModel.targetPort, connectionModel.sourceId, connectionModel.sourcePort);\r\n};\r\n\r\nNodeScope.prototype.setComponentModel = async function (componentModel) {\r\n this.componentModel = componentModel;\r\n\r\n const nodes = [];\r\n\r\n //create all nodes\r\n for (const nodeModel of componentModel.getAllNodes()) {\r\n const node = await this.createNodeFromModel(nodeModel, false);\r\n if (node) nodes.push(node);\r\n }\r\n\r\n componentModel.getAllConnections().forEach((conn) => this.addConnection(conn));\r\n\r\n //now that all nodes and connections are setup, trigger the dirty flagging so nodes can run with all the connections in place\r\n nodes.forEach((node) => (node.updateOnDirtyFlagging = true));\r\n\r\n nodes.forEach((node) => {\r\n if (node._dirty) {\r\n node._performDirtyUpdate();\r\n }\r\n });\r\n\r\n componentModel.on('connectionAdded', (conn) => this.addConnection(conn), this);\r\n componentModel.on('connectionRemoved', this.removeConnection, this);\r\n componentModel.on('nodeAdded', this.createNodeFromModel, this);\r\n\r\n var self = this;\r\n componentModel.on(\r\n 'nodeParentWillBeRemoved',\r\n function (nodeModel) {\r\n if (nodeModel.type === 'Component Children') {\r\n if (nodeModel.parent) {\r\n this.componentOwner.setChildRoot(null);\r\n }\r\n return;\r\n }\r\n\r\n const nodeInstance = self.getNodeWithId(nodeModel.id);\r\n if (nodeInstance.parent) {\r\n nodeInstance.parent.removeChild(nodeInstance);\r\n }\r\n },\r\n this\r\n );\r\n\r\n componentModel.on(\r\n 'nodeParentUpdated',\r\n function (nodeModel) {\r\n if (nodeModel.type === 'Component Children') {\r\n var parentInstance = this.getNodeWithId(nodeModel.parent.id);\r\n this.componentOwner.setChildRoot(parentInstance);\r\n } else {\r\n var nodeInstance = self.getNodeWithId(nodeModel.id);\r\n self.insertNodeInTree(nodeInstance, nodeModel);\r\n }\r\n },\r\n this\r\n );\r\n\r\n componentModel.on(\r\n 'nodeRemoved',\r\n function (nodeModel) {\r\n if (nodeModel.type !== 'Component Children') {\r\n self.onNodeModelRemoved(nodeModel);\r\n }\r\n },\r\n this\r\n );\r\n\r\n for (const id in this.nodes) {\r\n const node = this.nodes[id];\r\n node.nodeScopeDidInitialize && node.nodeScopeDidInitialize();\r\n }\r\n};\r\n\r\nNodeScope.prototype.reset = function () {\r\n if (this.componentModel) {\r\n this.componentModel.removeListenersWithRef(this);\r\n this.componentModel = undefined;\r\n }\r\n\r\n Object.keys(this.nodes).forEach((id) => {\r\n if (this.nodes.hasOwnProperty(id)) {\r\n this.deleteNode(this.nodes[id]);\r\n }\r\n });\r\n};\r\n\r\nNodeScope.prototype.deleteNode = function (nodeInstance) {\r\n if (this.nodes.hasOwnProperty(nodeInstance.id) === false) {\r\n console.error(\"Node doesn't belong to this scope\", nodeInstance.id, nodeInstance.name);\r\n return;\r\n }\r\n\r\n if (nodeInstance.parent) {\r\n nodeInstance.parent.removeChild(nodeInstance);\r\n }\r\n\r\n //depth first\r\n if (nodeInstance.getChildren) {\r\n nodeInstance.getChildren().forEach((child) => {\r\n nodeInstance.removeChild(child);\r\n //the child might be created in a different scope\r\n //if the child is a component instance, we want its parent scope, not the inner scope\r\n const nodeScope = child.parentNodeScope || child.nodeScope;\r\n nodeScope.deleteNode(child);\r\n });\r\n }\r\n\r\n if (this.componentModel) {\r\n const connectionFrom = this.componentModel.getConnectionsFrom(nodeInstance.id);\r\n const connectionTo = this.componentModel.getConnectionsTo(nodeInstance.id);\r\n\r\n connectionFrom.concat(connectionTo).forEach((connection) => {\r\n if (this.nodes.hasOwnProperty(connection.targetId) && this.nodes.hasOwnProperty(connection.sourceId)) {\r\n this.removeConnection(connection);\r\n }\r\n });\r\n }\r\n\r\n nodeInstance._onNodeDeleted();\r\n delete this.nodes[nodeInstance.id];\r\n delete this.componentInstanceChildren[nodeInstance.id]; //in case this is a component\r\n};\r\n\r\nNodeScope.prototype.sendEventFromThisScope = function (eventName, data, propagation, sendEventInThisScope, _exclude) {\r\n if (sendEventInThisScope) {\r\n var eventReceivers = this.getNodesWithType('Event Receiver').filter(function (eventReceiver) {\r\n return eventReceiver.getChannelName() === eventName;\r\n });\r\n\r\n for (var i = 0; i < eventReceivers.length; i++) {\r\n var consumed = eventReceivers[i].handleEvent(data);\r\n if (consumed) return true;\r\n }\r\n }\r\n\r\n if (propagation === 'parent' && this.componentOwner.parentNodeScope) {\r\n // Send event to parent scope\r\n //either the scope of the visual parent if there is one, otherwise the parent component\r\n const parentNodeScope = this.componentOwner.parent\r\n ? this.componentOwner.parent.nodeScope\r\n : this.componentOwner.parentNodeScope;\r\n if (!parentNodeScope) return;\r\n parentNodeScope.sendEventFromThisScope(eventName, data, propagation, true);\r\n } else if (propagation === 'children') {\r\n // Send event to all child scopes\r\n var nodes = this.nodes;\r\n for (var nodeId in nodes) {\r\n var children = nodes[nodeId].children;\r\n if (children)\r\n children.forEach((child) => {\r\n if (child.name && this.context.hasComponentModelWithName(child.name)) {\r\n // This is a component instance child\r\n var consumed = child.nodeScope.sendEventFromThisScope(eventName, data, propagation, true);\r\n if (consumed) return true;\r\n }\r\n });\r\n }\r\n } else if (propagation === 'siblings') {\r\n // Send event to all siblings, that is all children of the parent scope except this scope\r\n let parentNodeScope;\r\n if (this.componentOwner.parent) {\r\n parentNodeScope = this.componentOwner.parent.nodeScope;\r\n } else {\r\n parentNodeScope = this.componentOwner.parentNodeScope;\r\n }\r\n\r\n if (!parentNodeScope) return;\r\n\r\n var nodes = parentNodeScope.nodes;\r\n for (var nodeId in nodes) {\r\n var children = nodes[nodeId].children;\r\n if (children) {\r\n var _c = children.filter(\r\n (child) => child.name && this.context.hasComponentModelWithName(child.name) && child.nodeScope !== this\r\n );\r\n _c.forEach((child) => {\r\n var consumed = child.nodeScope.sendEventFromThisScope(eventName, data, null, true);\r\n if (consumed) return true;\r\n });\r\n }\r\n }\r\n }\r\n\r\n return false;\r\n};\r\n\r\nmodule.exports = NodeScope;\r\n","\"use strict\";\r\n\r\n/**\r\n * @class OutputProperty\r\n *\r\n * @param args Arguments\r\n * @param {Function} args.getter Function that returns the value\r\n * @param {Node} args.owner Port owner\r\n * @param {string} args.type Output value type\r\n * @constructor\r\n */\r\nfunction OutputProperty(args) {\r\n\r\n if(!args.owner) {\r\n throw new Error(\"Owner must be set\");\r\n }\r\n this.getter = args.getter;\r\n this.connections = [];\r\n this.owner = args.owner;\r\n this.name = args.name;\r\n this.onFirstConnectionAdded = args.onFirstConnectionAdded;\r\n this.onLastConnectionRemoved = args.onLastConnectionRemoved;\r\n\r\n this._id = undefined;\r\n}\r\n\r\nObject.defineProperties(OutputProperty.prototype, {\r\n /**\r\n * Gets the current value\r\n * @name OutputProperty#value\r\n * @readonly\r\n */\r\n value: {\r\n get: function() {\r\n return this.getter.call(this.owner);\r\n }\r\n },\r\n\r\n id: {\r\n get: function() {\r\n if(!this._id) {\r\n this._id = this.owner.id + this.name;\r\n }\r\n return this._id;\r\n }\r\n },\r\n\r\n /**\r\n * Registers a connection to propagate dirtiness\r\n * Also records which input port it's connected to so nodes like\r\n * Animation can set it's implicit start value\r\n * @name OutputProperty#registerConnection\r\n * @readonly\r\n */\r\n registerConnection: {\r\n value: function(node, inputPortName) {\r\n this.connections.push({\r\n node: node,\r\n inputPortName: inputPortName\r\n });\r\n\r\n if(this.connections.length === 1 && this.onFirstConnectionAdded) {\r\n this.onFirstConnectionAdded.call(this.owner);\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Deregisters a connection to a specific input port\r\n * @name OutputProperty#deregisterConnection\r\n * @readonly\r\n */\r\n deregisterConnection: {\r\n value: function(node, inputPortName) {\r\n for(var i=0; i 500) {\r\n //this will make the owner send a warning and stop its update\r\n this.owner._cyclicLoop = true;\r\n }\r\n\r\n for(var i= 0, len=this.connections.length; i 0;\r\n }\r\n }\r\n});\r\nmodule.exports = OutputProperty;","\"use strict\";\r\n\r\nfunction addModuleSettings(result, modules) {\r\n // Add module settings\r\n for(var i = 0; i < modules.length; i++) {\r\n var m = modules[i];\r\n if(m.settings) {\r\n m.settings.forEach(function(p) {\r\n result.ports.push(p);\r\n })\r\n }\r\n }\r\n}\r\n\r\nfunction generateProjectSettings(projectSettings, modules) {\r\n const result = {\r\n dynamicports: [],\r\n ports: []\r\n };\r\n\r\n addModuleSettings(result, modules);\r\n\r\n return result;\r\n}\r\n\r\nmodule.exports = {\r\n generateProjectSettings: generateProjectSettings\r\n};","var EventEmitter = require('../events');\r\n\r\nfunction Services() {\r\n}\r\n\r\nServices.events = new EventEmitter();\r\n\r\nmodule.exports = Services;","'use strict';\r\n\r\nfunction Timer(scheduler, args) {\r\n this.duration = args.duration || 0;\r\n this._isRunning = false;\r\n this._hasCalledOnStart = false;\r\n this.scheduler = scheduler;\r\n this.repeatCount = 1;\r\n this.delay = 0;\r\n\r\n for(var arg in args) {\r\n this[arg] = args[arg];\r\n }\r\n}\r\n\r\nTimer.prototype.start = function() {\r\n if(this._isRunning) {\r\n this.stop();\r\n }\r\n\r\n this.scheduler.scheduleTimer(this);\r\n return this;\r\n};\r\n\r\nTimer.prototype.stop = function() {\r\n this.scheduler.stopTimer(this);\r\n this._hasCalledOnStart = false;\r\n this._isRunning = false;\r\n this._wasStopped = true; // This is used to avoid calling onFinish\r\n};\r\n\r\nTimer.prototype.isRunning = function() {\r\n return this._isRunning;\r\n};\r\n\r\nTimer.prototype.durationLeft = function() {\r\n return this._durationLeft;\r\n};\r\n\r\nfunction TimerScheduler(requestFrameCallback) {\r\n this.requestFrame = requestFrameCallback;\r\n this.runningTimers = [];\r\n this.newTimers = [];\r\n}\r\n\r\nTimerScheduler.prototype.createTimer = function(args) {\r\n return new Timer(this, args);\r\n};\r\n\r\nTimerScheduler.prototype.scheduleTimer = function(timer) {\r\n if(this.newTimers.indexOf(timer) === -1) {\r\n if(timer.repeatCount === 0) {\r\n timer.repeatCount = 100000;\r\n }\r\n\r\n this.newTimers.push(timer);\r\n this.requestFrame();\r\n }\r\n};\r\n\r\nTimerScheduler.prototype.stopTimer = function(timer) {\r\n var index;\r\n\r\n if(timer._isRunning) {\r\n index = this.runningTimers.indexOf(timer);\r\n if(index !== -1) {\r\n this.runningTimers.splice(index, 1);\r\n }\r\n\r\n if (timer.onStop && !timer._wasStopped) {\r\n timer.onStop();\r\n }\r\n }\r\n else {\r\n index = this.newTimers.indexOf(timer);\r\n if(index !== -1) {\r\n this.newTimers.splice(index, 1);\r\n }\r\n }\r\n};\r\n\r\nTimerScheduler.prototype.runTimers = function(currentTime) {\r\n\r\n var remainingTimers = [],\r\n finishedTimers = [],\r\n timersThisFrame = [];\r\n\r\n var i,\r\n len = this.runningTimers.length,\r\n timer;\r\n\r\n //copy timer list in case timers are added or removed during onStart or onRunning\r\n for(i=0; i= timer._start) {\r\n\r\n if(timer._hasCalledOnStart === false && timer.onStart) {\r\n timer.onStart();\r\n timer._hasCalledOnStart = true;\r\n }\r\n\r\n var t;\r\n if(timer.duration > 0) {\r\n t = (currentTime - timer._start)/(timer.duration*timer.repeatCount);\r\n } else {\r\n t = 1.0;\r\n }\r\n\r\n timer._durationLeft = timer.duration * (1-t);\r\n\r\n var localT = t*timer.repeatCount - Math.floor(t*timer.repeatCount);\r\n if(t >= 1.0) {\r\n localT = 1.0;\r\n }\r\n\r\n if(timer.onRunning) {\r\n timer.onRunning(localT);\r\n }\r\n\r\n if(t < 1.0 && timer._isRunning) {\r\n remainingTimers.push(timer);\r\n }\r\n else if (!timer._wasStopped) {\r\n finishedTimers.push(timer);\r\n }\r\n } else {\r\n remainingTimers.push(timer);\r\n }\r\n }\r\n\r\n this.runningTimers = remainingTimers;\r\n\r\n for(i=0; i 0) {\r\n for(i=0; i 0 || this.newTimers.length > 0;\r\n};\r\n\r\nmodule.exports = TimerScheduler;\r\n","//this just assumes the base url is '/' always\r\nfunction getAbsoluteUrl(_url) {\r\n\r\n //convert to string in case the _url is a Cloud File (which is an object with a custom toString())\r\n const url = String(_url);\r\n\r\n //only add a the base url if this is a local URL (e.g. not a https url or base64 string)\r\n if (!url || url[0] === \"/\" || url.includes(\"://\") || url.startsWith('data:')) {\r\n return url;\r\n }\r\n\r\n return (Noodl.baseUrl || '/') + url;\r\n}\r\n\r\n/**\r\n * Log an error thrown by the JavaScript nodes.\r\n *\r\n * @param {any} error \r\n */\r\nfunction logJavaScriptNodeError(error) {\r\n if (typeof error === 'string') {\r\n console.log('Error in JS node run code.', error);\r\n } else {\r\n console.log(\r\n 'Error in JS node run code.',\r\n Object.getPrototypeOf(error).constructor.name + ': ' + error.message,\r\n error.stack\r\n );\r\n }\r\n}\r\n\r\nmodule.exports = {\r\n getAbsoluteUrl,\r\n logJavaScriptNodeError\r\n};\r\n","class Variants {\r\n\r\n constructor({graphModel, getNodeScope}) {\r\n this.getNodeScope = getNodeScope;\r\n\r\n if(graphModel) {\r\n this.graphModel = graphModel;\r\n graphModel.on('variantUpdated', variant => this.onVariantUpdated(variant));\r\n }\r\n }\r\n\r\n getVariant(typename, name) {\r\n if(!this.graphModel) return undefined;\r\n \r\n return this.graphModel.getVariant(typename, name);\r\n }\r\n\r\n onVariantUpdated(variant) {\r\n const nodeScope = this.getNodeScope();\r\n if(!nodeScope) return;\r\n\r\n //get all nodes with the type the variant applies to\r\n const nodes = nodeScope.getNodesWithTypeRecursive(variant.typename);\r\n\r\n //and filter for the ones using the updated variant\r\n const nodesWithVariant = nodes.filter(node => {\r\n\r\n //if a variant has been set during runtime, it'll override the value from the model\r\n if(node.variant) return node.variant.name === variant.name;\r\n\r\n //otherwise check the model (which always matches the editor)\r\n return node.model && node.model.variant === variant.name;\r\n });\r\n\r\n //and re-apply the variant\r\n for(const node of nodesWithVariant) {\r\n node.setVariant(variant);\r\n }\r\n }\r\n}\r\n\r\nmodule.exports = Variants;","const CloudStore = require('@noodl/runtime/src/api/cloudstore');\r\n\r\nconst files = {\r\n async delete(fileName) {\r\n return new Promise((resolve, reject) => {\r\n CloudStore.instance.deleteFile({\r\n file: { name: fileName },\r\n success: (response) => {\r\n resolve();\r\n },\r\n error: (e) => {\r\n reject(e);\r\n }\r\n });\r\n });\r\n }\r\n};\r\n\r\nmodule.exports = files;\r\n","const Model = require('@noodl/runtime/src/model');\r\nconst CloudStore = require('@noodl/runtime/src/api/cloudstore');\r\nconst NoodlRuntime = require('@noodl/runtime');\r\nconst RecordsAPI = require('@noodl/runtime/src/api/records');\r\n\r\nfunction createUsersAPI(modelScope) {\r\n let _cloudstore;\r\n const cloudstore = () => {\r\n // We must create the cloud store just in time so all meta data is loaded\r\n if (!_cloudstore) _cloudstore = new CloudStore(modelScope);\r\n return _cloudstore;\r\n };\r\n\r\n const Records = RecordsAPI(modelScope);\r\n\r\n const api = {\r\n // This API should support an options object, this is how it works on\r\n // the frontend and in the docs. To support any old use added a ugly fix\r\n async logIn(username, password) {\r\n if(typeof username === 'object' && password === undefined) {\r\n const options = username; \r\n username = options.username;\r\n password = options.password;\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n const userService = NoodlRuntime.Services.UserService.forScope(modelScope);\r\n userService.logIn({\r\n username,\r\n password,\r\n success: (user) => {\r\n resolve(user);\r\n },\r\n error: (e) => {\r\n reject(Error(e));\r\n }\r\n });\r\n });\r\n },\r\n\r\n async impersonate(username, options) {\r\n // Look for the user based on username\r\n const users = await Records.query('_User', {\r\n username: { equalTo: username }\r\n });\r\n\r\n if (!users || users.length !== 1) {\r\n throw Error('Could not find user.');\r\n }\r\n\r\n // See if there is a session already\r\n const user = users[0];\r\n\r\n const query = {\r\n and: [{ user: { pointsTo: user.id } }, { expiresAt: { greaterThan: new Date() } }]\r\n };\r\n\r\n if (options && options.installationId) {\r\n query.and.push({ installationId: { equalTo: options.installationId } });\r\n }\r\n\r\n const sessions = await Records.query('_Session', query);\r\n\r\n async function _fetchUser(sessionToken) {\r\n return new Promise((resolve, reject) => {\r\n const userService = NoodlRuntime.Services.UserService.forScope(modelScope);\r\n userService.fetchUser({\r\n sessionToken,\r\n success: (user) => resolve(user),\r\n error: (e) => reject(Error(e))\r\n });\r\n });\r\n }\r\n\r\n if (!sessions || sessions.length === 0) {\r\n // No session, we need to create one\r\n const session = await Records.create('_Session', {\r\n user: user.id,\r\n installationId: options ? options.installationId : undefined,\r\n sessionToken: 'r:' + Model.guid() + Model.guid(),\r\n expiresAt: new Date(\r\n Date.now() + (options && options.duration !== undefined ? options.duration : 24 * 60 * 60 * 1000)\r\n ),\r\n restricted: false\r\n });\r\n\r\n return _fetchUser(session.sessionToken);\r\n } else {\r\n return _fetchUser(sessions[0].sessionToken);\r\n }\r\n }\r\n };\r\n\r\n Object.defineProperty(api, 'Current', {\r\n get: function () {\r\n const request = (modelScope || Model).get('Request');\r\n const userId = request.get('UserId');\r\n if (!userId) return;\r\n\r\n return {\r\n UserId: userId,\r\n Properties: (modelScope || Model).get(userId),\r\n async save(options) {\r\n return new Promise((resolve, reject) => {\r\n cloudstore().save({\r\n collection: '_User',\r\n objectId: userId,\r\n data: (modelScope || Model).get(userId).data,\r\n acl: options ? options.acl : undefined,\r\n success: (response) => {\r\n resolve();\r\n },\r\n error: (err) => {\r\n reject(Error(err || 'Failed to save.'));\r\n }\r\n });\r\n });\r\n },\r\n async fetch() {\r\n return new Promise((resolve, reject) => {\r\n cloudstore().fetch({\r\n collection: '_User',\r\n objectId: userId,\r\n success: function (response) {\r\n var record = cloudstore()._fromJSON(response, '_User');\r\n resolve(record);\r\n },\r\n error: function (err) {\r\n reject(Error(err || 'Failed to fetch.'));\r\n }\r\n });\r\n });\r\n }\r\n };\r\n }\r\n });\r\n\r\n return api;\r\n}\r\n\r\nmodule.exports = createUsersAPI;\r\n","const { Node, EdgeTriggeredInput } = require('@noodl/runtime');\r\n\r\nconst CloudStore = require('@noodl/runtime/src/api/cloudstore'),\r\n JavascriptNodeParser = require('@noodl/runtime/src/javascriptnodeparser'),\r\n QueryUtils = require('@noodl/runtime/src/api/queryutils');\r\n\r\nvar AggregateNode = {\r\n name: 'noodl.cloud.aggregate',\r\n docs: 'https://docs.noodl.net/nodes/cloud-functions/cloud-data/aggregate-records',\r\n displayName: 'Aggregate Records',\r\n category: 'Cloud Services',\r\n usePortAsLabel: 'collectionName',\r\n color: 'data',\r\n initialize: function () {\r\n this._internal.queryParameters = {};\r\n\r\n this._internal.storageSettings = {};\r\n\r\n this._internal.aggregates = {};\r\n },\r\n getInspectInfo() {\r\n const aggregates = this._internal.aggregateValues;\r\n if (!aggregates) {\r\n return { type: 'text', value: '[Not executed yet]' };\r\n }\r\n\r\n return [\r\n {\r\n type: 'value',\r\n value: aggregates\r\n }\r\n ];\r\n },\r\n inputs: {\r\n aggregates:{\r\n index:100,\r\n group:\"Aggregates\",\r\n type:{name:\"stringlist\",allowEditOnly:true},\r\n displayName:\"Aggregates\",\r\n set:function(value) {\r\n this._internal.aggregatesList = value;\r\n }\r\n }\r\n },\r\n outputs: {\r\n fetched: {\r\n group: 'Events',\r\n type: 'signal',\r\n displayName: 'Success'\r\n },\r\n failure: {\r\n group: 'Events',\r\n type: 'signal',\r\n displayName: 'Failure'\r\n },\r\n error: {\r\n type: 'string',\r\n displayName: 'Error',\r\n group: 'Error',\r\n getter: function () {\r\n return this._internal.error;\r\n }\r\n }\r\n },\r\n prototypeExtensions: {\r\n setCollectionName: function (name) {\r\n this._internal.name = name;\r\n\r\n if (this.isInputConnected('storageFetch') === false) this.scheduleFetch();\r\n },\r\n _onNodeDeleted: function () {\r\n Node.prototype._onNodeDeleted.call(this);\r\n },\r\n setError: function (err) {\r\n this._internal.err = err;\r\n this.flagOutputDirty('error');\r\n this.sendSignalOnOutput('failure');\r\n },\r\n scheduleFetch: function () {\r\n var internal = this._internal;\r\n\r\n if (internal.fetchScheduled) return;\r\n internal.fetchScheduled = true;\r\n this.scheduleAfterInputsHaveUpdated(() => {\r\n internal.fetchScheduled = false;\r\n\r\n this.fetch();\r\n });\r\n },\r\n fetch: function () {\r\n if (this.context.editorConnection) {\r\n let validateAggNames = true;\r\n if(this._internal.aggregatesList) {\r\n this._internal.aggregatesList.split(',').forEach(k => {\r\n if(k.indexOf(' ')!==-1)\r\n validateAggNames = false;\r\n })\r\n }\r\n\r\n if (this._internal.name === undefined) {\r\n this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name, this.id, 'aggregate-node', {\r\n message: 'No class specified for aggregate.'\r\n });\r\n }\r\n else if(this._internal.aggregatesList === undefined) {\r\n this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name, this.id, 'aggregate-node', {\r\n message: 'No aggregates specified.'\r\n });\r\n }\r\n else if(!validateAggNames) {\r\n this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name, this.id, 'aggregate-node', {\r\n message: 'Invalid aggregate names, dont use space and special characters.'\r\n });\r\n }\r\n else {\r\n this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name, this.id, 'aggregate-node');\r\n }\r\n }\r\n\r\n const f = this.getStorageFilter();\r\n this._internal.currentQuery = {\r\n where: f.where,\r\n };\r\n CloudStore.forScope(this.nodeScope.modelScope).aggregate({\r\n collection: this._internal.name,\r\n where: f.where,\r\n group: this.getAggregates(),\r\n success: (results) => {\r\n this._internal.aggregateValues = results;\r\n for(const key in results) {\r\n if(this.hasOutput('agg-'+key))\r\n this.flagOutputDirty('agg-'+key);\r\n }\r\n this.sendSignalOnOutput('fetched');\r\n },\r\n error: (err) => {\r\n this.setError(err || 'Failed to aggregate.');\r\n }\r\n });\r\n },\r\n getStorageFilter: function () {\r\n const storageSettings = this._internal.storageSettings;\r\n if (storageSettings['storageFilterType'] === undefined || storageSettings['storageFilterType'] === 'simple') {\r\n // Create simple filter\r\n const _where =\r\n this._internal.visualFilter !== undefined\r\n ? QueryUtils.convertVisualFilter(this._internal.visualFilter, {\r\n queryParameters: this._internal.queryParameters,\r\n collectionName: this._internal.name\r\n })\r\n : undefined;\r\n\r\n return {\r\n where: _where,\r\n };\r\n } else if (storageSettings['storageFilterType'] === 'json') {\r\n // JSON filter\r\n if (!this._internal.filterFunc) {\r\n try {\r\n var filterCode = storageSettings['storageJSONFilter'];\r\n\r\n // Parse out variables\r\n filterCode = filterCode.replace(/\\/\\*[\\s\\S]*?\\*\\/|\\/\\/.*/g, ''); // Remove comments\r\n this._internal.filterVariables = filterCode.match(/\\$[A-Za-z0-9]+/g) || [];\r\n\r\n var args = ['where', 'Inputs']\r\n .concat(this._internal.filterVariables)\r\n .concat([filterCode]);\r\n this._internal.filterFunc = Function.apply(null, args);\r\n } catch (e) {\r\n this._internal.filterFunc = undefined;\r\n console.log('Error while parsing filter script: ' + e);\r\n }\r\n }\r\n\r\n if (!this._internal.filterFunc) return;\r\n\r\n var _filter = {},\r\n _this = this;\r\n\r\n // Collect filter variables\r\n var _filterCb = function (f) {\r\n _filter = QueryUtils.convertFilterOp(f, {\r\n collectionName: _this._internal.name,\r\n error: function (err) {\r\n _this.context.editorConnection.sendWarning(\r\n _this.nodeScope.componentOwner.name,\r\n _this.id,\r\n 'aggregate-node-filter',\r\n {\r\n message: err\r\n }\r\n );\r\n }\r\n });\r\n };\r\n\r\n // Extract inputs\r\n const inputs = {};\r\n for (let key in storageSettings) {\r\n if (key.startsWith('storageFilterValue-'))\r\n inputs[key.substring('storageFilterValue-'.length)] = storageSettings[key];\r\n }\r\n\r\n var filterFuncArgs = [ _filterCb, inputs]; // One for filter, one for where\r\n\r\n this._internal.filterVariables.forEach((v) => {\r\n filterFuncArgs.push(storageSettings['storageFilterValue-' + v.substring(1)]);\r\n });\r\n\r\n // Run the code to get the filter\r\n try {\r\n this._internal.filterFunc.apply(this, filterFuncArgs);\r\n } catch (e) {\r\n console.log('Error while running filter script: ' + e);\r\n }\r\n\r\n return { where: _filter };\r\n }\r\n },\r\n getAggregates:function() {\r\n if(!this._internal.aggregatesList) return {};\r\n if(!this._internal.aggregates) return {};\r\n\r\n const schema = CloudStore._collections;\r\n const classSchema = schema[this._internal.name];\r\n if(!classSchema || !classSchema.schema || !classSchema.schema.properties) return {};\r\n\r\n const defs = this._internal.aggregates;\r\n const aggs = {};\r\n this._internal.aggregatesList.split(',').forEach(a => {\r\n if(defs[a].prop === undefined) return;\r\n const propSchema = classSchema.schema.properties[defs[a].prop];\r\n if(propSchema === undefined) return;\r\n\r\n const op = {}\r\n\r\n const _def = (propSchema.type === 'String')?'distinct':'avg';\r\n \r\n op[defs[a].op || _def] = defs[a].prop;\r\n aggs[a] = op;\r\n })\r\n\r\n return aggs;\r\n },\r\n getAggregateValue:function(name) {\r\n if(!this._internal.aggregateValues) return;\r\n return this._internal.aggregateValues[name];\r\n },\r\n registerOutputIfNeeded: function (name) {\r\n if (this.hasOutput(name)) {\r\n return;\r\n }\r\n\r\n if(name.startsWith('agg-')) this.registerOutput(name, {\r\n getter: this.getAggregateValue.bind(this, name.substring('agg-'.length))\r\n });\r\n },\r\n setVisualFilter: function (value) {\r\n this._internal.visualFilter = value;\r\n\r\n if (this.isInputConnected('storageFetch') === false) this.scheduleFetch();\r\n },\r\n setQueryParameter: function (name, value) {\r\n this._internal.queryParameters[name] = value;\r\n\r\n if (this.isInputConnected('storageFetch') === false) this.scheduleFetch();\r\n },\r\n setAggregateParameter:function(name,value) {\r\n const aggregates = this._internal.aggregates;\r\n if(name.startsWith('aggprop-')) {\r\n const _name = name.substring('aggprop-'.length);\r\n if(!aggregates[_name]) aggregates[_name] = {}\r\n aggregates[_name].prop = value;\r\n }\r\n else if(name.startsWith('aggop-')) {\r\n const _name = name.substring('aggop-'.length);\r\n if(!aggregates[_name]) aggregates[_name] = {}\r\n aggregates[_name].op = value;\r\n }\r\n },\r\n registerInputIfNeeded: function (name) {\r\n if (this.hasInput(name)) {\r\n return;\r\n }\r\n\r\n if (name.startsWith('agg'))\r\n return this.registerInput(name, {\r\n set: this.setAggregateParameter.bind(this, name)\r\n });\r\n\r\n if (name.startsWith('qp-'))\r\n return this.registerInput(name, {\r\n set: this.setQueryParameter.bind(this, name.substring('qp-'.length))\r\n });\r\n\r\n const dynamicSignals = {\r\n storageFetch: this.scheduleFetch.bind(this)\r\n };\r\n\r\n if (dynamicSignals[name])\r\n return this.registerInput(name, {\r\n set: EdgeTriggeredInput.createSetter({\r\n valueChangedToTrue: dynamicSignals[name]\r\n })\r\n });\r\n\r\n const dynamicSetters = {\r\n collectionName: this.setCollectionName.bind(this),\r\n visualFilter: this.setVisualFilter.bind(this)\r\n };\r\n\r\n if (dynamicSetters[name])\r\n return this.registerInput(name, {\r\n set: dynamicSetters[name]\r\n });\r\n\r\n this.registerInput(name, {\r\n set: userInputSetter.bind(this, name)\r\n });\r\n }\r\n }\r\n};\r\n\r\nfunction userInputSetter(name, value) {\r\n /* jshint validthis:true */\r\n this._internal.storageSettings[name] = value;\r\n\r\n if (this.isInputConnected('storageFetch') === false) this.scheduleFetch();\r\n}\r\n\r\nconst _defaultJSONQuery =\r\n '// Write your query script here, check out the reference documentation for examples\\n' + 'where({ })\\n';\r\n\r\nfunction updatePorts(nodeId, parameters, editorConnection, graphModel) {\r\n var ports = [];\r\n\r\n const dbCollections = graphModel.getMetaData('dbCollections');\r\n const systemCollections = graphModel.getMetaData('systemCollections');\r\n\r\n const _systemClasses = [\r\n { label: 'User', value: '_User' },\r\n { label: 'Role', value: '_Role' }\r\n ];\r\n ports.push({\r\n name: 'collectionName',\r\n type: {\r\n name: 'enum',\r\n enums: _systemClasses.concat(\r\n dbCollections !== undefined\r\n ? dbCollections.map((c) => {\r\n return { value: c.name, label: c.name };\r\n })\r\n : []\r\n ),\r\n allowEditOnly: true\r\n },\r\n displayName: 'Class',\r\n plug: 'input',\r\n group: 'General'\r\n });\r\n\r\n ports.push({\r\n name: 'storageFilterType',\r\n type: {\r\n name: 'enum',\r\n allowEditOnly: true,\r\n enums: [\r\n { value: 'simple', label: 'Visual' },\r\n { value: 'json', label: 'Javascript' }\r\n ]\r\n },\r\n displayName: 'Filter',\r\n default: 'simple',\r\n plug: 'input',\r\n group: 'General'\r\n });\r\n\r\n ports.push({\r\n type: 'signal',\r\n plug: 'input',\r\n group: 'Actions',\r\n name: 'storageFetch',\r\n displayName: 'Do'\r\n });\r\n\r\n if(parameters['aggregates'] !== undefined && parameters.collectionName !== undefined) {\r\n var c = dbCollections && dbCollections.find((c) => c.name === parameters.collectionName);\r\n if (c === undefined && systemCollections) c = systemCollections.find((c) => c.name === parameters.collectionName);\r\n if (c && c.schema && c.schema.properties) {\r\n\r\n const aggs = parameters['aggregates'].split(',');\r\n\r\n const props = Object.keys(c.schema.properties).filter(k => c.schema.properties[k].type === 'Number' || c.schema.properties[k].type === 'String');\r\n\r\n aggs.forEach(a => {\r\n ports.push({\r\n index:101,\r\n name:'aggprop-'+a,\r\n plug:'input',\r\n type:{name:'enum',enums:props.map(k => ({value:k,label:k})),allowEditOnly:true},\r\n displayName:'Property',\r\n group:a\r\n });\r\n\r\n if(parameters['aggprop-'+a] !== undefined) {\r\n const prop = parameters['aggprop-'+a];\r\n const schema = c.schema.properties[prop];\r\n\r\n if(schema && schema.type === 'Number') {\r\n // Number aggregate\r\n ports.push({\r\n index:102,\r\n name: 'aggop-' + a,\r\n plug: 'input',\r\n type: {name:'enum', enums:[{value:'min',label:'Min'},\r\n {value:'max',label:'Max'},\r\n {value:'sum',label:'Sum'},\r\n {value:'avg',label:'Avg'}],allowEditOnly:true},\r\n default:'avg',\r\n displayName: 'Operation',\r\n group: a\r\n })\r\n\r\n ports.push({\r\n name: 'agg-' + a,\r\n plug: 'output',\r\n type: 'number',\r\n displayName: a,\r\n group: 'Aggregates'\r\n })\r\n }\r\n else if(schema && schema.type === 'String') {\r\n // String aggregate\r\n ports.push({\r\n index:102,\r\n name: 'aggop-' + a,\r\n plug: 'input',\r\n type: {name:'enum', enums:[{value:'distinct',label:'Distinct'}],allowEditOnly:true},\r\n default:'distinct',\r\n displayName: 'Operation',\r\n group: a\r\n })\r\n\r\n ports.push({\r\n name: 'agg-' + a,\r\n plug: 'output',\r\n type: 'string',\r\n displayName: a,\r\n group: 'Aggregates'\r\n })\r\n }\r\n }\r\n\r\n })\r\n }\r\n }\r\n\r\n // Simple query\r\n if (parameters['storageFilterType'] === undefined || parameters['storageFilterType'] === 'simple') {\r\n if (parameters.collectionName !== undefined) {\r\n var c = dbCollections && dbCollections.find((c) => c.name === parameters.collectionName);\r\n if (c === undefined && systemCollections) c = systemCollections.find((c) => c.name === parameters.collectionName);\r\n if (c && c.schema && c.schema.properties) {\r\n const schema = JSON.parse(JSON.stringify(c.schema));\r\n\r\n // Find all records that have a relation with this type\r\n function _findRelations(c) {\r\n if (c.schema !== undefined && c.schema.properties !== undefined)\r\n for (var key in c.schema.properties) {\r\n var p = c.schema.properties[key];\r\n if (p.type === 'Relation' && p.targetClass === parameters.collectionName) {\r\n if (schema.relations === undefined) schema.relations = {};\r\n if (schema.relations[c.name] === undefined) schema.relations[c.name] = [];\r\n\r\n schema.relations[c.name].push({ property: key });\r\n }\r\n }\r\n }\r\n\r\n dbCollections && dbCollections.forEach(_findRelations);\r\n systemCollections && systemCollections.forEach(_findRelations);\r\n\r\n ports.push({\r\n name: 'visualFilter',\r\n plug: 'input',\r\n type: { name: 'query-filter', schema: schema, allowEditOnly: true },\r\n displayName: 'Filter',\r\n group: 'Filter'\r\n });\r\n }\r\n\r\n if (parameters.visualFilter !== undefined) {\r\n // Find all input ports\r\n const uniqueInputs = {};\r\n function _collectInputs(query) {\r\n if (query === undefined) return;\r\n if (query.rules !== undefined) query.rules.forEach((r) => _collectInputs(r));\r\n else if (query.input !== undefined) uniqueInputs[query.input] = true;\r\n }\r\n\r\n _collectInputs(parameters.visualFilter);\r\n Object.keys(uniqueInputs).forEach((input) => {\r\n ports.push({\r\n name: 'qp-' + input,\r\n plug: 'input',\r\n type: '*',\r\n displayName: input,\r\n group: 'Query Parameters'\r\n });\r\n });\r\n }\r\n }\r\n }\r\n // JSON query\r\n else if (parameters['storageFilterType'] === 'json') {\r\n ports.push({\r\n type: { name: 'string', allowEditOnly: true, codeeditor: 'javascript' },\r\n plug: 'input',\r\n group: 'Filter',\r\n name: 'storageJSONFilter',\r\n default: _defaultJSONQuery,\r\n displayName: 'Filter'\r\n });\r\n\r\n var filter = parameters['storageJSONFilter'];\r\n if (filter) {\r\n filter = filter.replace(/\\/\\*[\\s\\S]*?\\*\\/|\\/\\/.*/g, ''); // Remove comments\r\n var variables = filter.match(/\\$[A-Za-z0-9]+/g);\r\n\r\n if (variables) {\r\n const unique = {};\r\n variables.forEach((v) => {\r\n unique[v] = true;\r\n });\r\n\r\n Object.keys(unique).forEach((p) => {\r\n ports.push({\r\n name: 'storageFilterValue-' + p.substring(1),\r\n displayName: p.substring(1),\r\n group: 'Filter Values',\r\n plug: 'input',\r\n type: { name: '*', allowConnectionsOnly: true }\r\n });\r\n });\r\n }\r\n\r\n // Support variables with the \"Inputs.\"\" syntax\r\n JavascriptNodeParser.parseAndAddPortsFromScript(filter, ports, {\r\n inputPrefix: 'storageFilterValue-',\r\n inputGroup: 'Filter Values',\r\n inputType: { name: '*', allowConnectionsOnly: true },\r\n skipOutputs: true\r\n });\r\n }\r\n }\r\n\r\n editorConnection.sendDynamicPorts(nodeId, ports);\r\n}\r\n\r\nmodule.exports = {\r\n node: AggregateNode,\r\n setup: function (context, graphModel) {\r\n if (!context.editorConnection || !context.editorConnection.isRunningLocally()) {\r\n return;\r\n }\r\n\r\n function _managePortsForNode(node) {\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel);\r\n\r\n node.on('parameterUpdated', function (event) {\r\n if (event.name.startsWith('storage') || event.name === 'visualFilter' || event.name === 'collectionName' || event.name.startsWith('agg')) {\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel);\r\n }\r\n });\r\n\r\n graphModel.on('metadataChanged.dbCollections', function (data) {\r\n CloudStore.invalidateCollections();\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel);\r\n });\r\n\r\n graphModel.on('metadataChanged.systemCollections', function (data) {\r\n CloudStore.invalidateCollections();\r\n updatePorts(node.id, node.parameters, context.editorConnection, graphModel);\r\n });\r\n\r\n graphModel.on('metadataChanged.cloudservices', function (data) {\r\n CloudStore.instance._initCloudServices();\r\n });\r\n }\r\n\r\n graphModel.on('editorImportComplete', () => {\r\n graphModel.on('nodeAdded.noodl.cloud.aggregate', function (node) {\r\n _managePortsForNode(node);\r\n });\r\n\r\n for (const node of graphModel.getNodesWithType('noodl.cloud.aggregate')) {\r\n _managePortsForNode(node);\r\n }\r\n });\r\n }\r\n};\r\n","'use strict';\r\n\r\nconst Model = require('@noodl/runtime/src/model');\r\nconst NoodlRuntime = require('@noodl/runtime');\r\nconst JavascriptNodeParser = require('@noodl/runtime/src/javascriptnodeparser');\r\n\r\n//Cloud functions override some of the JavascriptNodeParser functions\r\n\r\n//Override getComponentScopeForNode to just return an empty object. This basically disabled the 'Component' API in Function/Script nodes and removes a massive memory leak\r\n//Also improves performance.\r\nconst componentScope = {};\r\nJavascriptNodeParser.getComponentScopeForNode = function () {\r\n return componentScope;\r\n};\r\n\r\n//override the Noodl API so it uses a model scope\r\nJavascriptNodeParser.createNoodlAPI = function (modelScope) {\r\n return {\r\n getProjectSettings: NoodlRuntime.instance.getProjectSettings.bind(NoodlRuntime.instance),\r\n getMetaData: NoodlRuntime.instance.getMetaData.bind(NoodlRuntime.instance),\r\n Object: modelScope || Model,\r\n Variables: (modelScope || Model).get('--ndl--global-variables'),\r\n Records: require('@noodl/runtime/src/api/records')(modelScope),\r\n Users: require('./api/users')(modelScope),\r\n // CloudFunctions: require('./api/cloudfunctions'),\r\n Files: require('./api/files'),\r\n Objects: new Proxy(modelScope || Model, {\r\n get(target, prop, receiver) {\r\n return (modelScope || Model).get(prop);\r\n },\r\n set(obj, prop, value) {\r\n (modelScope || Model).get(prop).setAll(value);\r\n }\r\n })\r\n };\r\n};\r\n","const NoodlRuntime = require('@noodl/runtime');\r\nconst EventEmitter = require('@noodl/runtime/src/events');\r\n//const guid = require('../../../guid');\r\nconst Model = require('@noodl/runtime/src/model');\r\nconst CloudStore = require('@noodl/runtime/src/api/cloudstore');\r\n\r\nclass UserService {\r\n constructor(modelScope) {\r\n this.events = new EventEmitter();\r\n this.events.setMaxListeners(100000);\r\n\r\n // User is fetched and validate when the request is initiated\r\n // see if there is a current user\r\n const request = (modelScope || Model).get('Request');\r\n if (request.UserId !== undefined) {\r\n const user = (modelScope || Model).get(request.UserId);\r\n\r\n this.current = user;\r\n }\r\n\r\n this.modelScope = modelScope;\r\n }\r\n\r\n on() {\r\n this.events.on.apply(this.events, arguments);\r\n }\r\n\r\n off() {\r\n this.events.off.apply(this.events, arguments);\r\n }\r\n\r\n _makeRequest(path, options) {\r\n if (typeof _noodl_cloudservices === 'undefined') {\r\n options.error && options.error({ error: 'No active cloud service', status: 0 });\r\n return;\r\n }\r\n\r\n const cs = _noodl_cloudservices;\r\n\r\n fetch(cs.endpoint + path, {\r\n method: options.method || 'GET',\r\n headers: {\r\n 'X-Parse-Application-Id': cs.appId,\r\n 'X-Parse-Master-Key': cs.masterKey,\r\n 'content-type': 'application/json',\r\n 'X-Parse-Session-Token': options.sessionToken\r\n },\r\n body: JSON.stringify(options.content)\r\n })\r\n .then((res) => {\r\n if (res.ok) {\r\n res.json().then((json) => options.success(json));\r\n } else {\r\n res.json().then((json) => options.error({ error: json.error, status: res.status }));\r\n }\r\n })\r\n .catch((e) => {\r\n options.error({ error: e.message });\r\n });\r\n }\r\n\r\n setUserProperties(options) {\r\n if (this.current !== undefined) {\r\n //make a shallow copy to feed through CloudStore._serializeObject, which will modify the object\r\n const propsToSave = CloudStore._serializeObject({ ...options.properties }, '_User', this.modelScope || Model);\r\n\r\n const _content = Object.assign({}, { email: options.email, username: options.username }, propsToSave);\r\n\r\n delete _content.createdAt; // Remove props you cannot set\r\n delete _content.updatedAt;\r\n\r\n this._makeRequest('/users/' + this.current.getId(), {\r\n method: 'PUT',\r\n content: _content,\r\n success: (response) => {\r\n // Store current user\r\n for (let key in _content) {\r\n this.current.set(key, _content[key]);\r\n }\r\n options.success(response);\r\n },\r\n error: (e) => {\r\n options.error(e.error);\r\n }\r\n });\r\n }\r\n }\r\n\r\n logIn(options) {\r\n this._makeRequest('/login', {\r\n method: 'POST',\r\n content: {\r\n username: options.username,\r\n password: options.password,\r\n method: 'GET'\r\n },\r\n success: (user) => {\r\n delete user.ACL;\r\n delete user.className;\r\n delete user.__type;\r\n\r\n const _user = CloudStore._fromJSON(user, '_User', this.modelScope || Model);\r\n\r\n options.success(_user);\r\n },\r\n error: (e) => {\r\n options.error(e.error);\r\n }\r\n });\r\n }\r\n\r\n // Just fetch the user don't set to current\r\n fetchUser(options) {\r\n this._makeRequest('/users/me', {\r\n method: 'GET',\r\n sessionToken: options.sessionToken,\r\n success: (user) => {\r\n // Store current user\r\n delete user.ACL;\r\n delete user.className;\r\n delete user.__type;\r\n\r\n const _user = CloudStore._fromJSON(user, '_User', this.modelScope || Model);\r\n\r\n options.success(_user);\r\n },\r\n error: (e) => {\r\n options.error(e.error);\r\n }\r\n });\r\n }\r\n\r\n fetchCurrentUser(options) {\r\n if (options.sessionToken) {\r\n // Fetch the current user with the session token\r\n this._makeRequest('/users/me', {\r\n method: 'GET',\r\n sessionToken: options.sessionToken,\r\n success: (user) => {\r\n // Store current user\r\n delete user.ACL;\r\n delete user.className;\r\n delete user.__type;\r\n\r\n this.current = CloudStore._fromJSON(user, '_User', this.modelScope || Model);\r\n this.events.emit('sessionGained');\r\n options.success(this.current);\r\n },\r\n error: (e) => {\r\n options.error(e.error);\r\n }\r\n });\r\n } else if (this.current !== undefined) {\r\n // Fetch the current user, will use master key\r\n this._makeRequest('/users/' + this.current.getId(), {\r\n method: 'GET',\r\n success: (user) => {\r\n // Store current user\r\n delete user.ACL;\r\n delete user.className;\r\n delete user.__type;\r\n\r\n this.current = CloudStore._fromJSON(user, '_User', this.modelScope || Model);\r\n\r\n options.success(this.current);\r\n },\r\n error: (e) => {\r\n options.error(e.error);\r\n }\r\n });\r\n }\r\n }\r\n}\r\n\r\nUserService.forScope = (modelScope) => {\r\n if (modelScope === undefined) return UserService.instance;\r\n if (modelScope._userService) return modelScope._userService;\r\n\r\n modelScope._userService = new UserService(modelScope);\r\n return modelScope._userService;\r\n};\r\n\r\nvar _instance;\r\nObject.defineProperty(UserService, 'instance', {\r\n get: function () {\r\n if (_instance === undefined) _instance = new UserService();\r\n return _instance;\r\n }\r\n});\r\n\r\nNoodlRuntime.Services.UserService = UserService;\r\n\r\nmodule.exports = UserService;\r\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import { CloudRunner } from '.';\r\n\r\nconsole.log('Noodl Editor Cloud Runtime!');\r\nconsole.log('Version: ' + _noodl_cloud_runtime_version);\r\n\r\nconst _runner = new CloudRunner({\r\n webSocketClass: WebSocket,\r\n connectToEditor: true,\r\n editorAddress: 'ws://localhost:8574',\r\n enableDebugInspectors: true\r\n});\r\n\r\n_runner.runtime.graphModel.on('editorImportComplete', () => {\r\n ipcRenderer.send('noodl-cf-has-loaded-project');\r\n});\r\n\r\nconst handleRequest = async (functionName, req) => {\r\n return await _runner.run(functionName, req);\r\n};\r\n\r\nconst eventQueue = [];\r\nlet hasScheduledProcessJobs = false;\r\nconst _noodl_process_jobs = () => {\r\n hasScheduledProcessJobs = false;\r\n while (eventQueue.length > 0) {\r\n const cb = eventQueue.shift();\r\n cb();\r\n }\r\n};\r\n\r\nconst _setImmediate = window.setImmediate;\r\nwindow.setImmediate = (cb) => {\r\n eventQueue.push(cb);\r\n if (!hasScheduledProcessJobs) {\r\n hasScheduledProcessJobs = true;\r\n _setImmediate(_noodl_process_jobs);\r\n }\r\n};\r\n\r\nconst _fetch_response_handlers = {};\r\nconst _fetch = window.fetch;\r\nwindow.fetch = function (url, args) {\r\n if (args && args.platform === 'node') {\r\n return new Promise((resolve, reject) => {\r\n // Perform the fetch via the host node platform\r\n const token = Math.random().toString(26).slice(2);\r\n _fetch_response_handlers[token] = (args) => {\r\n if (args.error === undefined) {\r\n const res = {\r\n body: args.body,\r\n status: args.status,\r\n headers: args.headers,\r\n ok: args.status === 200 || args.status === 201\r\n };\r\n res.json = () => {\r\n try {\r\n return Promise.resolve(JSON.parse(res.body));\r\n } catch (e) {\r\n return Promise.reject('Failed to parse JSON response');\r\n }\r\n };\r\n res.text = () => {\r\n return Promise.resolve(res.body);\r\n };\r\n\r\n resolve(res);\r\n } else reject(args.error);\r\n };\r\n\r\n ipcRenderer.send('noodl-cf-fetch', {\r\n url,\r\n method: args.method,\r\n token,\r\n headers: JSON.parse(JSON.stringify(args.headers)),\r\n body: args.body\r\n });\r\n });\r\n } else return _fetch(url, args);\r\n};\r\n\r\nipcRenderer.on('noodl-cf-fetch-response', async function (event, args) {\r\n if (typeof _fetch_response_handlers[args.token] === 'function') {\r\n typeof _fetch_response_handlers[args.token](args);\r\n delete _fetch_response_handlers[args.token];\r\n }\r\n});\r\n\r\nipcRenderer.on('noodl-cf-request', async function (event, args) {\r\n if (args.cloudService) {\r\n window._noodl_cloudservices = {\r\n endpoint: args.cloudService.endpoint,\r\n appId: args.cloudService.appId,\r\n masterKey: args.cloudService.masterKey\r\n };\r\n }\r\n\r\n console.info(`Cloud function ${args.function} called`);\r\n\r\n try {\r\n // args.function\r\n // args.headers\r\n // args.body\r\n\r\n const res = await handleRequest(args.function, {\r\n body: args.body,\r\n headers: args.headers\r\n });\r\n\r\n console.info(`Cloud function ${args.function} response [${res.statusCode}]`);\r\n\r\n event.sender.send('noodl-cf-response', Object.assign({}, res, { token: args.token }));\r\n } catch (e) {\r\n console.error(`Cloud function ${args.function} response [400] message: ${e.message}`);\r\n\r\n event.sender.send('noodl-cf-response', {\r\n token: args.token,\r\n statusCode: 400,\r\n body: JSON.stringify({ error: e.message })\r\n });\r\n }\r\n});\r\n"],"names":["HASH_UNDEFINED","MAX_SAFE_INTEGER","argsTag","funcTag","genTag","reIsHostCtor","freeGlobal","g","Object","freeSelf","self","root","Function","arrayIncludes","array","value","length","fromIndex","predicate","fromRight","index","baseFindIndex","baseIsNaN","baseIndexOf","arrayIncludesWith","comparator","arrayPush","values","offset","cacheHas","cache","key","has","uid","arrayProto","Array","prototype","funcProto","objectProto","coreJsData","maskSrcKey","exec","keys","IE_PROTO","funcToString","toString","hasOwnProperty","objectToString","reIsNative","RegExp","call","replace","Symbol","propertyIsEnumerable","splice","spreadableSymbol","isConcatSpreadable","undefined","nativeMax","Math","max","Map","getNative","nativeCreate","Hash","entries","this","clear","entry","set","ListCache","MapCache","SetCache","__data__","add","assocIndexOf","other","baseFlatten","depth","isStrict","result","isFlattenable","getMapData","map","type","data","object","getValue","isObject","pattern","isFunction","e","isHostObject","test","func","toSource","baseIsNative","isArray","isArrayLikeObject","isArguments","get","pop","push","start","difference","iteratee","includes","isCommon","valuesLength","arrayMap","outer","computed","valuesIndex","baseDifference","args","arguments","otherArgs","thisArg","apply","isObjectLike","isLength","isArrayLike","tag","module","exports","constructor","options","runtime","platform","requestUpdate","f","setImmediate","getCurrentTime","Date","getTime","o","JSON","stringify","webSocketClass","isRunningLocally","connectToEditor","componentFilter","c","name","startsWith","dontCreateRootComponent","registerNodes","setDebugInspectorsEnabled","enableDebugInspectors","editorAddress","async","exportData","projectSettings","setData","setProjectSettings","functionName","request","Promise","resolve","reject","requestId","random","slice","requestScope","context","modelScope","Scope","createComponentInstanceNode","then","functionComponent","requestNode","nodeScope","getNodesWithType","hasResponded","getNodesWithTypeRecursive","forEach","resp","_internal","_sendResponseCallback","_onNodeDeleted","reset","sendRequest","catch","Error","node","displayNodeName","category","docs","useVariants","mountedInput","allowAsExportRoot","singleton","color","connectionPanel","groupPriority","outputs","receive","displayName","group","auth","getter","authenticated","userId","authUserId","inputs","allowNoAuth","default","params","allowEditOnly","initialize","requestParameters","userProperties","Authenticated","methods","getRequestParameter","setRequestParameter","hasOutput","flagOutputDirty","fetchCurrentUser","sessionToken","Services","UserService","forScope","success","error","req","headers","parse","body","userModel","current","getId","instance","getConfig","requestModel","sendSignalOnOutput","registerOutputIfNeeded","registerOutput","bind","substring","graphModel","_managePortsForNode","_updatePorts","ports","parameters","i","split","p","plug","editorConnection","sendDynamicPorts","id","on","event","dynamicports","condition","responseParameters","errorMessage","send","valueChangedToTrue","status","statusCode","enums","label","setResponseParameter","registerInputIfNeeded","hasInput","registerInput","nodeDefinition","registerNode","NodeContext","EditorConnection","generateNodeLibrary","ProjectSettings","GraphModel","NodeDefinition","Node","EditorModelEventsHandler","EdgeTriggeredInput","EventEmitter","asyncPool","NoodlRuntime","noodlModules","eventEmitter","updateScheduled","rootComponent","_currentLoadedData","isWaitingForExport","errorHandlers","frameNumber","runningInEditor","runDeployed","webSocketOptions","noodlRuntime","runtimeType","scheduleUpdate","_setupEditorCommunication","registerGraphModelListeners","prefetchBundles","bundleNames","numParallelFetches","fetchComponentBundle","objectEquals","x","y","every","indexOf","isEmpty","components","filter","componentIndex","allBundles","emit","reload","onModelUpdateReceived","onMetaDataUpdateReceived","sendNodeLibrary","enabled","registerModule","nodes","component","registerComponentModel","deregisterComponentModel","location","definedNode","defineNode","nodeRegister","register","setupNumberedInputDynamicPorts","setup","_setRootComponent","rootComponentName","model","removeListenersWithRef","componentModel","setRootComponent","graphData","_disableLoad","importEditorData","setTimeout","_doUpdate","currentFrameTime","update","settings","getNodeLibrary","generateProjectSettings","getSettings","concat","nodeLibrary","projectsettings","lastSentNodeLibrary","address","connect","EditorMetaDataEventsHandler","handleEvent","addErrorHandler","callback","reportError","message","eh","getProjectSettings","getMetaData","url","getUrl","getName","Model","Collection","CloudFile","_protectedFields","_common","_User","_removeProtectedFields","className","_data","assign","CloudStore","_initCloudServices","events","setMaxListeners","_fromJSON","item","collectionName","_deserializeJSON","_serializeObject","_collections","cloudServices","appId","endpoint","dbVersionMajor","off","_makeRequest","path","_noodl_cloud_runtime_version","xhr","XMLHttpRequest","onreadystatechange","readyState","json","response","responseText","open","method","setRequestHeader","_noodl_cloudservices","masterKey","_cu","localStorage","currentUser","onUploadProgress","upload","onprogress","pe","content","File","fetch","r","query","collection","_method","where","limit","skip","include","join","select","order","sort","count","results","aggregate","grouping","k","_g","_id","encodeURIComponent","objectId","res","distinct","property","excludeKeys","create","ACL","acl","_obj","increment","properties","__op","amount","save","createdAt","updatedAt","delete","addRelation","_content","objects","__type","targetObjectId","targetClass","removeRelation","uploadFile","file","contentType","err","deleteFile","_toJSON","obj","items","m","schema","_type","instanceOf","iso","toISOString","cloudFile","exists","latitude","Number","longitude","a","_isArrayOfObjects","_class","_instance","_cloudStore","defineProperty","invalidateCollections","ConfigService","cacheDuration","_getConfig","config","configCachePending","configCache","now","ttl","clearCache","_value","v","convertVisualFilter","queryParameters","combinator","rules","_res","_op","cond","operator","input","$relatedTo","relatedTo","relationProperty","$exists","$gt","$gte","$lt","$lte","$eq","$ne","$regex","$options","compareObjects","b","_s","prop","matchesQuery","match","q","convertVisualSorting","sorting","s","convertFilterOp","$in","modelId","relationKey","opAndValue","$nin","_v","$text","$search","$term","$caseSensitive","term","$language","language","caseSensitive","$diacriticSensitive","diacriticSensitive","$nearSphere","$maxDistanceInMiles","$maxDistanceInKilometers","maxDistanceInKilometers","$maxDistanceInRadians","maxDistanceInRadians","$within","$box","gp","$geoWithin","$polygon","QueryUtils","_cloudstore","cloudstore","_results","objectOrId","record","notify","recordId","targetRecordId","targetRecord","targetClassName","poolLimit","iteratorFn","ret","executing","race","all","enumerable","writable","src","bItems","aItems","aKeys","keyIndex","bKeys","removeAtIndex","min","remove","addAtIndex","_listeners","l","contains","idx","listener","collections","guid","createSetter","currentValue","currentWarnings","setWarning","nodeId","warning","warningKeys","clearWarning","clearWarnings","EventSender","ActiveWarnings","opts","_opts","ws","WebSocket","wsOptions","reconnectOnClose","enableDebugger","lastSendTimestamp","sendQueue","sendTimer","activeWarnings","document","hostname","socket","addEventListener","clientId","cmd","reconnect","console","log","code","reason","evt","text","target","debugInspectorsEnabled","inspectors","connectionId","pubsub","routeMessage","isConnected","OPEN","dt","trySend","msg","seen","WeakSet","getCircularReplacer","chunk","sendInspectId","sendSelectComponent","componentName","sendPulsingConnections","connectionMap","connectionsToPulse","connection","connections","sendDebugInspectorValues","sendConnectionValue","dynamicPortsHash","hash","detectRenamed","renamed","d","before","after","prefix","_detectRename","patterns","nodeid","sendWarning","sendPatches","patches","requestFullExport","requestNoodlModules","serviceRequests","sendServiceRequest","token","close","nodelibrary","sendComponentMetadata","sendProjectMetadata","array1","array2","valueSet","Set","applyPortDelta","nodeModel","newPorts","inputPorts","outputPorts","port","existingInputs","getInputPorts","inputPortsToRemove","inputPortsToAdd","updateInputPortTypes","removeInputPortWithName","portName","addInputPort","setInputValueOnNodeInstancesWithModel","updateOutputPortTypes","existingOutputs","getOutputPorts","outputPortsToRemove","outputPortsToAdd","removeOutputPortWithName","addOutputPort","getNodesWithIdRecursive","queueInput","getComponentWithName","eventHandlers","nodeAdded","importEditorNodeData","parentId","childIndex","nodeRemoved","hasNodeWithId","removeNodeWithId","connectionAdded","addConnection","connectionRemoved","removeConnection","targetNodeModel","getNodeWithId","targetId","getConnectionsToPort","targetPort","getDefaultValueForInput","parameterChanged","allParams","oldParameters","param","setParameter","parameterName","parameterValue","state","nodeAttached","setNodeParent","nodeDetached","addRootId","componentAdded","importComponentFromEditorData","componentRemoved","removeComponentWithName","rootAdded","portAdded","portRemoved","nodePortRenamed","renameInputPortOnNodeWithId","oldName","renameOutputPortOnNodeWithId","componentInstance","componentPortsUpdated","instancePortsChanged","componentRenamed","renameComponent","newName","settingsChanged","setSettings","metadataChanged","setMetaData","componentMetadataChanged","setMetadata","variantParametersChanged","variant","updateVariant","updateVariantParameter","variantName","variantTypeName","getVariant","getAllNodesWithVariantRecursive","getParameter","variantDeleted","deleteVariant","variantChanged","setVariant","variantRenamed","oldVariantName","defaultStateTransitionChanged","setDefaultStateTransition","curve","stateTransitionsChanged","setStateTransitionParamter","variantDefaultStateTransitionChanged","updateVariantDefaultStateTransition","variantStateTransitionsChanged","updateVariantStateTransition","routerIndexChanged","routerIndex","ReflectOwnKeys","R","Reflect","ReflectApply","receiver","ownKeys","getOwnPropertySymbols","getOwnPropertyNames","NumberIsNaN","isNaN","init","once","emitter","errorListener","removeListener","resolver","eventTargetAgnosticAddListener","handler","flags","addErrorHandlerIfEventEmitter","_events","_eventsCount","_maxListeners","defaultMaxListeners","checkListener","TypeError","_getMaxListeners","that","_addListener","prepend","existing","newListener","unshift","warned","w","String","warn","onceWrapper","fired","wrapFn","_onceWrap","wrapped","unwrap","evlistener","arr","unwrapListeners","arrayClone","listenerCount","n","copy","wrapListener","arg","removeEventListener","RangeError","getPrototypeOf","getMaxListeners","doError","er","len","listeners","addListener","prependListener","prependOnceListener","list","position","originalListener","shift","spliceOne","removeAllListeners","rawListeners","eventNames","listenersWithRefs","eventName","ref","callbacks","s4","floor","getAbsoluteUrl","userFunctionsCache","JavascriptNodeParser","_initializeAPIs","userCode","getCodePrefix","define","script","apis","getComponentScopeForNode","_afterSourced","userObject","change","run","destroy","definedObject","_userObjectExtended","_this","_extended","setOutputs","states","old","_oldInputs","changed","changedFunction","signals","_scriptExtend","Inputs","Outputs","Signals","Setters","_Node","_outputs","OnInit","OnDestroy","destory","changedInputs","OnInputsChanged","createFromCode","createFromURL","window","DONE","onerror","parseAndAddPortsFromScript","_addPortsFromMatch","unique","find","skipInputs","matchAll","inputType","inputGroup","inputPrefix","skipOutputs","skipOutputSignals","outputPrefix","skipRegularOutputs","getPorts","inputPort","_componentScopes","componentId","componentOwner","getInstanceId","componentObject","parentComponentObjectId","parent","getParentComponent","getRoots","getVisualParentNode","parentNodeScope","_findParentComponentStateModelId","parentComponentObject","ParentObject","RepeaterObject","_forEachModel","_findForEachModel","createNoodlAPI","Noodl","models","_models","proxies","_modelProxyHandler","getOwnPropertyDescriptor","_randomString","size","chars","Proxy","modelData","setAll","fill","temp","forceChange","oldValue","silent","toJSON","NodeModel","ComponentModel","roots","metadata","addNode","getAllNodes","findIndex","con","sourceId","sourcePort","getConnectionsFromPort","sourcePortName","targetPortName","getConnectionsFrom","getConnectionsTo","rootId","removeRootId","children","child","getAllConnections","getInputPort","getOutputPort","childModel","newParentModel","removeChild","addChild","nodeData","createFromExportData","rename","getMetadata","componentData","addComponent","getBundleContainingComponent","componentToBundleMap","getBundlesContainingSheet","sheetName","bundles","isOnDefaultSheet","from","getBundleDependencies","bundleName","recurse","bundle","dep","dependencies","variants","setAllMetaData","setRootComponentName","componentNames","hasComponentWithName","getAllComponents","_addComponentPorts","_onNodeAdded","_onNodeRemoved","_onNodeWasRemoved","getVariants","typename","stateParameters","transition","defaultStateTransitions","stateTransitions","setParameters","setStateParameters","setStateTransitions","parameter","stateTransition","OutputProperty","_dirty","_inputs","_inputValues","_inputConnections","_outputList","_isUpdating","_inputValuesQueue","_afterInputsHaveUpdatedCallbacks","_signalsSentThisUpdate","_deleted","_deleteListeners","_isFirstUpdate","_valuesFromConnections","updateOnDirtyFlagging","getInputValue","units","defaultUnit","deregisterInput","registerInputs","getInput","setInputValue","currentInputValue","unit","newValue","styles","resolveColor","eval","showGlobally","output","newOutput","owner","onFirstConnectionAdded","onLastConnectionRemoved","deregisterOutput","hasConnections","registerOutputs","getOutput","connectInput","inputName","sourceNode","registerConnection","_setValueFromConnection","outputValue","connectionSentValue","flagDirty","removeInputConnection","sourceNodeId","inputsToPort","deregisterConnection","isInputConnected","some","_updatedAtIteration","updateIteration","_updateIteration","_cyclicLoop","_updateDependencies","inputNames","hasMoreInputs","queue","afterInputCallbacks","scheduleNextFrame","nodeIsDirty","_cyclicWarningSent","isWarningTypeEnabled","connectedPorts","_performDirtyUpdate","flagDependeesDirty","sendValue","flagAllOutputsDirty","outputName","scheduleAfterInputsHaveUpdated","connectionSentSignal","_hasInputBeenSetFromAConnection","queueValue","setNodeModel","_onNodeModelParameterUpdated","_onNodeModelVariantUpdated","addDeleteListener","deleteListener","_getVisualStates","defaultValue","_resetReactVirtualDOM","NodeRegister","TimerScheduler","Variants","_dirtyNodes","callbacksAfterUpdate","eventSenderEmitter","globalValues","globalsEventEmitter","timerScheduler","componentModels","connectionsToPulseChanged","debugInspectors","connectionPulsingCallbackScheduled","_outputHistory","_signalHistory","warningTypes","bundleFetchesInFlight","getNodeScope","onDebugInspectorsUpdated","inspector","fromId","fromProperty","updateDirtyNodes","loop","iterations","isUpdating","dirtyNodes","stack","hasPendingTimers","runTimers","runningTimers","newTimers","clearDebugInspectors","scheduleAfterUpdate","setGlobalValue","getGlobalValue","fetchBundle","bundleUrl","Env","promise","getComponentModel","bundleDep","hasComponentModelWithName","extraProps","setComponentModel","_formatConnectionValue","HTMLElement","tagName","timestamp","inputPortName","clearOldConnectionPulsing","_getDebugInspectorValueForNode","getInspectInfo","info","valuesToSend","inspectorValue","sendGlobalEventFromEventSender","channelName","inputValues","setPopupCallbacks","onShow","onClose","onShowPopup","onClosePopup","showPopup","popupComponent","popupNode","createNode","inputKey","popupParent","senderNode","createPrimitiveNode","bodyScroll","closePopupNodes","j","_setCloseCallback","action","deleteNode","requestAnimationFrame","setWarningTypes","nodeType","hasNode","inputMetadata","getNodeMetadata","registerNumberedInput","oldRegisterInputIfNeeded","exportDynamicPorts","allowChildren","allowChildrenWithCategory","allowAsChild","visualStates","panels","usePortAsLabel","portLabelTruncationMode","deprecated","haveComponentPorts","version","nodeDoubleClickAction","searchTags","prototypeExtensions","NodeConstructor","setUnitType","editorName","exportToEditor","inputPriority","tooltip","tab","popout","allowVisualStates","allowConnectionsOnly","registerOutputsMetadata","propName","nodeScopeDidInitialize","defaultValues","inputsMetadata","numberedInputs","registerNumberedInputs","updatePorts","portNames","numPorts","displayPrefix","collectPorts","flat","registerSetupFunctionForNumberedInputs","extend","obj1","obj2","oldInit","formatPort","portData","plugType","description","typecasts","to","colors","base","baseHighlighted","header","headerHighlighted","outline","outlineHighlighted","visual","javascript","signal","normal","highlighted","pulsing","nodetypes","shortDesc","haveComponentChildren","nodeTypes","_constructors","nodeMetadata","nodeObj","shortDocs","dp","template","channelPort","dynamicPortGroup","formatDynamicPorts","selectorNames","conditionalPortNames","nodeIndex","coreNodes","subCategories","moduleNodes","getInputType","title","canArrangeInGroups","hidden","NodeScope","componentIdCounter","ComponentInstanceNode","childRoot","componentOutputValues","componentOutputs","componentInputs","instanceId","registerComponentInputPort","registerComponentOutputPort","forceUpdate","removeNodesWithId","componentInput","setOutputFromComponentOutput","creatorCallbacks","onOutputChanged","setChildRoot","prevChildRoot","newChildRoot","isChild","getChildRootIndex","getChildRoot","triggerDidMount","render","setChildIndex","getChildren","componentOutput","getRef","cachedChildren","AndNode","and","currentSelectedIndex","indexChanged","trueString","falseString","currentInput","inputChanged","ConditionNode","scheduleEvaluate","ontrue","onfalse","isfalse","CounterNode","startValue","startValueSet","limitsEnabled","limitsMin","limitsMax","increase","decrease","currentCount","countChanged","CloudFileNode","DbCollectionNode","collectionChangedScheduled","collectionChangedCallback","cloudStoreEvents","currentQuery","_addModelAtCorrectIndex","storageSettings","firstItemId","firstItem","fetched","failure","setCollectionName","scheduleFetch","setCollection","bindCollection","unbindCurrentCollection","setError","internal","fetchScheduled","_c","getStorageFilter","getStorageLimit","getStorageSkip","getStorageFetchTotalCount","storageTotalCount","visualFilter","visualSorting","filterFunc","filterCode","filterVariables","_filter","_sort","_filterCb","filterFuncArgs","userOutputGetter","setVisualFilter","setVisualSorting","setQueryParameter","dynamicSignals","storageFetch","dynamicSetters","visualSort","userInputSetter","dbCollections","systemCollections","_findRelations","relations","uniqueInputs","_collectInputs","codeeditor","variables","ConfigNodeDefinition","useDevValue","devValue","configKey","setInternal","configSchema","valueType","isCloud","masterKeyOnly","addInputProperties","def","_def","_methods","_setInputValue","addModelId","_includeInputs","includeInputs","_includeOutputs","includeOutputs","idSource","setModel","identifierOf","identifierDisplayName","setModelID","setCollectionID","collectionId","addBaseInfo","_includeInputProperties","includeInputProperties","_includeRelations","includeRelations","scheduleOnce","cb","checkWarningsBeforeCloudOp","props","_typeMap","Boolean","_p","_additionalDynamicPorts","addRelationProperty","targetModelId","setRelationProperty","addAccessControl","accessControl","autoName","accessControlRules","_super","ac","parentItemId","setAccessControl","_getACL","_rule","rule","read","write","currentUserId","UserId","cu","_getCurrentUser","userid","role","_parts","DbModelCRUDBase","AddDbModelRelationNodeDefinition","store","scheduleAddRelation","relationAdded","validateInputs","_warning","_key","scheduleRemoveRelation","relationRemoved","ModelNodeDefinition","relationModelIds","onModelChangedCallback","scheduleStore","DeleteDbModelPropertiedNodeDefinition","storageDelete","deleted","ModelScope","FilterDBModelsNode","scheduleFilter","filterSettings","filterParameters","filteredCollection","modified","getLimit","getSkip","filtered","setFilterParameter","_supportedTypes","Pointer","_addBaseInfo","_addModelId","_addInputProperties","_types","inputTypes","_pushInputValues","_defaultValueForType","boolean","string","number","date","_allKeys","validProperties","keysToSet","hasScheduledStore","_setInputType","dirtyValues","scheduleSetModel","hasScheduledSetModel","NewDbModelPropertiedNodeDefinition","storageInsert","sourceObjectId","created","initValues","ModelCRUDBase","NewModelNodeDefinition","new","scheduleNew","hasScheduledNew","newModel","RestNode","outputValues","outputValuesProxy","inspectData","resource","requestScript","requestFunc","responseScript","responseFunc","cancel","cancelFetch","canceled","getScriptOutputValue","setScriptInputValue","hasScheduledFetch","doFetch","doResponse","doExternalFetch","_xhr","sentResponse","responseType","getResponseHeader","rawResponse","responseData","toLowerCase","onabort","raw","abort","_parseScriptForErrors","_exists","scriptWithoutComments","SetDbModelPropertiedNodeDefinition","storeType","scheduleSave","storeProperties","stored","SetModelPropertiedNodeDefinition","DateToStringNode","formatString","_format","dateString","onError","t","format","getDate","month","getMonth","monthShort","Intl","DateTimeFormat","year","getFullYear","yearShort","hours","getHours","minutes","getMinutes","seconds","getSeconds","ExpressionNode","focusPort","scope","hasScheduledEvaluation","cachedValue","currentExpression","compiledFunction","expression","functionPreamble","newInputs","parsePorts","inputsToAdd","inputsToRemove","_scheduleEvaluateExpression","isTrue","isFalse","isTrueEv","isFalseEv","lastValue","_calculateExpression","_compileFunction","inputValue","compiledFunctionsCache","F","construct","portsToIgnore","addPort","identifiers","editAsType","evalCompileWarnings","invert","InverterNode","OrNode","RunTasksDefinition","queuedOperations","maxRunningTasks","activeTasks","stopOnFailure","taskTemplate","scheduleRun","scheduleAbort","done","aborted","hasScheduledRun","_queueOperation","hasScheduledAbort","itemNode","_forEachNode","_isInputConnected","itemOutputSignalTriggered","task","taskComponent","createTaskComponent","runningTasks","numTasks","failedTasks","completedTasks","queuedTasks","startTask","checkDone","op","_runQueueOperations","runningOperations","_deleteAllTasks","logJavaScriptNodeError","SimpleJavascriptNode","scriptInputs","scriptOutputs","functionScript","parseScript","runScheduled","runScript","_isSignalType","_sendSignal","setScriptInputType","setScriptOutputType","outputTypes","AsyncFunction","inputTypeEnums","_outputTypeEnums","_parseScriptForErrorsAndPorts","ev","StringFormatDefinition","cachedResult","resultDirty","formatValue","multiline","scheduleFormat","formatted","matches","formatScheduled","StringMapperNode","mappings","mappedString","scheduleMapping","inputString","currentInputString","defaultMapping","doMapping","startIndex","endIndex","end","substr","UniqueIdNode","SetUserPropertiesNodeDefinition","email","username","storeScheduled","setUserProperties","setUserProperty","_ignoreKeys","UserNodeDefinition","userService","setUserModel","getUserProperty","BooleanNode","createDefinition","cast","NumberNode","VariableBase","StringNode","onChanged","latestValue","setValueTo","saveValue","savedValue","componentInstanceChildren","connectionData","targetNode","setNodeParameters","inputA","inputB","createNodeFromModel","insertNodeInTree","parentInstance","nodeInstance","findNodesWithIdRec","getAllNodesRecursive","getAllNodesRec","onNodeModelRemoved","connectionModel","conn","connectionFrom","connectionTo","sendEventFromThisScope","propagation","sendEventInThisScope","_exclude","eventReceivers","eventReceiver","getChannelName","defineProperties","_lastUpdateIteration","valuesSendThisIteration","modules","addModuleSettings","Timer","scheduler","duration","_isRunning","_hasCalledOnStart","repeatCount","delay","requestFrameCallback","requestFrame","stop","scheduleTimer","stopTimer","_wasStopped","isRunning","durationLeft","_durationLeft","createTimer","timer","onStop","currentTime","remainingTimers","finishedTimers","timersThisFrame","_start","onStart","localT","onRunning","onFinish","_url","baseUrl","onVariantUpdated","nodesWithVariant","files","fileName","RecordsAPI","Records","api","password","logIn","user","users","equalTo","pointsTo","expiresAt","greaterThan","installationId","sessions","_fetchUser","fetchUser","restricted","Properties","AggregateNode","aggregates","aggregateValues","aggregatesList","validateAggNames","getAggregates","classSchema","defs","aggs","propSchema","getAggregateValue","setAggregateParameter","_name","componentScope","Variables","Users","Files","Objects","cs","ok","propsToSave","_user","_userService","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","__esModule","definition","globalThis","_runner","CloudRunner","ipcRenderer","eventQueue","hasScheduledProcessJobs","_noodl_process_jobs","_setImmediate","_fetch_response_handlers","_fetch","cloudService","function","handleRequest","sender"],"sourceRoot":""} \ No newline at end of file diff --git a/packages/noodl-editor/src/external/deploy/index.html b/packages/noodl-editor/src/external/deploy/index.html new file mode 100644 index 0000000..f67481d --- /dev/null +++ b/packages/noodl-editor/src/external/deploy/index.html @@ -0,0 +1,74 @@ + + + + + + + + + {{#title#}} +{{#customHeadCode#}} + + + + + + +
+ + + + + <%modules_dependencies%> + <%index_js%> + + <%modules_main%> + + + + + \ No newline at end of file diff --git a/packages/noodl-editor/src/external/deploy/index.js b/packages/noodl-editor/src/external/deploy/index.js new file mode 100644 index 0000000..76a67ae --- /dev/null +++ b/packages/noodl-editor/src/external/deploy/index.js @@ -0,0 +1,10 @@ +window.__noodl_modules = []; +window.Noodl = { + defineModule:function(m) { + window.__noodl_modules.push(m); + }, + deployed: true, + Env: {} +} + +window.projectData = {{#export#}}; diff --git a/packages/noodl-editor/src/external/deploy/index.json b/packages/noodl-editor/src/external/deploy/index.json new file mode 100644 index 0000000..66947b6 --- /dev/null +++ b/packages/noodl-editor/src/external/deploy/index.json @@ -0,0 +1,10 @@ +[ + {"url":"index.html", "injectHTML": true}, + {"url":"index.js", "injectExport": true}, + {"url":"noodl-app.png"}, + {"url":"load_terminator.js"}, + {"url":"noodl.deploy.js"}, + {"url":"noodl.deploy.js.map"}, + {"url":"react.production.min.js"}, + {"url":"react-dom.production.min.js"} +] diff --git a/packages/noodl-editor/src/external/deploy/load_terminator.js b/packages/noodl-editor/src/external/deploy/load_terminator.js new file mode 100644 index 0000000..04f71b9 --- /dev/null +++ b/packages/noodl-editor/src/external/deploy/load_terminator.js @@ -0,0 +1 @@ +// Empty file, used to know when script elements are fully loaded diff --git a/packages/noodl-editor/src/external/deploy/noodl-app.png b/packages/noodl-editor/src/external/deploy/noodl-app.png new file mode 100644 index 0000000000000000000000000000000000000000..9cc8a494c35281a5a9ce8376854da880b19c907b GIT binary patch literal 10346 zcmch72|QH)*T4EEd*W*=l`&LgnZ@i`GK;0`BuiwN!PrJKV<%Y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^hAAuB~B=BE78(MWXTret-cheM3$UJ^Z+W^mbk`;$~;|^_(o`k zaxSM$>^yn*^{dC6Psj$Y{j_zHmD!sqiEr;d_Y|!;6n=NrD&Yr~wtR+T)+7e#VCU-Q zsm2kRnZ}mT{1EQ~sp#yftWrhMUf+#DW1shEf2u0}boHY)B}%2X#_;{t_i}s{g-1WM z20-dG!VcCpZerOQ*qpOD>L%j5Q_m0sxg_%p@Q`UfYz&oO*Dj#B`jAZ0bDyH5^Nv~2 zyctsKi-$UmJA|yAu2~z~Rq@3gk)-wv4Nl{0-mckvGU>fZe6P0gNS#@T7onz9dg@Hj zbH5EXaKy$aN@fuf+xv9iM$6pYuhIf^9q(~Gm#=zvWLw?1eP?#JpU9>!qzfYmvoy%j zU%ZeS$qv$@{bNs}8JBd(vlAidorB9}8#j89WAadSM9EH5>l;5} zFhws691>d+=JZ#qdS}If!t(oWb=PJEF?75p_?RX$Y+a00*{Ept5fO1oO#iK$j@h?W zZaZeI5a@#quTG(4BoHf_L#QnK`e@Et@YhV~wH5bI!-j~Ad&XME5|Y?N^BXIxp0^yE z@%j+JF{5Ao^6_Dzu3Yy>lMj`|37g%w&QrGVO5jApxPy7ycd=rcJ-6Ca+2_TVR4H2b zT!c!U4^s^hV4ad}+_|Txf=ky=?xe^%x$WXNpOUW<$_Rtmo7_6|!sT~fI>mQ!*SiA} zNBwQL8v|;H$k}`uKmh^7k~ysekVO_05c%(mfP%8H2*@hJKNo+KRp!m#3(i7HIa{var __webpack_modules__={260:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Collection:()=>Collection,ComponentModel:()=>ComponentModel,EditorConnection:()=>EditorConnection,GraphModel:()=>GraphModel,JavascriptNodeParser:()=>JavascriptNodeParser,Model:()=>Model,ModelScope:()=>ModelScope,Node:()=>Node$1,NodeContext:()=>NodeContext,NodeModel:()=>NodeModel,NodeScope:()=>NodeScope,Services:()=>Services,TimerScheduler:()=>TimerScheduler,createRecordsAPI:()=>createRecordsAPI,createSetter:()=>createSetter,default:()=>NoodlRuntime$1,defineNode:()=>defineNode,extend:()=>extend,getAbsoluteUrl:()=>getAbsoluteUrl,guid:()=>guid,logJavaScriptNodeError:()=>logJavaScriptNodeError,randomString:()=>randomString});var eventemitter3__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6822),lodash_difference__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(8779),lodash_difference__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(lodash_difference__WEBPACK_IMPORTED_MODULE_1__);class NodeRegister{constructor(e){this._constructors={},this.context=e}register(e){const t=e.metadata.name;this._constructors[t]=e}createNode(e,t,n){if(!this._constructors.hasOwnProperty(e))throw new Error("Unknown node type with name "+e);return this._constructors[e](this.context,t,n)}getNodeMetadata(e){if(!this._constructors.hasOwnProperty(e))throw new Error("Unknown node type with name "+e);return this._constructors[e].metadata}hasNode(e){return this._constructors.hasOwnProperty(e)}getInputType(e,t){var n,o;return null===(o=null===(n=this.getNodeMetadata(e).inputs)||void 0===n?void 0:n[t])||void 0===o?void 0:o.type}}class Timer{constructor(e,t){this._hasCalledOnStart=!1,this._wasStopped=!1,this._start=0,this._durationLeft=0,this.duration=t.duration||0,this._isRunning=!1,this._hasCalledOnStart=!1,this.scheduler=e,this.repeatCount=1,this.delay=0;for(const e in t)this[e]=t[e]}start(){return this._isRunning&&this.stop(),this.scheduler.scheduleTimer(this),this}stop(){this.scheduler.stopTimer(this),this._hasCalledOnStart=!1,this._isRunning=!1,this._wasStopped=!0}isRunning(){return this._isRunning}durationLeft(){return this._durationLeft}}class TimerScheduler{constructor(e){this.requestFrame=e,this.runningTimers=[],this.newTimers=[]}createTimer(e){return new Timer(this,e)}scheduleTimer(e){-1===this.newTimers.indexOf(e)&&(0===e.repeatCount&&(e.repeatCount=1e5),this.newTimers.push(e),this.requestFrame())}stopTimer(e){let t;e._isRunning?(t=this.runningTimers.indexOf(e),-1!==t&&this.runningTimers.splice(t,1),e.onStop&&!e._wasStopped&&e.onStop()):(t=this.newTimers.indexOf(e),-1!==t&&this.newTimers.splice(t,1))}runTimers(e){var t,n;const o=[],i=[],s=[];let r;const a=this.runningTimers.length;let l;for(r=0;r=l._start){let t;!1===l._hasCalledOnStart&&l.onStart&&(l.onStart(),l._hasCalledOnStart=!0),t=l.duration>0?(e-l._start)/(l.duration*l.repeatCount):1,l._durationLeft=l.duration*(1-t);let n=t*l.repeatCount-Math.floor(t*l.repeatCount);t>=1&&(n=1),l.onRunning&&l.onRunning(n),t<1&&l._isRunning?o.push(l):l._wasStopped||i.push(l)}else o.push(l);for(this.runningTimers=o,r=0;r0){for(r=0;r0||this.newTimers.length>0}}class Variants{constructor({graphModel:e,getNodeScope:t}){this.getNodeScope=t,e&&(this.graphModel=e,e.on("variantUpdated",(e=>this.onVariantUpdated(e))))}getVariant(e,t){if(this.graphModel&&t)return this.graphModel.getVariant(e,t)}onVariantUpdated(e){const t=this.getNodeScope();if(!t)return;const n=t.getNodesWithTypeRecursive(e.typename).filter((t=>"object"==typeof t.variant?t.variant.name===e.name:"string"==typeof t.variant?t.variant===e.name:t.model&&t.model.variant===e.name));for(const t of n)t.setVariant(e)}}class OutputProperty{constructor(e){if(this.valuesSendThisIteration=0,!e.owner)throw new Error("Owner must be set");this.getter=e.getter||(()=>{}),this.connections=[],this._owner=e.owner,this._name=e.name,this.onFirstConnectionAdded=e.onFirstConnectionAdded,this.onLastConnectionRemoved=e.onLastConnectionRemoved}get name(){return this._name}get owner(){return this._owner}get value(){return this.getter.call(this.owner)}get id(){return this._id||(this._id=this.owner.id+this.name),this._id}registerConnection(e,t){this.connections.push({node:e,inputPortName:t}),1===this.connections.length&&this.onFirstConnectionAdded&&this.onFirstConnectionAdded.call(this.owner)}deregisterConnection(e,t){for(let n=0;n500&&(this.owner._cyclicLoop=!0);for(let t=0,n=this.connections.length;t0}}class Node$1{constructor(e,t){this.updateOnDirtyFlagging=!0,this.children=[],this._internal={},this._dirty=!1,this._inputs={},this._inputValues={},this._outputs={},this._inputConnections={},this._outputList=[],this._isUpdating=!1,this._inputValuesQueue={},this._afterInputsHaveUpdatedCallbacks=[],this._signalsSentThisUpdate={},this._deleted=!1,this._deleteListeners=[],this._isFirstUpdate=!0,this._valuesFromConnections={},this._updateIteration=0,this.id=t,this.context=e}getInputValue(e){return this._inputValues[e]}registerInput(e,t){var n;if(this.hasInput(e))throw new Error("Input property "+e+" already registered");if(this._inputs[e]=t,t.type&&"object"==typeof t.type&&"units"in t.type){const o=t.type.defaultUnit||(null===(n=t.type.units)||void 0===n?void 0:n[0])||"";this._inputValues[e]={value:t.default,type:o}}else t.hasOwnProperty("default")&&(this._inputValues[e]=t.default)}deregisterInput(e){if(!1===this.hasInput(e))throw new Error("Input property "+e+" doesn't exist");delete this._inputs[e],delete this._inputValues[e]}registerInputs(e){for(const t in e)this.registerInput(t,e[t])}getInput(e){if(!1!==this.hasInput(e))return this._inputs[e];console.log("Node "+this.name+": Invalid input property "+e)}hasInput(e){return e in this._inputs}registerInputIfNeeded(e){}setInputValue(name,value){var _a,_b,_c,_d,_e;const input=this.getInput(name);if(input){if("object"==typeof input.type&&"array"===input.type.name&&"string"==typeof value)try{const e=JSON.parse(value);input.set.call(this,e),input.value=e,this._inputValues[name]=e}catch(e){}else input.set.call(this,value),input.value=value,this._inputValues[name]=value;if("color"===input.type&&this.context&&this.context.styles)value=this.context.styles.resolveColor(value);else if("array"===input.type&&"string"==typeof value)try{value=eval(value),null===(_a=this.context.editorConnection)||void 0===_a||_a.clearWarning(null===(_c=null===(_b=this.nodeScope)||void 0===_b?void 0:_b.componentOwner)||void 0===_c?void 0:_c.name,this.id,"invalid-array-"+name)}catch(e){const t=e;value=[],console.log(e),this.context.editorConnection&&this.context.editorConnection.sendWarning(null===(_e=null===(_d=this.nodeScope)||void 0===_d?void 0:_d.componentOwner)||void 0===_e?void 0:_e.name,this.id,"invalid-array-"+name,{showGlobally:!0,message:"Invalid array
"+t.toString()})}input.set.call(this,value)}else console.log("node doesn't have input",name)}hasOutput(e){return e in this._outputs}registerOutput(e,t){if(this.hasOutput(e))throw new Error("Output property "+e+" already registered");const n=new OutputProperty({owner:this,getter:t.get||t.getter,name:e,onFirstConnectionAdded:t.onFirstConnectionAdded,onLastConnectionRemoved:t.onLastConnectionRemoved});this._outputs[e]=n,this._outputList.push(n)}deregisterOutput(e){if(!1===this.hasOutput(e))throw new Error("Output property "+e+" isn't registered");const t=this._outputs[e];if(t.hasConnections())throw new Error("Output property "+e+" has connections and can't be removed");delete this._outputs[e];const n=this._outputList.indexOf(t);this._outputList.splice(n,1)}registerOutputs(e){for(const t in e)this.registerOutput(t,e[t])}registerOutputIfNeeded(){}getOutput(e){if(!1===this.hasOutput(e))throw new Error("Node "+this.name+" doesn't have a port named "+e);return this._outputs[e]}connectInput(e,t,n){if(!1===this.hasInput(e))throw new Error("Invalid connection, input doesn't exist. Trying to connect from "+t.name+" output "+n+" to "+this.name+" input "+e);const o=t.getOutput(n);if(o.registerConnection(this,e),this._inputConnections[e]||(this._inputConnections[e]=[]),this._inputConnections[e].push(o),t._signalsSentThisUpdate[n])this._setValueFromConnection(e,!0),this._setValueFromConnection(e,!1);else{const t=o.value;void 0!==t&&(this._setValueFromConnection(e,t),this.context&&this.context.connectionSentValue(o,o.value))}this.flagDirty()}removeInputConnection(e,t,n){if(!this._inputConnections[e])throw new Error("Node removeInputConnection: Input doesn't exist");const o=this._inputConnections[e];for(let i=0;i{var t;if("Component Inputs"!==e.owner.name)return!0;const n=null===(t=e.owner.nodeScope)||void 0===t?void 0:t.componentOwner;return null==n?void 0:n.isInputConnected(e.name)}))}update(){var e,t,n,o;if(!this._isUpdating&&!1!==this._dirty){this._updatedAtIteration!==this.context.updateIteration&&(this._updatedAtIteration=this.context.updateIteration,this._updateIteration=0,this._cyclicLoop&&(this._cyclicLoop=!1)),this._isUpdating=!0;try{for(;this._dirty&&!this._cyclicLoop;){this._updateDependencies(),this._dirty=!1;const e=Object.keys(this._inputValuesQueue);let t=!0;for(;t&&!this._cyclicLoop;){t=!1;for(let n=0;n0&&(this.setInputValue(o,i.shift()),i.length>0&&(t=!0))}const n=this._afterInputsHaveUpdatedCallbacks;this._afterInputsHaveUpdatedCallbacks=[];for(let e=0;e=100&&(this._cyclicLoop=!0)}}catch(e){throw this._isUpdating=!1,e}this._cyclicLoop&&(this.context.scheduleNextFrame((()=>{this.context.nodeIsDirty(this)})),this.context.editorConnection&&!this._cyclicWarningSent&&this.context.isWarningTypeEnabled("cyclicLoops")&&(this.context.editorConnection.sendWarning(null===(t=null===(e=this.nodeScope)||void 0===e?void 0:e.componentOwner)||void 0===t?void 0:t.name,this.id,"cyclic-loop",{showGlobally:!0,message:"Cyclic loop detected"}),this._cyclicWarningSent=!0,console.log("cycle detected",{id:this.id,name:this.name,component:null===(o=null===(n=this.nodeScope)||void 0===n?void 0:n.componentOwner)||void 0===o?void 0:o.name}))),this._isFirstUpdate=!1,this._isUpdating=!1}}_updateDependencies(){for(const e in this._inputConnections){const t=this._inputConnections[e];for(let e=0;e{this.hasInput(e.name)&&this.deregisterInput(e.name)}),this),e.on("outputPortRemoved",(e=>{this.hasOutput(e.name)&&this.deregisterOutput(e.name)}),this)}addDeleteListener(e){this._deleteListeners.push(e)}_onNodeDeleted(){this.model&&(this.model.removeListenersWithRef(this),this.model=void 0),this._deleted=!0;for(const e of this._deleteListeners)e.call(this)}_onNodeModelParameterUpdated(e){var t;if(this.registerInputIfNeeded(e.name),void 0!==e.value)if(e.state){if(!this._getVisualStates)return void console.log("Node has nos visual states, but got a parameter for state",e.state);-1!==this._getVisualStates().indexOf(e.state)&&this.queueInput(e.name,e.value)}else this.queueInput(e.name,e.value);else{let n;const o=this.variant;"object"==typeof o&&(e.state?o&&o.stateParameters.hasOwnProperty(e.state)&&o.stateParameters[e.state].hasOwnProperty(e.name)?n=o.stateParameters[e.state][e.name]:(null===(t=this.model)||void 0===t?void 0:t.parameters.hasOwnProperty(e.name))?n=this.model.parameters[e.name]:o&&o.parameters.hasOwnProperty(e.name)&&(n=o.parameters[e.name]):o&&o.parameters.hasOwnProperty(e.name)&&(n=o.parameters[e.name])),void 0===n&&(n=this.context.getDefaultValueForInput(this.model.type,e.name),this._resetReactVirtualDOM&&this._resetReactVirtualDOM()),this.queueInput(e.name,n)}}_onNodeModelVariantUpdated(e){this.setVariant(e)}setVariant(e){this.variant=e}}function getAbsoluteUrl(e){if(null==e||""===e)return window.Noodl.baseUrl||"/";const t=String(e);return!t||"/"===t[0]||t.includes("://")||t.startsWith("data:")?t:(window.Noodl.baseUrl||"/")+t}function logJavaScriptNodeError(e){"string"==typeof e?console.log("Error in JS node run code.",e):e instanceof Error&&console.log("Error in JS node run code.",Object.getPrototypeOf(e).constructor.name+": "+e.message,e.stack)}function guid(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}function randomString(e){if(0===e)throw new Error("Zero-length randomString is useless.");let t="";for(let n=0;n{if(!e[t])throw new Error("Missing "+t)}))}addConnection(e){try{this.verifyData(e,["sourceId","sourcePort","targetId","targetPort"])}catch(e){throw new Error("Error in connection: "+e.message)}try{const t=this.getNodeWithId(e.sourceId),n=this.getNodeWithId(e.targetId);n.registerInputIfNeeded(e.targetPort),t.registerOutputIfNeeded(e.sourcePort),n.connectInput(e.targetPort,t,e.sourcePort)}catch(e){console.error(e.message)}}setNodeParameters(e,t){const n=this.context.variants.getVariant(t.type,t.variant);if(n)e.setVariant(n);else{const n=t.parameters||{};let o=Object.keys(n);if(this.context.nodeRegister.hasNode(e.name)){const t=this.context.nodeRegister.getNodeMetadata(e.name);t.inputs&&o.sort(((e,n)=>{var o,i;const s=t.inputs[e],r=t.inputs[n];return(null!==(o=null==r?void 0:r.inputPriority)&&void 0!==o?o:0)-(null!==(i=null==s?void 0:s.inputPriority)&&void 0!==i?i:0)}))}o.forEach((t=>{e.registerInputIfNeeded(t),!1!==e.hasInput(t)&&e.queueInput(t,n[t])}))}}async createNodeFromModel(e,t){if("Component Children"===e.type){if(e.parent){const t=this.getNodeWithId(e.parent.id);this.componentOwner.setChildRoot(t)}return}let n;try{n=await this.createNode(e.type,e.id),n.updateOnDirtyFlagging=!1!==t,n.setNodeModel(e)}catch(t){return console.error(t.message),void(this.context.editorConnection&&this.context.isWarningTypeEnabled("nodescope")&&this.context.editorConnection.sendWarning(this.componentOwner.name,e.id,"nodelibrary-unknown-node",{message:t.message,showGlobally:!0}))}return e.variant&&n.setVariant&&n.setVariant(e.variant),this.setNodeParameters(n,e),e.parent&&this.insertNodeInTree(n,e),n}insertNodeInTree(e,t){if(!t.parent)throw new Error("Cannot insert node without parent");const n=this.getNodeWithId(t.parent.id),o=t.parent.children.indexOf(t);if(!n.addChild)throw new Error("Node "+n.id+" of type "+n.constructor.name+" can't have children");n.addChild(e,o)}getNodeWithId(e){if(!this.nodes.hasOwnProperty(e))throw new Error("Unknown node id "+e);return this.nodes[e]}hasNodeWithId(e){return this.nodes.hasOwnProperty(e)}createPrimitiveNode(e,t,n){if(t||(t=guid()),this.nodes.hasOwnProperty(t))throw Error("duplicate id "+t);const o=this.context.nodeRegister.createNode(e,t,this);if(n)for(const e in n)o[e]=n[e];return this.nodes[t]=o,o}async createNode(e,t,n){if(t||(t=guid()),this.nodes.hasOwnProperty(t))throw Error("duplicate id "+t);let o;if(this.context.nodeRegister.hasNode(e)){if(o=this.context.nodeRegister.createNode(e,t,this),n)for(const e in n)o[e]=n[e]}else o=await this.context.createComponentInstanceNode(e,t,this,n),this.componentInstanceChildren[t]=o;return this.nodes[t]=o,o}getNodesWithIdRecursive(e){const t=[];return function e(t,n,o){t.nodes.hasOwnProperty(n)&&o.push(t.nodes[n]),Object.keys(t.nodes).filter((e=>t.nodes[e]instanceof ComponentInstanceNode)).forEach((i=>{const s=t.nodes[i].nodeScope;s&&e(s,n,o)}))}(this,e,t),t}getNodesWithType(e){return Object.keys(this.nodes).filter((t=>this.nodes[t].name===e)).map((e=>this.nodes[e]))}getNodesWithTypeRecursive(e){let t=[];return(()=>{t=t.concat(this.getNodesWithType(e)),Object.keys(this.nodes).filter((e=>this.nodes[e]instanceof ComponentInstanceNode)).forEach((n=>{const o=this.nodes[n];if(o&&o.nodeScope){const n=o.nodeScope.getNodesWithTypeRecursive(e);t=t.concat(n)}}))})(),t}getAllNodesRecursive(){let e=[];return(()=>{e=e.concat(Object.values(this.nodes)),Object.keys(this.nodes).filter((e=>this.nodes[e]instanceof ComponentInstanceNode)).forEach((t=>{const n=this.nodes[t];if(n&&n.nodeScope){const t=n.nodeScope.getAllNodesRecursive();e=e.concat(t)}}))})(),e}getAllNodesWithVariantRecursive(e){return this.getAllNodesRecursive().filter((t=>t.variant===e))}onNodeModelRemoved(e){const t=this.getNodeWithId(e.id);e.parent&&this.getNodeWithId(e.parent.id).removeChild(t),t._onNodeDeleted(),delete this.nodes[t.id],delete this.componentInstanceChildren[t.id]}removeConnection(e){this.getNodeWithId(e.targetId).removeInputConnection(e.targetPort,e.sourceId,e.sourcePort)}async setComponentModel(e){var t;this.componentModel=e;const n=[];for(const t of e.getAllNodes()){const e=await this.createNodeFromModel(t,!1);e&&n.push(e)}e.getAllConnections().forEach((e=>this.addConnection(e))),n.forEach((e=>e.updateOnDirtyFlagging=!0)),n.forEach((e=>{e._dirty&&e._performDirtyUpdate()})),e.on("connectionAdded",(e=>this.addConnection(e)),this),e.on("connectionRemoved",this.removeConnection,this),e.on("nodeAdded",this.createNodeFromModel,this),e.on("nodeParentWillBeRemoved",(e=>{if("Component Children"===e.type)return void(e.parent&&this.componentOwner.setChildRoot(null));const t=this.getNodeWithId(e.id);t.parent&&t.parent.removeChild(t)}),this),e.on("nodeParentUpdated",(e=>{if("Component Children"===e.type){const t=e.parent?this.getNodeWithId(e.parent.id):null;this.componentOwner.setChildRoot(t)}else{const t=this.getNodeWithId(e.id);this.insertNodeInTree(t,e)}}),this),e.on("nodeRemoved",(e=>{"Component Children"!==e.type&&this.onNodeModelRemoved(e)}),this);for(const e in this.nodes){const n=this.nodes[e];null===(t=null==n?void 0:n.nodeScopeDidInitialize)||void 0===t||t.call(n)}}reset(){this.componentModel&&(this.componentModel.removeListenersWithRef(this),this.componentModel=void 0),Object.keys(this.nodes).forEach((e=>{this.nodes.hasOwnProperty(e)&&this.deleteNode(this.nodes[e])}))}deleteNode(e){if(this.nodes.hasOwnProperty(e.id)){if(e.parent&&e.parent.removeChild(e),e.getChildren&&e.getChildren().forEach((t=>{e.removeChild(t),(t.parentNodeScope||t.nodeScope).deleteNode(t)})),this.componentModel){const t=this.componentModel.getConnectionsFrom(e.id),n=this.componentModel.getConnectionsTo(e.id);t.concat(n).forEach((e=>{this.nodes.hasOwnProperty(e.targetId)&&this.nodes.hasOwnProperty(e.sourceId)&&this.removeConnection(e)}))}e._onNodeDeleted(),delete this.nodes[e.id],delete this.componentInstanceChildren[e.id]}else console.error("Node doesn't belong to this scope",e.id,e.name)}sendEventFromThisScope(e,t,n,o){var i,s;if(o){const n=this.getNodesWithType("Event Receiver").filter((t=>t.getChannelName()===e));for(let e=0;ee.name&&this.context.hasComponentModelWithName(e.name)&&e.nodeScope!==this));for(const o of n)if(null===(s=o.nodeScope)||void 0===s?void 0:s.sendEventFromThisScope(e,t,void 0,!0))return!0}}}return!1}}let componentIdCounter=0;class ComponentInstanceNode extends Node$1{constructor(e,t,n){super(e,t),this.nodeScope=new NodeScope(e,this),this.parentNodeScope=n,this._internal={childRoot:null,componentOutputValues:{},componentOutputs:[],componentInputs:[],inputValues:{},roots:[],instanceId:"__$ndl_componentInstaceId"+componentIdCounter},this.nodeScope.modelScope=n?n.modelScope:void 0,componentIdCounter++}async setComponentModel(e){this.componentModel=e;const t=this;await this.nodeScope.setComponentModel(e),this._internal.componentInputs=this.nodeScope.getNodesWithType("Component Inputs"),this._internal.componentOutputs=this.nodeScope.getNodesWithType("Component Outputs"),Object.values(e.getInputPorts()).forEach(this.registerComponentInputPort.bind(this)),Object.values(e.getOutputPorts()).forEach(this.registerComponentOutputPort.bind(this));const n=e.roots||[];this._internal.roots=n.map((e=>this.nodeScope.getNodeWithId(e))),e.on("rootAdded",(e=>{this._internal.roots.push(this.nodeScope.getNodeWithId(e)),this.forceUpdate()}),this),e.on("rootRemoved",(function(e){const t=this._internal.roots.findIndex((t=>t.id===e));-1!==t&&this._internal.roots.splice(t,1),this.forceUpdate()}),this),e.on("inputPortAdded",this.registerComponentInputPort.bind(this),this),e.on("outputPortAdded",this.registerComponentOutputPort.bind(this),this),e.on("inputPortRemoved",(function(e){t.hasInput(e.name)&&t.deregisterInput(e.name)}),this),e.on("outputPortRemoved",(function(e){this.hasOutput(e.name)&&t.deregisterOutput(e.name)}),this),e.on("nodeAdded",(function(e){"Component Inputs"===e.type?t._internal.componentInputs.push(t.nodeScope.getNodeWithId(e.id)):"Component Outputs"===e.type&&t._internal.componentOutputs.push(t.nodeScope.getNodeWithId(e.id))}),this),e.on("nodeRemoved",(function(e){function n(e,t){return e.filter((e=>e.id!==t))}"Component Inputs"===e.type?t._internal.componentInputs=n(t._internal.componentInputs,e.id):"Component Outputs"===e.type&&(t._internal.componentOutputs=n(t._internal.componentOutputs,e.id))}),this),e.on("renamed",(function(e){t.name=e.newName}),this)}_onNodeDeleted(){this.componentModel&&(this.componentModel.removeListenersWithRef(this),this.componentModel=void 0),this.nodeScope.reset(),super._onNodeDeleted()}registerComponentInputPort(e){this.registerInput(e.name,{set:function(t){this._internal.inputValues[e.name]=t,this._internal.componentInputs.forEach((function(t){t.registerOutputIfNeeded(e.name),t.flagOutputDirty(e.name)}))}})}registerComponentOutputPort(e){this.registerOutput(e.name,{getter(){return this._internal.componentOutputValues[e.name]}})}setOutputFromComponentOutput(e,t){var n,o;!1!==this.hasOutput(e)&&(null===(o=null===(n=this._internal.creatorCallbacks)||void 0===n?void 0:n.onOutputChanged)||void 0===o||o.call(n,e,t,this._internal.componentOutputValues[e]),this._internal.componentOutputValues[e]=t,this.flagOutputDirty(e))}setChildRoot(e){const t=this._internal.childRoot,n=e;if(this._internal.childRoot=n,this.model&&this.model.children){const e=this.parentNodeScope,o=this.model.children.filter((e=>"Component Children"!==e.type)).map((t=>null==e?void 0:e.getNodeWithId(t.id)));if(t)for(let e=0;e{var t;null===(t=e.triggerDidMount)||void 0===t||t.call(e)}))}render(){return 0===this._internal.roots.length?null:this._internal.roots[0].render()}setChildIndex(e){this.getRoots().forEach((t=>{var n;return null===(n=t.setChildIndex)||void 0===n?void 0:n.call(t,e)}))}addChild(e,t){this.getChildRoot().addChild(e,t+this.getChildRootIndex())}removeChild(e){this.getChildRoot().removeChild(e)}getChildren(){const e=this.getChildRoot();return e?e.getChildren():[]}isChild(e){return!!this.getChildRoot()&&this.getChildRoot().isChild(e)}contains(e){return this.getRoots().some((t=>{var n;return null===(n=t.contains)||void 0===n?void 0:n.call(t,e)}))}_performDirtyUpdate(){super._performDirtyUpdate();const e=this._internal.componentInputs;for(let t=0,n=e.length;tthis.rootComponent?this.rootComponent.nodeScope:null}),this.editorConnection&&(this.editorConnection.on("debugInspectorsUpdated",(e=>{this.onDebugInspectorsUpdated(e)})),null===(t=this.editorConnection)||void 0===t||t.on("getConnectionValue",(({clientId:e,connectionId:t})=>{var n,o;if((null===(n=this.editorConnection)||void 0===n?void 0:n.clientId)!==e)return;const i=this._outputHistory[t];null===(o=this.editorConnection)||void 0===o||o.sendConnectionValue(t,i?i.value:void 0)})))}setRootComponent(e){this.rootComponent=e}getCurrentTime(){return this.platform.getCurrentTime()}onDebugInspectorsUpdated(e){this.debugInspectorsEnabled&&(e=e.map((e=>{if("connection"===e.type&&e.connection){const t=e.connection;e.id=t.fromId+t.fromProperty}else"node"===e.type&&e.nodeId&&(e.id=e.nodeId);return e})),this.debugInspectors={},e.forEach((e=>this.debugInspectors[e.id]=e)),this.sendDebugInspectorValues())}updateDirtyNodes(){let e,t,n=!0,o=0;for(this.updateIteration++,this.isUpdating=!0;n&&o<10;){const i=this._dirtyNodes;for(this._dirtyNodes=[],e=0,t=i.length;e0||this._dirtyNodes.length>0,o++}this.isUpdating=!1}update(){this.frameNumber++,this.updateDirtyNodes(),this.timerScheduler.hasPendingTimers()&&(this.scheduleUpdate(),this.timerScheduler.runTimers(this.currentFrameTime)),this.debugInspectorsEnabled&&this.sendDebugInspectorValues()}reset(){this.eventEmitter.emit("applicationDataReloaded");const e=this.eventEmitter;["frameStart","frameEnd"].forEach((function(t){e.removeAllListeners(t)})),this.globalValues={},this._dirtyNodes.length=0,this.callbacksAfterUpdate.length=0,this.timerScheduler.runningTimers=[],this.timerScheduler.newTimers=[],this.rootComponent=void 0,this.clearDebugInspectors()}nodeIsDirty(e){this._dirtyNodes.push(e),this.scheduleUpdate()}scheduleUpdate(){this.eventEmitter.emit("scheduleUpdate")}scheduleAfterUpdate(e){this.callbacksAfterUpdate.push(e),this.scheduleUpdate()}scheduleNextFrame(e){this.eventEmitter.once("frameStart",e),this.scheduleUpdate()}setGlobalValue(e,t){this.globalValues[e]=t,this.globalsEventEmitter.emit(e)}getGlobalValue(e){return this.globalValues[e]}registerComponentModel(e){if(this.componentModels.hasOwnProperty(e.name))throw new Error("Duplicate component name "+e.name);this.componentModels[e.name]=e,e.on("renamed",(t=>{delete this.componentModels[t.oldName],this.componentModels[t.newName]=e}),this)}deregisterComponentModel(e){this.componentModels.hasOwnProperty(e.name)&&(this.componentModels[e.name].removeListenersWithRef(this),delete this.componentModels[e.name])}async fetchComponentBundle(e){const t=async e=>{const t=`${window.Noodl.Env.BaseUrl||"/"}noodl_bundles/${e}.json`,n=await fetch(t);if(404===n.status)throw new Error("Component not found "+e);const o=await n.json();for(const e of o)!1===this.graphModel.hasComponentWithName(e.name)&&await this.graphModel.importComponentFromEditorData(e)};if(this.bundleFetchesInFlight.has(e))await this.bundleFetchesInFlight.get(e);else{const n=t(e);this.bundleFetchesInFlight.set(e,n),await n}}async getComponentModel(e){if(!e)throw new Error("Component instance must have a name");if(!1===this.componentModels.hasOwnProperty(e)){const t=this.graphModel.getBundleContainingComponent(e);if(!t)throw new Error("Can't find component model for "+e);for(const e of this.graphModel.getBundleDependencies(t))this.fetchComponentBundle(e);await this.fetchComponentBundle(t)}return this.componentModels[e]}hasComponentModelWithName(e){return this.componentModels.hasOwnProperty(e)}async createComponentInstanceNode(e,t,n,o){const i=new ComponentInstanceNode(this,t,n);if(i.name=e,o)for(const e in o)i[e]=o[e];const s=await this.getComponentModel(e);return await i.setComponentModel(s),i}_formatConnectionValue(e){if("object"==typeof e&&e&&e.constructor&&"Node"===e.constructor.name)e=" "+e.name;else if("object"==typeof e&&"undefined"!=typeof window&&e instanceof HTMLElement)e=`DOM Node <${e.tagName}>`;else{if("string"==typeof e&&!e.startsWith("[Signal]"))return'"'+e+'"';if(Number.isNaN(e))return"NaN"}return e}connectionSentValue(e,t){if(!this.editorConnection||!this.editorConnection.isConnected()||!this.debugInspectorsEnabled)return;const n=this.getCurrentTime();if(this._outputHistory[e.id]={value:t,timestamp:n},this.connectionsToPulse.hasOwnProperty(e.id))return void(this.connectionsToPulse[e.id].timestamp=n);const o=[];e.connections.forEach((t=>{o.push(e.owner.id+e.name+t.node.id+t.inputPortName)})),this.connectionsToPulse[e.id]={timestamp:n,connections:o},this.connectionsToPulseChanged=!0,!1===this.connectionPulsingCallbackScheduled&&(this.connectionPulsingCallbackScheduled=!0,setTimeout(this.clearOldConnectionPulsing.bind(this),100))}connectionSentSignal(e){const t=e.id;this._signalHistory.hasOwnProperty(t)||(this._signalHistory[t]={count:0}),this._signalHistory[t].count++,this.connectionSentValue(e,"[Signal] Trigger count "+this._signalHistory[t].count)}clearDebugInspectors(){var e;this.debugInspectors={},this.connectionsToPulse={},null===(e=this.editorConnection)||void 0===e||e.sendPulsingConnections(this.connectionsToPulse)}clearOldConnectionPulsing(){var e;this.connectionPulsingCallbackScheduled=!1;const t=this.getCurrentTime();Object.keys(this.connectionsToPulse).forEach((e=>{const n=this.connectionsToPulse[e];t-n.timestamp>100&&(this.connectionsToPulseChanged=!0,delete this.connectionsToPulse[e])})),this.connectionsToPulseChanged&&(this.connectionsToPulseChanged=!1,null===(e=this.editorConnection)||void 0===e||e.sendPulsingConnections(this.connectionsToPulse)),Object.keys(this.connectionsToPulse).length>0&&(this.connectionPulsingCallbackScheduled=!0,setTimeout(this.clearOldConnectionPulsing.bind(this),500))}_getDebugInspectorValueForNode(e){if(!this.rootComponent)return;const t=this.rootComponent.nodeScope.getNodesWithIdRecursive(e),n=t[t.length-1];if(n&&n.getInspectInfo){const t=n.getInspectInfo();if(void 0!==t)return{type:"node",id:e,value:t}}}sendDebugInspectorValues(){var e,t;const n=[];for(const e in this.debugInspectors){const t=this.debugInspectors[e];if("connection"===t.type&&this._outputHistory.hasOwnProperty(e)){const t=this._outputHistory[e].value;n.push({type:"connection",id:e,value:this._formatConnectionValue(t)})}else if("node"===t.type){const t=this._getDebugInspectorValueForNode(e);t&&n.push(t)}}n.length>0&&(null===(e=this.editorConnection)||void 0===e||e.sendDebugInspectorValues(n)),this.connectionsToPulseChanged&&(this.connectionsToPulseChanged=!1,null===(t=this.editorConnection)||void 0===t||t.sendPulsingConnections(this.connectionsToPulse))}setDebugInspectorsEnabled(e){this.debugInspectorsEnabled=e,this.editorConnection,e&&this.sendDebugInspectorValues()}sendGlobalEventFromEventSender(e,t){this.eventSenderEmitter.emit(e,t)}setPopupCallbacks(e){this.onShowPopup=e.onShow,this.onClosePopup=e.onClose}async showPopup(e,t,n){if(!this.onShowPopup)return;const o=this.rootComponent.nodeScope,i=await o.createNode(e);for(const e in t)i.setInputValue(e,t[e]);i.popupParent=(null==n?void 0:n.senderNode)||null;const s=o.createPrimitiveNode("Group");s.setInputValue("flexDirection","node"),s.setInputValue("cssClassName","noodl-popup");const r=this.graphModel.getSettings().bodyScroll;s.setInputValue("position",r?"fixed":"absolute");const a=i.nodeScope.getNodesWithType("NavigationClosePopup");if(a&&a.length>0)for(let e=0;e{this.scheduleNextFrame((()=>{var i,r;o.hasNodeWithId(s.id)&&(null===(i=this.onClosePopup)||void 0===i||i.call(this,s),o.deleteNode(s),null===(r=null==n?void 0:n.onClosePopup)||void 0===r||r.call(n,e,t||{}))}))}));this.onShowPopup(s),requestAnimationFrame((()=>{s.addChild(i)}))}setWarningTypes(e){Object.assign(this.warningTypes,e)}isWarningTypeEnabled(e){return!this.warningTypes.hasOwnProperty(e)||!!this.warningTypes[e]}getDefaultValueForInput(e,t){var n;if(!1===this.nodeRegister.hasNode(e))return;const o=null===(n=this.nodeRegister.getNodeMetadata(e).inputs)||void 0===n?void 0:n[t];return o?o.type.defaultUnit?{value:o.default,unit:o.type.defaultUnit}:o.default:void 0}}class EventSender{constructor(){this.listeners={},this.listenersWithRefs={}}on(e,t,n){n?(this.listenersWithRefs.hasOwnProperty(e)||(this.listenersWithRefs[e]=new Map),this.listenersWithRefs[e].get(n)||this.listenersWithRefs[e].set(n,[]),this.listenersWithRefs[e].get(n).push(t)):(this.listeners.hasOwnProperty(e)||(this.listeners[e]=[]),this.listeners[e].push(t))}removeListenersWithRef(e){Object.keys(this.listenersWithRefs).forEach((t=>{const n=this.listenersWithRefs[t];n.has(e)&&n.delete(e)}))}removeAllListeners(e){e?(delete this.listeners[e],delete this.listenersWithRefs[e]):(this.listeners={},this.listenersWithRefs={})}async emit(e,t){const n=this.listeners[e];if(n){const e=[...n];for(const n of e)await Promise.resolve(n(t))}const o=this.listenersWithRefs[e];if(o)for(const[e,n]of o)for(const o of n)await Promise.resolve(o.call(e,t))}}class ActiveWarnings{constructor(){this.currentWarnings=new Map}setWarning(e,t,n){if(this.currentWarnings.has(e)){const o=this.currentWarnings.get(e);return!(o&&o[t]===n||(o&&(o[t]=n),0))}return this.currentWarnings.set(e,{[t]:n}),!0}clearWarning(e,t){const n=this.currentWarnings.get(e);return!(!n||!n[t]||(delete n[t],0===Object.keys(n).length&&this.currentWarnings.delete(e),0))}clearWarnings(e){return!1!==this.currentWarnings.has(e)&&(this.currentWarnings.delete(e),!0)}}class EditorConnection extends EventSender{constructor(e={}){var t,n;super(),this.clientId="",this.dynamicPortsHash={},this.serviceRequests={},this.runtimeType=e.runtimeType,this.platform=e.platform||{getCurrentTime:()=>Date.now()},this.ws=(null===(t=e.platform)||void 0===t?void 0:t.webSocketClass)||("undefined"!=typeof WebSocket?WebSocket:void 0),this.wsOptions=null===(n=e.platform)||void 0===n?void 0:n.webSocketOptions,this.reconnectOnClose=!0,this.enableDebugger=!1,this.lastSendTimestamp=0,this.sendQueue=[],this.sendTimer=void 0,this.activeWarnings=new ActiveWarnings}isRunningLocally(){return this.platform.isRunningLocally&&this.platform.isRunningLocally()||"undefined"!=typeof document&&("localhost"===document.location.hostname||"127.0.0.1"===document.location.hostname)}connect(e){this.socket=this.wsOptions?new this.ws(e,this.wsOptions):new this.ws(e),this.socket.addEventListener("open",(()=>{var e;this.clientId=guid(),null===(e=this.socket)||void 0===e||e.send(JSON.stringify({cmd:"register",type:"viewer",clientId:this.clientId})),this.emit("connected")})),this.socket.addEventListener("close",(t=>{this.reconnectOnClose&&this.reconnect(e),console.log("Editor connection closed",t.code,t.reason),this.emit("connectionClosed")})),this.socket.addEventListener("error",(()=>{console.log("Editor connection error, trying to reconnect")})),this.socket.addEventListener("message",(async e=>{const t="string"==typeof e.data?e.data:await e.data.text(),n=JSON.parse(t);let o;"registered"===n.cmd||("export"===n.cmd?(o=JSON.parse(n.content),"full"===n.type&&n.target===this.clientId&&this.emit("exportDataFull",o)):"hoverStart"===n.cmd?this.emit("hoverStart",n.content.id):"hoverEnd"===n.cmd?this.emit("hoverEnd",n.content.id):"refresh"===n.cmd?this.emit("reload"):"debugInspectors"===n.cmd?this.debugInspectorsEnabled&&(o=JSON.parse(n.content),this.emit("debugInspectorsUpdated",o.inspectors)):"debuggingEnabled"===n.cmd?this.isRunningLocally()&&(o=JSON.parse(n.content),this.emit("debuggingEnabledChanged",o.enabled)):"getConnectionValue"===n.cmd?this.isRunningLocally()&&(o=JSON.parse(n.content),await this.emit("getConnectionValue",{clientId:o.clientId,connectionId:o.connectionId})):"modelUpdate"===n.cmd?await this.emit("modelUpdate",n.content):"publish"===n.cmd||("noodlModules"===n.cmd?this.emit("noodlModules",JSON.parse(n.content)):"mqttUpdate"===n.cmd?this.emit("mqttUpdate",n.content):"activeComponentChanged"===n.cmd?this.emit("activeComponentChanged",n.component):console.log("Command not implemented",n)))}))}reconnect(e){setTimeout((()=>{this.connect(e)}),2e3)}isConnected(){return void 0!==this.socket&&this.socket.readyState===this.ws.OPEN}getCircularReplacer(){const e=new WeakSet;return(t,n)=>{if("object"==typeof n&&null!==n){if(e.has(n))return"[Circular]";e.add(n)}return n}}send(e){const t=this.platform.getCurrentTime(),n=t-this.lastSendTimestamp,o=e=>{var t,n;try{null===(t=this.socket)||void 0===t||t.send(JSON.stringify(e))}catch(t){if(t.message&&t.message.startsWith("Converting circular"))try{null===(n=this.socket)||void 0===n||n.send(JSON.stringify(e,this.getCircularReplacer()))}catch(t){console.log("failed to send message to editor",e,t)}else console.log("failed to send message to editor",e,t)}};n<200||this.sendTimer||!this.isConnected()?(this.sendQueue.push(e),this.sendTimer||(this.sendTimer=setTimeout((()=>{if(!1!==this.isConnected()){for(let e=0;e{const o=e[n];t.push(...o.connections)})),this.send({cmd:"connectiondebugpulse",type:"viewer",content:JSON.stringify({connectionsToPulse:t})})}sendDebugInspectorValues(e){this.send({cmd:"debuginspectorvalues",type:"viewer",content:{inspectors:e}})}sendConnectionValue(e,t){this.send({cmd:"connectionValue",type:"viewer",content:{connectionId:e,value:t}})}_detectRename(e,t){if(!e||!t)return;if(e.length!==t.length)return;const n={};for(let o=0;o{let o=JSON.parse(this.dynamicPortsHash[e]),s=[...t];n.prefix&&(o=o.filter((e=>e.name.startsWith(n.prefix))),s=s.filter((e=>e.name.startsWith(n.prefix)))),n.plug&&(o=o.filter((e=>e.plug===n.plug)),s=s.filter((e=>e.plug===n.plug))),s=s.map((e=>e.name.substring((n.prefix||"").length))),o=o.map((e=>e.name.substring((n.prefix||"").length)));const r=this._detectRename(o,s);r&&i.push({plug:n.plug,patterns:[(n.prefix||"")+"{{*}}"],before:r.before,after:r.after})})),i.length>0&&(n.renamed=i),delete n.detectRenamed}this.dynamicPortsHash[e]=o,this.send({cmd:"instanceports",type:"viewer",content:JSON.stringify({nodeid:e,ports:t,options:n})})}}sendWarning(e,t,n,o){this.activeWarnings.setWarning(t,n,o)&&this.send({cmd:"showwarning",type:"viewer",content:JSON.stringify({componentName:e,nodeId:t,key:n,warning:o})})}clearWarning(e,t,n){this.activeWarnings.clearWarning(t,n)&&this.send({cmd:"showwarning",type:"viewer",content:JSON.stringify({componentName:e,nodeId:t,key:n,warning:void 0})})}clearWarnings(e,t){this.activeWarnings.clearWarnings(t)&&this.send({cmd:"clearwarnings",type:"viewer",content:JSON.stringify({componentName:e,nodeId:t})})}sendPatches(e){this.send({cmd:"patchproject",type:"viewer",content:JSON.stringify(e)})}requestFullExport(){this.send({cmd:"register",type:"viewer"})}requestNoodlModules(){this.send({cmd:"getNoodlModules",type:"viewer"})}sendServiceRequest(e,t){e.token=guid(),e.clientId=this.clientId,this.serviceRequests[e.token]=t,this.send(e)}close(){var e;this.reconnectOnClose=!1,!1!==this.isConnected()&&(null===(e=this.socket)||void 0===e||e.close())}sendNodeLibrary(e){this.send({cmd:"nodelibrary",type:"viewer",runtimeType:this.runtimeType,content:e,clientId:this.clientId})}sendComponentMetadata(e,t,n){this.send({cmd:"componentMetadata",type:"viewer",content:JSON.stringify({componentName:e,key:t,data:n})})}sendProjectMetadata(e,t){this.send({cmd:"projectMetadata",type:"viewer",content:JSON.stringify({key:e,data:t})})}}function formatDynamicPorts(e){var t,n;const o=[];for(const i of e.dynamicports||[])if(i.ports||i.template||i.port||i.channelPort)o.push(i);else if(i.inputs||i.outputs){const s=[];if(i.inputs)for(const n of i.inputs){const o=null===(t=e.inputs)||void 0===t?void 0:t[n];o&&s.push(formatPort(n,o,"input"))}if(i.outputs)for(const t of i.outputs){const o=null===(n=e.outputs)||void 0===n?void 0:n[t];o&&s.push(formatPort(t,o,"output"))}const r={name:i.name||"conditionalports/basic",condition:i.condition,ports:s};o.push(r)}return o}function formatPort(e,t,n){const o={name:e,type:t.type,plug:n};return t.group&&(o.group=t.group),t.displayName&&(o.displayName=t.displayName),t.description&&(o.description=t.description),t.editorName&&(o.editorName=t.editorName),void 0!==t.default&&(o.default=t.default),t.hasOwnProperty("index")&&(o.index=t.index),t.tooltip&&(o.tooltip=t.tooltip),t.tab&&(o.tab=t.tab),t.popout&&(o.popout=t.popout),t.allowVisualStates&&(o.allowVisualStates=t.allowVisualStates),o}function generateNodeLibrary(e){const t={typecasts:[{from:"string",to:["number","boolean","image","color","enum","textStyle","dimension","array","object"]},{from:"boolean",to:["number","string","signal"]},{from:"number",to:["boolean","string","dimension"]},{from:"date",to:["string"]},{from:"signal",to:["boolean","number"]},{from:"image",to:[]},{from:"cloudfile",to:["string","image"]},{from:"color",to:[]},{from:"enum",to:[]},{from:"object",to:[]},{from:"domelement",to:[]},{from:"reference",to:[]},{from:"font",to:[]},{from:"textStyle",to:["string"]},{from:"collection",to:["array"]},{from:"array",to:["collection"]}],dynamicports:[{type:"conditionalports",name:"basic"},{type:"expand",name:"basic"}],colors:{nodes:{component:{base:"#643D8B",baseHighlighted:"#79559b",header:"#4E2877",headerHighlighted:"#643d8b",outline:"#4E2877",outlineHighlighted:"#b58900",text:"#dbd0e4"},visual:{base:"#315272",baseHighlighted:"#4d6784",header:"#173E5D",headerHighlighted:"#315272",outline:"#173E5D",outlineHighlighted:"#b58900",text:"#cfd5de"},data:{base:"#465524",baseHighlighted:"#5b6a37",header:"#314110",headerHighlighted:"#465524",outline:"#314110",outlineHighlighted:"#b58900",text:"#d2d6c5"},javascript:{base:"#7E3660",baseHighlighted:"#944e74",header:"#67214B",headerHighlighted:"#7e3660",outline:"#67214B",outlineHighlighted:"#d57bab",text:"#e4cfd9"},default:{base:"#4C4F59",baseHighlighted:"#62656e",header:"#373B45",headerHighlighted:"#4c4f59",outline:"#373B45",outlineHighlighted:"#b58900",text:"#d3d4d6"}},connections:{signal:{normal:"#006f82",highlighted:"#7ec2cf",pulsing:"#ffffff"},default:{normal:"#875d00",highlighted:"#e5ae32",pulsing:"#ffffff"}}},nodetypes:[{name:"Component Children",shortDesc:"This node is a placeholder for where children of this component will be inserted.",docs:"https://docs.noodl.net/nodes/component-utilities/component-children",color:"component",allowAsChild:!0,category:"Visual",haveComponentChildren:["Visual"]}]},n=Object.keys(e._constructors);n.forEach((function(n){const o=e._constructors[n].metadata,i={name:n,searchTags:o.searchTags};t.nodetypes.push(i),o.version&&(i.version=o.version),o.displayNodeName&&(i.displayNodeName=o.displayNodeName),o.nodeDoubleClickAction&&(i.nodeDoubleClickAction=o.nodeDoubleClickAction),o.shortDesc&&(i.shortDesc=o.shortDesc),o.module&&(i.module=o.module),o.deprecated&&(i.deprecated=!0),o.haveComponentPorts&&(i.haveComponentPorts=!0),"Visual"===o.category&&(i.allowAsChild=!0,i.allowAsExportRoot=!0,i.color="visual"),void 0!==o.allowAsExportRoot&&(i.allowAsExportRoot=o.allowAsExportRoot),o.allowChildren&&(i.allowChildrenWithCategory=["Visual"],i.color="visual"),o.allowChildrenWithCategory&&(i.allowChildrenWithCategory=o.allowChildrenWithCategory),o.singleton&&(i.singleton=!0),o.allowAsChild&&(i.allowAsChild=!0),o.docs&&(i.docs=o.docs),o.shortDocs?i.shortDocs=o.shortDocs:o.docs&&0===o.docs.indexOf("https://docs.noodl.net")&&(i.shortDocs=o.docs.replace("/#","")+"-short.md"),i.category=o.category,o.panels&&(i.panels=o.panels),o.usePortAsLabel&&(i.usePortAsLabel=o.usePortAsLabel,i.portLabelTruncationMode=o.portLabelTruncationMode),o.color&&(i.color=o.color),o.dynamicports&&(i.dynamicports=formatDynamicPorts(o)),o.exportDynamicPorts&&(i.exportDynamicPorts=o.exportDynamicPorts),o.visualStates&&(i.visualStates=o.visualStates),o.useVariants&&(i.useVariants=o.useVariants),o.connectionPanel&&(i.connectionPanel=o.connectionPanel),i.ports=[];const s=i.dynamicports||[],r={},a={};s.filter((e=>void 0!==e.channelPort)).forEach((e=>{a[e.channelPort.plug+"/"+e.channelPort.name]=!0})),s.length&&(i.dynamicports=s),Object.keys(o.inputs||{}).forEach((function(e){var t;if(r.hasOwnProperty("input/"+e)||a.hasOwnProperty("input/"+e))return;const n=null===(t=o.inputs)||void 0===t?void 0:t[e];n&&!1!==n.exportToEditor&&(i.ports||(i.ports=[]),i.ports.push(formatPort(e,n,"input")))})),Object.keys(o.outputs||{}).forEach((function(e){var t;if(r.hasOwnProperty("output/"+e)||a.hasOwnProperty("output/"+e))return;const n=null===(t=o.outputs)||void 0===t?void 0:t[e];n&&function(e,t){const n={name:e,type:t.type,plug:"output"};t.group&&(n.group=t.group),t.displayName&&(n.displayName=t.displayName),t.editorName&&(n.editorName=t.editorName),t.hasOwnProperty("index")&&(n.index=t.index),i.ports||(i.ports=[]),i.ports.push(n)}(e,n)}))})),t.nodeIndex={coreNodes:[{name:"UI Elements",description:"Buttons, inputs, containers, media",type:"visual",subCategories:[{name:"Basic Elements",items:["Group","net.noodl.visual.columns","Text","Image","Video","Circle","net.noodl.visual.icon"]},{name:"UI Controls",items:["net.noodl.controls.button","net.noodl.controls.checkbox","net.noodl.controls.options","net.noodl.controls.radiobutton","Radio Button Group","net.noodl.controls.range","net.noodl.controls.textinput"]}]},{name:"Navigation & Popups",description:"Page routing, navigation, popups",type:"logic",subCategories:[{name:"Navigation",items:["Router","RouterNavigate","PageInputs","net.noodl.externallink","PageStackNavigateToPath"]},{name:"Component Stack",items:["Page Stack","PageStackNavigate","PageStackNavigateBack"]},{name:"Popups",items:["NavigationShowPopup","NavigationClosePopup"]}]},{name:"Logic & Utilities",description:"Logic, events, string manipulation",type:"logic",subCategories:[{name:"General Utils",items:["States","Value Changed","Timer","Color Blend","Number Remapper","Counter","Drag","net.noodl.animatetovalue"]},{name:"Logic",items:["Boolean To String","Switch","And","Or","Condition","Inverter"]},{name:"Events",items:["Event Sender","Event Receiver"]},{name:"String Manipulation",items:["Substring","String Mapper","String Format","Date To String","Unique Id"]},{name:"System",items:["Screen Resolution","Open File Picker"]},{name:"Variables",items:["String","Boolean","Color","Number"]}]},{name:"Component Utilities",description:"Component inputs, outputs & object",type:"component",subCategories:[{name:"",items:["Component Inputs","Component Outputs","Component Children","net.noodl.ComponentObject","net.noodl.ParentComponentObject","net.noodl.SetComponentObjectProperties","net.noodl.SetParentComponentObjectProperties"]}]},{name:"Read & Write Data",description:"Arrays, objects, cloud data",type:"data",subCategories:[{name:"",items:["RunTasks","For Each","For Each Actions","Model2","SetModelProperties","NewModel","Set Variable","Variable2"]},{name:"Array",items:["Collection2","CollectionNew","CollectionRemove","CollectionClear","CollectionInsert","Filter Collection","Map Collection","Static Data"]},{name:"Cloud Data",items:["DbModel2","NewDbModelProperties","FilterDBModels","SetDbModelProperties","DbCollection2","DeleteDbModelProperties","AddDbModelRelation","RemoveDbModelRelation","Cloud File","Upload File","CloudFunction2","DbConfig"]},{name:"User",items:["net.noodl.user.LogIn","net.noodl.user.LogOut","net.noodl.user.SignUp","net.noodl.user.User","net.noodl.user.SetUserProperties","net.noodl.user.VerifyEmail","net.noodl.user.SendEmailVerification","net.noodl.user.ResetPassword","net.noodl.user.RequestPasswordReset"]},{name:"External Data",items:["REST2"]}]},{name:"Custom Code",description:"Custom JavaScript and CSS",type:"javascript",subCategories:[{name:"",items:["Expression","JavaScriptFunction","Javascript2","CSS Definition"]}]},{name:"Cloud Functions",description:"Nodes to be used in cloud functions",type:"data",subCategories:[{name:"",items:["noodl.cloud.request","noodl.cloud.response"]},{name:"Cloud Data",items:["noodl.cloud.aggregate"]}]}]};const o=[];return n.forEach((t=>{e._constructors[t].metadata.module&&o.push(t)})),o.length&&(t.nodeIndex.moduleNodes=[{name:"",items:o}]),t}function addModuleSettings(e,t){for(let n=0;n{e.ports.push(t)}))}}function generateProjectSettings(e,t){const n={dynamicports:[],ports:[]};return addModuleSettings(n,t),n}class NodeModel extends EventSender{constructor(e,t){super(),this.id=e,this.type=t,this.inputs=[],this.outputs=[],this.children=[],this.parameters={},this.inputPorts={},this.outputPorts={}}setParameter(e,t,n){n?(this.stateParameters||(this.stateParameters={}),this.stateParameters[n]||(this.stateParameters[n]={}),void 0===t?delete this.stateParameters[n][e]:this.stateParameters[n][e]=t):void 0===t?delete this.parameters[e]:this.parameters[e]=t,this.emit("parameterUpdated",{name:e,value:t,state:n})}setParameters(e){Object.keys(e).forEach((t=>{this.setParameter(t,e[t])}))}setStateParameters(e){this.stateParameters=e}setStateTransitions(e){this.stateTransitions=e}setStateTransitionParamter(e,t,n){this.stateTransitions||(this.stateTransitions={}),t?this.stateTransitions[n][e]=t:delete this.stateTransitions[n][e]}setDefaultStateTransition(e,t){this.defaultStateTransitions||(this.defaultStateTransitions={}),this.defaultStateTransitions[t]=e}addInputPort(e){this.inputPorts[e.name]=e,this.emit("inputPortAdded",e)}getInputPort(e){return this.inputPorts[e]}getInputPorts(){return this.inputPorts}removeInputPortWithName(e){if(this.inputPorts.hasOwnProperty(e)){const t=this.inputPorts[e];delete this.inputPorts[e],this.emit("inputPortRemoved",t)}}updateInputPortTypes(e){let t=!1;for(const n in e)void 0!==this.inputPorts[n]&&(this.inputPorts[n].type=e[n].type,t=!0);t&&this.emit("inputPortTypesUpdated")}addOutputPort(e){this.outputPorts[e.name]=e,this.emit("outputPortAdded",e)}getOutputPort(e){return this.outputPorts[e]}getOutputPorts(){return this.outputPorts}removeOutputPortWithName(e){if(this.outputPorts.hasOwnProperty(e)){const t=this.outputPorts[e];delete this.outputPorts[e],this.emit("outputPortRemoved",t)}}updateOutputPortTypes(e){let t=!1;for(const n in e)void 0!==this.outputPorts[n]&&(this.outputPorts[n].type=e[n].type,t=!0);t&&this.emit("outputPortTypesUpdated")}addChild(e,t){e.parent=this,void 0===t?this.children.push(e):this.children.splice(t,0,e),this.emit("childAdded",e)}removeChild(e){e.parent=void 0;const t=this.children.indexOf(e);this.children.splice(t,1),this.emit("childRemoved",e)}reset(){this.removeAllListeners()}setVariant(e){this.variant=e,this.emit("variantUpdated",e)}static createFromExportData(e){const t=new NodeModel(e.id,e.type);if(e.parameters&&t.setParameters(e.parameters),e.stateParameters&&t.setStateParameters(e.stateParameters),e.stateTransitions&&t.setStateTransitions(e.stateTransitions),e.defaultStateTransitions)for(const n in e.defaultStateTransitions)t.setDefaultStateTransition(e.defaultStateTransitions[n],n);return e.ports&&e.ports.forEach((e=>{"input"!==e.plug&&"input/output"!==e.plug||t.addInputPort(e),"output"!==e.plug&&"input/output"!==e.plug||t.addOutputPort(e)})),e.variant&&t.setVariant(e.variant),t}}class ComponentModel extends EventSender{constructor(e){super(),this.name=e,this.nodes={},this.connections=[],this.roots=[],this.inputPorts={},this.outputPorts={},this.metadata={}}async addNode(e){e.component=this,this.nodes[e.id]=e,await this.emit("nodeAdded",e)}hasNodeWithId(e){return void 0!==this.getNodeWithId(e)}getNodeWithId(e){if(e)return this.nodes[e]}getAllNodes(){return Object.values(this.nodes)}getNodesWithType(e){const t=[];return Object.keys(this.nodes).forEach((n=>{const o=this.nodes[n];o.type===e&&t.push(o)})),t}addConnection(e){if(this.connections.push(e),this.emit("connectionAdded",e),e.targetId){const t=this.getNodeWithId(e.targetId);t&&t.emit("inputConnectionAdded",e)}}removeConnection(e){const t=this.connections.findIndex((t=>t.sourceId===e.sourceId&&t.sourcePort===e.sourcePort&&t.targetId===e.targetId&&t.targetPort===e.targetPort));if(-1!==t&&(this.connections.splice(t,1),this.emit("connectionRemoved",e),e.targetId)){const t=this.getNodeWithId(e.targetId);t&&t.emit("inputConnectionRemoved",e)}}getConnectionsFromPort(e,t){return this.connections.filter((n=>n.sourceId===e&&n.sourcePort===t))}getConnectionsToPort(e,t){return this.connections.filter((n=>n.targetId===e&&n.targetPort===t))}getConnectionsFrom(e){return this.connections.filter((t=>t.sourceId===e))}getConnectionsTo(e){return this.connections.filter((t=>t.targetId===e))}addRootId(e){e&&-1===this.roots.indexOf(e)&&(this.roots.push(e),this.emit("rootAdded",e))}removeRootId(e){const t=this.roots.indexOf(e);-1!==t&&(this.roots.splice(t,1),this.emit("rootRemoved",e))}getRoots(){return this.roots}async removeNodeWithId(e){const t=this.getNodeWithId(e);if(!t)return console.warn("ERROR: Attempted to remove non-existing node with ID:",e),!1;for(;t.children.length>0;){const e=t.children[0];await this.removeNodeWithId(e.id)||t.children.shift()}const n=this.getConnectionsTo(e).concat(this.getConnectionsFrom(e));for(let e=0;e{e.targetPort=n})),o.forEach(this.addConnection.bind(this))}renameOutputPortOnNodeWithId(e,t,n){const o=this.getConnectionsFromPort(e,t);o.forEach(this.removeConnection.bind(this));const i=this.getNodeWithId(e);if(!i)return;const s={...i.getOutputPort(t)};i.removeOutputPortWithName(t),s.name=n,i.addOutputPort(s),o.forEach((e=>{e.sourcePort=n})),o.forEach(this.addConnection.bind(this))}setNodeParent(e,t,n){e&&(-1!==this.roots.indexOf(e.id)&&this.removeRootId(e.id),e.parent&&(this.emit("nodeParentWillBeRemoved",e),e.parent.removeChild(e)),e.emit("parentUpdated",t),t&&(t.addChild(e,n),this.emit("nodeParentUpdated",e)))}async importEditorNodeData(e,t,n){const o=NodeModel.createFromExportData(e);if(await this.addNode(o),t&&this.setNodeParent(o,this.getNodeWithId(t),n),e.children)for(let t=0;t0)throw new Error("Not all nodes were removed during a reset");if(this.connections.length>0)throw new Error("Not all connections were removed during a reset")}rename(e){const t=this.name;this.name=e,this.emit("renamed",{oldName:t,newName:e})}setMetadata(e,t){this.metadata[e]=t}getMetadata(e){return e?this.metadata[e]:this.metadata}static async createFromExportData(e){const t=new ComponentModel(e.name);if(e.metadata)for(const n in e.metadata)t.setMetadata(n,e.metadata[n]);if(e.ports&&e.ports.forEach((e=>{"input"!==e.plug&&"input/output"!==e.plug||t.addInputPort(e),"output"!==e.plug&&"input/output"!==e.plug||t.addOutputPort(e)})),e.nodes)for(const n of e.nodes)await t.importEditorNodeData(n);return e.connections&&e.connections.forEach((e=>t.addConnection(e))),e.roots&&e.roots.forEach((e=>t.addRootId(e))),t}}class GraphModel extends EventSender{constructor(){super(),this.componentToBundleMap=new Map,this.variants=[],this.components={},this.settings={},this.metadata={}}async importComponentFromEditorData(e){const t=await ComponentModel.createFromExportData(e);this.addComponent(t)}getBundleContainingComponent(e){return this.componentToBundleMap.get(e)}getBundlesContainingSheet(e){const t=new Set;for(const n of this.componentToBundleMap.keys()){const o=0!==n.indexOf("/#");(o&&"Default"===e||!o&&0===n.indexOf("/#"+e))&&t.add(this.componentToBundleMap.get(n))}return Array.from(t)}getBundleDependencies(e){const t=new Set,n=e=>{var o;const i=null===(o=this.componentIndex)||void 0===o?void 0:o[e];if(i)for(const e of i.dependencies)t.has(e)||(t.add(e),n(e))};return n(e),Array.from(t)}async importEditorData(e){this.componentIndex=e.componentIndex,this.routerIndex=e.routerIndex,this.componentToBundleMap=new Map;for(const t in e.componentIndex){const n=e.componentIndex[t];for(const e of n.components)this.componentToBundleMap.set(e,t)}this.variants=e.variants||[],e.settings&&this.setSettings(e.settings),e.metadata&&this.setAllMetaData(e.metadata);for(const t of e.components)await this.importComponentFromEditorData(t);this.setRootComponentName(e.rootComponent)}setRootComponentName(e){this.rootComponent=e,this.emit("rootComponentNameUpdated",e)}getNodesWithType(e){let t=[];const n=Object.keys(this.components);for(let o=0;othis.components[e]))}getAllNodes(){let e=[];const t=Object.keys(this.components);for(let n=0;n{e.addInputPort(n[t])})),Object.keys(o).forEach((t=>{e.addOutputPort(o[t])}))}}_onNodeAdded(e){this._addComponentPorts(e),this.emit("nodeAdded",e),this.emit("nodeAdded."+e.type,e)}_onNodeRemoved(e){this.emit("nodeRemoved",e),this.emit("nodeRemoved."+e.type,e)}_onNodeWasRemoved(e){this.emit("nodeWasRemoved",e),this.emit("nodeWasRemoved."+e.type,e)}async reset(){for(const e of Object.keys(this.components))await this.removeComponentWithName(e);this.setSettings({})}isEmpty(){return 0===Object.keys(this.components).length}setSettings(e){this.settings=e,this.emit("projectSettingsChanged",e)}getSettings(){return this.settings}setAllMetaData(e){for(const t in e)this.setMetaData(t,e[t])}setMetaData(e,t){this.metadata[e]&&JSON.stringify(this.metadata[e])===JSON.stringify(t)||(this.metadata[e]=t,this.emit("metadataChanged",{key:e,data:t}),this.emit("metadataChanged."+e,t))}getMetaData(e){return e?this.metadata[e]:this.metadata}getVariants(){return this.variants||[]}getVariant(e,t){return this.variants.find((n=>n.name===t&&n.typename===e))}updateVariant(e){const t=this.variants.findIndex((t=>t.name===e.name&&t.typename===e.typename));-1!==t&&this.variants.splice(t,1),this.variants.push(e),this.emit("variantUpdated",e)}updateVariantParameter(e,t,n,o,i){const s=this.getVariant(t,e);s?(i?(s.stateParameters.hasOwnProperty(i)||(s.stateParameters[i]={}),void 0===o?delete s.stateParameters[i][n]:s.stateParameters[i][n]=o):void 0===o?delete s.parameters[n]:s.parameters[n]=o,this.emit("variantUpdated",s)):console.log("updateVariantParameter: can't find variant",e,t)}updateVariantDefaultStateTransition(e,t,n,o){const i=this.getVariant(t,e);i&&(i.defaultStateTransitions[o]=n,this.emit("variantUpdated",i))}updateVariantStateTransition(e){const{variantTypeName:t,variantName:n,state:o,parameterName:i,curve:s}=e,r=this.getVariant(t,n);r&&(r.stateTransitions[o]||(r.stateTransitions[o]={}),r.stateTransitions[o][i]=s)}deleteVariant(e,t){const n=this.variants.findIndex((n=>n.name===t&&n.typename===e));-1!==n&&this.variants.splice(n,1)}}function difference(e,t){const n=new Set(t);return e.filter((e=>!n.has(e)))}async function handleEvent(e,t,n){function o(t,n){const o={},s={};n.forEach((e=>{"input"!==e.plug&&"input/output"!==e.plug||(o[e.name]=e),"output"!==e.plug&&"input/output"!==e.plug||(s[e.name]=e)}));const r=Object.keys(t.getInputPorts()),a=difference(r,Object.keys(o)),l=difference(Object.keys(o),r);t.updateInputPortTypes(o),a.forEach(t.removeInputPortWithName.bind(t)),l.forEach((n=>{var s;t.addInputPort(o[n]),t instanceof NodeModel&&(null===(s=t.parameters)||void 0===s?void 0:s.hasOwnProperty(n))&&i(e.rootComponent.nodeScope,t,n,t.parameters[n])})),t.updateOutputPortTypes(s);const d=Object.keys(t.getOutputPorts()),u=difference(d,Object.keys(s)),c=difference(Object.keys(s),d);u.forEach(t.removeOutputPortWithName.bind(t)),c.forEach((e=>{t.addOutputPort(s[e])}))}function i(e,t,n,o){e.getNodesWithIdRecursive(t.id).forEach((e=>{e.queueInput(n,o)}))}let s;if(n.componentName&&(s=t.getComponentWithName(n.componentName),!s))return;if(!s)throw new Error("Component model not found");const r={nodeAdded:e=>{null==s||s.importEditorNodeData(e.model,e.parentId,e.childIndex)},nodeRemoved:async e=>{(null==s?void 0:s.hasNodeWithId(e.model.id))&&await s.removeNodeWithId(e.model.id)},connectionAdded:e=>{null==s||s.addConnection(e.model)},connectionRemoved:t=>{if(!s)return;s.removeConnection(t.model);const n=s.getNodeWithId(t.model.targetId);if(0===s.getConnectionsToPort(n.id,t.model.targetId).length){let o=n.parameters[t.model.targetPort];void 0===o&&(o=e.getDefaultValueForInput(n.type,t.model.targetPort)),i(e.rootComponent.nodeScope,n,t.model.targetPort,o)}},parameterChanged:e=>{if(!s)return;const t=s.getNodeWithId(e.nodeId);if(void 0!==t){if(e.parameters){const n=new Set([...Object.keys(e.parameters),...Object.keys(e.oldParameters)]);for(const o of n)t.setParameter(o,e.parameters[o])}e.parameterName&&t.setParameter(e.parameterName,e.parameterValue,e.state)}else console.log("parameterChanged: Unknown node id",e)},nodeAttached:e=>{s&&s.setNodeParent(s.getNodeWithId(e.nodeId),s.getNodeWithId(e.parentId),e.childIndex)},nodeDetached:e=>{s&&(s.setNodeParent(s.getNodeWithId(e.nodeId),null),s.addRootId(e.nodeId))},componentAdded:e=>{t.importComponentFromEditorData(e.model)},componentRemoved:async e=>{await t.removeComponentWithName(e.componentName)},rootAdded:e=>{null==s||s.addRootId(e.nodeId)},portAdded:t=>{if(!s)return;const n=s.getNodeWithId(t.nodeId);t.port&&n&&("input"!==t.port.plug&&"input/output"!==t.port.plug||(n.addInputPort(t.port),n.parameters.hasOwnProperty(t.port.name)&&i(e.rootComponent.nodeScope,n,t.port.name,n.parameters[t.port.name])),"output"!==t.port.plug&&"input/output"!==t.port.plug||n.addOutputPort(t.port))},portRemoved:e=>{if(!s)return;const t=s.getNodeWithId(e.nodeId);e.port&&t&&("input"!==e.port.plug&&"input/output"!==e.port.plug||t.removeInputPortWithName(e.port.name),"output"!==e.port.plug&&"input/output"!==e.port.plug||t.removeOutputPortWithName(e.port.name))},nodePortRenamed:e=>{if(!e.port||!s)return;"input"!==e.port.plug&&"input/output"!==e.port.plug||e.nodeId&&e.oldName&&s.renameInputPortOnNodeWithId(e.nodeId,e.oldName,e.port.name),e.nodeId&&e.oldName&&("output"===e.port.plug||"input/output"===e.port.plug)&&s.renameOutputPortOnNodeWithId(e.nodeId,e.oldName,e.port.name);const n=s.getNodeWithId(e.nodeId);"Component Inputs"===(null==n?void 0:n.type)?(s.addInputPort(e.port),t.getNodesWithType(s.name).forEach((t=>{var n;t.component.renameInputPortOnNodeWithId(t.id,e.oldName,null===(n=e.port)||void 0===n?void 0:n.name)})),s.removeInputPortWithName(e.oldName)):"Component Outputs"===(null==n?void 0:n.type)&&(s.addOutputPort(e.port),t.getNodesWithType(s.name).forEach((t=>{var n;t.component.renameOutputPortOnNodeWithId(t.id,e.oldName,null===(n=e.port)||void 0===n?void 0:n.name)})),s.removeOutputPortWithName(e.oldName))},componentPortsUpdated:e=>{s&&o(s,e.ports)},instancePortsChanged:e=>{if(!s.hasNodeWithId(e.nodeId))return;const t=s.getNodeWithId(e.nodeId);t&&o(t,e.ports)},componentRenamed:e=>{t.renameComponent(e.oldName,e.newName)},settingsChanged:e=>{t.setSettings(e.settings)},metadataChanged:e=>{t.setMetaData(e.key,e.data)},componentMetadataChanged:e=>{const n=t.getComponentWithName(e.componentName);n&&n.setMetadata(e.key,e.data)},variantParametersChanged:n=>{if(n.variant)t.updateVariant(n.variant);else if(t.updateVariantParameter(n.variantName,n.variantTypeName,n.parameterName,n.parameterValue,n.state),void 0===n.parameterValue){const o=t.getVariant(n.variantTypeName,n.variantName);e.rootComponent.nodeScope.getAllNodesWithVariantRecursive(o).forEach((e=>{e.queueInput(n.parameterName,e.getParameter(n.parameterName))}))}},variantDeleted:e=>{t.deleteVariant(e.variantTypeName,e.variantName)},variantChanged:e=>{const n=s.getNodeWithId(e.nodeId);if(n){const o=t.getVariant(n.type,e.variantName);n.setVariant(o)}},variantRenamed:e=>{const n=t.getVariant(e.variantTypeName,e.oldVariantName);(null==n?void 0:n.variantName)&&(n.name=n.variantName)},defaultStateTransitionChanged:e=>{const t=s.getNodeWithId(e.nodeId);null==t||t.setDefaultStateTransition(e.curve,e.state)},stateTransitionsChanged:e=>{const t=s.getNodeWithId(e.nodeId);t&&e.parameterName&&t.setStateTransitionParamter(e.parameterName,e.curve,e.state)},variantDefaultStateTransitionChanged:e=>{t.updateVariantDefaultStateTransition(e.variantName,e.variantTypeName,e.curve,e.state)},variantStateTransitionsChanged:e=>{t.updateVariantStateTransition(e)},routerIndexChanged:e=>{t.routerIndex=e.data}};r.hasOwnProperty(n.type)?(await r[n.type](n),e.scheduleUpdate()):console.log("Unknown event",n)}class Services{}function createSetter(e){let t=!1;return function(n){(n=!!n)&&!1===t&&e.valueChangedToTrue.call(this),t=n}}async function asyncPool(e,t,n){const o=[],i=[];for(const s of t){const r=Promise.resolve().then((()=>n(s,t)));if(o.push(r),e<=t.length){const t=r.then((()=>{i.splice(i.indexOf(t),1)}));i.push(t),i.length>=e&&await Promise.race(i)}}return Promise.all(o)}function registerInput(e,t,n,o){if(e.hasOwnProperty(n))throw new Error("Input property "+n+" already registered");o.set||o.valueChangedToTrue||(o.set=()=>{}),o.set&&(e[n]={set:o.set},["color","textStyle","array"].forEach((t=>{!o.type||o.type!==t&&o.type.name!==t||(e[n].type=t)}))),o.setUnitType&&(e[n].setUnitType=o.setUnitType),t.inputs=t.inputs||{},t.inputs[n]={displayName:o.displayName,editorName:o.editorName,group:o.group,type:o.type,default:o.default,index:o.index,exportToEditor:!o.hasOwnProperty("exportToEditor")||o.exportToEditor,inputPriority:o.inputPriority||0,tooltip:o.tooltip,tab:o.tab,popout:o.popout,allowVisualStates:o.allowVisualStates,nodeDoubleClickAction:o.nodeDoubleClickAction},o.valueChangedToTrue&&(t.inputs[n].type={name:"signal",allowConnectionsOnly:!0})}function registerInputs(e,t,n){Object.keys(n).forEach((function(o){registerInput(e,t,o,n[o])}))}function registerNumberedInputs(e,t){for(const n of Object.keys(t))registerNumberedInput(e,n,t[n])}function registerNumberedInput(e,t,n){const o=e.registerInputIfNeeded;e.registerInputIfNeeded=function(i){if(o&&o.call(e,i),e.hasInput(i)||!i.startsWith(t))return;const s=Number(i.slice(t.length+1));e.registerInput(i,{type:n.type,set:n.createSetter.call(e,s)})}}function registerOutputsMetadata(e,t){Object.keys(t).forEach((function(n){const o=t[n];e.outputs=e.outputs||{},e.outputs[n]={displayName:o.displayName,editorName:o.editorName,group:o.group,type:o.type,index:o.index,exportToEditor:!o.hasOwnProperty("exportToEditor")||o.exportToEditor}}))}function initializeDefaultValues(e,t){Object.keys(t).forEach((n=>{const o=t[n].default;void 0!==o&&(t[n].type.defaultUnit?e[n]={unit:t[n].type.defaultUnit,value:o}:e[n]=o)}))}function defineNode(e){if(!e.category)throw new Error("Node must have a category");if(!e.name)throw new Error("Node must have a name");const t={inputs:{},outputs:{},category:e.category,dynamicports:e.dynamicports,exportDynamicPorts:e.exportDynamicPorts,useVariants:e.useVariants,allowChildren:e.allowChildren,allowChildrenWithCategory:e.allowChildrenWithCategory,singleton:e.singleton,connectionPanel:e.connectionPanel,allowAsChild:e.allowAsChild,visualStates:e.visualStates,panels:e.panels,color:e.color,usePortAsLabel:e.usePortAsLabel,portLabelTruncationMode:e.portLabelTruncationMode,name:e.name,displayNodeName:e.displayNodeName||e.displayName,deprecated:e.deprecated,haveComponentPorts:e.haveComponentPorts,version:e.version,module:e.module,docs:e.docs,allowAsExportRoot:e.allowAsExportRoot,nodeDoubleClickAction:e.nodeDoubleClickAction,searchTags:e.searchTags};e._internal=e._internal||{},e.prototypeExtensions=e.methods||e.prototypeExtensions||{},e.inputs=e.inputs||{},e.outputs=e.outputs||{},e.initialize=e.initialize||function(){};const n={};registerInputs(n,t,e.inputs),registerOutputsMetadata(t,e.outputs);class o extends Node$1{constructor(e,t){super(e,t)}}e.prototypeExtensions&&Object.keys(e.prototypeExtensions).forEach((function(t){e.prototypeExtensions[t].value||(e.prototypeExtensions[t]={value:e.prototypeExtensions[t]})})),Object.defineProperties(o.prototype,e.prototypeExtensions),Object.defineProperty(o.prototype,"name",{value:e.name}),e.getInspectInfo&&(o.prototype.getInspectInfo=e.getInspectInfo),e.nodeScopeDidInitialize&&(o.prototype.nodeScopeDidInitialize=e.nodeScopeDidInitialize);const i=function(s,r,a){var l;const d=new o(s,r);if(d._inputs=Object.create(n),e.inputs)return Object.keys(e.inputs).forEach((function(t){const n=e.inputs[t];n.valueChangedToTrue&&(d._inputs[t]={set:createSetter({valueChangedToTrue:n.valueChangedToTrue})})})),e.outputs?(Object.keys(e.outputs).forEach((function(t){const n=e.outputs[t];"signal"===n.type?d.registerOutput(t,{getter(){}}):d.registerOutput(t,n)})),e.numberedInputs&®isterNumberedInputs(d,e.numberedInputs),d.nodeScope=a,initializeDefaultValues(d._inputValues,t.inputs||{}),null===(l=e.initialize)||void 0===l||l.call(d),d):(Object.assign(i,{metadata:t}),e.numberedInputs&®isterSetupFunctionForNumberedInputs(i,e.name,e.numberedInputs),i)};return i.metadata=t,i}function registerSetupFunctionForNumberedInputs(e,t,n){const o=Object.keys(n);o.length&&(e.setupNumberedInputDynamicPorts=function(e,i){const s=e.editorConnection;function r(e){const t=o.map((t=>function(e,t,n){const o=e.component.getConnectionsTo(e.id).map((e=>e.targetPort)),i=Object.keys(e.parameters).concat(o).filter((e=>e.startsWith(t+" "))),s=(i.length?1+Math.max(...i.map((e=>Number(e.slice(t.length+1))))):0)+1,r=[];for(let e=0;e{r(e),e.on("parameterUpdated",(()=>{r(e)})),e.on("inputConnectionAdded",(()=>{r(e)})),e.on("inputConnectionRemoved",(()=>{r(e)}))}))})}function extend(e,t){for(const n in t)if("initialize"===n&&e.initialize){const n=e.initialize;e.initialize=function(){n.call(this),t.initialize.call(this)}}else t[n]&&t[n].constructor===Object?e[n]=extend(e[n]||{},t[n]):t[n]&&t[n].constructor===Array&&e[n]&&e[n].constructor==Array?e[n]=e[n].concat(t[n]):e[n]=t[n];return e}Services.events=new eventemitter3__WEBPACK_IMPORTED_MODULE_0__.b;const node$y={name:"Component Inputs",shortDesc:"This node is used to define the inputs of a component.",docs:"https://docs.noodl.net/nodes/component-utilities/component-inputs",panels:[{name:"PortEditor",context:["select","connectFrom"],title:"Inputs",plug:"output",type:{name:"*"},canArrangeInGroups:!0},{name:"PropertyEditor",hidden:!0}],getInspectInfo(){var e;return{type:"value",value:null===(e=this.nodeScope)||void 0===e?void 0:e.componentOwner._internal.inputValues}},color:"component",haveComponentPorts:!0,category:"Component Utilities",methods:{registerOutputIfNeeded(e){this.hasOutput(e)||this.registerOutput(e,{getter(){var t;return null===(t=this.nodeScope)||void 0===t?void 0:t.componentOwner._internal.inputValues[e]}})},_updateDependencies(){var e,t;null===(t=null===(e=this.nodeScope)||void 0===e?void 0:e.componentOwner)||void 0===t||t.update()}}};var componentinputs=Object.freeze({__proto__:null,node:node$y});const node$x={category:"Component Utilities",name:"Component Outputs",shortDesc:"This node is used to define the outputs of a component.",docs:"https://docs.noodl.net/nodes/component-utilities/component-outputs",panels:[{name:"PortEditor",context:["select","connectTo"],title:"Outputs",plug:"input",type:{name:"*"},canArrangeInGroups:!0},{name:"PropertyEditor",hidden:!0}],color:"component",haveComponentPorts:!0,prototypeExtensions:{registerInputIfNeeded:function(e){this.hasInput(e)||this.registerInput(e,{set(t){var n,o;null===(o=null===(n=this.nodeScope)||void 0===n?void 0:n.componentOwner)||void 0===o||o.setOutputFromComponentOutput(e,t)}})}}};var componentoutputs=Object.freeze({__proto__:null,node:node$x});class Model{constructor(e,t){this.id=e,this.data=t}static get(e){return void 0===e&&(e=Model.guid()),Model.models[e]||(Model.models[e]=new Model(e,{}),Model.proxies[e]=new Proxy(Model.models[e],Model._modelProxyHandler)),Model.proxies[e]}static create(e){const t=e||{},n=Model.get(t.id);for(const e in t)"id"!==e&&n.set(e,t[e]);return n}static exists(e){return void 0!==Model.models[e]}static instanceOf(e){return e instanceof Model||e.target instanceof Model}static guid(){return randomString(10)}on(e,t){this.listeners||(this.listeners={}),this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)}off(e,t){if(!this.listeners)return;if(!this.listeners[e])return;const n=this.listeners[e].indexOf(t);-1!==n&&this.listeners[e].splice(n,1)}notify(e,t){if(!this.listeners)return;if(!this.listeners[e])return;const n=this.listeners[e].slice();for(let e=0;eReflect.ownKeys(e.data),getOwnPropertyDescriptor:(e,t)=>Object.getOwnPropertyDescriptor(e.data,t.toString())};class ModelScope{constructor(){this.models={},this.proxies={}}get(e){return void 0===e&&(e=Model.guid()),this.models[e]||(this.models[e]=new Model(e,{}),this.proxies[e]=new Proxy(this.models[e],Model._modelProxyHandler)),this.proxies[e]}create(e){const t=e||{},n=this.get(t.id);for(const e in t)"id"!==e&&n.set(e,t[e]);return n}exists(e){return void 0!==this.models[e]}instanceOf(e){return e instanceof Model||e.target instanceof Model}guid(){return randomString(10)}reset(){this.models={},this.proxies={},delete this._cloudStore}}function sendSignalOnInput(e,t){e.queueInput(t,!0),e.queueInput(t,!1)}const node$w={name:"RunTasks",displayNodeName:"Run Tasks",docs:"https://docs.noodl.net/nodes/data/run-tasks",color:"data",category:"Data",initialize(){this._internal={queuedOperations:[],state:"idle",maxRunningTasks:10,activeTasks:new Map}},inputs:{items:{group:"Data",displayName:"Items",type:"array",set(e){e&&e!==this._internal.items&&(this._internal.items=e)}},stopOnFailure:{group:"General",displayName:"Stop On Failure",type:"boolean",default:!1,set(e){this._internal.stopOnFailure=e}},maxRunningTasks:{group:"General",displayName:"Max Running Tasks",type:"number",default:10,set(e){this._internal.maxRunningTasks=e}},taskTemplate:{type:"component",displayName:"Template",group:"General",set(e){this._internal.template=e}},run:{group:"General",displayName:"Do",type:"signal",valueChangedToTrue(){this.scheduleRun()}},abort:{group:"General",displayName:"Abort",type:"signal",valueChangedToTrue(){this.scheduleAbort()}}},outputs:{success:{type:"signal",group:"Events",displayName:"Success"},failure:{type:"signal",group:"Events",displayName:"Failure"},done:{type:"signal",group:"Events",displayName:"Done"},aborted:{type:"signal",group:"Events",displayName:"Aborted"}},methods:{scheduleRun(){const e=this._internal;e.hasScheduledRun||(e.hasScheduledRun=!0,this.scheduleAfterInputsHaveUpdated((()=>{this._queueOperation((()=>{e.hasScheduledRun=!1,this.run()}))})))},scheduleAbort(){const e=this._internal;e.hasScheduledAbort||(e.hasScheduledAbort=!0,this.scheduleAfterInputsHaveUpdated((()=>{this._queueOperation((()=>{e.hasScheduledAbort=!1,this.abort()}))})))},async createTaskComponent(e){const t=this._internal,n=(this.nodeScope.modelScope||Model).create(e),o=await this.nodeScope.createNode(t.template,guid(),{_forEachModel:n,_forEachNode:this}),i=o.isInputConnected.bind(o);o.isInputConnected=e=>"Do"===e||i(e),o.hasInput("Id")&&o.setInputValue("Id",n.getId()),o.hasInput("id")&&o.setInputValue("id",n.getId());for(const e in o._inputs)void 0!==n.data[e]&&o.setInputValue(e,n.data[e]);return o._internal.creatorCallbacks={onOutputChanged:(e,t,i)=>{!1!==i&&void 0!==i||!0!==t||this.itemOutputSignalTriggered(e,n,o)}},o},async startTask(e){const t=this._internal;try{const n=await this.createTaskComponent(e);t.runningTasks++,sendSignalOnInput(n,"Do"),t.activeTasks.set(n.id,n)}catch(e){console.log(e)}},async run(){const e=this._internal;if(this.context.editorConnection&&("idle"!==e.state?this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"run-tasks",{message:"Cannot start when not in idle mode"}):e.template?e.items?this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"run-tasks"):this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"run-tasks",{message:"No items array provided."}):this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"run-tasks",{message:"No task template specified."})),"idle"===e.state&&e.template&&e.items){e.state="running",e.numTasks=e.items.length,e.failedTasks=0,e.completedTasks=0,e.queuedTasks=[].concat(e.items),e.runningTasks=0,0===e.items.length&&(this.sendSignalOnOutput("success"),e.state="idle");for(let t=0;t{if("aborted"===o.state)return this.sendSignalOnOutput("aborted"),void(o.state="idle");if(o.completedTasks===o.numTasks)0===o.failedTasks?this.sendSignalOnOutput("success"):this.sendSignalOnOutput("failure"),this.sendSignalOnOutput("done"),o.state="idle";else if(o.stopOnFailure)if(0===o.failedTasks){o.runningTasks++;const e=o.queuedTasks.shift();e&&this.startTask(e)}else this.sendSignalOnOutput("failure"),this.sendSignalOnOutput("aborted");else{o.runningTasks++;const e=o.queuedTasks.shift();e&&this.startTask(e)}};"Success"===e?(o.completedTasks++,o.runningTasks--,i()):"Failure"===e&&(o.completedTasks++,o.failedTasks++,o.runningTasks--,i()),o.activeTasks.delete(n.id),this.nodeScope.deleteNode(n)},_queueOperation(e){this._internal.queuedOperations.push(e),this._runQueueOperations()},async _runQueueOperations(){if(!this.runningOperations){for(this.runningOperations=!0;this._internal.queuedOperations.length;){const e=this._internal.queuedOperations.shift();await e()}this.runningOperations=!1}}},_deleteAllTasks(){for(const e of this._internal.activeTasks)this.nodeScope.deleteNode(e);this._internal.activeTasks.clear()},_onNodeDeleted(){Node.prototype._onNodeDeleted.call(this),this._deleteAllTasks()}};var runtasks=Object.freeze({__proto__:null,node:node$w});const defaultRequestScript="//Add custom code to setup the request object before the request\n//is made.\n//\n//*Request.resource contains the resource path of the request.\n//*Request.method contains the method, GET, POST, PUT or DELETE.\n//*Request.headers is a map where you can add additional headers.\n//*Request.parameters is a map the parameters that will be appended\n// to the url.\n//*Request.content contains the content of the request as a javascript\n// object.\n//\n//*Inputs and *Outputs contain the inputs and outputs of the node.\n",defaultResponseScript="// Add custom code to convert the response content to outputs\n//\n//*Response.status The status code of the response\n//*Response.content The content of the response as a javascript\n// object.\n//*Response.request The request object that resulted in the response.\n//\n//*Inputs and *Outputs contain the inputs and outputs of the node.\n",node$v={name:"REST2",displayNodeName:"REST",docs:"https://docs.noodl.net/nodes/data/rest",category:"Data",color:"data",searchTags:["http","request","fetch"],initialize(){this._internal.inputValues={},this._internal.outputValues={},this._internal.outputValuesProxy=new Proxy(this._internal.outputValues,{set:(e,t,n)=>(n!==this._internal.outputValues[t]&&(this.registerOutputIfNeeded("out-"+t),this._internal.outputValues[t]=n,this.flagOutputDirty("out-"+t)),!0)}),this._internal.self={}},getInspectInfo(){return this._internal.inspectData?{type:"value",value:this._internal.inspectData}:{type:"text",value:"[Not executed yet]"}},inputs:{resource:{type:"string",displayName:"Resource",group:"Request",default:"/",set(e){this._internal.resource=e}},method:{type:{name:"enum",enums:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"},{label:"DELETE",value:"DELETE"}]},displayName:"Method",group:"Request",default:"GET",set(e){this._internal.method=e}},requestScript:{type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},displayName:"Request",default:defaultRequestScript,group:"Scripts",set(e){try{this._internal.requestFunc=new Function("Inputs","Outputs","Request",e)}catch(e){console.log(e)}}},responseScript:{type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},displayName:"Response",default:defaultResponseScript,group:"Scripts",set(e){try{this._internal.responseFunc=new Function("Inputs","Outputs","Response",e)}catch(e){console.log(e)}}},fetch:{type:"signal",displayName:"Fetch",group:"Actions",valueChangedToTrue(){this.scheduleFetch()}},cancel:{type:"signal",displayName:"Cancel",group:"Actions",valueChangedToTrue(){this.cancelFetch()}}},outputs:{failure:{type:"signal",displayName:"Failure",group:"Events"},success:{type:"signal",displayName:"Success",group:"Events"},canceled:{type:"signal",displayName:"Canceled",group:"Events"}},prototypeExtensions:{getScriptOutputValue(e){return this._internal.outputValues[e]},setScriptInputValue(e,t){return this._internal.inputValues[e]=t},registerOutputIfNeeded(e){if(!this.hasOutput(e))return e.startsWith("out-")?this.registerOutput(e,{getter:this.getScriptOutputValue.bind(this,e.substring(4))}):void 0},registerInputIfNeeded(e){if(!this.hasInput(e))return e.startsWith("in-")?this.registerInput(e,{set:this.setScriptInputValue.bind(this,e.substring(3))}):void 0},scheduleFetch(){const e=this._internal;e.hasScheduledFetch||(e.hasScheduledFetch=!0,this.scheduleAfterInputsHaveUpdated(this.doFetch.bind(this)))},doResponse(e,t,n){this._internal.responseFunc&&this._internal.responseFunc.apply(this._internal.self,[this._internal.inputValues,this._internal.outputValuesProxy,{status:e,content:t,request:n}]),this._internal.inspectData={status:e,content:t},e>=200&&e<300?this.sendSignalOnOutput("success"):this.sendSignalOnOutput("failure")},doExternalFetch(e){let t=e.resource;if(Object.keys(e.parameters).length>0){const n=Object.keys(e.parameters).map((t=>t+"="+encodeURIComponent(e.parameters[t])));t+="?"+n.join("&")}if("undefined"==typeof _noodl_cloud_runtime_version){const n=new XMLHttpRequest;this._xhr=n,n.open(e.method,t,!0);for(const t in e.headers)n.setRequestHeader(t,e.headers[t]);n.onreadystatechange=()=>{let t=!1;if(4===n.readyState){const o=n.status,i=n.getResponseHeader("content-type"),s=n.response;if(delete this._xhr,i){i=i.toLowerCase();const n=-1!==i.indexOf("json")?JSON.parse(s):s;this.doResponse(o,n,e),t=!0}!1===t&&this.doResponse(o,s,e)}},n.onerror=()=>{delete this._xhr,this.sendSignalOnOutput("failure")},n.onabort=()=>{delete this._xhr,this.sendSignalOnOutput("canceled")},e.content?(n.setRequestHeader("Content-Type","application/json"),n.send(JSON.stringify(e.content))):n.send()}else{const n={...e.headers,...e.content?{"Content-Type":"application/json"}:{}};fetch(t,{method:e.method,headers:n,body:e.content?JSON.stringify(e.content):void 0}).then((t=>{const n=t.headers.get("content-type");n?-1!==n.indexOf("/json")?t.json().then((n=>{this.doResponse(t.status,n,e)})):this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"rest-run-waring-",{message:"REST only supports json content type in response."}):t.text().then((n=>{this.doResponse(t.status,n,e)}))})).catch((e=>{console.log("REST: Failed to request",t),console.log(e),this.sendSignalOnOutput("failure")}))}},doFetch(){this._internal.hasScheduledFetch=!1;let e=this._internal.resource;if(e)for(const t in this._internal.inputValues)e=e.replace("{"+t+"}",this._internal.inputValues[t]);const t={resource:e,headers:{},method:void 0!==this._internal.method?this._internal.method:"GET",parameters:{}};this._internal.requestFunc&&this._internal.requestFunc.apply(this._internal.self,[this._internal.inputValues,this._internal.outputValuesProxy,t]),this.doExternalFetch(t)},cancelFetch(){"undefined"==typeof _noodl_cloud_runtime_version?this._xhr&&this._xhr.abort():this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"rest-run-waring-",{message:"REST doesn't support cancel in cloud functions."})}}};function parseScriptForErrors(e,t,n,o,i,s){if(!i.editorConnection)return;if(i.editorConnection.clearWarning(o.component.name,o.id,"rest-run-waring-"+n),void 0===e)return void i.editorConnection.clearWarning(o.component.name,o.id,"rest-parse-waring-"+n);try{new Function(...t,e),i.editorConnection.clearWarning(o.component.name,o.id,"rest-parse-waring-"+n)}catch(e){i.editorConnection.sendWarning(o.component.name,o.id,"rest-parse-waring-"+n,{message:""+n+": "+e.message,showGlobally:!0})}function r(e){return void 0!==s.find((t=>t.name===e))}const a=e.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,""),l=a.match(/Inputs\.[A-Za-z0-9]+/g);if(l){const e={};l.forEach((t=>{e[t.substring(7)]=!0})),Object.keys(e).forEach((e=>{r("in-"+e)||s.push({name:"in-"+e,displayName:e,plug:"input",type:"*",group:"Inputs"})}))}const d=a.match(/Outputs\.[A-Za-z0-9]+/g);if(d){const e={};d.forEach((t=>{e[t.substring(8)]=!0})),Object.keys(e).forEach((e=>{r("out-"+e)||s.push({name:"out-"+e,displayName:e,plug:"output",type:"*",group:"Outputs"})}))}}function setup$a(e,t){function n(t){function n(){if(!t.parameters)return;const n=[];function o(e){for(let t=0;t{n()}))}e.editorConnection&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.REST2",(e=>{n(e)}));for(const e of t.getNodesWithType("REST2"))n(e)}))}var restnode=Object.freeze({__proto__:null,node:node$v,setup:setup$a});const node$u={name:"Expression",docs:"https://docs.noodl.net/nodes/math/expression",usePortAsLabel:"expression",category:"CustomCode",color:"javascript",nodeDoubleClickAction:{focusPort:"Expression"},searchTags:["javascript"],initialize(){const e=this._internal;e.scope={},e.hasScheduledEvaluation=!1,e.code=void 0,e.cachedValue=0,e.currentExpression="",e.compiledFunction=void 0,e.inputNames=[],e.inputValues=[]},getInspectInfo(){return this._internal.cachedValue},inputs:{expression:{group:"General",inputPriority:1,type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},displayName:"Expression",set(e){const t=this._internal;t.currentExpression=functionPreamble+"return ("+e+");",t.compiledFunction=void 0;const n=parsePorts(e),o=lodash_difference__WEBPACK_IMPORTED_MODULE_1___default()(n,t.inputNames),i=lodash_difference__WEBPACK_IMPORTED_MODULE_1___default()(t.inputNames,n),s=this;i.forEach((function(e){s.deregisterInput(e),delete t.scope[e]})),o.forEach((function(e){s.hasInput(e)||(s.registerInput(e,{set(n){t.scope[e]=n,this.isInputConnected("run")||this._scheduleEvaluateExpression()}}),t.scope[e]=0,s._inputValues[e]=0)})),t.inputNames=Object.keys(t.scope),this.isInputConnected("run")||this._scheduleEvaluateExpression()}},run:{group:"Actions",displayName:"Run",type:"signal",valueChangedToTrue(){this._scheduleEvaluateExpression()}}},outputs:{result:{group:"Result",type:"*",displayName:"Result",getter(){return this._internal.currentExpression?this._internal.cachedValue:0}},isTrue:{group:"Result",type:"boolean",displayName:"Is True",getter(){return!!this._internal.currentExpression&&!!this._internal.cachedValue}},isFalse:{group:"Result",type:"boolean",displayName:"Is False",getter(){return!this._internal.currentExpression||!this._internal.cachedValue}},isTrueEv:{group:"Events",type:"signal",displayName:"On True"},isFalseEv:{group:"Events",type:"signal",displayName:"On False"}},prototypeExtensions:{registerInputIfNeeded(e){this.hasInput(e)||(this._internal.scope[e]=0,this._inputValues[e]=0,this.registerInput(e,{set(t){this._internal.scope[e]=t,this.isInputConnected("run")||this._scheduleEvaluateExpression()}}))},_scheduleEvaluateExpression(){const e=this._internal;!1===e.hasScheduledEvaluation&&(e.hasScheduledEvaluation=!0,this.flagDirty(),this.scheduleAfterInputsHaveUpdated((function(){const t=e.cachedValue;e.cachedValue=this._calculateExpression(),t!==e.cachedValue&&(this.flagOutputDirty("result"),this.flagOutputDirty("isTrue"),this.flagOutputDirty("isFalse")),e.cachedValue?this.sendSignalOnOutput("isTrueEv"):this.sendSignalOnOutput("isFalseEv"),e.hasScheduledEvaluation=!1})))},_calculateExpression(){const e=this._internal;e.compiledFunction||(e.compiledFunction=this._compileFunction());for(let t=0;tt===e))||t.push(e))}const o=(e=e.replace(/\"([^\"]*)\"/g,"").replace(/\'([^\']*)\'/g,"")).matchAll(/[a-zA-Z\_\$][a-zA-Z0-9\.\_\$]*/g);for(const e of o){let t=e[0];-1!==t.indexOf(".")&&(t=t.split(".")[0]),n(t)}return t}function updatePorts$7(e,t,n){const o=parsePorts(t).map((e=>({group:"Parameters",name:e,type:{name:"*",editAsType:"string"},plug:"input"})));n.sendDynamicPorts(e,o)}function evalCompileWarnings(e,t){try{new Function(t.parameters.expression),e.clearWarning(t.component.name,t.id,"expression-compile-error")}catch(n){n instanceof Error&&e.sendWarning(t.component.name,t.id,"expression-compile-error",{message:n.message})}}function setup$9(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("nodeAdded.Expression",(t=>{t.parameters.expression&&(updatePorts$7(t.id,t.parameters.expression,e.editorConnection),evalCompileWarnings(e.editorConnection,t)),t.on("parameterUpdated",(n=>{"expression"===n.name&&(updatePorts$7(t.id,t.parameters.expression,e.editorConnection),evalCompileWarnings(e.editorConnection,t))}))}))}var expression=Object.freeze({__proto__:null,node:node$u,setup:setup$9});const userFunctionsCache={};class JavascriptNodeParser{constructor(e,t){this.inputs={},this.outputs={},this.code=e;const n=t?t.node:void 0;this._initializeAPIs();let o=userFunctionsCache[e];if(!o)try{o=new Function(["define","script","Node","Component"],JavascriptNodeParser.getCodePrefix()+e),userFunctionsCache[e]=o}catch(e){this.error=e instanceof Error?e.message:String(e),console.error(e)}if(o)try{o(this.define.bind(this),this.script.bind(this),this.apis.Node,n?JavascriptNodeParser.getComponentScopeForNode(n):{}),this._afterSourced()}catch(e){this.error=e instanceof Error?e.message:String(e),console.error(e)}}define(e){this.inputs=e.inputs||{},this.outputs=e.outputs||{},this.setup=e.setup,this.change=e.run||e.change,this.destroy=e.destroy,this.definedObject=e}script(e){const t=_scriptExtend(e);this.inputs=t.inputs||{},this.outputs=t.outputs||{},this.setup=t.setup,this.change=t.run||t.change,this.destroy=t.destroy,this.definedObject=t}_initializeAPIs(){this.apis={Node:{Inputs:{},Outputs:{},Signals:{},Setters:{}}}}_afterSourced(){if(void 0!==this.definedObject)return;const e=this.apis.Node;if(this.inputs=Object.assign({},e.Inputs||{}),this.outputs=Object.assign({},e.Outputs||{}),this.setup=function(t,n){const o=this;e.setOutputs=function(e){for(const t in e)n[t]=e[t],o.flagOutputDirty(t)},e.OnInit&&e.OnInit.apply(this)},this.destroy=e.OnDestroy||this.destroy,this.change=(t,n,o)=>{for(const n in o)"function"==typeof e.Setters[n]&&e.Setters[n](t[n]);"function"==typeof e.OnInputsChanged&&e.OnInputsChanged()},this.definedObject={inputs:this.inputs,outputs:this.outputs,setup:this.setup,destroy:this.destroy,change:this.change},void 0!==e.Signals)for(const t in e.Signals)"function"==typeof e.Signals[t]&&(this.inputs[t]="signal",this.definedObject[t]=e.Signals[t])}getPorts(){const e=[];return Object.keys(this.inputs).forEach((t=>{const n=this.inputs[t],o={name:t,plug:"input",type:void 0,group:"Inputs"};"string"==typeof n?o.type={name:n}:Object.assign(o,n),e.push(o)})),Object.keys(this.outputs).forEach((t=>{e.push({name:t,type:{name:this.outputs[t]},plug:"output",group:"Outputs"})})),JavascriptNodeParser.parseAndAddPortsFromScript(this.code,e,{}),e}static createFromCode(e,t){return new JavascriptNodeParser(e,t)}static createFromURL(e,t,n){e=getAbsoluteUrl(e);const o=new XMLHttpRequest;o.open("GET",e,!0),o.onreadystatechange=function(){4!==this.readyState&&this.readyState!==XMLHttpRequest.DONE||t(new JavascriptNodeParser(this.response))},o.onerror=function(){console.log("Failed to request",e)},o.send()}static parseAndAddPortsFromScript(e,t,n){function o(e,n){if(null==e)return;const o={};for(const t of e){let e=t[1];void 0!==e&&(o[e]=!0)}Object.keys(o).forEach((e=>{var o;("string"==typeof(o={name:n.prefix+e,plug:n.plug})?void 0===t.find((e=>e.name===o)):void 0===t.find((e=>e.name===o.name&&e.plug===o.plug)))&&t.push({name:n.prefix+e,displayName:e,plug:n.plug,type:n.type,group:n.group})}))}n.skipInputs||(o(e.matchAll(/Inputs\.([A-Za-z0-9_]+)/g),{type:n.inputType||"*",plug:"input",group:n.inputGroup||"Inputs",prefix:n.inputPrefix||""}),o(e.matchAll(/Inputs\s*\[\s*(?:'|")(.*)(?:'|")\s*\]/g),{type:n.inputType||"*",plug:"input",group:n.inputGroup||"Inputs",prefix:n.inputPrefix||""})),n.skipOutputs||(n.skipOutputSignals||(o(e.matchAll(/Outputs\.([A-Za-z0-9]+)\s*\(\s*\)/g),{type:"signal",plug:"output",group:"Outputs",prefix:n.outputPrefix||""}),o(e.matchAll(/Outputs\s*\[\s*(?:'|")(.*)(?:'|")\s*\]\(\s*\)/g),{type:"signal",plug:"output",group:"Outputs",prefix:n.outputPrefix||""})),n.skipRegularOutputs||(o(e.matchAll(/Outputs\.([A-Za-z0-9_]+)/g),{type:"*",plug:"output",group:"Outputs",prefix:n.outputPrefix||""}),o(e.matchAll(/Outputs\s*\[\s*\"([^\"]*)\"\s*\]/g),{type:"*",plug:"output",group:"Outputs",prefix:n.outputPrefix||""})))}static getCodePrefix(){return"const Script = (typeof Node !== 'undefined')?Node:undefined;\n"}static createNoodlAPI(){return"undefined"!=typeof window&&void 0!==window.Noodl?window.Noodl:{}}static getComponentScopeForNode(e){const t=e.nodeScope.componentOwner.getInstanceId();if(void 0===_componentScopes[t]){_componentScopes[t]={};const n=(e.nodeScope.modelScope||Model).get("componentState"+t);_componentScopes[t].Object=n}const n=_findParentComponentStateModelId(e),o=void 0!==n?(e.nodeScope.modelScope||Model).get(n):void 0;return _componentScopes[t].ParentObject=o,_componentScopes[t].RepeaterObject=_findForEachModel(e),_componentScopes[t]}}function _scriptExtend(e){const t={inputs:e.inputs||{},outputs:e.outputs||{},setup:function(t,n){if(this.inputs=t,this.outputs=n,this.setOutputs=function(e){for(const t in e)this.outputs[t]=e[t],this.flagOutputDirty(t)},e.methods)for(const t in e.methods)this[t]=e.methods[t];e.setup&&e.setup.apply(this)},destroy:function(t,n){this.inputs=t,this.outputs=n,e.destroy&&e.destroy.apply(this)},change:function(t,n){this.inputs=t,this.outputs=n;const o=this._oldInputs||{};if(e.changed)for(const n in t)if(t[n]!==o[n]){const i=e.changed[n];"function"==typeof i&&i.apply(this,[t[n],o[n]])}this._oldInputs=Object.assign({},t)}};if(e.signals)for(const n in e.signals)t[n]=e.signals[n],t.inputs[n]="signal";return t}const _componentScopes={};function _findParentComponentStateModelId(e){const t=function e(t){let n;if(t.getRoots().length>0){const e=t.getRoots()[0];e.getVisualParentNode?e.getVisualParentNode()&&(n=e.getVisualParentNode().nodeScope.componentOwner):e.parentNodeScope&&(n=t.parentNodeScope.componentOwner)}else t.parentNodeScope&&(n=t.parentNodeScope.componentOwner);if(n&&n.nodeScope&&n.nodeScope.componentOwner!==t)return n.nodeScope.getNodesWithType("net.noodl.ComponentObject").length>0||n.nodeScope.getNodesWithType("Component State").length>0?n:e(n)}(e.nodeScope.componentOwner);if(t)return"componentState"+t.getInstanceId()}function _findForEachModel(e){let t=e.nodeScope.componentOwner;for(;void 0!==t&&void 0===t._forEachModel&&t.parentNodeScope;)t=t.parentNodeScope.componentOwner;return void 0!==t?t._forEachModel:void 0}const node$t={name:"JavaScriptFunction",displayNodeName:"Function",docs:"https://docs.noodl.net/nodes/javascript/function",category:"CustomCode",color:"javascript",nodeDoubleClickAction:{focusPort:"Script"},searchTags:["javascript"],exportDynamicPorts:!0,initialize:function(){this._internal={},this._internal.inputValues={},this._internal.outputValues={},this._internal.inputTypes={},this._internal.outputTypes={},this._internal.outputValuesProxy=new Proxy(this._internal.outputValues,{set:(e,t,n)=>(this._deleted||n!==this._internal.outputValues[t]&&(this.registerOutputIfNeeded("out-"+t),this._internal.outputValues[t]=n,this.flagOutputDirty("out-"+t)),!0)}),this._internal._this={}},getInspectInfo(){return[{type:"value",value:{inputs:this._internal.inputValues,outputs:this._internal.outputValues}}]},inputs:{scriptInputs:{type:{name:"proplist",allowEditOnly:!0},group:"Script Inputs",set(e){}},scriptOutputs:{type:{name:"proplist",allowEditOnly:!0},group:"Script Outputs",set(e){}},functionScript:{displayName:"Script",plug:"input",type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},group:"General",set(e){void 0!==e?(this._internal.func=this.parseScript(e),this.isInputConnected("run")||this.scheduleRun()):this._internal.func=void 0}},run:{type:"signal",displayName:"Run",group:"Actions",valueChangedToTrue:function(){this.scheduleRun()}}},outputs:{},methods:{scheduleRun(){this.runScheduled||(this.runScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.runScheduled=!1,this._deleted||this.runScript()})))},async runScript(){const e=this._internal.func;if(void 0===e)return;const t=this._internal.inputValues,n=this._internal.outputValuesProxy;for(const e in this.model.outputPorts)if(this._isSignalType(e)){const t=()=>{this.hasOutput(e)&&this.sendSignalOnOutput(e)};this._internal.outputValues[e.substring(4)]=t,this._internal.outputValues[e.substring(4)].send=t}try{await e.apply(this._internal._this,[t,n,JavascriptNodeParser.createNoodlAPI(this.nodeScope.modelScope),JavascriptNodeParser.getComponentScopeForNode(this)])}catch(e){logJavaScriptNodeError(e),this.context.editorConnection&&this.context.isWarningTypeEnabled("javascriptExecution")&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"js-function-run-waring",{showGlobally:!0,message:e.message,stack:e.stack})}},setScriptInputValue(e,t){this._internal.inputValues[e]=t,this.isInputConnected("run")||this.scheduleRun()},getScriptOutputValue(e){if(!this._isSignalType(e))return this._internal.outputValues[e]},setScriptInputType(e,t){this._internal.inputTypes[e]=t},setScriptOutputType(e,t){this._internal.outputTypes[e]=t},parseScript(e){let t;try{t=new(0,Object.getPrototypeOf((async function(){})).constructor)("Inputs","Outputs","Noodl","Component",JavascriptNodeParser.getCodePrefix()+e)}catch(e){console.log("Error while parsing action script: "+e)}return t},_isSignalType(e){return this.model.outputPorts[e]&&"signal"===this.model.outputPorts[e].type},registerInputIfNeeded(e){if(!this.hasInput(e)){if(e.startsWith("in-")){const t=e.substring(3),n={set:this.setScriptInputValue.bind(this,t)};this.model&&this.model.parameters["intype-"+t]&&(n.type=this.model.parameters["intype-"+t]),this.registerInput(e,n)}if(e.startsWith("intype-")){const t=e.substring(7);this.registerInput(e,{set(e){this.hasInput("in"+t)&&(this.getInput("in"+t).type=e)}})}e.startsWith("outtype-")&&this.registerInput(e,{set(){}})}},registerOutputIfNeeded(e){if(!this.hasOutput(e))return e.startsWith("out-")?this.registerOutput(e,{getter:this.getScriptOutputValue.bind(this,e.substring(4))}):void 0}}};function _parseScriptForErrorsAndPorts(e,t,n,o,i){if(o.editorConnection.clearWarning(n.component.name,n.id,"js-function-run-waring"),void 0!==e){try{new(0,Object.getPrototypeOf((async function(){})).constructor)("Inputs","Outputs","Noodl","Component",e),o.editorConnection.clearWarning(n.component.name,n.id,"js-function-parse-waring")}catch(e){o.editorConnection.sendWarning(n.component.name,n.id,"js-function-parse-waring",{showGlobally:!0,message:e.message})}JavascriptNodeParser.parseAndAddPortsFromScript(e,i,{inputPrefix:"in-",outputPrefix:"out-"})}else o.editorConnection.clearWarning(n.component.name,n.id,"js-function-parse-waring")}const inputTypeEnums=[{value:"string",label:"String"},{value:"boolean",label:"Boolean"},{value:"number",label:"Number"},{value:"object",label:"Object"},{value:"date",label:"Date"},{value:"array",label:"Array"},{value:"color",label:"Color"}];function setup$8(e,t){function n(t){function n(){var n;const o=[],i=inputTypeEnums.concat([{value:"signal",label:"Signal"}]);void 0!==t.parameters.scriptOutputs&&t.parameters.scriptOutputs.length>0&&t.parameters.scriptOutputs.forEach((e=>{o.push({name:"outtype-"+e.label,displayName:"Type",editorName:e.label+" | Type",plug:"input",type:{name:"enum",enums:i,allowEditOnly:!0},default:"string",parent:"scriptOutputs",parentItemId:e.id}),o.push({name:"out-"+e.label,displayName:e.label,plug:"output",type:t.parameters["outtype-"+e.label]||"*",group:"Outputs"})})),void 0!==t.parameters.scriptInputs&&t.parameters.scriptInputs.length>0&&t.parameters.scriptInputs.forEach((e=>{o.push({name:"intype-"+e.label,displayName:"Type",editorName:e.label+" | Type",plug:"input",type:{name:"enum",enums:inputTypeEnums,allowEditOnly:!0},default:"string",parent:"scriptInputs",parentItemId:e.id}),o.push({name:"in-"+e.label,displayName:e.label,plug:"input",type:t.parameters["intype-"+e.label]||"string",group:"Inputs"})})),_parseScriptForErrorsAndPorts(t.parameters.functionScript,"Script ",t,e,o),o.forEach((e=>{"signal"===e.type&&"output"===e.plug&&(t.outputPorts[e.name]=e)})),null===(n=e.editorConnection)||void 0===n||n.sendDynamicPorts(t.id,o)}n(),t.on("parameterUpdated",(function(){n()}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.JavaScriptFunction",(function(e){n(e)}));for(const e of t.getNodesWithType("JavaScriptFunction"))n(e)}))}var simplejavascript=Object.freeze({__proto__:null,node:node$t,setup:setup$8});Object.prototype.hasOwnProperty.call(Array.prototype,"items")||Object.defineProperty(Array.prototype,"items",{enumerable:!1,get(){return this},set(e){this.set(e)}}),Object.defineProperty(Array.prototype,"each",{enumerable:!1,writable:!1,value:Array.prototype.forEach}),Object.prototype.hasOwnProperty.call(Array.prototype,"size")||Object.defineProperty(Array.prototype,"size",{enumerable:!1,writable:!1,value:function(){return this.length}}),Object.prototype.hasOwnProperty.call(Array.prototype,"get")||Object.defineProperty(Array.prototype,"get",{enumerable:!1,writable:!1,value:function(e){return this[e]}}),Object.prototype.hasOwnProperty.call(Array.prototype,"getId")||Object.defineProperty(Array.prototype,"getId",{enumerable:!1,writable:!1,value:function(){return this._id}}),Object.prototype.hasOwnProperty.call(Array.prototype,"id")||Object.defineProperty(Array.prototype,"id",{enumerable:!1,get(){return this.getId()}}),Object.prototype.hasOwnProperty.call(Array.prototype,"set")||Object.defineProperty(Array.prototype,"set",{enumerable:!1,writable:!1,value:function(e){let t,n;if(e===this)return;function o(e){const t={},n=e.length;for(let o=0;odelete n[e])),t&&_protectedFields[t]&&_protectedFields[t].forEach((e=>delete n[e])),n}class CloudStore{static get instance(){return void 0===CloudStore._instance&&(CloudStore._instance=new CloudStore),CloudStore._instance}static get collections(){return void 0===CloudStore._collections&&(CloudStore._collections={},(NoodlRuntime$1.instance.getMetaData("dbCollections")||[]).forEach((e=>{CloudStore._collections&&(CloudStore._collections[e.name]=e)})),(NoodlRuntime$1.instance.getMetaData("systemCollections")||[]).forEach((e=>{CloudStore._collections&&(CloudStore._collections[e.name]=e)}))),CloudStore._collections}constructor(e){this._initCloudServices(),this.events=new eventemitter3__WEBPACK_IMPORTED_MODULE_0__.b,this.modelScope=e||Model}_fromJSON(e,t){return CloudStore._fromJSON(e,t,this.modelScope)}_deserializeJSON(e,t){return CloudStore._deserializeJSON(e,t,this.modelScope)}_serializeObject(e,t){return CloudStore._serializeObject(e,t,this.modelScope)}_initCloudServices(){CloudStore._collections=void 0;const e=NoodlRuntime$1.instance.getMetaData("cloudservices");e&&(this.appId=e.appId,this.endpoint=e.endpoint);const t=NoodlRuntime$1.instance.getMetaData("dbVersionMajor");this.dbVersionMajor=t}on(e,t,n){this.events.on.apply(this.events,[e,t,n])}off(e,t,n,o){this.events.off.apply(this.events,[e,t,n,o])}_makeRequest(e,t){if(!this.appId)throw new Error("App ID is not set");if("undefined"==typeof _noodl_cloud_runtime_version){const n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState){let e;try{e=JSON.parse(n.response||n.responseText)}catch(e){}200===n.status||201===n.status?t.success(e):t.error(e||{error:n.responseText,status:n.status})}},n.open(t.method||"GET",this.endpoint+e,!0),n.setRequestHeader("X-Parse-Application-Id",this.appId),"undefined"!=typeof _noodl_cloudservices&&n.setRequestHeader("X-Parse-Master-Key",_noodl_cloudservices.masterKey);const o=localStorage["Parse/"+this.appId+"/currentUser"];if(void 0!==o)try{const e=JSON.parse(o);n.setRequestHeader("X-Parse-Session-Token",e.sessionToken)}catch(e){}t.onUploadProgress&&(n.upload.onprogress=e=>{t.onUploadProgress&&t.onUploadProgress(e)}),t.content instanceof File?n.send(t.content):(n.setRequestHeader("Content-Type","application/json"),n.send(JSON.stringify(t.content)))}else{const n="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.endpoint:this.endpoint,o="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.appId:this.appId,i="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.masterKey:void 0;fetch(n+e,{method:t.method||"GET",headers:{"X-Parse-Application-Id":o,"X-Parse-Master-Key":i,"Content-Type":"application/json"},body:JSON.stringify(t.content)}).then((e=>{200===e.status||201===e.status?"DELETE"===t.method?t.success(void 0):e.json().then((e=>t.success(e))).catch((e=>t.error({error:"CloudStore: Failed to get json result."}))):"DELETE"===t.method?t.error({error:"Failed to delete."}):e.json().then((e=>t.error(e))).catch((e=>t.error({error:"Failed to fetch."})))})).catch((e=>{t.error({error:e.message})}))}}query(e){this._makeRequest("/classes/"+e.collection,{method:"POST",content:{_method:"GET",where:e.where,limit:e.limit,skip:e.skip,include:Array.isArray(e.include)?e.include.join(","):e.include,keys:Array.isArray(e.select)?e.select.join(","):e.select,order:Array.isArray(e.sort)?e.sort.join(","):e.sort,count:e.count},success:function(t){e.success(t.results,t.count)},error:function(){e.error()}})}aggregate(e){const t=[];if(!e.group)return void e.error("You need to provide group option.");e.limit&&t.push("limit="+e.limit),e.skip&&t.push("skip="+e.skip);const n={};Object.keys(e.group).forEach((t=>{const o={},i=e.group[t];void 0!==i.avg?o.$avg="$"+i.avg:void 0!==i.sum?o.$sum="$"+i.sum:void 0!==i.max?o.$max="$"+i.max:void 0!==i.min?o.$min="$"+i.min:void 0!==i.distinct&&(o.$addToSet="$"+i.distinct),n[t]=o})),this.dbVersionMajor&&this.dbVersionMajor>4?(n._id=null,e.where&&t.push("$match="+encodeURIComponent(JSON.stringify(e.where))),t.push("$group="+JSON.stringify(n))):(n.objectId=null,e.where&&t.push("match="+encodeURIComponent(JSON.stringify(e.where))),t.push("group="+JSON.stringify(n))),this._makeRequest("/aggregate/"+e.collection+(t.length>0?"?"+t.join("&"):""),{success:function(t){const n={};t.results&&1===t.results.length?(Object.keys(e.group).forEach((e=>{n[e]=t.results[0][e]})),e.success(n)):e.success({})},error:function(){e.error()}})}count(e){const t=[];e.where&&t.push("where="+encodeURIComponent(JSON.stringify(e.where))),t.push("limit=0"),t.push("count=1"),this._makeRequest("/classes/"+e.collection+(t.length>0?"?"+t.join("&"):""),{success:function(t){e.success(t.count)},error:function(){e.error()}})}distinct(e){const t=[];e.where&&t.push("where="+encodeURIComponent(JSON.stringify(e.where))),t.push("distinct="+e.property),this._makeRequest("/aggregate/"+e.collection+(t.length>0?"?"+t.join("&"):""),{success:function(t){e.success(t.results)},error:function(){e.error()}})}fetch(e){const t=[];e.include&&t.push("include="+(Array.isArray(e.include)?e.include.join(","):e.include)),e.keys&&t.push("keys="+(Array.isArray(e.keys)?e.keys.join(","):e.keys)),e.excludeKeys&&t.push("excludeKeys="+(Array.isArray(e.excludeKeys)?e.excludeKeys.join(","):e.excludeKeys)),this._makeRequest("/classes/"+e.collection+"/"+e.objectId+(t.length>0?"?"+t.join("&"):""),{method:"GET",success:t=>{e.success(t),this.events.emit("fetch",{type:"fetch",objectId:e.objectId,object:t,collection:e.collection})},error:function(t){e.error(t.error)}})}create(e){this._makeRequest("/classes/"+e.collection,{method:"POST",content:Object.assign(_removeProtectedFields(CloudStore._serializeObject(e.data,e.collection),e.collection),{ACL:e.acl}),success:t=>{const n=Object.assign({},e.data,t);e.success(n),this.events.emit("create",{type:"create",objectId:e.objectId,object:n,collection:e.collection})},error:function(t){e.error(t.error)}})}increment(e){const t={};for(let n in e.properties)t[n]={__op:"Increment",amount:e.properties[n]};this._makeRequest("/classes/"+e.collection+"/"+e.objectId,{method:"PUT",content:t,success:t=>{e.success(t)},error:function(t){e.error(t.error)}})}save(e){const t=Object.assign({},e.data);delete t.createdAt,delete t.updatedAt,this._makeRequest("/classes/"+e.collection+"/"+e.objectId,{method:"PUT",content:Object.assign(_removeProtectedFields(CloudStore._serializeObject(t,e.collection),e.collection),{ACL:e.acl}),success:t=>{e.success(t),this.events.emit("save",{type:"save",objectId:e.objectId,object:Object.assign({},e.data,t),collection:e.collection})},error:function(t){e.error(t.error)}})}delete(e){this._makeRequest("/classes/"+e.collection+"/"+e.objectId,{method:"DELETE",success:()=>{e.success(),this.events.emit("delete",{type:"delete",objectId:e.objectId,collection:e.collection})},error:function(t){e.error(t.error)}})}addRelation(e){if(!e.key)throw new Error("Key is required");const t={};t[e.key]={__op:"AddRelation",objects:[{__type:"Pointer",objectId:e.targetObjectId,className:e.targetClass}]},this._makeRequest("/classes/"+e.collection+"/"+e.objectId,{method:"PUT",content:t,success:function(t){e.success(t)},error:function(t){e.error(t.error)}})}removeRelation(e){if(!e.key)throw new Error("Key is required");const t={};t[e.key]={__op:"RemoveRelation",objects:[{__type:"Pointer",objectId:e.targetObjectId,className:e.targetClass}]},this._makeRequest("/classes/"+e.collection+"/"+e.objectId,{method:"PUT",content:t,success:function(t){e.success(t)},error:function(t){e.error(t.error)}})}uploadFile(e){if(!e.file)throw new Error("File is required");this._makeRequest("/files/"+e.file.name,{method:"POST",content:e.file,contentType:e.file.type,success:t=>e.success(Object.assign({},e.data,t)),error:t=>e.error(t),onUploadProgress:e.onUploadProgress})}deleteFile(e){if(!e.file)throw new Error("File is required");this._makeRequest("/files/"+e.file.name,{method:"DELETE",success:t=>e.success(Object.assign({},e.data,t)),error:t=>e.error(t)})}static forScope(e){return void 0===e?CloudStore.instance:(e._cloudStore||(e._cloudStore=new CloudStore(e)),e._cloudStore)}static invalidateCollections(){_collections=void 0}static _fromJSON(e,t,n){const o=(n||Model).get(e.objectId);let i;o._class=t,void 0!==t&&void 0!==CloudStore._collections[t]&&(i=CloudStore._collections[t].schema);for(const t in e){if("objectId"===t||"ACL"===t)continue;const s=i&&i.properties&&i.properties[t]?i.properties[t].type:void 0;o.set(t,CloudStore._deserializeJSON(e[t],s,n))}return o}static _serializeObject(e,t,n){let o;CloudStore._collections[t]&&(o=CloudStore._collections[t].schema);for(const t in e){const i=o&&o.properties&&o.properties[t]?o.properties[t].type:void 0;if(void 0===e[t]||null===e[t]);else if("Pointer"===i&&"string"==typeof e[t])e[t]={__type:"Pointer",className:o.properties[t].targetClass,objectId:e[t]};else if("Pointer"===i&&"object"==typeof e[t]&&(n||Model).instanceOf(e[t]))e[t]={__type:"Pointer",className:o.properties[t].targetClass,objectId:e[t].getId()};else if("Date"===i&&("string"==typeof e[t]||e[t]instanceof Date))e[t]={__type:"Date",iso:e[t]instanceof Date?e[t].toISOString():e[t]};else if("File"===i&&e[t]instanceof CloudFile){const n=e[t];e[t]={__type:"File",url:n.getUrl(),name:n.getName()}}else"Array"===i&&"string"==typeof e[t]&&Collection.exists(e[t])?e[t]=_toJSON(Collection.get(e[t])):"Object"===i&&"string"==typeof e[t]&&(n||Model).exists(e[t])?e[t]=_toJSON((n||Model).get(e[t])):"GeoPoint"===i&&"object"==typeof e[t]?e[t]={__type:"GeoPoint",latitude:Number(e[t].latitude),longitude:Number(e[t].longitude)}:e[t]=_toJSON(e[t])}return e}static _deserializeJSON(e,t,n){if(void 0!==e){if(null===e)return null;if("Relation"!==t||"Relation"!==e.__type){if("Pointer"===t&&"Pointer"===e.__type)return e.objectId;if("Date"===t&&"Date"===e.__type)return new Date(e.iso);if("Date"===t&&"string"==typeof e)return new Date(e);if("File"===t&&"File"===e.__type)return new CloudFile(e);if("GeoPoint"===t&&"GeoPoint"===e.__type)return{latitude:e.latitude,longitude:e.longitude};if(_isArrayOfObjects(e)){const t=[];for(let o=0;o{t.push(_toJSON(e))})),t}return e}function convertVisualFilter(e,t){const n=t.queryParameters;if(void 0!==e.combinator&&void 0!==e.rules){if(0===e.rules.length)return;if(1===e.rules.length)return convertVisualFilter(e.rules[0],t);{const n={},o="$"+e.combinator;return n[o]=[],e.rules.forEach((e=>{const i=convertVisualFilter(e,t);void 0!==i&&n[o].push(i)})),n}}if("related to"===e.operator){const t=void 0!==e.input?n[e.input]:void 0;if(void 0===t)return;return{$relatedTo:{object:{__type:"Pointer",objectId:t,className:e.relatedTo},key:e.relationProperty}}}{const o={};let i,s,r=void 0!==e.input?n[e.input]:e.value;if("exist"===e.operator)return o[e.property]={$exists:!0},o;if("not exist"===e.operator)return o[e.property]={$exists:!1},o;if(void 0===r)return;return CloudStore._collections[t.collectionName]&&(s=CloudStore._collections[t.collectionName].schema),"Date"===(s&&s.properties&&s.properties[e.property]?s.properties[e.property].type:void 0)&&(r instanceof Date||(r=new Date(r.toString())),r={__type:"Date",iso:r.toISOString()}),"greater than"===e.operator?i={$gt:r}:"greater than or equal to"===e.operator?i={$gte:r}:"less than"===e.operator?i={$lt:r}:"less than or equal to"===e.operator?i={$lte:r}:"equal to"===e.operator?i={$eq:r}:"not equal to"===e.operator?i={$ne:r}:"points to"===e.operator?i={$eq:{__type:"Pointer",objectId:r,className:s&&s.properties&&s.properties[e.property]?s.properties[e.property].targetClass:void 0}}:"contain"===e.operator&&(i={$regex:r,$options:"i"}),o[e.property]=i,o}}function matchesQuery(e,t){let n=!0;return void 0===t||(void 0!==t.$and?t.$and.forEach((t=>{n=n&&matchesQuery(e,t)})):void 0!==t.$or?(n=!1,t.$or.forEach((t=>{n=n||matchesQuery(e,t)}))):Object.keys(t).forEach((o=>{if("objectId"===o)void 0!==t[o].$eq?n=n&&e.getId()===t[o].$eq:void 0!==t[o].$in&&(n=n&&-1!==t[o].$in.indexOf(e.getId()));else if("$relatedTo"===o)n=!1;else{const i=e.get(o);void 0!==t[o].$eq&&"Pointer"===t[o].$eq.__type?n=n&&i===t[o].$eq.objectId:void 0!==t[o].$eq?n=n&&i==t[o].$eq:void 0!==t[o].$ne?n=n&&i!=t[o].$ne:void 0!==t[o].$lt?n=n&&it[o].$gt:void 0!==t[o].$gte?n=n&&i>=t[o].$gte:void 0!==t[o].$exists?n=n&&void 0!==i:void 0!==t[o].$in?n=n&&-1!==t[o].$in.indexOf(i):void 0!==t[o].$nin?n=n&&-1===t[o].$in.indexOf(i):void 0!==t[o].$regex&&(n=n&&new RegExp(t[o].$regex,t[o].$options).test(i))}})),n)}function compareObjects(e,t,n){for(let o=0;on.get(e))return-1;if(t.get(e)n.get(i))return 1;if(t.get(i)("descending"===e.order?"-":"")+e.property))}function _value(e){return e instanceof Date&&"function"==typeof e.toISOString?{__type:"Date",iso:e.toISOString()}:e}function convertFilterOp(e,t){var n,o,i,s,r,a;const l=Object.keys(e);if(0===l.length)return{};if(1!==l.length)return null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.call(t,"Filter must only have one key found "+l.join(","));const d={},u=l[0];if(void 0!==e.and&&Array.isArray(e.and))d.$and=e.and.map((e=>convertFilterOp(e,t)));else if(void 0!==e.or&&Array.isArray(e.or))d.$or=e.or.map((e=>convertFilterOp(e,t)));else if(void 0!==e.idEqualTo)d.objectId={$eq:e.idEqualTo};else if(void 0!==e.idContainedIn)d.objectId={$in:e.idContainedIn};else if(void 0!==e.relatedTo){const n=e.relatedTo.id;if(void 0===n)return null===(o=null==t?void 0:t.error)||void 0===o?void 0:o.call(t,"Must provide id in relatedTo filter");const a=e.relatedTo.key;if(void 0===a)return null===(i=null==t?void 0:t.error)||void 0===i?void 0:i.call(t,"Must provide key in relatedTo filter");const l=e.relatedTo.className||(null===(s=(t.modelScope||Model).get(n))||void 0===s?void 0:s._class);if(void 0===l)return null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.call(t,"Must preload the Pointer or include className");d.$relatedTo={object:{__type:"Pointer",objectId:n,className:l},key:a}}else if("object"==typeof e[u]){const n=e[u];if(void 0!==n.equalTo)d[u]={$eq:_value(n.equalTo)};else if(void 0!==n.notEqualTo)d[u]={$ne:_value(n.notEqualTo)};else if(void 0!==n.lessThan)d[u]={$lt:_value(n.lessThan)};else if(void 0!==n.greaterThan)d[u]={$gt:_value(n.greaterThan)};else if(void 0!==n.lessThanOrEqualTo)d[u]={$lte:_value(n.lessThanOrEqualTo)};else if(void 0!==n.greaterThanOrEqualTo)d[u]={$gte:_value(n.greaterThanOrEqualTo)};else if(void 0!==n.exists)d[u]={$exists:n.exists};else if(void 0!==n.containedIn)d[u]={$in:n.containedIn};else if(void 0!==n.notContainedIn)d[u]={$nin:n.notContainedIn};else if(void 0!==n.pointsTo){let e=null;CloudStore._collections[t.collectionName]&&(e=CloudStore._collections[t.collectionName].schema);const o=e&&e.properties&&e.properties[u]?e.properties[u].targetClass:void 0;"Relation"===(e&&e.properties&&e.properties[u]?e.properties[u].type:void 0)?d[u]={__type:"Pointer",objectId:n.pointsTo,className:o}:Array.isArray(n.pointsTo)?d[u]={$in:n.pointsTo.map((e=>({__type:"Pointer",objectId:e,className:o})))}:d[u]={$eq:{__type:"Pointer",objectId:n.pointsTo,className:o}}}else if(void 0!==n.matchesRegex)d[u]={$regex:n.matchesRegex,$options:n.options};else if(void 0!==n.text&&void 0!==n.text.search){const e=n.text.search;d[u]="string"==typeof e?{$text:{$search:{$term:e,$caseSensitive:!1}}}:{$text:{$search:{$term:e.term,$language:e.language,$caseSensitive:e.caseSensitive,$diacriticSensitive:e.diacriticSensitive}}}}else if(void 0!==n.nearSphere){const e=n.nearSphere;d[u]={$nearSphere:{__type:"GeoPoint",latitude:e.latitude,longitude:e.longitude},$maxDistanceInMiles:e.maxDistanceInMiles,$maxDistanceInKilometers:e.maxDistanceInKilometers,$maxDistanceInRadians:e.maxDistanceInRadians}}else if(void 0!==n.withinBox){const e=n.withinBox;d[u]={$within:{$box:e.map((e=>({__type:"GeoPoint",latitude:e.latitude,longitude:e.longitude})))}}}else if(void 0!==n.withinPolygon){const e=n.withinPolygon;d[u]={$geoWithin:{$polygon:e.map((e=>({__type:"GeoPoint",latitude:e.latitude,longitude:e.longitude})))}}}}else null===(a=null==t?void 0:t.error)||void 0===a||a.call(t,"Unrecognized filter keys "+l.join(","));return d}const node$s={name:"DbCollection2",docs:"https://docs.noodl.net/nodes/data/cloud-data/query-records",displayName:"Query Records",category:"Cloud Services",usePortAsLabel:"collectionName",color:"data",initialize(){const e=this;this._internal.queryParameters={};let t=!1;this._internal.collectionChangedCallback=function(){t||(t=!0,e.scheduleAfterInputsHaveUpdated((function(){e.flagOutputDirty("count"),e.flagOutputDirty("firstItemId"),e.flagOutputDirty("isEmpty"),t=!1})))},this._internal.cloudStoreEvents=function(t){var n,o;if(!0!==e.isInputConnected("storageFetch")&&void 0!==e._internal.collection&&t.collection===e._internal.name)if("create"===t.type){const o=Model.get(t.object.objectId);void 0!==o&&matchesQuery(o,null===(n=e._internal.currentQuery)||void 0===n?void 0:n.where)&&s(o)}else if("save"===t.type){const n=Model.get(t.objectId);if(void 0!==n){const t=matchesQuery(n,null===(o=e._internal.currentQuery)||void 0===o?void 0:o.where);!t&&e._internal.collection.contains(n)?(e._internal.collection.remove(n),e.flagOutputDirty("items"),e.flagOutputDirty("count"),e.flagOutputDirty("firstItemId"),e.flagOutputDirty("isEmpty")):t&&!e._internal.collection.contains(n)&&s(n)}}else if("delete"===t.type){const n=Model.get(t.objectId);void 0!==n&&(e._internal.collection.remove(n),e.flagOutputDirty("items"),e.flagOutputDirty("count"),e.flagOutputDirty("firstItemId"),e.flagOutputDirty("isEmpty"))}function s(t){var n,o;if(void 0!==(null===(n=e._internal.currentQuery)||void 0===n?void 0:n.sort)){for(let n=0;n0);n++);e._internal.collection.addAtIndex(t,i)}else e._internal.collection.add(t);let s=e._internal.collection.size();void 0!==(null===(o=e._internal.currentQuery)||void 0===o?void 0:o.limit)&&s>e._internal.currentQuery.limit&&e._internal.collection.remove(e._internal.collection.get(void 0!==e._internal.currentQuery.sort&&"-"===e._internal.currentQuery.sort[0][0]?s-1:0)),e.flagOutputDirty("items"),e.flagOutputDirty("count"),e.flagOutputDirty("firstItemId"),e.flagOutputDirty("isEmpty")}};const n=CloudStore.forScope(this.nodeScope.modelScope);n.on("save",this._internal.cloudStoreEvents),n.on("create",this._internal.cloudStoreEvents),n.on("delete",this._internal.cloudStoreEvents),this._internal.storageSettings={}},getInspectInfo(){const e=this._internal.collection;return e?[{type:"value",value:e.items}]:{type:"text",value:"[Not executed yet]"}},inputs:{},outputs:{items:{type:"array",displayName:"Items",group:"General",getter:function(){return this._internal.collection}},firstItemId:{type:"string",displayName:"First Record Id",group:"General",getter:function(){if(this._internal.collection){const e=this._internal.collection.get(0);if(void 0!==e)return e.getId()}}},isEmpty:{type:"boolean",displayName:"Is Empty",group:"General",getter:function(){return!this._internal.collection||0===this._internal.collection.size()}},count:{type:"number",displayName:"Count",group:"General",getter:function(){return this._internal.collection?this._internal.collection.size():0}},fetched:{group:"Events",type:"signal",displayName:"Success"},failure:{group:"Events",type:"signal",displayName:"Failure"},error:{type:"string",displayName:"Error",group:"Error",getter:function(){return this._internal.error}}},prototypeExtensions:{setCollectionName:function(e){this._internal.name=e,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()},setCollection:function(e){this.bindCollection(e),this.flagOutputDirty("firstItemId"),this.flagOutputDirty("isEmpty"),this.flagOutputDirty("items"),this.flagOutputDirty("count")},unbindCurrentCollection:function(){const e=this._internal.collection;e&&(e.off("change",this._internal.collectionChangedCallback),this._internal.collection=void 0)},bindCollection:function(e){this.unbindCurrentCollection(),this._internal.collection=e,e&&e.on("change",this._internal.collectionChangedCallback)},_onNodeDeleted:function(){Node.prototype._onNodeDeleted.call(this),this.unbindCurrentCollection();const e=CloudStore.forScope(this.nodeScope.modelScope);e.off("insert",this._internal.cloudStoreEvents),e.off("delete",this._internal.cloudStoreEvents),e.off("save",this._internal.cloudStoreEvents)},setError:function(e){this._internal.err=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure")},scheduleFetch:function(){const e=this._internal;e.fetchScheduled||(e.fetchScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{e.fetchScheduled=!1,this.fetch()})))},fetch:function(){this.context.editorConnection&&(void 0===this._internal.name?this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"query-collection",{message:"No collection specified for query"}):this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"query-collection"));const e=Collection.get(),t=this.getStorageFilter(),n=this.getStorageLimit(),o=this.getStorageSkip(),i=this.getStorageFetchTotalCount();this._internal.currentQuery={where:t.where,sort:t.sort,limit:n,skip:o},CloudStore.forScope(this.nodeScope.modelScope).query({collection:this._internal.name,where:t.where,sort:t.sort,limit:n,skip:o,count:i,success:(t,n)=>{void 0!==t&&e.set(t.map((e=>CloudStore._fromJSON(e,this._internal.name,this.nodeScope.modelScope)))),void 0!==n&&(this._internal.storageSettings.storageTotalCount=n,this.hasOutput("storageTotalCount")&&this.flagOutputDirty("storageTotalCount")),this.setCollection(e),this.sendSignalOnOutput("fetched")},error:t=>{this.setCollection(e),this.setError(t||"Failed to fetch.")}})},getStorageFilter:function(){var e;const t=this._internal.storageSettings;if(void 0===t.storageFilterType||"simple"===t.storageFilterType)return{where:void 0!==this._internal.visualFilter?convertVisualFilter(this._internal.visualFilter,{queryParameters:this._internal.queryParameters,collectionName:this._internal.name}):void 0,sort:void 0!==this._internal.visualSorting?convertVisualSorting(this._internal.visualSorting):void 0};if("json"===t.storageFilterType){if(!this._internal.filterFunc)try{let e=t.storageJSONFilter;e=e.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,""),this._internal.filterVariables=e.match(/\$[A-Za-z0-9]+/g)||[];const n=["filter","where","sort","Inputs"].concat(this._internal.filterVariables).concat([e]);this._internal.filterFunc=Function.apply(null,n)}catch(e){this._internal.filterFunc=void 0,console.log("Error while parsing filter script: "+e)}if(!this._internal.filterFunc)return;let n={},o=[];const i=this,s=function(e){n=convertFilterOp(e,{collectionName:i._internal.name,error:function(e){i.context.editorConnection.sendWarning(i.nodeScope.componentOwner.name,i.id,"query-collection-filter",{message:e})}})},r=function(e){o=e},a={};for(const e in t)e.startsWith("storageFilterValue-")&&(a[e.substring(19)]=t[e]);const l=[s,s,r,a];null===(e=this._internal.filterVariables)||void 0===e||e.forEach((e=>{l.push(t["storageFilterValue-"+e.substring(1)])}));try{this._internal.filterFunc.apply(this,l)}catch(e){console.log("Error while running filter script: "+e)}return{where:n,sort:o}}},getStorageLimit:function(){const e=this._internal.storageSettings;return e.storageEnableLimit?e.storageLimit||10:void 0},getStorageSkip:function(){const e=this._internal.storageSettings;return e.storageEnableLimit?e.storageSkip||0:void 0},getStorageFetchTotalCount:function(){return!!this._internal.storageSettings.storageEnableCount},registerOutputIfNeeded:function(e){this.hasOutput(e)||this.registerOutput(e,{getter(){return this._internal.storageSettings[e]}})},setVisualFilter:function(e){this._internal.visualFilter=e,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()},setVisualSorting:function(e){this._internal.visualSorting=e,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()},setQueryParameter:function(e,t){this._internal.queryParameters[e]=t,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()},registerInputIfNeeded:function(e){if(this.hasInput(e))return;if(e.startsWith("qp-"))return this.registerInput(e,{set:this.setQueryParameter.bind(this,e.substring(3))});const t={storageFetch:this.scheduleFetch.bind(this)};if(t[e])return this.registerInput(e,{set:createSetter({valueChangedToTrue:t[e]})});const n={collectionName:this.setCollectionName.bind(this),visualFilter:this.setVisualFilter.bind(this),visualSort:this.setVisualSorting.bind(this)};if(n[e])return this.registerInput(e,{set:n[e]});this.registerInput(e,{set(t){this._internal.storageSettings[e]=t,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()}})}}},_defaultJSONQuery="// Write your query script here, check out the reference documentation for examples\nwhere({ })\n";function updatePorts$6(e,t,n,o){const i=[],s=o.getMetaData("dbCollections"),r=o.getMetaData("systemCollections");if(i.push({name:"collectionName",type:{name:"enum",enums:[{label:"User",value:"_User"},{label:"Role",value:"_Role"}].concat(void 0!==s?s.map((e=>({value:e.name,label:e.name}))):[]),allowEditOnly:!0},displayName:"Class",plug:"input",group:"General"}),i.push({name:"storageFilterType",type:{name:"enum",allowEditOnly:!0,enums:[{value:"simple",label:"Visual"},{value:"json",label:"Javascript"}]},displayName:"Filter",default:"simple",plug:"input",group:"General"}),i.push({type:{name:"boolean"},plug:"input",group:"Limit",name:"storageEnableLimit",displayName:"Use limit"}),t.storageEnableLimit&&(i.push({type:{name:"number"},default:10,plug:"input",group:"Limit",name:"storageLimit",displayName:"Limit"}),i.push({type:{name:"number"},default:0,plug:"input",group:"Limit",name:"storageSkip",displayName:"Skip"})),i.push({type:{name:"signal"},plug:"input",group:"Actions",name:"storageFetch",displayName:"Do"}),i.push({type:{name:"boolean"},plug:"input",group:"Total Count",name:"storageEnableCount",displayName:"Fetch total count"}),t.storageEnableCount&&i.push({type:{name:"number"},plug:"output",group:"General",name:"storageTotalCount",displayName:"Total Count"}),void 0===t.storageFilterType||"simple"===t.storageFilterType){if(void 0!==t.collectionName){let e=s&&s.find((e=>e.name===t.collectionName));if(void 0===e&&r&&(e=r.find((e=>e.name===t.collectionName))),e&&e.schema&&e.schema.properties){const n=JSON.parse(JSON.stringify(e.schema));null==s||s.forEach(_findRelations.bind(null,t,n)),null==r||r.forEach(_findRelations.bind(null,t,n)),i.push({name:"visualFilter",plug:"input",type:{name:"query-filter",schema:n,allowEditOnly:!0},displayName:"Filter",group:"Filter"}),i.push({name:"visualSort",plug:"input",type:{name:"query-sorting",schema:n,allowEditOnly:!0},displayName:"Sort",group:"Sorting"})}if(void 0!==t.visualFilter){const e={};_collectInputs$1(e,t.visualFilter),Object.keys(e).forEach((e=>{i.push({name:"qp-"+e,plug:"input",type:{name:"*"},displayName:e,group:"Query Parameters"})}))}}}else if("json"===t.storageFilterType){i.push({type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},plug:"input",group:"Filter",name:"storageJSONFilter",default:_defaultJSONQuery,displayName:"Filter"});let e=String(t.storageJSONFilter);if(e){e=e.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,"");const t=e.match(/\$[A-Za-z0-9]+/g);if(t){const e={};t.forEach((t=>{e[t]=!0})),Object.keys(e).forEach((e=>{i.push({name:"storageFilterValue-"+e.substring(1),displayName:e.substring(1),group:"Filter Values",plug:"input",type:{name:"*",allowConnectionsOnly:!0}})}))}JavascriptNodeParser.parseAndAddPortsFromScript(e,i,{inputPrefix:"storageFilterValue-",inputGroup:"Filter Values",inputType:{name:"*",allowConnectionsOnly:!0},skipOutputs:!0})}}n.sendDynamicPorts(e,i)}function setup$7(e,t){function n(n){updatePorts$6(n.id,n.parameters,e.editorConnection,t),n.on("parameterUpdated",(function(o){(o.name.startsWith("storage")||"visualFilter"===o.name||"collectionName"===o.name)&&updatePorts$6(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.dbCollections",(function(){CloudStore.invalidateCollections(),updatePorts$6(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.systemCollections",(function(){CloudStore.invalidateCollections(),updatePorts$6(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.cloudservices",(function(){CloudStore.instance._initCloudServices()}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.DbCollection2",(function(e){n(e)}));for(const e of t.getNodesWithType("DbCollection2"))n(e)}))}function _collectInputs$1(e,t){void 0!==t&&(void 0!==t.rules?t.rules.forEach((t=>_collectInputs$1(e,t))):void 0!==t.input&&(e[t.input]=!0))}function _findRelations(e,t,n){if(void 0!==n.schema&&void 0!==n.schema.properties)for(const o in n.schema.properties){const i=n.schema.properties[o];"Relation"===i.type&&i.targetClass===e.collectionName&&(void 0===t.relations&&(t.relations={}),void 0===t.relations[n.name]&&(t.relations[n.name]=[]),t.relations[n.name].push({property:o}))}}var dbcollectionnode2=Object.freeze({__proto__:null,node:node$s,setup:setup$7});const node$r={name:"DbModel2",docs:"https://docs.noodl.net/nodes/data/cloud-data/record",displayNodeName:"Record",shortDesc:"Database model",category:"Cloud Services",usePortAsLabel:"collectionName",color:"data",dynamicports:[{name:"conditionalports/extended",condition:"idSource = explicit OR idSource NOT SET",inputs:["modelId"]}],initialize:function(){const e=this._internal;e.inputValues={},e.relationModelIds={};const t=this;this._internal.onModelChangedCallback=function(e){t.isInputConnected("fetch")||(t.hasOutput("prop-"+e.name)&&t.flagOutputDirty("prop-"+e.name),t.hasOutput("changed-"+e.name)&&t.sendSignalOnOutput("changed-"+e.name),t.sendSignalOnOutput("changed"))}},getInspectInfo(){const e=this._internal.model;return e?[{type:"text",value:"Id: "+e.getId()},{type:"value",value:e.data}]:"[No Record]"},outputs:{id:{type:"string",displayName:"Id",group:"General",getter:function(){return this._internal.model?this._internal.model.getId():this._internal.modelId}},fetched:{type:"signal",displayName:"Fetched",group:"Events"},changed:{type:"signal",displayName:"Changed",group:"Events"},failure:{type:"signal",displayName:"Failure",group:"Events"},error:{type:"string",displayName:"Error",group:"Error",getter:function(){return this._internal.error}}},inputs:{idSource:{type:{name:"enum",enums:[{label:"Specify explicitly",value:"explicit"},{label:"From repeater",value:"foreach"}],allowEditOnly:!0},default:"explicit",displayName:"Id Source",group:"General",set(e){"foreach"===e&&this.scheduleAfterInputsHaveUpdated((()=>{let e=this.nodeScope.componentOwner;for(;void 0!==e&&void 0===e._forEachModel&&e.parentNodeScope;)e=e.parentNodeScope.componentOwner;this.setModel(void 0!==e?e._forEachModel:void 0)}))}},modelId:{type:{name:"string",allowConnectionsOnly:!0},displayName:"Id",group:"General",set(e){e instanceof Model?e=e.getId():"object"==typeof e&&(e=Model.create(e).getId()),this._internal.modelId=e,!1===this.isInputConnected("fetch")?this.setModelID(e):this.flagOutputDirty("id")}},fetch:{displayName:"Fetch",group:"Actions",valueChangedToTrue(){this.scheduleFetch()}}},methods:{setCollectionID(e){this._internal.collectionId=e},setModelID(e){const t=(this.nodeScope.modelScope||Model).get(e);this.setModel(t)},setModel(e){this._internal.model&&this._internal.model.off("change",this._internal.onModelChangedCallback),this._internal.model=e,this.flagOutputDirty("id"),e.on("change",this._internal.onModelChangedCallback);for(const t in e.data)this.hasOutput("prop-"+t)&&this.flagOutputDirty("prop-"+t);this.sendSignalOnOutput("fetched")},_onNodeDeleted(){Node.prototype._onNodeDeleted.call(this),this._internal.model&&this._internal.model.off("change",this._internal.onModelChangedCallback)},scheduleOnce(e,t){const n=this,o="hasScheduled"+e;this._internal[o]||(this._internal[o]=!0,this.scheduleAfterInputsHaveUpdated((function(){n._internal[o]=!1,t()})))},setError(e){this._internal.error=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure"),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"storage-op-warning",{message:e,showGlobally:!0})},clearWarnings(){this.context.editorConnection&&this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"storage-op-warning")},scheduleFetch(){const e=this,t=this._internal;this.scheduleOnce("Fetch",(function(){if(void 0===t.modelId||""===t.modelId)return void e.setError("Missing Id.");const n=CloudStore.forScope(e.nodeScope.modelScope);n.fetch({collection:t.collectionId,objectId:t.modelId,success:function(o){const i=n._fromJSON(o,t.collectionId);t.model!==i&&(t.model&&t.model.off("change",t.onModelChangedCallback),t.model=i,i.on("change",t.onModelChangedCallback)),e.flagOutputDirty("id"),delete o.objectId;for(const t in o)e.hasOutput("prop-"+t)&&e.flagOutputDirty("prop-"+t);e.sendSignalOnOutput("fetched")},error:function(t){e.setError(t||"Failed to fetch.")}})}))},scheduleStore:function(){const e=this._internal;e.model&&this.scheduleOnce("Store",(function(){for(const t in e.inputValues)e.model.set(t,e.inputValues[t],{resolve:!0})}))},registerOutputIfNeeded:function(e){this.hasOutput(e)||e.startsWith("prop-")&&this.registerOutput(e,{getter:userOutputGetter$1.bind(this,e.substring(5))})},registerInputIfNeeded:function(e){if(this.hasInput(e))return;const t={};if(t[e])return this.registerInput(e,{set:createSetter({valueChangedToTrue:t[e]})});const n={collectionName:this.setCollectionID.bind(this)};if(n[e])return this.registerInput(e,{set:n[e]});e.startsWith("prop-")&&this.registerInput(e,{set:userInputSetter$1.bind(this,e.substring(5))})}}};function userOutputGetter$1(e){return this._internal.model?this._internal.model.get(e,{resolve:!0}):void 0}function userInputSetter$1(e,t){this._internal.inputValues[e]=t}function updatePorts$5(e,t,n,o){const i=[],s=o.getMetaData("dbCollections"),r=o.getMetaData("systemCollections");if(i.push({name:"collectionName",displayName:"Class",group:"General",type:{name:"enum",enums:[{label:"User",value:"_User"},{label:"Role",value:"_Role"}].concat(void 0!==s?s.map((e=>({value:e.name,label:e.name}))):[]),allowEditOnly:!0},plug:"input"}),t.collectionName&&s){let e=s.find((e=>e.name===t.collectionName));if(void 0===e&&r&&(e=r.find((e=>e.name===t.collectionName))),e&&e.schema&&e.schema.properties){const t=e.schema.properties;for(const e in t){const n=t[e];if(!i.find((t=>t.name===e))&&"Relation"!==n.type){const t={String:"string",Boolean:"boolean",Number:"number",Date:"date"};i.push({type:{name:t[n.type]?t[n.type]:"*"},plug:"output",group:"Properties",name:"prop-"+e,displayName:e}),i.push({type:"signal",plug:"output",group:"Changed Events",displayName:e+" Changed",name:"changed-"+e})}}}}n.sendDynamicPorts(e,i)}function setup$6(e,t){function n(n){updatePorts$5(n.id,n.parameters,e.editorConnection,t),n.on("parameterUpdated",(function(){updatePorts$5(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.dbCollections",(function(){CloudStore.invalidateCollections(),updatePorts$5(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.systemCollections",(function(){CloudStore.invalidateCollections(),updatePorts$5(n.id,n.parameters,e.editorConnection,t)}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.DbModel2",(function(e){n(e)}));for(const e of t.getNodesWithType("DbModel2"))n(e)}))}var dbmodelnode2=Object.freeze({__proto__:null,node:node$r,setup:setup$6});function _addBaseInfo$1(e,t){const n=void 0===t||t.includeInputProperties,o=void 0!==t&&t.includeRelations;Object.assign(e.node,{category:"Data",color:"data",inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),Object.assign(e.node.outputs,{failure:{type:"signal",displayName:"Failure",group:"Events"},error:{type:"string",displayName:"Error",group:"Error",getter:function(){return this._internal.error}}}),Object.assign(e.node.methods,{scheduleOnce:function(e,t){const n=this,o="hasScheduled"+e;this._internal[o]||(this._internal[o]=!0,this.scheduleAfterInputsHaveUpdated((function(){n._internal[o]=!1,t()})))},checkWarningsBeforeCloudOp(){return this.clearWarnings(),!!this._internal.collectionId||(this.setError("No class name specified"),!1)},setError:function(e){this._internal.error=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure"),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"storage-op-warning",{message:e,showGlobally:!0})},clearWarnings(){this.context.editorConnection&&this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"storage-op-warning")}}),Object.assign(e,{setup:function(t,i){function s(s){function r(){var r;const a=[],l=i.getMetaData("dbCollections"),d=i.getMetaData("systemCollections"),u=s.parameters;if(a.push({name:"collectionName",displayName:"Class",group:"General",type:{name:"enum",enums:[{label:"User",value:"_User"},{label:"Role",value:"_Role"}].concat(void 0!==l?l.map((e=>({value:e.name,label:e.name}))):[]),allowEditOnly:!0},plug:"input"}),o&&u.collectionName&&l){let e=l.find((e=>e.name===u.collectionName));if(void 0===e&&d&&(e=d.find((e=>e.name===u.collectionName))),e&&e.schema&&e.schema.properties){const t=e.schema.properties,n=Object.keys(t).filter((e=>"Relation"===t[e].type)).map((e=>({label:e,value:e})));a.push({name:"relationProperty",displayName:"Relation",group:"General",type:{name:"enum",enums:n,allowEditOnly:!0},plug:"input"})}}if(n&&u.collectionName&&l){const e={String:"string",Boolean:"boolean",Number:"number",Date:"date"};let t=l.find((e=>e.name===u.collectionName));if(void 0===t&&d&&(t=d.find((e=>e.name===u.collectionName))),t&&t.schema&&t.schema.properties){const n=t.schema.properties;for(const t in n){const o=n[t];a.find((e=>e.name===t))||a.push({type:{name:e[o.type]?e[o.type]:"*"},plug:"input",group:"Properties",name:"prop-"+t,displayName:t})}}}null===(r=e._additionalDynamicPorts)||void 0===r||r.call(e,s,a,i),t.editorConnection.sendDynamicPorts(s.id,a)}r(),s.on("parameterUpdated",(function(){r()})),i.on("metadataChanged.dbCollections",(function(){CloudStore.invalidateCollections(),r()})),i.on("metadataChanged.systemCollections",(function(){CloudStore.invalidateCollections(),r()}))}t.editorConnection&&t.editorConnection.isRunningLocally()&&i.on("editorImportComplete",(()=>{i.on("nodeAdded."+e.node.name,(function(e){s(e)}));for(const t of i.getNodesWithType(e.node.name))s(t)}))}})}function _addModelId$1(e,t){const n=Object.assign({},e.node.methods),o=void 0===t||t.includeInputs,i=void 0===t||t.includeOutputs;Object.assign(e.node,{inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),o&&(Object.assign(e.node,{usePortAsLabel:"collectionName"}),e.node.dynamicports=(e.node.dynamicports||[]).concat([{name:"conditionalports/extended",condition:"idSource = explicit OR idSource NOT SET",inputs:["modelId"]}]),Object.assign(e.node.inputs,{idSource:{type:{name:"enum",enums:[{label:"Specify explicitly",value:"explicit"},{label:"From repeater",value:"foreach"}],allowEditOnly:!0},default:"explicit",displayName:"Id Source",group:"General",tooltip:"Choose if you want to specify the Id explicitly, \n or if you want it to be that of the current record in a repeater.",set:function(e){"foreach"===e&&this.scheduleAfterInputsHaveUpdated((()=>{let e=this.nodeScope.componentOwner;for(;void 0!==e&&void 0===e._forEachModel&&e.parentNodeScope;)e=e.parentNodeScope.componentOwner;this.setModel(void 0!==e?e._forEachModel:void 0)}))}},modelId:{type:{name:"string",identifierOf:"ModelName",identifierDisplayName:"Object Ids"},displayName:"Id",group:"General",set:function(e){e instanceof Model&&(e=e.getId()),this._internal.modelId=e,this.setModelID(e)}}})),i&&Object.assign(e.node.outputs,{id:{type:"string",displayName:"Id",group:"General",getter:function(){return this._internal.model?this._internal.model.getId():this._internal.modelId}}}),Object.assign(e.node.methods,{setCollectionID:function(e){this._internal.collectionId=e,this.clearWarnings()},setModelID:function(e){const t=(this.nodeScope.modelScope||Model).get(e);this.setModel(t)},setModel:function(e){this._internal.model=e,this.flagOutputDirty("id")},registerInputIfNeeded:function(e){this.hasInput(e)||("collectionName"===e&&this.registerInput(e,{set:this.setCollectionID.bind(this)}),n&&n.registerInputIfNeeded&&n.registerInputIfNeeded.call(this,e))}})}function _addInputProperties$1(e){const t={node:Object.assign({},e.node),setup:e.setup},n=Object.assign({},e.node.methods);Object.assign(e.node,{inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),Object.assign(e.node,{initialize:function(){this._internal.inputValues={},t.node.initialize&&t.node.initialize.call(this)}}),Object.assign(e.node.outputs,{}),Object.assign(e.node.inputs,{}),Object.assign(e.node.methods,{registerInputIfNeeded:function(e){this.hasInput(e)||(e.startsWith("prop-")&&this.registerInput(e,{set:this._setInputValue.bind(this,e.substring(5))}),n&&n.registerInputIfNeeded&&n.registerInputIfNeeded.call(this,e))},_setInputValue:function(e,t){this._internal.inputValues[e]=t}})}function _addRelationProperty(e){const t=Object.assign({},e.node.methods);Object.assign(e.node,{inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),Object.assign(e.node.inputs,{targetId:{type:{name:"string",allowConnectionsOnly:!0},displayName:"Target Record Id",group:"General",set:function(e){this._internal.targetModelId=e}}}),Object.assign(e.node.methods,{registerInputIfNeeded:function(e){this.hasInput(e)||("relationProperty"===e&&this.registerInput(e,{set:this.setRelationProperty.bind(this)}),t&&t.registerInputIfNeeded&&t.registerInputIfNeeded.call(this,e))},setRelationProperty:function(e){this._internal.relationProperty=e}})}function _getCurrentUser(e){if("undefined"!=typeof _noodl_cloud_runtime_version)return e.get("Request").UserId;{const t=localStorage["Parse/"+CloudStore.instance.appId+"/currentUser"];if(void 0!==t){let n;try{n=JSON.parse(t)}catch(e){}return void 0!==n?n.objectId:void 0}}}function _addAccessControl(e){const t={node:Object.assign({},e.node),setup:e.setup},n=Object.assign({},e.node.methods);Object.assign(e.node,{inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),Object.assign(e.node,{initialize(){this._internal.accessControl={},t.node.initialize&&t.node.initialize.call(this)}}),Object.assign(e.node.inputs,{accessControl:{type:{name:"proplist",autoName:"Rule",allowEditOnly:!0},index:1e3,displayName:"Access Control Rules",group:"Access Control Rules",set(e){this._internal.accessControlRules=e}}});const o=e._additionalDynamicPorts;e._additionalDynamicPorts=function(e,t,n){void 0!==e.parameters.accessControl&&e.parameters.accessControl.length>0&&e.parameters.accessControl.forEach((n=>{const o="acl-"+n.id;t.push({name:o+"-target",displayName:"Target",editorName:n.label+" | Target",plug:"input",type:{name:"enum",enums:[{value:"user",label:"User"},{value:"everyone",label:"Everyone"},{value:"role",label:"Role"}],allowEditOnly:!0},group:n.label+" Access Rule",default:"user",parent:"accessControl",parentItemId:n.id}),"role"===e.parameters[o+"-target"]?t.push({name:o+"-role",displayName:"Role",editorName:n.label+" | Role",group:n.label+" Access Rule",plug:"input",type:"string",parent:"accessControl",parentItemId:n.id}):void 0!==e.parameters[o+"-target"]&&"user"!==e.parameters[o+"-target"]||t.push({name:o+"-userid",displayName:"User Id",group:n.label+" Access Rule",editorName:n.label+" | User Id",plug:"input",type:{name:"string",allowConnectionsOnly:!0},parent:"accessControl",parentItemId:n.id}),t.push({name:o+"-read",displayName:"Read",editorName:n.label+" | Read",group:n.label+" Access Rule",plug:"input",type:{name:"boolean"},default:!0,parent:"accessControl",parentItemId:n.id}),t.push({name:o+"-write",displayName:"Write",editorName:n.label+" | Write",group:n.label+" Access Rule",plug:"input",type:{name:"boolean"},default:!0,parent:"accessControl",parentItemId:n.id})})),o&&o(e,t,n)},Object.assign(e.node.methods,{registerInputIfNeeded:function(e){this.hasInput(e)||(e.startsWith("acl-")&&this.registerInput(e,{set:this.setAccessControl.bind(this,e)}),n&&n.registerInputIfNeeded&&n.registerInputIfNeeded.call(this,e))},_getACL:function(){let e={};function t(e){return{read:void 0===e.read||e.read,write:void 0===e.write||e.write}}const n=_getCurrentUser(this.nodeScope.modelScope);return void 0!==this._internal.accessControlRules&&this._internal.accessControlRules.forEach((o=>{const i=this._internal.accessControl[o.id];if(void 0===i)void 0!==n&&(e[n]={write:!0,read:!0});else if("everyone"===i.target)e["*"]=t(i);else if("user"===i.target){const o=i.userid||n;e[o]=t(i)}else"role"===i.target&&(e["role:"+i.role]=t(i))})),Object.keys(e).length>0?e:void 0},setAccessControl:function(e,t){const n=e.split("-");void 0===this._internal.accessControl[n[1]]&&(this._internal.accessControl[n[1]]={}),this._internal.accessControl[n[1]][n[2]]=t}})}const SetDbModelPropertiedNodeDefinition={node:{name:"SetDbModelProperties",category:"",docs:"https://docs.noodl.net/nodes/data/cloud-data/set-record-properties",displayNodeName:"Set Record Properties",usePortAsLabel:"collectionName",dynamicports:[{name:"conditionalports/extended",condition:"storeType = cloud OR storeType NOT SET",inputs:["storeProperties"]}],inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue(){void 0===this._internal.storeType||"cloud"===this._internal.storeType?this.scheduleSave():this.scheduleStore()}},storeProperties:{displayName:"Properties to store",group:"General",type:{name:"enum",enums:[{label:"Only specified",value:"specified"},{label:"All",value:"all"}]},default:"specified",set:function(e){this._internal.storeProperties=e}},storeType:{displayName:"Store to",group:"General",type:{name:"enum",enums:[{label:"Cloud and local",value:"cloud"},{label:"Local only",value:"local"}]},default:"cloud",set:function(e){this._internal.storeType=e}}},outputs:{stored:{type:"signal",displayName:"Success",group:"Events"}},methods:{scheduleSave(){const e=this,t=this._internal;this.checkWarningsBeforeCloudOp()&&this.scheduleOnce("StorageSave",(function(){if(!t.model)return void e.setError("Missing Record Id");const n=t.model;for(const e in t.inputValues)n.set(e,t.inputValues[e],{resolve:!0});CloudStore.forScope(e.nodeScope.modelScope).save({collection:t.collectionId,objectId:n.getId(),data:"all"===t.storeProperties?n.data:t.inputValues,acl:e._getACL(),success:function(t){for(const e in t)n.set(e,t[e]);e.sendSignalOnOutput("stored")},error:function(t){e.setError(t||"Failed to save.")}})}))},scheduleStore(){if(this.hasScheduledStore)return;this.hasScheduledStore=!0;const e=this._internal;this.scheduleAfterInputsHaveUpdated((()=>{if(this.hasScheduledStore=!1,e.model){for(const t in e.inputValues)e.model.set(t,e.inputValues[t],{resolve:!0});this.sendSignalOnOutput("stored")}}))}}}};_addBaseInfo$1(SetDbModelPropertiedNodeDefinition),_addModelId$1(SetDbModelPropertiedNodeDefinition),_addInputProperties$1(SetDbModelPropertiedNodeDefinition),_addAccessControl(SetDbModelPropertiedNodeDefinition);const node$q=SetDbModelPropertiedNodeDefinition.node;var setdbmodelpropertiesnode=Object.freeze({__proto__:null,node:node$q});const DeleteDbModelPropertiedNodeDefinition={node:{name:"DeleteDbModelProperties",category:"",docs:"https://docs.noodl.net/nodes/data/cloud-data/delete-record",displayNodeName:"Delete Record",shortDesc:"Stores any amount of properties and can be used standalone or together with Collections and For Each nodes.",inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue(){this.storageDelete()}}},outputs:{deleted:{type:"signal",displayName:"Success",group:"Events"}},methods:{storageDelete(){const e=this._internal;this.checkWarningsBeforeCloudOp()&&this.scheduleOnce("StorageDelete",(()=>{e.model?CloudStore.forScope(this.nodeScope.ModelScope).delete({collection:e.collectionId,objectId:e.model.getId(),success:()=>{e.model.notify("delete"),this.sendSignalOnOutput("deleted")},error:e=>{this.setError(e||"Failed to delete.")}}):this.setError("Missing Record Id")}))}}}};_addBaseInfo$1(DeleteDbModelPropertiedNodeDefinition,{includeInputProperties:!1}),_addModelId$1(DeleteDbModelPropertiedNodeDefinition);const node$p=DeleteDbModelPropertiedNodeDefinition.node;var deletedbmodelpropertiesnode=Object.freeze({__proto__:null,node:node$p});const NewDbModelPropertiedNodeDefinition={node:{name:"NewDbModelProperties",category:"",docs:"https://docs.noodl.net/nodes/data/cloud-data/create-new-record",displayName:"Create New Record",usePortAsLabel:"collectionName",inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue(){this.storageInsert()}},sourceObjectId:{type:{name:"string",allowConnectionsOnly:!0},displayName:"Source Object Id",group:"General",set(e){e instanceof Model&&(e=e.getId()),this._internal.sourceObjectId=e}}},outputs:{created:{type:"signal",displayName:"Success",group:"Events"}},methods:{storageInsert(){const e=this._internal;this.checkWarningsBeforeCloudOp()&&this.scheduleOnce("StorageInsert",(()=>{const t=Object.assign({},e.sourceObjectId?(this.nodeScope.modelScope||Model).get(e.sourceObjectId).data:{},e.inputValues),n=CloudStore.forScope(this.nodeScope.modelScope);n.create({collection:e.collectionId,data:t,acl:this._getACL(),success:t=>{const o=n._fromJSON(t,e.collectionId);this.setModel(o),this.sendSignalOnOutput("created")},error:e=>{this.setError(e||"Failed to insert.")}})}))}}}};_addBaseInfo$1(NewDbModelPropertiedNodeDefinition),_addModelId$1(NewDbModelPropertiedNodeDefinition,{includeOutputs:!0}),_addInputProperties$1(NewDbModelPropertiedNodeDefinition),_addAccessControl(NewDbModelPropertiedNodeDefinition);const node$o=NewDbModelPropertiedNodeDefinition.node;var newdbmodelpropertiesnode=Object.freeze({__proto__:null,node:node$o});const AddDbModelRelationNodeDefinition$1={node:{name:"AddDbModelRelation",category:"Data",docs:"https://docs.noodl.net/nodes/data/cloud-data/add-record-relation",displayNodeName:"Add Record Relation",usePortAsLabel:"collectionName",inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue(){this.scheduleAddRelation()}}},outputs:{relationAdded:{type:"signal",displayName:"Success",group:"Events"}},methods:{validateInputs(){if(!this.context.editorConnection)return;const e=e=>{this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"add-relation",{message:e})};void 0===this._internal.collectionId?e("No class specified"):void 0===this._internal.relationProperty?e("No relation property specified"):void 0===this._internal.targetModelId?e("No target record Id (the record to add a relation to) specified"):void 0===this._internal.model?e("No record Id specified (the record that should get the relation)"):this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"add-relation")},scheduleAddRelation(){const e=this,t=this._internal;this.scheduleOnce("StorageAddRelation",(function(){if(e.validateInputs(),!t.model)return;const n=t.model,o=t.targetModelId;void 0!==o&&CloudStore.forScope(e.nodeScope.modelScope).addRelation({collection:t.collectionId,objectId:n.getId(),key:t.relationProperty,targetObjectId:o,targetClass:(e.nodeScope.modelScope||Model).get(o)._class,success:function(t){for(const e in t)n.set(e,t[e]);e.sendSignalOnOutput("relationAdded")},error:function(t){e.setError(t||"Failed to add relation.")}})}))}}}};_addBaseInfo$1(AddDbModelRelationNodeDefinition$1,{includeRelations:!0}),_addModelId$1(AddDbModelRelationNodeDefinition$1),_addRelationProperty(AddDbModelRelationNodeDefinition$1);const node$n=AddDbModelRelationNodeDefinition$1.node;var dbmodelnodeAddrelation=Object.freeze({__proto__:null,node:node$n});const AddDbModelRelationNodeDefinition={node:{name:"RemoveDbModelRelation",category:"",docs:"https://docs.noodl.net/nodes/data/cloud-data/remove-record-relation",displayName:"Remove Record Relation",usePortAsLabel:"collectionName",inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue(){this.scheduleRemoveRelation()}}},outputs:{relationRemoved:{type:"signal",displayName:"Success",group:"Events"}},methods:{validateInputs(){if(!this.context.editorConnection)return;const e=e=>{this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"add-relation",{message:e})};void 0===this._internal.collectionId?e("No class specified"):void 0===this._internal.relationProperty?e("No relation property specified"):void 0===this._internal.targetModelId?e("No target record Id (the record to add a relation to) specified"):void 0===this._internal.model?e("No record Id specified (the record that should get the relation)"):this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"add-relation")},scheduleRemoveRelation(){const e=this,t=this._internal;this.scheduleOnce("StorageRemoveRelation",(function(){if(e.validateInputs(),!t.model)return;const n=t.model,o=t.targetModelId;void 0!==o&&CloudStore.forScope(e.nodeScope.modelScope).removeRelation({collection:t.collectionId,objectId:n.getId(),key:t.relationProperty,targetObjectId:o,targetClass:(e.nodeScope.modelScope||Model).get(o)._class,success:function(t){for(const e in t)n.set(e,t[e]);e.sendSignalOnOutput("relationRemoved")},error:function(t){e.setError(t||"Failed to remove relation.")}})}))}}}};_addBaseInfo$1(AddDbModelRelationNodeDefinition,{includeRelations:!0}),_addModelId$1(AddDbModelRelationNodeDefinition),_addRelationProperty(AddDbModelRelationNodeDefinition);const node$m=AddDbModelRelationNodeDefinition.node;var dbmodelnodeRemoverelation=Object.freeze({__proto__:null,node:node$m});const node$l={name:"FilterDBModels",docs:"https://docs.noodl.net/nodes/data/cloud-data/filter-records",displayNodeName:"Filter Records",shortDesc:"Filter, sort and limit array",category:"Data",color:"data",initialize(){const e=this;this._internal.collectionChangedCallback=function(){!0!==e.isInputConnected("filter")&&e.scheduleFilter()},this._internal.cloudStoreEvents=function(t){!0!==e.isInputConnected("filter")&&void 0!==e._internal.visualFilter&&void 0!==e._internal.collection&&t.collection===e._internal.collectionName&&void 0!==t.objectId&&e._internal.collection.contains(Model.get(t.objectId))&&e.scheduleFilter()},CloudStore.instance.on("save",this._internal.cloudStoreEvents),this._internal.enabled=!0,this._internal.filterSettings={},this._internal.filterParameters={}},getInspectInfo(){const e=this._internal.filteredCollection;return e?[{type:"text",value:"Id: "+e.getId()},{type:"value",value:e.items}]:{type:"text",value:"[Not executed yet]"}},inputs:{items:{type:"array",displayName:"Items",group:"General",set(e){this.bindCollection(e),!1===this.isInputConnected("filter")&&this.scheduleFilter()}},enabled:{type:"boolean",group:"General",displayName:"Enabled",default:!0,set(e){this._internal.enabled=e,!1===this.isInputConnected("filter")&&this.scheduleFilter()}},filter:{type:"signal",group:"Actions",displayName:"Filter",valueChangedToTrue(){this.scheduleFilter()}}},outputs:{items:{type:"array",displayName:"Items",group:"General",getter(){return this._internal.filteredCollection}},firstItemId:{type:"string",displayName:"First Record Id",group:"General",getter(){if(void 0!==this._internal.filteredCollection){const e=this._internal.filteredCollection.get(0);if(void 0!==e)return e.getId()}}},count:{type:"number",displayName:"Count",group:"General",getter(){return this._internal.filteredCollection?this._internal.filteredCollection.size():0}},modified:{group:"Events",type:"signal",displayName:"Filtered"}},prototypeExtensions:{unbindCurrentCollection(){const e=this._internal.collection;e&&(e.off("change",this._internal.collectionChangedCallback),this._internal.collection=void 0)},bindCollection(e){this.unbindCurrentCollection(),this._internal.collection=e,e&&e.on("change",this._internal.collectionChangedCallback)},_onNodeDeleted(){Node.prototype._onNodeDeleted.call(this),this.unbindCurrentCollection(),CloudStore.instance.off("save",this._internal.cloudStoreEvents)},getLimit(){const e=this._internal.filterSettings;return e.filterEnableLimit?e.filterLimit||10:void 0},getSkip(){const e=this._internal.filterSettings;return e.filterEnableLimit?e.filterSkip||0:void 0},scheduleFilter(){this.collectionChangedScheduled||(this.collectionChangedScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{if(this.collectionChangedScheduled=!1,!this._internal.collection)return;let e=[].concat(this._internal.collection.items);if(this._internal.enabled){const t=this._internal.visualFilter;if(void 0!==t){const n=convertVisualFilter(t,{queryParameters:this._internal.filterParameters,collectionName:this._internal.collectionName});n&&(e=e.filter((e=>matchesQuery(e,n))))}const n=this._internal.visualSorting;if(void 0!==n&&n.length>0){const t=convertVisualSorting(n);t&&e.sort(compareObjects.bind(this,t))}const o=this.getSkip();o&&(e=e.slice(o,e.length));const i=this.getLimit();i&&(e=e.slice(0,i))}this._internal.filteredCollection=Collection.create(e),this.sendSignalOnOutput("modified"),this.flagOutputDirty("firstItemId"),this.flagOutputDirty("items"),this.flagOutputDirty("count")})))},setCollectionName(e){this._internal.collectionName=e},setVisualFilter(e){this._internal.visualFilter=e,!1===this.isInputConnected("filter")&&this.scheduleFilter()},setVisualSorting(e){this._internal.visualSorting=e,!1===this.isInputConnected("filter")&&this.scheduleFilter()},setFilterParameter:function(e,t){this._internal.filterParameters[e]=t,!1===this.isInputConnected("filter")&&this.scheduleFilter()},registerInputIfNeeded(e){if(!this.hasInput(e))return"collectionName"===e?this.registerInput(e,{set:this.setCollectionName.bind(this)}):"visualFilter"===e?this.registerInput(e,{set:this.setVisualFilter.bind(this)}):"visualSorting"===e?this.registerInput(e,{set:this.setVisualSorting.bind(this)}):e.startsWith("fp-")?this.registerInput(e,{set:this.setFilterParameter.bind(this,e.substring(3))}):void this.registerInput(e,{set(t){this._internal.filterSettings[e]=t,!1===this.isInputConnected("filter")&&this.scheduleFilter()}})}}};function updatePorts$4(e,t,n,o){const i=[];if(i.push({name:"collectionName",type:{name:"enum",enums:void 0!==o?o.map((e=>({value:e.name,label:e.name}))):[],allowEditOnly:!0},displayName:"Class",plug:"input",group:"General"}),i.push({type:"boolean",plug:"input",group:"Limit",name:"filterEnableLimit",displayName:"Use limit"}),t.filterEnableLimit&&(i.push({type:"number",default:10,plug:"input",group:"Limit",name:"filterLimit",displayName:"Limit"}),i.push({type:"number",default:0,plug:"input",group:"Limit",name:"filterSkip",displayName:"Skip"})),void 0!==t.collectionName){const e=o.find((e=>e.name===t.collectionName));if(e&&e.schema&&e.schema.properties){const t=JSON.parse(JSON.stringify(e.schema)),n={Boolean:!0,String:!0,Date:!0,Number:!0,Pointer:!0};for(const e in t.properties)n[t.properties[e].type]||delete t.properties[e];i.push({name:"visualFilter",plug:"input",type:{name:"query-filter",schema:t,allowEditOnly:!0},displayName:"Filter",group:"Filter"}),i.push({name:"visualSorting",plug:"input",type:{name:"query-sorting",schema:t,allowEditOnly:!0},displayName:"Sorting",group:"Sorting"})}if(void 0!==t.visualFilter){const e={};_collectInputs(e,t.visualFilter),Object.keys(e).forEach((e=>{i.push({name:"fp-"+e,plug:"input",type:"*",displayName:e,group:"Filter Parameters"})}))}}n.sendDynamicPorts(e,i)}function setup$5(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("nodeAdded.FilterDBModels",(function(n){updatePorts$4(n.id,n.parameters,e.editorConnection,t.getMetaData("dbCollections")),n.on("parameterUpdated",(function(){updatePorts$4(n.id,n.parameters,e.editorConnection,t.getMetaData("dbCollections"))})),t.on("metadataChanged.dbCollections",(function(t){CloudStore.invalidateCollections(),updatePorts$4(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.systemCollections",(function(t){CloudStore.invalidateCollections(),updatePorts$4(n.id,n.parameters,e.editorConnection,t)}))}))}function _collectInputs(e,t){void 0!==t&&(void 0!==t.rules?t.rules.forEach((t=>_collectInputs(e,t))):void 0!==t.input&&(e[t.input]=!0))}var filterdbmodelsnode=Object.freeze({__proto__:null,node:node$l,setup:setup$5});const node$k={name:"Model2",docs:"https://docs.noodl.net/nodes/data/object/object-node",displayNodeName:"Object",shortDesc:"Stores any amount of properties and can be used standalone or together with Collections and For Each nodes.",category:"Data",usePortAsLabel:"modelId",color:"data",dynamicports:[{name:"conditionalports/extended",condition:"idSource = explicit OR idSource NOT SET",inputs:["modelId"]}],initialize(){const e=this._internal;e.inputValues={},e.dirtyValues={},e.onModelChangedCallback=e=>{!0!==this.isInputConnected("fetch")&&(this.hasOutput("prop-"+e.name)&&this.flagOutputDirty("prop-"+e.name),this.hasOutput("changed-"+e.name)&&this.sendSignalOnOutput("changed-"+e.name),this.sendSignalOnOutput("changed"))}},getInspectInfo(){const e=this._internal.model;return e?[{type:"text",value:"Id: "+e.getId()},{type:"value",value:e.data}]:"[No Object]"},outputs:{id:{type:"string",displayName:"Id",group:"General",getter(){return this._internal.model?this._internal.model.getId():this._internal.modelId}},changed:{type:"signal",displayName:"Changed",group:"Events"},fetched:{type:"signal",displayName:"Fetched",group:"Events"}},inputs:{idSource:{type:{name:"enum",enums:[{label:"Specify explicitly",value:"explicit"},{label:"From repeater",value:"foreach"}],allowEditOnly:!0},default:"explicit",displayName:"Get Id from",group:"General",set(e){"foreach"===e&&this.scheduleAfterInputsHaveUpdated((()=>{let e=this.nodeScope.componentOwner;for(;void 0!==e&&void 0===e._forEachModel&&e.parentNodeScope;)e=e.parentNodeScope.componentOwner;this.setModel(void 0!==e?e._forEachModel:void 0)}))}},modelId:{type:{name:"string",identifierOf:"ModelName",identifierDisplayName:"Object Ids"},displayName:"Id",group:"General",set(e){e instanceof Model?e=e.getId():"object"==typeof e&&(e=Model.create(e).getId()),this._internal.modelId=e,!1===this.isInputConnected("fetch")?this.setModelID(e):this.flagOutputDirty("id")}},properties:{type:{name:"stringlist",allowEditOnly:!0},displayName:"Properties",group:"Properties",set(e){}},fetch:{displayName:"Fetch",group:"Actions",valueChangedToTrue(){this.scheduleSetModel()}}},prototypeExtensions:{scheduleStore(){if(this.hasScheduledStore)return;this.hasScheduledStore=!0;const e=this._internal;this.scheduleAfterInputsHaveUpdated((()=>{if(this.hasScheduledStore=!1,e.model){for(const t in e.dirtyValues)e.model.set(t,e.inputValues[t],{resolve:!0});e.dirtyValues={}}}))},scheduleSetModel(){this.hasScheduledSetModel||(this.hasScheduledSetModel=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.hasScheduledSetModel=!1,this.setModelID(this._internal.modelId)})))},setModelID(e){const t=(this.nodeScope.modelScope||Model).get(e);this.setModel(t),this.sendSignalOnOutput("fetched")},setModel(e){if(this._internal.model&&this._internal.model.off("change",this._internal.onModelChangedCallback),this._internal.model=e,this.flagOutputDirty("id"),e){e.on("change",this._internal.onModelChangedCallback);for(const t in e.data)this.hasOutput("prop-"+t)&&this.flagOutputDirty("prop-"+t)}},_onNodeDeleted(){this._internal.model&&this._internal.model.off("change",this._internal.onModelChangedCallback)},registerOutputIfNeeded(e){this.hasOutput(e)||e.startsWith("prop-")&&this.registerOutput(e,{getter:userOutputGetter.bind(this,e.substring(5))})},registerInputIfNeeded(e){this.hasInput(e)||e.startsWith("prop-")&&this.registerInput(e,{set:userInputSetter.bind(this,e.substring(5))})}}};function userOutputGetter(e){return this._internal.model?this._internal.model.get(e,{resolve:!0}):void 0}function userInputSetter(e,t){this._internal.inputValues[e]=t;const n=this._internal.model;(!n||n.get(e)!==t)&&(this._internal.dirtyValues[e]=!0,this.scheduleStore())}function updatePorts$3(e,t,n){const o=[],i=t.properties;if(i){const e=i?i.split(","):void 0;if(e)for(const t of e)o.push({type:{name:"*",allowConnectionsOnly:!0},plug:"input/output",group:"Properties",name:"prop-"+t,displayName:t}),o.push({type:"signal",plug:"output",group:"Changed Events",displayName:t+" Changed",name:"changed-"+t})}n.sendDynamicPorts(e,o,{detectRenamed:{plug:"input/output"}})}function setup$4(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("nodeAdded.Model2",(function(t){updatePorts$3(t.id,t.parameters,e.editorConnection),t.on("parameterUpdated",(function(){updatePorts$3(t.id,t.parameters,e.editorConnection)}))}))}var modelnode2=Object.freeze({__proto__:null,node:node$k,setup:setup$4});function _addBaseInfo(e){Object.assign(e.node,{category:"Data",color:"data"})}function _addModelId(e,t){const n=void 0===t||t.includeInputs,o=void 0===t||t.includeOutputs;Object.assign(e.node,{inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),n&&(Object.assign(e.node,{usePortAsLabel:"modelId"}),e.node.dynamicports=(e.node.dynamicports||[]).concat([{name:"conditionalports/extended",condition:"idSource = explicit OR idSource NOT SET",inputs:["modelId"]}]),Object.assign(e.node.inputs,{idSource:{type:{name:"enum",enums:[{label:"Specify explicitly",value:"explicit"},{label:"From repeater",value:"foreach"}],allowEditOnly:!0},default:"explicit",displayName:"Id Source",group:"General",set(e){"foreach"===e&&this.scheduleAfterInputsHaveUpdated((()=>{let e=this.nodeScope.componentOwner;for(;void 0!==e&&void 0===e._forEachModel&&e.parentNodeScope;)e=e.parentNodeScope.componentOwner;this.setModel(void 0!==e?e._forEachModel:void 0)}))}},modelId:{type:{name:"string",identifierOf:"ModelName",identifierDisplayName:"Object Ids"},displayName:"Id",group:"General",set:function(e){e instanceof Model&&(e=e.getId()),this._internal.modelId=e,this.setModelID(e)}}})),o&&Object.assign(e.node.outputs,{id:{type:"string",displayName:"Id",group:"General",getter:function(){return this._internal.model?this._internal.model.getId():this._internal.modelId}}}),Object.assign(e.node.methods,{setModelID:function(e){const t=(this.nodeScope.modelScope||Model).get(e);this.setModel(t)},setModel:function(e){this._internal.model=e,this.flagOutputDirty("id")}}),e.node.getInspectInfo||(e.node.getInspectInfo=function(){const e=this._internal.model;return e?[{type:"text",value:"Id: "+e.getId()},{type:"value",value:e.data}]:"[No Object]"})}function _addInputProperties(def){const _def={node:Object.assign({},def.node),setup:def.setup},_methods=Object.assign({},def.node.methods);Object.assign(def.node,{inputs:def.node.inputs||{},outputs:def.node.outputs||{},methods:def.node.methods||{}}),Object.assign(def,{setup:function(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&(t.on("nodeAdded."+def.node.name,(function(t){function n(){const n=[],o=[{label:"String",value:"string"},{label:"Boolean",value:"boolean"},{label:"Number",value:"number"},{label:"Date",value:"date"},{label:"Array",value:"array"},{label:"Object",value:"object"},{label:"Any",value:"*"}];let i=t.parameters.properties;if(i){i=i?i.split(","):void 0;for(const e of i)n.push({type:{name:void 0===t.parameters["type-"+e]?"*":t.parameters["type-"+e]},plug:"input",group:"Property Values",displayName:e,name:"prop-"+e}),n.push({type:{name:"enum",enums:o,allowEditOnly:!0},plug:"input",group:"Property Types",displayName:e,default:"*",name:"type-"+e})}e.editorConnection.sendDynamicPorts(t.id,n,{detectRenamed:{plug:"input"}})}n(),t.on("parameterUpdated",(function(){n()}))})),_def.setup&&_def.setup(e,t))}}),Object.assign(def.node,{initialize:function(){const e=this._internal;e.inputValues={},e.inputTypes={},_def.node.initialize&&_def.node.initialize.call(this)}}),Object.assign(def.node.outputs,{}),Object.assign(def.node.inputs,{properties:{type:{name:"stringlist",allowEditOnly:!0},displayName:"Properties",group:"Properties to set",set:function(){}}}),Object.assign(def.node.methods,{_pushInputValues:function(model){const internal=this._internal,_defaultValueForType={boolean:!1,string:"",number:0,date:new Date},_allKeys={};for(const e in internal.inputTypes)_allKeys[e]=!0;for(const e in internal.inputValues)_allKeys[e]=!0;const properties=this.model.parameters.properties||"",validProperties=properties.split(","),keysToSet=Object.keys(_allKeys).filter((e=>-1!==validProperties.indexOf(e)));for(const i of keysToSet){let value=internal.inputValues[i];if(void 0!==value){if(void 0!==internal.inputTypes[i]&&"array"===internal.inputTypes[i]&&"string"==typeof value){this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"invalid-array-"+i);try{value=eval(value)}catch(e){-1!==value.indexOf("[")||-1!==value.indexOf("{")?(this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"invalid-array-"+i,{showGlobally:!0,message:"Invalid array
"+e.toString()}),value=[]):value=Collection.get(value)}}void 0!==internal.inputTypes[i]&&"object"===internal.inputTypes[i]&&"string"==typeof value&&(value=(this.nodeScope.modelScope||Model).get(value)),model.set(i,value,{resolve:!0})}else model.set(i,_defaultValueForType[internal.inputTypes[i]],{resolve:!0})}},scheduleStore:function(){if(this.hasScheduledStore)return;this.hasScheduledStore=!0;const e=this._internal;this.scheduleAfterInputsHaveUpdated((()=>{this.hasScheduledStore=!1,e.model&&(this._pushInputValues(e.model),this.sendSignalOnOutput("stored"))}))},registerInputIfNeeded:function(e){this.hasInput(e)||(e.startsWith("prop-")&&this.registerInput(e,{set:this._setInputValue.bind(this,e.substring(5))}),e.startsWith("type-")&&this.registerInput(e,{set:this._setInputType.bind(this,e.substring(5))}),_methods&&_methods.registerInputIfNeeded&&_def.node.methods.registerInputIfNeeded.call(this,e))},_setInputValue:function(e,t){this._internal.inputValues[e]=t},_setInputType:function(e,t){this._internal.inputTypes[e]=t}})}const SetModelPropertiedNodeDefinition={node:{name:"SetModelProperties",category:"",docs:"https://docs.noodl.net/nodes/data/object/set-object-properties",displayNodeName:"Set Object Properties",inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue:function(){this.scheduleStore()}}},outputs:{stored:{type:"signal",displayName:"Done",group:"Events"}}}};_addBaseInfo(SetModelPropertiedNodeDefinition),_addModelId(SetModelPropertiedNodeDefinition),_addInputProperties(SetModelPropertiedNodeDefinition);const node$j=SetModelPropertiedNodeDefinition.node;var setmodelpropertiesnode=Object.freeze({__proto__:null,node:node$j});const NewModelNodeDefinition={node:{name:"NewModel",category:"",docs:"https://docs.noodl.net/nodes/data/object/create-new-object",displayNodeName:"Create New Object",inputs:{new:{displayName:"Do",group:"Actions",valueChangedToTrue(){this.scheduleNew()}}},outputs:{created:{type:"signal",displayName:"Done",group:"Events"}},methods:{scheduleNew(){this.hasScheduledNew||(this.hasScheduledNew=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.hasScheduledNew=!1;const e=(this.nodeScope.modelScope||Model).get();this._pushInputValues(e),this.setModel(e),this.sendSignalOnOutput("created")})))}}}};_addBaseInfo(NewModelNodeDefinition),_addModelId(NewModelNodeDefinition,{includeOutputs:!0}),_addInputProperties(NewModelNodeDefinition);const node$i=NewModelNodeDefinition.node;var newmodelnode=Object.freeze({__proto__:null,node:node$i});const node$h={name:"Cloud File",docs:"https://docs.noodl.net/nodes/data/cloud-data/cloud-file",category:"Cloud Services",color:"data",getInspectInfo(){var e;return null===(e=this._internal.cloudFile)||void 0===e?void 0:e.getUrl()},outputs:{url:{type:"string",displayName:"URL",group:"General",getter(){var e;return null===(e=this._internal.cloudFile)||void 0===e?void 0:e.getUrl()}},name:{type:"string",displayName:"Name",group:"General",getter(){if(!this._internal.cloudFile)return;const e=this._internal.cloudFile.getName().split("_");return 1===e.length?e[0]:e.slice(1).join("_")}}},inputs:{file:{type:"cloudfile",displayName:"Cloud File",group:"General",set(e){e instanceof CloudFile&&(this._internal.cloudFile=e,this.flagOutputDirty("name"),this.flagOutputDirty("url"))}}}};var cloudfilenode=Object.freeze({__proto__:null,node:node$h});class ConfigService{constructor(){this.cacheDuration=9e5}_makeRequest(e,t){if("undefined"==typeof _noodl_cloud_runtime_version){const n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState){let e;try{e=JSON.parse(n.response)}catch(e){}200===n.status||201===n.status?t.success(e):t.error(e||{error:n.responseText,status:n.status})}};const o=NoodlRuntime$1.instance.getMetaData("cloudservices"),i=o.appId,s=o.endpoint;n.open("GET",s+e,!0),n.setRequestHeader("X-Parse-Application-Id",i),n.send()}else{const n="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.endpoint:this.endpoint,o="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.appId:this.appId,i="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.masterKey:void 0;fetch(n+e,{method:"GET",headers:{"X-Parse-Application-Id":o,"X-Parse-Master-Key":i}}).then((e=>{200===e.status||201===e.status?e.json().then((e=>t.success(e))).catch((e=>t.error({error:"Config: Failed to get json result."}))):e.json().then((e=>t.error(e))).catch((e=>t.error({error:"Failed to fetch."})))})).catch((e=>{t.error({error:e.message})}))}}_getConfig(){return new Promise(((e,t)=>{this._makeRequest("/config",{success:t=>{e(t.params||{})},error:e=>{t(e)}})}))}async getConfig(){return this.configCachePending?this.configCachePending:this.configCache?(this.ttl&&Date.now()>this.ttl&&this._getConfig().then((e=>{this.configCache=e,this.ttl=Date.now()+this.cacheDuration})),this.configCache):(this.configCachePending=this._getConfig(),this.configCache=await this.configCachePending,delete this.configCachePending,this.ttl=Date.now()+this.cacheDuration,this.configCache)}clearCache(){delete this.configCache}}ConfigService.instance=new ConfigService;const ConfigNodeDefinition={name:"DbConfig",docs:"https://docs.noodl.net/nodes/data/cloud-data/config",displayNodeName:"Config",category:"Cloud Services",usePortAsLabel:"configKey",color:"data",initialize:function(){const e=this._internal;ConfigService.instance.getConfig().then((t=>{e.config=t,this.hasOutput("value")&&this.flagOutputDirty("value")}))},getInspectInfo(){const e=this.getValue();return void 0===e?"[No Value]":[{type:"value",value:e}]},methods:{getValue:function(){const e=this._internal;return e.useDevValue&&this.context.editorConnection&&this.context.editorConnection.isRunningLocally()?e.devValue:void 0!==e.config&&void 0!==e.configKey?e.config[e.configKey]:void 0},setInternal:function(e,t){this._internal[e]=t,this.hasOutput("value")&&this.flagOutputDirty("value")},registerOutputIfNeeded:function(e){if(!this.hasOutput(e))return"value"===e?this.registerOutput(e,{getter:this.getValue.bind(this)}):void 0},registerInputIfNeeded:function(e){if(!this.hasInput(e))return"configKey"===e||"useDevValue"===e||"devValue"===e?this.registerInput(e,{set:this.setInternal.bind(this,e)}):void 0}}},node$g=ConfigNodeDefinition;function setup$3(e,t){function n(n){const o=[];e.editorConnection.clearWarning(n.component.name,n.id,"dbconfig-warning");const i=t.getMetaData("dbConfigSchema");let s;if(i){const t=void 0!==__webpack_require__.g._noodl_cloud_runtime_version;o.push({name:"configKey",displayName:"Parameter",group:"General",type:{name:"enum",enums:Object.keys(i).filter((e=>t||!i[e].masterKeyOnly)).map((e=>({value:e,label:e}))),allowEditOnly:!0},plug:"input"}),void 0!==n.parameters.configKey&&i&&i[n.parameters.configKey]?(s=i[n.parameters.configKey].type,"string"!==s&&"boolean"!==s&&"number"!==s&&"object"!==s&&"array"!==s||(o.push({name:"useDevValue",displayName:"Enable",group:"Local Override",type:"boolean",default:!1,plug:"input"}),!0===n.parameters.useDevValue&&o.push({name:"devValue",displayName:"Value",group:"Local Override",type:s,plug:"input"}))):void 0!==n.parameters.configKey&&e.editorConnection.sendWarning(n.component.name,n.id,"dbconfig-warning",{showGlobally:!0,message:n.parameters.configKey+" config parameter is missing, add it to your cloud service."})}else e.editorConnection.sendWarning(n.component.name,n.id,"dbconfig-warning",{showGlobally:!0,message:"You need an active cloud service."});o.push({name:"value",displayName:"Value",group:"General",type:s||"*",plug:"output"}),e.editorConnection.sendDynamicPorts(n.id,o)}function o(e){n(e),e.on("parameterUpdated",(function(){n(e)})),t.on("metadataChanged.dbConfigSchema",(function(){ConfigService.instance.clearCache(),n(e)}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.DbConfig",(function(e){o(e)}));for(const e of t.getNodesWithType("DbConfig"))o(e)}))}var dbconfig=Object.freeze({__proto__:null,node:node$g,setup:setup$3});function createDefinition(e){return{name:e.name,docs:e.docs,shortDesc:e.shortDesc,nodeDoubleClickAction:e.nodeDoubleClickAction,category:"Variables",initialize(){this._internal.currentValue=e.startValue,this._internal.latestValue=0},getInspectInfo(){return[{type:"color"===e.type.name?"color":"text",value:this._internal.currentValue}]},inputs:{value:{type:e.type,displayName:"Value",default:e.startValue,set(e){!1===this.isInputConnected("saveValue")?this.setValueTo(e):this._internal.latestValue=e}},saveValue:{displayName:"Set",valueChangedToTrue(){this.scheduleAfterInputsHaveUpdated((function(){this.setValueTo(this._internal.latestValue),this.sendSignalOnOutput("stored")}))}}},outputs:{savedValue:{type:e.type.name,displayName:"Value",getter(){return this._internal.currentValue}},changed:{type:"signal",displayName:"Changed"},stored:{type:"signal",displayName:"Stored"}},prototypeExtensions:{setValueTo(t){t=e.cast(t);const n=this._internal.currentValue!==t;this._internal.currentValue=t,n&&(this.flagOutputDirty("savedValue"),this.sendSignalOnOutput("changed"),e.onChanged&&e.onChanged.call(this))}}}}const node$f=createDefinition({name:"Number",docs:"https://docs.noodl.net/nodes/data/number",startValue:0,nodeDoubleClickAction:{focusPort:"value"},type:{name:"number"},cast:e=>Number(e)});var number=Object.freeze({__proto__:null,node:node$f});const StringNode=createDefinition({name:"String",docs:"https://docs.noodl.net/nodes/data/string",shortDesc:"Contains a string (text).",startValue:"",nodeDoubleClickAction:{focusPort:"value"},type:{name:"string"},cast:e=>String(e),onChanged:function(){this.flagOutputDirty("length")}});extend(StringNode,{usePortAsLabel:"value",portLabelTruncationMode:"length",outputs:{length:{type:"number",displayName:"Length",getter:function(){return this._internal.currentValue.length}}}});const node$e=StringNode;var string=Object.freeze({__proto__:null,node:node$e});const node$d=createDefinition({name:"Boolean",docs:"https://docs.noodl.net/nodes/data/boolean",startValue:!1,type:{name:"boolean"},cast:e=>Boolean(e)});var boolean=Object.freeze({__proto__:null,node:node$d});const node$c={name:"Condition",docs:"https://docs.noodl.net/nodes/utilities/logic/condition",category:"Logic",initialize(){},getInspectInfo(){const e=this.getInputValue("condition");let t;return t=void 0===e?"[No input]":e,[{type:"value",value:t}]},inputs:{condition:{type:"boolean",displayName:"Condition",group:"General",set(e){this.isInputConnected("eval")||this.scheduleEvaluate()}},eval:{type:"signal",displayName:"Evaluate",group:"Actions",valueChangedToTrue(){this.scheduleEvaluate()}}},outputs:{ontrue:{type:"signal",displayName:"On True",group:"Events"},onfalse:{type:"signal",displayName:"On False",group:"Events"},result:{type:"boolean",displayName:"Is True",group:"Booleans",getter(){return!!this.getInputValue("condition")}},isfalse:{type:"boolean",displayName:"Is False",group:"Booleans",getter(){return!this.getInputValue("condition")}}},methods:{scheduleEvaluate(){this.scheduleAfterInputsHaveUpdated((()=>{this.flagOutputDirty("result"),this.flagOutputDirty("isfalse");const e=this.getInputValue("condition");this.sendSignalOnOutput(e?"ontrue":"onfalse")}))}}};var condition=Object.freeze({__proto__:null,node:node$c});function and(e){return e.length>0&&!1===e.some((e=>!e))}const node$b={name:"And",docs:"https://docs.noodl.net/nodes/logic/and",category:"Logic",initialize(){this._internal={inputs:[]}},getInspectInfo(){return and(this._internal.inputs)},numberedInputs:{input:{displayPrefix:"Input",type:"boolean",createSetter:e=>function(t){const n=!!t;if(this._internal.inputs[e]===n)return;this._internal.inputs[e]=n;const o=and(this._internal.inputs);this._internal.result!==o&&(this._internal.result=o,this.flagOutputDirty("result"))}}},outputs:{result:{type:"boolean",displayName:"Result",get(){return this._internal.result}}}};var and$1=Object.freeze({__proto__:null,node:node$b});function isTrue(e){return!!e}const node$a={name:"Or",docs:"https://docs.noodl.net/nodes/logic/or",category:"Logic",initialize(){this._internal.inputs=[]},getInspectInfo(){return this._internal.inputs.some(isTrue)},numberedInputs:{input:{type:"boolean",displayPrefix:"Input",createSetter:e=>function(t){this._internal.inputs[e]!==t&&(this._internal.inputs[e]=t,this.flagOutputDirty("result"))}}},outputs:{result:{type:"boolean",displayName:"Result",getter:function(){return this._internal.inputs.some(isTrue)}}}};var or=Object.freeze({__proto__:null,node:node$a});const node$9={name:"Boolean To String",docs:"https://docs.noodl.net/nodes/utilities/boolean-to-string",category:"Utilities",initialize(){this._internal.inputs=[],this._internal.currentSelectedIndex=0,this._internal.indexChanged=!1,this._internal.trueString="",this._internal.falseString=""},inputs:{trueString:{displayName:"String for true",type:"string",set(e){this._internal.trueString!==e&&(this._internal.trueString=e,this._internal.currentInput&&this.flagOutputDirty("currentValue"))}},falseString:{displayName:"String for false",type:"string",set(e){this._internal.falseString!==e&&(this._internal.falseString=e,this._internal.currentInput||this.flagOutputDirty("currentValue"))}},input:{type:{name:"boolean"},displayName:"Selector",set(e){this._internal.currentInput!==e&&(this._internal.currentInput=e,this.flagOutputDirty("currentValue"),this.sendSignalOnOutput("inputChanged"))}}},outputs:{currentValue:{type:"string",displayName:"Current Value",group:"Value",getter(){return this._internal.currentInput?this._internal.trueString:this._internal.falseString}},inputChanged:{type:"signal",displayName:"Selector Changed",group:"Signals"}}};var booleantostring=Object.freeze({__proto__:null,node:node$9});const node$8={name:"Date To String",docs:"https://docs.noodl.net/nodes/utilities/date-to-string",category:"Utilities",initialize(){this._internal.formatString="{year}-{month}-{date}"},inputs:{formatString:{displayName:"Format",type:"string",default:"{year}-{month}-{date}",set(e){this._internal.formatString!==e&&(this._internal.formatString=e,void 0!==this._internal.currentInput&&(this._format(),this.flagOutputDirty("currentValue")))}},input:{type:{name:"date"},displayName:"Date",set(e){const t="string"==typeof e?new Date(e):e;this._internal.currentInput!==t&&(this._internal.currentInput=t,this._format())}}},outputs:{currentValue:{type:"string",displayName:"Date String",group:"Value",getter(){return this._internal.dateString}},inputChanged:{type:"signal",displayName:"Date Changed",group:"Signals"},onError:{type:"signal",displayName:"Invalid Date",group:"Signals"}},methods:{_format(){try{const e=this._internal.currentInput,t=this._internal.formatString,n=("0"+e.getDate()).slice(-2),o=("0"+(e.getMonth()+1)).slice(-2),i=new Intl.DateTimeFormat("en-US",{month:"short"}).format(e),s=e.getFullYear(),r=s.toString().substring(2),a=("0"+e.getHours()).slice(-2),l=("0"+e.getMinutes()).slice(-2),d=("0"+e.getSeconds()).slice(-2);this._internal.dateString=t.replace(/\{date\}/g,n).replace(/\{month\}/g,String(o)).replace(/\{monthShort\}/g,i).replace(/\{year\}/g,String(s)).replace(/\{yearShort\}/g,String(r)).replace(/\{hours\}/g,String(a)).replace(/\{minutes\}/g,String(l)).replace(/\{seconds\}/g,String(d))}catch(e){this._internal.dateString="",this.flagOutputDirty("onError")}this.flagOutputDirty("currentValue"),this.sendSignalOnOutput("inputChanged")}}};var datetostring=Object.freeze({__proto__:null,node:node$8});const node$7={name:"String Mapper",docs:"https://docs.noodl.net/nodes/string-manipulation/string-mapper",category:"Utilities",initialize(){this._internal={inputs:[],mappings:[]}},getInspectInfo(){return this._internal.mappedString},numberedInputs:{input:{type:"string",displayPrefix:"Input",group:"Inputs",index:10,createSetter:e=>function(t){t=void 0===t?"":String(t),this._internal.inputs[e]=t,this.scheduleMapping()}},output:{type:"string",displayPrefix:"Mapping",index:1001,group:"Mappings",createSetter:e=>function(t){t=void 0===t?"":String(t),this._internal.mappings[e]=t,this.scheduleMapping()}}},inputs:{inputString:{type:{name:"string"},index:1,displayName:"Input String",set(e){this._internal.currentInputString=void 0!==e?String(e):void 0,this.scheduleMapping()}},defaultMapping:{type:"string",displayName:"Default",index:1e3,group:"Mappings",set(e){this._internal.defaultMapping=e,this.scheduleMapping()}}},outputs:{mappedString:{type:"string",displayName:"Mapped String",group:"Value",getter(){return this._internal.mappedString}}},prototypeExtensions:{doMapping(){this._internal.hasScheduledFetch=!1;const e=this._internal.inputs.indexOf(this._internal.currentInputString);this._internal.mappedString=-1!==e?this._internal.mappings[e]:this._internal.defaultMapping,this.flagOutputDirty("mappedString")},scheduleMapping(){const e=this._internal;e.hasScheduledFetch||(e.hasScheduledFetch=!0,this.scheduleAfterInputsHaveUpdated(this.doMapping.bind(this)))}}};var stringmapper=Object.freeze({__proto__:null,node:node$7});function invert(e){if(void 0!==e)return!e}const node$6={name:"Inverter",docs:"https://docs.noodl.net/nodes/logic/inverter",category:"Logic",initialize(){this._internal.currentValue=void 0},getInspectInfo(){return String(invert(this._internal.currentValue))},inputs:{value:{type:{name:"boolean"},displayName:"Value",set(e){this._internal.currentValue=e,this.flagOutputDirty("result")}}},outputs:{result:{type:"boolean",displayName:"Result",getter(){return invert(this._internal.currentValue)}}}};var inverter=Object.freeze({__proto__:null,node:node$6});const node$5={name:"Substring",docs:"https://docs.noodl.net/nodes/string-manipulation/substring",category:"String Manipulation",initialize(){var e=this._internal;e.startIndex=0,e.endIndex=-1,e.cachedResult="",e.inputString="",e.resultDirty=!1},inputs:{start:{type:"number",displayName:"Start",default:0,set(e){this._internal.startIndex=e,this._internal.resultDirty=!0,this.flagOutputDirty("result")}},end:{type:"number",displayName:"End",default:0,set(e){this._internal.endIndex=e,this._internal.resultDirty=!0,this.flagOutputDirty("result")}},string:{type:{name:"string"},displayName:"String",default:"",set(e){const t=String(e);this._internal.inputString=t,this._internal.resultDirty=!0,this.flagOutputDirty("result")}}},outputs:{result:{type:"string",displayName:"Result",getter(){var e=this._internal;return e.resultDirty&&(-1===e.endIndex?e.cachedResult=e.inputString.substr(e.startIndex):e.cachedResult=e.inputString.substr(e.startIndex,e.endIndex-e.startIndex),e.resultDirty=!1),e.cachedResult}}}};var substring=Object.freeze({__proto__:null,node:node$5});const node$4={name:"String Format",docs:"https://docs.noodl.net/nodes/string-manipulation/string-format",category:"String Manipulation",usePortAsLabel:"format",portLabelTruncationMode:"length",initialize(){const e=this._internal;e.format="",e.cachedResult="",e.resultDirty=!1,e.inputValues={}},getInspectInfo(){return this.formatValue()},inputs:{format:{type:{name:"string",multiline:!0},displayName:"Format",set(e){this._internal.format!==e&&(this._internal.format=e,this._internal.resultDirty=!0,this.scheduleFormat())}}},outputs:{formatted:{type:"string",displayName:"Formatted",get(){return this.formatValue()}}},methods:{formatValue(){const e=this._internal;if(e.resultDirty){let t=e.format;const n=e.format.match(/\{[A-Za-z0-9_]*\}/g);let o=[];n&&(o=n.map((e=>e.replace("{","").replace("}","")))),o.forEach((n=>{const o=e.inputValues[n];t=t.replace("{"+n+"}",void 0!==o?o:"")})),e.cachedResult=t,e.resultDirty=!1}return e.cachedResult},registerInputIfNeeded(e){this.hasInput(e)||this.registerInput(e,{set(t){this._internal.inputValues[e]!==t&&(this._internal.inputValues[e]=t,this._internal.resultDirty=!0,this.scheduleFormat())}})},scheduleFormat(){this.formatScheduled||(this.formatScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.formatValue(),this.flagOutputDirty("formatted"),this.formatScheduled=!1})))}}};function updatePorts$2(e,t,n){const o=(t.match(/\{[A-Za-z0-9_]*\}/g)||[]).map((e=>e.replace("{","").replace("}",""))).filter(((e,t,n)=>n.indexOf(e)===t)).map((e=>({name:e,type:"string",plug:"input"})));n.sendDynamicPorts(e,o)}function setup$2(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("nodeAdded.String Format",(t=>{t.parameters.format&&updatePorts$2(t.id,t.parameters.format,e.editorConnection),t.on("parameterUpdated",(n=>{"format"===n.name&&updatePorts$2(t.id,t.parameters.format,e.editorConnection)}))}))}var stringformat=Object.freeze({__proto__:null,node:node$4,setup:setup$2});const node$3={name:"Counter",docs:"https://docs.noodl.net/nodes/math/counter",category:"Math",initialize(){this._internal.currentValue=0,this._internal.startValue=0,this._internal.startValueSet=!1,this._internal.limitsEnabled=!1,this._internal.limitsMin=0,this._internal.limitsMax=0},getInspectInfo(){return"Count: "+this._internal.currentValue},inputs:{increase:{group:"Actions",displayName:"Increase Count",valueChangedToTrue(){this._internal.limitsEnabled&&this._internal.currentValue>=this._internal.limitsMax||(this._internal.currentValue++,this.flagOutputDirty("currentCount"),this.sendSignalOnOutput("countChanged"))}},decrease:{group:"Actions",displayName:"Decrease Count",valueChangedToTrue(){this._internal.limitsEnabled&&this._internal.currentValue<=this._internal.limitsMin||(this._internal.currentValue--,this.flagOutputDirty("currentCount"),this.sendSignalOnOutput("countChanged"))}},reset:{group:"Actions",displayName:"Reset To Start",valueChangedToTrue(){0!==this.currentValue&&(this._internal.currentValue=this._internal.startValue,this.flagOutputDirty("currentCount"),this.sendSignalOnOutput("countChanged"))}},startValue:{type:"number",displayName:"Start Value",default:0,set(e){this._internal.startValue=Number(e),!1===this._internal.startValueSet&&(this._internal.startValueSet=!0,this._internal.currentValue=this._internal.startValue,this.flagOutputDirty("currentCount"),this.sendSignalOnOutput("countChanged"))}},limitsMin:{type:{name:"number"},displayName:"Min Value",group:"Limits",default:0,set(e){this._internal.limitsMin=Number(e)}},limitsMax:{type:{name:"number"},displayName:"Max Value",group:"Limits",default:0,set(e){this._internal.limitsMax=Number(e)}},limitsEnabled:{type:{name:"boolean"},displayName:"Limits Enabled",group:"Limits",default:!1,set(e){this._internal.limitsEnabled=!!e}}},outputs:{currentCount:{displayName:"Current Count",type:"number",getter(){return this._internal.currentValue}},countChanged:{displayName:"Count Changed",type:"signal"}}};var counter=Object.freeze({__proto__:null,node:node$3});const node$2={name:"Unique Id",docs:"https://docs.noodl.net/nodes/utilities/unique-id",category:"String Manipulation",initialize(){this._internal.guid=guid()},getInspectInfo(){return this._internal.guid},inputs:{new:{displayName:"New",valueChangedToTrue:function(){this._internal.guid=guid(),this.flagOutputDirty("guid")}}},outputs:{guid:{type:"string",displayName:"Id",getter:function(){return this._internal.guid}}},prototypeExtensions:{}};var uniqueid=Object.freeze({__proto__:null,node:node$2});const node$1={name:"net.noodl.user.SetUserProperties",docs:"https://docs.noodl.net/nodes/data/user/set-user-properties",displayNodeName:"Set User Properties",category:"Cloud Services",color:"data",initialize(){this._internal.userProperties={}},outputs:{success:{type:"signal",displayName:"Success",group:"Events"},failure:{type:"signal",displayName:"Failure",group:"Events"},error:{type:"string",displayName:"Error",group:"Error",getter(){return this._internal.error}}},inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue(){this.scheduleStore()}},email:{displayName:"Email",type:"string",group:"General",set(e){this._internal.email=e}},username:{displayName:"Username",type:"string",group:"General",set(e){this._internal.username=e}}},methods:{setError(e){this._internal.error=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure"),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"user-set-warning",{message:e,showGlobally:!0})},clearWarnings(){this.context.editorConnection&&this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"user-set-warning")},scheduleStore(){const e=this._internal;!0!==this.storeScheduled&&(this.storeScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.storeScheduled=!1,NoodlRuntime.Services.UserService.forScope(this.nodeScope.modelScope).setUserProperties({email:this._internal.email,username:this._internal.username,properties:e.userProperties,success:()=>{this.sendSignalOnOutput("success")},error:e=>{this.setError(e)}})})))},setUserProperty(e,t){this._internal.userProperties[e]=t},registerInputIfNeeded(e){if(!this.hasInput(e))return e.startsWith("prop-")?this.registerInput(e,{set:this.setUserProperty.bind(this,e.substring(5))}):void 0}}};function updatePorts$1(e,t,n,o){const i=[];if(o){const e=o.find((e=>"_User"===e.name));if(e&&e.schema&&e.schema.properties){const t=e.schema.properties,n="undefined"==typeof _noodl_cloud_runtime_version?["authData","createdAt","updatedAt","email","username","emailVerified","password"]:["authData","createdAt","updatedAt","email","username"];for(const e in t){if(-1!==n.indexOf(e))continue;const o=t[e];if(!i.find((t=>t.name===e)))if("Relation"===o.type);else{const t={String:"string",Boolean:"boolean",Number:"number",Date:"date"};i.push({type:{name:t[o.type]?t[o.type]:"*"},plug:"input",group:"Properties",name:"prop-"+e,displayName:e})}}}}n.sendDynamicPorts(e,i)}function setup$1(e,t){function n(n){updatePorts$1(n.id,n.parameters,e.editorConnection,t.getMetaData("systemCollections")),n.on("parameterUpdated",(function(o){updatePorts$1(n.id,n.parameters,e.editorConnection,t.getMetaData("systemCollections"))})),t.on("metadataChanged.systemCollections",(function(t){updatePorts$1(n.id,n.parameters,e.editorConnection,t)}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.net.noodl.user.SetUserProperties",(function(e){n(e)}));for(const e of t.getNodesWithType("net.noodl.user.SetUserProperties"))n(e)}))}var setuserproperties=Object.freeze({__proto__:null,node:node$1,setup:setup$1});const node={name:"net.noodl.user.User",docs:"https://docs.noodl.net/nodes/data/user/user-node",displayNodeName:"User",category:"Cloud Services",color:"data",initialize(){const e=this;this._internal.onModelChangedCallback=function(t){e.isInputConnected("fetch")||(e.hasOutput("prop-"+t.name)&&e.flagOutputDirty("prop-"+t.name),e.hasOutput("changed-"+t.name)&&e.sendSignalOnOutput("changed-"+t.name),e.sendSignalOnOutput("changed"))};const t=NoodlRuntime.Services.UserService.forScope(this.nodeScope.modelScope);this.setUserModel(t.current),t.on("loggedIn",(()=>{this.setUserModel(t.current),this.hasOutput("loggedIn")&&this.sendSignalOnOutput("loggedIn")})),t.on("sessionGained",(()=>{this.setUserModel(t.current)})),t.on("loggedOut",(()=>{this.setUserModel(void 0),this.hasOutput("loggedOut")&&this.sendSignalOnOutput("loggedOut")})),t.on("sessionLost",(()=>{this.setUserModel(void 0),this.hasOutput("sessionLost")&&this.sendSignalOnOutput("sessionLost")}))},getInspectInfo(){const e=this._internal.model;return e?[{type:"text",value:"Id: "+e.getId()},{type:"value",value:this._internal.model.data}]:"[No Model]"},outputs:{id:{type:"string",displayName:"Id",group:"General",getter(){return void 0!==this._internal.model?this._internal.model.getId():void 0}},fetched:{type:"signal",displayName:"Fetched",group:"Events"},changed:{type:"signal",displayName:"Changed",group:"Events"},failure:{type:"signal",displayName:"Failure",group:"Events"},error:{type:"string",displayName:"Error",group:"Error",getter(){return this._internal.error}},username:{type:"string",displayName:"Username",group:"General",getter(){return void 0!==this._internal.model?this._internal.model.get("username"):void 0}},email:{type:"string",displayName:"Email",group:"General",getter(){return void 0!==this._internal.model?this._internal.model.get("email"):void 0}},authenticated:{type:"boolean",displayName:"Authenticated",group:"General",getter(){return void 0!==this._internal.model}}},inputs:{fetch:{displayName:"Fetch",group:"Actions",valueChangedToTrue(){this.scheduleFetch()}}},methods:{_onNodeDeleted(){Node.prototype._onNodeDeleted.call(this),this._internal.model&&this._internal.model.off("change",this._internal.onModelChangedCallback)},scheduleOnce(e,t){const n=this,o="hasScheduled"+e;this._internal[o]||(this._internal[o]=!0,this.scheduleAfterInputsHaveUpdated((function(){n._internal[o]=!1,t()})))},setError(e){this._internal.error=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure"),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"user-warning",{message:e,showGlobally:!0})},clearWarnings(){this.context.editorConnection&&this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"user-warning")},setUserModel(e){const t=this._internal;if(t.model!==e&&(t.model&&t.model.off("change",t.onModelChangedCallback),t.model=e,e&&e.on("change",t.onModelChangedCallback)),this.flagOutputDirty("id"),this.flagOutputDirty("authenticated"),this.flagOutputDirty("email"),this.flagOutputDirty("username"),e)for(const t in e.data)this.hasOutput("prop-"+t)&&this.flagOutputDirty("prop-"+t)},scheduleFetch(){this._internal,this.scheduleOnce("Fetch",(()=>{const e=NoodlRuntime.Services.UserService.forScope(this.nodeScope.modelScope);e.fetchCurrentUser({success:t=>{this.setUserModel(e.current),this.sendSignalOnOutput("fetched")},error:e=>{this.setError(e||"Failed to fetch.")}})}))},registerOutputIfNeeded(e){this.hasOutput(e)||("loggedOut"!==e&&"loggedIn"!==e&&"sessionLost"!==e?e.startsWith("prop-")&&this.registerOutput(e,{getter:this.getUserProperty.bind(this,e.substring(5))}):this.registerOutput(e,{getter:()=>{}}))},getUserProperty(e){return void 0!==this._internal.model?this._internal.model.get(e):void 0}}};function updatePorts(e,t,n,o){const i=[];if(o){const e=o.find((e=>"_User"===e.name));if(e&&e.schema&&e.schema.properties){const t=e.schema.properties,n=["authData","password","username","email"];for(const e in t){if(-1!==n.indexOf(e))continue;const o=t[e];if(!i.find((t=>t.name===e)))if("Relation"===o.type);else{const t={String:"string",Boolean:"boolean",Number:"number",Date:"date"};i.push({type:{name:t[o.type]?t[o.type]:"*"},plug:"output",group:"Properties",name:"prop-"+e,displayName:e}),i.push({type:"signal",plug:"output",group:"Changed Events",displayName:e+" Changed",name:"changed-"+e})}}}}"undefined"==typeof _noodl_cloud_runtime_version&&(i.push({plug:"output",name:"loggedIn",type:"signal",displayName:"Logged In",group:"Events"}),i.push({plug:"output",name:"loggedOut",type:"signal",displayName:"Logged Out",group:"Events"}),i.push({plug:"output",name:"sessionLost",type:"signal",displayName:"Session Lost",group:"Events"})),n.sendDynamicPorts(e,i)}function setup(e,t){function n(n){updatePorts(n.id,n.parameters,e.editorConnection,t.getMetaData("systemCollections")),n.on("parameterUpdated",(function(o){updatePorts(n.id,n.parameters,e.editorConnection,t.getMetaData("systemCollections"))})),t.on("metadataChanged.systemCollections",(function(t){updatePorts(n.id,n.parameters,e.editorConnection,t)}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.net.noodl.user.User",(function(e){n(e)}));for(const e of t.getNodesWithType("net.noodl.user.User"))n(e)}))}var user=Object.freeze({__proto__:null,node,setup});function registerNodes(e){[componentinputs,componentoutputs,runtasks,restnode,expression,simplejavascript,dbcollectionnode2,dbmodelnode2,setdbmodelpropertiesnode,deletedbmodelpropertiesnode,newdbmodelpropertiesnode,dbmodelnodeAddrelation,dbmodelnodeRemoverelation,filterdbmodelsnode,modelnode2,setmodelpropertiesnode,newmodelnode,cloudfilenode,dbconfig,number,string,boolean,condition,and$1,or,booleantostring,datetostring,stringmapper,inverter,substring,stringformat,counter,uniqueid,setuserproperties,user].forEach((t=>e.registerNode(t)))}class NoodlRuntime$1{constructor(e){if(e.platform=e.platform||{},NoodlRuntime$1.instance=this,this.type=e.type||"browser",this.noodlModules=[],this.eventEmitter=new eventemitter3__WEBPACK_IMPORTED_MODULE_0__.b,this.updateScheduled=!1,this.rootComponent=null,this._currentLoadedData=null,this.isWaitingForExport=!0,this.graphModel=new GraphModel,this.errorHandlers=[],this.frameNumber=0,this.dontCreateRootComponent=!!e.dontCreateRootComponent,this.componentFilter=e.componentFilter,this.runningInEditor=!e.runDeployed,this.platform={requestUpdate:e.platform.requestUpdate,getCurrentTime:e.platform.getCurrentTime,webSocketOptions:e.platform.webSocketOptions,objectToString:e.platform.objectToString},!e.platform.requestUpdate)throw new Error("platform.requestUpdate must be set");if(!e.platform.getCurrentTime)throw new Error("platform.getCurrentTime must be set");this.editorConnection=new EditorConnection({platform:e.platform,runtimeType:this.type}),this.context=new NodeContext({runningInEditor:!e.runDeployed,editorConnection:this.editorConnection,platform:this.platform,graphModel:this.graphModel}),this.context.eventEmitter.on("scheduleUpdate",this.scheduleUpdate.bind(this)),e.runDeployed||this._setupEditorCommunication(e),this.registerGraphModelListeners(),registerNodes(this)}async prefetchBundles(e,t){await asyncPool(t,e,(async e=>{await this.context.fetchComponentBundle(e)}))}_setupEditorCommunication(e){function t(e,n){if(null==e||null==n)return e===n;if(e===n)return!0;if(Array.isArray(e)&&e.length!==n.length)return!1;if(!(e instanceof Object))return!1;if(!(n instanceof Object))return!1;const o=Object.keys(e);return Object.keys(n).every((e=>-1!==o.indexOf(e)))&&o.every((o=>t(e[o],n[o])))}this.editorConnection.on("exportDataFull",(async e=>{if(!1!==this.graphModel.isEmpty()){if(this.isWaitingForExport=!1,!1===t(this._currentLoadedData,e)){if(this.componentFilter&&(e.components=e.components.filter((e=>this.componentFilter(e)))),await this.setData(e),e.componentIndex){const t=Object.keys(e.componentIndex);await this.prefetchBundles(t,2)}this.graphModel.emit("editorImportComplete")}}else this.reload()})),this.editorConnection.on("reload",this.reload.bind(this)),this.editorConnection.on("modelUpdate",this.onModelUpdateReceived.bind(this)),this.editorConnection.on("metadataUpdate",this.onMetaDataUpdateReceived.bind(this)),this.editorConnection.on("connected",(()=>{this.sendNodeLibrary()}))}setDebugInspectorsEnabled(e){this.context.setDebugInspectorsEnabled(e)}registerModule(e){if(e.nodes)for(let t of e.nodes)t.node||(t={node:t}),t.node.module=e.name||"Unknown Module",this.registerNode(t);this.noodlModules.push(e)}registerGraphModelListeners(){this.graphModel.on("componentAdded",(e=>{this.context.registerComponentModel(e)}),this),this.graphModel.on("componentRemoved",(e=>{this.context.deregisterComponentModel(e)}),this)}reload(){location.reload()}registerNode(e){if(e.node){const t=defineNode(e.node);this.context.nodeRegister.register(t),t.setupNumberedInputDynamicPorts&&t.setupNumberedInputDynamicPorts(this.context,this.graphModel)}else this.context.nodeRegister.register(e.node);e.setup&&e.setup(this.context,this.graphModel)}async _setRootComponent(e){this.rootComponent&&this.rootComponent.name===e||(this.rootComponent&&(this.rootComponent.model&&this.rootComponent.model.removeListenersWithRef(this),this.rootComponent=void 0),e&&(this.rootComponent=await this.context.createComponentInstanceNode(e,"rootComponent",null),this.rootComponent.componentModel.on("rootAdded",(()=>this.eventEmitter.emit("rootComponentUpdated")),this),this.rootComponent.componentModel.on("rootRemoved",(()=>this.eventEmitter.emit("rootComponentUpdated")),this),this.context.setRootComponent(this.rootComponent)),this.eventEmitter.emit("rootComponentUpdated"))}async setData(e){if(!this._disableLoad){this._currentLoadedData=e,await this.graphModel.importEditorData(e);for(const e of this.noodlModules)"function"==typeof e.setup&&e.setup();!0!==this.dontCreateRootComponent&&(await this._setRootComponent(this.graphModel.rootComponent||null),this.graphModel.on("rootComponentNameUpdated",(e=>{this._setRootComponent(e)})),this.graphModel.on("componentRemoved",(e=>{this.rootComponent&&this.rootComponent.name===e.name&&this._setRootComponent(null)})),this.graphModel.on("componentAdded",(e=>{setTimeout((()=>{this.rootComponent||this.graphModel.rootComponent!==e.name||this._setRootComponent(e.name)}),1)}))),this.scheduleUpdate()}}scheduleUpdate(){var e,t;this.updateScheduled||(this.updateScheduled=!0,null===(t=(e=this.platform).requestUpdate)||void 0===t||t.call(e,this._doUpdate.bind(this)))}_doUpdate(){this.updateScheduled=!1,this.context.currentFrameTime=this.platform.getCurrentTime(),this.context.eventEmitter.emit("frameStart"),this.context.update(),this.context.eventEmitter.emit("frameEnd"),this.frameNumber++}setProjectSettings(e){this.projectSettings=e}getNodeLibrary(){const e=generateProjectSettings(this.graphModel.getSettings(),this.noodlModules);this.projectSettings&&(this.projectSettings.ports&&(e.ports=e.ports.concat(this.projectSettings.ports)),this.projectSettings.dynamicports&&(e.dynamicports=e.ports.concat(this.projectSettings.dynamicports)));const t=generateNodeLibrary(this.context.nodeRegister);return t.projectsettings=e,JSON.stringify(t,null,3)}sendNodeLibrary(){const e=this.getNodeLibrary();this.lastSentNodeLibrary!==e&&(this.lastSentNodeLibrary=e,this.editorConnection.sendNodeLibrary(e))}connectToEditor(e){this.editorConnection.connect(e)}onMetaDataUpdateReceived(e){this.graphModel.isEmpty()||handleEvent(this.context,this.graphModel,e)}async onModelUpdateReceived(e){this.isWaitingForExport||("projectInstanceChanged"===e.type?this.reload():!1===this.graphModel.isEmpty()&&await handleEvent(this.context,this.graphModel,e))}addErrorHandler(e){this.errorHandlers.push(e)}reportError(e){this.errorHandlers.forEach((t=>{t(e)}))}getProjectSettings(){return this.graphModel.getSettings()}getMetaData(e){return this.graphModel.getMetaData(e)}}function createRecordsAPI(e){let t;const n=()=>(t||(t=new CloudStore(e)),t);return{async query(t,o,i){if(void 0===t)throw new Error("'className' is undefined");return new Promise(((s,r)=>{n().query({collection:t,where:convertFilterOp(o||{},{collectionName:t,error:e=>r(e),modelScope:e}),limit:null==i?void 0:i.limit,sort:null==i?void 0:i.sort,skip:null==i?void 0:i.skip,include:null==i?void 0:i.include,select:null==i?void 0:i.select,count:null==i?void 0:i.count,success:(e,o)=>{const i=e.map((e=>n()._fromJSON(e,t)));s(void 0!==o?{results:i,count:o}:i)},error:e=>{r(Error(e||"Failed to query."))}})}))},async count(t,o){if(void 0===t)throw new Error("'className' is undefined");return new Promise(((i,s)=>{n().count({collection:t,where:o?convertFilterOp(o||{},{collectionName:t,error:e=>s(e),modelScope:e}):void 0,success:e=>{i(e)},error:e=>{s(Error(e||"Failed to query."))}})}))},async distinct(t,o,i){if(void 0===t)throw new Error("'className' is undefined");return new Promise(((s,r)=>{n().distinct({collection:t,property:o,where:i?convertFilterOp(i||{},{collectionName:t,error:e=>r(e),modelScope:e}):void 0,success:e=>{s(e)},error:e=>{r(Error(e||"Failed to query."))}})}))},async aggregate(t,o,i){if(void 0===t)throw new Error("'className' is undefined");return new Promise(((s,r)=>{n().aggregate({collection:t,group:o,where:i?convertFilterOp(i||{},{collectionName:t,error:e=>r(e),modelScope:e}):void 0,success:e=>{s(e)},error:e=>{r(Error(e||"Failed to aggregate."))}})}))},async fetch(t,o){if(void 0===t)return Promise.reject(new Error("'objectOrId' is undefined."));const i="string"==typeof t?t:t.getId(),s=(null==o?void 0:o.className)||(e||Model).get(i)._class;return new Promise(((e,t)=>{if(!s)return t("No class name specified");n().fetch({collection:s,objectId:i,keys:null==o?void 0:o.keys,include:null==o?void 0:o.include,excludeKeys:null==o?void 0:o.excludeKeys,success:function(t){const o=n()._fromJSON(t,s);e(o)},error:function(e){t(Error(e||"Failed to fetch."))}})}))},async increment(t,o,i){if(void 0===t)return Promise.reject(new Error("'objectOrId' is undefined."));const s="string"==typeof t?t:t.getId(),r=(null==i?void 0:i.className)||(e||Model).get(s)._class;return new Promise(((e,t)=>{if(!r)return t("No class name specified");n().increment({collection:r,objectId:s,properties:o,success:t=>{n()._fromJSON(Object.assign({objectId:s},t),r),e()},error:e=>{t(Error(e||"Failed to increment."))}})}))},async save(t,o,i){if(void 0===t)return Promise.reject(new Error("'objectOrId' is undefined."));const s="string"==typeof t?t:t.getId(),r=(null==i?void 0:i.className)||(e||Model).get(s)._class,a=(e||Model).get(s);return o&&Object.keys(o).forEach((e=>{a.set(e,o[e])})),new Promise(((e,t)=>{if(!r)return t("No class name specified");n().save({collection:r,objectId:s,data:o||a.data,acl:null==i?void 0:i.acl,success:t=>{n()._fromJSON(Object.assign({objectId:s},t),r),e()},error:e=>{t(Error(e||"Failed to save."))}})}))},async create(e,t,o){if(void 0===e)throw new Error("'className' is undefined");return new Promise(((i,s)=>{n().create({collection:e,data:t,acl:null==o?void 0:o.acl,success:t=>{const o=n()._fromJSON(t,e);i(o)},error:e=>{s(Error(e||"Failed to insert."))}})}))},async delete(t,o){if(void 0===t)return Promise.reject(new Error("'objectOrId' is undefined."));const i="string"==typeof t?t:t.getId(),s=(null==o?void 0:o.className)||(e||Model).get(i)._class;return new Promise(((t,o)=>{if(!s)return o("No class name specified");n().delete({collection:s,objectId:i,success:()=>{(e||Model).get(i).notify("delete"),t()},error:e=>{o(Error(e||"Failed to delete."))}})}))},async addRelation(t){var o,i;const s=t.recordId||(null===(o=t.record)||void 0===o?void 0:o.getId()),r=t.className||(e||Model).get(s)._class,a=t.targetRecordId||(null===(i=t.targetRecord)||void 0===i?void 0:i.getId()),l=t.targetClassName||(e||Model).get(a)._class;return new Promise(((e,o)=>r?l?void n().addRelation({collection:r,objectId:s,key:t.key,targetObjectId:a,targetClass:l,success:()=>{e()},error:e=>{o(Error(e||"Failed to add relation."))}}):o("No target class name specified"):o("No class name specified")))},async removeRelation(t){var o,i;const s=t.recordId||(null===(o=t.record)||void 0===o?void 0:o.getId()),r=t.className||(e||Model).get(s)._class,a=t.targetRecordId||(null===(i=t.targetRecord)||void 0===i?void 0:i.getId()),l=t.targetClassName||(e||Model).get(a)._class;return new Promise(((e,o)=>r?l?void n().removeRelation({collection:r,objectId:s,key:t.key,targetObjectId:a,targetClass:l,success:()=>{e()},error:e=>{o(Error(e||"Failed to add relation."))}}):o("No target class name specified"):o("No class name specified")))}}}NoodlRuntime$1.Services=Services,NoodlRuntime$1.Node=Node$1,NoodlRuntime$1.NodeDefinition={defineNode},NoodlRuntime$1.EdgeTriggeredInput=createSetter},1150:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function o(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,o,s,r){if("function"!=typeof o)throw new TypeError("The listener must be a function");var a=new i(o,s||e,r),l=n?n+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],a]:e._events[l].push(a):(e._events[l]=a,e._eventsCount++),e}function r(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function a(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,o,i=[];if(0===this._eventsCount)return i;for(o in e=this._events)t.call(e,o)&&i.push(n?o.slice(1):o);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=n?n+e:e,o=this._events[t];if(!o)return[];if(o.fn)return[o.fn];for(var i=0,s=o.length,r=new Array(s);i{var o="__lodash_hash_undefined__",i=/^\[object .+?Constructor\]$/,s="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,r="object"==typeof self&&self&&self.Object===Object&&self,a=s||r||Function("return this")();function l(e,t){return!(!e||!e.length)&&function(e,t){if(t!=t)return function(e,t){for(var n=e.length,o=-1;++o-1}function d(e,t,n){for(var o=-1,i=e?e.length:0;++o0&&n(a)?t>1?M(a,t-1,n,o,i):u(i,a):o||(i[i.length]=a)}return i}function V(e,t){var n,o,i=e.__data__;return("string"==(o=typeof(n=t))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map}function j(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return function(e){if(!z(e)||v&&v in e)return!1;var t=q(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?C:i;return t.test(function(e){if(null!=e){try{return b.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}(n)?n:void 0}function F(e){return B(e)||function(e){return $(e)&&_.call(e,"callee")&&(!O.call(e,"callee")||"[object Arguments]"==S.call(e))}(e)||!!(w&&e&&e[w])}T.prototype.clear=function(){this.__data__=E?E(null):{}},T.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},T.prototype.get=function(e){var t=this.__data__;if(E){var n=t[e];return n===o?void 0:n}return _.call(t,e)?t[e]:void 0},T.prototype.has=function(e){var t=this.__data__;return E?void 0!==t[e]:_.call(t,e)},T.prototype.set=function(e,t){return this.__data__[e]=E&&void 0===t?o:t,this},A.prototype.clear=function(){this.__data__=[]},A.prototype.delete=function(e){var t=this.__data__,n=R(t,e);return!(n<0||(n==t.length-1?t.pop():I.call(t,n,1),0))},A.prototype.get=function(e){var t=this.__data__,n=R(t,e);return n<0?void 0:t[n][1]},A.prototype.has=function(e){return R(this.__data__,e)>-1},A.prototype.set=function(e,t){var n=this.__data__,o=R(n,e);return o<0?n.push([e,t]):n[o][1]=t,this},k.prototype.clear=function(){this.__data__={hash:new T,map:new(x||A),string:new T}},k.prototype.delete=function(e){return V(this,e).delete(e)},k.prototype.get=function(e){return V(this,e).get(e)},k.prototype.has=function(e){return V(this,e).has(e)},k.prototype.set=function(e,t){return V(this,e).set(e,t),this},D.prototype.add=D.prototype.push=function(e){return this.__data__.set(e,o),this},D.prototype.has=function(e){return this.__data__.has(e)};var U,W,L=(U=function(e,t){return $(e)?function(e,t,n,o){var i,s=-1,r=l,a=!0,u=e.length,c=[],h=t.length;if(!u)return c;n&&(t=function(e,t){for(var n=-1,o=e?e.length:0,i=Array(o);++n=200&&(r=p,a=!1,t=new D(t));e:for(;++s-1&&e%1==0&&e<=9007199254740991}(e.length)&&!q(e)}(e)}function q(e){var t=z(e)?S.call(e):"";return"[object Function]"==t||"[object GeneratorFunction]"==t}function z(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=L},8972:e=>{var t=.1,n="function"==typeof Float32Array;function o(e,t){return 1-3*t+3*e}function i(e,t){return 3*t-6*e}function s(e){return 3*e}function r(e,t,n){return((o(t,n)*e+i(t,n))*e+s(t))*e}function a(e,t,n){return 3*o(t,n)*e*e+2*i(t,n)*e+s(t)}function l(e,t,o,i){if(4===arguments.length)return new l([e,t,o,i]);if(!(this instanceof l))return new l(e);if(!e||4!==e.length)throw new Error("BezierEasing: points must contains 4 values");for(var s=0;s<4;++s)if("number"!=typeof e[s]||isNaN(e[s])||!isFinite(e[s]))throw new Error("BezierEasing: points should be integers.");if(e[0]<0||e[0]>1||e[2]<0||e[2]>1)throw new Error("BezierEasing x values must be in [0, 1] range.");this._str="BezierEasing("+e+")",this._css="cubic-bezier("+e+")",this._p=e,this._mSampleValues=n?new Float32Array(11):new Array(11),this._precomputed=!1,this.get=this.get.bind(this)}l.prototype={get:function(e){var t=this._p[0],n=this._p[1],o=this._p[2],i=this._p[3];return this._precomputed||this._precompute(),t===n&&o===i?e:0===e?0:1===e?1:r(this._getTForX(e),n,i)},getPoints:function(){return this._p},toString:function(){return this._str},toCSS:function(){return this._css},_precompute:function(){var e=this._p[0],t=this._p[1],n=this._p[2],o=this._p[3];this._precomputed=!0,e===t&&n===o||this._calcSampleValues()},_calcSampleValues:function(){for(var e=this._p[0],n=this._p[2],o=0;o<11;++o)this._mSampleValues[o]=r(o*t,e,n)},_getTForX:function(e){for(var n=this._p[0],o=this._p[2],i=this._mSampleValues,s=0,l=1;10!==l&&i[l]<=e;++l)s+=t;var d=s+(e-i[--l])/(i[l+1]-i[l])*t,u=a(d,n,o);return u>=.001?function(e,t,n,o){for(var i=0;i<4;++i){var s=a(t,n,o);if(0===s)return t;t-=(r(t,n,o)-e)/s}return t}(e,d,n,o):0===u?d:function(e,t,n,o,i){var s,a,l=0;do{(s=r(a=t+(n-t)/2,o,i)-e)>0?n=a:t=a}while(Math.abs(s)>1e-7&&++l<10);return a}(e,s,s+t,n,o)}},l.css={ease:l.ease=l(.25,.1,.25,1),linear:l.linear=l(0,0,1,1),"ease-in":l.easeIn=l(.42,0,1,1),"ease-out":l.easeOut=l(0,0,.58,1),"ease-in-out":l.easeInOut=l(.42,0,.58,1)},e.exports=l},53:(e,t,n)=>{"use strict";function o(e){var t,n,i="";if("string"==typeof e||"number"==typeof e)i+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;ti,default:()=>s});const s=i},4960:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var o=n(4991),i=n.n(o),s=n(6314),r=n.n(s)()(i());r.push([e.id,".ndl-visual-text {\r\n font-weight: 400;\r\n margin: 0;\r\n}\r\n\r\n.ndl-controls-pointer,\r\n.ndl-controls-pointer * {\r\n cursor: pointer;\r\n}\r\n\r\n.ndl-controls-abs-center {\r\n position: absolute;\r\n transform: translate(-50%, -50%);\r\n left: 50%;\r\n top: 50%;\r\n}\r\n\r\n/** Button **/\r\n.ndl-controls-button {\r\n outline: none;\r\n border: none;\r\n color: white;\r\n background-color: black;\r\n padding: 5px 20px 5px 20px;\r\n cursor: pointer;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n}\r\n.ndl-controls-button:disabled {\r\n cursor: default;\r\n}\r\n\r\n/** Deprecated checkbox **/\r\n.ndl-controls-checkbox {\r\n margin: 0;\r\n border: 1px solid #000000;\r\n border-radius: 0;\r\n background-color: transparent;\r\n -webkit-appearance: none;\r\n outline: none;\r\n cursor: pointer;\r\n}\r\n\r\n.ndl-controls-checkbox:checked {\r\n background-color: #000000;\r\n}\r\n\r\n.ndl-controls-checkbox:disabled {\r\n cursor: default;\r\n}\r\n\r\n/** Deprecated radio button **/\r\n.ndl-controls-radiobutton {\r\n margin: 0;\r\n border: 1px solid #000000;\r\n border-radius: 16px;\r\n background-color: transparent;\r\n -webkit-appearance: none;\r\n outline: none;\r\n width: 32px;\r\n height: 32px;\r\n display: block;\r\n cursor: pointer;\r\n}\r\n\r\n.ndl-controls-radiobutton:checked {\r\n background-color: #000000;\r\n}\r\n\r\n.ndl-controls-radiobutton:disabled {\r\n cursor: default;\r\n}\r\n\r\n/** New radio button **/\r\n.ndl-controls-radio-2 {\r\n opacity: 0;\r\n position: absolute;\r\n margin: 0;\r\n}\r\n\r\n.ndl-controls-radio-2:disabled {\r\n cursor: default;\r\n}\r\n\r\n/** New checkbox **/\r\n.ndl-controls-checkbox-2 {\r\n opacity: 0;\r\n position: absolute;\r\n margin: 0;\r\n}\r\n\r\n.ndl-controls-checkbox-2:disabled {\r\n cursor: default;\r\n}\r\n\r\n/** Options **/\r\n.ndl-controls-select {\r\n -webkit-appearance: none;\r\n appearance: none;\r\n background-color: transparent;\r\n border: 1px solid #000000;\r\n border-radius: 0;\r\n padding: 0 1em 0 0;\r\n margin: 0;\r\n width: 100%;\r\n font-family: inherit;\r\n font-size: inherit;\r\n cursor: inherit;\r\n line-height: inherit;\r\n\r\n /* Stack above custom arrow */\r\n z-index: 1;\r\n\r\n /* Remove dropdown arrow in IE10 & IE11\r\n @link https://www.filamentgroup.com/lab/select-css.html */\r\n /* &::-ms-expand {\r\n display: none;\r\n }*/\r\n\r\n /* Remove focus outline, will add on alternate element */\r\n outline: none;\r\n}\r\n\r\n.ndl-controls-select:disabled {\r\n cursor: default;\r\n}\r\n\r\n/** Range **/\r\n.ndl-controls-range2 {\r\n margin: 0;\r\n padding: 0;\r\n -webkit-appearance: none;\r\n appearance: none;\r\n outline: none;\r\n border: none;\r\n background: transparent;\r\n cursor: pointer;\r\n}\r\n\r\n.ndl-controls-range2::-webkit-slider-thumb {\r\n height: 100%;\r\n border: 0;\r\n -webkit-appearance: none;\r\n appearance: none;\r\n}\r\n\r\n.ndl-controls-range2::-moz-range-thumb {\r\n height: 100%;\r\n border: 0;\r\n -webkit-appearance: none;\r\n appearance: none;\r\n}\r\n\r\n.ndl-controls-range2::-webkit-slider-runnable-track {\r\n border: none;\r\n height: 100%;\r\n}\r\n\r\n.ndl-controls-range2::-moz-range-track {\r\n border: none;\r\n height: 100%;\r\n}\r\n\r\n.ndl-controls-range2:disabled {\r\n cursor: default;\r\n}\r\n\r\n/* Old range */\r\n\r\n.ndl-controls-range {\r\n margin: 0;\r\n padding: 0;\r\n -webkit-appearance: none;\r\n outline: none;\r\n border: none;\r\n background-color: transparent;\r\n cursor: pointer;\r\n}\r\n\r\n.ndl-controls-range::-webkit-slider-thumb {\r\n width: 16px;\r\n height: 16px;\r\n background: #000000;\r\n border: 0;\r\n border-radius: 8px;\r\n cursor: pointer;\r\n -webkit-appearance: none;\r\n margin-top: -5px;\r\n}\r\n\r\n.ndl-controls-range::-moz-range-thumb {\r\n width: 16px;\r\n height: 16px;\r\n background: #000000;\r\n border: none;\r\n border-radius: 8px;\r\n cursor: pointer;\r\n}\r\n\r\n.ndl-controls-range::-ms-thumb {\r\n width: 16px;\r\n height: 16px;\r\n background: #000000;\r\n border: none;\r\n border-radius: 8px;\r\n cursor: pointer;\r\n margin-top: 0px;\r\n /*Needed to keep the Edge thumb centred*/\r\n}\r\n\r\n.ndl-controls-range::-webkit-slider-runnable-track {\r\n background: #f0f0f0;\r\n border: none;\r\n width: 100%;\r\n height: 6px;\r\n cursor: pointer;\r\n top: 4px;\r\n margin-top: 5px;\r\n}\r\n\r\n.ndl-controls-range:focus::-webkit-slider-runnable-track {\r\n background: #f0f0f0;\r\n}\r\n\r\n.ndl-controls-range::-moz-range-track {\r\n background: #f0f0f0;\r\n border: none;\r\n width: 100%;\r\n height: 6px;\r\n cursor: pointer;\r\n}\r\n\r\n.ndl-controls-range::-ms-track {\r\n background: transparent;\r\n border-color: transparent;\r\n border-width: 5px 0;\r\n color: transparent;\r\n width: 100%;\r\n height: 6px;\r\n cursor: pointer;\r\n}\r\n\r\n.ndl-controls-range::-ms-fill-lower {\r\n background: #f0f0f0;\r\n border: none;\r\n}\r\n.ndl-controls-range::-ms-fill-upper {\r\n background: #f0f0f0;\r\n border: none;\r\n}\r\n\r\n/** Field Set **/\r\n.ndl-controls-fieldset {\r\n outline: none;\r\n border: none;\r\n margin: 0;\r\n padding: 0;\r\n}\r\n\r\n/** Text Input **/\r\n.ndl-controls-textinput {\r\n outline: none;\r\n border-style: none;\r\n background-color: transparent;\r\n}\r\n\r\n.ndl-controls-textinput::placeholder {\r\n color: inherit;\r\n opacity: 0.5;\r\n}\r\n","",{version:3,sources:["webpack://./src/assets/style.css"],names:[],mappings:"AAAA;EACE,gBAAgB;EAChB,SAAS;AACX;;AAEA;;EAEE,eAAe;AACjB;;AAEA;EACE,kBAA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AAgB;AAClB;;AAEA;EACE,YAAY;EACZ,SAAS;EACT,wBAAwB;EACxB,gBAAgB;AAClB;;AAEA;EACE,YAAY;EACZ,YAAY;AACd;;AAEA;EACE,YAAY;EACZ,YAAY;AACd;;AAEA;EACE,eAAe;AACjB;;AAEA,cAAc;;AAEd;EACE,SAAS;EACT,UAAU;EACV,wBAAwB;EACxB,aAAa;EACb,YAAY;EACZ,6BAA6B;EAC7B,eAAe;AACjB;;AAEA;EACE,WAAW;EACX,YAAY;EACZ,mBAAmB;EACnB,SAAS;EACT,kBAAkB;EAClB,eAAe;EACf,wBAAwB;EACxB,gBAAgB;AAClB;;AAEA;EACE,WAAW;EACX,YAAY;EACZ,mBAAmB;EACnB,YAAY;EACZ,kBAAkB;EAClB,eAAe;AACjB;;AAEA;EACE,WAAW;EACX,YAAY;EACZ,mBAAmB;EACnB,YAAY;EACZ,kBAAkB;EAClB,eAAe;EACf,eAAe;EACf,wCAAwC;AAC1C;;AAEA;EACE,mBAAmB;EACnB,YAAY;EACZ,WAAW;EACX,WAAW;EACX,eAAe;EACf,QAAQ;EACR,eAAe;AACjB;;AAEA;EACE,mBAAmB;AACrB;;AAEA;EACE,mBAAmB;EACnB,YAAY;EACZ,WAAW;EACX,WAAW;EACX,eAAe;AACjB;;AAEA;EACE,uBAAuB;EACvB,yBAAyB;EACzB,mBAAmB;EACnB,kBAAkB;EAClB,WAAW;EACX,WAAW;EACX,eAAe;AACjB;;AAEA;EACE,mBAAmB;EACnB,YAAY;AACd;AACA;EACE,mBAAmB;EACnB,YAAY;AACd;;AAEA,gBAAgB;AAChB;EACE,aAAa;EACb,YAAY;EACZ,SAAS;EACT,UAAU;AACZ;;AAEA,iBAAiB;AACjB;EACE,aAAa;EACb,kBAAkB;EAClB,6BAA6B;AAC/B;;AAEA;EACE,cAAc;EACd,YAAY;AACd",sourcesContent:[".ndl-visual-text {\r\n font-weight: 400;\r\n margin: 0;\r\n}\r\n\r\n.ndl-controls-pointer,\r\n.ndl-controls-pointer * {\r\n cursor: pointer;\r\n}\r\n\r\n.ndl-controls-abs-center {\r\n position: absolute;\r\n transform: translate(-50%, -50%);\r\n left: 50%;\r\n top: 50%;\r\n}\r\n\r\n/** Button **/\r\n.ndl-controls-button {\r\n outline: none;\r\n border: none;\r\n color: white;\r\n background-color: black;\r\n padding: 5px 20px 5px 20px;\r\n cursor: pointer;\r\n display: flex;\r\n align-items: center;\r\n justify-content: center;\r\n}\r\n.ndl-controls-button:disabled {\r\n cursor: default;\r\n}\r\n\r\n/** Deprecated checkbox **/\r\n.ndl-controls-checkbox {\r\n margin: 0;\r\n border: 1px solid #000000;\r\n border-radius: 0;\r\n background-color: transparent;\r\n -webkit-appearance: none;\r\n outline: none;\r\n cursor: pointer;\r\n}\r\n\r\n.ndl-controls-checkbox:checked {\r\n background-color: #000000;\r\n}\r\n\r\n.ndl-controls-checkbox:disabled {\r\n cursor: default;\r\n}\r\n\r\n/** Deprecated radio button **/\r\n.ndl-controls-radiobutton {\r\n margin: 0;\r\n border: 1px solid #000000;\r\n border-radius: 16px;\r\n background-color: transparent;\r\n -webkit-appearance: none;\r\n outline: none;\r\n width: 32px;\r\n height: 32px;\r\n display: block;\r\n cursor: pointer;\r\n}\r\n\r\n.ndl-controls-radiobutton:checked {\r\n background-color: #000000;\r\n}\r\n\r\n.ndl-controls-radiobutton:disabled {\r\n cursor: default;\r\n}\r\n\r\n/** New radio button **/\r\n.ndl-controls-radio-2 {\r\n opacity: 0;\r\n position: absolute;\r\n margin: 0;\r\n}\r\n\r\n.ndl-controls-radio-2:disabled {\r\n cursor: default;\r\n}\r\n\r\n/** New checkbox **/\r\n.ndl-controls-checkbox-2 {\r\n opacity: 0;\r\n position: absolute;\r\n margin: 0;\r\n}\r\n\r\n.ndl-controls-checkbox-2:disabled {\r\n cursor: default;\r\n}\r\n\r\n/** Options **/\r\n.ndl-controls-select {\r\n -webkit-appearance: none;\r\n appearance: none;\r\n background-color: transparent;\r\n border: 1px solid #000000;\r\n border-radius: 0;\r\n padding: 0 1em 0 0;\r\n margin: 0;\r\n width: 100%;\r\n font-family: inherit;\r\n font-size: inherit;\r\n cursor: inherit;\r\n line-height: inherit;\r\n\r\n /* Stack above custom arrow */\r\n z-index: 1;\r\n\r\n /* Remove dropdown arrow in IE10 & IE11\r\n @link https://www.filamentgroup.com/lab/select-css.html */\r\n /* &::-ms-expand {\r\n display: none;\r\n }*/\r\n\r\n /* Remove focus outline, will add on alternate element */\r\n outline: none;\r\n}\r\n\r\n.ndl-controls-select:disabled {\r\n cursor: default;\r\n}\r\n\r\n/** Range **/\r\n.ndl-controls-range2 {\r\n margin: 0;\r\n padding: 0;\r\n -webkit-appearance: none;\r\n appearance: none;\r\n outline: none;\r\n border: none;\r\n background: transparent;\r\n cursor: pointer;\r\n}\r\n\r\n.ndl-controls-range2::-webkit-slider-thumb {\r\n height: 100%;\r\n border: 0;\r\n -webkit-appearance: none;\r\n appearance: none;\r\n}\r\n\r\n.ndl-controls-range2::-moz-range-thumb {\r\n height: 100%;\r\n border: 0;\r\n -webkit-appearance: none;\r\n appearance: none;\r\n}\r\n\r\n.ndl-controls-range2::-webkit-slider-runnable-track {\r\n border: none;\r\n height: 100%;\r\n}\r\n\r\n.ndl-controls-range2::-moz-range-track {\r\n border: none;\r\n height: 100%;\r\n}\r\n\r\n.ndl-controls-range2:disabled {\r\n cursor: default;\r\n}\r\n\r\n/* Old range */\r\n\r\n.ndl-controls-range {\r\n margin: 0;\r\n padding: 0;\r\n -webkit-appearance: none;\r\n outline: none;\r\n border: none;\r\n background-color: transparent;\r\n cursor: pointer;\r\n}\r\n\r\n.ndl-controls-range::-webkit-slider-thumb {\r\n width: 16px;\r\n height: 16px;\r\n background: #000000;\r\n border: 0;\r\n border-radius: 8px;\r\n cursor: pointer;\r\n -webkit-appearance: none;\r\n margin-top: -5px;\r\n}\r\n\r\n.ndl-controls-range::-moz-range-thumb {\r\n width: 16px;\r\n height: 16px;\r\n background: #000000;\r\n border: none;\r\n border-radius: 8px;\r\n cursor: pointer;\r\n}\r\n\r\n.ndl-controls-range::-ms-thumb {\r\n width: 16px;\r\n height: 16px;\r\n background: #000000;\r\n border: none;\r\n border-radius: 8px;\r\n cursor: pointer;\r\n margin-top: 0px;\r\n /*Needed to keep the Edge thumb centred*/\r\n}\r\n\r\n.ndl-controls-range::-webkit-slider-runnable-track {\r\n background: #f0f0f0;\r\n border: none;\r\n width: 100%;\r\n height: 6px;\r\n cursor: pointer;\r\n top: 4px;\r\n margin-top: 5px;\r\n}\r\n\r\n.ndl-controls-range:focus::-webkit-slider-runnable-track {\r\n background: #f0f0f0;\r\n}\r\n\r\n.ndl-controls-range::-moz-range-track {\r\n background: #f0f0f0;\r\n border: none;\r\n width: 100%;\r\n height: 6px;\r\n cursor: pointer;\r\n}\r\n\r\n.ndl-controls-range::-ms-track {\r\n background: transparent;\r\n border-color: transparent;\r\n border-width: 5px 0;\r\n color: transparent;\r\n width: 100%;\r\n height: 6px;\r\n cursor: pointer;\r\n}\r\n\r\n.ndl-controls-range::-ms-fill-lower {\r\n background: #f0f0f0;\r\n border: none;\r\n}\r\n.ndl-controls-range::-ms-fill-upper {\r\n background: #f0f0f0;\r\n border: none;\r\n}\r\n\r\n/** Field Set **/\r\n.ndl-controls-fieldset {\r\n outline: none;\r\n border: none;\r\n margin: 0;\r\n padding: 0;\r\n}\r\n\r\n/** Text Input **/\r\n.ndl-controls-textinput {\r\n outline: none;\r\n border-style: none;\r\n background-color: transparent;\r\n}\r\n\r\n.ndl-controls-textinput::placeholder {\r\n color: inherit;\r\n opacity: 0.5;\r\n}\r\n"],sourceRoot:""}]);const a=r},6314:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=e(t);return t[2]?"@media ".concat(t[2]," {").concat(n,"}"):n})).join("")},t.i=function(e,n,o){"string"==typeof e&&(e=[[null,e,""]]);var i={};if(o)for(var s=0;s{"use strict";function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n{"use strict";var t,n="object"==typeof Reflect?Reflect:null,o=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise((function(n,o){function i(n){e.removeListener(t,s),o(n)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}g(e,t,s,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&g(e,"error",t,{once:!0})}(e,i)}))},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var r=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function d(e,t,n,o){var i,s,r,d;if(a(n),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),r=s[t]),void 0===r)r=s[t]=n,++e._eventsCount;else if("function"==typeof r?r=s[t]=o?[n,r]:[r,n]:o?r.unshift(n):r.push(n),(i=l(e))>0&&r.length>i&&!r.warned){r.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=r.length,d=u,console&&console.warn&&console.warn(d)}return e}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function c(e,t,n){var o={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=u.bind(o);return i.listener=n,o.wrapFn=i,i}function p(e,t,n){var o=e._events;if(void 0===o)return[];var i=o[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n0&&(r=t[0]),r instanceof Error)throw r;var a=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw a.context=r,a}var l=s[e];if(void 0===l)return!1;if("function"==typeof l)o(l,this,t);else{var d=l.length,u=m(l,d);for(n=0;n=0;s--)if(n[s]===t||n[s].listener===t){r=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1=0;o--)this.removeListener(e,t[o]);return this},s.prototype.listeners=function(e){return p(this,e,!0)},s.prototype.rawListeners=function(e){return p(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h,s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},2694:(e,t,n)=>{"use strict";var o=n(6925);function i(){}function s(){}s.resetWarningCache=i,e.exports=function(){function e(e,t,n,i,s,r){if(r!==o){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:s,resetWarningCache:i};return n.PropTypes=n,n}},5556:(e,t,n)=>{e.exports=n(2694)()},6925:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},6027:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"DraggableCore",{enumerable:!0,get:function(){return u.default}}),t.default=void 0;var o=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=h(t);if(n&&n.has(e))return n.get(e);var o={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var r=i?Object.getOwnPropertyDescriptor(e,s):null;r&&(r.get||r.set)?Object.defineProperty(o,s,r):o[s]=e[s]}return o.default=e,n&&n.set(e,o),o}(n(1594)),i=p(n(5556)),s=p(n(5206)),r=p(n(53)),a=n(1089),l=n(1726),d=n(7056),u=p(n(6888)),c=p(n(8696));function p(e){return e&&e.__esModule?e:{default:e}}function h(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(h=function(e){return e?n:t})(e)}function m(){return m=Object.assign?Object.assign.bind():function(e){for(var t=1;t{if((0,c.default)("Draggable: onDragStart: %j",t),!1===this.props.onStart(e,(0,l.createDraggableData)(this,t)))return!1;this.setState({dragging:!0,dragged:!0})})),g(this,"onDrag",((e,t)=>{if(!this.state.dragging)return!1;(0,c.default)("Draggable: onDrag: %j",t);const n=(0,l.createDraggableData)(this,t),o={x:n.x,y:n.y,slackX:0,slackY:0};if(this.props.bounds){const{x:e,y:t}=o;o.x+=this.state.slackX,o.y+=this.state.slackY;const[i,s]=(0,l.getBoundPosition)(this,o.x,o.y);o.x=i,o.y=s,o.slackX=this.state.slackX+(e-o.x),o.slackY=this.state.slackY+(t-o.y),n.x=o.x,n.y=o.y,n.deltaX=o.x-this.state.x,n.deltaY=o.y-this.state.y}if(!1===this.props.onDrag(e,n))return!1;this.setState(o)})),g(this,"onDragStop",((e,t)=>{if(!this.state.dragging)return!1;if(!1===this.props.onStop(e,(0,l.createDraggableData)(this,t)))return!1;(0,c.default)("Draggable: onDragStop: %j",t);const n={dragging:!1,slackX:0,slackY:0};if(Boolean(this.props.position)){const{x:e,y:t}=this.props.position;n.x=e,n.y=t}this.setState(n)})),this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},!e.position||e.onDrag||e.onStop||console.warn("A `position` was applied to this , without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){void 0!==window.SVGElement&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.setState({dragging:!1})}findDOMNode(){var e,t;return null!==(e=null===(t=this.props)||void 0===t||null===(t=t.nodeRef)||void 0===t?void 0:t.current)&&void 0!==e?e:s.default.findDOMNode(this)}render(){const{axis:e,bounds:t,children:n,defaultPosition:i,defaultClassName:s,defaultClassNameDragging:d,defaultClassNameDragged:c,position:p,positionOffset:h,scale:g,...f}=this.props;let y={},v=null;const b=!Boolean(p)||this.state.dragging,_=p||i,S={x:(0,l.canDragX)(this)&&b?this.state.x:_.x,y:(0,l.canDragY)(this)&&b?this.state.y:_.y};this.state.isElementSVG?v=(0,a.createSVGTransform)(S,h):y=(0,a.createCSSTransform)(S,h);const C=(0,r.default)(n.props.className||"",s,{[d]:this.state.dragging,[c]:this.state.dragged});return o.createElement(u.default,m({},f,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),o.cloneElement(o.Children.only(n),{className:C,style:{...n.props.style,...y},transform:v}))}}t.default=f,g(f,"displayName","Draggable"),g(f,"propTypes",{...u.default.propTypes,axis:i.default.oneOf(["both","x","y","none"]),bounds:i.default.oneOfType([i.default.shape({left:i.default.number,right:i.default.number,top:i.default.number,bottom:i.default.number}),i.default.string,i.default.oneOf([!1])]),defaultClassName:i.default.string,defaultClassNameDragging:i.default.string,defaultClassNameDragged:i.default.string,defaultPosition:i.default.shape({x:i.default.number,y:i.default.number}),positionOffset:i.default.shape({x:i.default.oneOfType([i.default.number,i.default.string]),y:i.default.oneOfType([i.default.number,i.default.string])}),position:i.default.shape({x:i.default.number,y:i.default.number}),className:d.dontSetMe,style:d.dontSetMe,transform:d.dontSetMe}),g(f,"defaultProps",{...u.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})},6888:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=c(t);if(n&&n.has(e))return n.get(e);var o={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var r=i?Object.getOwnPropertyDescriptor(e,s):null;r&&(r.get||r.set)?Object.defineProperty(o,s,r):o[s]=e[s]}return o.default=e,n&&n.set(e,o),o}(n(1594)),i=u(n(5556)),s=u(n(5206)),r=n(1089),a=n(1726),l=n(7056),d=u(n(8696));function u(e){return e&&e.__esModule?e:{default:e}}function c(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(c=function(e){return e?n:t})(e)}function p(e,t,n){return(t=function(e){var t=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const h={start:"touchstart",move:"touchmove",stop:"touchend"},m={start:"mousedown",move:"mousemove",stop:"mouseup"};let g=m;class f extends o.Component{constructor(){super(...arguments),p(this,"dragging",!1),p(this,"lastX",NaN),p(this,"lastY",NaN),p(this,"touchIdentifier",null),p(this,"mounted",!1),p(this,"handleDragStart",(e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&"number"==typeof e.button&&0!==e.button)return!1;const t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw new Error(" not mounted on DragStart!");const{ownerDocument:n}=t;if(this.props.disabled||!(e.target instanceof n.defaultView.Node)||this.props.handle&&!(0,r.matchesSelectorAndParentsTo)(e.target,this.props.handle,t)||this.props.cancel&&(0,r.matchesSelectorAndParentsTo)(e.target,this.props.cancel,t))return;"touchstart"===e.type&&e.preventDefault();const o=(0,r.getTouchIdentifier)(e);this.touchIdentifier=o;const i=(0,a.getControlPosition)(e,o,this);if(null==i)return;const{x:s,y:l}=i,u=(0,a.createCoreData)(this,s,l);(0,d.default)("DraggableCore: handleDragStart: %j",u),(0,d.default)("calling",this.props.onStart),!1!==this.props.onStart(e,u)&&!1!==this.mounted&&(this.props.enableUserSelectHack&&(0,r.addUserSelectStyles)(n),this.dragging=!0,this.lastX=s,this.lastY=l,(0,r.addEvent)(n,g.move,this.handleDrag),(0,r.addEvent)(n,g.stop,this.handleDragStop))})),p(this,"handleDrag",(e=>{const t=(0,a.getControlPosition)(e,this.touchIdentifier,this);if(null==t)return;let{x:n,y:o}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX,t=o-this.lastY;if([e,t]=(0,a.snapToGrid)(this.props.grid,e,t),!e&&!t)return;n=this.lastX+e,o=this.lastY+t}const i=(0,a.createCoreData)(this,n,o);if((0,d.default)("DraggableCore: handleDrag: %j",i),!1!==this.props.onDrag(e,i)&&!1!==this.mounted)this.lastX=n,this.lastY=o;else try{this.handleDragStop(new MouseEvent("mouseup"))}catch(e){const t=document.createEvent("MouseEvents");t.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(t)}})),p(this,"handleDragStop",(e=>{if(!this.dragging)return;const t=(0,a.getControlPosition)(e,this.touchIdentifier,this);if(null==t)return;let{x:n,y:o}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX||0,t=o-this.lastY||0;[e,t]=(0,a.snapToGrid)(this.props.grid,e,t),n=this.lastX+e,o=this.lastY+t}const i=(0,a.createCoreData)(this,n,o);if(!1===this.props.onStop(e,i)||!1===this.mounted)return!1;const s=this.findDOMNode();s&&this.props.enableUserSelectHack&&(0,r.removeUserSelectStyles)(s.ownerDocument),(0,d.default)("DraggableCore: handleDragStop: %j",i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,s&&((0,d.default)("DraggableCore: Removing handlers"),(0,r.removeEvent)(s.ownerDocument,g.move,this.handleDrag),(0,r.removeEvent)(s.ownerDocument,g.stop,this.handleDragStop))})),p(this,"onMouseDown",(e=>(g=m,this.handleDragStart(e)))),p(this,"onMouseUp",(e=>(g=m,this.handleDragStop(e)))),p(this,"onTouchStart",(e=>(g=h,this.handleDragStart(e)))),p(this,"onTouchEnd",(e=>(g=h,this.handleDragStop(e))))}componentDidMount(){this.mounted=!0;const e=this.findDOMNode();e&&(0,r.addEvent)(e,h.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const e=this.findDOMNode();if(e){const{ownerDocument:t}=e;(0,r.removeEvent)(t,m.move,this.handleDrag),(0,r.removeEvent)(t,h.move,this.handleDrag),(0,r.removeEvent)(t,m.stop,this.handleDragStop),(0,r.removeEvent)(t,h.stop,this.handleDragStop),(0,r.removeEvent)(e,h.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,r.removeUserSelectStyles)(t)}}findDOMNode(){var e,t;return null!==(e=this.props)&&void 0!==e&&e.nodeRef?null===(t=this.props)||void 0===t||null===(t=t.nodeRef)||void 0===t?void 0:t.current:s.default.findDOMNode(this)}render(){return o.cloneElement(o.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}}t.default=f,p(f,"displayName","DraggableCore"),p(f,"propTypes",{allowAnyClick:i.default.bool,children:i.default.node.isRequired,disabled:i.default.bool,enableUserSelectHack:i.default.bool,offsetParent:function(e,t){if(e[t]&&1!==e[t].nodeType)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:i.default.arrayOf(i.default.number),handle:i.default.string,cancel:i.default.string,nodeRef:i.default.object,onStart:i.default.func,onDrag:i.default.func,onStop:i.default.func,onMouseDown:i.default.func,scale:i.default.number,className:l.dontSetMe,style:l.dontSetMe,transform:l.dontSetMe}),p(f,"defaultProps",{allowAnyClick:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1})},5794:(e,t,n)=>{"use strict";const{default:o,DraggableCore:i}=n(6027);e.exports=o,e.exports.default=o,e.exports.DraggableCore=i},1089:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addClassName=d,t.addEvent=function(e,t,n,o){if(!e)return;const i={capture:!0,...o};e.addEventListener?e.addEventListener(t,n,i):e.attachEvent?e.attachEvent("on"+t,n):e["on"+t]=n},t.addUserSelectStyles=function(e){if(!e)return;let t=e.getElementById("react-draggable-style-el");t||(t=e.createElement("style"),t.type="text/css",t.id="react-draggable-style-el",t.innerHTML=".react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n",t.innerHTML+=".react-draggable-transparent-selection *::selection {all: inherit;}\n",e.getElementsByTagName("head")[0].appendChild(t)),e.body&&d(e.body,"react-draggable-transparent-selection")},t.createCSSTransform=function(e,t){const n=l(e,t,"px");return{[(0,i.browserPrefixToKey)("transform",i.default)]:n}},t.createSVGTransform=function(e,t){return l(e,t,"")},t.getTouch=function(e,t){return e.targetTouches&&(0,o.findInArray)(e.targetTouches,(e=>t===e.identifier))||e.changedTouches&&(0,o.findInArray)(e.changedTouches,(e=>t===e.identifier))},t.getTouchIdentifier=function(e){return e.targetTouches&&e.targetTouches[0]?e.targetTouches[0].identifier:e.changedTouches&&e.changedTouches[0]?e.changedTouches[0].identifier:void 0},t.getTranslation=l,t.innerHeight=function(e){let t=e.clientHeight;const n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=(0,o.int)(n.paddingTop),t-=(0,o.int)(n.paddingBottom),t},t.innerWidth=function(e){let t=e.clientWidth;const n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=(0,o.int)(n.paddingLeft),t-=(0,o.int)(n.paddingRight),t},t.matchesSelector=a,t.matchesSelectorAndParentsTo=function(e,t,n){let o=e;do{if(a(o,t))return!0;if(o===n)return!1;o=o.parentNode}while(o);return!1},t.offsetXYFromParent=function(e,t,n){const o=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect();return{x:(e.clientX+t.scrollLeft-o.left)/n,y:(e.clientY+t.scrollTop-o.top)/n}},t.outerHeight=function(e){let t=e.clientHeight;const n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=(0,o.int)(n.borderTopWidth),t+=(0,o.int)(n.borderBottomWidth),t},t.outerWidth=function(e){let t=e.clientWidth;const n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=(0,o.int)(n.borderLeftWidth),t+=(0,o.int)(n.borderRightWidth),t},t.removeClassName=u,t.removeEvent=function(e,t,n,o){if(!e)return;const i={capture:!0,...o};e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent?e.detachEvent("on"+t,n):e["on"+t]=null},t.removeUserSelectStyles=function(e){if(e)try{if(e.body&&u(e.body,"react-draggable-transparent-selection"),e.selection)e.selection.empty();else{const t=(e.defaultView||window).getSelection();t&&"Caret"!==t.type&&t.removeAllRanges()}}catch(e){}};var o=n(7056),i=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=s(t);if(n&&n.has(e))return n.get(e);var o={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if("default"!==r&&Object.prototype.hasOwnProperty.call(e,r)){var a=i?Object.getOwnPropertyDescriptor(e,r):null;a&&(a.get||a.set)?Object.defineProperty(o,r,a):o[r]=e[r]}return o.default=e,n&&n.set(e,o),o}(n(3514));function s(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(s=function(e){return e?n:t})(e)}let r="";function a(e,t){return r||(r=(0,o.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],(function(t){return(0,o.isFunction)(e[t])}))),!!(0,o.isFunction)(e[r])&&e[r](t)}function l(e,t,n){let{x:o,y:i}=e,s="translate(".concat(o).concat(n,",").concat(i).concat(n,")");if(t){const e="".concat("string"==typeof t.x?t.x:t.x+n),o="".concat("string"==typeof t.y?t.y:t.y+n);s="translate(".concat(e,", ").concat(o,")")+s}return s}function d(e,t){e.classList?e.classList.add(t):e.className.match(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)")))||(e.className+=" ".concat(t))}function u(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(?:^|\\s)".concat(t,"(?!\\S)"),"g"),"")}},3514:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.browserPrefixToKey=i,t.browserPrefixToStyle=function(e,t){return t?"-".concat(t.toLowerCase(),"-").concat(e):e},t.default=void 0,t.getPrefix=o;const n=["Moz","Webkit","O","ms"];function o(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"transform";if("undefined"==typeof window)return"";const o=null===(e=window.document)||void 0===e||null===(e=e.documentElement)||void 0===e?void 0:e.style;if(!o)return"";if(t in o)return"";for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){}},1726:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.canDragX=function(e){return"both"===e.props.axis||"x"===e.props.axis},t.canDragY=function(e){return"both"===e.props.axis||"y"===e.props.axis},t.createCoreData=function(e,t,n){const i=!(0,o.isNum)(e.lastX),r=s(e);return i?{node:r,deltaX:0,deltaY:0,lastX:t,lastY:n,x:t,y:n}:{node:r,deltaX:t-e.lastX,deltaY:n-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:n}},t.createDraggableData=function(e,t){const n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}},t.getBoundPosition=function(e,t,n){if(!e.props.bounds)return[t,n];let{bounds:r}=e.props;r="string"==typeof r?r:function(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}(r);const a=s(e);if("string"==typeof r){const{ownerDocument:e}=a,t=e.defaultView;let n;if(n="parent"===r?a.parentNode:e.querySelector(r),!(n instanceof t.HTMLElement))throw new Error('Bounds selector "'+r+'" could not find an element.');const s=n,l=t.getComputedStyle(a),d=t.getComputedStyle(s);r={left:-a.offsetLeft+(0,o.int)(d.paddingLeft)+(0,o.int)(l.marginLeft),top:-a.offsetTop+(0,o.int)(d.paddingTop)+(0,o.int)(l.marginTop),right:(0,i.innerWidth)(s)-(0,i.outerWidth)(a)-a.offsetLeft+(0,o.int)(d.paddingRight)-(0,o.int)(l.marginRight),bottom:(0,i.innerHeight)(s)-(0,i.outerHeight)(a)-a.offsetTop+(0,o.int)(d.paddingBottom)-(0,o.int)(l.marginBottom)}}return(0,o.isNum)(r.right)&&(t=Math.min(t,r.right)),(0,o.isNum)(r.bottom)&&(n=Math.min(n,r.bottom)),(0,o.isNum)(r.left)&&(t=Math.max(t,r.left)),(0,o.isNum)(r.top)&&(n=Math.max(n,r.top)),[t,n]},t.getControlPosition=function(e,t,n){const o="number"==typeof t?(0,i.getTouch)(e,t):null;if("number"==typeof t&&!o)return null;const r=s(n),a=n.props.offsetParent||r.offsetParent||r.ownerDocument.body;return(0,i.offsetXYFromParent)(o||e,a,n.props.scale)},t.snapToGrid=function(e,t,n){return[Math.round(t/e[0])*e[0],Math.round(n/e[1])*e[1]]};var o=n(7056),i=n(1089);function s(e){const t=e.findDOMNode();if(!t)throw new Error(": Unmounted during event!");return t}},7056:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dontSetMe=function(e,t,n){if(e[t])return new Error("Invalid prop ".concat(t," passed to ").concat(n," - do not set this, set it on the child."))},t.findInArray=function(e,t){for(let n=0,o=e.length;n{"use strict";var o,i=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}(),s=[];function r(e){for(var t=-1,n=0;n{"use strict";n.d(t,{A:()=>o});class o{constructor({name:e,url:t}){this.name=e,this.url=t}getUrl(){return this.url}getName(){return this.name}toString(){return this.url}}},3795:(e,t,n)=>{"use strict";n.d(t,{D:()=>u});var o=n(8763),i=n(3200),s=n(9678),r=n(6822),a=n(7031);const l={_common:["_createdAt","_updatedAt","objectId"],_User:["_email_verify_token"]};function d(e,t){const n=Object.assign({},e);return l._common.forEach((e=>delete n[e])),t&&l[t]&&l[t].forEach((e=>delete n[e])),n}class u{static get instance(){return void 0===u._instance&&(u._instance=new u),u._instance}static get collections(){return void 0===u._collections&&(u._collections={},(a.A.instance.getMetaData("dbCollections")||[]).forEach((e=>{u._collections&&(u._collections[e.name]=e)})),(a.A.instance.getMetaData("systemCollections")||[]).forEach((e=>{u._collections&&(u._collections[e.name]=e)}))),u._collections}constructor(e){this._initCloudServices(),this.events=new r.b,this.modelScope=e||o.K}_fromJSON(e,t){return u._fromJSON(e,t,this.modelScope)}_deserializeJSON(e,t){return u._deserializeJSON(e,t,this.modelScope)}_serializeObject(e,t){return u._serializeObject(e,t,this.modelScope)}_initCloudServices(){u._collections=void 0;const e=a.A.instance.getMetaData("cloudservices");e&&(this.appId=e.appId,this.endpoint=e.endpoint);const t=a.A.instance.getMetaData("dbVersionMajor");this.dbVersionMajor=t}on(e,t,n){this.events.on.apply(this.events,[e,t,n])}off(e,t,n,o){this.events.off.apply(this.events,[e,t,n,o])}_makeRequest(e,t){if(!this.appId)throw new Error("App ID is not set");if("undefined"==typeof _noodl_cloud_runtime_version){const n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState){let e;try{e=JSON.parse(n.response||n.responseText)}catch(e){}200===n.status||201===n.status?t.success(e):t.error(e||{error:n.responseText,status:n.status})}},n.open(t.method||"GET",this.endpoint+e,!0),n.setRequestHeader("X-Parse-Application-Id",this.appId),"undefined"!=typeof _noodl_cloudservices&&n.setRequestHeader("X-Parse-Master-Key",_noodl_cloudservices.masterKey);const o=localStorage["Parse/"+this.appId+"/currentUser"];if(void 0!==o)try{const e=JSON.parse(o);n.setRequestHeader("X-Parse-Session-Token",e.sessionToken)}catch(e){}t.onUploadProgress&&(n.upload.onprogress=e=>{t.onUploadProgress&&t.onUploadProgress(e)}),t.content instanceof File?n.send(t.content):(n.setRequestHeader("Content-Type","application/json"),n.send(JSON.stringify(t.content)))}else{const n="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.endpoint:this.endpoint,o="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.appId:this.appId,i="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.masterKey:void 0;fetch(n+e,{method:t.method||"GET",headers:{"X-Parse-Application-Id":o,"X-Parse-Master-Key":i,"Content-Type":"application/json"},body:JSON.stringify(t.content)}).then((e=>{200===e.status||201===e.status?"DELETE"===t.method?t.success(void 0):e.json().then((e=>t.success(e))).catch((e=>t.error({error:"CloudStore: Failed to get json result."}))):"DELETE"===t.method?t.error({error:"Failed to delete."}):e.json().then((e=>t.error(e))).catch((e=>t.error({error:"Failed to fetch."})))})).catch((e=>{t.error({error:e.message})}))}}query(e){this._makeRequest("/classes/"+e.collection,{method:"POST",content:{_method:"GET",where:e.where,limit:e.limit,skip:e.skip,include:Array.isArray(e.include)?e.include.join(","):e.include,keys:Array.isArray(e.select)?e.select.join(","):e.select,order:Array.isArray(e.sort)?e.sort.join(","):e.sort,count:e.count},success:function(t){e.success(t.results,t.count)},error:function(){e.error()}})}aggregate(e){const t=[];if(!e.group)return void e.error("You need to provide group option.");e.limit&&t.push("limit="+e.limit),e.skip&&t.push("skip="+e.skip);const n={};Object.keys(e.group).forEach((t=>{const o={},i=e.group[t];void 0!==i.avg?o.$avg="$"+i.avg:void 0!==i.sum?o.$sum="$"+i.sum:void 0!==i.max?o.$max="$"+i.max:void 0!==i.min?o.$min="$"+i.min:void 0!==i.distinct&&(o.$addToSet="$"+i.distinct),n[t]=o})),this.dbVersionMajor&&this.dbVersionMajor>4?(n._id=null,e.where&&t.push("$match="+encodeURIComponent(JSON.stringify(e.where))),t.push("$group="+JSON.stringify(n))):(n.objectId=null,e.where&&t.push("match="+encodeURIComponent(JSON.stringify(e.where))),t.push("group="+JSON.stringify(n))),this._makeRequest("/aggregate/"+e.collection+(t.length>0?"?"+t.join("&"):""),{success:function(t){const n={};t.results&&1===t.results.length?(Object.keys(e.group).forEach((e=>{n[e]=t.results[0][e]})),e.success(n)):e.success({})},error:function(){e.error()}})}count(e){const t=[];e.where&&t.push("where="+encodeURIComponent(JSON.stringify(e.where))),t.push("limit=0"),t.push("count=1"),this._makeRequest("/classes/"+e.collection+(t.length>0?"?"+t.join("&"):""),{success:function(t){e.success(t.count)},error:function(){e.error()}})}distinct(e){const t=[];e.where&&t.push("where="+encodeURIComponent(JSON.stringify(e.where))),t.push("distinct="+e.property),this._makeRequest("/aggregate/"+e.collection+(t.length>0?"?"+t.join("&"):""),{success:function(t){e.success(t.results)},error:function(){e.error()}})}fetch(e){const t=[];e.include&&t.push("include="+(Array.isArray(e.include)?e.include.join(","):e.include)),e.keys&&t.push("keys="+(Array.isArray(e.keys)?e.keys.join(","):e.keys)),e.excludeKeys&&t.push("excludeKeys="+(Array.isArray(e.excludeKeys)?e.excludeKeys.join(","):e.excludeKeys)),this._makeRequest("/classes/"+e.collection+"/"+e.objectId+(t.length>0?"?"+t.join("&"):""),{method:"GET",success:t=>{e.success(t),this.events.emit("fetch",{type:"fetch",objectId:e.objectId,object:t,collection:e.collection})},error:function(t){e.error(t.error)}})}create(e){this._makeRequest("/classes/"+e.collection,{method:"POST",content:Object.assign(d(u._serializeObject(e.data,e.collection),e.collection),{ACL:e.acl}),success:t=>{const n=Object.assign({},e.data,t);e.success(n),this.events.emit("create",{type:"create",objectId:e.objectId,object:n,collection:e.collection})},error:function(t){e.error(t.error)}})}increment(e){const t={};for(let n in e.properties)t[n]={__op:"Increment",amount:e.properties[n]};this._makeRequest("/classes/"+e.collection+"/"+e.objectId,{method:"PUT",content:t,success:t=>{e.success(t)},error:function(t){e.error(t.error)}})}save(e){const t=Object.assign({},e.data);delete t.createdAt,delete t.updatedAt,this._makeRequest("/classes/"+e.collection+"/"+e.objectId,{method:"PUT",content:Object.assign(d(u._serializeObject(t,e.collection),e.collection),{ACL:e.acl}),success:t=>{e.success(t),this.events.emit("save",{type:"save",objectId:e.objectId,object:Object.assign({},e.data,t),collection:e.collection})},error:function(t){e.error(t.error)}})}delete(e){this._makeRequest("/classes/"+e.collection+"/"+e.objectId,{method:"DELETE",success:()=>{e.success(),this.events.emit("delete",{type:"delete",objectId:e.objectId,collection:e.collection})},error:function(t){e.error(t.error)}})}addRelation(e){if(!e.key)throw new Error("Key is required");const t={};t[e.key]={__op:"AddRelation",objects:[{__type:"Pointer",objectId:e.targetObjectId,className:e.targetClass}]},this._makeRequest("/classes/"+e.collection+"/"+e.objectId,{method:"PUT",content:t,success:function(t){e.success(t)},error:function(t){e.error(t.error)}})}removeRelation(e){if(!e.key)throw new Error("Key is required");const t={};t[e.key]={__op:"RemoveRelation",objects:[{__type:"Pointer",objectId:e.targetObjectId,className:e.targetClass}]},this._makeRequest("/classes/"+e.collection+"/"+e.objectId,{method:"PUT",content:t,success:function(t){e.success(t)},error:function(t){e.error(t.error)}})}uploadFile(e){if(!e.file)throw new Error("File is required");this._makeRequest("/files/"+e.file.name,{method:"POST",content:e.file,contentType:e.file.type,success:t=>e.success(Object.assign({},e.data,t)),error:t=>e.error(t),onUploadProgress:e.onUploadProgress})}deleteFile(e){if(!e.file)throw new Error("File is required");this._makeRequest("/files/"+e.file.name,{method:"DELETE",success:t=>e.success(Object.assign({},e.data,t)),error:t=>e.error(t)})}static forScope(e){return void 0===e?u.instance:(e._cloudStore||(e._cloudStore=new u(e)),e._cloudStore)}static invalidateCollections(){_collections=void 0}static _fromJSON(e,t,n){const i=(n||o.K).get(e.objectId);let s;i._class=t,void 0!==t&&void 0!==u._collections[t]&&(s=u._collections[t].schema);for(const t in e){if("objectId"===t||"ACL"===t)continue;const o=s&&s.properties&&s.properties[t]?s.properties[t].type:void 0;i.set(t,u._deserializeJSON(e[t],o,n))}return i}static _serializeObject(e,t,n){let r;u._collections[t]&&(r=u._collections[t].schema);for(const t in e){const a=r&&r.properties&&r.properties[t]?r.properties[t].type:void 0;if(void 0===e[t]||null===e[t]);else if("Pointer"===a&&"string"==typeof e[t])e[t]={__type:"Pointer",className:r.properties[t].targetClass,objectId:e[t]};else if("Pointer"===a&&"object"==typeof e[t]&&(n||o.K).instanceOf(e[t]))e[t]={__type:"Pointer",className:r.properties[t].targetClass,objectId:e[t].getId()};else if("Date"===a&&("string"==typeof e[t]||e[t]instanceof Date))e[t]={__type:"Date",iso:e[t]instanceof Date?e[t].toISOString():e[t]};else if("File"===a&&e[t]instanceof s.A){const n=e[t];e[t]={__type:"File",url:n.getUrl(),name:n.getName()}}else"Array"===a&&"string"==typeof e[t]&&i.p.exists(e[t])?e[t]=c(i.p.get(e[t])):"Object"===a&&"string"==typeof e[t]&&(n||o.K).exists(e[t])?e[t]=c((n||o.K).get(e[t])):"GeoPoint"===a&&"object"==typeof e[t]?e[t]={__type:"GeoPoint",latitude:Number(e[t].latitude),longitude:Number(e[t].longitude)}:e[t]=c(e[t])}return e}static _deserializeJSON(e,t,n){if(void 0!==e){if(null===e)return null;if("Relation"!==t||"Relation"!==e.__type){if("Pointer"===t&&"Pointer"===e.__type)return e.objectId;if("Date"===t&&"Date"===e.__type)return new Date(e.iso);if("Date"===t&&"string"==typeof e)return new Date(e);if("File"===t&&"File"===e.__type)return new s.A(e);if("GeoPoint"===t&&"GeoPoint"===e.__type)return{latitude:e.latitude,longitude:e.longitude};if(function(e){if(!Array.isArray(e))return!1;for(let t=0;t{t.push(c(e))})),t}return e}},3200:(e,t,n)=>{"use strict";n.d(t,{p:()=>i});var o=n(8763);Object.prototype.hasOwnProperty.call(Array.prototype,"items")||Object.defineProperty(Array.prototype,"items",{enumerable:!1,get(){return this},set(e){this.set(e)}}),Object.defineProperty(Array.prototype,"each",{enumerable:!1,writable:!1,value:Array.prototype.forEach}),Object.prototype.hasOwnProperty.call(Array.prototype,"size")||Object.defineProperty(Array.prototype,"size",{enumerable:!1,writable:!1,value:function(){return this.length}}),Object.prototype.hasOwnProperty.call(Array.prototype,"get")||Object.defineProperty(Array.prototype,"get",{enumerable:!1,writable:!1,value:function(e){return this[e]}}),Object.prototype.hasOwnProperty.call(Array.prototype,"getId")||Object.defineProperty(Array.prototype,"getId",{enumerable:!1,writable:!1,value:function(){return this._id}}),Object.prototype.hasOwnProperty.call(Array.prototype,"id")||Object.defineProperty(Array.prototype,"id",{enumerable:!1,get(){return this.getId()}}),Object.prototype.hasOwnProperty.call(Array.prototype,"set")||Object.defineProperty(Array.prototype,"set",{enumerable:!1,writable:!1,value:function(e){let t,n;if(e===this)return;function i(e){const t={},n=e.length;for(let o=0;o{"use strict";function o(e){let t=!1;return function(n){(n=!!n)&&!1===t&&e.valueChangedToTrue.call(this),t=n}}n.d(t,{i:()=>o})},8763:(e,t,n)=>{"use strict";n.d(t,{K:()=>i});var o=n(6351);class i{constructor(e,t){this.id=e,this.data=t}static get(e){return void 0===e&&(e=i.guid()),i.models[e]||(i.models[e]=new i(e,{}),i.proxies[e]=new Proxy(i.models[e],i._modelProxyHandler)),i.proxies[e]}static create(e){const t=e||{},n=i.get(t.id);for(const e in t)"id"!==e&&n.set(e,t[e]);return n}static exists(e){return void 0!==i.models[e]}static instanceOf(e){return e instanceof i||e.target instanceof i}static guid(){return(0,o.DU)(10)}on(e,t){this.listeners||(this.listeners={}),this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)}off(e,t){if(!this.listeners)return;if(!this.listeners[e])return;const n=this.listeners[e].indexOf(t);-1!==n&&this.listeners[e].splice(n,1)}notify(e,t){if(!this.listeners)return;if(!this.listeners[e])return;const n=this.listeners[e].slice();for(let e=0;eReflect.ownKeys(e.data),getOwnPropertyDescriptor:(e,t)=>Object.getOwnPropertyDescriptor(e.data,t.toString())}},2908:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.d(__webpack_exports__,{b:()=>Node});var _outputproperty__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(900);class Node{constructor(e,t){this.updateOnDirtyFlagging=!0,this.children=[],this._internal={},this._dirty=!1,this._inputs={},this._inputValues={},this._outputs={},this._inputConnections={},this._outputList=[],this._isUpdating=!1,this._inputValuesQueue={},this._afterInputsHaveUpdatedCallbacks=[],this._signalsSentThisUpdate={},this._deleted=!1,this._deleteListeners=[],this._isFirstUpdate=!0,this._valuesFromConnections={},this._updateIteration=0,this.id=t,this.context=e}getInputValue(e){return this._inputValues[e]}registerInput(e,t){var n;if(this.hasInput(e))throw new Error("Input property "+e+" already registered");if(this._inputs[e]=t,t.type&&"object"==typeof t.type&&"units"in t.type){const o=t.type.defaultUnit||(null===(n=t.type.units)||void 0===n?void 0:n[0])||"";this._inputValues[e]={value:t.default,type:o}}else t.hasOwnProperty("default")&&(this._inputValues[e]=t.default)}deregisterInput(e){if(!1===this.hasInput(e))throw new Error("Input property "+e+" doesn't exist");delete this._inputs[e],delete this._inputValues[e]}registerInputs(e){for(const t in e)this.registerInput(t,e[t])}getInput(e){if(!1!==this.hasInput(e))return this._inputs[e];console.log("Node "+this.name+": Invalid input property "+e)}hasInput(e){return e in this._inputs}registerInputIfNeeded(e){}setInputValue(name,value){var _a,_b,_c,_d,_e;const input=this.getInput(name);if(input){if("object"==typeof input.type&&"array"===input.type.name&&"string"==typeof value)try{const e=JSON.parse(value);input.set.call(this,e),input.value=e,this._inputValues[name]=e}catch(e){}else input.set.call(this,value),input.value=value,this._inputValues[name]=value;if("color"===input.type&&this.context&&this.context.styles)value=this.context.styles.resolveColor(value);else if("array"===input.type&&"string"==typeof value)try{value=eval(value),null===(_a=this.context.editorConnection)||void 0===_a||_a.clearWarning(null===(_c=null===(_b=this.nodeScope)||void 0===_b?void 0:_b.componentOwner)||void 0===_c?void 0:_c.name,this.id,"invalid-array-"+name)}catch(e){const t=e;value=[],console.log(e),this.context.editorConnection&&this.context.editorConnection.sendWarning(null===(_e=null===(_d=this.nodeScope)||void 0===_d?void 0:_d.componentOwner)||void 0===_e?void 0:_e.name,this.id,"invalid-array-"+name,{showGlobally:!0,message:"Invalid array
"+t.toString()})}input.set.call(this,value)}else console.log("node doesn't have input",name)}hasOutput(e){return e in this._outputs}registerOutput(e,t){if(this.hasOutput(e))throw new Error("Output property "+e+" already registered");const n=new _outputproperty__WEBPACK_IMPORTED_MODULE_0__.V({owner:this,getter:t.get||t.getter,name:e,onFirstConnectionAdded:t.onFirstConnectionAdded,onLastConnectionRemoved:t.onLastConnectionRemoved});this._outputs[e]=n,this._outputList.push(n)}deregisterOutput(e){if(!1===this.hasOutput(e))throw new Error("Output property "+e+" isn't registered");const t=this._outputs[e];if(t.hasConnections())throw new Error("Output property "+e+" has connections and can't be removed");delete this._outputs[e];const n=this._outputList.indexOf(t);this._outputList.splice(n,1)}registerOutputs(e){for(const t in e)this.registerOutput(t,e[t])}registerOutputIfNeeded(){}getOutput(e){if(!1===this.hasOutput(e))throw new Error("Node "+this.name+" doesn't have a port named "+e);return this._outputs[e]}connectInput(e,t,n){if(!1===this.hasInput(e))throw new Error("Invalid connection, input doesn't exist. Trying to connect from "+t.name+" output "+n+" to "+this.name+" input "+e);const o=t.getOutput(n);if(o.registerConnection(this,e),this._inputConnections[e]||(this._inputConnections[e]=[]),this._inputConnections[e].push(o),t._signalsSentThisUpdate[n])this._setValueFromConnection(e,!0),this._setValueFromConnection(e,!1);else{const t=o.value;void 0!==t&&(this._setValueFromConnection(e,t),this.context&&this.context.connectionSentValue(o,o.value))}this.flagDirty()}removeInputConnection(e,t,n){if(!this._inputConnections[e])throw new Error("Node removeInputConnection: Input doesn't exist");const o=this._inputConnections[e];for(let i=0;i{var t;if("Component Inputs"!==e.owner.name)return!0;const n=null===(t=e.owner.nodeScope)||void 0===t?void 0:t.componentOwner;return null==n?void 0:n.isInputConnected(e.name)}))}update(){var e,t,n,o;if(!this._isUpdating&&!1!==this._dirty){this._updatedAtIteration!==this.context.updateIteration&&(this._updatedAtIteration=this.context.updateIteration,this._updateIteration=0,this._cyclicLoop&&(this._cyclicLoop=!1)),this._isUpdating=!0;try{for(;this._dirty&&!this._cyclicLoop;){this._updateDependencies(),this._dirty=!1;const e=Object.keys(this._inputValuesQueue);let t=!0;for(;t&&!this._cyclicLoop;){t=!1;for(let n=0;n0&&(this.setInputValue(o,i.shift()),i.length>0&&(t=!0))}const n=this._afterInputsHaveUpdatedCallbacks;this._afterInputsHaveUpdatedCallbacks=[];for(let e=0;e=100&&(this._cyclicLoop=!0)}}catch(e){throw this._isUpdating=!1,e}this._cyclicLoop&&(this.context.scheduleNextFrame((()=>{this.context.nodeIsDirty(this)})),this.context.editorConnection&&!this._cyclicWarningSent&&this.context.isWarningTypeEnabled("cyclicLoops")&&(this.context.editorConnection.sendWarning(null===(t=null===(e=this.nodeScope)||void 0===e?void 0:e.componentOwner)||void 0===t?void 0:t.name,this.id,"cyclic-loop",{showGlobally:!0,message:"Cyclic loop detected"}),this._cyclicWarningSent=!0,console.log("cycle detected",{id:this.id,name:this.name,component:null===(o=null===(n=this.nodeScope)||void 0===n?void 0:n.componentOwner)||void 0===o?void 0:o.name}))),this._isFirstUpdate=!1,this._isUpdating=!1}}_updateDependencies(){for(const e in this._inputConnections){const t=this._inputConnections[e];for(let e=0;e{this.hasInput(e.name)&&this.deregisterInput(e.name)}),this),e.on("outputPortRemoved",(e=>{this.hasOutput(e.name)&&this.deregisterOutput(e.name)}),this)}addDeleteListener(e){this._deleteListeners.push(e)}_onNodeDeleted(){this.model&&(this.model.removeListenersWithRef(this),this.model=void 0),this._deleted=!0;for(const e of this._deleteListeners)e.call(this)}_onNodeModelParameterUpdated(e){var t;if(this.registerInputIfNeeded(e.name),void 0!==e.value)if(e.state){if(!this._getVisualStates)return void console.log("Node has nos visual states, but got a parameter for state",e.state);-1!==this._getVisualStates().indexOf(e.state)&&this.queueInput(e.name,e.value)}else this.queueInput(e.name,e.value);else{let n;const o=this.variant;"object"==typeof o&&(e.state?o&&o.stateParameters.hasOwnProperty(e.state)&&o.stateParameters[e.state].hasOwnProperty(e.name)?n=o.stateParameters[e.state][e.name]:(null===(t=this.model)||void 0===t?void 0:t.parameters.hasOwnProperty(e.name))?n=this.model.parameters[e.name]:o&&o.parameters.hasOwnProperty(e.name)&&(n=o.parameters[e.name]):o&&o.parameters.hasOwnProperty(e.name)&&(n=o.parameters[e.name])),void 0===n&&(n=this.context.getDefaultValueForInput(this.model.type,e.name),this._resetReactVirtualDOM&&this._resetReactVirtualDOM()),this.queueInput(e.name,n)}}_onNodeModelVariantUpdated(e){this.setVariant(e)}setVariant(e){this.variant=e}}},4281:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.d(__webpack_exports__,{BO:()=>_addBaseInfo,D3:()=>_addInputProperties,Gs:()=>_addModelId});var _collection__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(3200),_model__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(8763);function _addBaseInfo(e){Object.assign(e.node,{category:"Data",color:"data"})}function _addModelId(e,t){const n=void 0===t||t.includeInputs,o=void 0===t||t.includeOutputs;Object.assign(e.node,{inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),n&&(Object.assign(e.node,{usePortAsLabel:"modelId"}),e.node.dynamicports=(e.node.dynamicports||[]).concat([{name:"conditionalports/extended",condition:"idSource = explicit OR idSource NOT SET",inputs:["modelId"]}]),Object.assign(e.node.inputs,{idSource:{type:{name:"enum",enums:[{label:"Specify explicitly",value:"explicit"},{label:"From repeater",value:"foreach"}],allowEditOnly:!0},default:"explicit",displayName:"Id Source",group:"General",set(e){"foreach"===e&&this.scheduleAfterInputsHaveUpdated((()=>{let e=this.nodeScope.componentOwner;for(;void 0!==e&&void 0===e._forEachModel&&e.parentNodeScope;)e=e.parentNodeScope.componentOwner;this.setModel(void 0!==e?e._forEachModel:void 0)}))}},modelId:{type:{name:"string",identifierOf:"ModelName",identifierDisplayName:"Object Ids"},displayName:"Id",group:"General",set:function(e){e instanceof _model__WEBPACK_IMPORTED_MODULE_1__.K&&(e=e.getId()),this._internal.modelId=e,this.setModelID(e)}}})),o&&Object.assign(e.node.outputs,{id:{type:"string",displayName:"Id",group:"General",getter:function(){return this._internal.model?this._internal.model.getId():this._internal.modelId}}}),Object.assign(e.node.methods,{setModelID:function(e){const t=(this.nodeScope.modelScope||_model__WEBPACK_IMPORTED_MODULE_1__.K).get(e);this.setModel(t)},setModel:function(e){this._internal.model=e,this.flagOutputDirty("id")}}),e.node.getInspectInfo||(e.node.getInspectInfo=function(){const e=this._internal.model;return e?[{type:"text",value:"Id: "+e.getId()},{type:"value",value:e.data}]:"[No Object]"})}function _addInputProperties(def){const _def={node:Object.assign({},def.node),setup:def.setup},_methods=Object.assign({},def.node.methods);Object.assign(def.node,{inputs:def.node.inputs||{},outputs:def.node.outputs||{},methods:def.node.methods||{}}),Object.assign(def,{setup:function(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&(t.on("nodeAdded."+def.node.name,(function(t){function n(){const n=[],o=[{label:"String",value:"string"},{label:"Boolean",value:"boolean"},{label:"Number",value:"number"},{label:"Date",value:"date"},{label:"Array",value:"array"},{label:"Object",value:"object"},{label:"Any",value:"*"}];let i=t.parameters.properties;if(i){i=i?i.split(","):void 0;for(const e of i)n.push({type:{name:void 0===t.parameters["type-"+e]?"*":t.parameters["type-"+e]},plug:"input",group:"Property Values",displayName:e,name:"prop-"+e}),n.push({type:{name:"enum",enums:o,allowEditOnly:!0},plug:"input",group:"Property Types",displayName:e,default:"*",name:"type-"+e})}e.editorConnection.sendDynamicPorts(t.id,n,{detectRenamed:{plug:"input"}})}n(),t.on("parameterUpdated",(function(){n()}))})),_def.setup&&_def.setup(e,t))}}),Object.assign(def.node,{initialize:function(){const e=this._internal;e.inputValues={},e.inputTypes={},_def.node.initialize&&_def.node.initialize.call(this)}}),Object.assign(def.node.outputs,{}),Object.assign(def.node.inputs,{properties:{type:{name:"stringlist",allowEditOnly:!0},displayName:"Properties",group:"Properties to set",set:function(){}}}),Object.assign(def.node.methods,{_pushInputValues:function(model){const internal=this._internal,_defaultValueForType={boolean:!1,string:"",number:0,date:new Date},_allKeys={};for(const e in internal.inputTypes)_allKeys[e]=!0;for(const e in internal.inputValues)_allKeys[e]=!0;const properties=this.model.parameters.properties||"",validProperties=properties.split(","),keysToSet=Object.keys(_allKeys).filter((e=>-1!==validProperties.indexOf(e)));for(const i of keysToSet){let value=internal.inputValues[i];if(void 0!==value){if(void 0!==internal.inputTypes[i]&&"array"===internal.inputTypes[i]&&"string"==typeof value){this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"invalid-array-"+i);try{value=eval(value)}catch(e){-1!==value.indexOf("[")||-1!==value.indexOf("{")?(this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"invalid-array-"+i,{showGlobally:!0,message:"Invalid array
"+e.toString()}),value=[]):value=_collection__WEBPACK_IMPORTED_MODULE_0__.p.get(value)}}void 0!==internal.inputTypes[i]&&"object"===internal.inputTypes[i]&&"string"==typeof value&&(value=(this.nodeScope.modelScope||_model__WEBPACK_IMPORTED_MODULE_1__.K).get(value)),model.set(i,value,{resolve:!0})}else model.set(i,_defaultValueForType[internal.inputTypes[i]],{resolve:!0})}},scheduleStore:function(){if(this.hasScheduledStore)return;this.hasScheduledStore=!0;const e=this._internal;this.scheduleAfterInputsHaveUpdated((()=>{this.hasScheduledStore=!1,e.model&&(this._pushInputValues(e.model),this.sendSignalOnOutput("stored"))}))},registerInputIfNeeded:function(e){this.hasInput(e)||(e.startsWith("prop-")&&this.registerInput(e,{set:this._setInputValue.bind(this,e.substring(5))}),e.startsWith("type-")&&this.registerInput(e,{set:this._setInputType.bind(this,e.substring(5))}),_methods&&_methods.registerInputIfNeeded&&_def.node.methods.registerInputIfNeeded.call(this,e))},_setInputValue:function(e,t){this._internal.inputValues[e]=t},_setInputType:function(e,t){this._internal.inputTypes[e]=t}})}},900:(e,t,n)=>{"use strict";n.d(t,{V:()=>o});class o{constructor(e){if(this.valuesSendThisIteration=0,!e.owner)throw new Error("Owner must be set");this.getter=e.getter||(()=>{}),this.connections=[],this._owner=e.owner,this._name=e.name,this.onFirstConnectionAdded=e.onFirstConnectionAdded,this.onLastConnectionRemoved=e.onLastConnectionRemoved}get name(){return this._name}get owner(){return this._owner}get value(){return this.getter.call(this.owner)}get id(){return this._id||(this._id=this.owner.id+this.name),this._id}registerConnection(e,t){this.connections.push({node:e,inputPortName:t}),1===this.connections.length&&this.onFirstConnectionAdded&&this.onFirstConnectionAdded.call(this.owner)}deregisterConnection(e,t){for(let n=0;n500&&(this.owner._cyclicLoop=!0);for(let t=0,n=this.connections.length;t0}}},7031:(e,t,n)=>{"use strict";n.d(t,{A:()=>rn});var o={};n.r(o),n.d(o,{node:()=>de});var s={};n.r(s),n.d(s,{node:()=>ue});var r={};n.r(r),n.d(r,{node:()=>pe});var a={};n.r(a),n.d(a,{node:()=>he,setup:()=>ge});var l={};n.r(l),n.d(l,{node:()=>ve,setup:()=>Ie});var d={};n.r(d),n.d(d,{node:()=>Ee,setup:()=>Ae});var u={};n.r(u),n.d(u,{node:()=>We,setup:()=>$e});var c={};n.r(c),n.d(c,{node:()=>He,setup:()=>Je});var p={};n.r(p),n.d(p,{node:()=>ot});var h={};n.r(h),n.d(h,{node:()=>st});var m={};n.r(m),n.d(m,{node:()=>at});var g={};n.r(g),n.d(g,{node:()=>dt});var f={};n.r(f),n.d(f,{node:()=>ct});var y={};n.r(y),n.d(y,{node:()=>pt,setup:()=>mt});var v={};n.r(v),n.d(v,{node:()=>ft,setup:()=>_t});var b={};n.r(b),n.d(b,{node:()=>Nt});var _={};n.r(_),n.d(_,{node:()=>It});var S={};n.r(S),n.d(S,{node:()=>Pt});var C={};n.r(C),n.d(C,{node:()=>Et,setup:()=>Tt});var N={};n.r(N),n.d(N,{node:()=>kt});var O={};n.r(O),n.d(O,{node:()=>Rt});var I={};n.r(I),n.d(I,{node:()=>Mt});var w={};n.r(w),n.d(w,{node:()=>Vt});var P={};n.r(P),n.d(P,{node:()=>Ft});var x={};n.r(x),n.d(x,{node:()=>Wt});var E={};n.r(E),n.d(E,{node:()=>Lt});var T={};n.r(T),n.d(T,{node:()=>Bt});var A={};n.r(A),n.d(A,{node:()=>$t});var k={};n.r(k),n.d(k,{node:()=>zt});var D={};n.r(D),n.d(D,{node:()=>Ht});var R={};n.r(R),n.d(R,{node:()=>Gt,setup:()=>Yt});var M={};n.r(M),n.d(M,{node:()=>Jt});var V={};n.r(V),n.d(V,{node:()=>Kt});var j={};n.r(j),n.d(j,{node:()=>Qt,setup:()=>en});var F={};n.r(F),n.d(F,{node:()=>tn,setup:()=>on});var U=n(6822);class W{constructor(e){this._constructors={},this.context=e}register(e){const t=e.metadata.name;this._constructors[t]=e}createNode(e,t,n){if(!this._constructors.hasOwnProperty(e))throw new Error("Unknown node type with name "+e);return this._constructors[e](this.context,t,n)}getNodeMetadata(e){if(!this._constructors.hasOwnProperty(e))throw new Error("Unknown node type with name "+e);return this._constructors[e].metadata}hasNode(e){return this._constructors.hasOwnProperty(e)}getInputType(e,t){var n,o;return null===(o=null===(n=this.getNodeMetadata(e).inputs)||void 0===n?void 0:n[t])||void 0===o?void 0:o.type}}class L{constructor(e,t){this._hasCalledOnStart=!1,this._wasStopped=!1,this._start=0,this._durationLeft=0,this.duration=t.duration||0,this._isRunning=!1,this._hasCalledOnStart=!1,this.scheduler=e,this.repeatCount=1,this.delay=0;for(const e in t)this[e]=t[e]}start(){return this._isRunning&&this.stop(),this.scheduler.scheduleTimer(this),this}stop(){this.scheduler.stopTimer(this),this._hasCalledOnStart=!1,this._isRunning=!1,this._wasStopped=!0}isRunning(){return this._isRunning}durationLeft(){return this._durationLeft}}class B{constructor(e){this.requestFrame=e,this.runningTimers=[],this.newTimers=[]}createTimer(e){return new L(this,e)}scheduleTimer(e){-1===this.newTimers.indexOf(e)&&(0===e.repeatCount&&(e.repeatCount=1e5),this.newTimers.push(e),this.requestFrame())}stopTimer(e){let t;e._isRunning?(t=this.runningTimers.indexOf(e),-1!==t&&this.runningTimers.splice(t,1),e.onStop&&!e._wasStopped&&e.onStop()):(t=this.newTimers.indexOf(e),-1!==t&&this.newTimers.splice(t,1))}runTimers(e){var t,n;const o=[],i=[],s=[];let r;const a=this.runningTimers.length;let l;for(r=0;r=l._start){let t;!1===l._hasCalledOnStart&&l.onStart&&(l.onStart(),l._hasCalledOnStart=!0),t=l.duration>0?(e-l._start)/(l.duration*l.repeatCount):1,l._durationLeft=l.duration*(1-t);let n=t*l.repeatCount-Math.floor(t*l.repeatCount);t>=1&&(n=1),l.onRunning&&l.onRunning(n),t<1&&l._isRunning?o.push(l):l._wasStopped||i.push(l)}else o.push(l);for(this.runningTimers=o,r=0;r0){for(r=0;r0||this.newTimers.length>0}}class ${constructor({graphModel:e,getNodeScope:t}){this.getNodeScope=t,e&&(this.graphModel=e,e.on("variantUpdated",(e=>this.onVariantUpdated(e))))}getVariant(e,t){if(this.graphModel&&t)return this.graphModel.getVariant(e,t)}onVariantUpdated(e){const t=this.getNodeScope();if(!t)return;const n=t.getNodesWithTypeRecursive(e.typename).filter((t=>"object"==typeof t.variant?t.variant.name===e.name:"string"==typeof t.variant?t.variant===e.name:t.model&&t.model.variant===e.name));for(const t of n)t.setVariant(e)}}var q=n(2908),z=n(6351);class H{constructor(e,t){this.context=e,this.nodes={},this.componentOwner=t,this.componentInstanceChildren={}}verifyData(e,t){t.forEach((t=>{if(!e[t])throw new Error("Missing "+t)}))}addConnection(e){try{this.verifyData(e,["sourceId","sourcePort","targetId","targetPort"])}catch(e){throw new Error("Error in connection: "+e.message)}try{const t=this.getNodeWithId(e.sourceId),n=this.getNodeWithId(e.targetId);n.registerInputIfNeeded(e.targetPort),t.registerOutputIfNeeded(e.sourcePort),n.connectInput(e.targetPort,t,e.sourcePort)}catch(e){console.error(e.message)}}setNodeParameters(e,t){const n=this.context.variants.getVariant(t.type,t.variant);if(n)e.setVariant(n);else{const n=t.parameters||{};let o=Object.keys(n);if(this.context.nodeRegister.hasNode(e.name)){const t=this.context.nodeRegister.getNodeMetadata(e.name);t.inputs&&o.sort(((e,n)=>{var o,i;const s=t.inputs[e],r=t.inputs[n];return(null!==(o=null==r?void 0:r.inputPriority)&&void 0!==o?o:0)-(null!==(i=null==s?void 0:s.inputPriority)&&void 0!==i?i:0)}))}o.forEach((t=>{e.registerInputIfNeeded(t),!1!==e.hasInput(t)&&e.queueInput(t,n[t])}))}}async createNodeFromModel(e,t){if("Component Children"===e.type){if(e.parent){const t=this.getNodeWithId(e.parent.id);this.componentOwner.setChildRoot(t)}return}let n;try{n=await this.createNode(e.type,e.id),n.updateOnDirtyFlagging=!1!==t,n.setNodeModel(e)}catch(t){return console.error(t.message),void(this.context.editorConnection&&this.context.isWarningTypeEnabled("nodescope")&&this.context.editorConnection.sendWarning(this.componentOwner.name,e.id,"nodelibrary-unknown-node",{message:t.message,showGlobally:!0}))}return e.variant&&n.setVariant&&n.setVariant(e.variant),this.setNodeParameters(n,e),e.parent&&this.insertNodeInTree(n,e),n}insertNodeInTree(e,t){if(!t.parent)throw new Error("Cannot insert node without parent");const n=this.getNodeWithId(t.parent.id),o=t.parent.children.indexOf(t);if(!n.addChild)throw new Error("Node "+n.id+" of type "+n.constructor.name+" can't have children");n.addChild(e,o)}getNodeWithId(e){if(!this.nodes.hasOwnProperty(e))throw new Error("Unknown node id "+e);return this.nodes[e]}hasNodeWithId(e){return this.nodes.hasOwnProperty(e)}createPrimitiveNode(e,t,n){if(t||(t=(0,z.Os)()),this.nodes.hasOwnProperty(t))throw Error("duplicate id "+t);const o=this.context.nodeRegister.createNode(e,t,this);if(n)for(const e in n)o[e]=n[e];return this.nodes[t]=o,o}async createNode(e,t,n){if(t||(t=(0,z.Os)()),this.nodes.hasOwnProperty(t))throw Error("duplicate id "+t);let o;if(this.context.nodeRegister.hasNode(e)){if(o=this.context.nodeRegister.createNode(e,t,this),n)for(const e in n)o[e]=n[e]}else o=await this.context.createComponentInstanceNode(e,t,this,n),this.componentInstanceChildren[t]=o;return this.nodes[t]=o,o}getNodesWithIdRecursive(e){const t=[];return function e(t,n,o){t.nodes.hasOwnProperty(n)&&o.push(t.nodes[n]),Object.keys(t.nodes).filter((e=>t.nodes[e]instanceof X)).forEach((i=>{const s=t.nodes[i].nodeScope;s&&e(s,n,o)}))}(this,e,t),t}getNodesWithType(e){return Object.keys(this.nodes).filter((t=>this.nodes[t].name===e)).map((e=>this.nodes[e]))}getNodesWithTypeRecursive(e){let t=[];return(()=>{t=t.concat(this.getNodesWithType(e)),Object.keys(this.nodes).filter((e=>this.nodes[e]instanceof X)).forEach((n=>{const o=this.nodes[n];if(o&&o.nodeScope){const n=o.nodeScope.getNodesWithTypeRecursive(e);t=t.concat(n)}}))})(),t}getAllNodesRecursive(){let e=[];return(()=>{e=e.concat(Object.values(this.nodes)),Object.keys(this.nodes).filter((e=>this.nodes[e]instanceof X)).forEach((t=>{const n=this.nodes[t];if(n&&n.nodeScope){const t=n.nodeScope.getAllNodesRecursive();e=e.concat(t)}}))})(),e}getAllNodesWithVariantRecursive(e){return this.getAllNodesRecursive().filter((t=>t.variant===e))}onNodeModelRemoved(e){const t=this.getNodeWithId(e.id);e.parent&&this.getNodeWithId(e.parent.id).removeChild(t),t._onNodeDeleted(),delete this.nodes[t.id],delete this.componentInstanceChildren[t.id]}removeConnection(e){this.getNodeWithId(e.targetId).removeInputConnection(e.targetPort,e.sourceId,e.sourcePort)}async setComponentModel(e){var t;this.componentModel=e;const n=[];for(const t of e.getAllNodes()){const e=await this.createNodeFromModel(t,!1);e&&n.push(e)}e.getAllConnections().forEach((e=>this.addConnection(e))),n.forEach((e=>e.updateOnDirtyFlagging=!0)),n.forEach((e=>{e._dirty&&e._performDirtyUpdate()})),e.on("connectionAdded",(e=>this.addConnection(e)),this),e.on("connectionRemoved",this.removeConnection,this),e.on("nodeAdded",this.createNodeFromModel,this),e.on("nodeParentWillBeRemoved",(e=>{if("Component Children"===e.type)return void(e.parent&&this.componentOwner.setChildRoot(null));const t=this.getNodeWithId(e.id);t.parent&&t.parent.removeChild(t)}),this),e.on("nodeParentUpdated",(e=>{if("Component Children"===e.type){const t=e.parent?this.getNodeWithId(e.parent.id):null;this.componentOwner.setChildRoot(t)}else{const t=this.getNodeWithId(e.id);this.insertNodeInTree(t,e)}}),this),e.on("nodeRemoved",(e=>{"Component Children"!==e.type&&this.onNodeModelRemoved(e)}),this);for(const e in this.nodes){const n=this.nodes[e];null===(t=null==n?void 0:n.nodeScopeDidInitialize)||void 0===t||t.call(n)}}reset(){this.componentModel&&(this.componentModel.removeListenersWithRef(this),this.componentModel=void 0),Object.keys(this.nodes).forEach((e=>{this.nodes.hasOwnProperty(e)&&this.deleteNode(this.nodes[e])}))}deleteNode(e){if(this.nodes.hasOwnProperty(e.id)){if(e.parent&&e.parent.removeChild(e),e.getChildren&&e.getChildren().forEach((t=>{e.removeChild(t),(t.parentNodeScope||t.nodeScope).deleteNode(t)})),this.componentModel){const t=this.componentModel.getConnectionsFrom(e.id),n=this.componentModel.getConnectionsTo(e.id);t.concat(n).forEach((e=>{this.nodes.hasOwnProperty(e.targetId)&&this.nodes.hasOwnProperty(e.sourceId)&&this.removeConnection(e)}))}e._onNodeDeleted(),delete this.nodes[e.id],delete this.componentInstanceChildren[e.id]}else console.error("Node doesn't belong to this scope",e.id,e.name)}sendEventFromThisScope(e,t,n,o){var i,s;if(o){const n=this.getNodesWithType("Event Receiver").filter((t=>t.getChannelName()===e));for(let e=0;ee.name&&this.context.hasComponentModelWithName(e.name)&&e.nodeScope!==this));for(const o of n)if(null===(s=o.nodeScope)||void 0===s?void 0:s.sendEventFromThisScope(e,t,void 0,!0))return!0}}}return!1}}let G=0;class X extends q.b{constructor(e,t,n){super(e,t),this.nodeScope=new H(e,this),this.parentNodeScope=n,this._internal={childRoot:null,componentOutputValues:{},componentOutputs:[],componentInputs:[],inputValues:{},roots:[],instanceId:"__$ndl_componentInstaceId"+G},this.nodeScope.modelScope=n?n.modelScope:void 0,G++}async setComponentModel(e){this.componentModel=e;const t=this;await this.nodeScope.setComponentModel(e),this._internal.componentInputs=this.nodeScope.getNodesWithType("Component Inputs"),this._internal.componentOutputs=this.nodeScope.getNodesWithType("Component Outputs"),Object.values(e.getInputPorts()).forEach(this.registerComponentInputPort.bind(this)),Object.values(e.getOutputPorts()).forEach(this.registerComponentOutputPort.bind(this));const n=e.roots||[];this._internal.roots=n.map((e=>this.nodeScope.getNodeWithId(e))),e.on("rootAdded",(e=>{this._internal.roots.push(this.nodeScope.getNodeWithId(e)),this.forceUpdate()}),this),e.on("rootRemoved",(function(e){const t=this._internal.roots.findIndex((t=>t.id===e));-1!==t&&this._internal.roots.splice(t,1),this.forceUpdate()}),this),e.on("inputPortAdded",this.registerComponentInputPort.bind(this),this),e.on("outputPortAdded",this.registerComponentOutputPort.bind(this),this),e.on("inputPortRemoved",(function(e){t.hasInput(e.name)&&t.deregisterInput(e.name)}),this),e.on("outputPortRemoved",(function(e){this.hasOutput(e.name)&&t.deregisterOutput(e.name)}),this),e.on("nodeAdded",(function(e){"Component Inputs"===e.type?t._internal.componentInputs.push(t.nodeScope.getNodeWithId(e.id)):"Component Outputs"===e.type&&t._internal.componentOutputs.push(t.nodeScope.getNodeWithId(e.id))}),this),e.on("nodeRemoved",(function(e){function n(e,t){return e.filter((e=>e.id!==t))}"Component Inputs"===e.type?t._internal.componentInputs=n(t._internal.componentInputs,e.id):"Component Outputs"===e.type&&(t._internal.componentOutputs=n(t._internal.componentOutputs,e.id))}),this),e.on("renamed",(function(e){t.name=e.newName}),this)}_onNodeDeleted(){this.componentModel&&(this.componentModel.removeListenersWithRef(this),this.componentModel=void 0),this.nodeScope.reset(),super._onNodeDeleted()}registerComponentInputPort(e){this.registerInput(e.name,{set:function(t){this._internal.inputValues[e.name]=t,this._internal.componentInputs.forEach((function(t){t.registerOutputIfNeeded(e.name),t.flagOutputDirty(e.name)}))}})}registerComponentOutputPort(e){this.registerOutput(e.name,{getter(){return this._internal.componentOutputValues[e.name]}})}setOutputFromComponentOutput(e,t){var n,o;!1!==this.hasOutput(e)&&(null===(o=null===(n=this._internal.creatorCallbacks)||void 0===n?void 0:n.onOutputChanged)||void 0===o||o.call(n,e,t,this._internal.componentOutputValues[e]),this._internal.componentOutputValues[e]=t,this.flagOutputDirty(e))}setChildRoot(e){const t=this._internal.childRoot,n=e;if(this._internal.childRoot=n,this.model&&this.model.children){const e=this.parentNodeScope,o=this.model.children.filter((e=>"Component Children"!==e.type)).map((t=>null==e?void 0:e.getNodeWithId(t.id)));if(t)for(let e=0;e{var t;null===(t=e.triggerDidMount)||void 0===t||t.call(e)}))}render(){return 0===this._internal.roots.length?null:this._internal.roots[0].render()}setChildIndex(e){this.getRoots().forEach((t=>{var n;return null===(n=t.setChildIndex)||void 0===n?void 0:n.call(t,e)}))}addChild(e,t){this.getChildRoot().addChild(e,t+this.getChildRootIndex())}removeChild(e){this.getChildRoot().removeChild(e)}getChildren(){const e=this.getChildRoot();return e?e.getChildren():[]}isChild(e){return!!this.getChildRoot()&&this.getChildRoot().isChild(e)}contains(e){return this.getRoots().some((t=>{var n;return null===(n=t.contains)||void 0===n?void 0:n.call(t,e)}))}_performDirtyUpdate(){super._performDirtyUpdate();const e=this._internal.componentInputs;for(let t=0,n=e.length;tthis.rootComponent?this.rootComponent.nodeScope:null}),this.editorConnection&&(this.editorConnection.on("debugInspectorsUpdated",(e=>{this.onDebugInspectorsUpdated(e)})),null===(t=this.editorConnection)||void 0===t||t.on("getConnectionValue",(({clientId:e,connectionId:t})=>{var n,o;if((null===(n=this.editorConnection)||void 0===n?void 0:n.clientId)!==e)return;const i=this._outputHistory[t];null===(o=this.editorConnection)||void 0===o||o.sendConnectionValue(t,i?i.value:void 0)})))}setRootComponent(e){this.rootComponent=e}getCurrentTime(){return this.platform.getCurrentTime()}onDebugInspectorsUpdated(e){this.debugInspectorsEnabled&&(e=e.map((e=>{if("connection"===e.type&&e.connection){const t=e.connection;e.id=t.fromId+t.fromProperty}else"node"===e.type&&e.nodeId&&(e.id=e.nodeId);return e})),this.debugInspectors={},e.forEach((e=>this.debugInspectors[e.id]=e)),this.sendDebugInspectorValues())}updateDirtyNodes(){let e,t,n=!0,o=0;for(this.updateIteration++,this.isUpdating=!0;n&&o<10;){const i=this._dirtyNodes;for(this._dirtyNodes=[],e=0,t=i.length;e0||this._dirtyNodes.length>0,o++}this.isUpdating=!1}update(){this.frameNumber++,this.updateDirtyNodes(),this.timerScheduler.hasPendingTimers()&&(this.scheduleUpdate(),this.timerScheduler.runTimers(this.currentFrameTime)),this.debugInspectorsEnabled&&this.sendDebugInspectorValues()}reset(){this.eventEmitter.emit("applicationDataReloaded");const e=this.eventEmitter;["frameStart","frameEnd"].forEach((function(t){e.removeAllListeners(t)})),this.globalValues={},this._dirtyNodes.length=0,this.callbacksAfterUpdate.length=0,this.timerScheduler.runningTimers=[],this.timerScheduler.newTimers=[],this.rootComponent=void 0,this.clearDebugInspectors()}nodeIsDirty(e){this._dirtyNodes.push(e),this.scheduleUpdate()}scheduleUpdate(){this.eventEmitter.emit("scheduleUpdate")}scheduleAfterUpdate(e){this.callbacksAfterUpdate.push(e),this.scheduleUpdate()}scheduleNextFrame(e){this.eventEmitter.once("frameStart",e),this.scheduleUpdate()}setGlobalValue(e,t){this.globalValues[e]=t,this.globalsEventEmitter.emit(e)}getGlobalValue(e){return this.globalValues[e]}registerComponentModel(e){if(this.componentModels.hasOwnProperty(e.name))throw new Error("Duplicate component name "+e.name);this.componentModels[e.name]=e,e.on("renamed",(t=>{delete this.componentModels[t.oldName],this.componentModels[t.newName]=e}),this)}deregisterComponentModel(e){this.componentModels.hasOwnProperty(e.name)&&(this.componentModels[e.name].removeListenersWithRef(this),delete this.componentModels[e.name])}async fetchComponentBundle(e){const t=async e=>{const t=`${window.Noodl.Env.BaseUrl||"/"}noodl_bundles/${e}.json`,n=await fetch(t);if(404===n.status)throw new Error("Component not found "+e);const o=await n.json();for(const e of o)!1===this.graphModel.hasComponentWithName(e.name)&&await this.graphModel.importComponentFromEditorData(e)};if(this.bundleFetchesInFlight.has(e))await this.bundleFetchesInFlight.get(e);else{const n=t(e);this.bundleFetchesInFlight.set(e,n),await n}}async getComponentModel(e){if(!e)throw new Error("Component instance must have a name");if(!1===this.componentModels.hasOwnProperty(e)){const t=this.graphModel.getBundleContainingComponent(e);if(!t)throw new Error("Can't find component model for "+e);for(const e of this.graphModel.getBundleDependencies(t))this.fetchComponentBundle(e);await this.fetchComponentBundle(t)}return this.componentModels[e]}hasComponentModelWithName(e){return this.componentModels.hasOwnProperty(e)}async createComponentInstanceNode(e,t,n,o){const i=new X(this,t,n);if(i.name=e,o)for(const e in o)i[e]=o[e];const s=await this.getComponentModel(e);return await i.setComponentModel(s),i}_formatConnectionValue(e){if("object"==typeof e&&e&&e.constructor&&"Node"===e.constructor.name)e=" "+e.name;else if("object"==typeof e&&"undefined"!=typeof window&&e instanceof HTMLElement)e=`DOM Node <${e.tagName}>`;else{if("string"==typeof e&&!e.startsWith("[Signal]"))return'"'+e+'"';if(Number.isNaN(e))return"NaN"}return e}connectionSentValue(e,t){if(!this.editorConnection||!this.editorConnection.isConnected()||!this.debugInspectorsEnabled)return;const n=this.getCurrentTime();if(this._outputHistory[e.id]={value:t,timestamp:n},this.connectionsToPulse.hasOwnProperty(e.id))return void(this.connectionsToPulse[e.id].timestamp=n);const o=[];e.connections.forEach((t=>{o.push(e.owner.id+e.name+t.node.id+t.inputPortName)})),this.connectionsToPulse[e.id]={timestamp:n,connections:o},this.connectionsToPulseChanged=!0,!1===this.connectionPulsingCallbackScheduled&&(this.connectionPulsingCallbackScheduled=!0,setTimeout(this.clearOldConnectionPulsing.bind(this),100))}connectionSentSignal(e){const t=e.id;this._signalHistory.hasOwnProperty(t)||(this._signalHistory[t]={count:0}),this._signalHistory[t].count++,this.connectionSentValue(e,"[Signal] Trigger count "+this._signalHistory[t].count)}clearDebugInspectors(){var e;this.debugInspectors={},this.connectionsToPulse={},null===(e=this.editorConnection)||void 0===e||e.sendPulsingConnections(this.connectionsToPulse)}clearOldConnectionPulsing(){var e;this.connectionPulsingCallbackScheduled=!1;const t=this.getCurrentTime();Object.keys(this.connectionsToPulse).forEach((e=>{const n=this.connectionsToPulse[e];t-n.timestamp>100&&(this.connectionsToPulseChanged=!0,delete this.connectionsToPulse[e])})),this.connectionsToPulseChanged&&(this.connectionsToPulseChanged=!1,null===(e=this.editorConnection)||void 0===e||e.sendPulsingConnections(this.connectionsToPulse)),Object.keys(this.connectionsToPulse).length>0&&(this.connectionPulsingCallbackScheduled=!0,setTimeout(this.clearOldConnectionPulsing.bind(this),500))}_getDebugInspectorValueForNode(e){if(!this.rootComponent)return;const t=this.rootComponent.nodeScope.getNodesWithIdRecursive(e),n=t[t.length-1];if(n&&n.getInspectInfo){const t=n.getInspectInfo();if(void 0!==t)return{type:"node",id:e,value:t}}}sendDebugInspectorValues(){var e,t;const n=[];for(const e in this.debugInspectors){const t=this.debugInspectors[e];if("connection"===t.type&&this._outputHistory.hasOwnProperty(e)){const t=this._outputHistory[e].value;n.push({type:"connection",id:e,value:this._formatConnectionValue(t)})}else if("node"===t.type){const t=this._getDebugInspectorValueForNode(e);t&&n.push(t)}}n.length>0&&(null===(e=this.editorConnection)||void 0===e||e.sendDebugInspectorValues(n)),this.connectionsToPulseChanged&&(this.connectionsToPulseChanged=!1,null===(t=this.editorConnection)||void 0===t||t.sendPulsingConnections(this.connectionsToPulse))}setDebugInspectorsEnabled(e){this.debugInspectorsEnabled=e,this.editorConnection,e&&this.sendDebugInspectorValues()}sendGlobalEventFromEventSender(e,t){this.eventSenderEmitter.emit(e,t)}setPopupCallbacks(e){this.onShowPopup=e.onShow,this.onClosePopup=e.onClose}async showPopup(e,t,n){if(!this.onShowPopup)return;const o=this.rootComponent.nodeScope,i=await o.createNode(e);for(const e in t)i.setInputValue(e,t[e]);i.popupParent=(null==n?void 0:n.senderNode)||null;const s=o.createPrimitiveNode("Group");s.setInputValue("flexDirection","node"),s.setInputValue("cssClassName","noodl-popup");const r=this.graphModel.getSettings().bodyScroll;s.setInputValue("position",r?"fixed":"absolute");const a=i.nodeScope.getNodesWithType("NavigationClosePopup");if(a&&a.length>0)for(let e=0;e{this.scheduleNextFrame((()=>{var i,r;o.hasNodeWithId(s.id)&&(null===(i=this.onClosePopup)||void 0===i||i.call(this,s),o.deleteNode(s),null===(r=null==n?void 0:n.onClosePopup)||void 0===r||r.call(n,e,t||{}))}))}));this.onShowPopup(s),requestAnimationFrame((()=>{s.addChild(i)}))}setWarningTypes(e){Object.assign(this.warningTypes,e)}isWarningTypeEnabled(e){return!this.warningTypes.hasOwnProperty(e)||!!this.warningTypes[e]}getDefaultValueForInput(e,t){var n;if(!1===this.nodeRegister.hasNode(e))return;const o=null===(n=this.nodeRegister.getNodeMetadata(e).inputs)||void 0===n?void 0:n[t];return o?o.type.defaultUnit?{value:o.default,unit:o.type.defaultUnit}:o.default:void 0}}class J{constructor(){this.listeners={},this.listenersWithRefs={}}on(e,t,n){n?(this.listenersWithRefs.hasOwnProperty(e)||(this.listenersWithRefs[e]=new Map),this.listenersWithRefs[e].get(n)||this.listenersWithRefs[e].set(n,[]),this.listenersWithRefs[e].get(n).push(t)):(this.listeners.hasOwnProperty(e)||(this.listeners[e]=[]),this.listeners[e].push(t))}removeListenersWithRef(e){Object.keys(this.listenersWithRefs).forEach((t=>{const n=this.listenersWithRefs[t];n.has(e)&&n.delete(e)}))}removeAllListeners(e){e?(delete this.listeners[e],delete this.listenersWithRefs[e]):(this.listeners={},this.listenersWithRefs={})}async emit(e,t){const n=this.listeners[e];if(n){const e=[...n];for(const n of e)await Promise.resolve(n(t))}const o=this.listenersWithRefs[e];if(o)for(const[e,n]of o)for(const o of n)await Promise.resolve(o.call(e,t))}}class K{constructor(){this.currentWarnings=new Map}setWarning(e,t,n){if(this.currentWarnings.has(e)){const o=this.currentWarnings.get(e);return!(o&&o[t]===n||(o&&(o[t]=n),0))}return this.currentWarnings.set(e,{[t]:n}),!0}clearWarning(e,t){const n=this.currentWarnings.get(e);return!(!n||!n[t]||(delete n[t],0===Object.keys(n).length&&this.currentWarnings.delete(e),0))}clearWarnings(e){return!1!==this.currentWarnings.has(e)&&(this.currentWarnings.delete(e),!0)}}class Q extends J{constructor(e={}){var t,n;super(),this.clientId="",this.dynamicPortsHash={},this.serviceRequests={},this.runtimeType=e.runtimeType,this.platform=e.platform||{getCurrentTime:()=>Date.now()},this.ws=(null===(t=e.platform)||void 0===t?void 0:t.webSocketClass)||("undefined"!=typeof WebSocket?WebSocket:void 0),this.wsOptions=null===(n=e.platform)||void 0===n?void 0:n.webSocketOptions,this.reconnectOnClose=!0,this.enableDebugger=!1,this.lastSendTimestamp=0,this.sendQueue=[],this.sendTimer=void 0,this.activeWarnings=new K}isRunningLocally(){return this.platform.isRunningLocally&&this.platform.isRunningLocally()||"undefined"!=typeof document&&("localhost"===document.location.hostname||"127.0.0.1"===document.location.hostname)}connect(e){this.socket=this.wsOptions?new this.ws(e,this.wsOptions):new this.ws(e),this.socket.addEventListener("open",(()=>{var e;this.clientId=(0,z.Os)(),null===(e=this.socket)||void 0===e||e.send(JSON.stringify({cmd:"register",type:"viewer",clientId:this.clientId})),this.emit("connected")})),this.socket.addEventListener("close",(t=>{this.reconnectOnClose&&this.reconnect(e),console.log("Editor connection closed",t.code,t.reason),this.emit("connectionClosed")})),this.socket.addEventListener("error",(()=>{console.log("Editor connection error, trying to reconnect")})),this.socket.addEventListener("message",(async e=>{const t="string"==typeof e.data?e.data:await e.data.text(),n=JSON.parse(t);let o;"registered"===n.cmd||("export"===n.cmd?(o=JSON.parse(n.content),"full"===n.type&&n.target===this.clientId&&this.emit("exportDataFull",o)):"hoverStart"===n.cmd?this.emit("hoverStart",n.content.id):"hoverEnd"===n.cmd?this.emit("hoverEnd",n.content.id):"refresh"===n.cmd?this.emit("reload"):"debugInspectors"===n.cmd?this.debugInspectorsEnabled&&(o=JSON.parse(n.content),this.emit("debugInspectorsUpdated",o.inspectors)):"debuggingEnabled"===n.cmd?this.isRunningLocally()&&(o=JSON.parse(n.content),this.emit("debuggingEnabledChanged",o.enabled)):"getConnectionValue"===n.cmd?this.isRunningLocally()&&(o=JSON.parse(n.content),await this.emit("getConnectionValue",{clientId:o.clientId,connectionId:o.connectionId})):"modelUpdate"===n.cmd?await this.emit("modelUpdate",n.content):"publish"===n.cmd||("noodlModules"===n.cmd?this.emit("noodlModules",JSON.parse(n.content)):"mqttUpdate"===n.cmd?this.emit("mqttUpdate",n.content):"activeComponentChanged"===n.cmd?this.emit("activeComponentChanged",n.component):console.log("Command not implemented",n)))}))}reconnect(e){setTimeout((()=>{this.connect(e)}),2e3)}isConnected(){return void 0!==this.socket&&this.socket.readyState===this.ws.OPEN}getCircularReplacer(){const e=new WeakSet;return(t,n)=>{if("object"==typeof n&&null!==n){if(e.has(n))return"[Circular]";e.add(n)}return n}}send(e){const t=this.platform.getCurrentTime(),n=t-this.lastSendTimestamp,o=e=>{var t,n;try{null===(t=this.socket)||void 0===t||t.send(JSON.stringify(e))}catch(t){if(t.message&&t.message.startsWith("Converting circular"))try{null===(n=this.socket)||void 0===n||n.send(JSON.stringify(e,this.getCircularReplacer()))}catch(t){console.log("failed to send message to editor",e,t)}else console.log("failed to send message to editor",e,t)}};n<200||this.sendTimer||!this.isConnected()?(this.sendQueue.push(e),this.sendTimer||(this.sendTimer=setTimeout((()=>{if(!1!==this.isConnected()){for(let e=0;e{const o=e[n];t.push(...o.connections)})),this.send({cmd:"connectiondebugpulse",type:"viewer",content:JSON.stringify({connectionsToPulse:t})})}sendDebugInspectorValues(e){this.send({cmd:"debuginspectorvalues",type:"viewer",content:{inspectors:e}})}sendConnectionValue(e,t){this.send({cmd:"connectionValue",type:"viewer",content:{connectionId:e,value:t}})}_detectRename(e,t){if(!e||!t)return;if(e.length!==t.length)return;const n={};for(let o=0;o{let o=JSON.parse(this.dynamicPortsHash[e]),s=[...t];n.prefix&&(o=o.filter((e=>e.name.startsWith(n.prefix))),s=s.filter((e=>e.name.startsWith(n.prefix)))),n.plug&&(o=o.filter((e=>e.plug===n.plug)),s=s.filter((e=>e.plug===n.plug))),s=s.map((e=>e.name.substring((n.prefix||"").length))),o=o.map((e=>e.name.substring((n.prefix||"").length)));const r=this._detectRename(o,s);r&&i.push({plug:n.plug,patterns:[(n.prefix||"")+"{{*}}"],before:r.before,after:r.after})})),i.length>0&&(n.renamed=i),delete n.detectRenamed}this.dynamicPortsHash[e]=o,this.send({cmd:"instanceports",type:"viewer",content:JSON.stringify({nodeid:e,ports:t,options:n})})}}sendWarning(e,t,n,o){this.activeWarnings.setWarning(t,n,o)&&this.send({cmd:"showwarning",type:"viewer",content:JSON.stringify({componentName:e,nodeId:t,key:n,warning:o})})}clearWarning(e,t,n){this.activeWarnings.clearWarning(t,n)&&this.send({cmd:"showwarning",type:"viewer",content:JSON.stringify({componentName:e,nodeId:t,key:n,warning:void 0})})}clearWarnings(e,t){this.activeWarnings.clearWarnings(t)&&this.send({cmd:"clearwarnings",type:"viewer",content:JSON.stringify({componentName:e,nodeId:t})})}sendPatches(e){this.send({cmd:"patchproject",type:"viewer",content:JSON.stringify(e)})}requestFullExport(){this.send({cmd:"register",type:"viewer"})}requestNoodlModules(){this.send({cmd:"getNoodlModules",type:"viewer"})}sendServiceRequest(e,t){e.token=(0,z.Os)(),e.clientId=this.clientId,this.serviceRequests[e.token]=t,this.send(e)}close(){var e;this.reconnectOnClose=!1,!1!==this.isConnected()&&(null===(e=this.socket)||void 0===e||e.close())}sendNodeLibrary(e){this.send({cmd:"nodelibrary",type:"viewer",runtimeType:this.runtimeType,content:e,clientId:this.clientId})}sendComponentMetadata(e,t,n){this.send({cmd:"componentMetadata",type:"viewer",content:JSON.stringify({componentName:e,key:t,data:n})})}sendProjectMetadata(e,t){this.send({cmd:"projectMetadata",type:"viewer",content:JSON.stringify({key:e,data:t})})}}function Z(e,t,n){const o={name:e,type:t.type,plug:n};return t.group&&(o.group=t.group),t.displayName&&(o.displayName=t.displayName),t.description&&(o.description=t.description),t.editorName&&(o.editorName=t.editorName),void 0!==t.default&&(o.default=t.default),t.hasOwnProperty("index")&&(o.index=t.index),t.tooltip&&(o.tooltip=t.tooltip),t.tab&&(o.tab=t.tab),t.popout&&(o.popout=t.popout),t.allowVisualStates&&(o.allowVisualStates=t.allowVisualStates),o}class ee extends J{constructor(e,t){super(),this.id=e,this.type=t,this.inputs=[],this.outputs=[],this.children=[],this.parameters={},this.inputPorts={},this.outputPorts={}}setParameter(e,t,n){n?(this.stateParameters||(this.stateParameters={}),this.stateParameters[n]||(this.stateParameters[n]={}),void 0===t?delete this.stateParameters[n][e]:this.stateParameters[n][e]=t):void 0===t?delete this.parameters[e]:this.parameters[e]=t,this.emit("parameterUpdated",{name:e,value:t,state:n})}setParameters(e){Object.keys(e).forEach((t=>{this.setParameter(t,e[t])}))}setStateParameters(e){this.stateParameters=e}setStateTransitions(e){this.stateTransitions=e}setStateTransitionParamter(e,t,n){this.stateTransitions||(this.stateTransitions={}),t?this.stateTransitions[n][e]=t:delete this.stateTransitions[n][e]}setDefaultStateTransition(e,t){this.defaultStateTransitions||(this.defaultStateTransitions={}),this.defaultStateTransitions[t]=e}addInputPort(e){this.inputPorts[e.name]=e,this.emit("inputPortAdded",e)}getInputPort(e){return this.inputPorts[e]}getInputPorts(){return this.inputPorts}removeInputPortWithName(e){if(this.inputPorts.hasOwnProperty(e)){const t=this.inputPorts[e];delete this.inputPorts[e],this.emit("inputPortRemoved",t)}}updateInputPortTypes(e){let t=!1;for(const n in e)void 0!==this.inputPorts[n]&&(this.inputPorts[n].type=e[n].type,t=!0);t&&this.emit("inputPortTypesUpdated")}addOutputPort(e){this.outputPorts[e.name]=e,this.emit("outputPortAdded",e)}getOutputPort(e){return this.outputPorts[e]}getOutputPorts(){return this.outputPorts}removeOutputPortWithName(e){if(this.outputPorts.hasOwnProperty(e)){const t=this.outputPorts[e];delete this.outputPorts[e],this.emit("outputPortRemoved",t)}}updateOutputPortTypes(e){let t=!1;for(const n in e)void 0!==this.outputPorts[n]&&(this.outputPorts[n].type=e[n].type,t=!0);t&&this.emit("outputPortTypesUpdated")}addChild(e,t){e.parent=this,void 0===t?this.children.push(e):this.children.splice(t,0,e),this.emit("childAdded",e)}removeChild(e){e.parent=void 0;const t=this.children.indexOf(e);this.children.splice(t,1),this.emit("childRemoved",e)}reset(){this.removeAllListeners()}setVariant(e){this.variant=e,this.emit("variantUpdated",e)}static createFromExportData(e){const t=new ee(e.id,e.type);if(e.parameters&&t.setParameters(e.parameters),e.stateParameters&&t.setStateParameters(e.stateParameters),e.stateTransitions&&t.setStateTransitions(e.stateTransitions),e.defaultStateTransitions)for(const n in e.defaultStateTransitions)t.setDefaultStateTransition(e.defaultStateTransitions[n],n);return e.ports&&e.ports.forEach((e=>{"input"!==e.plug&&"input/output"!==e.plug||t.addInputPort(e),"output"!==e.plug&&"input/output"!==e.plug||t.addOutputPort(e)})),e.variant&&t.setVariant(e.variant),t}}class te extends J{constructor(e){super(),this.name=e,this.nodes={},this.connections=[],this.roots=[],this.inputPorts={},this.outputPorts={},this.metadata={}}async addNode(e){e.component=this,this.nodes[e.id]=e,await this.emit("nodeAdded",e)}hasNodeWithId(e){return void 0!==this.getNodeWithId(e)}getNodeWithId(e){if(e)return this.nodes[e]}getAllNodes(){return Object.values(this.nodes)}getNodesWithType(e){const t=[];return Object.keys(this.nodes).forEach((n=>{const o=this.nodes[n];o.type===e&&t.push(o)})),t}addConnection(e){if(this.connections.push(e),this.emit("connectionAdded",e),e.targetId){const t=this.getNodeWithId(e.targetId);t&&t.emit("inputConnectionAdded",e)}}removeConnection(e){const t=this.connections.findIndex((t=>t.sourceId===e.sourceId&&t.sourcePort===e.sourcePort&&t.targetId===e.targetId&&t.targetPort===e.targetPort));if(-1!==t&&(this.connections.splice(t,1),this.emit("connectionRemoved",e),e.targetId)){const t=this.getNodeWithId(e.targetId);t&&t.emit("inputConnectionRemoved",e)}}getConnectionsFromPort(e,t){return this.connections.filter((n=>n.sourceId===e&&n.sourcePort===t))}getConnectionsToPort(e,t){return this.connections.filter((n=>n.targetId===e&&n.targetPort===t))}getConnectionsFrom(e){return this.connections.filter((t=>t.sourceId===e))}getConnectionsTo(e){return this.connections.filter((t=>t.targetId===e))}addRootId(e){e&&-1===this.roots.indexOf(e)&&(this.roots.push(e),this.emit("rootAdded",e))}removeRootId(e){const t=this.roots.indexOf(e);-1!==t&&(this.roots.splice(t,1),this.emit("rootRemoved",e))}getRoots(){return this.roots}async removeNodeWithId(e){const t=this.getNodeWithId(e);if(!t)return console.warn("ERROR: Attempted to remove non-existing node with ID:",e),!1;for(;t.children.length>0;){const e=t.children[0];await this.removeNodeWithId(e.id)||t.children.shift()}const n=this.getConnectionsTo(e).concat(this.getConnectionsFrom(e));for(let e=0;e{e.targetPort=n})),o.forEach(this.addConnection.bind(this))}renameOutputPortOnNodeWithId(e,t,n){const o=this.getConnectionsFromPort(e,t);o.forEach(this.removeConnection.bind(this));const i=this.getNodeWithId(e);if(!i)return;const s={...i.getOutputPort(t)};i.removeOutputPortWithName(t),s.name=n,i.addOutputPort(s),o.forEach((e=>{e.sourcePort=n})),o.forEach(this.addConnection.bind(this))}setNodeParent(e,t,n){e&&(-1!==this.roots.indexOf(e.id)&&this.removeRootId(e.id),e.parent&&(this.emit("nodeParentWillBeRemoved",e),e.parent.removeChild(e)),e.emit("parentUpdated",t),t&&(t.addChild(e,n),this.emit("nodeParentUpdated",e)))}async importEditorNodeData(e,t,n){const o=ee.createFromExportData(e);if(await this.addNode(o),t&&this.setNodeParent(o,this.getNodeWithId(t),n),e.children)for(let t=0;t0)throw new Error("Not all nodes were removed during a reset");if(this.connections.length>0)throw new Error("Not all connections were removed during a reset")}rename(e){const t=this.name;this.name=e,this.emit("renamed",{oldName:t,newName:e})}setMetadata(e,t){this.metadata[e]=t}getMetadata(e){return e?this.metadata[e]:this.metadata}static async createFromExportData(e){const t=new te(e.name);if(e.metadata)for(const n in e.metadata)t.setMetadata(n,e.metadata[n]);if(e.ports&&e.ports.forEach((e=>{"input"!==e.plug&&"input/output"!==e.plug||t.addInputPort(e),"output"!==e.plug&&"input/output"!==e.plug||t.addOutputPort(e)})),e.nodes)for(const n of e.nodes)await t.importEditorNodeData(n);return e.connections&&e.connections.forEach((e=>t.addConnection(e))),e.roots&&e.roots.forEach((e=>t.addRootId(e))),t}}class ne extends J{constructor(){super(),this.componentToBundleMap=new Map,this.variants=[],this.components={},this.settings={},this.metadata={}}async importComponentFromEditorData(e){const t=await te.createFromExportData(e);this.addComponent(t)}getBundleContainingComponent(e){return this.componentToBundleMap.get(e)}getBundlesContainingSheet(e){const t=new Set;for(const n of this.componentToBundleMap.keys()){const o=0!==n.indexOf("/#");(o&&"Default"===e||!o&&0===n.indexOf("/#"+e))&&t.add(this.componentToBundleMap.get(n))}return Array.from(t)}getBundleDependencies(e){const t=new Set,n=e=>{var o;const i=null===(o=this.componentIndex)||void 0===o?void 0:o[e];if(i)for(const e of i.dependencies)t.has(e)||(t.add(e),n(e))};return n(e),Array.from(t)}async importEditorData(e){this.componentIndex=e.componentIndex,this.routerIndex=e.routerIndex,this.componentToBundleMap=new Map;for(const t in e.componentIndex){const n=e.componentIndex[t];for(const e of n.components)this.componentToBundleMap.set(e,t)}this.variants=e.variants||[],e.settings&&this.setSettings(e.settings),e.metadata&&this.setAllMetaData(e.metadata);for(const t of e.components)await this.importComponentFromEditorData(t);this.setRootComponentName(e.rootComponent)}setRootComponentName(e){this.rootComponent=e,this.emit("rootComponentNameUpdated",e)}getNodesWithType(e){let t=[];const n=Object.keys(this.components);for(let o=0;othis.components[e]))}getAllNodes(){let e=[];const t=Object.keys(this.components);for(let n=0;n{e.addInputPort(n[t])})),Object.keys(o).forEach((t=>{e.addOutputPort(o[t])}))}}_onNodeAdded(e){this._addComponentPorts(e),this.emit("nodeAdded",e),this.emit("nodeAdded."+e.type,e)}_onNodeRemoved(e){this.emit("nodeRemoved",e),this.emit("nodeRemoved."+e.type,e)}_onNodeWasRemoved(e){this.emit("nodeWasRemoved",e),this.emit("nodeWasRemoved."+e.type,e)}async reset(){for(const e of Object.keys(this.components))await this.removeComponentWithName(e);this.setSettings({})}isEmpty(){return 0===Object.keys(this.components).length}setSettings(e){this.settings=e,this.emit("projectSettingsChanged",e)}getSettings(){return this.settings}setAllMetaData(e){for(const t in e)this.setMetaData(t,e[t])}setMetaData(e,t){this.metadata[e]&&JSON.stringify(this.metadata[e])===JSON.stringify(t)||(this.metadata[e]=t,this.emit("metadataChanged",{key:e,data:t}),this.emit("metadataChanged."+e,t))}getMetaData(e){return e?this.metadata[e]:this.metadata}getVariants(){return this.variants||[]}getVariant(e,t){return this.variants.find((n=>n.name===t&&n.typename===e))}updateVariant(e){const t=this.variants.findIndex((t=>t.name===e.name&&t.typename===e.typename));-1!==t&&this.variants.splice(t,1),this.variants.push(e),this.emit("variantUpdated",e)}updateVariantParameter(e,t,n,o,i){const s=this.getVariant(t,e);s?(i?(s.stateParameters.hasOwnProperty(i)||(s.stateParameters[i]={}),void 0===o?delete s.stateParameters[i][n]:s.stateParameters[i][n]=o):void 0===o?delete s.parameters[n]:s.parameters[n]=o,this.emit("variantUpdated",s)):console.log("updateVariantParameter: can't find variant",e,t)}updateVariantDefaultStateTransition(e,t,n,o){const i=this.getVariant(t,e);i&&(i.defaultStateTransitions[o]=n,this.emit("variantUpdated",i))}updateVariantStateTransition(e){const{variantTypeName:t,variantName:n,state:o,parameterName:i,curve:s}=e,r=this.getVariant(t,n);r&&(r.stateTransitions[o]||(r.stateTransitions[o]={}),r.stateTransitions[o][i]=s)}deleteVariant(e,t){const n=this.variants.findIndex((n=>n.name===t&&n.typename===e));-1!==n&&this.variants.splice(n,1)}}function oe(e,t){const n=new Set(t);return e.filter((e=>!n.has(e)))}async function ie(e,t,n){function o(t,n){const o={},s={};n.forEach((e=>{"input"!==e.plug&&"input/output"!==e.plug||(o[e.name]=e),"output"!==e.plug&&"input/output"!==e.plug||(s[e.name]=e)}));const r=Object.keys(t.getInputPorts()),a=oe(r,Object.keys(o)),l=oe(Object.keys(o),r);t.updateInputPortTypes(o),a.forEach(t.removeInputPortWithName.bind(t)),l.forEach((n=>{var s;t.addInputPort(o[n]),t instanceof ee&&(null===(s=t.parameters)||void 0===s?void 0:s.hasOwnProperty(n))&&i(e.rootComponent.nodeScope,t,n,t.parameters[n])})),t.updateOutputPortTypes(s);const d=Object.keys(t.getOutputPorts()),u=oe(d,Object.keys(s)),c=oe(Object.keys(s),d);u.forEach(t.removeOutputPortWithName.bind(t)),c.forEach((e=>{t.addOutputPort(s[e])}))}function i(e,t,n,o){e.getNodesWithIdRecursive(t.id).forEach((e=>{e.queueInput(n,o)}))}let s;if(n.componentName&&(s=t.getComponentWithName(n.componentName),!s))return;if(!s)throw new Error("Component model not found");const r={nodeAdded:e=>{null==s||s.importEditorNodeData(e.model,e.parentId,e.childIndex)},nodeRemoved:async e=>{(null==s?void 0:s.hasNodeWithId(e.model.id))&&await s.removeNodeWithId(e.model.id)},connectionAdded:e=>{null==s||s.addConnection(e.model)},connectionRemoved:t=>{if(!s)return;s.removeConnection(t.model);const n=s.getNodeWithId(t.model.targetId);if(0===s.getConnectionsToPort(n.id,t.model.targetId).length){let o=n.parameters[t.model.targetPort];void 0===o&&(o=e.getDefaultValueForInput(n.type,t.model.targetPort)),i(e.rootComponent.nodeScope,n,t.model.targetPort,o)}},parameterChanged:e=>{if(!s)return;const t=s.getNodeWithId(e.nodeId);if(void 0!==t){if(e.parameters){const n=new Set([...Object.keys(e.parameters),...Object.keys(e.oldParameters)]);for(const o of n)t.setParameter(o,e.parameters[o])}e.parameterName&&t.setParameter(e.parameterName,e.parameterValue,e.state)}else console.log("parameterChanged: Unknown node id",e)},nodeAttached:e=>{s&&s.setNodeParent(s.getNodeWithId(e.nodeId),s.getNodeWithId(e.parentId),e.childIndex)},nodeDetached:e=>{s&&(s.setNodeParent(s.getNodeWithId(e.nodeId),null),s.addRootId(e.nodeId))},componentAdded:e=>{t.importComponentFromEditorData(e.model)},componentRemoved:async e=>{await t.removeComponentWithName(e.componentName)},rootAdded:e=>{null==s||s.addRootId(e.nodeId)},portAdded:t=>{if(!s)return;const n=s.getNodeWithId(t.nodeId);t.port&&n&&("input"!==t.port.plug&&"input/output"!==t.port.plug||(n.addInputPort(t.port),n.parameters.hasOwnProperty(t.port.name)&&i(e.rootComponent.nodeScope,n,t.port.name,n.parameters[t.port.name])),"output"!==t.port.plug&&"input/output"!==t.port.plug||n.addOutputPort(t.port))},portRemoved:e=>{if(!s)return;const t=s.getNodeWithId(e.nodeId);e.port&&t&&("input"!==e.port.plug&&"input/output"!==e.port.plug||t.removeInputPortWithName(e.port.name),"output"!==e.port.plug&&"input/output"!==e.port.plug||t.removeOutputPortWithName(e.port.name))},nodePortRenamed:e=>{if(!e.port||!s)return;"input"!==e.port.plug&&"input/output"!==e.port.plug||e.nodeId&&e.oldName&&s.renameInputPortOnNodeWithId(e.nodeId,e.oldName,e.port.name),e.nodeId&&e.oldName&&("output"===e.port.plug||"input/output"===e.port.plug)&&s.renameOutputPortOnNodeWithId(e.nodeId,e.oldName,e.port.name);const n=s.getNodeWithId(e.nodeId);"Component Inputs"===(null==n?void 0:n.type)?(s.addInputPort(e.port),t.getNodesWithType(s.name).forEach((t=>{var n;t.component.renameInputPortOnNodeWithId(t.id,e.oldName,null===(n=e.port)||void 0===n?void 0:n.name)})),s.removeInputPortWithName(e.oldName)):"Component Outputs"===(null==n?void 0:n.type)&&(s.addOutputPort(e.port),t.getNodesWithType(s.name).forEach((t=>{var n;t.component.renameOutputPortOnNodeWithId(t.id,e.oldName,null===(n=e.port)||void 0===n?void 0:n.name)})),s.removeOutputPortWithName(e.oldName))},componentPortsUpdated:e=>{s&&o(s,e.ports)},instancePortsChanged:e=>{if(!s.hasNodeWithId(e.nodeId))return;const t=s.getNodeWithId(e.nodeId);t&&o(t,e.ports)},componentRenamed:e=>{t.renameComponent(e.oldName,e.newName)},settingsChanged:e=>{t.setSettings(e.settings)},metadataChanged:e=>{t.setMetaData(e.key,e.data)},componentMetadataChanged:e=>{const n=t.getComponentWithName(e.componentName);n&&n.setMetadata(e.key,e.data)},variantParametersChanged:n=>{if(n.variant)t.updateVariant(n.variant);else if(t.updateVariantParameter(n.variantName,n.variantTypeName,n.parameterName,n.parameterValue,n.state),void 0===n.parameterValue){const o=t.getVariant(n.variantTypeName,n.variantName);e.rootComponent.nodeScope.getAllNodesWithVariantRecursive(o).forEach((e=>{e.queueInput(n.parameterName,e.getParameter(n.parameterName))}))}},variantDeleted:e=>{t.deleteVariant(e.variantTypeName,e.variantName)},variantChanged:e=>{const n=s.getNodeWithId(e.nodeId);if(n){const o=t.getVariant(n.type,e.variantName);n.setVariant(o)}},variantRenamed:e=>{const n=t.getVariant(e.variantTypeName,e.oldVariantName);(null==n?void 0:n.variantName)&&(n.name=n.variantName)},defaultStateTransitionChanged:e=>{const t=s.getNodeWithId(e.nodeId);null==t||t.setDefaultStateTransition(e.curve,e.state)},stateTransitionsChanged:e=>{const t=s.getNodeWithId(e.nodeId);t&&e.parameterName&&t.setStateTransitionParamter(e.parameterName,e.curve,e.state)},variantDefaultStateTransitionChanged:e=>{t.updateVariantDefaultStateTransition(e.variantName,e.variantTypeName,e.curve,e.state)},variantStateTransitionsChanged:e=>{t.updateVariantStateTransition(e)},routerIndexChanged:e=>{t.routerIndex=e.data}};r.hasOwnProperty(n.type)?(await r[n.type](n),e.scheduleUpdate()):console.log("Unknown event",n)}class se{}se.events=new U.b;var re=n(1142);function ae(e,t,n){const o=e.registerInputIfNeeded;e.registerInputIfNeeded=function(i){if(o&&o.call(e,i),e.hasInput(i)||!i.startsWith(t))return;const s=Number(i.slice(t.length+1));e.registerInput(i,{type:n.type,set:n.createSetter.call(e,s)})}}function le(e){if(!e.category)throw new Error("Node must have a category");if(!e.name)throw new Error("Node must have a name");const t={inputs:{},outputs:{},category:e.category,dynamicports:e.dynamicports,exportDynamicPorts:e.exportDynamicPorts,useVariants:e.useVariants,allowChildren:e.allowChildren,allowChildrenWithCategory:e.allowChildrenWithCategory,singleton:e.singleton,connectionPanel:e.connectionPanel,allowAsChild:e.allowAsChild,visualStates:e.visualStates,panels:e.panels,color:e.color,usePortAsLabel:e.usePortAsLabel,portLabelTruncationMode:e.portLabelTruncationMode,name:e.name,displayNodeName:e.displayNodeName||e.displayName,deprecated:e.deprecated,haveComponentPorts:e.haveComponentPorts,version:e.version,module:e.module,docs:e.docs,allowAsExportRoot:e.allowAsExportRoot,nodeDoubleClickAction:e.nodeDoubleClickAction,searchTags:e.searchTags};e._internal=e._internal||{},e.prototypeExtensions=e.methods||e.prototypeExtensions||{},e.inputs=e.inputs||{},e.outputs=e.outputs||{},e.initialize=e.initialize||function(){};const n={};(function(e,t,n){Object.keys(n).forEach((function(o){!function(e,t,n,o){if(e.hasOwnProperty(n))throw new Error("Input property "+n+" already registered");o.set||o.valueChangedToTrue||(o.set=()=>{}),o.set&&(e[n]={set:o.set},["color","textStyle","array"].forEach((t=>{!o.type||o.type!==t&&o.type.name!==t||(e[n].type=t)}))),o.setUnitType&&(e[n].setUnitType=o.setUnitType),t.inputs=t.inputs||{},t.inputs[n]={displayName:o.displayName,editorName:o.editorName,group:o.group,type:o.type,default:o.default,index:o.index,exportToEditor:!o.hasOwnProperty("exportToEditor")||o.exportToEditor,inputPriority:o.inputPriority||0,tooltip:o.tooltip,tab:o.tab,popout:o.popout,allowVisualStates:o.allowVisualStates,nodeDoubleClickAction:o.nodeDoubleClickAction},o.valueChangedToTrue&&(t.inputs[n].type={name:"signal",allowConnectionsOnly:!0})}(e,t,o,n[o])}))})(n,t,e.inputs),function(e,t){Object.keys(t).forEach((function(n){const o=t[n];e.outputs=e.outputs||{},e.outputs[n]={displayName:o.displayName,editorName:o.editorName,group:o.group,type:o.type,index:o.index,exportToEditor:!o.hasOwnProperty("exportToEditor")||o.exportToEditor}}))}(t,e.outputs);class o extends q.b{constructor(e,t){super(e,t)}}e.prototypeExtensions&&Object.keys(e.prototypeExtensions).forEach((function(t){e.prototypeExtensions[t].value||(e.prototypeExtensions[t]={value:e.prototypeExtensions[t]})})),Object.defineProperties(o.prototype,e.prototypeExtensions),Object.defineProperty(o.prototype,"name",{value:e.name}),e.getInspectInfo&&(o.prototype.getInspectInfo=e.getInspectInfo),e.nodeScopeDidInitialize&&(o.prototype.nodeScopeDidInitialize=e.nodeScopeDidInitialize);const i=function(s,r,a){var l;const d=new o(s,r);if(d._inputs=Object.create(n),e.inputs)return Object.keys(e.inputs).forEach((function(t){const n=e.inputs[t];n.valueChangedToTrue&&(d._inputs[t]={set:(0,re.i)({valueChangedToTrue:n.valueChangedToTrue})})})),e.outputs?(Object.keys(e.outputs).forEach((function(t){const n=e.outputs[t];"signal"===n.type?d.registerOutput(t,{getter(){}}):d.registerOutput(t,n)})),e.numberedInputs&&function(e,t){for(const n of Object.keys(t))ae(e,n,t[n])}(d,e.numberedInputs),d.nodeScope=a,u=d._inputValues,c=t.inputs||{},Object.keys(c).forEach((e=>{const t=c[e].default;void 0!==t&&(c[e].type.defaultUnit?u[e]={unit:c[e].type.defaultUnit,value:t}:u[e]=t)})),null===(l=e.initialize)||void 0===l||l.call(d),d):(Object.assign(i,{metadata:t}),e.numberedInputs&&function(e,t,n){const o=Object.keys(n);o.length&&(e.setupNumberedInputDynamicPorts=function(e,i){const s=e.editorConnection;function r(e){const t=o.map((t=>function(e,t,n){const o=e.component.getConnectionsTo(e.id).map((e=>e.targetPort)),i=Object.keys(e.parameters).concat(o).filter((e=>e.startsWith(t+" "))),s=(i.length?1+Math.max(...i.map((e=>Number(e.slice(t.length+1))))):0)+1,r=[];for(let e=0;e{r(e),e.on("parameterUpdated",(()=>{r(e)})),e.on("inputConnectionAdded",(()=>{r(e)})),e.on("inputConnectionRemoved",(()=>{r(e)}))}))})}(i,e.name,e.numberedInputs),i);var u,c};return i.metadata=t,i}const de={name:"Component Inputs",shortDesc:"This node is used to define the inputs of a component.",docs:"https://docs.noodl.net/nodes/component-utilities/component-inputs",panels:[{name:"PortEditor",context:["select","connectFrom"],title:"Inputs",plug:"output",type:{name:"*"},canArrangeInGroups:!0},{name:"PropertyEditor",hidden:!0}],getInspectInfo(){var e;return{type:"value",value:null===(e=this.nodeScope)||void 0===e?void 0:e.componentOwner._internal.inputValues}},color:"component",haveComponentPorts:!0,category:"Component Utilities",methods:{registerOutputIfNeeded(e){this.hasOutput(e)||this.registerOutput(e,{getter(){var t;return null===(t=this.nodeScope)||void 0===t?void 0:t.componentOwner._internal.inputValues[e]}})},_updateDependencies(){var e,t;null===(t=null===(e=this.nodeScope)||void 0===e?void 0:e.componentOwner)||void 0===t||t.update()}}},ue={category:"Component Utilities",name:"Component Outputs",shortDesc:"This node is used to define the outputs of a component.",docs:"https://docs.noodl.net/nodes/component-utilities/component-outputs",panels:[{name:"PortEditor",context:["select","connectTo"],title:"Outputs",plug:"input",type:{name:"*"},canArrangeInGroups:!0},{name:"PropertyEditor",hidden:!0}],color:"component",haveComponentPorts:!0,prototypeExtensions:{registerInputIfNeeded:function(e){this.hasInput(e)||this.registerInput(e,{set(t){var n,o;null===(o=null===(n=this.nodeScope)||void 0===n?void 0:n.componentOwner)||void 0===o||o.setOutputFromComponentOutput(e,t)}})}}};var ce=n(8763);const pe={name:"RunTasks",displayNodeName:"Run Tasks",docs:"https://docs.noodl.net/nodes/data/run-tasks",color:"data",category:"Data",initialize(){this._internal={queuedOperations:[],state:"idle",maxRunningTasks:10,activeTasks:new Map}},inputs:{items:{group:"Data",displayName:"Items",type:"array",set(e){e&&e!==this._internal.items&&(this._internal.items=e)}},stopOnFailure:{group:"General",displayName:"Stop On Failure",type:"boolean",default:!1,set(e){this._internal.stopOnFailure=e}},maxRunningTasks:{group:"General",displayName:"Max Running Tasks",type:"number",default:10,set(e){this._internal.maxRunningTasks=e}},taskTemplate:{type:"component",displayName:"Template",group:"General",set(e){this._internal.template=e}},run:{group:"General",displayName:"Do",type:"signal",valueChangedToTrue(){this.scheduleRun()}},abort:{group:"General",displayName:"Abort",type:"signal",valueChangedToTrue(){this.scheduleAbort()}}},outputs:{success:{type:"signal",group:"Events",displayName:"Success"},failure:{type:"signal",group:"Events",displayName:"Failure"},done:{type:"signal",group:"Events",displayName:"Done"},aborted:{type:"signal",group:"Events",displayName:"Aborted"}},methods:{scheduleRun(){const e=this._internal;e.hasScheduledRun||(e.hasScheduledRun=!0,this.scheduleAfterInputsHaveUpdated((()=>{this._queueOperation((()=>{e.hasScheduledRun=!1,this.run()}))})))},scheduleAbort(){const e=this._internal;e.hasScheduledAbort||(e.hasScheduledAbort=!0,this.scheduleAfterInputsHaveUpdated((()=>{this._queueOperation((()=>{e.hasScheduledAbort=!1,this.abort()}))})))},async createTaskComponent(e){const t=this._internal,n=(this.nodeScope.modelScope||ce.K).create(e),o=await this.nodeScope.createNode(t.template,(0,z.Os)(),{_forEachModel:n,_forEachNode:this}),i=o.isInputConnected.bind(o);o.isInputConnected=e=>"Do"===e||i(e),o.hasInput("Id")&&o.setInputValue("Id",n.getId()),o.hasInput("id")&&o.setInputValue("id",n.getId());for(const e in o._inputs)void 0!==n.data[e]&&o.setInputValue(e,n.data[e]);return o._internal.creatorCallbacks={onOutputChanged:(e,t,i)=>{!1!==i&&void 0!==i||!0!==t||this.itemOutputSignalTriggered(e,n,o)}},o},async startTask(e){const t=this._internal;try{const o=await this.createTaskComponent(e);t.runningTasks++,(n=o).queueInput("Do",!0),n.queueInput("Do",!1),t.activeTasks.set(o.id,o)}catch(e){console.log(e)}var n},async run(){const e=this._internal;if(this.context.editorConnection&&("idle"!==e.state?this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"run-tasks",{message:"Cannot start when not in idle mode"}):e.template?e.items?this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"run-tasks"):this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"run-tasks",{message:"No items array provided."}):this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"run-tasks",{message:"No task template specified."})),"idle"===e.state&&e.template&&e.items){e.state="running",e.numTasks=e.items.length,e.failedTasks=0,e.completedTasks=0,e.queuedTasks=[].concat(e.items),e.runningTasks=0,0===e.items.length&&(this.sendSignalOnOutput("success"),e.state="idle");for(let t=0;t{if("aborted"===o.state)return this.sendSignalOnOutput("aborted"),void(o.state="idle");if(o.completedTasks===o.numTasks)0===o.failedTasks?this.sendSignalOnOutput("success"):this.sendSignalOnOutput("failure"),this.sendSignalOnOutput("done"),o.state="idle";else if(o.stopOnFailure)if(0===o.failedTasks){o.runningTasks++;const e=o.queuedTasks.shift();e&&this.startTask(e)}else this.sendSignalOnOutput("failure"),this.sendSignalOnOutput("aborted");else{o.runningTasks++;const e=o.queuedTasks.shift();e&&this.startTask(e)}};"Success"===e?(o.completedTasks++,o.runningTasks--,i()):"Failure"===e&&(o.completedTasks++,o.failedTasks++,o.runningTasks--,i()),o.activeTasks.delete(n.id),this.nodeScope.deleteNode(n)},_queueOperation(e){this._internal.queuedOperations.push(e),this._runQueueOperations()},async _runQueueOperations(){if(!this.runningOperations){for(this.runningOperations=!0;this._internal.queuedOperations.length;){const e=this._internal.queuedOperations.shift();await e()}this.runningOperations=!1}}},_deleteAllTasks(){for(const e of this._internal.activeTasks)this.nodeScope.deleteNode(e);this._internal.activeTasks.clear()},_onNodeDeleted(){Node.prototype._onNodeDeleted.call(this),this._deleteAllTasks()}},he={name:"REST2",displayNodeName:"REST",docs:"https://docs.noodl.net/nodes/data/rest",category:"Data",color:"data",searchTags:["http","request","fetch"],initialize(){this._internal.inputValues={},this._internal.outputValues={},this._internal.outputValuesProxy=new Proxy(this._internal.outputValues,{set:(e,t,n)=>(n!==this._internal.outputValues[t]&&(this.registerOutputIfNeeded("out-"+t),this._internal.outputValues[t]=n,this.flagOutputDirty("out-"+t)),!0)}),this._internal.self={}},getInspectInfo(){return this._internal.inspectData?{type:"value",value:this._internal.inspectData}:{type:"text",value:"[Not executed yet]"}},inputs:{resource:{type:"string",displayName:"Resource",group:"Request",default:"/",set(e){this._internal.resource=e}},method:{type:{name:"enum",enums:[{label:"GET",value:"GET"},{label:"POST",value:"POST"},{label:"PUT",value:"PUT"},{label:"PATCH",value:"PATCH"},{label:"DELETE",value:"DELETE"}]},displayName:"Method",group:"Request",default:"GET",set(e){this._internal.method=e}},requestScript:{type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},displayName:"Request",default:"//Add custom code to setup the request object before the request\n//is made.\n//\n//*Request.resource contains the resource path of the request.\n//*Request.method contains the method, GET, POST, PUT or DELETE.\n//*Request.headers is a map where you can add additional headers.\n//*Request.parameters is a map the parameters that will be appended\n// to the url.\n//*Request.content contains the content of the request as a javascript\n// object.\n//\n//*Inputs and *Outputs contain the inputs and outputs of the node.\n",group:"Scripts",set(e){try{this._internal.requestFunc=new Function("Inputs","Outputs","Request",e)}catch(e){console.log(e)}}},responseScript:{type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},displayName:"Response",default:"// Add custom code to convert the response content to outputs\n//\n//*Response.status The status code of the response\n//*Response.content The content of the response as a javascript\n// object.\n//*Response.request The request object that resulted in the response.\n//\n//*Inputs and *Outputs contain the inputs and outputs of the node.\n",group:"Scripts",set(e){try{this._internal.responseFunc=new Function("Inputs","Outputs","Response",e)}catch(e){console.log(e)}}},fetch:{type:"signal",displayName:"Fetch",group:"Actions",valueChangedToTrue(){this.scheduleFetch()}},cancel:{type:"signal",displayName:"Cancel",group:"Actions",valueChangedToTrue(){this.cancelFetch()}}},outputs:{failure:{type:"signal",displayName:"Failure",group:"Events"},success:{type:"signal",displayName:"Success",group:"Events"},canceled:{type:"signal",displayName:"Canceled",group:"Events"}},prototypeExtensions:{getScriptOutputValue(e){return this._internal.outputValues[e]},setScriptInputValue(e,t){return this._internal.inputValues[e]=t},registerOutputIfNeeded(e){if(!this.hasOutput(e))return e.startsWith("out-")?this.registerOutput(e,{getter:this.getScriptOutputValue.bind(this,e.substring(4))}):void 0},registerInputIfNeeded(e){if(!this.hasInput(e))return e.startsWith("in-")?this.registerInput(e,{set:this.setScriptInputValue.bind(this,e.substring(3))}):void 0},scheduleFetch(){const e=this._internal;e.hasScheduledFetch||(e.hasScheduledFetch=!0,this.scheduleAfterInputsHaveUpdated(this.doFetch.bind(this)))},doResponse(e,t,n){this._internal.responseFunc&&this._internal.responseFunc.apply(this._internal.self,[this._internal.inputValues,this._internal.outputValuesProxy,{status:e,content:t,request:n}]),this._internal.inspectData={status:e,content:t},e>=200&&e<300?this.sendSignalOnOutput("success"):this.sendSignalOnOutput("failure")},doExternalFetch(e){let t=e.resource;if(Object.keys(e.parameters).length>0){const n=Object.keys(e.parameters).map((t=>t+"="+encodeURIComponent(e.parameters[t])));t+="?"+n.join("&")}if("undefined"==typeof _noodl_cloud_runtime_version){const n=new XMLHttpRequest;this._xhr=n,n.open(e.method,t,!0);for(const t in e.headers)n.setRequestHeader(t,e.headers[t]);n.onreadystatechange=()=>{let t=!1;if(4===n.readyState){const o=n.status,i=n.getResponseHeader("content-type"),s=n.response;if(delete this._xhr,i){i=i.toLowerCase();const n=-1!==i.indexOf("json")?JSON.parse(s):s;this.doResponse(o,n,e),t=!0}!1===t&&this.doResponse(o,s,e)}},n.onerror=()=>{delete this._xhr,this.sendSignalOnOutput("failure")},n.onabort=()=>{delete this._xhr,this.sendSignalOnOutput("canceled")},e.content?(n.setRequestHeader("Content-Type","application/json"),n.send(JSON.stringify(e.content))):n.send()}else{const n={...e.headers,...e.content?{"Content-Type":"application/json"}:{}};fetch(t,{method:e.method,headers:n,body:e.content?JSON.stringify(e.content):void 0}).then((t=>{const n=t.headers.get("content-type");n?-1!==n.indexOf("/json")?t.json().then((n=>{this.doResponse(t.status,n,e)})):this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"rest-run-waring-",{message:"REST only supports json content type in response."}):t.text().then((n=>{this.doResponse(t.status,n,e)}))})).catch((e=>{console.log("REST: Failed to request",t),console.log(e),this.sendSignalOnOutput("failure")}))}},doFetch(){this._internal.hasScheduledFetch=!1;let e=this._internal.resource;if(e)for(const t in this._internal.inputValues)e=e.replace("{"+t+"}",this._internal.inputValues[t]);const t={resource:e,headers:{},method:void 0!==this._internal.method?this._internal.method:"GET",parameters:{}};this._internal.requestFunc&&this._internal.requestFunc.apply(this._internal.self,[this._internal.inputValues,this._internal.outputValuesProxy,t]),this.doExternalFetch(t)},cancelFetch(){"undefined"==typeof _noodl_cloud_runtime_version?this._xhr&&this._xhr.abort():this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"rest-run-waring-",{message:"REST doesn't support cancel in cloud functions."})}}};function me(e,t,n,o,i,s){if(!i.editorConnection)return;if(i.editorConnection.clearWarning(o.component.name,o.id,"rest-run-waring-"+n),void 0===e)return void i.editorConnection.clearWarning(o.component.name,o.id,"rest-parse-waring-"+n);try{new Function(...t,e),i.editorConnection.clearWarning(o.component.name,o.id,"rest-parse-waring-"+n)}catch(e){i.editorConnection.sendWarning(o.component.name,o.id,"rest-parse-waring-"+n,{message:""+n+": "+e.message,showGlobally:!0})}function r(e){return void 0!==s.find((t=>t.name===e))}const a=e.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,""),l=a.match(/Inputs\.[A-Za-z0-9]+/g);if(l){const e={};l.forEach((t=>{e[t.substring(7)]=!0})),Object.keys(e).forEach((e=>{r("in-"+e)||s.push({name:"in-"+e,displayName:e,plug:"input",type:"*",group:"Inputs"})}))}const d=a.match(/Outputs\.[A-Za-z0-9]+/g);if(d){const e={};d.forEach((t=>{e[t.substring(8)]=!0})),Object.keys(e).forEach((e=>{r("out-"+e)||s.push({name:"out-"+e,displayName:e,plug:"output",type:"*",group:"Outputs"})}))}}function ge(e,t){function n(t){function n(){if(!t.parameters)return;const n=[];function o(e){for(let t=0;t{n()}))}e.editorConnection&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.REST2",(e=>{n(e)}));for(const e of t.getNodesWithType("REST2"))n(e)}))}var fe=n(8779),ye=n.n(fe);const ve={name:"Expression",docs:"https://docs.noodl.net/nodes/math/expression",usePortAsLabel:"expression",category:"CustomCode",color:"javascript",nodeDoubleClickAction:{focusPort:"Expression"},searchTags:["javascript"],initialize(){const e=this._internal;e.scope={},e.hasScheduledEvaluation=!1,e.code=void 0,e.cachedValue=0,e.currentExpression="",e.compiledFunction=void 0,e.inputNames=[],e.inputValues=[]},getInspectInfo(){return this._internal.cachedValue},inputs:{expression:{group:"General",inputPriority:1,type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},displayName:"Expression",set(e){const t=this._internal;t.currentExpression=be+"return ("+e+");",t.compiledFunction=void 0;const n=Ce(e),o=ye()(n,t.inputNames),i=ye()(t.inputNames,n),s=this;i.forEach((function(e){s.deregisterInput(e),delete t.scope[e]})),o.forEach((function(e){s.hasInput(e)||(s.registerInput(e,{set(n){t.scope[e]=n,this.isInputConnected("run")||this._scheduleEvaluateExpression()}}),t.scope[e]=0,s._inputValues[e]=0)})),t.inputNames=Object.keys(t.scope),this.isInputConnected("run")||this._scheduleEvaluateExpression()}},run:{group:"Actions",displayName:"Run",type:"signal",valueChangedToTrue(){this._scheduleEvaluateExpression()}}},outputs:{result:{group:"Result",type:"*",displayName:"Result",getter(){return this._internal.currentExpression?this._internal.cachedValue:0}},isTrue:{group:"Result",type:"boolean",displayName:"Is True",getter(){return!!this._internal.currentExpression&&!!this._internal.cachedValue}},isFalse:{group:"Result",type:"boolean",displayName:"Is False",getter(){return!this._internal.currentExpression||!this._internal.cachedValue}},isTrueEv:{group:"Events",type:"signal",displayName:"On True"},isFalseEv:{group:"Events",type:"signal",displayName:"On False"}},prototypeExtensions:{registerInputIfNeeded(e){this.hasInput(e)||(this._internal.scope[e]=0,this._inputValues[e]=0,this.registerInput(e,{set(t){this._internal.scope[e]=t,this.isInputConnected("run")||this._scheduleEvaluateExpression()}}))},_scheduleEvaluateExpression(){const e=this._internal;!1===e.hasScheduledEvaluation&&(e.hasScheduledEvaluation=!0,this.flagDirty(),this.scheduleAfterInputsHaveUpdated((function(){const t=e.cachedValue;e.cachedValue=this._calculateExpression(),t!==e.cachedValue&&(this.flagOutputDirty("result"),this.flagOutputDirty("isTrue"),this.flagOutputDirty("isFalse")),e.cachedValue?this.sendSignalOnOutput("isTrueEv"):this.sendSignalOnOutput("isFalseEv"),e.hasScheduledEvaluation=!1})))},_calculateExpression(){const e=this._internal;e.compiledFunction||(e.compiledFunction=this._compileFunction());for(let t=0;tt===e))||t.push(e))}const o=(e=e.replace(/\"([^\"]*)\"/g,"").replace(/\'([^\']*)\'/g,"")).matchAll(/[a-zA-Z\_\$][a-zA-Z0-9\.\_\$]*/g);for(const e of o){let t=e[0];-1!==t.indexOf(".")&&(t=t.split(".")[0]),n(t)}return t}function Ne(e,t,n){const o=Ce(t).map((e=>({group:"Parameters",name:e,type:{name:"*",editAsType:"string"},plug:"input"})));n.sendDynamicPorts(e,o)}function Oe(e,t){try{new Function(t.parameters.expression),e.clearWarning(t.component.name,t.id,"expression-compile-error")}catch(n){n instanceof Error&&e.sendWarning(t.component.name,t.id,"expression-compile-error",{message:n.message})}}function Ie(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("nodeAdded.Expression",(t=>{t.parameters.expression&&(Ne(t.id,t.parameters.expression,e.editorConnection),Oe(e.editorConnection,t)),t.on("parameterUpdated",(n=>{"expression"===n.name&&(Ne(t.id,t.parameters.expression,e.editorConnection),Oe(e.editorConnection,t))}))}))}const we={};class Pe{constructor(e,t){this.inputs={},this.outputs={},this.code=e;const n=t?t.node:void 0;this._initializeAPIs();let o=we[e];if(!o)try{o=new Function(["define","script","Node","Component"],Pe.getCodePrefix()+e),we[e]=o}catch(e){this.error=e instanceof Error?e.message:String(e),console.error(e)}if(o)try{o(this.define.bind(this),this.script.bind(this),this.apis.Node,n?Pe.getComponentScopeForNode(n):{}),this._afterSourced()}catch(e){this.error=e instanceof Error?e.message:String(e),console.error(e)}}define(e){this.inputs=e.inputs||{},this.outputs=e.outputs||{},this.setup=e.setup,this.change=e.run||e.change,this.destroy=e.destroy,this.definedObject=e}script(e){const t=function(e){const t={inputs:e.inputs||{},outputs:e.outputs||{},setup:function(t,n){if(this.inputs=t,this.outputs=n,this.setOutputs=function(e){for(const t in e)this.outputs[t]=e[t],this.flagOutputDirty(t)},e.methods)for(const t in e.methods)this[t]=e.methods[t];e.setup&&e.setup.apply(this)},destroy:function(t,n){this.inputs=t,this.outputs=n,e.destroy&&e.destroy.apply(this)},change:function(t,n){this.inputs=t,this.outputs=n;const o=this._oldInputs||{};if(e.changed)for(const n in t)if(t[n]!==o[n]){const i=e.changed[n];"function"==typeof i&&i.apply(this,[t[n],o[n]])}this._oldInputs=Object.assign({},t)}};if(e.signals)for(const n in e.signals)t[n]=e.signals[n],t.inputs[n]="signal";return t}(e);this.inputs=t.inputs||{},this.outputs=t.outputs||{},this.setup=t.setup,this.change=t.run||t.change,this.destroy=t.destroy,this.definedObject=t}_initializeAPIs(){this.apis={Node:{Inputs:{},Outputs:{},Signals:{},Setters:{}}}}_afterSourced(){if(void 0!==this.definedObject)return;const e=this.apis.Node;if(this.inputs=Object.assign({},e.Inputs||{}),this.outputs=Object.assign({},e.Outputs||{}),this.setup=function(t,n){const o=this;e.setOutputs=function(e){for(const t in e)n[t]=e[t],o.flagOutputDirty(t)},e.OnInit&&e.OnInit.apply(this)},this.destroy=e.OnDestroy||this.destroy,this.change=(t,n,o)=>{for(const n in o)"function"==typeof e.Setters[n]&&e.Setters[n](t[n]);"function"==typeof e.OnInputsChanged&&e.OnInputsChanged()},this.definedObject={inputs:this.inputs,outputs:this.outputs,setup:this.setup,destroy:this.destroy,change:this.change},void 0!==e.Signals)for(const t in e.Signals)"function"==typeof e.Signals[t]&&(this.inputs[t]="signal",this.definedObject[t]=e.Signals[t])}getPorts(){const e=[];return Object.keys(this.inputs).forEach((t=>{const n=this.inputs[t],o={name:t,plug:"input",type:void 0,group:"Inputs"};"string"==typeof n?o.type={name:n}:Object.assign(o,n),e.push(o)})),Object.keys(this.outputs).forEach((t=>{e.push({name:t,type:{name:this.outputs[t]},plug:"output",group:"Outputs"})})),Pe.parseAndAddPortsFromScript(this.code,e,{}),e}static createFromCode(e,t){return new Pe(e,t)}static createFromURL(e,t,n){e=(0,z.Lo)(e);const o=new XMLHttpRequest;o.open("GET",e,!0),o.onreadystatechange=function(){4!==this.readyState&&this.readyState!==XMLHttpRequest.DONE||t(new Pe(this.response))},o.onerror=function(){console.log("Failed to request",e)},o.send()}static parseAndAddPortsFromScript(e,t,n){function o(e,n){if(null==e)return;const o={};for(const t of e){let e=t[1];void 0!==e&&(o[e]=!0)}Object.keys(o).forEach((e=>{var o;("string"==typeof(o={name:n.prefix+e,plug:n.plug})?void 0===t.find((e=>e.name===o)):void 0===t.find((e=>e.name===o.name&&e.plug===o.plug)))&&t.push({name:n.prefix+e,displayName:e,plug:n.plug,type:n.type,group:n.group})}))}n.skipInputs||(o(e.matchAll(/Inputs\.([A-Za-z0-9_]+)/g),{type:n.inputType||"*",plug:"input",group:n.inputGroup||"Inputs",prefix:n.inputPrefix||""}),o(e.matchAll(/Inputs\s*\[\s*(?:'|")(.*)(?:'|")\s*\]/g),{type:n.inputType||"*",plug:"input",group:n.inputGroup||"Inputs",prefix:n.inputPrefix||""})),n.skipOutputs||(n.skipOutputSignals||(o(e.matchAll(/Outputs\.([A-Za-z0-9]+)\s*\(\s*\)/g),{type:"signal",plug:"output",group:"Outputs",prefix:n.outputPrefix||""}),o(e.matchAll(/Outputs\s*\[\s*(?:'|")(.*)(?:'|")\s*\]\(\s*\)/g),{type:"signal",plug:"output",group:"Outputs",prefix:n.outputPrefix||""})),n.skipRegularOutputs||(o(e.matchAll(/Outputs\.([A-Za-z0-9_]+)/g),{type:"*",plug:"output",group:"Outputs",prefix:n.outputPrefix||""}),o(e.matchAll(/Outputs\s*\[\s*\"([^\"]*)\"\s*\]/g),{type:"*",plug:"output",group:"Outputs",prefix:n.outputPrefix||""})))}static getCodePrefix(){return"const Script = (typeof Node !== 'undefined')?Node:undefined;\n"}static createNoodlAPI(){return"undefined"!=typeof window&&void 0!==window.Noodl?window.Noodl:{}}static getComponentScopeForNode(e){const t=e.nodeScope.componentOwner.getInstanceId();if(void 0===xe[t]){xe[t]={};const n=(e.nodeScope.modelScope||ce.K).get("componentState"+t);xe[t].Object=n}const n=function(e){const t=function e(t){let n;if(t.getRoots().length>0){const e=t.getRoots()[0];e.getVisualParentNode?e.getVisualParentNode()&&(n=e.getVisualParentNode().nodeScope.componentOwner):e.parentNodeScope&&(n=t.parentNodeScope.componentOwner)}else t.parentNodeScope&&(n=t.parentNodeScope.componentOwner);if(n&&n.nodeScope&&n.nodeScope.componentOwner!==t)return n.nodeScope.getNodesWithType("net.noodl.ComponentObject").length>0||n.nodeScope.getNodesWithType("Component State").length>0?n:e(n)}(e.nodeScope.componentOwner);if(t)return"componentState"+t.getInstanceId()}(e),o=void 0!==n?(e.nodeScope.modelScope||ce.K).get(n):void 0;return xe[t].ParentObject=o,xe[t].RepeaterObject=function(e){let t=e.nodeScope.componentOwner;for(;void 0!==t&&void 0===t._forEachModel&&t.parentNodeScope;)t=t.parentNodeScope.componentOwner;return void 0!==t?t._forEachModel:void 0}(e),xe[t]}}const xe={},Ee={name:"JavaScriptFunction",displayNodeName:"Function",docs:"https://docs.noodl.net/nodes/javascript/function",category:"CustomCode",color:"javascript",nodeDoubleClickAction:{focusPort:"Script"},searchTags:["javascript"],exportDynamicPorts:!0,initialize:function(){this._internal={},this._internal.inputValues={},this._internal.outputValues={},this._internal.inputTypes={},this._internal.outputTypes={},this._internal.outputValuesProxy=new Proxy(this._internal.outputValues,{set:(e,t,n)=>(this._deleted||n!==this._internal.outputValues[t]&&(this.registerOutputIfNeeded("out-"+t),this._internal.outputValues[t]=n,this.flagOutputDirty("out-"+t)),!0)}),this._internal._this={}},getInspectInfo(){return[{type:"value",value:{inputs:this._internal.inputValues,outputs:this._internal.outputValues}}]},inputs:{scriptInputs:{type:{name:"proplist",allowEditOnly:!0},group:"Script Inputs",set(e){}},scriptOutputs:{type:{name:"proplist",allowEditOnly:!0},group:"Script Outputs",set(e){}},functionScript:{displayName:"Script",plug:"input",type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},group:"General",set(e){void 0!==e?(this._internal.func=this.parseScript(e),this.isInputConnected("run")||this.scheduleRun()):this._internal.func=void 0}},run:{type:"signal",displayName:"Run",group:"Actions",valueChangedToTrue:function(){this.scheduleRun()}}},outputs:{},methods:{scheduleRun(){this.runScheduled||(this.runScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.runScheduled=!1,this._deleted||this.runScript()})))},async runScript(){const e=this._internal.func;if(void 0===e)return;const t=this._internal.inputValues,n=this._internal.outputValuesProxy;for(const e in this.model.outputPorts)if(this._isSignalType(e)){const t=()=>{this.hasOutput(e)&&this.sendSignalOnOutput(e)};this._internal.outputValues[e.substring(4)]=t,this._internal.outputValues[e.substring(4)].send=t}try{await e.apply(this._internal._this,[t,n,Pe.createNoodlAPI(this.nodeScope.modelScope),Pe.getComponentScopeForNode(this)])}catch(e){(0,z.Ql)(e),this.context.editorConnection&&this.context.isWarningTypeEnabled("javascriptExecution")&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"js-function-run-waring",{showGlobally:!0,message:e.message,stack:e.stack})}},setScriptInputValue(e,t){this._internal.inputValues[e]=t,this.isInputConnected("run")||this.scheduleRun()},getScriptOutputValue(e){if(!this._isSignalType(e))return this._internal.outputValues[e]},setScriptInputType(e,t){this._internal.inputTypes[e]=t},setScriptOutputType(e,t){this._internal.outputTypes[e]=t},parseScript(e){let t;try{t=new(0,Object.getPrototypeOf((async function(){})).constructor)("Inputs","Outputs","Noodl","Component",Pe.getCodePrefix()+e)}catch(e){console.log("Error while parsing action script: "+e)}return t},_isSignalType(e){return this.model.outputPorts[e]&&"signal"===this.model.outputPorts[e].type},registerInputIfNeeded(e){if(!this.hasInput(e)){if(e.startsWith("in-")){const t=e.substring(3),n={set:this.setScriptInputValue.bind(this,t)};this.model&&this.model.parameters["intype-"+t]&&(n.type=this.model.parameters["intype-"+t]),this.registerInput(e,n)}if(e.startsWith("intype-")){const t=e.substring(7);this.registerInput(e,{set(e){this.hasInput("in"+t)&&(this.getInput("in"+t).type=e)}})}e.startsWith("outtype-")&&this.registerInput(e,{set(){}})}},registerOutputIfNeeded(e){if(!this.hasOutput(e))return e.startsWith("out-")?this.registerOutput(e,{getter:this.getScriptOutputValue.bind(this,e.substring(4))}):void 0}}},Te=[{value:"string",label:"String"},{value:"boolean",label:"Boolean"},{value:"number",label:"Number"},{value:"object",label:"Object"},{value:"date",label:"Date"},{value:"array",label:"Array"},{value:"color",label:"Color"}];function Ae(e,t){function n(t){function n(){var n;const o=[],i=Te.concat([{value:"signal",label:"Signal"}]);void 0!==t.parameters.scriptOutputs&&t.parameters.scriptOutputs.length>0&&t.parameters.scriptOutputs.forEach((e=>{o.push({name:"outtype-"+e.label,displayName:"Type",editorName:e.label+" | Type",plug:"input",type:{name:"enum",enums:i,allowEditOnly:!0},default:"string",parent:"scriptOutputs",parentItemId:e.id}),o.push({name:"out-"+e.label,displayName:e.label,plug:"output",type:t.parameters["outtype-"+e.label]||"*",group:"Outputs"})})),void 0!==t.parameters.scriptInputs&&t.parameters.scriptInputs.length>0&&t.parameters.scriptInputs.forEach((e=>{o.push({name:"intype-"+e.label,displayName:"Type",editorName:e.label+" | Type",plug:"input",type:{name:"enum",enums:Te,allowEditOnly:!0},default:"string",parent:"scriptInputs",parentItemId:e.id}),o.push({name:"in-"+e.label,displayName:e.label,plug:"input",type:t.parameters["intype-"+e.label]||"string",group:"Inputs"})})),function(e,t,n,o,i){if(o.editorConnection.clearWarning(n.component.name,n.id,"js-function-run-waring"),void 0!==e){try{new(0,Object.getPrototypeOf((async function(){})).constructor)("Inputs","Outputs","Noodl","Component",e),o.editorConnection.clearWarning(n.component.name,n.id,"js-function-parse-waring")}catch(e){o.editorConnection.sendWarning(n.component.name,n.id,"js-function-parse-waring",{showGlobally:!0,message:e.message})}Pe.parseAndAddPortsFromScript(e,i,{inputPrefix:"in-",outputPrefix:"out-"})}else o.editorConnection.clearWarning(n.component.name,n.id,"js-function-parse-waring")}(t.parameters.functionScript,0,t,e,o),o.forEach((e=>{"signal"===e.type&&"output"===e.plug&&(t.outputPorts[e.name]=e)})),null===(n=e.editorConnection)||void 0===n||n.sendDynamicPorts(t.id,o)}n(),t.on("parameterUpdated",(function(){n()}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.JavaScriptFunction",(function(e){n(e)}));for(const e of t.getNodesWithType("JavaScriptFunction"))n(e)}))}var ke=n(3200),De=n(3795);function Re(e,t){const n=t.queryParameters;if(void 0!==e.combinator&&void 0!==e.rules){if(0===e.rules.length)return;if(1===e.rules.length)return Re(e.rules[0],t);{const n={},o="$"+e.combinator;return n[o]=[],e.rules.forEach((e=>{const i=Re(e,t);void 0!==i&&n[o].push(i)})),n}}if("related to"===e.operator){const t=void 0!==e.input?n[e.input]:void 0;if(void 0===t)return;return{$relatedTo:{object:{__type:"Pointer",objectId:t,className:e.relatedTo},key:e.relationProperty}}}{const o={};let i,s,r=void 0!==e.input?n[e.input]:e.value;if("exist"===e.operator)return o[e.property]={$exists:!0},o;if("not exist"===e.operator)return o[e.property]={$exists:!1},o;if(void 0===r)return;return De.D._collections[t.collectionName]&&(s=De.D._collections[t.collectionName].schema),"Date"===(s&&s.properties&&s.properties[e.property]?s.properties[e.property].type:void 0)&&(r instanceof Date||(r=new Date(r.toString())),r={__type:"Date",iso:r.toISOString()}),"greater than"===e.operator?i={$gt:r}:"greater than or equal to"===e.operator?i={$gte:r}:"less than"===e.operator?i={$lt:r}:"less than or equal to"===e.operator?i={$lte:r}:"equal to"===e.operator?i={$eq:r}:"not equal to"===e.operator?i={$ne:r}:"points to"===e.operator?i={$eq:{__type:"Pointer",objectId:r,className:s&&s.properties&&s.properties[e.property]?s.properties[e.property].targetClass:void 0}}:"contain"===e.operator&&(i={$regex:r,$options:"i"}),o[e.property]=i,o}}function Me(e,t){let n=!0;return void 0===t||(void 0!==t.$and?t.$and.forEach((t=>{n=n&&Me(e,t)})):void 0!==t.$or?(n=!1,t.$or.forEach((t=>{n=n||Me(e,t)}))):Object.keys(t).forEach((o=>{if("objectId"===o)void 0!==t[o].$eq?n=n&&e.getId()===t[o].$eq:void 0!==t[o].$in&&(n=n&&-1!==t[o].$in.indexOf(e.getId()));else if("$relatedTo"===o)n=!1;else{const i=e.get(o);void 0!==t[o].$eq&&"Pointer"===t[o].$eq.__type?n=n&&i===t[o].$eq.objectId:void 0!==t[o].$eq?n=n&&i==t[o].$eq:void 0!==t[o].$ne?n=n&&i!=t[o].$ne:void 0!==t[o].$lt?n=n&&it[o].$gt:void 0!==t[o].$gte?n=n&&i>=t[o].$gte:void 0!==t[o].$exists?n=n&&void 0!==i:void 0!==t[o].$in?n=n&&-1!==t[o].$in.indexOf(i):void 0!==t[o].$nin?n=n&&-1===t[o].$in.indexOf(i):void 0!==t[o].$regex&&(n=n&&new RegExp(t[o].$regex,t[o].$options).test(i))}})),n)}function Ve(e,t,n){for(let o=0;on.get(e))return-1;if(t.get(e)n.get(i))return 1;if(t.get(i)("descending"===e.order?"-":"")+e.property))}function Fe(e){return e instanceof Date&&"function"==typeof e.toISOString?{__type:"Date",iso:e.toISOString()}:e}function Ue(e,t){var n,o,i,s,r,a;const l=Object.keys(e);if(0===l.length)return{};if(1!==l.length)return null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.call(t,"Filter must only have one key found "+l.join(","));const d={},u=l[0];if(void 0!==e.and&&Array.isArray(e.and))d.$and=e.and.map((e=>Ue(e,t)));else if(void 0!==e.or&&Array.isArray(e.or))d.$or=e.or.map((e=>Ue(e,t)));else if(void 0!==e.idEqualTo)d.objectId={$eq:e.idEqualTo};else if(void 0!==e.idContainedIn)d.objectId={$in:e.idContainedIn};else if(void 0!==e.relatedTo){const n=e.relatedTo.id;if(void 0===n)return null===(o=null==t?void 0:t.error)||void 0===o?void 0:o.call(t,"Must provide id in relatedTo filter");const a=e.relatedTo.key;if(void 0===a)return null===(i=null==t?void 0:t.error)||void 0===i?void 0:i.call(t,"Must provide key in relatedTo filter");const l=e.relatedTo.className||(null===(s=(t.modelScope||ce.K).get(n))||void 0===s?void 0:s._class);if(void 0===l)return null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.call(t,"Must preload the Pointer or include className");d.$relatedTo={object:{__type:"Pointer",objectId:n,className:l},key:a}}else if("object"==typeof e[u]){const n=e[u];if(void 0!==n.equalTo)d[u]={$eq:Fe(n.equalTo)};else if(void 0!==n.notEqualTo)d[u]={$ne:Fe(n.notEqualTo)};else if(void 0!==n.lessThan)d[u]={$lt:Fe(n.lessThan)};else if(void 0!==n.greaterThan)d[u]={$gt:Fe(n.greaterThan)};else if(void 0!==n.lessThanOrEqualTo)d[u]={$lte:Fe(n.lessThanOrEqualTo)};else if(void 0!==n.greaterThanOrEqualTo)d[u]={$gte:Fe(n.greaterThanOrEqualTo)};else if(void 0!==n.exists)d[u]={$exists:n.exists};else if(void 0!==n.containedIn)d[u]={$in:n.containedIn};else if(void 0!==n.notContainedIn)d[u]={$nin:n.notContainedIn};else if(void 0!==n.pointsTo){let e=null;De.D._collections[t.collectionName]&&(e=De.D._collections[t.collectionName].schema);const o=e&&e.properties&&e.properties[u]?e.properties[u].targetClass:void 0;"Relation"===(e&&e.properties&&e.properties[u]?e.properties[u].type:void 0)?d[u]={__type:"Pointer",objectId:n.pointsTo,className:o}:Array.isArray(n.pointsTo)?d[u]={$in:n.pointsTo.map((e=>({__type:"Pointer",objectId:e,className:o})))}:d[u]={$eq:{__type:"Pointer",objectId:n.pointsTo,className:o}}}else if(void 0!==n.matchesRegex)d[u]={$regex:n.matchesRegex,$options:n.options};else if(void 0!==n.text&&void 0!==n.text.search){const e=n.text.search;d[u]="string"==typeof e?{$text:{$search:{$term:e,$caseSensitive:!1}}}:{$text:{$search:{$term:e.term,$language:e.language,$caseSensitive:e.caseSensitive,$diacriticSensitive:e.diacriticSensitive}}}}else if(void 0!==n.nearSphere){const e=n.nearSphere;d[u]={$nearSphere:{__type:"GeoPoint",latitude:e.latitude,longitude:e.longitude},$maxDistanceInMiles:e.maxDistanceInMiles,$maxDistanceInKilometers:e.maxDistanceInKilometers,$maxDistanceInRadians:e.maxDistanceInRadians}}else if(void 0!==n.withinBox){const e=n.withinBox;d[u]={$within:{$box:e.map((e=>({__type:"GeoPoint",latitude:e.latitude,longitude:e.longitude})))}}}else if(void 0!==n.withinPolygon){const e=n.withinPolygon;d[u]={$geoWithin:{$polygon:e.map((e=>({__type:"GeoPoint",latitude:e.latitude,longitude:e.longitude})))}}}}else null===(a=null==t?void 0:t.error)||void 0===a||a.call(t,"Unrecognized filter keys "+l.join(","));return d}const We={name:"DbCollection2",docs:"https://docs.noodl.net/nodes/data/cloud-data/query-records",displayName:"Query Records",category:"Cloud Services",usePortAsLabel:"collectionName",color:"data",initialize(){const e=this;this._internal.queryParameters={};let t=!1;this._internal.collectionChangedCallback=function(){t||(t=!0,e.scheduleAfterInputsHaveUpdated((function(){e.flagOutputDirty("count"),e.flagOutputDirty("firstItemId"),e.flagOutputDirty("isEmpty"),t=!1})))},this._internal.cloudStoreEvents=function(t){var n,o;if(!0!==e.isInputConnected("storageFetch")&&void 0!==e._internal.collection&&t.collection===e._internal.name)if("create"===t.type){const o=ce.K.get(t.object.objectId);void 0!==o&&Me(o,null===(n=e._internal.currentQuery)||void 0===n?void 0:n.where)&&s(o)}else if("save"===t.type){const n=ce.K.get(t.objectId);if(void 0!==n){const t=Me(n,null===(o=e._internal.currentQuery)||void 0===o?void 0:o.where);!t&&e._internal.collection.contains(n)?(e._internal.collection.remove(n),e.flagOutputDirty("items"),e.flagOutputDirty("count"),e.flagOutputDirty("firstItemId"),e.flagOutputDirty("isEmpty")):t&&!e._internal.collection.contains(n)&&s(n)}}else if("delete"===t.type){const n=ce.K.get(t.objectId);void 0!==n&&(e._internal.collection.remove(n),e.flagOutputDirty("items"),e.flagOutputDirty("count"),e.flagOutputDirty("firstItemId"),e.flagOutputDirty("isEmpty"))}function s(t){var n,o;if(void 0!==(null===(n=e._internal.currentQuery)||void 0===n?void 0:n.sort)){for(let n=0;n0);n++);e._internal.collection.addAtIndex(t,i)}else e._internal.collection.add(t);let s=e._internal.collection.size();void 0!==(null===(o=e._internal.currentQuery)||void 0===o?void 0:o.limit)&&s>e._internal.currentQuery.limit&&e._internal.collection.remove(e._internal.collection.get(void 0!==e._internal.currentQuery.sort&&"-"===e._internal.currentQuery.sort[0][0]?s-1:0)),e.flagOutputDirty("items"),e.flagOutputDirty("count"),e.flagOutputDirty("firstItemId"),e.flagOutputDirty("isEmpty")}};const n=De.D.forScope(this.nodeScope.modelScope);n.on("save",this._internal.cloudStoreEvents),n.on("create",this._internal.cloudStoreEvents),n.on("delete",this._internal.cloudStoreEvents),this._internal.storageSettings={}},getInspectInfo(){const e=this._internal.collection;return e?[{type:"value",value:e.items}]:{type:"text",value:"[Not executed yet]"}},inputs:{},outputs:{items:{type:"array",displayName:"Items",group:"General",getter:function(){return this._internal.collection}},firstItemId:{type:"string",displayName:"First Record Id",group:"General",getter:function(){if(this._internal.collection){const e=this._internal.collection.get(0);if(void 0!==e)return e.getId()}}},isEmpty:{type:"boolean",displayName:"Is Empty",group:"General",getter:function(){return!this._internal.collection||0===this._internal.collection.size()}},count:{type:"number",displayName:"Count",group:"General",getter:function(){return this._internal.collection?this._internal.collection.size():0}},fetched:{group:"Events",type:"signal",displayName:"Success"},failure:{group:"Events",type:"signal",displayName:"Failure"},error:{type:"string",displayName:"Error",group:"Error",getter:function(){return this._internal.error}}},prototypeExtensions:{setCollectionName:function(e){this._internal.name=e,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()},setCollection:function(e){this.bindCollection(e),this.flagOutputDirty("firstItemId"),this.flagOutputDirty("isEmpty"),this.flagOutputDirty("items"),this.flagOutputDirty("count")},unbindCurrentCollection:function(){const e=this._internal.collection;e&&(e.off("change",this._internal.collectionChangedCallback),this._internal.collection=void 0)},bindCollection:function(e){this.unbindCurrentCollection(),this._internal.collection=e,e&&e.on("change",this._internal.collectionChangedCallback)},_onNodeDeleted:function(){Node.prototype._onNodeDeleted.call(this),this.unbindCurrentCollection();const e=De.D.forScope(this.nodeScope.modelScope);e.off("insert",this._internal.cloudStoreEvents),e.off("delete",this._internal.cloudStoreEvents),e.off("save",this._internal.cloudStoreEvents)},setError:function(e){this._internal.err=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure")},scheduleFetch:function(){const e=this._internal;e.fetchScheduled||(e.fetchScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{e.fetchScheduled=!1,this.fetch()})))},fetch:function(){this.context.editorConnection&&(void 0===this._internal.name?this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"query-collection",{message:"No collection specified for query"}):this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"query-collection"));const e=ke.p.get(),t=this.getStorageFilter(),n=this.getStorageLimit(),o=this.getStorageSkip(),i=this.getStorageFetchTotalCount();this._internal.currentQuery={where:t.where,sort:t.sort,limit:n,skip:o},De.D.forScope(this.nodeScope.modelScope).query({collection:this._internal.name,where:t.where,sort:t.sort,limit:n,skip:o,count:i,success:(t,n)=>{void 0!==t&&e.set(t.map((e=>De.D._fromJSON(e,this._internal.name,this.nodeScope.modelScope)))),void 0!==n&&(this._internal.storageSettings.storageTotalCount=n,this.hasOutput("storageTotalCount")&&this.flagOutputDirty("storageTotalCount")),this.setCollection(e),this.sendSignalOnOutput("fetched")},error:t=>{this.setCollection(e),this.setError(t||"Failed to fetch.")}})},getStorageFilter:function(){var e;const t=this._internal.storageSettings;if(void 0===t.storageFilterType||"simple"===t.storageFilterType)return{where:void 0!==this._internal.visualFilter?Re(this._internal.visualFilter,{queryParameters:this._internal.queryParameters,collectionName:this._internal.name}):void 0,sort:void 0!==this._internal.visualSorting?je(this._internal.visualSorting):void 0};if("json"===t.storageFilterType){if(!this._internal.filterFunc)try{let e=t.storageJSONFilter;e=e.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,""),this._internal.filterVariables=e.match(/\$[A-Za-z0-9]+/g)||[];const n=["filter","where","sort","Inputs"].concat(this._internal.filterVariables).concat([e]);this._internal.filterFunc=Function.apply(null,n)}catch(e){this._internal.filterFunc=void 0,console.log("Error while parsing filter script: "+e)}if(!this._internal.filterFunc)return;let n={},o=[];const i=this,s=function(e){n=Ue(e,{collectionName:i._internal.name,error:function(e){i.context.editorConnection.sendWarning(i.nodeScope.componentOwner.name,i.id,"query-collection-filter",{message:e})}})},r=function(e){o=e},a={};for(const e in t)e.startsWith("storageFilterValue-")&&(a[e.substring(19)]=t[e]);const l=[s,s,r,a];null===(e=this._internal.filterVariables)||void 0===e||e.forEach((e=>{l.push(t["storageFilterValue-"+e.substring(1)])}));try{this._internal.filterFunc.apply(this,l)}catch(e){console.log("Error while running filter script: "+e)}return{where:n,sort:o}}},getStorageLimit:function(){const e=this._internal.storageSettings;return e.storageEnableLimit?e.storageLimit||10:void 0},getStorageSkip:function(){const e=this._internal.storageSettings;return e.storageEnableLimit?e.storageSkip||0:void 0},getStorageFetchTotalCount:function(){return!!this._internal.storageSettings.storageEnableCount},registerOutputIfNeeded:function(e){this.hasOutput(e)||this.registerOutput(e,{getter(){return this._internal.storageSettings[e]}})},setVisualFilter:function(e){this._internal.visualFilter=e,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()},setVisualSorting:function(e){this._internal.visualSorting=e,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()},setQueryParameter:function(e,t){this._internal.queryParameters[e]=t,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()},registerInputIfNeeded:function(e){if(this.hasInput(e))return;if(e.startsWith("qp-"))return this.registerInput(e,{set:this.setQueryParameter.bind(this,e.substring(3))});const t={storageFetch:this.scheduleFetch.bind(this)};if(t[e])return this.registerInput(e,{set:(0,re.i)({valueChangedToTrue:t[e]})});const n={collectionName:this.setCollectionName.bind(this),visualFilter:this.setVisualFilter.bind(this),visualSort:this.setVisualSorting.bind(this)};if(n[e])return this.registerInput(e,{set:n[e]});this.registerInput(e,{set(t){this._internal.storageSettings[e]=t,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()}})}}},Le="// Write your query script here, check out the reference documentation for examples\nwhere({ })\n";function Be(e,t,n,o){const i=[],s=o.getMetaData("dbCollections"),r=o.getMetaData("systemCollections");if(i.push({name:"collectionName",type:{name:"enum",enums:[{label:"User",value:"_User"},{label:"Role",value:"_Role"}].concat(void 0!==s?s.map((e=>({value:e.name,label:e.name}))):[]),allowEditOnly:!0},displayName:"Class",plug:"input",group:"General"}),i.push({name:"storageFilterType",type:{name:"enum",allowEditOnly:!0,enums:[{value:"simple",label:"Visual"},{value:"json",label:"Javascript"}]},displayName:"Filter",default:"simple",plug:"input",group:"General"}),i.push({type:{name:"boolean"},plug:"input",group:"Limit",name:"storageEnableLimit",displayName:"Use limit"}),t.storageEnableLimit&&(i.push({type:{name:"number"},default:10,plug:"input",group:"Limit",name:"storageLimit",displayName:"Limit"}),i.push({type:{name:"number"},default:0,plug:"input",group:"Limit",name:"storageSkip",displayName:"Skip"})),i.push({type:{name:"signal"},plug:"input",group:"Actions",name:"storageFetch",displayName:"Do"}),i.push({type:{name:"boolean"},plug:"input",group:"Total Count",name:"storageEnableCount",displayName:"Fetch total count"}),t.storageEnableCount&&i.push({type:{name:"number"},plug:"output",group:"General",name:"storageTotalCount",displayName:"Total Count"}),void 0===t.storageFilterType||"simple"===t.storageFilterType){if(void 0!==t.collectionName){let e=s&&s.find((e=>e.name===t.collectionName));if(void 0===e&&r&&(e=r.find((e=>e.name===t.collectionName))),e&&e.schema&&e.schema.properties){const n=JSON.parse(JSON.stringify(e.schema));null==s||s.forEach(ze.bind(null,t,n)),null==r||r.forEach(ze.bind(null,t,n)),i.push({name:"visualFilter",plug:"input",type:{name:"query-filter",schema:n,allowEditOnly:!0},displayName:"Filter",group:"Filter"}),i.push({name:"visualSort",plug:"input",type:{name:"query-sorting",schema:n,allowEditOnly:!0},displayName:"Sort",group:"Sorting"})}if(void 0!==t.visualFilter){const e={};qe(e,t.visualFilter),Object.keys(e).forEach((e=>{i.push({name:"qp-"+e,plug:"input",type:{name:"*"},displayName:e,group:"Query Parameters"})}))}}}else if("json"===t.storageFilterType){i.push({type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},plug:"input",group:"Filter",name:"storageJSONFilter",default:Le,displayName:"Filter"});let e=String(t.storageJSONFilter);if(e){e=e.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,"");const t=e.match(/\$[A-Za-z0-9]+/g);if(t){const e={};t.forEach((t=>{e[t]=!0})),Object.keys(e).forEach((e=>{i.push({name:"storageFilterValue-"+e.substring(1),displayName:e.substring(1),group:"Filter Values",plug:"input",type:{name:"*",allowConnectionsOnly:!0}})}))}Pe.parseAndAddPortsFromScript(e,i,{inputPrefix:"storageFilterValue-",inputGroup:"Filter Values",inputType:{name:"*",allowConnectionsOnly:!0},skipOutputs:!0})}}n.sendDynamicPorts(e,i)}function $e(e,t){function n(n){Be(n.id,n.parameters,e.editorConnection,t),n.on("parameterUpdated",(function(o){(o.name.startsWith("storage")||"visualFilter"===o.name||"collectionName"===o.name)&&Be(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.dbCollections",(function(){De.D.invalidateCollections(),Be(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.systemCollections",(function(){De.D.invalidateCollections(),Be(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.cloudservices",(function(){De.D.instance._initCloudServices()}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.DbCollection2",(function(e){n(e)}));for(const e of t.getNodesWithType("DbCollection2"))n(e)}))}function qe(e,t){void 0!==t&&(void 0!==t.rules?t.rules.forEach((t=>qe(e,t))):void 0!==t.input&&(e[t.input]=!0))}function ze(e,t,n){if(void 0!==n.schema&&void 0!==n.schema.properties)for(const o in n.schema.properties){const i=n.schema.properties[o];"Relation"===i.type&&i.targetClass===e.collectionName&&(void 0===t.relations&&(t.relations={}),void 0===t.relations[n.name]&&(t.relations[n.name]=[]),t.relations[n.name].push({property:o}))}}const He={name:"DbModel2",docs:"https://docs.noodl.net/nodes/data/cloud-data/record",displayNodeName:"Record",shortDesc:"Database model",category:"Cloud Services",usePortAsLabel:"collectionName",color:"data",dynamicports:[{name:"conditionalports/extended",condition:"idSource = explicit OR idSource NOT SET",inputs:["modelId"]}],initialize:function(){const e=this._internal;e.inputValues={},e.relationModelIds={};const t=this;this._internal.onModelChangedCallback=function(e){t.isInputConnected("fetch")||(t.hasOutput("prop-"+e.name)&&t.flagOutputDirty("prop-"+e.name),t.hasOutput("changed-"+e.name)&&t.sendSignalOnOutput("changed-"+e.name),t.sendSignalOnOutput("changed"))}},getInspectInfo(){const e=this._internal.model;return e?[{type:"text",value:"Id: "+e.getId()},{type:"value",value:e.data}]:"[No Record]"},outputs:{id:{type:"string",displayName:"Id",group:"General",getter:function(){return this._internal.model?this._internal.model.getId():this._internal.modelId}},fetched:{type:"signal",displayName:"Fetched",group:"Events"},changed:{type:"signal",displayName:"Changed",group:"Events"},failure:{type:"signal",displayName:"Failure",group:"Events"},error:{type:"string",displayName:"Error",group:"Error",getter:function(){return this._internal.error}}},inputs:{idSource:{type:{name:"enum",enums:[{label:"Specify explicitly",value:"explicit"},{label:"From repeater",value:"foreach"}],allowEditOnly:!0},default:"explicit",displayName:"Id Source",group:"General",set(e){"foreach"===e&&this.scheduleAfterInputsHaveUpdated((()=>{let e=this.nodeScope.componentOwner;for(;void 0!==e&&void 0===e._forEachModel&&e.parentNodeScope;)e=e.parentNodeScope.componentOwner;this.setModel(void 0!==e?e._forEachModel:void 0)}))}},modelId:{type:{name:"string",allowConnectionsOnly:!0},displayName:"Id",group:"General",set(e){e instanceof ce.K?e=e.getId():"object"==typeof e&&(e=ce.K.create(e).getId()),this._internal.modelId=e,!1===this.isInputConnected("fetch")?this.setModelID(e):this.flagOutputDirty("id")}},fetch:{displayName:"Fetch",group:"Actions",valueChangedToTrue(){this.scheduleFetch()}}},methods:{setCollectionID(e){this._internal.collectionId=e},setModelID(e){const t=(this.nodeScope.modelScope||ce.K).get(e);this.setModel(t)},setModel(e){this._internal.model&&this._internal.model.off("change",this._internal.onModelChangedCallback),this._internal.model=e,this.flagOutputDirty("id"),e.on("change",this._internal.onModelChangedCallback);for(const t in e.data)this.hasOutput("prop-"+t)&&this.flagOutputDirty("prop-"+t);this.sendSignalOnOutput("fetched")},_onNodeDeleted(){Node.prototype._onNodeDeleted.call(this),this._internal.model&&this._internal.model.off("change",this._internal.onModelChangedCallback)},scheduleOnce(e,t){const n=this,o="hasScheduled"+e;this._internal[o]||(this._internal[o]=!0,this.scheduleAfterInputsHaveUpdated((function(){n._internal[o]=!1,t()})))},setError(e){this._internal.error=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure"),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"storage-op-warning",{message:e,showGlobally:!0})},clearWarnings(){this.context.editorConnection&&this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"storage-op-warning")},scheduleFetch(){const e=this,t=this._internal;this.scheduleOnce("Fetch",(function(){if(void 0===t.modelId||""===t.modelId)return void e.setError("Missing Id.");const n=De.D.forScope(e.nodeScope.modelScope);n.fetch({collection:t.collectionId,objectId:t.modelId,success:function(o){const i=n._fromJSON(o,t.collectionId);t.model!==i&&(t.model&&t.model.off("change",t.onModelChangedCallback),t.model=i,i.on("change",t.onModelChangedCallback)),e.flagOutputDirty("id"),delete o.objectId;for(const t in o)e.hasOutput("prop-"+t)&&e.flagOutputDirty("prop-"+t);e.sendSignalOnOutput("fetched")},error:function(t){e.setError(t||"Failed to fetch.")}})}))},scheduleStore:function(){const e=this._internal;e.model&&this.scheduleOnce("Store",(function(){for(const t in e.inputValues)e.model.set(t,e.inputValues[t],{resolve:!0})}))},registerOutputIfNeeded:function(e){this.hasOutput(e)||e.startsWith("prop-")&&this.registerOutput(e,{getter:Ge.bind(this,e.substring(5))})},registerInputIfNeeded:function(e){if(this.hasInput(e))return;const t={};if(t[e])return this.registerInput(e,{set:(0,re.i)({valueChangedToTrue:t[e]})});const n={collectionName:this.setCollectionID.bind(this)};if(n[e])return this.registerInput(e,{set:n[e]});e.startsWith("prop-")&&this.registerInput(e,{set:Xe.bind(this,e.substring(5))})}}};function Ge(e){return this._internal.model?this._internal.model.get(e,{resolve:!0}):void 0}function Xe(e,t){this._internal.inputValues[e]=t}function Ye(e,t,n,o){const i=[],s=o.getMetaData("dbCollections"),r=o.getMetaData("systemCollections");if(i.push({name:"collectionName",displayName:"Class",group:"General",type:{name:"enum",enums:[{label:"User",value:"_User"},{label:"Role",value:"_Role"}].concat(void 0!==s?s.map((e=>({value:e.name,label:e.name}))):[]),allowEditOnly:!0},plug:"input"}),t.collectionName&&s){let e=s.find((e=>e.name===t.collectionName));if(void 0===e&&r&&(e=r.find((e=>e.name===t.collectionName))),e&&e.schema&&e.schema.properties){const t=e.schema.properties;for(const e in t){const n=t[e];if(!i.find((t=>t.name===e))&&"Relation"!==n.type){const t={String:"string",Boolean:"boolean",Number:"number",Date:"date"};i.push({type:{name:t[n.type]?t[n.type]:"*"},plug:"output",group:"Properties",name:"prop-"+e,displayName:e}),i.push({type:"signal",plug:"output",group:"Changed Events",displayName:e+" Changed",name:"changed-"+e})}}}}n.sendDynamicPorts(e,i)}function Je(e,t){function n(n){Ye(n.id,n.parameters,e.editorConnection,t),n.on("parameterUpdated",(function(){Ye(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.dbCollections",(function(){De.D.invalidateCollections(),Ye(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.systemCollections",(function(){De.D.invalidateCollections(),Ye(n.id,n.parameters,e.editorConnection,t)}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.DbModel2",(function(e){n(e)}));for(const e of t.getNodesWithType("DbModel2"))n(e)}))}function Ke(e,t){const n=void 0===t||t.includeInputProperties,o=void 0!==t&&t.includeRelations;Object.assign(e.node,{category:"Data",color:"data",inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),Object.assign(e.node.outputs,{failure:{type:"signal",displayName:"Failure",group:"Events"},error:{type:"string",displayName:"Error",group:"Error",getter:function(){return this._internal.error}}}),Object.assign(e.node.methods,{scheduleOnce:function(e,t){const n=this,o="hasScheduled"+e;this._internal[o]||(this._internal[o]=!0,this.scheduleAfterInputsHaveUpdated((function(){n._internal[o]=!1,t()})))},checkWarningsBeforeCloudOp(){return this.clearWarnings(),!!this._internal.collectionId||(this.setError("No class name specified"),!1)},setError:function(e){this._internal.error=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure"),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"storage-op-warning",{message:e,showGlobally:!0})},clearWarnings(){this.context.editorConnection&&this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"storage-op-warning")}}),Object.assign(e,{setup:function(t,i){function s(s){function r(){var r;const a=[],l=i.getMetaData("dbCollections"),d=i.getMetaData("systemCollections"),u=s.parameters;if(a.push({name:"collectionName",displayName:"Class",group:"General",type:{name:"enum",enums:[{label:"User",value:"_User"},{label:"Role",value:"_Role"}].concat(void 0!==l?l.map((e=>({value:e.name,label:e.name}))):[]),allowEditOnly:!0},plug:"input"}),o&&u.collectionName&&l){let e=l.find((e=>e.name===u.collectionName));if(void 0===e&&d&&(e=d.find((e=>e.name===u.collectionName))),e&&e.schema&&e.schema.properties){const t=e.schema.properties,n=Object.keys(t).filter((e=>"Relation"===t[e].type)).map((e=>({label:e,value:e})));a.push({name:"relationProperty",displayName:"Relation",group:"General",type:{name:"enum",enums:n,allowEditOnly:!0},plug:"input"})}}if(n&&u.collectionName&&l){const e={String:"string",Boolean:"boolean",Number:"number",Date:"date"};let t=l.find((e=>e.name===u.collectionName));if(void 0===t&&d&&(t=d.find((e=>e.name===u.collectionName))),t&&t.schema&&t.schema.properties){const n=t.schema.properties;for(const t in n){const o=n[t];a.find((e=>e.name===t))||a.push({type:{name:e[o.type]?e[o.type]:"*"},plug:"input",group:"Properties",name:"prop-"+t,displayName:t})}}}null===(r=e._additionalDynamicPorts)||void 0===r||r.call(e,s,a,i),t.editorConnection.sendDynamicPorts(s.id,a)}r(),s.on("parameterUpdated",(function(){r()})),i.on("metadataChanged.dbCollections",(function(){De.D.invalidateCollections(),r()})),i.on("metadataChanged.systemCollections",(function(){De.D.invalidateCollections(),r()}))}t.editorConnection&&t.editorConnection.isRunningLocally()&&i.on("editorImportComplete",(()=>{i.on("nodeAdded."+e.node.name,(function(e){s(e)}));for(const t of i.getNodesWithType(e.node.name))s(t)}))}})}function Qe(e,t){const n=Object.assign({},e.node.methods),o=void 0===t||t.includeInputs,i=void 0===t||t.includeOutputs;Object.assign(e.node,{inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),o&&(Object.assign(e.node,{usePortAsLabel:"collectionName"}),e.node.dynamicports=(e.node.dynamicports||[]).concat([{name:"conditionalports/extended",condition:"idSource = explicit OR idSource NOT SET",inputs:["modelId"]}]),Object.assign(e.node.inputs,{idSource:{type:{name:"enum",enums:[{label:"Specify explicitly",value:"explicit"},{label:"From repeater",value:"foreach"}],allowEditOnly:!0},default:"explicit",displayName:"Id Source",group:"General",tooltip:"Choose if you want to specify the Id explicitly, \n or if you want it to be that of the current record in a repeater.",set:function(e){"foreach"===e&&this.scheduleAfterInputsHaveUpdated((()=>{let e=this.nodeScope.componentOwner;for(;void 0!==e&&void 0===e._forEachModel&&e.parentNodeScope;)e=e.parentNodeScope.componentOwner;this.setModel(void 0!==e?e._forEachModel:void 0)}))}},modelId:{type:{name:"string",identifierOf:"ModelName",identifierDisplayName:"Object Ids"},displayName:"Id",group:"General",set:function(e){e instanceof ce.K&&(e=e.getId()),this._internal.modelId=e,this.setModelID(e)}}})),i&&Object.assign(e.node.outputs,{id:{type:"string",displayName:"Id",group:"General",getter:function(){return this._internal.model?this._internal.model.getId():this._internal.modelId}}}),Object.assign(e.node.methods,{setCollectionID:function(e){this._internal.collectionId=e,this.clearWarnings()},setModelID:function(e){const t=(this.nodeScope.modelScope||ce.K).get(e);this.setModel(t)},setModel:function(e){this._internal.model=e,this.flagOutputDirty("id")},registerInputIfNeeded:function(e){this.hasInput(e)||("collectionName"===e&&this.registerInput(e,{set:this.setCollectionID.bind(this)}),n&&n.registerInputIfNeeded&&n.registerInputIfNeeded.call(this,e))}})}function Ze(e){const t={node:Object.assign({},e.node),setup:e.setup},n=Object.assign({},e.node.methods);Object.assign(e.node,{inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),Object.assign(e.node,{initialize:function(){this._internal.inputValues={},t.node.initialize&&t.node.initialize.call(this)}}),Object.assign(e.node.outputs,{}),Object.assign(e.node.inputs,{}),Object.assign(e.node.methods,{registerInputIfNeeded:function(e){this.hasInput(e)||(e.startsWith("prop-")&&this.registerInput(e,{set:this._setInputValue.bind(this,e.substring(5))}),n&&n.registerInputIfNeeded&&n.registerInputIfNeeded.call(this,e))},_setInputValue:function(e,t){this._internal.inputValues[e]=t}})}function et(e){const t=Object.assign({},e.node.methods);Object.assign(e.node,{inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),Object.assign(e.node.inputs,{targetId:{type:{name:"string",allowConnectionsOnly:!0},displayName:"Target Record Id",group:"General",set:function(e){this._internal.targetModelId=e}}}),Object.assign(e.node.methods,{registerInputIfNeeded:function(e){this.hasInput(e)||("relationProperty"===e&&this.registerInput(e,{set:this.setRelationProperty.bind(this)}),t&&t.registerInputIfNeeded&&t.registerInputIfNeeded.call(this,e))},setRelationProperty:function(e){this._internal.relationProperty=e}})}function tt(e){const t={node:Object.assign({},e.node),setup:e.setup},n=Object.assign({},e.node.methods);Object.assign(e.node,{inputs:e.node.inputs||{},outputs:e.node.outputs||{},methods:e.node.methods||{}}),Object.assign(e.node,{initialize(){this._internal.accessControl={},t.node.initialize&&t.node.initialize.call(this)}}),Object.assign(e.node.inputs,{accessControl:{type:{name:"proplist",autoName:"Rule",allowEditOnly:!0},index:1e3,displayName:"Access Control Rules",group:"Access Control Rules",set(e){this._internal.accessControlRules=e}}});const o=e._additionalDynamicPorts;e._additionalDynamicPorts=function(e,t,n){void 0!==e.parameters.accessControl&&e.parameters.accessControl.length>0&&e.parameters.accessControl.forEach((n=>{const o="acl-"+n.id;t.push({name:o+"-target",displayName:"Target",editorName:n.label+" | Target",plug:"input",type:{name:"enum",enums:[{value:"user",label:"User"},{value:"everyone",label:"Everyone"},{value:"role",label:"Role"}],allowEditOnly:!0},group:n.label+" Access Rule",default:"user",parent:"accessControl",parentItemId:n.id}),"role"===e.parameters[o+"-target"]?t.push({name:o+"-role",displayName:"Role",editorName:n.label+" | Role",group:n.label+" Access Rule",plug:"input",type:"string",parent:"accessControl",parentItemId:n.id}):void 0!==e.parameters[o+"-target"]&&"user"!==e.parameters[o+"-target"]||t.push({name:o+"-userid",displayName:"User Id",group:n.label+" Access Rule",editorName:n.label+" | User Id",plug:"input",type:{name:"string",allowConnectionsOnly:!0},parent:"accessControl",parentItemId:n.id}),t.push({name:o+"-read",displayName:"Read",editorName:n.label+" | Read",group:n.label+" Access Rule",plug:"input",type:{name:"boolean"},default:!0,parent:"accessControl",parentItemId:n.id}),t.push({name:o+"-write",displayName:"Write",editorName:n.label+" | Write",group:n.label+" Access Rule",plug:"input",type:{name:"boolean"},default:!0,parent:"accessControl",parentItemId:n.id})})),o&&o(e,t,n)},Object.assign(e.node.methods,{registerInputIfNeeded:function(e){this.hasInput(e)||(e.startsWith("acl-")&&this.registerInput(e,{set:this.setAccessControl.bind(this,e)}),n&&n.registerInputIfNeeded&&n.registerInputIfNeeded.call(this,e))},_getACL:function(){let e={};function t(e){return{read:void 0===e.read||e.read,write:void 0===e.write||e.write}}const n=function(e){if("undefined"!=typeof _noodl_cloud_runtime_version)return e.get("Request").UserId;{const e=localStorage["Parse/"+De.D.instance.appId+"/currentUser"];if(void 0!==e){let t;try{t=JSON.parse(e)}catch(e){}return void 0!==t?t.objectId:void 0}}}(this.nodeScope.modelScope);return void 0!==this._internal.accessControlRules&&this._internal.accessControlRules.forEach((o=>{const i=this._internal.accessControl[o.id];if(void 0===i)void 0!==n&&(e[n]={write:!0,read:!0});else if("everyone"===i.target)e["*"]=t(i);else if("user"===i.target){const o=i.userid||n;e[o]=t(i)}else"role"===i.target&&(e["role:"+i.role]=t(i))})),Object.keys(e).length>0?e:void 0},setAccessControl:function(e,t){const n=e.split("-");void 0===this._internal.accessControl[n[1]]&&(this._internal.accessControl[n[1]]={}),this._internal.accessControl[n[1]][n[2]]=t}})}const nt={node:{name:"SetDbModelProperties",category:"",docs:"https://docs.noodl.net/nodes/data/cloud-data/set-record-properties",displayNodeName:"Set Record Properties",usePortAsLabel:"collectionName",dynamicports:[{name:"conditionalports/extended",condition:"storeType = cloud OR storeType NOT SET",inputs:["storeProperties"]}],inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue(){void 0===this._internal.storeType||"cloud"===this._internal.storeType?this.scheduleSave():this.scheduleStore()}},storeProperties:{displayName:"Properties to store",group:"General",type:{name:"enum",enums:[{label:"Only specified",value:"specified"},{label:"All",value:"all"}]},default:"specified",set:function(e){this._internal.storeProperties=e}},storeType:{displayName:"Store to",group:"General",type:{name:"enum",enums:[{label:"Cloud and local",value:"cloud"},{label:"Local only",value:"local"}]},default:"cloud",set:function(e){this._internal.storeType=e}}},outputs:{stored:{type:"signal",displayName:"Success",group:"Events"}},methods:{scheduleSave(){const e=this,t=this._internal;this.checkWarningsBeforeCloudOp()&&this.scheduleOnce("StorageSave",(function(){if(!t.model)return void e.setError("Missing Record Id");const n=t.model;for(const e in t.inputValues)n.set(e,t.inputValues[e],{resolve:!0});De.D.forScope(e.nodeScope.modelScope).save({collection:t.collectionId,objectId:n.getId(),data:"all"===t.storeProperties?n.data:t.inputValues,acl:e._getACL(),success:function(t){for(const e in t)n.set(e,t[e]);e.sendSignalOnOutput("stored")},error:function(t){e.setError(t||"Failed to save.")}})}))},scheduleStore(){if(this.hasScheduledStore)return;this.hasScheduledStore=!0;const e=this._internal;this.scheduleAfterInputsHaveUpdated((()=>{if(this.hasScheduledStore=!1,e.model){for(const t in e.inputValues)e.model.set(t,e.inputValues[t],{resolve:!0});this.sendSignalOnOutput("stored")}}))}}}};Ke(nt),Qe(nt),Ze(nt),tt(nt);const ot=nt.node,it={node:{name:"DeleteDbModelProperties",category:"",docs:"https://docs.noodl.net/nodes/data/cloud-data/delete-record",displayNodeName:"Delete Record",shortDesc:"Stores any amount of properties and can be used standalone or together with Collections and For Each nodes.",inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue(){this.storageDelete()}}},outputs:{deleted:{type:"signal",displayName:"Success",group:"Events"}},methods:{storageDelete(){const e=this._internal;this.checkWarningsBeforeCloudOp()&&this.scheduleOnce("StorageDelete",(()=>{e.model?De.D.forScope(this.nodeScope.ModelScope).delete({collection:e.collectionId,objectId:e.model.getId(),success:()=>{e.model.notify("delete"),this.sendSignalOnOutput("deleted")},error:e=>{this.setError(e||"Failed to delete.")}}):this.setError("Missing Record Id")}))}}}};Ke(it,{includeInputProperties:!1}),Qe(it);const st=it.node,rt={node:{name:"NewDbModelProperties",category:"",docs:"https://docs.noodl.net/nodes/data/cloud-data/create-new-record",displayName:"Create New Record",usePortAsLabel:"collectionName",inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue(){this.storageInsert()}},sourceObjectId:{type:{name:"string",allowConnectionsOnly:!0},displayName:"Source Object Id",group:"General",set(e){e instanceof ce.K&&(e=e.getId()),this._internal.sourceObjectId=e}}},outputs:{created:{type:"signal",displayName:"Success",group:"Events"}},methods:{storageInsert(){const e=this._internal;this.checkWarningsBeforeCloudOp()&&this.scheduleOnce("StorageInsert",(()=>{const t=Object.assign({},e.sourceObjectId?(this.nodeScope.modelScope||ce.K).get(e.sourceObjectId).data:{},e.inputValues),n=De.D.forScope(this.nodeScope.modelScope);n.create({collection:e.collectionId,data:t,acl:this._getACL(),success:t=>{const o=n._fromJSON(t,e.collectionId);this.setModel(o),this.sendSignalOnOutput("created")},error:e=>{this.setError(e||"Failed to insert.")}})}))}}}};Ke(rt),Qe(rt,{includeOutputs:!0}),Ze(rt),tt(rt);const at=rt.node,lt={node:{name:"AddDbModelRelation",category:"Data",docs:"https://docs.noodl.net/nodes/data/cloud-data/add-record-relation",displayNodeName:"Add Record Relation",usePortAsLabel:"collectionName",inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue(){this.scheduleAddRelation()}}},outputs:{relationAdded:{type:"signal",displayName:"Success",group:"Events"}},methods:{validateInputs(){if(!this.context.editorConnection)return;const e=e=>{this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"add-relation",{message:e})};void 0===this._internal.collectionId?e("No class specified"):void 0===this._internal.relationProperty?e("No relation property specified"):void 0===this._internal.targetModelId?e("No target record Id (the record to add a relation to) specified"):void 0===this._internal.model?e("No record Id specified (the record that should get the relation)"):this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"add-relation")},scheduleAddRelation(){const e=this,t=this._internal;this.scheduleOnce("StorageAddRelation",(function(){if(e.validateInputs(),!t.model)return;const n=t.model,o=t.targetModelId;void 0!==o&&De.D.forScope(e.nodeScope.modelScope).addRelation({collection:t.collectionId,objectId:n.getId(),key:t.relationProperty,targetObjectId:o,targetClass:(e.nodeScope.modelScope||ce.K).get(o)._class,success:function(t){for(const e in t)n.set(e,t[e]);e.sendSignalOnOutput("relationAdded")},error:function(t){e.setError(t||"Failed to add relation.")}})}))}}}};Ke(lt,{includeRelations:!0}),Qe(lt),et(lt);const dt=lt.node,ut={node:{name:"RemoveDbModelRelation",category:"",docs:"https://docs.noodl.net/nodes/data/cloud-data/remove-record-relation",displayName:"Remove Record Relation",usePortAsLabel:"collectionName",inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue(){this.scheduleRemoveRelation()}}},outputs:{relationRemoved:{type:"signal",displayName:"Success",group:"Events"}},methods:{validateInputs(){if(!this.context.editorConnection)return;const e=e=>{this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"add-relation",{message:e})};void 0===this._internal.collectionId?e("No class specified"):void 0===this._internal.relationProperty?e("No relation property specified"):void 0===this._internal.targetModelId?e("No target record Id (the record to add a relation to) specified"):void 0===this._internal.model?e("No record Id specified (the record that should get the relation)"):this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"add-relation")},scheduleRemoveRelation(){const e=this,t=this._internal;this.scheduleOnce("StorageRemoveRelation",(function(){if(e.validateInputs(),!t.model)return;const n=t.model,o=t.targetModelId;void 0!==o&&De.D.forScope(e.nodeScope.modelScope).removeRelation({collection:t.collectionId,objectId:n.getId(),key:t.relationProperty,targetObjectId:o,targetClass:(e.nodeScope.modelScope||ce.K).get(o)._class,success:function(t){for(const e in t)n.set(e,t[e]);e.sendSignalOnOutput("relationRemoved")},error:function(t){e.setError(t||"Failed to remove relation.")}})}))}}}};Ke(ut,{includeRelations:!0}),Qe(ut),et(ut);const ct=ut.node,pt={name:"FilterDBModels",docs:"https://docs.noodl.net/nodes/data/cloud-data/filter-records",displayNodeName:"Filter Records",shortDesc:"Filter, sort and limit array",category:"Data",color:"data",initialize(){const e=this;this._internal.collectionChangedCallback=function(){!0!==e.isInputConnected("filter")&&e.scheduleFilter()},this._internal.cloudStoreEvents=function(t){!0!==e.isInputConnected("filter")&&void 0!==e._internal.visualFilter&&void 0!==e._internal.collection&&t.collection===e._internal.collectionName&&void 0!==t.objectId&&e._internal.collection.contains(ce.K.get(t.objectId))&&e.scheduleFilter()},De.D.instance.on("save",this._internal.cloudStoreEvents),this._internal.enabled=!0,this._internal.filterSettings={},this._internal.filterParameters={}},getInspectInfo(){const e=this._internal.filteredCollection;return e?[{type:"text",value:"Id: "+e.getId()},{type:"value",value:e.items}]:{type:"text",value:"[Not executed yet]"}},inputs:{items:{type:"array",displayName:"Items",group:"General",set(e){this.bindCollection(e),!1===this.isInputConnected("filter")&&this.scheduleFilter()}},enabled:{type:"boolean",group:"General",displayName:"Enabled",default:!0,set(e){this._internal.enabled=e,!1===this.isInputConnected("filter")&&this.scheduleFilter()}},filter:{type:"signal",group:"Actions",displayName:"Filter",valueChangedToTrue(){this.scheduleFilter()}}},outputs:{items:{type:"array",displayName:"Items",group:"General",getter(){return this._internal.filteredCollection}},firstItemId:{type:"string",displayName:"First Record Id",group:"General",getter(){if(void 0!==this._internal.filteredCollection){const e=this._internal.filteredCollection.get(0);if(void 0!==e)return e.getId()}}},count:{type:"number",displayName:"Count",group:"General",getter(){return this._internal.filteredCollection?this._internal.filteredCollection.size():0}},modified:{group:"Events",type:"signal",displayName:"Filtered"}},prototypeExtensions:{unbindCurrentCollection(){const e=this._internal.collection;e&&(e.off("change",this._internal.collectionChangedCallback),this._internal.collection=void 0)},bindCollection(e){this.unbindCurrentCollection(),this._internal.collection=e,e&&e.on("change",this._internal.collectionChangedCallback)},_onNodeDeleted(){Node.prototype._onNodeDeleted.call(this),this.unbindCurrentCollection(),De.D.instance.off("save",this._internal.cloudStoreEvents)},getLimit(){const e=this._internal.filterSettings;return e.filterEnableLimit?e.filterLimit||10:void 0},getSkip(){const e=this._internal.filterSettings;return e.filterEnableLimit?e.filterSkip||0:void 0},scheduleFilter(){this.collectionChangedScheduled||(this.collectionChangedScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{if(this.collectionChangedScheduled=!1,!this._internal.collection)return;let e=[].concat(this._internal.collection.items);if(this._internal.enabled){const t=this._internal.visualFilter;if(void 0!==t){const n=Re(t,{queryParameters:this._internal.filterParameters,collectionName:this._internal.collectionName});n&&(e=e.filter((e=>Me(e,n))))}const n=this._internal.visualSorting;if(void 0!==n&&n.length>0){const t=je(n);t&&e.sort(Ve.bind(this,t))}const o=this.getSkip();o&&(e=e.slice(o,e.length));const i=this.getLimit();i&&(e=e.slice(0,i))}this._internal.filteredCollection=ke.p.create(e),this.sendSignalOnOutput("modified"),this.flagOutputDirty("firstItemId"),this.flagOutputDirty("items"),this.flagOutputDirty("count")})))},setCollectionName(e){this._internal.collectionName=e},setVisualFilter(e){this._internal.visualFilter=e,!1===this.isInputConnected("filter")&&this.scheduleFilter()},setVisualSorting(e){this._internal.visualSorting=e,!1===this.isInputConnected("filter")&&this.scheduleFilter()},setFilterParameter:function(e,t){this._internal.filterParameters[e]=t,!1===this.isInputConnected("filter")&&this.scheduleFilter()},registerInputIfNeeded(e){if(!this.hasInput(e))return"collectionName"===e?this.registerInput(e,{set:this.setCollectionName.bind(this)}):"visualFilter"===e?this.registerInput(e,{set:this.setVisualFilter.bind(this)}):"visualSorting"===e?this.registerInput(e,{set:this.setVisualSorting.bind(this)}):e.startsWith("fp-")?this.registerInput(e,{set:this.setFilterParameter.bind(this,e.substring(3))}):void this.registerInput(e,{set(t){this._internal.filterSettings[e]=t,!1===this.isInputConnected("filter")&&this.scheduleFilter()}})}}};function ht(e,t,n,o){const i=[];if(i.push({name:"collectionName",type:{name:"enum",enums:void 0!==o?o.map((e=>({value:e.name,label:e.name}))):[],allowEditOnly:!0},displayName:"Class",plug:"input",group:"General"}),i.push({type:"boolean",plug:"input",group:"Limit",name:"filterEnableLimit",displayName:"Use limit"}),t.filterEnableLimit&&(i.push({type:"number",default:10,plug:"input",group:"Limit",name:"filterLimit",displayName:"Limit"}),i.push({type:"number",default:0,plug:"input",group:"Limit",name:"filterSkip",displayName:"Skip"})),void 0!==t.collectionName){const e=o.find((e=>e.name===t.collectionName));if(e&&e.schema&&e.schema.properties){const t=JSON.parse(JSON.stringify(e.schema)),n={Boolean:!0,String:!0,Date:!0,Number:!0,Pointer:!0};for(const e in t.properties)n[t.properties[e].type]||delete t.properties[e];i.push({name:"visualFilter",plug:"input",type:{name:"query-filter",schema:t,allowEditOnly:!0},displayName:"Filter",group:"Filter"}),i.push({name:"visualSorting",plug:"input",type:{name:"query-sorting",schema:t,allowEditOnly:!0},displayName:"Sorting",group:"Sorting"})}if(void 0!==t.visualFilter){const e={};gt(e,t.visualFilter),Object.keys(e).forEach((e=>{i.push({name:"fp-"+e,plug:"input",type:"*",displayName:e,group:"Filter Parameters"})}))}}n.sendDynamicPorts(e,i)}function mt(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("nodeAdded.FilterDBModels",(function(n){ht(n.id,n.parameters,e.editorConnection,t.getMetaData("dbCollections")),n.on("parameterUpdated",(function(){ht(n.id,n.parameters,e.editorConnection,t.getMetaData("dbCollections"))})),t.on("metadataChanged.dbCollections",(function(t){De.D.invalidateCollections(),ht(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.systemCollections",(function(t){De.D.invalidateCollections(),ht(n.id,n.parameters,e.editorConnection,t)}))}))}function gt(e,t){void 0!==t&&(void 0!==t.rules?t.rules.forEach((t=>gt(e,t))):void 0!==t.input&&(e[t.input]=!0))}const ft={name:"Model2",docs:"https://docs.noodl.net/nodes/data/object/object-node",displayNodeName:"Object",shortDesc:"Stores any amount of properties and can be used standalone or together with Collections and For Each nodes.",category:"Data",usePortAsLabel:"modelId",color:"data",dynamicports:[{name:"conditionalports/extended",condition:"idSource = explicit OR idSource NOT SET",inputs:["modelId"]}],initialize(){const e=this._internal;e.inputValues={},e.dirtyValues={},e.onModelChangedCallback=e=>{!0!==this.isInputConnected("fetch")&&(this.hasOutput("prop-"+e.name)&&this.flagOutputDirty("prop-"+e.name),this.hasOutput("changed-"+e.name)&&this.sendSignalOnOutput("changed-"+e.name),this.sendSignalOnOutput("changed"))}},getInspectInfo(){const e=this._internal.model;return e?[{type:"text",value:"Id: "+e.getId()},{type:"value",value:e.data}]:"[No Object]"},outputs:{id:{type:"string",displayName:"Id",group:"General",getter(){return this._internal.model?this._internal.model.getId():this._internal.modelId}},changed:{type:"signal",displayName:"Changed",group:"Events"},fetched:{type:"signal",displayName:"Fetched",group:"Events"}},inputs:{idSource:{type:{name:"enum",enums:[{label:"Specify explicitly",value:"explicit"},{label:"From repeater",value:"foreach"}],allowEditOnly:!0},default:"explicit",displayName:"Get Id from",group:"General",set(e){"foreach"===e&&this.scheduleAfterInputsHaveUpdated((()=>{let e=this.nodeScope.componentOwner;for(;void 0!==e&&void 0===e._forEachModel&&e.parentNodeScope;)e=e.parentNodeScope.componentOwner;this.setModel(void 0!==e?e._forEachModel:void 0)}))}},modelId:{type:{name:"string",identifierOf:"ModelName",identifierDisplayName:"Object Ids"},displayName:"Id",group:"General",set(e){e instanceof ce.K?e=e.getId():"object"==typeof e&&(e=ce.K.create(e).getId()),this._internal.modelId=e,!1===this.isInputConnected("fetch")?this.setModelID(e):this.flagOutputDirty("id")}},properties:{type:{name:"stringlist",allowEditOnly:!0},displayName:"Properties",group:"Properties",set(e){}},fetch:{displayName:"Fetch",group:"Actions",valueChangedToTrue(){this.scheduleSetModel()}}},prototypeExtensions:{scheduleStore(){if(this.hasScheduledStore)return;this.hasScheduledStore=!0;const e=this._internal;this.scheduleAfterInputsHaveUpdated((()=>{if(this.hasScheduledStore=!1,e.model){for(const t in e.dirtyValues)e.model.set(t,e.inputValues[t],{resolve:!0});e.dirtyValues={}}}))},scheduleSetModel(){this.hasScheduledSetModel||(this.hasScheduledSetModel=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.hasScheduledSetModel=!1,this.setModelID(this._internal.modelId)})))},setModelID(e){const t=(this.nodeScope.modelScope||ce.K).get(e);this.setModel(t),this.sendSignalOnOutput("fetched")},setModel(e){if(this._internal.model&&this._internal.model.off("change",this._internal.onModelChangedCallback),this._internal.model=e,this.flagOutputDirty("id"),e){e.on("change",this._internal.onModelChangedCallback);for(const t in e.data)this.hasOutput("prop-"+t)&&this.flagOutputDirty("prop-"+t)}},_onNodeDeleted(){this._internal.model&&this._internal.model.off("change",this._internal.onModelChangedCallback)},registerOutputIfNeeded(e){this.hasOutput(e)||e.startsWith("prop-")&&this.registerOutput(e,{getter:yt.bind(this,e.substring(5))})},registerInputIfNeeded(e){this.hasInput(e)||e.startsWith("prop-")&&this.registerInput(e,{set:vt.bind(this,e.substring(5))})}}};function yt(e){return this._internal.model?this._internal.model.get(e,{resolve:!0}):void 0}function vt(e,t){this._internal.inputValues[e]=t;const n=this._internal.model;(!n||n.get(e)!==t)&&(this._internal.dirtyValues[e]=!0,this.scheduleStore())}function bt(e,t,n){const o=[],i=t.properties;if(i){const e=i?i.split(","):void 0;if(e)for(const t of e)o.push({type:{name:"*",allowConnectionsOnly:!0},plug:"input/output",group:"Properties",name:"prop-"+t,displayName:t}),o.push({type:"signal",plug:"output",group:"Changed Events",displayName:t+" Changed",name:"changed-"+t})}n.sendDynamicPorts(e,o,{detectRenamed:{plug:"input/output"}})}function _t(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("nodeAdded.Model2",(function(t){bt(t.id,t.parameters,e.editorConnection),t.on("parameterUpdated",(function(){bt(t.id,t.parameters,e.editorConnection)}))}))}var St=n(4281);const Ct={node:{name:"SetModelProperties",category:"",docs:"https://docs.noodl.net/nodes/data/object/set-object-properties",displayNodeName:"Set Object Properties",inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue:function(){this.scheduleStore()}}},outputs:{stored:{type:"signal",displayName:"Done",group:"Events"}}}};St.BO(Ct),St.Gs(Ct),St.D3(Ct);const Nt=Ct.node,Ot={node:{name:"NewModel",category:"",docs:"https://docs.noodl.net/nodes/data/object/create-new-object",displayNodeName:"Create New Object",inputs:{new:{displayName:"Do",group:"Actions",valueChangedToTrue(){this.scheduleNew()}}},outputs:{created:{type:"signal",displayName:"Done",group:"Events"}},methods:{scheduleNew(){this.hasScheduledNew||(this.hasScheduledNew=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.hasScheduledNew=!1;const e=(this.nodeScope.modelScope||ce.K).get();this._pushInputValues(e),this.setModel(e),this.sendSignalOnOutput("created")})))}}}};St.BO(Ot),St.Gs(Ot,{includeOutputs:!0}),St.D3(Ot);const It=Ot.node;var wt=n(9678);const Pt={name:"Cloud File",docs:"https://docs.noodl.net/nodes/data/cloud-data/cloud-file",category:"Cloud Services",color:"data",getInspectInfo(){var e;return null===(e=this._internal.cloudFile)||void 0===e?void 0:e.getUrl()},outputs:{url:{type:"string",displayName:"URL",group:"General",getter(){var e;return null===(e=this._internal.cloudFile)||void 0===e?void 0:e.getUrl()}},name:{type:"string",displayName:"Name",group:"General",getter(){if(!this._internal.cloudFile)return;const e=this._internal.cloudFile.getName().split("_");return 1===e.length?e[0]:e.slice(1).join("_")}}},inputs:{file:{type:"cloudfile",displayName:"Cloud File",group:"General",set(e){e instanceof wt.A&&(this._internal.cloudFile=e,this.flagOutputDirty("name"),this.flagOutputDirty("url"))}}}};class xt{constructor(){this.cacheDuration=9e5}_makeRequest(e,t){if("undefined"==typeof _noodl_cloud_runtime_version){const n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState){let e;try{e=JSON.parse(n.response)}catch(e){}200===n.status||201===n.status?t.success(e):t.error(e||{error:n.responseText,status:n.status})}};const o=rn.instance.getMetaData("cloudservices"),i=o.appId,s=o.endpoint;n.open("GET",s+e,!0),n.setRequestHeader("X-Parse-Application-Id",i),n.send()}else{const n="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.endpoint:this.endpoint,o="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.appId:this.appId,i="undefined"!=typeof _noodl_cloudservices?_noodl_cloudservices.masterKey:void 0;fetch(n+e,{method:"GET",headers:{"X-Parse-Application-Id":o,"X-Parse-Master-Key":i}}).then((e=>{200===e.status||201===e.status?e.json().then((e=>t.success(e))).catch((e=>t.error({error:"Config: Failed to get json result."}))):e.json().then((e=>t.error(e))).catch((e=>t.error({error:"Failed to fetch."})))})).catch((e=>{t.error({error:e.message})}))}}_getConfig(){return new Promise(((e,t)=>{this._makeRequest("/config",{success:t=>{e(t.params||{})},error:e=>{t(e)}})}))}async getConfig(){return this.configCachePending?this.configCachePending:this.configCache?(this.ttl&&Date.now()>this.ttl&&this._getConfig().then((e=>{this.configCache=e,this.ttl=Date.now()+this.cacheDuration})),this.configCache):(this.configCachePending=this._getConfig(),this.configCache=await this.configCachePending,delete this.configCachePending,this.ttl=Date.now()+this.cacheDuration,this.configCache)}clearCache(){delete this.configCache}}xt.instance=new xt;const Et={name:"DbConfig",docs:"https://docs.noodl.net/nodes/data/cloud-data/config",displayNodeName:"Config",category:"Cloud Services",usePortAsLabel:"configKey",color:"data",initialize:function(){const e=this._internal;xt.instance.getConfig().then((t=>{e.config=t,this.hasOutput("value")&&this.flagOutputDirty("value")}))},getInspectInfo(){const e=this.getValue();return void 0===e?"[No Value]":[{type:"value",value:e}]},methods:{getValue:function(){const e=this._internal;return e.useDevValue&&this.context.editorConnection&&this.context.editorConnection.isRunningLocally()?e.devValue:void 0!==e.config&&void 0!==e.configKey?e.config[e.configKey]:void 0},setInternal:function(e,t){this._internal[e]=t,this.hasOutput("value")&&this.flagOutputDirty("value")},registerOutputIfNeeded:function(e){if(!this.hasOutput(e))return"value"===e?this.registerOutput(e,{getter:this.getValue.bind(this)}):void 0},registerInputIfNeeded:function(e){if(!this.hasInput(e))return"configKey"===e||"useDevValue"===e||"devValue"===e?this.registerInput(e,{set:this.setInternal.bind(this,e)}):void 0}}};function Tt(e,t){function o(o){const i=[];e.editorConnection.clearWarning(o.component.name,o.id,"dbconfig-warning");const s=t.getMetaData("dbConfigSchema");let r;if(s){const t=void 0!==n.g._noodl_cloud_runtime_version;i.push({name:"configKey",displayName:"Parameter",group:"General",type:{name:"enum",enums:Object.keys(s).filter((e=>t||!s[e].masterKeyOnly)).map((e=>({value:e,label:e}))),allowEditOnly:!0},plug:"input"}),void 0!==o.parameters.configKey&&s&&s[o.parameters.configKey]?(r=s[o.parameters.configKey].type,"string"!==r&&"boolean"!==r&&"number"!==r&&"object"!==r&&"array"!==r||(i.push({name:"useDevValue",displayName:"Enable",group:"Local Override",type:"boolean",default:!1,plug:"input"}),!0===o.parameters.useDevValue&&i.push({name:"devValue",displayName:"Value",group:"Local Override",type:r,plug:"input"}))):void 0!==o.parameters.configKey&&e.editorConnection.sendWarning(o.component.name,o.id,"dbconfig-warning",{showGlobally:!0,message:o.parameters.configKey+" config parameter is missing, add it to your cloud service."})}else e.editorConnection.sendWarning(o.component.name,o.id,"dbconfig-warning",{showGlobally:!0,message:"You need an active cloud service."});i.push({name:"value",displayName:"Value",group:"General",type:r||"*",plug:"output"}),e.editorConnection.sendDynamicPorts(o.id,i)}function i(e){o(e),e.on("parameterUpdated",(function(){o(e)})),t.on("metadataChanged.dbConfigSchema",(function(){xt.instance.clearCache(),o(e)}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.DbConfig",(function(e){i(e)}));for(const e of t.getNodesWithType("DbConfig"))i(e)}))}function At(e){return{name:e.name,docs:e.docs,shortDesc:e.shortDesc,nodeDoubleClickAction:e.nodeDoubleClickAction,category:"Variables",initialize(){this._internal.currentValue=e.startValue,this._internal.latestValue=0},getInspectInfo(){return[{type:"color"===e.type.name?"color":"text",value:this._internal.currentValue}]},inputs:{value:{type:e.type,displayName:"Value",default:e.startValue,set(e){!1===this.isInputConnected("saveValue")?this.setValueTo(e):this._internal.latestValue=e}},saveValue:{displayName:"Set",valueChangedToTrue(){this.scheduleAfterInputsHaveUpdated((function(){this.setValueTo(this._internal.latestValue),this.sendSignalOnOutput("stored")}))}}},outputs:{savedValue:{type:e.type.name,displayName:"Value",getter(){return this._internal.currentValue}},changed:{type:"signal",displayName:"Changed"},stored:{type:"signal",displayName:"Stored"}},prototypeExtensions:{setValueTo(t){t=e.cast(t);const n=this._internal.currentValue!==t;this._internal.currentValue=t,n&&(this.flagOutputDirty("savedValue"),this.sendSignalOnOutput("changed"),e.onChanged&&e.onChanged.call(this))}}}}const kt=At({name:"Number",docs:"https://docs.noodl.net/nodes/data/number",startValue:0,nodeDoubleClickAction:{focusPort:"value"},type:{name:"number"},cast:e=>Number(e)}),Dt=At({name:"String",docs:"https://docs.noodl.net/nodes/data/string",shortDesc:"Contains a string (text).",startValue:"",nodeDoubleClickAction:{focusPort:"value"},type:{name:"string"},cast:e=>String(e),onChanged:function(){this.flagOutputDirty("length")}});!function e(t,n){for(const o in n)if("initialize"===o&&t.initialize){const e=t.initialize;t.initialize=function(){e.call(this),n.initialize.call(this)}}else n[o]&&n[o].constructor===Object?t[o]=e(t[o]||{},n[o]):n[o]&&n[o].constructor===Array&&t[o]&&t[o].constructor==Array?t[o]=t[o].concat(n[o]):t[o]=n[o];return t}(Dt,{usePortAsLabel:"value",portLabelTruncationMode:"length",outputs:{length:{type:"number",displayName:"Length",getter:function(){return this._internal.currentValue.length}}}});const Rt=Dt,Mt=At({name:"Boolean",docs:"https://docs.noodl.net/nodes/data/boolean",startValue:!1,type:{name:"boolean"},cast:e=>Boolean(e)}),Vt={name:"Condition",docs:"https://docs.noodl.net/nodes/utilities/logic/condition",category:"Logic",initialize(){},getInspectInfo(){const e=this.getInputValue("condition");let t;return t=void 0===e?"[No input]":e,[{type:"value",value:t}]},inputs:{condition:{type:"boolean",displayName:"Condition",group:"General",set(e){this.isInputConnected("eval")||this.scheduleEvaluate()}},eval:{type:"signal",displayName:"Evaluate",group:"Actions",valueChangedToTrue(){this.scheduleEvaluate()}}},outputs:{ontrue:{type:"signal",displayName:"On True",group:"Events"},onfalse:{type:"signal",displayName:"On False",group:"Events"},result:{type:"boolean",displayName:"Is True",group:"Booleans",getter(){return!!this.getInputValue("condition")}},isfalse:{type:"boolean",displayName:"Is False",group:"Booleans",getter(){return!this.getInputValue("condition")}}},methods:{scheduleEvaluate(){this.scheduleAfterInputsHaveUpdated((()=>{this.flagOutputDirty("result"),this.flagOutputDirty("isfalse");const e=this.getInputValue("condition");this.sendSignalOnOutput(e?"ontrue":"onfalse")}))}}};function jt(e){return e.length>0&&!1===e.some((e=>!e))}const Ft={name:"And",docs:"https://docs.noodl.net/nodes/logic/and",category:"Logic",initialize(){this._internal={inputs:[]}},getInspectInfo(){return jt(this._internal.inputs)},numberedInputs:{input:{displayPrefix:"Input",type:"boolean",createSetter:e=>function(t){const n=!!t;if(this._internal.inputs[e]===n)return;this._internal.inputs[e]=n;const o=jt(this._internal.inputs);this._internal.result!==o&&(this._internal.result=o,this.flagOutputDirty("result"))}}},outputs:{result:{type:"boolean",displayName:"Result",get(){return this._internal.result}}}};function Ut(e){return!!e}const Wt={name:"Or",docs:"https://docs.noodl.net/nodes/logic/or",category:"Logic",initialize(){this._internal.inputs=[]},getInspectInfo(){return this._internal.inputs.some(Ut)},numberedInputs:{input:{type:"boolean",displayPrefix:"Input",createSetter:e=>function(t){this._internal.inputs[e]!==t&&(this._internal.inputs[e]=t,this.flagOutputDirty("result"))}}},outputs:{result:{type:"boolean",displayName:"Result",getter:function(){return this._internal.inputs.some(Ut)}}}},Lt={name:"Boolean To String",docs:"https://docs.noodl.net/nodes/utilities/boolean-to-string",category:"Utilities",initialize(){this._internal.inputs=[],this._internal.currentSelectedIndex=0,this._internal.indexChanged=!1,this._internal.trueString="",this._internal.falseString=""},inputs:{trueString:{displayName:"String for true",type:"string",set(e){this._internal.trueString!==e&&(this._internal.trueString=e,this._internal.currentInput&&this.flagOutputDirty("currentValue"))}},falseString:{displayName:"String for false",type:"string",set(e){this._internal.falseString!==e&&(this._internal.falseString=e,this._internal.currentInput||this.flagOutputDirty("currentValue"))}},input:{type:{name:"boolean"},displayName:"Selector",set(e){this._internal.currentInput!==e&&(this._internal.currentInput=e,this.flagOutputDirty("currentValue"),this.sendSignalOnOutput("inputChanged"))}}},outputs:{currentValue:{type:"string",displayName:"Current Value",group:"Value",getter(){return this._internal.currentInput?this._internal.trueString:this._internal.falseString}},inputChanged:{type:"signal",displayName:"Selector Changed",group:"Signals"}}},Bt={name:"Date To String",docs:"https://docs.noodl.net/nodes/utilities/date-to-string",category:"Utilities",initialize(){this._internal.formatString="{year}-{month}-{date}"},inputs:{formatString:{displayName:"Format",type:"string",default:"{year}-{month}-{date}",set(e){this._internal.formatString!==e&&(this._internal.formatString=e,void 0!==this._internal.currentInput&&(this._format(),this.flagOutputDirty("currentValue")))}},input:{type:{name:"date"},displayName:"Date",set(e){const t="string"==typeof e?new Date(e):e;this._internal.currentInput!==t&&(this._internal.currentInput=t,this._format())}}},outputs:{currentValue:{type:"string",displayName:"Date String",group:"Value",getter(){return this._internal.dateString}},inputChanged:{type:"signal",displayName:"Date Changed",group:"Signals"},onError:{type:"signal",displayName:"Invalid Date",group:"Signals"}},methods:{_format(){try{const e=this._internal.currentInput,t=this._internal.formatString,n=("0"+e.getDate()).slice(-2),o=("0"+(e.getMonth()+1)).slice(-2),i=new Intl.DateTimeFormat("en-US",{month:"short"}).format(e),s=e.getFullYear(),r=s.toString().substring(2),a=("0"+e.getHours()).slice(-2),l=("0"+e.getMinutes()).slice(-2),d=("0"+e.getSeconds()).slice(-2);this._internal.dateString=t.replace(/\{date\}/g,n).replace(/\{month\}/g,String(o)).replace(/\{monthShort\}/g,i).replace(/\{year\}/g,String(s)).replace(/\{yearShort\}/g,String(r)).replace(/\{hours\}/g,String(a)).replace(/\{minutes\}/g,String(l)).replace(/\{seconds\}/g,String(d))}catch(e){this._internal.dateString="",this.flagOutputDirty("onError")}this.flagOutputDirty("currentValue"),this.sendSignalOnOutput("inputChanged")}}},$t={name:"String Mapper",docs:"https://docs.noodl.net/nodes/string-manipulation/string-mapper",category:"Utilities",initialize(){this._internal={inputs:[],mappings:[]}},getInspectInfo(){return this._internal.mappedString},numberedInputs:{input:{type:"string",displayPrefix:"Input",group:"Inputs",index:10,createSetter:e=>function(t){t=void 0===t?"":String(t),this._internal.inputs[e]=t,this.scheduleMapping()}},output:{type:"string",displayPrefix:"Mapping",index:1001,group:"Mappings",createSetter:e=>function(t){t=void 0===t?"":String(t),this._internal.mappings[e]=t,this.scheduleMapping()}}},inputs:{inputString:{type:{name:"string"},index:1,displayName:"Input String",set(e){this._internal.currentInputString=void 0!==e?String(e):void 0,this.scheduleMapping()}},defaultMapping:{type:"string",displayName:"Default",index:1e3,group:"Mappings",set(e){this._internal.defaultMapping=e,this.scheduleMapping()}}},outputs:{mappedString:{type:"string",displayName:"Mapped String",group:"Value",getter(){return this._internal.mappedString}}},prototypeExtensions:{doMapping(){this._internal.hasScheduledFetch=!1;const e=this._internal.inputs.indexOf(this._internal.currentInputString);this._internal.mappedString=-1!==e?this._internal.mappings[e]:this._internal.defaultMapping,this.flagOutputDirty("mappedString")},scheduleMapping(){const e=this._internal;e.hasScheduledFetch||(e.hasScheduledFetch=!0,this.scheduleAfterInputsHaveUpdated(this.doMapping.bind(this)))}}};function qt(e){if(void 0!==e)return!e}const zt={name:"Inverter",docs:"https://docs.noodl.net/nodes/logic/inverter",category:"Logic",initialize(){this._internal.currentValue=void 0},getInspectInfo(){return String(qt(this._internal.currentValue))},inputs:{value:{type:{name:"boolean"},displayName:"Value",set(e){this._internal.currentValue=e,this.flagOutputDirty("result")}}},outputs:{result:{type:"boolean",displayName:"Result",getter(){return qt(this._internal.currentValue)}}}},Ht={name:"Substring",docs:"https://docs.noodl.net/nodes/string-manipulation/substring",category:"String Manipulation",initialize(){var e=this._internal;e.startIndex=0,e.endIndex=-1,e.cachedResult="",e.inputString="",e.resultDirty=!1},inputs:{start:{type:"number",displayName:"Start",default:0,set(e){this._internal.startIndex=e,this._internal.resultDirty=!0,this.flagOutputDirty("result")}},end:{type:"number",displayName:"End",default:0,set(e){this._internal.endIndex=e,this._internal.resultDirty=!0,this.flagOutputDirty("result")}},string:{type:{name:"string"},displayName:"String",default:"",set(e){const t=String(e);this._internal.inputString=t,this._internal.resultDirty=!0,this.flagOutputDirty("result")}}},outputs:{result:{type:"string",displayName:"Result",getter(){var e=this._internal;return e.resultDirty&&(-1===e.endIndex?e.cachedResult=e.inputString.substr(e.startIndex):e.cachedResult=e.inputString.substr(e.startIndex,e.endIndex-e.startIndex),e.resultDirty=!1),e.cachedResult}}}},Gt={name:"String Format",docs:"https://docs.noodl.net/nodes/string-manipulation/string-format",category:"String Manipulation",usePortAsLabel:"format",portLabelTruncationMode:"length",initialize(){const e=this._internal;e.format="",e.cachedResult="",e.resultDirty=!1,e.inputValues={}},getInspectInfo(){return this.formatValue()},inputs:{format:{type:{name:"string",multiline:!0},displayName:"Format",set(e){this._internal.format!==e&&(this._internal.format=e,this._internal.resultDirty=!0,this.scheduleFormat())}}},outputs:{formatted:{type:"string",displayName:"Formatted",get(){return this.formatValue()}}},methods:{formatValue(){const e=this._internal;if(e.resultDirty){let t=e.format;const n=e.format.match(/\{[A-Za-z0-9_]*\}/g);let o=[];n&&(o=n.map((e=>e.replace("{","").replace("}","")))),o.forEach((n=>{const o=e.inputValues[n];t=t.replace("{"+n+"}",void 0!==o?o:"")})),e.cachedResult=t,e.resultDirty=!1}return e.cachedResult},registerInputIfNeeded(e){this.hasInput(e)||this.registerInput(e,{set(t){this._internal.inputValues[e]!==t&&(this._internal.inputValues[e]=t,this._internal.resultDirty=!0,this.scheduleFormat())}})},scheduleFormat(){this.formatScheduled||(this.formatScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.formatValue(),this.flagOutputDirty("formatted"),this.formatScheduled=!1})))}}};function Xt(e,t,n){const o=(t.match(/\{[A-Za-z0-9_]*\}/g)||[]).map((e=>e.replace("{","").replace("}",""))).filter(((e,t,n)=>n.indexOf(e)===t)).map((e=>({name:e,type:"string",plug:"input"})));n.sendDynamicPorts(e,o)}function Yt(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("nodeAdded.String Format",(t=>{t.parameters.format&&Xt(t.id,t.parameters.format,e.editorConnection),t.on("parameterUpdated",(n=>{"format"===n.name&&Xt(t.id,t.parameters.format,e.editorConnection)}))}))}const Jt={name:"Counter",docs:"https://docs.noodl.net/nodes/math/counter",category:"Math",initialize(){this._internal.currentValue=0,this._internal.startValue=0,this._internal.startValueSet=!1,this._internal.limitsEnabled=!1,this._internal.limitsMin=0,this._internal.limitsMax=0},getInspectInfo(){return"Count: "+this._internal.currentValue},inputs:{increase:{group:"Actions",displayName:"Increase Count",valueChangedToTrue(){this._internal.limitsEnabled&&this._internal.currentValue>=this._internal.limitsMax||(this._internal.currentValue++,this.flagOutputDirty("currentCount"),this.sendSignalOnOutput("countChanged"))}},decrease:{group:"Actions",displayName:"Decrease Count",valueChangedToTrue(){this._internal.limitsEnabled&&this._internal.currentValue<=this._internal.limitsMin||(this._internal.currentValue--,this.flagOutputDirty("currentCount"),this.sendSignalOnOutput("countChanged"))}},reset:{group:"Actions",displayName:"Reset To Start",valueChangedToTrue(){0!==this.currentValue&&(this._internal.currentValue=this._internal.startValue,this.flagOutputDirty("currentCount"),this.sendSignalOnOutput("countChanged"))}},startValue:{type:"number",displayName:"Start Value",default:0,set(e){this._internal.startValue=Number(e),!1===this._internal.startValueSet&&(this._internal.startValueSet=!0,this._internal.currentValue=this._internal.startValue,this.flagOutputDirty("currentCount"),this.sendSignalOnOutput("countChanged"))}},limitsMin:{type:{name:"number"},displayName:"Min Value",group:"Limits",default:0,set(e){this._internal.limitsMin=Number(e)}},limitsMax:{type:{name:"number"},displayName:"Max Value",group:"Limits",default:0,set(e){this._internal.limitsMax=Number(e)}},limitsEnabled:{type:{name:"boolean"},displayName:"Limits Enabled",group:"Limits",default:!1,set(e){this._internal.limitsEnabled=!!e}}},outputs:{currentCount:{displayName:"Current Count",type:"number",getter(){return this._internal.currentValue}},countChanged:{displayName:"Count Changed",type:"signal"}}},Kt={name:"Unique Id",docs:"https://docs.noodl.net/nodes/utilities/unique-id",category:"String Manipulation",initialize(){this._internal.guid=(0,z.Os)()},getInspectInfo(){return this._internal.guid},inputs:{new:{displayName:"New",valueChangedToTrue:function(){this._internal.guid=(0,z.Os)(),this.flagOutputDirty("guid")}}},outputs:{guid:{type:"string",displayName:"Id",getter:function(){return this._internal.guid}}},prototypeExtensions:{}},Qt={name:"net.noodl.user.SetUserProperties",docs:"https://docs.noodl.net/nodes/data/user/set-user-properties",displayNodeName:"Set User Properties",category:"Cloud Services",color:"data",initialize(){this._internal.userProperties={}},outputs:{success:{type:"signal",displayName:"Success",group:"Events"},failure:{type:"signal",displayName:"Failure",group:"Events"},error:{type:"string",displayName:"Error",group:"Error",getter(){return this._internal.error}}},inputs:{store:{displayName:"Do",group:"Actions",valueChangedToTrue(){this.scheduleStore()}},email:{displayName:"Email",type:"string",group:"General",set(e){this._internal.email=e}},username:{displayName:"Username",type:"string",group:"General",set(e){this._internal.username=e}}},methods:{setError(e){this._internal.error=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure"),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"user-set-warning",{message:e,showGlobally:!0})},clearWarnings(){this.context.editorConnection&&this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"user-set-warning")},scheduleStore(){const e=this._internal;!0!==this.storeScheduled&&(this.storeScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.storeScheduled=!1,NoodlRuntime.Services.UserService.forScope(this.nodeScope.modelScope).setUserProperties({email:this._internal.email,username:this._internal.username,properties:e.userProperties,success:()=>{this.sendSignalOnOutput("success")},error:e=>{this.setError(e)}})})))},setUserProperty(e,t){this._internal.userProperties[e]=t},registerInputIfNeeded(e){if(!this.hasInput(e))return e.startsWith("prop-")?this.registerInput(e,{set:this.setUserProperty.bind(this,e.substring(5))}):void 0}}};function Zt(e,t,n,o){const i=[];if(o){const e=o.find((e=>"_User"===e.name));if(e&&e.schema&&e.schema.properties){const t=e.schema.properties,n="undefined"==typeof _noodl_cloud_runtime_version?["authData","createdAt","updatedAt","email","username","emailVerified","password"]:["authData","createdAt","updatedAt","email","username"];for(const e in t){if(-1!==n.indexOf(e))continue;const o=t[e];if(!i.find((t=>t.name===e)))if("Relation"===o.type);else{const t={String:"string",Boolean:"boolean",Number:"number",Date:"date"};i.push({type:{name:t[o.type]?t[o.type]:"*"},plug:"input",group:"Properties",name:"prop-"+e,displayName:e})}}}}n.sendDynamicPorts(e,i)}function en(e,t){function n(n){Zt(n.id,n.parameters,e.editorConnection,t.getMetaData("systemCollections")),n.on("parameterUpdated",(function(o){Zt(n.id,n.parameters,e.editorConnection,t.getMetaData("systemCollections"))})),t.on("metadataChanged.systemCollections",(function(t){Zt(n.id,n.parameters,e.editorConnection,t)}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.net.noodl.user.SetUserProperties",(function(e){n(e)}));for(const e of t.getNodesWithType("net.noodl.user.SetUserProperties"))n(e)}))}const tn={name:"net.noodl.user.User",docs:"https://docs.noodl.net/nodes/data/user/user-node",displayNodeName:"User",category:"Cloud Services",color:"data",initialize(){const e=this;this._internal.onModelChangedCallback=function(t){e.isInputConnected("fetch")||(e.hasOutput("prop-"+t.name)&&e.flagOutputDirty("prop-"+t.name),e.hasOutput("changed-"+t.name)&&e.sendSignalOnOutput("changed-"+t.name),e.sendSignalOnOutput("changed"))};const t=NoodlRuntime.Services.UserService.forScope(this.nodeScope.modelScope);this.setUserModel(t.current),t.on("loggedIn",(()=>{this.setUserModel(t.current),this.hasOutput("loggedIn")&&this.sendSignalOnOutput("loggedIn")})),t.on("sessionGained",(()=>{this.setUserModel(t.current)})),t.on("loggedOut",(()=>{this.setUserModel(void 0),this.hasOutput("loggedOut")&&this.sendSignalOnOutput("loggedOut")})),t.on("sessionLost",(()=>{this.setUserModel(void 0),this.hasOutput("sessionLost")&&this.sendSignalOnOutput("sessionLost")}))},getInspectInfo(){const e=this._internal.model;return e?[{type:"text",value:"Id: "+e.getId()},{type:"value",value:this._internal.model.data}]:"[No Model]"},outputs:{id:{type:"string",displayName:"Id",group:"General",getter(){return void 0!==this._internal.model?this._internal.model.getId():void 0}},fetched:{type:"signal",displayName:"Fetched",group:"Events"},changed:{type:"signal",displayName:"Changed",group:"Events"},failure:{type:"signal",displayName:"Failure",group:"Events"},error:{type:"string",displayName:"Error",group:"Error",getter(){return this._internal.error}},username:{type:"string",displayName:"Username",group:"General",getter(){return void 0!==this._internal.model?this._internal.model.get("username"):void 0}},email:{type:"string",displayName:"Email",group:"General",getter(){return void 0!==this._internal.model?this._internal.model.get("email"):void 0}},authenticated:{type:"boolean",displayName:"Authenticated",group:"General",getter(){return void 0!==this._internal.model}}},inputs:{fetch:{displayName:"Fetch",group:"Actions",valueChangedToTrue(){this.scheduleFetch()}}},methods:{_onNodeDeleted(){Node.prototype._onNodeDeleted.call(this),this._internal.model&&this._internal.model.off("change",this._internal.onModelChangedCallback)},scheduleOnce(e,t){const n=this,o="hasScheduled"+e;this._internal[o]||(this._internal[o]=!0,this.scheduleAfterInputsHaveUpdated((function(){n._internal[o]=!1,t()})))},setError(e){this._internal.error=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure"),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"user-warning",{message:e,showGlobally:!0})},clearWarnings(){this.context.editorConnection&&this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"user-warning")},setUserModel(e){const t=this._internal;if(t.model!==e&&(t.model&&t.model.off("change",t.onModelChangedCallback),t.model=e,e&&e.on("change",t.onModelChangedCallback)),this.flagOutputDirty("id"),this.flagOutputDirty("authenticated"),this.flagOutputDirty("email"),this.flagOutputDirty("username"),e)for(const t in e.data)this.hasOutput("prop-"+t)&&this.flagOutputDirty("prop-"+t)},scheduleFetch(){this._internal,this.scheduleOnce("Fetch",(()=>{const e=NoodlRuntime.Services.UserService.forScope(this.nodeScope.modelScope);e.fetchCurrentUser({success:t=>{this.setUserModel(e.current),this.sendSignalOnOutput("fetched")},error:e=>{this.setError(e||"Failed to fetch.")}})}))},registerOutputIfNeeded(e){this.hasOutput(e)||("loggedOut"!==e&&"loggedIn"!==e&&"sessionLost"!==e?e.startsWith("prop-")&&this.registerOutput(e,{getter:this.getUserProperty.bind(this,e.substring(5))}):this.registerOutput(e,{getter:()=>{}}))},getUserProperty(e){return void 0!==this._internal.model?this._internal.model.get(e):void 0}}};function nn(e,t,n,o){const i=[];if(o){const e=o.find((e=>"_User"===e.name));if(e&&e.schema&&e.schema.properties){const t=e.schema.properties,n=["authData","password","username","email"];for(const e in t){if(-1!==n.indexOf(e))continue;const o=t[e];if(!i.find((t=>t.name===e)))if("Relation"===o.type);else{const t={String:"string",Boolean:"boolean",Number:"number",Date:"date"};i.push({type:{name:t[o.type]?t[o.type]:"*"},plug:"output",group:"Properties",name:"prop-"+e,displayName:e}),i.push({type:"signal",plug:"output",group:"Changed Events",displayName:e+" Changed",name:"changed-"+e})}}}}"undefined"==typeof _noodl_cloud_runtime_version&&(i.push({plug:"output",name:"loggedIn",type:"signal",displayName:"Logged In",group:"Events"}),i.push({plug:"output",name:"loggedOut",type:"signal",displayName:"Logged Out",group:"Events"}),i.push({plug:"output",name:"sessionLost",type:"signal",displayName:"Session Lost",group:"Events"})),n.sendDynamicPorts(e,i)}function on(e,t){function n(n){nn(n.id,n.parameters,e.editorConnection,t.getMetaData("systemCollections")),n.on("parameterUpdated",(function(o){nn(n.id,n.parameters,e.editorConnection,t.getMetaData("systemCollections"))})),t.on("metadataChanged.systemCollections",(function(t){nn(n.id,n.parameters,e.editorConnection,t)}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.net.noodl.user.User",(function(e){n(e)}));for(const e of t.getNodesWithType("net.noodl.user.User"))n(e)}))}class sn{constructor(e){if(e.platform=e.platform||{},sn.instance=this,this.type=e.type||"browser",this.noodlModules=[],this.eventEmitter=new U.b,this.updateScheduled=!1,this.rootComponent=null,this._currentLoadedData=null,this.isWaitingForExport=!0,this.graphModel=new ne,this.errorHandlers=[],this.frameNumber=0,this.dontCreateRootComponent=!!e.dontCreateRootComponent,this.componentFilter=e.componentFilter,this.runningInEditor=!e.runDeployed,this.platform={requestUpdate:e.platform.requestUpdate,getCurrentTime:e.platform.getCurrentTime,webSocketOptions:e.platform.webSocketOptions,objectToString:e.platform.objectToString},!e.platform.requestUpdate)throw new Error("platform.requestUpdate must be set");if(!e.platform.getCurrentTime)throw new Error("platform.getCurrentTime must be set");var t;this.editorConnection=new Q({platform:e.platform,runtimeType:this.type}),this.context=new Y({runningInEditor:!e.runDeployed,editorConnection:this.editorConnection,platform:this.platform,graphModel:this.graphModel}),this.context.eventEmitter.on("scheduleUpdate",this.scheduleUpdate.bind(this)),e.runDeployed||this._setupEditorCommunication(e),this.registerGraphModelListeners(),t=this,[o,s,r,a,l,d,u,c,p,h,m,g,f,y,v,b,_,S,C,N,O,I,w,P,x,E,T,A,k,D,R,M,V,j,F].forEach((e=>t.registerNode(e)))}async prefetchBundles(e,t){await async function(e,t,n){const o=[],i=[];for(const s of t){const r=Promise.resolve().then((()=>n(s)));if(o.push(r),e<=t.length){const t=r.then((()=>{i.splice(i.indexOf(t),1)}));i.push(t),i.length>=e&&await Promise.race(i)}}return Promise.all(o)}(t,e,(async e=>{await this.context.fetchComponentBundle(e)}))}_setupEditorCommunication(e){function t(e,n){if(null==e||null==n)return e===n;if(e===n)return!0;if(Array.isArray(e)&&e.length!==n.length)return!1;if(!(e instanceof Object))return!1;if(!(n instanceof Object))return!1;const o=Object.keys(e);return Object.keys(n).every((e=>-1!==o.indexOf(e)))&&o.every((o=>t(e[o],n[o])))}this.editorConnection.on("exportDataFull",(async e=>{if(!1!==this.graphModel.isEmpty()){if(this.isWaitingForExport=!1,!1===t(this._currentLoadedData,e)){if(this.componentFilter&&(e.components=e.components.filter((e=>this.componentFilter(e)))),await this.setData(e),e.componentIndex){const t=Object.keys(e.componentIndex);await this.prefetchBundles(t,2)}this.graphModel.emit("editorImportComplete")}}else this.reload()})),this.editorConnection.on("reload",this.reload.bind(this)),this.editorConnection.on("modelUpdate",this.onModelUpdateReceived.bind(this)),this.editorConnection.on("metadataUpdate",this.onMetaDataUpdateReceived.bind(this)),this.editorConnection.on("connected",(()=>{this.sendNodeLibrary()}))}setDebugInspectorsEnabled(e){this.context.setDebugInspectorsEnabled(e)}registerModule(e){if(e.nodes)for(let t of e.nodes)t.node||(t={node:t}),t.node.module=e.name||"Unknown Module",this.registerNode(t);this.noodlModules.push(e)}registerGraphModelListeners(){this.graphModel.on("componentAdded",(e=>{this.context.registerComponentModel(e)}),this),this.graphModel.on("componentRemoved",(e=>{this.context.deregisterComponentModel(e)}),this)}reload(){location.reload()}registerNode(e){if(e.node){const t=le(e.node);this.context.nodeRegister.register(t),t.setupNumberedInputDynamicPorts&&t.setupNumberedInputDynamicPorts(this.context,this.graphModel)}else this.context.nodeRegister.register(e.node);e.setup&&e.setup(this.context,this.graphModel)}async _setRootComponent(e){this.rootComponent&&this.rootComponent.name===e||(this.rootComponent&&(this.rootComponent.model&&this.rootComponent.model.removeListenersWithRef(this),this.rootComponent=void 0),e&&(this.rootComponent=await this.context.createComponentInstanceNode(e,"rootComponent",null),this.rootComponent.componentModel.on("rootAdded",(()=>this.eventEmitter.emit("rootComponentUpdated")),this),this.rootComponent.componentModel.on("rootRemoved",(()=>this.eventEmitter.emit("rootComponentUpdated")),this),this.context.setRootComponent(this.rootComponent)),this.eventEmitter.emit("rootComponentUpdated"))}async setData(e){if(!this._disableLoad){this._currentLoadedData=e,await this.graphModel.importEditorData(e);for(const e of this.noodlModules)"function"==typeof e.setup&&e.setup();!0!==this.dontCreateRootComponent&&(await this._setRootComponent(this.graphModel.rootComponent||null),this.graphModel.on("rootComponentNameUpdated",(e=>{this._setRootComponent(e)})),this.graphModel.on("componentRemoved",(e=>{this.rootComponent&&this.rootComponent.name===e.name&&this._setRootComponent(null)})),this.graphModel.on("componentAdded",(e=>{setTimeout((()=>{this.rootComponent||this.graphModel.rootComponent!==e.name||this._setRootComponent(e.name)}),1)}))),this.scheduleUpdate()}}scheduleUpdate(){var e,t;this.updateScheduled||(this.updateScheduled=!0,null===(t=(e=this.platform).requestUpdate)||void 0===t||t.call(e,this._doUpdate.bind(this)))}_doUpdate(){this.updateScheduled=!1,this.context.currentFrameTime=this.platform.getCurrentTime(),this.context.eventEmitter.emit("frameStart"),this.context.update(),this.context.eventEmitter.emit("frameEnd"),this.frameNumber++}setProjectSettings(e){this.projectSettings=e}getNodeLibrary(){const e=function(e,t){const n={dynamicports:[],ports:[]};return function(e,t){for(let n=0;n{e.ports.push(t)}))}}(n,t),n}(this.graphModel.getSettings(),this.noodlModules);this.projectSettings&&(this.projectSettings.ports&&(e.ports=e.ports.concat(this.projectSettings.ports)),this.projectSettings.dynamicports&&(e.dynamicports=e.ports.concat(this.projectSettings.dynamicports)));const t=function(e){const t={typecasts:[{from:"string",to:["number","boolean","image","color","enum","textStyle","dimension","array","object"]},{from:"boolean",to:["number","string","signal"]},{from:"number",to:["boolean","string","dimension"]},{from:"date",to:["string"]},{from:"signal",to:["boolean","number"]},{from:"image",to:[]},{from:"cloudfile",to:["string","image"]},{from:"color",to:[]},{from:"enum",to:[]},{from:"object",to:[]},{from:"domelement",to:[]},{from:"reference",to:[]},{from:"font",to:[]},{from:"textStyle",to:["string"]},{from:"collection",to:["array"]},{from:"array",to:["collection"]}],dynamicports:[{type:"conditionalports",name:"basic"},{type:"expand",name:"basic"}],colors:{nodes:{component:{base:"#643D8B",baseHighlighted:"#79559b",header:"#4E2877",headerHighlighted:"#643d8b",outline:"#4E2877",outlineHighlighted:"#b58900",text:"#dbd0e4"},visual:{base:"#315272",baseHighlighted:"#4d6784",header:"#173E5D",headerHighlighted:"#315272",outline:"#173E5D",outlineHighlighted:"#b58900",text:"#cfd5de"},data:{base:"#465524",baseHighlighted:"#5b6a37",header:"#314110",headerHighlighted:"#465524",outline:"#314110",outlineHighlighted:"#b58900",text:"#d2d6c5"},javascript:{base:"#7E3660",baseHighlighted:"#944e74",header:"#67214B",headerHighlighted:"#7e3660",outline:"#67214B",outlineHighlighted:"#d57bab",text:"#e4cfd9"},default:{base:"#4C4F59",baseHighlighted:"#62656e",header:"#373B45",headerHighlighted:"#4c4f59",outline:"#373B45",outlineHighlighted:"#b58900",text:"#d3d4d6"}},connections:{signal:{normal:"#006f82",highlighted:"#7ec2cf",pulsing:"#ffffff"},default:{normal:"#875d00",highlighted:"#e5ae32",pulsing:"#ffffff"}}},nodetypes:[{name:"Component Children",shortDesc:"This node is a placeholder for where children of this component will be inserted.",docs:"https://docs.noodl.net/nodes/component-utilities/component-children",color:"component",allowAsChild:!0,category:"Visual",haveComponentChildren:["Visual"]}]},n=Object.keys(e._constructors);n.forEach((function(n){const o=e._constructors[n].metadata,i={name:n,searchTags:o.searchTags};t.nodetypes.push(i),o.version&&(i.version=o.version),o.displayNodeName&&(i.displayNodeName=o.displayNodeName),o.nodeDoubleClickAction&&(i.nodeDoubleClickAction=o.nodeDoubleClickAction),o.shortDesc&&(i.shortDesc=o.shortDesc),o.module&&(i.module=o.module),o.deprecated&&(i.deprecated=!0),o.haveComponentPorts&&(i.haveComponentPorts=!0),"Visual"===o.category&&(i.allowAsChild=!0,i.allowAsExportRoot=!0,i.color="visual"),void 0!==o.allowAsExportRoot&&(i.allowAsExportRoot=o.allowAsExportRoot),o.allowChildren&&(i.allowChildrenWithCategory=["Visual"],i.color="visual"),o.allowChildrenWithCategory&&(i.allowChildrenWithCategory=o.allowChildrenWithCategory),o.singleton&&(i.singleton=!0),o.allowAsChild&&(i.allowAsChild=!0),o.docs&&(i.docs=o.docs),o.shortDocs?i.shortDocs=o.shortDocs:o.docs&&0===o.docs.indexOf("https://docs.noodl.net")&&(i.shortDocs=o.docs.replace("/#","")+"-short.md"),i.category=o.category,o.panels&&(i.panels=o.panels),o.usePortAsLabel&&(i.usePortAsLabel=o.usePortAsLabel,i.portLabelTruncationMode=o.portLabelTruncationMode),o.color&&(i.color=o.color),o.dynamicports&&(i.dynamicports=function(e){var t,n;const o=[];for(const i of e.dynamicports||[])if(i.ports||i.template||i.port||i.channelPort)o.push(i);else if(i.inputs||i.outputs){const s=[];if(i.inputs)for(const n of i.inputs){const o=null===(t=e.inputs)||void 0===t?void 0:t[n];o&&s.push(Z(n,o,"input"))}if(i.outputs)for(const t of i.outputs){const o=null===(n=e.outputs)||void 0===n?void 0:n[t];o&&s.push(Z(t,o,"output"))}const r={name:i.name||"conditionalports/basic",condition:i.condition,ports:s};o.push(r)}return o}(o)),o.exportDynamicPorts&&(i.exportDynamicPorts=o.exportDynamicPorts),o.visualStates&&(i.visualStates=o.visualStates),o.useVariants&&(i.useVariants=o.useVariants),o.connectionPanel&&(i.connectionPanel=o.connectionPanel),i.ports=[];const s=i.dynamicports||[],r={},a={};s.filter((e=>void 0!==e.channelPort)).forEach((e=>{a[e.channelPort.plug+"/"+e.channelPort.name]=!0})),s.length&&(i.dynamicports=s),Object.keys(o.inputs||{}).forEach((function(e){var t;if(r.hasOwnProperty("input/"+e)||a.hasOwnProperty("input/"+e))return;const n=null===(t=o.inputs)||void 0===t?void 0:t[e];n&&!1!==n.exportToEditor&&(i.ports||(i.ports=[]),i.ports.push(Z(e,n,"input")))})),Object.keys(o.outputs||{}).forEach((function(e){var t;if(r.hasOwnProperty("output/"+e)||a.hasOwnProperty("output/"+e))return;const n=null===(t=o.outputs)||void 0===t?void 0:t[e];n&&function(e,t){const n={name:e,type:t.type,plug:"output"};t.group&&(n.group=t.group),t.displayName&&(n.displayName=t.displayName),t.editorName&&(n.editorName=t.editorName),t.hasOwnProperty("index")&&(n.index=t.index),i.ports||(i.ports=[]),i.ports.push(n)}(e,n)}))})),t.nodeIndex={coreNodes:[{name:"UI Elements",description:"Buttons, inputs, containers, media",type:"visual",subCategories:[{name:"Basic Elements",items:["Group","net.noodl.visual.columns","Text","Image","Video","Circle","net.noodl.visual.icon"]},{name:"UI Controls",items:["net.noodl.controls.button","net.noodl.controls.checkbox","net.noodl.controls.options","net.noodl.controls.radiobutton","Radio Button Group","net.noodl.controls.range","net.noodl.controls.textinput"]}]},{name:"Navigation & Popups",description:"Page routing, navigation, popups",type:"logic",subCategories:[{name:"Navigation",items:["Router","RouterNavigate","PageInputs","net.noodl.externallink","PageStackNavigateToPath"]},{name:"Component Stack",items:["Page Stack","PageStackNavigate","PageStackNavigateBack"]},{name:"Popups",items:["NavigationShowPopup","NavigationClosePopup"]}]},{name:"Logic & Utilities",description:"Logic, events, string manipulation",type:"logic",subCategories:[{name:"General Utils",items:["States","Value Changed","Timer","Color Blend","Number Remapper","Counter","Drag","net.noodl.animatetovalue"]},{name:"Logic",items:["Boolean To String","Switch","And","Or","Condition","Inverter"]},{name:"Events",items:["Event Sender","Event Receiver"]},{name:"String Manipulation",items:["Substring","String Mapper","String Format","Date To String","Unique Id"]},{name:"System",items:["Screen Resolution","Open File Picker"]},{name:"Variables",items:["String","Boolean","Color","Number"]}]},{name:"Component Utilities",description:"Component inputs, outputs & object",type:"component",subCategories:[{name:"",items:["Component Inputs","Component Outputs","Component Children","net.noodl.ComponentObject","net.noodl.ParentComponentObject","net.noodl.SetComponentObjectProperties","net.noodl.SetParentComponentObjectProperties"]}]},{name:"Read & Write Data",description:"Arrays, objects, cloud data",type:"data",subCategories:[{name:"",items:["RunTasks","For Each","For Each Actions","Model2","SetModelProperties","NewModel","Set Variable","Variable2"]},{name:"Array",items:["Collection2","CollectionNew","CollectionRemove","CollectionClear","CollectionInsert","Filter Collection","Map Collection","Static Data"]},{name:"Cloud Data",items:["DbModel2","NewDbModelProperties","FilterDBModels","SetDbModelProperties","DbCollection2","DeleteDbModelProperties","AddDbModelRelation","RemoveDbModelRelation","Cloud File","Upload File","CloudFunction2","DbConfig"]},{name:"User",items:["net.noodl.user.LogIn","net.noodl.user.LogOut","net.noodl.user.SignUp","net.noodl.user.User","net.noodl.user.SetUserProperties","net.noodl.user.VerifyEmail","net.noodl.user.SendEmailVerification","net.noodl.user.ResetPassword","net.noodl.user.RequestPasswordReset"]},{name:"External Data",items:["REST2"]}]},{name:"Custom Code",description:"Custom JavaScript and CSS",type:"javascript",subCategories:[{name:"",items:["Expression","JavaScriptFunction","Javascript2","CSS Definition"]}]},{name:"Cloud Functions",description:"Nodes to be used in cloud functions",type:"data",subCategories:[{name:"",items:["noodl.cloud.request","noodl.cloud.response"]},{name:"Cloud Data",items:["noodl.cloud.aggregate"]}]}]};const o=[];return n.forEach((t=>{e._constructors[t].metadata.module&&o.push(t)})),o.length&&(t.nodeIndex.moduleNodes=[{name:"",items:o}]),t}(this.context.nodeRegister);return t.projectsettings=e,JSON.stringify(t,null,3)}sendNodeLibrary(){const e=this.getNodeLibrary();this.lastSentNodeLibrary!==e&&(this.lastSentNodeLibrary=e,this.editorConnection.sendNodeLibrary(e))}connectToEditor(e){this.editorConnection.connect(e)}onMetaDataUpdateReceived(e){this.graphModel.isEmpty()||ie(this.context,this.graphModel,e)}async onModelUpdateReceived(e){this.isWaitingForExport||("projectInstanceChanged"===e.type?this.reload():!1===this.graphModel.isEmpty()&&await ie(this.context,this.graphModel,e))}addErrorHandler(e){this.errorHandlers.push(e)}reportError(e){this.errorHandlers.forEach((t=>{t(e)}))}getProjectSettings(){return this.graphModel.getSettings()}getMetaData(e){return this.graphModel.getMetaData(e)}}sn.Services=se,sn.Node=q.b,sn.NodeDefinition={defineNode:le},sn.EdgeTriggeredInput=re.i;const rn=sn},6351:(e,t,n)=>{"use strict";function o(e){if(null==e||""===e)return window.Noodl.baseUrl||"/";const t=String(e);return!t||"/"===t[0]||t.includes("://")||t.startsWith("data:")?t:(window.Noodl.baseUrl||"/")+t}function i(e){"string"==typeof e?console.log("Error in JS node run code.",e):e instanceof Error&&console.log("Error in JS node run code.",Object.getPrototypeOf(e).constructor.name+": "+e.message,e.stack)}function s(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}function r(e){if(0===e)throw new Error("Zero-length randomString is useless.");let t="";for(let n=0;nr,Lo:()=>o,Os:()=>s,Ql:()=>i})},2004:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});const o={easeOutQuartic:function(e,t,n){return-(t-e)*(--n*n*n*n-1)+e},easeInQuartic:function(e,t,n){return n*n*n*n*(t-e)+e},easeInOutQuartic:function(e,t,n){return(n*=2)<1?(t-e)/2*n*n*n*n+e:-(t-e)/2*((n-=2)*n*n*n-2)+e},easeOutCubic:function(e,t,n){return(t-e)*(--n*n*n+1)+e},easeInCubic:function(e,t,n){return n*n*n*(t-e)+e},easeInOutCubic:function(e,t,n){return(n*=2)<1?(t-e)/2*n*n*n+e:(t-e)/2*((n-=2)*n*n+2)+e},easeOutQuadratic:function(e,t,n){return-(t-e)*n*(n-2)+e},easeInQuadratic:function(e,t,n){return n*n*(t-e)+e},easeInOutQuadratic:function(e,t,n){return(n*=2)<1?(t-e)/2*n*n+e:-(t-e)/2*((n-=1)*(n-2)-1)+e},linear:function(e,t,n){return e+(t-e)*n},easeIn:()=>0,easeOut:()=>0,easeInOut:()=>0};o.easeIn=o.easeInCubic,o.easeOut=o.easeOutCubic,o.easeInOut=o.easeInOutCubic;const i=o},7095:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i,setup:()=>s});var o=n(1142);const i={name:"NavigationClosePopup",displayNodeName:"Close Popup",category:"Navigation",docs:"https://docs.noodl.net/nodes/popups/close-popup",_internal:{resultValues:{}},inputs:{results:{type:{name:"stringlist",allowEditOnly:!0},group:"Results",set(e){this._internal.results=e}},closeActions:{type:{name:"stringlist",allowEditOnly:!0},group:"Close Actions",set(e){this._internal.closeActions=e}},close:{type:"Signal",displayName:"Close",group:"Actions",valueChangedToTrue(){this.scheduleClose()}}},methods:{setResultValue(e,t){this._internal.resultValues[e]=t},_setCloseCallback(e){this._internal.closeCallback=e},scheduleClose(){const e=this,t=this._internal;t.hasScheduledClose||(t.hasScheduledClose=!0,this.scheduleAfterInputsHaveUpdated((function(){t.hasScheduledClose=!1,e.close()})))},close(){this._internal.closeCallback&&this._internal.closeCallback(this._internal.closeAction||"",this._internal.resultValues)},closeActionTriggered(e){this._internal.closeAction=e,this.scheduleClose()},registerInputIfNeeded(e){if(!this.hasInput(e))return e.startsWith("result-")?this.registerInput(e,{set:this.setResultValue.bind(this,e.substring(7))}):e.startsWith("closeAction-")?this.registerInput(e,{set:(0,o.i)({valueChangedToTrue:this.closeActionTriggered.bind(this,e)})}):void 0}}};function s(e,t){function n(t){function n(){var n;const o=[],i=t.parameters.results;if(i){const e=i?i.split(","):void 0;for(const t of e)o.push({type:{name:"*"},plug:"input",group:"Results",name:"result-"+t,displayName:t})}const s=t.parameters.closeActions;if(s){const e=s?s.split(","):void 0;for(const t of e)o.push({type:"signal",plug:"input",group:"Close Actions",name:"closeAction-"+t,displayName:t})}null===(n=e.editorConnection)||void 0===n||n.sendDynamicPorts(t.id,o)}n(),t.on("parameterUpdated",(function(e){"results"!==e.name&&"closeActions"!==e.name||n()}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.NavigationClosePopup",(function(e){n(e)}));for(const e of t.getNodesWithType("NavigationClosePopup"))n(e)}))}},8064:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>o,setup:()=>i});const o={name:"PageStackNavigateBack",displayNodeName:"Pop Component Stack",category:"Navigation",docs:"https://docs.noodl.net/nodes/component-stack/pop-component",inputs:{navigate:{displayName:"Navigate",group:"Actions",valueChangedToTrue(){this.scheduleNavigate()}},results:{type:{name:"stringlist",allowEditOnly:!0},group:"Results",set(e){this._internal.results=e}},backActions:{type:{name:"stringlist",allowEditOnly:!0},group:"Back Actions",set(e){this._internal.backActions=e}}},initialize(){this._internal.resultValues={}},methods:{scheduleNavigate(){var e=this,t=this._internal;t.hasScheduledNavigate||(t.hasScheduledNavigate=!0,this.scheduleAfterInputsHaveUpdated((function(){t.hasScheduledNavigate=!1,e.navigate()})))},_setBackCallback(e){this._internal.backCallback=e},navigate(){void 0!==this._internal.backCallback&&this._internal.backCallback({backAction:this._internal.backAction,results:this._internal.resultValues})},setResultValue(e,t){this._internal.resultValues[e]=t},backActionTriggered(e){this._internal.backAction=e,this.scheduleNavigate()},registerInputIfNeeded(e){if(!this.hasInput(e))return e.startsWith("result-")?this.registerInput(e,{set:this.setResultValue.bind(this,e.substring(7))}):e.startsWith("backAction-")?this.registerInput(e,{set:t=>{t&&this.backActionTriggered(e)}}):void 0}}};function i(e,t){function n(t){function n(){var n,o=[],i=t.parameters.results;if(i)for(var s in i=i?i.split(","):void 0){var r=i[s];o.push({type:{name:"*"},plug:"input",group:"Results",name:"result-"+r,displayName:r})}var a=t.parameters.backActions;if(a)for(var s in a=a?a.split(","):void 0)r=a[s],o.push({type:"signal",plug:"input",group:"Back Actions",name:"backAction-"+r,displayName:r});null===(n=e.editorConnection)||void 0===n||n.sendDynamicPorts(t.id,o)}n(),t.on("parameterUpdated",(function(e){"results"!==e.name&&"backActions"!==e.name||n()}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.PageStackNavigateBack",(function(e){n(e)}));for(const e of t.getNodesWithType("PageStackNavigateBack"))n(e)}))}},3700:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i,setup:()=>s});var o=n(260);const i={name:"PageStackNavigateToPath",displayNodeName:"Navigate To Path",category:"Navigation",docs:"https://docs.noodl.net/nodes/navigation/navigate-to-path",initialize(){const e=this._internal;e.params={},e.query={},e.openInNewTab=!1},inputs:{path:{type:{name:"string"},displayName:"Path",group:"General",set(e){this._internal.path=e}},queryNames:{type:{name:"stringlist",allowEditOnly:!0},displayName:"Query",group:"Query",set(e){this._internal.queryNames=e}},openInNewTab:{index:10,displayName:"Open in new tab",group:"General",default:!1,type:"boolean",set(e){this._internal.openInNewTab=!!e}},navigate:{displayName:"Navigate",group:"Actions",valueChangedToTrue(){this.scheduleNavigate()}}},outputs:{},methods:{scheduleNavigate(){const e=this._internal;e.hasScheduledNavigate||(e.hasScheduledNavigate=!0,this.scheduleAfterInputsHaveUpdated((()=>{e.hasScheduledNavigate=!1,this.navigate()})))},navigate(){var e;const t=this._internal;let n=t.path;if(void 0===n)return;const i=null===(e=t.path)||void 0===e?void 0:e.match(/\{[A-Za-z0-9_]*\}/g);let s,r,a=[];i&&(a=i.map((e=>e.replace("{","").replace("}","")))),a.forEach((e=>{const o=t.params[e];n=n.replace("{"+e+"}",void 0!==o?o:"")}));const l=o.default.instance.getProjectSettings().navigationPathType;void 0===l||"hash"===l?r=n:s=n;const d=[];void 0!==t.queryNames&&t.queryNames.split(",").forEach((e=>{void 0!==t.query[e]&&d.push(e+"="+t.query[e])}));const u=(void 0!==s?s:"")+(d.length>=1?"?"+d.join("&"):"")+(void 0!==r?"#"+r:"");this._internal.openInNewTab?window.open(u,"_blank"):(window.history.pushState({},"",u),dispatchEvent(new PopStateEvent("popstate",{})))},setParam(e,t){this._internal.params[e]=t},setQuery(e,t){this._internal.query[e]=t},registerInputIfNeeded(e){if(!this.hasInput(e))return e.startsWith("p-")?this.registerInput(e,{set:this.setParam.bind(this,e.substring(2))}):e.startsWith("q-")?this.registerInput(e,{set:this.setQuery.bind(this,e.substring(2))}):void 0}}};function s(e,t){function n(t){function n(){var n;const o=[];if(void 0!==t.parameters.path){const e=(t.parameters.path.match(/\{[A-Za-z0-9_]*\}/g)||[]).map((e=>e.replace("{","").replace("}",""))).filter(((e,t,n)=>n.indexOf(e)===t)).map((e=>({name:"p-"+e,displayName:e,group:"Parameter",type:"*",plug:"input"})));o.push(...e)}void 0!==t.parameters.queryNames&&t.parameters.queryNames.split(",").forEach((e=>{o.push({name:"q-"+e,displayName:e,group:"Query",plug:"input",type:"*"})})),null===(n=e.editorConnection)||void 0===n||n.sendDynamicPorts(t.id,o)}n(),t.on("parameterUpdated",(function(e){n()}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.PageStackNavigateToPath",(function(e){n(e)}));for(const e of t.getNodesWithType("PageStackNavigateToPath"))n(e)}))}},5738:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>s,setup:()=>r});var o=n(5573),i=n(7410);const s={name:"PageStackNavigate",displayNodeName:"Push Component To Stack",category:"Navigation",docs:"https://docs.noodl.net/nodes/component-stack/push-component",initialize(){this._internal.transitionParams={},this._internal.pageParams={},this._internal.backResults={}},inputs:{stack:{type:{name:"string",identifierOf:"PackStack"},displayName:"Stack",group:"General",default:"Main",set(e){this._internal.stack=e}},mode:{type:{name:"enum",enums:[{label:"Push",value:"push"},{label:"Replace",value:"replace"}]},displayName:"Mode",default:"push",group:"General",set(e){this._internal.navigationMode=e}},navigate:{displayName:"Navigate",group:"Actions",valueChangedToTrue(){this.scheduleNavigate()}}},outputs:{navigated:{type:"signal",displayName:"Navigated",group:"Events"}},methods:{scheduleNavigate(){const e=this._internal;e.hasScheduledNavigate||(e.hasScheduledNavigate=!0,this.scheduleAfterInputsHaveUpdated((()=>{e.hasScheduledNavigate=!1,this.navigate()})))},navigate(){"push"===this._internal.navigationMode||void 0===this._internal.navigationMode?i.A.instance.navigate(this._internal.stack,{target:this._internal.target,transition:{type:this._internal.transition,...this._internal.transitionParams},params:this._internal.pageParams,backCallback:(e,t)=>{this._internal.backResults=t;for(const e in t)this.hasOutput("backResult-"+e)&&this.flagOutputDirty("backResult-"+e);void 0!==e&&this.sendSignalOnOutput(e)},hasNavigated:()=>{this.sendSignalOnOutput("navigated")}}):"replace"===this._internal.navigationMode&&i.A.instance.replace(this._internal.stack,{target:this._internal.target,params:this._internal.pageParams,hasNavigated:()=>{this.scheduleAfterInputsHaveUpdated((()=>{this.sendSignalOnOutput("navigated")}))}})},setTransitionParam(e,t){this._internal.transitionParams[e]=t},setPageParam(e,t){this._internal.pageParams[e]=t},getBackResult(e){return this._internal.backResults[e]},setTargetPageId(e){this._internal.target=e},setTransition(e){this._internal.transition=e},registerInputIfNeeded(e){if(!this.hasInput(e))return"target"===e?this.registerInput(e,{set:this.setTargetPageId.bind(this)}):"transition"===e?this.registerInput(e,{set:this.setTransition.bind(this)}):e.startsWith("tr-")?this.registerInput(e,{set:this.setTransitionParam.bind(this,e.substring(3))}):e.startsWith("pm-")?this.registerInput(e,{set:this.setPageParam.bind(this,e.substring(3))}):void 0},registerOutputIfNeeded(e){if(!this.hasOutput(e))return e.startsWith("backResult-")?this.registerOutput(e,{getter:this.getBackResult.bind(this,e.substring(11))}):e.startsWith("backAction-")?this.registerOutput(e,{getter(){}}):void 0}}};function r(e,t){function n(n){function i(){var i;const s=[];if("push"===n.parameters.mode||void 0===n.parameters.mode){s.push({name:"transition",plug:"input",type:{name:"enum",enums:Object.keys(o.x)},default:"Push",displayName:"Transition",group:"Transition"});const e=n.parameters.transition||"Push";o.x[e]&&s.push(...o.x[e].ports(n.parameters))}const r=t.getNodesWithType("Page Stack").find((e=>(e.parameters.name||"Main")===(n.parameters.stack||"Main")));if(void 0!==r){const e=r.parameters.pages;if(void 0!==e&&e.length>0){s.push({plug:"input",type:{name:"enum",enums:e.map((e=>({label:e.label,value:e.id})))},group:"General",displayName:"Target Page",name:"target",default:e[0].id});const o=n.parameters.target||e[0].id,i=r.parameters["pageComp-"+o];if(void 0!==i){const e=t.components[i];if(void 0!==e){for(const t in e.inputPorts)s.push({name:"pm-"+t,displayName:t,type:"*",plug:"input",group:"Parameters"});for(const t of e.getNodesWithType("PageStackNavigateBack"))void 0!==t.parameters.backActions&&t.parameters.backActions.split(",").forEach((e=>{s.find((t=>t.name==="backAction-"+e))||s.push({name:"backAction-"+e,displayName:e,type:"signal",plug:"output",group:"Back Actions"})})),t.parameters.results&&t.parameters.results.split(",").forEach((e=>{s.find((t=>t.name==="backResult-"+e))||s.push({name:"backResult-"+e,displayName:e,type:"*",plug:"output",group:"Back Results"})}))}}}}null===(i=e.editorConnection)||void 0===i||i.sendDynamicPorts(n.id,s)}function s(){const e=t.getNodesWithType("Page Stack").find((e=>e.parameters.name===n.parameters.stack));if(void 0===e)return;const o=e.parameters.pages;if(void 0===o||0===o.length)return;const s=e.parameters["pageComp-"+(n.parameters.target||o[0].id)];if(void 0===s)return;const r=t.components[s];if(void 0!==r){r.on("inputPortAdded",i),r.on("inputPortRemoved",i);for(const e of r.getNodesWithType("PageStackNavigateBack"))e.on("parameterUpdated",i);r.on("nodeAdded",(e=>{"PageStackNavigateBack"===e.type&&(e.on("parameterUpdated",i),i())})),r.on("nodeWasRemoved",(e=>{"PageStackNavigateBack"===e.type&&i()}))}}function r(e){e.on("parameterUpdated",(function(e){"pages"!==e.name&&"name"!==e.name||i()}))}i(),s(),n.on("parameterUpdated",(function(e){"target"===e.name?(s(),i()):("stack"===e.name||"mode"===e.name||"transition"===e.name||e.name.startsWith("tr-"))&&i()})),t.on("nodeAdded.Page Stack",r),t.on("nodeWasRemoved.Page Stack",i);for(const e of t.getNodesWithType("Page Stack"))r(e)}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.PageStackNavigate",(function(e){n(e)}));for(const e of t.getNodesWithType("PageStackNavigate"))n(e)}))}},7410:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});class o{constructor(){this._pageStacks={},this._navigationQueue=[]}_performNavigation(e="Main",t,n){if(this._pageStacks[e])for(const o of this._pageStacks[e])"navigate"===n?o.navigate(t):o.replace(t);else this._navigationQueue.push({name:e,args:t,type:n})}navigate(e="Main",t){this._performNavigation(e,t,"navigate")}replace(e="Main",t){this._performNavigation(e,t,"replace")}registerPageStack(e="Main",t){this._pageStacks[e]||(this._pageStacks[e]=[]),this._pageStacks[e].push(t);let n=!1,o=!1,i=0;for(;i{"use strict";n.r(t),n.d(t,{node:()=>o,setup:()=>i});const o={name:"PageInputs",displayNodeName:"Page Inputs",category:"Navigation",docs:"https://docs.noodl.net/nodes/navigation/page-inputs",color:"component",initialize(){this._internal.params={}},inputs:{pathParams:{type:{name:"stringlist",allowEditOnly:!0},group:"Path Parameters"},queryParams:{type:{name:"stringlist",allowEditOnly:!0},group:"Query Parameters"}},outputs:{},methods:{_setPageParams(e){for(const t in e)this._internal.params[t]=e[t],this.hasOutput("pm-"+t)&&this.flagOutputDirty("pm-"+t)},getPageParam(e){return this._internal.params[e]},registerOutputIfNeeded(e){if(!this.hasOutput(e))return e.startsWith("pm-")?this.registerOutput(e,{getter:this.getPageParam.bind(this,e.substring(3))}):void 0}}};function i(e,t){function n(t){function n(){var n;const o=[],i={};void 0!==t.parameters.pathParams&&t.parameters.pathParams.split(",").forEach((e=>{i[e]=!0})),void 0!==t.parameters.queryParams&&t.parameters.queryParams.split(",").forEach((e=>{i[e]=!0})),Object.keys(i).forEach((e=>{o.push({name:"pm-"+e,displayName:e,type:"*",plug:"output",group:"Parameters"})})),null===(n=e.editorConnection)||void 0===n||n.sendDynamicPorts(t.id,o)}n(),t.on("parameterUpdated",(function(){n()}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.PageInputs",(function(e){n(e)}));for(const e of t.getNodesWithType("PageInputs"))n(e)}))}},5741:(e,t,n)=>{"use strict";n.d(t,{u:()=>i});var o=n(260);class i{constructor(){this._routers={},this._navigationQueue=[]}navigate(e,t){setTimeout((()=>{const n=Object.keys(this._routers);if(1===n.length&&(e=n[0]),this._routers[e])for(const n of this._routers[e])n.navigate(t);else this._navigationQueue.push({name:e,args:t})}),1)}registerRouter(e,t){e=e||"Main",this._routers[e]||(this._routers[e]=[]),this._routers[e].push(t);let n=!1,o=0;for(;ot.name===e)),i=new Set;return n.forEach((e=>{const t=e.pages;void 0!==t&&void 0!==t.routes&&t.routes.forEach((e=>{i.add(e)}))})),Array.from(i).map((e=>this.getPageInfoForComponent(String(e)))).filter((e=>!!e))}getPageInfoForComponent(e){return o.default.instance.graphModel.routerIndex.pages.find((t=>t.component===e))}onNavigated(e,t){window.Noodl.Events.emit("NoodlApp_Navigated",{routerName:e,...t})}}i.instance=new i},5178:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i});var o=n(5741);const i={name:"RouterNavigate",displayNodeName:"Navigate",category:"Navigation",docs:"https://docs.noodl.net/nodes/navigation/navigate",initialize(){this._internal.pageParams={},this._internal.openInNewTab=!1},inputs:{navigate:{displayName:"Navigate",group:"Actions",valueChangedToTrue(){this.scheduleNavigate()}},openInNewTab:{index:10,displayName:"Open in new tab",group:"General",default:!1,type:"boolean",set(e){this._internal.openInNewTab=!!e}}},outputs:{navigated:{type:"signal",displayName:"Navigated",group:"Events"}},methods:{scheduleNavigate(){const e=this._internal;e.hasScheduledNavigate||(e.hasScheduledNavigate=!0,this.scheduleAfterInputsHaveUpdated((()=>{e.hasScheduledNavigate=!1,this.navigate()})))},navigate(){o.u.instance.navigate(this._internal.router,{target:this._internal.target,params:this._internal.pageParams,openInNewTab:this._internal.openInNewTab,hasNavigated:()=>{this.scheduleAfterInputsHaveUpdated((()=>{this.sendSignalOnOutput("navigated")}))}})},setPageParam(e,t){this._internal.pageParams[e]=t},setTargetPage(e){this._internal.target=e},setRouter(e){this._internal.router=e},registerInputIfNeeded(e){if(!this.hasInput(e))return"target"===e?this.registerInput(e,{set:this.setTargetPage.bind(this)}):"router"===e?this.registerInput(e,{set:this.setRouter.bind(this)}):e.startsWith("pm-")?this.registerInput(e,{set:this.setPageParam.bind(this,e.substring(3))}):void 0}}}},320:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>o,setup:()=>i});const o={name:"NavigationShowPopup",displayNodeName:"Show Popup",category:"Navigation",docs:"https://docs.noodl.net/nodes/popups/show-popup",initialize(){this._internal.popupParams={},this._internal.closeResults={}},inputs:{target:{type:"component",displayName:"Target",group:"General",set(e){this._internal.target=e}},show:{type:"signal",displayName:"Show",group:"Actions",valueChangedToTrue(){this.scheduleShow()}}},outputs:{Closed:{type:"signal"}},methods:{setPopupParam(e,t){this._internal.popupParams[e]=t},getCloseResult(e){return this._internal.closeResults[e]},scheduleShow(){const e=this._internal;e.hasScheduledShow||(e.hasScheduledShow=!0,this.scheduleAfterInputsHaveUpdated((()=>{e.hasScheduledShow=!1,this.show()})))},show(){void 0!==this._internal.target&&this.context.showPopup(this._internal.target,this._internal.popupParams,{senderNode:this.nodeScope.componentOwner,onClosePopup:(e,t)=>{this._internal.closeResults=t;for(const e in t)this.hasOutput("closeResult-"+e)&&this.flagOutputDirty("closeResult-"+e);e?this.sendSignalOnOutput(e):this.sendSignalOnOutput("Closed")}})},registerInputIfNeeded(e){if(!this.hasInput(e))return e.startsWith("popupParam-")?this.registerInput(e,{set:this.setPopupParam.bind(this,e.substring(11))}):void 0},registerOutputIfNeeded(e){if(!this.hasOutput(e))return e.startsWith("closeResult-")?this.registerOutput(e,{getter:this.getCloseResult.bind(this,e.substring(12))}):e.startsWith("closeAction-")?this.registerOutput(e,{getter(){}}):void 0}}};function i(e,t){function n(n){function o(){var o;const i=[],s=n.parameters.target;if(void 0!==s){const e=t.components[s];if(e){for(const t in e.inputPorts){const n=e.inputPorts[t];i.push({name:"popupParam-"+t,displayName:t,type:n.type||"*",plug:"input",group:"Params"})}for(const t of e.getNodesWithType("NavigationClosePopup"))void 0!==t.parameters.closeActions&&t.parameters.closeActions.split(",").forEach((e=>{i.find((t=>t.name===e))||i.push({name:"closeAction-"+e,displayName:e,type:"signal",plug:"output",group:"Close Actions"})})),void 0!==t.parameters.results&&t.parameters.results.split(",").forEach((e=>{i.push({name:"closeResult-"+e,displayName:e,type:"*",plug:"output",group:"Close Results"})}))}}null===(o=e.editorConnection)||void 0===o||o.sendDynamicPorts(n.id,i)}function i(e){if(void 0===e)return;const n=t.components[e];if(void 0!==n){n.on("inputPortAdded",o),n.on("inputPortRemoved",o);for(const e of n.getNodesWithType("NavigationClosePopup"))e.on("parameterUpdated",o);n.on("nodeAdded",(e=>{"NavigationClosePopup"===e.type&&(e.on("parameterUpdated",o),o())})),n.on("nodeWasRemoved",(e=>{"NavigationClosePopup"===e.type&&o()}))}}o(),i(n.parameters.target),n.on("parameterUpdated",(function(e){"target"===e.name&&(o(),i(n.parameters.target))}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.NavigationShowPopup",(function(e){n(e)}));for(const e of t.getNodesWithType("NavigationShowPopup"))n(e)}))}},5573:(e,t,n)=>{"use strict";n.d(t,{x:()=>r});class o{constructor(){this.transitionForward=!1,this.startTime=0,this.timing={delay:0,dur:0},this._frame=this.frame.bind(this),this.timing={delay:0,dur:0}}start(e){this.cb=e.end,this.timing.delay+this.timing.dur===0?this.end():(this.transitionForward=!e.back,this.startTime=window.performance.now(),requestAnimationFrame(this._frame))}frame(){const e=(window.performance.now()-(this.startTime+this.timing.delay))/this.timing.dur,t=Math.max(0,Math.min(e,1));this.transitionForward?this.forward(t):this.back(t),window.performance.now()<=this.startTime+this.timing.dur+this.timing.delay?requestAnimationFrame(this._frame):this.end()}end(){this.cb&&this.cb()}forward(e){}back(e){}}var i=n(8972),s=n.n(i);const r={None:class extends o{constructor(e,t,n){super(),this.from=e,this.to=t,this.timing={dur:0,delay:0}}update(e){}forward(e){}back(e){}static ports(){return[]}},Push:class extends o{constructor(e,t,n){super(),this.from=e,this.to=t,this.timing=n.timing||{curve:[0,0,.58,1],dur:300,delay:0},this.distance=n.shift||{value:25,unit:"%"},"number"==typeof this.distance&&(this.distance={value:this.distance,unit:"%"}),this.direction=n.direction||"Left",this.timing.curve[0]=Math.min(1,Math.max(0,this.timing.curve[0])),this.timing.curve[2]=Math.min(1,Math.max(0,this.timing.curve[2])),this.ease=s().apply(null,this.timing.curve).get,this.crossfade=void 0!==n.crossfade&&n.crossfade,this.darkOverlay=void 0===n.darkoverlay||n.darkoverlay,this.darkOverlayAmount=void 0===n.darkoverlayamount?.5:n.darkoverlayamount,this.zoom=n.zoom||{value:25,unit:"%"},"number"==typeof this.zoom&&(this.zoom={value:this.zoom,unit:"%"}),this.darkOverlay&&(this.darkOverlay=e.nodeScope.createPrimitiveNode("Group"),this.darkOverlay.setInputValue("position","absolute"),this.darkOverlay.setInputValue("sizeMode","explicit"),this.darkOverlay.setInputValue("width",{value:100,unit:"%"}),this.darkOverlay.setInputValue("height",{value:100,unit:"%"}),this.darkOverlay.setInputValue("backgroundColor","#000000"),this.darkOverlay.setInputValue("opacity",0))}update(e){if("In"===this.direction||"Out"===this.direction){let t=this.zoom.value/100;t="Out"===this.direction?-t:t,this.from.setStyle({transform:"scale("+(1+t*e)+")",opacity:this.crossfade?1-e:1}),this.to.setStyle({transform:"scale("+(1-t*(1-e))+")",opacity:this.crossfade?e:1})}else{const t=this.distance.value,n=this.distance.unit,o={Up:{x:0,y:-1},Down:{x:0,y:1},Left:{x:-1,y:0},Right:{x:1,y:0}},i={x:o[this.direction].x*t,y:o[this.direction].y*t},s={x:100*o[this.direction].x,y:100*o[this.direction].y};this.from.setStyle({transform:"translate("+i.x*e+n+","+i.y*e+n+")",opacity:this.crossfade?1-e:1}),this.to.setStyle({transform:"translate("+s.x*(e-1)+n+","+s.y*(e-1)+"%)",opacity:this.crossfade?e:1})}this.darkOverlay&&this.darkOverlay.setStyle({opacity:e*this.darkOverlayAmount})}forward(e){const t=this.ease(e);this.update(t)}back(e){const t=this.ease(e);this.update(1-t)}start(e){super.start(e),this.darkOverlay&&this.from.addChild(this.darkOverlay)}end(){this.darkOverlay&&this.from.removeChild(this.darkOverlay),super.end()}static ports(e){const t=[];return t.push({name:"tr-direction",displayName:"Direction",group:"Transition",type:{name:"enum",enums:["Right","Left","Up","Down","In","Out"]},default:"Left",plug:"input"}),"In"===e["tr-direction"]||"Out"===e["tr-direction"]?t.push({name:"tr-zoom",displayName:"Zoom",group:"Transition",type:{name:"number",units:["%"]},default:{value:25,unit:"%"},plug:"input"}):t.push({name:"tr-shift",displayName:"Shift Distance",group:"Transition",type:{name:"number",units:["%","px"]},default:{value:25,unit:"%"},plug:"input"}),t.push({name:"tr-crossfade",displayName:"Crossfade",group:"Transition",type:"boolean",default:!1,plug:"input"}),t.push({name:"tr-darkoverlay",displayName:"Dark Overlay",group:"Transition",type:"boolean",default:!0,plug:"input"}),t.push({name:"tr-darkoverlayamount",displayName:"Dark Overlay Amount",group:"Transition",type:"number",default:.5,plug:"input"}),t.push({name:"tr-timing",displayName:"Timing",group:"Transition",type:"curve",plug:"input"}),t}},Popup:class extends o{constructor(e,t,n){super(),this.from=e,this.to=t,this.timing=n.timing||{curve:[0,0,.58,1],dur:300,delay:0},this.distance=n.shift||{value:25,unit:"%"},"number"==typeof this.distance&&(this.distance={value:this.distance,unit:"%"}),this.direction=n.direction||"Right",this.timing.curve[0]=Math.min(1,Math.max(0,this.timing.curve[0])),this.timing.curve[2]=Math.min(1,Math.max(0,this.timing.curve[2])),this.ease=s().apply(null,this.timing.curve).get,this.fadein=void 0!==n.fadein&&n.fadein,this.zoom=n.zoom||{value:25,unit:"%"},"number"==typeof this.zoom&&(this.zoom={value:this.zoom,unit:"%"})}update(e){if("In"===this.direction||"Out"===this.direction){let t=this.zoom.value/100;t="Out"===this.direction?-t:t,this.to.setStyle({transform:"scale("+(1-t*(1-e))+")",opacity:this.crossfade?e:1})}else{const t=this.distance.value,n=this.distance.unit,o={Up:{x:0,y:-1},Down:{x:0,y:1},Left:{x:-1,y:0},Right:{x:1,y:0}},i={x:o[this.direction].x*t,y:o[this.direction].y*t};this.to.setStyle({transform:"translate("+i.x*(e-1)+n+","+i.y*(e-1)+n+")",opacity:this.fadein?e:1})}}forward(e){const t=this.ease(e);this.update(t)}back(e){const t=this.ease(e);this.update(1-t)}static ports(e){const t=[];return t.push({name:"tr-direction",displayName:"Direction",group:"Transition",type:{name:"enum",enums:["Right","Left","Up","Down","In","Out"]},default:"Right",plug:"input"}),"In"===e["tr-direction"]||"Out"===e["tr-direction"]?t.push({name:"tr-zoom",displayName:"Zoom",group:"Transition",type:{name:"number",units:["%"]},default:{value:25,unit:"%"},plug:"input"}):t.push({name:"tr-shift",displayName:"Shift Distance",group:"Transition",type:{name:"number",units:["%","px"]},default:{value:25,unit:"%"},plug:"input"}),t.push({name:"tr-fadein",displayName:"Fade In",group:"Transition",type:"boolean",default:!1,plug:"input"}),t.push({name:"tr-timing",displayName:"Timing",group:"Transition",type:"curve",plug:"input"}),t}}}},7183:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i});var o=n(2004);const i={name:"net.noodl.animatetovalue",docs:"https://docs.noodl.net/nodes/logic/animate-to-value",displayName:"Animate To Value",shortDesc:"This node can interpolate smoothly from the current value to a target value.",category:"Animation",initialize(){const e=this._internal;e.currentNumber=0,e.numberInitialized=!1,e.animationStarted=!1,e.setCurrentNumberEnabled=!1,e.overrideValue=0,e._animation=this.context.timerScheduler.createTimer({duration:300,startValue:0,endValue:0,ease:o.A.easeOut,onStart:()=>{e.animationStarted=!0},onRunning:t=>{e.currentNumber=this.ease(this.startValue,this.endValue,t),this.flagOutputDirty("currentValue")},onFinish:()=>{this.sendSignalOnOutput("atTargetValue")}})},getInspectInfo(){return this._internal.currentNumber},inputs:{targetValue:{type:{name:"number"},displayName:"Target Value",group:"Target Value",default:void 0,set(e){if(!0===e?e=1:!1===e&&(e=0),e=Number(e),isNaN(e))return;const t=this._internal;if(!t.numberInitialized)return t.currentNumber=e,t.numberInitialized=!0,t._animation.endValue=e,void this.flagOutputDirty("currentValue");e!==t._animation.endValue&&(t._animation.startValue=t.currentNumber,t._animation.endValue=e,t._animation.start())}},duration:{type:"number",group:"Parameters",displayName:"Duration",default:300,set(e){this._internal._animation.duration=e}},delay:{type:"number",group:"Parameters",displayName:"Delay",default:0,set(e){this._internal._animation.delay=e}},easingCurve:{type:{name:"enum",enums:[{value:"easeOut",label:"Ease Out"},{value:"easeIn",label:"Ease In"},{value:"linear",label:"Linear"},{value:"easeInOut",label:"Ease In Out"}]},default:"easeOut",displayName:"Easing Curve",group:"Parameters",set(e){this._internal._animation.ease=o.A[e]}}},outputs:{currentValue:{type:"number",displayName:"Current Value",group:"Current State",getter(){return this._internal.currentNumber}},atTargetValue:{type:"signal",displayName:"At Target Value",group:"Signals"}}}},374:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>d});var o=n(2004);function i(e,t){for(let n=0;n<3;++n){const o=1+2*n;e[n]=parseInt(t.substring(o,o+2),16)}}function s(e){const t=e.toString(16);return 1===t.length?"0"+t:t}let r=[0,0,0],a=[0,0,0],l=[0,0,0];const d={name:"Color Blend",docs:"https://docs.noodl.net/nodes/utilities/color-blend",shortDesc:"Given any number of input colors this node can interpolate between these and give the result color as output.",category:"Interpolation",getInspectInfo(){return[{type:"color",value:this._internal.resultColor}]},initialize(){const e=this._internal;e.resultColor="#000000",e.blendValue=0,e.colors=[]},numberedInputs:{color:{type:"color",displayPrefix:"Color",createSetter(e){return t=>{this._internal.colors[e]=t,this.updateColor()}}}},inputs:{blendValue:{type:"number",displayName:"Blend Value",default:0,set(e){this._internal.blendValue=e,this.updateColor()}}},outputs:{result:{type:"color",displayName:"Result",getter(){return this._internal.resultColor}}},methods:{updateColor(){const e=this._internal.colors;if(0===e.length)return;const t=t=>e[t]?e[t]:"#000000",n=(d=e.length-1,u=this._internal.blendValue,Math.max(0,Math.min(d,u)));var d,u;const c=Math.floor(n),p=n-c;var h;0===p?this._internal.resultColor=t(c):(i(r,t(c)),i(a,t(c+1)),l[0]=Math.floor(o.A.linear(r[0],a[0],p)),l[1]=Math.floor(o.A.linear(r[1],a[1],p)),l[2]=Math.floor(o.A.linear(r[2],a[2],p)),this._internal.resultColor="#"+s((h=l)[0])+s(h[1])+s(h[2])),this.flagOutputDirty("result")}}}},2390:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i});var o=n(260);const i={name:"CloudFunction2",displayName:"Cloud Function",category:"Cloud Services",color:"data",usePortAsLabel:"function",docs:"https://docs.noodl.net/nodes/data/cloud-data/cloud-function",_internal:{paramsValues:{},resultsValues:{}},initialize:function(){this._internal.paramsValues={},this._internal.resultsValues={}},getInspectInfo(){const e=this._internal.lastCallResult;return e?[{type:"value",value:e}]:"[Not executed yet]"},inputs:{call:{type:"signal",displayName:"Call",group:"Actions",valueChangedToTrue:function(){this.scheduleCall()}}},outputs:{success:{type:"signal",displayName:"Success",group:"Signals"},failure:{type:"signal",displayName:"Failure",group:"Signals"},error:{type:"string",displayName:"Error",group:"Error",getter:function(){return this._internal.error}}},methods:{setError:function(e){this._internal.error=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure")},getResultsValue:function(e){return this._internal.resultsValues[e]},registerOutputIfNeeded:function(e){this.hasOutput(e)||e.startsWith("out-")&&this.registerOutput(e,{getter:this.getResultsValue.bind(this,e.substring(4))})},setParamsValue:function(e,t){this._internal.paramsValues[e]=t},setFunctionName:function(e){this._internal.functionName=e},registerInputIfNeeded:function(e){this.hasInput(e)||("function"===e&&this.registerInput(e,{set:this.setFunctionName.bind(this)}),e.startsWith("in-")&&this.registerInput(e,{set:this.setParamsValue.bind(this,e.substring(3))}))},scheduleCall:function(){const e=this._internal;e.hasScheduledCall||(e.hasScheduledCall=!0,this.scheduleAfterInputsHaveUpdated(this.doCall.bind(this)))},doCall:function(){this._internal.hasScheduledCall=!1;const e=o.default.instance.getMetaData("cloudservices");this.context.editorConnection&&(void 0===e||void 0===e.endpoint?this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"cloud-function-2",{message:"No cloud services defined in this project."}):void 0===this._internal.functionName?this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"cloud-function-2",{message:"No function specified"}):this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"cloud-function-2"));const t=e.appId,n=this.context.editorConnection.isRunningLocally()?`http://${window.location.hostname}:8577`:e.endpoint;!function(e,t){const n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState){let e;try{e=JSON.parse(n.response)}catch(e){}200===n.status||201===n.status?t.success(e):t.error(e)}},n.open(t.method||"GET",t.endpoint+e,!0),n.setRequestHeader("X-Parse-Application-Id",t.appId),n.setRequestHeader("Content-Type","application/json");const i=o.default.instance.getMetaData("cloudservices");i&&i.deployVersion&&n.setRequestHeader("x-noodl-cloud-version",i.deployVersion);const s=localStorage["Parse/"+t.appId+"/currentUser"];if(void 0!==s)try{const e=JSON.parse(s);n.setRequestHeader("X-Parse-Session-Token",e.sessionToken)}catch(e){}n.send(JSON.stringify(t.content))}("/functions/"+encodeURIComponent(this._internal.functionName),{appId:t,endpoint:n,content:this._internal.paramsValues,method:"POST",success:e=>{if(void 0===e)this._internal.lastCallResult={status:"success",parameters:this._internal.paramsValues,results:"empty"};else{const t=e.result||{};for(let e in t)this._internal.resultsValues[e]=t[e],this.hasOutput("out-"+e)&&this.flagOutputDirty("out-"+e);this._internal.lastCallResult={status:"success",parameters:this._internal.paramsValues,results:this._internal.resultsValues}}this.sendSignalOnOutput("success")},error:e=>{const t="string"==typeof e?e:e.error||"Failed running cloud function.";this._internal.lastCallResult={status:"failure",error:t},this.setError(t)}})}}}},6439:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i});var o=n(260);const i={name:"CollectionClear",docs:"https://docs.noodl.net/nodes/data/array/clear-array",displayNodeName:"Clear Array",category:"Data",usePortAsLabel:"collectionId",color:"data",inputs:{collectionId:{type:{name:"string",identifierOf:"CollectionName",identifierDisplayName:"Array Ids"},displayName:"Array Id",group:"General",set:function(e){e instanceof o.Collection&&(e=e.getId()),this.setCollectionID(e)}},clear:{displayName:"Do",group:"Actions",valueChangedToTrue:function(){this.scheduleAfterInputsHaveUpdated((()=>{this._internal.collection.set([]),this.sendSignalOnOutput("modified")}))}}},outputs:{modified:{group:"Events",type:"signal",displayName:"Done"}},methods:{setCollectionID:function(e){this.setCollection(o.Collection.get(e))},setCollection:function(e){this._internal.collection=e}}}},1749:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i});var o=n(260);const i={name:"CollectionInsert",docs:"https://docs.noodl.net/nodes/data/array/insert-into-array",displayNodeName:"Insert Object Into Array",shortDesc:"A collection of models, mainly used together with a For Each Node.",category:"Data",usePortAsLabel:"collectionId",color:"data",inputs:{collectionId:{type:{name:"string",identifierOf:"CollectionName",identifierDisplayName:"Array Ids"},displayName:"Array Id",group:"General",set(e){e instanceof o.Collection&&(e=e.getId()),this.setCollectionID(e)}},modifyId:{type:{name:"string",allowConnectionsOnly:!0},displayName:"Object Id",group:"Modify",set(e){this._internal.modifyId=e}},add:{displayName:"Do",group:"Actions",valueChangedToTrue:function(){const e=this._internal;this.scheduleAfterInputsHaveUpdated((()=>{if(this.context.editorConnection&&this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"insert-warning"),void 0===e.modifyId)return void(this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"insert-warning",{showGlobally:!0,message:"No Object Id specified"}));if(void 0===e.collection)return void(this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"insert-warning",{showGlobally:!0,message:"No Array Id specified"}));const t=o.Model.get(e.modifyId);e.collection.add(t),this.sendSignalOnOutput("modified")}))}}},outputs:{modified:{group:"Events",type:"signal",displayName:"Done"}},methods:{setCollectionID(e){this.setCollection(o.Collection.get(e))},setCollection(e){this._internal.collection=e}}}},4380:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i});var o=n(260);const i={name:"CollectionNew",docs:"https://docs.noodl.net/nodes/data/array/create-new-array",displayNodeName:"Create New Array",shortDesc:"A collection of models, mainly used together with a For Each Node.",category:"Data",color:"data",initialize(){},inputs:{new:{displayName:"Do",group:"Actions",valueChangedToTrue(){this.scheduleNew()}},items:{type:"array",group:"General",displayName:"Items",set(e){this._internal.sourceCollection=e}}},outputs:{id:{type:"string",displayName:"Id",group:"General",getter(){return this._internal.collection?this._internal.collection.getId():this._internal.collectionId}},created:{group:"Events",type:"signal",displayName:"Done"}},prototypeExtensions:{setCollectionID(e){this.setCollection(o.Collection.get(e))},setCollection(e){this._internal.collection=e,this.flagOutputDirty("id")},scheduleNew(){this.hasScheduledNew||(this.hasScheduledNew=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.hasScheduledNew=!1;const e=o.Collection.get();void 0!==this._internal.sourceCollection&&e.set(this._internal.sourceCollection),this.setCollection(e),this.sendSignalOnOutput("created")})))}}}},1088:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i});var o=n(260);const i={name:"CollectionRemove",docs:"https://docs.noodl.net/nodes/data/array/remove-from-array",displayNodeName:"Remove Object From Array",shortDesc:"A collection of models, mainly used together with a For Each Node.",category:"Data",usePortAsLabel:"collectionId",color:"data",initialize:function(){},inputs:{collectionId:{type:{name:"string",identifierOf:"CollectionName",identifierDisplayName:"Array Ids"},displayName:"Array Id",group:"General",set:function(e){e instanceof o.Collection&&(e=e.getId()),this.setCollectionID(e)}},modifyId:{type:{name:"string",allowConnectionsOnly:!0},displayName:"Object Id",group:"Modify",set:function(e){this._internal.modifyId=e}},remove:{displayName:"Do",group:"Actions",valueChangedToTrue:function(){const e=this,t=this._internal;this.scheduleAfterInputsHaveUpdated((function(){if(void 0===t.modifyId)return;if(void 0===t.collection)return;const n=o.Model.get(t.modifyId);t.collection.remove(n),e.sendSignalOnOutput("modified")}))}}},outputs:{modified:{group:"Events",type:"signal",displayName:"Done"}},prototypeExtensions:{setCollectionID:function(e){this.setCollection(o.Collection.get(e))},setCollection:function(e){this._internal.collection=e}}}},7397:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i});var o=n(260);const i={name:"Collection2",docs:"https://docs.noodl.net/nodes/data/array/array-node",displayNodeName:"Array",shortDesc:"A collection of models, mainly used together with a For Each Node.",category:"Data",usePortAsLabel:"collectionId",color:"data",initialize(){let e=!1;this._internal.collectionChangedCallback=()=>{this.isInputConnected("fetch")||e||(e=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.sendSignalOnOutput("changed"),this.flagOutputDirty("firstItemId"),this.flagOutputDirty("count"),e=!1})))},this._internal.sourceCollectionChangedCallback=()=>{this.isInputConnected("store")||this.scheduleCopyItems()}},getInspectInfo(){const e=this._internal.collection;return e?[{type:"text",value:"Id: "+e.getId()},{type:"value",value:e.items}]:{type:"text",value:"[No Array]"}},inputs:{collectionId:{type:{name:"string",identifierOf:"CollectionName",identifierDisplayName:"Array Ids"},displayName:"Id",group:"General",set(e){e instanceof o.Collection&&(e=e.getId()),this._internal.collectionId=e,this.isInputConnected("fetch")?this.flagOutputDirty("id"):this.setCollectionID(e)}},items:{type:"array",group:"General",displayName:"Items",set(e){void 0!==e&&e!==this._internal.collection&&(this._internal.pendingSourceCollection=e,this.isInputConnected("store")||this.scheduleAfterInputsHaveUpdated((()=>{this.setSourceCollection(e)})))}},fetch:{displayName:"Fetch",group:"Actions",valueChangedToTrue(){this.scheduleSetCollection()}}},outputs:{id:{type:"string",displayName:"Id",group:"General",getter(){return this._internal.collection?this._internal.collection.getId():this._internal.collectionId}},items:{type:"array",displayName:"Items",group:"General",getter(){return this._internal.collection}},firstItemId:{type:"string",displayName:"First Item Id",group:"General",getter(){if(this._internal.collection){const e=this._internal.collection.get(0);if(void 0!==e)return e.getId()}}},count:{type:"number",displayName:"Count",group:"General",getter(){return this._internal.collection?this._internal.collection.size():0}},changed:{group:"Events",type:"signal",displayName:"Changed"},fetched:{group:"Events",type:"signal",displayName:"Fetched"}},prototypeExtensions:{setCollectionID(e){this.setCollection(o.Collection.get(e))},setCollection(e){this._internal.collection&&this._internal.collection.off("change",this._internal.collectionChangedCallback),this._internal.collection=e,this.flagOutputDirty("id"),e.on("change",this._internal.collectionChangedCallback),this.flagOutputDirty("items"),this.flagOutputDirty("firstItemId"),this.flagOutputDirty("count")},setSourceCollection(e){const t=this._internal;t.sourceCollection&&t.sourceCollection instanceof o.Collection&&t.sourceCollection.off("change",t.sourceCollectionChangedCallback),t.sourceCollection=e,t.sourceCollection instanceof o.Collection&&t.sourceCollection.on("change",t.sourceCollectionChangedCallback),this._copySourceItems()},scheduleSetCollection(){this.hasScheduledSetCollection||(this.hasScheduledSetCollection=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.hasScheduledSetCollection=!1,this.setCollectionID(this._internal.collectionId),this.sendSignalOnOutput("fetched")})))},scheduleStore(){if(this.hasScheduledStore)return;this.hasScheduledStore=!0;const e=this._internal;this.scheduleAfterInputsHaveUpdated((()=>{this.hasScheduledStore=!1,this.setSourceCollection(e.pendingSourceCollection)}))},_copySourceItems(){const e=this._internal;void 0!==e.collection||this.isInputConnected("fetch")||this.setCollection(o.Collection.get()),e.collection&&e.collection.set(e.sourceCollection)},scheduleCopyItems(){this.hasScheduledCopyItems||(this.hasScheduledCopyItems=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.hasScheduledCopyItems=!1,this._copySourceItems()})))},_onNodeDeleted(){Node.prototype._onNodeDeleted.call(this),this._internal.collection&&this._internal.collection.off("change",this._internal.collectionChangedCallback)}}}},2653:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>s,setup:()=>l});var o=n(260);const i=function(e,t){e instanceof o.Model&&(e=e.data),t instanceof o.Model&&(t=t.data);for(const n in this){const o=e[n],i=t[n];if(o!==i)return"string"==typeof o&&"string"==typeof i?1===this[n]?o>i?1:-1:o>i?-1:1:"number"==typeof o&&"number"==typeof i?1===this[n]?o-i:i-o:1===this[n]?o>i?1:-1:o>i?-1:1}return 0},s={name:"Filter Collection",docs:"https://docs.noodl.net/nodes/data/array/array-filter",displayNodeName:"Array Filter",shortDesc:"Filter, sort and limit array",category:"Data",color:"data",initialize:function(){this._internal.collectionChangedCallback=()=>{!0!==this.isInputConnected("filter")&&this.scheduleFilter()},this._internal.enabled=!0,this._internal.filterSettings={}},getInspectInfo(){const e=this._internal.filteredCollection;return e?[{type:"text",value:"Id: "+e.getId()},{type:"value",value:e.items}]:{type:"text",value:"[Not executed yet]"}},inputs:{items:{type:"array",displayName:"Items",group:"General",set(e){this.bindCollection(e),this.isInputConnected("filter")||this.scheduleFilter()}},enabled:{type:"boolean",group:"General",displayName:"Enabled",default:!0,set:function(e){this._internal.enabled=e,this.isInputConnected("filter")||this.scheduleFilter()}},filter:{type:"signal",group:"Actions",displayName:"Filter",valueChangedToTrue:function(){this.scheduleFilter()}}},outputs:{items:{type:"array",displayName:"Items",group:"General",getter:function(){return this._internal.filteredCollection}},firstItemId:{type:"string",displayName:"First Item Id",group:"General",getter:function(){if(void 0!==this._internal.filteredCollection){const e=this._internal.filteredCollection.get(0);if(void 0!==e)return e.getId()}}},count:{type:"number",displayName:"Count",group:"General",getter:function(){return this._internal.filteredCollection?this._internal.filteredCollection.size():0}},modified:{group:"Events",type:"signal",displayName:"Filtered"}},prototypeExtensions:{unbindCurrentCollection:function(){const e=this._internal.collection;e&&(e.off("change",this._internal.collectionChangedCallback),this._internal.collection=void 0)},bindCollection:function(e){this.unbindCurrentCollection(),this._internal.collection=e,e&&e.on("change",this._internal.collectionChangedCallback)},_onNodeDeleted:function(){o.Node.prototype._onNodeDeleted.call(this),this.unbindCurrentCollection()},getFilter:function(){const e=this._internal.filterSettings,t=["case"];if(e.filterFilter){const n=e.filterFilter.split(","),o={};return n.forEach((n=>{const i="$"+(e["filterFilterOp-"+n]||"eq");o[n]={},o[n][i]=e["filterFilterValue-"+n],t.forEach((t=>{const i=e["filterFilterOption-"+t+"-"+n];i&&(o[n]["$"+t]=i)}))})),o}},getSort:function(){const e=this._internal.filterSettings;if(e.filterSort){const t=e.filterSort.split(","),n={};return t.forEach((t=>{n[t]="descending"===e["filterSort-"+t]?-1:1})),n}},getLimit:function(){const e=this._internal.filterSettings;if(e.filterEnableLimit)return e.filterLimit||10},getSkip:function(){const e=this._internal.filterSettings;if(e.filterEnableLimit)return e.filterSkip||0},scheduleFilter:function(){this.collectionChangedScheduled||(this.collectionChangedScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{if(this.collectionChangedScheduled=!1,!this._internal.collection)return;let e=[].concat(this._internal.collection.items);if(this._internal.enabled){const t=this.getFilter();t&&(e=e.filter((e=>((e,t)=>{for(const n in t){const o=t[n];if(void 0!==o.$neq){if(e[n]==o.$neq)return!1}else{if(void 0===e[n])return!1;if(void 0!==o.$eq&&e[n]!=o.$eq)return!1;if(!(void 0===o.$gt||e[n]>o.$gt))return!1;if(!(void 0===o.$lt||e[n]=o.$gte))return!1;if(!(void 0===o.$lte||e[n]<=o.$lte))return!1;if(void 0!==o.$regex){const t=e[n]+"";if(!new RegExp(o.$regex,!0!==o.$case?"i":void 0).test(t))return!1}}}return!0})(e.data,t))));const n=this.getSort();n&&e.sort(i.bind(n));const o=this.getSkip();o&&(e=e.slice(o,e.length));const s=this.getLimit();s&&(e=e.slice(0,s))}this._internal.filteredCollection=o.Collection.create(e),this.sendSignalOnOutput("modified"),this.flagOutputDirty("firstItemId"),this.flagOutputDirty("items"),this.flagOutputDirty("count")})))},registerInputIfNeeded:function(e){this.hasInput(e)||this.registerInput(e,{set:r.bind(this,e)})}}};function r(e,t){this._internal.filterSettings[e]=t,this.isInputConnected("filter")||this.scheduleFilter()}function a(e,t,n,o){const i=[];i.push({type:"boolean",plug:"input",group:"Limit",name:"filterEnableLimit",displayName:"Use limit"}),t.filterEnableLimit&&(i.push({type:"number",default:10,plug:"input",group:"Limit",name:"filterLimit",displayName:"Limit"}),i.push({type:"number",default:0,plug:"input",group:"Limit",name:"filterSkip",displayName:"Skip"})),i.push({type:{name:"stringlist",allowEditOnly:!0},plug:"input",group:"Filter",name:"filterFilter",displayName:"Filter"}),i.push({type:{name:"stringlist",allowEditOnly:!0},plug:"input",group:"Sort",name:"filterSort",displayName:"Sort"});const s={string:[{value:"eq",label:"Equals"},{value:"neq",label:"Not Equals"},{value:"regex",label:"Matches RegEx"}],boolean:[{value:"eq",label:"Equals"},{value:"neq",label:"Not Equals"}],number:[{value:"eq",label:"Equals"},{value:"neq",label:"Not Equals"},{value:"lt",label:"Less than"},{value:"gt",label:"Greater than"},{value:"gte",label:"Greater than or equal"},{value:"lte",label:"Less than or equal"}]};t.filterFilter&&t.filterFilter.split(",").forEach((e=>{i.push({type:{name:"enum",enums:[{value:"string",label:"String"},{value:"number",label:"Number"},{value:"boolean",label:"Boolean"}]},default:"string",plug:"input",group:e+" filter",displayName:"Type",editorName:e+" filter | Type",name:"filterFilterType-"+e});const n=t["filterFilterType-"+e];i.push({type:{name:"enum",enums:s[n||"string"]},default:"eq",plug:"input",group:e+" filter",displayName:"Op",editorName:e+" filter| Op",name:"filterFilterOp-"+e}),"regex"===t["filterFilterOp-"+e]&&i.push({type:"boolean",default:!1,plug:"input",group:e+" filter",displayName:"Case sensitive",editorName:e+" filter| Case",name:"filterFilterOption-case-"+e}),i.push({type:n||"string",plug:"input",group:e+" filter",displayName:"Value",editorName:e+" Filter Value",name:"filterFilterValue-"+e})})),t.filterSort&&t.filterSort.split(",").forEach((e=>{i.push({type:{name:"enum",enums:[{value:"ascending",label:"Ascending"},{value:"descending",label:"Descending"}]},default:"ascending",plug:"input",group:e+" sort",displayName:"Sort",editorName:e+" sorting",name:"filterSort-"+e})})),n.sendDynamicPorts(e,i)}function l(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("nodeAdded.Filter Collection",(function(n){a(n.id,n.parameters,e.editorConnection,t.getMetaData("dbCollections")),n.on("parameterUpdated",(function(o){o.name.startsWith("filter")&&a(n.id,n.parameters,e.editorConnection,t.getMetaData("dbCollections"))})),t.on("metadataChanged.dbCollections",(function(t){a(n.id,n.parameters,e.editorConnection)}))}))}},5071:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>l,setup:()=>d});var o=n(1594),i=n.n(o),s=n(260);const r=e=>{const{didMount:t,willUnmount:n}=e;return(0,o.useEffect)((()=>(t(),()=>{n()})),[t,n]),null};function a(e){return"object"==typeof e?e.name:e}const l={name:"For Each",displayNodeName:"Repeater",docs:"https://docs.noodl.net/nodes/ui-controls/repeater",color:"visual",category:"Visual",dynamicports:[{name:"conditionalports/extended",condition:"templateType = explicit OR templateType NOT SET",inputs:["template"]},{name:"conditionalports/extended",condition:"templateType = dynamic",inputs:["templateScript"]}],initialize(){this._internal.itemNodes=[],this._internal.itemOutputSignals={},this._internal.itemOutputs={},this._internal.collection=s.Collection.get(),this._internal.queuedOperations=[],this._internal.mountedOperations=[],this._internal.collection.on("add",(async e=>{this._internal.target&&this._queueOperation((async()=>{const t=this._internal.target.getChildren().indexOf(this)+1;await this.addItem(e.item,t+e.index)}))})),this._internal.collection.on("remove",(e=>{this._queueOperation((()=>{this.removeItem(e.item)}))})),this._internal.onItemsCollectionChanged=()=>{s.default.instance.getProjectSettings().repeaterDisabledWhenUnmounted&&!this.isMounted?this._internal.mountedOperations.push((()=>{this._internal.collection.set(this._internal.items)})):this._queueOperation((()=>{this._internal.collection.set(this._internal.items)}))},this.addDeleteListener((()=>{this._deleteAllItemNodes()}))},inputs:{items:{group:"Data",displayName:"Items",type:"array",set(e){e&&e!==this._internal.items&&this.bindCollection(e)}},templateType:{group:"Appearance",displayName:"Template Type",type:{name:"enum",enums:[{label:"Explicit",value:"explicit"},{label:"Dynamic",value:"dynamic"}]},default:"explicit",set(e){this._internal.templateType=e,this.scheduleRefresh()}},template:{type:"component",displayName:"Template",group:"Appearance",set(e){this._internal.template=e,this.scheduleRefresh()}},templateScript:{type:{name:"string",codeeditor:"javascript",allowEditOnly:!0},displayName:"Script",group:"Appearance",default:"// Set the 'component' variable to the name of the desired component for this item.\n// Component name must start with a '/'.\n// A component in a sheet is referred to by '/#Sheet Name/Comopnent Name'.\n// The data for each item is available in a variable called 'item'\ncomponent = '/MyComponent';",set(e){try{this._internal.templateFunction=new Function("item","var component;"+e+";return component;")}catch(e){console.log(e),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"foreach-syntax-warning",{message:"Syntax: "+e.message})}this.scheduleRefresh()}},refresh:{group:"Appearance",displayName:"Refresh",type:"signal",valueChangedToTrue(){this.scheduleRefresh()}}},outputs:{itemActionItemId:{type:"string",group:"Actions",displayName:"Item Id",getter(){return this._internal.itemActionItemId}}},prototypeExtensions:{updateTarget(e){this._internal.target=e?this.nodeScope.getNodeWithId(e):void 0,this.scheduleRefresh()},setNodeModel(e){s.Node.prototype.setNodeModel.call(this,e),e.parent&&this.updateTarget(e.parent.id);var t=this;e.on("parentUpdated",(function(e){t.updateTarget(e?e.id:void 0)}),this)},scheduleRefresh(){var e=this._internal;e.hasScheduledRefresh||(e.hasScheduledRefresh=!0,this.scheduleAfterInputsHaveUpdated((()=>{this._queueOperation((()=>{this.refresh()}))})))},unbindCurrentCollection(){var e=this._internal.items;e&&(s.Collection.instanceOf(e)&&e.off("change",this._internal.onItemsCollectionChanged),this._internal.items=void 0)},bindCollection(e){var t=this._internal;this.unbindCurrentCollection(),s.Collection.instanceOf(e)&&e.on("change",this._internal.onItemsCollectionChanged),t.items=e,this.scheduleCopyItems()},getTemplateForModel(e){var t=this._internal;if(void 0===t.templateType||"explicit"===t.templateType)return t.template;if(t.templateFunction){try{var n=t.templateFunction(e)}catch(e){console.log(e),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"foreach-dynamic-warning",{message:"Dynamic template: "+e.message})}if(n&&(n.startsWith("./")&&(n=this.model.component.name+n.substring(1)),n.startsWith("../"))){const e=this.model.component.name.split("/");n=e.slice(0,e.length-1).join("/")+n.substring(2)}return n}},_mapInputs(e,t){void 0!==this._internal.inputMapFunc&&this._internal.inputMapFunc((function(n){for(var o in n)e.hasInput(o)&&("function"==typeof n[o]?e.setInputValue(o,n[o](t)):"string"==typeof n[o]&&e.setInputValue(o,t.get(n[o])))}),t)},addItem:async function(e,t){var n=this._internal,o=this.getTemplateForModel(e);if(o){var i=await this.nodeScope.createNode(o,(0,s.guid)(),{_forEachModel:e,_forEachNode:this});if(void 0===this._internal.inputMapFunc){for(var r in i.hasInput("Id")&&i.setInputValue("Id",e.getId()),i.hasInput("id")&&i.setInputValue("id",e.getId()),i._inputs)void 0!==e.data[r]&&i.setInputValue(r,e.data[r]);i._forEachModelChangeListener=function(e){i._inputs[e.name]&&i.setInputValue(e.name,e.value)},e.on("change",i._forEachModelChangeListener),i.componentModel.on("inputPortAdded",(t=>{"id"===t.name&&i.setInputValue("id",e.getId()),"Id"===t.name&&i.setInputValue("Id",e.getId()),void 0!==e.data[t.name]&&i.setInputValue(t.name,e.data[t.name])}),this)}else this._mapInputs(i,e),i._forEachModelChangeListener=()=>this._mapInputs(i,e),e.on("change",i._forEachModelChangeListener);i._internal.creatorCallbacks={onOutputChanged:(t,o,s)=>{!1!==s&&void 0!==s||!0!==o||!n.itemOutputSignals[t]||this.itemOutputSignalTriggered(t,e,i)}};for(var a=i.nodeScope.getNodesWithType("For Each Actions"),l=0;l0?(n._forEachRemoveInProgress=!0,o[0].tryRemove((()=>this._deleteItem(n)))):this._deleteItem(n);var i=t.itemNodes.indexOf(n);-1!==i&&t.itemNodes.splice(i,1)}}},_deleteItem(e){e._forEachModel.off("change",e._forEachModelChangeListener),e.model&&e.model.removeListenersWithRef(this),e.componentModel&&e.componentModel.removeListenersWithRef(this);const t=e.parent;!e._deleted&&t&&(t.removeChild(e),this.nodeScope.deleteNode(e))},_deleteAllItemNodes(){if(this._internal.itemNodes){for(const e of this._internal.itemNodes)this._deleteItem(e);this._internal.itemNodes=[]}},refresh:async function(){var e=this._internal;if(e.hasScheduledRefresh=!1,!e.template&&!e.templateFunction||!e.items)return;if(this._deleteAllItemNodes(),!e.target)return;const t=this._internal.target.getChildren().indexOf(this)+1;for(var n=0;n{const t=performance.now();for(;this._internal.queuedOperations.length&&performance.now()-t<25;){const e=this._internal.queuedOperations.shift();await e()}this._internal.queuedOperations.length?setTimeout(e,0):this.runningOperations=!1};e()}else{for(;this._internal.queuedOperations.length;){const e=this._internal.queuedOperations.shift();await e()}this.runningOperations=!1}},_onNodeDeleted(){s.Node.prototype._onNodeDeleted.call(this),this._internal.queuedOperations.length=0,this.unbindCurrentCollection()},render(){return i().createElement(r,{key:this.id,didMount:()=>this.didMount(),willUnmount:()=>this.willUnmount()})},didMount(){this.isMounted=!0;for(const e of this._internal.mountedOperations)this._queueOperation(e);this._internal.mountedOperations=[]},willUnmount(){this.isMounted=!1},getItemActionParameter(e){if(this._internal.itemActionParameters)return this._internal.itemActionParameters[e]},scheduleCopyItems(){this._internal.hasScheduledCopyItems||(this._internal.hasScheduledCopyItems=!0,this.scheduleAfterInputsHaveUpdated((()=>{this._internal.hasScheduledCopyItems=!1,void 0!==this._internal.items&&(s.default.instance.getProjectSettings().repeaterDisabledWhenUnmounted&&!this.isMounted?this._internal.mountedOperations.push((()=>{this._internal.collection.set(this._internal.items)})):this._internal.collection.set(this._internal.items))})))},itemOutputSignalTriggered(e,t,n){this._internal.itemActionItemId=t.getId(),this._internal.itemActionSignal=e,this.flagOutputDirty("itemActionItemId"),this._internal.hasScheduledTriggerItemOutputSignal||(this._internal.hasScheduledTriggerItemOutputSignal=!0,this.context.scheduleAfterUpdate((()=>{for(var e in this._internal.hasScheduledTriggerItemOutputSignal=!1,n._outputs){var t="itemOutput-"+e;this.hasOutput(t)&&(this._internal.itemOutputs[e]=n._outputs[e].value,this.flagOutputDirty(t))}this.sendSignalOnOutput("itemOutputSignal-"+this._internal.itemActionSignal)})))},getItemOutput(e){return this._internal.itemOutputs[e]},registerOutputIfNeeded(e){this.hasOutput(e)||(e.startsWith("itemOutputSignal-")?(this._internal.itemOutputSignals[e.substring(17)]=!0,this.registerOutput(e,{getter(){}})):e.startsWith("itemOutput-")&&this.registerOutput(e,{getter:this.getItemOutput.bind(this,e.substring(11))}))},setInputMappingScript(e){if(this.context.editorConnection&&this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"foreach-inputmapping-warning"),this._internal.inputMappingScript=e,this._internal.inputMappingScript)try{this._internal.inputMapFunc=new Function("map","object",this._internal.inputMappingScript)}catch(e){this._internal.inputMapFunc=void 0,this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"foreach-inputmapping-warning",{message:"Input mapping: "+e.message})}else this._internal.inputMapFunc=void 0;this.scheduleRefresh()},registerInputIfNeeded(e){if(!this.hasInput(e))return"inputMappingScript"===e?this.registerInput(e,{set:this.setInputMappingScript.bind(this)}):void 0}}},d=function(e,t){function n(n){function o(){var o=n.parameters.template;if(void 0!==o){var i=[],s=t.components[o];if(void 0!==s){for(var r in s.outputPorts)"signal"===a((u=s.outputPorts[r]).type)?i.push({name:"itemOutputSignal-"+r,displayName:r,type:"signal",plug:"output",group:"Item Signals"}):i.push({name:"itemOutput-"+r,displayName:r,type:u.type,plug:"output",group:"Item Outputs"});var l="";for(var d in s.inputPorts){var u;"signal"!==a((u=s.inputPorts[d]).type)&&(l+="\t'"+d+"': '"+d+"',\n")}i.push({name:"inputMappingScript",type:{name:"string",codeeditor:"javascript"},displayName:"Script",group:"Input Mapping",default:"// Here you add mappings between the properties of the item objects and the inputs of the components.\n// 'myComponentInput': 'myObjectProperty',\n// 'anotherComponentInput'() { return object.get('someProperty') + ' ' + object.get('otherProp') }\n// These are the default mappings based on the selected template component.\nmap({\n{{#mappings}}})\n".replace("{{#mappings}}",l),plug:"input"}),e.editorConnection.sendDynamicPorts(n.id,i,{detectRenamed:{plug:"output",prefix:"itemOutput"}})}}}function i(e){if(void 0!==e){var n=t.components[e];void 0!==n&&(n.on("outputPortAdded",o),n.on("outputPortRemoved",o),n.on("outputPortTypesUpdated",o),n.on("inputPortTypesUpdated",o),n.on("inputPortAdded",o),n.on("inputPortRemoved",o))}}o(),i(n.parameters.template),n.on("parameterUpdated",(function(e){"template"===e.name&&(o(),i(n.parameters.template))}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.For Each",(function(e){n(e)}));for(const e of t.getNodesWithType("For Each"))n(e)}))}},1358:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i});var o=n(260);const i={name:"For Each Actions",docs:"https://docs.noodl.net/nodes/ui-controls/repeater-item",displayNodeName:"Repeater Item",category:"Data",color:"data",inputs:{removeCompleted:{type:{name:"boolean",allowConnectionsOnly:!0},displayName:"Remove Completed",group:"Events",valueChangedToTrue:function(){this._internal.removeCompletedCallback&&this._internal.removeCompletedCallback()}}},outputs:{added:{type:"signal",displayName:"Added",group:"Events"},tryRemove:{type:"signal",displayName:"Try Remove",group:"Events"},itemId:{type:"string",displayName:"Item Id",group:"General",get(){return this.getItemId()}}},prototypeExtensions:{getItemId(){const e=this.nodeScope.componentOwner._forEachModel;return e&&e.getId()},signalAdded:function(){this.sendSignalOnOutput("added")},tryRemove:function(e){this.getOutput("tryRemove").hasConnections()?(this._internal.removeCompletedCallback=e,this.sendSignalOnOutput("tryRemove")):this.scheduleAfterInputsHaveUpdated((function(){e()}))},itemActionTriggered(e){this.scheduleAfterInputsHaveUpdated((()=>{const t=this.getItemId();this.nodeScope.componentOwner._forEachNode.signalItemAction(e,t,this._internal.actionParameters||{})}))},setItemActionParameter(e){this._internal.actionParameters||(this._internal.actionParameters={}),this._internal.actionParameters[e]=e},registerInputIfNeeded:function(e){if(!this.hasInput(e))return e.startsWith("itemAction-")?this.registerInput(e,{set:(0,o.createSetter)({valueChangedToTrue:this.itemActionTriggered.bind(this,e)})}):e.startsWith("itemActionParameter-")?this.registerInput(e,{set:this.setItemActionParameter.bind(this,e)}):void 0}}}},7949:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i});var o=n(260);const i={name:"Map Collection",docs:"https://docs.noodl.net/nodes/data/array/array-map",displayNodeName:"Array Map",shortDesc:"Map array fields",category:"Data",color:"data",initialize:function(){this._internal.collectionChangedCallback=()=>{this.scheduleMap()}},inputs:{items:{type:"array",displayName:"Items",group:"General",set:function(e){this.setCollection(e),this.scheduleMap()}},mapScript:{type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},displayName:"Script",default:"map({\n\t// Here you add mappings between the input object and the mapped output object.\n\t//myOutputProp: 'inputProp',\n\t//anotherProperty: function(object) { return object.get('someProperty') + ' ' + object.get('otherProp') }\n})\n",set:function(e){this._internal.mapCode=e;try{this._internal.mapFunc=new Function("map","object",this._internal.mapCode)}catch(e){this._internal.mapFunc=void 0,console.log("Error while parsing map script: "+e)}this.scheduleMap()}}},outputs:{items:{type:"array",displayName:"Items",group:"General",getter:function(){return this._internal.mappedCollection}},count:{type:"number",displayName:"Count",group:"General",getter:function(){return this._internal.mappedCollection?this._internal.mappedCollection.size():0}},modified:{group:"Events",type:"signal",displayName:"Changed"}},prototypeExtensions:{setCollection:function(e){this.bindCollection(e),this.flagOutputDirty("items"),this.flagOutputDirty("count")},unbindCurrentCollection:function(){const e=this._internal.collection;e&&(e.off("change",this._internal.collectionChangedCallback),this._internal.collection=void 0)},bindCollection:function(e){this.unbindCurrentCollection(),this._internal.collection=e,e&&e.on("change",this._internal.collectionChangedCallback)},_onNodeDeleted:function(){o.Node.prototype._onNodeDeleted.call(this),this.unbindCurrentCollection()},scheduleMap:function(){this.collectionChangedScheduled||(this.collectionChangedScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{if(this.collectionChangedScheduled=!1,void 0===this._internal.collection)return;const e=this._internal.collection.map((e=>{const t=o.Model.create();return this._internal.mapFunc((function(n){for(const o in n)"function"==typeof n[o]?t.set(o,n[o](e)):"string"==typeof n[o]&&t.set(o,e.get(n[o]))}),e),t}));this._internal.mappedCollection=o.Collection.create(e),this.sendSignalOnOutput("modified"),this.flagOutputDirty("items"),this.flagOutputDirty("count")})))}}}},1579:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i,setup:()=>s});var o=n(260);const i={name:"Set Variable",docs:"https://docs.noodl.net/nodes/data/variable/set-variable",category:"Data",usePortAsLabel:"name",color:"data",initialize(){this._internal.variablesModel=o.Model.get("--ndl--global-variables")},getInspectInfo(){return this._internal.name?this._internal.variablesModel.get(this._internal.name):"[No value set]"},outputs:{done:{type:"signal",displayName:"Done",group:"Events"}},inputs:{name:{type:{name:"string",identifierOf:"VariableName",identifierDisplayName:"Variable names"},displayName:"Name",group:"General",set(e){this._internal.name=e}},setWith:{type:{name:"enum",enums:[{label:"String",value:"string"},{label:"Boolean",value:"boolean"},{label:"Number",value:"number"},{label:"Empty string",value:"emptyString"},{label:"Date",value:"date"},{label:"Object",value:"object"},{label:"Array",value:"array"},{label:"Any",value:"*"}],allowEditOnly:!0},displayName:"Set as",default:"*",group:"General",set(e){this._internal.setWith=e}},do:{displayName:"Do",group:"Actions",valueChangedToTrue(){this.scheduleStore()}}},methods:{setValue(e){this._internal.value=e},scheduleStore(){if(this.hasScheduledStore)return;this.hasScheduledStore=!0;const e=this._internal;this.scheduleAfterInputsHaveUpdated((()=>{this.hasScheduledStore=!1;let t="emptyString"===e.setWith?"":e.value;"object"===e.setWith&&"string"==typeof t&&(t=o.Model.get(t)),"array"===e.setWith&&"string"==typeof t&&(t=o.Collection.get(t)),"boolean"===e.setWith&&(t=!!t),e.variablesModel.set(e.name,t,{forceChange:!0}),this.sendSignalOnOutput("done")}))},registerInputIfNeeded(e){this.hasInput(e)||"value"===e&&this.registerInput(e,{set:this.setValue.bind(this)})}}};function s(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("nodeAdded.Set Variable",(t=>{const n=()=>{var n;const o=[];"emptyString"!==t.parameters.setWith&&o.push({type:void 0!==t.parameters.setWith?t.parameters.setWith:"*",plug:"input",group:"General",name:"value",displayName:"Value"}),null===(n=e.editorConnection)||void 0===n||n.sendDynamicPorts(t.id,o)};n(),t.on("parameterUpdated",(()=>{n()}))}))}},3817:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i,setup:()=>s});var o=n(260);const i={name:"Static Data",docs:"https://docs.noodl.net/nodes/data/array/static-array",displayNodeName:"Static Array",shortDesc:"Store static data to populate a Collection with items.",category:"Data",color:"data",nodeDoubleClickAction:[{focusPort:"JSON"},{focusPort:"CSV"}],getInspectInfo(){if(this._internal.collection)return[{type:"value",value:this._internal.collection.items}]},dynamicports:[{name:"conditionalports/extended",condition:"type = csv OR type NOT SET",inputs:["csv"]},{name:"conditionalports/extended",condition:"type = json",inputs:["json"]}],inputs:{type:{type:{name:"enum",enums:[{label:"CSV",value:"csv"},{label:"JSON",value:"json"}],allowEditOnly:!0},displayName:"Type",group:"General",default:"csv",set(e){this._internal.type=e}},csv:{type:{name:"string",codeeditor:"text",allowEditOnly:!0},displayName:"CSV",group:"General",set(e){this._internal.csv=e,this.scheduleParseData()}},json:{type:{name:"string",codeeditor:"json",allowEditOnly:!0},displayName:"JSON",group:"General",set(e){this._internal.json=e,this.scheduleParseData()}}},outputs:{items:{type:"array",displayName:"Items",group:"General",getter(){return this._internal.collection}},count:{type:"number",displayName:"Count",group:"General",get(){return this._internal.collection?this._internal.collection.size():0}}},methods:{scheduleParseData(){const e=this._internal;e.hasScheduledParseData||(e.hasScheduledParseData=!0,this.scheduleAfterInputsHaveUpdated(this.parseData.bind(this)))},parseData(){const e=this._internal;if(e.hasScheduledParseData=!1,e.collection=o.Collection.get(),void 0===e.type||"csv"===e.type){const t=function(e,t=","){const n=new RegExp("(\\"+t+'|\\r?\\n|\\r|^)(?:"([^"]*(?:""[^"]*)*)"|([^"\\'+t+"\\r\\n]*))","gi"),o=[[]];let i,s;for(;(i=n.exec(e))&&s!==n.lastIndex;){s=n.lastIndex;const e=i[1];let r;e.length&&e!==t&&o.push([]),r=i[2]?i[2].replace(new RegExp('""',"g"),'"'):i[3],o[o.length-1].push(r)}return o}(e.csv),n=[],o=t[0];for(let e=1;e{"use strict";n.r(t),n.d(t,{node:()=>i});var o=n(260);const i={name:"Variable2",displayNodeName:"Variable",docs:"https://docs.noodl.net/nodes/data/variable/variable-node",category:"Data",usePortAsLabel:"name",color:"data",initialize(){const e=this._internal;this._internal.onModelChangedCallback=t=>{this.isInputConnected("fetch")||t.name!==e.name||(this.sendSignalOnOutput("changed"),this.flagOutputDirty("value"))},e.variablesModel=o.Model.get("--ndl--global-variables"),e.variablesModel.on("change",this._internal.onModelChangedCallback)},getInspectInfo(){return this._internal.name?this._internal.variablesModel.get(this._internal.name):"[No value set]"},outputs:{name:{type:"string",displayName:"Name",group:"General",getter(){return this._internal.name}},changed:{type:"signal",displayName:"Changed",group:"Events"},fetched:{type:"signal",displayName:"Fetched",group:"Events"},value:{type:"*",displayName:"Value",group:"General",getter(){const e=this._internal;if(e.name)return e.variablesModel.get(e.name)}}},inputs:{name:{type:{name:"string",identifierOf:"VariableName",identifierDisplayName:"Variable names"},displayName:"Name",group:"General",set(e){this.isInputConnected("fetch")?(this._internal.name=e,this.flagOutputDirty("name")):this.setVariableName(e)}},fetch:{displayName:"Fetch",group:"Actions",valueChangedToTrue(){this.setVariableName(this._internal.name)}},value:{type:"*",displayName:"Value",group:"General",set(e){this._internal.value=e,this.scheduleStore()}}},prototypeExtensions:{scheduleStore(){if(this.hasScheduledStore)return;this.hasScheduledStore=!0;const e=this._internal;this.scheduleAfterInputsHaveUpdated((()=>{this.hasScheduledStore=!1,e.variablesModel.set(e.name,e.value)}))},setVariableName(e){this._internal.name=e,this.flagOutputDirty("name"),this.flagOutputDirty("value"),this.sendSignalOnOutput("fetched")},_onNodeDeleted(){o.Node.prototype._onNodeDeleted.call(this),this._internal.variablesModel.off("change",this._internal.onModelChangedCallback)}}}},1391:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>o,setup:()=>i});const o={name:"Event Receiver",docs:"https://docs.noodl.net/nodes/events/receive-event",displayNodeName:"Receive Event",category:"Events",usePortAsLabel:"channelName",color:"component",initialize(){this._internal.outputValues={},this._internal.outputNames=[],this._internal.eventReceived=!1,this._internal._isEnabled=!0,this._internal.channelName=""},inputs:{enabled:{displayName:"Enabled",type:"boolean",default:!0,set(e){this._internal._isEnabled=e}},consume:{displayName:"Consume",type:{name:"enum",enums:[{label:"Never",value:"never"},{label:"Always",value:"always"}]},default:"never",set(e){this._internal.consume=e}},channelName:{type:{name:"string",identifierOf:"EventChannelName"},displayName:"Channel",set(e){this._internal.onEventReceivedCallback&&(this.context.eventSenderEmitter.removeListener(this._internal.channelName,this._internal.onEventReceivedCallback),this._internal.onEventReceivedCallback=null),this._internal.channelName=e,this.registerListenersForChannel(e)}}},outputs:{eventReceived:{displayName:"Received",type:"signal"}},prototypeExtensions:{registerOutputIfNeeded(e){this.hasOutput(e)||(this._internal.outputNames.push(e),this.registerOutput(e,{getter:()=>this._internal.outputValues[e]}))},handleEvent(e){if(this._internal._isEnabled){this.sendSignalOnOutput("eventReceived");for(const t in e)this.hasOutput(t)&&(this._internal.outputValues[t]=e[t],this.flagOutputDirty(t));return"always"===this._internal.consume}},onEventReceived(e){this.handleEvent(e)},_onNodeDeleted(){Node.prototype._onNodeDeleted.call(this),this._internal.onEventReceivedCallback&&this.context.eventSenderEmitter.removeListener(this._internal.channelName,this._internal.onEventReceivedCallback)},registerListenersForChannel(e){const t=this.context.eventSenderEmitter;this._internal.onEventReceivedCallback=this.onEventReceived.bind(this),t.on(e,this._internal.onEventReceivedCallback),this.context.eventEmitter.once("applicationDataReloaded",(()=>{this._internal.onEventReceivedCallback&&t.removeListener(e,this._internal.onEventReceivedCallback)}))},getChannelName(){return this._internal.channelName}}};function i(e,t){function n(n){let o=n.parameters.channelName;function i(){var i;const s=t.getNodesWithType("Event Sender").filter((e=>e.parameters.channelName===o)),r={};s.forEach((e=>{const t=e.parameters.payload?e.parameters.payload.split(","):[];for(const e of t)r[e]=!0}));const a=Object.keys(r).map((e=>({name:e,type:"*",plug:"output",displayName:e})));null===(i=e.editorConnection)||void 0===i||i.sendDynamicPorts(n.id,a,{detectRenamed:{plug:"output"}})}function s(e){e.on("inputPortAdded",i),e.on("inputPortRemoved",i),e.on("parameterUpdated",(function(e){"channelName"===e.name&&i()}))}i(),n.on("parameterUpdated",(function(e){"channelName"===e.name&&(o=e.value,i())})),t.getNodesWithType("Event Sender").forEach(s),t.on("nodeAdded.Event Sender",s),t.on("nodeRemoved.Event Sender",i)}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.Event Receiver",n),t.getNodesWithType("Event Receiver").forEach(n)}))}},3631:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>o,setup:()=>s});const o={name:"Event Sender",docs:"https://docs.noodl.net/nodes/events/send-event",displayNodeName:"Send Event",category:"Events",usePortAsLabel:"channelName",color:"component",exportDynamicPorts:!0,initialize:function(){this._internal.inputValues={},this._internal.channelName="",this._internal.propagation="global"},inputs:{sendEvent:{displayName:"Send",valueChangedToTrue:function(){const e=this;this.scheduleAfterInputsHaveUpdated((function(){"global"===e._internal.propagation?e.context.sendGlobalEventFromEventSender(e._internal.channelName,e._internal.inputValues):e.nodeScope.sendEventFromThisScope(e._internal.channelName,e._internal.inputValues,e._internal.propagation)}))}},channelName:{type:{name:"string",allowEditOnly:!0,identifierOf:"EventChannelName",identifierDisplayName:"Event Channels"},default:"",group:"Settings",displayName:"Channel Name",set:function(e){this._internal.channelName=e,this._internal.inputValues._channelName=e}},propagation:{type:{name:"enum",enums:[{value:"global",label:"Global"},{value:"parent",label:"Parent"},{value:"children",label:"Children"},{value:"siblings",label:"Siblings"}]},default:"global",group:"Settings",displayName:"Send to",set:function(e){this._internal.propagation=e}},payload:{type:{name:"stringlist",allowEditOnly:!0},group:"Payload"}},prototypeExtensions:{registerInputIfNeeded(e){if(this.hasInput(e))return;const t=this;this.registerInput(e,{set:function(n){t._internal.inputValues[e]=n}})}}};function i(e,t,n){const o=[];let i=t.payload;if(i){i=i.split(",");for(const e of i)o.push({type:{name:"*",allowConnectionsOnly:!0},plug:"input",group:"Payload",name:e,displayName:e})}n.sendDynamicPorts(e,o,{detectRenamed:{plug:"input"}})}function s(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("nodeAdded.Event Sender",(function(t){i(t.id,t.parameters,e.editorConnection),t.on("parameterUpdated",(function(n){i(t.id,t.parameters,e.editorConnection)}))}))}},8423:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i,setup:()=>p});var o=n(260);const i={name:"Javascript2",docs:"https://docs.noodl.net/nodes/javascript/script",displayNodeName:"Script",category:"CustomCode",color:"javascript",nodeDoubleClickAction:{focusPort:"Code"},searchTags:["javascript"],exportDynamicPorts:!0,initialize:function(){const e=this._internal;e.inputValues={},e.outputValues={},e.outputProperties={},e.runScheduled=!1,e.setupScheduled=!1,e.runNextFrameScheduled=!1,e.isWaitingForExternalFileToLoad=!1,e.useExternalFile=!1,e.runFunction=void 0,e.destroyFunction=void 0,e.setupFunction=void 0,e.hasParsedCode=!1,e.changedInputs={},e.signalScheduled={},e.killed=!1,e.inputQueue=[];const t=this;e.userFunctionScope={createComponent:e=>(e&&e.length>0&&"/"!==e[0]&&(e="/"+e),t.nodeScope.createNode(e,(0,o.guid)())),deleteComponent(e){t.nodeScope.deleteNode(e)},flagOutputDirty(e){if(!e)throw new Error("Output port name must be specified");t.flagOutputDirty(e)},runNextFrame(){e.runNextFrameScheduled||(e.runNextFrameScheduled=!0,t.context.scheduleNextFrame((function(){e.runNextFrameScheduled=!1,e.killed||r.call(t)})))},sendSignalOnOutput(e){t.sendSignalOnOutput(e)}},e.onFrameStart=l.bind(this)},dynamicports:[{condition:"useExternalFile = no OR useExternalFile NOT SET",inputs:["code"]},{condition:"useExternalFile = yes",inputs:["externalFile"]}],inputs:{scriptInputs:{type:{name:"proplist",allowEditOnly:!0},group:"Script Inputs",set(e){}},scriptOutputs:{type:{name:"proplist",allowEditOnly:!0},group:"Script Outputs",set(e){}},useExternalFile:{type:{name:"enum",enums:[{value:"yes",label:"Yes"},{value:"no",label:"No"}],allowEditOnly:!0},default:"no",displayName:"Use External File",group:"Code",set(e){this._internal.isWaitingForExternalFileToLoad="yes"===e,this._internal.useExternalFile="yes"===e}},code:{displayName:"Code",group:"Code",type:{name:"string",allowEditOnly:!0,codeeditor:"javascript"},default:"",set(e){if(!e)return;const t=this;this.scheduleAfterInputsHaveUpdated((function(){if(!1===this._internal.useExternalFile){this._callDestroyFunction();const n=o.JavascriptNodeParser.createFromCode(e,{node:this});t._onCodeParsed(n)}}))}},externalFile:{displayName:"File Path",group:"Code",type:{name:"source",allowEditOnly:!0},set(e){if(!1===this._internal.useExternalFile)return;const t=this;o.JavascriptNodeParser.createFromURL(e,(function(e){t._internal.isWaitingForExternalFileToLoad=!1,t._onCodeParsed(e)}),{node:this})}}},prototypeExtensions:{_onNodeDeleted(){o.Node.prototype._onNodeDeleted.call(this),this._internal.killed=!0,this._callDestroyFunction()},update(){!0===this._internal.isWaitingForExternalFileToLoad?this._dirty=!1:o.Node.prototype.update.call(this)},_onCodeParsed(e){const t=this.context.editorConnection;if(t)for(const e of["js-destroy-waring","js-run-waring","js-setup-waring"])t.clearWarning(this.nodeScope.componentOwner.name,this.id,e);if(!e.error){if(Object.keys(this.model.inputPorts).forEach((e=>{const t=this.model.inputPorts[e].type;"color"!==t&&"color"!==t.name||(this._internal.inputValues[e]=void 0,this.hasInput(e)?this.getInput(e).type="color":this.registerInput(e,{type:"color",set:u.bind(this,e)}))})),Object.keys(this.model.outputPorts).forEach((e=>{this.registerOutputIfNeeded(e)})),this._internal.setupFunction=e.setup,this._internal.runFunction=e.change,this._internal.destroyFunction=e.destroy,this._internal.definedObject=e.definedObject,this._internal.setupFunction&&s.call(this),this._internal.runFunction&&r.call(this),this._internal.hasParsedCode=!0,this._internal.inputQueue){for(const{name:e,value:t}of this._internal.inputQueue)this.setInputValue(e,t);this._internal.inputQueue=void 0}e.apis.Node.Inputs=this._internal.inputValues,e.apis.Node.Outputs=this._internal.outputProperties}},registerInputIfNeeded(e){this.hasInput(e)||(this._internal.inputValues[e]=void 0,this.registerInput(e,{set:u.bind(this,e)}))},registerOutputIfNeeded(e){if(this.hasOutput(e))return;const t=this,n="signal"===d(this.model.outputPorts[e].type);Object.defineProperty(this._internal.outputProperties,e,{set(o){n||(t._internal.outputValues[e]=o,t.flagOutputDirty(e))},get:()=>n?()=>{t.hasOutput(e)&&t.sendSignalOnOutput(e)}:t._internal.outputValues[e]}),this.registerOutput(e,{getter:c.bind(this,e)})},_callRunFunction(){const e=this._internal;if(e.runFunction&&!e.killed)try{e.runFunction.call(e.userFunctionScope,e.inputValues,e.outputProperties,e.changedInputs)}catch(e){(0,o.logJavaScriptNodeError)(e),this.context.editorConnection&&this.context.isWarningTypeEnabled("javascriptExecution")&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"js-run-waring",{showGlobally:!0,message:"run: "+e.message})}},_callSignalFunction(e){const t=this._internal;if(t.definedObject&&!t.killed&&t.definedObject[e]&&"function"==typeof t.definedObject[e])try{t.definedObject[e].call(t.userFunctionScope,t.inputValues,t.outputProperties)}catch(e){console.log("Error in JS node signal function code.",Object.getPrototypeOf(e).constructor.name+": "+e.message),this.context.editorConnection&&this.context.isWarningTypeEnabled("javascriptExecution")&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"js-run-waring",{showGlobally:!0,message:"run: "+e.message})}},_callDestroyFunction(){const e=this._internal;if(e.destroyFunction)try{e.destroyFunction.call(e.userFunctionScope,e.inputValues,e.outputProperties)}catch(e){console.log("Error in JS node destroy code.",Object.getPrototypeOf(e).constructor.name+": "+e.message),this.context.editorConnection&&this.context.isWarningTypeEnabled("javascriptExecution")&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"js-destroy-waring",{showGlobally:!0,message:"setup: "+e.message})}},_callSetupFunction(){const e=this._internal;if(e.setupFunction&&!e.killed)try{e.setupFunction.call(e.userFunctionScope,e.inputValues,e.outputProperties)}catch(e){console.log("Error in JS node setup code.",Object.getPrototypeOf(e).constructor.name+": "+e.message),this.context.editorConnection&&this.context.isWarningTypeEnabled("javascriptExecution")&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"js-setup-waring",{showGlobally:!0,message:"setup: "+e.message})}}}};function s(){this._internal.setupScheduled||(this._internal.setupScheduled=!0,this.scheduleAfterInputsHaveUpdated((function(){this._internal.killed||(this._callSetupFunction(),this._internal.setupScheduled=!1)})))}function r(){this._internal.runScheduled||this._internal.killed||(this._internal.runScheduled=!0,this.scheduleAfterInputsHaveUpdated((function(){this._internal.killed||(this._callRunFunction(),this._internal.changedInputs={},this._internal.runScheduled=!1)})))}function a(e){this._internal.signalScheduled[e]||this._internal.killed||(this._internal.signalScheduled[e]=!0,this.scheduleAfterInputsHaveUpdated((function(){this._internal.killed||(this._callSignalFunction(e),this._internal.signalScheduled[e]=!1)})))}function l(){this._internal.runNextFrame=!1,r.call(this)}function d(e){return"string"==typeof e?e:e.name}function u(e,t){!0===this._internal.hasParsedCode?void 0!==this.model.inputPorts[e]&&"signal"===d(this.model.inputPorts[e].type)?this._internal.definedObject&&"function"==typeof this._internal.definedObject[e]&&t&&a.call(this,e):(this._internal.inputValues[e]=t,this._internal.changedInputs[e]=!0,r.call(this)):this._internal.inputQueue.push({name:e,value:t})}function c(e){return this._internal.outputValues[e]}function p(e,t){function n(t){function n(){const n=[],i=[{value:"string",label:"String"},{value:"boolean",label:"Boolean"},{value:"number",label:"Number"},{value:"object",label:"Object"},{value:"array",label:"Array"}],s=[{value:"string",label:"String"},{value:"boolean",label:"Boolean"},{value:"number",label:"Number"},{value:"object",label:"Object"},{value:"array",label:"Array"},{value:"signal",label:"Signal"}];void 0!==t.parameters.scriptOutputs&&t.parameters.scriptOutputs.length>0&&t.parameters.scriptOutputs.forEach((e=>{n.push({name:"outtype-"+e.label,displayName:"Type",plug:"input",type:{name:"enum",enums:s,allowEditOnly:!0},default:"string",parent:"scriptOutputs",parentItemId:e.id}),n.push({name:e.label,plug:"output",type:t.parameters["outtype-"+e.label]||"*",group:"Outputs"})})),void 0!==t.parameters.scriptInputs&&t.parameters.scriptInputs.length>0&&t.parameters.scriptInputs.forEach((e=>{n.push({name:"intype-"+e.label,displayName:"Type",plug:"input",type:{name:"enum",enums:i,allowEditOnly:!0},default:"string",parent:"scriptInputs",parentItemId:e.id}),n.push({name:e.label,plug:"input",type:t.parameters["intype-"+e.label]||"string",group:"Inputs"})})),function(e,t,n){const i=t.editorConnection;if(e.parameters)if(e.parameters.externalFile&&"yes"===e.parameters.useExternalFile){const t=e.parameters.externalFile;o.JavascriptNodeParser.createFromURL(t,r)}else e.parameters.code?r(o.JavascriptNodeParser.createFromCode(e.parameters.code)):(s(),n([]));function s(){for(const t of["js-parse-waring","js-destroy-waring","js-run-waring","js-setup-waring"])i.clearWarning(e.component.name,e.id,t)}function r(t){t.error?i.sendWarning(e.component.name,e.id,"js-parse-waring",{showGlobally:!0,message:t.error}):s(),n(t.getPorts())}}(t,e,(function(o){var i;o.forEach((e=>{n.find((t=>t.name===e.name&&t.plug===e.plug))||n.push(e)})),null===(i=e.editorConnection)||void 0===i||i.sendDynamicPorts(t.id,n)}))}n(),t.on("parameterUpdated",(function(){n()}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.Javascript2",(function(e){n(e)}));for(const e of t.getNodesWithType("Javascript2"))n(e)}))}},8129:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>o});const o={name:"Number Remapper",docs:"https://docs.noodl.net/nodes/math/number-remapper",category:"Math",initialize(){const e=this._internal;e._currentInputValue=0,e._remappedValue=0,e._minInputValue=0,e._maxInputValue=0,e._minOutputValue=0,e._maxOutputValue=1,e._clampOutput=!0},getInspectInfo(){return this._internal._remappedValue},inputs:{inputValue:{group:"Value to Remap",type:{name:"number",allowConnectionOnly:!0},default:0,displayName:"Input Value",set(e){this._internal._currentInputValue=e,this._calculateNewOutputValue()}},minInputValue:{group:"Input Parameters",type:{name:"number"},default:0,displayName:"Input Minimum",set(e){this._internal._minInputValue=e,this._calculateNewOutputValue()}},maxInputValue:{group:"Input Parameters",type:{name:"number"},default:0,displayName:"Input Maximum",set(e){this._internal._maxInputValue=e,this._calculateNewOutputValue()}},minOutputValue:{group:"Output Parameters",type:{name:"number"},default:0,displayName:"Output Minimum",set(e){this._internal._minOutputValue=e,this._calculateNewOutputValue()}},maxOutputValue:{group:"Output Parameters",type:{name:"number"},default:1,displayName:"Output Maximum",set(e){this._internal._maxOutputValue=e,this._calculateNewOutputValue()}},clamp:{group:"Output Parameters",type:{name:"boolean",allowEditOnly:!0},default:!0,displayName:"Clamp Output",set(e){this._internal._clampOutput=e,this._calculateNewOutputValue()}}},outputs:{remappedValue:{type:"number",displayName:"Remapped Value",group:"Outputs",getter(){return this._internal._remappedValue}}},prototypeExtensions:{_calculateNewOutputValue(){let e;const t=this._internal;e=t._maxInputValue===t._minInputValue?0:(t._currentInputValue-t._minInputValue)/(t._maxInputValue-t._minInputValue),t._clampOutput&&(e=Math.max(0,Math.min(1,e))),t._remappedValue=t._minOutputValue+e*(t._maxOutputValue-t._minOutputValue),this.flagOutputDirty("remappedValue")}}}},6552:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>o});const o={name:"Open File Picker",docs:"https://docs.noodl.net/nodes/utilities/open-file-picker",category:"Utilities",getInspectInfo(){if(this._internal.file)return this._internal.file.path},initialize(){const e=document.createElement("input");e.type="file",this._internal.inputElement=e},inputs:{open:{type:"signal",displayName:"Open",group:"Actions",valueChangedToTrue(){const e=this._internal.inputElement;e.accept=this._internal.acceptedFileTypes||"",this._internal.capture&&(e.capture=this._internal.capture),e.onchange=t=>{const n=t.target;this._internal.file=n.files?n.files[0]:void 0,this.flagOutputDirty("file"),this.flagOutputDirty("path"),this.flagOutputDirty("name"),this.flagOutputDirty("sizeInBytes"),this.flagOutputDirty("type"),this.sendSignalOnOutput("success"),e.onchange=null,e.value=""},e.click()}},acceptedFileTypes:{group:"General",type:"string",displayName:"Accepted file types",set(e){this._internal.acceptedFileTypes=e}},capture:{group:"General",type:"string",displayName:"Capture",set(e){this._internal.capture=e}}},outputs:{file:{type:"*",displayName:"File",group:"General",get(){return this._internal.file}},path:{displayName:"Path",group:"Metadata",type:"string",get(){return this._internal.file&&this._internal.file.path}},name:{displayName:"Name",group:"Metadata",type:"string",get(){return this._internal.file&&this._internal.file.name}},sizeInBytes:{displayName:"Size in bytes",group:"Metadata",type:"number",get(){return this._internal.file&&this._internal.file.size}},type:{displayName:"Type",group:"Metadata",type:"string",get(){return this._internal.file&&this._internal.file.type}},success:{type:"signal",group:"Events",displayName:"Success"}}}},7518:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>o});const o={name:"Screen Resolution",docs:"https://docs.noodl.net/nodes/utilities/screen-resolution",category:"Utilities",initialize(){"undefined"!=typeof window&&(window.addEventListener("resize",(()=>{this._viewportSizeChanged()})),this._viewportSizeChanged())},getInspectInfo(){return`${this._internal.width} x ${this._internal.height}`},outputs:{width:{type:"number",displayName:"Width",get(){return this._internal.width}},height:{type:"number",displayName:"Height",get(){return this._internal.height}},aspectRatio:{type:"number",displayName:"Aspect Ratio",get(){return this._internal.width/this._internal.height}}},methods:{_viewportSizeChanged(){this._internal.width=window.innerWidth,this._internal.height=window.innerHeight,this.flagAllOutputsDirty()}}}},5250:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>p,setup:()=>g});var o=n(260),i=n(2004),s=n(8972),r=n.n(s);const a={},l={};function d(e,t){if("transparent"===t||!t)return void(e[3]=0);const n=(t.length-1)/2;for(let o=0;o=a.delay+a.dur)s[n]="color"===this.valueTypes[n]?c(this.targetValues[n]):this.targetValues[n];else{const e=t.transitionFuncs[n].get((o-a.delay)/a.dur);if("number"===this.valueTypes[n])s[n]=i.A.linear(Number(this.startValues[n]),Number(this.targetValues[n]),e);else if("color"===this.valueTypes[n]){const t=this.startValues[n],o=this.targetValues[n];r[0]=Math.floor(i.A.linear(t[0],o[0],e)),r[1]=Math.floor(i.A.linear(t[1],o[1],e)),r[2]=Math.floor(i.A.linear(t[2],o[2],e)),r[3]=Math.floor(i.A.linear(t[3],o[3],e)),s[n]=c(r)}}e.flagOutputDirty(n)}},onFinish(){const n="reached-"+t.state;e.hasOutput(n)&&e.sendSignalOnOutput(n)}})},getInspectInfo(){return`Current state: ${this._internal.state}`},inputs:{states:{type:{name:"stringlist",allowEditOnly:!0},displayName:"States",group:"States",set(e){if(this._internal.states=e?e.split(","):[],this._internal.states.length>0){const e=this;e._internal.state||this.scheduleGoToState(e._internal.startState||e._internal.states[0])}}},values:{type:{name:"stringlist",allowEditOnly:!0},displayName:"Values",group:"Values",set(e){const t=this._internal;t.values=e.split(",");for(const e in t.values)this.registerOutputIfNeeded(t.values[e])}},toggle:{group:"Go to state",displayName:"Toggle",valueChangedToTrue(){const e=this._internal;if(!e.states)return;const t=(e.states.indexOf(e.state)+1)%e.states.length;this.scheduleGoToState(e.states[t])}},useTransitions:{type:"boolean",displayName:"Use Transitions",group:"General",default:!0,set(e){this._internal.useTransitions=e}}},outputs:{currentState:{type:"string",displayName:"State",group:"Current State",getter(){return this._internal.state}},stateChanged:{type:"signal",displayName:"State Changed",group:"Current State"}},prototypeExtensions:{registerOutputIfNeeded(e){const t=this._internal;this.hasOutput(e)||this.registerOutput(e,{getter:()=>t.currentValues[e]})},registerInputIfNeeded(e){const t=this,n=this._internal;if(!this.hasInput(e))if(0===e.indexOf("to-")){const t=e.substring(3);this.registerInput(e,{set:(0,o.createSetter)({valueChangedToTrue(){this.scheduleGoToState(t)}})})}else if("startState"===e)this.registerInput(e,{set(e){this._internal.startState=e,this.scheduleGoToState(e)}});else if("currentState"===e)this.registerInput(e,{set:this.scheduleGoToState.bind(this)});else if(0===e.indexOf("type-"))this.registerInput(e,{set(t){n.stateParameterTypes[e]=t}});else if(0===e.indexOf("value-")){const o=e.split("-"),i=o[1],s=o[2];this.registerInput(e,{set(o){n.stateParameters[e]=o,n.state===i&&(n.currentValues[s]=o,t.flagOutputDirty(s))}})}else 0===e.search(/duration-/g)?this.registerInput(e,{set(t){n.stateParameters[e]=t}}):0===e.search(/transition/g)&&(e.substring(11),this.registerInput(e,{set(t){n.stateParameters[e]=t}}))},setCurrentState(e){this.scheduleGoToState(e)},jumpToState(e){const t=this._internal;if(!t.states)return;if(e||(e=t.states[0]),t.state===e)return;t.animation.stop();const n="value-"+e+"-";for(const e in t.values){const o=t.values[e];t.currentValues[o]=t.stateParameters[n+o]||0,this.flagOutputDirty(o)}t.state=e,this.flagOutputDirty("currentState"),t.valuesAreInitialised&&this.sendSignalOnOutput("stateChanged"),t.valuesAreInitialised=!0,this.updateAtStatePorts()},scheduleGoToState(e){const t=this;this._internal.goToState=e,this.hasScheduledGoToState||(this.hasScheduledGoToState=!0,this.scheduleAfterInputsHaveUpdated((function(){t.hasScheduledGoToState=!1,t.goToState(t._internal.goToState)})))},goToState(e){const t=this._internal;if(t.states&&(e||(e=t.states[0]),t.state!==e))if(t.valuesAreInitialised){let n=0,o=0;const i={};for(const s in t.values){const a=t.values[s];t.startValues[a]=t.currentValues[a];const l=t.stateParameterTypes["type-"+a];if("boolean"===l){const n=t.stateParameters["value-"+e+"-"+a];t.currentValues[a]=void 0!==n&&!!n,this.flagOutputDirty(a)}else if("string"===l||"textStyle"===l)t.currentValues[a]=t.stateParameters["value-"+e+"-"+a],this.flagOutputDirty(a);else{let s=t.stateParameters["transition-"+e+"-"+a];s||(s=t.stateParameters["transitiondef-"+e]||{curve:[0,0,.58,1],dur:300,delay:0}),0===s.dur&&0===s.delay||!t.useTransitions?(t.currentValues[a]=t.stateParameters["value-"+e+"-"+a],this.flagOutputDirty(a)):(t.transitionFuncs[a]=r()(s.curve),i[a]=s,n=Math.min(n,s.delay),o=Math.max(o,s.dur+s.delay))}}if((o>0||n>0)&&(t.animation.transitionCurves=i,t.animation.duration=o,t.animation.delay=n,t.animation.start()),t.state=e,this.flagOutputDirty("currentState"),this.sendSignalOnOutput("stateChanged"),this.updateAtStatePorts(),0===o&&0===n){const e="reached-"+t.state;this.hasOutput(e)&&this.sendSignalOnOutput(e)}}else this.jumpToState(e)},updateAtStatePorts(){const e=this._internal,t=e.states;for(const n in t){const o=t[n],i="at-"+o;e.currentValues[i]=e.state===o,this.hasOutput(i)&&this.flagOutputDirty(i)}}}};function h(e,t){if(!e||!t)return;if(e.length!==t.length)return;const n={};for(let o=0;o{r&&r.forEach((n=>{s.push({plug:"input",type:t["type-"+n]||"number",group:e+" Values",name:"value-"+e+"-"+n,displayName:n,editorName:e+"|"+n})})),r&&!1!==t.useTransitions&&(s.push({plug:"input",type:"curve",displayName:"Default",default:{curve:[0,0,.58,1],dur:300,delay:0},group:e+" Transitions",name:"transitiondef-"+e}),r.forEach((n=>{void 0!==t["type-"+n]&&"number"!==t["type-"+n]&&"color"!==t["type-"+n]||s.push({plug:"input",type:{name:"curve"},default:t["transitiondef-"+e]||{curve:[0,0,.58,1],dur:300,delay:0},group:e+" Transitions",name:"transition-"+e+"-"+n,displayName:n,editorName:"Transition "+e+"|"+n})}))),s.push({plug:"input",type:{name:"signal",allowConnectionsOnly:!0},displayName:"To "+e,name:"to-"+e,group:"Go to state"}),s.push({plug:"output",type:"boolean",displayName:"At "+e,name:"at-"+e,group:"Current state"}),s.push({plug:"output",type:"signal",displayName:"Has Reached "+e,name:"reached-"+e,group:"Current state"})})),o&&s.push({plug:"input",type:{name:"enum",enums:o},group:"States",displayName:"State",name:"currentState",default:t.startState||o[0]});const u=h(a[e],o);a[e]=o;const c=h(l[e],i);let p;l[e]=i,u?(p={plug:"input",before:u.before,after:u.after,patterns:["transition-{{*}}","to-{{*}}","at-{{*}}","reached-{{*}}"]},r&&r.forEach((e=>{p.patterns.push("value-{{*}}-"+e)}))):c&&(p=[{plug:"output",before:c.before,after:c.after,patterns:["{{*}}"]},{plug:"input",before:c.before,after:c.after,patterns:["type-{{*}}"]},{plug:"input",before:c.before,after:c.after,patterns:o?o.map((e=>"value-"+e+"-{{*}}")):void 0}]),n.sendDynamicPorts(e,s,{renamed:p})}function g(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("nodeAdded.States",(function(t){t.parameters.states&&m(t.id,t.parameters,e.editorConnection),t.on("parameterUpdated",(function(n){("useTransitions"===n.name||"states"===n.name||"values"===n.name||n.name.startsWith("transition")||n.name.startsWith("type-"))&&m(t.id,t.parameters,e.editorConnection)}))}))}},8044:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>o});const o={name:"Switch",docs:"https://docs.noodl.net/nodes/logic/switch",category:"Logic",initialize(){this._internal.state=!1,this._internal.initialized=!1},getInspectInfo(){return this._internal.state},inputs:{on:{displayName:"On",group:"Change State",valueChangedToTrue(){!0!==this._internal.state&&(this._internal.state=!0,this.flagOutputDirty("state"),this.emitSignals())}},off:{displayName:"Off",group:"Change State",valueChangedToTrue(){!1!==this._internal.state&&(this._internal.state=!1,this.flagOutputDirty("state"),this.emitSignals())}},flip:{displayName:"Flip",group:"Change State",valueChangedToTrue(){this._internal.state=!this._internal.state,this.flagOutputDirty("state"),this.emitSignals()}},onFromStart:{type:"boolean",displayName:"State",group:"General",default:!1,set(e){this._internal.state=!!e,this.flagOutputDirty("state"),this.emitSignals()}}},outputs:{state:{type:"boolean",displayName:"Current State",getter(){return this._internal.state}},switched:{displayName:"Switched",type:"signal",group:"Signals"},switchedToOn:{displayName:"Switched To On",type:"signal",group:"Signals"},switchedToOff:{displayName:"Switched To Off",type:"signal",group:"Signals"}},prototypeExtensions:{emitSignals(){!0===this._internal.state?this.sendSignalOnOutput("switchedToOn"):this.sendSignalOnOutput("switchedToOff"),this.sendSignalOnOutput("switched")}}}},1407:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>o});const o={name:"Timer",docs:"https://docs.noodl.net/nodes/utilities/delay",displayName:"Delay",category:"Utilities",nodeDoubleClickAction:{focusPort:"duration"},initialize(){const e=this;this._internal._animation=this.context.timerScheduler.createTimer({duration:0,onStart(){e.sendSignalOnOutput("timerStarted")},onFinish(){e.sendSignalOnOutput("timerFinished")}}),this.addDeleteListener((()=>{this._internal._animation.stop()}))},getInspectInfo(){return this._internal._animation.isRunning()?Math.floor(this._internal._animation.durationLeft()/10)/100+" seconds":"Not running"},inputs:{start:{displayName:"Start",valueChangedToTrue(){!1===this._internal._animation._isRunning&&this._internal._animation.start()}},restart:{displayName:"Restart",valueChangedToTrue(){this._internal._animation.start()}},duration:{type:"number",displayName:"Duration",default:0,set(e){this._internal._animation.duration=e}},startDelay:{type:"number",displayName:"Start Delay",default:0,set(e){this._internal._animation.delay=e}},stop:{displayName:"Stop",valueChangedToTrue(){this._internal._animation.stop()}}},outputs:{timerStarted:{type:"signal",displayName:"Started"},timerFinished:{type:"signal",displayName:"Finished"}}}},655:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>s});var o=n(9678),i=n(3795);const s={name:"Upload File",docs:"https://docs.noodl.net/nodes/data/cloud-data/upload-file",category:"Cloud Services",color:"data",getInspectInfo(){return this._internal.response},inputs:{file:{group:"General",displayName:"File",type:"*",set(e){this._internal.file=e}},upload:{type:"signal",displayName:"Upload",group:"Actions",valueChangedToTrue(){this.scheduleAfterInputsHaveUpdated((()=>{const e=this._internal.file;e?i.D.instance.uploadFile({file:e,onUploadProgress:e=>{this._internal.progressTotal=e.total,this._internal.progressLoaded=e.loaded,this.flagOutputDirty("progressTotalBytes"),this.flagOutputDirty("progressLoadedBytes"),this.flagOutputDirty("progressLoadedPercent"),this.sendSignalOnOutput("progressChanged")},success:e=>{this._internal.cloudFile=new o.A(e),this.flagOutputDirty("cloudFile"),this.sendSignalOnOutput("success")},error:e=>this.setError(e)}):this.setError("No file specified")}))}}},outputs:{cloudFile:{group:"General",displayName:"Cloud File",type:"cloudfile",get(){return this._internal.cloudFile}},success:{group:"Events",displayName:"Success",type:"signal"},failure:{group:"Events",displayName:"Failure",type:"signal"},error:{type:"string",displayName:"Error",group:"Error",get(){return this._internal.error}},errorStatus:{type:"number",displayName:"Error Status Code",group:"Error",get(){return this._internal.errorStatus}},progressChanged:{type:"signal",displayName:"Progress Changed",group:"Events"},progressTotalBytes:{type:"number",displayName:"Total Bytes",group:"Progress",get(){return this._internal.progressTotal}},progressLoadedBytes:{type:"number",displayName:"Uploaded Bytes",group:"Progress",get(){return this._internal.progressLoaded}},progressLoadedPercent:{type:"number",displayName:"Uploaded Percent",group:"Progress",get(){return this._internal.progressTotal?this._internal.progressLoaded/this._internal.progressTotal*100:0}}},methods:{setError(e){this._internal.error=e.hasOwnProperty("error")?e.error:e,this._internal.errorStatus=e.code||e.status||0,this.flagOutputDirty("error"),this.flagOutputDirty("errorStatus"),this.sendSignalOnOutput("failure")}}}},2457:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i});var o=n(5506);const i={name:"net.noodl.user.LogIn",docs:"https://docs.noodl.net/nodes/data/user/log-in",displayNodeName:"Log In",category:"Cloud Services",color:"data",outputs:{success:{type:"signal",displayName:"Success",group:"Events"},failure:{type:"signal",displayName:"Failure",group:"Events"},error:{type:"string",displayName:"Error",group:"Error",getter(){return this._internal.error}}},inputs:{login:{displayName:"Do",group:"Actions",valueChangedToTrue(){this.scheduleLogIn()}},username:{displayName:"Username",type:"string",group:"General",set(e){this._internal.username=e}},password:{displayName:"Password",type:"string",group:"General",set(e){this._internal.password=e}}},methods:{setError(e){this._internal.error=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure"),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"user-login-warning",{message:e,showGlobally:!0})},clearWarnings(){this.context.editorConnection&&this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"user-login-warning")},scheduleLogIn(){!0!==this.logInScheduled&&(this.logInScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.logInScheduled=!1,o.default.instance.logIn({username:this._internal.username,password:this._internal.password,success:()=>{this.sendSignalOnOutput("success")},error:e=>{this.setError(e)}})})))}}}},2228:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i});var o=n(5506);const i={name:"net.noodl.user.LogOut",docs:"https://docs.noodl.net/nodes/data/user/log-out",displayNodeName:"Log Out",category:"Cloud Services",color:"data",outputs:{success:{type:"signal",displayName:"Success",group:"Events"},failure:{type:"signal",displayName:"Failure",group:"Events"},error:{type:"string",displayName:"Error",group:"Error",getter(){return this._internal.error}}},inputs:{login:{displayName:"Do",group:"Actions",valueChangedToTrue(){this.scheduleLogOut()}}},methods:{setError(e){this._internal.error=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure"),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"user-login-warning",{message:e,showGlobally:!0})},clearWarnings(){this.context.editorConnection&&this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"user-login-warning")},scheduleLogOut(){!0!==this.logOutScheduled&&(this.logOutScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.logOutScheduled=!1,o.default.instance.logOut({success:()=>{this.sendSignalOnOutput("success")},error:e=>{this.setError(e)}})})))}}}},7154:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>i,setup:()=>r});var o=n(5506);const i={name:"net.noodl.user.SignUp",docs:"https://docs.noodl.net/nodes/data/user/sign-up",displayNodeName:"Sign Up",category:"Cloud Services",color:"data",initialize(){const e=this._internal;e.userProperties={},e.signUpScheduled=!1},outputs:{success:{type:"signal",displayName:"Success",group:"Events"},failure:{type:"signal",displayName:"Failure",group:"Events"},error:{type:"string",displayName:"Error",group:"Error",getter(){return this._internal.error}}},inputs:{signup:{displayName:"Do",group:"Actions",valueChangedToTrue(){this.scheduleSignUp()}},username:{displayName:"Username",type:"string",group:"General",set(e){this._internal.username=e}},password:{displayName:"Password",type:"string",group:"General",set(e){this._internal.password=e}},email:{displayName:"Email",type:"string",group:"General",set(e){this._internal.email=e}}},methods:{setError(e){this._internal.error=e,this.flagOutputDirty("error"),this.sendSignalOnOutput("failure"),this.context.editorConnection&&this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"user-login-warning",{message:e,showGlobally:!0})},clearWarnings(){this.context.editorConnection&&this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"user-login-warning")},scheduleSignUp(){const e=this._internal;!0!==this.signUpScheduled&&(this.signUpScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.signUpScheduled=!1,o.default.instance.signUp({username:this._internal.username,password:this._internal.password,email:this._internal.email,properties:e.userProperties,success:()=>{this.sendSignalOnOutput("success")},error:e=>{this.setError(e)}})})))},setUserProperty(e,t){this._internal.userProperties[e]=t},registerInputIfNeeded(e){if(!this.hasInput(e))return e.startsWith("prop-")?this.registerInput(e,{set:this.setUserProperty.bind(this,e.substring(5))}):void 0}}};function s(e,t,n,o){const i=[];if(o){const e=o.find((e=>"_User"===e.name));if(e&&e.schema&&e.schema.properties){const t=e.schema.properties,n=["authData","password","username","createdAt","updatedAt","emailVerified","email"];for(const e in t){if(-1!==n.indexOf(e))continue;const o=t[e];if(!i.find((t=>t.name===e)))if("Relation"===o.type);else{const t={String:"string",Boolean:"boolean",Number:"number",Date:"date"};i.push({type:{name:t[o.type]?t[o.type]:"*"},plug:"input",group:"Properties",name:"prop-"+e,displayName:e})}}}}n.sendDynamicPorts(e,i)}function r(e,t){function n(n){s(n.id,n.parameters,e.editorConnection,t.getMetaData("systemCollections")),n.on("parameterUpdated",(function(o){s(n.id,n.parameters,e.editorConnection,t.getMetaData("systemCollections"))})),t.on("metadataChanged.systemCollections",(function(t){s(n.id,n.parameters,e.editorConnection,t)}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.net.noodl.user.SignUp",(function(e){n(e)}));for(const e of t.getNodesWithType("net.noodl.user.SignUp"))n(e)}))}},5506:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>a});var o=n(260),i=n(7007),s=n(3795);class r{static forScope(e){return r.instance}static get instance(){return void 0===r._instance&&(r._instance=new r),r._instance}constructor(){this._initCloudServices(),this.events=new i.EventEmitter,this.events.setMaxListeners(1e5),this.getUserFromLocalStorage()&&(this.current=this.getUserModel(),this.fetchCurrentUser({success:()=>{},error:()=>{delete localStorage["Parse/"+this.appId+"/currentUser"],delete this.current,this.events.emit("sessionLost")}}))}getUserFromLocalStorage(){const e=localStorage["Parse/"+this.appId+"/currentUser"];if(e)try{return JSON.parse(e)}catch(e){}}_initCloudServices(){const e=o.default.instance.getMetaData("cloudservices");e&&(this.appId=e.appId,this.endpoint=e.endpoint)}on(...e){this.events.on(...e)}off(...e){this.events.off(...e)}_makeRequest(e,t){if(!this.endpoint)return void(t.error&&t.error({error:"No active cloud service",status:0}));const n=new XMLHttpRequest;n.onreadystatechange=()=>{if(4===n.readyState){let e;try{e=JSON.parse(n.response)}catch(e){}200===n.status||201===n.status?t.success(e||n.response):t.error(e||{error:n.responseText,status:n.status})}},n.open(t.method||"GET",this.endpoint+e,!0),n.setRequestHeader("X-Parse-Application-Id",this.appId);let i=localStorage["Parse/"+this.appId+"/installationId"];if(void 0===i&&(i=localStorage["Parse/"+this.appId+"/installationId"]=(0,o.guid)()),n.setRequestHeader("X-Parse-Installation-Id",i),t.sessionToken)n.setRequestHeader("X-Parse-Session-Token",t.sessionToken);else{const e=this.getUserFromLocalStorage();void 0!==e&&n.setRequestHeader("X-Parse-Session-Token",e.sessionToken)}n.setRequestHeader("Content-Type","application/json"),n.send(JSON.stringify(t.content))}logIn(e){this._makeRequest("/login",{method:"POST",content:{username:e.username,password:e.password,_method:"GET"},success:t=>{var n;localStorage["Parse/"+this.appId+"/currentUser"]=JSON.stringify(t),this.current=this.getUserModel(),null===(n=null==e?void 0:e.success)||void 0===n||n.call(e,t),this.events.emit("loggedIn")},error:t=>{var n;null===(n=null==e?void 0:e.error)||void 0===n||n.call(e,t.error)}})}logOut(e){this._makeRequest("/logout",{method:"POST",content:{},success:t=>{delete localStorage["Parse/"+this.appId+"/currentUser"],delete this.current,e.success(),this.events.emit("loggedOut")},error:t=>{e.error(t.error)}})}signUp(e){const t=e.properties?s.D._serializeObject({...e.properties},"_User"):{};this._makeRequest("/users",{method:"POST",content:{...t,username:e.username,password:e.password,email:e.email},success:t=>{var n;const o={...t,username:e.username,...e.properties};localStorage["Parse/"+this.appId+"/currentUser"]=JSON.stringify(o),this.current=this.getUserModel(),null===(n=null==e?void 0:e.success)||void 0===n||n.call(e,t),this.events.emit("loggedIn")},error:t=>{var n;null===(n=null==e?void 0:e.error)||void 0===n||n.call(e,t.error)}})}setUserProperties(e){const t=this.getCurrentUser();if(void 0!==t){const n=s.D._serializeObject({...e.properties},"_User"),o={email:e.email,username:e.username,...n};delete o.emailVerified,delete o.createdAt,delete o.updatedAt,this._makeRequest("/users/"+t.objectId,{method:"PUT",content:o,success:n=>{Object.assign(t,o),localStorage["Parse/"+this.appId+"/currentUser"]=JSON.stringify(t),this.current=this.getUserModel(),e.success(n)},error:t=>{e.error(t.error)}})}}fetchCurrentUser(e){this._makeRequest("/users/me",{method:"GET",sessionToken:e.sessionToken,success:t=>{localStorage["Parse/"+this.appId+"/currentUser"]=JSON.stringify(t),this.current=this.getUserModel(),this.events.emit("sessionGained"),e.success(t)},error:t=>{209===t.code&&(delete localStorage["Parse/"+this.appId+"/currentUser"],this.events.emit("sessionLost")),e.error(t.error)}})}verifyEmail(e){this._makeRequest("/apps/"+this.appId+"/verify_email?username="+e.username+"&token="+e.token,{method:"GET",success:t=>{-1!==t.indexOf("Successfully verified your email")?e.success():t.indexOf("Invalid Verification Link")?e.error("Invalid verification token"):e.error("Failed to verify email")},error:t=>{e.error(t.error)}})}sendEmailVerification(e){this._makeRequest("/verificationEmailRequest",{method:"POST",content:{email:e.email},success:t=>{e.success()},error:t=>{e.error(t.error)}})}resetPassword(e){this._makeRequest("/apps/"+this.appId+"/request_password_reset",{method:"POST",content:{username:e.username,token:e.token,new_password:e.newPassword},success:t=>{-1!==t.indexOf("Password successfully reset")||-1!==t.indexOf("Successfully updated your password")?e.success():t.indexOf("Invalid Link")?e.error("Invalid verification token"):e.error("Failed to verify email")},error:t=>{e.error(t.error)}})}requestPasswordReset(e){this._makeRequest("/requestPasswordReset",{method:"POST",content:{email:e.email},success:t=>{e.success()},error:t=>{e.error(t.error)}})}getCurrentUser(){const e=localStorage["Parse/"+this.appId+"/currentUser"];if(void 0!==e)return JSON.parse(e)}getUserModel(){const e=this.getCurrentUser();if(void 0!==e)return delete e.sessionToken,delete e.ACL,delete e.className,delete e.__type,s.D._fromJSON(e,"_User")}}o.default.Services.UserService=r;const a=r},7387:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>o});const o={name:"Value Changed",docs:"https://docs.noodl.net/nodes/logic/value-changed",category:"Logic",initialize:function(){this._internal.lastValue=void 0,this._internal.changeCount=0},getInspectInfo(){return this._internal.changeCount?"Triggered "+this._internal.changeCount+(1===this._internal.changeCount?" time":" times"):"Not triggered"},inputs:{value:{type:"*",displayName:"Input",set:function(e){this._internal.lastValue!==e&&(this._internal.changeCount++,this.sendSignalOnOutput("valueChanged"),this._internal.lastValue=e)}}},outputs:{valueChanged:{type:"signal",displayName:"Value Changed"}}}},8355:(e,t,n)=>{"use strict";n.r(t),n.d(t,{node:()=>o});const o={name:"Color",category:"Variables",docs:"https://docs.noodl.net/nodes/data/color",startValue:"#f1f2f4",nodeDoubleClickAction:{focusPort:"value"},type:{name:"color"},cast:e=>e}},5371:(e,t,n)=>{var o;!function(){function i(e,t,n){return e.call.apply(e.bind,arguments)}function s(e,t,n){if(!e)throw Error();if(2=t.f?i():e.fonts.load(function(e){return I(e)+" "+e.f+"00 300px "+N(e.c)}(t.a),t.h).then((function(e){1<=e.length?o():setTimeout(s,25)}),(function(){i()}))}()})),i=null,s=new Promise((function(e,n){i=setTimeout(n,t.f)}));Promise.race([s,o]).then((function(){i&&(clearTimeout(i),i=null),t.g(t.a)}),(function(){t.j(t.a)}))};var V={D:"serif",C:"sans-serif"},j=null;function F(){if(null===j){var e=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);j=!!e&&(536>parseInt(e[1],10)||536===parseInt(e[1],10)&&11>=parseInt(e[2],10))}return j}function U(e,t,n){for(var o in V)if(V.hasOwnProperty(o)&&t===e.f[V[o]]&&n===e.f[V[o]])return!0;return!1}function W(e){var t,n=e.g.a.offsetWidth,o=e.h.a.offsetWidth;(t=n===e.f.serif&&o===e.f["sans-serif"])||(t=F()&&U(e,n,o)),t?a()-e.A>=e.w?F()&&U(e,n,o)&&(null===e.u||e.u.hasOwnProperty(e.a.c))?L(e,e.v):L(e,e.B):function(e){setTimeout(r((function(){W(this)}),e),50)}(e):L(e,e.v)}function L(e,t){setTimeout(r((function(){p(this.g.a),p(this.h.a),p(this.j.a),p(this.m.a),t(this.a)}),e),0)}function B(e,t,n){this.c=e,this.a=t,this.f=0,this.m=this.j=!1,this.s=n}M.prototype.start=function(){this.f.serif=this.j.a.offsetWidth,this.f["sans-serif"]=this.m.a.offsetWidth,this.A=a(),W(this)};var $=null;function q(e){0==--e.f&&e.j&&(e.m?((e=e.a).g&&h(e.f,[e.a.c("wf","active")],[e.a.c("wf","loading"),e.a.c("wf","inactive")]),E(e,"active")):x(e.a))}function z(e){this.j=e,this.a=new T,this.h=0,this.f=this.g=!0}function H(e,t,n,o,i){var s=0==--e.h;(e.f||e.g)&&setTimeout((function(){var e=i||null,a=o||{};if(0===n.length&&s)x(t.a);else{t.f+=n.length,s&&(t.j=s);var l,d=[];for(l=0;l{const{default:o}=n(260),i={run:async(e,t)=>new Promise(((n,i)=>{const s=o.instance.getMetaData("cloudservices");if(void 0===s)return void i("No cloud services defined in this project.");const r=s.appId,a=o.instance.editorConnection.isRunningLocally()?`http://${window.location.hostname}:8577`:s.endpoint;!function(e,t){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState){var e;try{e=JSON.parse(n.response)}catch(e){}200===n.status||201===n.status?t.success(e):t.error(e)}},n.open(t.method||"GET",t.endpoint+e,!0),n.setRequestHeader("X-Parse-Application-Id",t.appId),n.setRequestHeader("Content-Type","application/json");const i=o.instance.getMetaData("cloudservices");i&&i.deployVersion&&n.setRequestHeader("x-noodl-cloud-version",i.deployVersion);var s=localStorage["Parse/"+t.appId+"/currentUser"];if(void 0!==s)try{const e=JSON.parse(s);n.setRequestHeader("X-Parse-Session-Token",e.sessionToken)}catch(e){}n.send(JSON.stringify(t.content))}("/functions/"+encodeURIComponent(e),{appId:r,endpoint:a,content:t,method:"POST",success:e=>{n(e?e.result:void 0)},error:e=>{i(e)}})}))};e.exports=i},4483:(e,t,n)=>{const o=n(5506),i={logIn:async e=>new Promise(((t,n)=>{o.instance.logIn({username:e.username,password:e.password,success:()=>{t()},error:e=>{n(e)}})})),signUp:async e=>new Promise(((t,n)=>{o.instance.signUp({username:e.username,password:e.password,email:e.email,properties:e.properties,success:()=>{t()},error:e=>{n(e)}})})),become:async e=>new Promise(((t,n)=>{o.instance.fetchCurrentUser({sessionToken:e,success:()=>{t()},error:e=>{n(e)}})})),on(e,t){o.instance.on(e,t)},off(e,t){o.instance.off(e,t)}},s={logOut:async()=>new Promise(((e,t)=>{o.instance.logOut({success:()=>{e()},error:e=>{t(e)}})})),save:async()=>new Promise(((e,t)=>{const n=Object.assign({},s.Properties.data);o.instance.setUserProperties({properties:n,success:()=>{e()},error:e=>{t(e)}})})),fetch:async()=>new Promise(((e,t)=>{o.instance.fetchCurrentUser({success:()=>{e()},error:e=>{t(e)}})}))};Object.defineProperty(i,"Current",{get:function(){const e=o.instance.current;return void 0===e?void 0:(s.email=e.email,s.username=e.username,s.id=e.id,s.emailVerified=e.emailVerified,s.Properties=e,s)}}),e.exports=i},7685:e=>{e.exports=function(e,t,n,o,i,s,r){void 0===r&&(r=this.options);var a=e-t,l=Math.abs(a)/n,d=r.deceleration,u=(r.swipeBounceTime,{destination:e+l/d*(a<0?-1:1),duration:r.swipeTime,rate:15});return this.hooks.trigger(this.hooks.eventTypes.momentum,u,a),u.destinationi&&(u.destination=s?Math.min(i+s/4,i+s/u.rate*l):i,u.duration=Math.abs(u.destination-e)/l),u.destination=Math.round(u.destination),u}},5542:(e,t,n)=>{"use strict";const o=n(260);e.exports={extendSetComponentObjectProperties:function(e){function t(e,t,n){var o=[];const i=[{label:"String",value:"string"},{label:"Boolean",value:"boolean"},{label:"Number",value:"number"},{label:"Date",value:"date"},{label:"Array",value:"array"},{label:"Object",value:"object"},{label:"Any",value:"*"}];var s=t.properties;if(s)for(var r in s=s?s.split(","):void 0){var a=s[r];o.push({type:{name:void 0===t["type-"+a]?"*":t["type-"+a]},plug:"input",group:"Property Values",displayName:a,name:"prop-"+a}),o.push({type:{name:"enum",enums:i,allowEditOnly:!0},plug:"input",group:"Property Types",displayName:a,default:"*",name:"type-"+a})}n.sendDynamicPorts(e,o,{detectRenamed:{plug:"input"}})}return{node:{name:e.name,displayNodeName:e.displayName,category:"Component Utilities",color:"component",docs:e.docs,initialize:function(){this._internal.inputValues={}},inputs:{properties:{type:{name:"stringlist",allowEditOnly:!0},displayName:"Properties",group:"Properties",set(e){}},store:{type:"signal",group:"Actions",displayName:"Do",valueChangedToTrue(){this.scheduleStore()}}},outputs:{stored:{type:"signal",group:"Events",displayName:"Done"}},methods:{getComponentObjectId:e.getComponentObjectId,scheduleStore(){if(!this.hasScheduledStore){this.hasScheduledStore=!0;var e=this._internal;this.scheduleAfterInputsHaveUpdated((()=>{const t=o.get(this.getComponentObjectId());this.hasScheduledStore=!1;const n=(this.model.parameters.properties||"").split(","),i=Object.keys(e.inputValues).filter((e=>-1!==n.indexOf(e)));for(const n of i)t.set(n,e.inputValues[n],{resolve:!0});this.sendSignalOnOutput("stored")}))}},registerInputIfNeeded:function(e){if(!this.hasInput(e))if(e.startsWith("prop-")){const t=e.substring(5);this.registerInput(e,{set(e){this._internal.inputValues[t]=e}})}else e.startsWith("type-")&&this.registerInput(e,{set(e){}})}}},setup:function(n,o){n.editorConnection&&n.editorConnection.isRunningLocally()&&o.on("nodeAdded."+e.name,(e=>{t(e.id,e.parameters,n.editorConnection),e.on("parameterUpdated",(o=>{("properties"===o.name||o.name.startsWith("type-"))&&t(e.id,e.parameters,n.editorConnection)}))}))}}}}},3235:(e,t,n)=>{"use strict";const{Node:o}=n(260),i=n(260),s={name:"net.noodl.ComponentObject",displayNodeName:"Component Object",category:"Component Utilities",color:"component",docs:"https://docs.noodl.net/nodes/component-utilities/component-object",initialize:function(){this._internal.inputValues={},this._internal.dirtyValues={},this._internal.onModelChangedCallback=e=>{!1===this.isInputConnected("fetch")&&(this.hasOutput("value-"+e.name)&&this.flagOutputDirty("value-"+e.name),this.hasOutput("changed-"+e.name)&&this.sendSignalOnOutput("changed-"+e.name),this.sendSignalOnOutput("changed"))};const e=i.get("componentState"+this.nodeScope.componentOwner.getInstanceId());this._internal.model=e,e.on("change",this._internal.onModelChangedCallback)},getInspectInfo(){return{type:"value",value:this._internal.model.data}},inputs:{properties:{type:{name:"stringlist",allowEditOnly:!0},displayName:"Properties",group:"Properties",set(e){}},fetch:{displayName:"Fetch",group:"Actions",valueChangedToTrue(){this.scheduleFetch()}}},outputs:{changed:{type:"signal",displayName:"Changed",group:"Events"},fetched:{type:"signal",displayName:"Fetched",group:"Events"}},methods:{scheduleStore(){if(!this.hasScheduledStore){this.hasScheduledStore=!0;var e=this._internal;this.scheduleAfterInputsHaveUpdated((()=>{for(var t in this.hasScheduledStore=!1,e.dirtyValues)e.model.set(t,e.inputValues[t],{resolve:!0});e.dirtyValues={}}))}},scheduleFetch(){this.hasScheduledFetch||(this.hasScheduledFetch=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.hasScheduledFetch=!1,this.fetch()})))},fetch(){for(var e in this._internal.model.data)this.hasOutput("value-"+e)&&(this.flagOutputDirty("value-"+e),this.hasOutput("changed-"+e)&&this.sendSignalOnOutput("changed-"+e));this.sendSignalOnOutput("fetched")},_onNodeDeleted(){o.prototype._onNodeDeleted.call(this),this._internal.model.off("change",this._internal.onModelChangedCallback)},registerOutputIfNeeded(e){if(this.hasOutput(e))return;const t=e.split("-"),n=t[t.length-1];this.registerOutput(e,{get(){return this._internal.model.get(n,{resolve:!0})}})},registerInputIfNeeded:function(e){if(!this.hasInput(e)&&e.startsWith("value-")){const t=e.substring(6);this.registerInput(e,{set(e){this._internal.inputValues[t]=e,this._internal.dirtyValues[t]=!0,this.scheduleStore()}})}}}};function r(e,t,n){const o=[];if(t.properties){var i=t.properties.split(",");for(var s in i){var r=i[s];o.push({type:{name:"*",allowConnectionsOnly:!0},plug:"input/output",group:"Properties",name:"value-"+r,displayName:r}),o.push({type:"signal",plug:"output",group:"Changed Events",displayName:r+" Changed",name:"changed-"+r})}}n.sendDynamicPorts(e,o,{detectRenamed:{plug:"input/output"}})}e.exports={node:s,setup:function(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("nodeAdded.net.noodl.ComponentObject",(t=>{r(t.id,t.parameters,e.editorConnection),t.on("parameterUpdated",(n=>{"properties"===n.name&&r(t.id,t.parameters,e.editorConnection)}))}))}}},619:(e,t,n)=>{"use strict";const{Node:o}=n(260),i=n(260),s=new(0,n(7007).EventEmitter);s.setMaxListeners(1e6);const r={name:"net.noodl.ParentComponentObject",displayNodeName:"Parent Component Object",category:"Component Utilities",color:"component",docs:"https://docs.noodl.net/nodes/component-utilities/parent-component-object",initialize(){this._internal.inputValues={},this._internal.onModelChangedCallback=e=>{!1===this.isInputConnected("fetch")&&(this.hasOutput("value-"+e.name)&&this.flagOutputDirty("value-"+e.name),this.hasOutput("changed-"+e.name)&&this.sendSignalOnOutput("changed-"+e.name),this.sendSignalOnOutput("changed"))},this.onComponentStateNodesChanged=()=>{const e=this.findParentComponentStateModelId();this._internal.modelId!==e&&(this._internal.modelId=e,!1===this.isInputConnected("fetch")&&this.setModelId(this._internal.modelId))},s.on("componentStateNodesChanged",this.onComponentStateNodesChanged),this.updateComponentState()},nodeScopeDidInitialize(){this._internal.modelId||this.context.scheduleAfterUpdate((()=>{this.updateComponentState()}))},getInspectInfo(){if(!this._internal.model)return"No parent component state found";const e=[{type:"text",value:this._internal.parentComponentName}],t=this._internal.model.data;return e.concat(Object.keys(t).map((e=>({type:"text",value:e+": "+t[e]}))))},inputs:{properties:{type:{name:"stringlist",allowEditOnly:!0},displayName:"Properties",group:"Properties",set(e){}},fetch:{displayName:"Fetch",group:"Actions",valueChangedToTrue:function(){this.setModelId(this._internal.modelId)}}},outputs:{changed:{type:"signal",displayName:"Changed",group:"Events"},fetched:{type:"signal",displayName:"Fetched",group:"Events"}},methods:{updateComponentState(){this._internal.modelId=this.findParentComponentStateModelId(),!1===this.isInputConnected("fetch")&&this.setModelId(this._internal.modelId)},findParentComponentStateModelId(){const e=function e(t){let n;if(t.getRoots().length>0){const e=t.getRoots()[0];e.getVisualParentNode?e.getVisualParentNode()&&(n=e.getVisualParentNode().nodeScope.componentOwner):e.parentNodeScope&&(n=t.parentNodeScope.componentOwner)}else t.parentNodeScope&&(n=t.parentNodeScope.componentOwner);if(n&&n.nodeScope&&n.nodeScope.componentOwner!==t)return n.nodeScope.getNodesWithType("net.noodl.ComponentObject").length>0?n:e(n)}(this.nodeScope.componentOwner);if(e)return this._internal.parentComponentName=e.name,"componentState"+e.getInstanceId()},setModelId(e){if(this._internal.model&&this._internal.model.off("change",this._internal.onModelChangedCallback),this._internal.model=void 0,!e)return;const t=i.get(e);for(var n in this._internal.model=t,t.on("change",this._internal.onModelChangedCallback),t.data)this.hasOutput("value-"+n)&&this.flagOutputDirty("value-"+n),this.hasOutput("changed-"+n)&&this.sendSignalOnOutput("changed-"+n);this.sendSignalOnOutput("changed"),this.sendSignalOnOutput("fetched")},scheduleStore(){if(!this.hasScheduledStore){this.hasScheduledStore=!0;var e=this._internal;this.scheduleAfterInputsHaveUpdated((()=>{if(this.hasScheduledStore=!1,e.model)for(var t in e.inputValues)e.model.set(t,e.inputValues[t],{resolve:!0})}))}},_onNodeDeleted(){o.prototype._onNodeDeleted.call(this),s.off("componentStateNodesChanged",this.onComponentStateNodesChanged),this._internal.model&&this._internal.model.off("change",this._internal.onModelChangedCallback)},registerOutputIfNeeded(e){if(this.hasOutput(e))return;const t=e.substring(6);this.registerOutput(e,{get(){if(this._internal.model)return this._internal.model.get(t,{resolve:!0})}})},registerInputIfNeeded:function(e){if(!this.hasInput(e)&&e.startsWith("value-")){const t=e.substring(6);this.registerInput(e,{set(e){this._internal.inputValues[t]=e,this.scheduleStore()}})}}}};function a(e,t,n){const o=[];var i=t.properties&&t.properties.split(",");for(var s in i){var r=i[s];o.push({type:{name:"*",allowConnectionsOnly:!0},plug:"input/output",group:"Properties",name:"value-"+r,displayName:r}),o.push({type:"signal",plug:"output",group:"Changed Events",displayName:r+" Changed",name:"changed-"+r})}n.sendDynamicPorts(e,o,{detectRenamed:{plug:"input/output"}})}e.exports={node:r,setup:function(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&(t.on("nodeAdded.net.noodl.ParentComponentObject",(t=>{a(t.id,t.parameters,e.editorConnection),t.on("parameterUpdated",(n=>{a(t.id,t.parameters,e.editorConnection)}))})),t.on("nodeAdded.net.noodl.ComponentObject",(e=>{setTimeout((()=>{s.emit("componentStateNodesChanged")}),0)})),t.on("nodeRemoved.net.noodl.ComponentObject",(e=>{setTimeout((()=>{s.emit("componentStateNodesChanged")}))})))}}},2610:(e,t,n)=>{"use strict";const o=n(5542);e.exports=o.extendSetComponentObjectProperties({name:"net.noodl.SetComponentObjectProperties",displayName:"Set Component Object Properties",docs:"https://docs.noodl.net/nodes/component-utilities/set-component-object-properties",getComponentObjectId:function(){return"componentState"+this.nodeScope.componentOwner.getInstanceId()}})},4986:(e,t,n)=>{"use strict";const{Node:o}=n(260),i=(n(260),n(5542));e.exports=i.extendSetComponentObjectProperties({name:"net.noodl.SetParentComponentObjectProperties",displayName:"Set Parent Component Object Properties",docs:"https://docs.noodl.net/nodes/component-utilities/set-parent-component-object-properties",getComponentObjectId:function(){const e=function e(t){let n;if(t.getRoots().length>0){const e=t.getRoots()[0];e.getVisualParentNode?e.getVisualParentNode()&&(n=e.getVisualParentNode().nodeScope.componentOwner):e.parentNodeScope&&(n=t.parentNodeScope.componentOwner)}else t.parentNodeScope&&(n=t.parentNodeScope.componentOwner);if(n&&n.nodeScope&&n.nodeScope.componentOwner!==t)return n.nodeScope.getNodesWithType("net.noodl.ComponentObject").length>0?n:e(n)}(this.nodeScope.componentOwner);if(e)return this._internal.parentComponentName=e.name,"componentState"+e.getInstanceId()}})},5900:e=>{const t=new Map,n={name:"CSS Definition",docs:"https://docs.noodl.net/nodes/utilities/css-definition",category:"CustomCode",color:"javascript",nodeDoubleClickAction:{focusPort:"Style"},initialize:function(){this._internal.style="";const e=this.getStyleRefId();this.addDeleteListener((()=>{t.set(e,t.get(e)-1),0===t.get(e)&&(this.removeStyleDeclaration(),t.delete(e))})),t.has(e)||t.set(e,0),t.set(e,t.get(e)+1)},inputs:{style:{index:4005,type:{name:"string",allowEditOnly:!0,codeeditor:"css"},displayName:"Style",group:"Content",default:"",set:function(e){this.updateStyle(e)}}},outputs:{},methods:{getStyleRefId:function(){return"style_"+this.id},removeStyleDeclaration:function(){if("undefined"!=typeof document){var e=this.getStyleRefId(),t=document.getElementById(e);null!==t&&t.parentNode.removeChild(t)}},updateStyle:function(e){if("undefined"!=typeof document){var t=this._internal,n=this.getStyleRefId();if(t.style=e,null!==e){var o=document.getElementById(n);null===o&&((o=document.createElement("style")).id=n,o.type="text/css",document.head.appendChild(o)),o.innerHTML="\n"+e+"\n"}else this.removeStyleDeclaration()}}}};e.exports={node:n}},1594:e=>{"use strict";e.exports=React},5206:e=>{"use strict";e.exports=ReactDOM},6822:(e,t,n)=>{"use strict";n.d(t,{b:()=>o});var o=n(1150)}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={id:e,exports:{}};return __webpack_modules__[e](n,n.exports,__webpack_require__),n.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.nc=void 0;var __webpack_exports__={};(()=>{"use strict";var e={};__webpack_require__.r(e),__webpack_require__.d(e,{node:()=>rt});var t=__webpack_require__(1594),n=__webpack_require__.n(t),o=__webpack_require__(5206),i=__webpack_require__.n(o),s=__webpack_require__(260);class r{constructor(e,t){this.graphModel=e,this.editorConnection=t,this.graphModel.getAllComponents().forEach((e=>this._bindComponentModel(e))),this.graphModel.on("componentAdded",(e=>this._bindComponentModel(e)),this),this.graphModel.on("componentRemoved",(e=>e.removeListenersWithRef(this)),this)}_bindComponentModel(e){e.on("rootAdded",(()=>this._evaluateWarnings(e)),this),e.on("rootRemoved",(t=>{this.editorConnection.clearWarning(e.name,t,"multiple-visual-roots-warning"),this._evaluateWarnings(e)}),this),this._evaluateWarnings(e)}_evaluateWarnings(e){const t=e.getRoots();if(0!==t.length){this.editorConnection.clearWarning(e.name,t[0],"multiple-visual-roots-warning");for(let n=1;nand won't be rendered",level:"info"})}}dispose(){this.graphModel.getAllComponents().forEach((e=>{e.removeListenersWithRef(this)})),this.graphModel.removeListenersWithRef(this)}}class a{constructor(e){this.highlightedNodes=new Map,this.selectedNodes=new Map,this.noodlRuntime=e,this.isUpdatingHighlights=!1;const t=document.createElement("div");t.style.width="100%",t.style.height="100%",t.style.top="0",t.style.left="0",t.style.overflow="hidden",t.style.position="fixed",t.style.zIndex="1000000000",t.style.pointerEvents="none",document.body.appendChild(t),this.highlightRootDiv=t,this.windowBorderDiv=this.createHighlightDiv(),this.windowBorderDiv.style.position="absolute",this.windowBorderDiv.style.top="0",this.windowBorderDiv.style.left="0",this.windowBorderDiv.style.boxShadow="inset 0 0 0 3px #2CA7BA",this.windowBorderDiv.style.opacity="1.0",this.windowBorderDiv.style.width="100vw",this.windowBorderDiv.style.height="100vh"}createHighlightDiv(){const e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.outline="2px solid #2CA7BA",e.style.opacity="1.0",e}setWindowSelected(e){}updateHighlights(){const e=Array.from(this.highlightedNodes.entries()).concat(Array.from(this.selectedNodes.entries()));for(const t of e){const e=t[0].getRef()&&i().findDOMNode(t[0].getRef());if(!e){this.highlightedNodes.delete(t[0]),t[1].remove();continue}const n=e.getBoundingClientRect(),o=t[1];o.style.transform=`translateX(${n.x}px) translateY(${n.y}px)`,o.style.width=n.width+"px",o.style.height=n.height+"px"}this.isUpdatingHighlights=this.highlightedNodes.size>0||this.selectedNodes.size>0,this.isUpdatingHighlights&&requestAnimationFrame(this.updateHighlights.bind(this))}highlightNodesWithId(e){const t=l(this.noodlRuntime,e).filter((e=>e.getRef)).filter((e=>!this.highlightedNodes.has(e)));for(const e of t){const t=this.createHighlightDiv();this.highlightRootDiv.appendChild(t),this.highlightedNodes.set(e,t)}(this.selectedNodes.size>0||this.highlightedNodes.size>0)&&!this.isUpdatingHighlights&&this.updateHighlights()}disableHighlight(){for(const e of this.highlightedNodes){const t=e[1];t&&t.remove()}this.highlightedNodes.clear()}selectNodesWithId(e){this.noodlRuntime.rootComponent||this.noodlRuntime.eventEmitter.once("rootComponentUpdated",(()=>{setTimeout((()=>{this.selectNodesWithId(e)}),300)}));const t=l(this.noodlRuntime,e).filter((e=>e.getRef)).filter((e=>!this.selectedNodes.has(e)));for(const e of t){const t=this.createHighlightDiv();this.highlightRootDiv.appendChild(t),this.selectedNodes.set(e,t)}return this.selectedNodes.size>0&&this.setWindowSelected(!1),(this.selectedNodes.size>0||this.highlightedNodes.size>0)&&!this.isUpdatingHighlights&&this.updateHighlights(),t}deselectNodes(){for(const e of this.selectedNodes){const t=e[1];t&&t.remove()}this.selectedNodes.clear()}}function l(e,t){return e.rootComponent?e.rootComponent.nodeScope.getNodesWithIdRecursive(t):[]}class d{constructor({onInspect:e,onHighlight:t,onDisableHighlight:n}){this.onMouseMove=e=>{n();const o=this.findNoodlNode(e.target);o?(document.body.style.cursor="pointer",t(o.id)):document.body.style.cursor="initial",e.stopPropagation()},this.onClick=t=>{n();const o=this.findNoodlNode(t.target);o&&e([o.id]),t.stopPropagation(),t.preventDefault(),document.activeElement&&document.activeElement.blur()},this.onContextMenu=t=>{const n=document.elementsFromPoint(t.clientX,t.clientY).map((e=>this.findNoodlNode(e))).filter((e=>!!e)).map((e=>e.id));n.length&&e(n),t.stopPropagation(),t.preventDefault(),document.activeElement&&document.activeElement.blur()},this.onMouseOut=e=>{n()},this.blockEvent=e=>{e.stopPropagation()},this.onDisableHighlight=n}setComponent(e){this.component=e}enable(){document.activeElement&&document.activeElement.blur(),document.addEventListener("mouseenter",this.blockEvent,!0),document.addEventListener("mouseover",this.blockEvent,!0),document.addEventListener("mousedown",this.blockEvent,!0),document.addEventListener("mouseup",this.blockEvent,!0),document.addEventListener("mousemove",this.onMouseMove,!0),document.addEventListener("mouseout",this.onMouseOut,!0),document.addEventListener("click",this.onClick,!0),document.addEventListener("contextmenu",this.onContextMenu,!0)}disable(){document.body.style.cursor="initial",document.removeEventListener("mouseenter",this.blockEvent,!0),document.removeEventListener("mouseover",this.blockEvent,!0),document.removeEventListener("mousedown",this.blockEvent,!0),document.removeEventListener("mouseup",this.blockEvent,!0),document.removeEventListener("mousemove",this.onMouseMove,!0),document.removeEventListener("mouseout",this.onMouseOut,!0),document.removeEventListener("click",this.onClick,!0),document.removeEventListener("contextmenu",this.onContextMenu,!0),this.onDisableHighlight()}findNoodlNode(e){let t;for(;!t&&e;){const n=Object.keys(e).find((e=>e.startsWith("__reactInternalInstance$")));t=n?e[n]:null,t||(e=e.parentElement)}if(!t)return;const n=e=>{let t=e.return;for(;t&&"string"==typeof t.type;)t=t.return;return t};let o=n(t);for(;o&&(!o.stateNode||!o.stateNode.props||!o.stateNode.props.noodlNode);)o=n(o);const i=o?o.stateNode.props.noodlNode:void 0;if(i){if(this.component){let e=i;for(;e;)if(e.parentNodeScope){if(e.parentNodeScope.componentOwner.name===this.component.name)return e;e=e.parentNodeScope.componentOwner}else{if(e.nodeScope.componentOwner.name===this.component.name)return e;e=e.nodeScope.componentOwner}return e}return i}}}const u="undefined"!=typeof document;class c{constructor(){this._title="",this._meta={}}get title(){return u?document.title:this._title}setTitle(e){this._title=e,u&&(document.title=e)}get meta(){return this._meta}clearMeta(){u&&Object.keys(this._meta).forEach((e=>{const t=document.querySelector(`meta[name="${e}"]`);t&&t.remove()})),this._meta={}}getMeta(e){return this._meta[e]}setMeta(e,t){if(this._meta[e]=t,u){const n=document.querySelector(`meta[name="${e}"]`);if(n)t?n.setAttribute("content",t):n.remove();else if(t){const n=document.createElement("meta");n.setAttribute("name",e),n.setAttribute("property",e),n.setAttribute("content",t),document.head.appendChild(n)}}}}var p=__webpack_require__(4483),h=__webpack_require__.n(p),m=__webpack_require__(4665),g=__webpack_require__.n(m),f=__webpack_require__(7031),y=__webpack_require__(5741);const v={_noodlRuntime:void 0,showPopup:async(e,t)=>new Promise((n=>{v._noodlRuntime.context.showPopup(e,t,{onClosePopup:(e,t)=>{n({action:null==e?void 0:e.replace("closeAction-",""),parameters:t})}})})),navigate(e,t,n){y.u.instance.navigate(e,{target:t,params:n})},navigateToPath(e,t){let n,o;const i=f.A.instance.getProjectSettings().navigationPathType;void 0===i||"hash"===i?n=e:o=e;const s=[];if(t&&void 0!==t.query)for(const e in t.query)s.push(`${e}=${t.query[e]}`);const r=(void 0!==o?o:"")+(s.length>=1?"?"+s.join("&"):"")+(void 0!==n?"#"+n:"");window.history.pushState({},"",r),dispatchEvent(new PopStateEvent("popstate",{}))}},b=v;var _=__webpack_require__(3795),S=__webpack_require__(9678);const C={upload:async(e,t)=>new Promise(((n,o)=>{_.D.instance.uploadFile({file:e,onUploadProgress:e=>{var n;null===(n=null==t?void 0:t.onProgress)||void 0===n||n.call(t,e)},success:e=>{n(new S.A(e))},error:e=>{o(e)}})}))},N={ports:[{name:"htmlTitle",displayName:"Title",group:"General",plug:"input",type:"string",default:"Fluxscape Viewer",tooltip:"The title that web browsers show",ignoreInExport:!0},{name:"headCode",displayName:"Head Code",group:"Custom Code",plug:"input",type:{name:"string",codeeditor:"html"},tooltip:"Add custom code to the <head> tag",ignoreInExport:!0},{name:"navigationPathType",displayName:"URL Path Type",group:"Navigation",plug:"input",type:{name:"enum",enums:[{label:"Hash",value:"hash"},{label:"Path",value:"path"}]},default:"hash"},{name:"bodyScroll",displayName:"Body Scroll",group:"Experimental features",plug:"input",type:{name:"boolean"},tooltip:"Changes so the <body> tag will scroll by default"},{name:"repeaterDisabledWhenUnmounted",displayName:"Disable when unmounted",group:"Experimental features - Repeater",plug:"input",type:{name:"boolean"},tooltip:"Repeater will only create components when it's mounted"},{name:"repeaterCreateComponentsAsync",displayName:"Create asynchronously",group:"Experimental features - Repeater",plug:"input",type:{name:"boolean"},tooltip:"Repeater items will be created in chunks to keep UI responsive"}]};class O{constructor(e,t){this.isRunning=!1,this.numBoundingBoxObservers=0,this.callback=e,this.pollDelay=t}addObserver(){this.numBoundingBoxObservers++,this.isRunning||this._startObserver()}removeObserver(){this.numBoundingBoxObservers--,0===this.numBoundingBoxObservers&&this._stopObserver()}setTarget(e){this.target=e,this.numBoundingBoxObservers>0&&!this.isRunning&&this._startObserver()}_startObserver(){if(this.isRunning)return;if(!this.target)return;this.isRunning=!0;let e=this.target.getBoundingClientRect();const t=()=>{if(!this.target)return void(this.isRunning=!1);const n=this.target.getBoundingClientRect();e.x!==n.x&&this.callback("x",n),e.y!==n.y&&this.callback("y",n),e.width!==n.width&&this.callback("width",n),e.height!==n.height&&this.callback("height",n),e=n,this.isRunning&&(this.pollDelay?setTimeout(t,this.pollDelay):window.requestAnimationFrame(t))};window.requestAnimationFrame(t)}_stopObserver(){this.isRunning=!1}}function I(e){return e&&"%"===e[e.length-1]}function w(e){return Number(e.slice(0,-1))}function P(e,t,n){if(!t&&!n)return e;let o=`calc(${e}`;return t&&(o+=` - ${t}`),n&&(o+=` - ${n}`),o+=")",o}const x={size(e,t){"none"===t.parentLayout&&(e.position="absolute"),"explicit"===t.sizeMode?(e.width=t.width,e.height=t.height):"contentHeight"===t.sizeMode?e.width=t.width:"contentWidth"===t.sizeMode&&(e.height=t.height),e.flexShrink=0,"row"===t.parentLayout&&"relative"===e.position?(I(e.width)&&!t.fixedWidth&&(e.flexGrow=w(e.width),e.flexShrink=1),I(e.height)&&!t.fixedHeight&&(e.height=P(e.height,e.marginTop,e.marginBottom))):"column"===t.parentLayout&&"relative"===e.position?(I(e.width)&&!t.fixedWidth&&(e.width=P(e.width,e.marginLeft,e.marginRight)),I(e.height)&&!t.fixedHeight&&(e.flexGrow=w(e.height),e.flexShrink=1)):"relative"!==e.position&&(I(e.width)&&(e.width=P(e.width,e.marginLeft,e.marginRight)),I(e.height)&&(e.height=P(e.height,e.marginTop,e.marginBottom)))},align(e,t){const{position:n}=e;let{alignX:o,alignY:i}=t;"relative"!==n&&(o=o||"left",i=i||"top");let s="";const r=t.parentLayout||"column";if(o)if("relative"!==n)"left"===o?e.left=0:"center"===o?(e.left="50%",s+="translateX(-50%) "):e.right=0;else if("relative"===n&&"row"===r)switch(o){case"left":e.marginRight=e.marginRight?e.marginRight:"auto";break;case"center":e.marginRight=e.marginRight?e.marginRight:"auto",e.marginLeft=e.marginLeft?e.marginLeft:"auto";break;case"right":e.marginLeft=e.marginLeft?e.marginLeft:"auto"}else if("relative"===n&&"column"===r)switch(o){case"left":e.alignSelf="flex-start";break;case"center":e.alignSelf="center";break;case"right":e.alignSelf="flex-end"}if(i)if("relative"!==n)"top"===i?e.top=0:"center"===i?(e.top="50%",s+="translateY(-50%)"):e.bottom=0;else if("relative"===n&&"column"===r)switch(i){case"top":e.marginBottom=e.marginBottom?e.marginBottom:"auto";break;case"center":e.marginTop=e.marginTop?e.marginTop:"auto",e.marginBottom=e.marginBottom?e.marginBottom:"auto";break;case"bottom":e.marginTop=e.marginTop?e.marginTop:"auto"}else if("relative"===n&&"row"===r)switch(i){case"top":e.alignSelf="flex-start";break;case"center":e.alignSelf="center";break;case"bottom":e.alignSelf="flex-end"}s&&(e.transform=s+(e.transform||""))}};function E(e){return e&&"object"==typeof e&&!Array.isArray(e)}function T(e,...t){if(!t.length)return e;const n=t.shift();if(E(e)&&E(n))for(const t in n)E(n[t])?(e[t]||Object.assign(e,{[t]:{}}),T(e[t],n[t])):Object.assign(e,{[t]:n[t]});return T(e,...t)}class A{constructor(){this.loadedFontFamilies={},this.fontCssFamiliesAdded={},this.fontCallbacks={},["Arial","Arial Black","Courier New","Helvetica","Impact","Lucida Console","Tahoma","Times New Roman"].forEach((e=>{this.loadedFontFamilies[e]=!0}))}removeFileEnding(e){return e.replace(/\.[^/.]+$/,"")}loadFont(e){var t;if("undefined"==typeof document)return;e=(0,s.getAbsoluteUrl)(e);const n=this.removeFileEnding(e).split("/").pop();if(this.loadedFontFamilies[n])return void(null===(t=this.fontCallbacks[n])||void 0===t||t.forEach((e=>{e()})));if(this.fontCssFamiliesAdded[n])return;this.fontCssFamiliesAdded[n]=!0;const o=document.createElement("style");o.type="text/css";const i=Noodl.Env.BaseUrl||"/";e.startsWith("/")&&(e=e.substring(1)),o.appendChild(document.createTextNode(`@font-face { font-family: '${n}'; src: url('${i}${e}'); }\n`)),document.head.appendChild(o),"undefined"!=typeof window&&__webpack_require__(5371).load({timeout:6e5,custom:{families:[n]},fontactive:e=>{var t;this.loadedFontFamilies[e]=!0,null===(t=this.fontCallbacks[e])||void 0===t||t.forEach((e=>{e()}))}})}callWhenFontIsActive(e,t){this.loadedFontFamilies[e]?t():(this.fontCallbacks[e]||(this.fontCallbacks[e]=[]),this.fontCallbacks[e].push(t))}}function k({title:e,body:t,images:n}){let o=`

${e}

`;if(t&&(o+=(t=Array.isArray(t)?t:[t]).map((e=>`

${e}

`)).join("")),n){let e="";n.forEach((t=>{e+='"})),o+=``}return o}function D(e,t){e.inputCss||(e.inputCss={}),e.defaultCss||(e.defaultCss={});for(const n in t)e.inputCss[n]=t[n]}function R(e,t,n){e[t]||(e[t]={});for(const o in n)e[t][o]=n[o]}function M(e,t){R(e,"inputs",t)}function V(e,t){R(e,"inputProps",t)}function j(e,t,n){e.dynamicports||(e.dynamicports=[]),e.dynamicports.push({condition:t,inputs:n})}A.instance=new A;const F={addInputProps:V,addInputs:M,addDynamicInputPorts:j,addInputCss:D,addSharedVisualInputs(e){D(e,{opacity:{index:200,group:"Style",displayName:"Opacity",type:"number",default:1,allowVisualStates:!0},mixBlendMode:{index:201,group:"Style",displayName:"Blend Mode",type:{name:"enum",enums:[{label:"Normal",value:"normal"},{label:"Multiply",value:"multiply"},{label:"Screen",value:"screen"},{label:"Overlay",value:"overlay"},{label:"Darken",value:"darken"},{label:"Lighten",value:"lighten"},{label:"Color Dodge",value:"color-dodge"},{label:"Color Burn",value:"color-burn"},{label:"Hard Light",value:"hard-light"},{label:"Soft Light",value:"soft-light"},{label:"Difference",value:"difference"},{label:"Exclusion",value:"exclusion"},{label:"Hue",value:"hue"},{label:"Saturation",value:"saturation"},{label:"Color",value:"color"},{label:"Luminosity",value:"luminosity"}]},default:"normal",applyDefault:!1,allowVisualStates:!0}}),M(e,{visible:{index:210,displayName:"Visible",group:"Style",default:!0,type:"boolean",set(e){e?this.removeStyle(["visibility"]):this.setStyle({visibility:"hidden"})}},zIndex:{index:211,displayName:"zIndex",group:"Style",type:"number",allowVisualStates:!0,set(e){void 0===e?this.removeStyle(["zIndex"]):this.setStyle({zIndex:Number(e)})}}})},addMarginInputs(e){D(e,{marginLeft:{index:1,group:"Margin and padding",displayName:"Margin Left",type:{name:"number",units:["px","%"],defaultUnit:"px",marginPaddingComp:"margin-left"},allowVisualStates:!0},marginRight:{index:2,group:"Margin and padding",displayName:"Margin Right",type:{name:"number",units:["px","%"],defaultUnit:"px",marginPaddingComp:"margin-right"},allowVisualStates:!0},marginTop:{index:3,group:"Margin and padding",displayName:"Margin Top",type:{name:"number",units:["px","%"],defaultUnit:"px",marginPaddingComp:"margin-top"},allowVisualStates:!0},marginBottom:{index:4,group:"Margin and padding",displayName:"Margin Bottom",type:{name:"number",units:["px","%"],defaultUnit:"px",marginPaddingComp:"margin-bottom"},allowVisualStates:!0}})},addPaddingInputs(e,t){const n=(t=t||{}).defaults?t.defaults:{},o=t.styleTag;D(e,{paddingLeft:{index:64,group:"Margin and padding",default:n.paddingLeft||0,applyDefault:!1,displayName:"Pad Left",type:{name:"number",units:["px"],defaultUnit:"px",marginPaddingComp:"padding-left"},allowVisualStates:!0,styleTag:o},paddingRight:{index:65,group:"Margin and padding",default:n.paddingRight||0,applyDefault:!1,displayName:"Pad Right",type:{name:"number",units:["px"],defaultUnit:"px",marginPaddingComp:"padding-right"},allowVisualStates:!0,styleTag:o},paddingTop:{index:66,group:"Margin and padding",displayName:"Pad Top",default:n.paddingTop||0,applyDefault:!1,type:{name:"number",units:["px"],defaultUnit:"px",marginPaddingComp:"padding-top"},allowVisualStates:!0,styleTag:o},paddingBottom:{index:67,group:"Margin and padding",displayName:"Pad Bottom",default:n.paddingBottom||0,applyDefault:!1,type:{name:"number",units:["px"],defaultUnit:"px",marginPaddingComp:"padding-bottom"},allowVisualStates:!0,styleTag:o}})},addTransformInputs(e){M(e,{transformX:{group:"Placement",displayName:"Pos X",default:0,index:300,allowVisualStates:!0,type:{name:"number",units:["px","%"],defaultUnit:"px"},set(e){this.transforms||(this.transforms={}),this.transforms.x=e.value+e.unit,this.updateTransform()}},transformY:{group:"Placement",displayName:"Pos Y",default:0,index:301,allowVisualStates:!0,type:{name:"number",units:["px","%"],defaultUnit:"px"},set(e){this.transforms||(this.transforms={}),this.transforms.y=e.value+e.unit,this.updateTransform()}},transformRotation:{index:302,group:"Placement",displayName:"Rotation",default:0,allowVisualStates:!0,type:{name:"number",units:["deg"],defaultUnit:"deg"},set(e){this.transforms||(this.transforms={}),this.transforms.rotation=e.value+e.unit,this.updateTransform()}},transformScale:{index:303,group:"Placement",displayName:"Scale",default:1,allowVisualStates:!0,type:{name:"number"},set(e){this.transforms||(this.transforms={}),this.transforms.scale=e,this.updateTransform()}},transformOriginX:{index:304,group:"Placement",displayName:"Transform Origin X",allowVisualStates:!0,type:{name:"number",units:["px","%"],defaultUnit:"%"},default:"50",set(e){this.transformOriginX=e.value+e.unit,this.updateTransformOrigin()}},transformOriginY:{index:305,group:"Placement",displayName:"Transform Origin Y",allowVisualStates:!0,type:{name:"number",units:["px","%"],defaultUnit:"%"},default:"50",set(e){this.transformOriginY=e.value+e.unit,this.updateTransformOrigin()}}}),e.methods||(e.methods={}),e.methods.updateTransform=function(){let e="";const{x:t,y:n,rotation:o,scale:i}=this.transforms;t&&(e+=`translateX(${t}) `),n&&(e+=`translateY(${n}) `),o&&(e+=`rotate(${o}) `),void 0!==i&&(e+=`scale(${i},${i})`),this.setStyle({transform:e})},e.methods.updateTransformOrigin=function(){const e=void 0!==this.transformOriginX?this.transformOriginX:"50%",t=void 0!==this.transformOriginY?this.transformOriginY:"50%";this.setStyle({transformOrigin:`${e} ${t}`})}},addAlignInputs(e){D(e,{position:{index:11,displayName:"Position",group:"Layout",type:{name:"enum",enums:[{label:"In Layout",value:"relative"},{label:"Absolute",value:"absolute"},{label:"Sticky",value:"sticky"},{label:"Fixed",value:"fixed"}]},default:"relative"}}),V(e,{alignX:{index:5,group:"Alignment",displayName:"Align X",type:{name:"enum",enums:[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}],alignComp:"horizontal"}},alignY:{index:6,group:"Alignment",displayName:"Align Y",type:{name:"enum",enums:[{label:"Top",value:"top"},{label:"Center",value:"center"},{label:"Bottom",value:"bottom"}],alignComp:"vertical"}}}),function(e){e.inputCss.position.tooltip=k({title:"Position",images:[{label:"Relative",body:"Relative to its siblings",src:"position-relative.svg"},{label:"Absolute",body:"Not affected by siblings or parent's layout",src:"position-absolute.svg"},{label:"Sticky",body:"Stick to parent's edge on overflow",src:"position-sticky.svg"},{label:"Fixed",body:"Always stay in the same place and take no space in the layout",src:"position-sticky.svg"}]})}(e)},addPointerEventOutputs(e){M(e,{pointerEventsMode:{index:403,displayName:"Pointer Events Mode",type:{name:"enum",enums:[{label:"Inherit",value:"inherit"},{label:"Explicit",value:"explicit"}]},default:"inherit",group:"Pointer Events",set(e){if("inherit"===e)this.removeStyle(["pointerEvents"]);else{let e="auto";void 0!==this._internal.pointerEventsEnabled&&(e=this._internal.pointerEventsEnabled?"auto":"none"),this.setStyle({pointerEvents:e})}}},pointerEventsEnabled:{index:404,displayName:"Pointer Events Enabled",type:"boolean",group:"Pointer Events",default:!0,set(e){this._internal.pointerEventsEnabled=!!e,this.setStyle({pointerEvents:this._internal.pointerEventsEnabled?"auto":"none"})}}}),V(e,{blockTouch:{index:450,displayName:"Block Pointer Events",group:"Pointer Events",type:"boolean"}}),j(e,"pointerEventsMode = explicit",["pointerEventsEnabled"]),function(e){R(e,"outputProps",{onClick:{displayName:"Click",group:"Events",type:"signal",propPath:"pointer"},pointerDown:{displayName:"Pointer Down",group:"Pointer Events",type:"signal",propPath:"pointer",props:{onMouseDown(){this.sendSignalOnOutput("pointerDown")},onTouchStart(){this.sendSignalOnOutput("pointerDown")}}},pointerUp:{displayName:"Pointer Up",group:"Pointer Events",type:"signal",propPath:"pointer",props:{onMouseUp(){this.sendSignalOnOutput("pointerUp")},onTouchEnd(){this.sendSignalOnOutput("pointerUp")},onTouchCancel(){this.sendSignalOnOutput("pointerUp")}}},pointerEnter:{displayName:"Pointer Enter",group:"Pointer Events",type:"signal",propPath:"pointer",props:{onMouseEnter(){this.sendSignalOnOutput("pointerEnter")}}},hoverStart:{displayName:"Hover Start",group:"Hover Events",type:"signal",propPath:"pointer",props:{onMouseOver(){this.sendSignalOnOutput("hoverStart"),this.setVisualStates(["hover"])}}},hoverEnd:{displayName:"Hover End",group:"Hover Events",type:"signal",propPath:"pointer",props:{onMouseLeave(){this.sendSignalOnOutput("hoverEnd"),this.setVisualStates([""])}}}})}(e),function(e){e.inputs.pointerEventsMode.tooltip=k({title:"Pointer events mode",body:["Control if mouse and touch events are enabled on this node","- Inherit: Same settings as parent","- Explicit: Enable control on this element"]}),e.inputs.pointerEventsEnabled.tooltip=k({title:"Pointer events enabled",body:["- Enabled: This element will receive mouse and touch events","- Disabled: No mouse or touch events will be captured by this element and the element below will receive it instead"]})}(e)},addDimensions(e,{defaultSizeMode:t="explicit",contentLabel:n="Content",useDimensionConstraints:o=!0}={}){let i="sizeMode = explicit OR sizeMode = contentHeight",s="sizeMode = explicit OR sizeMode = contentWidth";"explicit"!==t&&"contentHeight"!==t||(i+=" OR sizeMode NOT SET"),"explicit"!==t&&"contentWidth"!==t||(s+=" OR sizeMode NOT SET"),j(e,i,["width"]),j(e,s,["height"]),V(e,{sizeMode:{index:10,type:{name:"enum",enums:[{value:"explicit",label:"Explicit"},{value:"contentWidth",label:"Content Width"},{value:"contentHeight",label:"Content Height"},{value:"contentSize",label:"Content Size"}],allowEditOnly:!0,sizeComp:"mode"},group:"Dimensions",displayName:"Size Mode",default:t,allowVisualStates:!0},width:{index:11,group:"Dimensions",displayName:"Width",type:{name:"dimension",units:["%","px","vw","vh"],defaultUnit:"%"},default:100,allowVisualStates:!0,onChange(e){this.props.fixedWidth=e.isFixed}},height:{index:13,group:"Dimensions",displayName:"Height",type:{name:"dimension",units:["%","px","vw","vh"],defaultUnit:"%"},default:100,allowVisualStates:!0,onChange(e){this.props.fixedHeight=e.isFixed}}}),Noodl.deployed||function(e,t){e.inputProps.sizeMode.tooltip={explicit:{standard:"Explicit width & height",extended:k({title:"Explicit width & height",body:"Set width & height explicitly in pixels(px), percentage(%) or viewport size(vh/vw).",images:[{src:"size-mode-explicit.svg"}]})},contentWidth:{standard:`${t} width & explicit height`,extended:k({title:`${t} width & explicit height`,body:`The width will match the width of the ${t.toLowerCase()}. Height is set explicitly.`,images:[{src:"size-mode-content-width.svg"}]})},contentHeight:{standard:`Explicit width & ${t.toLowerCase()} height`,extended:k({title:`Explicit width & ${t.toLowerCase()} height`,body:`The width is set explicitly. The height will match the height of the ${t.toLowerCase()}`,images:[{src:"size-mode-content-height.svg"}]})},contentSize:{standard:`${t} width & height`,extended:k({title:`${t} width & height`,body:`The width and height will match the size of the ${t.toLowerCase()}`,images:[{src:"size-mode-content-size.svg"}]})}};const n=["- %: Relative to parents size. If 'fixed' is false this element will resize to share space with siblings. If 'Clip Content' is disabled, it'll also expand to fit the boundaries of all its content","- px: Pixels","- vw: Relative to viewport width. 100 makes the element the same width as the screen","- vh: Relative to viewport height. 100 makes the element the same height as the screen"],o=k({title:"Fixed",body:["- Enabled: Elements will be the exact size set","- Disabled: Element will resize to fill up empty space, or shrink to make space for siblings. Use the dimension constraints, min and max size, to control the boundaries"]});e.inputProps.width.tooltip={dimension:k({title:"Width",body:n}),fixed:o},e.inputProps.height.tooltip={dimension:k({title:"Height",body:n}),fixed:o}}(e,n),o&&(D(e,{minWidth:{index:400,group:"Dimension Constraints",displayName:"Min Width",allowVisualStates:!0,type:{name:"number",units:["%","px","vw","vh"],defaultUnit:"%"}},maxWidth:{index:401,group:"Dimension Constraints",displayName:"Max Width",allowVisualStates:!0,type:{name:"number",units:["%","px","vw","vh"],defaultUnit:"%"}},minHeight:{index:402,group:"Dimension Constraints",displayName:"Min Height",allowVisualStates:!0,type:{name:"number",units:["%","px","vw","vh"],defaultUnit:"%"}},maxHeight:{index:403,group:"Dimension Constraints",displayName:"Max Height",allowVisualStates:!0,type:{name:"number",units:["%","px","vw","vh"],defaultUnit:"%"}}}),Noodl.deployed||function(e){e.inputCss.minWidth.tooltip=k({title:"Minimum width",body:"This is prioritized over other properties, so the element won't shrink below this size"}),e.inputCss.minHeight.tooltip=k({title:"Minimum height",body:"This is prioritized over other properties, so the element won't shrink below this size"}),e.inputCss.maxWidth.tooltip=k({title:"Maximum width",body:"This is prioritized over other properties, so the element won't grow beyond this size"}),e.inputCss.maxHeight.tooltip=k({title:"Maximum height",body:"This is prioritized over other properties, so the element won't grow beyond this size"})}(e))},_addCornerRadius(e,t){const n=(t=t||{}).defaults||{},o=t.styleTag;function i(e,t,o,i){const s={group:"corners",tab:o,label:t},r=`border${t}Radius`;M(e,{[r]:{index:240+i,displayName:"Corner Radius",editorName:"Corner Radius "+(t?"("+t+")":""),group:"Corner Radius",type:{name:"number",units:["px","%"],defaultUnit:"px"},allowVisualStates:!0,default:n[r],tab:s,set(e){this._internal.borderRadius[r]=void 0===e.value?Number(e)+"px":e.value+e.unit,this._updateCornerRadii()}}})}n.borderRadius||(n.borderRadius=0),i(e,"","corners-all",0),i(e,"TopLeft","corners-top-left",1),i(e,"TopRight","corners-top-right",2),i(e,"BottomRight","corners-bottom-right",3),i(e,"BottomLeft","corners-bottom-left",4),e.methods._updateCornerRadii=function(){const e=this._internal.borderRadius;function t(t,n){const o=`border${n}Radius`;t[o]=e[o]||e.borderRadius}const n={};t(n,"TopLeft"),t(n,"TopRight"),t(n,"BottomRight"),t(n,"BottomLeft"),this.setStyle(n,o)};const s=e.initialize;e.initialize=function(){s&&s.call(this),this._internal.borderRadius={...n},n.borderRadius&&this._updateCornerRadii()}},addBorderInputs(e,t){const n=(t=t||{}).defaults||{},o=t.styleTag;function i(e,t,o,i){const s=`border${t}Style`,r=`border${t}Width`,a=`border${t}Color`;let l="none"!==n.borderStyle?"OR borderStyle NOT SET":"";t?(n[s]&&"none"!==n[s]&&(l+=`OR ${s} NOT SET`),j(e,`${s} = solid OR ${s} = dashed OR ${s} = dotted OR borderStyle = solid OR borderStyle = dashed OR borderStyle = dotted ${l}`,[`${r}`,`${a}`])):j(e,`${s} = solid OR ${s} = dashed OR ${s} = dotted ${l}`,[`${r}`,`${a}`]);const d={group:"border-styles",tab:o,label:t},u=e=>`${e} ${t?"("+t+")":""}`,c=202+4*i;M(e,{[s]:{index:c+1,displayName:"Border Style",editorName:u("Border Style"),group:"Border Style",allowVisualStates:!0,type:{name:"enum",enums:[{label:"None",value:"none"},{label:"Solid",value:"solid"},{label:"Dotted",value:"dotted"},{label:"Dashed",value:"dashed"}]},default:n[s],tab:d,set(e){this._internal.borders[s]=e,this._updateBorders()}},[r]:{index:c+2,displayName:"Border Width",editorName:u("Border Width"),group:"Border Style",allowVisualStates:!0,type:{name:"number",units:["px"],defaultUnit:"px"},default:n[r],tab:d,set(e){this._internal.borders[r]=void 0===e.value?Number(e)+"px":e.value+e.unit,this._updateBorders()}},[a]:{index:c+3,displayName:"Border Color",editorName:u("Border Color"),group:"Border Style",type:"color",default:n[a],allowVisualStates:!0,tab:d,set(e){this._internal.borders[a]=e,this._updateBorders()}}})}void 0===n.borderStyle&&(n.borderStyle="none"),void 0===n.borderWidth&&(n.borderWidth=2),void 0===n.borderColor&&(n.borderColor="#000000"),i(e,"","borders-all",0),i(e,"Left","borders-left",1),i(e,"Top","borders-top",2),i(e,"Right","borders-right",3),i(e,"Bottom","borders-bottom",4),e.methods._updateBorders=function(){const e=this._internal.borders;function t(t,n){const o=`border${n}Width`,i=`border${n}Color`,s=`border${n}Style`;t[o]=e[o]||e.borderWidth,t[i]=e[i]||e.borderColor,t[s]=e[s]||e.borderStyle}const n={};t(n,"Top"),t(n,"Right"),t(n,"Bottom"),t(n,"Left"),this.setStyle(n,o)};const s=e.initialize;e.initialize=function(){s&&s.call(this),this._internal.borders={...n},("none"!==n.borderStyle||n.borderTopStyle&&"none"!==n.borderTopStyle||n.borderRightStyle&&"none"!==n.borderRightStyle||n.borderBottomStyle&&"none"!==n.borderBottomStyle||n.borderRightStyle&&"none"!==n.borderRightStyle)&&this._updateBorders()},this._addCornerRadius(e,{defaults:n,styleTag:o})},addShadowInputs(e,t){const n=(t=t||{}).styleTag;j(e,"boxShadowEnabled = true",["boxShadowOffsetX","boxShadowOffsetY","boxShadowInset","boxShadowBlurRadius","boxShadowSpreadRadius","boxShadowColor"]),M(e,{boxShadowEnabled:{index:250,group:"Box Shadow",displayName:"Shadow Enabled",type:"boolean",default:!1,allowVisualStates:!0,set(e){this._internal.boxShadowEnabled=e,this._updateBoxShadow()}},boxShadowOffsetX:{index:251,group:"Box Shadow",displayName:"Offset X",default:0,type:{name:"number",units:["px"],defaultUnit:"px"},allowVisualStates:!0,set(e){this._internal.boxShadowOffsetX=e.value+e.unit,this._updateBoxShadow()}},boxShadowOffsetY:{index:252,group:"Box Shadow",displayName:"Offset Y",default:0,type:{name:"number",units:["px"],defaultUnit:"px"},allowVisualStates:!0,set(e){this._internal.boxShadowOffsetY=e.value+e.unit,this._updateBoxShadow()}},boxShadowBlurRadius:{index:253,group:"Box Shadow",displayName:"Blur Radius",default:5,type:{name:"number",units:["px"],defaultUnit:"px"},allowVisualStates:!0,set(e){this._internal.boxShadowBlurRadius=e.value+e.unit,this._updateBoxShadow()}},boxShadowSpreadRadius:{index:254,group:"Box Shadow",displayName:"Spread Radius",default:2,type:{name:"number",units:["px"],defaultUnit:"px"},allowVisualStates:!0,set(e){this._internal.boxShadowSpreadRadius=e.value+e.unit,this._updateBoxShadow()}},boxShadowInset:{index:255,group:"Box Shadow",displayName:"Inset",type:"boolean",default:!1,allowVisualStates:!0,set(e){this._internal.boxShadowInset=e,this._updateBoxShadow()}},boxShadowColor:{index:256,group:"Box Shadow",displayName:"Shadow Color",type:"color",default:"#00000033",allowVisualStates:!0,set(e){this._internal.boxShadowColor=e,this._updateBoxShadow()}}}),e.methods._updateBoxShadow=function(){const e=this._internal;e.boxShadowEnabled?this.setStyle({boxShadow:`${e.boxShadowInset?"inset ":""}${e.boxShadowOffsetX} ${e.boxShadowOffsetY} ${e.boxShadowBlurRadius} ${e.boxShadowSpreadRadius} ${e.boxShadowColor}`},n):this.removeStyle(["boxShadow"],n)};const o=e.initialize;e.initialize=function(){o&&o.call(this),this._internal.boxShadowOffsetX=0,this._internal.boxShadowOffsetY=0,this._internal.boxShadowBlurRadius="5px",this._internal.boxShadowSpreadRadius="2px",this._internal.boxShadowColor="#00000033"}},addIconInputs(e,t){const n={useIcon:!0,iconColor:"#FFFFFF"};(t=t||{}).defaults&&Object.assign(n,t.defaults);let o="useIcon = true";n.useIcon&&(o+=" OR useIcon NOT SET");const i=["iconSourceType","iconSize"];t.enableIconPlacement&&(i.push("iconPlacement"),i.push("iconSpacing")),j(e,o,i),n.useIcon?(j(e,"#js (params.useIcon===true || params.useIcon===undefined) && params.iconSourceType === 'image'",["iconImageSource"]),j(e,"#js (params.useIcon===true || params.useIcon===undefined) && params.iconSourceType === 'icon'",["iconIconSource","iconColor"])):(j(e,"useIcon = true AND iconSourceType = image",["iconImageSource"]),j(e,"useIcon = true AND iconSourceType = icon",["iconIconSource","iconColor"])),t.hideEnableIconInput||V(e,{useIcon:{type:"boolean",group:"Icon",displayName:"Enable Icon",default:n.useIcon,allowVisualStates:!0,index:20}}),V(e,{iconSourceType:{type:{name:"enum",enums:[{label:"Image",value:"image"},{label:"Icon",value:"icon"}]},group:"Icon",displayName:"Type",default:"icon",allowVisualStates:!0,index:21},iconIconSource:{type:"icon",displayName:"Icon Source",group:"Icon",allowVisualStates:!0,index:23}}),M(e,{iconImageSource:{type:"image",displayName:"Image Source",group:"Icon",allowVisualStates:!0,index:22,set(e){this.props.iconImageSource=(0,s.getAbsoluteUrl)(e)}}}),t.enableIconPlacement&&V(e,{iconSpacing:{group:"Icon",displayName:"Spacing",default:10,type:{name:"number",units:["px"],defaultUnit:"px"},allowVisualStates:!0,index:24},iconPlacement:{type:{name:"enum",enums:[{label:"Left",value:"left"},{label:"Right",value:"right"}]},group:"Icon",displayName:"Placement",default:"left",allowVisualStates:!0,index:25}}),V(e,{iconSize:{group:"Icon",displayName:"Size",default:16,type:{name:"number",units:["px"],defaultUnit:"px"},allowVisualStates:!0,index:26},iconColor:{group:"Icon",displayName:"Color",editorName:"Icon Color",default:n.iconColor,type:"color",allowVisualStates:!0,index:27}})},addLabelInputs(e,t){const n={useLabel:!1};(t=t||{}).defaults&&Object.assign(n,t.defaults);const o=n.useLabel?"useLabel = true OR useLabel NOT SET":"useLabel = true",i=t.styleTag||"",s=["label"].concat(["textStyle","fontFamily","fontSize","color","letterSpacing","lineHeight","textTransform"].map((e=>i+e)));t.enableSpacing&&s.push("labelSpacing"),j(e,o,s),V(e,{useLabel:{index:18,type:"boolean",displayName:"Enable Label",group:"Label",default:n.useLabel},label:{type:"string",displayName:"Label",group:"Label",default:"Label"}}),t.enableSpacing&&V(e,{labelSpacing:{displayName:"Spacing",group:"Label",type:{name:"number",units:["px"],defaultUnit:"px"},default:10}}),this.addTextStyleInputs(e,{...t,group:"Label Text Style",popout:{group:"label-text-style",label:"Text Style",parentGroup:"Label"}})},addTextStyleInputs(e,t){const n=(t=t||{}).group||"Text Style",o=t.styleTag,i=t.hasOwnProperty("portPrefix")?t.portPrefix:t.styleTag||"",s=i+"textStyle",r=void 0!==t.portIndex?t.portIndex:19;function a(e){return t.displayName?t.displayName+" "+e:e}M(e,{[s]:{index:r,type:{name:"textStyle",childPorts:["fontFamily","fontSize","color","letterSpacing","lineHeight","textTransform"],childPortPrefix:i},group:n,displayName:"Text Style",editorName:a("Text Style"),default:"None",set(e){this.props[s]=this.context.styles.getTextStyle(e),this.forceUpdate()},allowVisualStates:!0,popout:t.popout},[i+"fontFamily"]:{index:r+1,type:{name:"font",parentPort:s},group:n,displayName:"Font Family",editorName:a("Font Family"),set(e){if(e){let t=e;t.split(".").length>1&&(A.instance.loadFont(t),t=t.replace(/\.[^/.]+$/,""),t=t.split("/").pop()),this.setStyle({fontFamily:t},o)}else this.removeStyle(["fontFamily"],o);this.props[s]&&this.forceUpdate()},allowVisualStates:!0,popout:t.popout}}),D(e,{[i+"fontSize"]:{index:r+2,group:n,displayName:"Font Size",editorName:a("Font Size"),targetStyleProperty:"fontSize",type:{name:"number",units:["px"],defaultUnit:"px",parentPort:s},onChange(){this.props[s]&&this.forceUpdate()},allowVisualStates:!0,popout:t.popout,styleTag:o},[i+"color"]:{index:r+3,type:{name:"color",parentPort:s},displayName:"Color",editorName:a("Color"),group:n,targetStyleProperty:"color",allowVisualStates:!0,popout:t.popout,styleTag:o,onChange(){this.props[s]&&this.forceUpdate()}},[i+"letterSpacing"]:{index:r+4,group:n,displayName:"Letter Spacing",editorName:a("Letter Spacing"),targetStyleProperty:"letterSpacing",type:{name:"number",units:["px","em"],defaultUnit:"px"},allowVisualStates:!0,popout:t.popout,styleTag:o,default:"Auto",applyDefault:!1,onChange(){this.props[s]&&this.forceUpdate()}},[i+"lineHeight"]:{index:r+5,group:n,displayName:"Line Height",editorName:a("Line Height"),targetStyleProperty:"lineHeight",type:{name:"number",units:["","px","%"],defaultUnit:"",parentPort:s},allowVisualStates:!0,onChange(){this.props[s]&&this.forceUpdate()},popout:t.popout,styleTag:o,default:"Auto",applyDefault:!1},[i+"textTransform"]:{index:r+6,group:n,displayName:"Case",editorName:a("Case"),applyDefault:!1,targetStyleProperty:"textTransform",type:{name:"enum",enums:[{label:"None",value:"none"},{label:"Uppercase",value:"uppercase"},{label:"Lowercase",value:"lowercase"},{label:"Capitalize",value:"capitalize"}],parentPort:s},default:"none",popout:t.popout,styleTag:o,allowVisualStates:!0,onChange(){this.props[s]&&this.forceUpdate()}}});const l=i+"fontFamily";e.setup=function(t,n){n.on("nodeAdded."+e.name,(function(e){e.parameters[l]&&e.parameters[l].split(".").length>1&&A.instance.loadFont(e.parameters[l]),e.on("parameterUpdated",(function(e){e.name===l&&e.value&&e.value.split(".").length>1&&A.instance.loadFont(e.value)}))}))}}};var U=__webpack_require__(8972),W=__webpack_require__.n(U),L=__webpack_require__(2004);function B(e,t,n,o){e._transitions&&e._transitions[t]&&(e._transitions[t].stop(),delete e._transitions[t]);const i=e.getInputValue(t),s=e.getInput(t);let r;if(s&&"color"===s.type?r=function(e,t){const n=[0,0,0,255];q(n,e);const o=[0,0,0,255];q(o,t),e&&"transparent"!==e||(n[0]=o[0],n[1]=o[1],n[2]=o[2]),t&&"transparent"!==t||(o[0]=n[0],o[1]=n[1],o[2]=n[2]);const i=[0,0,0,0];return e=>(i[0]=Math.floor(L.A.linear(n[0],o[0],e)),i[1]=Math.floor(L.A.linear(n[1],o[1],e)),i[2]=Math.floor(L.A.linear(n[2],o[2],e)),i[3]=Math.floor(L.A.linear(n[3],o[3],e)),function(e){return"#"+z(e[0])+z(e[1])+z(e[2])+z(e[3])}(i))}(e.context.styles.resolveColor(i),e.context.styles.resolveColor(n)):"number"==typeof i&&"number"==typeof n?r=$(i,n):"object"==typeof i&&i.hasOwnProperty("value")&&"object"==typeof n&&n.hasOwnProperty("value")&&(r=$(i.value,n.value)),r){e._transitions||(e._transitions={});const n=W()(o.curve);e._transitions[t]=e.context.timerScheduler.createTimer({duration:o.dur,onRunning:o=>{const i=r(n.get(o));e.queueInput(t,i)},onFinish:()=>{delete e._transitions[t]}}),e._transitions[t].start()}else e.queueInput(t,n)}function $(e,t){return n=>L.A.linear(e,t,n)}function q(e,t){if("transparent"===t||!t)return void(e[3]=0);const n=(t.length-1)/2;for(let o=0;o{i(),t[n].call(e)}}else o[n]=t[n].bind(e);e.forceUpdate()}function G(e,t,n){let o;o="signal"===n.type?()=>{e.sendSignalOnOutput(t)}:(...o)=>{e.outputPropValues[t]=n.getValue?n.getValue.call(e,...o):o[0],e.flagOutputDirty(t),n.onChange&&n.onChange.call(e,e.outputPropValues[t])},H(e,{[t]:o},n.propPath)}function X(e,t){if(!e.type)throw new Error(`input ${t} is missing a type`);e.type.units?e.set=function(n){const o=e.propPath?this.props[e.propPath]:this.props;n&&void 0!==n.value?o[t]=n.value+n.unit:delete o[t],e.onChange&&e.onChange.call(this,n),this.forceUpdate()}:e.set=function(n){const o=e.propPath?this.props[e.propPath]:this.props;void 0!==n?o[t]=n:delete o[t],e.onChange&&e.onChange.call(this,n),this.forceUpdate()}}function Y(e,t){for(const n of t)Array.isArray(n)?Y(e,n):void 0!==n&&e.push(n)}class J extends n().Component{componentDidMount(){this.props.noodlNode.sendSignalOnOutput("didMount")}componentWillUnmount(){this.props.noodlNode.sendSignalOnOutput("willUnmount");const e=this.props.noodlNode;if(e.currentVisualStates){const t=["hover","pressed","focused"],n=e.currentVisualStates.filter((e=>!t.includes(e)));e.setVisualStates(n)}}render(){const{noodlNode:e,style:t,...o}=this.props;let i=e.style;t&&(i={...e.style,...t});const s={ref:t=>{e.innerReactComponentRef=t},style:i,...e.props,...o};if(e.noodlNodeAsProp){s.noodlNode=e;const t=e.getVisualParentNode();t&&t.props.layout&&(s.parentLayout=t.props.layout)}return e.renderedAtFrame=e.context.frameNumber,e.useFrame&&(void 0!==s.textStyle&&(s.style=i=Object.assign({},s.textStyle,i)),x.size(i,s),x.align(i,s)),n().createElement(e.reactComponent,s,e.renderChildren())}}function K(e,t,n){let o=e;if(n&&o.getAttribute("noodl-style-tag")!==n&&(o=e.querySelector(`[noodl-style-tag=${n}]`)),o)for(const e in t)o.style[e]=t[e]}let Q=0;function Z(e){const{frame:t}=e;void 0!==t&&(t.dimensions&&F.addDimensions(e,"object"==typeof t.dimensions?t.dimensions:void 0),t.position&&F.addTransformInputs(e),t.margins&&F.addMarginInputs(e),t.padding&&F.addPaddingInputs(e),t.align&&F.addAlignInputs(e));const{initialize:o,inputs:s,inputProps:r,inputCss:a,outputs:l,outputProps:d,dynamicports:u,defaultCss:c={},methods:p}=e,h=Object.assign({},c),m={};for(const e in a){const t=a[e],n=t.hasOwnProperty("default")&&!1!==t.applyDefault;if(t.styleTag&&!m.hasOwnProperty(t.styleTag)&&(m[t.styleTag]={}),n){const n=t.type.units?t.default+t.type.defaultUnit:t.default;t.styleTag?m[t.styleTag][e]=n:h[e]=n}}function g(e,t){this.clientBoundingRect=t,"x"===e?this.flagOutputDirty("screenPositionX"):"y"===e?this.flagOutputDirty("screenPositionY"):"width"===e?this.flagOutputDirty("boundingWidth"):"height"===e&&this.flagOutputDirty("boundingHeight")}const f=void 0===e.useVariants||e.useVariants,y={name:e.name,docs:e.docs,displayNodeName:e.displayNodeName||e.displayName,shortDesc:"",category:"Visual",allowChildren:void 0===e.allowChildren||e.allowChildren,visualStates:e.visualStates,allowAsExportRoot:e.allowAsExportRoot,singleton:e.singleton,useVariants:f,usePortAsLabel:e.usePortAsLabel,portLabelTruncationMode:e.portLabelTruncationMode,connectionPanel:e.connectionPanel,nodeDoubleClickAction:e.nodeDoubleClickAction,initialize(){this.reactKey="key"+Q,Q++,this.children=[],v&&(this.childrenCount=0),this.props={styles:{}},this.outputPropValues={},this.style=Object.assign({},h);for(const e in m)this.props.styles[e]=Object.assign({},m[e]);this.childIndex=0,this.clientBoundingRect={},this.noodlNodeAsProp=!!e.noodlNodeAsProp;const n=this.context&&this.context.runningInCanvas?300:0;this.boundingBoxObserver=new O(g.bind(this),n),this.wantsToBeMounted=!0,this.useFrame=!!t;for(const e in r){const t=r[e];t.propPath&&!this.props.hasOwnProperty(t.propPath)&&(this.props[t.propPath]={});const n=t.propPath?this.props[t.propPath]:this.props;t.hasOwnProperty("default")&&(t.type.defaultUnit&&void 0!==t.default?n[e]=t.default+t.type.defaultUnit:n[e]=t.default)}for(const e in d){const t=d[e];t.propPath&&!this.props.hasOwnProperty(t.propPath)&&(this.props[t.propPath]={}),t.props?H(this,t.props,t.propPath):G(this,e,t)}this.reactComponentRef=null,this.reactComponent=e.getReactComponent.call(this),o&&o.call(this)},getInspectInfo:e.getInspectInfo,nodeScopeDidInitialize:e.nodeScopeDidInitialize,dynamicports:u,inputs:{cssClassName:{index:100010,displayName:"CSS Class",group:"Advanced HTML",type:"string",default:"",set(e){this.props.className=e,this.forceUpdate()}},styleCss:{index:100011,displayName:"CSS Style",group:"Advanced HTML",type:{name:"string",codeeditor:"text",allowEditOnly:!0},default:"/* background-color: red; */",set(e){this.updateAdvancedStyle({content:e})}}},outputs:{childIndex:{displayName:"Child Index",type:"number",get(){return this.childIndex}},this:{displayName:"This",type:"reference",get(){return this}},screenPositionX:{group:"Bounding Box",displayName:"Screen Position X",type:"number",get(){return this.clientBoundingRect.x},onFirstConnectionAdded(){this.boundingBoxObserver.addObserver()},onLastConnectionRemoved(){this.boundingBoxObserver.removeObserver()}},screenPositionY:{group:"Bounding Box",displayName:"Screen Position Y",type:"number",get(){return this.clientBoundingRect.y},onFirstConnectionAdded(){this.boundingBoxObserver.addObserver()},onLastConnectionRemoved(){this.boundingBoxObserver.removeObserver()}},boundingWidth:{group:"Bounding Box",displayName:"Width",type:"number",get(){return this.clientBoundingRect.width},onFirstConnectionAdded(){this.boundingBoxObserver.addObserver()},onLastConnectionRemoved(){this.boundingBoxObserver.removeObserver()}},boundingHeight:{group:"Bounding Box",displayName:"Height",type:"number",get(){return this.clientBoundingRect.height},onFirstConnectionAdded(){this.boundingBoxObserver.addObserver()},onLastConnectionRemoved(){this.boundingBoxObserver.removeObserver()}},didMount:{group:"Mounted",displayName:"Did Mount",type:"signal"},willUnmount:{group:"Mounted",displayName:"Will Unmount",type:"signal"}},methods:{updateAdvancedStyle(e){let t;this.customCssStyles&&(this.removeStyle(Object.keys(this.customCssStyles)),this.customCssStyles=void 0);let n="",o=(e.content||"").replace("\n",""),i="";for(;o.length;){let e=o.indexOf("/*");if(-1===e&&(e=o.length),i+=o.substring(0,e),o=o.substring(e),o.length){let e=o.indexOf("*/");-1===e&&(e=o.length),o=o.substring(e+2)}}function s(e){return e.replace(/^\s+|\s+$/gm,"")}const r=i.split(";").map(s).filter((e=>e.length));t={};for(const e of r){const o=e.split(":").map(s);if(-1!==e.indexOf("\n"))n+="Missing semicolon: "+e.split("\n")[0];else if(2!==o.length)n+="Syntax error: "+e;else{const e=o[0].split("-");for(let t=1;t"+n}):(this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"css-parse-waring"),t&&this.setStyle(t),this.customCssStyles=t)},setChildIndex(e){this.childIndex=e,this.flagOutputDirty("childIndex")},updateChildIndices(){let e=0;for(let t=0;t{"For Each"===t?.model?.type?e+=t.model.children.length:e++})),this.childrenCount=e,this.flagOutputDirty("childrenCount")},addChild(e,t){void 0===t&&(t=this.children.length),e.parent=this,this.children.splice(t,0,e),this.cachedChildren=void 0,this.scheduleUpdateChildCountAndIndicies(),this.forceUpdate()},removeChild(e){const t=this.children.indexOf(e);-1!==t&&(this.children.splice(t,1),e.parent=void 0,this.cachedChildren=void 0,this.scheduleUpdateChildCountAndIndicies(),this.forceUpdate())},contains(e){return-1!==this.children.indexOf(e)||this.children.some((t=>t.contains&&t.contains(e)))},scheduleUpdateChildCountAndIndicies(){this.updateChildIndiciesScheduled||(this.updateChildIndiciesScheduled=!0,this.scheduleAfterInputsHaveUpdated((()=>{this.updateChildIndices(),v&&this.updateChildrenCount(),this.updateChildIndiciesScheduled=!1})))},getChildren(){return this.children},isChild(e){return-1!==this.children.indexOf(e)},getChildRoot(){return this},forceUpdate(){!0!==this.forceUpdateScheduled&&(this.forceUpdateScheduled=!0,this.context.eventEmitter.once("frameEnd",(()=>{this.forceUpdateScheduled=!1,this.renderedAtFrame!==this.context.frameNumber&&this.reactComponentRef&&this.reactComponentRef.setState({})})),this.context.scheduleUpdate())},_resetReactVirtualDOM(){this.reactKey="key"+Q,Q++;const e=this.getVisualParentNode();e&&(e.cachedChildren=void 0,e.forceUpdate())},triggerDidMount(){this.wantsToBeMounted&&!this.didCallTriggerDidMount&&(this.didCallTriggerDidMount=!0,this.hasOutput("didMount")&&this.sendSignalOnOutput("didMount"),this.props.didMount&&this.props.didMount(),this.didMount&&this.didMount()),this.children.forEach((e=>{e.triggerDidMount&&e.triggerDidMount()}))},render(){if(this.wantsToBeMounted)return n().createElement(J,{key:this.reactKey,noodlNode:this,ref:e=>{this.reactComponentRef=e,this.boundingBoxObserver.setTarget(i().findDOMNode(e))}})},renderChildren(){if(!this.cachedChildren){let e=[];Y(e,this.children.map((e=>e.render()))),0===e.length?e=null:1===e.length&&(e=e[0]),this.cachedChildren=e}return this.cachedChildren},setStyle(e,t){const n=t?this.props.styles[t]:this.style;for(const t in e)n[t]=e[t];const o=this.getDOMElement();if(!o)return;let i=!1;if(!t){if(e.hasOwnProperty("opacity")&&(i=e.hasOwnProperty("opacity")&&("0"===o.style.opacity&&e.opacity>0||"0"!==o.style.opacity&&0===e.opacity)),e.transform){let t=e.transform;const n=this.getVisualParentNode();"absolute"!==this.style.position&&n&&n.style.flexDirection||("center"!==this.props.alignX||o.style.marginLeft&&o.style.marginRight||(t="translateX(-50%) "+t),"center"!==this.props.alignY||o.style.marginTop&&o.style.marginBottom||(t="translateY(-50%) "+t)),e.transform=t}const t=e.hasOwnProperty("marginLeft")||e.hasOwnProperty("marginRight")||e.hasOwnProperty("marginTop")||e.hasOwnProperty("marginBottom");(this.props.width&&"%"===this.props.width[this.props.width.length-1]||this.props.height&&"%"===this.props.height[this.props.height.length-1])&&t&&(i=!0),(e.position||e.flexDirection||e.clip)&&(i=!0)}i?this.forceUpdate():K(o,e,t)},removeStyle(e,t){const n=t?this.props.styles[t]:this.style;for(const t of e)delete n[t];const o=this.getDOMElement();let i=!1;if(!t&&o){const t={marginTop:!0,marginBottom:!0,marginLeft:!0,marginRight:!0};for(const n of e)t[n]&&(i=!0)}if(o){const n={};for(const t of e)n[t]="";K(o,n,t)}i&&this.forceUpdate()},getStyle(e){return this.style[e]},getRef(){return this.reactComponentRef},getDOMElement(){const e=this.getRef();if(e)return i().findDOMNode(e)},getVisualParentNode(){if(this.parent)return this.parent;let e=this.nodeScope.componentOwner;for(;!e.parent&&e.parentNodeScope;)e=e.parentNodeScope.componentOwner;return e?e.parent:void 0},setVariant(e){this._stopStateTransitions(),this.variant=e;const t={};e&&T(t,e.parameters),T(t,this.model.parameters),this.currentVisualStates&&T(t,this.getParametersForStates(this.currentVisualStates));const n=Object.keys(t).filter((e=>!this._hasInputBeenSetFromAConnection(e)));for(const e of n)this.registerInputIfNeeded(e),this.hasInput(e)&&this.queueInput(e,t[e])},getParameter(e){return this.model.parameters.hasOwnProperty(e)?this.model.parameters[e]:this.variant&&this.variant.parameters.hasOwnProperty(e)?this.variant.parameters[e]:this.context.getDefaultValueForInput(this.model.type,e)},getParametersForStates(e){const t={};if(this.variant)for(const n of e)this.variant.stateParameters&&this.variant.stateParameters.hasOwnProperty(n)&&T(t,this.variant.stateParameters[n]);for(const e in t)this.model.parameters.hasOwnProperty(e)&&((n=t[e])&&"object"==typeof n&&!Array.isArray(n)?T(t[e],this.model.parameters[e]):t[e]=this.model.parameters[e]);var n;if(this.model.stateParameters)for(const n of e)this.model.stateParameters.hasOwnProperty(n)&&T(t,this.model.stateParameters[n]);return t},_getNewState(e,t){const n=t.filter((t=>!(e||[]).includes(t))),o=n.length?n[0]:"neutral";return""===o?"neutral":o},_getDefaultTransition(e){return this.model.defaultStateTransitions&&this.model.defaultStateTransitions[e]&&this.model.defaultStateTransitions[e].curve?this.model.defaultStateTransitions[e]:this.variant&&this.variant.defaultStateTransitions&&this.variant.defaultStateTransitions[e]&&this.variant.defaultStateTransitions[e].curve?this.variant.defaultStateTransitions[e]:void 0},_getStateTransition(e){let t={};return this.model.stateTransitions&&this.model.stateTransitions[e]&&Object.assign(t,this.model.stateTransitions[e]),this.variant&&this.variant.stateTransitions&&this.variant.stateTransitions[e]&&Object.assign(t,this.variant.stateTransitions[e]),t},setVisualStates(e){if(!this.model)return;if(this.currentVisualStates&&e.length===this.currentVisualStates.length&&e.every(((e,t)=>e===this.currentVisualStates[t])))return;const t=this.currentVisualStates?this.getParametersForStates(this.currentVisualStates):{},n=this.getParametersForStates(e),o=this._getNewState(this.currentVisualStates,e);this.currentVisualStates=e;const i={};for(const e in t)n.hasOwnProperty(e)||this._hasInputBeenSetFromAConnection(e)||void 0!==this.getParameter(e)&&(i[e]=this.getParameter(e));for(const e in n)this._hasInputBeenSetFromAConnection(e)||void 0===n[e]||(i[e]=n[e]);const s=this._getDefaultTransition(o),r=this._getStateTransition(o);for(const e in i)r[e]&&r[e].curve?B(this,e,i[e],r[e]):!r[e]&&s?B(this,e,i[e],s):(this._transitions&&this._transitions[e]&&(this._transitions[e].stop(),delete this._transitions[e]),this.queueInput(e,i[e]))},_getVisualStates(){return this.currentVisualStates||[]},_stopStateTransitions(){if(this._transitions)for(const e in this._transitions)this._transitions[e].stop(),delete this._transitions[e]}}};f&&(y.inputs.variant={displayName:"Variant",group:"General",type:{name:"string",allowConnectionsOnly:!0},set(e){if(this.variant&&this.variant.name===e)return;const t=this.context.variants.getVariant(this.model.type,e);t&&this.setVariant(t)}}),!1!==e.mountedInput&&(y.inputs.mounted={displayName:"Mounted",index:9999,type:"boolean",group:"General",default:!0,set(e){if(e=!!e,this.wantsToBeMounted!==e){this.wantsToBeMounted=e;const t=this.getVisualParentNode();t&&(t.cachedChildren=void 0,t.forceUpdate())}}});const v=y.allowChildren||y.displayName;v&&(y.outputs.childrenCount={displayName:"Children Count",type:"number",get(){return this.childrenCount}});for(const e in s)y.inputs[e]=s[e];for(const t in r){const n=r[t];"node"===n.type?(n.type="reference",n.set=function(e){const o=n.propPath?this.props[n.propPath]:this.props;void 0!==e?o[t]=e.render():delete o[t],this.forceUpdate()}):"signal"===n.type?console.error(`Error: Signals not supported as a react prop. node: '${e.name}' input: '${t}'`):X(n,t),y.inputs[t]=n}for(const e in a){const t=a[e],n=t.targetStyleProperty||e;t.type.units?t.set=function(e){"object"!=typeof e&&t.type.defaultUnit&&(e={value:e,unit:t.type.defaultUnit}),"object"==typeof e&&void 0!==e.value?this.setStyle({[n]:e.value+e.unit},t.styleTag):void 0!==e?this.setStyle({[n]:e},t.styleTag):this.removeStyle([n],t.styleTag),t.onChange&&t.onChange.call(this,e)}:t.set=function(e){void 0!==e?this.setStyle({[n]:e},t.styleTag):this.removeStyle([n],t.styleTag),t.onChange&&t.onChange.call(this,e)},y.inputs[e]=t}for(const e in l)y.outputs[e]=l[e];for(const e in d){const t=d[e];"signal"!==t.type&&(t.get=function(){return this.outputPropValues[e]}),y.outputs[e]=t}for(const e in p)y.methods[e]=p[e];return{node:y,setup:e.setup}}const ee=["onClick","onMouseDown","onMouseMove","onMouseUp","onMouseEnter","onMouseLeave","onMouseOver","onMouseOut","onTouchStart","onTouchMove","onTouchEnd","onTouchCancel","onPointerDown","onPointerMove","onPointerUp","onPointerCancel"],te=new Set(["onMouseLeave","onMouseOut"]);function ne(e){const t={};for(const n of ee)e.blockTouch&&!te.has(n)?e.pointer&&e.pointer[n]?t[n]=t=>{e.pointer[n](t),t.stopPropagation()}:e[n]?t[n]=t=>{e[n](t),t.stopPropagation()}:t[n]=e=>{e.stopPropagation()}:e[n]?t[n]=e[n]:e.pointer&&(t[n]=e.pointer[n]);if(e.noodlNode)for(const n in t){const o=t[n];o&&(t[n]=t=>{o.call(this,t),e.noodlNode.context.updateDirtyNodes()})}return t}const oe={};function ie(e,t,n){e[t]||(e[t]={});for(const o in n)e[t][o]=n[o]}const se=function(e,t,n){if(oe[e])(function(e,t){let n;for(n in e)if(e.hasOwnProperty(n)&&e[n]!==t[n])return!1;for(n in t)if(t.hasOwnProperty(n)&&e[n]!==t[n])return!1;return!0})(t,oe[e].props)||(oe[e].style.innerHTML=n(e,t),oe[e].props=Object.assign({},t));else{const o=document.createElement("style");o.innerHTML=n(e,t),document.head.appendChild(o),oe[e]={style:o,props:Object.assign({},t)}}},re=function(e,t){t=t||{},e.visualStates=[{name:"neutral",label:"Neutral"},{name:"hover",label:"Hover"},{name:"pressed",label:"Pressed"},{name:"focused",label:"Focused"},{name:"disabled",label:"Disabled"}],t.checked&&e.visualStates.splice(3,0,{name:"checked",label:"Checked"}),function(e){ie(e,"inputs",{enabled:{type:"boolean",displayName:"Enabled",group:"General",default:!0,set:function(e){const t=(e=!!e)!==this._internal.enabled;this.props.enabled=this._internal.enabled=e,t&&(this._updateVisualState(),this.forceUpdate(),this.flagOutputDirty("enabled"))}}})}(e),function(e){ie(e,"inputProps",{blockTouch:{index:450,displayName:"Block Pointer Events",type:"boolean",group:"Pointer Events"}})}(e),e.methods._updateVisualState=function(){const e=[];this._internal.enabled&&(this.outputPropValues.hoverState&&e.push("hover"),this.outputPropValues.pressedState&&e.push("pressed"),this.outputPropValues.focusState&&e.push("focused")),t.checked&&this._internal.checked&&e.push("checked"),this._internal.enabled||e.push("disabled"),this.setVisualStates(e)},function(e){ie(e,"outputProps",{focusState:{displayName:"Focused",group:"States",type:"boolean",props:{onFocus(){this.outputPropValues.focusState=!0,this.flagOutputDirty("focusState"),this._updateVisualState()},onBlur(){this.outputPropValues.focusState=!1,this.flagOutputDirty("focusState"),this._updateVisualState()}}},onFocus:{displayName:"Focused",group:"Focus Events",type:"signal",props:{onFocus(){this.sendSignalOnOutput("onFocus")}}},onBlur:{displayName:"Blurred",group:"Focus Events",type:"signal",props:{onBlur(){this.sendSignalOnOutput("onBlur")}}},hoverState:{displayName:"Hover",group:"States",type:"boolean",props:{onMouseOver(){this.outputPropValues.hoverState=!0,this.flagOutputDirty("hoverState"),this._updateVisualState()},onMouseLeave(){this.outputPropValues.hoverState=!1,this.flagOutputDirty("hoverState"),this._updateVisualState()}}},hoverStart:{displayName:"Hover Start",group:"Pointer Events",type:"signal",props:{onMouseOver(){this.sendSignalOnOutput("hoverStart")}}},hoverEnd:{displayName:"Hover End",group:"Pointer Events",type:"signal",props:{onMouseLeave(){this.sendSignalOnOutput("hoverEnd")}}},pressedState:{displayName:"Pressed",group:"States",type:"boolean",props:{onMouseDown(){this.outputPropValues.pressedState=!0,this.flagOutputDirty("pressedState"),this._updateVisualState()},onTouchStart(){this.outputPropValues.pressedState=!0,this.flagOutputDirty("pressedState"),this._updateVisualState()},onMouseUp(){this.outputPropValues.pressedState=!1,this.flagOutputDirty("pressedState"),this._updateVisualState()},onTouchEnd(){this.outputPropValues.pressedState=!1,this.flagOutputDirty("pressedState"),this._updateVisualState()},onTouchCancel(){this.outputPropValues.pressedState=!1,this.flagOutputDirty("pressedState"),this._updateVisualState()},onMouseLeave(){this.outputPropValues.pressedState=!1,this.flagOutputDirty("pressedState"),this._updateVisualState()}}},pointerDown:{displayName:"Pointer Down",group:"Pointer Events",type:"signal",props:{onMouseDown(){this.sendSignalOnOutput("pointerDown")},onTouchStart(){this.sendSignalOnOutput("pointerDown")}}},pointerUp:{displayName:"Pointer Up",group:"Pointer Events",type:"signal",props:{onMouseUp(){this.sendSignalOnOutput("pointerUp")},onTouchEnd(){this.sendSignalOnOutput("pointerUp")},onTouchCancel(){this.sendSignalOnOutput("pointerUp")}}}})}(e),function(e){ie(e,"outputs",{enabled:{type:"boolean",displayName:"Enabled",group:"States",getter:function(){return this._internal.enabled}}})}(e);const n=e.initialize;e.initialize=function(){n&&n.call(this),this.props.enabled=this._internal.enabled=!0,this.outputPropValues.hoverState=this.outputPropValues.focusState=this.outputPropValues.pressedState=!1}},ae=function(e){return Object.assign({},{onFocus:e.onFocus,onBlur:e.onBlur},ne(e))};function le(e){let t={...e.style};function o(){const t={};return e.useLabel&&("left"===e.iconPlacement||void 0===e.iconPlacement?t.marginRight=e.iconSpacing:t.marginLeft=e.iconSpacing),"image"===e.iconSourceType&&void 0!==e.iconImageSource?(t.width=e.iconSize,t.height=e.iconSize,n().createElement("img",{alt:"",src:e.iconImageSource,style:t})):"icon"===e.iconSourceType&&void 0!==e.iconIconSource?(t.fontSize=e.iconSize,t.color=e.iconColor,!0===e.iconIconSource.codeAsClass?n().createElement("span",{className:[e.iconIconSource.class,e.iconIconSource.code].join(" "),style:t}):n().createElement("span",{className:e.iconIconSource.class,style:t},e.iconIconSource.code)):null}x.size(t,e),x.align(t,e),void 0!==e.textStyle&&(t=Object.assign({},e.textStyle,t),t.color=e.noodlNode.context.styles.resolveColor(t.color));let i="ndl-controls-button";e.className&&(i=i+" "+e.className);let s=null;return e.useLabel&&e.useIcon?s=n().createElement(n().Fragment,null,"left"===e.iconPlacement?o():null,String(e.label),"right"===e.iconPlacement?o():null):e.useLabel?s=String(e.label):e.useIcon&&(s=o()),n().createElement("button",{...e.attrs,className:i,disabled:!e.enabled,...ae(e),type:e.buttonType,style:t,onClick:e.onClick},s,e.children)}const de={name:"net.noodl.controls.button",displayName:"Button",docs:"https://docs.noodl.net/nodes/ui-controls/button",allowChildren:!0,noodlNodeAsProp:!0,usePortAsLabel:"label",portLabelTruncationMode:"length",nodeDoubleClickAction:{focusPort:"label"},connectionPanel:{groupPriority:["General","Style","Actions","Events","States","Mounted","Label","Label Text Style","Hover Events","Pointer Events","Focus Events"]},initialize(){this.props.attrs={},this.props.layout="row"},getReactComponent:()=>le,inputs:{testId:{index:100009,displayName:"Test ID Attribute",group:"Advanced HTML",type:"string",set(e){this.props.attrs["data-testid"]=e,this.forceUpdate()}}},inputCss:{backgroundColor:{index:100,displayName:"Background Color",group:"Style",type:"color",default:"#000000",allowVisualStates:!0}},outputProps:{onClick:{displayName:"Click",group:"Events",type:"signal"}}};F.addDimensions(de,{defaultSizeMode:"contentSize",contentLabel:"Content"}),F.addTextStyleInputs(de),F.addAlignInputs(de),F.addTransformInputs(de),F.addPaddingInputs(de,{defaults:{paddingTop:5,paddingRight:20,paddingBottom:5,paddingLeft:20}}),F.addMarginInputs(de),F.addLabelInputs(de,{defaults:{useLabel:!0}}),F.addIconInputs(de,{enableIconPlacement:!0,defaults:{useIcon:!1}}),F.addSharedVisualInputs(de),F.addBorderInputs(de),F.addShadowInputs(de),re(de);const ue=Z(de);function ce(e){const[o,i]=(0,t.useState)(e.checked);(0,t.useEffect)((()=>{i(!!e.checked)}),[]),(0,t.useEffect)((()=>{i(!!e.checked)}),[e.checked]);const s={...e.style};"none"===e.parentLayout&&(s.position="absolute"),x.align(s,e);const r={...e.attrs,id:e.id,className:[e.className,"ndl-controls-checkbox-2"].join(" "),disabled:!e.enabled,style:{width:e.styles.checkbox.width,height:e.styles.checkbox.height}},a={display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,position:"relative",...e.styles.checkbox};e.useLabel||(Object.assign(r,ae(e)),Object.assign(a,s));const l=n().createElement("div",{className:"ndl-controls-pointer",style:a,"noodl-style-tag":"checkbox"},e.useIcon?function(){if("image"===e.iconSourceType&&void 0!==e.iconImageSource)return n().createElement("img",{alt:"",src:e.iconImageSource,style:{width:e.iconSize,height:e.iconSize,position:"absolute"}});if("icon"===e.iconSourceType&&void 0!==e.iconIconSource){const t={fontSize:e.iconSize,color:e.iconColor,position:"absolute"};return!0===e.iconIconSource.codeAsClass?n().createElement("span",{className:[e.iconIconSource.class,e.iconIconSource.code].join(" "),style:t}):n().createElement("span",{className:e.iconIconSource.class,style:t},e.iconIconSource.code)}return null}():null,n().createElement("input",{type:"checkbox",...r,checked:o,onChange:t=>{i(t.target.checked),e.checkedChanged&&e.checkedChanged(t.target.checked)}}));if(e.useLabel){const t={marginLeft:e.labelSpacing,...e.labeltextStyle,...e.styles.label};return e.enabled||(t.cursor="default"),t.color=e.noodlNode.context.styles.resolveColor(t.color),n().createElement("div",{style:{display:"flex",alignItems:"center",...s},...ae(e)},l,n().createElement("label",{className:"ndl-controls-pointer",style:t,htmlFor:e.id,"noodl-style-tag":"label"},e.label))}return l}const pe={name:"net.noodl.controls.checkbox",displayName:"Checkbox",docs:"https://docs.noodl.net/nodes/ui-controls/checkbox",allowChildren:!1,noodlNodeAsProp:!0,nodeDoubleClickAction:{focusPort:"label"},usePortAsLabel:"label",portLabelTruncationMode:"length",connectionPanel:{groupPriority:["General","Style","Actions","Events","States","Mounted","Label","Label Text Style","Hover Events","Pointer Events","Focus Events"]},initialize(){this.props.attrs={},this.props.sizeMode="explicit",this.props.id="input-"+(0,s.guid)(),this.props.checked=this._internal.checked=!1,this.props.checkedChanged=e=>{const t=this._internal.checked!==e;this._internal.checked=e,t&&(this.flagOutputDirty("checked"),this.sendSignalOnOutput("onChange"),this._updateVisualState())}},getReactComponent:()=>ce,inputs:{checked:{type:"boolean",displayName:"Checked",group:"General",default:!1,index:100,set:function(e){const t=(e=!!e)!==this._internal.checked;this.props.checked=this._internal.checked=e,t&&(this.forceUpdate(),this.flagOutputDirty("checked"),this._updateVisualState())}},check:{type:"signal",displayName:"Check",group:"Actions",valueChangedToTrue(){!0!==this._internal.checked&&(this.props.checked=this._internal.checked=!0,this.forceUpdate(),this.flagOutputDirty("checked"),this._updateVisualState())}},uncheck:{type:"signal",displayName:"Uncheck",group:"Actions",valueChangedToTrue(){!1!==this._internal.checked&&(this.props.checked=this._internal.checked=!1,this.forceUpdate(),this.flagOutputDirty("checked"),this._updateVisualState())}},testId:{index:100009,displayName:"Test ID Attribute",group:"Advanced HTML",type:"string",set(e){this.props.attrs["data-testid"]=e,this.forceUpdate()}}},inputCss:{backgroundColor:{index:201,displayName:"Background Color",group:"Style",type:"color",default:"transparent",applyDefault:!1,allowVisualStates:!0,styleTag:"checkbox"},width:{index:11,group:"Dimensions",displayName:"Width",type:{name:"number",units:["px","vw","vh"],defaultUnit:"px"},default:32,allowVisualStates:!0,styleTag:"checkbox"},height:{index:12,group:"Dimensions",displayName:"Height",type:{name:"number",units:["px","vw","vh"],defaultUnit:"px"},default:32,allowVisualStates:!0,styleTag:"checkbox"}},outputs:{checked:{type:"boolean",displayName:"Checked",group:"States",getter:function(){return this._internal.checked}},onChange:{displayName:"Changed",group:"Events",type:"signal"}}};F.addAlignInputs(pe),F.addTransformInputs(pe),F.addMarginInputs(pe),F.addPaddingInputs(pe),F.addIconInputs(pe),F.addLabelInputs(pe,{enableSpacing:!0,styleTag:"label"}),F.addSharedVisualInputs(pe),F.addBorderInputs(pe,{defaults:{borderStyle:"solid",borderWidth:2,borderColor:"#000000",borderRadius:3},styleTag:"checkbox"}),F.addShadowInputs(pe,{styleTag:"checkbox"}),re(pe,{checked:!0});const he=Z(pe);function me(e){const[o,i]=(0,t.useState)(e.value);(0,t.useEffect)((()=>{i(e.value),e.valueChanged(e.value)}),[e.value,e.items]);let s={...e.style};x.size(s,e),x.align(s,e),void 0!==e.textStyle&&(s=Object.assign({},e.textStyle,s),s.color=e.noodlNode.context.styles.resolveColor(s.color));const r=e.items&&void 0!==o?e.items.findIndex((e=>e.Value===o)):-1,{height:a,...l}=s;function d(){if("image"===e.iconSourceType&&void 0!==e.iconImageSource)return n().createElement("img",{alt:"",src:e.iconImageSource,style:{width:e.iconSize,height:e.iconSize}});if("icon"===e.iconSourceType&&void 0!==e.iconIconSource){const t={fontSize:e.iconSize,color:e.iconColor};return"left"===e.iconPlacement||void 0===e.iconPlacement?t.marginRight=e.iconSpacing:t.marginLeft=e.iconSpacing,!0===e.iconIconSource.codeAsClass?n().createElement("span",{className:[e.iconIconSource.class,e.iconIconSource.code].join(" "),style:t}):n().createElement("span",{className:e.iconIconSource.class,style:t},e.iconIconSource.code)}return null}const u={...e.attrs,id:e.id,className:e.className,style:{inset:0,opacity:0,position:"absolute",textTransform:"inherit",cursor:e.enabled?"":"default","-webkit-appearance":"none"},onClick:e.onClick},c={display:"flex",alignItems:"center",...e.styles.inputWrapper,cursor:e.enabled?"":"default"},p=a&&"%"===a[String(a).length-1];e.useLabel?p?c.flexGrow=1:c.height=a:(Object.assign(c,l),c.height=a);let h=[];e.items&&(h=e.items.map((e=>n().createElement("option",{key:e.Value,value:e.Value,disabled:"true"===e.Disabled||!0===e.Disabled||void 0},e.Label))));let m=null;r>=0&&re.props.value===o))?o:void 0,...ae(e),onChange:t=>{i(t.target.value),e.valueChanged&&e.valueChanged(t.target.value)}},n().createElement("option",{value:"",disabled:!0,selected:!0,hidden:!0}),h));if(e.useLabel){const t={...l,display:"flex",flexDirection:"column"};return p&&(t.height=a),n().createElement("div",{style:t},n().createElement("label",{htmlFor:e.id,style:{...e.labeltextStyle,...e.styles.label,marginBottom:e.labelSpacing},"noodl-style-tag":"label"},e.label),g)}return g}const ge={name:"net.noodl.controls.options",displayName:"Dropdown",docs:"https://docs.noodl.net/nodes/ui-controls/dropdown",allowChildren:!1,noodlNodeAsProp:!0,usePortAsLabel:"label",nodeDoubleClickAction:{focusPort:"label"},connectionPanel:{groupPriority:["General","Style","Actions","Events","States","Mounted","Text Style","Label","Label Text Style","Hover Events","Pointer Events","Focus Events"]},initialize(){this.props.attrs={},this._itemsChanged=()=>{this.forceUpdate()},this.props.id="input-"+(0,s.guid)(),this.props.valueChanged=e=>{const t=this._internal.value!==e;this._internal.value=e,t&&(this.flagOutputDirty("value"),this.sendSignalOnOutput("onChange"))}},getReactComponent:()=>me,inputs:{items:{type:"array",displayName:"Items",group:"General",set:function(e){this._internal.items!==e&&void 0!==this._internal.items&&this._internal.items.off("change",this._itemsChanged),this._internal.items=e,this._internal.items.on("change",this._itemsChanged),this.props.items=this._internal.items,this.forceUpdate()}},value:{type:"string",displayName:"Value",group:"General",set:function(e){if(void 0!==e&&"string"!=typeof e){if(void 0===(null==e?void 0:e.toString))return;e=e.toString()}const t=e!==this._internal.value;this.props.value=this._internal.value=e,t&&(this.forceUpdate(),this.flagOutputDirty("value"))}},testId:{index:100009,displayName:"Test ID Attribute",group:"Advanced HTML",type:"string",set(e){this.props.attrs["data-testid"]=e,this.forceUpdate()}}},inputProps:{placeholder:{displayName:"Placeholder",type:"string",group:"Placeholder"},placeholderOpacity:{group:"Placeholder",displayName:"Placeholder opacity",type:"number",default:.5}},outputs:{value:{type:"string",displayName:"Value",group:"States",getter:function(){return this._internal.value}},onChange:{type:"signal",displayName:"Changed",group:"Events"}},inputCss:{backgroundColor:{index:100,displayName:"Background Color",group:"Style",type:"color",default:"transparent",styleTag:"inputWrapper",allowVisualStates:!0}}};F.addDimensions(ge,{defaultSizeMode:"contentSize",contentLabel:"Content"}),F.addAlignInputs(ge),F.addTextStyleInputs(ge),F.addTransformInputs(ge),F.addPaddingInputs(ge,{styleTag:"inputWrapper"}),F.addMarginInputs(ge),F.addIconInputs(ge,{enableIconPlacement:!0,defaults:{useIcon:!1,iconColor:"#000000"}}),F.addLabelInputs(ge,{enableSpacing:!0,styleTag:"label"}),F.addSharedVisualInputs(ge),F.addBorderInputs(ge,{defaults:{borderStyle:"solid",borderWidth:2,borderColor:"#000000",borderRadius:5},styleTag:"inputWrapper"}),F.addShadowInputs(ge,{styleTag:"inputWrapper"}),re(ge);const fe=Z(ge),ye=n().createContext({name:void 0,selected:void 0,checkedChanged:void 0});function ve(e){return e&&"%"===e[e.length-1]}function be(e){const o=(0,t.useContext)(ye),i={...e.style};"none"===e.parentLayout&&(i.position="absolute"),x.align(i,e),e.checkedChanged&&e.checkedChanged(!!o&&o.selected===e.value);const s={...e.attrs,id:e.id,disabled:!e.enabled,className:[e.className,"ndl-controls-radio-2"].join(" "),style:{width:e.styles.radio.width,height:e.styles.radio.height}},r={display:"flex",alignItems:"center",justifyContent:"center",position:"relative",flexShrink:0,...e.styles.radio};e.useLabel?ve(e.styles.radio.width)&&(delete r.width,r.flexGrow=1):(Object.assign(s,ae(e)),Object.assign(r,i));const a={left:e.fillSpacing,right:e.fillSpacing,top:e.fillSpacing,bottom:e.fillSpacing,backgroundColor:e.styles.fill.backgroundColor,borderRadius:"inherit",position:"absolute"},l=n().createElement("div",{className:"ndl-controls-pointer",style:r,"noodl-style-tag":"radio"},n().createElement("div",{style:a,"noodl-style-tag":"fill"}),e.useIcon?function(){if("image"===e.iconSourceType&&void 0!==e.iconImageSource)return n().createElement("img",{alt:"",src:e.iconImageSource,style:{width:e.iconSize,height:e.iconSize}});if("icon"===e.iconSourceType&&void 0!==e.iconIconSource){const t={fontSize:e.iconSize,color:e.iconColor};return!0===e.iconIconSource.codeAsClass?n().createElement("span",{className:["ndl-controls-abs-center",e.iconIconSource.class,e.iconIconSource.code].join(" "),style:t}):n().createElement("span",{className:["ndl-controls-abs-center",e.iconIconSource.class].join(" "),style:t},e.iconIconSource.code)}return null}():null,n().createElement("input",{type:"radio",name:o?o.name:void 0,...s,checked:!!o&&o.selected===e.value,onChange:t=>{o&&o.checkedChanged&&o.checkedChanged(e.value)}}));if(e.useLabel){const t={marginLeft:e.labelSpacing,...e.labeltextStyle,...e.styles.label,cursor:e.enabled?void 0:"default"};t.color=e.noodlNode.context.styles.resolveColor(t.color);const o={display:"flex",alignItems:"center",...i};return ve(e.styles.radio.width)&&(o.width=e.styles.radio.width),ve(e.styles.radio.height)&&(o.height=e.styles.radio.height),n().createElement("div",{style:o,...ae(e)},l,n().createElement("label",{className:"ndl-controls-pointer",style:t,htmlFor:e.id,"noodl-style-tag":"label"},e.label))}return l}const _e={name:"net.noodl.controls.radiobutton",displayName:"Radio Button",docs:"https://docs.noodl.net/nodes/ui-controls/radio-button",allowChildren:!1,noodlNodeAsProp:!0,usePortAsLabel:"label",nodeDoubleClickAction:{focusPort:"label"},connectionPanel:{groupPriority:["General","Style","Fill Style","Actions","Events","States","Mounted","Label","Label Text Style","Hover Events","Pointer Events","Focus Events"]},initialize(){this.props.attrs={},this.props.sizeMode="explicit",this.props.id="input-"+(0,s.guid)(),this._internal.checked=!1,this.props.checkedChanged=e=>{const t=this._internal.checked!==e;this._internal.checked=e,t&&(this.flagOutputDirty("checked"),this._updateVisualState())},this.props.styles.fill={}},getReactComponent:()=>be,inputs:{fillColor:{index:19,displayName:"Fill Color",group:"Fill Style",type:"color",allowVisualStates:!0,styleTag:"fill",set(e){this.setStyle({backgroundColor:e},"fill")}},testId:{index:100009,displayName:"Test ID Attribute",group:"Advanced HTML",type:"string",set(e){this.props.attrs["data-testid"]=e,this.forceUpdate()}}},inputProps:{value:{type:"string",displayName:"Value",group:"General",index:100},fillSpacing:{displayName:"Fill Spacing",group:"Fill Style",type:{name:"number",units:["px","vw","vh"],defaultUnit:"px"},allowVisualStates:!0,default:2}},inputCss:{width:{index:11,group:"Dimensions",displayName:"Width",type:{name:"number",units:["px","%","vw","vh"],defaultUnit:"px"},default:32,allowVisualStates:!0,styleTag:"radio",onChange(){this.forceUpdate()}},height:{index:12,group:"Dimensions",displayName:"Height",type:{name:"number",units:["px","%"],defaultUnit:"px"},default:32,allowVisualStates:!0,styleTag:"radio",onChange(){this.forceUpdate()}},backgroundColor:{index:201,displayName:"Background Color",group:"Style",type:"color",allowVisualStates:!0,styleTag:"radio",default:"transparent",applyDefault:!1}},outputs:{checked:{type:"boolean",displayName:"Checked",group:"States",get(){return this._internal.checked}}}};F.addAlignInputs(_e),F.addTransformInputs(_e),F.addMarginInputs(_e),F.addPaddingInputs(_e),F.addIconInputs(_e),F.addLabelInputs(_e,{enableSpacing:!0,styleTag:"label"}),F.addSharedVisualInputs(_e),F.addBorderInputs(_e,{defaults:{borderStyle:"solid",borderWidth:2,borderRadius:16},styleTag:"radio"}),F.addShadowInputs(_e,{styleTag:"radio"}),re(_e,{checked:!0});const Se=Z(_e);function Ce(e){const[o,i]=(0,t.useState)(e.value),s={selected:o,name:e.name,checkedChanged:t=>{i(t),e.valueChanged&&e.valueChanged(t)}};(0,t.useEffect)((()=>{i(e.value)}),[e.value]);const r={...e.style};x.size(r,e),x.align(r,e);let a="ndl-controls-radiobuttongroup";return e.className&&(a=a+" "+e.className),n().createElement(ye.Provider,{value:s},n().createElement("div",{className:a,style:r},e.children))}const Ne=["row","row-reverse","column","column-reverse","inherit","initial","revert","unset"],Oe={name:"Radio Button Group",displayName:"Radio Button Group",docs:"https://docs.noodl.net/nodes/ui-controls/radio-button-group",allowChildren:!0,noodlNodeAsProp:!0,useVariants:!1,connectionPanel:{groupPriority:["General","Style","Actions","Events","Mounted","States"]},initialize(){this.props.name="radio-"+(0,s.guid)(),this.props.valueChanged=e=>{const t=this._internal.value!==e;this._internal.value=e,this.props.value=e,t&&(this.forceUpdate(),this.flagOutputDirty("value"),this.sendSignalOnOutput("onChange"))}},getReactComponent:()=>Ce,defaultCss:{display:"flex",position:"relative",flexDirection:"column"},inputs:{flexDirection:{index:11,displayName:"Layout",group:"Layout",type:{name:"enum",enums:[{label:"Vertical",value:"column"},{label:"Horizontal",value:"row"}]},default:"column",set(e){this.props.layout=e,"none"!==e?this.setStyle({flexDirection:e}):this.removeStyle(["flexDirection"]),this.context.editorConnection&&("none"===e||Ne.includes(e)?this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"layout-warning"):this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"layout-warning",{message:"Invalid Layout value has to be a valid flex-direction value."})),this.forceUpdate()}},value:{index:20,type:"string",displayName:"Value",group:"General",set:function(e){if("string"!=typeof e&&void 0!==e.toString&&(e=e.toString()),"string"!=typeof e)return;const t=e!==this._internal.value;this.props.value=this._internal.value=e,t&&(this.forceUpdate(),this.flagOutputDirty("value"))}}},outputs:{value:{type:"string",displayName:"Value",group:"States",getter:function(){return this._internal.value}},onChange:{type:"signal",displayName:"Changed",group:"Events"}},inputProps:{},outputProps:{}};F.addDimensions(Oe,{defaultSizeMode:"contentSize",contentLabel:"Content"}),F.addAlignInputs(Oe),F.addTransformInputs(Oe),F.addMarginInputs(Oe),F.addPaddingInputs(Oe),F.addSharedVisualInputs(Oe);const Ie=Z(Oe);function we(e,t){return`.${e}::-webkit-slider-thumb {\n width: ${t.thumbWidth};\n}`}function Pe(e,t,n){function o(e,o){const i=`${t}Border${o}Color`,s=`${t}Border${o}Style`,r=n[`${t}Border${o}Width`]||n[`${t}BorderWidth`];void 0!==r&&(e[`border${o}Width`]=r);const a=e[i]=n[i]||n[`${t}BorderColor`];void 0!==a&&(e[`border${o}Color`]=a);const l=n[s]||n[`${t}BorderStyle`];void 0!==l&&(e[`border${o}Style`]=l)}o(e,"Top"),o(e,"Right"),o(e,"Bottom"),o(e,"Left")}function xe(e,t,n){const o=n[`${t}BorderRadius`],i=n[`${t}BorderTopLeftRadius`]||o,s=n[`${t}BorderTopRightRadius`]||o,r=n[`${t}BorderBottomRightRadius`]||o,a=n[`${t}BorderBottomLeftRadius`]||o;e.borderRadius=`${i} ${s} ${r} ${a}`}function Ee(e,t,n){if(!n[`${t}BoxShadowEnabled`])return;const o=n[`${t}BoxShadowInset`],i=n[`${t}BoxShadowOffsetX`],s=n[`${t}BoxShadowOffsetY`],r=n[`${t}BoxShadowBlurRadius`],a=n[`${t}BoxShadowSpreadRadius`],l=n[`${t}BoxShadowColor`];e.boxShadow=`${o?"inset ":""}${i} ${s} ${r} ${a} ${l}`}function Te(e){return e&&"x"===e[e.length-1]}function Ae(e){const[o,i]=(0,t.useState)(e.value);function s(t){i(t),e.updateOutputValue(t)}(0,t.useEffect)((()=>{s(e.value)}),[e.value]);const r={...e.style};x.size(r,e),x.align(r,e);const a="ndl-controls-range-"+e._nodeId;se(a,e,we);const l=`ndl-controls-range2 ${a} ${e.className?e.className:""} `,d={...e.attrs,id:e.id,style:{width:"100%",opacity:0},onClick:e.onClick,min:e.min,max:e.max};if(d.style=d.style||{},e.step&&(d.step=e.step),Te(e.thumbHeight))if(Te(e.trackHeight)){const t=Number(e.thumbHeight.slice(0,-2)),n=Number(e.trackHeight.slice(0,-2));d.style.height=Math.max(t,n)+"px"}else d.style.height=e.thumbHeight;else d.style.height=e.trackHeight;const u={display:"flex",alignItems:"center",...r},c=(o-e.min)/(e.max-e.min),p={position:"absolute",width:"100%",height:e.trackHeight,background:`linear-gradient(to right, ${e.trackActiveColor} 0%, ${e.trackActiveColor} ${100*c}%, ${e.trackColor} ${100*c}%, ${e.trackColor} 100%)`};Pe(p,"track",e),xe(p,"track",e),Ee(p,"track",e);const h={position:"absolute",left:"calc((100% - "+e.thumbWidth+") * "+c+")",width:e.thumbWidth,height:e.thumbHeight,backgroundColor:e.thumbColor};return Pe(h,"thumb",e),xe(h,"thumb",e),Ee(h,"thumb",e),n().createElement("div",{style:u},n().createElement("div",{style:p}),n().createElement("div",{style:h}),n().createElement("input",{className:l,...ae(e),type:"range",...d,value:o,disabled:!e.enabled,onChange:e=>s(Number(e.target.value))}))}const ke={group:"thumb-styles",label:"Thumb Styles"},De={group:"track-styles",label:"Track Styles"},Re={name:"net.noodl.controls.range",displayNodeName:"Slider",category:"Controls",docs:"https://docs.noodl.net/nodes/ui-controls/slider",allowChildren:!1,noodlNodeAsProp:!0,connectionPanel:{groupPriority:["General","Style","Actions","Events","States","Mounted","Hover Events","Pointer Events","Focus Events"]},initialize(){this.props.attrs={},this.props.sizeMode="contentHeight",this.props.id="input-"+(0,s.guid)(),this.props.value=this.props.min,this._internal.outputValue=0,this.props._nodeId=this.id,this.props.updateOutputValue=e=>{e="string"==typeof e?parseFloat(e):e,this._internal.outputValue!==e&&(this._internal.outputValue=e,this.flagOutputDirty("value"),this._updateOutputValuePercent(e),this.sendSignalOnOutput("onChange")),this._internal.valuePercent||this._updateOutputValuePercent(e)},this.props.updateOutputValue(this.props.value)},getReactComponent:()=>Ae,inputs:{value:{type:"string",displayName:"Value",group:"General",index:100,set(e){this._setInputValue(e)}},testId:{index:100009,displayName:"Test ID Attribute",group:"Advanced HTML",type:"string",set(e){this.props.attrs["data-testid"]=e,this.forceUpdate()}}},outputs:{value:{type:"number",displayName:"Value",group:"States",get(){return this._internal.outputValue}},valuePercent:{type:"number",displayName:"Value Percent",group:"States",get(){return this._internal.valuePercent}},onChange:{type:"signal",displayName:"Changed",group:"Events"}},inputProps:{min:{type:"number",displayName:"Min",group:"General",default:0,index:100,onChange(){this._setInputValue(this.props.value)}},max:{type:"number",displayName:"Max",group:"General",default:100,index:100,onChange(){this._setInputValue(this.props.value)}},step:{type:"number",displayName:"Step",group:"General",default:1,index:100},width:{index:11,group:"Dimensions",displayName:"Width",type:{name:"number",units:["%","px","vw"],defaultUnit:"%"},default:100,allowVisualStates:!0},thumbWidth:{group:"Thumb Style",displayName:"Width",type:{name:"number",units:["px","vw","%"],defaultUnit:"px",allowEditOnly:!0},default:16,popout:ke,allowVisualStates:!0},thumbHeight:{group:"Thumb Style",displayName:"Height",type:{name:"number",units:["px","vh","%"],defaultUnit:"px",allowEditOnly:!0},default:16,popout:ke,allowVisualStates:!0},thumbColor:{group:"Thumb Style",displayName:"Color",type:{name:"color",allowEditOnly:!0},default:"#000000",popout:ke,allowVisualStates:!0},trackHeight:{group:"Track Style",displayName:"Height",type:{name:"number",units:["px","vh","%"],defaultUnit:"px",allowEditOnly:!0},default:6,popout:De,allowVisualStates:!0},trackColor:{group:"Track Style",displayName:"Inactive Color",type:{name:"color",allowEditOnly:!0},default:"#f0f0f0",popout:De,allowVisualStates:!0},trackActiveColor:{group:"Track Style",displayName:"Active Color",type:{name:"color",allowEditOnly:!0},default:"#f0f0f0",popout:De,allowVisualStates:!0}},methods:{_updateOutputValuePercent(e){const t=this.props.min,n=this.props.max,o=Math.floor((e-t)/(n-t)*100),i=this._internal.valuePercentChanged!==o;this._internal.valuePercent=o,i&&this.flagOutputDirty("valuePercent")},_setInputValue(e){const t=Math.max(this.props.min,Math.min(this.props.max,e||0));t!==this.props.value&&(this.props.value=t,this.forceUpdate())}}};function Me(e,t){const n=(t=t||{}).defaults||{},o=t.popout;n.borderStyle="none",n.borderWidth=0,n.borderColor="#000000";const i=t.propPrefix[0].toUpperCase()+t.propPrefix.slice(1);function s(e,s,r,a){const l=t.propPrefix+`Border${s}Style`,d=t.propPrefix+`Border${s}Width`,u=t.propPrefix+`Border${s}Color`;let c="none"!==n.borderStyle?"OR borderStyle NOT SET":"";s?(n[l]&&"none"!==n[l]&&(c+=`OR ${l} NOT SET`),F.addDynamicInputPorts(e,`${l} = solid OR ${l} = dashed OR ${l} = dotted OR borderStyle = solid OR borderStyle = dashed OR borderStyle = dotted ${c}`,[`${d}`,`${u}`])):F.addDynamicInputPorts(e,`${l} = solid OR ${l} = dashed OR ${l} = dotted ${c}`,[`${d}`,`${u}`]);const p={group:t.propPrefix+"-border-styles",tab:r,label:s},h=e=>`${i} ${e} ${s?"("+s+")":""}`,m=202+4*a,g=i+" Border Style";F.addInputProps(e,{[l]:{index:m+1,displayName:"Border Style",editorName:h("Border Style"),group:g,type:{name:"enum",enums:[{label:"None",value:"none"},{label:"Solid",value:"solid"},{label:"Dotted",value:"dotted"},{label:"Dashed",value:"dashed"}]},default:n[`border${s}Style`],tab:p,popout:o,allowVisualStates:!0},[d]:{index:m+2,displayName:"Border Width",editorName:h("Border Width"),group:g,type:{name:"number",units:["px"],defaultUnit:"px"},default:n[`border${s}Width`],tab:p,popout:o,allowVisualStates:!0},[u]:{index:m+3,displayName:"Border Color",editorName:h("Border Color"),group:g,type:"color",default:n[`border${s}Color`],tab:p,popout:o,allowVisualStates:!0}})}s(e,"","borders-all",0),s(e,"Left","borders-left",1),s(e,"Top","borders-top",2),s(e,"Right","borders-right",3),s(e,"Bottom","borders-bottom",4)}function Ve(e,t){const n=(t=t||{}).defaults||{},o=t.popout;n.borderRadius||(n.borderRadius=0);const i=t.propPrefix[0].toUpperCase()+t.propPrefix.slice(1);function s(e,s,r,a){const l={group:t.propPrefix+"-corners",tab:r,label:s},d=`Border${s}Radius`;F.addInputProps(e,{[t.propPrefix+d]:{index:240+a,displayName:"Corner Radius",editorName:`${i} Corner Radius ${s?"("+s+")":""}`,group:i+" Corner Radius",type:{name:"number",units:["px","%"],defaultUnit:"px"},default:n[`border${s}Radius`],tab:l,popout:o}})}s(e,"","corners-all",0),s(e,"TopLeft","corners-top-left",1),s(e,"TopRight","corners-top-right",2),s(e,"BottomRight","corners-bottom-right",3),s(e,"BottomLeft","corners-bottom-left",4)}function je(e,t){const n=(t=t||{}).popout,o=t.propPrefix;F.addDynamicInputPorts(e,`${o}BoxShadowEnabled = true`,[`${o}BoxShadowOffsetX`,`${o}BoxShadowOffsetY`,`${o}BoxShadowInset`,`${o}BoxShadowBlurRadius`,`${o}BoxShadowSpreadRadius`,`${o}BoxShadowColor`]);const i=t.propPrefix[0].toUpperCase()+t.propPrefix.slice(1),s=e=>`${i} ${e}`;F.addInputProps(e,{[`${o}BoxShadowEnabled`]:{index:250,group:t.group||"Box Shadow",displayName:"Shadow Enabled",editorName:s("Shadow Enabled"),type:"boolean",allowVisualStates:!0,popout:n},[`${o}BoxShadowOffsetX`]:{index:251,group:t.group||"Box Shadow",displayName:"Offset X",editorName:s("Offset X"),default:0,type:{name:"number",units:["px"],defaultUnit:"px"},allowVisualStates:!0,popout:n},[`${o}BoxShadowOffsetY`]:{index:252,group:t.group||"Box Shadow",displayName:"Offset Y",editorName:s("Offset Y"),default:0,type:{name:"number",units:["px"],defaultUnit:"px"},allowVisualStates:!0,popout:n},[`${o}BoxShadowBlurRadius`]:{index:253,group:t.group||"Box Shadow",displayName:"Blur Radius",editorName:s("Blur Radius"),default:5,type:{name:"number",units:["px"],defaultUnit:"px"},allowVisualStates:!0,popout:n},[`${o}BoxShadowSpreadRadius`]:{index:254,group:t.group||"Box Shadow",displayName:"Spread Radius",editorName:s("Spread Radius"),default:2,type:{name:"number",units:["px"],defaultUnit:"px"},allowVisualStates:!0,popout:n},[`${o}BoxShadowInset`]:{index:255,group:t.group||"Box Shadow",displayName:"Inset",editorName:s("Inset"),type:"boolean",default:!1,allowVisualStates:!0,popout:n},[`${o}BoxShadowColor`]:{index:256,group:t.group||"Box Shadow",displayName:"Shadow Color",editorName:s("Shadow Color"),type:"color",default:"#00000033",allowVisualStates:!0,popout:n}})}F.addAlignInputs(Re),F.addTransformInputs(Re),F.addMarginInputs(Re),F.addPaddingInputs(Re),F.addSharedVisualInputs(Re),Me(Re,{propPrefix:"track",popout:De}),Ve(Re,{propPrefix:"track",popout:De}),je(Re,{propPrefix:"track",popout:De,group:"Track Box Shadow"}),Me(Re,{propPrefix:"thumb",popout:ke}),Ve(Re,{propPrefix:"thumb",popout:ke}),je(Re,{propPrefix:"thumb",popout:ke,group:"Thumb Box Shadow"}),re(Re);const Fe=Z(Re);function Ue(e){e.stopPropagation(),window.removeEventListener("click",Ue,!0)}class We extends n().Component{constructor(e){super(e),this.state={value:e.startValue},this.ref=n().createRef()}setText(e){this.setState({value:e}),this.props.onTextChanged&&this.props.onTextChanged(e)}componentDidMount(){this.ref.current&&(this.ref.current.noodlNode=this.props.noodlNode),this.setText(this.props.startValue)}render(){const e={...this.props.style};x.size(e,this.props),x.align(e,this.props),0===e.opacity&&(e.pointerEvents="none");const{height:t,...o}=e,i=o,s=this.props,r=()=>{if("image"===s.iconSourceType&&void 0!==s.iconImageSource)return n().createElement("img",{alt:"",src:s.iconImageSource,style:{width:s.iconSize,height:s.iconSize},onClick:()=>this.focus()});if("icon"===s.iconSourceType&&void 0!==s.iconIconSource){const e={userSelect:"none",fontSize:s.iconSize,color:s.iconColor};return"left"===s.iconPlacement||void 0===s.iconPlacement?e.marginRight=s.iconSpacing:e.marginLeft=s.iconSpacing,!0===s.iconIconSource.codeAsClass?n().createElement("span",{className:[s.iconIconSource.class,s.iconIconSource.code].join(" "),style:e}):n().createElement("span",{className:s.iconIconSource.class,style:e},s.iconIconSource.code)}return null};let a,l="ndl-controls-textinput "+s.id;s.className&&(l=l+" "+s.className);const d={...s.textStyle,...s.styles.input,width:"100%",height:"100%"};d.color=s.noodlNode.context.styles.resolveColor(d.color);const u={...s.attrs,id:s.id,value:this.state.value,...ae(s),disabled:!s.enabled,style:d,className:l,placeholder:s.placeholder,maxLength:s.maxLength,onChange:e=>this.onChange(e)};"textArea"!==s.type?a=n().createElement("input",{ref:e=>this.ref.current=e,type:this.props.type,...u,onKeyDown:e=>this.onKeyDown(e),onMouseDown:()=>window.addEventListener("click",Ue,!0),"noodl-style-tag":"input"}):(u.style.resize="none",a=n().createElement("textarea",{ref:e=>this.ref.current=e,...u,onKeyDown:e=>this.onKeyDown(e),"noodl-style-tag":"input"}));const c={display:"flex",alignItems:"center",...s.styles.inputWrapper},p=t&&"%"===t[String(t).length-1];s.useLabel?p?c.flexGrow=1:c.height=t:(Object.assign(c,i),c.height=t),"textArea"!==s.type&&(c.alignItems="center");const h=n().createElement("div",{style:c,"noodl-style-tag":"inputWrapper"},s.useIcon&&"left"===s.iconPlacement?r():null,a,s.useIcon&&"right"===s.iconPlacement?r():null);if(s.useLabel){i.display="flex",i.flexDirection="column",p&&(i.height=t);const e={...s.labeltextStyle,...s.styles.label,marginBottom:s.labelSpacing};return e.color=s.noodlNode.context.styles.resolveColor(e.color),n().createElement("div",{style:i},n().createElement("label",{htmlFor:s.id,style:e,"noodl-style-tag":"label"},s.label),h)}return h}onKeyDown(e){"Enter"!==e.key&&13!==e.which||this.props.onEnter&&this.props.onEnter()}onChange(e){const t=e.target.value;this.setText(t)}focus(){this.ref.current&&this.ref.current.focus()}blur(){this.ref.current&&this.ref.current.blur()}hasFocus(){return document.activeElement===this.ref.current}}function Le(e,t){return`\n .${e}::placeholder {\n opacity: ${t.placeholderOpacity};\n }\n `}const Be={name:"net.noodl.controls.textinput",displayName:"Text Input",docs:"https://docs.noodl.net/nodes/ui-controls/text-input",allowChildren:!1,noodlNodeAsProp:!0,usePortAsLabel:"label",nodeDoubleClickAction:{focusPort:"label"},connectionPanel:{groupPriority:["General","Text","Style","Actions","Events","States","Mounted","Text Style","Label","Label Text Style","Hover Events","Pointer Events","Focus Events"]},getReactComponent:()=>We,initialize(){this.props.attrs={},this.props.startValue="",this.props.id=this._internal.controlId="input-"+(0,s.guid)()},inputProps:{type:{displayName:"Type",group:"Text",index:19,type:{name:"enum",enums:[{label:"Text",value:"text"},{label:"Text Area",value:"textArea"},{label:"Email",value:"email"},{label:"Number",value:"number"},{label:"Password",value:"password"},{label:"URL",value:"url"}]},default:"text"},placeholder:{index:22,group:"Text",displayName:"Placeholder",default:"Type here...",type:{name:"string"}},maxLength:{group:"Text",displayName:"Max length",type:"number",index:24}},inputs:{placeHolderOpacity:{index:23,group:"Text",displayName:"Placeholder opacity",type:"number",default:.5,set(e){const t=this._internal.controlId;se(t,{placeholderOpacity:e},Le)}},set:{group:"Actions",displayName:"Set",type:"signal",valueChangedToTrue(){this.scheduleAfterInputsHaveUpdated((()=>{this.setText(this._internal.text)}))}},startValue:{index:18,displayName:"Text",type:"string",group:"Text",set(e){this._internal.text!==e&&(this._internal.text=e,!1===this.isInputConnected("set")&&this.setText(e))}},clear:{type:"signal",group:"Actions",displayName:"Clear",valueChangedToTrue(){this.clear()}},focus:{type:"signal",group:"Actions",displayName:"Focus",valueChangedToTrue(){this.context.setNodeFocused(this,!0)}},blur:{type:"signal",group:"Actions",displayName:"Blur",valueChangedToTrue(){this.context.setNodeFocused(this,!1)}},textAlignX:{group:"Text Alignment",index:13,displayName:"Text Horizontal Align",type:{name:"enum",enums:[{label:"left",value:"left"},{label:"center",value:"center"},{label:"right",value:"right"}],alignComp:"justify"},default:"left",set(e){switch(e){case"left":this.setStyle({textAlign:"left"},"input");break;case"center":this.setStyle({textAlign:"center"},"input");break;case"right":this.setStyle({textAlign:"right"},"input")}}},testId:{index:100009,displayName:"Test ID Attribute",group:"Advanced HTML",type:"string",set(e){this.props.attrs["data-testid"]=e,this.forceUpdate()}}},inputCss:{backgroundColor:{index:100,displayName:"Background Color",group:"Style",type:"color",default:"transparent",allowVisualStates:!0,styleTag:"inputWrapper"}},outputProps:{onTextChanged:{group:"General",displayName:"Text",type:"string",index:1,onChange(){this.sendSignalOnOutput("textChanged")}},onEnter:{group:"Events",displayName:"On Enter",type:"signal"}},outputs:{textChanged:{displayName:"Text Changed",type:"signal",group:"General",index:2}},methods:{_focus(){this.innerReactComponentRef&&this.innerReactComponentRef.focus()},_blur(){this.innerReactComponentRef&&this.innerReactComponentRef.blur()},clear(){this.props.startValue="",this.innerReactComponentRef&&this.innerReactComponentRef.setText("")},setText(e){this.props.startValue=e,this.innerReactComponentRef?!1===this.innerReactComponentRef.hasFocus()&&this.innerReactComponentRef.setText(e):this.outputPropValues.onTextChanged!==e&&(this.outputPropValues.onTextChanged=e,this.flagOutputDirty("onTextChanged"))}}};F.addDimensions(Be,{defaultSizeMode:"contentSize",contentLabel:"Text"}),F.addIconInputs(Be,{enableIconPlacement:!0,defaults:{useIcon:!1,iconColor:"#000000"}}),F.addLabelInputs(Be,{enableSpacing:!0,styleTag:"label",displayName:"Label"}),F.addTextStyleInputs(Be,{styleTag:"input",portPrefix:"",portIndex:18,popout:{group:"input-text-style",label:"Text Style",parentGroup:"Text"}}),F.addAlignInputs(Be),F.addTransformInputs(Be),F.addPaddingInputs(Be,{styleTag:"inputWrapper"}),F.addMarginInputs(Be),F.addSharedVisualInputs(Be),F.addBorderInputs(Be,{styleTag:"inputWrapper"}),F.addShadowInputs(Be,{styleTag:"inputWrapper"}),re(Be);const $e=Z(Be);class qe{constructor(){this.queue=[],this.workingOnPromise=!1}enqueue(e){return new Promise(((t,n)=>{this.queue.push({promise:e,resolve:t,reject:n}),this.dequeue()}))}dequeue(){if(this.workingOnPromise)return!1;const e=this.queue.shift();if(!e)return!1;try{this.workingOnPromise=!0,e.promise().then((t=>{this.workingOnPromise=!1,e.resolve(t),this.dequeue()})).catch((t=>{this.workingOnPromise=!1,e.reject(t),this.dequeue()}))}catch(t){this.workingOnPromise=!1,e.reject(t),this.dequeue()}return!0}}var ze=__webpack_require__(7410),He=__webpack_require__(5573);const Ge=e=>{const{didMount:o,willUnmount:i,style:s,children:r}=e;return(0,t.useEffect)((()=>(o(),()=>{i()})),[o,i]),n().createElement("div",{style:s},r)},Xe={name:"Page Stack",displayNodeName:"Component Stack",category:"Visuals",docs:"https://docs.noodl.net/nodes/component-stack/component-stack-node",useVariants:!1,initialize(){this._internal.stack=[],this._internal.topPageName="",this._internal.stackDepth=0,this._internal.pageInfo={},this._internal.asyncQueue=new qe,this.onScheduleReset=()=>{this.scheduleReset()},this.props.didMount=()=>{this._internal.isMounted=!0,window.history&&window.history.pushState?window.addEventListener("popstate",this.onScheduleReset):window.addEventListener("hashchange",this.onScheduleReset),this._registerPageStack()},this.props.willUnmount=()=>{this._internal.isMounted=!1,window.removeEventListener("popstate",this.onScheduleReset),window.removeEventListener("hashchange",this.onScheduleReset),this._deregisterPageStack()}},getInspectInfo(){return 0===this._internal.stack.length?"No active page":[{type:"text",value:"Active Components:"}].concat(this._internal.stack.map((e=>({type:"text",value:"- "+this._findPage(e.pageId).label}))))},defaultCss:{width:"100%",flex:"1 1 100%",position:"relative",display:"flex",flexDirection:"column"},getReactComponent:()=>Ge,inputs:{name:{type:{name:"string",identifierOf:"PackStack"},displayName:"Name",group:"General",default:"Main",set(e){this._deregisterPageStack(),this._internal.name=e,this._internal.isMounted&&this._registerPageStack()}},useRoutes:{type:"boolean",displayName:"Use Routes",group:"General",default:!1,set(e){this._internal.useRoutes=!!e}},clip:{displayName:"Clip Content",type:"boolean",group:"Layout",default:!0,set(e){e?this.setStyle({overflow:"hidden"}):this.removeStyle(["overflow"])}},pages:{type:"proplist",displayName:"Components",group:"Components",set(e){this._internal.pages=e,this._internal.isMounted&&this.scheduleReset()}},reset:{type:"signal",displayName:"Reset",group:"Actions",valueChangedToTrue(){this.scheduleReset()}}},inputCss:{backgroundColor:{type:"color",displayName:"Background Color",group:"Style",default:"transparent",applyDefault:!1}},outputs:{topPageName:{type:"string",displayName:"Top Component Name",group:"General",get(){return this._internal.topPageName}},stackDepth:{type:"number",displayName:"Stack Depth",group:"General",get(){return this._internal.stackDepth}}},methods:{_registerPageStack(){ze.A.instance.registerPageStack(this._internal.name,this)},_deregisterPageStack(){ze.A.instance.deregisterPageStack(this._internal.name,this)},_findPage(e){if(this._internal.pageInfo[e]){const t=this._internal.pageInfo[e],n=this._internal.pages.find((t=>t.id===e));return{component:String(t.component),label:String(n.label),id:String(e)}}const t=this._internal.pages.find((t=>t.label===e));if(t){const e=this._internal.pageInfo[t.id];return{component:String(e.component),label:String(t.label),id:String(t.id)}}},setPageOutputs(e){for(const t in e)this._internal[t]=e[t],this.flagOutputDirty(t)},scheduleReset(){const e=this._internal;e.hasScheduledReset||(e.hasScheduledReset=!0,this.scheduleAfterInputsHaveUpdated((()=>{e.hasScheduledReset=!1,this.reset()})))},createPageContainer(){const e=this.nodeScope.createPrimitiveNode("Group");return e.setStyle({flex:"1 0 100%"}),e},reset(){this._internal.asyncQueue.enqueue(this.resetAsync.bind(this))},async resetAsync(){const e=this.getChildren();for(const t of e)this.removeChild(t),this.nodeScope.deleteNode(t);if(void 0===this._internal.pages||0===this._internal.pages.length)return;let t,n={};const o=this.matchPageFromUrl();void 0!==o?(t=o.pageId,n={...o.query,...o.params}):(t=this._internal.startPageId,void 0===t&&(t=this._internal.pages[0].id));const i=this._findPage(t);if(void 0===i||void 0===i.component)return;const r=await this.nodeScope.createNode(i.component,(0,s.guid)());for(const e in n)r.setInputValue(e,n[e]);const a=this.createPageContainer();a.addChild(r),this.addChild(a),this._internal.stack=[{from:null,page:a,pageId:t,pageInfo:i,params:n,componentName:this._internal.startPage}],this.setPageOutputs({topPageName:i.label,stackDepth:this._internal.stack.length})},getRelativeURL(){const e=this._internal.stack[this._internal.stack.length-1];if(void 0===e)return;let t=e.pageInfo.path;if(void 0===t){const n=this._internal.pages.find((t=>t.id==e.pageId));if(void 0===n)return;t=n.label.replace(/\s+/g,"-").toLowerCase()}const n=t.match(/{([^}]+)}/g),o={...e.params};if(n)for(const i of n){const n=i.replace(/[{}]/g,"");void 0!==e.params[n]&&(t=t.replace(i,encodeURIComponent(o[n])),delete o[n])}const i=Object.keys(o).map((e=>({name:e,value:o[e]})));return t.startsWith("/")&&(t=t.substring(1)),{path:t,query:i}},getNavigationAbsoluteURL(){let e=this.parent;for(;void 0!==e&&"function"!=typeof e.getNavigationAbsoluteURL;)e=e.getVisualParentNode();const t=void 0===e?{path:"",query:[]}:e.getNavigationAbsoluteURL(),n=this.getRelativeURL();return void 0===n?t:{path:t.path+(t.path.endsWith("/")?"":"/")+n.path,query:t.query.concat(n.query)}},_getLocationPath(){const e=s.default.instance.getProjectSettings().navigationPathType;if(void 0===e||"hash"===e){let e=location.hash;return e&&("#"===e[0]&&(e=e.substring(1)),"/"===e[0]&&(e=e.substring(1))),e}{let e=location.pathname;return e&&"/"===e[0]&&(e=e.substring(1)),e}},_getSearchParams(){const e=/\+/g,t=/([^&=]+)=?([^&]*)/g,n=t=>decodeURIComponent(t.replace(e," ")),o=window.location.search.substring(1);let i;const s={};for(;i=t.exec(o);)s[n(i[1])]=n(i[2]);return s},getNavigationRemainingPath(){return this._internal.remainingNavigationPath},matchPageFromUrl(e){if(!this._internal.useRoutes)return;if(void 0===this._internal.pages||0===this._internal.pages.length)return;let t=this.parent;for(;void 0!==t&&"function"!=typeof t.getNavigationRemainingPath;)t=t.getVisualParentNode();const n=void 0===t?this._getLocationPath().split("/").filter(Boolean):t.getNavigationRemainingPath();if(void 0===n)return;const o=this._getSearchParams(),i=(e,t)=>{const n={};for(let o=0;o`${e.name}=${e.value}`)),r=(void 0!==t?t:"")+(i.length>=1?"?"+i.join("&"):"")+(void 0!==n?"#"+n:"");this._internal.remainingNavigationPath=void 0,window.history.pushState({},"",r)}},replace(e){this._internal.asyncQueue.enqueue(this.replaceAsync.bind(this,e))},async replaceAsync(e){if(void 0===this._internal.pages||0===this._internal.pages.length)return;if(this._internal.isTransitioning)return;const t=e.target||this._internal.pages[0].id,n=this._findPage(t);if(void 0===n||void 0===n.component)return;const o=this.getChildren();for(const e of o)this.removeChild(e),this.nodeScope.deleteNode(e);const i=this.createPageContainer(),r=await this.nodeScope.createNode(n.component,(0,s.guid)());for(const t in e.params)r.setInputValue(t,e.params[t]);i.addChild(r),this.addChild(i),this._internal.stack=[{from:null,page:i,pageId:t,pageInfo:n,params:e.params,componentName:e.target}],this.setPageOutputs({topPageName:n.label,stackDepth:this._internal.stack.length}),this._updateUrlWithTopPage(),e.hasNavigated&&e.hasNavigated()},navigate(e){this._internal.asyncQueue.enqueue(this.navigateAsync.bind(this,e))},async navigateAsync(e){if(void 0===this._internal.pages||0===this._internal.pages.length)return;if(this._internal.isTransitioning)return;const t=e.target||this._internal.pages[0].id,n=this._findPage(t);if(void 0===n||void 0===n.component)return;const o=this.createPageContainer();o.setInputValue("position","absolute");const i=await this.nodeScope.createNode(n.component,(0,s.guid)());for(const t in e.params)i.setInputValue(t,e.params[t]);o.addChild(i);const r=i.nodeScope.getNodesWithType("PageStackNavigateBack");if(r&&r.length>0)for(const e of r)e._setBackCallback(this.back.bind(this));const a=this._internal.stack[this._internal.stack.length-1],l={from:a.page,page:o,pageInfo:n,pageId:t,params:e.params,transition:new He.x[e.transition.type||"Push"](a.page,o,e.transition),backCallback:e.backCallback,componentName:e.target};this._internal.stack.push(l),this.setPageOutputs({topPageName:n.label,stackDepth:this._internal.stack.length}),this._updateUrlWithTopPage(),l.transition.forward(0),this._internal.isTransitioning=!0,l.transition.start({end:()=>{this._internal.isTransitioning=!1,this.removeChild(a.page),o.setInputValue("position","relative")}}),this.addChild(o),e.hasNavigated&&e.hasNavigated()},back(e){if(this._internal.stack.length<=1)return;if(this._internal.isTransitioning)return;const t=this._internal.stack[this._internal.stack.length-1];t.page.setInputValue("position","absolute"),this.addChild(t.from,0),t.backCallback&&t.backCallback(e.backAction,e.results);const n=this._findPage(this._internal.stack[this._internal.stack.length-2].pageId);this.setPageOutputs({topPageName:n.label,stackDepth:this._internal.stack.length-1}),this._internal.isTransitioning=!0,t.transition.start({end:()=>{this._internal.isTransitioning=!1,t.page.setInputValue("position","relative"),this.removeChild(t.page),this.nodeScope.deleteNode(t.page),this._internal.stack.pop(),this._updateUrlWithTopPage()},back:!0})},setPageComponent(e,t){const n=this._internal;n.pageInfo[e]||(n.pageInfo[e]={}),n.pageInfo[e].component=t},setPagePath(e,t){const n=this._internal;n.pageInfo[e]||(n.pageInfo[e]={}),n.pageInfo[e].path=t},setStartPage(e){this._internal.startPageId=e},registerInputIfNeeded(e){if(!this.hasInput(e))return e.startsWith("pageComp-")?this.registerInput(e,{set:this.setPageComponent.bind(this,e.substring(9))}):e.startsWith("pagePath-")?this.registerInput(e,{set:this.setPagePath.bind(this,e.substring(9))}):"startPage"===e?this.registerInput(e,{set:this.setStartPage.bind(this)}):void 0}},setup(e,t){function n(t){function n(){const n=[];void 0!==t.parameters.pages&&t.parameters.pages.length>0&&(t.parameters.pages.forEach((e=>{n.push({name:"pageComp-"+e.id,displayName:"Component",editorName:e.label+" | Component",plug:"input",type:"component",parent:"pages",parentItemId:e.id}),!0===t.parameters.useRoutes&&n.push({name:"pagePath-"+e.id,displayName:"Path",editorName:e.label+" | Path",plug:"input",type:"string",default:e.label.replace(/\s+/g,"-").toLowerCase(),parent:"pages",parentItemId:e.id})})),n.push({plug:"input",type:{name:"enum",enums:t.parameters.pages.map((e=>({label:e.label,value:e.id}))),allowEditOnly:!0},group:"General",displayName:"Start Page",name:"startPage",default:t.parameters.pages[0].id})),e.editorConnection.sendDynamicPorts(t.id,n)}n(),t.on("parameterUpdated",(function(e){"pages"!==e.name&&"useRoutes"!==e.name||n()}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.Page Stack",(function(e){n(e)}));for(const e of t.getNodesWithType("Page Stack"))n(e)}))}},Ye=Z(Xe),Je={group:"seo-og",label:"Open Graph",parentGroup:"Experimental SEO"},Ke={group:"seo-twitter",label:"Twitter",parentGroup:"Experimental SEO"},Qe=[{isProperty:!0,key:"description",displayName:"Description",group:"Experimental SEO"},{isProperty:!0,key:"robots",displayName:"Robots",group:"Experimental SEO"},{isProperty:!0,key:"og:title",displayName:"Title",editorName:"OG Title",group:"General",popout:Je},{isProperty:!0,key:"og:description",displayName:"Description",editorName:"OG Description",group:"General",popout:Je},{isProperty:!0,key:"og:url",displayName:"Url",editorName:"OG Url",group:"General",popout:Je},{isProperty:!0,key:"og:type",displayName:"Type",editorName:"OG Type",group:"General",popout:Je},{isProperty:!0,key:"og:image",displayName:"Image",editorName:"OG Image",group:"Image",popout:Je},{isProperty:!0,key:"og:image:width",displayName:"Image Width",editorName:"OG Image Width",group:"Image",popout:Je},{isProperty:!0,key:"og:image:height",displayName:"Image Height",editorName:"OG Image Height",group:"Image",popout:Je},{isProperty:!1,key:"twitter:card",displayName:"Card",editorName:"Twitter Card",group:"General",popout:Ke},{isProperty:!1,key:"twitter:title",displayName:"Title",editorName:"Twitter Title",group:"General",popout:Ke},{isProperty:!1,key:"twitter:description",displayName:"Description",editorName:"Twitter Description",group:"General",popout:Ke},{isProperty:!1,key:"twitter:image",displayName:"Image",editorName:"Twitter Image",group:"General",popout:Ke}];function Ze(e){const{style:t,children:o}=e;return x.size(t,e),x.align(t,e),Qe.forEach((t=>{const n=e.metatags&&e.metatags[t.key];Noodl.SEO.setMeta(t.key,n)})),n().createElement("div",{style:t,className:e.className},o)}const et={name:"Page",displayNodeName:"Page",category:"Visuals",docs:"https://docs.noodl.net/nodes/navigation/page",useVariants:!1,mountedInput:!1,allowAsExportRoot:!1,singleton:!0,connectionPanel:{groupPriority:["General","Mounted"]},initialize(){this.props.layout="column",this.isInputConnected("onPageReady")&&this.nodeScope.context.eventEmitter.emit("SSR_PageLoading",this.id)},defaultCss:{display:"flex",flexDirection:"column",position:"relative",alignItems:"flex-start",flex:"1 1",alignSelf:"stretch"},getReactComponent:()=>Ze,inputs:{sitemapIncluded:{index:80001,displayName:"Included",group:"Experimental Sitemap",default:!0,type:{name:"boolean",allowEditOnly:!0}},sitemapChangefreq:{index:80002,displayName:"Change Freq",group:"Experimental Sitemap",default:"weekly",type:{name:"enum",allowEditOnly:!0,enums:[{label:"always",value:"always"},{label:"hourly",value:"hourly"},{label:"daily",value:"daily"},{label:"weekly",value:"weekly"},{label:"monthly",value:"monthly"},{label:"yearly",value:"yearly"},{label:"never",value:"never"}]}},sitemapPriority:{index:80003,displayName:"Priority",group:"Experimental Sitemap",default:.5,type:{name:"number",allowEditOnly:!0}}},inputProps:Qe.reduce(((e,t,n)=>(e[t.key]={index:8e4+n,displayName:t.displayName,editorName:t.editorName||t.displayName,propPath:"metatags",group:t.group,popout:t.popout,type:t.type||"string"},e)),{}),methods:{getUrlPath(){return this._internal.urlPath},getTitle(){return this._internal.title},setTitle(e){this._internal.title=e},setUrlPath(e){this._internal.urlPath=e},registerInputIfNeeded(e){if(!this.hasInput(e))return"title"===e?this.registerInput(e,{set:this.setTitle.bind(this)}):"urlPath"===e?this.registerInput(e,{set:this.setUrlPath.bind(this)}):void 0}},setup(e,t){function n(t){function n(){const n=[],o=t.component.name.split("/");n.push({name:"title",displayName:"Title",type:"string",group:"General",plug:"input",default:o[o.length-1]});const i=(t.parameters.title||o[o.length-1]).replace(/\s+/g,"-").toLowerCase();n.push({name:"urlPath",displayName:"Url Path",type:"string",group:"General",plug:"input",default:i}),e.editorConnection.sendDynamicPorts(t.id,n)}n(),t.on("parameterUpdated",(function(e){"title"===e.name&&n()}))}e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("editorImportComplete",(()=>{t.on("nodeAdded.Page",(function(e){n(e)})),t.on("componentRenamed",(function(e){const o=t.getNodesWithType("Page").filter((t=>e.roots.includes(t.id)));o.length>0&&n(o[0])}));for(const e of t.getNodesWithType("Page"))n(e)}))}};F.addPaddingInputs(et);const tt=Z(et);function nt(e){const{didMount:o,willUnmount:i,children:s,style:r}=e;return(0,t.useEffect)((()=>(o(),()=>{i()})),[]),n().createElement("div",{className:e.className,style:r},s)}function ot(e){return"/"===e[0]&&(e=e.substring(1)),"/"===e[e.length-1]&&(e=e.substring(0,e.length-1)),e}const it={name:"Router",displayNodeName:"Page Router",category:"Visuals",docs:"https://docs.noodl.net/nodes/navigation/page-router",useVariants:!1,connectionPanel:{groupPriority:["General","Actions","Events","Mounted"]},initialize(){this._internal.asyncQueue=new qe,this.onScheduleReset=()=>{this.scheduleReset()},this.props.didMount=()=>{this._internal.isMounted=!0,"undefined"!=typeof window&&(window.history&&window.history.pushState?window.addEventListener("popstate",this.onScheduleReset):window.addEventListener("hashchange",this.onScheduleReset)),this._registerRouter()},this.props.willUnmount=()=>{this._internal.isMounted=!1,window.removeEventListener("popstate",this.onScheduleReset),window.removeEventListener("hashchange",this.onScheduleReset),this._deregisterRouter()},this.props.layout="column"},getInspectInfo(){return this._internal.currentUrl},defaultCss:{flex:"1 1",alignSelf:"stretch",position:"relative",display:"flex",flexDirection:"column"},getReactComponent:()=>nt,inputs:{name:{type:"string",displayName:"Name",group:"General",set(e){this._deregisterRouter(),this._internal.name=e,this._internal.isMounted&&this._registerRouter()}},pages:{type:{name:"pages",allowEditOnly:!0},displayName:"Pages",group:"Pages",set(e){this._internal.pages=e,this._internal.isMounted&&this.scheduleReset()}},urlPath:{type:"string",displayName:"Url path",group:"General",set(e){this._internal.urlPath=e}},clip:{displayName:"Clip Behavior",type:{name:"enum",enums:[{value:"contentHeight",label:"Expand to content size"},{value:"scroll",label:"Scroll"},{value:"clip",label:"Clip content"}]},group:"Layout",default:"contentHeight",set(e){switch(e){case"scroll":this.setStyle({overflow:"auto"});break;case"clip":this.setStyle({overflow:"hidden"});break;default:this.removeStyle(["overflow"])}}},reset:{type:"signal",displayName:"Reset",group:"Actions",valueChangedToTrue(){this.scheduleReset()}}},inputCss:{backgroundColor:{type:"color",displayName:"Background Color",group:"Style",default:"transparent",applyDefault:!1}},outputs:{currentPageTitle:{type:"string",group:"General",displayName:"Current Page Title",getter(){return void 0!==this._internal.currentPage?this._internal.currentPage.title:void 0}},currentPageComponent:{type:"string",group:"General",displayName:"Current Page Component",getter(){return void 0!==this._internal.currentPage?this._internal.currentPage.component:void 0}}},methods:{_registerRouter(){y.u.instance.registerRouter(this._internal.name,this)},_deregisterRouter(){y.u.instance.deregisterRouter(this._internal.name,this)},setPageOutputs(e){for(const t in e)this._internal[t]=e[t],this.flagOutputDirty(t)},scheduleReset(){const e=this._internal;e.hasScheduledReset||(e.hasScheduledReset=!0,this.scheduleAfterInputsHaveUpdated((()=>{e.hasScheduledReset=!1,this.reset()})))},createPageContainer(){const e=this.nodeScope.createPrimitiveNode("Group");return e.setStyle({flex:"1 0 100%"}),e},reset(){this._internal.asyncQueue.enqueue(this.resetAsync.bind(this))},scrollToTop(){const e=this.getDOMElement();e&&(e.scrollTop=0,s.default.instance.getProjectSettings().bodyScroll&&e.scrollIntoView())},async resetAsync(){let e,t={};const n=this.matchPageFromUrl();if(n?n.page?(e=n.page.component,t=Object.assign({},n.params,n.query)):(e=void 0!==this._internal.pages?this._internal.pages.startPage:void 0,t=Object.assign({},n.params,n.query)):(e=this._internal.pages.startPage,t={}),void 0===e)return;const o=y.u.instance.getPageInfoForComponent(e);if(this._internal.currentPage===o)return void(function(e,t){const n=Object.keys(e||{}),o=Object.keys(t||{});return n.length===o.length&&n.every((n=>e[n]===t[n]))}(this._internal.currentParams,t)||(this._internal.currentParams=t,this._updatePageInputs(this._internal.currentPageComponent.nodeScope,t)));this.scrollToTop();const i=this.getChildren();for(const e in i){const t=i[e];this.removeChild(t),this.nodeScope.deleteNode(t)}const r=await this.nodeScope.createNode(e,(0,s.guid)());this._internal.currentPageComponent=r;const a=r.nodeScope.getNodesWithType("Page");if(void 0===a||1!==a.length)return;this._internal.currentPage=y.u.instance.getPageInfoForComponent(e),this._internal.currentParams=t,this.flagOutputDirty("currentPageTitle"),this.flagOutputDirty("currentPageComponent"),Noodl.SEO.setTitle(this._internal.currentPage.title),this._updatePageInputs(this._internal.currentPageComponent.nodeScope,t);const l=this.createPageContainer();l.addChild(r),this.addChild(l)},_updatePageInputs(e,t){for(const n of e.getNodesWithType("PageInputs"))n._setPageParams(t)},getRelativeURL(e,t){if(!e)return;let n=e.path;if(void 0===n)return;const o=n.match(/{([^}]+)}/g),i=Object.assign({},t);if(o)for(const e of o){const o=e.replace(/[{}]/g,"");void 0!==t[o]&&(n=n.replace(e,encodeURIComponent(i[o])),delete i[o])}const s=[];for(const e in i)s.push({name:e,value:encodeURIComponent(i[e])});return n=ot(n),void 0!==this._internal.urlPath&&(n=ot(this._internal.urlPath)+"/"+n),{path:n,query:s}},getNavigationAbsoluteURL(e,t){let n=this.parent,o={path:"",query:[]};for(;void 0!==n&&"function"!=typeof n.getNavigationAbsoluteURL;)n=n.getVisualParentNode();n&&(o=n.getNavigationAbsoluteURL(n._internal.currentPage,n._internal.currentParams));const i=this.getRelativeURL(e,t);if(i){const e=o.path.endsWith("/")||i.path.startsWith("/");return{path:o.path+(e?"":"/")+i.path,query:o.query.concat(i.query)}}return o},_getLocationPath:function(){const e=s.default.instance.getProjectSettings().navigationPathType;if(void 0===e||"hash"===e){let e=location.hash;return e&&("#"===e[0]&&(e=e.substring(1)),"/"===e[0]&&(e=e.substring(1))),decodeURI(e)}{let e=location.pathname;if(e&&"/"===e[0]){const t=Noodl.Env.BaseUrl;if(t){const n=function(e){if(!e.startsWith("/"))try{return new URL(e).pathname.length}catch(e){}return e.length}(t);e=e.substring(n)}else e=e.substring(1)}return decodeURI(e)}},_getSearchParams:function(){const e=/\+/g,t=/([^&=]+)=?([^&]*)/g,n=function(t){return decodeURIComponent(t.replace(e," "))},o=location.search.substring(1);let i;const s={};for(;i=t.exec(o);)s[n(i[1])]=n(i[2]);return s},getNavigationRemainingPath(){return this._internal.remainingNavigationPath},matchPageFromUrl(){let e,t=this.parent;for(;void 0!==t&&"function"!=typeof t.getNavigationRemainingPath;)t=t.getVisualParentNode();if(void 0===t){let t=this._getLocationPath();"/"===t[0]&&(t=t.substring(1)),e=t.split("/")}else e=t.getNavigationRemainingPath();if(void 0===e)return;const n=this._getSearchParams();function o(e,t){const n={};for(let o=0;ol&&(s={match:a,pageInfo:t},r=l)}return s?(this._internal.remainingNavigationPath=s.match.remainingPathParts,{page:s.pageInfo,params:s.match.params,query:n}):{page:void 0,params:{},query:n}},_getCompleteUrlToPage(e,t){const n=this.getNavigationAbsoluteURL(e,t);let o,i;const r=s.default.instance.getProjectSettings().navigationPathType;void 0===r||"hash"===r?i=n.path:o=n.path;const a=n.query.map((e=>e.name+"="+e.value));return(void 0!==o?o:"")+(a.length>=1?"?"+a.join("&"):"")+(void 0!==i?"#"+i:"")},_updateUrlWithTopPage(){if(void 0!==window.history){this._internal.remainingNavigationPath=void 0;const e=this._getCompleteUrlToPage(this._internal.currentPage,this._internal.currentParams);window.history.pushState({},"",e)}},navigate(e){this._internal.asyncQueue.enqueue(this.navigateAsync.bind(this,e))},async navigateAsync(e){if(void 0===e.target)return;const t=y.u.instance.getPageInfoForComponent(e.target);if(t)if(e.openInNewTab){const n=this._getCompleteUrlToPage(t,e.params);window.open(n,"_blank"),e.hasNavigated&&e.hasNavigated()}else await this._navigateInCurrentWindow(t,e)},async _navigateInCurrentWindow(e,t){this.scrollToTop();const n=this.getChildren();for(const e in n){const t=n[e];this.removeChild(t),this.nodeScope.deleteNode(t)}const o=this.createPageContainer(),i=await this.nodeScope.createNode(t.target,(0,s.guid)());this._internal.currentPage=e,this._internal.currentParams=t.params,this.flagOutputDirty("currentPageTitle"),this.flagOutputDirty("currentPageComponent"),Noodl.SEO.setTitle(this._internal.currentPage.title);const r=i.nodeScope.getNodesWithType("PageInputs");void 0!==r&&r.length>0&&r.forEach((e=>{e._setPageParams(t.params)})),o.addChild(i),this.addChild(o),this._updateUrlWithTopPage(),t.hasNavigated&&t.hasNavigated(),y.u.instance.onNavigated(this._internal.name,e)},registerInputIfNeeded(e){this.hasInput(e)}}},st=Z(it),rt={name:"net.noodl.externallink",displayNodeName:"External Link",docs:"https://docs.noodl.net/nodes/navigation/external-link",category:"Navigation",nodeDoubleClickAction:{focusPort:"link"},inputs:{link:{type:"string",displayName:"Link"},openInNewTab:{type:"boolean",displayName:"Open In New Tab",default:!0},do:{type:"signal",displayName:"Do",valueChangedToTrue(){const e=this.getInputValue("openInNewTab"),t=e?"noopener,noreferrer":"",n=!0===e||void 0===e?"_blank":"_self";window.open(this.getInputValue("link"),n,t)}}}};function at(e,t,n,o){const i=(o-90)*Math.PI/180;return{x:e+n*Math.cos(i),y:t+n*Math.sin(i)}}function lt(e,t,n,o,i){i%360==o%360&&(i-=1e-4);const s=at(e,t,n,i),r=at(e,t,n,o),a=i-o<=180?"0":"1";return["M",s.x,s.y,"A",n,n,0,a,0,r.x,r.y,"L",e,t,"L",s.x,s.y].join(" ")}class dt extends n().Component{constructor(e){super(e)}render(){let e,t;const o=this.props.size/2,{startAngle:i,endAngle:s}=this.props;if(this.props.fillEnabled){const t=this.props.size/2;e=n().createElement("path",{d:lt(t,t,t,i,s),fill:this.props.fillColor})}if(this.props.strokeEnabled){const{strokeColor:e,strokeWidth:r,strokeLineCap:a}=this.props,l=function(e,t,n,o,i){i%360==o%360&&(i-=1e-4);const s=at(e,t,n,i),r=at(e,t,n,o),a=i-o<=180?"0":"1";return["M",s.x,s.y,"A",n,n,0,a,0,r.x,r.y].join(" ")}(o,o,o-this.props.strokeWidth/2,i,s);t=n().createElement("path",{d:l,stroke:e,strokeWidth:r,fill:"transparent",strokeLinecap:a})}const r={...this.props.style};return x.size(r,this.props),x.align(r,this.props),0===r.opacity&&(r.pointerEvents="none"),n().createElement("div",{className:this.props.className,...this.props.dom,...ne(this.props),style:r},n().createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:this.props.size,height:this.props.size},e,t))}}const ut={name:"Circle",docs:"https://docs.noodl.net/nodes/basic-elements/circle",connectionPanel:{groupPriority:["General","Fill","Stroke","Dimensions","Style","Actions","Events","Mounted","Margin and padding","Pointer Events","Hover Events"]},getReactComponent:()=>dt,noodlNodeAsProp:!0,allowChildren:!1,defaultCss:{flexShrink:0,position:"relative",display:"flex"},inputProps:{size:{displayName:"Size",default:"100",group:"Dimension",type:{name:"number"},index:10,allowVisualStates:!0},fillEnabled:{group:"Fill",displayName:"Fill",default:!0,type:"boolean",index:20,allowVisualStates:!0},fillColor:{group:"Fill",displayName:"Fill Color",default:"red",type:"color",index:21,allowVisualStates:!0},strokeEnabled:{index:23,group:"Stroke",default:!1,displayName:"Stroke",type:"boolean",allowVisualStates:!0},strokeWidth:{index:24,group:"Stroke",displayName:"Stroke Width",default:10,type:{name:"number"},allowVisualStates:!0},strokeColor:{index:25,group:"Stroke",displayName:"Stroke Color",type:"color",default:"black",allowVisualStates:!0},strokeLineCap:{index:26,group:"Stroke",displayName:"Line Cap",type:{name:"enum",enums:[{label:"Butt",value:"butt"},{label:"Round",value:"round"}]},default:"butt",allowVisualStates:!0},startAngle:{displayName:"Start Angle",type:"number",default:0,group:"Style",index:198,allowVisualStates:!0},endAngle:{displayName:"End Angle",type:"number",default:360,group:"Style",index:199,allowVisualStates:!0}},setup(e,t){F.addTransformInputs(ut),F.addMarginInputs(ut),F.addSharedVisualInputs(ut),F.addAlignInputs(ut),F.addPointerEventOutputs(ut)}},ct=Z(ut);var pt=__webpack_require__(5071);function ht(e,t,n,o){const i=mt(e,t,n,o),s=mt(i.layout,t,n,o);return i.totalFractions===s.totalFractions?i:ht(s.layout,t,n,o)}function mt(e,t,n,o){const i=100/e.reduce(((e,t)=>e+t),0),s=e.reduce(((e,s,r)=>({expected:e.expected+i/100*n*s,min:e.min+parseFloat(t)+o})),{expected:0,min:0,max:null}),r=e;s.expectede+t),0);return{layout:r,totalFractions:a,fractionSize:100/a,columnAmount:r.length}}function gt(e){if(!e.children)return null;let o=null;const i=(0,t.useRef)(null),[s,r]=(0,t.useState)(null);switch((0,t.useEffect)((()=>{const e=i.current;if(!e)return;const t=new ResizeObserver((()=>{const e=i.current;e&&r(e.offsetWidth)}));return t.observe(e),()=>{t.disconnect()}}),[]),typeof e.layoutString){case"string":o=e.layoutString.trim();break;case"number":o=String(e.layoutString).trim();break;default:o=null}if(!o)return n().createElement(n().Fragment,null,e.children);const a=o.split(" ").map((e=>parseInt(e))),{layout:l,columnAmount:d,fractionSize:u}=ht(a,e.minWidth,s||0,e.marginX);let c=[],p=null;return Array.isArray(e.children)?(c=e.children.filter((e=>n().isValidElement(e)&&e.type!==pt.node)),p=e.children.find((e=>n().isValidElement(e)&&e.type===pt.node))):e.children.type!==pt.node&&(c=[e.children]),n().createElement("div",{...e.attrs,className:["columns-container",e.className].join(" "),ref:i,style:{visibility:null===s?"hidden":"visible",marginTop:-1*parseFloat(e.marginY),marginLeft:-1*parseFloat(e.marginX),display:"flex",flexWrap:"wrap",alignItems:"stretch",justifyContent:e.justifyContent,flexDirection:e.direction,width:`calc(100% + (${parseFloat(e.marginX)}px)`,boxSizing:"border-box",...e.style}},p&&p,c.map(((t,o)=>n().isValidElement(t)?n().createElement("div",{className:"column-item",key:o,style:{boxSizing:"border-box",paddingTop:e.marginY,paddingLeft:e.marginX,width:l[o%d]*u+"%",flexShrink:0,flexGrow:0,minWidth:e.minWidth}},n().cloneElement(t)):null)))}const ft=Z({name:"net.noodl.visual.columns",displayName:"Columns",docs:"https://docs.noodl.net/nodes/basic-elements/columns",allowChildren:!0,noodlNodeAsProp:!0,connectionPanel:{groupPriority:["General","Style","Actions","Events","States","Mounted","Label","Label Text Style","Hover Events","Pointer Events","Focus Events"]},initialize(){this.props.attrs={},this.props.layoutString="1 2 1",this.props.minWidth=0,this.props.marginX=16,this.props.marginY=16,this.props.direction="row",this.props.justifyContent="flex-start"},getReactComponent:()=>gt,inputs:{layoutString:{group:"Layout Settings",displayName:"Layout String",type:"string",default:"1 2 1",set(e){this.props.layoutString=e,"string"!=typeof e?this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"layout-type-warning",{message:"Layout String needs to be a string."}):this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"layout-type-warning"),this.forceUpdate()}},testId:{index:100009,displayName:"Test ID Attribute",group:"Advanced HTML",type:"string",set(e){this.props.attrs["data-testid"]=e,this.forceUpdate()}}},inputProps:{marginX:{group:"Layout Settings",displayName:"Horizontal Gap",type:{name:"number",units:["px"],defaultUnit:"px"},default:16},marginY:{group:"Layout Settings",displayName:"Vertical Gap",type:{name:"number",units:["px"],defaultUnit:"px"},default:16},minWidth:{group:"Constraints",displayName:"Min Column Width",type:{name:"number",units:["px"],defaultUnit:"px"},default:0},direction:{group:"Layout Settings",displayName:"Layout Direction",type:{name:"enum",enums:[{label:"Horizontal",value:"row"},{label:"Vertical",value:"column"}]},default:"row"},justifyContent:{group:"Justify Content",displayName:"Justify Content",type:{name:"enum",enums:[{label:"Start",value:"flex-start"},{label:"End",value:"flex-end"},{label:"Center",value:"center"}],alignComp:"align-items"},default:"flex-start"}}});var yt=__webpack_require__(5900),vt=__webpack_require__.n(yt),bt=__webpack_require__(5794),_t=__webpack_require__.n(bt);function St(e,t){t.positionX&&t.positionX(e.x),t.positionY&&t.positionY(e.y),t.deltaX&&t.deltaX(e.deltaX),t.deltaY&&t.deltaY(e.deltaY)}class Ct extends n().Component{constructor(e){super(e),this.state={x:0,y:0}}snapToPosition({timerScheduler:e,propCallback:t,duration:n,axis:o,endValue:i}){const s=this;return e.createTimer({duration:void 0===n?300:n,startValue:this.state[o],endValue:i,ease:L.A.easeOut,onRunning:function(e){const n=this.ease(this.startValue,this.endValue,e);s.setState({[o]:n}),t&&t(n)}}).start()}componentDidMount(){const e=this.props.inputPositionX?this.props.inputPositionX:0,t=this.props.inputPositionY?this.props.inputPositionY:0;this.setState({x:e,y:t}),St({x:e,y:t,deltaX:0,deltaY:0},this.props)}UNSAFE_componentWillReceiveProps(e){const t=this.props;t.inputPositionX!==e.inputPositionX&&(this.setState({x:e.inputPositionX}),t.positionX&&t.positionX(e.inputPositionX),t.deltaX&&t.deltaX(e.inputPositionX-t.inputPositionX)),t.inputPositionY!==e.inputPositionY&&(this.setState({y:e.inputPositionY}),t.positionY&&t.positionY(e.inputPositionY),t.deltaY&&t.deltaY(e.inputPositionY-t.inputPositionY))}snapToPositionX(e,t){this.state.x!==e&&(this.snapToPositionXTimer&&this.snapToPositionXTimer.stop(),this.snapToPositionXTimer=this.snapToPosition({timerScheduler:this.props.noodlNode.context.timerScheduler,propCallback:this.props.positionX,duration:t,axis:"x",endValue:e}))}snapToPositionY(e,t){this.state.y!==e&&(this.snapToPositionYTimer&&this.snapToPositionYTimer.stop(),this.snapToPositionYTimer=this.snapToPosition({timerScheduler:this.props.noodlNode.context.timerScheduler,propCallback:this.props.positionY,duration:t,axis:"y",endValue:e}))}render(){const e=this.props,t=e.useParentBounds?"parent":void 0;let o;return n().Children.count(e.children)>0?(o=n().Children.toArray(e.children)[0],n().createElement(_t(),{axis:e.axis,bounds:t,disabled:!1===e.enabled,scale:e.scale||0,position:{x:this.state.x,y:this.state.y},onStart:(t,n)=>{St(n,e),e.onStart&&e.onStart(),this.snapToPositionXTimer&&this.snapToPositionXTimer.stop(),this.snapToPositionYTimer&&this.snapToPositionYTimer.stop()},onStop:(t,n)=>{"x"!==e.axis&&"both"!==e.axis||this.setState({x:n.x}),"y"!==e.axis&&"both"!==e.axis||this.setState({y:n.y}),e.positionX&&e.positionX(n.x),e.positionY&&e.positionY(n.y),e.onStop&&e.onStop()},onDrag:(t,n)=>{St(n,e),e.onDrag&&e.onDrag()}},n().cloneElement(o,{parentLayout:e.parentLayout}))):null}}const Nt=Z({name:"Drag",docs:"https://docs.noodl.net/nodes/utilities/drag",allowChildren:!0,noodlNodeAsProp:!0,getReactComponent:()=>Ct,initialize(){this._internal.snapPositionX=0,this._internal.snapPositionY=0,this._internal.snapDurationX=300,this._internal.snapDurationY=300},inputs:{"snapToPositionX.do":{group:"Snap To Position X",displayName:"Do",editorName:"Do|Snap To Position X",type:"signal",valueChangedToTrue(){this.scheduleAfterInputsHaveUpdated((()=>{const{snapPositionX:e,snapDurationX:t}=this._internal;this.innerReactComponentRef&&this.innerReactComponentRef.snapToPositionX(e,t)}))}},"snapToPositionX.value":{default:0,group:"Snap To Position X",displayName:"Value",editorName:"Value|Snap To Position X",type:"number",set(e){this._internal.snapPositionX=e}},"snapToPositionX.duration":{default:300,group:"Snap To Position X",displayName:"Duration",editorName:"Duration|Snap To Position X",type:"number",set(e){this._internal.snapDurationX=e}},"snapToPositionY.do":{group:"Snap To Position Y",displayName:"Do",editorName:"Do|Snap To Position Y",type:"signal",valueChangedToTrue(){this.scheduleAfterInputsHaveUpdated((()=>{const{snapPositionY:e,snapDurationY:t}=this._internal;this.innerReactComponentRef&&this.innerReactComponentRef.snapToPositionY(e,t)}))}},"snapToPositionY.value":{default:0,group:"Snap To Position Y",displayName:"Value",editorName:"Value|Snap To Position Y",type:"number",set(e){this._internal.snapPositionY=e}},"snapToPositionY.duration":{default:300,group:"Snap To Position Y",displayName:"Duration",editorName:"Duration|Snap To Position Y",type:"number",set(e){this._internal.snapDurationY=e}}},inputProps:{enabled:{group:"Drag",displayName:"Enabled",type:"boolean",default:!0},axis:{group:"Drag",displayName:"Axis",type:{name:"enum",enums:[{label:"X",value:"x"},{label:"Y",value:"y"},{label:"Both",value:"both"}]},default:"x"},useParentBounds:{group:"Drag",displayName:"Constrain to parent",type:"boolean",default:!0},inputPositionX:{displayName:"Start Drag X",type:{name:"number"}},inputPositionY:{displayName:"Start Drag Y",type:{name:"number"}},scale:{displayName:"Scale",default:1,type:{name:"number"}}},outputProps:{onStart:{group:"Signals",type:"signal",displayName:"Drag Started"},onStop:{group:"Signals",type:"signal",displayName:"Drag Ended"},onDrag:{group:"Signals",type:"signal",displayName:"Drag Moved"},positionX:{group:"Values",displayName:"Drag X",type:"number"},positionY:{group:"Values",displayName:"Drag Y",type:"number"},deltaX:{group:"Values",displayName:"Delta X",type:"number"},deltaY:{group:"Values",displayName:"Delta Y",type:"number"}}});var Ot=function(e,t){return Ot=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Ot(e,t)};function It(e,t){function n(){this.constructor=e}Ot(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var wt=function(){return wt=Object.assign||function(e){for(var t,n=1,o=arguments.length;n0,Rt=function(){if("string"==typeof At){var e=/os (\d\d?_\d(_\d)?)/.exec(At);if(!e)return!1;var t=e[1].split("_").map((function(e){return parseInt(e,10)}));return!!(13===t[0]&&t[1]>=4)}return!1}(),Mt=!1;if(Tt)try{var Vt={};Object.defineProperty(Vt,"passive",{get:function(){Mt=!0}}),window.addEventListener("test-passive",(function(){}),Vt)}catch(e){}function jt(){return window.performance&&window.performance.now&&window.performance.timing?window.performance.now()+window.performance.timing.navigationStart:+new Date}var Ft=function(e,t){for(var n in t)e[n]=t[n];return e};function Ut(e){return null==e}function Wt(e,t,n){return en?n:e}var Lt=Tt&&document.createElement("div").style,Bt=function(){if(!Tt)return!1;for(var e=0,t=[{key:"standard",value:"transform"},{key:"webkit",value:"webkitTransform"},{key:"Moz",value:"MozTransform"},{key:"O",value:"OTransform"},{key:"ms",value:"msTransform"}];edocument.documentElement.clientWidth-l||a>document.documentElement.clientHeight-l||r0?-1:n<0?1:0},s=i(t.x,e.x),r=i(t.y,e.y),a=n.x-o.x,l=n.y-o.y;return s*a<=0&&r*l<=0})(e,t,s,o)&&n.hooks.trigger(n.hooks.eventTypes.move,s),n.pending||(n.callStopWhenPending?n.callStopWhenPending=!1:n.hooks.trigger(n.hooks.eventTypes.end,s)),o=s,n.pending&&(n.timer=gn(i))};this.callStopWhenPending&&this.setCallStop(!1),fn(this.timer),i()},t.prototype.transitionTime=function(e){void 0===e&&(e=0),this.style[en.transitionDuration]=e+"ms",this.hooks.trigger(this.hooks.eventTypes.time,e)},t.prototype.transitionTimingFunction=function(e){this.style[en.transitionTimingFunction]=e,this.hooks.trigger(this.hooks.eventTypes.timeFunction,e)},t.prototype.transitionProperty=function(){this.style[en.transitionProperty]=en.transform},t.prototype.move=function(e,t,n,o){this.setPending(n>0),this.transitionTimingFunction(o),this.transitionProperty(),this.transitionTime(n),this.translate(t);var i=3===this.options.probeType;n&&i&&this.startProbe(e,t),n||(this._reflow=this.content.offsetHeight,i&&this.hooks.trigger(this.hooks.eventTypes.move,t),this.hooks.trigger(this.hooks.eventTypes.end,t))},t.prototype.doStop=function(){var e=this.pending;if(this.setForceStopped(!1),this.setCallStop(!1),e){this.setPending(!1),fn(this.timer);var t=this.translater.getComputedPosition(),n=t.x,o=t.y;this.transitionTime(),this.translate({x:n,y:o}),this.setForceStopped(!0),this.setCallStop(!0),this.hooks.trigger(this.hooks.eventTypes.forceStop,{x:n,y:o})}return e},t.prototype.stop=function(){this.doStop()&&this.hooks.trigger(this.hooks.eventTypes.callStop)},t}(In),Pn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return It(t,e),t.prototype.move=function(e,t,n,o){if(!n)return this.translate(t),3===this.options.probeType&&this.hooks.trigger(this.hooks.eventTypes.move,t),void this.hooks.trigger(this.hooks.eventTypes.end,t);this.animate(e,t,n,o)},t.prototype.animate=function(e,t,n,o){var i=this,s=jt(),r=s+n,a=3===this.options.probeType,l=function(){var d=jt();if(d>=r)return i.translate(t),a&&i.hooks.trigger(i.hooks.eventTypes.move,t),void i.hooks.trigger(i.hooks.eventTypes.end,t);var u=o(d=(d-s)/n),c={};Object.keys(t).forEach((function(n){var o=e[n],i=t[n];c[n]=(i-o)*u+o})),i.translate(c),a&&i.hooks.trigger(i.hooks.eventTypes.move,c),i.pending&&(i.timer=gn(l)),i.pending||(i.callStopWhenPending?i.callStopWhenPending=!1:i.hooks.trigger(i.hooks.eventTypes.end,t))};this.setPending(!0),this.callStopWhenPending&&this.setCallStop(!1),fn(this.timer),l()},t.prototype.doStop=function(){var e=this.pending;if(this.setForceStopped(!1),this.setCallStop(!1),e){this.setPending(!1),fn(this.timer);var t=this.translater.getComputedPosition();this.setForceStopped(!0),this.setCallStop(!0),this.hooks.trigger(this.hooks.eventTypes.forceStop,t)}return e},t.prototype.stop=function(){this.doStop()&&this.hooks.trigger(this.hooks.eventTypes.callStop)},t}(In),xn=function(){function e(e,t,n){this.wrapper=e,this.options=n,this.hooks=new bn(["beforeComputeBoundary","computeBoundary","momentum","end","ignoreHasScroll"]),this.refresh(t)}return e.prototype.start=function(){this.dist=0,this.setMovingDirection(0),this.setDirection(0)},e.prototype.move=function(e){return e=this.hasScroll?e:0,this.setMovingDirection(e),this.performDampingAlgorithm(e,this.options.outOfBoundaryDampingFactor)},e.prototype.setMovingDirection=function(e){this.movingDirection=e>0?-1:e<0?1:0},e.prototype.setDirection=function(e){this.direction=e>0?-1:e<0?1:0},e.prototype.performDampingAlgorithm=function(e,t){var n=this.currentPos+e;return(n>this.minScrollPos||nthis.minScrollPos&&this.options.bounces[0]||nthis.minScrollPos?this.minScrollPos:this.maxScrollPos),n},e.prototype.end=function(e){var t={duration:0},n=Math.abs(this.currentPos-this.startPos);if(this.options.momentum&&ethis.options.momentumLimitDistance){var o=-1===this.direction&&this.options.bounces[0]||1===this.direction&&this.options.bounces[1]?this.wrapperSize:0;t=this.hasScroll?this.momentum(this.currentPos,this.startPos,e,this.maxScrollPos,this.minScrollPos,o,this.options):{destination:this.currentPos,duration:0}}else this.hooks.trigger(this.hooks.eventTypes.end,t);return t},e.prototype.momentum=function(e,t,n,o,i,s,r){void 0===r&&(r=this.options);var a=e-t,l=Math.abs(a)/n,d=r.deceleration,u=r.swipeBounceTime,c=r.swipeTime,p={destination:e+l*l/d*(a<0?-1:1),duration:Math.min(c,2*l/d),rate:15};return this.hooks.trigger(this.hooks.eventTypes.momentum,p,a),p.destinationi&&(p.destination=s?Math.min(i+s/4,i+s/p.rate*l):i,p.duration=u),p.destination=Math.round(p.destination),p},e.prototype.updateDirection=function(){var e=this.currentPos-this.absStartPos;this.setDirection(e)},e.prototype.refresh=function(e){var t=this.options.rect,n=t.size,o=t.position,i="static"===window.getComputedStyle(this.wrapper,null).position,s=nn(this.wrapper);this.wrapperSize=this.wrapper["width"===n?"clientWidth":"clientHeight"],this.setContent(e);var r=nn(this.content);this.contentSize=r[n],this.relativeOffset=r[o],i&&(this.relativeOffset-=s[o]),this.computeBoundary(),this.setDirection(0)},e.prototype.setContent=function(e){e!==this.content&&(this.content=e,this.resetState())},e.prototype.resetState=function(){this.currentPos=0,this.startPos=0,this.dist=0,this.setDirection(0),this.setMovingDirection(0),this.resetStartPos()},e.prototype.computeBoundary=function(){this.hooks.trigger(this.hooks.eventTypes.beforeComputeBoundary);var e={minScrollPos:0,maxScrollPos:this.wrapperSize-this.contentSize};e.maxScrollPos<0&&(e.maxScrollPos-=this.relativeOffset,0===this.options.specifiedIndexAsContent&&(e.minScrollPos=-this.relativeOffset)),this.hooks.trigger(this.hooks.eventTypes.computeBoundary,e),this.minScrollPos=e.minScrollPos,this.maxScrollPos=e.maxScrollPos,this.hasScroll=this.options.scrollable&&this.maxScrollPosthis.minScrollPos?e=this.minScrollPos:et+this.directionLockThreshold?this.directionLocked="horizontal":t>=e+this.directionLockThreshold?this.directionLocked="vertical":this.directionLocked="none")},e.prototype.handleEventPassthrough=function(e){var t=Tn[this.directionLocked];if(t){if(this.eventPassthrough===t.yes)return En.yes(e);if(this.eventPassthrough===t.no)return En.no(e)}return!1},e}(),kn=function(){function e(e,t,n,o,i){this.hooks=new bn(["start","beforeMove","scrollStart","scroll","beforeEnd","end","scrollEnd","contentNotMoved","detectMovingDirection","coordinateTransformation"]),this.scrollBehaviorX=e,this.scrollBehaviorY=t,this.actionsHandler=n,this.animater=o,this.options=i,this.directionLockAction=new An(i.directionLockThreshold,i.freeScroll,i.eventPassthrough),this.enabled=!0,this.bindActionsHandler()}return e.prototype.bindActionsHandler=function(){var e=this;this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.start,(function(t){return!e.enabled||e.handleStart(t)})),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.move,(function(t){var n=t.deltaX,o=t.deltaY,i=t.e;if(!e.enabled)return!0;var s=function(e,t,n){return 2===n?[t,-e]:3===n?[-e,-t]:4===n?[-t,e]:[e,t]}(n,o,e.options.quadrant),r={deltaX:s[0],deltaY:s[1]};return e.hooks.trigger(e.hooks.eventTypes.coordinateTransformation,r),e.handleMove(r.deltaX,r.deltaY,i)})),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.end,(function(t){return!e.enabled||e.handleEnd(t)})),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.click,(function(t){e.enabled&&!t._constructed&&e.handleClick(t)}))},e.prototype.handleStart=function(e){var t=jt();this.fingerMoved=!1,this.contentMoved=!1,this.startTime=t,this.directionLockAction.reset(),this.scrollBehaviorX.start(),this.scrollBehaviorY.start(),this.animater.doStop(),this.scrollBehaviorX.resetStartPos(),this.scrollBehaviorY.resetStartPos(),this.hooks.trigger(this.hooks.eventTypes.start,e)},e.prototype.handleMove=function(e,t,n){if(!this.hooks.trigger(this.hooks.eventTypes.beforeMove,n)){var o=this.scrollBehaviorX.getAbsDist(e),i=this.scrollBehaviorY.getAbsDist(t),s=jt();if(this.checkMomentum(o,i,s))return!0;if(this.directionLockAction.checkMovingDirection(o,i,n))return this.actionsHandler.setInitiated(),!0;var r=this.directionLockAction.adjustDelta(e,t),a=this.scrollBehaviorX.getCurrentPos(),l=this.scrollBehaviorX.move(r.deltaX),d=this.scrollBehaviorY.getCurrentPos(),u=this.scrollBehaviorY.move(r.deltaY);if(!this.hooks.trigger(this.hooks.eventTypes.detectMovingDirection)){this.fingerMoved||(this.fingerMoved=!0);var c=l!==a||u!==d;this.contentMoved||c||this.hooks.trigger(this.hooks.eventTypes.contentNotMoved),!this.contentMoved&&c&&(this.contentMoved=!0,this.hooks.trigger(this.hooks.eventTypes.scrollStart)),this.contentMoved&&c&&(this.animater.translate({x:l,y:u}),this.dispatchScroll(s))}}},e.prototype.dispatchScroll=function(e){e-this.startTime>this.options.momentumLimitTime&&(this.startTime=e,this.scrollBehaviorX.updateStartPos(),this.scrollBehaviorY.updateStartPos(),1===this.options.probeType&&this.hooks.trigger(this.hooks.eventTypes.scroll,this.getCurrentPos())),this.options.probeType>1&&this.hooks.trigger(this.hooks.eventTypes.scroll,this.getCurrentPos())},e.prototype.checkMomentum=function(e,t,n){return n-this.endTime>this.options.momentumLimitTime&&t0?Math.ceil(t):Math.floor(t),n=n>0?Math.ceil(n):Math.floor(n),{x:t=Wt(t,s,i),y:n=Wt(n,l,a)}},e.prototype.handleClick=function(e){on(e.target,this.options.preventDefaultException)||(Gt(e),e.stopPropagation())},e.prototype.getCurrentPos=function(){return{x:this.scrollBehaviorX.getCurrentPos(),y:this.scrollBehaviorY.getCurrentPos()}},e.prototype.refresh=function(){this.endTime=0},e.prototype.destroy=function(){this.hooks.destroy()},e}();function Dn(e,t,n,o){var i=["momentum","momentumLimitTime","momentumLimitDistance","deceleration","swipeBounceTime","swipeTime","outOfBoundaryDampingFactor","specifiedIndexAsContent"].reduce((function(t,n){return t[n]=e[n],t}),{});return i.scrollable=!!e[t],i.bounces=n,i.rect=o,i}function Rn(e,t,n){n.forEach((function(n){var o,i;"string"==typeof n?o=i=n:(o=n.source,i=n.target),e.on(o,(function(){for(var e=[],n=0;n1&&e1||t>1))return!0},e.prototype.momentum=function(e,t){var n={time:0,easing:an.swiper,newX:e.x,newY:e.y},o=this.scrollBehaviorX.end(t),i=this.scrollBehaviorY.end(t);if(n.newX=Ut(o.destination)?n.newX:o.destination,n.newY=Ut(i.destination)?n.newY:i.destination,n.time=Math.max(o.duration,i.duration),this.hooks.trigger(this.hooks.eventTypes.momentum,n,this),n.newX!==e.x||n.newY!==e.y)return(n.newX>this.scrollBehaviorX.minScrollPos||n.newXthis.scrollBehaviorY.minScrollPos||n.newYMath.abs(o)&&(o=i),i=0),this.scroll.hasHorizontalScroll||(o=0),{x:o,y:i,directionX:o>0?-1:o<0?1:0,directionY:i>0?-1:i<0?1:0}},e.prototype.beforeHandler=function(e){var t=this.scroll.options,n=t.preventDefault,o=t.stopPropagation,i=t.preventDefaultException;n&&!function(e,t){for(var n in t)if(t[n].test(e[n]))return!0;return!1}(e.target,i)&&function(e){e.cancelable&&e.preventDefault()}(e),o&&e.stopPropagation()},e.prototype.getEaseTime=function(){var e=this.mouseWheelOpt.easeTime;return e<100&&console.error("[BScroll warn]: easeTime should be greater than 100.If mouseWheel easeTime is too small,scrollEnd will be triggered many times."),Math.max(e,100)},e.prototype.destroy=function(){this.eventRegister.destroy(),window.clearTimeout(this.wheelEndTimer),window.clearTimeout(this.wheelMoveTimer),this.hooksFn.forEach((function(e){var t=e[0],n=e[1],o=e[2];t.off(n,o)}))},e.pluginName="mouseWheel",e.applyOrder="pre",e}(),Jn=function(){return Jn=Object.assign||function(e){for(var t,n=1,o=arguments.length;nn?n:e}var oo=Kn&&document.createElement("div").style,io=function(){if(!Kn)return!1;for(var e=0,t=[{key:"standard",value:"transform"},{key:"webkit",value:"webkitTransform"},{key:"Moz",value:"MozTransform"},{key:"O",value:"OTransform"},{key:"ms",value:"msTransform"}];er?d=r+s-(n=Math.max(s-3*(d-r),l)):n=s,{pos:d,size:n}},e.prototype.refreshStyle=function(e,t){var n=this.keysMap,o=n.translateProperty,i=n.size,s=this.scroll.options.translateZ;this.indicatorEl.style[i]=e+"px",this.indicatorEl.style[co]=o+"("+t+"px)"+s},e.prototype.startHandler=function(){this.moved=!1,this.startTime=to(),this.transitionTime(),this.scroll.scroller.hooks.trigger(this.scroll.scroller.hooks.eventTypes.beforeScrollStart)},e.prototype.moveHandler=function(e){if(this.moved||this.indicatorNotMoved(e)||(this.moved=!0,this.scroll.scroller.hooks.trigger(this.scroll.scroller.hooks.eventTypes.scrollStart)),this.moved){var t=this.newPos(this.currentPos,e,this.scrollInfo);this.syncBScroll(t)}},e.prototype.endHandler=function(){if(this.moved){var e=this.scroll,t=e.x,n=e.y;this.scroll.scroller.hooks.trigger(this.scroll.scroller.hooks.eventTypes.scrollEnd,{x:t,y:n})}},e.prototype.indicatorNotMoved=function(e){var t=this.currentPos,n=this.scrollInfo,o=n.maxScrollPos;return t===n.minScrollPos&&e<=0||t===o&&e>=0},e.prototype.syncBScroll=function(e){var t=to(),n=this.scroll,o=n.x,i=n.y,s=n.options,r=n.scroller,a=n.maxScrollY,l=n.minScrollY,d=n.maxScrollX,u=n.minScrollX,c=s.probeType,p=s.momentumLimitTime,h={x:o,y:i};"vertical"===this.direction?h.y=no(e,a,l):h.x=no(e,d,u),r.translater.translate(h),t-this.startTime>p&&(this.startTime=t,1===c&&r.hooks.trigger(r.hooks.eventTypes.scroll,h)),c>1&&r.hooks.trigger(r.hooks.eventTypes.scroll,h)},e.prototype.newPos=function(e,t,n){var o=n.maxScrollPos,i=n.sizeRatio,s=e+t;return s=no(s,n.minScrollPos,o),Math.round(s/i)},e.prototype.destroy=function(){var e=this.options,t=e.interactive,n=e.scrollbarTrackClickable,o=e.isCustom;t&&this.eventHandler.destroy(),n&&this.clickEventRegister.destroy(),o||this.wrapper.parentNode.removeChild(this.wrapper),this.hooksFn.forEach((function(e){var t=e[0],n=e[1],o=e[2];t.off(n,o)})),this.hooksFn.length=0},e}(),vo=function(){function e(e){this.scroll=e,this.handleOptions(),this.createIndicators(),this.handleHooks()}return e.prototype.handleHooks=function(){var e=this,t=this.scroll;t.hooks.on(t.hooks.eventTypes.destroy,(function(){for(var t=0,n=e.indicators;t=e.minScrollX&&-1===a.movingDirection,u=e.x<=e.maxScrollX&&1===a.movingDirection,c=e.y>=e.minScrollY&&-1===l.movingDirection,p=e.y<=e.maxScrollY&&1===l.movingDirection,(s?c||p:i&&(d||u))&&(n.disable(),t.enable())})))}};function _o(e,t){for(var n=0,o=e.parentNode;o&&o!==t;)n++,o=o.parentNode;return n}function So(e){return{hasHorizontalScroll:e.scroller.scrollBehaviorX.hasScroll,hasVerticalScroll:e.scroller.scrollBehaviorY.hasScroll}}const Co=function(){function e(t){var n=e.nestedScroll;return n instanceof e||((n=e.nestedScroll=this).stores=[]),n.setup(t),n.addHooks(t),n}return e.prototype.setup=function(e){this.appendBScroll(e),this.handleContainRelationship(),this.handleCompatible()},e.prototype.addHooks=function(e){var t=this;e.on("destroy",(function(){t.teardown(e)}))},e.prototype.teardown=function(e){this.removeBScroll(e),this.handleContainRelationship(),this.handleCompatible()},e.prototype.appendBScroll=function(e){this.stores.push(e)},e.prototype.removeBScroll=function(e){var t=this.stores.indexOf(e);-1!==t&&(e.wrapper.isBScrollContainer=void 0,this.stores.splice(t,1))},e.prototype.handleContainRelationship=function(){var e=this.stores;if(e.length<=1)e[0]&&e[0].__parentInfo&&(e[0].__parentInfo=void 0);else for(var t,n,o,i,s=0;sa&&(t.__parentInfo={parent:o,depth:a})}else t.__parentInfo={parent:o,depth:_o(n,i)}}},e.prototype.handleCompatible=function(){var e=this.availableBScrolls(),t=["duplicateClick","nestedScroll"];e.forEach((function(e){t.forEach((function(t){bo[t](e)}))}))},e.prototype.availableBScrolls=function(){return this.stores.filter((function(e){return!!e.__parentInfo})).map((function(e){return[e.__parentInfo.parent,e]}))},e.pluginName="nestedScroll",e}();var No=__webpack_require__(7685),Oo=__webpack_require__.n(No),Io="undefined"!=typeof window,wo=Io&&navigator.userAgent.toLowerCase();function Po(e,t,n){return en?n:e}wo&&/wechatdevtools/.test(wo),wo&&wo.indexOf("android");var xo=Io&&document.createElement("div").style,Eo=function(){if(!Io)return!1;var e={webkit:"webkitTransform",Moz:"MozTransform",O:"OTransform",ms:"msTransform",standard:"transform"};for(var t in e)if(void 0!==xo[e[t]])return t;return!1}();function To(e){return!1===Eo?e:"standard"===Eo?"transitionEnd"===e?"transitionend":e:Eo+e.charAt(0).toUpperCase()+e.substr(1)}function Ao(e){if(e instanceof window.SVGElement){var t=e.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}}return{top:e.offsetTop,left:e.offsetLeft,width:e.offsetWidth,height:e.offsetHeight}}function ko(e,t){e.removeChild(t)}Eo&&"standard"!==Eo&&Eo.toLowerCase(),To("transform"),To("transition"),Io&&To("perspective"),To("transitionTimingFunction"),To("transitionDuration"),To("transitionDelay"),To("transformOrigin"),To("transitionEnd");var Do={swipe:{style:"cubic-bezier(0.23, 1, 0.32, 1)",fn:function(e){return 1+--e*e*e*e*e}},swipeBounce:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(e){return e*(2-e)}},bounce:{style:"cubic-bezier(0.165, 0.84, 0.44, 1)",fn:function(e){return 1- --e*e*e*e}}},Ro=Io&&window;Io&&(Ro.requestAnimationFrame||Ro.webkitRequestAnimationFrame||Ro.mozRequestAnimationFrame||Ro.oRequestAnimationFrame),Io&&(Ro.cancelAnimationFrame||Ro.webkitCancelAnimationFrame||Ro.mozCancelAnimationFrame||Ro.oCancelAnimationFrame);var Mo=function(){function e(e,t){this.scroll=e,this.slideOpt=t,this.slideEl=null,this.init()}return e.prototype.init=function(){var e=this.scroll.scroller,t=e.scrollBehaviorX,n=e.scrollBehaviorY,o=Ao(e.wrapper),i=Ao(e.content);this.wrapperWidth=o.width,this.wrapperHeight=o.height,this.scrollerHeight=n.hasScroll?i.height:o.height,this.scrollerWidth=t.hasScroll?i.width:o.width;var s=this.slideOpt.stepX||this.wrapperWidth,r=this.slideOpt.stepY||this.wrapperHeight,a=e.content,l=this.slideOpt.el;"string"==typeof l&&(this.slideEl=a.querySelectorAll(l)),this.pages=this.slideEl?this.computePagePosInfoByEl(this.slideEl):this.computePagePosInfo(s,r),this.xLen=this.pages?this.pages.length:0,this.yLen=this.pages&&this.pages[0]?this.pages[0].length:0},e.prototype.hasInfo=function(){return!(!this.pages||!this.pages.length)},e.prototype.getPos=function(e,t){return this.pages[e]?this.pages[e][t]:null},e.prototype.getNearestPage=function(e,t){if(this.hasInfo()){for(var n=0,o=0,i=this.pages.length;n=this.pages[n][0].cx);n++);for(i=this.pages[n].length;o=this.pages[0][o].cy);o++);return{pageX:n,pageY:o}}},e.prototype.computePagePosInfo=function(e,t){var n,o,i,s,r=[],a=0,l=0,d=this.scroll.scroller.scrollBehaviorX.maxScrollPos,u=this.scroll.scroller.scrollBehaviorY.maxScrollPos;for(o=Math.round(e/2),i=Math.round(t/2);a>-this.scrollerWidth;){for(r[l]=[],s=0,n=0;n>-this.scrollerHeight;)r[l][s]={x:Math.max(a,d),y:Math.max(n,u),width:e,height:t,cx:a-o,cy:n-i},n-=t,s++;a-=e,l++}return r},e.prototype.computePagePosInfoByEl=function(e){for(var t,n,o,i=[],s=0,r=0,a=0,l=e.length,d=0,u=-1,c=this.scroll.scroller.scrollBehaviorX.maxScrollPos,p=this.scroll.scroller.scrollBehaviorY.maxScrollPos;ac&&d++;return i},e}(),Vo=function(){function e(e,t){this.scroll=e,this.slideOpt=t}return e.prototype.init=function(){this.currentPage={x:0,y:0,pageX:0,pageY:0},this.pagesPos=new Mo(this.scroll,this.slideOpt),this.checkSlideLoop()},e.prototype.changeCurrentPage=function(e){this.currentPage=e},e.prototype.change2safePage=function(e,t){if(this.pagesPos.hasInfo()){e>=this.pagesPos.xLen?e=this.pagesPos.xLen-1:e<0&&(e=0),t>=this.pagesPos.yLen?t=this.pagesPos.yLen-1:t<0&&(t=0);var n=this.pagesPos.getPos(e,t);return{pageX:e,pageY:t,x:n?n.x:0,y:n?n.y:0}}},e.prototype.getInitPage=function(){return{pageX:this.loopX?1:0,pageY:this.loopY?1:0}},e.prototype.getRealPage=function(e){var t=function(e,t){for(var n=[],o=0;o1&&(this.slideX=!0),this.pagesPos.pages[0]&&this.pagesPos.yLen>1&&(this.slideY=!0),this.loopX=this.needLoop&&this.slideX,this.loopY=this.needLoop&&this.slideY,this.slideX&&this.slideY&&console.error("[BScroll warn]: slide does not support two direction at the same time.")},e}(),jo=[{key:"next",name:"next"},{key:"prev",name:"prev"},{key:"goToPage",name:"goToPage"},{key:"getCurrentPage",name:"getCurrentPage"}].map((function(e){return{key:e.key,sourceKey:"plugins.slide."+e.name}}));const Fo=function(){function e(e){this.scroll=e,this.resetLooping=!1,this.isTouching=!1,this.scroll.proxy(jo),this.scroll.registerType(["slideWillChange"]),this.slideOpt=this.scroll.options.slide,this.page=new Vo(e,this.slideOpt),this.hooksFn=[],this.willChangeToPage={pageX:0,pageY:0},this.init()}return e.prototype.init=function(){var e=this,t=this.slideOpt,n=this.scroll.scroller.content,o=!1;t.loop&&(n.children.length>1?(this.cloneSlideEleForLoop(n),o=!0):t.loop=!1);var i=this.setSlideWidth(n),s=this.setSlideHeight(this.scroll.scroller.wrapper,n),r=i||s,a=this.scroll.hooks,l=this.scroll.scroller.hooks;this.registorHooks(a,"refresh",this.initSlideState),this.registorHooks(a,"destroy",this.destroy),this.registorHooks(l,"momentum",this.modifyScrollMetaHandler),this.registorHooks(this.scroll,"scrollEnd",this.amendCurrentPage),this.registorHooks(l,"beforeStart",this.setTouchFlag),this.registorHooks(l,"scroll",this.scrollMoving),this.registorHooks(l,"resize",this.resize),this.scroll.eventTypes.mousewheelMove&&this.scroll.eventTypes.mousewheelEnd&&(this.registorHooks(this.scroll,"mousewheelMove",(function(){return!0})),this.registorHooks(this.scroll,"mousewheelEnd",(function(t){1!==t.directionX&&1!==t.directionY||e.next(),-1!==t.directionX&&-1!==t.directionY||e.prev()}))),!1!==t.listenFlick&&this.registorHooks(l,"flick",this.flickHandler),o||r?this.scroll.refresh():this.initSlideState()},e.prototype.resize=function(){var e=this,t=this.scroll.scroller.content,n=this.scroll.scroller.wrapper;return clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout((function(){e.clearSlideWidth(t),e.clearSlideHeight(t),e.setSlideWidth(t),e.setSlideHeight(n,t),e.scroll.refresh()}),this.scroll.options.resizePolling),!0},e.prototype.next=function(e,t){var n=this.page.nextPage(),o=n.pageX,i=n.pageY;this.goTo(o,i,e,t)},e.prototype.prev=function(e,t){var n=this.page.prevPage(),o=n.pageX,i=n.pageY;this.goTo(o,i,e,t)},e.prototype.goToPage=function(e,t,n,o){var i=this.page.realPage2Page(e,t);i&&this.goTo(i.realX,i.realY,n,o)},e.prototype.getCurrentPage=function(){return this.page.getRealPage()},e.prototype.nearestPage=function(e,t){var n=this.scroll.scroller.scrollBehaviorX,o=this.scroll.scroller.scrollBehaviorY,i=!0;return Math.abs(e-n.absStartPos)<=this.thresholdX&&Math.abs(t-o.absStartPos)<=this.thresholdY&&(i=!1),i?this.page.nearestPage(Po(e,n.maxScrollPos,n.minScrollPos),Po(t,o.maxScrollPos,o.minScrollPos),n.direction,o.direction):this.page.currentPage},e.prototype.destroy=function(){var e=this.scroll.scroller.content;if(this.slideOpt.loop){var t=e.children;t.length>2&&(ko(e,t[t.length-1]),ko(e,t[0]))}this.hooksFn.forEach((function(e){var t=e[0],n=e[1],o=e[2];t.eventTypes[n]&&t.off(n,o)})),this.hooksFn.length=0},e.prototype.initSlideState=function(){const e=this.page.currentPage;if(this.page.init(),e)this.page.currentPage=e;else{var t=this.page.getInitPage();this.goTo(t.pageX,t.pageY,0)}this.initThreshold()},e.prototype.initThreshold=function(){var e=this.slideOpt.threshold||.1;if(e%1==0)this.thresholdX=e,this.thresholdY=e;else{var t=this.page.getPageSize();t&&(this.thresholdX=Math.round(t.width*e),this.thresholdY=Math.round(t.height*e))}},e.prototype.cloneSlideEleForLoop=function(e){var t,n,o,i=e.children;t=i[i.length-1].cloneNode(!0),(o=(n=e).firstChild)?function(e,t){t.parentNode.insertBefore(e,t)}(t,o):n.appendChild(t),e.appendChild(i[1].cloneNode(!0))},e.prototype.amendCurrentPage=function(){if(this.isTouching=!1,this.slideOpt.loop)if(this.resetLooping)this.resetLooping=!1;else{var e=!1;if(!this.page.loopX||this.scroll.x!==this.scroll.scroller.scrollBehaviorX.minScrollPos&&this.scroll.x!==this.scroll.scroller.scrollBehaviorX.maxScrollPos||(e=!0),!this.page.loopY||this.scroll.y!==this.scroll.scroller.scrollBehaviorY.minScrollPos&&this.scroll.y!==this.scroll.scroller.scrollBehaviorY.maxScrollPos||(e=!0),e){var t=this.scroll.scroller.scrollBehaviorX,n=this.scroll.scroller.scrollBehaviorY,o=this.page.nearestPage(Po(this.scroll.x,t.maxScrollPos,t.minScrollPos),Po(this.scroll.y,n.maxScrollPos,n.minScrollPos),0,0),i={x:o.x,y:o.y,pageX:o.pageX,pageY:o.pageY};this.page.isSameWithCurrent(i)||this.page.changeCurrentPage(i)}var s=this.page.resetLoopPage();if(s)return this.resetLooping=!0,this.goTo(s.pageX,s.pageY,0),!0;this.pageWillChangeTo(this.page.currentPage)}},e.prototype.shouldSetWidthHeight=function(e){var t={width:["scrollX","disableSetWidth"],height:["scrollY","disableSetHeight"]}[e];return!!this.scroll.options[t[0]]&&!this.slideOpt[t[1]]},e.prototype.clearSlideWidth=function(e){if(this.shouldSetWidthHeight("width")){for(var t=e.children,n=0;n{this.iScroll&&this.iScroll.refresh()}),0)}scrollToIndex(e,t){var n,o;if(this.iScroll){const o=null===(n=this.scrollRef.current)||void 0===n?void 0:n.children[0].children[e];o&&this.iScroll.scrollToElement(o,t,0,0)}else{const t=null===(o=this.scrollRef.current)||void 0===o?void 0:o.children[e];t&&t.scrollIntoView({behavior:"smooth"})}}scrollToElement(e,t){if(!e)return;const n=i().findDOMNode(e.getRef());n&&n.scrollIntoView&&(this.iScroll?this.iScroll.scrollToElement(n,t,0,0):n.scrollIntoView({behavior:"smooth"}))}setupIScroll(){const{scrollSnapEnabled:e}=this.props,t=this.getScrollDirection(),n={disableSetWidth:!0,disableSetHeight:!0,loop:!1},o=this.scrollRef.current;this.iScroll=new Fn(o,{bounceTime:500,swipeBounceTime:300,scrollbar:this.props.showScrollbar?{}:void 0,momentum:!e||!this.props.scrollSnapToEveryItem,bounce:this.props.scrollBounceEnabled&&!(e&&n.loop),scrollX:"x"===t||"both"===t,scrollY:"y"===t||"both"===t,slide:e?n:void 0,probeType:this.props.onScrollPositionChanged?3:1,click:!0,nestedScroll:!0,useTransition:!1});const i=this.iScroll.scroller;i.scrollBehaviorX&&(i.scrollBehaviorX.momentum=Oo().bind(i.scrollBehaviorX)),i.scrollBehaviorY&&(i.scrollBehaviorY.momentum=Oo().bind(i.scrollBehaviorY)),this.iScroll.on("beforeScrollStart",(()=>{this.iScroll.refresh()})),this.iScroll.on("scrollStart",(()=>{this.props.onScrollStart&&this.props.onScrollStart()})),this.iScroll.on("scrollEnd",(()=>{this.props.onScrollEnd&&this.props.onScrollEnd()})),this.props.onScrollPositionChanged&&this.iScroll.on("scroll",(()=>{this.props.onScrollPositionChanged("x"===t?-this.iScroll.x:-this.iScroll.y)}))}UNSAFE_componentWillReceiveProps(e){(this.props.scrollSnapEnabled!==e.scrollSnapEnabled||this.props.onScrollPositionChanged!==e.onScrollPositionChanged||this.props.onScrollStart!==e.onScrollStart||this.props.onScrollEnd!==e.onScrollEnd||this.props.showScrollbar!==e.showScrollbar||this.props.scrollEnabled!==e.scrollEnabled||this.props.nativeScroll!==e.nativeScroll||this.props.scrollSnapToEveryItem!==e.scrollSnapToEveryItem||this.props.layout!==e.layout||this.props.flexWrap!==e.flexWrap||this.props.scrollBounceEnabled!==e.scrollBounceEnabled)&&(this.iScroll&&(this.iScroll.destroy(),this.iScroll=void 0),this.scrollNeedsToInit=e.scrollEnabled&&!e.nativeScroll)}renderIScroll(){const{flexDirection:e,flexWrap:t}=this.props.style,o={display:"inline-flex",flexShrink:0,flexDirection:e,flexWrap:t,touchAction:"none"};return"row"===e?"wrap"===t?o.width="100%":o.height="100%":"wrap"===t?o.height="100%":o.width="100%",n().createElement("div",{className:"scroll-wrapper-internal",style:o},this.props.children)}getScrollDirection(){return"wrap"===this.props.flexWrap||"wrap-reverse"===this.props.flexWrap?"row"===this.props.layout?"y":"x":"row"===this.props.layout?"x":"y"}render(){const{as:e="div",...t}=this.props,o=t.scrollEnabled&&!t.nativeScroll?this.renderIScroll():t.children,i={...t.style};if(x.size(i,t),x.align(i,t),t.clip&&(i.overflowX="hidden",i.overflowY="hidden"),t.scrollEnabled&&t.nativeScroll){const e=this.getScrollDirection();"y"===e?i.overflowY="auto":"x"===e?i.overflowX="auto":"both"===e&&(i.overflowX="auto",i.overflowY="auto")}return 0===i.opacity&&(i.pointerEvents="none"),n().createElement(e,{className:t.className,...t.attrs,...t.dom,...ne(t),style:i,ref:this.scrollRef},o)}}const Wo={name:"Group",docs:"https://docs.noodl.net/nodes/basic-elements/group",connectionPanel:{groupPriority:["General","Style","Events","Mounted","Hover Events","Pointer Events","Focus","Scroll"]},initialize(){this.props.attrs={},this._internal={scrollElementDuration:500,scrollIndexDuration:500,scrollIndex:0},this.props.layout="column"},getReactComponent:()=>Uo,noodlNodeAsProp:!0,visualStates:[{name:"neutral",label:"Neutral"},{name:"hover",label:"Hover"}],defaultCss:{display:"flex",position:"relative",flexDirection:"column"},inputs:{flexDirection:{index:12,displayName:"Layout",group:"Layout",type:{name:"enum",enums:[{label:"None",value:"none"},{label:"Vertical",value:"column"},{label:"Horizontal",value:"row"}]},default:"column",set(e){this.props.layout=e,"none"!==e?this.setStyle({flexDirection:e}):this.removeStyle(["flexDirection"]),this.context.editorConnection&&("none"===e||Ne.includes(e)?this.context.editorConnection.clearWarning(this.nodeScope.componentOwner.name,this.id,"layout-warning"):this.context.editorConnection.sendWarning(this.nodeScope.componentOwner.name,this.id,"layout-warning",{message:"Invalid Layout value has to be a valid flex-direction value."})),this.forceUpdate()}},"scrollToIndex.do":{displayName:"Scroll To Index - Do",group:"Scroll To Index",type:"signal",index:505,valueChangedToTrue(){this.scheduleAfterInputsHaveUpdated((()=>{if(!this.innerReactComponentRef)return;const e=this._internal.scrollIndex,t=this._internal.scrollIndexDuration;this.innerReactComponentRef.scrollToIndex(e,t)}))}},"scrollToElement.do":{displayName:"Scroll To Element - Do",group:"Scroll To Element",type:"signal",index:500,valueChangedToTrue(){this.innerReactComponentRef&&this.scheduleAfterInputsHaveUpdated((()=>{const e=this._internal.scrollElement,t=this._internal.scrollElementDuration;this.innerReactComponentRef.scrollToElement(e,t)}))}},"scrollToElement.element":{displayName:"Scroll To Element - Element",group:"Scroll To Element",type:"reference",index:501,set(e){this._internal.scrollElement=e}},"scrollToElement.duration":{displayName:"Scroll To Element - Duration",group:"Scroll To Element",type:"number",default:500,index:502,set(e){this._internal.scrollElementDuration=e}},"scrollToIndex.index":{displayName:"Scroll To Index - Index",group:"Scroll To Index",type:"number",default:0,index:506,set(e){this._internal.scrollIndex=e}},"scrollToIndex.duration":{displayName:"Scroll To Index - Duration",group:"Scroll To Index",type:"number",default:500,index:507,set(e){this._internal.scrollIndexDuration=e}},focus:{displayName:"Focus",type:"signal",group:"Focus",valueChangedToTrue(){this.context.setNodeFocused(this,!0)}},testId:{index:100009,displayName:"Test ID Attribute",group:"Advanced HTML",type:"string",set(e){this.props.attrs["data-testid"]=e,this.forceUpdate()}}},inputProps:{clip:{index:19,displayName:"Clip Content",type:"boolean",group:"Layout",default:!1},scrollEnabled:{index:54,group:"Scroll",displayName:"Enable Scroll",type:"boolean",default:!1},scrollSnapEnabled:{index:55,displayName:"Snap",group:"Scroll",type:"boolean",default:!1},scrollSnapToEveryItem:{index:56,displayName:"Snap To Every Item",group:"Scroll",type:"boolean",default:!1},showScrollbar:{index:57,displayName:"Show Scrollbar",group:"Scroll",type:"boolean",default:!1},scrollBounceEnabled:{index:58,displayName:"Bounce at boundaries",group:"Scroll",type:"boolean",default:!0},nativeScroll:{index:60,group:"Scroll",displayName:"Native platform scroll",type:"boolean",default:!0},as:{index:1e5,group:"Advanced HTML",displayName:"Tag",type:{name:"enum",enums:[{label:"
",value:"div"},{label:"
",value:"section"},{label:"
",value:"article"},{label:"