text: !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Flowed=t():e.Flowed=t()}(self,(function(){return e={865:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const r=s(227),o={};t.default=e=>{let t=o[e];return void 0===t&&(t=(0,r.default)(`flowed:${e}`),o[e]=t),t}},155:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FlowManager=void 0;const r=s(673),o=s(883),n=s(316),i=s(167);class a{static run(e,t={},s=[],r={},o={},n={}){return new i.Flow(e).start(t,s,r,o,n)}static runFromString(e,t={},s=[],r={},o={},n={}){return new Promise(((i,u)=>{try{const l=JSON.parse(e);a.run(l,t,s,r,o,n).then(i,u)}catch(e){u(e)}}))}static runFromFile(e,t={},s=[],o={},n={},i={}){return new Promise(((u,l)=>{(0,r.readFile)(e,"utf8",((e,r)=>{e?l(e):a.runFromString(r,t,s,o,n,i).then(u,l)}))}))}static runFromUrl(e,t={},s=[],r={},i={},u={}){let l=null;if(e.startsWith("http://")?l=o:e.startsWith("https://")&&(l=n),null===l){let t=null;const s=e.match(/^([a-zA-Z]+):/);return Array.isArray(s)&&2===s.length?(t=s[1],Promise.reject(new Error(`Protocol not supported: ${t}. Supported protocols are: [http, https]`))):Promise.reject(new Error(`Invalid URL: ${e}`))}return new Promise(((o,c)=>{(l||n).get(e,(e=>{const{statusCode:n}=e,l=e.headers["content-type"]||"application/json";let d;if(200!==n?d=new Error(`Request failed with status code: ${n}`):/^application\/json/.test(l)||/^text\/plain/.test(l)||(d=new Error(`Invalid content-type. Expected application/json or text/plain but received ${l}`)),d)c(d);else{e.setEncoding("utf8");let n="";e.on("data",(e=>{n+=e})),e.on("end",(()=>{a.runFromString(n,t,s,r,i,u).then(o,c)}))}})).on("error",(e=>{c(e)}))}))}static installPlugin(e){if(e.resolverLibrary)for(const[t,s]of Object.entries(e.resolverLibrary))this.plugins.resolvers[t]=s}static installLogger(e){this.logger=e}static log(e){null!==a.logger&&a.logger.log(e)}}t.FlowManager=a,a.plugins={resolvers:{}},a.logger=null},875:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FlowRunStatus=void 0;const r=s(985),o=s(871),n=s(851),i=s(413);class a{constructor(e,t,s){this.tasksReady=[],this.tasksByReq={},this.resolvers={},this.expectedResults=[],this.results={},this.context={},this.runOptions={},this.flow=e,this.processManager=new n.ProcessManager,this.id=a.nextId,a.nextId=(a.nextId+1)%Number.MAX_SAFE_INTEGER,this.states={Ready:new o.FlowReady(this),Running:new o.FlowRunning(this),Finished:new o.FlowFinished(this),Pausing:new o.FlowPausing(this),Paused:new o.FlowPaused(this),Stopping:new o.FlowStopping(this),Stopped:new o.FlowStopped(this)},this.state=this.states[r.FlowStateEnum.Ready],this.initRunStatus(t,s)}initRunStatus(e,t){var s,r,o,n,a;this.spec=e,this.tasks={};const u=[];for(const[e,t]of Object.entries(null!==(s=this.spec.tasks)&&void 0!==s?s:{}))u.push(...null!==(r=t.provides)&&void 0!==r?r:[]),this.tasks[e]=new i.Task(e,t);this.taskProvisions=Array.from(new Set(u)),this.options=Object.assign({},null!==(o=this.spec.configs)&&void 0!==o?o:{},null!==(n=this.spec.options)&&void 0!==n?n:{}),Object.prototype.hasOwnProperty.call(this.spec,"configs")&&this.flow.log({m:"DEPRECATED: 'configs' field in flow spec. Use 'options' instead.",l:"w"}),this.tasksByReq={},this.tasksReady=[];for(const e of Object.values(this.tasks)){e.resetRunStatus(),e.isReadyToRun()&&this.tasksReady.push(e);const t=null!==(a=e.spec.requires)&&void 0!==a?a:[];for(const s of t)void 0===this.tasksByReq[s]&&(this.tasksByReq[s]={}),this.tasksByReq[s][e.code]=e}this.results={},t&&this.fromSerializable(t)}fromSerializable(e){this.id=e.id,this.processManager.nextProcessId=e.nextProcessId,this.processManager.processes=[],this.tasksReady=e.tasksReady.map((e=>this.tasks[e])),this.tasksByReq={};for(const[t,s]of Object.entries(e.tasksByReq))this.tasksByReq[t]=s.reduce(((e,t)=>(e[t]=this.tasks[t],e)),{});this.taskProvisions=JSON.parse(JSON.stringify(e.taskProvisions)),this.expectedResults=JSON.parse(JSON.stringify(e.expectedResults)),this.results=JSON.parse(JSON.stringify(e.results)),this.context=JSON.parse(JSON.stringify(e.context)),this.options=JSON.parse(JSON.stringify(e.options));for(const[t,s]of Object.entries(e.taskStatuses))this.tasks[t].setSerializableState(s)}toSerializable(){const e={id:this.id,nextProcessId:this.processManager.nextProcessId,tasksReady:this.tasksReady.map((e=>e.code)),tasksByReq:{},taskProvisions:JSON.parse(JSON.stringify(this.taskProvisions)),expectedResults:JSON.parse(JSON.stringify(this.expectedResults)),results:JSON.parse(JSON.stringify(this.results)),context:{},options:JSON.parse(JSON.stringify(this.options)),taskStatuses:{}},t=Object.assign({},this.context);delete t.$flowed,e.context=JSON.parse(JSON.stringify(t));for(const[t,s]of Object.entries(this.tasksByReq))e.tasksByReq[t]=Object.keys(s);for(const[t,s]of Object.entries(this.tasks))e.taskStatuses[t]=JSON.parse(JSON.stringify(s.getSerializableState()));return e}}t.FlowRunStatus=a,a.nextId=1},389:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FlowFinished=void 0;const r=s(871),o=s(985);class n extends r.FlowState{getStateCode(){return o.FlowStateEnum.Finished}reset(){this.setState(o.FlowStateEnum.Ready),this.runStatus.initRunStatus(this.runStatus.spec)}getSerializableState(){return this.runStatus.toSerializable()}}t.FlowFinished=n},578:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FlowPaused=void 0;const r=s(871),o=s(985);class n extends r.FlowState{getStateCode(){return o.FlowStateEnum.Paused}resume(){return this.setState(o.FlowStateEnum.Running),this.createFinishPromise(),this.startReadyTasks(),this.runStatus.state.isRunning()||this.runStatus.state.finished(),this.runStatus.finishPromise}stop(){return this.setState(o.FlowStateEnum.Stopping),Promise.resolve(this.getResults())}getSerializableState(){return this.runStatus.toSerializable()}}t.FlowPaused=n},547:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FlowPausing=void 0;const r=s(985),o=s(823);class n extends o.FlowState{getStateCode(){return r.FlowStateEnum.Pausing}paused(e){this.setState(r.FlowStateEnum.Paused),e?(this.log({n:this.runStatus.id,m:"Flow paused with error.",e:"FP"}),this.execFinishReject(e)):(this.log({n:this.runStatus.id,m:"Flow paused.",e:"FP"}),this.execFinishResolve())}postProcessFinished(e,t){this.runStatus.state.paused(e)}}t.FlowPausing=n},106:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FlowReady=void 0;const r=s(871),o=s(985);class n extends r.FlowState{getStateCode(){return o.FlowStateEnum.Ready}start(e,t,s,r,n={}){return this.setRunOptions(n),this.log({n:this.runStatus.id,m:"Flow started with params: %O",mp:e,e:"FS"}),this.setState(o.FlowStateEnum.Running),this.setExpectedResults([...t]),this.setResolvers(s),this.setContext(r),this.supplyParameters(e),this.createFinishPromise(),this.startReadyTasks(),this.runStatus.state.isRunning()||this.runStatus.state.finished(),this.runStatus.finishPromise}getSerializableState(){return this.runStatus.toSerializable()}}t.FlowReady=n},873:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FlowRunning=void 0;const r=s(871),o=s(985);class n extends r.FlowState{getStateCode(){return o.FlowStateEnum.Running}pause(){return this.setState(o.FlowStateEnum.Pausing),this.runStatus.finishPromise}stop(){return this.setState(o.FlowStateEnum.Stopping),this.runStatus.finishPromise}finished(e=!1){this.setState(o.FlowStateEnum.Finished),e?(this.log({n:this.runStatus.id,m:"Flow finished with error. Results: %O",mp:this.getResults(),l:"e",e:"FF"}),this.execFinishReject(e)):(this.log({n:this.runStatus.id,m:"Flow finished with results: %O",mp:this.getResults(),e:"FF"}),this.execFinishResolve())}postProcessFinished(e,t){e&&t||this.runStatus.state.startReadyTasks(),this.runStatus.state.isRunning()||this.runStatus.state.finished(e)}}t.FlowRunning=n},823:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FlowState=void 0;const r=s(865),o=s(582),n=s(985),i=s(155);class a{constructor(e){this.runStatus=e}start(e,t,s,r,o={}){throw this.createTransitionError(n.FlowTransitionEnum.Start)}finished(e=!1){throw this.createTransitionError(n.FlowTransitionEnum.Finished)}pause(){throw this.createTransitionError(n.FlowTransitionEnum.Pause)}paused(e=!1){throw this.createTransitionError(n.FlowTransitionEnum.Paused)}resume(){throw this.createTransitionError(n.FlowTransitionEnum.Resume)}stop(){throw this.createTransitionError(n.FlowTransitionEnum.Stop)}stopped(e=!1){throw this.createTransitionError(n.FlowTransitionEnum.Stopped)}reset(){throw this.createTransitionError(n.FlowTransitionEnum.Reset)}execFinishResolve(){this.runStatus.finishResolve(this.runStatus.results)}execFinishReject(e){this.runStatus.finishReject(e)}isRunning(){return this.runStatus.processManager.runningCount()>0}setExpectedResults(e){const t=e.filter((e=>!this.runStatus.taskProvisions.includes(e)));if(t.length>0){const e=`The results [${t.join(", ")}] are not provided by any task`;if(this.runStatus.options.throwErrorOnUnsolvableResult)throw new Error(e);this.log({m:e,l:"w"})}this.runStatus.expectedResults=[...e]}getResults(){return this.runStatus.results}setResolvers(e){this.runStatus.resolvers=e}setContext(e){this.runStatus.context=Object.assign({$flowed:{getResolverByName:this.getResolverByName.bind(this),getResolvers:this.getResolvers.bind(this),processManager:this.runStatus.processManager,flow:this.runStatus.flow}},e)}setRunOptions(e){this.runStatus.runOptions=Object.assign({debugKey:"flow",instanceId:null,logFields:{}},e)}supplyParameters(e){for(const[t,s]of Object.entries(e))this.runStatus.state.supplyResult(t,s)}createFinishPromise(){return this.runStatus.finishPromise=new Promise(((e,t)=>{this.runStatus.finishResolve=e,this.runStatus.finishReject=t})),this.runStatus.finishPromise}getResolverForTask(e){const t=e.getResolverName(),s=this.getResolverByName(t);if(null===s)throw new Error(`Task resolver '${t}' for task '${e.code}' has no definition. Defined custom resolvers are: [${Object.keys(this.runStatus.resolvers).join(", ")}].`);return s}getResolverByName(e){const t=this.runStatus.resolvers;return void 0!==t[e]?t[e]:void 0!==i.FlowManager.plugins.resolvers[e]?i.FlowManager.plugins.resolvers[e]:void 0!==a.builtInResolvers[e]?a.builtInResolvers[e]:null}getResolvers(){const e=this.runStatus.resolvers,t=i.FlowManager.plugins.resolvers,s=a.builtInResolvers;return Object.assign(Object.assign(Object.assign({},s),t),e)}supplyResult(e,t){if(void 0!==this.runStatus.tasksByReq[e]){const s=this.runStatus.tasksByReq[e],r=Object.keys(s);for(const o of r){const r=s[o];r.supplyReq(e,t),r.isReadyToRun()&&this.runStatus.tasksReady.push(r)}}this.runStatus.expectedResults.indexOf(e)>-1&&(this.runStatus.results[e]=t)}getStateInstance(e){return this.runStatus.states[e]}startReadyTasks(){const e=this.runStatus.tasksReady;this.runStatus.tasksReady=[];for(const t of e){const e=this.runStatus.state.getResolverForTask(t),s=this.runStatus.processManager.createProcess(t,e,this.runStatus.context,!!this.runStatus.options.resolverAutomapParams,!!this.runStatus.options.resolverAutomapResults,this.runStatus.id,this.debug,this.log.bind(this)),r=e=>{this.processFinished(s,e,!0)};s.run().then((()=>{this.processFinished(s,!1,!0)}),r).catch(r),this.log({n:this.runStatus.id,m:`Task '${t.code}(${t.getResolverName()})' started, params: %O`,mp:s.getParams(),e:"TS",pid:s.pid,task:{code:t.code,type:t.getResolverName()}})}}setState(e){const t=this.runStatus.state.getStateCode();this.runStatus.state=this.getStateInstance(e),this.log({n:this.runStatus.id,m:`Changed flow state from '${t}' to '${e}'`,l:"d",e:"FC"})}getSerializableState(){throw this.createMethodError("getSerializableState")}processFinished(e,t,s){var r;this.runStatus.processManager.removeProcess(e);const o=e.task,n=o.code,i=o.spec,a=null!==(r=i.provides)&&void 0!==r?r:[],u=o.getResults(),l=Object.prototype.hasOwnProperty.call(i,"defaultResult");t?this.log({n:this.runStatus.id,m:`Error in task '${n}', results: %O`,mp:u,l:"e",e:"TF",pid:e.pid,task:{code:o.code,type:o.getResolverName()}}):this.log({n:this.runStatus.id,m:`Finished task '${n}', results: %O`,mp:u,e:"TF",pid:e.pid,task:{code:o.code,type:o.getResolverName()}});for(const e of a)Object.prototype.hasOwnProperty.call(u,e)?this.runStatus.state.supplyResult(e,u[e]):l?this.runStatus.state.supplyResult(e,i.defaultResult):this.log({n:this.runStatus.id,m:`Expected value '${e}' was not provided by task '${n}' with resolver '${o.getResolverName()}'. Consider using the task field 'defaultResult' to provide values by default.`,l:"w"});this.runStatus.state.postProcessFinished(t,s)}postProcessFinished(e,t){}createTransitionError(e){return new Error(`Cannot execute transition ${e} in current state ${this.getStateCode()}.`)}createMethodError(e){return new Error(`Cannot execute method ${e} in current state ${this.getStateCode()}.`)}debug(e,...t){const s=this&&this.runStatus&&"string"==typeof this.runStatus.runOptions.debugKey?this.runStatus.runOptions.debugKey:"init";(0,r.default)(s)(e,...t)}static formatDebugMessage({n:e,m:t,l:s,e:r}){var o;const n="w"===s?"⚠️ ":"";let i=null!==(o={FS:"▶ ",FF:"✔ ",TS:"  ‣ ",TF:"  ✓ ",FC:"  ⓘ ",FT:"◼ ",FP:"⏸ "}[r||""])&&void 0!==o?o:"";return"TF"===r&&["e","f"].includes(s||"")?i="  ✗":"FF"===r&&["e","f"].includes(s||"")&&(i="✘"),`[${e}] ${n+i}${t}`}static createLogEntry({n:e,m:t,mp:s,l:r,e:o,pid:n,task:i},a){let u={level:(e=>{switch(e=e||"i"){case"e":return"error";case"w":return"warning";case"i":return"info";case"d":return"debug";default:throw new Error(`Not supported error level: "${e}"`)}})(r),eventType:(e=>{switch(e){case"TS":return"Task.Started";case"TF":return"Task.Finished";case"FC":return"Flow.StateChanged";case"FS":return"Flow.Started";case"FF":return"Flow.Finished";case"FT":return"Flow.Stopped";case"FP":return"Flow.Paused";default:return"General"}})(o),message:((e,t)=>{if(t){const s=JSON.stringify(t);return e.replace("%O",s.length>100?s.slice(0,97)+"...":s)}return e})(t,s),timestamp:new Date,extra:{pid:n,task:i,debugId:e,values:JSON.stringify(s)}};return a&&(u.objectId=a.runOptions.instanceId,u=Object.assign(a.runOptions.logFields,u)),u}log({n:e,m:t,mp:s,l:r,e:o,pid:n,task:u}){this.debug(a.formatDebugMessage({n:e,m:t,mp:s,l:r,e:o}),[s]),i.FlowManager.log(a.createLogEntry({n:e,m:t,mp:s,l:r,e:o,pid:n,task:u},this.runStatus))}}t.FlowState=a,a.builtInResolvers={"flowed::Noop":o.NoopResolver,"flowed::Echo":o.EchoResolver,"flowed::ThrowError":o.ThrowErrorResolver,"flowed::Conditional":o.ConditionalResolver,"flowed::Wait":o.WaitResolver,"flowed::SubFlow":o.SubFlowResolver,"flowed::Repeater":o.RepeaterResolver,"flowed::Loop":o.LoopResolver,"flowed::ArrayMap":o.ArrayMapResolver,"flowed::Stop":o.StopResolver,"flowed::Pause":o.PauseResolver}},784:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FlowStopped=void 0;const r=s(871),o=s(985);class n extends r.FlowState{getStateCode(){return o.FlowStateEnum.Stopped}reset(){this.setState(o.FlowStateEnum.Ready),this.runStatus.initRunStatus(this.runStatus.spec)}getSerializableState(){return this.runStatus.toSerializable()}}t.FlowStopped=n},17:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FlowStopping=void 0;const r=s(871),o=s(985);class n extends r.FlowState{getStateCode(){return o.FlowStateEnum.Stopping}stopped(e=!1){this.setState(o.FlowStateEnum.Stopped),e?(this.log({n:this.runStatus.id,m:"Flow stopped with error.",e:"FT"}),this.execFinishReject(e)):(this.log({n:this.runStatus.id,m:"Flow stopped.",e:"FT"}),this.execFinishResolve())}postProcessFinished(e,t){this.runStatus.state.stopped(e)}}t.FlowStopping=n},871:function(e,t,s){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var o=Object.getOwnPropertyDescriptor(t,s);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,o)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),o=this&&this.__exportStar||function(e,t){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(t,s)||r(t,e,s)};Object.defineProperty(t,"__esModule",{value:!0}),o(s(823),t),o(s(106),t),o(s(389),t),o(s(578),t),o(s(547),t),o(s(873),t),o(s(784),t),o(s(17),t)},167:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Flow=void 0;const r=s(875),o=s(865),n=s(155),i=s(871);t.Flow=class{constructor(e,t){this.runStatus=new r.FlowRunStatus(this,null!=e?e:{},t)}getStateCode(){return this.runStatus.state.getStateCode()}start(e={},t=[],s={},r={},o={}){return this.runStatus.state.start(e,t,s,r,o)}pause(){return this.runStatus.state.pause()}resume(){return this.runStatus.state.resume()}stop(){return this.runStatus.state.stop()}reset(){this.runStatus.state.reset()}getSerializableState(){return this.runStatus.state.getSerializableState()}debug(e,...t){this&&this.runStatus?this.runStatus.state.debug(e,...t):(0,o.default)("init")(e,...t)}log({n:e,m:t,mp:s,l:r,e:o}){this.debug(i.FlowState.formatDebugMessage({n:e,m:t,mp:s,l:r,e:o}),[s]),n.FlowManager.log(i.FlowState.createLogEntry({n:e,m:t,mp:s,l:r,e:o},this.runStatus))}}},454:function(e,t,s){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var o=Object.getOwnPropertyDescriptor(t,s);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,o)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),o=this&&this.__exportStar||function(e,t){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(t,s)||r(t,e,s)};Object.defineProperty(t,"__esModule",{value:!0}),o(s(155),t),o(s(167),t),o(s(580),t),o(s(413),t)},851:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProcessManager=void 0;const r=s(8);t.ProcessManager=class{constructor(){this.nextProcessId=1,this.processes=[]}createProcess(e,t,s,o,n,i,a,u){this.nextProcessId++;const l=new r.TaskProcess(this,this.nextProcessId,e,t,s,o,n,i,a,u);return this.processes.push(l),l}runningCount(){return this.processes.length}removeProcess(e){const t=this.processes.findIndex((t=>t.id===e.id));this.processes.splice(t,1)}}},580:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TaskSpecMap=void 0,t.TaskSpecMap=class{}},8:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TaskProcess=void 0;class s{constructor(e,t,r,o,n,i,a,u,l,c){this.manager=e,this.id=t,this.task=r,this.taskResolverExecutor=o,this.context=n,this.automapParams=i,this.automapResults=a,this.flowId=u,this.debug=l,this.log=c,this.pid=s.nextPid,s.nextPid=(s.nextPid+1)%Number.MAX_SAFE_INTEGER}getParams(){return this.params}run(){this.params=this.task.mapParamsForResolver(this.task.runStatus.solvedReqs.popAll(),this.automapParams,this.flowId,this.log);let e,t=this.taskResolverExecutor;if(this.taskResolverExecutor.prototype&&this.taskResolverExecutor.prototype.exec){const s=new this.taskResolverExecutor;t=s.exec,e=s}return new Promise(((s,r)=>{const o=e=>{this.task.runStatus.solvedResults=this.task.mapResultsFromResolver(e,this.automapResults,this.flowId,this.log),s(this.task.runStatus.solvedResults)},n=e=>{r(e)};let i;try{i=t.call(e,this.params,this.context,this.task,this.debug,this.log)}catch(e){n(e)}const a="object"==typeof i,u=i&&i.constructor&&"Promise"===i.constructor.name;if(!a)throw new Error(`Expected resolver for task '${this.task.code}' to return an object or Promise that resolves to object. Returned value is of type '${typeof i}'.`);u?i.then(o).catch(n):o(i)}))}}t.TaskProcess=s,s.nextPid=1},413:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Task=void 0;const r=s(405),o=s(829);t.Task=class{constructor(e,t){this.code=e,this.spec=t,this.parseSpec()}getResolverName(){var e;return(null!==(e=this.spec.resolver)&&void 0!==e?e:{name:"flowed::Noop"}).name}getSerializableState(){const e=JSON.parse(JSON.stringify(this.runStatus));return e.solvedReqs=this.runStatus.solvedReqs.toSerializable(),e}setSerializableState(e){this.runStatus=JSON.parse(JSON.stringify(e)),this.runStatus.solvedReqs=r.ValueQueueManager.fromSerializable(e.solvedReqs)}resetRunStatus(){var e;const t=[...null!==(e=this.spec.requires)&&void 0!==e?e:[]];this.runStatus={solvedReqs:new r.ValueQueueManager(t),solvedResults:{}}}isReadyToRun(){return this.runStatus.solvedReqs.allHaveContent()}getResults(){return this.runStatus.solvedResults}supplyReq(e,t){var s;if(-1===(null!==(s=this.spec.requires)&&void 0!==s?s:[]).indexOf(e))throw new Error(`Requirement '${e}' for task '${this.code}' is not valid.`);this.runStatus.solvedReqs.push(e,t)}supplyReqs(e){for(const[t,s]of Object.entries(e))this.supplyReq(t,s)}mapParamsForResolver(e,t,s,r){var n,i,a;const u={};let l,c=null!==(i=(null!==(n=this.spec.resolver)&&void 0!==n?n:{}).params)&&void 0!==i?i:{};if(t){const e=(null!==(a=this.spec.requires)&&void 0!==a?a:[]).map((e=>({[e]:e}))).reduce(((e,t)=>Object.assign(e,t)),{});r({n:s,m:`  ⓘ Auto-mapped resolver params in task '${this.code}': %O`,mp:e,l:"d"}),c=Object.assign(e,c)}for(const[t,s]of Object.entries(c)){if(l=void 0,"string"==typeof s)l=e[s];else if(Object.prototype.hasOwnProperty.call(s,"value"))l=s.value;else{const t=s.transform;l=o.select(e).transformWith(t).root()}u[t]=l}return u}mapResultsFromResolver(e,t,s,r){var o,n,i;if("object"!=typeof e)throw new Error(`Expected resolver for task '${this.code}' to return an object or Promise that resolves to object. Returned value is of type '${typeof e}'.`);const a={};let u=null!==(n=(null!==(o=this.spec.resolver)&&void 0!==o?o:{}).results)&&void 0!==n?n:{};if(t){const e=(null!==(i=this.spec.provides)&&void 0!==i?i:[]).map((e=>({[e]:e}))).reduce(((e,t)=>Object.assign(e,t)),{});r({n:s,m:`  ⓘ Auto-mapped resolver results in task '${this.code}': %O`,mp:e,l:"d"}),u=Object.assign(e,u)}for(const[t,s]of Object.entries(u))Object.prototype.hasOwnProperty.call(e,t)&&(a[s]=e[t]);return a}parseSpec(){this.resetRunStatus()}}},405:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ValueQueueManager=void 0;class s{constructor(e){this.nonEmptyQueues=new Set,this.queueNames=[...e],this.queues=e.reduce(((e,t)=>(e[t]=[],e)),{})}static fromSerializable(e){const t=Object.keys(e),r=new s(t);return r.queues=e,r.nonEmptyQueues=t.reduce(((e,t)=>(r.queues[t].length>0&&e.add(t),e)),new Set),r}push(e,t){if(!this.queueNames.includes(e))throw new Error(`Queue name ${e} does not exist in queue manager. Existing queues are: [${this.queueNames.join(", ")}].`);this.nonEmptyQueues.add(e),this.queues[e].push(t)}getEmptyQueueNames(){return this.queueNames.reduce(((e,t)=>(0===this.queues[t].length&&e.push(t),e)),[])}popAll(){return this.validateAllNonEmpty(),this.queueNames.reduce(((e,t)=>(e[t]=this.queues[t].shift(),0===this.queues[t].length&&this.nonEmptyQueues.delete(t),e)),{})}topAll(){return this.validateAllNonEmpty(),this.queueNames.reduce(((e,t)=>(e[t]=this.queues[t][0],e)),{})}toSerializable(){return JSON.parse(JSON.stringify(this.queues))}validateAllNonEmpty(){if(!this.allHaveContent())throw new Error(`Some of the queues are empty: [${this.getEmptyQueueNames().join(", ")}].`)}allHaveContent(){return this.nonEmptyQueues.size===this.queueNames.length}}t.ValueQueueManager=s},590:function(e,t,s){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,s,r){void 0===r&&(r=s);var o=Object.getOwnPropertyDescriptor(t,s);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,r,o)}:function(e,t,s,r){void 0===r&&(r=s),e[r]=t[s]}),o=this&&this.__exportStar||function(e,t){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(t,s)||r(t,e,s)};Object.defineProperty(t,"__esModule",{value:!0}),o(s(985),t),o(s(454),t),o(s(582),t)},582:function(e,t,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PauseResolver=t.StopResolver=t.LoopResolver=t.ArrayMapResolver=t.RepeaterResolver=t.SubFlowResolver=t.WaitResolver=t.ConditionalResolver=t.ThrowErrorResolver=t.EchoResolver=t.NoopResolver=void 0;const r=s(454),o=s(8);t.NoopResolver=class{async exec(){return{}}},t.EchoResolver=class{async exec(e){return{out:e.in}}},t.ThrowErrorResolver=class{async exec(e){throw new Error(void 0!==e.message?e.message:"ThrowErrorResolver resolver has thrown an error")}},t.ConditionalResolver=class{async exec(e){return e.condition?{onTrue:e.trueResult}:{onFalse:e.falseResult}}},t.WaitResolver=class{async exec(e){return new Promise((t=>{setTimeout((()=>{t({result:e.result})}),e.ms)}))}},t.SubFlowResolver=class{async exec(e,t){let s=e.flowResolvers;void 0===s&&(s=t.$flowed.getResolvers());let o=await r.FlowManager.run(e.flowSpec,e.flowParams,e.flowExpectedResults,s,t,t.$flowed.flow.runStatus.runOptions);return"string"==typeof e.uniqueResult&&(o=o[e.uniqueResult]),{flowResult:o}}},t.RepeaterResolver=class{async exec(e,t,s,n,i){const a=t.$flowed.getResolverByName(e.resolver);if(null===a)throw new Error(`Task resolver '${e.resolver}' for inner flowed::Repeater task has no definition.`);const u=new r.Task("task-repeat-model",e.taskSpec),l=[];let c=[];for(let s=0;s<e.count;s++){u.resetRunStatus(),u.supplyReqs(e.taskParams);const s=new o.TaskProcess(t.$flowed.processManager,0,u,a,t,!!e.resolverAutomapParams,!!e.resolverAutomapResults,e.flowId,n,i).run();e.parallel?l.push(s):c.push(await s)}return e.parallel&&(c=await Promise.all(l)),{results:c}}},t.ArrayMapResolver=class{async exec(e,t,s,n,i){const a=t.$flowed.getResolverByName(e.resolver);if(null===a)throw new Error(`Task resolver '${e.resolver}' for inner flowed::ArrayMap task has no definition.`);const u=new r.Task("task-loop-model",e.spec),l=[];let c=[];for(const s of e.params){u.resetRunStatus(),u.supplyReqs(s);const r=new o.TaskProcess(t.$flowed.processManager,0,u,a,t,!!e.automapParams,!!e.automapResults,e.flowId,n,i).run();e.parallel?l.push(r):c.push(await r)}return e.parallel&&(c=await Promise.all(l)),{results:c}}},t.LoopResolver=class{async exec(e,t,s,n,i){const a=e.subtask.resolver.name,u=t.$flowed.getResolverByName(a);if(null===u)throw new Error(`Task resolver '${a}' for inner flowed::Loop task has no definition.`);const l=new r.Task("task-loop-model",e.subtask),c=[];let d=[];for(const s of e.inCollection){const r={[e.inItemName]:s};l.resetRunStatus(),l.supplyReqs(r);const a=new o.TaskProcess(t.$flowed.processManager,0,l,u,t,!!e.automapParams,!!e.automapResults,e.flowId,n,i).run();if(e.parallel)c.push(a);else{const t=await a;d.push(t[e.outItemName])}}return e.parallel&&(d=(await Promise.all(c)).map((t=>t[e.outItemName]))),{outCollection:d}}},t.StopResolver=class{async exec(e,t){return{promise:t.$flowed.flow.stop()}}},t.PauseResolver=class{async exec(e,t){return{promise:t.$flowed.flow.pause()}}}},985:function(e,t){"use strict";var s,r;Object.defineProperty(t,"__esModule",{value:!0}),t.TaskResolverMap=t.TaskResolver=t.FlowTransitionEnum=t.FlowStateEnum=void 0,(r=t.FlowStateEnum||(t.FlowStateEnum={})).Ready="Ready",r.Running="Running",r.Finished="Finished",r.Pausing="Pausing",r.Paused="Paused",r.Stopping="Stopping",r.Stopped="Stopped",(s=t.FlowTransitionEnum||(t.FlowTransitionEnum={})).Start="Start",s.Finished="Finished",s.Reset="Reset",s.Pause="Pause",s.Paused="Paused",s.Resume="Resume",s.Stop="Stop",s.Stopped="Stopped",t.TaskResolver=class{exec(e,t,s,r,o){return Promise.resolve({})}},t.TaskResolverMap=class{}},227:function(e,t,s){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const s="color: "+this.color;t.splice(1,0,s,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,s)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=s(447)(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},447:function(e,t,s){e.exports=function(e){function t(e){let s,o,n,i=null;function a(...e){if(!a.enabled)return;const r=a,o=Number(new Date),n=o-(s||o);r.diff=n,r.prev=s,r.curr=o,s=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((s,o)=>{if("%%"===s)return"%";i++;const n=t.formatters[o];if("function"==typeof n){const t=e[i];s=n.call(r,t),e.splice(i,1),i--}return s})),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(o!==t.namespaces&&(o=t.namespaces,n=t.enabled(e)),n),set:e=>{i=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,s){const r=t(this.namespace+(void 0===s?":":s)+e);return r.log=this.log,r}function o(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(o),...t.skips.map(o).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let s;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(s=0;s<o;s++)r[s]&&("-"===(e=r[s].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let s,r;for(s=0,r=t.skips.length;s<r;s++)if(t.skips[s].test(e))return!1;for(s=0,r=t.names.length;s<r;s++)if(t.names[s].test(e))return!0;return!1},t.humanize=s(824),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((s=>{t[s]=e[s]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let s=0;for(let t=0;t<e.length;t++)s=(s<<5)-s+e.charCodeAt(t),s|=0;return t.colors[Math.abs(s)%t.colors.length]},t.enable(t.load()),t}},829:function(e,t){!function(){var t,s={is_template:function(e){return/{{(.+)}}/g.test(e)},is_array:function(e){return Array.isArray(e)||!!e&&"object"==typeof e&&"number"==typeof e.length&&(0===e.length||e.length>0&&e.length-1 in e)},resolve:function(e,t,s){return t&&t.length>0?Function("new_val","with(this) {this"+t+"=new_val; return this;}").bind(e)(s):e=s}},r={run:function(e,t){for(var s=0;s<e.length;s++){var r=e[s],n=Object.keys(r)[0],i=o.tokenize(n);if("#if"!==i.name&&"#elseif"!==i.name)return o.run(r[n],t);var a=i.expression,u=o.fillout(t,"{{"+a+"}}");if(u==="{{"+a+"}}")return e;if(u)return o.run(r[n],t)}return null},is:function(e){if(!s.is_array(e))return!1;if(0===e.length)return!1;for(var t=!0,r=0;r<e.length;r++){var n=e[0];if("object"!=typeof n){t=!1;break}if(1!==Object.keys(n).length){t=!1;break}}if(!t)return!1;var i,a=e[0];for(var u in a){if(!(i=o.tokenize(u)))return!1;if(!i.name)return!1;if(!i.expression||0===i.expression.length)return!1;if("#if"!==i.name.toLowerCase())return!1}if(1===e.length)return!0;for(var l=!0,c=1;c<e.length-1;c++){var d=e[c];for(var p in d)if("#elseif"!==(i=o.tokenize(p)).name.toLowerCase()){l=!1;break}}if(!l)return!1;var h=e[e.length-1];for(var f in h)if(i=o.tokenize(f),-1===["#else","#elseif"].indexOf(i.name.toLowerCase()))return!1;return!0}},o={memory:{},transform:function(e,t,s,r){var o,i=null;if(/#include/.test(a(e))&&(i=function(e,t){return/#include/.test(e)||/#include/.test(t)}),s){var u=n.select(e,i,r).transform(t,r).root();o=n.select(t,null,r).inject(s,r).transformWith(u,r).root()}else o=n.select(e,i,r).transform(t,r).root();return r?a(o):o},tokenize:function(e){var t=(e=e.replace(/\{\{(.+)\}\}/g,"$1")).trim().split(" ");return t.length>0&&"#"===t[0][0]?{name:t.shift(),expression:t.join(" ")}:null},run:function(e,t){var n,i;if("string"==typeof e)s.is_template(e)?/\{\{([ ]*#include)[ ]*([^ ]*)\}\}/g.test(e)?(i=o.tokenize(e),n=i.expression?o.fillout(t,"{{"+i.expression+"}}",!0):e):n=o.fillout(t,e):n=e;else if(s.is_array(e))if(r.is(e))n=r.run(e,t);else{n=[];for(var a=0;a<e.length;a++){var u=o.run(e[a],t);n.push(u)}}else{if("[object Object]"!==Object.prototype.toString.call(e))return e;n={};var l=/\{\{([ ]*#include)[ ]*(.*)\}\}/,c=Object.keys(e).filter((function(e){return l.test(e)}));for(var d in c.length>0&&(i=o.tokenize(c[0]),n=i.expression?o.fillout(e[c[0]],"{{"+i.expression+"}}",!0):e[c[0]]),e)if(s.is_template(d))if(i=o.tokenize(d)){if("#include"===i.name);else if("#let"===i.name){if(s.is_array(e[d])&&2===e[d].length){var p=e[d][0],h=e[d][1],f=o.run(p,t);for(var m in f)o.memory[m]=f[m],t[m]=f[m];n=o.run(h,t)}}else if("#concat"===i.name)s.is_array(e[d])&&(n=[],e[d].forEach((function(e){var s=o.run(e,t);n=n.concat(s)})));else if("#merge"===i.name){if(s.is_array(e[d]))if(n={},e[d].forEach((function(e){var s=o.run(e,t);for(var r in s)n[r]=s[r]})),"object"==typeof t)for(var g in delete n.$index,o.memory)delete n[g];else for(g in delete String.prototype.$index,delete Number.prototype.$index,delete Function.prototype.$index,delete Array.prototype.$index,delete Boolean.prototype.$index,o.memory)delete String.prototype[g],delete Number.prototype[g],delete Function.prototype[g],delete Array.prototype[g],delete Boolean.prototype[g]}else if("#each"===i.name){var v=o.fillout(t,"{{"+i.expression+"}}",!0);if(v&&s.is_array(v)){n=[];for(var y=0;y<v.length;y++){if("object"==typeof v[y])for(g in v[y].$index=y,o.memory)v[y][g]=o.memory[g];else for(g in String.prototype.$index=y,Number.prototype.$index=y,Function.prototype.$index=y,Array.prototype.$index=y,Boolean.prototype.$index=y,o.memory)String.prototype[g]=o.memory[g],Number.prototype[g]=o.memory[g],Function.prototype[g]=o.memory[g],Array.prototype[g]=o.memory[g],Boolean.prototype[g]=o.memory[g];var S=o.run(e[d],v[y]);if("object"==typeof v[y])for(g in delete v[y].$index,o.memory)delete v[y][g];else for(g in delete String.prototype.$index,delete Number.prototype.$index,delete Function.prototype.$index,delete Array.prototype.$index,delete Boolean.prototype.$index,o.memory)delete String.prototype[g],delete Number.prototype[g],delete Function.prototype[g],delete Array.prototype[g],delete Boolean.prototype[g];S&&n.push(S)}}else n=e}}else{var w=o.fillout(t,d),F=o.fillout(t,e[d]);void 0!==w&&void 0!==F&&(n[w]=F)}else if("string"==typeof e[d])if((i=o.tokenize(e[d]))&&"#?"===i.name){var R=o.fillout(t,"{{"+i.expression+"}}");R!=="{{"+i.expression+"}}"&&R&&(n[d]=R)}else void 0!==(u=o.run(e[d],t))&&(n[d]=u);else void 0!==(u=o.run(e[d],t))&&(n[d]=u)}return n},fillout:function(e,t,r){var n=t;if(s.is_template(t)){var i=t.match(/{{(.*?)}}/g);if(!i)return n;if(r)n=o._fillout({variable:i[0],data:e,template:null});else for(var a=0;a<i.length;a++){var u=i[a];n=o._fillout({variable:u,data:e,template:n})}}return n},_fillout:function(e){var s=/^{{((?!}}).)*}}$/,r=e.variable,o=e.data,n=e.template;try{var i=r.replace(/{{(.*?)}}/g,"$1");if(o){["number","string","array","boolean","function"].indexOf(-1===typeof o)&&(o.$root=t);var a=function(e){return e.replace(/JSON.stringify\(/g,"JSON.stringify2(")},u=/function\([ ]*\)[ ]*{(.*)}[ ]*$/g.exec(i),l=(u?Function("with(this) {"+a(u[1])+"}").bind(o):/\breturn [^;]+;?[ ]*$/.test(i)&&/return[^}]*$/.test(i)?Function("with(this) {"+a(i)+"}").bind(o):Function("with(this) {return ("+a(i)+")}").bind(o))();return delete o.$root,l&&(l=l.valueOf()),void 0===l?n:l?n?s.test(n)?l:n.replace(r,l):l:n?s.test(n)?l:n.replace(r,""):""}return n}catch(e){return n}}},n={$val:null,$selected:[],$injected:[],$progress:null,exec:function(e,t,r){if("string"==typeof e);else if(s.is_array(e))for(var o=0;o<e.length;o++)n.exec(e[o],t+"["+o+"]",r);else for(var i in e)if("$root"!==i){if(r(i,e[i])){var a=n.$selected.length;n.$selected.push({index:a,key:i,path:t,object:e,value:e[i]})}n.exec(e[i],t+'["'+i+'"]',r)}},inject:function(e,t){n.$injected=e;try{t&&(n.$injected=JSON.parse(e))}catch(e){}return Object.keys(n.$injected).length>0&&n.select(n.$injected),n},select:function(e,t,r){var o=e;try{r&&(o=JSON.parse(e))}catch(e){}return t?(n.$selected=[],n.exec(o,"",t)):n.$selected=null,o&&(s.is_array(o)||"object"==typeof o)?(n.$progress||(s.is_array(o)?(n.$val=[],n.$selected_root=[]):(n.$val={},n.$selected_root={})),Object.keys(o).forEach((function(e){n.$val[e]=o[e],n.$selected_root[e]=o[e]}))):(n.$val=o,n.$selected_root=o),n.$progress=!0,n},transformWith:function(e,r){n.$parsed=[],n.$progress=null;var i=e;try{r&&(i=JSON.parse(e))}catch(e){}if(n.$template_root=i,String.prototype.$root=n.$selected_root,Number.prototype.$root=n.$selected_root,Function.prototype.$root=n.$selected_root,Array.prototype.$root=n.$selected_root,Boolean.prototype.$root=n.$selected_root,t=n.$selected_root,n.$selected&&n.$selected.length>0)n.$selected.sort((function(e,t){return t.path.length-e.path.length})).forEach((function(e){var t=o.run(i,e.object);n.$selected_root=s.resolve(n.$selected_root,e.path,t),e.object=t})),n.$selected.sort((function(e,t){return e.index-t.index}));else{var a=o.run(i,n.$selected_root);n.$selected_root=s.resolve(n.$selected_root,"",a)}return delete String.prototype.$root,delete Number.prototype.$root,delete Function.prototype.$root,delete Array.prototype.$root,delete Boolean.prototype.$root,n},transform:function(e,r){n.$parsed=[],n.$progress=null;var i=e;try{r&&(i=JSON.parse(e))}catch(e){}if(n.$template_root=n.$selected_root,String.prototype.$root=i,Number.prototype.$root=i,Function.prototype.$root=i,Array.prototype.$root=i,Boolean.prototype.$root=i,t=i,n.$selected&&n.$selected.length>0)n.$selected.sort((function(e,t){return t.path.length-e.path.length})).forEach((function(e){var t=o.run(e.object,i);n.$template_root=s.resolve(n.$template_root,e.path,t),n.$selected_root=n.$template_root,e.object=t})),n.$selected.sort((function(e,t){return e.index-t.index}));else{var a=o.run(n.$selected_root,i);n.$template_root=s.resolve(n.$template_root,"",a),n.$selected_root=n.$template_root}return delete String.prototype.$root,delete Number.prototype.$root,delete Function.prototype.$root,delete Array.prototype.$root,delete Boolean.prototype.$root,n},objects:function(){return n.$progress=null,n.$selected?n.$selected.map((function(e){return e.object})):[n.$selected_root]},keys:function(){return n.$progress=null,n.$selected?n.$selected.map((function(e){return e.key})):Array.isArray(n.$selected_root)?Object.keys(n.$selected_root).map((function(e){return parseInt(e)})):Object.keys(n.$selected_root)},paths:function(){return n.$progress=null,n.$selected?n.$selected.map((function(e){return e.path})):Array.isArray(n.$selected_root)?Object.keys(n.$selected_root).map((function(e){return"["+e+"]"})):Object.keys(n.$selected_root).map((function(e){return'["'+e+'"]'}))},values:function(){return n.$progress=null,n.$selected?n.$selected.map((function(e){return e.value})):Object.values(n.$selected_root)},root:function(){return n.$progress=null,n.$selected_root}},i=JSON.stringify,a=function(e,t,s){return-1!==["number","string","boolean"].indexOf(typeof e)?i(e,t,s):i(e,t||function(e,t){if(!(n.$injected&&n.$injected.length>0&&-1!==n.$injected.indexOf(e)||"$root"===e||"$index"===e||e in o.memory))return"function"==typeof t?"("+t.toString()+")":t},s)};JSON.stringify2=a;var u={TRANSFORM:o,SELECT:n,Conditional:r,Helper:s,inject:n.inject,select:n.select,transform:o.transform};e.exports&&(e.exports=u)}()},824:function(e){var t=1e3,s=60*t,r=60*s,o=24*r;function n(e,t,s,r){var o=t>=1.5*s;return Math.round(e/s)+" "+r+(o?"s":"")}e.exports=function(e,i){i=i||{};var a,u,l=typeof e;if("string"===l&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var n=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(n){var i=parseFloat(n[1]);switch((n[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*i;case"weeks":case"week":case"w":return 6048e5*i;case"days":case"day":case"d":return i*o;case"hours":case"hour":case"hrs":case"hr":case"h":return i*r;case"minutes":case"minute":case"mins":case"min":case"m":return i*s;case"seconds":case"second":case"secs":case"sec":case"s":return i*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return i;default:return}}}}(e);if("number"===l&&isFinite(e))return i.long?(a=e,(u=Math.abs(a))>=o?n(a,u,o,"day"):u>=r?n(a,u,r,"hour"):u>=s?n(a,u,s,"minute"):u>=t?n(a,u,t,"second"):a+" ms"):function(e){var n=Math.abs(e);return n>=o?Math.round(e/o)+"d":n>=r?Math.round(e/r)+"h":n>=s?Math.round(e/s)+"m":n>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},673:function(){},883:function(){},316:function(){}},t={},function s(r){var o=t[r];if(void 0!==o)return o.exports;var n=t[r]={exports:{}};return e[r].call(n.exports,n,n.exports,s),n.exports}(590);var e,t}));