UNPKG

scorm-again

Version:

A modern SCORM JavaScript run-time library for SCORM 1.2 and SCORM 2004

1 lines 362 kB
!function(){"use strict";const e={D:86400,H:3600,M:60,S:1},t=e=>{if(!e||0>=e)return"00:00:00";const t=Math.floor(e/3600),i=new Date(1e3*e),s=i.getUTCMinutes(),r=i.getSeconds(),n=e%1;let o="";return a(n)>0&&(o=a(n)>2?n.toFixed(2):n+"",o="."+o.split(".")[1]),(t+":"+s+":"+r).replace(/\b\d\b/g,"0$&")+o},i=t=>{if(!t||0>=t)return"PT0S";let i="P",s=t;return Object.entries(e).forEach(e=>{let[t,r]=e,n=Math.floor(s/r);s%=r,a(s)>2&&(s=+(+s).toFixed(2)),"S"===t&&s>0&&(n+=s),n&&((i.indexOf("D")>0||["H","M","S"].includes(t))&&-1===i.indexOf("T")&&(i+="T"),i+=`${n}${t}`)}),i},s=l((e,t)=>{if("number"!=typeof e&&"boolean"!=typeof e||(e+=""),"string"==typeof t&&(t=RegExp(t)),!e)return 0;if(!e.match(t))return/^\d+(?:\.\d+)?$/.test(e)?+e:0;const i=e.split(":");return 3600*+i[0]+60*+i[1]+ +i[2]},(e,t)=>`${"string"==typeof e?e:(e??"")+""}:${"string"==typeof t?t:t?.toString()??""}`),r=l((e,t)=>{if("string"==typeof t&&(t=RegExp(t)),!e||!e?.match?.(t))return 0;const[,i,s,r,n,o,a,c]=RegExp(t).exec?.(e)??[];let result=0;return result+=+c||0,result+=60*+a||0,result+=3600*+o||0,result+=86400*+n||0,result+=604800*+r||0,result+=2592e3*+s||0,result+=31536e3*+i||0,result},(e,t)=>`${e??""}:${"string"==typeof t?t:t?.toString()??""}`),n=l((e,t)=>("string"==typeof t&&(t=RegExp(t)),!(!e||!e?.match?.(t))));function o(e){const result={};return function e(t,i){if(Object(t)!==t)result[i]=t;else if(Array.isArray(t))t.forEach((t,s)=>{e(t,`${i}[${s}]`)}),0===t.length&&(result[i]=[]);else{const s=Object.keys(t).filter(e=>({}.hasOwnProperty.call(t,e))),r=0===s.length;s.forEach(s=>{e(t[s],i?`${i}.${s}`:s)}),r&&i&&(result[i]={})}}(e,""),result}function a(e){if(Math.floor(e)===e||0>(e+"")?.indexOf?.("."))return 0;const t=(""+e).split(".")?.[1];return t?.length??0}function c(e,t){return"string"==typeof e&&RegExp(t).test(e)}function l(e,t){const i=new Map;return function(){for(var s=arguments.length,r=Array(s),n=0;s>n;n++)r[n]=arguments[n];const o=t?t(...r):JSON.stringify(r);return i.has(o)?i.get(o):(()=>{const result=e(...r);return i.set(o,result),result})()}}var u=Object.defineProperty,h=(e,t,i)=>((e,t,i)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class d{constructor(e){h(this,"jsonString",!1),h(this,"_cmi_element"),h(this,"_initialized",!1),this._cmi_element=e}get initialized(){return this._initialized}initialize(){this._initialized=!0}}class m extends d{constructor(){super(...arguments),h(this,"_start_time")}get start_time(){return this._start_time}setStartTime(){if(void 0!==this._start_time)throw Error("Start time has already been set.");this._start_time=(new Date).getTime()}}var p=Object.defineProperty,_=(e,t,i)=>((e,t,i)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class v extends Error{constructor(e,t){super(`${e} : ${""+t}`),_(this,"_errorCode"),this._errorCode=t,Object.setPrototypeOf(this,v.prototype)}get errorCode(){return this._errorCode}}class g extends v{constructor(e,t,i,s){super(e,t),_(this,"_errorMessage"),_(this,"_detailedMessage",""),this.message=`${e} : ${i}`,this._errorMessage=i,s&&(this._detailedMessage=s),Object.setPrototypeOf(this,g.prototype)}get errorMessage(){return this._errorMessage}get detailedMessage(){return this._detailedMessage}}const f="true",S="false",b="raw,min,max",y="id,score,status",C={0:{basicMessage:"No Error",detailMessage:"No error occurred, the previous API call was successful."},101:{basicMessage:"General Exception",detailMessage:"No specific error code exists to describe the error."},201:{basicMessage:"Invalid argument error",detailMessage:"Indicates that an argument represents an invalid data model element or is otherwise incorrect."},202:{basicMessage:"Element cannot have children",detailMessage:'Indicates that LMSGetValue was called with a data model element name that ends in "_children" for a data model element that does not support the "_children" suffix.'},203:{basicMessage:"Element not an array - cannot have count",detailMessage:'Indicates that LMSGetValue was called with a data model element name that ends in "_count" for a data model element that does not support the "_count" suffix.'},301:{basicMessage:"Not initialized",detailMessage:"Indicates that an API call was made before the call to lmsInitialize."},401:{basicMessage:"Not implemented error",detailMessage:"The data model element indicated in a call to LMSGetValue or LMSSetValue is valid, but was not implemented by this LMS. SCORM 1.2 defines a set of data model elements as being optional for an LMS to implement."},402:{basicMessage:"Invalid set value, element is a keyword",detailMessage:'Indicates that LMSSetValue was called on a data model element that represents a keyword (elements that end in "_children" and "_count").'},403:{basicMessage:"Element is read only",detailMessage:"LMSSetValue was called with a data model element that can only be read."},404:{basicMessage:"Element is write only",detailMessage:"LMSGetValue was called on a data model element that can only be written to."},405:{basicMessage:"Incorrect Data Type",detailMessage:"LMSSetValue was called with a value that is not consistent with the data format of the supplied data model element."},407:{basicMessage:"Element Value Out Of Range",detailMessage:"The numeric value supplied to a LMSSetValue call is outside of the numeric range allowed for the supplied data model element."},408:{basicMessage:"Data Model Dependency Not Established",detailMessage:"Some data model elements cannot be set until another data model element was set. This error condition indicates that the prerequisite element was not set before the dependent element."}},A={cmi_children:"_version,comments_from_learner,comments_from_lms,completion_status,completion_threshold,credit,entry,exit,interactions,launch_data,learner_id,learner_name,learner_preference,location,max_time_allowed,mode,objectives,progress_measure,scaled_passing_score,score,session_time,success_status,suspend_data,time_limit_action,total_time",comments_children:"comment,timestamp,location",score_children:"max,raw,scaled,min",objectives_children:"progress_measure,completion_status,success_status,description,score,id",correct_responses_children:"pattern",student_preference_children:"audio_level,audio_captioning,delivery_speed,language",interactions_children:"id,type,objectives,timestamp,correct_responses,weighting,learner_response,result,latency,description",adl_data_children:"id,store",error_descriptions:{0:{basicMessage:"No Error",detailMessage:"No error occurred, the previous API call was successful."},101:{basicMessage:"General Exception",detailMessage:"No specific error code exists to describe the error."},102:{basicMessage:"General Initialization Failure",detailMessage:"Call to Initialize failed for an unknown reason."},103:{basicMessage:"Already Initialized",detailMessage:"Call to Initialize failed because Initialize was already called."},104:{basicMessage:"Content Instance Terminated",detailMessage:"Call to Initialize failed because Terminate was already called."},111:{basicMessage:"General Termination Failure",detailMessage:"Call to Terminate failed for an unknown reason."},112:{basicMessage:"Termination Before Initialization",detailMessage:"Call to Terminate failed because it was made before the call to Initialize."},113:{basicMessage:"Termination After Termination",detailMessage:"Call to Terminate failed because Terminate was already called."},122:{basicMessage:"Retrieve Data Before Initialization",detailMessage:"Call to GetValue failed because it was made before the call to Initialize."},123:{basicMessage:"Retrieve Data After Termination",detailMessage:"Call to GetValue failed because it was made after the call to Terminate."},132:{basicMessage:"Store Data Before Initialization",detailMessage:"Call to SetValue failed because it was made before the call to Initialize."},133:{basicMessage:"Store Data After Termination",detailMessage:"Call to SetValue failed because it was made after the call to Terminate."},142:{basicMessage:"Commit Before Initialization",detailMessage:"Call to Commit failed because it was made before the call to Initialize."},143:{basicMessage:"Commit After Termination",detailMessage:"Call to Commit failed because it was made after the call to Terminate."},201:{basicMessage:"General Argument Error",detailMessage:"An invalid argument was passed to an API method (usually indicates that Initialize, Commit or Terminate did not receive the expected empty string argument."},301:{basicMessage:"General Get Failure",detailMessage:"Indicates a failed GetValue call where no other specific error code is applicable. Use GetDiagnostic for more information."},351:{basicMessage:"General Set Failure",detailMessage:"Indicates a failed SetValue call where no other specific error code is applicable. Use GetDiagnostic for more information."},391:{basicMessage:"General Commit Failure",detailMessage:"Indicates a failed Commit call where no other specific error code is applicable. Use GetDiagnostic for more information."},401:{basicMessage:"Undefined Data Model Element",detailMessage:"The data model element name passed to GetValue or SetValue is not a valid SCORM data model element."},402:{basicMessage:"Unimplemented Data Model Element",detailMessage:"The data model element indicated in a call to GetValue or SetValue is valid, but was not implemented by this LMS. In SCORM 2004, this error would indicate an LMS that is not fully SCORM conformant."},403:{basicMessage:"Data Model Element Value Not Initialized",detailMessage:"Attempt to read a data model element that has not been initialized by the LMS or through a SetValue call. This error condition is often reached during normal execution of a SCO."},404:{basicMessage:"Data Model Element Is Read Only",detailMessage:"SetValue was called with a data model element that can only be read."},405:{basicMessage:"Data Model Element Is Write Only",detailMessage:"GetValue was called on a data model element that can only be written to."},406:{basicMessage:"Data Model Element Type Mismatch",detailMessage:"SetValue was called with a value that is not consistent with the data format of the supplied data model element."},407:{basicMessage:"Data Model Element Value Out Of Range",detailMessage:"The numeric value supplied to a SetValue call is outside of the numeric range allowed for the supplied data model element."},408:{basicMessage:"Data Model Dependency Not Established",detailMessage:"Some data model elements cannot be set until another data model element was set. This error condition indicates that the prerequisite element was not set before the dependent element."}}},E=C;class w extends g{constructor(e,t){!{}.hasOwnProperty.call(E,t+"")?super(e,101,E[101]?.basicMessage,E[101]?.detailMessage):super(e,t,E[t+""]?.basicMessage||"Unknown error",E[t+""]?.detailMessage),Object.setPrototypeOf(this,w.prototype)}}const M=A.error_descriptions;class O extends g{constructor(e,t){!{}.hasOwnProperty.call(M,t+"")?super(e,101,M[101]?.basicMessage,M[101]?.detailMessage):super(e,t,M[t+""]?.basicMessage||"Unknown error",M[t+""]?.detailMessage),Object.setPrototypeOf(this,O.prototype)}}const R={GENERAL:101,INITIALIZATION_FAILED:101,INITIALIZED:101,TERMINATED:101,TERMINATION_FAILURE:101,TERMINATION_BEFORE_INIT:101,MULTIPLE_TERMINATION:101,RETRIEVE_BEFORE_INIT:101,RETRIEVE_AFTER_TERM:101,STORE_BEFORE_INIT:101,STORE_AFTER_TERM:101,COMMIT_BEFORE_INIT:101,COMMIT_AFTER_TERM:101,ARGUMENT_ERROR:101,CHILDREN_ERROR:101,COUNT_ERROR:101,GENERAL_GET_FAILURE:101,GENERAL_SET_FAILURE:101,GENERAL_COMMIT_FAILURE:101,UNDEFINED_DATA_MODEL:101,UNIMPLEMENTED_ELEMENT:101,VALUE_NOT_INITIALIZED:101,INVALID_SET_VALUE:101,READ_ONLY_ELEMENT:101,WRITE_ONLY_ELEMENT:101,TYPE_MISMATCH:101,VALUE_OUT_OF_RANGE:101,DEPENDENCY_NOT_ESTABLISHED:101},T={...R,RETRIEVE_BEFORE_INIT:301,STORE_BEFORE_INIT:301,COMMIT_BEFORE_INIT:301,ARGUMENT_ERROR:201,CHILDREN_ERROR:202,COUNT_ERROR:203,UNDEFINED_DATA_MODEL:401,UNIMPLEMENTED_ELEMENT:401,VALUE_NOT_INITIALIZED:301,INVALID_SET_VALUE:402,READ_ONLY_ELEMENT:403,WRITE_ONLY_ELEMENT:404,TYPE_MISMATCH:405,VALUE_OUT_OF_RANGE:407,DEPENDENCY_NOT_ESTABLISHED:408},j={...R,INITIALIZATION_FAILED:102,INITIALIZED:103,TERMINATED:104,TERMINATION_FAILURE:111,TERMINATION_BEFORE_INIT:112,MULTIPLE_TERMINATION:113,MULTIPLE_TERMINATIONS:113,RETRIEVE_BEFORE_INIT:122,RETRIEVE_AFTER_TERM:123,STORE_BEFORE_INIT:132,STORE_AFTER_TERM:133,COMMIT_BEFORE_INIT:142,COMMIT_AFTER_TERM:143,ARGUMENT_ERROR:201,GENERAL_GET_FAILURE:301,GENERAL_SET_FAILURE:351,GENERAL_COMMIT_FAILURE:391,UNDEFINED_DATA_MODEL:401,UNIMPLEMENTED_ELEMENT:402,VALUE_NOT_INITIALIZED:403,READ_ONLY_ELEMENT:404,WRITE_ONLY_ELEMENT:405,TYPE_MISMATCH:406,VALUE_OUT_OF_RANGE:407,DEPENDENCY_NOT_ESTABLISHED:408};var I=Object.defineProperty,N=(e,t,i)=>((e,t,i)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class x extends d{constructor(e){super(e.CMIElement),N(this,"_errorCode"),N(this,"_errorClass"),N(this,"__children"),N(this,"childArray"),this.__children=e.children,this._errorCode=e.errorCode??T.GENERAL,this._errorClass=e.errorClass||v,this.childArray=[]}reset(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this._initialized=!1,e)this.childArray=[];else for(let e=0;this.childArray.length>e;e++)this.childArray[e]?.reset()}get _children(){return this.__children}set _children(_children){throw new this._errorClass(this._cmi_element+"._children",this._errorCode)}get _count(){return this.childArray.length}set _count(_count){throw new this._errorClass(this._cmi_element+"._count",this._errorCode)}toJSON(){this.jsonString=!0;const result={};for(let e=0;this.childArray.length>e;e++)result[e+""]=this.childArray[e];return this.jsonString=!1,result}}const q="unknown",D="true",L="false",P="passed",z="failed",F="unknown",k="completed",V="incomplete",H="unknown",B={_:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,NONE:5},U={autocommit:!1,autocommitSeconds:10,throttleCommits:!1,useAsynchronousCommits:!1,sendFullCommit:!0,lmsCommitUrl:!1,dataCommitFormat:"json",commitRequestDataType:"application/json;charset=UTF-8",autoProgress:!1,logLevel:B.ERROR,selfReportSessionTime:!1,alwaysSendTotalTime:!1,renderCommonCommitFields:!1,autoCompleteLessonStatus:!1,strict_errors:!0,xhrHeaders:{},xhrWithCredentials:!1,fetchMode:"cors",asyncModeBeaconBehavior:"never",responseHandler:async function(e){if(void 0!==e){let t=null;try{if("function"==typeof e.json)t=await e.json();else if("function"==typeof e.text){const i=await e.text();i&&(t=JSON.parse(i))}}catch(e){}return null!==t&&{}.hasOwnProperty.call(t,"result")?{result:t.result,errorCode:"number"==typeof t.errorCode?t.errorCode:!0===t.result||t.result===f?0:101}:200===e.status?{result:f,errorCode:0}:{result:S,errorCode:101}}return{result:S,errorCode:101}},xhrResponseHandler:function(e){if(void 0!==e){let t=null;if(200>e.status||e.status>299)return{result:S,errorCode:101};try{t=JSON.parse(e.responseText)}catch(e){}return null!==t&&{}.hasOwnProperty.call(t,"result")?{result:t.result,errorCode:"number"==typeof t.errorCode?t.errorCode:!0===t.result||t.result===f?0:101}:{result:f,errorCode:0}}return{result:S,errorCode:101}},requestHandler:function(e){return e},onLogMessage:$,mastery_override:!1,score_overrides_status:!1,completion_status_on_failed:"completed",scoItemIds:[],scoItemIdValidator:!1,globalObjectiveIds:[],enableOfflineSupport:!1,courseId:"",syncOnInitialize:!0,syncOnTerminate:!0,maxSyncAttempts:5,scoId:"",autoPopulateCommitMetadata:!1,httpService:null,globalStudentPreferences:!1};function $(e,t){switch(e){case"4":case 4:case"ERROR":case B.ERROR:console.error(t);break;case"3":case 3:case"WARN":case B.WARN:console.warn(t);break;case"2":case 2:case"INFO":case B.INFO:console.info(t);break;case"1":case 1:case"DEBUG":case B.DEBUG:console.debug?console.debug(t):console.log(t)}}const G="^[\\s\\S]{0,255}$",Y="^([0-9]+):([0-9]{2}):([0-9]{2})(\\.\\d{1,2})?$",W="^-?([0-9]+)$",J="^-?([0-9]{0,10})(\\.[0-9]*)?$",K="^[\\u0021-\\u007E\\s]{0,255}$",X="^.*$",Q="^(passed|completed|failed|incomplete|browsed|not attempted)$",Z="0#100",ee="^[\\u0000-\\uFFFF]{0,4000}$",te="^[\\u0000-\\uFFFF]{0,64000}$",ie="^({lang=([a-zA-Z]{1,8}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,250}$)?$",se="^({lang=([a-zA-Z]{1,8}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,4000}$)?$",re="^(19[7-9][0-9]|[2-9][0-9]{3})((-(0[1-9]|1[0-2]))((-(0[1-9]|[1-2][0-9]|3[0-1]))(T([0-1][0-9]|2[0-3])((:[0-5][0-9])((:[0-5][0-9])((\\.[0-9]{1,6})((Z|([+|-]([0-1][0-9]|2[0-3])))(:[0-5][0-9])?)?)?)?)?)?)?)?$",ne="^P(?:([.,\\d]+)Y)?(?:([.,\\d]+)M)?(?:([.,\\d]+)W)?(?:([.,\\d]+)D)?(?:T?(?:([.,\\d]+)H)?(?:([.,\\d]+)M)?(?:(\\d+(?:\\.\\d{1,2})?)S)?)?$",oe="^-?([0-9]{1,10})(\\.[0-9]{1,18})?$",ae="^(?=.*\\w)[\\w\\-\\(\\)\\+\\.\\:\\=\\@\\;\\$\\_\\!\\*\\'\\%\\/\\#]{1,250}$",ce="^(?:(?!urn:)\\S{1,4000}|urn:[A-Za-z0-9-]{1,31}:\\S{1,4000}|.{1,4000})$",le="^(completed|incomplete|not attempted|unknown)$",ue="^(passed|failed|unknown)$",he="^(_?(start|resumeAll|previous|continue|exit|exitAll|abandon|abandonAll|suspendAll|retry|retryAll)|_none_|(\\{target=(?<choice_target>\\S{0,}[a-zA-Z0-9-_]+)})?choice|(\\{target=(?<jump_target>\\S{0,}[a-zA-Z0-9-_]+)})?jump)$",de="^(unknown|true|false)$",me="^{target=\\S{0,}[a-zA-Z0-9-_]+}$",pe="^$|"+ae,_e="(?![\\s\\S]*(?:\\[,\\]|\\[\\.\\]|\\[:\\]))[\\s\\S]{1,250}",ve={"true-false":{format:"^true$|^false$",max:1,delimiter:"",unique:!1},choice:{format:ce,max:36,delimiter:"[,]",unique:!0},"fill-in":{format:ie,max:10,delimiter:"[,]",unique:!1},"long-fill-in":{format:se,max:1,delimiter:"",unique:!1},matching:{format:ae,format2:ae,max:36,delimiter:"[,]",delimiter2:"[.]",unique:!1},performance:{format:pe,format2:"^(?:|"+_e+")$",max:250,delimiter:"[,]",delimiter2:"[.]",unique:!1},sequencing:{format:ae,max:36,delimiter:"[,]",unique:!1},likert:{format:ae,max:1,delimiter:"",unique:!1},numeric:{format:oe,max:1,delimiter:"",unique:!1},other:{format:ee,max:1,delimiter:"",unique:!1}},ge={"true-false":{max:1,delimiter:"",unique:!1,duplicate:!1,format:"^true$|^false$",limit:1},choice:{max:36,delimiter:"[,]",unique:!0,duplicate:!1,format:ce},"fill-in":{max:10,delimiter:"[,]",unique:!1,duplicate:!1,format:"^(({lang=([a-zA-Z]{1,8}|i|x)?(-[a-zA-Z0-9-]{2,8})?})?(.{0,250})?)?$"},"long-fill-in":{max:1,delimiter:"",unique:!1,duplicate:!0,format:se},matching:{max:36,delimiter:"[,]",delimiter2:"[.]",unique:!1,duplicate:!1,format:ae,format2:ae},performance:{max:250,delimiter:"[,]",delimiter2:"[.]",unique:!1,duplicate:!1,format:pe,format2:"^(?:|(?:-?\\d+(?:\\.\\d+)?)?\\[:\\](?:-?\\d+(?:\\.\\d+)?)?|"+_e+")$"},sequencing:{max:36,delimiter:"[,]",unique:!1,duplicate:!1,format:ae},likert:{max:1,delimiter:"",unique:!1,duplicate:!1,format:ae,limit:1},numeric:{max:2,delimiter:"[:]",unique:!1,duplicate:!1,format:oe,limit:1},other:{max:1,delimiter:"",unique:!1,duplicate:!1,format:ee,limit:1}},fe=["aa","ab","ae","af","ak","am","an","ar","as","av","ay","az","ba","be","bg","bh","bi","bm","bn","bo","br","bs","ca","ce","ch","co","cr","cs","cu","cv","cy","da","de","dv","dz","ee","el","en","eo","es","et","eu","fa","ff","fi","fj","fo","fr","fy","ga","gd","gl","gn","gu","gv","ha","he","hi","ho","hr","ht","hu","hy","hz","ia","id","ie","ig","ii","ik","io","is","it","iu","ja","jv","ka","kg","ki","kj","kk","kl","km","kn","ko","kr","ks","ku","kv","kw","ky","la","lb","lg","li","ln","lo","lt","lu","lv","mg","mh","mi","mk","ml","mn","mo","mr","ms","mt","my","na","nb","nd","ne","ng","nl","nn","no","nr","nv","ny","oc","oj","om","or","os","pa","pi","pl","ps","pt","qu","rm","rn","ro","ru","rw","sa","sc","sd","se","sg","sh","si","sk","sl","sm","sn","so","sq","sr","ss","st","su","sv","sw","ta","te","tg","th","ti","tk","tl","tn","to","tr","ts","tt","tw","ty","ug","uk","ur","uz","ve","vi","vo","wa","wo","xh","yi","yo","za","zh","zu","aar","abk","ave","afr","aka","amh","arg","ara","asm","ava","aym","aze","bak","bel","bul","bih","bis","bam","ben","tib","bod","bre","bos","cat","che","cha","cos","cre","cze","ces","chu","chv","wel","cym","dan","ger","deu","div","dzo","ewe","gre","ell","eng","epo","spa","est","baq","eus","per","fas","ful","fin","fij","fao","fre","fra","fry","gle","gla","glg","grn","guj","glv","hau","heb","hin","hmo","hrv","hat","hun","arm","hye","her","ina","ind","ile","ibo","iii","ipk","ido","ice","isl","ita","iku","jpn","jav","geo","kat","kon","kik","kua","kaz","kal","khm","kan","kor","kau","kas","kur","kom","cor","kir","lat","ltz","lug","lim","lin","lao","lit","lub","lav","mlg","mah","mao","mri","mac","mkd","mal","mon","mol","mar","may","msa","mlt","bur","mya","nau","nob","nde","nep","ndo","dut","nld","nno","nor","nbl","nav","nya","oci","oji","orm","ori","oss","pan","pli","pol","pus","por","que","roh","run","rum","ron","rus","kin","san","srd","snd","sme","sag","slo","sin","slk","slv","smo","sna","som","alb","sqi","srp","ssw","sot","sun","swe","swa","tam","tel","tgk","tha","tir","tuk","tgl","tsn","ton","tur","tso","tat","twi","tah","uig","ukr","urd","uzb","ven","vie","vol","wln","wol","xho","yid","yor","zha","chi","zho","zul"];var Se=Object.defineProperty,be=(e,t,i)=>((e,t,i)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class ye{constructor(e,t,i){be(this,"_API"),be(this,"_cancelled",!1),be(this,"_timeout"),be(this,"_callback"),this._API=e,this._timeout=setTimeout(this.wrapper.bind(this),t),this._callback=i}cancel(){this._cancelled=!0,this._timeout&&clearTimeout(this._timeout)}wrapper(){this._cancelled||this._API.isInitialized()&&(async()=>{await this._API.commit(this._callback)})()}}const Ce=["continue","previous","exit","exitAll","abandon","abandonAll","suspendAll"];var Ae=Object.defineProperty,Ee=(e,t,i)=>((e,t,i)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i),we=(e=>(e.NOT="not",e.AND="and",e.OR="or",e))(we||{}),Me=(e=>(e.SKIP="skip",e.DISABLED="disabled",e.HIDE_FROM_CHOICE="hiddenFromChoice",e.STOP_FORWARD_TRAVERSAL="stopForwardTraversal",e.EXIT_PARENT="exitParent",e.EXIT_ALL="exitAll",e.RETRY="retry",e.RETRY_ALL="retryAll",e.CONTINUE="continue",e.PREVIOUS="previous",e.EXIT="exit",e))(Me||{});const Oe=class e extends d{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"always",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Map;super("ruleCondition"),Ee(this,"_condition","always"),Ee(this,"_operator",null),Ee(this,"_parameters",new Map),Ee(this,"_referencedObjective",null),this._condition=e,this._operator=t,this._parameters=i}static setNowProvider(t){"function"==typeof t&&(e._now=t)}static setElapsedSecondsHook(t){e._getElapsedSecondsHook=t}reset(){this._initialized=!1,this._condition="always",this._operator=null,this._parameters=new Map}get condition(){return this._condition}set condition(e){this._condition=e}get operator(){return this._operator}set operator(e){this._operator=e}get parameters(){return this._parameters}set parameters(e){this._parameters=e}get referencedObjective(){return this._referencedObjective}set referencedObjective(e){this._referencedObjective=e}resolveReferencedObjective(e){return this._referencedObjective?e.primaryObjective?.id===this._referencedObjective?e.primaryObjective:(e.objectives||[]).find(e=>e.id===this._referencedObjective)||null:null}evaluate(e){let result;const t=this.resolveReferencedObjective(e);switch(this._condition){case"satisfied":case"objectiveSatisfied":result=t?!0===t.satisfiedStatus:e.successStatus===P||!0===e.objectiveSatisfiedStatus;break;case"objectiveStatusKnown":case"objectiveMeasureKnown":result=t?!!t.measureStatus:!!e.objectiveMeasureStatus;break;case"objectiveMeasureGreaterThan":{const i=this._parameters.get("threshold")||0;result=!!(t?t.measureStatus:e.objectiveMeasureStatus)&&(t?t.normalizedMeasure:e.objectiveNormalizedMeasure)>i;break}case"objectiveMeasureLessThan":{const i=this._parameters.get("threshold")||0;result=!!(t?t.measureStatus:e.objectiveMeasureStatus)&&i>(t?t.normalizedMeasure:e.objectiveNormalizedMeasure);break}case"completed":case"activityCompleted":result=t?t.completionStatus===k:e.isCompleted;break;case"progressKnown":case"activityProgressKnown":result=t?t.completionStatus!==H:"unknown"!==e.completionStatus;break;case"attempted":result=e.attemptCount>0;break;case"attemptLimitExceeded":result=e.hasAttemptLimitExceeded();break;case"timeLimitExceeded":result=this.evaluateTimeLimitExceeded(e);break;case"outsideAvailableTimeRange":result=this.evaluateOutsideAvailableTimeRange(e);break;case"always":result=!0;break;default:result=!1}return"not"===this._operator&&(result=!result),result}evaluateTimeLimitExceeded(t){let i=t.timeLimitDuration;if(!i&&t.attemptAbsoluteDurationLimit&&(i=t.attemptAbsoluteDurationLimit),!i)return!1;const s=r(i,ne);if(0>=s)return!1;let n=0;if(e._getElapsedSecondsHook)try{const i=e._getElapsedSecondsHook(t);"number"!=typeof i||Number.isNaN(i)||0>i||(n=i)}catch{n=0}if(0===n&&t.attemptExperiencedDuration){const e=r(t.attemptExperiencedDuration,ne);e>0&&(n=e)}if(0===n&&t.attemptAbsoluteStartTime)try{const i=new Date(t.attemptAbsoluteStartTime).getTime(),s=e._now().getTime();Number.isNaN(i)||Number.isNaN(s)||i>s||(n=(s-i)/1e3)}catch{n=0}return n>s}evaluateOutsideAvailableTimeRange(t){const i=t.beginTimeLimit,s=t.endTimeLimit;if(!i&&!s)return!1;const r=e._now();return!(!i||r>=new Date(i))||!(!s||new Date(s)>=r)}parseISO8601Duration(e){return 1e3*r(e,ne)}toJSON(){this.jsonString=!0;const result={condition:this._condition,operator:this._operator,parameters:Object.fromEntries(this._parameters)};return this.jsonString=!1,result}};Ee(Oe,"_now",()=>new Date),Ee(Oe,"_getElapsedSecondsHook");let Re=Oe;class Te extends d{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"skip",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"and";super("sequencingRule"),Ee(this,"_conditions",[]),Ee(this,"_action","skip"),Ee(this,"_conditionCombination","and"),this._action=e,this._conditionCombination=t}reset(){this._initialized=!1,this._conditions=[],this._action="skip",this._conditionCombination="and"}get conditions(){return this._conditions}addCondition(e){if(!(e instanceof Re))throw new O(this._cmi_element+".conditions",j.TYPE_MISMATCH);this._conditions.includes(e)||this._conditions.push(e)}removeCondition(e){if(!(e instanceof Re))throw new O(this._cmi_element+".conditions",j.TYPE_MISMATCH);const t=this._conditions.indexOf(e);return-1!==t&&(this._conditions.splice(t,1),!0)}get action(){return this._action}set action(e){this._action=e}get conditionCombination(){return this._conditionCombination}set conditionCombination(e){this._conditionCombination=e}evaluate(e){return 0===this._conditions.length||("all"===this._conditionCombination||"and"===this._conditionCombination?this._conditions.every(t=>t.evaluate(e)):("any"===this._conditionCombination||"or"===this._conditionCombination)&&this._conditions.some(t=>t.evaluate(e)))}toJSON(){this.jsonString=!0;const result={conditions:this._conditions,action:this._action,conditionCombination:this._conditionCombination};return this.jsonString=!1,result}}class je extends d{constructor(){super("sequencingRules"),Ee(this,"_preConditionRules",[]),Ee(this,"_exitConditionRules",[]),Ee(this,"_postConditionRules",[])}reset(){this._initialized=!1,this._preConditionRules=[],this._exitConditionRules=[],this._postConditionRules=[]}get preConditionRules(){return this._preConditionRules}addPreConditionRule(e){if(!(e instanceof Te))throw new O(this._cmi_element+".preConditionRules",j.TYPE_MISMATCH);this._preConditionRules.push(e)}get exitConditionRules(){return this._exitConditionRules}addExitConditionRule(e){if(!(e instanceof Te))throw new O(this._cmi_element+".exitConditionRules",j.TYPE_MISMATCH);this._exitConditionRules.push(e)}get postConditionRules(){return this._postConditionRules}addPostConditionRule(e){if(!(e instanceof Te))throw new O(this._cmi_element+".postConditionRules",j.TYPE_MISMATCH);this._postConditionRules.push(e)}evaluatePreConditionRules(e){for(const t of this._preConditionRules)if(t.evaluate(e))return t.action;return null}evaluateExitConditionRules(e){for(const t of this._exitConditionRules)if(t.evaluate(e))return t.action;return null}evaluatePostConditionRules(e){for(const t of this._postConditionRules)if(t.evaluate(e))return t.action;return null}toJSON(){this.jsonString=!0;const result={preConditionRules:this._preConditionRules,exitConditionRules:this._exitConditionRules,postConditionRules:this._postConditionRules};return this.jsonString=!1,result}}var Ie=Object.defineProperty;class Ne{constructor(e){((e,t,i)=>{t in e?Ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i})(this,"activityTree"+"",e)}isInTree(e){return this.activityTree.getAllActivities().includes(e)}isAncestorOf(e,t){let i=t;for(;i;){if(i===e)return!0;i=i.parent}return!1}findCommonAncestor(e,t){if(!e||!t)return null;const i=[];let s=e;for(;s;)i.push(s),s=s.parent;for(s=t;s;){if(i.includes(s))return s;s=s.parent}return null}findChildInPath(e,t){let i=t;for(;i&&i.parent;){if(i.parent===e)return i;i=i.parent}return null}isLastInTree(e){if(e.children.length>0)return!1;let t=e;for(;t;){if(this.activityTree.getNextSibling(t))return!1;t=t.parent}return!0}getCurrentInParent(e){if(e.children)for(const t of e.children)if(t.isActive)return t;return null}isMandatory(e){if(e.sequencingRules&&e.sequencingRules.preConditionRules)for(const t of e.sequencingRules.preConditionRules)if("skip"===t.action&&t.conditions&&0===t.conditions.length)return!1;return!0===e.mandatory}isCompleted(e){return"completed"===e.completionStatus||"passed"===e.completionStatus||"passed"===e.successStatus}isAvailableForChoice(e){return e.isVisible&&!e.isHiddenFromChoice&&e.isAvailable&&(!e.sequencingControls||e.sequencingControls.choice)}getAncestors(e){const t=[];let i=e.parent;for(;i;)t.push(i),i=i.parent;return t}getPathToRoot(e){const t=[e];let i=e.parent;for(;i;)t.push(i),i=i.parent;return t}isLeaf(e){return 0===e.children.length}isCluster(e){return e.children.length>0}getDepth(e){let t=0,i=e.parent;for(;i;)t++,i=i.parent;return t}}var xe=Object.defineProperty,qe=(e,t,i)=>((e,t,i)=>t in e?xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class De{constructor(e,t){qe(this,"activityTree",e),qe(this,"treeQueries",t)}validateChoice(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!this.treeQueries.isInTree(t))return{valid:!1,exception:"SB.2.9-2"};if(t===this.activityTree.root)return{valid:!1,exception:"SB.2.9-3"};const s=this.validatePathToRoot(t);if(!s.valid)return s;if(i.checkAvailability&&!t.isAvailable)return{valid:!1,exception:"SB.2.9-7"};if(!e)return{valid:!0,exception:null};const r=this.validateChoiceExit(e,t);if(!r.valid)return r;const n=this.validateAncestorConstraints(e,t);return n.valid?{valid:!0,exception:null}:n}validatePathToRoot(e){let t=e;for(;t;){if(t.isHiddenFromChoice)return{valid:!1,exception:"SB.2.9-4"};if(t.parent&&!t.parent.sequencingControls.choice)return{valid:!1,exception:"SB.2.9-5"};if(t.parent&&t.parent.sequencingControls.preventActivation&&0===e.attemptCount&&!e.isActive)return{valid:!1,exception:"SB.2.9-6"};t=t.parent}return{valid:!0,exception:null}}validateChoiceExit(e,t){let i=e.parent;for(;i;){if(i.isActive&&!i.sequencingControls.choiceExit){if(!this.treeQueries.isAncestorOf(i,t))return{valid:!1,exception:"SB.2.9-8"};break}i=i.parent}return{valid:!0,exception:null}}validateAncestorConstraints(e,t){let i=t.parent;for(;i;){const s=this.validateConstraintsAtLevel(i,e,t);if(!s.valid)return s;i=i.parent}return{valid:!0,exception:null}}validateConstraintsAtLevel(e,t,i){const s=this.treeQueries.findChildInPath(e,i),r=this.treeQueries.findChildInPath(e,t);if(!s||!r)return{valid:!0,exception:null};const n=e.children,o=n.indexOf(s),a=n.indexOf(r);if(-1===o||-1===a)return{valid:!0,exception:null};if(e.sequencingControls.forwardOnly&&a>o)return{valid:!1,exception:"SB.2.9-5"};if(o>a)for(let e=a+1;o>e;e++){const t=n[e];if(t&&this.treeQueries.isMandatory(t)&&!this.treeQueries.isCompleted(t))return{valid:!1,exception:"SB.2.9-6"}}if(e.sequencingControls.constrainChoice){if(o>a+1)return{valid:!1,exception:"SB.2.9-7"};if(a>o&&"completed"!==i.completionStatus&&"passed"!==i.completionStatus)return{valid:!1,exception:"SB.2.9-7"}}return e.sequencingControls.preventActivation&&0===i.attemptCount&&!i.isActive?{valid:!1,exception:"SB.2.9-6"}:{valid:!0,exception:null}}checkForwardOnlyViolation(e){let t=e.parent;for(;t;){if(t.sequencingControls.forwardOnly)return{valid:!1,exception:"SB.2.9-5"};t=t.parent}return{valid:!0,exception:null}}isAvailableForChoice(e){return this.treeQueries.isAvailableForChoice(e)}validateFlowConstraints(e,t){const i=[];for(const s of t)this.meetsFlowConstraints(s,e)&&i.push(s);return{valid:i.length>0,validChildren:i}}meetsFlowConstraints(e,t){return!(!e.isAvailable||e.isHiddenFromChoice)&&(!t.sequencingControls.constrainChoice||this.validateConstrainChoiceForFlow(e,t))}validateConstrainChoiceForFlow(e,t){if(!t.sequencingControls||!t.sequencingControls.constrainChoice)return!0;const i=t.children;if(!i||0===i.length)return!0;const s=i.indexOf(e);if(-1===s)return!1;const r=this.treeQueries.getCurrentInParent(t);if(!r)return this.isAvailableForChoice(e);const n=i.indexOf(r);return-1===n||(t.sequencingControls.flow?t.sequencingControls.forwardOnly&&n>s?"completed"===e.completionStatus||"passed"===e.completionStatus:n>s?n>s&&("completed"===e.completionStatus||"passed"===e.completionStatus)&&this.isAvailableForChoice(e):(s===n||s===n+1)&&this.isAvailableForChoice(e):this.isAvailableForChoice(e)&&("completed"===e.completionStatus||"unknown"===e.completionStatus||"incomplete"===e.completionStatus))}validateTraversalConstraints(e){let t=!0,i=!0;return e.parent?.sequencingControls.constrainChoice&&(t=this.evaluateConstrainChoiceForTraversal(e)),e.sequencingControls&&e.sequencingControls.stopForwardTraversal&&(i=!1),e.parent?.sequencingControls.forwardOnly&&(i=this.evaluateForwardOnlyForChoice(e)),{canTraverse:t,canTraverseInto:i}}evaluateConstrainChoiceForTraversal(e){if(!e.parent)return!0;let t=e.parent;for(;t;){if(t.sequencingControls&&t.sequencingControls.constrainChoice){const i=t.children,s=this.treeQueries.findChildInPath(t,e);if(s){const r=i.indexOf(s),n=this.treeQueries.getCurrentInParent(t);if(n){const s=i.indexOf(n);if(-1!==s&&-1!==r){if(r>s)for(let e=s+1;r>e;e++){const t=i[e];if(t&&this.treeQueries.isMandatory(t)&&!this.treeQueries.isCompleted(t))return!1}if(t.sequencingControls.forwardOnly&&s>r&&!this.treeQueries.isCompleted(e))return!1}}}}t=t.parent}return this.isAvailableForChoice(e)}evaluateForwardOnlyForChoice(e){if(!e.parent)return!0;const t=e.parent;if(!t.sequencingControls||!t.sequencingControls.forwardOnly)return!0;const i=t.children;if(!i||0===i.length)return!0;const s=i.indexOf(e);if(-1===s)return!1;const r=this.treeQueries.getCurrentInParent(t);if(!r)return this.isAvailableForChoice(e);const n=i.indexOf(r);return-1===n||(n>s?!("completed"!==e.completionStatus&&"passed"!==e.completionStatus||!e.sequencingControls||!e.sequencingControls.choice):this.isAvailableForChoice(e))}hasTimeBoundaryViolation(e,t){if(e.beginTimeLimit)try{if(new Date(e.beginTimeLimit)>t)return!0}catch{}if(e.endTimeLimit)try{if(t>new Date(e.endTimeLimit))return!0}catch{}return!1}hasAttemptLimitViolation(e){return!(!e.attemptLimit||e.attemptLimit>e.attemptCount)}}var Le=Object.defineProperty,Pe=(e,t,i)=>((e,t,i)=>t in e?Le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i),ze=(e=>(e.START="start",e.RESUME_ALL="resumeAll",e.CONTINUE="continue",e.PREVIOUS="previous",e.CHOICE="choice",e.JUMP="jump",e.EXIT="exit",e.EXIT_PARENT="exitParent",e.EXIT_ALL="exitAll",e.ABANDON="abandon",e.ABANDON_ALL="abandonAll",e.SUSPEND_ALL="suspendAll",e.RETRY="retry",e.RETRY_ALL="retryAll",e))(ze||{}),Fe=(e=>(e.DELIVER="deliver",e.DO_NOT_DELIVER="doNotDeliver",e))(Fe||{});class ke{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"doNotDeliver",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];Pe(this,"deliveryRequest"),Pe(this,"targetActivity"),Pe(this,"exception"),Pe(this,"endSequencingSession"),this.deliveryRequest=e,this.targetActivity=t,this.exception=i,this.endSequencingSession=s}}class Ve{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];Pe(this,"identifiedActivity"),Pe(this,"deliverable"),Pe(this,"exception"),Pe(this,"endSequencingSession"),this.identifiedActivity=e,this.deliverable=t,this.exception=i,this.endSequencingSession=s}}class He{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;Pe(this,"activity"),Pe(this,"exception"),this.activity=e,this.exception=t}}var Be=(e=>(e.FORWARD="forward",e.BACKWARD="backward",e))(Be||{}),Ue=Object.defineProperty,$e=(e,t,i)=>((e,t,i)=>t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Ge{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};$e(this,"now"),$e(this,"getAttemptElapsedSecondsHook"),this.now=e.now||(()=>new Date),this.getAttemptElapsedSecondsHook=e.getAttemptElapsedSecondsHook||null}checkSequencingRules(e,t){for(const i of t)if(this.checkRuleSubprocess(e,i))return i.action;return null}checkRuleSubprocess(e,t){if(0===t.conditions.length)return!0;const i=t.conditionCombination;return"all"===i||i===we.AND?t.conditions.every(t=>t.evaluate(e)):("any"===i||i===we.OR)&&t.conditions.some(t=>t.evaluate(e))}evaluateExitRules(e){const t=this.checkSequencingRules(e,e.sequencingRules.exitConditionRules);return t===Me.EXIT||t===Me.EXIT_PARENT||t===Me.EXIT_ALL?t:null}evaluatePostConditionAction(e){const t=this.checkSequencingRules(e,e.sequencingRules.postConditionRules);return t&&[Me.EXIT_PARENT,Me.EXIT_ALL,Me.RETRY,Me.RETRY_ALL,Me.CONTINUE,Me.PREVIOUS,Me.STOP_FORWARD_TRAVERSAL].includes(t)?t:null}evaluatePostConditions(e){const t=this.evaluatePostConditionAction(e);if(!t)return{sequencingRequest:null,terminationRequest:null};switch(t){case Me.EXIT_PARENT:return{sequencingRequest:null,terminationRequest:ze.EXIT_PARENT};case Me.EXIT_ALL:return{sequencingRequest:null,terminationRequest:ze.EXIT_ALL};case Me.RETRY:return{sequencingRequest:ze.RETRY,terminationRequest:null};case Me.RETRY_ALL:return{sequencingRequest:ze.RETRY,terminationRequest:ze.EXIT_ALL};case Me.CONTINUE:return{sequencingRequest:ze.CONTINUE,terminationRequest:null};case Me.PREVIOUS:return{sequencingRequest:ze.PREVIOUS,terminationRequest:null};case Me.STOP_FORWARD_TRAVERSAL:return e.sequencingControls.stopForwardTraversal=!0,{sequencingRequest:null,terminationRequest:null};default:return{sequencingRequest:null,terminationRequest:null}}}checkLimitConditions(e){if(null!==e.attemptLimit&&e.attemptCount>=e.attemptLimit)return!0;if(null!==e.attemptAbsoluteDurationLimit){const t=this.parseDuration(e.attemptAbsoluteDurationLimit);if(t>0&&this.parseDuration(e.attemptExperiencedDuration)>=t)return!0}if(null!==e.activityAbsoluteDurationLimit){const t=this.parseDuration(e.activityAbsoluteDurationLimit);if(t>0&&this.parseDuration(e.activityExperiencedDuration)>=t)return!0}return!1}parseDuration(e){if(!e||"string"!=typeof e)return 0;const t=e.match(/^P(?:(\d+(?:\.\d+)?)Y)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)W)?(?:(\d+(?:\.\d+)?)D)?(?:T(?:(\d+(?:\.\d+)?)H)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)S)?)?$/);if(!t||"P"===e||e.endsWith("T"))return 0;let i=0;return i+=315576e5*parseFloat(t[1]||"0"),i+=30.44*24*parseFloat(t[2]||"0")*36e5,i+=6048e5*parseFloat(t[3]||"0"),i+=864e5*parseFloat(t[4]||"0"),i+=36e5*parseFloat(t[5]||"0"),i+=6e4*parseFloat(t[6]||"0"),i+=1e3*parseFloat(t[7]||"0"),i}getElapsedSeconds(e){if(this.getAttemptElapsedSecondsHook)try{return this.getAttemptElapsedSecondsHook(e)||0}catch{return 0}if(e.attemptAbsoluteStartTime){const t=new Date(e.attemptAbsoluteStartTime).getTime(),i=this.now().getTime();if(!Number.isNaN(t)&&i>t)return Math.max(0,(i-t)/1e3)}return 0}isTimeLimitExceeded(e){let t=e.timeLimitDuration;if(!t&&e.attemptAbsoluteDurationLimit&&(t=e.attemptAbsoluteDurationLimit),!t)return!1;const i=r(t,ne);return i>0&&this.getElapsedSeconds(e)>i}isOutsideAvailableTimeRange(e){const t=this.now();if(e.beginTimeLimit)try{const i=new Date(e.beginTimeLimit);if(!Number.isNaN(i.getTime())&&i>t)return!0}catch{}if(e.endTimeLimit)try{const i=new Date(e.endTimeLimit);if(!Number.isNaN(i.getTime())&&t>i)return!0}catch{}return!1}canDeliverActivity(e){if(this.checkLimitConditions(e))return{canDeliver:!1,wasSkipped:!1};const t=this.checkSequencingRules(e,e.sequencingRules.preConditionRules);return{canDeliver:t!==Me.SKIP&&t!==Me.DISABLED,wasSkipped:t===Me.SKIP}}}var Ye=Object.defineProperty,We=(e,t,i)=>((e,t,i)=>t in e?Ye(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i),Je=(e=>(e.NEVER="never",e.ONCE="once",e.ON_EACH_NEW_ATTEMPT="onEachNewAttempt",e))(Je||{}),Ke=(e=>(e.NEVER="never",e.ONCE="once",e.ON_EACH_NEW_ATTEMPT="onEachNewAttempt",e))(Ke||{});class Xe extends d{constructor(){super("sequencingControls"),We(this,"_enabled",!0),We(this,"_choice",!0),We(this,"_choiceExit",!0),We(this,"_flow",!0),We(this,"_forwardOnly",!1),We(this,"_useCurrentAttemptObjectiveInfo",!0),We(this,"_useCurrentAttemptProgressInfo",!0),We(this,"_preventActivation",!1),We(this,"_constrainChoice",!1),We(this,"_stopForwardTraversal",!1),We(this,"_rollupObjectiveSatisfied",!0),We(this,"_rollupProgressCompletion",!0),We(this,"_objectiveMeasureWeight",1),We(this,"_selectionTiming","never"),We(this,"_selectCount",null),We(this,"_selectionCountStatus",!1),We(this,"_randomizeChildren",!1),We(this,"_randomizationTiming","never"),We(this,"_reorderChildren",!1),We(this,"_completionSetByContent",!1),We(this,"_objectiveSetByContent",!1),We(this,"_tracked",!0)}reset(){this._initialized=!1,this._enabled=!0,this._choice=!0,this._choiceExit=!0,this._flow=!0,this._forwardOnly=!1,this._useCurrentAttemptObjectiveInfo=!0,this._useCurrentAttemptProgressInfo=!0,this._preventActivation=!1,this._constrainChoice=!1,this._stopForwardTraversal=!1,this._rollupObjectiveSatisfied=!0,this._rollupProgressCompletion=!0,this._objectiveMeasureWeight=1,this._selectionTiming="never",this._selectCount=null,this._selectionCountStatus=!1,this._randomizeChildren=!1,this._randomizationTiming="never",this._reorderChildren=!1,this._completionSetByContent=!1,this._objectiveSetByContent=!1,this._tracked=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e}get choice(){return this._choice}set choice(e){this._choice=e}get choiceExit(){return this._choiceExit}set choiceExit(e){this._choiceExit=e}get flow(){return this._flow}set flow(e){this._flow=e}get forwardOnly(){return this._forwardOnly}set forwardOnly(e){this._forwardOnly=e}get useCurrentAttemptObjectiveInfo(){return this._useCurrentAttemptObjectiveInfo}set useCurrentAttemptObjectiveInfo(e){this._useCurrentAttemptObjectiveInfo=e}get useCurrentAttemptProgressInfo(){return this._useCurrentAttemptProgressInfo}set useCurrentAttemptProgressInfo(e){this._useCurrentAttemptProgressInfo=e}get preventActivation(){return this._preventActivation}set preventActivation(e){this._preventActivation=e}get constrainChoice(){return this._constrainChoice}set constrainChoice(e){this._constrainChoice=e}get stopForwardTraversal(){return this._stopForwardTraversal}set stopForwardTraversal(e){this._stopForwardTraversal=e}get rollupObjectiveSatisfied(){return this._rollupObjectiveSatisfied}set rollupObjectiveSatisfied(e){this._rollupObjectiveSatisfied=e}get rollupProgressCompletion(){return this._rollupProgressCompletion}set rollupProgressCompletion(e){this._rollupProgressCompletion=e}get objectiveMeasureWeight(){return this._objectiveMeasureWeight}set objectiveMeasureWeight(e){0>e||(this._objectiveMeasureWeight=e)}isChoiceNavigationAllowed(){return this._enabled&&!this._constrainChoice}isFlowNavigationAllowed(){return this._enabled&&this._flow}isForwardNavigationAllowed(){return this._enabled&&this._flow}isBackwardNavigationAllowed(){return this._enabled&&this._flow&&!this._forwardOnly}get selectionTiming(){return this._selectionTiming}set selectionTiming(e){this._selectionTiming=e}get selectCount(){return this._selectCount}set selectCount(e){(null===e||e>0)&&(this._selectCount=e)}get selectionCountStatus(){return this._selectionCountStatus}set selectionCountStatus(e){this._selectionCountStatus=e}get randomizeChildren(){return this._randomizeChildren}set randomizeChildren(e){this._randomizeChildren=e}get randomizationTiming(){return this._randomizationTiming}set randomizationTiming(e){this._randomizationTiming=e}get reorderChildren(){return this._reorderChildren}set reorderChildren(e){this._reorderChildren=e}get completionSetByContent(){return this._completionSetByContent}set completionSetByContent(e){this._completionSetByContent=e}get objectiveSetByContent(){return this._objectiveSetByContent}set objectiveSetByContent(e){this._objectiveSetByContent=e}get tracked(){return this._tracked}set tracked(e){this._tracked=e}toJSON(){this.jsonString=!0;const result={enabled:this._enabled,choice:this._choice,choiceExit:this._choiceExit,flow:this._flow,forwardOnly:this._forwardOnly,useCurrentAttemptObjectiveInfo:this._useCurrentAttemptObjectiveInfo,useCurrentAttemptProgressInfo:this._useCurrentAttemptProgressInfo,preventActivation:this._preventActivation,constrainChoice:this._constrainChoice,stopForwardTraversal:this._stopForwardTraversal,rollupObjectiveSatisfied:this._rollupObjectiveSatisfied,rollupProgressCompletion:this._rollupProgressCompletion,objectiveMeasureWeight:this._objectiveMeasureWeight,selectionTiming:this._selectionTiming,selectCount:this._selectCount,selectionCountStatus:this._selectionCountStatus,randomizeChildren:this._randomizeChildren,randomizationTiming:this._randomizationTiming,reorderChildren:this._reorderChildren,completionSetByContent:this._completionSetByContent,objectiveSetByContent:this._objectiveSetByContent,tracked:this._tracked};return this.jsonString=!1,result}}class Qe{static selectChildrenProcess(e){const t=e.sequencingControls,i=[...e.children];if(t.selectionTiming===Je.NEVER)return i;if(t.selectionTiming===Je.ONCE&&t.selectionCountStatus)return i;if(t.selectionTiming!==Je.ONCE&&!t.selectionCountStatus)return i;const s=t.selectCount;if(null===s||s>=i.length)return t.selectionTiming===Je.ONCE&&(t.selectionCountStatus=!0),i;const r=[],n=i.map((e,t)=>t);for(let e=0;s>e&&0!==n.length;e++){const e=Math.floor(Math.random()*n.length),t=n[e];void 0!==t&&i[t]&&r.push(i[t]),n.splice(e,1)}t.selectionTiming===Je.ONCE&&(t.selectionCountStatus=!0);for(const e of i)r.includes(e)||(e.isHiddenFromChoice=!0,e.isAvailable=!1);return r}static randomizeChildrenProcess(e){const t=e.sequencingControls,i=[...e.children];if(t.randomizationTiming===Ke.NEVER)return i;if(t.randomizationTiming===Ke.ONCE&&t.reorderChildren)return i;if(!t.randomizeChildren)return i;const s=[...i];for(let e=s.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1)),i=s[e],r=s[t];i&&r&&(s[e]=r,s[t]=i)}return t.randomizationTiming===Ke.ONCE&&(t.reorderChildren=!0),e.children.length=0,e.children.push(...s),s}static applySelectionAndRandomization(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=e.sequencingControls;if(!t&&(e.isActive||e.isSuspended))return e.children;let s=!1,r=!1;i.selectionTiming===Je.ON_EACH_NEW_ATTEMPT?(s=t,t&&(i.selectionCountStatus=!0)):i.selectionTiming===Je.ONCE&&(s=!i.selectionCountStatus),i.randomizationTiming===Ke.ON_EACH_NEW_ATTEMPT?(r=t,t&&(i.reorderChildren=!1)):i.randomizationTiming===Ke.ONCE&&(r=!i.reorderChildren),s&&this.selectChildrenProcess(e),r&&this.randomizeChildrenProcess(e);const n=e.children.filter(e=>e.isAvailable);return e.setProcessedChildren(n),n}static isSelectionNeeded(e){const t=e.sequencingControls;return t.selectionTiming!==Je.NEVER&&(t.selectionTiming!==Je.ONCE||!t.selectionCountStatus)&&null!==t.selectCount&&e.children.length>t.selectCount}static isRandomizationNeeded(e){const t=e.sequencingControls;return t.randomizationTiming!==Ke.NEVER&&(t.randomizationTiming!==Ke.ONCE||!t.reorderChildren)&&t.randomizeChildren}}var Ze=Object.defineProperty,et=(e,t,i)=>((e,t,i)=>t in e?Ze(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class tt{constructor(e,t){et(this,"activityTree",e),et(this,"ruleEngine",t)}flowSubprocess(e,t){let i=e,s=!0,r=!1;for(;i;){const e=this.flowTreeTraversalSubprocess(i,t,s);if(!e.activity){let s=null;return e.exception?s=e.exception:t===Be.BACKWARD?s="SB.2.1-3":r&&(s="SB.2.1-2"),new Ve(i,!1,s,e.endSequencingSession)}r=e.activity.children.length>0&&0===e.activity.getAvailableChildren().length;const n=this.flowActivityTraversalSubprocess(e.activity,t===Be.FORWARD,!0,t);if(n)return new Ve(n,!0,null,!1);i=e.activity,s=!1}return new Ve(null,!1,null,!1)}flowTreeTraversalSubprocess(e,t){return t===Be.FORWARD?this.traverseForward(e,arguments.length>2&&void 0!==arguments[2]&&arguments[2]):this.traverseBackward(e)}traverseForward(e,t){if(t&&this.isActivityLastOverall(e))return this.activityTree.root&&this.terminateDescendentAttempts(this.activityTree.root),{activity:null,endSequencingSession:!0};if(!t){this.ensureSelectionAndRandomization(e);const t=e.getAvailableChildren();if(t.length>0)return{activity:t[0]||null,endSequencingSession:!1}}let i=e;for(;i;){const e=this.activityTree.getNextSibling(i);if(e)return{activity:e,endSequencingSession:!1};i=i.parent}return this.activityTree.root&&this.terminateDescendentAttempts(this.activityTree.root),{activity:null,endSequencingSession:!0}}traverseBackward(e){if(e.parent&&e.parent.sequencingControls.forwardOnly)return{activity:null,endSequencingSession:!1,exception:"SB.2.1-4"};const t=this.activityTree.getPreviousSibli