-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcloud-runtime-0-6-3.js
More file actions
1 lines (1 loc) · 256 KB
/
cloud-runtime-0-6-3.js
File metadata and controls
1 lines (1 loc) · 256 KB
1
const _noodl_cloud_runtime_version="cloud-runtime-0-6-3";(()=>{var __webpack_modules__={2806:e=>{var t="__lodash_hash_undefined__",n=9007199254740991,o="[object Arguments]",i="[object Function]",s="[object GeneratorFunction]",r=/^\[object .+?Constructor\]$/,a="object"==typeof global&&global&&global.Object===Object&&global,u="object"==typeof self&&self&&self.Object===Object&&self,l=a||u||Function("return this")();function c(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<i;)if(t(e[s],s,e))return s;return-1}(e,h);for(var o=-1,i=e.length;++o<i;)if(e[o]===t)return o;return-1}(e,t)>-1}function d(e,t,n){for(var o=-1,i=e?e.length:0;++o<i;)if(n(t,e[o]))return!0;return!1}function p(e,t){for(var n=-1,o=t.length,i=e.length;++n<o;)e[i+n]=t[n];return e}function h(e){return e!=e}function m(e,t){return e.has(t)}var f,g=Array.prototype,y=Function.prototype,v=Object.prototype,_=l["__core-js_shared__"],b=(f=/[^.]+$/.exec(_&&_.keys&&_.keys.IE_PROTO||""))?"Symbol(src)_1."+f:"",I=y.toString,C=v.hasOwnProperty,O=v.toString,N=RegExp("^"+I.call(C).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),S=l.Symbol,w=v.propertyIsEnumerable,P=g.splice,E=S?S.isConcatSpreadable:void 0,x=Math.max,T=U(l,"Map"),D=U(Object,"create");function R(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function j(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function F(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var o=e[t];this.set(o[0],o[1])}}function M(e){var t=-1,n=e?e.length:0;for(this.__data__=new F;++t<n;)this.add(e[t])}function A(e,t){for(var n,o,i=e.length;i--;)if((n=e[i][0])===(o=t)||n!=n&&o!=o)return i;return-1}function V(e,t,n,o,i){var s=-1,r=e.length;for(n||(n=W),i||(i=[]);++s<r;){var a=e[s];t>0&&n(a)?t>1?V(a,t-1,n,o,i):p(i,a):o||(i[i.length]=a)}return i}function k(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 U(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return function(e){if(!z(e)||b&&b in e)return!1;var t=H(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e)?N:r;return t.test(function(e){if(null!=e){try{return I.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}(n)?n:void 0}function W(e){return $(e)||function(e){return J(e)&&C.call(e,"callee")&&(!w.call(e,"callee")||O.call(e)==o)}(e)||!!(E&&e&&e[E])}R.prototype.clear=function(){this.__data__=D?D(null):{}},R.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},R.prototype.get=function(e){var n=this.__data__;if(D){var o=n[e];return o===t?void 0:o}return C.call(n,e)?n[e]:void 0},R.prototype.has=function(e){var t=this.__data__;return D?void 0!==t[e]:C.call(t,e)},R.prototype.set=function(e,n){return this.__data__[e]=D&&void 0===n?t:n,this},j.prototype.clear=function(){this.__data__=[]},j.prototype.delete=function(e){var t=this.__data__,n=A(t,e);return!(n<0||(n==t.length-1?t.pop():P.call(t,n,1),0))},j.prototype.get=function(e){var t=this.__data__,n=A(t,e);return n<0?void 0:t[n][1]},j.prototype.has=function(e){return A(this.__data__,e)>-1},j.prototype.set=function(e,t){var n=this.__data__,o=A(n,e);return o<0?n.push([e,t]):n[o][1]=t,this},F.prototype.clear=function(){this.__data__={hash:new R,map:new(T||j),string:new R}},F.prototype.delete=function(e){return k(this,e).delete(e)},F.prototype.get=function(e){return k(this,e).get(e)},F.prototype.has=function(e){return k(this,e).has(e)},F.prototype.set=function(e,t){return k(this,e).set(e,t),this},M.prototype.add=M.prototype.push=function(e){return this.__data__.set(e,t),this},M.prototype.has=function(e){return this.__data__.has(e)};var L,q,G=(L=function(e,t){return J(e)?function(e,t,n,o){var i,s=-1,r=c,a=!0,u=e.length,l=[],p=t.length;if(!u)return l;n&&(t=function(e,t){for(var n=-1,o=e?e.length:0,i=Array(o);++n<o;)i[n]=t(e[n],n,e);return i}(t,(i=n,function(e){return i(e)}))),o?(r=d,a=!1):t.length>=200&&(r=m,a=!1,t=new M(t));e:for(;++s<u;){var h=e[s],f=n?n(h):h;if(h=o||0!==h?h:0,a&&f==f){for(var g=p;g--;)if(t[g]===f)continue e;l.push(h)}else r(t,f,o)||l.push(h)}return l}(e,V(t,1,J,!0)):[]},q=x(void 0===q?L.length-1:q,0),function(){for(var e=arguments,t=-1,n=x(e.length-q,0),o=Array(n);++t<n;)o[t]=e[q+t];t=-1;for(var i=Array(q+1);++t<q;)i[t]=e[t];return i[q]=o,function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}(L,this,i)}),$=Array.isArray;function J(e){return function(e){return!!e&&"object"==typeof e}(e)&&function(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=n}(e.length)&&!H(e)}(e)}function H(e){var t=z(e)?O.call(e):"";return t==i||t==s}function z(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=G},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),l=n(2487),c=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 c.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=l,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 l(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 c{constructor(e){this._initCloudServices(),this.events=new a,this.events.setMaxListeners(1e4),this.modelScope=e,this._fromJSON=(t,n)=>c._fromJSON(t,n,e),this._deserializeJSON=(t,n)=>c._deserializeJSON(t,n,e),this._serializeObject=(t,n)=>c._serializeObject(t,n,e)}_initCloudServices(){g=void 0;const e=o.instance.getMetaData("cloudservices");e&&(this.appId=e.appId,this.endpoint=e.endpoint)}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.where&&t.push("match="+encodeURIComponent(JSON.stringify(e.where))),e.limit&&t.push("limit="+e.limit),e.skip&&t.push("skip="+e.skip);const n={objectId:null};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})),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)),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(l(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(l(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(c._collections[t])var o=c._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;t<e.length;t++)if("object"!=typeof e[t]||null===e[t])return!1;return!0}(e)){for(var o=[],a=0;a<e.length;a++)o.push(h(e[a],void 0,n));var u=s.get();return u.set(o),u}if(Array.isArray(e))return e;if(e&&"Object"===e.__type&&void 0!==e.className&&void 0!==e.objectId){const t=Object.assign({},e);return delete t.className,delete t.__type,m(t,e.className,n)}if("object"==typeof e&&null!==e){var l=(n||i).get();for(var c in e)l.set(c,h(e[c],void 0,n));return l}return e}}}function m(e,t,n){const o=(n||i).get(e.objectId);if(o._class=t,void 0!==t&&void 0!==c._collections[t])var s=c._collections[t].schema;for(var r in e)if("objectId"!==r&&"ACL"!==r){var a=s&&s.properties&&s.properties[r]?s.properties[r].type:void 0;o.set(r,h(e[r],a,n))}return o}var f,g;c._fromJSON=m,c._deserializeJSON=h,c._serializeObject=p,c.forScope=e=>void 0===e?c.instance:(e._cloudStore||(e._cloudStore=new c(e)),e._cloudStore),Object.defineProperty(c,"instance",{get:function(){return void 0===f&&(f=new c),f}}),Object.defineProperty(c,"_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}}),c.invalidateCollections=()=>{g=void 0},e.exports=c},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;o<e.length;o++){let i=e[o];if("-"===i[0]){let e=i.substring(1);if(t.get(e)>n.get(e))return-1;if(t.get(e)<n.get(e))return 1}else{if(t.get(i)>n.get(i))return 1;if(t.get(i)<n.get(i))return-1}}return 0},matchesQuery:function e(t,n){var o=!0;return void 0===n||(void 0!==n.$and?n.$and.forEach((n=>{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&=i<n[e].$lt:void 0!==n[e].$lte?o&=i<=n[e].$lt:void 0!==n[e].$gt?o&=i>n[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){var l=t.relatedTo.id;if(void 0===l)return n.error("Must provide id in relatedTo filter");var c=t.relatedTo.key;if(void 0===c)return n.error("Must provide key in relatedTo filter");var d=(n.modelScope||i).get(l);a.$relatedTo={object:{__type:"Pointer",objectId:l,className:d._class},key:c}}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){if(d=(n.modelScope||i).get(e.pointsTo),o._collections[n.collectionName])var p=o._collections[n.collectionName].schema;var h=p&&p.properties&&p.properties[u]?p.properties[u].targetClass:void 0;"Relation"===(p&&p.properties&&p.properties[u]?p.properties[u].type:void 0)?a[u]={__type:"Pointer",objectId:e.pointsTo,className:h}:Array.isArray(e.pointsTo)?a[u]={$in:e.pointsTo.map((e=>({__type:"Pointer",objectId:e,className:h})))}:a[u]={$eq:{__type:"Pointer",objectId:e.pointsTo,className:h}}}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 m=e.text.search;a[u]="string"==typeof m?{$text:{$search:{$term:m,$caseSensitive:!1}}}:{$text:{$search:{$term:m.term,$language:m.language,$caseSensitive:m.caseSensitive,$diacriticSensitive:m.diacriticSensitive}}}}else void 0!==e.nearSphere?(m=e.nearSphere,a[u]={$nearSphere:{__type:"GeoPoint",latitude:m.latitude,longitude:m.longitude},$maxDistanceInMiles:m.$maxDistanceInMiles,$maxDistanceInKilometers:m.maxDistanceInKilometers,$maxDistanceInRadians:m.maxDistanceInRadians}):void 0!==e.withinBox?(m=e.withinBox,a[u]={$within:{$box:m.map((e=>({__type:"GeoPoint",latitude:e.latitude,longitude:e.longitude})))}}):void 0!==e.withinPolygon&&(m=e.withinPolygon,a[u]={$geoWithin:{$polygon:m.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{query:async(t,o,s)=>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."))}})})),count:async(t,o)=>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."))}})})),distinct:async(t,o,s)=>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."))}})})),aggregate:async(t,o,s)=>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){"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,include:o?o.include:void 0,success:function(t){var o=n()._fromJSON(t,i);e(o)},error:function(e){s(Error(e||"Failed to fetch."))}})}))},async increment(t,o,i){"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){"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."))}})}))},create:async(e,t,o)=>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){"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(rr||"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<t;n++){var s=e[n];o.instanceOf(s)?i.push(s):i.push(o.create(s))}var r=this.items,a=l(r),u=l(i);for(t=r.length,n=0;n<t;n++)u.hasOwnProperty(r[n].getId())||(this.removeAtIndex(n),n--,t--);for(n=0;n<Math.min(r.length,i.length);n++)r[n]!==i[n]&&(a.hasOwnProperty(i[n].getId())&&this.remove(i[n]),this.addAtIndex(i[n],n));for(n=r.length;n<i.length;n++)this.add(i[n])}function l(e){for(var t={},n=e.length,o=0;o<n;o++){var i=e[o];t[i.getId()]=i}return t}}}),Object.defineProperty(Array.prototype,"notify",{enumerable:!1,writable:!1,value:async function(e,t){if(this._listeners&&this._listeners[e])for(var n=this._listeners[e].slice(),o=0;o<n.length;o++)await n[o](t)}}),Object.defineProperty(Array.prototype,"contains",{enumerable:!1,writable:!1,value:function(e){return-1!==this.indexOf(e)}}),Object.defineProperty(Array.prototype,"add",{enumerable:!1,writable:!1,value:async function(e){this.contains(e)||(this.items.push(e),await this.notify("add",{item:e,index:this.items.length-1}),await this.notify("change"),await e.notify("add",{collection:this}))}}),Object.defineProperty(Array.prototype,"remove",{enumerable:!1,writable:!1,value:function(e){var t=this.items.indexOf(e);-1!==t&&this.removeAtIndex(t)}}),Object.defineProperty(Array.prototype,"addAtIndex",{enumerable:!1,writable:!1,value:async function(e,t){this.contains(e)||(this.items.splice(t,0,e),await this.notify("add",{item:e,index:t}),await this.notify("change"),await e.notify("add",{collection:this,index:t}))}}),Object.defineProperty(Array.prototype,"removeAtIndex",{enumerable:!1,writable:!1,value:async function(e){var t=this.items[e];this.items.splice(e,1),await this.notify("remove",{item:t,index:e}),await this.notify("change"),await t.notify("remove",{collection:this})}}),Object.defineProperty(Array.prototype,"on",{enumerable:!1,writable:!1,value:function(e,t){this._listeners||Object.defineProperty(this,"_listeners",{enumerable:!1,writable:!1,value:{}}),this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)}}),Object.defineProperty(Array.prototype,"off",{enumerable:!1,writable:!1,value:function(e,t){if(this._listeners&&this._listeners[e]){var n=this._listeners[e].indexOf(t);-1!==n&&this._listeners[e].splice(n,1)}}});class i extends Array{}var s=i._collections={};i.create=function(e){const t=o.guid();return s[t]=new i,Object.defineProperty(s[t],"_id",{enumerable:!1,writable:!1,value:t}),e&&s[t].set(e),s[t]},i.get=function(e){return void 0===e&&(e=o.guid()),s[e]||(s[e]=new i,Object.defineProperty(s[e],"_id",{enumerable:!1,writable:!1,value:e})),s[e]},i.instanceOf=function(e){return e instanceof i},i.exists=function(e){return void 0!==s[e]},e.exports=i},6607:e=>{"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<this.sendQueue.length;e+=50){const t=this.sendQueue.slice(e,e+50);o(t)}this.sendQueue=[],this.sendTimer=void 0,this.lastSendTimestamp=this.platform.getCurrentTime()}}),100))):(this.lastSendTimestamp=t,o(e))},a.prototype.sendInspectId=function(e){this.send({cmd:"select",type:"viewer",content:JSON.stringify({id:e})})},a.prototype.sendSelectComponent=function(e){this.send({cmd:"select",type:"viewer",content:JSON.stringify({componentName:e})})},a.prototype.sendPulsingConnections=function(e){var t=[];Object.keys(e).forEach((function(n){var o=e[n];t=t.concat(o.connections)})),this.send({cmd:"connectiondebugpulse",type:"viewer",content:JSON.stringify({connectionsToPulse:t})})},a.prototype.sendDebugInspectorValues=function(e){this.send({cmd:"debuginspectorvalues",type:"viewer",content:{inspectors:e}})},a.prototype.sendConnectionValue=function(e,t){this.send({cmd:"connectionValue",type:"viewer",content:{connectionId:e,value:t}})};const u={};a.prototype.sendDynamicPorts=function(e,t,n){var o=JSON.stringify(t);if(u[e]!==o){if(u[e]&&t&&n&&n.detectRenamed){var i=Array.isArray(n.detectRenamed)?n.detectRenamed:[n.detectRenamed],s=[];i.forEach((n=>{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;o<e.length;o++){if(-1===t.indexOf(e[o])){if(n.before)return;n.before=e[o]}if(-1===e.indexOf(t[o])){if(n.after)return;n.after=t[o]}}return n.before&&n.after?n:void 0}}(o=o.map((e=>e.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 l={};a.prototype.sendServiceRequest=function(e,t){e.token=s(),e.clientId=this.clientId,l[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)),l=t(Object.keys(i),a);n.updateInputPortTypes(i),u.forEach(n.removeInputPortWithName.bind(n)),l.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 c=Object.keys(n.getOutputPorts()),d=t(c,Object.keys(r)),p=t(Object.keys(r),c);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 l(e,t,n,o){var i,s,r,l;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 c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=r.length,l=c,console&&console.warn&&console.warn(l)}return e}function c(){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=c.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;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):m(i,i.length)}function h(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function m(e,t){for(var n=new Array(t),o=0;o<t;++o)n[o]=e[o];return n}function f(e,t,n,o){if("function"==typeof e.on)o.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function i(s){o.once&&e.removeEventListener(t,i),n(s)}))}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return r},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");r=e}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i="error"===e,s=this._events;if(void 0!==s)i=i&&void 0===s.error;else if(!i)return!1;if(i){var r;if(t.length>0&&(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 l=u.length,c=m(u,l);for(n=0;n<l;++n)o(c[n],this,t)}return!0},s.prototype.addListener=function(e,t){return l(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return l(this,e,t,!0)},s.prototype.once=function(e,t){return a(t),this.on(e,d(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,d(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,o,i,s,r;if(a(t),void 0===(o=this._events))return this;if(void 0===(n=o[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length-1;s>=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<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(o[e]=n[0]),void 0!==o.removeListener&&this.emit("removeListener",e,r||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n,o;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,s=Object.keys(n);for(o=0;o<s.length;++o)"removeListener"!==(i=s[o])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(o=t.length-1;o>=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<n.length;e++){const o=n[e];await Promise.resolve(o.call(null,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))},e.exports=t},7662: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<e;++n)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"[Math.floor(65536*(1+Math.random()))%62];return t}t.get=function(e){return void 0===e&&(e=t.guid()),n[e]||(n[e]=new t(e,{}),o[e]=new Proxy(n[e],i)),o[e]},t.create=function(e){var n=e||{},o=t.get(n.id);for(var i in n)"id"!==i&&o.set(i,n[i]);return o},t.exists=function(e){return void 0!==n[e]},t.instanceOf=function(e){return e instanceof t||e.target instanceof t},t.guid=function(){return s(10)},t.prototype.on=function(e,t){this.listeners||(this.listeners={}),this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},t.prototype.off=function(e,t){if(this.listeners&&this.listeners[e]){var n=this.listeners[e].indexOf(t);-1!==n&&this.listeners[e].splice(n,1)}},t.prototype.notify=function(e,t){if(this.listeners&&this.listeners[e])for(var n=this.listeners[e].slice(),o=0;o<n.length;o++)n[o](t)},t.prototype.setAll=function(e){for(var t in e)if("id"!==t&&this.data[t]!==e[t]){var n=this.data[t];this.data[t]=e[t],this.notify("change",{name:t,value:e[t],old:n})}},t.prototype.fill=function(e=null){for(const t in this.data){if("id"===t)continue;const n=this.data[t];this.data[t]=e,this.notify("change",{name:t,value:this.data[t],old:n})}},t.prototype.set=function(e,n,o){if(o&&o.resolve&&-1!==e.indexOf(".")){for(var i=e.split("."),s=this,r=0;r<i.length-1;r++){var a=s.get(i[r]);if(!t.instanceOf(a))return;s=a}return void s.set(i[i.length-1],n)}const u=o&&o.forceChange;var l=this.data[e];this.data[e]=n,(u||l!==n)&&(!o||!o.silent)&&this.notify("change",{name:e,value:n,old:l})},t.prototype.getId=function(){return this.id},t.prototype.get=function(e,n){if(n&&n.resolve&&-1!==e.indexOf(".")){for(var o=e.split("."),i=this,s=0;s<o.length-1;s++){var r=i.get(o[s]);if(!t.instanceOf(r))return;i=r}return i.get(o[o.length-1])}return this.data[e]},t.prototype.toJSON=function(){return Object.assign({},this.data,{id:this.id})},t.Scope=function(){this.models={},this.proxies={}},t.Scope.prototype.get=function(e){return void 0===e&&(e=t.guid()),this.models[e]||(this.models[e]=new t(e,{}),this.proxies[e]=new Proxy(this.models[e],i)),this.proxies[e]},t.Scope.prototype.create=function(e){var t=e||{},n=this.get(t.id);for(var o in t)"id"!==o&&n.set(o,t[o]);return n},t.Scope.prototype.exists=function(e){return void 0!==this.models[e]},t.Scope.prototype.instanceOf=function(e){return e instanceof t||e.target instanceof t},t.Scope.prototype.guid=function(){return s(10)},t.Scope.prototype.reset=function(){this.models={},this.proxies={},delete this._cloudStore},e.exports=t},7863:(e,t,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;e<n.length;e++)this.removeConnection(n[e]);return this.setNodeParent(t,null),-1!==this.roots.indexOf(t.id)&&this.removeRootId(t.id),await this.emit("nodeRemoved",t),t.removeAllListeners(),delete this.nodes[e],await this.emit("nodeWasRemoved",t),!0},s.prototype.getAllConnections=function(){return this.connections},s.prototype.getInputPorts=function(){return this.inputPorts},s.prototype.getOutputPorts=function(){return this.outputPorts},s.prototype.addInputPort=function(e){this.inputPorts[e.name]=e,this.emit("inputPortAdded",e)},s.prototype.addOutputPort=function(e){this.outputPorts[e.name]=e,this.emit("outputPortAdded",e)},s.prototype.removeOutputPortWithName=function(e){if(this.outputPorts.hasOwnProperty(e)){var t=this.outputPorts[e];delete this.outputPorts[e],this.emit("outputPortRemoved",t)}},s.prototype.removeInputPortWithName=function(e){if(this.inputPorts.hasOwnProperty(e)){var t=this.inputPorts[e];delete this.inputPorts[e],this.emit("inputPortRemoved",t)}},s.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")},s.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")},s.prototype.renameInputPortOnNodeWithId=function(e,t,n){var o=this.getConnectionsToPort(e,t);o.forEach(this.removeConnection.bind(this));var i=this.getNodeWithId(e),s={...i.getInputPort(t)};s&&(i.removeInputPortWithName(t),s.name=n,i.addInputPort(s)),o.forEach((function(e){e.targetPort=n})),o.forEach(this.addConnection.bind(this))},s.prototype.renameOutputPortOnNodeWithId=function(e,t,n){var o=this.getConnectionsFromPort(e,t);o.forEach(this.removeConnection.bind(this));var i=this.getNodeWithId(e),s={...i.getOutputPort(t)};i.removeOutputPortWithName(t),s.name=n,i.addOutputPort(s),o.forEach((function(e){e.sourcePort=n})),o.forEach(this.addConnection.bind(this))},s.prototype.setNodeParent=function(e,t,n){-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))},s.prototype.importEditorNodeData=async function(e,t,n){var i=o.createFromExportData(e);if(await this.addNode(i),t&&this.setNodeParent(i,this.getNodeWithId(t),n),e.children)for(let t=0;t<e.children.length;t++){const n=e.children[t];await this.importEditorNodeData(n,i.id,t)}},s.prototype.reset=async function(){for(;this.roots.length;)await this.removeNodeWithId(this.roots[0]);for(const e of this.nodes)this.hasNodeWithId(e)&&await this.removeNodeWithId(e);if(this.nodes.length>0)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;o<n.length;o++){var i=this.components[n[o]];t=t.concat(i.getNodesWithType(e))}return t},s.prototype.getComponentWithName=function(e){return this.components[e]},s.prototype.hasComponentWithName=function(e){return!!this.components[e]},s.prototype.getAllComponents=function(){return Object.keys(this.components).map((e=>this.components[e]))},s.prototype.getAllNodes=function(){for(var e=[],t=Object.keys(this.components),n=0;n<t.length;n++){var o=this.components[t[n]];e=e.concat(o.getAllNodes())}return e},s.prototype.addComponent=function(e){this.components[e.name]=e,this.getNodesWithType(e.name).forEach(this._addComponentPorts.bind(this)),e.getAllNodes().forEach(this._onNodeAdded.bind(this)),e.on("nodeAdded",this._onNodeAdded.bind(this),this),e.on("nodeRemoved",this._onNodeRemoved.bind(this),this),e.on("nodeWasRemoved",this._onNodeWasRemoved.bind(this),this),this.emit("componentAdded",e)},s.prototype.removeComponentWithName=async function(e){if(!1!==this.components.hasOwnProperty(e)){var t=this.components[e];await t.reset(),t.removeAllListeners(),delete this.components[t.name],this.emit("componentRemoved",t)}else console.error("GraphModel: Component with name "+e+" not in graph")},s.prototype.renameComponent=function(e,t){if(!1!==this.components.hasOwnProperty(e)){this.getNodesWithType(e).forEach((function(e){e.type=t}));var n=this.components[e];n.rename(t),delete this.components[e],this.components[t]=n,this.emit("componentRenamed",n)}else console.error("GraphModel: Component with name "+e+" not in graph")},s.prototype._addComponentPorts=function(e){if(this.components.hasOwnProperty(e.type)){var t=this.components[e.type];const n=t.getInputPorts(),o=t.getOutputPorts();Object.keys(n).forEach((t=>{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<br>"+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<o.length;i++){const s=o[i];if(s.owner.id===t&&s.name===n){o.splice(i,1),s.owner.getOutput(n).deregisterConnection(this,e);break}}0===o.length&&delete this._valuesFromConnections[e]},Node.prototype.isInputConnected=function(e){return!!this._inputConnections.hasOwnProperty(e)&&this._inputConnections[e].some((e=>"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;n<e.length;n++){const o=e[n],i=this._inputValuesQueue[o];i.length>0&&(this.setInputValue(o,i.shift()),i.length>0&&(t=!0))}const n=this._afterInputsHaveUpdatedCallbacks;this._afterInputsHaveUpdatedCallbacks=[];for(let e=0;e<n.length;e++)n[e].call(this)}this._updateIteration++,this._updateIteration>=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<t.length;++n)t[n].owner.update()},Node.prototype.flagDirty=function(){this._dirty||(this._dirty=!0,this.updateOnDirtyFlagging&&this._performDirtyUpdate())},Node.prototype._performDirtyUpdate=function(){this.context&&this.context.nodeIsDirty(this);for(var e=0;e<this._outputList.length;++e)this._outputList[e].flagDependeesDirty()},Node.prototype.sendValue=function(e,t){if(!1===this.hasOutput(e))return void console.log("Error: Node",this.name,"doesn't have a output named",e);if(void 0===t)return;const n=this.getOutput(e);n.sendValue(t),this.context&&this.context.connectionSentValue(n,t)},Node.prototype.flagOutputDirty=function(e){const t=this.getOutput(e);this.sendValue(e,t.value)},Node.prototype.flagAllOutputsDirty=function(){for(const e of this._outputList)this.sendValue(e.name,e.value)},Node.prototype.sendSignalOnOutput=function(e){if(!1===this.hasOutput(e))return void console.log("Error: Node",this.name,"doesn't have a output named",e);const t=this.getOutput(e);t.sendValue(!0),t.sendValue(!1),this._signalsSentThisUpdate[e]=!0,this.scheduleAfterInputsHaveUpdated((function(){this._signalsSentThisUpdate[e]=!1})),this.context&&this.context.connectionSentSignal(t)},Node.prototype._setValueFromConnection=function(e,t){this._valuesFromConnections[e]=t,this.queueInput(e,t)},Node.prototype._hasInputBeenSetFromAConnection=function(e){return this._valuesFromConnections.hasOwnProperty(e)},Node.prototype.queueInput=function(e,t){if(this._inputValuesQueue[e]||(this._inputValuesQueue[e]=[]),this._isFirstUpdate){const n=this._inputValuesQueue[e][0];!0===n||(n instanceof Object&&n.unit&&t instanceof Object==0&&(t={value:t,unit:n.unit}),this._inputValuesQueue[e].length=0)}this._inputValuesQueue[e].push(t),this.flagDirty()},Node.prototype.scheduleAfterInputsHaveUpdated=function(e){this._afterInputsHaveUpdatedCallbacks.push(e),this.flagDirty()},Node.prototype.setNodeModel=function(e){this.model=e,e.on("parameterUpdated",this._onNodeModelParameterUpdated,this),e.on("variantUpdated",this._onNodeModelVariantUpdated,this),e.on("inputPortRemoved",(e=>{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;e<t;++e)try{i[e]._deleted||i[e].update()}catch(e){console.error(e,e.stack)}var s=this.callbacksAfterUpdate;for(this.callbacksAfterUpdate=[],e=0,t=s.length;e<t;e++)try{s[e]()}catch(e){console.error(e)}n=this.callbacksAfterUpdate.length>0||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="<Node> "+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<a.length;u++)a[u]._setCloseCallback(((e,t)=>{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 l=new r(o,a);var c,d;return l._inputs=Object.create(n),Object.keys(e.inputs).forEach((function(t){var n=e.inputs[t];n.valueChangedToTrue&&(l._inputs[t]={set:i.createSetter({valueChangedToTrue:n.valueChangedToTrue})})})),Object.keys(e.outputs).forEach((function(t){var n=e.outputs[t];"signal"===n.type?l.registerOutput(t,{getter:function(){}}):l.registerOutput(t,n)})),e.numberedInputs&&function(e,t){for(const n of Object.keys(t))s(e,n,t[n])}(l,e.numberedInputs),l.nodeScope=u,c=l._inputValues,d=t.inputs,Object.keys(d).forEach((e=>{const t=d[e].default;void 0!==t&&(d[e].type.defaultUnit?c[e]={unit:d[e].type.defaultUnit,value:t}:c[e]=t)})),e.initialize.call(l),l};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<s;e++){const o={name:t+" "+e,displayName:(n.displayPrefix||t)+" "+e,type:n.type,plug:"input",group:n.group};n.hasOwnProperty("index")&&(o.index=n.index+e),r.push(o)}return r}(e,t,n[t]))).flat();s.sendDynamicPorts(e.id,t)}s&&s.isRunningLocally()&&i.on("nodeAdded."+t,(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<o.length;e++)t.isChild(o[e])&&t.removeChild(o[e]);if(n)for(let e=0;e<o.length;e++){const t=o[e],n=t.model.parent.children.indexOf(t.model);this.addChild(t,n)}}}},getChildRootIndex:{value:function(){if(!this._internal.childRoot||!this._internal.childRoot.model||!this._internal.childRoot.model.children)return 0;for(var e=this._internal.childRoot.model.children,t=0;t<e.length;t++)if("Component Children"===e[t].type)return t;return 0}},getChildRoot:{value:function(){return this._internal.childRoot?this._internal.childRoot:null}},getRoots:{value:function(){return this._internal.roots}},triggerDidMount:{value:function(){this._internal.roots.forEach((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<n;t++)e[t].flagDirty();this._internal.componentOutputs.forEach((function(e){e.flagDirty()}))}},getRef:{value:function(){const e=this._internal.roots[0];return e?e.getRef():void 0}},update:{value:function(){o.prototype.update.call(this),this._internal.componentOutputs.forEach((function(e){e.update()}))}},forceUpdate:{value:function(){this.parent&&(this.parent.cachedChildren=void 0,this.parent.forceUpdate())}},getInstanceId:{value(){return this._internal.instanceId}}}),r.prototype.constructor=r,e.exports=r},1208:e=>{"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),l=n(5802);var c={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"),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&&l.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=l.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")):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"))}function n(t){if(void 0!==e._internal.currentQuery.sort){for(var n=0;n<e._internal.collection.size()&&!(l.compareObjects(e._internal.currentQuery.sort,e._internal.collection.get(n),t)>0);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")}};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()}}},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("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?l.convertVisualFilter(this._internal.visualFilter,{queryParameters:this._internal.queryParameters,collectionName:this._internal.name}):void 0,sort:void 0!==this._internal.visualSorting?l.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=l.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 l(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(l),r&&r.forEach(l),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 c=t.storageJSONFilter;if(c){var d=(c=c.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(c,i,{inputPrefix:"storageFilterValue-",inputGroup:"Filter Values",inputType:{name:"*",allowConnectionsOnly:!0},skipOutputs:!0})}}n.sendDynamicPorts(e,i)}e.exports={node:c,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"),l=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&&l.collectionName&&a&&(void 0===(c=a.find((e=>e.name===l.collectionName)))&&u&&(c=u.find((e=>e.name===l.collectionName))),c&&c.schema&&c.schema.properties)){const e=c.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&&l.collectionName&&a){const e={String:"string",Boolean:"boolean",Number:"number",Date:"date"};var c;if(void 0===(c=a.find((e=>e.name===l.collectionName)))&&u&&(c=u.find((e=>e.name===l.collectionName))),c&&c.schema&&c.schema.properties){var d=c.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);var s=n(3839);const r=n(4007);var 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(){var e=this._internal;e.inputValues={},e.relationModelIds={};var 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(){var e=this;const 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){var i=n._fromJSON(o,t.collectionId);for(var s in 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,o)e.hasOutput("prop-"+s)&&e.flagOutputDirty("prop-"+s);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:l.bind(this,e.substring(5))})}}};function u(e){return this._internal.model?this._internal.model.get(e,{resolve:!0}):void 0}function l(e,t){this._internal.inputValues[e]=t}function c(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 l in u){var c=u[l];if(!i.find((e=>e.name===l)))if("Relation"===c.type);else{const e={String:"string",Boolean:"boolean",Number:"number",Date:"date"};i.push({type:{name:e[c.type]?e[c.type]:"*"},plug:"output",group:"Properties",name:"prop-"+l,displayName:l}),i.push({type:"signal",plug:"output",group:"Changed Events",displayName:l+" Changed",name:"changed-"+l})}}}}n.sendDynamicPorts(e,i)}e.exports={node:a,setup:function(e,t){function n(n){c(n.id,n.parameters,e.editorConnection,t),n.on("parameterUpdated",(function(o){c(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.dbCollections",(function(o){r.invalidateCollections(),c(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.systemCollections",(function(o){r.invalidateCollections(),c(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:l.bind(this,e)})}}};function l(e,t){this._internal.filterSettings[e]=t,!1===this.isInputConnected("filter")&&this.scheduleFilter()}function c(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 l={};function c(e){void 0!==e&&(void 0!==e.rules?e.rules.forEach((e=>c(e))):void 0!==e.input&&(l[e.input]=!0))}c(t.visualFilter),Object.keys(l).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){c(n.id,n.parameters,e.editorConnection,t.getMetaData("dbCollections")),n.on("parameterUpdated",(function(o){c(n.id,n.parameters,e.editorConnection,t.getMetaData("dbCollections"))})),t.on("metadataChanged.dbCollections",(function(t){r.invalidateCollections(),c(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.systemCollections",(function(t){r.invalidateCollections(),c(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<br>"+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:"<strong>"+n+"</strong>: "+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 l=a.match(/Outputs\.[A-Za-z0-9]+/g);if(l){const e={};l.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<o.length;t++)if(o[t].name===e&&"input"===o[t].plug)return!0;return!1}}o(),t.on("parameterUpdated",(function(){o()}))}e.editorConnection&&t.on("editorImportComplete",(()=>{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){var n=t.model;for(var o in t.inputValues)n.set(o,t.inputValues[o],{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.")}})}else e.setError("Missing Record Id")}))},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(),this.flagOutputDirty("currentValue"),this.sendSignalOnOutput("inputChanged"))}}},outputs:{currentValue:{type:"string",displayName:"Date String",group:"Value",getter:function(){return this._internal.dateString}},inputChanged:{type:"signal",displayName:"Date Changed",group:"Signals"}},methods:{_format(){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=("0"+e.getHours()).slice(-2),a=("0"+e.getMinutes()).slice(-2),u=("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(/\{hours\}/g,r).replace(/\{minutes\}/g,a).replace(/\{seconds\}/g,u)}}};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<e.inputNames.length;++t){var n=e.scope[e.inputNames[t]];e.inputValues[t]=n}try{return e.compiledFunction.apply(null,e.inputValues)}catch(e){console.error("Error in expression:",e.message)}return 0}},_compileFunction:{value:function(){var e=this._internal.currentExpression,t=Object.keys(this._internal.scope),n=e+t.join(" ");if(!1===r.hasOwnProperty(n)){t.push(e);try{r[n]=function(e,t){function n(){return e.apply(this,t)}return n.prototype=e.prototype,new n}(Function,t)}catch(e){console.error("Failed to compile JS function",e.message)}}return r[n]}}}};var s=["var min = Math.min, max = Math.max, cos = Math.cos, sin = Math.sin, tan = Math.tan, sqrt = Math.sqrt, pi = Math.PI, round = Math.round, floor = Math.floor, ceil = Math.ceil, abs = Math.abs, random = Math.random;"].join(""),r={},a=["min","max","cos","sin","tan","sqrt","pi","round","floor","ceil","abs","random","Math","window","document","undefined","Vars","true","false","null","Boolean"];function u(e){var t=[];function n(e){-1===a.indexOf(e)&&(t.some((function(t){return t===e}))||t.push(e))}var o=(e=e.replace(/\"([^\"]*)\"/g,"").replace(/\'([^\']*)\'/g,"")).matchAll(/[a-zA-Z\_\$][a-zA-Z0-9\.\_\$]*/g);for(const e of o){var i=e[0];-1!==i.indexOf(".")&&(i=i.split(".")[0]),n(i)}return t}function l(e,t,n){var o=u(t).map((function(e){return{group:"Parameters",name:e,type:{name:"*",editAsType:"string"},plug:"input"}}));n.sendDynamicPorts(e,o)}function c(e,t){try{new Function(t.parameters.expression),e.clearWarning(t.component.name,t.id,"expression-compile-error")}catch(n){e.sendWarning(t.component.name,t.id,"expression-compile-error",{message:n.message})}}e.exports={node:i,setup:function(e,t){e.editorConnection&&e.editorConnection.isRunningLocally()&&t.on("nodeAdded.Expression",(function(t){t.parameters.expression&&(l(t.id,t.parameters.expression,e.editorConnection),c(e.editorConnection,t)),t.on("parameterUpdated",(function(n){"expression"===n.name&&(l(t.id,t.parameters.expression,e.editorConnection),c(e.editorConnection,t))}))}))}}},7820:e=>{"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<Math.min(e.maxRunningTasks,e.queuedTasks.length);t++){const t=e.queuedTasks.shift();if(!t)break;this.startTask(t)}}},abort:function(){this._internal.state="aborted"},itemOutputSignalTriggered:function(e,t,n){const o=this._internal;if("idle"===o.state)return;const i=()=>{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),i={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){console.log("Error in JS node run code.",Object.getPrototypeOf(e).constructor.name+": "+e.message,e.stack),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}}},s=[{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:i,setup:function(e,t){function n(t){function n(){var n=[];const i=s.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:s,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",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<s.length;r++)if(s[r].handleEvent(t))return!0;if("parent"===n&&this.componentOwner.parentNodeScope){const o=this.componentOwner.parent?this.componentOwner.parent.nodeScope:this.componentOwner.parentNodeScope;if(!o)return;o.sendEventFromThisScope(e,t,n,!0)}else if("children"===n){var a=this.nodes;for(var u in a)(l=a[u].children)&&l.forEach((o=>{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 l;(l=a[u].children)&&l.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;n<this.connections.length;n++){var o=this.connections[n];if(o.node===e&&o.inputPortName===t){this.connections.splice(n,1);break}}0===this.connections.length&&this.onLastConnectionRemoved&&this.onLastConnectionRemoved.call(this.owner)}},flagDependeesDirty:{value:function(e){for(var t=0,n=this.connections.length;t<n;t++)this.connections[t].node.flagDirty()}},sendValue:{value:function(e){this._lastUpdateIteration!==this.owner._updatedAtIteration?(this._lastUpdateIteration=this.owner._updatedAtIteration,this.valuesSendThisIteration=0):this.valuesSendThisIteration++,this.valuesSendThisIteration>500&&(this.owner._cyclicLoop=!0);for(var t=0,n=this.connections.length;t<n;t++){var o=this.connections[t];o.node._setValueFromConnection(o.inputPortName,e)}}},hasConnections:{value:function(){return this.connections.length>0}}}),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<t.length;n++){var o=t[n];o.settings&&o.settings.forEach((function(t){e.ports.push(t)}))}}(n,t),n}}},3855:(e,t,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<r;++t)s[t]=this.runningTimers[t];for(t=0;t<r;++t)if((n=s[t])&&e>=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;t<i.length;++t)i[t]._isRunning=!1,i[t]._hasCalledOnStart=!1,i[t].onFinish&&i[t].onFinish();if(this.newTimers.length>0){for(t=0;t<this.newTimers.length;++t)(n=this.newTimers[t])._start=e+n.delay,n._isRunning=!0,n._wasStopped=!1,this.runningTimers.push(n),0===n.delay&&(n.onStart&&(n.onStart(),n._hasCalledOnStart=!0),n.onRunning&&n.onRunning(0));this.newTimers.length=0}},n.prototype.hasPendingTimers=function(){return this.runningTimers.length>0||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}}},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 l=await a.query("_Session",u);async function c(t){return new Promise(((n,o)=>{s.Services.UserService.forScope(e).fetchUser({sessionToken:t,success:e=>n(e),error:e=>o(Error(e))})}))}return l&&0!==l.length?c(l[0].sessionToken):c((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:l.bind(this,e)})}}};function l(e,t){this._internal.storageSettings[e]=t,!1===this.isInputConnected("storageFetch")&&this.scheduleFetch()}function c(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 l(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(l),a&&a.forEach(l),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 c=t.storageJSONFilter;if(c){var d=(c=c.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(c,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){c(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"))&&c(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.dbCollections",(function(o){s.invalidateCollections(),c(n.id,n.parameters,e.editorConnection,t)})),t.on("metadataChanged.systemCollections",(function(o){s.invalidateCollections(),c(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__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var __webpack_exports__={};(()=>{"use strict";var e=__webpack_require__(1920);let t;const n={};_noodl_api_response=(e,t)=>{"function"==typeof n[e]&&(n[e](t),delete n[e])};const o=[];_noodl_process_jobs=()=>{for(;o.length>0;)o.shift()()};const i=()=>{global.require=function(e){console.log("Error, require not supported: "+e)},global.console={log:function(){let e="";for(let t=0;t<arguments.length;t++)e+=arguments[t]+"\n";_noodl_api_call("log",void 0,{level:"info",message:e})},info:function(){global.console.log.apply(void 0,arguments)},error:function(){let e="";for(let t=0;t<arguments.length;t++)e+=arguments[t]+"\n";_noodl_api_call("log",void 0,{level:"error",message:e})}};class e{constructor(e){this._headers=e}append(e,t){const n=e.toLowerCase();this._headers[n]=this._headers[n]?this._headers[n].concat([t]):[t]}set(e,t){const n=e.toLowerCase();this._headers[n]=[t]}get(e){const t=e.toLowerCase();return void 0===this._headers[t]?null:this._headers[t].join(", ")}delete(e){const t=e.toLowerCase();delete this._headers[t]}has(e){return e.toLowerCase(),void 0!==this._headers[e]}keys(){return Object.keys(this._headers)}forEach(e,t=void 0){for(const n of this.keys())Reflect.apply(e,t,[this.get(n),n,this])}*values(){for(const e of this.keys())yield this.get(e)}*entries(){for(const e of this.keys())yield[e,this.get(e)]}}global.fetch=async function(t,o){return new Promise(((i,s)=>{const r=Math.random().toString(26).slice(2);n[r]=t=>{void 0===t.error?(t.json=()=>{try{return Promise.resolve(JSON.parse(t.body))}catch(e){return Promise.reject("Failed to parse JSON response")}},t.text=()=>Promise.resolve(t.body),t.headers=new e(t.headers),i(t)):s(t.error)},_noodl_api_call("fetch",r,{url:t,...o})}))},global.setTimeout=function(e,t){const o=Math.random().toString(26).slice(2);n[o]=()=>{e()},_noodl_api_call("setTimeout",o,t)},global.setImmediate=function(e){o.push(e),_noodl_request_process_jobs()}};_noodl_handleReq=(n,o)=>{global.log||i(),console.info(`Cloud function ${o.function} called (requestId:${n})`),(n=>new Promise(((o,i)=>{(async()=>{if(!t){if(t=new e.CloudRunner({}),"undefined"==typeof _exportedComponents)throw Error("No cloud components present.");await t.load(_exportedComponents)}})().then((()=>{t.run(n.function,{body:n.body,headers:n.headers}).then(o).catch(i)})).catch(i)})))(o).then((e=>{console.info(`Cloud function ${o.function} response [${e.statusCode}] (requestId:${n})`),_noodl_response(n,e)})).catch((e=>{console.error(`Cloud function ${o.function} response [400] message: ${e.message} (requestId:${n})`),_noodl_response(n,{statusCode:400,body:JSON.stringify({error:e.message})})}))}})()})();