/*! xAPIWrapper v 1.10.1 | Built on 2019-03-14 09:34:56-0400 */ function toBase64(a){return CryptoJS&&CryptoJS.enc.Base64?CryptoJS.enc.Base64.stringify(CryptoJS.enc.Latin1.parse(a)):Base64.encode(a)}function toSHA1(a){return CryptoJS&&CryptoJS.SHA1?CryptoJS.SHA1(a).toString():Crypto.util.bytesToHex(Crypto.SHA1(a,{asBytes:!0}))}function toSHA256(a){if("[object ArrayBuffer]"!==Object.prototype.toString.call(a))return CryptoJS.SHA256(a).toString(CryptoJS.enc.Hex);for(var b=new Uint8Array(a),c=[],d=0;df;f++){var g=c[f>>>2]>>>24-f%4*8&255;b[d+f>>>2]|=g<<24-(d+f)%4*8}else if(c.length>65535)for(var f=0;e>f;f+=4)b[d+f>>>2]=c[f>>>2];else b.push.apply(b,c);return this.sigBytes+=e,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-c%4*8,b.length=a.ceil(c/4)},clone:function(){var a=e.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;b>d;d+=4)c.push(4294967296*a.random()|0);return new f.init(c,b)}}),g=c.enc={},h=g.Hex={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=b[e>>>2]>>>24-e%4*8&255;d.push((f>>>4).toString(16)),d.push((15&f).toString(16))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-d%8*4;return new f.init(c,b/2)}},i=g.Latin1={stringify:function(a){for(var b=a.words,c=a.sigBytes,d=[],e=0;c>e;e++){var f=b[e>>>2]>>>24-e%4*8&255;d.push(String.fromCharCode(f))}return d.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d++)c[d>>>2]|=(255&a.charCodeAt(d))<<24-d%4*8;return new f.init(c,b)}},j=g.Utf8={stringify:function(a){try{return decodeURIComponent(escape(i.stringify(a)))}catch(b){throw new Error("Malformed UTF-8 data")}},parse:function(a){return i.parse(unescape(encodeURIComponent(a)))}},k=(g.Base64={stringify:function(a){var b=a.words,c=a.sigBytes,d=this._map;a.clamp();for(var e=[],f=0;c>f;f+=3)for(var g=b[f>>>2]>>>24-f%4*8&255,h=b[f+1>>>2]>>>24-(f+1)%4*8&255,i=b[f+2>>>2]>>>24-(f+2)%4*8&255,j=g<<16|h<<8|i,k=0;4>k&&c>f+.75*k;k++)e.push(d.charAt(j>>>6*(3-k)&63));var l=d.charAt(64);if(l)for(;e.length%4;)e.push(l);return e.join("")},parse:function(a){var b=a.length,c=this._map,d=c.charAt(64);if(d){var e=a.indexOf(d);-1!=e&&(b=e)}for(var g=[],h=0,i=0;b>i;i++)if(i%4){var j=c.indexOf(a.charAt(i-1))<>>6-i%4*2;g[h>>>2]|=(j|k)<<24-h%4*8,h++}return f.create(g,h)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},d.BufferedBlockAlgorithm=e.extend({reset:function(){this._data=new f.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,g=this.blockSize,h=4*g,i=e/h;i=b?a.ceil(i):a.max((0|i)-this._minBufferSize,0);var j=i*g,k=a.min(4*j,e);if(j){for(var l=0;j>l;l+=g)this._doProcessBlock(d,l);var m=d.splice(0,j);c.sigBytes-=k}return new f.init(m,k)},clone:function(){var a=e.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0})),l=d.Hasher=k.extend({cfg:e.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset()},reset:function(){k.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){a&&this._append(a);var b=this._doFinalize();return b},blockSize:16,_createHelper:function(a){return function(b,c){return new a.init(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return new m.HMAC.init(a,c).finalize(b)}}}),m=c.algo={},n=[],o=m.SHA1=l.extend({_doReset:function(){this._hash=new f.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],g=c[3],h=c[4],i=0;80>i;i++){if(16>i)n[i]=0|a[b+i];else{var j=n[i-3]^n[i-8]^n[i-14]^n[i-16];n[i]=j<<1|j>>>31}var k=(d<<5|d>>>27)+h+n[i];k+=20>i?(e&f|~e&g)+1518500249:40>i?(e^f^g)+1859775393:60>i?(e&f|e&g|f&g)-1894007588:(e^f^g)-899497514,h=g,g=f,f=e<<30|e>>>2,e=d,d=k}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+g|0,c[4]=c[4]+h|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;return c[e>>>5]|=128<<24-e%32,c[(e+64>>>9<<4)+14]=a.floor(d/4294967296),c[(e+64>>>9<<4)+15]=d,b.sigBytes=4*c.length,this._process(),this._hash},clone:function(){var a=l.clone.call(this);return a._hash=this._hash.clone(),a}});return c.SHA1=l._createHelper(o),c.HmacSHA1=l._createHmacHelper(o),c}(Math),CryptoJS=CryptoJS||function(a,b){var c={},d=c.lib={},e=function(){},f=d.Base={extend:function(a){e.prototype=this;var b=new e;return a&&b.mixIn(a),b.hasOwnProperty("init")||(b.init=function(){b.$super.init.apply(this,arguments)}),b.init.prototype=b,b.$super=this,b},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},g=d.WordArray=f.extend({init:function(a,c){a=this.words=a||[],this.sigBytes=c!=b?c:4*a.length},toString:function(a){return(a||i).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes;if(a=a.sigBytes,this.clamp(),d%4)for(var e=0;a>e;e++)b[d+e>>>2]|=(c[e>>>2]>>>24-8*(e%4)&255)<<24-8*((d+e)%4);else if(65535e;e+=4)b[d+e>>>2]=c[e>>>2];else b.push.apply(b,c);return this.sigBytes+=a,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-8*(c%4),b.length=a.ceil(c/4)},clone:function(){var a=f.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;b>d;d+=4)c.push(4294967296*a.random()|0);return new g.init(c,b)}}),h=c.enc={},i=h.Hex={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],d=0;a>d;d++){var e=b[d>>>2]>>>24-8*(d%4)&255;c.push((e>>>4).toString(16)),c.push((15&e).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return new g.init(c,b/2)}},j=h.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],d=0;a>d;d++)c.push(String.fromCharCode(b[d>>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d++)c[d>>>2]|=(255&a.charCodeAt(d))<<24-8*(d%4);return new g.init(c,b)}},k=h.Utf8={stringify:function(a){try{return decodeURIComponent(escape(j.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data")}},parse:function(a){return j.parse(unescape(encodeURIComponent(a)))}},l=d.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=k.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,f=this.blockSize,h=e/(4*f),h=b?a.ceil(h):a.max((0|h)-this._minBufferSize,0);if(b=h*f,e=a.min(4*b,e),b){for(var i=0;b>i;i+=f)this._doProcessBlock(d,i);i=d.splice(0,b),c.sigBytes-=e}return new g.init(i,e)},clone:function(){var a=f.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0});d.Hasher=l.extend({cfg:f.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){return a&&this._append(a),this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,c){return new a.init(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return new m.HMAC.init(a,c).finalize(b)}}});var m=c.algo={};return c}(Math);!function(a){for(var b=CryptoJS,c=b.lib,d=c.WordArray,e=c.Hasher,c=b.algo,f=[],g=[],h=function(a){return 4294967296*(a-(0|a))|0},i=2,j=0;64>j;){var k;a:{k=i;for(var l=a.sqrt(k),m=2;l>=m;m++)if(!(k%m)){k=!1;break a}k=!0}k&&(8>j&&(f[j]=h(a.pow(i,.5))),g[j]=h(a.pow(i,1/3)),j++),i++}var n=[],c=c.SHA256=e.extend({_doReset:function(){this._hash=new d.init(f.slice(0))},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],h=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=0;64>m;m++){if(16>m)n[m]=0|a[b+m];else{var o=n[m-15],p=n[m-2];n[m]=((o<<25|o>>>7)^(o<<14|o>>>18)^o>>>3)+n[m-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[m-16]}o=l+((i<<26|i>>>6)^(i<<21|i>>>11)^(i<<7|i>>>25))+(i&j^~i&k)+g[m]+n[m],p=((d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22))+(d&e^d&f^e&f),l=k,k=j,j=i,i=h+o|0,h=f,f=e,e=d,d=o+p|0}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+h|0,c[4]=c[4]+i|0,c[5]=c[5]+j|0,c[6]=c[6]+k|0,c[7]=c[7]+l|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;return c[e>>>5]|=128<<24-e%32,c[(e+64>>>9<<4)+14]=a.floor(d/4294967296),c[(e+64>>>9<<4)+15]=d,b.sigBytes=4*c.length,this._process(),this._hash},clone:function(){var a=e.clone.call(this);return a._hash=this._hash.clone(),a}});b.SHA256=e._createHelper(c),b.HmacSHA256=e._createHmacHelper(c)}(Math),function(){var a=CryptoJS,b=a.enc.Utf8;a.algo.HMAC=a.lib.Base.extend({init:function(a,c){a=this._hasher=new a.init,"string"==typeof c&&(c=b.parse(c));var d=a.blockSize,e=4*d;c.sigBytes>e&&(c=a.finalize(c)),c.clamp();for(var f=this._oKey=c.clone(),g=this._iKey=c.clone(),h=f.words,i=g.words,j=0;d>j;j++)h[j]^=1549556828,i[j]^=909522486;f.sigBytes=g.sigBytes=e,this.reset()},reset:function(){var a=this._hasher;a.reset(),a.update(this._iKey)},update:function(a){return this._hasher.update(a),this},finalize:function(a){var b=this._hasher;return a=b.finalize(a),b.reset(),b.finalize(this._oKey.clone().concat(a))}})}(),function(a){function b(a,b){if(String.prototype.codePointAt)return a.codePointAt(b);a=String(a);var c=a.length,d=b?Number(b):0;if(d!=d&&(d=0),0>d||d>=c)return void 0;var e,f=a.charCodeAt(d);return f>=55296&&56319>=f&&c>d+1&&(e=a.charCodeAt(d+1),e>=56320&&57343>=e)?1024*(f-55296)+e-56320+65536:f}function c(a){switch(a||(a="utf8"),a){case"utf-8":case"utf8":break;default:throw"TextEncoder only supports utf8"}}function d(a){if(String.fromCodePoint)return String.fromCodePoint(a);for(var b=[],c=0,d="",e=0,f=arguments.length;e!==f;++e){var g=+arguments[e];if(!(1114111>g&&g>>>0===g))throw RangeError("Invalid code point: "+g);65535>=g?c=b.push(g):(g-=65536,c=b.push((g>>10)+55296,g%1024+56320)),c>=16383&&(d+=String.fromCharCode.apply(null,b),b.length=0)}return d+String.fromCharCode.apply(null,b)}function e(a){switch(a||(a="utf8"),a){case"utf-8":case"utf8":break;default:throw"TextDecoder only supports utf8"}}"undefined"==typeof a.TextEncoder&&(c.prototype.encode=function(a){for(var c=new Uint8Array(3*a.length),d=-1,e=a.length,f=0;e>f;){var g=b(a,f),h=0,i=0;for(127>=g?(h=0,i=0):2047>=g?(h=6,i=192):65535>=g?(h=12,i=224):2097151>=g&&(h=18,i=240),c[d+=1]=i|g>>h,h-=6;h>=0;)c[d+=1]=128|g>>h&63,h-=6;f+=g>=65536?2:1}return c.subarray(0,d+1)},a.TextEncoder=c),"undefined"==typeof a.TextDecoder&&(e.prototype.decode=function(a){for(var b="",c=0;c=e?(f=0,g=255&e):223>=e?(f=1,g=31&e):239>=e?(f=2,g=15&e):244>=e&&(f=3,g=7&e),a.length-c-f>0)for(var h=0;f>h;)e=a[c+h+1],g=g<<6|63&e,h+=1;else g=65533,f=a.length-c;b+=d(g),c+=f+1}return b},a.TextDecoder=e)}(this),function(a){a.activityTypes={assessment:"http://adlnet.gov/expapi/activities/assessment",attempt:"http://adlnet.gov/expapi/activities/attempt",course:"http://adlnet.gov/expapi/activities/course",file:"http://adlnet.gov/expapi/activities/file",interaction:"http://adlnet.gov/expapi/activities/interaction",lesson:"http://adlnet.gov/expapi/activities/lesson",link:"http://adlnet.gov/expapi/activities/link",media:"http://adlnet.gov/expapi/activities/media",meeting:"http://adlnet.gov/expapi/activities/meeting",module:"http://adlnet.gov/expapi/activities/module",objective:"http://adlnet.gov/expapi/activities/objective",performance:"http://adlnet.gov/expapi/activities/performance",profile:"http://adlnet.gov/expapi/activities/profile",question:"http://adlnet.gov/expapi/activities/question",simulation:"http://adlnet.gov/expapi/activities/simulation"}}(window.ADL=window.ADL||{}),function(a){a.verbs={abandoned:{id:"https://w3id.org/xapi/adl/verbs/abandoned",display:{"en-US":"abandoned"}},answered:{id:"http://adlnet.gov/expapi/verbs/answered",display:{"de-DE":"beantwortete","en-US":"answered","fr-FR":"a répondu","es-ES":"contestó","ar-AR":"أجاب"}},asked:{id:"http://adlnet.gov/expapi/verbs/asked",display:{"de-DE":"fragte","en-US":"asked","fr-FR":"a demandé","es-ES":"preguntó","ar-AR":"طلب"}},attempted:{id:"http://adlnet.gov/expapi/verbs/attempted",display:{"de-DE":"versuchte","en-US":"attempted","fr-FR":"a essayé","es-ES":"intentó","ar-AR":"حاول"}},attended:{id:"http://adlnet.gov/expapi/verbs/attended",display:{"de-DE":"nahm teil an","en-US":"attended","fr-FR":"a suivi","es-ES":"asistió","ar-AR":"حضر"}},commented:{id:"http://adlnet.gov/expapi/verbs/commented",display:{"de-DE":"kommentierte","en-US":"commented","fr-FR":"a commenté","es-ES":"comentó","ar-AR":"علق"}},completed:{id:"http://adlnet.gov/expapi/verbs/completed",display:{"de-DE":"beendete","en-US":"completed","fr-FR":"a terminé","es-ES":"completó","ar-AR":"أكمل"}},exited:{id:"http://adlnet.gov/expapi/verbs/exited",display:{"de-DE":"verließ","en-US":"exited","fr-FR":"a quitté","es-ES":"salió","ar-AR":"خرج"}},experienced:{id:"http://adlnet.gov/expapi/verbs/experienced",display:{"de-DE":"erlebte","en-US":"experienced","fr-FR":"a éprouvé","es-ES":"experimentó","ar-AR":"شاهد"}},failed:{id:"http://adlnet.gov/expapi/verbs/failed",display:{"de-DE":"verfehlte","en-US":"failed","fr-FR":"a échoué","es-ES":"fracasó","ar-AR":"فشل"}},imported:{id:"http://adlnet.gov/expapi/verbs/imported",display:{"de-DE":"importierte","en-US":"imported","fr-FR":"a importé","es-ES":"importó","ar-AR":"مستورد"}},initialized:{id:"http://adlnet.gov/expapi/verbs/initialized",display:{"de-DE":"initialisierte","en-US":"initialized","fr-FR":"a initialisé","es-ES":"inicializó","ar-AR":"بدأ"}},interacted:{id:"http://adlnet.gov/expapi/verbs/interacted",display:{"de-DE":"interagierte","en-US":"interacted","fr-FR":"a interagi","es-ES":"interactuó","ar-AR":"تفاعل"}},launched:{id:"http://adlnet.gov/expapi/verbs/launched",display:{"de-DE":"startete","en-US":"launched","fr-FR":"a lancé","es-ES":"lanzó","ar-AR":"أطلق"}},mastered:{id:"http://adlnet.gov/expapi/verbs/mastered",display:{"de-DE":"meisterte","en-US":"mastered","fr-FR":"a maîtrisé","es-ES":"dominó","ar-AR":"أتقن"}},passed:{id:"http://adlnet.gov/expapi/verbs/passed",display:{"de-DE":"bestand","en-US":"passed","fr-FR":"a réussi","es-ES":"aprobó","ar-AR":"نجح"}},preferred:{id:"http://adlnet.gov/expapi/verbs/preferred",display:{"de-DE":"bevorzugte","en-US":"preferred","fr-FR":"a préféré","es-ES":"prefirió","ar-AR":"فضل"}},progressed:{id:"http://adlnet.gov/expapi/verbs/progressed",display:{"de-DE":"machte Fortschritt mit","en-US":"progressed","fr-FR":"a progressé","es-ES":"progresó","ar-AR":"تقدم"}},registered:{id:"http://adlnet.gov/expapi/verbs/registered",display:{"de-DE":"registrierte","en-US":"registered","fr-FR":"a enregistré","es-ES":"registró","ar-AR":"سجل"}},responded:{id:"http://adlnet.gov/expapi/verbs/responded",display:{"de-DE":"reagierte","en-US":"responded","fr-FR":"a répondu","es-ES":"respondió","ar-AR":"استجاب"}},resumed:{id:"http://adlnet.gov/expapi/verbs/resumed",display:{"de-DE":"setzte fort","en-US":"resumed","fr-FR":"a repris","es-ES":"continuó","ar-AR":"استأنف"}},satisfied:{id:"https://w3id.org/xapi/adl/verbs/satisfied",display:{"de-DE":"befriedigt","en-US":"satisfied","fr-FR":"satisfaite","es-ES":"satisfecho","ar-AR":"راض"}},scored:{id:"http://adlnet.gov/expapi/verbs/scored",display:{"de-DE":"erreichte","en-US":"scored","fr-FR":"a marqué","es-ES":"anotó","ar-AR":"سحل النقاط"}},shared:{id:"http://adlnet.gov/expapi/verbs/shared",display:{"de-DE":"teilte","en-US":"shared","fr-FR":"a partagé","es-ES":"compartió","ar-AR":"شارك"}},suspended:{id:"http://adlnet.gov/expapi/verbs/suspended",display:{"de-DE":"pausierte","en-US":"suspended","fr-FR":"a suspendu","es-ES":"aplazó","ar-AR":"علق"}},terminated:{id:"http://adlnet.gov/expapi/verbs/terminated",display:{"de-DE":"beendete","en-US":"terminated","fr-FR":"a terminé","es-ES":"terminó","ar-AR":"أنهى"}},voided:{id:"http://adlnet.gov/expapi/verbs/voided",display:{"de-DE":"entwertete","en-US":"voided","fr-FR":"a annulé","es-ES":"anuló","ar-AR":"فرغ"}},waived:{id:"https://w3id.org/xapi/adl/verbs/waived",display:{"de-DE":"verzichtet","en-US":"waived","fr-FR":"renoncé","es-ES":"renunciado","ar-AR":"تخلى"}}}}(window.ADL=window.ADL||{}),Date.prototype.toISOString||!function(){function a(a){var b=String(a);return 1===b.length&&(b="0"+b),b}Date.prototype.toISOString=function(){return this.getUTCFullYear()+"-"+a(this.getUTCMonth()+1)+"-"+a(this.getUTCDate())+"T"+a(this.getUTCHours())+":"+a(this.getUTCMinutes())+":"+a(this.getUTCSeconds())+"."+String((this.getUTCMilliseconds()/1e3).toFixed(3)).slice(2,5)+"Z"}}(),function(a){function b(){try{return void 0!=this.lrs.endpoint&&""!=this.lrs.endpoint}catch(a){return!1}}function c(a){if(!c.debug)return!1;try{return console.log(a),!0}catch(b){return!1}}function d(a,b){for(var e in b)if(0!=b.hasOwnProperty(e)){var f=b[e];c(e+" : "+f);try{b[e].constructor==Object?a[e]=d(a[e],b[e]):(void 0==a&&(a=new Object),a[e]=b[e])}catch(g){void 0==a&&(a=new Object),a[e]=b[e]}}return a}function e(a){var b,c,e=["endpoint","auth","actor","registration","activity_id","grouping","activity_platform"],g=new Object;if(b=f(),void 0!==b&&0!==Object.keys(b).length){for(var h=0;h0&&(f.push(e.substr(g+1)),e=e.substr(0,g)),e=e+"?method="+a,null!==c)for(var h in c)c.hasOwnProperty(h)&&f.push(h+"="+encodeURIComponent(c[h]));return null!==d&&f.push("content="+encodeURIComponent(d)),{method:"POST",url:e,headers:{},data:f.join("&")}}c.debug=!1;var i=function(){var a={};return a.endpoint="http://localhost:8000/xapi/",a.auth="Basic "+toBase64("tom:1234"),a}(),j=function(c,f){function g(b){var c=document.createElement("a");if(c.href=b,c.protocol&&c.host)return c.protocol+"//"+c.host;if(c.href){var d=c.href.split("//");return d[0]+"//"+d[1].substr(0,d[1].indexOf("/"))}a.XAPIWrapper.log("Couldn't create base url from endpoint: "+b)}function h(a,b,c){a.auth="Basic "+toBase64(b+":"+c)}this.lrs=e(c||{}),this.lrs.user&&this.lrs.password&&h(this.lrs,this.lrs.user,this.lrs.password),this.base=g(this.lrs.endpoint),this.withCredentials=!1,c&&"undefined"!=typeof c.withCredentials&&(this.withCredentials=c.withCredentials),this.strictCallbacks=!1,this.strictCallbacks=c&&c.strictCallbacks,f&&b.call(this)&&window.ADL.XHR_request(this.lrs,this.lrs.endpoint+"about","GET",null,null,function(b){if(200==b.status)try{var c=JSON.parse(b.response),d=!1;for(var e in c.version)if(c.version.hasOwnProperty(e)&&c.version[e]==a.XAPIWrapper.xapiVersion){d=!0;break}d||a.XAPIWrapper.log("The lrs version ["+c.version+"] does not match this wrapper's XAPI version ["+a.XAPIWrapper.xapiVersion+"]")}catch(f){a.XAPIWrapper.log("The response was not an about object")}else a.XAPIWrapper.log("The request to get information about the LRS failed: "+b)},null,!1,null,this.withCredentials,!1),this.searchParams=function(){var a={format:"exact"};return a},this.hash=function(b){if(!b)return null;try{return toSHA1(b)}catch(c){return a.XAPIWrapper.log("Error trying to hash -- "+c),null}},this.changeConfig=function(b){try{a.XAPIWrapper.log("updating lrs object with new configuration"),this.lrs=d(this.lrs,b),b.user&&b.password&&this.updateAuth(this.lrs,b.user,b.password),this.base=g(this.lrs.endpoint),this.withCredentials=b.withCredentials,this.strictCallbacks=b.strictCallbacks}catch(c){a.XAPIWrapper.log("error while changing configuration -- "+c)}},this.updateAuth=h};j.prototype.xapiVersion="1.0.1",j.prototype.prepareStatement=function(a){void 0===a.actor?a.actor=JSON.parse(this.lrs.actor):"string"==typeof a.actor&&(a.actor=JSON.parse(a.actor)),(this.lrs.grouping||this.lrs.registration||this.lrs.activity_platform)&&(a.context||(a.context={})),this.lrs.grouping&&(a.context.contextActivities||(a.context.contextActivities={}),a.context.contextActivities.grouping=[{id:this.lrs.grouping}]),this.lrs.registration&&(a.context.registration=this.lrs.registration),this.lrs.activity_platform&&(a.context.platform=this.lrs.activity_platform)},j.prototype.testConfig=b,j.prototype.log=c,j.prototype.defaultEncoding="utf-8",j.prototype.sendStatement=function(b,c,d){if(this.testConfig()){this.prepareStatement(b);var e;b.id?e=b.id:(e=a.ruuid(),b.id=e);var f=JSON.stringify(b),g=null;d&&d.length>0&&(g={},f=this.buildMultipartPost(b,d,g));var h=a.XHR_request(this.lrs,this.lrs.endpoint+"statements","POST",f,this.lrs.auth,c,{id:e},null,g,this.withCredentials,this.strictCallbacks);if(!c)return{xhr:h,id:e}}},j.prototype.stringToArrayBuffer=function(b,c){return c=c||a.XAPIWrapper.defaultEncoding,new TextEncoder(c).encode(b).buffer},j.prototype.stringFromArrayBuffer=function(b,c){return c=c||a.XAPIWrapper.defaultEncoding,new TextDecoder(c).decode(b)},j.prototype.buildMultipartPost=function(a,b,c){a.attachments=[];for(var d=0;d0&&(e=e+"?"+f.join("&"))}var h=a.XHR_request(this.lrs,e,"GET",null,this.lrs.auth,d,null,!1,null,this.withCredentials,this.strictCallbacks);if(void 0===h||404==h.status)return null;try{return JSON.parse(h.response)}catch(i){return h.response}}},j.prototype.getActivities=function(b,c){if(this.testConfig()){var d=this.lrs.endpoint+"activities?activityId=";d=d.replace("",encodeURIComponent(b));var e=a.XHR_request(this.lrs,d,"GET",null,this.lrs.auth,c,null,!0,null,this.withCredentials,this.strictCallbacks);if(void 0===e||404==e.status)return null;try{return JSON.parse(e.response)}catch(f){return e.response}}},j.prototype.sendState=function(b,d,e,f,g,h,i,j){if(this.testConfig()){var k=this.lrs.endpoint+"activities/state?activityId=&agent=&stateId=";k=k.replace("",encodeURIComponent(b)),k=k.replace("",encodeURIComponent(JSON.stringify(d))),k=k.replace("",encodeURIComponent(e)),f&&(k+="®istration="+encodeURIComponent(f));var l=null;h&&i?c("Can't have both If-Match and If-None-Match"):h?l={"If-Match":a.formatHash(h)}:i&&(l={"If-None-Match":a.formatHash(i)});var m="PUT";if(!g)return this.log("No activity state was included."),!1;g instanceof Array?(g=JSON.stringify(g),l=l||{},l["Content-Type"]="application/json"):g instanceof Object?(g=JSON.stringify(g),l=l||{},l["Content-Type"]="application/json",m="POST"):(l=l||{},l["Content-Type"]="application/octet-stream"),a.XHR_request(this.lrs,k,m,g,this.lrs.auth,j,null,null,l,this.withCredentials,this.strictCallbacks)}},j.prototype.getState=function(b,c,d,e,f,g){if(this.testConfig()){var h=this.lrs.endpoint+"activities/state?activityId=&agent=";h=h.replace("",encodeURIComponent(b)),h=h.replace("",encodeURIComponent(JSON.stringify(c))),d&&(h+="&stateId="+encodeURIComponent(d)),e&&(h+="®istration="+encodeURIComponent(e)),f&&(f=isDate(f),null!=f&&(h+="&since="+encodeURIComponent(f.toISOString())));var i=a.XHR_request(this.lrs,h,"GET",null,this.lrs.auth,g,null,!0,null,this.withCredentials,this.strictCallbacks);if(void 0===i||404==i.status)return null;try{return JSON.parse(i.response)}catch(j){return i.response}}},j.prototype.deleteState=function(b,d,e,f,g,h,i){if(this.testConfig()){var j=this.lrs.endpoint+"activities/state?activityId=&agent=&stateId=";j=j.replace("",encodeURIComponent(b)),j=j.replace("",encodeURIComponent(JSON.stringify(d))),j=j.replace("",encodeURIComponent(e)),f&&(j+="®istration="+encodeURIComponent(f));var k=null;g&&h?c("Can't have both If-Match and If-None-Match"):g?k={"If-Match":a.formatHash(g)}:h&&(k={"If-None-Match":a.formatHash(h)});var l=a.XHR_request(this.lrs,j,"DELETE",null,this.lrs.auth,i,null,!1,k,this.withCredentials,this.strictCallbacks);if(void 0===l||404==l.status)return null;try{return JSON.parse(l.response)}catch(m){return l}}},j.prototype.sendActivityProfile=function(b,d,e,f,g,h){if(this.testConfig()){var i=this.lrs.endpoint+"activities/profile?activityId=&profileId=";i=i.replace("",encodeURIComponent(b)),i=i.replace("",encodeURIComponent(d));var j=null;f&&g?c("Can't have both If-Match and If-None-Match"):f?j={"If-Match":a.formatHash(f)}:g&&(j={"If-None-Match":a.formatHash(g)});var k="PUT";if(!e)return this.log("No activity profile was included."),!1;e instanceof Array?(e=JSON.stringify(e),j=j||{},j["Content-Type"]="application/json"):e instanceof Object?(e=JSON.stringify(e),j=j||{},j["Content-Type"]="application/json",k="POST"):(j=j||{},j["Content-Type"]="application/octet-stream"),a.XHR_request(this.lrs,i,k,e,this.lrs.auth,h,null,!1,j,this.withCredentials,this.strictCallbacks)}},j.prototype.getActivityProfile=function(b,c,d,e){if(this.testConfig()){var f=this.lrs.endpoint+"activities/profile?activityId=";f=f.replace("",encodeURIComponent(b)),c&&(f+="&profileId="+encodeURIComponent(c)),d&&(d=isDate(d),null!=d&&(f+="&since="+encodeURIComponent(d.toISOString())));var g=a.XHR_request(this.lrs,f,"GET",null,this.lrs.auth,e,null,!0,null,this.withCredentials,this.strictCallbacks);if(void 0===g||404==g.status)return null;try{return JSON.parse(g.response)}catch(h){return g.response}}},j.prototype.deleteActivityProfile=function(b,d,e,f,g){if(this.testConfig()){var h=this.lrs.endpoint+"activities/profile?activityId=&profileId=";h=h.replace("",encodeURIComponent(b)),h=h.replace("",encodeURIComponent(d));var i=null;e&&f?c("Can't have both If-Match and If-None-Match"):e?i={"If-Match":a.formatHash(e)}:f&&(i={"If-None-Match":a.formatHash(f)});var j=a.XHR_request(this.lrs,h,"DELETE",null,this.lrs.auth,g,null,!1,i,this.withCredentials,this.strictCallbacks);if(void 0===j||404==j.status)return null;try{return JSON.parse(j.response)}catch(k){return j}}},j.prototype.getAgents=function(b,c){if(this.testConfig()){var d=this.lrs.endpoint+"agents?agent=";d=d.replace("",encodeURIComponent(JSON.stringify(b)));var e=a.XHR_request(this.lrs,d,"GET",null,this.lrs.auth,c,null,!0,null,this.withCredentials,this.strictCallbacks);if(void 0===e||404==e.status)return null;try{return JSON.parse(e.response)}catch(f){return e.response}}},j.prototype.sendAgentProfile=function(b,d,e,f,g,h){if(this.testConfig()){var i=this.lrs.endpoint+"agents/profile?agent=&profileId=";i=i.replace("",encodeURIComponent(JSON.stringify(b))),i=i.replace("",encodeURIComponent(d));var j=null;f&&g?c("Can't have both If-Match and If-None-Match"):f?j={"If-Match":a.formatHash(f)}:g&&(j={"If-None-Match":a.formatHash(g)});var k="PUT";if(!e)return this.log("No agent profile was included."),!1;e instanceof Array?(e=JSON.stringify(e),j=j||{},j["Content-Type"]="application/json"):e instanceof Object?(e=JSON.stringify(e),j=j||{},j["Content-Type"]="application/json",k="POST"):(j=j||{},j["Content-Type"]="application/octet-stream"),a.XHR_request(this.lrs,i,k,e,this.lrs.auth,h,null,!1,j,this.withCredentials,this.strictCallbacks)}},j.prototype.getAgentProfile=function(b,c,d,e){if(this.testConfig()){var f=this.lrs.endpoint+"agents/profile?agent=";f=f.replace("",encodeURIComponent(JSON.stringify(b))),f=f.replace("",encodeURIComponent(c)),c&&(f+="&profileId="+encodeURIComponent(c)),d&&(d=isDate(d),null!=d&&(f+="&since="+encodeURIComponent(d.toISOString())));var g=a.XHR_request(this.lrs,f,"GET",null,this.lrs.auth,e,null,!0,null,this.withCredentials,this.strictCallbacks);if(void 0===g||404==g.status)return null;try{return JSON.parse(g.response)}catch(h){return g.response}}},j.prototype.deleteAgentProfile=function(b,d,e,f,g){if(this.testConfig()){var h=this.lrs.endpoint+"agents/profile?agent=&profileId=";h=h.replace("",encodeURIComponent(JSON.stringify(b))),h=h.replace("",encodeURIComponent(d));var i=null;e&&f?c("Can't have both If-Match and If-None-Match"):e?i={"If-Match":a.formatHash(e)}:f&&(i={"If-None-Match":a.formatHash(f)});var j=a.XHR_request(this.lrs,h,"DELETE",null,this.lrs.auth,g,null,!1,i,this.withCredentials,this.strictCallbacks);if(void 0===j||404==j.status)return null;try{return JSON.parse(j.response)}catch(k){return j}}},a.ruuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},a.dateFromISOString=function(a){var b="([0-9]{4})(-([0-9]{2})(-([0-9]{2})([T| ]([0-9]{2}):([0-9]{2})(:([0-9]{2})(.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?",c=a.match(new RegExp(b)),d=0,e=new Date(c[1],0,1);c[3]&&e.setMonth(c[3]-1),c[5]&&e.setDate(c[5]),c[7]&&e.setHours(c[7]),c[8]&&e.setMinutes(c[8]), c[10]&&e.setSeconds(c[10]),c[12]&&e.setMilliseconds(1e3*Number("0."+c[12])),c[14]&&(d=60*Number(c[16])+Number(c[17]),d*="-"==c[15]?1:-1),d-=e.getTimezoneOffset(),time=Number(e)+60*d*1e3;var f=new Date;return f.setTime(Number(time)),f},a.XHR_request=function(b,c,d,e,f,i,j,k,l,m,n){"use strict";function o(){if(w)return s;w=!0;var b=k&&404===p.status;if(!(void 0===p.status||p.status>=200&&p.status<400||b)){var e;try{e="There was a problem communicating with the Learning Record Store. ( "+p.status+" | "+p.response+" )"+c}catch(f){e=f.toString()}return a.XAPIWrapper.log(e),a.xhrRequestOnError(p,d,c,i,j,n),s=p,p}if(!i)return s=p,p;if(j)n?i(null,p,j):i(p,j);else{var g;try{g=JSON.parse(p.responseText)}catch(h){g=p.responseText}n?i(null,p,g):i(p,g)}}var p,q,r,s,t,u,v,w=!1,x=!1,y=!1,z=c.toLowerCase().match(/^(.+):\/\/([^:\/]*):?(\d+)?(\/.*)?$/),A=window.location,B={};if(B["Content-Type"]="application/json",B.Authorization=f,B["X-Experience-API-Version"]=a.XAPIWrapper.xapiVersion,null!==l)for(var C in l)l.hasOwnProperty(C)&&(B[C]=l[C]);if(x=A.protocol.toLowerCase()!==z[1]||A.hostname.toLowerCase()!==z[2],x||(r=null===z[3]?"http"===z[1]?"80":"443":z[3],x=r===A.port),null!==b&&void 0!==b.extended){t=new Array;for(u in b.extended)t.push(u+"="+encodeURIComponent(b.extended[u]));t.length>0&&(c+=(c.indexOf("?")>-1?"&":"?")+t.join("&"))}var D=window.XDomainRequest&&window.XMLHttpRequest&&void 0===(new XMLHttpRequest).responseType;if(x&&void 0!==D&&D!==!1)y=!0,q=h(d,c,B,e),p=new XDomainRequest,p.open(q.method,q.url);else{p=new XMLHttpRequest,p.withCredentials=m,p.open(d,c,null!=i);for(var C in B)p.setRequestHeader(C,B[C])}if(p.onreadystatechange=function(){return 4===p.readyState?o():void 0},p.onload=o,p.onerror=o,p.send(y?q.data:e),!i){if(y)for(v=1e3+new Date;new Date-1?i+"&"+f:i+"?"+f,h.href=i)}}function f(a,h,i){a=c(a);try{var j=b("xAPILaunchKey"),k=b("xAPILaunchService");b("encrypted");if(f.terminate=function(a){var b=new URL(k);b.pathname+="launch/"+j+"/terminate";var c=new XMLHttpRequest;c.withCredentials=!0,c.crossDomain=!0,c.open("POST",b.toString(),!1),c.setRequestHeader("Content-type","application/json"),c.send(JSON.stringify({code:0,description:a||"User closed content"}))},!j||!k)return a("invalid launch parameters");var l=new URL(k);l.pathname+="launch/"+j;var m=new XMLHttpRequest;m.withCredentials=!0,m.crossDomain=!0,m.onerror=function(b){window.setTimeout(function(){return a(b)})},m.onload=function(b){if(200!==m.status)return m.onerror(m.responseText);var c=JSON.parse(m.responseText),j=c,k={};k.endpoint=j.endpoint,k.actor=j.actor,k.withCredentials=!0,k.strictCallbacks=i||!1,window.onunload=function(){h&&f.terminate("User closed content")};var l=new g.XAPIWrapper.constructor;return l.changeConfig(k),e(document.body.querySelectorAll("a")),d(),a(null,c,l)},m.open("POST",l.toString(),!0),m.send()}catch(n){a(n)}}var g=a;g.launch=f}(window.ADL=window.ADL||{});