@nimmsta/workflow-library 8.0.1918
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +14 -0
- package/workflow.bundle.js +2 -0
- package/workflow.bundle.js.map +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nimmsta/workflow-library",
|
|
3
|
+
"version": "8.0.1918",
|
|
4
|
+
"main": "workflow.bundle.js",
|
|
5
|
+
"types": "index.d.ts",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@nimmsta/web-library": "^8.0.1832",
|
|
9
|
+
"async-mutex": "^0.5.0",
|
|
10
|
+
"sub-events": "^1.10.1",
|
|
11
|
+
"uuid": "^11.1.0"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@nimmsta/web-library"));else if("function"==typeof define&&define.amd)define(["@nimmsta/web-library"],t);else{var r="object"==typeof exports?t(require("@nimmsta/web-library")):t(e.NimmstaWebLibrary);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,e=>(()=>{"use strict";var t={208(e,t){Object.defineProperty(t,"__esModule",{value:!0})},443(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.NIMMSTAEvalUtils=void 0;const o=r(4585);t.NIMMSTAEvalUtils=class{static transformAsyncCode=e=>e;static evalWithParams(e,t,r,n){if(e&&""!==e.trim()){try{n.debug("Evaluating",e,t);const r=Object.values(t);return new Function(...Object.keys(t),e)(...r)}catch(i){r(new o.PlatformEvalError(i,e,t)),n.error(i),n.error(i.stack)}return null}}static async evalWithParamsAsync(e,t,r,n){if(!e||""===e.trim())return;let i;try{n.debug("Evaluating async",e,t);const r=Object.keys(t),o=await Promise.all(Object.values(t));return await new Promise((t,n)=>{const s=`(async () => {\n try {\n var fn = async () => { ${e} };\n var result = await fn();\n ____resolve(result);\n } catch (error) {\n ____reject(error);\n }\n })()`;i=this.transformAsyncCode(s),new Function(...["____resolve","____reject"].concat(r),i)(t,n,...o)})}catch(s){r(new o.PlatformEvalError(s,e,t,i)),n.error(s),n.error(s.stack)}return null}static runWithCatch(e,t,r){if(void 0!==e)return()=>{try{return e()}catch(n){t(new o.PlatformEvalError(n,e.toString(),{})),r.error(n),r.error(n.stack)}}}}},510(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.unsafeStringify=void 0;const o=r(4837),n=[];for(let e=0;e<256;++e)n.push((e+256).toString(16).slice(1));function i(e,t=0){return(n[e[t+0]]+n[e[t+1]]+n[e[t+2]]+n[e[t+3]]+"-"+n[e[t+4]]+n[e[t+5]]+"-"+n[e[t+6]]+n[e[t+7]]+"-"+n[e[t+8]]+n[e[t+9]]+"-"+n[e[t+10]]+n[e[t+11]]+n[e[t+12]]+n[e[t+13]]+n[e[t+14]]+n[e[t+15]]).toLowerCase()}t.unsafeStringify=i,t.default=function(e,t=0){const r=i(e,t);if(!(0,o.default)(r))throw TypeError("Stringified UUID is invalid");return r}},517(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.StopJobController=void 0;const o=r(946),n=r(6265),i=r(2654),s=r(3600);class a extends n.WorkflowStepController{needsBackForError=!0;previousTriggerMode;static LoadingLayoutClass=i.LoadingLayout;static ErrorLayoutClass=s.ErrorLayout;execute(){this.previousTriggerMode=this.workflowController.device.preferredTriggerMode,this.workflowController.device.preferredTriggerMode=o.TriggerMode.Disabled,this.stopJob(),this.onAppearEvent()}stopJob(){const e=super.getLayoutParams();this.workflowController.setLayout(new a.LoadingLayoutClass(e.title??"Stopping Job")),this.workflowController.stop().then(()=>{this.isCurrentStep&&(this.logger.info("Job stopped"),this.workflowController.device.preferredTriggerMode=this.previousTriggerMode,this.onJobStopped())}).catch(e=>{this.isCurrentStep&&(this.logger.error("Error while stopping job",e),this.workflowController.device.triggerSOS(),this.workflowController.setLayout(new a.ErrorLayoutClass(e?.translatedRecoveryInfo??e.message)))})}onJobStopped(){this.executeEvent("onJobStopped")}onButtonEvent(e){super.onButtonEvent(e),e.name===s.ErrorLayout.RETRY_BUTTON&&this.stopJob()}}t.StopJobController=a},526(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var o=r(5608),n=r(2441),i=function(){function e(e,t){void 0===t&&(t=n.E_CANCELED),this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}return e.prototype.acquire=function(e,t){var r=this;if(void 0===e&&(e=1),void 0===t&&(t=0),e<=0)throw new Error("invalid weight ".concat(e,": must be positive"));return new Promise(function(o,n){var i={resolve:o,reject:n,weight:e,priority:t},a=s(r._queue,function(e){return t<=e.priority});-1===a&&e<=r._value?r._dispatchItem(i):r._queue.splice(a+1,0,i)})},e.prototype.runExclusive=function(e){return o.__awaiter(this,arguments,void 0,function(e,t,r){var n,i,s;return void 0===t&&(t=1),void 0===r&&(r=0),o.__generator(this,function(o){switch(o.label){case 0:return[4,this.acquire(t,r)];case 1:n=o.sent(),i=n[0],s=n[1],o.label=2;case 2:return o.trys.push([2,,4,5]),[4,e(i)];case 3:return[2,o.sent()];case 4:return s(),[7];case 5:return[2]}})})},e.prototype.waitForUnlock=function(e,t){var r=this;if(void 0===e&&(e=1),void 0===t&&(t=0),e<=0)throw new Error("invalid weight ".concat(e,": must be positive"));return this._couldLockImmediately(e,t)?Promise.resolve():new Promise(function(o){var n,i,a;r._weightedWaiters[e-1]||(r._weightedWaiters[e-1]=[]),n=r._weightedWaiters[e-1],i={resolve:o,priority:t},a=s(n,function(e){return i.priority<=e.priority}),n.splice(a+1,0,i)})},e.prototype.isLocked=function(){return this._value<=0},e.prototype.getValue=function(){return this._value},e.prototype.setValue=function(e){this._value=e,this._dispatchQueue()},e.prototype.release=function(e){if(void 0===e&&(e=1),e<=0)throw new Error("invalid weight ".concat(e,": must be positive"));this._value+=e,this._dispatchQueue()},e.prototype.cancel=function(){var e=this;this._queue.forEach(function(t){return t.reject(e._cancelError)}),this._queue=[]},e.prototype._dispatchQueue=function(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()},e.prototype._dispatchItem=function(e){var t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])},e.prototype._newReleaser=function(e){var t=this,r=!1;return function(){r||(r=!0,t.release(e))}},e.prototype._drainUnlockWaiters=function(){if(0===this._queue.length)for(var e=this._value;e>0;e--)(r=this._weightedWaiters[e-1])&&(r.forEach(function(e){return e.resolve()}),this._weightedWaiters[e-1]=[]);else{var t=this._queue[0].priority;for(e=this._value;e>0;e--){var r;if(r=this._weightedWaiters[e-1]){var o=r.findIndex(function(e){return e.priority<=t});(-1===o?r:r.splice(0,o)).forEach(function(e){return e.resolve()})}}}},e.prototype._couldLockImmediately=function(e,t){return(0===this._queue.length||this._queue[0].priority<t)&&e<=this._value},e}();function s(e,t){for(var r=e.length-1;r>=0;r--)if(t(e[r]))return r;return-1}t.default=i},788(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r="undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);t.default={randomUUID:r}},902(e,t){Object.defineProperty(t,"__esModule",{value:!0})},946(t){t.exports=e},1283(e,t){var r,o;Object.defineProperty(t,"__esModule",{value:!0}),t.PlatformControllerUIState=t.PlatformControllerState=void 0,function(e){e[e.WAITING_TO_PAIR=0]="WAITING_TO_PAIR",e[e.CONNECT_SMART_WATCH=1]="CONNECT_SMART_WATCH",e[e.IDLE=2]="IDLE",e[e.IN_WORKFLOW=3]="IN_WORKFLOW",e[e.WORKFLOW_ERROR=4]="WORKFLOW_ERROR",e[e.USER_STILL_ACTIVE=5]="USER_STILL_ACTIVE"}(r||(t.PlatformControllerState=r={})),function(e){e[e.PAIRING=0]="PAIRING",e[e.WORKFLOW=1]="WORKFLOW",e[e.ERROR=2]="ERROR",e[e.LOADING=3]="LOADING",e[e.LOGIN_ON_DEVICE=4]="LOGIN_ON_DEVICE",e[e.USER_STILL_ACTIVE=5]="USER_STILL_ACTIVE"}(o||(t.PlatformControllerUIState=o={}))},1316(e,t){Object.defineProperty(t,"__esModule",{value:!0})},1323(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CancelJobController=void 0;const o=r(946),n=r(6265),i=r(2654),s=r(3600);class a extends n.WorkflowStepController{needsBackForError=!0;previousTriggerMode;static LoadingLayoutClass=i.LoadingLayout;static ErrorLayoutClass=s.ErrorLayout;execute(){this.previousTriggerMode=this.workflowController.device.preferredTriggerMode,this.workflowController.device.preferredTriggerMode=o.TriggerMode.Disabled,this.cancelJob(),this.onAppearEvent()}cancelJob(){const e=super.getLayoutParams();this.workflowController.setLayout(new a.LoadingLayoutClass(e.title??"Cancelling Job")),this.workflowController.cancel().then(()=>{this.isCurrentStep&&(this.logger.info("Job cancelled"),this.workflowController.device.preferredTriggerMode=this.previousTriggerMode,this.onJobCancelled())}).catch(e=>{this.isCurrentStep&&(this.logger.error("Error while cancelling job",e),this.workflowController.device.triggerSOS(),this.workflowController.setLayout(new a.ErrorLayoutClass(e?.translatedRecoveryInfo??e.message)))})}onJobCancelled(){this.executeEvent("onJobCancelled")}onButtonEvent(e){super.onButtonEvent(e),e.name===s.ErrorLayout.RETRY_BUTTON&&this.cancelJob()}}t.CancelJobController=a},1389(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.PlatformUpdateAccountAction=void 0,t.PlatformUpdateAccountAction=class{name="PlatformUpdateAccountAction";isDeviceAction=!1;data;constructor(e){this.data=e.toJson()}}},1436(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.URL=t.DNS=void 0;const o=r(3375),n=r(7433);var i=r(7433);function s(e,t,r,i){return(0,n.default)(48,o.default,e,t,r,i)}Object.defineProperty(t,"DNS",{enumerable:!0,get:function(){return i.DNS}}),Object.defineProperty(t,"URL",{enumerable:!0,get:function(){return i.URL}}),s.DNS=n.DNS,s.URL=n.URL,t.default=s},1536(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i},1590(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.SaveJobController=void 0;const o=r(946),n=r(6265),i=r(9539),s=r(2654),a=r(4387);class l extends n.WorkflowStepController{needsBackForError=!0;previousTriggerMode;static LoadingLayoutClass=s.LoadingLayout;static ErrorLayoutClass=a.ErrorLayoutWithSkip;execute(){this.previousTriggerMode=this.workflowController.device.preferredTriggerMode,this.workflowController.device.preferredTriggerMode=o.TriggerMode.Disabled,this.saveJob(),this.onAppearEvent()}saveJob(){const e=super.getLayoutParams();this.workflowController.setLayout(new l.LoadingLayoutClass(e.title??"Saving Job")),this.workflowController.done().then(()=>{this.isCurrentStep&&(this.logger.info("Job saved"),this.workflowController.device.preferredTriggerMode=this.previousTriggerMode,this.onJobSaved())}).catch(e=>{this.isCurrentStep&&(this.logger.error("Error while saving job",e),this.workflowController.device.triggerSOS(),this.workflowController.setLayout(new l.ErrorLayoutClass(e?.translatedRecoveryInfo??e.message)))})}onJobSaved(){this.executeEvent("onJobSaved")}onButtonEvent(e){super.onButtonEvent(e),e.name===a.ErrorLayoutWithSkip.RETRY_BUTTON&&this.saveJob(),e.name===a.ErrorLayoutWithSkip.SKIP_BUTTON&&this.workflowController.executeWorkflowStep(i.WorkflowController.SKIP_JOB)}}t.SaveJobController=l},1625(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.WhoAmIError=void 0;const o=r(5534),n=r(1751);class i extends n.PlatformError{authFailed;get shouldShowError(){return this.cause instanceof o.HTTPError&&"error.DeviceUnlinkedException"===this.cause.json?.error||!this.authFailed}get errorCause(){return this.cause instanceof o.HTTPError?this.cause.json?.error:this.cause?.message}constructor(e,t,r){super(e,r),this.authFailed=t}toString(){return`${this.name}: ${this.message} (cause: ${this.cause})`}}t.WhoAmIError=i},1708(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.FetchFromServerAction=void 0,t.FetchFromServerAction=class{name="FetchFromServerAction";isDeviceAction=!1;data;constructor(e){this.data=e}}},1751(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.PlatformError=void 0;const o=r(4471);class n extends Error{cause;status;translatedTitle;translatedRecoveryInfo;platformContext={};_isPlatformError=!0;get isIgnorable(){return"object"==typeof this.cause&&this.cause.isIgnorable||404===this.status||0===this.status||401===this.status}constructor(e,t=void 0,r=void 0,n=void 0,i=void 0,s={}){super(e),this.cause=t,this.status=r,this.translatedTitle=n??e,this.translatedRecoveryInfo=i??e,this.platformContext=(0,o.cleanErrorContextFromCircularReferences)(s,new Set([this])),Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}get developerInfo(){let e;try{e=JSON.stringify(this.cause,o.errorAwareReplacer)}catch(t){e=`Error serializing cause: ${t.message}`}return{...this.platformContext,status:this.status?.toString(),cause:e}}}t.PlatformError=n},1914(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.URL=t.DNS=void 0;const o=r(3290),n=r(7433);var i=r(7433);function s(e,t,r,i){return(0,n.default)(80,o.default,e,t,r,i)}Object.defineProperty(t,"DNS",{enumerable:!0,get:function(){return i.DNS}}),Object.defineProperty(t,"URL",{enumerable:!0,get:function(){return i.URL}}),s.DNS=n.DNS,s.URL=n.URL,t.default=s},2023(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultWorkflow=void 0;const o=r(9539);t.DefaultWorkflow=class{static getDefaultWorkflow(){return{workflowName:"Default Workflow",workflowSteps:[{isInitialStep:!0,workflowStepName:"Default Workflow Step",layout:'<?xml version="1.0" encoding="utf-8"?><NimmstaLayout name="Initial Default Layout"><staticElements><StatusBar /><cell maxLines="0" wrapMode="wrap" fontSize="auto" textAlign="center" padding="4">Welcome to Productivity Cloud. Please define a initial step to get started.</cell>></staticElements></NimmstaLayout>'},{workflowStepName:o.WorkflowController.CANCEL_JOB,type:o.WorkflowController.CANCEL_JOB,neverStoreState:!0},{workflowStepName:o.WorkflowController.SAVE_JOB,type:o.WorkflowController.SAVE_JOB,neverStoreState:!0},{workflowStepName:o.WorkflowController.SKIP_JOB,type:o.WorkflowController.SKIP_JOB,neverStoreState:!0},{workflowStepName:o.WorkflowController.STOP_JOB,type:o.WorkflowController.STOP_JOB,neverStoreState:!0}]}}}},2064(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.updateV7State=void 0;const o=r(2706),n=r(510),i={};function s(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,0===e.seq&&e.msecs++),e}function a(e,t,r,o,n=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(o){if(n<0||n+16>o.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`)}else o=new Uint8Array(16),n=0;return t??=Date.now(),r??=127*e[6]<<24|e[7]<<16|e[8]<<8|e[9],o[n++]=t/1099511627776&255,o[n++]=t/4294967296&255,o[n++]=t/16777216&255,o[n++]=t/65536&255,o[n++]=t/256&255,o[n++]=255&t,o[n++]=112|r>>>28&15,o[n++]=r>>>20&255,o[n++]=128|r>>>14&63,o[n++]=r>>>6&255,o[n++]=r<<2&255|3&e[10],o[n++]=e[11],o[n++]=e[12],o[n++]=e[13],o[n++]=e[14],o[n++]=e[15],o}t.updateV7State=s,t.default=function(e,t,r){let l;if(e)l=a(e.random??e.rng?.()??(0,o.default)(),e.msecs,e.seq,t,r);else{const e=Date.now(),n=(0,o.default)();s(i,e,n),l=a(n,i.msecs,i.seq,t,r)}return t??(0,n.unsafeStringify)(l)}},2189(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.PlatformPairWithAction=void 0,t.PlatformPairWithAction=class{name="PlatformPairWithAction";isDeviceAction=!1;data;constructor(e){this.data=e}}},2240(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.SkipJobController=void 0;const o=r(946),n=r(6265),i=r(2654),s=r(3600);class a extends n.WorkflowStepController{needsBackForError=!0;previousTriggerMode;static LoadingLayoutClass=i.LoadingLayout;static ErrorLayoutClass=s.ErrorLayout;execute(){this.previousTriggerMode=this.workflowController.device.preferredTriggerMode,this.workflowController.device.preferredTriggerMode=o.TriggerMode.Disabled,this.skipJob(),this.onAppearEvent()}skipJob(){const e=super.getLayoutParams();this.workflowController.setLayout(new a.LoadingLayoutClass(e.title??"Skipping Job")),this.workflowController.skip().then(()=>{this.isCurrentStep&&(this.logger.info("Job skipped"),this.workflowController.device.preferredTriggerMode=this.previousTriggerMode,this.onJobSkipped())}).catch(e=>{this.isCurrentStep&&(this.logger.error("Error while skipping job",e),this.workflowController.device.triggerSOS(),this.workflowController.setLayout(new a.ErrorLayoutClass(e?.translatedRecoveryInfo??e.messa)))})}onJobSkipped(){this.executeEvent("onJobSkipped")}onButtonEvent(e){super.onButtonEvent(e),e.name===s.ErrorLayout.RETRY_BUTTON&&this.skipJob()}}t.SkipJobController=a},2425(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const o=r(788),n=r(2706),i=r(510);t.default=function(e,t,r){if(o.default.randomUUID&&!t&&!e)return o.default.randomUUID();const s=(e=e||{}).random??e.rng?.()??(0,n.default)();if(s.length<16)throw new Error("Random bytes length must be >= 16");if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t){if((r=r||0)<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[r+e]=s[e];return t}return(0,i.unsafeStringify)(s)}},2441(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.E_CANCELED=t.E_ALREADY_LOCKED=t.E_TIMEOUT=void 0,t.E_TIMEOUT=new Error("timeout while waiting for mutex to become available"),t.E_ALREADY_LOCKED=new Error("mutex already locked"),t.E_CANCELED=new Error("request for lock canceled")},2598(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.NIMSubEventState=void 0;const o=r(946);class n extends o.NIMSubEvent{_value;constructor(e){super(),this._value=e}get value(){return this._value}set value(e){this._value!==e&&this.emit(e)}subscribe(e,t){const r=super.subscribe(e,t);return e(this._value),r}emit(e,t){return this._value===e?this:(this._value=e,super.emit(e,t))}}t.NIMSubEventState=n},2654(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.LoadingLayout=void 0;const o=r(946);class n extends o.NimmstaLayout{constructor(e){super('<?xml version="1.0" encoding="utf-8"?>\n<NimmstaLayout name="Loading Layout">\n <device width="1.54" height="1.54" pxx="200" pxy="200">\n <screen default="true" name="default">\n <staticElements>\n <statusbar/>\n <cell horizontalAlignment="center" y="50" fontSize="21">Loading...</cell>\n <cell horizontalAlignment="center" padding="10pt" fontSize="17" wrapMode="wrap" maxLines="0" name="title">\n </cell>\n </staticElements>\n </screen>\n </device>\n</NimmstaLayout>',{title:e})}}t.LoadingLayout=n},2705(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.PlatformWorkflowEventController=void 0;const o=r(4200),n=r(3848),i=r(1751),s=r(6643),a=r(9899);t.PlatformWorkflowEventController=class{executionId;device;platformController;apiWrapper;evalWithContextAsyncThrow;translations;workflowResponse;_onError;setWorkflowAppData;onLocaleChanged;storeProgress;shouldUseOAuth;obtainAccessToken;defaultEndpoints;accessToken=null;idToken=null;expiresAt=null;authFlowError=!1;mutex=new o.Mutex;constructor(e,t=e.executionId,r=e.device,o=e.platformController,i=e.apiWrapper,s=e.evalWithContextAsyncThrow,a=e.translations,l=e.workflowResponse,c=e.onError,u=e.setWorkflowAppData,h=e.onLocaleChanged,d=e.storeProgress,f=e.shouldUseOAuth??!1,p=e.obtainAccessToken??(()=>Promise.resolve({accessToken:""}))){this.executionId=t,this.device=r,this.platformController=o,this.apiWrapper=i,this.evalWithContextAsyncThrow=s,this.translations=a,this.workflowResponse=l,this._onError=c,this.setWorkflowAppData=u,this.onLocaleChanged=h,this.storeProgress=d,this.shouldUseOAuth=f,this.obtainAccessToken=p,this.defaultEndpoints=new n.DefaultEndpoints(i,()=>e.platformController.whoami.value)}applyTokenResult(e){this.accessToken=e.accessToken||null,this.idToken=e.idToken??null,this.expiresAt=e.expiresAt??null}needRefresh(){if(!this.accessToken)return!0;if(null!=this.expiresAt){const e=Math.floor(Date.now()/1e3);return this.expiresAt<=e+30}return a.JwtParser.isExpired(this.accessToken,30)}async funCatchedAndMapToPlatformError(e,t,r=!0){try{return await t()}catch(o){if(o instanceof i.PlatformError)throw o;if(r&&401===o.status&&this.accessToken&&this.obtainAccessToken)try{const r=await this.obtainAccessToken(this.accessToken);return this.applyTokenResult(r),await this.funCatchedAndMapToPlatformError(e,t)}catch(e){console.log("Refreshing Token Failed",e)}const n=(0,s.platformErrorFromCause)(o,this.translations,e);throw console.log("PlatformError",n),n}}done(e,t,r=!0,o=void 0){return this.funCatchedAndMapToPlatformError("completeJob",()=>this.platformController.completeCurrentJob(e,t,r,o))}exit(e,t=!0){if(t){const t=this.platformController.currentWorkflowExecution.value?.workflow?.identifier;return this.platformController.startWorkflowByIdentifier(void 0===e.doneOrSkipWorkflowIdentifier?t:e.doneOrSkipWorkflowIdentifier)}return this.platformController.exitWorkflow(e,e.job)}cancelled(e,t,r){return this.funCatchedAndMapToPlatformError("cancelJob",()=>this.platformController.cancelCurrentJob(e,t,r))}skipped(e,t,r){return this.funCatchedAndMapToPlatformError("skipJob",()=>this.platformController.skipCurrentJob(e,t,r))}stop(e,t){return this.funCatchedAndMapToPlatformError("stopJob",()=>this.platformController.stopCurrentJob(e,t))}onError(e){if(console.error("Error in workflow handler",this.executionId,e,e?.stack),!this.executionId||this.platformController.currentWorkflowExecution.value?.id!==this.executionId)return;this._onError(e);const t="object"==typeof e&&null!==e&&"developerInfo"in e?e.developerInfo:void 0,r="object"==typeof e&&null!==e&&"stack"in e?e.stack:void 0,o="object"==typeof e&&null!==e&&"message"in e?e.message:void 0;this.apiWrapper.logEventAsync(this.executionId,{id:"error-job",results:[],app:[]},{error:JSON.stringify(e,Object.getOwnPropertyNames(e)),developerInfo:t,stack:r,message:o},"","error")}async updateProgress(e,t,r,o,n){this.executionId&&this.platformController.currentWorkflowExecution.value?.id===this.executionId&&(console.log(`Update progress for job ${r}`),!0!==e.currentWorkflowStep?.neverStoreState&&this.storeProgress({...e},{...t},{...o}),console.log(`Update progress - store progress done ${r}`),this.setWorkflowAppData(t?.app),console.log(`Update progress for job done ${r}`),await this.apiWrapper.logEventAsync(this.executionId,t,o,n,r),console.log(`Update progress - log event done ${r}`))}async fetchFromDataSource(e,t,r,o){this.platformController.isFetchingDataSource=!0;try{return await this.funCatchedAndMapToPlatformError("fetchFromDataSource",async()=>{let n=r||{};return this.shouldUseOAuth&&(this.needRefresh()&&await this.obtainAndSetAccessToken(),n={...n,header:{Authorization:`Bearer ${this.accessToken}`,...n?.header}}),this.apiWrapper.fetchFromDataSource(e,t,n,this.defaultEndpoints,this.workflowResponse,this.evalWithContextAsyncThrow,this.translations,o)})}finally{this.platformController.isFetchingDataSource=!1}}startWorkflow(e,t,r){this.platformController.startWorkflowByIdentifier(e,t,r)}createUniqueJob(e,t){return this.funCatchedAndMapToPlatformError("createUniqueJob",()=>this.apiWrapper.createUniqueJob(this.executionId,e,t,this.device))}onLocaleSet(e){this.onLocaleChanged(e)}sendEmail(e,t,r){this.apiWrapper.sendEmail(e,t,r)}async onBeforeShowWorkflowOnDevice(){this.shouldUseOAuth&&this.needRefresh()&&await this.obtainAndSetAccessToken()}async obtainAndSetAccessToken(){await this.mutex.runExclusive(async()=>{try{const e=await this.obtainAccessToken(this.accessToken);this.applyTokenResult(e)}catch(e){throw console.error("Error obtaining access token",e),(0,s.platformErrorFromCause)(e,this.translations,"obtainAndSetAccessToken")}})}}},2706(e,t){let r;Object.defineProperty(t,"__esModule",{value:!0});const o=new Uint8Array(16);t.default=function(){if(!r){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");r=crypto.getRandomValues.bind(crypto)}return r(o)}},2855(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const o=r(4837);t.default=function(e){if(!(0,o.default)(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}},3290(e,t){function r(e,t,r,o){switch(e){case 0:return t&r^~t&o;case 1:case 3:return t^r^o;case 2:return t&r^t&o^r&o}}function o(e,t){return e<<t|e>>>32-t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){const t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520],i=new Uint8Array(e.length+1);i.set(e),i[e.length]=128;const s=(e=i).length/4+2,a=Math.ceil(s/16),l=new Array(a);for(let t=0;t<a;++t){const r=new Uint32Array(16);for(let o=0;o<16;++o)r[o]=e[64*t+4*o]<<24|e[64*t+4*o+1]<<16|e[64*t+4*o+2]<<8|e[64*t+4*o+3];l[t]=r}l[a-1][14]=8*(e.length-1)/Math.pow(2,32),l[a-1][14]=Math.floor(l[a-1][14]),l[a-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<a;++e){const i=new Uint32Array(80);for(let t=0;t<16;++t)i[t]=l[e][t];for(let e=16;e<80;++e)i[e]=o(i[e-3]^i[e-8]^i[e-14]^i[e-16],1);let s=n[0],a=n[1],c=n[2],u=n[3],h=n[4];for(let e=0;e<80;++e){const n=Math.floor(e/20),l=o(s,5)+r(n,a,c,u)+h+t[n]+i[e]>>>0;h=u,u=c,c=o(a,30)>>>0,a=s,s=l}n[0]=n[0]+s>>>0,n[1]=n[1]+a>>>0,n[2]=n[2]+c>>>0,n[3]=n[3]+u>>>0,n[4]=n[4]+h>>>0}return Uint8Array.of(n[0]>>24,n[0]>>16,n[0]>>8,n[0],n[1]>>24,n[1]>>16,n[1]>>8,n[1],n[2]>>24,n[2]>>16,n[2]>>8,n[2],n[3]>>24,n[3]>>16,n[3]>>8,n[3],n[4]>>24,n[4]>>16,n[4]>>8,n[4])}},3375(e,t){function r(e){return 14+(e+64>>>9<<4)+1}function o(e,t){const r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function n(e,t,r,n,i,s){return o((a=o(o(t,e),o(n,s)))<<(l=i)|a>>>32-l,r);var a,l}function i(e,t,r,o,i,s,a){return n(t&r|~t&o,e,t,i,s,a)}function s(e,t,r,o,i,s,a){return n(t&o|r&~o,e,t,i,s,a)}function a(e,t,r,o,i,s,a){return n(t^r^o,e,t,i,s,a)}function l(e,t,r,o,i,s,a){return n(r^(t|~o),e,t,i,s,a)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(e){const t=new Uint8Array(4*e.length);for(let r=0;r<4*e.length;r++)t[r]=e[r>>2]>>>r%4*8&255;return t}(function(e,t){const n=new Uint32Array(r(t)).fill(0);n.set(e),n[t>>5]|=128<<t%32,n[n.length-1]=t,e=n;let c=1732584193,u=-271733879,h=-1732584194,d=271733878;for(let t=0;t<e.length;t+=16){const r=c,n=u,f=h,p=d;c=i(c,u,h,d,e[t],7,-680876936),d=i(d,c,u,h,e[t+1],12,-389564586),h=i(h,d,c,u,e[t+2],17,606105819),u=i(u,h,d,c,e[t+3],22,-1044525330),c=i(c,u,h,d,e[t+4],7,-176418897),d=i(d,c,u,h,e[t+5],12,1200080426),h=i(h,d,c,u,e[t+6],17,-1473231341),u=i(u,h,d,c,e[t+7],22,-45705983),c=i(c,u,h,d,e[t+8],7,1770035416),d=i(d,c,u,h,e[t+9],12,-1958414417),h=i(h,d,c,u,e[t+10],17,-42063),u=i(u,h,d,c,e[t+11],22,-1990404162),c=i(c,u,h,d,e[t+12],7,1804603682),d=i(d,c,u,h,e[t+13],12,-40341101),h=i(h,d,c,u,e[t+14],17,-1502002290),u=i(u,h,d,c,e[t+15],22,1236535329),c=s(c,u,h,d,e[t+1],5,-165796510),d=s(d,c,u,h,e[t+6],9,-1069501632),h=s(h,d,c,u,e[t+11],14,643717713),u=s(u,h,d,c,e[t],20,-373897302),c=s(c,u,h,d,e[t+5],5,-701558691),d=s(d,c,u,h,e[t+10],9,38016083),h=s(h,d,c,u,e[t+15],14,-660478335),u=s(u,h,d,c,e[t+4],20,-405537848),c=s(c,u,h,d,e[t+9],5,568446438),d=s(d,c,u,h,e[t+14],9,-1019803690),h=s(h,d,c,u,e[t+3],14,-187363961),u=s(u,h,d,c,e[t+8],20,1163531501),c=s(c,u,h,d,e[t+13],5,-1444681467),d=s(d,c,u,h,e[t+2],9,-51403784),h=s(h,d,c,u,e[t+7],14,1735328473),u=s(u,h,d,c,e[t+12],20,-1926607734),c=a(c,u,h,d,e[t+5],4,-378558),d=a(d,c,u,h,e[t+8],11,-2022574463),h=a(h,d,c,u,e[t+11],16,1839030562),u=a(u,h,d,c,e[t+14],23,-35309556),c=a(c,u,h,d,e[t+1],4,-1530992060),d=a(d,c,u,h,e[t+4],11,1272893353),h=a(h,d,c,u,e[t+7],16,-155497632),u=a(u,h,d,c,e[t+10],23,-1094730640),c=a(c,u,h,d,e[t+13],4,681279174),d=a(d,c,u,h,e[t],11,-358537222),h=a(h,d,c,u,e[t+3],16,-722521979),u=a(u,h,d,c,e[t+6],23,76029189),c=a(c,u,h,d,e[t+9],4,-640364487),d=a(d,c,u,h,e[t+12],11,-421815835),h=a(h,d,c,u,e[t+15],16,530742520),u=a(u,h,d,c,e[t+2],23,-995338651),c=l(c,u,h,d,e[t],6,-198630844),d=l(d,c,u,h,e[t+7],10,1126891415),h=l(h,d,c,u,e[t+14],15,-1416354905),u=l(u,h,d,c,e[t+5],21,-57434055),c=l(c,u,h,d,e[t+12],6,1700485571),d=l(d,c,u,h,e[t+3],10,-1894986606),h=l(h,d,c,u,e[t+10],15,-1051523),u=l(u,h,d,c,e[t+1],21,-2054922799),c=l(c,u,h,d,e[t+8],6,1873313359),d=l(d,c,u,h,e[t+15],10,-30611744),h=l(h,d,c,u,e[t+6],15,-1560198380),u=l(u,h,d,c,e[t+13],21,1309151649),c=l(c,u,h,d,e[t+4],6,-145523070),d=l(d,c,u,h,e[t+11],10,-1120210379),h=l(h,d,c,u,e[t+2],15,718787259),u=l(u,h,d,c,e[t+9],21,-343485551),c=o(c,r),u=o(u,n),h=o(h,f),d=o(d,p)}return Uint32Array.of(c,u,h,d)}(function(e){if(0===e.length)return new Uint32Array;const t=new Uint32Array(r(8*e.length)).fill(0);for(let r=0;r<e.length;r++)t[r>>2]|=(255&e[r])<<r%4*8;return t}(e),8*e.length))}},3600(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorLayout=void 0;const o=r(946);class n extends o.NimmstaLayout{static RETRY_BUTTON="retry";constructor(e){super('<?xml version="1.0" encoding="utf-8"?>\n<NimmstaLayout name="Error Layout">\n <device width="1.54" height="1.54" pxx="200" pxy="200">\n <screen default="true" name="default">\n <staticElements>\n <statusbar/>\n <cell horizontalAlignment="center" fontSize="17" wrapMode="wrap" maxLines="0" name="error"></cell>\n <button x="5" y="150" type="inverted_rounded" horizontalAlignment="center"\n width="190" height="45" name="retry">RETRY</button>\n </staticElements>\n </screen>\n </device>\n</NimmstaLayout>',{error:e})}}t.ErrorLayout=n},3684(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.PlatformCoreLibConnectorImpl=void 0;const o=r(3824),n=r(6466),i=r(4173),s=r(1389),a=r(5994),l=r(9995),c=r(2189),u=r(5534),h=r(6372),d=r(1751);t.PlatformCoreLibConnectorImpl=class{account;httpClient;connectionManager;updateAccountTimeoutRunning=!1;async pairWith(e,t){const r=await this.sendActionWithSuccessOrThrow(new c.PlatformPairWithAction({qrcode:e,deviceName:t}));return this.account=i.AccountImpl.fromJSON(r.data,()=>{this.updateAccountDelayed()}),this.account}async logEvent(e){await this.sendActionWithSuccessOrThrow(new l.PlatformLogEventAction(e))}async updateAccount(e){try{return await this.sendActionWithSuccessOrThrow(new s.PlatformUpdateAccountAction(e)),this.account}catch(e){throw new Error(`Failed to update account due to ${e.message}`)}}async uploadLogFile(){try{await this.sendActionWithSuccessOrThrow(new a.PlatformUploadLogFileAction)}catch(e){throw new d.PlatformError(`Failed to upload log file due to ${e.message}`,e)}}async sendActionWithSuccessOrThrow(e){try{const t=await this.connectionManager.sendAction(e);if(!t.success)throw this.parseErrorResponseToError(e,t);return t}catch(t){throw this.parseErrorResponseToError(e,t)}}parseErrorResponseToError(e,t){return t.data?.isHttpError?new u.HTTPError(t.data.message,t.data.status,t.data.responseText):new d.PlatformError(t.data?.message??`Failed to execute action ${e.name} due to unknown error`,new Error(t.message),-1,void 0,void 0,t.data)}async bindToConnectionManager(e,t,r){this.connectionManager=e,this.httpClient=new o.HttpClientActionImpl(e);const s=await e.sendAction(new n.PlatformGetAccountAction(t,r));if(!s.success)throw new Error(`Failed to get account due to ${s.message}`);this.account=i.AccountImpl.fromJSON(s.data,()=>{this.updateAccountDelayed()})}async updateAccountDelayed(){this.updateAccountTimeoutRunning||(this.updateAccountTimeoutRunning=!0,h.TimerUtils.setTimeout(()=>{this.updateAccountTimeoutRunning=!1,this.updateAccount(this.account)},500))}}},3741(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.defaultIdleWorkflow=void 0;const o=r(946);t.defaultIdleWorkflow=()=>({id:"DefaultIdleWorkflow",identifier:"default-idle",lastUpdatedAt:"",definition:{workflowName:"Idle Workflow1",created:"2023-02-14T01:51:09.871Z",updated:"2023-02-14T01:51:09.871Z",description:"Idle workflow",workflowSteps:[{workflowStepName:"Idle Step",isInitialStep:!0,triggerMode:o.TriggerMode.Disabled,layout:'\n <?xml version="1.0" encoding="utf-8"?>\n <NimmstaLayout name="Open Jobs Layout">\n <staticElements>\n <statusbar/>\n <cell horizontalAlignment="center" fontSize="17pt" padding="4" fontFamily="Bahnschrift_SemiBold" y="40" wrapMode="wrap" maxLines="2" name="workflow">Ready to Work</cell>\n <cell horizontalAlignment="center" fontSize="auto" wrapMode="wrap" padding="10" paddingTop="0" paddingBottom="35" maxLines="0" name="error"></cell>\n <button horizontalAlignment="center" y="140" height="60" name="start-first-job">Start Working</button>\n </staticElements>\n </NimmstaLayout>\n ',layoutParams:{workflow:"workflowStep.lastError != null ? (workflowStep.lastError?.translatedTitle ?? translations.error) : workflowStep.whoAmI == null ? translations.ready_to_work : translations.hello_comma + workflowStep.whoAmI?.firstName + ' ' + workflowStep.whoAmI?.lastName",error:'workflowStep.lastError?.translatedRecoveryInfo ?? ""',"start-first-job":"translations.start_working"},loadData:{endpoint:"_legacy/whoami",preProcessCode:"workflowStep.lastError = null",postProcessCode:"workflowStep.whoAmI = response;",onError:[{code:"workflowStep.lastError = data.error"}]},onButtonPress:[{condition:'data.button.name == "start-first-job"',targetWorkflow:"default/StartWorkerWorkflow"}]}]}})},3824(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.HttpClientActionImpl=void 0;const o=r(1708),n=r(5534);t.HttpClientActionImpl=class{connectionManager;constructor(e){this.connectionManager=e}async executeRequest(e,t,r,i,s){const a=await this.connectionManager.sendAction(new o.FetchFromServerAction({url:e,method:t,headers:r,body:i}));if(s?.aborted){const e=new Error("Request was aborted");throw e.name="AbortError",e}if(a.success){const t=a.data;if(!t.ok)throw new n.HTTPError(`Error fetching from ${e} response with status ${t.status}`,t.status,t.responseText);return t}throw new Error(`Failed to fetch data from server with error: ${a.message}`)}}},3848(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultEndpoints=void 0,t.DefaultEndpoints=class{api;whoAmIFetch;defaultEndpoints={"_legacy/whoami":async e=>this.whoAmIFetch()??this.api.fetchWhoAmIAsync()};constructor(e,t){this.api=e,this.whoAmIFetch=t,this.api=e}}},3897(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.UserStillActiveLayout=void 0;const o=r(946);class n extends o.NimmstaLayout{constructor(e="Are you still Working?",t="No - Stop Job",r="Warning",o="Yes"){super('\n <?xml version="1.0" encoding="utf-8"?>\n <NimmstaLayout name="Workflow Error Layout">\n <staticElements>\n <statusbar/>\n <cell horizontalAlignment="center" y="30" fontSize="22pt" name="title">Warning</cell>\n <cell horizontalAlignment="center" wrapMode="wrap" maxLines="2" paddingBottom="5pt" name="stillWorking"></cell>\n <button horizontalAlignment="center" name="continue-workflow">Yes</button>\n <button horizontalAlignment="center" y="165" name="stop-job"></button>\n </staticElements>\n </NimmstaLayout>\n ',{stillWorking:e,"stop-job":t,title:r,"continue-workflow":o})}}t.UserStillActiveLayout=n},3954(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.DeviceAPIWrapper=void 0;const o=r(946),n=r(8855),i=r(6643),s=r(1751),a=r(9539),l=r(5120);t.DeviceAPIWrapper=class{api;cachedDataConnectionInfo={};logger;constructor(e){this.api=e,this.logger=o.Logger.for("DeviceAPIWrapper")}clearCache(){this.cachedDataConnectionInfo={}}async getOperationsData(e,t=!1){if(e.deviceState?.isConnected&&(t||void 0===e.lastOperationData)){const t=await e.sendAction(new l.GetOperationDataAction);if(t.success){const r=t.data;return e.lastOperationData=r,r}throw new Error("Failed to get operation data")}return e.lastOperationData}async smartWatchConnected(e,t){const r=await e.getDeviceInfo();this.logger.debug("Got device info response",r,e?.deviceState),await this.api.smartWatchConnectedAsync({deviceSerial:e?.serialNumber,deviceType:"HS 50",deviceAddress:e?.address,deviceVersions:e?.deviceState?.bleFirmwareVersion?e.deviceState:null,operationsData:JSON.stringify(await this.getOperationsData(e,!0)??{})},t)}async smartWatchDisconnected(e,t,r){void 0!==e?.serialNumber&&this.api.smartWatchDisconnectedAsync({deviceSerial:e?.serialNumber,deviceType:"HS 50",deviceAddress:e?.address,deviceVersions:e?.deviceState?.bleFirmwareVersion?e.deviceState:null,operationsData:JSON.stringify(await this.getOperationsData(e,!0)??{})},t,r)}async fetchFromDataSource(e,t,r,o,n,a,l,c){try{if(this.logger.debug("Fetch from data source",e,t,r,n.dataConnection?.identifier),void 0!==o.defaultEndpoints[t])return await o.defaultEndpoints[t](r);const i=await this.getEndpointInfoFromCacheOrCloud(e,t,n,c),s={request:r,requestOverride:r,endpoint:i};if(i?.preprocess){const e=await a(i.preprocess,s);e&&(s.request=e)}const l={response:await this.api.executeDataSourceEndpointAsync(e??n.dataConnection?.identifier,t,s.request,c)};if(i?.postprocess){const e=await a(i.postprocess,l);e&&(l.response=e)}return l.response}catch(e){const t=(0,i.getErrorUserMessageTitle)(e,l,"fetchFromDataSource");throw new s.PlatformError(t,e,e.status,t,(0,i.getErrorUserMessageRecoveryInfo)(e,l,"fetchFromDataSource"))}}async getEndpointInfoFromCacheOrCloud(e,t,r,o){if(!e||r.dataConnection?.identifier===e){const e=r.dataConnection?.endpoints.find(e=>e.identifier===t);return e}const n=`${e}/${t}`;if(void 0!==this.cachedDataConnectionInfo[n])return this.cachedDataConnectionInfo[n];if(!e&&!r.dataConnection?.identifier)throw new Error("No data connection identifier found");const i=await this.api.getEndpointFromDataSourceAsync(e??r.dataConnection?.identifier,t,o);return this.cachedDataConnectionInfo[n]=i,i}async fetchWhoAmIAsync(e,t){return this.api.fetchWhoAmIAsync(e,t?.serialNumber)}async logEventAsync(e,t,r,o,i){const s=(0,n.v4)();this.api.logEventAsync({eventId:s,executionId:e,eventName:i,results:t?.results??t,eventData:r,condition:o,timestamp:new Date})}async pairWithAsync(e,t){return this.api.pairWithAsync(e,t)}async stopJob(e){return this.api.stopJobAsync(e)}async cancelJob(e){return this.api.cancelJobAsync(e)}async skipJob(e){return this.api.skipJobAsync(e)}async startWorkflowWithIdentifier(e,t,r,o,n,i){let s=e;return"default/StartWorkerWorkflow"!==e&&"default/StartWorkerWorkflow"!==e||(s=null),this.api.startNextWorkflowAsync(s,{eventName:"startWorkflow",executionId:o,results:t?.results??t,job:t,timestamp:new Date,device:{deviceSerial:n?.serialNumber,deviceType:"HS 50",deviceAddress:n?.address,deviceVersions:n?.deviceState?.bleFirmwareVersion?n.deviceState:null,operationsData:JSON.stringify(await this.getOperationsData(n)??{})}},r,a.WorkflowController.supportedSchemaVersion,i)}async completeJob(e,t,r,o,n){return this.api.completeJobAsync({eventName:"completeJob",executionId:e,results:t?.results??t,data:{workflow:r,job:t,date:Date.now()},timestamp:new Date,device:{deviceSerial:o?.serialNumber,deviceType:"HS 50",deviceAddress:o?.address,deviceVersions:o?.deviceState?.bleFirmwareVersion?o.deviceState:null,operationsData:JSON.stringify(await this.getOperationsData(o)??{})}},n)}async createUniqueJob(e,t,r,o,n){return this.api.createUniqueJob({eventName:"createUniqueJob",executionId:e,results:r?.results??r,data:{workflow:t,job:r,date:Date.now()},timestamp:new Date,device:{deviceSerial:o?.serialNumber,deviceType:"HS 50",deviceAddress:o?.address,deviceVersions:o?.deviceState?.bleFirmwareVersion?o.deviceState:null,operationsData:JSON.stringify(await this.getOperationsData(o)??{})}},n)}async uploadCurrentLogFile(){return this.api.uploadCurrentLogFile()}async sendEmail(e,t,r){return this.api.sendEmail(e,t,r)}}},4173(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.AccountImpl=void 0;const o=r(8855);class n{_whoAmI;_currentExecution;_userId;_deviceId;_serverUri;_isLoggedIn;_onUpdated;constructor(e,t,r,n,i,s,a){this._whoAmI=e,this._userId=t,this._deviceId=r??(0,o.v4)(),this._serverUri=n,this._currentExecution=i,this._isLoggedIn=s,this._onUpdated=a,r||this._onUpdated(this)}get whoAmI(){return this._whoAmI}set whoAmI(e){this._whoAmI=e,this._isLoggedIn=!!e,this._onUpdated(this)}get userId(){return this._userId}set userId(e){this._userId=e,this._onUpdated(this)}get deviceId(){return this._deviceId}set deviceId(e){this._deviceId=e,this._onUpdated(this)}get serverUri(){return this._serverUri}set serverUri(e){this._serverUri=e,this._onUpdated(this)}get isProduction(){return!this.serverUri||!this.serverUri.includes("nimmsta-test.de")&&!this.serverUri.includes("localhost")&&!this.serverUri.includes("127.0.0.1")}get testEnvironment(){const e=this._serverUri.split(".");return e.length>2?`${e[1]} Environment`:"Test Environment"}get currentExecution(){return this._currentExecution}set currentExecution(e){this._currentExecution=e,this._onUpdated(this)}static fromJSON(e,t){return new n(e?.whoAmI??e?._whoAmI,e?.userId??e?._userId,e?.deviceId??e?._deviceId,e?.serverUri??e?._serverUri??n.defaultProdUris[0],e?.currentExecution??e?._currentExecution??e?.currentJob??e?._currentJob,e?.isLoggedIn??e?._isLoggedIn??!1,t)}toJson(){return{whoAmI:this._whoAmI,userId:this._userId,deviceId:this._deviceId,serverUri:this._serverUri,currentExecution:this._currentExecution}}get isLoggedIn(){return this._isLoggedIn}static defaultProdUris=["https://backend.cloud.nimmsta.com/api/v1/","https://workflow-backend.workflow.nimmsta.com/api/v1/","https://backend.cloud.nimmsta.com/api/v1","https://workflow-backend.workflow.nimmsta.com/api/v1"]}t.AccountImpl=n},4200(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.tryAcquire=t.withTimeout=t.Semaphore=t.Mutex=void 0;var o=r(5608),n=r(9195);Object.defineProperty(t,"Mutex",{enumerable:!0,get:function(){return n.default}});var i=r(526);Object.defineProperty(t,"Semaphore",{enumerable:!0,get:function(){return i.default}});var s=r(7867);Object.defineProperty(t,"withTimeout",{enumerable:!0,get:function(){return s.withTimeout}});var a=r(8561);Object.defineProperty(t,"tryAcquire",{enumerable:!0,get:function(){return a.tryAcquire}}),o.__exportStar(r(2441),t)},4324(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ActionController=void 0,t.ActionController=class{workflowController;action;workflow;data;additionalContext;onFinishedRequest;constructor(e,t,r,o={},n={},i=()=>{}){this.workflowController=e,this.action=t,this.workflow=r,this.data=o,this.additionalContext=n,this.onFinishedRequest=i}execute(){if(this.action.actionName){if(Object.keys(this.action).some(e=>"actionName"!==e))throw new Error('For an action with "actionName", only "actionName" should be defined.');for(const e of this.workflow.actions)if(this.action.actionName===e.actionName){this.action=e;break}}this.action.ledBurst&&this.workflowController.device.triggerLEDBurst(this.action.ledBurst),this.action.vibratorBurst&&this.workflowController.device.triggerVibratorBurst(this.action.vibratorBurst),this.action.beeperBurst&&this.workflowController.device.triggerBeeperBurst(this.action.beeperBurst),this.action.code&&this.workflowController.evalWithContext(this.action.code,{...this.additionalContext,data:this.data},this.onFinishedRequest)}}},4387(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorLayoutWithSkip=void 0;const o=r(946);class n extends o.NimmstaLayout{static SKIP_BUTTON="skip";static RETRY_BUTTON="retry";constructor(e,t="SKIP"){super('<?xml version="1.0" encoding="utf-8"?>\n<NimmstaLayout name="Error Layout">\n <device width="1.54" height="1.54" pxx="200" pxy="200">\n <screen default="true" name="default">\n <staticElements>\n <statusbar/>\n <cell horizontalAlignment="center" fontSize="17" wrapMode="wrap" maxLines="0" name="error"></cell>\n <button x="5" y="101" type="inverted_rounded" horizontalAlignment="center"\n width="190" height="45" name="retry">RETRY</button>\n <button x="5" y="149" type="inverted_rounded" horizontalAlignment="center"\n width="190" height="45" name="skip">SKIP</button>\n </staticElements>\n </screen>\n </device>\n</NimmstaLayout>',{error:e,skip:t})}}t.ErrorLayoutWithSkip=n},4464(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.Job=void 0;const o=r(8855);class n{id;job;name;status="IN_PROGRESS";articles=[];data;results=[];uniqueKey;completeJobOnStop;app;isJobClass=!0;currentArticleIndex;get currentArticle(){return this.results[this.currentArticleIndex]}constructor(e,t,r=(0,o.v4)(),n="IN_PROGRESS"){this.job=e,this.name=e,this.id=r,this.status=n,this.articles=t.map(e=>({...e})),this.currentArticleIndex=0,this.articles.forEach(e=>{const t={scannedArticles:e.scannedArticles??0,...e};this.results.push(t)}),this.data=this.articles}fixJobDataReferenceAndInit(e){if(this.app&&Array.isArray(this.app)&&(this.app=this.app.map(e=>{const t={...e},r=this;return Object.entries(e).forEach(([e,o])=>{JSON.stringify(o)===JSON.stringify(r.results)?t[e]=r.results:o===r.name?t[e]=r.name:JSON.stringify(o)===JSON.stringify(r.articles)&&(t[e]=r.articles)}),t})),!0===e?.completeJobOnStop&&!1!==this.completeJobOnStop&&(this.completeJobOnStop=e.completeJobOnStop),!1===e?.resetJobOnStop&&0===this.currentArticleIndex){this.results.sort((e,t)=>e.check===t.check?0:e.check?-1:1);let e=-1;this.results.forEach((t,r)=>{t.check&&(e=r)}),e>=0&&(this.currentArticleIndex=e+1)}}static fromNameAndArticles(e,t,r){const o=new n(e,t);return o.fixJobDataReferenceAndInit(r),o}static fromJSON(e,t){if(null==e)return e;if("object"!=typeof e)throw new Error("JSON must be an object");if(e instanceof n)return e;if(e.data?.isJobClass)return n.fromJSON(e.data,t);if(!e.isJobClass){if(e.name&&Array.isArray(e.data)){const r=e.result&&!1===t?.resetJobOnStop&&Array.isArray(e.result)&&e.result.length>0?e.result:e.data,o=new n(e.name,r);return o.id=e.id,o.status=e.status,o.fixJobDataReferenceAndInit(t),o}return e}const r=new n(e.job,e.articles);return r.id=e.id??r.id,r.status=e.status??r.status,r.app=e.app,r.currentArticleIndex=e.currentArticleIndex,r.results=e.results??[],r.uniqueKey=e.uniqueKey,r.data=e.data,r.app=e.app,r.completeJobOnStop=e.completeJobOnStop??t?.completeJobOnStop,Object.keys(e).forEach(t=>{Object.keys(r).includes(t)||(r[t]=e[t])}),r.fixJobDataReferenceAndInit(t),r}}t.Job=n},4471(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.errorAwareReplacer=function(e,t){if(t instanceof Error){const e={name:t.name,message:t.message,stack:t.stack};return Object.getOwnPropertyNames(t).forEach(r=>{r in e||(e[r]=t[r])}),e}return t},t.cleanErrorContextFromCircularReferences=function e(t,r=new Set){if("object"!=typeof t||null===t)return t;if(r.has(t))return"[Circular]";r.add(t);const o={};for(const[n,i]of Object.entries(t))o[n]=e(i,r);return o}},4480(e,t){Object.defineProperty(t,"__esModule",{value:!0})},4585(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.PlatformEvalError=void 0;const o=r(4471),n=r(1751);class i extends n.PlatformError{code;asyncCode;context;errorCorrelation;get isIgnorable(){return!1}constructor(e,t,r={},o=void 0){const n=Math.random().toString(36).substring(2,15);super(`Error executing code ${n}`),this.errorCorrelation=n,this.cause=e,this.code=t,this.asyncCode=o,this.context=Object.fromEntries(Object.entries(r??{}).map(([e,t])=>"device"===e?["device","device"]:[e,t])),Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}get developerInfo(){let e;try{e=JSON.stringify(this.context,o.errorAwareReplacer)}catch(t){e=`Error serializing context: ${t.message}`}return{...super.developerInfo,code:this.code,asyncCode:this.asyncCode,context:e,correlation:this.errorCorrelation}}}t.PlatformEvalError=i},4687(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.PairAppLayout=void 0;const o=r(946);class n extends o.NimmstaLayout{constructor(e="Pair App",t="Scan the QR code using the Smart Watch or Camera."){super('\n <?xml version="1.0" encoding="utf-8"?>\n <NimmstaLayout name="Pair App Layout">\n <staticElements>\n <statusbar/>\n <cell horizontalAlignment="center" fontSize="22pt" y="40" name="title">Pair App</cell>\n <cell horizontalAlignment="center" wrapMode="wrap" name="description" padding="4pt" maxLines="4">Scan the QR code using the Smart Watch or Camera.</cell>\n </staticElements>\n </NimmstaLayout>\n ',{title:e,description:t})}}t.PairAppLayout=n},4806(e,t){Object.defineProperty(t,"__esModule",{value:!0})},4837(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const o=r(1536);t.default=function(e){return"string"==typeof e&&o.default.test(e)}},5120(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.GetOperationDataAction=void 0,t.GetOperationDataAction=class{name="GetOperationDataAction";isDeviceAction=!0}},5142(e,t){Object.defineProperty(t,"__esModule",{value:!0})},5191(e,t){Object.defineProperty(t,"__esModule",{value:!0})},5407(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.PairingError=void 0;const o=r(1751);class n extends o.PlatformError{toString(){return`${this.name}: ${this.message} (cause: ${this.cause})`}}t.PairingError=n},5534(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.HTTPError=void 0;const o=r(1751);class n extends o.PlatformError{response;get isIgnorable(){return 404===this.status||"error.no_job_pending"===this.json?.error}constructor(e,t,r,o){super(e,o),this.status=t,this.response=r}get json(){try{return JSON.parse(this.response)}catch{return null}}toString(){return`${this.name}: ${this.message} (${this.status})\n${this.response}`}}t.HTTPError=n},5608(e,t,r){r.r(t),r.d(t,{__addDisposableResource:()=>j,__assign:()=>i,__asyncDelegator:()=>C,__asyncGenerator:()=>E,__asyncValues:()=>A,__await:()=>S,__awaiter:()=>p,__classPrivateFieldGet:()=>x,__classPrivateFieldIn:()=>D,__classPrivateFieldSet:()=>L,__createBinding:()=>g,__decorate:()=>a,__disposeResources:()=>N,__esDecorate:()=>c,__exportStar:()=>v,__extends:()=>n,__generator:()=>w,__importDefault:()=>O,__importStar:()=>P,__makeTemplateObject:()=>W,__metadata:()=>f,__param:()=>l,__propKey:()=>h,__read:()=>y,__rest:()=>s,__rewriteRelativeImportExtension:()=>U,__runInitializers:()=>u,__setFunctionName:()=>d,__spread:()=>_,__spreadArray:()=>k,__spreadArrays:()=>b,__values:()=>m,default:()=>R});var o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},o(e,t)};function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var i=function(){return i=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},i.apply(this,arguments)};function s(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r}function a(e,t,r,o){var n,i=arguments.length,s=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,o);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(i<3?n(s):i>3?n(t,r,s):n(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s}function l(e,t){return function(r,o){t(r,o,e)}}function c(e,t,r,o,n,i){function s(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var a,l=o.kind,c="getter"===l?"get":"setter"===l?"set":"value",u=!t&&e?o.static?e:e.prototype:null,h=t||(u?Object.getOwnPropertyDescriptor(u,o.name):{}),d=!1,f=r.length-1;f>=0;f--){var p={};for(var w in o)p[w]="access"===w?{}:o[w];for(var w in o.access)p.access[w]=o.access[w];p.addInitializer=function(e){if(d)throw new TypeError("Cannot add initializers after decoration has completed");i.push(s(e||null))};var g=(0,r[f])("accessor"===l?{get:h.get,set:h.set}:h[c],p);if("accessor"===l){if(void 0===g)continue;if(null===g||"object"!=typeof g)throw new TypeError("Object expected");(a=s(g.get))&&(h.get=a),(a=s(g.set))&&(h.set=a),(a=s(g.init))&&n.unshift(a)}else(a=s(g))&&("field"===l?n.unshift(a):h[c]=a)}u&&Object.defineProperty(u,o.name,h),d=!0}function u(e,t,r){for(var o=arguments.length>2,n=0;n<t.length;n++)r=o?t[n].call(e,r):t[n].call(e);return o?r:void 0}function h(e){return"symbol"==typeof e?e:"".concat(e)}function d(e,t,r){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function f(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function p(e,t,r,o){return new(r||(r=Promise))(function(n,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})}function w(e,t){var r,o,n,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(r=1,o&&(n=2&a[0]?o.return:a[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,a[1])).done)return n;switch(o=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,o=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!((n=(n=i.trys).length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){i.label=a[1];break}if(6===a[0]&&i.label<n[1]){i.label=n[1],n=a;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(a);break}n[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],o=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}var g=Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]};function v(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||g(t,e,r)}function m(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],o=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function y(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var o,n,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)s.push(o.value)}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return s}function _(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(y(arguments[t]));return e}function b(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var o=Array(e),n=0;for(t=0;t<r;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,n++)o[n]=i[s];return o}function k(e,t,r){if(r||2===arguments.length)for(var o,n=0,i=t.length;n<i;n++)!o&&n in t||(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))}function S(e){return this instanceof S?(this.v=e,this):new S(e)}function E(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,n=r.apply(e,t||[]),i=[];return o=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",function(e){return function(t){return Promise.resolve(t).then(e,c)}}),o[Symbol.asyncIterator]=function(){return this},o;function s(e,t){n[e]&&(o[e]=function(t){return new Promise(function(r,o){i.push([e,t,r,o])>1||a(e,t)})},t&&(o[e]=t(o[e])))}function a(e,t){try{(r=n[e](t)).value instanceof S?Promise.resolve(r.value.v).then(l,c):u(i[0][2],r)}catch(e){u(i[0][3],e)}var r}function l(e){a("next",e)}function c(e){a("throw",e)}function u(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function C(e){var t,r;return t={},o("next"),o("throw",function(e){throw e}),o("return"),t[Symbol.iterator]=function(){return this},t;function o(o,n){t[o]=e[o]?function(t){return(r=!r)?{value:S(e[o](t)),done:!1}:n?n(t):t}:n}}function A(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=m(e),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(r){t[r]=e[r]&&function(t){return new Promise(function(o,n){!function(e,t,r,o){Promise.resolve(o).then(function(t){e({value:t,done:r})},t)}(o,n,(t=e[r](t)).done,t.value)})}}}function W(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var I=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},T=function(e){return T=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},T(e)};function P(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=T(e),o=0;o<r.length;o++)"default"!==r[o]&&g(t,e,r[o]);return I(t,e),t}function O(e){return e&&e.__esModule?e:{default:e}}function x(e,t,r,o){if("a"===r&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?o:"a"===r?o.call(e):o?o.value:t.get(e)}function L(e,t,r,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,r):n?n.value=r:t.set(e,r),r}function D(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function j(e,t,r){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var o,n;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");o=t[Symbol.asyncDispose]}if(void 0===o){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");o=t[Symbol.dispose],r&&(n=o)}if("function"!=typeof o)throw new TypeError("Object not disposable.");n&&(o=function(){try{n.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:o,async:r})}else r&&e.stack.push({async:!0});return t}var M="function"==typeof SuppressedError?SuppressedError:function(e,t,r){var o=new Error(r);return o.name="SuppressedError",o.error=e,o.suppressed=t,o};function N(e){function t(t){e.error=e.hasError?new M(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}var r,o=0;return function n(){for(;r=e.stack.pop();)try{if(!r.async&&1===o)return o=0,e.stack.push(r),Promise.resolve().then(n);if(r.dispose){var i=r.dispose.call(r.value);if(r.async)return o|=2,Promise.resolve(i).then(n,function(e){return t(e),n()})}else o|=1}catch(e){t(e)}if(1===o)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}function U(e,t){return"string"==typeof e&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,r,o,n,i){return r?t?".jsx":".js":!o||n&&i?o+n+"."+i.toLowerCase()+"js":e}):e}const R={__extends:n,__assign:i,__rest:s,__decorate:a,__param:l,__esDecorate:c,__runInitializers:u,__propKey:h,__setFunctionName:d,__metadata:f,__awaiter:p,__generator:w,__createBinding:g,__exportStar:v,__values:m,__read:y,__spread:_,__spreadArrays:b,__spreadArray:k,__await:S,__asyncGenerator:E,__asyncDelegator:C,__asyncValues:A,__makeTemplateObject:W,__importStar:P,__importDefault:O,__classPrivateFieldGet:x,__classPrivateFieldSet:L,__classPrivateFieldIn:D,__addDisposableResource:j,__disposeResources:N,__rewriteRelativeImportExtension:U}},5631(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const o=r(6784),n=r(510);t.default=function(e){const t=(r="string"==typeof e?(0,o.default)(e):e,Uint8Array.of((15&r[6])<<4|r[7]>>4&15,(15&r[7])<<4|(240&r[4])>>4,(15&r[4])<<4|(240&r[5])>>4,(15&r[5])<<4|(240&r[0])>>4,(15&r[0])<<4|(240&r[1])>>4,(15&r[1])<<4|(240&r[2])>>4,96|15&r[2],r[3],r[8],r[9],r[10],r[11],r[12],r[13],r[14],r[15]));var r;return"string"==typeof e?(0,n.unsafeStringify)(t):t}},5755(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.TransitionControllerFactory=void 0;const o=r(7525);class n{static customControllers=new Map;static createTransitionController(e,t,r,n,i,s={},a={},l){return n.type?this.customControllers.has(n.type)?new(this.customControllers.get(n.type))(e,t,r,n,i,s,a,l):void console.error("Custom type set but no Controller is registered!"):new o.TransitionController(e,t,r,n,i,s,a,l)}static registerTransitionController(e,t){this.customControllers.set(e,t)}}t.TransitionControllerFactory=n},5884(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.SoftwareAPIImpl=void 0,t.SoftwareAPIImpl=class{platformConnector;constructor(e){this.platformConnector=e}async getLatestAppVersion(e,t){const r=await this.platformConnector.httpClient.executeRequest(`software/${e}/artifacts/latest`,"GET",{},null,t);return JSON.parse(r.responseText)}}},5994(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.PlatformUploadLogFileAction=void 0,t.PlatformUploadLogFileAction=class{name="PlatformUploadLogFileAction";isDeviceAction=!1}},6144(e,t){Object.defineProperty(t,"__esModule",{value:!0})},6167(e,t){Object.defineProperty(t,"__esModule",{value:!0})},6265(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.WorkflowStepController=void 0;const o=r(946),n=r(5755),i=r(6372);t.WorkflowStepController=class{workflowController;workflow;workflowStep;needsBackForError=!1;logger;loadedData=!1;abortController=new AbortController;isVisible=!1;lastRenderedLayoutData;get isCurrentStep(){return this.workflowController.workflow.currentWorkflowStep===this.workflowStep&&this.workflowController.isVisible}get allowStopJob(){return this.workflowStep.allowStopJob}constructor(e,t,r){this.workflowController=e,this.workflow=t,this.workflowStep=r,this.logger=o.Logger.for(`WorkflowStepController+${r.workflowStepName}`)}execute(){if(console.log("execute",this.workflowStep.workflowStepName),this.lastRenderedLayoutData=null,this.workflowStep.triggerMode){let e=this.workflowStep.triggerMode;void 0===this.workflowController.device.supportsTriggerMode&&e!==o.TriggerMode.Button&&e!==o.TriggerMode.ButtonAndTouch&&e!==o.TriggerMode.Touch&&e!==o.TriggerMode.Disabled&&(e=o.TriggerMode.ButtonAndTouch),this.workflowController.device.preferredTriggerMode=e}this.renderLayout(),this.isVisible||(this.isVisible=!0,this.onAppearEvent(),this.loadDataIfNeededAsync().then(()=>{this.isCurrentStep&&this.handleLightTag()}))}hide(){this.isVisible&&(this.isVisible=!1,this.abortController?.abort(),this.abortController=new AbortController,this.onDisappearEvent())}async loadDataIfNeededAsync(){if(console.log("loadDataIfNeededAsync",this.workflowStep.workflowStepName),this.workflowStep.loadData&&!this.loadedData){this.loadedData=!0;const{endpoint:e,dataConnection:t,preProcessCode:r,postProcessCode:o,onError:n,onSuccess:s,postProcessErrorCode:a}=this.workflowStep.loadData;try{const n={request:this.evaluateAPIParameters(),workflowStep:this.workflowStep};console.log("eval preProcessCode",r),await this.workflowController.evalWithContextAsyncThrow(r,n,void 0,this.abortController.signal),console.log("fetchFromDataSource",t,e,n.request);const i=await this.workflowController.fetchFromDataSource(t,e,n.request,this.abortController.signal),a={response:i,workflowStep:this.workflowStep};await this.workflowController.evalWithContextAsyncThrow(o,a,()=>{this.renderLayout()},this.abortController.signal),this.executeEventData("loadDataIfNeededAsync.onSuccess",s,i,{response:a.response})}catch(e){const t={error:e,workflowStep:this.workflowStep};try{await this.workflowController.evalWithContextAsync(a,t,()=>{this.renderLayout()},this.abortController.signal)}catch{this.executeEventData("loadDataIfNeededAsync.postProcess.onError",n,{error:e},{error:e})}this.loadedData=!1,this.renderLayout(),this.executeEventData("loadDataIfNeededAsync.onError",n,{error:e},{error:e})}finally{if(this.workflowStep.loadData.autoRetryEveryMs){const e=this.abortController.signal;i.TimerUtils.setTimeout(()=>{this.isCurrentStep&&!0!==e?.aborted&&(this.loadedData=!1,this.loadDataIfNeededAsync())},this.workflowStep.loadData.autoRetryEveryMs)}}}}async handleLightTag(){if(this.workflowStep.lighttag){const{location:e,color:t,pattern:r,intensity:n}=this.workflowStep.lighttag,i=(t.toUpperCase()?o.LTColor[t.toUpperCase()]:void 0)??("string"==typeof t&&t.startsWith("#")?new o.LTColor(void 0,t):void 0),s=r.toUpperCase()?o.LTBlinkingPattern[r.toUpperCase()]:void 0,a=this.evaluateStringOrDictionary(e),l={color:i,pattern:s,intensity:n};await this.workflowController.connectionManager.setDesiredLightTagDevices([a],l).catch(e=>{console.error("Error for setDesiredLightTagDevices",e)})}}evaluateAPIParameters(){const e=this.workflowStep.loadData?.requestOverride??{},t={};return t.body=this.evaluateStringOrDictionary(e.body),t.header=this.evaluateDictionary(e.header),t.params=this.evaluateDictionary(e.params),t.query=this.evaluateDictionary(e.query),t}evaluateStringOrDictionary(e){return"string"==typeof e?this.workflowController.evalWithContext(`return ${e}`,{workflowStep:this.workflowStep}):this.evaluateDictionary(e)}evaluateDictionary(e){if(!e)return;const t={};return Object.keys(e).forEach(r=>{t[r]=this.workflowController.evalWithContext(`return ${e[r]}`,{workflowStep:this.workflowStep})}),t}getLayoutParams(){const e={...this.workflowController.currentLocaleDict};return this.workflowStep.layoutParams&&(Array.isArray(this.workflowStep.layoutParams)?this.workflowStep.layoutParams.forEach(t=>{Object.keys(t).forEach(r=>{e[r]=this.workflowController.evalWithContext(`return ${t[r]}`,{workflowStep:this.workflowStep})})}):Object.keys(this.workflowStep.layoutParams).forEach(t=>{e[t]=this.workflowController.evalWithContext(`return ${this.workflowStep.layoutParams[t]}`,{workflowStep:this.workflowStep})})),e}renderLayout(){if(this.isCurrentStep&&this.workflowStep.layout){const e=this.getLayoutParams();if(this.lastRenderedLayoutData===JSON.stringify(e))return void console.log("renderLayout skipped",this.workflowStep.workflowStepName,e);console.log("renderLayout",this.workflowStep.workflowStepName,e),this.lastRenderedLayoutData=JSON.stringify(e);const t=performance.now();this.workflowController.setLayout(new o.NimmstaLayout(this.workflowStep.layout,e)).then(r=>{if(r){this.lastRenderedLayoutData=JSON.stringify(e);const r=performance.now();this.workflowController.updateProgress({layout:this.workflowStep.layout,layoutParams:e,duration:r-t},"layoutRendered",null)}else this.lastRenderedLayoutData=null})}}onScanEvent(e){this.executeEvent("onScan",{scan:e})}onButtonEvent(e){this.executeEvent("onButtonPress",{button:e})}onTriggerEvent(){this.executeEvent("onTrigger")}onDoubleTriggerEvent(){this.executeEvent("onDoubleTrigger")}onTripleTriggerEvent(){this.executeEvent("onTripleTrigger")}onTouchEvent(e){this.executeEvent("onTouch",{touch:e})}onAppearEvent(){this.executeEvent("onAppear",{},{},!0)}onDisappearEvent(){this.workflowStep.lighttag&&this.workflowController.connectionManager.setDesiredLightTagDevices([]),this.executeEvent("onDisappear",{},{},!0)}executeEvent(e,t={},r={},o=!1){this.workflowController.updateProgress({...t},e,null);try{if(this.workflowStep[e])for(let i=0;i<this.workflowStep[e].length;i++){const s=this.workflowStep[e][i];if(n.TransitionControllerFactory.createTransitionController(e,this,this.workflowController,s,this.workflow,t,{workflowStep:this.workflowStep,...r},this.abortController.signal).execute(()=>{this.renderLayout()})&&!o)return}}catch(r){this.workflowController.updateProgress({error:r,...t},`${e}.error`,null),this.logger.error(`Error executing event ${e}`,r),this.workflowController.onError(r)}}executeEventData(e,t,r={},o={},i=!1){if(this.workflowController.updateProgress({...r},e,null),t&&0!==t.length)for(let s=0;s<t.length;s++){const a=t[s];if(n.TransitionControllerFactory.createTransitionController(e,this,this.workflowController,a,this.workflow,r,{workflowStep:this.workflowStep,...o},this.abortController.signal).execute(()=>{this.renderLayout()})&&!i)return}}}},6344(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.english=void 0,t.english={pairing_with_platform_failed:"Pairing with cloud failed.",pairing_code_not_found:"The pairing code was not found on the server",pairing_code_not_found_recovery_info:"Please check the code and try again or generate a new one.","error.no_job_pending":"No job open","error.no_workflow_found":"No active workflow found","error.app_update_required":"Please update your app to the latest version to use the Cloud.","error.app_update_required_workflow":"Please update your app to start this workflow.",failed_to_identify_you:"Failed to identify you.","error.DeviceUnlinkedException":"Your device was unlinked.","error.DeviceUnlinkedException_recovery_info":"Please pair your device again.",we_could_not_connect_to_the_server:"Could not connect to the server.",please_check_your_internet_connection:"Please check your internet connection and try again.",try_again_later:"Please try again later.",unknown_error:"Unknown error",you_are_not_authorized_to_perform_this_action:"Please login to perform this action.",you_do_not_have_the_permission_perform_this_action:"You do not have the permission to perform this action.",the_requested_resource_was_not_found:"Not Found",the_resource_already_exists:"Already exists",internal_server_error:"Internal Server Error",unknown_http_error:"Unknown HTTP error",http_error:"HTTP Error",service_not_available:"Service not available",job_name:"Job Name",article_name:"Article Name",restart_workflow:"Restart Workflow",retry:"Retry",error:"Error",stop_job_failed:"Failed to stop job",stop_job_code_failed:"Stop Job Code failed",force_stop_job:"Stop Job",cancel_job_failed:"Failed to cancel job",complete_job_failed:"Failed to complete job",skip_job_failed:"Failed to skip job",could_not_start_workflow:"Could not start workflow",pair_again:"Pair again",ready_to_work:"Ready to work",hello_comma:"Hello, ",start_working:"Start Working",error_executing_code:"Error executing code. Correlation: ",pair_app:"Pair App",scan_qr_code:"Scan the QR code using the Smart Watch or Camera.",loading:"Loading...",back:"Back",user_still_active:"Are you still Working?",warning:"Warning",yes:"Yes",no:"No",cancel:"Cancel",no_stop_job:"No - Stop Job",stop_job:"Stop Job",login_on_device:"Please login on the smartphone to continue.",user_cancelled_auth_flow:"Login cancelled",user_cancelled_auth_flow_recovery_info:"Please try again.",exit_workflow_failed:"Failed to exit workflow"}},6372(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.TimerUtils=void 0;class r{static originalSetTimeout=window.setTimeout.bind(window);static originalSetInterval=window.setInterval.bind(window);static originalClearTimeout=window.clearTimeout.bind(window);static originalClearInterval=window.clearInterval.bind(window);static activeSetTimeout=r.originalSetTimeout;static activeSetInterval=r.originalSetInterval;static activeClearTimeout=r.originalClearTimeout;static activeClearInterval=r.originalClearInterval;static replaceSetTimeout(e){r.activeSetTimeout=e}static replaceSetInterval(e){r.activeSetInterval=e}static replaceClearTimeout(e){r.activeClearTimeout=e}static replaceClearInterval(e){r.activeClearInterval=e}static restoreSetTimeout(){r.activeSetTimeout=r.originalSetTimeout}static restoreSetInterval(){r.activeSetInterval=r.originalSetInterval}static restoreClearTimeout(){r.activeClearTimeout=r.originalClearTimeout}static restoreClearInterval(){r.activeClearInterval=r.originalClearInterval}static restoreAll(){r.restoreSetTimeout(),r.restoreSetInterval(),r.restoreClearTimeout(),r.restoreClearInterval()}static setTimeout(e,t,...o){return r.activeSetTimeout(e,Number(t),...o)}static setInterval(e,t,...o){return r.activeSetInterval(e,Number(t),...o)}static clearTimeout(e){r.activeClearTimeout(e)}static clearInterval(e){r.activeClearInterval(e)}}t.TimerUtils=r},6466(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.PlatformGetAccountAction=void 0,t.PlatformGetAccountAction=class{name="PlatformGetAccountAction";isDeviceAction=!1;data={};constructor(e,t){this.data.os=e,this.data.appVersion=t}}},6578(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.WorkflowErrorLayoutWithBack=void 0;const o=r(946);class n extends o.NimmstaLayout{constructor(e,t="Error",r="Retry",o="Back"){super('\n <?xml version="1.0" encoding="utf-8"?>\n <NimmstaLayout name="Workflow Error Layout">\n <staticElements>\n <statusbar/>\n <cell horizontalAlignment="center" fontSize="17pt" y="30" padding="5" fontFamily="Bahnschrift_SemiBold" wrapMode="wrap" maxLines="2" name="title">Failed to complete Job</cell>\n <cell horizontalAlignment="center" fontSize="auto" wrapMode="wrap" padding="10" paddingTop="0" paddingBottom="35" maxLines="0" name="error">Please check your internet connection</cell>\n <button y="165" x="110" horizontalAlignment="center" name="restart-workflow" width="80">Retry</button>\n <button y="165" x="10" width="80" horizontalAlignment="center" name="back">Back</button>\n </staticElements>\n </NimmstaLayout>\n ',{error:e,title:t,"restart-workflow":r,back:o})}}t.WorkflowErrorLayoutWithBack=n},6643(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.platformErrorFromCauseAndMessage=t.platformErrorFromCause=t.getErrorUserMessageRecoveryInfo=t.getErrorUserMessageTitle=t.isInternetError=t.isErrorIgnoreable=void 0;const o=r(5534),n=r(5407),i=r(1751),s=r(4585),a=r(1625);function l(e,t){return"whoami"===e?t.who_am_i:"pairing"===e?t.pairing:void 0}t.isErrorIgnoreable=e=>{if(null==e)return!0;if(e.constructor===o.HTTPError){if(404===e.status)return!0;if("error.no_job_pending"===e.json?.error)return!0}return"Cancelled"===e?.message},t.isInternetError=e=>!!e&&("Network request failed"===e.message||"Failed to fetch"===e.message||!0===e.message.includes("Unable to resolve host")||0===e.status),t.getErrorUserMessageTitle=(e,r,c)=>{if(!e)return r.unknown_error;if(console.error("Get error user message title for",e,e?.stack),"string"==typeof e)return e;if((0,t.isInternetError)(e))return r.we_could_not_connect_to_the_server;switch(e.constructor){case s.PlatformEvalError:return r.error_executing_code+e.errorCorrelation;case a.WhoAmIError:if(e.cause instanceof o.HTTPError){const t=e.cause;if(t.json?.error&&r[t.json.error])return r[t.json.error]}return r.failed_to_identify_you;case n.PairingError:return e.cause instanceof o.HTTPError&&404===e.cause.status?r.pairing_code_not_found:r.pairing_with_platform_failed;case o.HTTPError:const u=e;if(u.json?.error&&r[u.json.error])return r[u.json.error];if(u.json?.message)return u.json.message;switch(u.status){case 401:return r.you_are_not_authorized_to_perform_this_action;case 403:return r.you_do_not_have_the_permission_perform_this_action;case 404:return r.the_requested_resource_was_not_found;case 409:return r.the_resource_already_exists;case 500:return r.internal_server_error;case 502:case 503:case 504:return r.service_not_available;default:return l(c,r)??`${r.http_error} ${u.status} ${u.message}`}case i.PlatformError:if(e instanceof i.PlatformError)return e.cause?(0,t.getErrorUserMessageTitle)(e.cause,r,c):e.translatedTitle??e.message;break;default:return l(c,r)??r.error}},t.getErrorUserMessageRecoveryInfo=(e,r,s)=>{if(!e)return"";if("string"==typeof e)return"";if((0,t.isInternetError)(e))return r.please_check_your_internet_connection;switch(e.constructor){case a.WhoAmIError:return e?.errorCause&&r[`${e?.errorCause}_recovery_info`]?r[`${e?.errorCause}_recovery_info`]:(0,t.getErrorUserMessageRecoveryInfo)(e.cause,r,s);case n.PairingError:return e.cause instanceof o.HTTPError&&404===e.cause.status?r.pairing_code_not_found_recovery_info:(0,t.getErrorUserMessageRecoveryInfo)(e.cause,r,s);case o.HTTPError:{const o=e;return l(s,r)?(0,t.getErrorUserMessageTitle)(e,r,null):r[`${o.json?.error}_recovery_info`]?r[`${o.json?.error}_recovery_info`]:`${r.try_again_later} (${o.status} ${o.json?.error??o.message})`}case i.PlatformError:if(e instanceof i.PlatformError)return e.cause?(0,t.getErrorUserMessageRecoveryInfo)(e.cause,r,s):e.translatedRecoveryInfo??e.message;break;default:return e.message?e.message:e.toString()}},t.platformErrorFromCause=(e,r,o=void 0)=>e instanceof i.PlatformError&&e._isPlatformError?e:new i.PlatformError(e.message,e,e.status,(0,t.getErrorUserMessageTitle)(e,r,o),(0,t.getErrorUserMessageRecoveryInfo)(e,r,o),o),t.platformErrorFromCauseAndMessage=(e,r,o,n=void 0)=>new i.PlatformError(e,r,r.status,(0,t.getErrorUserMessageTitle)(r,o,n),(0,t.getErrorUserMessageRecoveryInfo)(r,o,n),n)},6672(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default="00000000-0000-0000-0000-000000000000"},6701(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Base36=void 0;class r{static CHAR_LIST="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";static BASE=r.CHAR_LIST.length;static decode(e){if(null===e)return null;let t=BigInt(0),o=0;for(let n=e.length-1;n>=0;n--){const i=e[n].toUpperCase(),s=r.CHAR_LIST.indexOf(i);if(-1===s)throw new Error(`Invalid Base36 character: '${i}'`);t+=BigInt(s)*r.powBigInt(BigInt(r.BASE),BigInt(o)),o++}return t}static encode(e){if(null===e)return null;if(e<BigInt(0))throw new Error("Negative numbers not supported");let t="",o=e;do{const e=o%BigInt(r.BASE);t=r.CHAR_LIST[Number(e)]+t,o/=BigInt(r.BASE)}while(o>BigInt(0));return t}static powBigInt(e,t){let r=BigInt(1),o=e,n=t;for(;n>BigInt(0);)n%BigInt(2)===BigInt(1)&&(r*=o),o*=o,n/=BigInt(2);return r}}t.Base36=r},6784(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const o=r(4837);t.default=function(e){if(!(0,o.default)(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,255&t,(t=parseInt(e.slice(9,13),16))>>>8,255&t,(t=parseInt(e.slice(14,18),16))>>>8,255&t,(t=parseInt(e.slice(19,23),16))>>>8,255&t,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,255&t)}},6900(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.LoadingLayout=void 0;const o=r(946);class n extends o.NimmstaLayout{constructor(e="Loading...",t="Productivity Cloud"){super('\n <?xml version="1.0" encoding="utf-8"?>\n <NimmstaLayout name="Productivity Cloud Loading Layout">\n <staticElements>\n <statusbar/>\n <cell horizontalAlignment="center" wrapMode="wrap" name="productName" padding="4pt" maxLines="2" fontSize="22pt" y="40" name="title">Productivity Cloud</cell>\n <cell horizontalAlignment="center" wrapMode="wrap" name="loading" padding="4pt" maxLines="4">Loading...</cell>\n </staticElements>\n </NimmstaLayout>\n ',{loading:e,productName:t})}}t.LoadingLayout=n},7061(e,t){Object.defineProperty(t,"__esModule",{value:!0})},7161(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.WorkflowErrorLayout=void 0;const o=r(946);class n extends o.NimmstaLayout{constructor(e,t="Error",r="Restart workflow"){super('\n <?xml version="1.0" encoding="utf-8"?>\n <NimmstaLayout name="Workflow Error Layout">\n <staticElements>\n <statusbar/>\n <cell horizontalAlignment="center" fontSize="17pt" y="30" padding="5" fontFamily="Bahnschrift_SemiBold" wrapMode="wrap" maxLines="2" name="title">Error</cell>\n <cell horizontalAlignment="center" fontSize="auto" wrapMode="wrap" padding="10" paddingTop="0" paddingBottom="35" maxLines="0" name="error">Please try again</cell>\n <button y="165" horizontalAlignment="center" name="restart-workflow">Restart Workflow</button>\n </staticElements>\n </NimmstaLayout>\n ',{error:e,title:t,"restart-workflow":r})}}t.WorkflowErrorLayout=n},7192(e,t){Object.defineProperty(t,"__esModule",{value:!0})},7296(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.LangUtils=void 0;const o=r(5608).__importDefault(r(7327));class n{static langKeys=o.default;static getDefaultMatchingLocale(e,t){const r=e??Object.keys(t??{})[0];return null!=r?t[r]??{}:{}}static getMatchingLocaleDict(e,t,r){const o=Object.keys(r??{}).find(t=>t.toLowerCase()===e?.toLowerCase());if(-1!==e?.indexOf("-")){const n=e.split("-")[0],i=Object.keys(r??{}).find(e=>e.toLowerCase()===n.toLowerCase());return r[o]??r[i]??this.getDefaultMatchingLocale(t,r)}if(-1!==e?.indexOf("_")){const n=e.split("_")[0],i=Object.keys(r??{}).find(e=>e.toLowerCase()===n.toLowerCase());return r[o]??r[i]??this.getDefaultMatchingLocale(t,r)}return r[o]??this.getDefaultMatchingLocale(t,r)}}t.LangUtils=n},7327(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const o=r(8380),n=r(6344),i={de:o.german,en:n.english};t.default=i},7332(e,t){Object.defineProperty(t,"__esModule",{value:!0})},7390(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const o=r(5608);o.__exportStar(r(5142),t),o.__exportStar(r(9585),t),o.__exportStar(r(9566),t),o.__exportStar(r(5884),t),o.__exportStar(r(3824),t),o.__exportStar(r(5191),t),o.__exportStar(r(3684),t),o.__exportStar(r(8119),t),o.__exportStar(r(8640),t),o.__exportStar(r(1283),t),o.__exportStar(r(8401),t),o.__exportStar(r(6643),t),o.__exportStar(r(5534),t),o.__exportStar(r(1751),t),o.__exportStar(r(5407),t),o.__exportStar(r(1625),t),o.__exportStar(r(7327),t),o.__exportStar(r(1316),t),o.__exportStar(r(4173),t),o.__exportStar(r(9368),t),o.__exportStar(r(208),t),o.__exportStar(r(9148),t),o.__exportStar(r(7332),t),o.__exportStar(r(902),t),o.__exportStar(r(4480),t),o.__exportStar(r(6167),t)},7433(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.URL=t.DNS=t.stringToBytes=void 0;const o=r(6784),n=r(510);function i(e){e=unescape(encodeURIComponent(e));const t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}t.stringToBytes=i,t.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",t.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",t.default=function(e,t,r,s,a,l){const c="string"==typeof r?i(r):r,u="string"==typeof s?(0,o.default)(s):s;if("string"==typeof s&&(s=(0,o.default)(s)),16!==s?.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let h=new Uint8Array(16+c.length);if(h.set(u),h.set(c,u.length),h=t(h),h[6]=15&h[6]|e,h[8]=63&h[8]|128,a){l=l||0;for(let e=0;e<16;++e)a[l+e]=h[e];return a}return(0,n.unsafeStringify)(h)}},7525(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.TransitionController=void 0;const o=r(9004),n=r(6372);t.TransitionController=class{eventName;workflowStepController;workflowController;transition;workflow;data;additionalContext;signal;constructor(e,t,r,o,n,i={},s={},a){this.eventName=e,this.workflowStepController=t,this.workflowController=r,this.transition=o,this.workflow=n,this.data=i,this.additionalContext=s,this.signal=a}execute(e){if(!this.transition.condition||this.transition.condition&&this.workflowController.evalWithContext(`return ${this.transition.condition}`,{...this.additionalContext,data:this.data},()=>{},this.signal)){if(this.transition.delay){const t=this.signal;n.TimerUtils.setTimeout(()=>{!0!==t?.aborted&&this.runTransition(e)},this.transition.delay)}else this.runTransition(e);return!0}return!1}runTransition(e){this.transition.actions?.forEach(t=>{o.ActionControllerFactory.createActionController(this.workflowController,t,this.workflow,this.data,this.additionalContext,e).execute()}),this.transition.code&&this.workflowController.evalWithContext(`${this.transition.code}`,{...this.additionalContext,data:this.data},e,this.signal),this.workflowController.updateProgress({transition:this.transition,...this.data},`${this.eventName}.executedTransition`,this.transition.condition),this.transition.targetWorkflow?this.workflowController.startWorkflowWithIdentifier(this.transition.targetWorkflow,this.transition.targetWorkflowPassJob?this.workflow.job:null):this.transition.targetStep||""===this.transition.targetStep?this.workflowController.executeWorkflowStep(this.transition.targetStep):this.transition.backToPreviousStep&&this.workflowController.goBack()}}},7648(e,t){Object.defineProperty(t,"__esModule",{value:!0})},7670(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.updateV1State=void 0;const o=r(2706),n=r(510),i={};function s(e,t,r){return e.msecs??=-1/0,e.nsecs??=0,t===e.msecs?(e.nsecs++,e.nsecs>=1e4&&(e.node=void 0,e.nsecs=0)):t>e.msecs?e.nsecs=0:t<e.msecs&&(e.node=void 0),e.node||(e.node=r.slice(10,16),e.node[0]|=1,e.clockseq=16383&(r[8]<<8|r[9])),e.msecs=t,e}function a(e,t,r,o,n,i,s=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(i){if(s<0||s+16>i.length)throw new RangeError(`UUID byte range ${s}:${s+15} is out of buffer bounds`)}else i=new Uint8Array(16),s=0;t??=Date.now(),r??=0,o??=16383&(e[8]<<8|e[9]),n??=e.slice(10,16);const a=(1e4*(268435455&(t+=122192928e5))+r)%4294967296;i[s++]=a>>>24&255,i[s++]=a>>>16&255,i[s++]=a>>>8&255,i[s++]=255&a;const l=t/4294967296*1e4&268435455;i[s++]=l>>>8&255,i[s++]=255&l,i[s++]=l>>>24&15|16,i[s++]=l>>>16&255,i[s++]=o>>>8|128,i[s++]=255&o;for(let e=0;e<6;++e)i[s++]=n[e];return i}t.updateV1State=s,t.default=function(e,t,r){let l;const c=e?._v6??!1;if(e){const t=Object.keys(e);1===t.length&&"_v6"===t[0]&&(e=void 0)}if(e)l=a(e.random??e.rng?.()??(0,o.default)(),e.msecs,e.nsecs,e.clockseq,e.node,t,r);else{const e=Date.now(),n=(0,o.default)();s(i,e,n),l=a(n,i.msecs,i.nsecs,c?void 0:i.clockseq,c?void 0:i.node,t,r)}return t??(0,n.unsafeStringify)(l)}},7867(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.withTimeout=void 0;var o=r(5608),n=r(2441);function i(e){return void 0!==e.getValue}t.withTimeout=function(e,t,r){var s=this;return void 0===r&&(r=n.E_TIMEOUT),{acquire:function(n,a){var l;if(i(e)?l=n:(l=void 0,a=n),void 0!==l&&l<=0)throw new Error("invalid weight ".concat(l,": must be positive"));return new Promise(function(n,c){return o.__awaiter(s,void 0,void 0,function(){var s,u,h,d;return o.__generator(this,function(o){switch(o.label){case 0:s=!1,u=setTimeout(function(){s=!0,c(r)},t),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,i(e)?e.acquire(l,a):e.acquire(a)];case 2:return h=o.sent(),s?(Array.isArray(h)?h[1]:h)():(clearTimeout(u),n(h)),[3,4];case 3:return d=o.sent(),s||(clearTimeout(u),c(d)),[3,4];case 4:return[2]}})})})},runExclusive:function(e,t,r){return o.__awaiter(this,void 0,void 0,function(){var n,i;return o.__generator(this,function(o){switch(o.label){case 0:n=function(){},o.label=1;case 1:return o.trys.push([1,,7,8]),[4,this.acquire(t,r)];case 2:return i=o.sent(),Array.isArray(i)?(n=i[1],[4,e(i[0])]):[3,4];case 3:return[2,o.sent()];case 4:return n=i,[4,e()];case 5:return[2,o.sent()];case 6:return[3,8];case 7:return n(),[7];case 8:return[2]}})})},release:function(t){e.release(t)},cancel:function(){return e.cancel()},waitForUnlock:function(o,n){var s;if(i(e)?s=o:(s=void 0,n=o),void 0!==s&&s<=0)throw new Error("invalid weight ".concat(s,": must be positive"));return new Promise(function(o,a){var l=setTimeout(function(){return a(r)},t);(i(e)?e.waitForUnlock(s,n):e.waitForUnlock(n)).then(function(){clearTimeout(l),o()})})},isLocked:function(){return e.isLocked()},getValue:function(){return e.getValue()},setValue:function(t){return e.setValue(t)}}}},8119(e,t){Object.defineProperty(t,"__esModule",{value:!0})},8344(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const o=r(5608);o.__exportStar(r(8505),t),o.__exportStar(r(6144),t),o.__exportStar(r(7061),t),o.__exportStar(r(9586),t),o.__exportStar(r(7648),t),o.__exportStar(r(4464),t),o.__exportStar(r(4806),t),o.__exportStar(r(7192),t),o.__exportStar(r(4324),t),o.__exportStar(r(7525),t),o.__exportStar(r(9539),t),o.__exportStar(r(6265),t),o.__exportStar(r(6372),t),o.__exportStar(r(7296),t),o.__exportStar(r(443),t),o.__exportStar(r(6701),t),o.__exportStar(r(9899),t),o.__exportStar(r(7390),t)},8380(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.german=void 0,t.german={pairing_with_platform_failed:"Koppeln fehlgeschlagen.",pairing_code_not_found:"Der Kopplungscode wurde nicht auf dem Server gefunden",pairing_code_not_found_recovery_info:"Bitte überprüfen Sie den Code und versuchen Sie es erneut oder erstellen Sie einen neuen.","error.no_job_pending":"Kein Job offen","error.no_workflow_found":"Kein aktiver Workflow gefunden","error.app_update_required":"Bitte aktualisieren Sie Ihre App auf die neueste Version, um die Cloud zu verwenden.","error.app_update_required_workflow":"Bitte aktualisieren Sie Ihre App, um diesen Workflow zu starten.",failed_to_identify_you:"Identifizierung fehlgeschlagen.","error.DeviceUnlinkedException":"Ihr Gerät wurde entkoppelt.","error.DeviceUnlinkedException_recovery_info":"Bitte koppeln Sie Ihr Gerät erneut.",we_could_not_connect_to_the_server:"Keine Verbindung zum Internet.",unknown_error:"Unbekannter Fehler",please_check_your_internet_connection:"Bitte überprüfen Sie Ihre Internetverbindung und versuchen Sie es erneut.",you_are_not_authorized_to_perform_this_action:"Sie sind nicht eingeloggt. Bitte loggen Sie sich ein.",you_do_not_have_the_permission_perform_this_action:"Sie haben keine Berechtigung diese Aktion auszuführen.",the_requested_resource_was_not_found:"Nicht gefunden",the_resource_already_exists:"Die Ressource existiert bereits",internal_server_error:"Interner Serverfehler",unknown_http_error:"Unbekannter HTTP-Fehler",http_error:"HTTP-Fehler",service_not_available:"Cloud nicht verfügbar",try_again_later:"Bitte versuchen Sie es später erneut.",job_name:"Job Name",article_name:"Artikel Name",restart_workflow:"Workflow neu Starten",retry:"Nochmal versuchen",error:"Fehler",stop_job_failed:"Job konnte nicht gestoppt werden",stop_job_code_failed:"Stop Job Code fehlgeschlagen",force_stop_job:"Stoppen",cancel_job_failed:"Job konnte nicht abgebrochen werden",complete_job_failed:"Job konnte nicht abgeschlossen werden",skip_job_failed:"Job konnte nicht übersprungen werden",could_not_start_workflow:"Workflow konnte nicht gestartet werden",pair_again:"Erneut koppeln",ready_to_work:"Bereit zum Arbeiten",hello_comma:"Hallo, ",start_working:"Arbeit beginnen",error_executing_code:"Fehler im Workflow. Support-ID: ",pair_app:"App koppeln",scan_qr_code:"Scannen Sie den QR-Code mit der Smartwatch oder Kamera.",loading:"Laden...",back:"Zurück",user_still_active:"Sind Sie noch am Arbeiten?",warning:"Warnung",yes:"Ja",no:"Nein",cancel:"Abbrechen",no_stop_job:"Nein - Job stoppen",stop_job:"Job stoppen",login_on_device:"Bitte loggen Sie sich auf dem Smartphone ein, um fortzufahren.",user_cancelled_auth_flow:"Login Abgebrochen",user_cancelled_auth_flow_recovery_info:"Bitte versuchen Sie es erneut.",exit_workflow_failed:"Workflow konnte nicht beendet werden"}},8401(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.WorkflowActionEnum=void 0,t.WorkflowActionEnum={START_FIRST_JOB:"start-first-job",RESTART_WORKFLOW:"restart-workflow",BACK:"back",CONTINUE_WORKFLOW:"continue-workflow",STOP_JOB:"stop-job",CONTINUE:"continue"}},8505(e,t){Object.defineProperty(t,"__esModule",{value:!0})},8561(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.tryAcquire=void 0;var o=r(2441),n=r(7867);t.tryAcquire=function(e,t){return void 0===t&&(t=o.E_ALREADY_LOCKED),(0,n.withTimeout)(e,0,t)}},8640(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.PlatformController=void 0;const o=r(5608),n=r(946),i=r(4200),s=r(2598),a=r(1283),l=r(1625),c=r(4464),u=r(8401),h=r(3954),d=r(9539),f=r(4687),p=r(3897),w=r(7161),g=r(6643),v=r(6900),m=r(7296),y=o.__importDefault(r(7327)),_=r(3741),b=r(2705),k=r(6372),S=r(1751),E=r(6578),C=r(9566),A=r(8978);class W{platformConnector;os;appVersion;deviceName;locale;onApplyDefaultDeviceSettings;whoamIFetchInterval;oAuthDelegate;logger;static currentControllerCount=0;deviceEvent=new n.NIMSubEvent;whoami=new s.NIMSubEventState(null);workflowAppData=new s.NIMSubEventState(null);whoamiError=new s.NIMSubEventState(null);workflowError=new s.NIMSubEventState(null);isLoading=new s.NIMSubEventState(!1);currentWorkflowExecution=new s.NIMSubEventState(null);uiState=new s.NIMSubEventState(null);stateUpdatedEvent=new n.NIMSubEvent;jobProgressEvent=new n.NIMSubEvent;userState={};get isProduction(){return this.platformConnector.account?.isProduction??!0}get testEnvironment(){return this.platformConnector.account?.testEnvironment}translations;isFetchingDataSource=!1;connectionManager;firstActionWasStop=!1;workflowShouldStillRun=!1;isObtainingAccessTokenForConfig=null;get isPaired(){return!!this.whoami.value&&!!this.whoami.value.workerId}get state(){return this.isPaired?this.device?this.currentWorkflowExecution.value?this.shouldAskUserForStillActive||this.uiState.value===a.PlatformControllerUIState.USER_STILL_ACTIVE?a.PlatformControllerState.USER_STILL_ACTIVE:this.workflowError.value?a.PlatformControllerState.WORKFLOW_ERROR:a.PlatformControllerState.IN_WORKFLOW:a.PlatformControllerState.IDLE:a.PlatformControllerState.CONNECT_SMART_WATCH:a.PlatformControllerState.WAITING_TO_PAIR}get isInForeground(){return this._isInForeground}set isInForeground(e){this.logger.debug("Is in foreground",e);const t=this.shouldRunTimedActions;this._isInForeground!==e&&(this._isInForeground=e,e&&(t||(this.fetchWhoAmI(),this.runTimedActions()),this.applyDeviceScreen()))}get shouldControlSmartWatch(){return this._shouldControlSmartWatch}set shouldControlSmartWatch(e){this.logger.debug("Should handle events",e),this._shouldControlSmartWatch=e,e?this.applyDeviceScreen():(this.userState=this.currentWorkflowController?.userState??this.userState,this.showingWorkflowOnDeviceAbortion?.abort(),this.currentWorkflowController?.hide())}get isFetchingOrLoading(){return this.isLoading.value||this.isFetchingUniqueAction||this.isFetchingDataSource}get allowStopJob(){return this.currentWorkflowExecution.value&&!this.device||!0===this.currentWorkflowController?.allowStopJob}_device;userStillActiveYes=0;lastAction=Date.now();lastUserStillActive=Date.now();get shouldAskUserForStillActive(){return this.allowStopJob&&this.currentWorkflowExecution.value&&!0!==this.currentWorkflowExecution.value?.workflow?.definition?.disableIdleStopJob&&this.isPaired&&this.lastAction&&this.shouldControlSmartWatch&&this.uiState.value!==a.PlatformControllerUIState.LOGIN_ON_DEVICE&&(0===this.userStillActiveYes&&Date.now()-this.lastAction>3e5||this.userStillActiveYes>0&&Date.now()-this.lastAction>6e5)}isReady=!1;isRunning=!0;_shouldControlSmartWatch=!0;_isInForeground=!0;deviceSubscriptions=[];isFetchingUniqueAction=!1;fetchWhoAmIAbortController;get shouldRunTimedActions(){return this.isInForeground||!0===this.device?.deviceState?.isConnected||null!==this.currentWorkflowExecution.value}deviceApiWrapper;currentWorkflowController;currentWorkflowEventHandler;currentIdleWorkflow;retryAction;isWaitingForTimeout=!1;currentTimedActionTimeout;isUploadingLogFile=!1;showingWorkflowMutex=new i.Mutex;showingWorkflowOnDeviceAbortion;constructor(e,t,r,o,i=null,s=()=>{},a=64693,l=5e3,c=null){this.platformConnector=e,this.os=t,this.appVersion=r,this.deviceName=o,this.locale=i,this.onApplyDefaultDeviceSettings=s,this.whoamIFetchInterval=l,this.oAuthDelegate=c,W.currentControllerCount++,this.logger=n.Logger.for(`PlatformController ${W.currentControllerCount}`),this.translations=m.LangUtils.getMatchingLocaleDict(i,"en",y.default),console.log("Creating PlatformController",this.locale,a),n.NIMMSTA.websocketPort=a,n.NIMMSTA.onReady(()=>this.onReady()),n.NIMMSTA.onError(e=>{this.isReady=!1,this.workflowError.value=new S.PlatformError(`Error connecting to app ${e}`)}),n.NIMMSTA.keepAlwaysConnected=!0,this.logger.info("Trying to connect to the webserver: Is Ready: ",n.NIMMSTA.isReady),n.NIMMSTA.docReady(),n.NIMMSTA.tryConnect(),this.currentWorkflowExecution.subscribe(e=>{this.isReady&&(console.log("Workflow Execution changed"),this.platformConnector.account.currentExecution=e,console.log("Workflow Execution changed - account updated"),this.currentWorkflowExecution.value||(this.workflowAppData.value=null),console.log("Workflow Execution changed done"))}),this.whoami.subscribe(e=>{this.isReady&&(console.log("Whoami changed"),this.platformConnector.account.whoAmI=e,console.log("Whoami changed - account updated"))}),this.uiState.subscribe(e=>{console.log("UI State changed",this.uiState.value),this.logger.debug("UI State changed",this.uiState.value)})}onReady(){this.isReady||(this.isReady=!0,this.connectionManager=new n.NimmstaConnectionManager,this.platformConnector.bindToConnectionManager(this.connectionManager,this.os,this.appVersion).then(()=>{this.deviceApiWrapper=new h.DeviceAPIWrapper(new C.PlatformAPIImpl(this.platformConnector,this.os,this.appVersion,this.deviceName)),this.shouldRunTimedActions&&this.runTimedActions(),this.platformConnector.account.whoAmI&&(this.platformConnector.account.currentExecution&&(this.currentWorkflowExecution.value=this.platformConnector.account.currentExecution),this.updateWhoAmI(this.platformConnector.account.whoAmI)),this.connectionManager.connectedDevices.length>0&&!this.device&&this.connectionManager.connectedDevices[0]&&(this.device=this.connectionManager.connectedDevices[0]),this.connectionManager.connectEvent.subscribe(e=>{this.device=e}),this.connectionManager.deviceStartedConnectingEvent.subscribe(e=>{e.setLayout(new v.LoadingLayout(this.translations.connecting))})}).catch(e=>{this.whoamiError.value=(0,g.platformErrorFromCauseAndMessage)(`Critical App Error. Error binding to connection manager ${e}`,e,this.translations,"platform")}))}get device(){return this._device}set device(e){try{if(!e)return this._device=null,this.deviceSubscriptions.forEach(e=>e.cancel()),this.deviceSubscriptions=[],void this.deviceEvent.emit(null);const t=this.shouldRunTimedActions;this.fetchWhoAmILoading(),this.logger.debug("Smart Watch connected",e.address,this.device,e),this.device!==e&&(this.whoami.value&&this.deviceApiWrapper.smartWatchConnected(e).catch(e=>{this.logger.debug("Error signaling connect to smart watch",e)}),this._device=e,this.deviceEvent.emit(this.device),this.subscribeToDevice(),this.applyDeviceScreen(),t||this.runTimedActions())}catch(t){this.logger.error("Error setting device",t,t.stack,e.address),this.workflowError.value=(0,g.platformErrorFromCauseAndMessage)(`Error setting device ${t}`,t,this.translations,"device"),this.logErrorToExectionIfExisting(this.workflowError.value,"Error setting device"),this.showWorkflowError()}}subscribeToDevice(){this.deviceSubscriptions.forEach(e=>e.cancel()),this.deviceSubscriptions=[],this.deviceSubscriptions.push(this.device.scanEvent.subscribe(e=>this.onScan(e))),this.deviceSubscriptions.push(this.device.disconnectEvent.subscribe(e=>this.onDeviceDisconnect(e))),this.deviceSubscriptions.push(this.device.buttonEvent.subscribe(e=>this.onButtonPress(e)))}onScan(e){this.shouldControlSmartWatch&&this.state===a.PlatformControllerState.WAITING_TO_PAIR&&this.pairWith(e.barcode)}onDeviceDisconnect(e){this.userState=this.currentWorkflowController?.userState??this.userState,this.currentWorkflowController?.hide(),this.currentWorkflowController=null,this.deviceApiWrapper.smartWatchDisconnected(this.device,e.reason),this.device=null}onButtonPress(e){if(this.shouldControlSmartWatch)switch(this.uiState.value){case a.PlatformControllerUIState.ERROR:e.name===u.WorkflowActionEnum.RESTART_WORKFLOW?this.retryAction?(this.retryAction(),this.retryAction=null):this.restartJob():e.name===u.WorkflowActionEnum.BACK&&(this.retryAction=null,this.currentWorkflowController?.currentWorkflowStepController?.needsBackForError&&this.currentWorkflowController?.goBack(),this.showWorkflowOnDevice());break;case a.PlatformControllerUIState.WORKFLOW:e.name===u.WorkflowActionEnum.RESTART_WORKFLOW&&this.applyDeviceScreen();break;case a.PlatformControllerUIState.USER_STILL_ACTIVE:e.name===u.WorkflowActionEnum.CONTINUE_WORKFLOW&&(this.userStillActiveYes+=1,this.showWorkflowOnDevice()),e.name===u.WorkflowActionEnum.STOP_JOB&&this.stopCurrentJob();break;default:throw new Error("Can't handle button press in this state")}}applyDeviceScreen(){this.device&&(this.isPaired?this.uiState.value!==a.PlatformControllerUIState.LOGIN_ON_DEVICE&&(this.currentWorkflowController||this.loadWorkflow(),this.showWorkflowOnDevice()):this.showPairOnDevice())}loadWorkflow(){const e=this.currentWorkflowExecution.value;null!==e?this.loadWorkflowController(e.id,e.data?.workflow??e.workflow.definition,c.Job.fromJSON(e.data?.job??e.job,e.data?.workflow?.jobOptions??e.workflow.definition.jobOptions),e.workflow):this.currentIdleWorkflow&&this.loadWorkflowController(null,this.currentIdleWorkflow.definition,null,this.currentIdleWorkflow)}loadWorkflowController(e,t,r,o){if(!this.device)return;this.workflowAppData.value=null,this.showingWorkflowOnDeviceAbortion?.abort(),this.currentWorkflowController?.hide(),this.userState=this.currentWorkflowController?.userState??this.userState;const i=this.currentWorkflowController?.connectionManager??new n.NimmstaConnectionManager;this.currentWorkflowController=new d.WorkflowController(i,this.device),this.currentWorkflowController.userState=this.userState,this.linkAdditionalEvalContext(),this.deviceApiWrapper.clearCache();const s={shouldUseOAuth:!!(t.oauthConfig?.clientId&&t.oauthConfig.issuerUrl&&t.oauthConfig.scope&&this.oAuthDelegate),executionId:e,device:this.device,platformController:this,apiWrapper:this.deviceApiWrapper,evalWithContextAsyncThrow:async(e,t)=>this.currentWorkflowController.evalWithContextAsync(e,t),translations:this.translations,workflowResponse:o,onError:t=>{if(t?.isIgnorable)return;const n=t;n&&(n.platformContext={...n.platformContext,workflowIdentifier:o.identifier,workflowExecution:e,job:r?.id}),this.workflowError.value=n,this.showWorkflowError()},setWorkflowAppData:e=>{this.workflowAppData.value!==e&&(this.workflowAppData.value=e)},onLocaleChanged:e=>{this.locale=e,this.translations=m.LangUtils.getMatchingLocaleDict(e,"en",y.default),this.linkAdditionalEvalContext()},storeProgress:(e,t,r)=>{console.log("Store progress started"),this.jobProgressEvent.emit(),console.log("Job progress event emitted"),this.currentWorkflowExecution.value&&(this.uiState.value===a.PlatformControllerUIState.WORKFLOW&&(this.lastAction=Date.now()),console.log("Update local workflow exec"),this.currentWorkflowExecution.value={...this.currentWorkflowExecution.value,data:{workflow:e,job:t,date:Date.now()},job:t},console.log("Done update local"))},obtainAccessToken:!1!==t.oauthConfig?.allowRefreshToken?async e=>this.obtainAccessTokenIfNeeded(t.oauthConfig,e):void 0};this.currentWorkflowEventHandler=new b.PlatformWorkflowEventController(s),this.currentWorkflowController.loadWorkflow(t,r,this.currentWorkflowEventHandler,this.locale),this.linkAdditionalEvalContext()}async obtainAccessTokenIfNeeded(e,t){this.isObtainingAccessTokenForConfig&&this.isObtainingAccessTokenForConfig!==e&&await this.oAuthDelegate.cancelAccessTokenRequest();let r=!1;return this.isObtainingAccessTokenForConfig=e,this.logger.debug("Obtaining access token for config",e,t),this.oAuthDelegate.obtainAccessToken(e,t??null,()=>{r=!0,this.showLoginOnDevice()}).then(e=>(r&&this.uiState.value===a.PlatformControllerUIState.LOGIN_ON_DEVICE&&this.state===a.PlatformControllerState.IN_WORKFLOW&&(this.uiState.value=a.PlatformControllerUIState.WORKFLOW,this.onApplyDefaultDeviceSettings(),this.currentWorkflowController?.bringToFront()),e)).finally(()=>{this.isObtainingAccessTokenForConfig=null})}showPairOnDevice(){this.uiState.value=a.PlatformControllerUIState.PAIRING,this.showingWorkflowOnDeviceAbortion?.abort(),this.workflowAppData.value=null,this.userState=this.currentWorkflowController?.userState??this.userState,this.currentWorkflowController?.hide(),this.shouldControlSmartWatch&&(this.onApplyDefaultDeviceSettings(),this.device?.setLayout(new f.PairAppLayout(this.translations.pair_app,this.translations.scan_qr_code)))}showLoginOnDevice(){this.uiState.value=a.PlatformControllerUIState.LOGIN_ON_DEVICE,this.workflowAppData.value=null,this.userState=this.currentWorkflowController?.userState??this.userState,this.currentWorkflowController?.hide(),this.shouldControlSmartWatch&&(this.onApplyDefaultDeviceSettings(),this.device?.setLayout(new A.LoginOnDeviceLayout(this.translations.login_on_device)))}showLoading(){this.uiState.value=a.PlatformControllerUIState.LOADING,this.userState=this.currentWorkflowController?.userState??this.userState,this.currentWorkflowController?.hide(),this.shouldControlSmartWatch&&(this.onApplyDefaultDeviceSettings(),this.device?.triggerLEDBurstParameters(10,100,100,255,255,0),this.device?.setLayout(new v.LoadingLayout(this.translations.loading)))}async showWorkflowOnDevice(){try{if(this.uiState.value=a.PlatformControllerUIState.WORKFLOW,this.workflowAppData.value=null,this.workflowError.value=null,this.lastAction=Date.now(),this.logger.debug("Showing workflow on device",this.currentWorkflowExecution.value),this.device?.__visibleWorkflowController?.uniqueId!==this.currentWorkflowController?.uniqueId&&this.device?.__visibleWorkflowController?.hide(),!this.shouldControlSmartWatch)return;const e=new AbortController;if(await this.showingWorkflowMutex.runExclusive(async()=>{!1===this.showingWorkflowOnDeviceAbortion?.signal?.aborted?e.abort():this.showingWorkflowOnDeviceAbortion=e}),e.signal.aborted)return;if(await this.onBeforeShowWorkflowOnDevice(),e.signal.aborted)return;this.showingWorkflowOnDeviceAbortion=void 0,this.onApplyDefaultDeviceSettings(),this.device?.triggerLEDBurstParameters(1,100,100,0,0,0),this.currentWorkflowController?.bringToFront()}catch(e){!0===e?.isIgnorable?this.stopCurrentJob():(this.logger.error("Error bringing workflow to front",e,e.stack),this.workflowError.value=(0,g.platformErrorFromCauseAndMessage)(`Error running workflow ${e}`,e,this.translations,"workflow"),this.logErrorToExectionIfExisting(this.workflowError.value,"Error showing workflow on device"),this.showWorkflowError())}}async onBeforeShowWorkflowOnDevice(){await(this.currentWorkflowEventHandler?.onBeforeShowWorkflowOnDevice())}showWorkflowError(){this.showError((0,g.getErrorUserMessageRecoveryInfo)(this.workflowError.value,this.translations,"workflow"),this.translations.error)}logErrorToExectionIfExisting(e,t){this.currentWorkflowExecution.value.id&&this.deviceApiWrapper.logEventAsync(this.currentWorkflowExecution.value.id,null,{error:e,developerInfo:e?.developerInfo,stack:e?.stack,message:e?.message,platformContext:t,workflow:this.currentWorkflowController?.workflow},null,"error").catch(r=>{this.logErrorToExectionIfExisting(r,`Error logging error to execution for ${t} for ${e?.message} due to ${r?.message}`)})}showError(e,t,r,o=()=>this.restartJob(),n=!1){this.uiState.value=a.PlatformControllerUIState.ERROR,this.userState=this.currentWorkflowController?.userState??this.userState,this.currentWorkflowController?.hide(),this.retryAction=o,this.shouldControlSmartWatch&&(this.logger.debug("Showing Error"),this.onApplyDefaultDeviceSettings(),this.device?.triggerSOS(),!n||this.currentWorkflowController?.currentWorkflowStepController?.needsBackForError&&!this.currentWorkflowController?.canGoBack()?this.device?.setLayout(new w.WorkflowErrorLayout(e,t??this.translations.error,r??this.translations.restart_workflow)):this.device?.setLayout(new E.WorkflowErrorLayoutWithBack(e,t??this.translations.error,r??this.translations.retry,this.translations.back)))}showUserStillActiveOnDevice(){this.uiState.value!==a.PlatformControllerUIState.USER_STILL_ACTIVE?(this.lastUserStillActive=Date.now(),this.uiState.value=a.PlatformControllerUIState.USER_STILL_ACTIVE,this.shouldControlSmartWatch&&(this.onApplyDefaultDeviceSettings(),this.userState=this.currentWorkflowController?.userState??this.userState,this.currentWorkflowController?.hide(),this.device?.triggerLEDBurstParameters(10,100,100,255,255,0),this.device?.triggerVibratorBurstParameters(1,50,100,100),this.device?.triggerBeeperBurstParameters(1,50,100,100),this.device?.setLayout(new p.UserStillActiveLayout(this.translations.user_still_active,this.translations.no_stop_job,this.translations.warning,this.translations.yes)))):this.lastUserStillActive&&Date.now()-this.lastUserStillActive>6e4&&this.stopCurrentJob()}async startFetchingUniqueAction(e){if(this.isFetchingUniqueAction)throw new S.PlatformError("Already fetching. Do not call two actions at the same time.",void 0,void 0,void 0,void 0,{state:this.state,whoami:this.whoami.value,currentWorkflowExecution:this.currentWorkflowExecution.value});this.fetchWhoAmIAbortController?.abort(),this.isLoading.value=!0,this.isFetchingUniqueAction=!0,this.showLoading();try{await e()}finally{this.isLoading.value=!1,this.isFetchingUniqueAction=!1}}async fetchWhoAmIAsync(e){try{if(this.isFetchingUniqueAction||!this.platformConnector.account?.whoAmI&&!this.platformConnector.account?.isLoggedIn||e.aborted)return;const t=await this.deviceApiWrapper.fetchWhoAmIAsync(e,this.device);if(e.aborted)return;this.updateWhoAmI(t)}catch(t){if(e.aborted||"AbortError"===t?.name)return;if(t instanceof l.WhoAmIError&&t.authFailed)this.whoami.value=null,this.whoamiError.value=null,this.currentIdleWorkflow=null,this.currentWorkflowExecution.value=null,t.shouldShowError?this.showError((0,g.getErrorUserMessageRecoveryInfo)(t,this.translations,"whoami"),(0,g.getErrorUserMessageTitle)(t,this.translations,"whoami"),this.translations.pair_again,()=>this.showPairOnDevice()):this.showPairOnDevice();else{if(!this.isFetchingOrLoading&&(this.state===a.PlatformControllerState.WAITING_TO_PAIR||this.state===a.PlatformControllerState.IDLE)){if(this.whoamiError.value)return;this.showError((0,g.getErrorUserMessageRecoveryInfo)(t,this.translations,"whoami"),(0,g.getErrorUserMessageTitle)(t,this.translations,"whoami"),this.translations.retry,()=>{this.fetchWhoAmILoading()})}this.whoamiError.value=t}}}updateWhoAmI(e){try{this.logger.debug("Updating whoami"),this.whoami.value=e;const t=e?.idleWorkflow??(0,_.defaultIdleWorkflow)();this.logger.debug("Desired idle workflow",t?.id),t?.id===this.currentIdleWorkflow?.id&&t?.lastUpdatedAt===this.currentIdleWorkflow?.lastUpdatedAt||(this.currentIdleWorkflow={...t},this.state===a.PlatformControllerState.IDLE&&(this.loadWorkflow(),this.showWorkflowOnDevice())),e?.currentWorkflowExecutionId&&e?.currentWorkflowExecutionId!==this.currentWorkflowExecution.value?.id&&!this.workflowShouldStillRun&&this.startWorkflowByIdentifier(null),this.workflowShouldStillRun||e?.currentWorkflowExecutionId||!this.currentWorkflowExecution.value||(this.logger.debug("Job is not available on the server anymore",this.currentWorkflowExecution.value?.id),this.currentWorkflowExecution.value=null,this.loadWorkflow(),this.state===a.PlatformControllerState.IDLE&&this.showWorkflowOnDevice()),!0===e?.requestLogFile&&this.uploadCurrentLogFileIfNeeded(),this.linkAdditionalEvalContext(),this.whoamiError.value&&(this.whoamiError.value=null,this.applyDeviceScreen())}catch(e){if(this.state===a.PlatformControllerState.WAITING_TO_PAIR||this.state===a.PlatformControllerState.IDLE){if(this.whoamiError.value)return;this.showError((0,g.getErrorUserMessageRecoveryInfo)(e,this.translations,"whoami"),this.translations.failed_to_identify_you,this.translations.retry,()=>this.fetchWhoAmILoading())}this.whoamiError.value=e}}uploadCurrentLogFileIfNeeded(){this.isUploadingLogFile||(this.isUploadingLogFile=!0,this.deviceApiWrapper.uploadCurrentLogFile().finally(()=>{k.TimerUtils.setTimeout(()=>{this.isUploadingLogFile=!1},6e4)}))}fetchWhoAmILoading(){this.isLoading.value=!0,this.showLoading(),this.fetchWhoAmI(()=>{this.isLoading.value=!1,this.applyDeviceScreen()})}fetchWhoAmI(e=()=>{}){this.fetchWhoAmIAbortController?.abort(),this.fetchWhoAmIAbortController=new AbortController,this.fetchWhoAmIAsync(this.fetchWhoAmIAbortController.signal).finally(e)}runTimedActions(){if(this.logger.debug("Install timer for timed actions",this.isRunning,this.shouldRunTimedActions,this.isFetchingOrLoading),this.isWaitingForTimeout)return void this.logger.debug("Already waiting for timeout");this.isWaitingForTimeout=!0;const e=new AbortController;this.currentTimedActionTimeout?.abort(),this.currentTimedActionTimeout=e,k.TimerUtils.setTimeout(()=>{if(this.isWaitingForTimeout=!1,!e.signal.aborted&&(this.logger.debug("Running timed actions",this.isRunning,this.shouldRunTimedActions,this.isFetchingOrLoading),this.isRunning&&this.shouldRunTimedActions)){if(this.isFetchingOrLoading)return void this.runTimedActions();this.fetchWhoAmI(()=>{e.signal.aborted||(this.shouldAskUserForStillActive&&this.showUserStillActiveOnDevice(),this.logger.debug("Rerun timed actions",e.signal.aborted),this.runTimedActions())})}},this.whoamIFetchInterval)}async executeWorkflowAction(e,t,r,o=()=>{this.isFetchingUniqueAction||(this.loadWorkflow(),this.showWorkflowOnDevice())}){console.log("Executing workflow action",e,this.isFetchingUniqueAction),this.lastAction=Date.now(),await this.startFetchingUniqueAction(async()=>{try{await r(),this.isLoading.value=!1,this.isFetchingUniqueAction=!1,o()}catch(n){if(this.logErrorToExectionIfExisting(n,`Workflow Action: ${e}`),this.uiState.value===a.PlatformControllerUIState.ERROR)return;this.logger.error("Error in execute workflow action",n),this.showError((0,g.getErrorUserMessageRecoveryInfo)(n,this.translations,e),t,this.translations.retry,()=>this.executeWorkflowAction(e,t,r,o),!0)}})}async exitWorkflow(e,t){await this.executeWorkflowAction("exitWorkflow",this.translations.exit_workflow_failed,async()=>{this.currentWorkflowExecution.value&&"COMPLETE"!==this.currentWorkflowExecution.value.status?this.showError(this.translations.exit_workflow_failed,"Job must be completed before exiting.",this.translations.force_stop_job,()=>this.stopCurrentJob(e,t,!0),!0):(this.logger.debug("Job exited",this.currentWorkflowExecution.value),this.currentWorkflowExecution.value=null)})}async stopCurrentJob(e,t,r=!1){this.firstActionWasStop=!0,await this.executeWorkflowAction("stopCurrentJob",this.translations.stop_job_failed,async()=>{const o=e??this.currentWorkflowController?.workflow;if(o?.onStopJobCode){this.logger.debug("Executing onStopJobCode",o.onStopJobCode),this.isFetchingUniqueAction=!1;try{await this.currentWorkflowController.evalWithContextAsyncThrow(o.onStopJobCode,{worker:this.whoami.value})}catch(o){if(!r){console.log("Error executing onStopJobCode, not stopping the job",this.translations.force_stop_job,this.translations,o),this.logErrorToExectionIfExisting(o,`On Stop Code: ${e?.onStopJobCode}`),this.showError((0,g.getErrorUserMessageRecoveryInfo)(o,this.translations,this.translations.stop_job_code_failed),this.translations.stop_job_code_failed,this.translations.force_stop_job,()=>this.stopCurrentJob(e,t,!0),!0);const r=new Error(`Error executing onStopJobCode with error: ${o}`);throw r.cause=o,r}}if(!0!==t?.completeJobOnStop||this.isFetchingUniqueAction||null===this.currentWorkflowExecution.value||this.completeCurrentJob(o,t),this.isFetchingUniqueAction||null===this.currentWorkflowExecution.value)return;this.isFetchingUniqueAction=!0}this.logger.debug("Stopping job",this.currentWorkflowExecution.value),await this.deviceApiWrapper.stopJob(),this.logger.debug("Job stopped",this.currentWorkflowExecution.value),this.currentWorkflowExecution.value=null})}async skipCurrentJob(e,t,r){const o=this.currentWorkflowExecution.value?.workflow?.identifier;await this.executeWorkflowAction("skipCurrentJob",this.translations.skip_job_failed,async()=>{await this.deviceApiWrapper.skipJob(),this.currentWorkflowExecution.value=null},()=>this.startWorkflowByIdentifierIfNotStop(void 0===e.doneOrSkipWorkflowIdentifier?o:e.doneOrSkipWorkflowIdentifier,void 0,r))}async cancelCurrentJob(e,t,r){const o=this.currentWorkflowExecution.value?.workflow?.identifier;await this.executeWorkflowAction("cancelCurrentJob",this.translations.cancel_job_failed,async()=>{await this.deviceApiWrapper.cancelJob(),this.currentWorkflowExecution.value=null},()=>this.startWorkflowByIdentifierIfNotStop(void 0===e.doneOrSkipWorkflowIdentifier?o:e.doneOrSkipWorkflowIdentifier,void 0,r))}async completeCurrentJob(e,t,r=!0,o=void 0){this.logger.debug("Completing job",t,e,this),this.workflowShouldStillRun=!r;const n=this.currentWorkflowExecution.value?.workflow?.identifier;await this.executeWorkflowAction("completeCurrentJob",this.translations.complete_job_failed,async()=>this.deviceApiWrapper.completeJob(this.currentWorkflowExecution.value?.id,t,this.currentWorkflowController?.workflow,this.device),()=>{this.currentWorkflowExecution?.value&&(this.currentWorkflowExecution.value.status="COMPLETE"),r||this.firstActionWasStop?this.startWorkflowByIdentifierIfNotStop(void 0===e.doneOrSkipWorkflowIdentifier?n:e.doneOrSkipWorkflowIdentifier,void 0,o):this.applyDeviceScreen()})}async startWorkflowByIdentifierIfNotStop(e,t,r,o){if(this.firstActionWasStop)return this.firstActionWasStop=!1,this.currentWorkflowExecution.value=null,this.loadWorkflow(),void this.applyDeviceScreen();this.startWorkflowByIdentifier(e,t,r,o)}async startWorkflowByIdentifier(e,t,r,o){this.workflowShouldStillRun=!1,this.firstActionWasStop=!1,await this.executeWorkflowAction("startWorkflowWithIdentifier",this.translations.could_not_start_workflow,async()=>{this.currentWorkflowExecution.value=null,this.currentWorkflowExecution.value=await this.deviceApiWrapper.startWorkflowWithIdentifier(e,t,r,o,this.device)})}restartJob(){this.lastAction=Date.now(),this.loadWorkflow(),this.showWorkflowOnDevice()}async pairWith(e){if(this.logger.debug("Pairing with QR Code",e),!this.isLoading.value){this.fetchWhoAmIAbortController?.abort(),this.isLoading.value=!0,this.showLoading(),this.userState=this.currentWorkflowController?.userState??this.userState,this.currentWorkflowController?.hide(),this.currentWorkflowController=null;try{await this.deviceApiWrapper.pairWithAsync(e),this.fetchWhoAmIAsync((new AbortController).signal),this.device&&this.deviceApiWrapper.smartWatchConnected(this.device).catch(e=>{this.logger.debug("Error signaling connect to smart watch",e)})}catch(e){throw this.showError((0,g.getErrorUserMessageRecoveryInfo)(e,this.translations,"pairing"),(0,g.getErrorUserMessageTitle)(e,this.translations,"pairing"),this.translations.retry,()=>{this.whoami.value?this.showWorkflowOnDevice():this.showPairOnDevice()}),e}finally{this.isLoading.value=!1}this.fetchWhoAmILoading()}}getWFTranslation(e){return this.translations[e]??e}linkAdditionalEvalContext(){this.currentWorkflowController&&(this.currentWorkflowController.additionalEvalContext={worker:this.whoami.value,translations:{...this.translations,...this.currentWorkflowController.currentLocaleDict},app:{os:this.os,appVersion:this.appVersion,deviceName:this.deviceName,locale:this.locale}})}close(){n.NIMMSTA.close(),this.currentWorkflowController?.hide(),this.isRunning=!1}static enableDebugLogging(){n.Logger.enableDebugLogging()}}t.PlatformController=W},8683(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const o=r(6784),n=r(510);t.default=function(e){const t=(r="string"==typeof e?(0,o.default)(e):e,Uint8Array.of((15&r[3])<<4|r[4]>>4&15,(15&r[4])<<4|(240&r[5])>>4,(15&r[5])<<4|15&r[6],r[7],(15&r[1])<<4|(240&r[2])>>4,(15&r[2])<<4|(240&r[3])>>4,16|(240&r[0])>>4,(15&r[0])<<4|(240&r[1])>>4,r[8],r[9],r[10],r[11],r[12],r[13],r[14],r[15]));var r;return"string"==typeof e?(0,n.unsafeStringify)(t):t}},8855(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.version=t.validate=t.v7=t.v6ToV1=t.v6=t.v5=t.v4=t.v3=t.v1ToV6=t.v1=t.stringify=t.parse=t.NIL=t.MAX=void 0;var o=r(9549);Object.defineProperty(t,"MAX",{enumerable:!0,get:function(){return o.default}});var n=r(6672);Object.defineProperty(t,"NIL",{enumerable:!0,get:function(){return n.default}});var i=r(6784);Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return i.default}});var s=r(510);Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return s.default}});var a=r(7670);Object.defineProperty(t,"v1",{enumerable:!0,get:function(){return a.default}});var l=r(5631);Object.defineProperty(t,"v1ToV6",{enumerable:!0,get:function(){return l.default}});var c=r(1436);Object.defineProperty(t,"v3",{enumerable:!0,get:function(){return c.default}});var u=r(2425);Object.defineProperty(t,"v4",{enumerable:!0,get:function(){return u.default}});var h=r(1914);Object.defineProperty(t,"v5",{enumerable:!0,get:function(){return h.default}});var d=r(8935);Object.defineProperty(t,"v6",{enumerable:!0,get:function(){return d.default}});var f=r(8683);Object.defineProperty(t,"v6ToV1",{enumerable:!0,get:function(){return f.default}});var p=r(2064);Object.defineProperty(t,"v7",{enumerable:!0,get:function(){return p.default}});var w=r(4837);Object.defineProperty(t,"validate",{enumerable:!0,get:function(){return w.default}});var g=r(2855);Object.defineProperty(t,"version",{enumerable:!0,get:function(){return g.default}})},8935(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const o=r(510),n=r(7670),i=r(5631);t.default=function(e,t,r){e??={},r??=0;let s=(0,n.default)({...e,_v6:!0},new Uint8Array(16));if(s=(0,i.default)(s),t){for(let e=0;e<16;e++)t[r+e]=s[e];return t}return(0,o.unsafeStringify)(s)}},8978(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.LoginOnDeviceLayout=void 0;const o=r(946);class n extends o.NimmstaLayout{constructor(e="Log in on your SmartPhone...",t="Productivity Cloud"){super('\n <?xml version="1.0" encoding="utf-8"?>\n <NimmstaLayout name="Productivity Cloud Login Layout">\n <staticElements>\n <statusbar/>\n <cell horizontalAlignment="center" wrapMode="wrap" name="productName" padding="4pt" maxLines="2" fontSize="22pt" y="40" name="title">Productivity Cloud</cell>\n <cell horizontalAlignment="center" wrapMode="wrap" name="loading" padding="4pt" maxLines="4">Log in on your SmartPhone...</cell>\n </staticElements>\n </NimmstaLayout>\n ',{loading:e,productName:t})}}t.LoginOnDeviceLayout=n},9004(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.ActionControllerFactory=void 0;const o=r(4324);class n{static customControllers=new Map;static createActionController(e,t,r,n={},i={},s=()=>{}){return t.type?this.customControllers.has(t.type)?new(this.customControllers.get(t.type))(e,t,r,n,i,s):void console.error("Custom type set but no Controller is registered!"):new o.ActionController(e,t,r,n,i,s)}static registerActionController(e,t){this.customControllers.set(e,t)}}t.ActionControllerFactory=n},9148(e,t){Object.defineProperty(t,"__esModule",{value:!0})},9195(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var o=r(5608),n=r(526),i=function(){function e(e){this._semaphore=new n.default(1,e)}return e.prototype.acquire=function(){return o.__awaiter(this,arguments,void 0,function(e){return void 0===e&&(e=0),o.__generator(this,function(t){switch(t.label){case 0:return[4,this._semaphore.acquire(1,e)];case 1:return[2,t.sent()[1]]}})})},e.prototype.runExclusive=function(e,t){return void 0===t&&(t=0),this._semaphore.runExclusive(function(){return e()},1,t)},e.prototype.isLocked=function(){return this._semaphore.isLocked()},e.prototype.waitForUnlock=function(e){return void 0===e&&(e=0),this._semaphore.waitForUnlock(1,e)},e.prototype.release=function(){this._semaphore.isLocked()&&this._semaphore.release()},e.prototype.cancel=function(){return this._semaphore.cancel()},e}();t.default=i},9368(e,t){Object.defineProperty(t,"__esModule",{value:!0})},9539(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.WorkflowController=void 0;const o=r(946),n=r(9711),i=r(4464),s=r(2240),a=r(1590),l=r(1323),c=r(517),u=r(2023),h=r(7296),d=r(6372),f=r(443),p=r(7390),w=r(6701),g=r(9899);class v{connectionManager;device;static supportedSchemaVersion=2;workflow;currentLocaleDict={};currentWorkflowStepController;userState={};additionalEvalContext={};get uniqueId(){return this._uniqueId}get allowStopJob(){return!1===this.workflow.disallowStopJob||(!0===this.workflow.disallowStopJob?!0===this.currentWorkflowStepController?.allowStopJob:!1!==this.currentWorkflowStepController?.allowStopJob)}get isVisible(){return this._isVisible}subscriptions=[];workflowHandler;_isVisible=!1;lighttagsSet=!1;_uniqueId;currentIntervalAbortController;static CANCEL_JOB="CancelJob";static SAVE_JOB="SaveJob";static SKIP_JOB="SkipJob";static STOP_JOB="StopJob";static globalUniqueCounter=0;logger;constructor(e,t){this.connectionManager=e,this.device=t,this.logger=o.Logger.for("WorkflowController"),this._uniqueId=v.globalUniqueCounter++,this.subscribeToEvents(),n.WorkflowStepControllerFactory.registerWorkflowStepController(v.CANCEL_JOB,l.CancelJobController),n.WorkflowStepControllerFactory.registerWorkflowStepController(v.SAVE_JOB,a.SaveJobController),n.WorkflowStepControllerFactory.registerWorkflowStepController(v.SKIP_JOB,s.SkipJobController),n.WorkflowStepControllerFactory.registerWorkflowStepController(v.STOP_JOB,c.StopJobController)}subscribeToEvents(){this.unsubscribe(),this.subscriptions.push(this.device.scanEvent.subscribe(e=>this.onScanEvent(e))),this.subscriptions.push(this.device.buttonEvent.subscribe(e=>this.onButtonEvent(e))),this.subscriptions.push(this.device.triggerEvent.subscribe(()=>this.onTriggerEvent())),this.subscriptions.push(this.device.doubleTriggerEvent.subscribe(()=>this.onDoubleTriggerEvent())),this.subscriptions.push(this.device.tripleTriggerEvent.subscribe(()=>this.onTripleTriggerEvent())),this.subscriptions.push(this.device.touchEvent.subscribe(e=>this.onTouchEvent(e)))}loadWorkflow(e,t,r,o="en_US"){0===this.subscriptions.length&&console.error("You need to subscribe before executing a workflow!"),this.workflowHandler=r,this.workflow="string"==typeof e?JSON.parse(e):e,this.workflow={...u.DefaultWorkflow.getDefaultWorkflow(),...this.workflow},this.addDefaultSteps(),this.workflow.job=i.Job.fromJSON(t,this.workflow.jobOptions),this.workflow.translationKeys=this.workflow.translationKeys??{},this.currentLocaleDict=h.LangUtils.getMatchingLocaleDict(o,this.workflow.defaultLocale,this.workflow.translationKeys)}registerIntervals(){this.workflow.intervalActions&&(this.currentIntervalAbortController?.abort(),this.currentIntervalAbortController=new AbortController,this.workflow.intervalActions.forEach(e=>this.registerInterval(e,this.currentIntervalAbortController.signal)))}registerInterval(e,t){if(void 0===e.code||void 0===e.interval)return;let r;try{if(r=parseInt(e.interval.toString(),10),r<1e3)throw new Error("Interval must be at least 1000ms")}catch(t){return void this.onError(new p.PlatformError("Error in interval code execution",t,null,null,null,{code:e.code,interval:e.interval}))}d.TimerUtils.setTimeout(()=>{this._isVisible&&!t.aborted&&this.evalWithContextAsyncThrow(e.code).catch(t=>{this.onError(new p.PlatformError("Error in interval code execution",t,null,null,null,{code:e.code,interval:r}))}).finally(()=>{this.registerInterval(e,t)})},r)}addDefaultSteps(){this.workflow.workflowSteps!==u.DefaultWorkflow.getDefaultWorkflow().workflowSteps&&(this.workflow.workflowSteps=this.workflow.workflowSteps.concat(u.DefaultWorkflow.getDefaultWorkflow().workflowSteps.filter(e=>!e.isInitialStep)),void 0===this.workflow.workflowSteps.find(e=>e.isInitialStep)&&(this.workflow.workflowSteps=this.workflow.workflowSteps.concat(u.DefaultWorkflow.getDefaultWorkflow().workflowSteps.filter(e=>e.isInitialStep))))}executeWorkflow(e,t,r){this.loadWorkflow(e,t,r),this.bringToFront()}startWorkflowWithIdentifier(e,t){this.workflowHandler.startWorkflow(e,t!==this.workflow.job?this.workflow.job:null,t)}async setLayout(e){return!(!this._isVisible||!this.shouldUpdateLayout(e)||(this.device.__layout=e,await this.device.setLayout(e),0))}shouldUpdateLayout(e){const t=this.device?.__layout;return!t||t.layout!==e.layout||t.parameters!==e.parameters}bringToFront(){if(void 0!==this.device.__visibleWorkflowController?.uniqueId&&this.device.__visibleWorkflowController?.uniqueId!==this.uniqueId)throw new Error("You can't have multiple WorkflowControllers for one device visible! Please call unsubscribe or hide first.");this.updateProgress({workflow:this.workflow,job:this.workflow.job},"bringToFront",null),this.subscribeToEvents(),this.device.__visibleWorkflowController=this,this._isVisible||this.registerIntervals(),this._isVisible=!0,void 0===this.currentWorkflowStepController&&this.loadFirstOrCurrentStep(),this.executeOnController()}hide(){this.lighttagsSet&&this.connectionManager.setDesiredLightTagDevices([]),this._isVisible=!1,this.device.__layout=void 0,null!==this.workflow.useListeningLightTags&&void 0!==this.workflow.useListeningLightTags&&(this.connectionManager.useListeningLightTags=null),this.currentWorkflowStepController?.hide(),this.unsubscribe(),this.currentIntervalAbortController?.abort(),this.currentIntervalAbortController=void 0}executeWorkflowStep(e,t={}){for(const r of this.workflow.workflowSteps)if(r.workflowStepName===e)return this.workflow.currentWorkflowStep?.previousStep?.previousStep&&delete this.workflow.currentWorkflowStep?.previousStep?.previousStep,this.workflow.currentWorkflowStep={previousStep:this.workflow.currentWorkflowStep,...r,...t},this.currentWorkflowStepController?.hide(),this.currentWorkflowStepController=n.WorkflowStepControllerFactory.createWorkflowStepController(this,this.workflow,this.workflow.currentWorkflowStep),void this.executeOnController();this.onError(new Error(`Workflow Step ${e} not found!`))}goBack(){this.workflow.currentWorkflowStep?.previousStep&&(this.workflow.currentWorkflowStep=this.workflow.currentWorkflowStep.previousStep,this.currentWorkflowStepController?.hide(),this.currentWorkflowStepController=n.WorkflowStepControllerFactory.createWorkflowStepController(this,this.workflow,this.workflow.currentWorkflowStep),this.executeOnController())}canGoBack(){return void 0!==this.workflow.currentWorkflowStep?.previousStep}executeOnController(){this.currentWorkflowStepController?.execute(),null!==this.workflow.useListeningLightTags&&void 0!==this.workflow.useListeningLightTags&&(this.connectionManager.useListeningLightTags=this.workflow.useListeningLightTags)}loadFirstOrCurrentStep(){if(void 0!==this.workflow.currentWorkflowStep&&!0!==this.workflow.currentWorkflowStep.neverStoreState&&this.workflow.currentWorkflowStep.type!==v.STOP_JOB)return this.currentWorkflowStepController?.hide(),this.currentWorkflowStepController=n.WorkflowStepControllerFactory.createWorkflowStepController(this,this.workflow,this.workflow.currentWorkflowStep),void this.executeOnController();for(const e of this.workflow.workflowSteps)if(e.isInitialStep){this.executeWorkflowStep(e.workflowStepName);break}}done(e=!0,t){return this.workflowHandler?this.workflowHandler.done(this.workflow,this.workflow.job,e,t):Promise.reject(new Error("No workflow handler attached!"))}exit(e=!0){return this.workflowHandler?this.workflowHandler.exit(this.workflow,e):Promise.reject(new Error("No workflow handler attached!"))}updateProgress(e,t,r){return this.workflowHandler?this.workflowHandler.updateProgress(this.workflow,this.workflow.job,this.currentWorkflowStepController?.workflowStep?`${this.currentWorkflowStepController?.workflowStep?.workflowStepName}.${t}`:t,e,r):Promise.resolve()}cancel(e){return this.workflowHandler?this.workflowHandler.cancelled(this.workflow,this.workflow.job,e):Promise.reject(new Error("No workflow handler attached!"))}skip(e){return this.workflowHandler?this.workflowHandler.skipped(this.workflow,this.workflow.job,e):Promise.reject(new Error("No workflow handler attached!"))}stop(){return this.workflowHandler?this.workflowHandler.stop(this.workflow,this.workflow.job):Promise.reject(new Error("No workflow handler attached!"))}unsubscribe(){this.subscriptions.forEach(e=>e.cancel()),this.device.__visibleWorkflowController?.uniqueId===this.uniqueId&&(this.device.__visibleWorkflowController=void 0)}onScanEvent(e){this._isVisible&&this.currentWorkflowStepController?.onScanEvent(e)}onButtonEvent(e){this._isVisible&&this.currentWorkflowStepController?.onButtonEvent(e)}onTriggerEvent(){this._isVisible&&this.currentWorkflowStepController?.onTriggerEvent()}onDoubleTriggerEvent(){this._isVisible&&this.currentWorkflowStepController?.onDoubleTriggerEvent()}onTripleTriggerEvent(){this._isVisible&&this.currentWorkflowStepController?.onTripleTriggerEvent()}onTouchEvent(e){this._isVisible&&this.currentWorkflowStepController?.onTouchEvent(e)}onError(e){this._isVisible&&this.workflowHandler.onError(e)}evalWithContext(e,t={},r=void 0,o){const n=f.NIMMSTAEvalUtils.runWithCatch(r,e=>this.onError(e),this.logger),i=f.NIMMSTAEvalUtils.evalWithParams(e,this.getActualContext(t,n,o),e=>this.onError(e),this.logger);return n&&d.TimerUtils.setTimeout(n,0),i}evalWithContextThrow(e,t={},r=void 0,o){const n=f.NIMMSTAEvalUtils.runWithCatch(r,e=>this.onError(e),this.logger),i=f.NIMMSTAEvalUtils.evalWithParams(e,this.getActualContext(t,n,o),e=>this.onError(e),this.logger);return n&&d.TimerUtils.setTimeout(n,0),i}async evalWithContextAsync(e,t={},r=void 0,o){const n=f.NIMMSTAEvalUtils.runWithCatch(r,e=>this.onError(e),this.logger),i=await f.NIMMSTAEvalUtils.evalWithParamsAsync(e,this.getActualContext(t,n,o),e=>{throw e},this.logger);return n&&d.TimerUtils.setTimeout(n,0),i}async evalWithContextAsyncThrow(e,t={},r=void 0,o){const n=f.NIMMSTAEvalUtils.runWithCatch(r,e=>this.onError(e),this.logger),i=await f.NIMMSTAEvalUtils.evalWithParamsAsync(e,this.getActualContext(t,n,o),e=>{throw e},this.logger);return n&&d.TimerUtils.setTimeout(n,0),i}getActualContext(e={},t=void 0,r){const n=()=>{t&&d.TimerUtils.setTimeout(f.NIMMSTAEvalUtils.runWithCatch(t,e=>this.onError(e),this.logger),0)};return{signal:r,console:{...console,log:(...e)=>this.updateProgress({args:e},"console.log",null),error:(...e)=>this.updateProgress({args:e},"console.error",null),warn:(...e)=>this.updateProgress({args:e},"console.warn",null),info:(...e)=>this.updateProgress({args:e},"console.info",null),debug:(...e)=>this.updateProgress({args:e},"console.debug",null),trace:(...e)=>this.updateProgress({args:e},"console.trace",null)},job:this.workflow.job,userState:this.userState,setUserState:(e={})=>{if(null==e)this.userState={};else{if(Array.isArray(e))throw new Error("User state has to be an object");this.userState=e}},setJob:e=>(this.workflow.job=i.Job.fromJSON(e,this.workflow.jobOptions),this.workflow.job.status="IN_PROGRESS",d.TimerUtils.setTimeout(()=>this.updateProgress({...this.workflow.job},"new-job-set",null),10),this.workflow.job),createJob:(e=`Job at ${(new Date).toISOString()}`,t=[])=>(this.workflow.job=i.Job.fromNameAndArticles(e,t,this.workflow.jobOptions),this.workflow.job.status="IN_PROGRESS",d.TimerUtils.setTimeout(()=>this.updateProgress({...this.workflow.job},"new-job-created",null),10),this.workflow.job),createUniqueJob:async(e=`Job at ${(new Date).toISOString()}`,t,r=[])=>{const o=i.Job.fromNameAndArticles(e,r,this.workflow.jobOptions);return o.uniqueKey=t,o.status="IN_PROGRESS",await this.workflowHandler.createUniqueJob(this.workflow,o),this.workflow.job=o,this.workflow.job},Base36:w.Base36,Job:i.Job,Jwt:g.JwtParser,workflow:this.workflow,setLocale:e=>{this.currentLocaleDict=h.LangUtils.getMatchingLocaleDict(e),this.workflowHandler.onLocaleSet(e)},LTColor:o.LTColor,LTBlinkingPattern:o.LTBlinkingPattern,device:this.device,api:{setDecoderBoardSettings:e=>{this.device.decoderBoardSettings=e},fetch:async(e,t,o)=>{try{this.updateProgress({endpoint:e,data:t},"fetch",null);const n=await this.fetch(e,t,o??r);return this.updateProgress({endpoint:e,data:t,result:n},"fetch.success",null),n}catch(r){throw this.updateProgress({endpoint:e,data:t,error:r},"fetch.error",null),r}finally{n()}},fetchWithDatasource:async(e,t,o,i)=>{try{this.updateProgress({dataSource:e,endpoint:t,data:o},"fetchWithDatasource",null);const n=await this.fetchFromDataSource(e,t,o,i??r);return this.updateProgress({dataSource:e,endpoint:t,data:o,result:n},"fetchWithDatasource.success",null),n}catch(r){throw this.updateProgress({dataSource:e,endpoint:t,data:o,error:r},"fetchWithDatasource.error",null),r}finally{n()}},sendEmail:async(e,t={})=>{this.updateProgress({emailIdentifier:e,context:t,workflow:this.workflow,job:this.workflow.job},"sendEmail",null),await this.sendEmail(e,{job:this.workflow.job,workflow:this.workflow,worker:this.additionalEvalContext.worker,...t})},lighttag:{set useListeningLightTags(e){this.connectionManager.useListeningLightTags=e},get useListeningLightTags(){return this.connectionManager.useListeningLightTags},setLightTag:async(e,t)=>{this.lighttagsSet=!0;try{this.updateProgress({location:e,ledMode:t},"setLightTag",null),await this.connectionManager.setDesiredLightTagDevices([e],t)}finally{n()}},setLightTags:async(e,t=void 0,r=100,i=o.LTBlinkingPattern.BLINK)=>{this.lighttagsSet=0!==e?.length;try{this.updateProgress({desiredDevices:e,ledMode:t,intensity:r,pattern:i},"setLightTags",null),await this.connectionManager.setDesiredLightTagDevices(e,t,r,i)}finally{n()}},disableLightTag:async()=>{this.lighttagsSet=!1;try{this.updateProgress({},"disableLightTag",null),await this.connectionManager.setDesiredLightTagDevices([])}finally{n()}},disableLightTags:async()=>{try{this.updateProgress({},"disableLightTags",null),await this.connectionManager.setDesiredLightTagDevices([])}finally{n()}},attachLocation:async(e,t)=>{try{this.updateProgress({macAddress:e,location:t},"attachLocation",null),await this.connectionManager.attachLocation(e,t)}finally{n()}},detachLocation:async e=>{try{this.updateProgress({macAddress:e},"detachLocation",null),await this.connectionManager.detachLocation(e)}finally{n()}}},workflow:{done:async(e=!0,t)=>{try{this.updateProgress({stopWorkflow:e,jobToPass:t},"api.workflow.done",null),await this.done(e,t)}finally{n()}},cancel:async e=>{try{this.updateProgress({jobToPass:e},"api.workflow.cancel",null),await this.cancel(e)}finally{n()}},skip:async e=>{try{this.updateProgress({jobToPass:e},"api.workflow.skip",null),await this.skip(e)}finally{n()}},stop:async()=>{try{this.updateProgress({},"api.workflow.stop",null),await this.stop()}finally{n()}},exit:async(e=!0)=>{try{this.updateProgress({restartWorkflow:e},"api.workflow.exit",null),await this.exit(e)}finally{n()}},startWorkflowWithIdentifier:(e,t=null)=>{this.updateProgress({identifier:e,jobToPass:t},"api.workflow.startWorkflowWithIdentifier",null),this.startWorkflowWithIdentifier(e,t)},executeWorkflowStep:(e,t={})=>{this.updateProgress({name:e,override:t},"api.workflow.executeWorkflowStep",null),this.executeWorkflowStep(e,t)},canGoBack(){return this.canGoBack()},goBack:()=>{this.updateProgress({},"api.workflow.goBack",null),this.goBack()},runActionCodeAsync:async(e,t={})=>{const r=this.workflow.actions.find(t=>t.actionName===e);if(void 0===r.code)throw new Error(`Action ${e} not found!`);return this.evalWithContextAsyncThrow(r.code,t)},runActionCode:(e,t={})=>{const r=this.workflow.actions.find(t=>t.actionName===e);if(void 0===r.code)throw new Error(`Action ${e} not found!`);return this.evalWithContextThrow(r.code,t)}}},...this.additionalEvalContext,...e}}fetchFromDataSource(e,t,r,o){return this.workflowHandler.fetchFromDataSource(e,t,r,o)}fetch(e,t,r){return this.workflowHandler.fetchFromDataSource(null,e,t,r)}sendEmail(e,t){return this.workflowHandler.sendEmail(e,t)}}t.WorkflowController=v},9549(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default="ffffffff-ffff-ffff-ffff-ffffffffffff"},9566(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.PlatformAPIImpl=void 0;const o=r(946),n=r(5534),i=r(5407),s=r(1625),a=r(4471);t.PlatformAPIImpl=class{platformConnector;os;appVersion;deviceName;isPairing=!1;logger;get account(){return this.platformConnector.account}constructor(e,t,r,n){this.platformConnector=e,this.os=t,this.appVersion=r,this.deviceName=n,this.os=t,this.appVersion=r,this.deviceName=n,this.logger=o.Logger.for("PlatformAPIImpl")}async fetchWhoAmIAsync(e,t){try{const e=t?`?deviceSerial=${t}`:"",r=await this.platformConnector.httpClient.executeRequest(`app/device/self${e}`);this.logger.debug("Got whoami");const o=JSON.parse(r.responseText),n={firstName:o.user?.given_name??o.user?.firstName??"",lastName:o.user?.family_name??o.user?.lastName??"",email:!0!==o.user?.email?.includes("logistician.nimmsta.com")?o.user?.email??"":"",deviceName:o.name??"",accountName:o.organization.name,currentWorkflowExecutionId:o.currentWorkflowExecutionId,idleWorkflow:o.idleWorkflow,workerId:o.user?.id,handheldId:o.id,additionalData:o.user?.additionalData,requestLogFile:o.requestLogFile,shouldUpdateDeviceOrganization:o.user?.shouldUpdateDeviceOrganization};return this.platformConnector.account.whoAmI=n,n}catch(e){this.logger.error("Error fetching whoami",e);const t=e instanceof n.HTTPError&&401===e.status;throw t&&(this.platformConnector.account.whoAmI=null),new s.WhoAmIError(`Error fetching whoami due to ${e}`,t,e)}}async pairWithAsync(e,t){if(this.logger.debug(`Pairing using ${e}`),!this.isPairing){this.isPairing=!1;try{await this.platformConnector.pairWith(e,this.deviceName)}catch(e){throw e instanceof i.PairingError?e:new i.PairingError(`Error pairing device due to ${e}`,e)}finally{this.isPairing=!1}}}async startNextWorkflowAsync(e,t,r,o,n){const i=await this.platformConnector.httpClient.executeRequest("app/startNextWorkflow","POST",{"Content-Type":"application/json"},JSON.stringify({desiredWorkflow:e,previousResult:t.results,previousExecutionId:t.executionId,jobToPass:r,supportedSchemaVersion:o,device:{deviceSerial:t.device?.deviceSerial,deviceType:t.device?.deviceType,deviceAddress:t.device?.deviceAddress,deviceVersions:JSON.stringify(t.device?.deviceVersions),operationsData:t.device?.operationsData}}),n);return JSON.parse(i.responseText)}async cancelJobAsync(e){await this.platformConnector.httpClient.executeRequest("app/cancelJob","POST",{},null,e)}async stopJobAsync(e){await this.platformConnector.httpClient.executeRequest("app/stopJob","POST",{},null,e)}async skipJobAsync(e){await this.platformConnector.httpClient.executeRequest("app/skipJob","POST",{},null,e)}async completeJobAsync(e,t){await this.platformConnector.httpClient.executeRequest("app/completeJobWithData","POST",{"Content-Type":"application/json"},JSON.stringify({executionId:e.executionId,currentResult:JSON.stringify(e.results),data:JSON.stringify(e.data),condition:null,device:{deviceSerial:e.device?.deviceSerial,deviceType:e.device?.deviceType,deviceAddress:e.device?.deviceAddress,deviceVersions:JSON.stringify(e.device?.deviceVersions),operationsData:e.device?.operationsData}},a.errorAwareReplacer),t)}async createUniqueJob(e,t){const r=await this.platformConnector.httpClient.executeRequest("app/createUniqueJob","POST",{"Content-Type":"application/json"},JSON.stringify({currentResult:JSON.stringify(e.results),data:JSON.stringify(e.data),job:JSON.stringify(e.job),condition:JSON.stringify(e.condition),device:{deviceSerial:e.device?.deviceSerial,deviceType:e.device?.deviceType,deviceAddress:e.device?.deviceAddress,deviceVersions:JSON.stringify(e.device?.deviceVersions),operationsData:e.device?.operationsData}}),t);return JSON.parse(r.responseText)}async smartWatchDisconnectedAsync(e,t,r){await this.platformConnector.httpClient.executeRequest("app/smart-watch-disconnected","POST",{"Content-Type":"application/json"},JSON.stringify({deviceSerial:e.deviceSerial,deviceType:e.deviceType,deviceAddress:e.deviceAddress,deviceVersions:JSON.stringify(e.deviceVersions),operationsData:e.operationsData,disconnectReason:t}),r)}async smartWatchConnectedAsync(e,t){await this.platformConnector.httpClient.executeRequest("app/smart-watch-connected","POST",{"Content-Type":"application/json"},JSON.stringify({deviceSerial:e.deviceSerial,deviceType:e.deviceType,deviceAddress:e.deviceAddress,deviceVersions:JSON.stringify(e.deviceVersions),operationsData:e.operationsData}),t)}async getEndpointFromDataSourceAsync(e,t,r){const o=await this.platformConnector.httpClient.executeRequest(`app/api/${e}/${t}`,"GET",{},null,r);return JSON.parse(o.responseText)}async executeDataSourceEndpointAsync(e,t,r,o){!(r=r||{}).body||r.body instanceof String||(r.body=JSON.stringify(r.body)),r.timestamp=(new Date).toISOString();const n=(await this.platformConnector.httpClient.executeRequest(`app/api/${e}/${t}/execute`,"POST",{"Content-Type":"application/json"},JSON.stringify(r),o)).responseText;try{return JSON.parse(n)}catch{return n}}async logEventAsync(e,t){await this.platformConnector.logEvent(e)}async uploadCurrentLogFile(){await this.platformConnector.uploadLogFile()}async sendEmail(e,t,r){await this.platformConnector.httpClient.executeRequest(`app/email/template/${e}/send`,"POST",{"Content-Type":"application/json"},JSON.stringify(t),r)}}},9585(e,t){Object.defineProperty(t,"__esModule",{value:!0})},9586(e,t){Object.defineProperty(t,"__esModule",{value:!0})},9711(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.WorkflowStepControllerFactory=void 0;const o=r(6265);class n{static customControllers=new Map;static createWorkflowStepController(e,t,r){return r.type?this.customControllers.has(r.type)?new(this.customControllers.get(r.type))(e,t,r):void console.error("Custom type set but no Controller is registered!"):new o.WorkflowStepController(e,t,r)}static registerWorkflowStepController(e,t){this.customControllers.set(e,t)}}t.WorkflowStepControllerFactory=n},9899(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.JwtParser=void 0;class r{static base64UrlDecode(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const r=t.length%4;let o;if(r&&(t+="====".slice(0,4-r)),"undefined"!=typeof atob)o=atob(t);else{if("undefined"==typeof Buffer)throw new Error("JwtParser: no base64 decoder (atob or Buffer) available");o=Buffer.from(t,"base64").toString("binary")}try{return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(Uint8Array.from(o,e=>e.charCodeAt(0))):decodeURIComponent(escape(o))}catch{return o}}static decode(e){if(!e||"string"!=typeof e)return null;const t=e.trim().split(".");if(3!==t.length)return null;try{return{header:JSON.parse(r.base64UrlDecode(t[0])),payload:JSON.parse(r.base64UrlDecode(t[1]))}}catch{return null}}static decodePayload(e){const t=r.decode(e);return t?t.payload:null}static getExpirationTime(e){const t=r.decodePayload(e);return t&&"number"==typeof t.exp?t.exp:null}static isExpired(e,t=0){const o=r.getExpirationTime(e);return null==o||o<=Math.floor(Date.now()/1e3)-t}}t.JwtParser=r},9995(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.PlatformLogEventAction=void 0,t.PlatformLogEventAction=class{name="PlatformLogEventAction";isDeviceAction=!1;data;constructor(e){this.data=e}}}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,o),i.exports}return o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o(8344)})());
|
|
2
|
+
//# sourceMappingURL=workflow.bundle.js.map
|