@aastrika_npmjs/sunbird-sdk 6.0.0 → 6.1.0

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/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("rxjs/operators"),require("rxjs"),require("@project-sunbird/client-services"),require("@project-sunbird/client-services/core/http-service"),require("@project-sunbird/client-services/models/content/index"),require("@project-sunbird/client-services/services/content/utilities/primary-category-mapper"),require("@project-sunbird/client-services/services/content"),require("@project-sunbird/client-services/core"),require("@project-sunbird/client-services/core/http-service/utilities/interceptors"),require("@project-sunbird/client-services/models/group"),require("@project-sunbird/client-services/models/user"),require("@project-sunbird/client-services/services/content/utilities/content-group-generator"),require("@project-sunbird/client-services/services/content/utilities/content-progress-calculator"),require("@project-sunbird/client-services/services/content/utilities/mime-type-facet-to-mime-type-category-aggregator"));else if("function"==typeof define&&define.amd)define(["rxjs/operators","rxjs","@project-sunbird/client-services","@project-sunbird/client-services/core/http-service","@project-sunbird/client-services/models/content/index","@project-sunbird/client-services/services/content/utilities/primary-category-mapper","@project-sunbird/client-services/services/content","@project-sunbird/client-services/core","@project-sunbird/client-services/core/http-service/utilities/interceptors","@project-sunbird/client-services/models/group","@project-sunbird/client-services/models/user","@project-sunbird/client-services/services/content/utilities/content-group-generator","@project-sunbird/client-services/services/content/utilities/content-progress-calculator","@project-sunbird/client-services/services/content/utilities/mime-type-facet-to-mime-type-category-aggregator"],t);else{var n="object"==typeof exports?t(require("rxjs/operators"),require("rxjs"),require("@project-sunbird/client-services"),require("@project-sunbird/client-services/core/http-service"),require("@project-sunbird/client-services/models/content/index"),require("@project-sunbird/client-services/services/content/utilities/primary-category-mapper"),require("@project-sunbird/client-services/services/content"),require("@project-sunbird/client-services/core"),require("@project-sunbird/client-services/core/http-service/utilities/interceptors"),require("@project-sunbird/client-services/models/group"),require("@project-sunbird/client-services/models/user"),require("@project-sunbird/client-services/services/content/utilities/content-group-generator"),require("@project-sunbird/client-services/services/content/utilities/content-progress-calculator"),require("@project-sunbird/client-services/services/content/utilities/mime-type-facet-to-mime-type-category-aggregator")):t(e.rxjs.operators,e.rxjs,e["@project-sunbird"]["client-services"],e["@project-sunbird"]["client-services"].core["http-service"],e["@project-sunbird"]["client-services"].models.content.index,e["@project-sunbird"]["client-services"].services.content.utilities["primary-category-mapper"],e["@project-sunbird"]["client-services"].services.content,e["@project-sunbird"]["client-services"].core,e["@project-sunbird"]["client-services"].core["http-service"].utilities.interceptors,e["@project-sunbird"]["client-services"].models.group,e["@project-sunbird"]["client-services"].models.user,e["@project-sunbird"]["client-services"].services.content.utilities["content-group-generator"],e["@project-sunbird"]["client-services"].services.content.utilities["content-progress-calculator"],e["@project-sunbird"]["client-services"].services.content.utilities["mime-type-facet-to-mime-type-category-aggregator"]);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(e,t,n,r,i,o,s,a,c,u,l,d,h,E){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=104)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiBindToService=t.getServiceIdentifierAsString=t.typeConstraint=t.namedConstraint=t.taggedConstraint=t.traverseAncerstors=t.decorate=t.id=t.MetadataReader=t.postConstruct=t.targetName=t.multiInject=t.unmanaged=t.optional=t.LazyServiceIdentifer=t.inject=t.named=t.tagged=t.injectable=t.ContainerModule=t.AsyncContainerModule=t.TargetTypeEnum=t.BindingTypeEnum=t.BindingScopeEnum=t.Container=t.METADATA_KEY=void 0;var r=n(5);t.METADATA_KEY=r;var i=n(53);Object.defineProperty(t,"Container",{enumerable:!0,get:function(){return i.Container}});var o=n(13);Object.defineProperty(t,"BindingScopeEnum",{enumerable:!0,get:function(){return o.BindingScopeEnum}}),Object.defineProperty(t,"BindingTypeEnum",{enumerable:!0,get:function(){return o.BindingTypeEnum}}),Object.defineProperty(t,"TargetTypeEnum",{enumerable:!0,get:function(){return o.TargetTypeEnum}});var s=n(69);Object.defineProperty(t,"AsyncContainerModule",{enumerable:!0,get:function(){return s.AsyncContainerModule}}),Object.defineProperty(t,"ContainerModule",{enumerable:!0,get:function(){return s.ContainerModule}});var a=n(70);Object.defineProperty(t,"injectable",{enumerable:!0,get:function(){return a.injectable}});var c=n(71);Object.defineProperty(t,"tagged",{enumerable:!0,get:function(){return c.tagged}});var u=n(72);Object.defineProperty(t,"named",{enumerable:!0,get:function(){return u.named}});var l=n(37);Object.defineProperty(t,"inject",{enumerable:!0,get:function(){return l.inject}}),Object.defineProperty(t,"LazyServiceIdentifer",{enumerable:!0,get:function(){return l.LazyServiceIdentifer}});var d=n(73);Object.defineProperty(t,"optional",{enumerable:!0,get:function(){return d.optional}});var h=n(74);Object.defineProperty(t,"unmanaged",{enumerable:!0,get:function(){return h.unmanaged}});var E=n(75);Object.defineProperty(t,"multiInject",{enumerable:!0,get:function(){return E.multiInject}});var f=n(76);Object.defineProperty(t,"targetName",{enumerable:!0,get:function(){return f.targetName}});var p=n(77);Object.defineProperty(t,"postConstruct",{enumerable:!0,get:function(){return p.postConstruct}});var _=n(35);Object.defineProperty(t,"MetadataReader",{enumerable:!0,get:function(){return _.MetadataReader}});var O=n(19);Object.defineProperty(t,"id",{enumerable:!0,get:function(){return O.id}});var S=n(15);Object.defineProperty(t,"decorate",{enumerable:!0,get:function(){return S.decorate}});var g=n(40);Object.defineProperty(t,"traverseAncerstors",{enumerable:!0,get:function(){return g.traverseAncerstors}}),Object.defineProperty(t,"taggedConstraint",{enumerable:!0,get:function(){return g.taggedConstraint}}),Object.defineProperty(t,"namedConstraint",{enumerable:!0,get:function(){return g.namedConstraint}}),Object.defineProperty(t,"typeConstraint",{enumerable:!0,get:function(){return g.typeConstraint}});var A=n(23);Object.defineProperty(t,"getServiceIdentifierAsString",{enumerable:!0,get:function(){return A.getServiceIdentifierAsString}});var N=n(78);Object.defineProperty(t,"multiBindToService",{enumerable:!0,get:function(){return N.multiBindToService}})},function(e,t){e.exports=n},function(e,t){e.exports=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NON_CUSTOM_TAG_KEYS=t.POST_CONSTRUCT=t.DESIGN_PARAM_TYPES=t.PARAM_TYPES=t.TAGGED_PROP=t.TAGGED=t.MULTI_INJECT_TAG=t.INJECT_TAG=t.OPTIONAL_TAG=t.UNMANAGED_TAG=t.NAME_TAG=t.NAMED_TAG=void 0,t.NAMED_TAG="named",t.NAME_TAG="name",t.UNMANAGED_TAG="unmanaged",t.OPTIONAL_TAG="optional",t.INJECT_TAG="inject",t.MULTI_INJECT_TAG="multi_inject",t.TAGGED="inversify:tagged",t.TAGGED_PROP="inversify:tagged_props",t.PARAM_TYPES="inversify:paramtypes",t.DESIGN_PARAM_TYPES="design:paramtypes",t.POST_CONSTRUCT="post_construct",t.NON_CUSTOM_TAG_KEYS=[t.INJECT_TAG,t.MULTI_INJECT_TAG,t.NAME_TAG,t.UNMANAGED_TAG,t.NAMED_TAG,t.OPTIONAL_TAG]},function(e,t,n){e.exports=function(){"use strict";var e=6e4,t=36e5,n="millisecond",r="second",i="minute",o="hour",s="day",a="week",c="month",u="quarter",l="year",d="date",h="Invalid Date",E=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,f=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,p={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:""+Array(t+1-r.length).join(n)+e},O={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?"+":"-")+_(r,2,"0")+":"+_(i,2,"0")},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,c),o=n-i<0,s=t.clone().add(r+(o?-1:1),c);return+(-(r+(n-i)/(o?i-s:s-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:c,y:l,w:a,d:s,D:d,h:o,m:i,s:r,ms:n,Q:u}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},S="en",g={};g[S]=p;var A="$isDayjsObject",N=function(e){return e instanceof y||!(!e||!e[A])},T=function e(t,n,r){var i;if(!t)return S;if("string"==typeof t){var o=t.toLowerCase();g[o]&&(i=o),n&&(g[o]=n,i=o);var s=t.split("-");if(!i&&s.length>1)return e(s[0])}else{var a=t.name;g[a]=t,i=a}return!r&&i&&(S=i),i||!r&&S},C=function(e,t){if(N(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new y(n)},v=O;v.l=T,v.i=N,v.w=function(e,t){return C(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var y=function(){function p(e){this.$L=T(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[A]=!0}var _=p.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(v.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var r=t.match(E);if(r){var i=r[2]-1||0,o=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,o)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,o)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return v},_.isValid=function(){return!(this.$d.toString()===h)},_.isSame=function(e,t){var n=C(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return C(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<C(e)},_.$g=function(e,t,n){return v.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,u=!!v.u(t)||t,h=v.p(e),E=function(e,t){var r=v.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return u?r:r.endOf(s)},f=function(e,t){return v.w(n.toDate()[e].apply(n.toDate("s"),(u?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},p=this.$W,_=this.$M,O=this.$D,S="set"+(this.$u?"UTC":"");switch(h){case l:return u?E(1,0):E(31,11);case c:return u?E(1,_):E(0,_+1);case a:var g=this.$locale().weekStart||0,A=(p<g?p+7:p)-g;return E(u?O-A:O+(6-A),_);case s:case d:return f(S+"Hours",0);case o:return f(S+"Minutes",1);case i:return f(S+"Seconds",2);case r:return f(S+"Milliseconds",3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var a,u=v.p(e),h="set"+(this.$u?"UTC":""),E=(a={},a[s]=h+"Date",a[d]=h+"Date",a[c]=h+"Month",a[l]=h+"FullYear",a[o]=h+"Hours",a[i]=h+"Minutes",a[r]=h+"Seconds",a[n]=h+"Milliseconds",a)[u],f=u===s?this.$D+(t-this.$W):t;if(u===c||u===l){var p=this.clone().set(d,1);p.$d[E](f),p.init(),this.$d=p.set(d,Math.min(this.$D,p.daysInMonth())).$d}else E&&this.$d[E](f);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[v.p(e)]()},_.add=function(n,u){var d,h=this;n=Number(n);var E=v.p(u),f=function(e){var t=C(h);return v.w(t.date(t.date()+Math.round(e*n)),h)};if(E===c)return this.set(c,this.$M+n);if(E===l)return this.set(l,this.$y+n);if(E===s)return f(1);if(E===a)return f(7);var p=(d={},d[i]=e,d[o]=t,d[r]=1e3,d)[E]||1,_=this.$d.getTime()+n*p;return v.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||h;var r=e||"YYYY-MM-DDTHH:mm:ssZ",i=v.z(this),o=this.$H,s=this.$m,a=this.$M,c=n.weekdays,u=n.months,l=n.meridiem,d=function(e,n,i,o){return e&&(e[n]||e(t,r))||i[n].slice(0,o)},E=function(e){return v.s(o%12||12,e,"0")},p=l||function(e,t,n){var r=e<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(f,(function(e,r){return r||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return v.s(t.$y,4,"0");case"M":return a+1;case"MM":return v.s(a+1,2,"0");case"MMM":return d(n.monthsShort,a,u,3);case"MMMM":return d(u,a);case"D":return t.$D;case"DD":return v.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return d(n.weekdaysMin,t.$W,c,2);case"ddd":return d(n.weekdaysShort,t.$W,c,3);case"dddd":return c[t.$W];case"H":return String(o);case"HH":return v.s(o,2,"0");case"h":return E(1);case"hh":return E(2);case"a":return p(o,s,!0);case"A":return p(o,s,!1);case"m":return String(s);case"mm":return v.s(s,2,"0");case"s":return String(t.$s);case"ss":return v.s(t.$s,2,"0");case"SSS":return v.s(t.$ms,3,"0");case"Z":return i}return null}(e)||i.replace(":","")}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(n,d,h){var E,f=this,p=v.p(d),_=C(n),O=(_.utcOffset()-this.utcOffset())*e,S=this-_,g=function(){return v.m(f,_)};switch(p){case l:E=g()/12;break;case c:E=g();break;case u:E=g()/3;break;case a:E=(S-O)/6048e5;break;case s:E=(S-O)/864e5;break;case o:E=S/t;break;case i:E=S/e;break;case r:E=S/1e3;break;default:E=S}return h?E:v.a(E)},_.daysInMonth=function(){return this.endOf(c).$D},_.$locale=function(){return g[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=T(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return v.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},p}(),m=y.prototype;return C.prototype=m,[["$ms",n],["$s",r],["$m",i],["$H",o],["$W",s],["$M",c],["$y",l],["$D",d]].forEach((function(e){m[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),C.extend=function(e,t){return e.$i||(e(t,y,C),e.$i=!0),C},C.locale=T,C.isDayjs=N,C.unix=function(e){return C(1e3*e)},C.en=g[S],C.Ls=g,C.p={},C}()},function(e,t){e.exports=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.STACK_OVERFLOW=t.CIRCULAR_DEPENDENCY_IN_FACTORY=t.POST_CONSTRUCT_ERROR=t.MULTIPLE_POST_CONSTRUCT_METHODS=t.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK=t.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE=t.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE=t.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT=t.ARGUMENTS_LENGTH_MISMATCH=t.INVALID_DECORATOR_OPERATION=t.INVALID_TO_SELF_VALUE=t.INVALID_FUNCTION_BINDING=t.INVALID_MIDDLEWARE_RETURN=t.NO_MORE_SNAPSHOTS_AVAILABLE=t.INVALID_BINDING_TYPE=t.NOT_IMPLEMENTED=t.CIRCULAR_DEPENDENCY=t.UNDEFINED_INJECT_ANNOTATION=t.MISSING_INJECT_ANNOTATION=t.MISSING_INJECTABLE_ANNOTATION=t.NOT_REGISTERED=t.CANNOT_UNBIND=t.AMBIGUOUS_MATCH=t.KEY_NOT_FOUND=t.NULL_ARGUMENT=t.DUPLICATED_METADATA=t.DUPLICATED_INJECTABLE_DECORATOR=void 0,t.DUPLICATED_INJECTABLE_DECORATOR="Cannot apply @injectable decorator multiple times.",t.DUPLICATED_METADATA="Metadata key was used more than once in a parameter:",t.NULL_ARGUMENT="NULL argument",t.KEY_NOT_FOUND="Key Not Found",t.AMBIGUOUS_MATCH="Ambiguous match found for serviceIdentifier:",t.CANNOT_UNBIND="Could not unbind serviceIdentifier:",t.NOT_REGISTERED="No matching bindings found for serviceIdentifier:",t.MISSING_INJECTABLE_ANNOTATION="Missing required @injectable annotation in:",t.MISSING_INJECT_ANNOTATION="Missing required @inject or @multiInject annotation in:";t.UNDEFINED_INJECT_ANNOTATION=function(e){return"@inject called with undefined this could mean that the class "+e+" has a circular dependency problem. You can use a LazyServiceIdentifer to overcome this limitation."},t.CIRCULAR_DEPENDENCY="Circular dependency found:",t.NOT_IMPLEMENTED="Sorry, this feature is not fully implemented yet.",t.INVALID_BINDING_TYPE="Invalid binding type:",t.NO_MORE_SNAPSHOTS_AVAILABLE="No snapshot available to restore.",t.INVALID_MIDDLEWARE_RETURN="Invalid return type in middleware. Middleware must return!",t.INVALID_FUNCTION_BINDING="Value provided to function binding must be a function!",t.INVALID_TO_SELF_VALUE="The toSelf function can only be applied when a constructor is used as service identifier",t.INVALID_DECORATOR_OPERATION="The @inject @multiInject @tagged and @named decorators must be applied to the parameters of a class constructor or a class property.";t.ARGUMENTS_LENGTH_MISMATCH=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"The number of constructor arguments in the derived class "+e[0]+" must be >= than the number of constructor arguments of its base class."},t.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT="Invalid Container constructor argument. Container options must be an object.",t.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE="Invalid Container option. Default scope must be a string ('singleton' or 'transient').",t.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE="Invalid Container option. Auto bind injectable must be a boolean",t.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK="Invalid Container option. Skip base check must be a boolean",t.MULTIPLE_POST_CONSTRUCT_METHODS="Cannot apply @postConstruct decorator multiple times in the same class";t.POST_CONSTRUCT_ERROR=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"@postConstruct error in class "+e[0]+": "+e[1]};t.CIRCULAR_DEPENDENCY_IN_FACTORY=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"It looks like there is a circular dependency in one of the '"+e[0]+"' bindings. Please investigate bindings withservice identifier '"+e[1]+"'."},t.STACK_OVERFLOW="Maximum call stack size exceeded"},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(11),i=n(45),o=n(101),s=function(){function e(e){this.dictionary=new o.default(e)}return e.prototype.contains=function(e){return this.dictionary.containsKey(e)},e.prototype.add=function(e){return!this.contains(e)&&!r.isUndefined(e)&&(this.dictionary.setValue(e,e),!0)},e.prototype.intersection=function(e){var t=this;this.forEach((function(n){return e.contains(n)||t.remove(n),!0}))},e.prototype.union=function(e){var t=this;e.forEach((function(e){return t.add(e),!0}))},e.prototype.difference=function(e){var t=this;e.forEach((function(e){return t.remove(e),!0}))},e.prototype.isSubsetOf=function(e){if(this.size()>e.size())return!1;var t=!0;return this.forEach((function(n){return!!e.contains(n)||(t=!1,!1)})),t},e.prototype.remove=function(e){return!!this.contains(e)&&(this.dictionary.remove(e),!0)},e.prototype.forEach=function(e){this.dictionary.forEach((function(t,n){return e(n)}))},e.prototype.toArray=function(){return this.dictionary.values()},e.prototype.isEmpty=function(){return this.dictionary.isEmpty()},e.prototype.size=function(){return this.dictionary.size()},e.prototype.clear=function(){this.dictionary.clear()},e.prototype.toString=function(){return i.toString(this.toArray())},e}();t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Metadata=void 0;var r=n(5),i=function(){function e(e,t){this.key=e,this.value=t}return e.prototype.toString=function(){return this.key===r.NAMED_TAG?"named: "+this.value.toString()+" ":"tagged: { key:"+this.key.toString()+", value: "+this.value+" }"},e}();t.Metadata=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=Object.prototype.hasOwnProperty;function i(e){return"function"==typeof e}function o(e){return void 0===e}function s(e){return"[object String]"===Object.prototype.toString.call(e)}t.has=function(e,t){return r.call(e,t)},t.defaultCompare=function(e,t){return e<t?-1:e===t?0:1},t.defaultEquals=function(e,t){return e===t},t.defaultToString=function(e){return null===e?"COLLECTION_NULL":o(e)?"COLLECTION_UNDEFINED":s(e)?"$s"+e:"$o"+e.toString()},t.makeString=function(e,n){if(void 0===n&&(n=","),null===e)return"COLLECTION_NULL";if(o(e))return"COLLECTION_UNDEFINED";if(s(e))return e.toString();var r="{",i=!0;for(var a in e)t.has(e,a)&&(i?i=!1:r+=n,r=r+a+":"+e[a]);return r+"}"},t.isFunction=i,t.isUndefined=o,t.isString=s,t.reverseCompareFunction=function(e){return o(e)||!i(e)?function(e,t){return e<t?1:e===t?0:-1}:function(t,n){return-1*e(t,n)}},t.compareToEquals=function(e){return function(t,n){return 0===e(t,n)}}},function(e,t,n){"use strict";var r=n(79),i=n(98),o=n(31);e.exports={formats:o,parse:i,stringify:r}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TargetTypeEnum=t.BindingTypeEnum=t.BindingScopeEnum=void 0;t.BindingScopeEnum={Request:"Request",Singleton:"Singleton",Transient:"Transient"};t.BindingTypeEnum={ConstantValue:"ConstantValue",Constructor:"Constructor",DynamicValue:"DynamicValue",Factory:"Factory",Function:"Function",Instance:"Instance",Invalid:"Invalid",Provider:"Provider"};t.TargetTypeEnum={ClassProperty:"ClassProperty",ConstructorArgument:"ConstructorArgument",Variable:"Variable"}},function(e,t,n){var r,i,o,s,a,c,u,l;e.exports=(l=n(44),i=(r=l).lib,o=i.WordArray,s=i.Hasher,a=r.algo,c=[],u=a.SHA1=s.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],s=n[3],a=n[4],u=0;u<80;u++){if(u<16)c[u]=0|e[t+u];else{var l=c[u-3]^c[u-8]^c[u-14]^c[u-16];c[u]=l<<1|l>>>31}var d=(r<<5|r>>>27)+a+c[u];d+=u<20?1518500249+(i&o|~i&s):u<40?1859775393+(i^o^s):u<60?(i&o|i&s|o&s)-1894007588:(i^o^s)-899497514,a=s,s=o,o=i<<30|i>>>2,i=r,r=d}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(r+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=s._createHelper(u),r.HmacSHA1=s._createHmacHelper(u),l.SHA1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagProperty=t.tagParameter=t.decorate=void 0;var r=n(8),i=n(5);function o(e,t,n,i,o){var s={},a="number"==typeof o,c=void 0!==o&&a?o.toString():n;if(a&&void 0!==n)throw new Error(r.INVALID_DECORATOR_OPERATION);Reflect.hasOwnMetadata(e,t)&&(s=Reflect.getMetadata(e,t));var u=s[c];if(Array.isArray(u))for(var l=0,d=u;l<d.length;l++){var h=d[l];if(h.key===i.key)throw new Error(r.DUPLICATED_METADATA+" "+h.key.toString())}else u=[];u.push(i),s[c]=u,Reflect.defineMetadata(e,s,t)}function s(e,t){Reflect.decorate(e,t)}function a(e,t){return function(n,r){t(n,r,e)}}t.tagParameter=function(e,t,n,r){o(i.TAGGED,e,t,r,n)},t.tagProperty=function(e,t,n){o(i.TAGGED_PROP,e.constructor,t,n)},t.decorate=function(e,t,n){"number"==typeof n?s([a(n,e)],t):"string"==typeof n?Reflect.decorate([e],t,n):s([e],t)}},function(e,t,n){e.exports=function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};t[s][0].call(u.exports,(function(e){return i(t[s][1][e]||e)}),u,u.exports,e,t,n,r)}return n[s].exports}for(var o=!1,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}n.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var r in n)i(n,r)&&(e[r]=n[r])}}return e},n.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var o={arraySet:function(e,t,n,r,i){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+r),i);else for(var o=0;o<r;o++)e[i+o]=t[n+o]},flattenChunks:function(e){var t,n,r,i,o,s;for(r=0,t=0,n=e.length;t<n;t++)r+=e[t].length;for(s=new Uint8Array(r),i=0,t=0,n=e.length;t<n;t++)o=e[t],s.set(o,i),i+=o.length;return s}},s={arraySet:function(e,t,n,r,i){for(var o=0;o<r;o++)e[i+o]=t[n+o]},flattenChunks:function(e){return[].concat.apply([],e)}};n.setTyped=function(e){e?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,o)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,s))},n.setTyped(r)},{}],2:[function(e,t,n){"use strict";var r=e("./common"),i=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){o=!1}for(var s=new r.Buf8(256),a=0;a<256;a++)s[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;function c(e,t){if(t<65534&&(e.subarray&&o||!e.subarray&&i))return String.fromCharCode.apply(null,r.shrinkBuf(e,t));for(var n="",s=0;s<t;s++)n+=String.fromCharCode(e[s]);return n}s[254]=s[254]=1,n.string2buf=function(e){var t,n,i,o,s,a=e.length,c=0;for(o=0;o<a;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(i-56320),o++),c+=n<128?1:n<2048?2:n<65536?3:4;for(t=new r.Buf8(c),s=0,o=0;s<c;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(i-56320),o++),n<128?t[s++]=n:n<2048?(t[s++]=192|n>>>6,t[s++]=128|63&n):n<65536?(t[s++]=224|n>>>12,t[s++]=128|n>>>6&63,t[s++]=128|63&n):(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63,t[s++]=128|n>>>6&63,t[s++]=128|63&n);return t},n.buf2binstring=function(e){return c(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n<i;n++)t[n]=e.charCodeAt(n);return t},n.buf2string=function(e,t){var n,r,i,o,a=t||e.length,u=new Array(2*a);for(r=0,n=0;n<a;)if((i=e[n++])<128)u[r++]=i;else if((o=s[i])>4)u[r++]=65533,n+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&n<a;)i=i<<6|63&e[n++],o--;o>1?u[r++]=65533:i<65536?u[r++]=i:(i-=65536,u[r++]=55296|i>>10&1023,u[r++]=56320|1023&i)}return c(u,r)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+s[e[n]]>t?n:t}},{"./common":1}],3:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){for(var i=65535&e|0,o=e>>>16&65535|0,s=0;0!==n;){n-=s=n>2e3?2e3:n;do{o=o+(i=i+t[r++]|0)|0}while(--s);i%=65521,o%=65521}return i|o<<16|0}},{}],4:[function(e,t,n){"use strict";var r=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var o=r,s=i+n;e^=-1;for(var a=i;a<s;a++)e=e>>>8^o[255&(e^t[a])];return-1^e}},{}],5:[function(e,t,n){"use strict";var r,i=e("../utils/common"),o=e("./trees"),s=e("./adler32"),a=e("./crc32"),c=e("./messages");function u(e,t){return e.msg=c[t],t}function l(e){return(e<<1)-(e>4?9:0)}function d(e){for(var t=e.length;--t>=0;)e[t]=0}function h(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function E(e,t){o._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,h(e.strm)}function f(e,t){e.pending_buf[e.pending++]=t}function p(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function _(e,t){var n,r,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match,c=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,u=e.window,l=e.w_mask,d=e.prev,h=e.strstart+258,E=u[o+s-1],f=u[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(u[(n=t)+s]===f&&u[n+s-1]===E&&u[n]===u[o]&&u[++n]===u[o+1]){o+=2,n++;do{}while(u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&o<h);if(r=258-(h-o),o=h-258,r>s){if(e.match_start=t,s=r,r>=a)break;E=u[o+s-1],f=u[o+s]}}}while((t=d[t&l])>c&&0!=--i);return s<=e.lookahead?s:e.lookahead}function O(e){var t,n,r,o,c,u,l,d,h,E,f=e.w_size;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=f+(f-262)){i.arraySet(e.window,e.window,f,f,0),e.match_start-=f,e.strstart-=f,e.block_start-=f,t=n=e.hash_size;do{r=e.head[--t],e.head[t]=r>=f?r-f:0}while(--n);t=n=f;do{r=e.prev[--t],e.prev[t]=r>=f?r-f:0}while(--n);o+=f}if(0===e.strm.avail_in)break;if(u=e.strm,l=e.window,d=e.strstart+e.lookahead,h=o,E=void 0,(E=u.avail_in)>h&&(E=h),n=0===E?0:(u.avail_in-=E,i.arraySet(l,u.input,u.next_in,E,d),1===u.state.wrap?u.adler=s(u.adler,l,E,d):2===u.state.wrap&&(u.adler=a(u.adler,l,E,d)),u.next_in+=E,u.total_in+=E,E),e.lookahead+=n,e.lookahead+e.insert>=3)for(c=e.strstart-e.insert,e.ins_h=e.window[c],e.ins_h=(e.ins_h<<e.hash_shift^e.window[c+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[c+3-1])&e.hash_mask,e.prev[c&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=c,c++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<262&&0!==e.strm.avail_in)}function S(e,t){for(var n,r;;){if(e.lookahead<262){if(O(e),e.lookahead<262&&0===t)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-262&&(e.match_length=_(e,n)),e.match_length>=3)if(r=o._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(E(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(E(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(E(e,!1),0===e.strm.avail_out)?1:2}function g(e,t){for(var n,r,i;;){if(e.lookahead<262){if(O(e),e.lookahead<262&&0===t)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-262&&(e.match_length=_(e,n),e.match_length<=5&&(1===e.strategy||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,r=o._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(E(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((r=o._tr_tally(e,0,e.window[e.strstart-1]))&&E(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=o._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(E(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(E(e,!1),0===e.strm.avail_out)?1:2}function A(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}function N(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(1146),this.dyn_dtree=new i.Buf16(122),this.bl_tree=new i.Buf16(78),d(this.dyn_ltree),d(this.dyn_dtree),d(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(16),this.heap=new i.Buf16(573),d(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(573),d(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function T(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:113,e.adler=2===t.wrap?0:1,t.last_flush=0,o._tr_init(t),0):u(e,-2)}function C(e){var t,n=T(e);return 0===n&&((t=e.state).window_size=2*t.w_size,d(t.head),t.max_lazy_match=r[t.level].max_lazy,t.good_match=r[t.level].good_length,t.nice_match=r[t.level].nice_length,t.max_chain_length=r[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),n}function v(e,t,n,r,o,s){if(!e)return-2;var a=1;if(-1===t&&(t=6),r<0?(a=0,r=-r):r>15&&(a=2,r-=16),o<1||o>9||8!==n||r<8||r>15||t<0||t>9||s<0||s>4)return u(e,-2);8===r&&(r=9);var c=new N;return e.state=c,c.strm=e,c.wrap=a,c.gzhead=null,c.w_bits=r,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.hash_bits=o+7,c.hash_size=1<<c.hash_bits,c.hash_mask=c.hash_size-1,c.hash_shift=~~((c.hash_bits+3-1)/3),c.window=new i.Buf8(2*c.w_size),c.head=new i.Buf16(c.hash_size),c.prev=new i.Buf16(c.w_size),c.lit_bufsize=1<<o+6,c.pending_buf_size=4*c.lit_bufsize,c.pending_buf=new i.Buf8(c.pending_buf_size),c.d_buf=1*c.lit_bufsize,c.l_buf=3*c.lit_bufsize,c.level=t,c.strategy=s,c.method=n,C(e)}r=[new A(0,0,0,0,(function(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(O(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,E(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-262&&(E(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(E(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(E(e,!1),e.strm.avail_out),1)})),new A(4,4,8,4,S),new A(4,5,16,8,S),new A(4,6,32,32,S),new A(4,4,16,16,g),new A(8,16,32,32,g),new A(8,16,128,128,g),new A(8,32,128,256,g),new A(32,128,258,1024,g),new A(32,258,258,4096,g)],n.deflateInit=function(e,t){return v(e,t,8,15,8,0)},n.deflateInit2=v,n.deflateReset=C,n.deflateResetKeep=T,n.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?-2:(e.state.gzhead=t,0):-2},n.deflate=function(e,t){var n,i,s,c;if(!e||!e.state||t>5||t<0)return e?u(e,-2):-2;if(i=e.state,!e.output||!e.input&&0!==e.avail_in||666===i.status&&4!==t)return u(e,0===e.avail_out?-5:-2);if(i.strm=e,n=i.last_flush,i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,f(i,31),f(i,139),f(i,8),i.gzhead?(f(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),f(i,255&i.gzhead.time),f(i,i.gzhead.time>>8&255),f(i,i.gzhead.time>>16&255),f(i,i.gzhead.time>>24&255),f(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),f(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(f(i,255&i.gzhead.extra.length),f(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=a(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(f(i,0),f(i,0),f(i,0),f(i,0),f(i,0),f(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),f(i,3),i.status=113);else{var _=8+(i.w_bits-8<<4)<<8;_|=(i.strategy>=2||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(_|=32),_+=31-_%31,i.status=113,p(i,_),0!==i.strstart&&(p(i,e.adler>>>16),p(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(s=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),h(e),s=i.pending,i.pending!==i.pending_buf_size));)f(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),h(e),s=i.pending,i.pending===i.pending_buf_size)){c=1;break}c=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,f(i,c)}while(0!==c);i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),0===c&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),h(e),s=i.pending,i.pending===i.pending_buf_size)){c=1;break}c=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,f(i,c)}while(0!==c);i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),0===c&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&h(e),i.pending+2<=i.pending_buf_size&&(f(i,255&e.adler),f(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(h(e),0===e.avail_out)return i.last_flush=-1,0}else if(0===e.avail_in&&l(t)<=l(n)&&4!==t)return u(e,-5);if(666===i.status&&0!==e.avail_in)return u(e,-5);if(0!==e.avail_in||0!==i.lookahead||0!==t&&666!==i.status){var S=2===i.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(O(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(E(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(E(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(E(e,!1),0===e.strm.avail_out)?1:2}(i,t):3===i.strategy?function(e,t){for(var n,r,i,s,a=e.window;;){if(e.lookahead<=258){if(O(e),e.lookahead<=258&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=a[i=e.strstart-1])===a[++i]&&r===a[++i]&&r===a[++i]){s=e.strstart+258;do{}while(r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&i<s);e.match_length=258-(s-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=o._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(E(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(E(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(E(e,!1),0===e.strm.avail_out)?1:2}(i,t):r[i.level].func(i,t);if(3!==S&&4!==S||(i.status=666),1===S||3===S)return 0===e.avail_out&&(i.last_flush=-1),0;if(2===S&&(1===t?o._tr_align(i):5!==t&&(o._tr_stored_block(i,0,0,!1),3===t&&(d(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),h(e),0===e.avail_out))return i.last_flush=-1,0}return 4!==t?0:i.wrap<=0?1:(2===i.wrap?(f(i,255&e.adler),f(i,e.adler>>8&255),f(i,e.adler>>16&255),f(i,e.adler>>24&255),f(i,255&e.total_in),f(i,e.total_in>>8&255),f(i,e.total_in>>16&255),f(i,e.total_in>>24&255)):(p(i,e.adler>>>16),p(i,65535&e.adler)),h(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?0:1)},n.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?u(e,-2):(e.state=null,113===t?u(e,-3):0):-2},n.deflateSetDictionary=function(e,t){var n,r,o,a,c,u,l,h,E=t.length;if(!e||!e.state)return-2;if(2===(a=(n=e.state).wrap)||1===a&&42!==n.status||n.lookahead)return-2;for(1===a&&(e.adler=s(e.adler,t,E,0)),n.wrap=0,E>=n.w_size&&(0===a&&(d(n.head),n.strstart=0,n.block_start=0,n.insert=0),h=new i.Buf8(n.w_size),i.arraySet(h,t,E-n.w_size,n.w_size,0),t=h,E=n.w_size),c=e.avail_in,u=e.next_in,l=e.input,e.avail_in=E,e.next_in=0,e.input=t,O(n);n.lookahead>=3;){r=n.strstart,o=n.lookahead-2;do{n.ins_h=(n.ins_h<<n.hash_shift^n.window[r+3-1])&n.hash_mask,n.prev[r&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=r,r++}while(--o);n.strstart=r,n.lookahead=2,O(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=u,e.input=l,e.avail_in=c,n.wrap=a,0},n.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":4,"./messages":6,"./trees":7}],6:[function(e,t,n){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],7:[function(e,t,n){"use strict";var r=e("../utils/common");function i(e){for(var t=e.length;--t>=0;)e[t]=0}var o=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],s=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],c=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],u=new Array(576);i(u);var l=new Array(60);i(l);var d=new Array(512);i(d);var h=new Array(256);i(h);var E=new Array(29);i(E);var f,p,_,O=new Array(30);function S(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}function g(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function A(e){return e<256?d[e]:d[256+(e>>>7)]}function N(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function T(e,t,n){e.bi_valid>16-n?(e.bi_buf|=t<<e.bi_valid&65535,N(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function C(e,t,n){T(e,n[2*t],n[2*t+1])}function v(e,t){var n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1}function y(e,t,n){var r,i,o=new Array(16),s=0;for(r=1;r<=15;r++)o[r]=s=s+n[r-1]<<1;for(i=0;i<=t;i++){var a=e[2*i+1];0!==a&&(e[2*i]=v(o[a]++,a))}}function m(e){var t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function b(e){e.bi_valid>8?N(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function I(e,t,n,r){var i=2*t,o=2*n;return e[i]<e[o]||e[i]===e[o]&&r[t]<=r[n]}function M(e,t,n){for(var r=e.heap[n],i=n<<1;i<=e.heap_len&&(i<e.heap_len&&I(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!I(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r}function R(e,t,n){var r,i,a,c,u=0;if(0!==e.last_lit)do{r=e.pending_buf[e.d_buf+2*u]<<8|e.pending_buf[e.d_buf+2*u+1],i=e.pending_buf[e.l_buf+u],u++,0===r?C(e,i,t):(C(e,(a=h[i])+256+1,t),0!==(c=o[a])&&T(e,i-=E[a],c),C(e,a=A(--r),n),0!==(c=s[a])&&T(e,r-=O[a],c))}while(u<e.last_lit);C(e,256,t)}function L(e,t){var n,r,i,o=t.dyn_tree,s=t.stat_desc.static_tree,a=t.stat_desc.has_stree,c=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=573,n=0;n<c;n++)0!==o[2*n]?(e.heap[++e.heap_len]=u=n,e.depth[n]=0):o[2*n+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,a&&(e.static_len-=s[2*i+1]);for(t.max_code=u,n=e.heap_len>>1;n>=1;n--)M(e,o,n);i=c;do{n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],M(e,o,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,o[2*i]=o[2*n]+o[2*r],e.depth[i]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,o[2*n+1]=o[2*r+1]=i,e.heap[1]=i++,M(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,i,o,s,a,c=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,d=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,E=t.stat_desc.extra_base,f=t.stat_desc.max_length,p=0;for(o=0;o<=15;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<573;n++)(o=c[2*c[2*(r=e.heap[n])+1]+1]+1)>f&&(o=f,p++),c[2*r+1]=o,r>u||(e.bl_count[o]++,s=0,r>=E&&(s=h[r-E]),a=c[2*r],e.opt_len+=a*(o+s),d&&(e.static_len+=a*(l[2*r+1]+s)));if(0!==p){do{for(o=f-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[f]--,p-=2}while(p>0);for(o=f;0!==o;o--)for(r=e.bl_count[o];0!==r;)(i=e.heap[--n])>u||(c[2*i+1]!==o&&(e.opt_len+=(o-c[2*i+1])*c[2*i],c[2*i+1]=o),r--)}}(e,t),y(o,u,e.bl_count)}function P(e,t,n){var r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)i=s,s=t[2*(r+1)+1],++a<c&&i===s||(a<u?e.bl_tree[2*i]+=a:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[32]++):a<=10?e.bl_tree[34]++:e.bl_tree[36]++,a=0,o=i,0===s?(c=138,u=3):i===s?(c=6,u=3):(c=7,u=4))}function D(e,t,n){var r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),r=0;r<=n;r++)if(i=s,s=t[2*(r+1)+1],!(++a<c&&i===s)){if(a<u)do{C(e,i,e.bl_tree)}while(0!=--a);else 0!==i?(i!==o&&(C(e,i,e.bl_tree),a--),C(e,16,e.bl_tree),T(e,a-3,2)):a<=10?(C(e,17,e.bl_tree),T(e,a-3,3)):(C(e,18,e.bl_tree),T(e,a-11,7));a=0,o=i,0===s?(c=138,u=3):i===s?(c=6,u=3):(c=7,u=4)}}i(O);var w=!1;function U(e,t,n,i){T(e,0+(i?1:0),3),function(e,t,n,i){b(e),i&&(N(e,n),N(e,~n)),r.arraySet(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}(e,t,n,!0)}n._tr_init=function(e){w||(function(){var e,t,n,r,i,c=new Array(16);for(n=0,r=0;r<28;r++)for(E[r]=n,e=0;e<1<<o[r];e++)h[n++]=r;for(h[n-1]=r,i=0,r=0;r<16;r++)for(O[r]=i,e=0;e<1<<s[r];e++)d[i++]=r;for(i>>=7;r<30;r++)for(O[r]=i<<7,e=0;e<1<<s[r]-7;e++)d[256+i++]=r;for(t=0;t<=15;t++)c[t]=0;for(e=0;e<=143;)u[2*e+1]=8,e++,c[8]++;for(;e<=255;)u[2*e+1]=9,e++,c[9]++;for(;e<=279;)u[2*e+1]=7,e++,c[7]++;for(;e<=287;)u[2*e+1]=8,e++,c[8]++;for(y(u,287,c),e=0;e<30;e++)l[2*e+1]=5,l[2*e]=v(e,5);f=new S(u,o,257,286,15),p=new S(l,s,0,30,15),_=new S(new Array(0),a,0,19,7)}(),w=!0),e.l_desc=new g(e.dyn_ltree,f),e.d_desc=new g(e.dyn_dtree,p),e.bl_desc=new g(e.bl_tree,_),e.bi_buf=0,e.bi_valid=0,m(e)},n._tr_stored_block=U,n._tr_flush_block=function(e,t,n,r){var i,o,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),L(e,e.l_desc),L(e,e.d_desc),s=function(e){var t;for(P(e,e.dyn_ltree,e.l_desc.max_code),P(e,e.dyn_dtree,e.d_desc.max_code),L(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*c[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=n+5,n+4<=i&&-1!==t?U(e,t,n,r):4===e.strategy||o===i?(T(e,2+(r?1:0),3),R(e,u,l)):(T(e,4+(r?1:0),3),function(e,t,n,r){var i;for(T(e,t-257,5),T(e,n-1,5),T(e,r-4,4),i=0;i<r;i++)T(e,e.bl_tree[2*c[i]+1],3);D(e,e.dyn_ltree,t-1),D(e,e.dyn_dtree,n-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),R(e,e.dyn_ltree,e.dyn_dtree)),m(e),r&&b(e)},n._tr_tally=function(e,t,n){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(h[n]+256+1)]++,e.dyn_dtree[2*A(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){T(e,2,3),C(e,256,u),function(e){16===e.bi_valid?(N(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":1}],8:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],"/lib/deflate.js":[function(e,t,n){"use strict";var r=e("./zlib/deflate"),i=e("./utils/common"),o=e("./utils/strings"),s=e("./zlib/messages"),a=e("./zlib/zstream"),c=Object.prototype.toString;function u(e){if(!(this instanceof u))return new u(e);this.options=i.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var n=r.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==n)throw new Error(s[n]);if(t.header&&r.deflateSetHeader(this.strm,t.header),t.dictionary){var l;if(l="string"==typeof t.dictionary?o.string2buf(t.dictionary):"[object ArrayBuffer]"===c.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(n=r.deflateSetDictionary(this.strm,l)))throw new Error(s[n]);this._dict_set=!0}}function l(e,t){var n=new u(t);if(n.push(e,!0),n.err)throw n.msg||s[n.err];return n.result}u.prototype.push=function(e,t){var n,s,a=this.strm,u=this.options.chunkSize;if(this.ended)return!1;s=t===~~t?t:!0===t?4:0,"string"==typeof e?a.input=o.string2buf(e):"[object ArrayBuffer]"===c.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new i.Buf8(u),a.next_out=0,a.avail_out=u),1!==(n=r.deflate(a,s))&&0!==n)return this.onEnd(n),this.ended=!0,!1;0!==a.avail_out&&(0!==a.avail_in||4!==s&&2!==s)||("string"===this.options.to?this.onData(o.buf2binstring(i.shrinkBuf(a.output,a.next_out))):this.onData(i.shrinkBuf(a.output,a.next_out)))}while((a.avail_in>0||0===a.avail_out)&&1!==n);return 4===s?(n=r.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,0===n):2!==s||(this.onEnd(0),a.avail_out=0,!0)},u.prototype.onData=function(e){this.chunks.push(e)},u.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Deflate=u,n.deflate=l,n.deflateRaw=function(e,t){return(t=t||{}).raw=!0,l(e,t)},n.gzip=function(e,t){return(t=t||{}).gzip=!0,l(e,t)}},{"./utils/common":1,"./utils/strings":2,"./zlib/deflate":5,"./zlib/messages":6,"./zlib/zstream":8}]},{},[])("/lib/deflate.js")},function(e,t){e.exports=o},function(e,t){e.exports=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.id=void 0;var r=0;t.id=function(){return r++}},function(e,t,n){"use strict";var r=n(81),i=n(82),o=n(83),s=n(84),a=n(41),c=n(24),u=n(85),l=Function,d=function(e){try{return l('"use strict"; return ('+e+").constructor;")()}catch(e){}},h=Object.getOwnPropertyDescriptor;if(h)try{h({},"")}catch(e){h=null}var E=function(){throw new c},f=h?function(){try{return E}catch(e){try{return h(arguments,"callee").get}catch(e){return E}}}():E,p=n(86)(),_=n(88)(),O=Object.getPrototypeOf||(_?function(e){return e.__proto__}:null),S={},g="undefined"!=typeof Uint8Array&&O?O(Uint8Array):void 0,A={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":p&&O?O([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":S,"%AsyncGenerator%":S,"%AsyncGeneratorFunction%":S,"%AsyncIteratorPrototype%":S,"%Atomics%":"undefined"==typeof Atomics?void 0:Atomics,"%BigInt%":"undefined"==typeof BigInt?void 0:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?void 0:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?void 0:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":r,"%eval%":eval,"%EvalError%":i,"%Float32Array%":"undefined"==typeof Float32Array?void 0:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?void 0:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?void 0:FinalizationRegistry,"%Function%":l,"%GeneratorFunction%":S,"%Int8Array%":"undefined"==typeof Int8Array?void 0:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?void 0:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":p&&O?O(O([][Symbol.iterator]())):void 0,"%JSON%":"object"==typeof JSON?JSON:void 0,"%Map%":"undefined"==typeof Map?void 0:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&p&&O?O((new Map)[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?void 0:Promise,"%Proxy%":"undefined"==typeof Proxy?void 0:Proxy,"%RangeError%":o,"%ReferenceError%":s,"%Reflect%":"undefined"==typeof Reflect?void 0:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?void 0:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&p&&O?O((new Set)[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":p&&O?O(""[Symbol.iterator]()):void 0,"%Symbol%":p?Symbol:void 0,"%SyntaxError%":a,"%ThrowTypeError%":f,"%TypedArray%":g,"%TypeError%":c,"%Uint8Array%":"undefined"==typeof Uint8Array?void 0:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?void 0:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?void 0:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?void 0:Uint32Array,"%URIError%":u,"%WeakMap%":"undefined"==typeof WeakMap?void 0:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?void 0:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?void 0:WeakSet};if(O)try{null.error}catch(e){var N=O(O(e));A["%Error.prototype%"]=N}var T={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},C=n(29),v=n(90),y=C.call(Function.call,Array.prototype.concat),m=C.call(Function.apply,Array.prototype.splice),b=C.call(Function.call,String.prototype.replace),I=C.call(Function.call,String.prototype.slice),M=C.call(Function.call,RegExp.prototype.exec),R=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,L=/\\(\\)?/g,P=function(e){var t=I(e,0,1),n=I(e,-1);if("%"===t&&"%"!==n)throw new a("invalid intrinsic syntax, expected closing `%`");if("%"===n&&"%"!==t)throw new a("invalid intrinsic syntax, expected opening `%`");var r=[];return b(e,R,(function(e,t,n,i){r[r.length]=n?b(i,L,"$1"):t||e})),r},D=function(e,t){var n,r=e;if(v(T,r)&&(r="%"+(n=T[r])[0]+"%"),v(A,r)){var i=A[r];if(i===S&&(i=function e(t){var n;if("%AsyncFunction%"===t)n=d("async function () {}");else if("%GeneratorFunction%"===t)n=d("function* () {}");else if("%AsyncGeneratorFunction%"===t)n=d("async function* () {}");else if("%AsyncGenerator%"===t){var r=e("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&O&&(n=O(i.prototype))}return A[t]=n,n}(r)),void 0===i&&!t)throw new c("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:n,name:r,value:i}}throw new a("intrinsic "+e+" does not exist!")};e.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new c("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new c('"allowMissing" argument must be a boolean');if(null===M(/^%?[^%]*%?$/,e))throw new a("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=P(e),r=n.length>0?n[0]:"",i=D("%"+r+"%",t),o=i.name,s=i.value,u=!1,l=i.alias;l&&(r=l[0],m(n,y([0,1],l)));for(var d=1,E=!0;d<n.length;d+=1){var f=n[d],p=I(f,0,1),_=I(f,-1);if(('"'===p||"'"===p||"`"===p||'"'===_||"'"===_||"`"===_)&&p!==_)throw new a("property names with quotes must have matching quotes");if("constructor"!==f&&E||(u=!0),v(A,o="%"+(r+="."+f)+"%"))s=A[o];else if(null!=s){if(!(f in s)){if(!t)throw new c("base intrinsic for "+e+" exists, but the property is not available.");return}if(h&&d+1>=n.length){var O=h(s,f);s=(E=!!O)&&"get"in O&&!("originalValue"in O.get)?O.get:s[f]}else E=v(s,f),s=s[f];E&&!u&&(A[o]=s)}}return s}},function(e,t,n){e.exports=function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};t[s][0].call(u.exports,(function(e){return i(t[s][1][e]||e)}),u,u.exports,e,t,n,r)}return n[s].exports}for(var o=!1,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}n.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var r in n)i(n,r)&&(e[r]=n[r])}}return e},n.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var o={arraySet:function(e,t,n,r,i){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+r),i);else for(var o=0;o<r;o++)e[i+o]=t[n+o]},flattenChunks:function(e){var t,n,r,i,o,s;for(r=0,t=0,n=e.length;t<n;t++)r+=e[t].length;for(s=new Uint8Array(r),i=0,t=0,n=e.length;t<n;t++)o=e[t],s.set(o,i),i+=o.length;return s}},s={arraySet:function(e,t,n,r,i){for(var o=0;o<r;o++)e[i+o]=t[n+o]},flattenChunks:function(e){return[].concat.apply([],e)}};n.setTyped=function(e){e?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,o)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,s))},n.setTyped(r)},{}],2:[function(e,t,n){"use strict";var r=e("./common"),i=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){o=!1}for(var s=new r.Buf8(256),a=0;a<256;a++)s[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;function c(e,t){if(t<65534&&(e.subarray&&o||!e.subarray&&i))return String.fromCharCode.apply(null,r.shrinkBuf(e,t));for(var n="",s=0;s<t;s++)n+=String.fromCharCode(e[s]);return n}s[254]=s[254]=1,n.string2buf=function(e){var t,n,i,o,s,a=e.length,c=0;for(o=0;o<a;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(i-56320),o++),c+=n<128?1:n<2048?2:n<65536?3:4;for(t=new r.Buf8(c),s=0,o=0;s<c;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(i-56320),o++),n<128?t[s++]=n:n<2048?(t[s++]=192|n>>>6,t[s++]=128|63&n):n<65536?(t[s++]=224|n>>>12,t[s++]=128|n>>>6&63,t[s++]=128|63&n):(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63,t[s++]=128|n>>>6&63,t[s++]=128|63&n);return t},n.buf2binstring=function(e){return c(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n<i;n++)t[n]=e.charCodeAt(n);return t},n.buf2string=function(e,t){var n,r,i,o,a=t||e.length,u=new Array(2*a);for(r=0,n=0;n<a;)if((i=e[n++])<128)u[r++]=i;else if((o=s[i])>4)u[r++]=65533,n+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&n<a;)i=i<<6|63&e[n++],o--;o>1?u[r++]=65533:i<65536?u[r++]=i:(i-=65536,u[r++]=55296|i>>10&1023,u[r++]=56320|1023&i)}return c(u,r)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+s[e[n]]>t?n:t}},{"./common":1}],3:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){for(var i=65535&e|0,o=e>>>16&65535|0,s=0;0!==n;){n-=s=n>2e3?2e3:n;do{o=o+(i=i+t[r++]|0)|0}while(--s);i%=65521,o%=65521}return i|o<<16|0}},{}],4:[function(e,t,n){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],5:[function(e,t,n){"use strict";var r=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var o=r,s=i+n;e^=-1;for(var a=i;a<s;a++)e=e>>>8^o[255&(e^t[a])];return-1^e}},{}],6:[function(e,t,n){"use strict";t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],7:[function(e,t,n){"use strict";t.exports=function(e,t){var n,r,i,o,s,a,c,u,l,d,h,E,f,p,_,O,S,g,A,N,T,C,v,y,m;n=e.state,r=e.next_in,y=e.input,i=r+(e.avail_in-5),o=e.next_out,m=e.output,s=o-(t-e.avail_out),a=o+(e.avail_out-257),c=n.dmax,u=n.wsize,l=n.whave,d=n.wnext,h=n.window,E=n.hold,f=n.bits,p=n.lencode,_=n.distcode,O=(1<<n.lenbits)-1,S=(1<<n.distbits)-1;e:do{f<15&&(E+=y[r++]<<f,f+=8,E+=y[r++]<<f,f+=8),g=p[E&O];t:for(;;){if(E>>>=A=g>>>24,f-=A,0==(A=g>>>16&255))m[o++]=65535&g;else{if(!(16&A)){if(0==(64&A)){g=p[(65535&g)+(E&(1<<A)-1)];continue t}if(32&A){n.mode=12;break e}e.msg="invalid literal/length code",n.mode=30;break e}N=65535&g,(A&=15)&&(f<A&&(E+=y[r++]<<f,f+=8),N+=E&(1<<A)-1,E>>>=A,f-=A),f<15&&(E+=y[r++]<<f,f+=8,E+=y[r++]<<f,f+=8),g=_[E&S];n:for(;;){if(E>>>=A=g>>>24,f-=A,!(16&(A=g>>>16&255))){if(0==(64&A)){g=_[(65535&g)+(E&(1<<A)-1)];continue n}e.msg="invalid distance code",n.mode=30;break e}if(T=65535&g,f<(A&=15)&&(E+=y[r++]<<f,(f+=8)<A&&(E+=y[r++]<<f,f+=8)),(T+=E&(1<<A)-1)>c){e.msg="invalid distance too far back",n.mode=30;break e}if(E>>>=A,f-=A,T>(A=o-s)){if((A=T-A)>l&&n.sane){e.msg="invalid distance too far back",n.mode=30;break e}if(C=0,v=h,0===d){if(C+=u-A,A<N){N-=A;do{m[o++]=h[C++]}while(--A);C=o-T,v=m}}else if(d<A){if(C+=u+d-A,(A-=d)<N){N-=A;do{m[o++]=h[C++]}while(--A);if(C=0,d<N){N-=A=d;do{m[o++]=h[C++]}while(--A);C=o-T,v=m}}}else if(C+=d-A,A<N){N-=A;do{m[o++]=h[C++]}while(--A);C=o-T,v=m}for(;N>2;)m[o++]=v[C++],m[o++]=v[C++],m[o++]=v[C++],N-=3;N&&(m[o++]=v[C++],N>1&&(m[o++]=v[C++]))}else{C=o-T;do{m[o++]=m[C++],m[o++]=m[C++],m[o++]=m[C++],N-=3}while(N>2);N&&(m[o++]=m[C++],N>1&&(m[o++]=m[C++]))}break}}break}}while(r<i&&o<a);r-=N=f>>3,E&=(1<<(f-=N<<3))-1,e.next_in=r,e.next_out=o,e.avail_in=r<i?i-r+5:5-(r-i),e.avail_out=o<a?a-o+257:257-(o-a),n.hold=E,n.bits=f}},{}],8:[function(e,t,n){"use strict";var r=e("../utils/common"),i=e("./adler32"),o=e("./crc32"),s=e("./inffast"),a=e("./inftrees");function c(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function u(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function l(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new r.Buf32(852),t.distcode=t.distdyn=new r.Buf32(592),t.sane=1,t.back=-1,0):-2}function d(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,l(e)):-2}function h(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?-2:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,d(e))):-2}function E(e,t){var n,r;return e?(r=new u,e.state=r,r.window=null,0!==(n=h(e,t))&&(e.state=null),n):-2}var f,p,_=!0;function O(e){if(_){var t;for(f=new r.Buf32(512),p=new r.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(a(1,e.lens,0,288,f,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(2,e.lens,0,32,p,0,e.work,{bits:5}),_=!1}e.lencode=f,e.lenbits=9,e.distcode=p,e.distbits=5}function S(e,t,n,i){var o,s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new r.Buf8(s.wsize)),i>=s.wsize?(r.arraySet(s.window,t,n-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):((o=s.wsize-s.wnext)>i&&(o=i),r.arraySet(s.window,t,n-i,o,s.wnext),(i-=o)?(r.arraySet(s.window,t,n-i,i,0),s.wnext=i,s.whave=s.wsize):(s.wnext+=o,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=o))),0}n.inflateReset=d,n.inflateReset2=h,n.inflateResetKeep=l,n.inflateInit=function(e){return E(e,15)},n.inflateInit2=E,n.inflate=function(e,t){var n,u,l,d,h,E,f,p,_,g,A,N,T,C,v,y,m,b,I,M,R,L,P,D,w=0,U=new r.Buf8(4),j=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return-2;12===(n=e.state).mode&&(n.mode=13),h=e.next_out,l=e.output,f=e.avail_out,d=e.next_in,u=e.input,E=e.avail_in,p=n.hold,_=n.bits,g=E,A=f,L=0;e:for(;;)switch(n.mode){case 1:if(0===n.wrap){n.mode=13;break}for(;_<16;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(2&n.wrap&&35615===p){n.check=0,U[0]=255&p,U[1]=p>>>8&255,n.check=o(n.check,U,2,0),p=0,_=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&p)<<8)+(p>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&p)){e.msg="unknown compression method",n.mode=30;break}if(_-=4,R=8+(15&(p>>>=4)),0===n.wbits)n.wbits=R;else if(R>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<<R,e.adler=n.check=1,n.mode=512&p?10:12,p=0,_=0;break;case 2:for(;_<16;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(n.flags=p,8!=(255&n.flags)){e.msg="unknown compression method",n.mode=30;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=30;break}n.head&&(n.head.text=p>>8&1),512&n.flags&&(U[0]=255&p,U[1]=p>>>8&255,n.check=o(n.check,U,2,0)),p=0,_=0,n.mode=3;case 3:for(;_<32;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}n.head&&(n.head.time=p),512&n.flags&&(U[0]=255&p,U[1]=p>>>8&255,U[2]=p>>>16&255,U[3]=p>>>24&255,n.check=o(n.check,U,4,0)),p=0,_=0,n.mode=4;case 4:for(;_<16;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}n.head&&(n.head.xflags=255&p,n.head.os=p>>8),512&n.flags&&(U[0]=255&p,U[1]=p>>>8&255,n.check=o(n.check,U,2,0)),p=0,_=0,n.mode=5;case 5:if(1024&n.flags){for(;_<16;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}n.length=p,n.head&&(n.head.extra_len=p),512&n.flags&&(U[0]=255&p,U[1]=p>>>8&255,n.check=o(n.check,U,2,0)),p=0,_=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&((N=n.length)>E&&(N=E),N&&(n.head&&(R=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),r.arraySet(n.head.extra,u,d,N,R)),512&n.flags&&(n.check=o(n.check,u,N,d)),E-=N,d+=N,n.length-=N),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===E)break e;N=0;do{R=u[d+N++],n.head&&R&&n.length<65536&&(n.head.name+=String.fromCharCode(R))}while(R&&N<E);if(512&n.flags&&(n.check=o(n.check,u,N,d)),E-=N,d+=N,R)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=8;case 8:if(4096&n.flags){if(0===E)break e;N=0;do{R=u[d+N++],n.head&&R&&n.length<65536&&(n.head.comment+=String.fromCharCode(R))}while(R&&N<E);if(512&n.flags&&(n.check=o(n.check,u,N,d)),E-=N,d+=N,R)break e}else n.head&&(n.head.comment=null);n.mode=9;case 9:if(512&n.flags){for(;_<16;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(p!==(65535&n.check)){e.msg="header crc mismatch",n.mode=30;break}p=0,_=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;_<32;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}e.adler=n.check=c(p),p=0,_=0,n.mode=11;case 11:if(0===n.havedict)return e.next_out=h,e.avail_out=f,e.next_in=d,e.avail_in=E,n.hold=p,n.bits=_,2;e.adler=n.check=1,n.mode=12;case 12:if(5===t||6===t)break e;case 13:if(n.last){p>>>=7&_,_-=7&_,n.mode=27;break}for(;_<3;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}switch(n.last=1&p,_-=1,3&(p>>>=1)){case 0:n.mode=14;break;case 1:if(O(n),n.mode=20,6===t){p>>>=2,_-=2;break e}break;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}p>>>=2,_-=2;break;case 14:for(p>>>=7&_,_-=7&_;_<32;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if((65535&p)!=(p>>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&p,p=0,_=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(N=n.length){if(N>E&&(N=E),N>f&&(N=f),0===N)break e;r.arraySet(l,u,d,N,h),E-=N,d+=N,f-=N,h+=N,n.length-=N;break}n.mode=12;break;case 17:for(;_<14;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(n.nlen=257+(31&p),p>>>=5,_-=5,n.ndist=1+(31&p),p>>>=5,_-=5,n.ncode=4+(15&p),p>>>=4,_-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=30;break}n.have=0,n.mode=18;case 18:for(;n.have<n.ncode;){for(;_<3;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}n.lens[j[n.have++]]=7&p,p>>>=3,_-=3}for(;n.have<19;)n.lens[j[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,P={bits:n.lenbits},L=a(0,n.lens,0,19,n.lencode,0,n.work,P),n.lenbits=P.bits,L){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have<n.nlen+n.ndist;){for(;y=(w=n.lencode[p&(1<<n.lenbits)-1])>>>16&255,m=65535&w,!((v=w>>>24)<=_);){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(m<16)p>>>=v,_-=v,n.lens[n.have++]=m;else{if(16===m){for(D=v+2;_<D;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(p>>>=v,_-=v,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}R=n.lens[n.have-1],N=3+(3&p),p>>>=2,_-=2}else if(17===m){for(D=v+3;_<D;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}_-=v,R=0,N=3+(7&(p>>>=v)),p>>>=3,_-=3}else{for(D=v+7;_<D;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}_-=v,R=0,N=11+(127&(p>>>=v)),p>>>=7,_-=7}if(n.have+N>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;N--;)n.lens[n.have++]=R}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,P={bits:n.lenbits},L=a(1,n.lens,0,n.nlen,n.lencode,0,n.work,P),n.lenbits=P.bits,L){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,P={bits:n.distbits},L=a(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,P),n.distbits=P.bits,L){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(E>=6&&f>=258){e.next_out=h,e.avail_out=f,e.next_in=d,e.avail_in=E,n.hold=p,n.bits=_,s(e,A),h=e.next_out,l=e.output,f=e.avail_out,d=e.next_in,u=e.input,E=e.avail_in,p=n.hold,_=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;y=(w=n.lencode[p&(1<<n.lenbits)-1])>>>16&255,m=65535&w,!((v=w>>>24)<=_);){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(y&&0==(240&y)){for(b=v,I=y,M=m;y=(w=n.lencode[M+((p&(1<<b+I)-1)>>b)])>>>16&255,m=65535&w,!(b+(v=w>>>24)<=_);){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}p>>>=b,_-=b,n.back+=b}if(p>>>=v,_-=v,n.back+=v,n.length=m,0===y){n.mode=26;break}if(32&y){n.back=-1,n.mode=12;break}if(64&y){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&y,n.mode=22;case 22:if(n.extra){for(D=n.extra;_<D;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}n.length+=p&(1<<n.extra)-1,p>>>=n.extra,_-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;y=(w=n.distcode[p&(1<<n.distbits)-1])>>>16&255,m=65535&w,!((v=w>>>24)<=_);){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(0==(240&y)){for(b=v,I=y,M=m;y=(w=n.distcode[M+((p&(1<<b+I)-1)>>b)])>>>16&255,m=65535&w,!(b+(v=w>>>24)<=_);){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}p>>>=b,_-=b,n.back+=b}if(p>>>=v,_-=v,n.back+=v,64&y){e.msg="invalid distance code",n.mode=30;break}n.offset=m,n.extra=15&y,n.mode=24;case 24:if(n.extra){for(D=n.extra;_<D;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}n.offset+=p&(1<<n.extra)-1,p>>>=n.extra,_-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===f)break e;if(N=A-f,n.offset>N){if((N=n.offset-N)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}N>n.wnext?(N-=n.wnext,T=n.wsize-N):T=n.wnext-N,N>n.length&&(N=n.length),C=n.window}else C=l,T=h-n.offset,N=n.length;N>f&&(N=f),f-=N,n.length-=N;do{l[h++]=C[T++]}while(--N);0===n.length&&(n.mode=21);break;case 26:if(0===f)break e;l[h++]=n.length,f--,n.mode=21;break;case 27:if(n.wrap){for(;_<32;){if(0===E)break e;E--,p|=u[d++]<<_,_+=8}if(A-=f,e.total_out+=A,n.total+=A,A&&(e.adler=n.check=n.flags?o(n.check,l,A,h-A):i(n.check,l,A,h-A)),A=f,(n.flags?p:c(p))!==n.check){e.msg="incorrect data check",n.mode=30;break}p=0,_=0}n.mode=28;case 28:if(n.wrap&&n.flags){for(;_<32;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(p!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=30;break}p=0,_=0}n.mode=29;case 29:L=1;break e;case 30:L=-3;break e;case 31:return-4;case 32:default:return-2}return e.next_out=h,e.avail_out=f,e.next_in=d,e.avail_in=E,n.hold=p,n.bits=_,(n.wsize||A!==e.avail_out&&n.mode<30&&(n.mode<27||4!==t))&&S(e,e.output,e.next_out,A-e.avail_out)?(n.mode=31,-4):(g-=e.avail_in,A-=e.avail_out,e.total_in+=g,e.total_out+=A,n.total+=A,n.wrap&&A&&(e.adler=n.check=n.flags?o(n.check,l,A,e.next_out-A):i(n.check,l,A,e.next_out-A)),e.data_type=n.bits+(n.last?64:0)+(12===n.mode?128:0)+(20===n.mode||15===n.mode?256:0),(0===g&&0===A||4===t)&&0===L&&(L=-5),L)},n.inflateEnd=function(e){if(!e||!e.state)return-2;var t=e.state;return t.window&&(t.window=null),e.state=null,0},n.inflateGetHeader=function(e,t){var n;return e&&e.state?0==(2&(n=e.state).wrap)?-2:(n.head=t,t.done=!1,0):-2},n.inflateSetDictionary=function(e,t){var n,r=t.length;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?-2:11===n.mode&&i(1,t,r,0)!==n.check?-3:S(e,t,r,r)?(n.mode=31,-4):(n.havedict=1,0):-2},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":5,"./inffast":7,"./inftrees":9}],9:[function(e,t,n){"use strict";var r=e("../utils/common"),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],s=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],a=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,n,c,u,l,d,h){var E,f,p,_,O,S,g,A,N,T=h.bits,C=0,v=0,y=0,m=0,b=0,I=0,M=0,R=0,L=0,P=0,D=null,w=0,U=new r.Buf16(16),j=new r.Buf16(16),F=null,k=0;for(C=0;C<=15;C++)U[C]=0;for(v=0;v<c;v++)U[t[n+v]]++;for(b=T,m=15;m>=1&&0===U[m];m--);if(b>m&&(b=m),0===m)return u[l++]=20971520,u[l++]=20971520,h.bits=1,0;for(y=1;y<m&&0===U[y];y++);for(b<y&&(b=y),R=1,C=1;C<=15;C++)if(R<<=1,(R-=U[C])<0)return-1;if(R>0&&(0===e||1!==m))return-1;for(j[1]=0,C=1;C<15;C++)j[C+1]=j[C]+U[C];for(v=0;v<c;v++)0!==t[n+v]&&(d[j[t[n+v]]++]=v);if(0===e?(D=F=d,S=19):1===e?(D=i,w-=257,F=o,k-=257,S=256):(D=s,F=a,S=-1),P=0,v=0,C=y,O=l,I=b,M=0,p=-1,_=(L=1<<b)-1,1===e&&L>852||2===e&&L>592)return 1;for(;;){g=C-M,d[v]<S?(A=0,N=d[v]):d[v]>S?(A=F[k+d[v]],N=D[w+d[v]]):(A=96,N=0),E=1<<C-M,y=f=1<<I;do{u[O+(P>>M)+(f-=E)]=g<<24|A<<16|N|0}while(0!==f);for(E=1<<C-1;P&E;)E>>=1;if(0!==E?(P&=E-1,P+=E):P=0,v++,0==--U[C]){if(C===m)break;C=t[n+d[v]]}if(C>b&&(P&_)!==p){for(0===M&&(M=b),O+=y,R=1<<(I=C-M);I+M<m&&!((R-=U[I+M])<=0);)I++,R<<=1;if(L+=1<<I,1===e&&L>852||2===e&&L>592)return 1;u[p=P&_]=b<<24|I<<16|O-l|0}}return 0!==P&&(u[O+P]=C-M<<24|64<<16|0),h.bits=b,0}},{"../utils/common":1}],10:[function(e,t,n){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],11:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],"/lib/inflate.js":[function(e,t,n){"use strict";var r=e("./zlib/inflate"),i=e("./utils/common"),o=e("./utils/strings"),s=e("./zlib/constants"),a=e("./zlib/messages"),c=e("./zlib/zstream"),u=e("./zlib/gzheader"),l=Object.prototype.toString;function d(e){if(!(this instanceof d))return new d(e);this.options=i.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var n=r.inflateInit2(this.strm,t.windowBits);if(n!==s.Z_OK)throw new Error(a[n]);if(this.header=new u,r.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=o.string2buf(t.dictionary):"[object ArrayBuffer]"===l.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=r.inflateSetDictionary(this.strm,t.dictionary))!==s.Z_OK))throw new Error(a[n])}function h(e,t){var n=new d(t);if(n.push(e,!0),n.err)throw n.msg||a[n.err];return n.result}d.prototype.push=function(e,t){var n,a,c,u,d,h=this.strm,E=this.options.chunkSize,f=this.options.dictionary,p=!1;if(this.ended)return!1;a=t===~~t?t:!0===t?s.Z_FINISH:s.Z_NO_FLUSH,"string"==typeof e?h.input=o.binstring2buf(e):"[object ArrayBuffer]"===l.call(e)?h.input=new Uint8Array(e):h.input=e,h.next_in=0,h.avail_in=h.input.length;do{if(0===h.avail_out&&(h.output=new i.Buf8(E),h.next_out=0,h.avail_out=E),(n=r.inflate(h,s.Z_NO_FLUSH))===s.Z_NEED_DICT&&f&&(n=r.inflateSetDictionary(this.strm,f)),n===s.Z_BUF_ERROR&&!0===p&&(n=s.Z_OK,p=!1),n!==s.Z_STREAM_END&&n!==s.Z_OK)return this.onEnd(n),this.ended=!0,!1;h.next_out&&(0!==h.avail_out&&n!==s.Z_STREAM_END&&(0!==h.avail_in||a!==s.Z_FINISH&&a!==s.Z_SYNC_FLUSH)||("string"===this.options.to?(c=o.utf8border(h.output,h.next_out),u=h.next_out-c,d=o.buf2string(h.output,c),h.next_out=u,h.avail_out=E-u,u&&i.arraySet(h.output,h.output,c,u,0),this.onData(d)):this.onData(i.shrinkBuf(h.output,h.next_out)))),0===h.avail_in&&0===h.avail_out&&(p=!0)}while((h.avail_in>0||0===h.avail_out)&&n!==s.Z_STREAM_END);return n===s.Z_STREAM_END&&(a=s.Z_FINISH),a===s.Z_FINISH?(n=r.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===s.Z_OK):a!==s.Z_SYNC_FLUSH||(this.onEnd(s.Z_OK),h.avail_out=0,!0)},d.prototype.onData=function(e){this.chunks.push(e)},d.prototype.onEnd=function(e){e===s.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Inflate=d,n.inflate=h,n.inflateRaw=function(e,t){return(t=t||{}).raw=!0,h(e,t)},n.ungzip=h},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")},function(e,t){e.exports=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.circularDependencyToException=t.listMetadataForTarget=t.listRegisteredBindingsForServiceIdentifier=t.getServiceIdentifierAsString=t.getFunctionName=void 0;var r=n(8);function i(e){return"function"==typeof e?e.name:"symbol"==typeof e?e.toString():e}function o(e){if(e.name)return e.name;var t=e.toString(),n=t.match(/^function\s*([^\s(]+)/);return n?n[1]:"Anonymous function: "+t}t.getServiceIdentifierAsString=i,t.listRegisteredBindingsForServiceIdentifier=function(e,t,n){var r="",i=n(e,t);return 0!==i.length&&(r="\nRegistered bindings:",i.forEach((function(e){var t="Object";null!==e.implementationType&&(t=o(e.implementationType)),r=r+"\n "+t,e.constraint.metaData&&(r=r+" - "+e.constraint.metaData)}))),r},t.circularDependencyToException=function e(t){t.childRequests.forEach((function(t){if(function e(t,n){return null!==t.parentRequest&&(t.parentRequest.serviceIdentifier===n||e(t.parentRequest,n))}(t,t.serviceIdentifier)){var n=function(e){return function e(t,n){void 0===n&&(n=[]);var r=i(t.serviceIdentifier);return n.push(r),null!==t.parentRequest?e(t.parentRequest,n):n}(e).reverse().join(" --\x3e ")}(t);throw new Error(r.CIRCULAR_DEPENDENCY+" "+n)}e(t)}))},t.listMetadataForTarget=function(e,t){if(t.isTagged()||t.isNamed()){var n="",r=t.getNamedTag(),i=t.getCustomTags();return null!==r&&(n+=r.toString()+"\n"),null!==i&&i.forEach((function(e){n+=e.toString()+"\n"}))," "+e+"\n "+e+" - "+n}return" "+e},t.getFunctionName=o},function(e,t,n){"use strict";e.exports=TypeError},function(e,t){e.exports=c},function(e,t){e.exports=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingOnSyntax=void 0;var r=n(28),i=function(){function e(e){this._binding=e}return e.prototype.onActivation=function(e){return this._binding.onActivation=e,new r.BindingWhenSyntax(this._binding)},e}();t.BindingOnSyntax=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingWhenSyntax=void 0;var r=n(27),i=n(40),o=function(){function e(e){this._binding=e}return e.prototype.when=function(e){return this._binding.constraint=e,new r.BindingOnSyntax(this._binding)},e.prototype.whenTargetNamed=function(e){return this._binding.constraint=i.namedConstraint(e),new r.BindingOnSyntax(this._binding)},e.prototype.whenTargetIsDefault=function(){return this._binding.constraint=function(e){return null!==e.target&&!e.target.isNamed()&&!e.target.isTagged()},new r.BindingOnSyntax(this._binding)},e.prototype.whenTargetTagged=function(e,t){return this._binding.constraint=i.taggedConstraint(e)(t),new r.BindingOnSyntax(this._binding)},e.prototype.whenInjectedInto=function(e){return this._binding.constraint=function(t){return i.typeConstraint(e)(t.parentRequest)},new r.BindingOnSyntax(this._binding)},e.prototype.whenParentNamed=function(e){return this._binding.constraint=function(t){return i.namedConstraint(e)(t.parentRequest)},new r.BindingOnSyntax(this._binding)},e.prototype.whenParentTagged=function(e,t){return this._binding.constraint=function(n){return i.taggedConstraint(e)(t)(n.parentRequest)},new r.BindingOnSyntax(this._binding)},e.prototype.whenAnyAncestorIs=function(e){return this._binding.constraint=function(t){return i.traverseAncerstors(t,i.typeConstraint(e))},new r.BindingOnSyntax(this._binding)},e.prototype.whenNoAncestorIs=function(e){return this._binding.constraint=function(t){return!i.traverseAncerstors(t,i.typeConstraint(e))},new r.BindingOnSyntax(this._binding)},e.prototype.whenAnyAncestorNamed=function(e){return this._binding.constraint=function(t){return i.traverseAncerstors(t,i.namedConstraint(e))},new r.BindingOnSyntax(this._binding)},e.prototype.whenNoAncestorNamed=function(e){return this._binding.constraint=function(t){return!i.traverseAncerstors(t,i.namedConstraint(e))},new r.BindingOnSyntax(this._binding)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._binding.constraint=function(n){return i.traverseAncerstors(n,i.taggedConstraint(e)(t))},new r.BindingOnSyntax(this._binding)},e.prototype.whenNoAncestorTagged=function(e,t){return this._binding.constraint=function(n){return!i.traverseAncerstors(n,i.taggedConstraint(e)(t))},new r.BindingOnSyntax(this._binding)},e.prototype.whenAnyAncestorMatches=function(e){return this._binding.constraint=function(t){return i.traverseAncerstors(t,e)},new r.BindingOnSyntax(this._binding)},e.prototype.whenNoAncestorMatches=function(e){return this._binding.constraint=function(t){return!i.traverseAncerstors(t,e)},new r.BindingOnSyntax(this._binding)},e}();t.BindingWhenSyntax=o},function(e,t,n){"use strict";var r=n(89);e.exports=Function.prototype.bind||r},function(e,t,n){"use strict";var r=n(20)("%Object.defineProperty%",!0)||!1;if(r)try{r({},"a",{value:1})}catch(e){r=!1}e.exports=r},function(e,t,n){"use strict";var r=String.prototype.replace,i=/%20/g,o="RFC1738",s="RFC3986";e.exports={default:s,formatters:{RFC1738:function(e){return r.call(e,i,"+")},RFC3986:function(e){return String(e)}},RFC1738:o,RFC3986:s}},function(e,t){e.exports=l},function(e,t){e.exports=d},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataReader=void 0;var r=n(5),i=function(){function e(){}return e.prototype.getConstructorMetadata=function(e){return{compilerGeneratedMetadata:Reflect.getMetadata(r.PARAM_TYPES,e),userGeneratedMetadata:Reflect.getMetadata(r.TAGGED,e)||{}}},e.prototype.getPropertiesMetadata=function(e){return Reflect.getMetadata(r.TAGGED_PROP,e)||[]},e}();t.MetadataReader=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isStackOverflowExeption=void 0;var r=n(8);t.isStackOverflowExeption=function(e){return e instanceof RangeError||e.message===r.STACK_OVERFLOW}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inject=t.LazyServiceIdentifer=void 0;var r=n(8),i=n(5),o=n(10),s=n(15),a=function(){function e(e){this._cb=e}return e.prototype.unwrap=function(){return this._cb()},e}();t.LazyServiceIdentifer=a,t.inject=function(e){return function(t,n,a){if(void 0===e)throw new Error(r.UNDEFINED_INJECT_ANNOTATION(t.name));var c=new o.Metadata(i.INJECT_TAG,e);"number"==typeof a?s.tagParameter(t,n,a,c):s.tagProperty(t,n,c)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Target=void 0;var r=n(5),i=n(19),o=n(10),s=n(60),a=function(){function e(e,t,n,a){this.id=i.id(),this.type=e,this.serviceIdentifier=n,this.name=new s.QueryableString(t||""),this.metadata=new Array;var c=null;"string"==typeof a?c=new o.Metadata(r.NAMED_TAG,a):a instanceof o.Metadata&&(c=a),null!==c&&this.metadata.push(c)}return e.prototype.hasTag=function(e){for(var t=0,n=this.metadata;t<n.length;t++){if(n[t].key===e)return!0}return!1},e.prototype.isArray=function(){return this.hasTag(r.MULTI_INJECT_TAG)},e.prototype.matchesArray=function(e){return this.matchesTag(r.MULTI_INJECT_TAG)(e)},e.prototype.isNamed=function(){return this.hasTag(r.NAMED_TAG)},e.prototype.isTagged=function(){return this.metadata.some((function(e){return r.NON_CUSTOM_TAG_KEYS.every((function(t){return e.key!==t}))}))},e.prototype.isOptional=function(){return this.matchesTag(r.OPTIONAL_TAG)(!0)},e.prototype.getNamedTag=function(){return this.isNamed()?this.metadata.filter((function(e){return e.key===r.NAMED_TAG}))[0]:null},e.prototype.getCustomTags=function(){return this.isTagged()?this.metadata.filter((function(e){return r.NON_CUSTOM_TAG_KEYS.every((function(t){return e.key!==t}))})):null},e.prototype.matchesNamedTag=function(e){return this.matchesTag(r.NAMED_TAG)(e)},e.prototype.matchesTag=function(e){var t=this;return function(n){for(var r=0,i=t.metadata;r<i.length;r++){var o=i[r];if(o.key===e&&o.value===n)return!0}return!1}},e}();t.Target=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingWhenOnSyntax=void 0;var r=n(27),i=n(28),o=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new i.BindingWhenSyntax(this._binding),this._bindingOnSyntax=new r.BindingOnSyntax(this._binding)}return e.prototype.when=function(e){return this._bindingWhenSyntax.when(e)},e.prototype.whenTargetNamed=function(e){return this._bindingWhenSyntax.whenTargetNamed(e)},e.prototype.whenTargetIsDefault=function(){return this._bindingWhenSyntax.whenTargetIsDefault()},e.prototype.whenTargetTagged=function(e,t){return this._bindingWhenSyntax.whenTargetTagged(e,t)},e.prototype.whenInjectedInto=function(e){return this._bindingWhenSyntax.whenInjectedInto(e)},e.prototype.whenParentNamed=function(e){return this._bindingWhenSyntax.whenParentNamed(e)},e.prototype.whenParentTagged=function(e,t){return this._bindingWhenSyntax.whenParentTagged(e,t)},e.prototype.whenAnyAncestorIs=function(e){return this._bindingWhenSyntax.whenAnyAncestorIs(e)},e.prototype.whenNoAncestorIs=function(e){return this._bindingWhenSyntax.whenNoAncestorIs(e)},e.prototype.whenAnyAncestorNamed=function(e){return this._bindingWhenSyntax.whenAnyAncestorNamed(e)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenAnyAncestorTagged(e,t)},e.prototype.whenNoAncestorNamed=function(e){return this._bindingWhenSyntax.whenNoAncestorNamed(e)},e.prototype.whenNoAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenNoAncestorTagged(e,t)},e.prototype.whenAnyAncestorMatches=function(e){return this._bindingWhenSyntax.whenAnyAncestorMatches(e)},e.prototype.whenNoAncestorMatches=function(e){return this._bindingWhenSyntax.whenNoAncestorMatches(e)},e.prototype.onActivation=function(e){return this._bindingOnSyntax.onActivation(e)},e}();t.BindingWhenOnSyntax=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.typeConstraint=t.namedConstraint=t.taggedConstraint=t.traverseAncerstors=void 0;var r=n(5),i=n(10),o=function(e,t){var n=e.parentRequest;return null!==n&&(!!t(n)||o(n,t))};t.traverseAncerstors=o;var s=function(e){return function(t){var n=function(n){return null!==n&&null!==n.target&&n.target.matchesTag(e)(t)};return n.metaData=new i.Metadata(e,t),n}};t.taggedConstraint=s;var a=s(r.NAMED_TAG);t.namedConstraint=a;t.typeConstraint=function(e){return function(t){var n=null;if(null!==t){if(n=t.bindings[0],"string"==typeof e)return n.serviceIdentifier===e;var r=t.bindings[0].implementationType;return e===r}return!1}}},function(e,t,n){"use strict";e.exports=SyntaxError},function(e,t,n){"use strict";var r=n(20)("%Object.getOwnPropertyDescriptor%",!0);if(r)try{r([],"length")}catch(e){r=null}e.exports=r},function(e,t,n){"use strict";var r=n(31),i=Object.prototype.hasOwnProperty,o=Array.isArray,s=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),a=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r<e.length;++r)void 0!==e[r]&&(n[r]=e[r]);return n};e.exports={arrayToObject:a,assign:function(e,t){return Object.keys(t).reduce((function(e,n){return e[n]=t[n],e}),e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],n=[],r=0;r<t.length;++r)for(var i=t[r],s=i.obj[i.prop],a=Object.keys(s),c=0;c<a.length;++c){var u=a[c],l=s[u];"object"==typeof l&&null!==l&&-1===n.indexOf(l)&&(t.push({obj:s,prop:u}),n.push(l))}return function(e){for(;e.length>1;){var t=e.pop(),n=t.obj[t.prop];if(o(n)){for(var r=[],i=0;i<n.length;++i)void 0!==n[i]&&r.push(n[i]);t.obj[t.prop]=r}}}(t),e},decode:function(e,t,n){var r=e.replace(/\+/g," ");if("iso-8859-1"===n)return r.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(r)}catch(e){return r}},encode:function(e,t,n,i,o){if(0===e.length)return e;var a=e;if("symbol"==typeof e?a=Symbol.prototype.toString.call(e):"string"!=typeof e&&(a=String(e)),"iso-8859-1"===n)return escape(a).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var c="",u=0;u<a.length;u+=1024){for(var l=a.length>=1024?a.slice(u,u+1024):a,d=[],h=0;h<l.length;++h){var E=l.charCodeAt(h);45===E||46===E||95===E||126===E||E>=48&&E<=57||E>=65&&E<=90||E>=97&&E<=122||o===r.RFC1738&&(40===E||41===E)?d[d.length]=l.charAt(h):E<128?d[d.length]=s[E]:E<2048?d[d.length]=s[192|E>>6]+s[128|63&E]:E<55296||E>=57344?d[d.length]=s[224|E>>12]+s[128|E>>6&63]+s[128|63&E]:(h+=1,E=65536+((1023&E)<<10|1023&l.charCodeAt(h)),d[d.length]=s[240|E>>18]+s[128|E>>12&63]+s[128|E>>6&63]+s[128|63&E])}c+=d.join("")}return c},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(o(e)){for(var n=[],r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)},merge:function e(t,n,r){if(!n)return t;if("object"!=typeof n){if(o(t))t.push(n);else{if(!t||"object"!=typeof t)return[t,n];(r&&(r.plainObjects||r.allowPrototypes)||!i.call(Object.prototype,n))&&(t[n]=!0)}return t}if(!t||"object"!=typeof t)return[t].concat(n);var s=t;return o(t)&&!o(n)&&(s=a(t,r)),o(t)&&o(n)?(n.forEach((function(n,o){if(i.call(t,o)){var s=t[o];s&&"object"==typeof s&&n&&"object"==typeof n?t[o]=e(s,n,r):t.push(n)}else t[o]=n})),t):Object.keys(n).reduce((function(t,o){var s=n[o];return i.call(t,o)?t[o]=e(t[o],s,r):t[o]=s,t}),s)}}},function(e,t,n){var r;e.exports=(r=r||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),r={},i=r.lib={},o=i.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},s=i.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var o=0;o<i;o++){var s=n[o>>>2]>>>24-o%4*8&255;t[r+o>>>2]|=s<<24-(r+o)%4*8}else for(o=0;o<i;o+=4)t[r+o>>>2]=n[o>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,r=[],i=function(t){t=t;var n=987654321,r=4294967295;return function(){var i=((n=36969*(65535&n)+(n>>16)&r)<<16)+(t=18e3*(65535&t)+(t>>16)&r)&r;return i/=4294967296,(i+=.5)*(e.random()>.5?1:-1)}},o=0;o<t;o+=4){var a=i(4294967296*(n||e.random()));n=987654071*a(),r.push(4294967296*a()|0)}return new s.init(r,t)}}),a=r.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},d=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,u=e.min(4*c,i);if(c){for(var l=0;l<c;l+=o)this._doProcessBlock(r,l);var d=r.splice(0,c);n.sigBytes-=u}return new s.init(d,u)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),h=(i.Hasher=d.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new h.HMAC.init(e,n).finalize(t)}}}),r.algo={});return r}(Math),r)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(11);function i(e,t,n){for(var i=n||r.defaultEquals,o=e.length,s=0;s<o;s++)if(i(e[s],t))return s;return-1}t.indexOf=i,t.lastIndexOf=function(e,t,n){for(var i=n||r.defaultEquals,o=e.length-1;o>=0;o--)if(i(e[o],t))return o;return-1},t.contains=function(e,t,n){return i(e,t,n)>=0},t.remove=function(e,t,n){var r=i(e,t,n);return!(r<0)&&(e.splice(r,1),!0)},t.frequency=function(e,t,n){for(var i=n||r.defaultEquals,o=e.length,s=0,a=0;a<o;a++)i(e[a],t)&&s++;return s},t.equals=function(e,t,n){var i=n||r.defaultEquals;if(e.length!==t.length)return!1;for(var o=e.length,s=0;s<o;s++)if(!i(e[s],t[s]))return!1;return!0},t.copy=function(e){return e.concat()},t.swap=function(e,t,n){if(t<0||t>=e.length||n<0||n>=e.length)return!1;var r=e[t];return e[t]=e[n],e[n]=r,!0},t.toString=function(e){return"["+e.toString()+"]"},t.forEach=function(e,t){for(var n=0,r=e;n<r.length;n++){if(!1===t(r[n]))return}}},function(e,t,n){var r=n(99),i=n(100);e.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[o+a]=s[a];return t||i(s)}},function(e,t,n){var r;e.exports=(r=n(44),function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,s=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=s.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var r=t+n,i=e[r];e[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,s=e[t+0],c=e[t+1],E=e[t+2],f=e[t+3],p=e[t+4],_=e[t+5],O=e[t+6],S=e[t+7],g=e[t+8],A=e[t+9],N=e[t+10],T=e[t+11],C=e[t+12],v=e[t+13],y=e[t+14],m=e[t+15],b=o[0],I=o[1],M=o[2],R=o[3];b=u(b,I,M,R,s,7,a[0]),R=u(R,b,I,M,c,12,a[1]),M=u(M,R,b,I,E,17,a[2]),I=u(I,M,R,b,f,22,a[3]),b=u(b,I,M,R,p,7,a[4]),R=u(R,b,I,M,_,12,a[5]),M=u(M,R,b,I,O,17,a[6]),I=u(I,M,R,b,S,22,a[7]),b=u(b,I,M,R,g,7,a[8]),R=u(R,b,I,M,A,12,a[9]),M=u(M,R,b,I,N,17,a[10]),I=u(I,M,R,b,T,22,a[11]),b=u(b,I,M,R,C,7,a[12]),R=u(R,b,I,M,v,12,a[13]),M=u(M,R,b,I,y,17,a[14]),b=l(b,I=u(I,M,R,b,m,22,a[15]),M,R,c,5,a[16]),R=l(R,b,I,M,O,9,a[17]),M=l(M,R,b,I,T,14,a[18]),I=l(I,M,R,b,s,20,a[19]),b=l(b,I,M,R,_,5,a[20]),R=l(R,b,I,M,N,9,a[21]),M=l(M,R,b,I,m,14,a[22]),I=l(I,M,R,b,p,20,a[23]),b=l(b,I,M,R,A,5,a[24]),R=l(R,b,I,M,y,9,a[25]),M=l(M,R,b,I,f,14,a[26]),I=l(I,M,R,b,g,20,a[27]),b=l(b,I,M,R,v,5,a[28]),R=l(R,b,I,M,E,9,a[29]),M=l(M,R,b,I,S,14,a[30]),b=d(b,I=l(I,M,R,b,C,20,a[31]),M,R,_,4,a[32]),R=d(R,b,I,M,g,11,a[33]),M=d(M,R,b,I,T,16,a[34]),I=d(I,M,R,b,y,23,a[35]),b=d(b,I,M,R,c,4,a[36]),R=d(R,b,I,M,p,11,a[37]),M=d(M,R,b,I,S,16,a[38]),I=d(I,M,R,b,N,23,a[39]),b=d(b,I,M,R,v,4,a[40]),R=d(R,b,I,M,s,11,a[41]),M=d(M,R,b,I,f,16,a[42]),I=d(I,M,R,b,O,23,a[43]),b=d(b,I,M,R,A,4,a[44]),R=d(R,b,I,M,C,11,a[45]),M=d(M,R,b,I,m,16,a[46]),b=h(b,I=d(I,M,R,b,E,23,a[47]),M,R,s,6,a[48]),R=h(R,b,I,M,S,10,a[49]),M=h(M,R,b,I,y,15,a[50]),I=h(I,M,R,b,_,21,a[51]),b=h(b,I,M,R,C,6,a[52]),R=h(R,b,I,M,f,10,a[53]),M=h(M,R,b,I,N,15,a[54]),I=h(I,M,R,b,c,21,a[55]),b=h(b,I,M,R,g,6,a[56]),R=h(R,b,I,M,m,10,a[57]),M=h(M,R,b,I,O,15,a[58]),I=h(I,M,R,b,v,21,a[59]),b=h(b,I,M,R,p,6,a[60]),R=h(R,b,I,M,T,10,a[61]),M=h(M,R,b,I,E,15,a[62]),I=h(I,M,R,b,A,21,a[63]),o[0]=o[0]+b|0,o[1]=o[1]+I|0,o[2]=o[2]+M|0,o[3]=o[3]+R|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var o=e.floor(r/4294967296),s=r;n[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,r,i,o,s){var a=e+(t&n|~t&r)+i+s;return(a<<o|a>>>32-o)+t}function l(e,t,n,r,i,o,s){var a=e+(t&r|n&~r)+i+s;return(a<<o|a>>>32-o)+t}function d(e,t,n,r,i,o,s){var a=e+(t^n^r)+i+s;return(a<<o|a>>>32-o)+t}function h(e,t,n,r,i,o,s){var a=e+(n^(t|~r))+i+s;return(a<<o|a>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),r.MD5)},function(e,t){e.exports=h},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(102),i=function(){function e(){this.list=new r.default}return e.prototype.enqueue=function(e){return this.list.add(e)},e.prototype.add=function(e){return this.list.add(e)},e.prototype.dequeue=function(){if(0!==this.list.size()){var e=this.list.first();return this.list.removeElementAtIndex(0),e}},e.prototype.peek=function(){if(0!==this.list.size())return this.list.first()},e.prototype.size=function(){return this.list.size()},e.prototype.contains=function(e,t){return this.list.contains(e,t)},e.prototype.isEmpty=function(){return this.list.size()<=0},e.prototype.clear=function(){this.list.clear()},e.prototype.forEach=function(e){this.list.forEach(e)},e}();t.default=i},function(e,t){e.exports=E},function(e,t,n){var r=n(103);function i(){}function o(e,t,n){null==n&&(n=s),cordova.exec((function(){var e=Array.prototype.slice.call(arguments);e.unshift(null),n.apply(null,e)}),(function(e){e=e instanceof Error?e:new Error(e),n(e)}),"DownloadManagerPlugin",e,t||[])}function s(){}e.exports=new i,i.prototype.enqueue=function(e,t){"string"==typeof e&&(e={uri:e}),e.url&&(e.uri=e.url),r("string"==typeof e.uri,"req.uri must be string"),r(null==t||"function"==typeof t,"cb must be function"),r(null==e.title||"string"==typeof e.title,"req.title must be string"),r(null==e.description||"string"==typeof e.description,"req.description must be string"),r(null==e.mimeType||"string"==typeof e.mimeType,"req.mimeType must be string"),r(null==e.destinationInExternalFilesDir||"string"==typeof e.destinationInExternalFilesDir.dirType,"req.destinationInExternalFilesDir.dirType must be string"),r(null==e.destinationInExternalFilesDir||"string"==typeof e.destinationInExternalFilesDir.subPath,"req.destinationInExternalFilesDir.subPath must be string"),r(null==e.destinationInExternalPublicDir||"string"==typeof e.destinationInExternalPublicDir.dirType,"req.destinationInExternalPublicDir.dirType must be string"),r(null==e.destinationInExternalPublicDir||"string"==typeof e.destinationInExternalPublicDir.subPath,"req.destinationInExternalPublicDir.subPath must be string"),r(null==e.destinationUri||"string"==typeof e.destinationUri,"req.destinationUri must be string"),r(null==e.visibleInDownloadsUi||"boolean"==typeof e.visibleInDownloadsUi,"req.visibleInDownloadsUi must be boolean"),r(null==e.notificationVisibility||Number.isSafeInteger(e.notificationVisibility),"req.notificationVisibility must be safe integer"),o("enqueue",[e],t)},i.prototype.query=function(e,t){"function"==typeof e&&(t=e,e=null),null==e&&(e={}),r("function"==typeof t,"cb must be function"),o("query",[e],t)},i.prototype.remove=function(e,t){r(Array.isArray(e),"ids must be array"),r(null==t||"function"==typeof t,"cb must be function"),o("remove",e,t)},i.prototype.addCompletedDownload=function(e,t){o("addCompletedDownload",[e],t)},i.prototype.fetchSpeedLog=function(e){o("fetchSpeedLog",[],e)}},function(e,t,n){"use strict";(function(e){var t="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==e&&e||{},n="URLSearchParams"in t,r="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(e){return!1}}(),o="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(e){return e&&a.indexOf(Object.prototype.toString.call(e))>-1};function u(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function d(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r&&(t[Symbol.iterator]=function(){return t}),t}function h(e){this.map={},e instanceof h?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){if(2!=e.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function E(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function f(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function p(e){var t=new FileReader,n=f(t);return t.readAsArrayBuffer(e),n}function _(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function O(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:i&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:o&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:n&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():s&&i&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=_(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(e)||c(e))?this._bodyArrayBuffer=_(e):this._bodyText=e=Object.prototype.toString.call(e):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var e=E(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=E(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(i)return this.blob().then(p);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e,t,n,r,i,o=E(this);if(o)return o;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=f(t),r=/charset=([A-Za-z0-9_-]+)/.exec(e.type),i=r?r[1]:"utf-8",t.readAsText(e,i),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(A)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(e,t){e=u(e),t=l(t);var n=this.map[e];this.map[e]=n?n+", "+t:t},h.prototype.delete=function(e){delete this.map[u(e)]},h.prototype.get=function(e){return e=u(e),this.has(e)?this.map[e]:null},h.prototype.has=function(e){return this.map.hasOwnProperty(u(e))},h.prototype.set=function(e,t){this.map[u(e)]=l(t)},h.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},h.prototype.keys=function(){var e=[];return this.forEach((function(t,n){e.push(n)})),d(e)},h.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),d(e)},h.prototype.entries=function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),d(e)},r&&(h.prototype[Symbol.iterator]=h.prototype.entries);var S=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function g(e,n){if(!(this instanceof g))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,i,o=(n=n||{}).body;if(e instanceof g){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,n.headers||(this.headers=new h(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,o||null==e._bodyInit||(o=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=n.credentials||this.credentials||"same-origin",!n.headers&&this.headers||(this.headers=new h(n.headers)),this.method=(r=n.method||this.method||"GET",i=r.toUpperCase(),S.indexOf(i)>-1?i:r),this.mode=n.mode||this.mode||null,this.signal=n.signal||this.signal||function(){if("AbortController"in t)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(o),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==n.cache&&"no-cache"!==n.cache)){var s=/([?&])_=[^&]*/;if(s.test(this.url))this.url=this.url.replace(s,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function A(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(i))}})),t}function N(e,t){if(!(this instanceof N))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new h(t.headers),this.url=t.url||"",this._initBody(e)}g.prototype.clone=function(){return new g(this,{body:this._bodyInit})},O.call(g.prototype),O.call(N.prototype),N.prototype.clone=function(){return new N(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},N.error=function(){var e=new N(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var T=[301,302,303,307,308];N.redirect=function(e,t){if(-1===T.indexOf(t))throw new RangeError("Invalid status code");return new N(null,{status:t,headers:{location:e}})};var C=t.DOMException;try{new C}catch(e){(C=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),C.prototype.constructor=C}function v(e,n){return new Promise((function(r,o){var a=new g(e,n);if(a.signal&&a.signal.aborted)return o(new C("Aborted","AbortError"));var c=new XMLHttpRequest;function d(){c.abort()}if(c.onload=function(){var e,t,n={statusText:c.statusText,headers:(e=c.getAllResponseHeaders()||"",t=new h,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();try{t.append(r,i)}catch(e){console.warn("Response "+e.message)}}})),t)};0===a.url.indexOf("file://")&&(c.status<200||c.status>599)?n.status=200:n.status=c.status,n.url="responseURL"in c?c.responseURL:n.headers.get("X-Request-URL");var i="response"in c?c.response:c.responseText;setTimeout((function(){r(new N(i,n))}),0)},c.onerror=function(){setTimeout((function(){o(new TypeError("Network request failed"))}),0)},c.ontimeout=function(){setTimeout((function(){o(new TypeError("Network request timed out"))}),0)},c.onabort=function(){setTimeout((function(){o(new C("Aborted","AbortError"))}),0)},c.open(a.method,function(e){try{return""===e&&t.location.href?t.location.href:e}catch(t){return e}}(a.url),!0),"include"===a.credentials?c.withCredentials=!0:"omit"===a.credentials&&(c.withCredentials=!1),"responseType"in c&&(i?c.responseType="blob":s&&(c.responseType="arraybuffer")),n&&"object"==typeof n.headers&&!(n.headers instanceof h||t.Headers&&n.headers instanceof t.Headers)){var E=[];Object.getOwnPropertyNames(n.headers).forEach((function(e){E.push(u(e)),c.setRequestHeader(e,l(n.headers[e]))})),a.headers.forEach((function(e,t){-1===E.indexOf(t)&&c.setRequestHeader(t,e)}))}else a.headers.forEach((function(e,t){c.setRequestHeader(t,e)}));a.signal&&(a.signal.addEventListener("abort",d),c.onreadystatechange=function(){4===c.readyState&&a.signal.removeEventListener("abort",d)}),c.send(void 0===a._bodyInit?null:a._bodyInit)}))}v.polyfill=!0,t.fetch||(t.fetch=v,t.Headers=h,t.Request=g,t.Response=N)}).call(this,n(34))},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},o=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.Container=void 0;var s=n(54),a=n(8),c=n(13),u=n(5),l=n(35),d=n(55),h=n(62),E=n(64),f=n(19),p=n(23),_=n(67),O=n(68),S=function(){function e(e){this._appliedMiddleware=[];var t=e||{};if("object"!=typeof t)throw new Error(""+a.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT);if(void 0===t.defaultScope)t.defaultScope=c.BindingScopeEnum.Transient;else if(t.defaultScope!==c.BindingScopeEnum.Singleton&&t.defaultScope!==c.BindingScopeEnum.Transient&&t.defaultScope!==c.BindingScopeEnum.Request)throw new Error(""+a.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE);if(void 0===t.autoBindInjectable)t.autoBindInjectable=!1;else if("boolean"!=typeof t.autoBindInjectable)throw new Error(""+a.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE);if(void 0===t.skipBaseClassChecks)t.skipBaseClassChecks=!1;else if("boolean"!=typeof t.skipBaseClassChecks)throw new Error(""+a.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK);this.options={autoBindInjectable:t.autoBindInjectable,defaultScope:t.defaultScope,skipBaseClassChecks:t.skipBaseClassChecks},this.id=f.id(),this._bindingDictionary=new O.Lookup,this._snapshots=[],this._middleware=null,this.parent=null,this._metadataReader=new l.MetadataReader}return e.merge=function(t,n){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];var s=new e,a=o([t,n],r).map((function(e){return d.getBindingDictionary(e)})),c=d.getBindingDictionary(s);function u(e,t){e.traverse((function(e,n){n.forEach((function(e){t.add(e.serviceIdentifier,e.clone())}))}))}return a.forEach((function(e){u(e,c)})),s},e.prototype.load=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=this._getContainerModuleHelpersFactory(),r=0,i=e;r<i.length;r++){var o=i[r],s=n(o.id);o.registry(s.bindFunction,s.unbindFunction,s.isboundFunction,s.rebindFunction)}},e.prototype.loadAsync=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r(this,void 0,void 0,(function(){var t,n,r,o,s;return i(this,(function(i){switch(i.label){case 0:t=this._getContainerModuleHelpersFactory(),n=0,r=e,i.label=1;case 1:return n<r.length?(o=r[n],s=t(o.id),[4,o.registry(s.bindFunction,s.unbindFunction,s.isboundFunction,s.rebindFunction)]):[3,4];case 2:i.sent(),i.label=3;case 3:return n++,[3,1];case 4:return[2]}}))}))},e.prototype.unload=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=function(e){return function(t){return t.moduleId===e}};t.forEach((function(t){var n=r(t.id);e._bindingDictionary.removeByCondition(n)}))},e.prototype.bind=function(e){var t=this.options.defaultScope||c.BindingScopeEnum.Transient,n=new s.Binding(e,t);return this._bindingDictionary.add(e,n),new E.BindingToSyntax(n)},e.prototype.rebind=function(e){return this.unbind(e),this.bind(e)},e.prototype.unbind=function(e){try{this._bindingDictionary.remove(e)}catch(t){throw new Error(a.CANNOT_UNBIND+" "+p.getServiceIdentifierAsString(e))}},e.prototype.unbindAll=function(){this._bindingDictionary=new O.Lookup},e.prototype.isBound=function(e){var t=this._bindingDictionary.hasKey(e);return!t&&this.parent&&(t=this.parent.isBound(e)),t},e.prototype.isBoundNamed=function(e,t){return this.isBoundTagged(e,u.NAMED_TAG,t)},e.prototype.isBoundTagged=function(e,t,n){var r=!1;if(this._bindingDictionary.hasKey(e)){var i=this._bindingDictionary.get(e),o=d.createMockRequest(this,e,t,n);r=i.some((function(e){return e.constraint(o)}))}return!r&&this.parent&&(r=this.parent.isBoundTagged(e,t,n)),r},e.prototype.snapshot=function(){this._snapshots.push(_.ContainerSnapshot.of(this._bindingDictionary.clone(),this._middleware))},e.prototype.restore=function(){var e=this._snapshots.pop();if(void 0===e)throw new Error(a.NO_MORE_SNAPSHOTS_AVAILABLE);this._bindingDictionary=e.bindings,this._middleware=e.middleware},e.prototype.createChild=function(t){var n=new e(t||this.options);return n.parent=this,n},e.prototype.applyMiddleware=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._appliedMiddleware=this._appliedMiddleware.concat(e);var n=this._middleware?this._middleware:this._planAndResolve();this._middleware=e.reduce((function(e,t){return t(e)}),n)},e.prototype.applyCustomMetadataReader=function(e){this._metadataReader=e},e.prototype.get=function(e){return this._get(!1,!1,c.TargetTypeEnum.Variable,e)},e.prototype.getTagged=function(e,t,n){return this._get(!1,!1,c.TargetTypeEnum.Variable,e,t,n)},e.prototype.getNamed=function(e,t){return this.getTagged(e,u.NAMED_TAG,t)},e.prototype.getAll=function(e){return this._get(!0,!0,c.TargetTypeEnum.Variable,e)},e.prototype.getAllTagged=function(e,t,n){return this._get(!1,!0,c.TargetTypeEnum.Variable,e,t,n)},e.prototype.getAllNamed=function(e,t){return this.getAllTagged(e,u.NAMED_TAG,t)},e.prototype.resolve=function(e){var t=this.createChild();return t.bind(e).toSelf(),this._appliedMiddleware.forEach((function(e){t.applyMiddleware(e)})),t.get(e)},e.prototype._getContainerModuleHelpersFactory=function(){var e=this,t=function(e,t){e._binding.moduleId=t},n=function(n){return function(r){var i=e.rebind.bind(e)(r);return t(i,n),i}};return function(r){return{bindFunction:(i=r,function(n){var r=e.bind.bind(e)(n);return t(r,i),r}),isboundFunction:function(t){return e.isBound.bind(e)(t)},rebindFunction:n(r),unbindFunction:function(t){e.unbind.bind(e)(t)}};var i}},e.prototype._get=function(e,t,n,r,i,o){var s=null,c={avoidConstraints:e,contextInterceptor:function(e){return e},isMultiInject:t,key:i,serviceIdentifier:r,targetType:n,value:o};if(this._middleware){if(null==(s=this._middleware(c)))throw new Error(a.INVALID_MIDDLEWARE_RETURN)}else s=this._planAndResolve()(c);return s},e.prototype._planAndResolve=function(){var e=this;return function(t){var n=d.plan(e._metadataReader,e,t.isMultiInject,t.targetType,t.serviceIdentifier,t.key,t.value,t.avoidConstraints);return n=t.contextInterceptor(n),h.resolve(n)}},e}();t.Container=S},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Binding=void 0;var r=n(13),i=n(19),o=function(){function e(e,t){this.id=i.id(),this.activated=!1,this.serviceIdentifier=e,this.scope=t,this.type=r.BindingTypeEnum.Invalid,this.constraint=function(e){return!0},this.implementationType=null,this.cache=null,this.factory=null,this.provider=null,this.onActivation=null,this.dynamicValue=null}return e.prototype.clone=function(){var t=new e(this.serviceIdentifier,this.scope);return t.activated=t.scope===r.BindingScopeEnum.Singleton&&this.activated,t.implementationType=this.implementationType,t.dynamicValue=this.dynamicValue,t.scope=this.scope,t.type=this.type,t.factory=this.factory,t.provider=this.provider,t.constraint=this.constraint,t.onActivation=this.onActivation,t.cache=this.cache,t},e}();t.Binding=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getBindingDictionary=t.createMockRequest=t.plan=void 0;var r=n(56),i=n(8),o=n(13),s=n(5),a=n(36),c=n(23),u=n(57),l=n(10),d=n(58),h=n(59),E=n(61),f=n(38);function p(e){return e._bindingDictionary}function _(e,t,n,o,s){var a=O(n.container,s.serviceIdentifier),u=[];return a.length===r.BindingCount.NoBindingsAvailable&&n.container.options.autoBindInjectable&&"function"==typeof s.serviceIdentifier&&e.getConstructorMetadata(s.serviceIdentifier).compilerGeneratedMetadata&&(n.container.bind(s.serviceIdentifier).toSelf(),a=O(n.container,s.serviceIdentifier)),u=t?a:a.filter((function(e){var t=new E.Request(e.serviceIdentifier,n,o,e,s);return e.constraint(t)})),function(e,t,n,o){switch(t.length){case r.BindingCount.NoBindingsAvailable:if(n.isOptional())return t;var s=c.getServiceIdentifierAsString(e),a=i.NOT_REGISTERED;throw a+=c.listMetadataForTarget(s,n),a+=c.listRegisteredBindingsForServiceIdentifier(o,s,O),new Error(a);case r.BindingCount.OnlyOneBindingAvailable:if(!n.isArray())return t;case r.BindingCount.MultipleBindingsAvailable:default:if(n.isArray())return t;s=c.getServiceIdentifierAsString(e),a=i.AMBIGUOUS_MATCH+" "+s;throw a+=c.listRegisteredBindingsForServiceIdentifier(o,s,O),new Error(a)}}(s.serviceIdentifier,u,s,n.container),u}function O(e,t){var n=[],r=p(e);return r.hasKey(t)?n=r.get(t):null!==e.parent&&(n=O(e.parent,t)),n}t.getBindingDictionary=p,t.plan=function(e,t,n,r,p,O,S,g){void 0===g&&(g=!1);var A=new u.Context(t),N=function(e,t,n,r,i,o){var a=e?s.MULTI_INJECT_TAG:s.INJECT_TAG,c=new l.Metadata(a,n),u=new f.Target(t,r,n,c);if(void 0!==i){var d=new l.Metadata(i,o);u.metadata.push(d)}return u}(n,r,p,"",O,S);try{return function e(t,n,r,s,a,c){var u,l;if(null===a){u=_(t,n,s,null,c),l=new E.Request(r,s,null,u,c);var f=new d.Plan(s,l);s.addPlan(f)}else u=_(t,n,s,a,c),l=a.addChildRequest(c.serviceIdentifier,u,c);u.forEach((function(n){var r=null;if(c.isArray())r=l.addChildRequest(n.serviceIdentifier,n,c);else{if(n.cache)return;r=l}if(n.type===o.BindingTypeEnum.Instance&&null!==n.implementationType){var a=h.getDependencies(t,n.implementationType);if(!s.container.options.skipBaseClassChecks){var u=h.getBaseClassDependencyCount(t,n.implementationType);if(a.length<u){var d=i.ARGUMENTS_LENGTH_MISMATCH(h.getFunctionName(n.implementationType));throw new Error(d)}}a.forEach((function(n){e(t,!1,n.serviceIdentifier,s,r,n)}))}}))}(e,g,p,A,null,N),A}catch(e){throw a.isStackOverflowExeption(e)&&A.plan&&c.circularDependencyToException(A.plan.rootRequest),e}},t.createMockRequest=function(e,t,n,r){var i=new f.Target(o.TargetTypeEnum.Variable,"",t,new l.Metadata(n,r)),s=new u.Context(e);return new E.Request(t,s,null,[],i)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingCount=void 0;t.BindingCount={MultipleBindingsAvailable:2,NoBindingsAvailable:0,OnlyOneBindingAvailable:1}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Context=void 0;var r=n(19),i=function(){function e(e){this.id=r.id(),this.container=e}return e.prototype.addPlan=function(e){this.plan=e},e.prototype.setCurrentRequest=function(e){this.currentRequest=e},e}();t.Context=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Plan=void 0;var r=function(e,t){this.parentContext=e,this.rootRequest=t};t.Plan=r},function(e,t,n){"use strict";var r=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.getFunctionName=t.getBaseClassDependencyCount=t.getDependencies=void 0;var i=n(37),o=n(8),s=n(13),a=n(5),c=n(23);Object.defineProperty(t,"getFunctionName",{enumerable:!0,get:function(){return c.getFunctionName}});var u=n(38);function l(e,t,n,i){var a=e.getConstructorMetadata(n),c=a.compilerGeneratedMetadata;if(void 0===c){var l=o.MISSING_INJECTABLE_ANNOTATION+" "+t+".";throw new Error(l)}var E=a.userGeneratedMetadata,f=Object.keys(E),p=0===n.length&&f.length>0,_=f.length>n.length,O=function(e,t,n,r,i){for(var o=[],s=0;s<i;s++){var a=d(s,e,t,n,r);null!==a&&o.push(a)}return o}(i,t,c,E,p||_?f.length:n.length),S=function e(t,n){for(var i=t.getPropertiesMetadata(n),o=[],a=Object.keys(i),c=0,l=a;c<l.length;c++){var d=l[c],E=i[d],f=h(i[d]),p=f.targetName||d,_=f.inject||f.multiInject,O=new u.Target(s.TargetTypeEnum.ClassProperty,p,_);O.metadata=E,o.push(O)}var S=Object.getPrototypeOf(n.prototype).constructor;if(S!==Object){var g=e(t,S);o=r(r([],o),g)}return o}(e,n);return r(r([],O),S)}function d(e,t,n,r,a){var c=a[e.toString()]||[],l=h(c),d=!0!==l.unmanaged,E=r[e],f=l.inject||l.multiInject;if((E=f||E)instanceof i.LazyServiceIdentifer&&(E=E.unwrap()),d){if(!t&&(E===Object||E===Function||void 0===E)){var p=o.MISSING_INJECT_ANNOTATION+" argument "+e+" in class "+n+".";throw new Error(p)}var _=new u.Target(s.TargetTypeEnum.ConstructorArgument,l.targetName,E);return _.metadata=c,_}return null}function h(e){var t={};return e.forEach((function(e){t[e.key.toString()]=e.value})),{inject:t[a.INJECT_TAG],multiInject:t[a.MULTI_INJECT_TAG],targetName:t[a.NAME_TAG],unmanaged:t[a.UNMANAGED_TAG]}}t.getDependencies=function(e,t){return l(e,c.getFunctionName(t),t,!1)},t.getBaseClassDependencyCount=function e(t,n){var r=Object.getPrototypeOf(n.prototype).constructor;if(r!==Object){var i=l(t,c.getFunctionName(r),r,!0),o=i.map((function(e){return e.metadata.filter((function(e){return e.key===a.UNMANAGED_TAG}))})),s=[].concat.apply([],o).length,u=i.length-s;return u>0?u:e(t,r)}return 0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.QueryableString=void 0;var r=function(){function e(e){this.str=e}return e.prototype.startsWith=function(e){return 0===this.str.indexOf(e)},e.prototype.endsWith=function(e){var t,n=e.split("").reverse().join("");return t=this.str.split("").reverse().join(""),this.startsWith.call({str:t},n)},e.prototype.contains=function(e){return-1!==this.str.indexOf(e)},e.prototype.equals=function(e){return this.str===e},e.prototype.value=function(){return this.str},e}();t.QueryableString=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Request=void 0;var r=n(19),i=function(){function e(e,t,n,i,o){this.id=r.id(),this.serviceIdentifier=e,this.parentContext=t,this.parentRequest=n,this.target=o,this.childRequests=[],this.bindings=Array.isArray(i)?i:[i],this.requestScope=null===n?new Map:null}return e.prototype.addChildRequest=function(t,n,r){var i=new e(t,this.parentContext,this,n,r);return this.childRequests.push(i),i},e}();t.Request=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolve=void 0;var r=n(8),i=n(13),o=n(36),s=n(23),a=n(63),c=function(e,t,n){try{return n()}catch(n){throw o.isStackOverflowExeption(n)?new Error(r.CIRCULAR_DEPENDENCY_IN_FACTORY(e,t.toString())):n}},u=function(e){return function(t){t.parentContext.setCurrentRequest(t);var n=t.bindings,o=t.childRequests,l=t.target&&t.target.isArray(),d=!(t.parentRequest&&t.parentRequest.target&&t.target&&t.parentRequest.target.matchesArray(t.target.serviceIdentifier));if(l&&d)return o.map((function(t){return u(e)(t)}));var h=null;if(!t.target.isOptional()||0!==n.length){var E=n[0],f=E.scope===i.BindingScopeEnum.Singleton,p=E.scope===i.BindingScopeEnum.Request;if(f&&E.activated)return E.cache;if(p&&null!==e&&e.has(E.id))return e.get(E.id);if(E.type===i.BindingTypeEnum.ConstantValue)h=E.cache,E.activated=!0;else if(E.type===i.BindingTypeEnum.Function)h=E.cache,E.activated=!0;else if(E.type===i.BindingTypeEnum.Constructor)h=E.implementationType;else if(E.type===i.BindingTypeEnum.DynamicValue&&null!==E.dynamicValue)h=c("toDynamicValue",E.serviceIdentifier,(function(){return E.dynamicValue(t.parentContext)}));else if(E.type===i.BindingTypeEnum.Factory&&null!==E.factory)h=c("toFactory",E.serviceIdentifier,(function(){return E.factory(t.parentContext)}));else if(E.type===i.BindingTypeEnum.Provider&&null!==E.provider)h=c("toProvider",E.serviceIdentifier,(function(){return E.provider(t.parentContext)}));else{if(E.type!==i.BindingTypeEnum.Instance||null===E.implementationType){var _=s.getServiceIdentifierAsString(t.serviceIdentifier);throw new Error(r.INVALID_BINDING_TYPE+" "+_)}h=a.resolveInstance(E.implementationType,o,u(e))}return"function"==typeof E.onActivation&&(h=E.onActivation(t.parentContext,h)),f&&(E.cache=h,E.activated=!0),p&&null!==e&&!e.has(E.id)&&e.set(E.id,h),h}}};t.resolve=function(e){return u(e.plan.rootRequest.requestScope)(e.plan.rootRequest)}},function(e,t,n){"use strict";var r=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveInstance=void 0;var i=n(8),o=n(13),s=n(5);t.resolveInstance=function(e,t,n){var a,c,u=null;if(t.length>0){var l=t.filter((function(e){return null!==e.target&&e.target.type===o.TargetTypeEnum.ConstructorArgument})).map(n);c=l,u=function(e,t,n){var r=t.filter((function(e){return null!==e.target&&e.target.type===o.TargetTypeEnum.ClassProperty})),i=r.map(n);return r.forEach((function(t,n){var r;r=t.target.name.value();var o=i[n];e[r]=o})),e}(u=new((a=e).bind.apply(a,r([void 0],c))),t,n)}else u=new e;return function(e,t){if(Reflect.hasMetadata(s.POST_CONSTRUCT,e)){var n=Reflect.getMetadata(s.POST_CONSTRUCT,e);try{t[n.value]()}catch(t){throw new Error(i.POST_CONSTRUCT_ERROR(e.name,t.message))}}}(e,u),u}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingToSyntax=void 0;var r=n(8),i=n(13),o=n(65),s=n(39),a=function(){function e(e){this._binding=e}return e.prototype.to=function(e){return this._binding.type=i.BindingTypeEnum.Instance,this._binding.implementationType=e,new o.BindingInWhenOnSyntax(this._binding)},e.prototype.toSelf=function(){if("function"!=typeof this._binding.serviceIdentifier)throw new Error(""+r.INVALID_TO_SELF_VALUE);var e=this._binding.serviceIdentifier;return this.to(e)},e.prototype.toConstantValue=function(e){return this._binding.type=i.BindingTypeEnum.ConstantValue,this._binding.cache=e,this._binding.dynamicValue=null,this._binding.implementationType=null,this._binding.scope=i.BindingScopeEnum.Singleton,new s.BindingWhenOnSyntax(this._binding)},e.prototype.toDynamicValue=function(e){return this._binding.type=i.BindingTypeEnum.DynamicValue,this._binding.cache=null,this._binding.dynamicValue=e,this._binding.implementationType=null,new o.BindingInWhenOnSyntax(this._binding)},e.prototype.toConstructor=function(e){return this._binding.type=i.BindingTypeEnum.Constructor,this._binding.implementationType=e,this._binding.scope=i.BindingScopeEnum.Singleton,new s.BindingWhenOnSyntax(this._binding)},e.prototype.toFactory=function(e){return this._binding.type=i.BindingTypeEnum.Factory,this._binding.factory=e,this._binding.scope=i.BindingScopeEnum.Singleton,new s.BindingWhenOnSyntax(this._binding)},e.prototype.toFunction=function(e){if("function"!=typeof e)throw new Error(r.INVALID_FUNCTION_BINDING);var t=this.toConstantValue(e);return this._binding.type=i.BindingTypeEnum.Function,this._binding.scope=i.BindingScopeEnum.Singleton,t},e.prototype.toAutoFactory=function(e){return this._binding.type=i.BindingTypeEnum.Factory,this._binding.factory=function(t){return function(){return t.container.get(e)}},this._binding.scope=i.BindingScopeEnum.Singleton,new s.BindingWhenOnSyntax(this._binding)},e.prototype.toProvider=function(e){return this._binding.type=i.BindingTypeEnum.Provider,this._binding.provider=e,this._binding.scope=i.BindingScopeEnum.Singleton,new s.BindingWhenOnSyntax(this._binding)},e.prototype.toService=function(e){this.toDynamicValue((function(t){return t.container.get(e)}))},e}();t.BindingToSyntax=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingInWhenOnSyntax=void 0;var r=n(66),i=n(27),o=n(28),s=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new o.BindingWhenSyntax(this._binding),this._bindingOnSyntax=new i.BindingOnSyntax(this._binding),this._bindingInSyntax=new r.BindingInSyntax(e)}return e.prototype.inRequestScope=function(){return this._bindingInSyntax.inRequestScope()},e.prototype.inSingletonScope=function(){return this._bindingInSyntax.inSingletonScope()},e.prototype.inTransientScope=function(){return this._bindingInSyntax.inTransientScope()},e.prototype.when=function(e){return this._bindingWhenSyntax.when(e)},e.prototype.whenTargetNamed=function(e){return this._bindingWhenSyntax.whenTargetNamed(e)},e.prototype.whenTargetIsDefault=function(){return this._bindingWhenSyntax.whenTargetIsDefault()},e.prototype.whenTargetTagged=function(e,t){return this._bindingWhenSyntax.whenTargetTagged(e,t)},e.prototype.whenInjectedInto=function(e){return this._bindingWhenSyntax.whenInjectedInto(e)},e.prototype.whenParentNamed=function(e){return this._bindingWhenSyntax.whenParentNamed(e)},e.prototype.whenParentTagged=function(e,t){return this._bindingWhenSyntax.whenParentTagged(e,t)},e.prototype.whenAnyAncestorIs=function(e){return this._bindingWhenSyntax.whenAnyAncestorIs(e)},e.prototype.whenNoAncestorIs=function(e){return this._bindingWhenSyntax.whenNoAncestorIs(e)},e.prototype.whenAnyAncestorNamed=function(e){return this._bindingWhenSyntax.whenAnyAncestorNamed(e)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenAnyAncestorTagged(e,t)},e.prototype.whenNoAncestorNamed=function(e){return this._bindingWhenSyntax.whenNoAncestorNamed(e)},e.prototype.whenNoAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenNoAncestorTagged(e,t)},e.prototype.whenAnyAncestorMatches=function(e){return this._bindingWhenSyntax.whenAnyAncestorMatches(e)},e.prototype.whenNoAncestorMatches=function(e){return this._bindingWhenSyntax.whenNoAncestorMatches(e)},e.prototype.onActivation=function(e){return this._bindingOnSyntax.onActivation(e)},e}();t.BindingInWhenOnSyntax=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingInSyntax=void 0;var r=n(13),i=n(39),o=function(){function e(e){this._binding=e}return e.prototype.inRequestScope=function(){return this._binding.scope=r.BindingScopeEnum.Request,new i.BindingWhenOnSyntax(this._binding)},e.prototype.inSingletonScope=function(){return this._binding.scope=r.BindingScopeEnum.Singleton,new i.BindingWhenOnSyntax(this._binding)},e.prototype.inTransientScope=function(){return this._binding.scope=r.BindingScopeEnum.Transient,new i.BindingWhenOnSyntax(this._binding)},e}();t.BindingInSyntax=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContainerSnapshot=void 0;var r=function(){function e(){}return e.of=function(t,n){var r=new e;return r.bindings=t,r.middleware=n,r},e}();t.ContainerSnapshot=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Lookup=void 0;var r=n(8),i=function(){function e(){this._map=new Map}return e.prototype.getMap=function(){return this._map},e.prototype.add=function(e,t){if(null==e)throw new Error(r.NULL_ARGUMENT);if(null==t)throw new Error(r.NULL_ARGUMENT);var n=this._map.get(e);void 0!==n?(n.push(t),this._map.set(e,n)):this._map.set(e,[t])},e.prototype.get=function(e){if(null==e)throw new Error(r.NULL_ARGUMENT);var t=this._map.get(e);if(void 0!==t)return t;throw new Error(r.KEY_NOT_FOUND)},e.prototype.remove=function(e){if(null==e)throw new Error(r.NULL_ARGUMENT);if(!this._map.delete(e))throw new Error(r.KEY_NOT_FOUND)},e.prototype.removeByCondition=function(e){var t=this;this._map.forEach((function(n,r){var i=n.filter((function(t){return!e(t)}));i.length>0?t._map.set(r,i):t._map.delete(r)}))},e.prototype.hasKey=function(e){if(null==e)throw new Error(r.NULL_ARGUMENT);return this._map.has(e)},e.prototype.clone=function(){var t=new e;return this._map.forEach((function(e,n){e.forEach((function(e){return t.add(n,e.clone())}))})),t},e.prototype.traverse=function(e){this._map.forEach((function(t,n){e(n,t)}))},e}();t.Lookup=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncContainerModule=t.ContainerModule=void 0;var r=n(19),i=function(e){this.id=r.id(),this.registry=e};t.ContainerModule=i;var o=function(e){this.id=r.id(),this.registry=e};t.AsyncContainerModule=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.injectable=void 0;var r=n(8),i=n(5);t.injectable=function(){return function(e){if(Reflect.hasOwnMetadata(i.PARAM_TYPES,e))throw new Error(r.DUPLICATED_INJECTABLE_DECORATOR);var t=Reflect.getMetadata(i.DESIGN_PARAM_TYPES,e)||[];return Reflect.defineMetadata(i.PARAM_TYPES,t,e),e}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagged=void 0;var r=n(10),i=n(15);t.tagged=function(e,t){return function(n,o,s){var a=new r.Metadata(e,t);"number"==typeof s?i.tagParameter(n,o,s,a):i.tagProperty(n,o,a)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.named=void 0;var r=n(5),i=n(10),o=n(15);t.named=function(e){return function(t,n,s){var a=new i.Metadata(r.NAMED_TAG,e);"number"==typeof s?o.tagParameter(t,n,s,a):o.tagProperty(t,n,a)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.optional=void 0;var r=n(5),i=n(10),o=n(15);t.optional=function(){return function(e,t,n){var s=new i.Metadata(r.OPTIONAL_TAG,!0);"number"==typeof n?o.tagParameter(e,t,n,s):o.tagProperty(e,t,s)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unmanaged=void 0;var r=n(5),i=n(10),o=n(15);t.unmanaged=function(){return function(e,t,n){var s=new i.Metadata(r.UNMANAGED_TAG,!0);o.tagParameter(e,t,n,s)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiInject=void 0;var r=n(5),i=n(10),o=n(15);t.multiInject=function(e){return function(t,n,s){var a=new i.Metadata(r.MULTI_INJECT_TAG,e);"number"==typeof s?o.tagParameter(t,n,s,a):o.tagProperty(t,n,a)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.targetName=void 0;var r=n(5),i=n(10),o=n(15);t.targetName=function(e){return function(t,n,s){var a=new i.Metadata(r.NAME_TAG,e);o.tagParameter(t,n,s,a)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.postConstruct=void 0;var r=n(8),i=n(5),o=n(10);t.postConstruct=function(){return function(e,t,n){var s=new o.Metadata(i.POST_CONSTRUCT,t);if(Reflect.hasOwnMetadata(i.POST_CONSTRUCT,e.constructor))throw new Error(r.MULTIPLE_POST_CONSTRUCT_METHODS);Reflect.defineMetadata(i.POST_CONSTRUCT,s,e.constructor)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiBindToService=void 0;t.multiBindToService=function(e){return function(t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return n.forEach((function(n){return e.bind(n).toService(t)}))}}}},function(e,t,n){"use strict";var r=n(80),i=n(43),o=n(31),s=Object.prototype.hasOwnProperty,a={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},c=Array.isArray,u=Array.prototype.push,l=function(e,t){u.apply(e,c(t)?t:[t])},d=Date.prototype.toISOString,h=o.default,E={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:i.encode,encodeValuesOnly:!1,format:h,formatter:o.formatters[h],indices:!1,serializeDate:function(e){return d.call(e)},skipNulls:!1,strictNullHandling:!1},f={},p=function e(t,n,o,s,a,u,d,h,p,_,O,S,g,A,N,T,C,v){for(var y,m=t,b=v,I=0,M=!1;void 0!==(b=b.get(f))&&!M;){var R=b.get(t);if(I+=1,void 0!==R){if(R===I)throw new RangeError("Cyclic object value");M=!0}void 0===b.get(f)&&(I=0)}if("function"==typeof _?m=_(n,m):m instanceof Date?m=g(m):"comma"===o&&c(m)&&(m=i.maybeMap(m,(function(e){return e instanceof Date?g(e):e}))),null===m){if(u)return p&&!T?p(n,E.encoder,C,"key",A):n;m=""}if("string"==typeof(y=m)||"number"==typeof y||"boolean"==typeof y||"symbol"==typeof y||"bigint"==typeof y||i.isBuffer(m))return p?[N(T?n:p(n,E.encoder,C,"key",A))+"="+N(p(m,E.encoder,C,"value",A))]:[N(n)+"="+N(String(m))];var L,P=[];if(void 0===m)return P;if("comma"===o&&c(m))T&&p&&(m=i.maybeMap(m,p)),L=[{value:m.length>0?m.join(",")||null:void 0}];else if(c(_))L=_;else{var D=Object.keys(m);L=O?D.sort(O):D}var w=h?n.replace(/\./g,"%2E"):n,U=s&&c(m)&&1===m.length?w+"[]":w;if(a&&c(m)&&0===m.length)return U+"[]";for(var j=0;j<L.length;++j){var F=L[j],k="object"==typeof F&&void 0!==F.value?F.value:m[F];if(!d||null!==k){var x=S&&h?F.replace(/\./g,"%2E"):F,B=c(m)?"function"==typeof o?o(U,x):U:U+(S?"."+x:"["+x+"]");v.set(t,I);var V=r();V.set(f,v),l(P,e(k,B,o,s,a,u,d,h,"comma"===o&&T&&c(m)?null:p,_,O,S,g,A,N,T,C,V))}}return P};e.exports=function(e,t){var n,i=e,u=function(e){if(!e)return E;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||E.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=o.default;if(void 0!==e.format){if(!s.call(o.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r,i=o.formatters[n],u=E.filter;if(("function"==typeof e.filter||c(e.filter))&&(u=e.filter),r=e.arrayFormat in a?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":E.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var l=void 0===e.allowDots?!0===e.encodeDotInKeys||E.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:E.addQueryPrefix,allowDots:l,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:E.allowEmptyArrays,arrayFormat:r,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:E.charsetSentinel,commaRoundTrip:e.commaRoundTrip,delimiter:void 0===e.delimiter?E.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:E.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:E.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:E.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:E.encodeValuesOnly,filter:u,format:n,formatter:i,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:E.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:E.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:E.strictNullHandling}}(t);"function"==typeof u.filter?i=(0,u.filter)("",i):c(u.filter)&&(n=u.filter);var d=[];if("object"!=typeof i||null===i)return"";var h=a[u.arrayFormat],f="comma"===h&&u.commaRoundTrip;n||(n=Object.keys(i)),u.sort&&n.sort(u.sort);for(var _=r(),O=0;O<n.length;++O){var S=n[O];u.skipNulls&&null===i[S]||l(d,p(i[S],S,h,f,u.allowEmptyArrays,u.strictNullHandling,u.skipNulls,u.encodeDotInKeys,u.encode?u.encoder:null,u.filter,u.sort,u.allowDots,u.serializeDate,u.format,u.formatter,u.encodeValuesOnly,u.charset,_))}var g=d.join(u.delimiter),A=!0===u.addQueryPrefix?"?":"";return u.charsetSentinel&&("iso-8859-1"===u.charset?A+="utf8=%26%2310003%3B&":A+="utf8=%E2%9C%93&"),g.length>0?A+g:""}},function(e,t,n){"use strict";var r=n(20),i=n(91),o=n(96),s=n(24),a=r("%WeakMap%",!0),c=r("%Map%",!0),u=i("WeakMap.prototype.get",!0),l=i("WeakMap.prototype.set",!0),d=i("WeakMap.prototype.has",!0),h=i("Map.prototype.get",!0),E=i("Map.prototype.set",!0),f=i("Map.prototype.has",!0),p=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n};e.exports=function(){var e,t,n,r={assert:function(e){if(!r.has(e))throw new s("Side channel does not contain "+o(e))},get:function(r){if(a&&r&&("object"==typeof r||"function"==typeof r)){if(e)return u(e,r)}else if(c){if(t)return h(t,r)}else if(n)return function(e,t){var n=p(e,t);return n&&n.value}(n,r)},has:function(r){if(a&&r&&("object"==typeof r||"function"==typeof r)){if(e)return d(e,r)}else if(c){if(t)return f(t,r)}else if(n)return function(e,t){return!!p(e,t)}(n,r);return!1},set:function(r,i){a&&r&&("object"==typeof r||"function"==typeof r)?(e||(e=new a),l(e,r,i)):c?(t||(t=new c),E(t,r,i)):(n||(n={key:{},next:null}),function(e,t,n){var r=p(e,t);r?r.value=n:e.next={key:t,next:e.next,value:n}}(n,r,i))}};return r}},function(e,t,n){"use strict";e.exports=Error},function(e,t,n){"use strict";e.exports=EvalError},function(e,t,n){"use strict";e.exports=RangeError},function(e,t,n){"use strict";e.exports=ReferenceError},function(e,t,n){"use strict";e.exports=URIError},function(e,t,n){"use strict";var r="undefined"!=typeof Symbol&&Symbol,i=n(87);e.exports=function(){return"function"==typeof r&&("function"==typeof Symbol&&("symbol"==typeof r("foo")&&("symbol"==typeof Symbol("bar")&&i())))}},function(e,t,n){"use strict";e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),n=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(n))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var r=Object.getOwnPropertySymbols(e);if(1!==r.length||r[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(e,t);if(42!==i.value||!0!==i.enumerable)return!1}return!0}},function(e,t,n){"use strict";var r={__proto__:null,foo:{}},i=Object;e.exports=function(){return{__proto__:r}.foo===r.foo&&!(r instanceof i)}},function(e,t,n){"use strict";var r="Function.prototype.bind called on incompatible ",i=Object.prototype.toString,o=Math.max,s=function(e,t){for(var n=[],r=0;r<e.length;r+=1)n[r]=e[r];for(var i=0;i<t.length;i+=1)n[i+e.length]=t[i];return n},a=function(e,t){for(var n=[],r=t||0,i=0;r<e.length;r+=1,i+=1)n[i]=e[r];return n},c=function(e,t){for(var n="",r=0;r<e.length;r+=1)n+=e[r],r+1<e.length&&(n+=t);return n};e.exports=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==i.apply(t))throw new TypeError(r+t);for(var n,u=a(arguments,1),l=function(){if(this instanceof n){var r=t.apply(this,s(u,arguments));return Object(r)===r?r:this}return t.apply(e,s(u,arguments))},d=o(0,t.length-u.length),h=[],E=0;E<d;E++)h[E]="$"+E;if(n=Function("binder","return function ("+c(h,",")+"){ return binder.apply(this,arguments); }")(l),t.prototype){var f=function(){};f.prototype=t.prototype,n.prototype=new f,f.prototype=null}return n}},function(e,t,n){"use strict";var r=Function.prototype.call,i=Object.prototype.hasOwnProperty,o=n(29);e.exports=o.call(r,i)},function(e,t,n){"use strict";var r=n(20),i=n(92),o=i(r("String.prototype.indexOf"));e.exports=function(e,t){var n=r(e,!!t);return"function"==typeof n&&o(e,".prototype.")>-1?i(n):n}},function(e,t,n){"use strict";var r=n(29),i=n(20),o=n(93),s=n(24),a=i("%Function.prototype.apply%"),c=i("%Function.prototype.call%"),u=i("%Reflect.apply%",!0)||r.call(c,a),l=n(30),d=i("%Math.max%");e.exports=function(e){if("function"!=typeof e)throw new s("a function is required");var t=u(r,c,arguments);return o(t,1+d(0,e.length-(arguments.length-1)),!0)};var h=function(){return u(r,a,arguments)};l?l(e.exports,"apply",{value:h}):e.exports.apply=h},function(e,t,n){"use strict";var r=n(20),i=n(94),o=n(95)(),s=n(42),a=n(24),c=r("%Math.floor%");e.exports=function(e,t){if("function"!=typeof e)throw new a("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||c(t)!==t)throw new a("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],r=!0,u=!0;if("length"in e&&s){var l=s(e,"length");l&&!l.configurable&&(r=!1),l&&!l.writable&&(u=!1)}return(r||u||!n)&&(o?i(e,"length",t,!0,!0):i(e,"length",t)),e}},function(e,t,n){"use strict";var r=n(30),i=n(41),o=n(24),s=n(42);e.exports=function(e,t,n){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new o("`obj` must be an object or a function`");if("string"!=typeof t&&"symbol"!=typeof t)throw new o("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new o("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new o("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new o("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new o("`loose`, if provided, must be a boolean");var a=arguments.length>3?arguments[3]:null,c=arguments.length>4?arguments[4]:null,u=arguments.length>5?arguments[5]:null,l=arguments.length>6&&arguments[6],d=!!s&&s(e,t);if(r)r(e,t,{configurable:null===u&&d?d.configurable:!u,enumerable:null===a&&d?d.enumerable:!a,value:n,writable:null===c&&d?d.writable:!c});else{if(!l&&(a||c||u))throw new i("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=n}}},function(e,t,n){"use strict";var r=n(30),i=function(){return!!r};i.hasArrayLengthDefineBug=function(){if(!r)return null;try{return 1!==r([],"length",{value:1}).length}catch(e){return!0}},e.exports=i},function(e,t,n){(function(t){var r="function"==typeof Map&&Map.prototype,i=Object.getOwnPropertyDescriptor&&r?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,o=r&&i&&"function"==typeof i.get?i.get:null,s=r&&Map.prototype.forEach,a="function"==typeof Set&&Set.prototype,c=Object.getOwnPropertyDescriptor&&a?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,u=a&&c&&"function"==typeof c.get?c.get:null,l=a&&Set.prototype.forEach,d="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,h="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,E="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,f=Boolean.prototype.valueOf,p=Object.prototype.toString,_=Function.prototype.toString,O=String.prototype.match,S=String.prototype.slice,g=String.prototype.replace,A=String.prototype.toUpperCase,N=String.prototype.toLowerCase,T=RegExp.prototype.test,C=Array.prototype.concat,v=Array.prototype.join,y=Array.prototype.slice,m=Math.floor,b="function"==typeof BigInt?BigInt.prototype.valueOf:null,I=Object.getOwnPropertySymbols,M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,R="function"==typeof Symbol&&"object"==typeof Symbol.iterator,L="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===R||"symbol")?Symbol.toStringTag:null,P=Object.prototype.propertyIsEnumerable,D=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function w(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||T.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-m(-e):m(e);if(r!==e){var i=String(r),o=S.call(t,i.length+1);return g.call(i,n,"$&_")+"."+g.call(g.call(o,/([0-9]{3})/g,"$&_"),/_$/,"")}}return g.call(t,n,"$&_")}var U=n(97),j=U.custom,F=Y(j)?j:null;function k(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function x(e){return g.call(String(e),/"/g,"&quot;")}function B(e){return!("[object Array]"!==$(e)||L&&"object"==typeof e&&L in e)}function V(e){return!("[object RegExp]"!==$(e)||L&&"object"==typeof e&&L in e)}function Y(e){if(R)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!M)return!1;try{return M.call(e),!0}catch(e){}return!1}e.exports=function e(n,r,i,a){var c=r||{};if(H(c,"quoteStyle")&&"single"!==c.quoteStyle&&"double"!==c.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(H(c,"maxStringLength")&&("number"==typeof c.maxStringLength?c.maxStringLength<0&&c.maxStringLength!==1/0:null!==c.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var p=!H(c,"customInspect")||c.customInspect;if("boolean"!=typeof p&&"symbol"!==p)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(H(c,"indent")&&null!==c.indent&&"\t"!==c.indent&&!(parseInt(c.indent,10)===c.indent&&c.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(H(c,"numericSeparator")&&"boolean"!=typeof c.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var A=c.numericSeparator;if(void 0===n)return"undefined";if(null===n)return"null";if("boolean"==typeof n)return n?"true":"false";if("string"==typeof n)return function e(t,n){if(t.length>n.maxStringLength){var r=t.length-n.maxStringLength,i="... "+r+" more character"+(r>1?"s":"");return e(S.call(t,0,n.maxStringLength),n)+i}return k(g.call(g.call(t,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,K),"single",n)}(n,c);if("number"==typeof n){if(0===n)return 1/0/n>0?"0":"-0";var T=String(n);return A?w(n,T):T}if("bigint"==typeof n){var m=String(n)+"n";return A?w(n,m):m}var I=void 0===c.depth?5:c.depth;if(void 0===i&&(i=0),i>=I&&I>0&&"object"==typeof n)return B(n)?"[Array]":"[Object]";var j=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=v.call(Array(e.indent+1)," ")}return{base:n,prev:v.call(Array(t+1),n)}}(c,i);if(void 0===a)a=[];else if(q(a,n)>=0)return"[Circular]";function G(t,n,r){if(n&&(a=y.call(a)).push(n),r){var o={depth:c.depth};return H(c,"quoteStyle")&&(o.quoteStyle=c.quoteStyle),e(t,o,i+1,a)}return e(t,c,i+1,a)}if("function"==typeof n&&!V(n)){var Z=function(e){if(e.name)return e.name;var t=O.call(_.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(n),ee=Q(n,G);return"[Function"+(Z?": "+Z:" (anonymous)")+"]"+(ee.length>0?" { "+v.call(ee,", ")+" }":"")}if(Y(n)){var te=R?g.call(String(n),/^(Symbol\(.*\))_[^)]*$/,"$1"):M.call(n);return"object"!=typeof n||R?te:z(te)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(n)){for(var ne="<"+N.call(String(n.nodeName)),re=n.attributes||[],ie=0;ie<re.length;ie++)ne+=" "+re[ie].name+"="+k(x(re[ie].value),"double",c);return ne+=">",n.childNodes&&n.childNodes.length&&(ne+="..."),ne+="</"+N.call(String(n.nodeName))+">"}if(B(n)){if(0===n.length)return"[]";var oe=Q(n,G);return j&&!function(e){for(var t=0;t<e.length;t++)if(q(e[t],"\n")>=0)return!1;return!0}(oe)?"["+J(oe,j)+"]":"[ "+v.call(oe,", ")+" ]"}if(function(e){return!("[object Error]"!==$(e)||L&&"object"==typeof e&&L in e)}(n)){var se=Q(n,G);return"cause"in Error.prototype||!("cause"in n)||P.call(n,"cause")?0===se.length?"["+String(n)+"]":"{ ["+String(n)+"] "+v.call(se,", ")+" }":"{ ["+String(n)+"] "+v.call(C.call("[cause]: "+G(n.cause),se),", ")+" }"}if("object"==typeof n&&p){if(F&&"function"==typeof n[F]&&U)return U(n,{depth:I-i});if("symbol"!==p&&"function"==typeof n.inspect)return n.inspect()}if(function(e){if(!o||!e||"object"!=typeof e)return!1;try{o.call(e);try{u.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(n)){var ae=[];return s&&s.call(n,(function(e,t){ae.push(G(t,n,!0)+" => "+G(e,n))})),X("Map",o.call(n),ae,j)}if(function(e){if(!u||!e||"object"!=typeof e)return!1;try{u.call(e);try{o.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(n)){var ce=[];return l&&l.call(n,(function(e){ce.push(G(e,n))})),X("Set",u.call(n),ce,j)}if(function(e){if(!d||!e||"object"!=typeof e)return!1;try{d.call(e,d);try{h.call(e,h)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(n))return W("WeakMap");if(function(e){if(!h||!e||"object"!=typeof e)return!1;try{h.call(e,h);try{d.call(e,d)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(n))return W("WeakSet");if(function(e){if(!E||!e||"object"!=typeof e)return!1;try{return E.call(e),!0}catch(e){}return!1}(n))return W("WeakRef");if(function(e){return!("[object Number]"!==$(e)||L&&"object"==typeof e&&L in e)}(n))return z(G(Number(n)));if(function(e){if(!e||"object"!=typeof e||!b)return!1;try{return b.call(e),!0}catch(e){}return!1}(n))return z(G(b.call(n)));if(function(e){return!("[object Boolean]"!==$(e)||L&&"object"==typeof e&&L in e)}(n))return z(f.call(n));if(function(e){return!("[object String]"!==$(e)||L&&"object"==typeof e&&L in e)}(n))return z(G(String(n)));if("undefined"!=typeof window&&n===window)return"{ [object Window] }";if("undefined"!=typeof globalThis&&n===globalThis||void 0!==t&&n===t)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==$(e)||L&&"object"==typeof e&&L in e)}(n)&&!V(n)){var ue=Q(n,G),le=D?D(n)===Object.prototype:n instanceof Object||n.constructor===Object,de=n instanceof Object?"":"null prototype",he=!le&&L&&Object(n)===n&&L in n?S.call($(n),8,-1):de?"Object":"",Ee=(le||"function"!=typeof n.constructor?"":n.constructor.name?n.constructor.name+" ":"")+(he||de?"["+v.call(C.call([],he||[],de||[]),": ")+"] ":"");return 0===ue.length?Ee+"{}":j?Ee+"{"+J(ue,j)+"}":Ee+"{ "+v.call(ue,", ")+" }"}return String(n)};var G=Object.prototype.hasOwnProperty||function(e){return e in this};function H(e,t){return G.call(e,t)}function $(e){return p.call(e)}function q(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}function K(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+A.call(t.toString(16))}function z(e){return"Object("+e+")"}function W(e){return e+" { ? }"}function X(e,t,n,r){return e+" ("+t+") {"+(r?J(n,r):v.call(n,", "))+"}"}function J(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+v.call(e,","+n)+"\n"+t.prev}function Q(e,t){var n=B(e),r=[];if(n){r.length=e.length;for(var i=0;i<e.length;i++)r[i]=H(e,i)?t(e[i],e):""}var o,s="function"==typeof I?I(e):[];if(R){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in e)H(e,c)&&(n&&String(Number(c))===c&&c<e.length||R&&o["$"+c]instanceof Symbol||(T.call(/[^\w$]/,c)?r.push(t(c,e)+": "+t(e[c],e)):r.push(c+": "+t(e[c],e))));if("function"==typeof I)for(var u=0;u<s.length;u++)P.call(e,s[u])&&r.push("["+t(s[u])+"]: "+t(e[s[u]],e));return r}}).call(this,n(34))},function(e,t){},function(e,t,n){"use strict";var r=n(43),i=Object.prototype.hasOwnProperty,o=Array.isArray,s={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:r.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1},a=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},c=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},u=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,s=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),u=a?o.slice(0,a.index):o,l=[];if(u){if(!n.plainObjects&&i.call(Object.prototype,u)&&!n.allowPrototypes)return;l.push(u)}for(var d=0;n.depth>0&&null!==(a=s.exec(o))&&d<n.depth;){if(d+=1,!n.plainObjects&&i.call(Object.prototype,a[1].slice(1,-1))&&!n.allowPrototypes)return;l.push(a[1])}if(a){if(!0===n.strictDepth)throw new RangeError("Input depth exceeded depth option of "+n.depth+" and strictDepth is true");l.push("["+o.slice(a.index)+"]")}return function(e,t,n,r){for(var i=r?t:c(t,n),o=e.length-1;o>=0;--o){var s,a=e[o];if("[]"===a&&n.parseArrays)s=n.allowEmptyArrays&&(""===i||n.strictNullHandling&&null===i)?[]:[].concat(i);else{s=n.plainObjects?Object.create(null):{};var u="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,l=n.decodeDotInKeys?u.replace(/%2E/g,"."):u,d=parseInt(l,10);n.parseArrays||""!==l?!isNaN(d)&&a!==l&&String(d)===l&&d>=0&&n.parseArrays&&d<=n.arrayLimit?(s=[])[d]=i:"__proto__"!==l&&(s[l]=i):s={0:i}}i=s}return i}(l,t,n,r)}};e.exports=function(e,t){var n=function(e){if(!e)return s;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.decodeDotInKeys&&"boolean"!=typeof e.decodeDotInKeys)throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?s.charset:e.charset,n=void 0===e.duplicates?s.duplicates:e.duplicates;if("combine"!==n&&"first"!==n&&"last"!==n)throw new TypeError("The duplicates option must be either combine, first, or last");return{allowDots:void 0===e.allowDots?!0===e.decodeDotInKeys||s.allowDots:!!e.allowDots,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:s.allowEmptyArrays,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:s.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:s.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:s.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:s.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:s.comma,decodeDotInKeys:"boolean"==typeof e.decodeDotInKeys?e.decodeDotInKeys:s.decodeDotInKeys,decoder:"function"==typeof e.decoder?e.decoder:s.decoder,delimiter:"string"==typeof e.delimiter||r.isRegExp(e.delimiter)?e.delimiter:s.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:s.depth,duplicates:n,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:s.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:s.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:s.plainObjects,strictDepth:"boolean"==typeof e.strictDepth?!!e.strictDepth:s.strictDepth,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:s.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var l="string"==typeof e?function(e,t){var n={__proto__:null},u=t.ignoreQueryPrefix?e.replace(/^\?/,""):e;u=u.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var l,d=t.parameterLimit===1/0?void 0:t.parameterLimit,h=u.split(t.delimiter,d),E=-1,f=t.charset;if(t.charsetSentinel)for(l=0;l<h.length;++l)0===h[l].indexOf("utf8=")&&("utf8=%E2%9C%93"===h[l]?f="utf-8":"utf8=%26%2310003%3B"===h[l]&&(f="iso-8859-1"),E=l,l=h.length);for(l=0;l<h.length;++l)if(l!==E){var p,_,O=h[l],S=O.indexOf("]="),g=-1===S?O.indexOf("="):S+1;-1===g?(p=t.decoder(O,s.decoder,f,"key"),_=t.strictNullHandling?null:""):(p=t.decoder(O.slice(0,g),s.decoder,f,"key"),_=r.maybeMap(c(O.slice(g+1),t),(function(e){return t.decoder(e,s.decoder,f,"value")}))),_&&t.interpretNumericEntities&&"iso-8859-1"===f&&(_=a(_)),O.indexOf("[]=")>-1&&(_=o(_)?[_]:_);var A=i.call(n,p);A&&"combine"===t.duplicates?n[p]=r.combine(n[p],_):A&&"last"!==t.duplicates||(n[p]=_)}return n}(e,n):e,d=n.plainObjects?Object.create(null):{},h=Object.keys(l),E=0;E<h.length;++E){var f=h[E],p=u(f,l[f],n,"string"==typeof e);d=r.merge(d,p,n)}return!0===n.allowSparse?d:r.compact(d)}},function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var r=new Uint8Array(16);e.exports=function(){return n(r),r}}else{var i=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),i[t]=e>>>((3&t)<<3)&255;return i}}},function(e,t){for(var n=[],r=0;r<256;++r)n[r]=(r+256).toString(16).substr(1);e.exports=function(e,t){var r=t||0,i=n;return[i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]]].join("")}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(11),i=function(){function e(e){this.table={},this.nElements=0,this.toStr=e||r.defaultToString}return e.prototype.getValue=function(e){var t=this.table["$"+this.toStr(e)];if(!r.isUndefined(t))return t.value},e.prototype.setValue=function(e,t){if(!r.isUndefined(e)&&!r.isUndefined(t)){var n,i="$"+this.toStr(e),o=this.table[i];return r.isUndefined(o)?(this.nElements++,n=void 0):n=o.value,this.table[i]={key:e,value:t},n}},e.prototype.remove=function(e){var t="$"+this.toStr(e),n=this.table[t];if(!r.isUndefined(n))return delete this.table[t],this.nElements--,n.value},e.prototype.keys=function(){var e=[];for(var t in this.table)if(r.has(this.table,t)){var n=this.table[t];e.push(n.key)}return e},e.prototype.values=function(){var e=[];for(var t in this.table)if(r.has(this.table,t)){var n=this.table[t];e.push(n.value)}return e},e.prototype.forEach=function(e){for(var t in this.table)if(r.has(this.table,t)){var n=this.table[t];if(!1===e(n.key,n.value))return}},e.prototype.containsKey=function(e){return!r.isUndefined(this.getValue(e))},e.prototype.clear=function(){this.table={},this.nElements=0},e.prototype.size=function(){return this.nElements},e.prototype.isEmpty=function(){return this.nElements<=0},e.prototype.toString=function(){var e="{";return this.forEach((function(t,n){e+="\n\t"+t+" : "+n})),e+"\n}"},e}();t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(11),i=n(45),o=function(){function e(){this.firstNode=null,this.lastNode=null,this.nElements=0}return e.prototype.add=function(e,t){if(r.isUndefined(t)&&(t=this.nElements),t<0||t>this.nElements||r.isUndefined(e))return!1;var n=this.createNode(e);if(0===this.nElements||null===this.lastNode)this.firstNode=n,this.lastNode=n;else if(t===this.nElements)this.lastNode.next=n,this.lastNode=n;else if(0===t)n.next=this.firstNode,this.firstNode=n;else{var i=this.nodeAtIndex(t-1);if(null===i)return!1;n.next=i.next,i.next=n}return this.nElements++,!0},e.prototype.first=function(){if(null!==this.firstNode)return this.firstNode.element},e.prototype.last=function(){if(null!==this.lastNode)return this.lastNode.element},e.prototype.elementAtIndex=function(e){var t=this.nodeAtIndex(e);if(null!==t)return t.element},e.prototype.indexOf=function(e,t){var n=t||r.defaultEquals;if(r.isUndefined(e))return-1;for(var i=this.firstNode,o=0;null!==i;){if(n(i.element,e))return o;o++,i=i.next}return-1},e.prototype.contains=function(e,t){return this.indexOf(e,t)>=0},e.prototype.remove=function(e,t){var n=t||r.defaultEquals;if(this.nElements<1||r.isUndefined(e))return!1;for(var i=null,o=this.firstNode;null!==o;){if(n(o.element,e))return null===i?(this.firstNode=o.next,o===this.lastNode&&(this.lastNode=null)):o===this.lastNode?(this.lastNode=i,i.next=o.next,o.next=null):(i.next=o.next,o.next=null),this.nElements--,!0;i=o,o=o.next}return!1},e.prototype.clear=function(){this.firstNode=null,this.lastNode=null,this.nElements=0},e.prototype.equals=function(t,n){var i=n||r.defaultEquals;return t instanceof e&&(this.size()===t.size()&&this.equalsAux(this.firstNode,t.firstNode,i))},e.prototype.equalsAux=function(e,t,n){for(;null!==e&&null!==t;){if(!n(e.element,t.element))return!1;e=e.next,t=t.next}return!0},e.prototype.removeElementAtIndex=function(e){if(!(e<0||e>=this.nElements||null===this.firstNode||null===this.lastNode)){var t;if(1===this.nElements)t=this.firstNode.element,this.firstNode=null,this.lastNode=null;else{var n=this.nodeAtIndex(e-1);null===n?(t=this.firstNode.element,this.firstNode=this.firstNode.next):n.next===this.lastNode&&(t=this.lastNode.element,this.lastNode=n),null!==n&&null!==n.next&&(t=n.next.element,n.next=n.next.next)}return this.nElements--,t}},e.prototype.forEach=function(e){for(var t=this.firstNode;null!==t&&!1!==e(t.element);)t=t.next},e.prototype.reverse=function(){for(var e=null,t=this.firstNode,n=null;null!==t;)n=t.next,t.next=e,e=t,t=n;n=this.firstNode,this.firstNode=this.lastNode,this.lastNode=n},e.prototype.toArray=function(){for(var e=[],t=this.firstNode;null!==t;)e.push(t.element),t=t.next;return e},e.prototype.size=function(){return this.nElements},e.prototype.isEmpty=function(){return this.nElements<=0},e.prototype.toString=function(){return i.toString(this.toArray())},e.prototype.nodeAtIndex=function(e){if(e<0||e>=this.nElements)return null;if(e===this.nElements-1)return this.lastNode;for(var t=this.firstNode,n=0;n<e&&null!==t;n++)t=t.next;return t},e.prototype.createNode=function(e){return{element:e,next:null}},e}();t.default=o},function(e,t){function n(e,t){if(!e)throw new Error(t||"AssertionError")}n.notEqual=function(e,t,r){n(e!=t,r)},n.notOk=function(e,t){n(!e,t)},n.equal=function(e,t,r){n(e==t,r)},n.ok=n,e.exports=n},function(e,t,n){"use strict";n.r(t),n.d(t,"DbConstants",(function(){return r})),n.d(t,"Migration",(function(){return i})),n.d(t,"DbService",(function(){return o})),n.d(t,"DeviceRegisterServiceImpl",(function(){return X})),n.d(t,"HttpRequestType",(function(){return a.CsHttpRequestType})),n.d(t,"ResponseCode",(function(){return a.CsHttpResponseCode})),n.d(t,"HttpSerializer",(function(){return a.CsHttpSerializer})),n.d(t,"Request",(function(){return a.CsRequest})),n.d(t,"Response",(function(){return a.CsResponse})),n.d(t,"NetworkError",(function(){return a.CsNetworkError})),n.d(t,"HttpClientError",(function(){return a.CsHttpClientError})),n.d(t,"HttpServerError",(function(){return a.CsHttpServerError})),n.d(t,"ApiServiceImpl",(function(){return G})),n.d(t,"TelemetryDecorator",(function(){return J})),n.d(t,"Actor",(function(){return pe})),n.d(t,"Context",(function(){return _e})),n.d(t,"DeviceSpecification",(function(){return Oe})),n.d(t,"Etags",(function(){return Se})),n.d(t,"ExData",(function(){return ge})),n.d(t,"GameData",(function(){return Ae})),n.d(t,"CorrelationData",(function(){return Ne})),n.d(t,"Rollup",(function(){return Te})),n.d(t,"Visit",(function(){return Ce})),n.d(t,"ProducerData",(function(){return ve})),n.d(t,"Search",(function(){return ye})),n.d(t,"TelemetryObject",(function(){return me})),n.d(t,"ProcessedEventModel",(function(){return be})),n.d(t,"AuditState",(function(){return ue})),n.d(t,"SunbirdTelemetry",(function(){return le})),n.d(t,"ObjectType",(function(){return Q})),n.d(t,"Mode",(function(){return Z})),n.d(t,"LogType",(function(){return ee})),n.d(t,"LogLevel",(function(){return te})),n.d(t,"ShareDirection",(function(){return ne})),n.d(t,"ShareType",(function(){return re})),n.d(t,"ShareItemType",(function(){return ie})),n.d(t,"LogMessage",(function(){return Ee})),n.d(t,"InteractType",(function(){return oe})),n.d(t,"InteractSubType",(function(){return se})),n.d(t,"TelemetryErrorCode",(function(){return ae})),n.d(t,"ErrorType",(function(){return ce})),n.d(t,"TelemetryInteractRequest",(function(){return Ie})),n.d(t,"TelemetryErrorRequest",(function(){return Me})),n.d(t,"TelemetryInterruptRequest",(function(){return Re})),n.d(t,"TelemetryImpressionRequest",(function(){return Le})),n.d(t,"TelemetryStartRequest",(function(){return Pe})),n.d(t,"TelemetrySummaryRequest",(function(){return De})),n.d(t,"TelemetryEndRequest",(function(){return we})),n.d(t,"TelemetryFeedbackRequest",(function(){return Ue})),n.d(t,"TelemetryLogRequest",(function(){return je})),n.d(t,"TelemetryShareRequest",(function(){return Fe})),n.d(t,"TelemetryAutoSyncModes",(function(){return de})),n.d(t,"SignInError",(function(){return xe})),n.d(t,"AuthEventType",(function(){return he})),n.d(t,"WebviewLoginSessionProvider",(function(){return Dd})),n.d(t,"WebviewManualMergeSessionProvider",(function(){return Ud})),n.d(t,"WebviewAutoMergeSessionProvider",(function(){return Ld})),n.d(t,"WebviewRunnerError",(function(){return Ve})),n.d(t,"InterruptError",(function(){return jd})),n.d(t,"NoInappbrowserSessionAssertionFailError",(function(){return Ye})),n.d(t,"ParamNotCapturedError",(function(){return Ge})),n.d(t,"NativeGoogleSessionProvider",(function(){return kd})),n.d(t,"NativeAppleSessionProvider",(function(){return Bd})),n.d(t,"WebviewStateSessionProvider",(function(){return Yd})),n.d(t,"NativeKeycloakSessionProvider",(function(){return Hd})),n.d(t,"NativeCustomBrowserSessionProvider",(function(){return qd})),n.d(t,"CourseServiceImpl",(function(){return hi})),n.d(t,"UpdateContentStateTarget",(function(){return Ei})),n.d(t,"CourseEnrollmentType",(function(){return fi})),n.d(t,"CourseBatchStatus",(function(){return pi})),n.d(t,"CertificateAlreadyDownloaded",(function(){return _i})),n.d(t,"FrameworkServiceImpl",(function(){return co})),n.d(t,"FrameworkCategoryCode",(function(){return uo})),n.d(t,"FrameworkCategoryCodesGroup",(function(){return lo})),n.d(t,"FrameworkUtilServiceImpl",(function(){return Ao})),n.d(t,"TrackingEnabled",(function(){return Dn.TrackingEnabled})),n.d(t,"ContentDeleteStatus",(function(){return _n})),n.d(t,"SortOrder",(function(){return On})),n.d(t,"MarkerType",(function(){return Sn})),n.d(t,"SearchType",(function(){return gn})),n.d(t,"ChildContents",(function(){return An})),n.d(t,"State",(function(){return Nn})),n.d(t,"MimeType",(function(){return Tn})),n.d(t,"Visibility",(function(){return Cn})),n.d(t,"ContentStatus",(function(){return vn})),n.d(t,"ContentEncoding",(function(){return yn})),n.d(t,"ContentDisposition",(function(){return mn})),n.d(t,"FileExtension",(function(){return bn})),n.d(t,"ContentImportStatus",(function(){return In})),n.d(t,"ContentErrorCode",(function(){return Mn})),n.d(t,"ErrorCode",(function(){return Rn})),n.d(t,"FileName",(function(){return Ln})),n.d(t,"ContentEventType",(function(){return Pn})),n.d(t,"ContentMapper",(function(){return xn})),n.d(t,"UserFeedCategory",(function(){return Qn.UserFeedCategory})),n.d(t,"UserFeedStatus",(function(){return Qn.UserFeedStatus})),n.d(t,"ProfileType",(function(){return zn})),n.d(t,"ProfileSource",(function(){return Wn})),n.d(t,"ProfileSession",(function(){return Zn})),n.d(t,"ContentAccess",(function(){return er})),n.d(t,"ContentAccessStatus",(function(){return Xn})),n.d(t,"ProfileServiceImpl",(function(){return Fi})),n.d(t,"NoActiveSessionError",(function(){return ki})),n.d(t,"NoProfileFoundError",(function(){return xi})),n.d(t,"GroupMembershipType",(function(){return Kd.GroupMembershipType})),n.d(t,"GroupMemberRole",(function(){return Kd.GroupMemberRole})),n.d(t,"GroupEntityStatus",(function(){return Kd.GroupEntityStatus})),n.d(t,"GroupSessionDeprecated",(function(){return wl})),n.d(t,"NoGroupFoundError",(function(){return Ul})),n.d(t,"NoActiveGroupSessionError",(function(){return jl})),n.d(t,"PageName",(function(){return na})),n.d(t,"SunbirdSdk",(function(){return bd})),n.d(t,"EventNamespace",(function(){return M})),n.d(t,"ErrorEventType",(function(){return R})),n.d(t,"SystemSettingsServiceImpl",(function(){return ka})),n.d(t,"SummarizerServiceImpl",(function(){return wr})),n.d(t,"ContentCache",(function(){return Ur})),n.d(t,"ReportDetailPerUser",(function(){return jr})),n.d(t,"SummarizerHandler",(function(){return Fr})),n.d(t,"SummarizerQueries",(function(){return kr})),n.d(t,"SummaryTelemetryEventHandler",(function(){return Ai})),n.d(t,"CachedItemRequestSourceFrom",(function(){return Jn})),n.d(t,"StorageDestination",(function(){return Va})),n.d(t,"StorageEventType",(function(){return Ya})),n.d(t,"ExistingContentAction",(function(){return Ga})),n.d(t,"TransferFailedDuplicateContentError",(function(){return Ha})),n.d(t,"TransferFailedError",(function(){return $a})),n.d(t,"NotificationType",(function(){return hu})),n.d(t,"NotificationStatus",(function(){return Eu})),n.d(t,"CodePUshExperimentServiceImpl",(function(){return Zu})),n.d(t,"FaqServiceImpl",(function(){return il})),n.d(t,"ArchiveObjectType",(function(){return ol})),n.d(t,"ExportAssertionError",(function(){return sl})),n.d(t,"InvalidRequestError",(function(){return al})),n.d(t,"ObjectNotFoundError",(function(){return cl})),n.d(t,"FetchSegmentationTagHandler",(function(){return Xl})),n.d(t,"FetchSegmentationCommandHandler",(function(){return Jl})),n.d(t,"StoreSegmentationTagHandler",(function(){return Ql})),n.d(t,"StoreSegmentationCommandHandler",(function(){return Zl})),n.d(t,"SegmentationServiceImpl",(function(){return rd})),n.d(t,"DebuggingDurationHandler",(function(){return sd})),n.d(t,"DebuggingServiceImpl",(function(){return dd})),n.d(t,"CertificateServiceImpl",(function(){return yd})),n.d(t,"DownloadEventType",(function(){return $r})),n.d(t,"DownloadStatus",(function(){return qr})),n.d(t,"PlayerServiceImpl",(function(){return Ac})),n.d(t,"NetworkStatus",(function(){return Vn})),n.d(t,"ValidationError",(function(){return Rr}));n(52);class r{}r.DATE_TYPE="DATE",r.TEXT_TYPE="TEXT",r.INT_TYPE="INTEGER",r.REAL_TYPE="REAL",r.COMMA_SEP=",",r.SPACE=" ",r.MAX_NUM_OF_EVENTS=1e3,r.MAX_NUM_OF_PROCESSED_EVENTS=1,r.ERROR="DB_ERROR",r.BLOB_TYPE="BLOB",r.NOT_NULL="NOT NULL",r.NULL="NULL";class i{constructor(e,t){this.targetDbVersion=t,this.migrationNumber=e}required(e,t){return e<this.targetDbVersion&&this.targetDbVersion<=t}}class o{}var s=n(2),a=n(4),c=n(1);const u={HTTP_SERVICE:Symbol.for("CS_HTTP_SERVICE"),GROUP_SERVICE:Symbol.for("CS_GROUP_SERVICE"),COURSE_SERVICE:Symbol.for("CS_COURSE_SERVICE"),USER_SERVICE:Symbol.for("CS_USER_SERVICE"),DISCUSSION_SERVICE:Symbol.for("CS_DISCUSSION_SERVICE"),CONTENT_SERVICE:Symbol.for("CS_CONTENT_SERVICE"),NOTIFICATION_SERVICE_V2:Symbol.for("CS_NOTIFICATION_SERVICE"),CERTIFICATE_SERVICE:Symbol.for("CS_CERTIFICATE_SERVICE"),FRAMEWORK_SERVICE:Symbol.for("CS_FRAMEWORK_SERVICE")},l={CONTAINER:Symbol.for("CONTAINER"),DB_VERSION:Symbol.for("DB_VERSION"),DB_MIGRATION_LIST:Symbol.for("DB_MIGRATION_LIST"),SDK_CONFIG:Symbol.for("SDK_CONFIG"),DEVICE_INFO:Symbol.for("DEVICE_INFO"),SHARED_PREFERENCES:Symbol.for("SHARED_PREFERENCES"),EVENTS_BUS_SERVICE:Symbol.for("EVENTS_BUS_SERVICE"),DB_SERVICE:Symbol.for("DB_SERVICE"),APP_INFO:Symbol.for("APP_INFO"),API_SERVICE:Symbol.for("API_SERVICE"),AUTH_SERVICE:Symbol.for("AUTH_SERVICE"),FILE_SERVICE:Symbol.for("FILE_SERVICE"),SYSTEM_SETTINGS_SERVICE:Symbol.for("SYSTEM_SETTINGS_SERVICE"),FRAMEWORK_SERVICE:Symbol.for("FRAMEWORK_SERVICE"),PROFILE_SERVICE:Symbol.for("PROFILE_SERVICE"),GROUP_SERVICE:Symbol.for("GROUP_SERVICE"),GROUP_SERVICE_DEPRECATED:Symbol.for("GROUP_SERVICE_DEPRECATED"),ZIP_SERVICE:Symbol.for("ZIP_SERVICE"),TELEMETRY_SERVICE:Symbol.for("TELEMETRY_SERVICE"),CONTENT_FEEDBACK_SERVICE:Symbol.for("CONTENT_FEEDBACK_SERVICE"),FORM_SERVICE:Symbol.for("FORM_SERVICE"),PAGE_ASSEMBLE_SERVICE:Symbol.for("PAGE_ASSEMBLE_SERVICE"),FRAMEWORK_UTIL_SERVICE:Symbol.for("FRAMEWORK_UTIL_SERVICE"),DOWNLOAD_SERVICE:Symbol.for("DOWNLOAD_SERVICE"),CONTENT_SERVICE:Symbol.for("CONTENT_SERVICE"),COURSE_SERVICE:Symbol.for("COURSE_SERVICE"),SUMMARIZER_SERVICE:Symbol.for("SUMMARIZER_SERVICE"),PLAYER_SERVICE:Symbol.for("PLAYER_SERVICE"),CACHED_ITEM_STORE:Symbol.for("CACHED_ITEM_STORE"),KEY_VALUE_STORE:Symbol.for("KEY_VALUE_STORE"),TELEMETRY_DECORATOR:Symbol.for("TELEMETRY_DECORATOR"),STORAGE_SERVICE:Symbol.for("STORAGE_SERVICE"),NOTIFICATION_SERVICE:Symbol.for("NOTIFICATION_SERVICE"),ERROR_LOGGER_SERVICE:Symbol.for("ERROR_LOGGER_SERVICE"),NETWORKINFO_SERVICE:Symbol.for("NETWORKINFO_SERVICE"),SEARCH_HISTORY_SERVICE:Symbol.for("SEARCH_HISTORY_SERVICE"),CODEPUSH_EXPERIMENT_SERVICE:Symbol.for("CODEPUSH_EXPERIMENT_SERVICE"),FAQ_SERVICE:Symbol.for("FAQ_SERVICE"),DEVICE_REGISTER_SERVICE:Symbol.for("DEVICE_REGISTER_SERVICE"),CONTENT_RATING_SERVICE:Symbol.for("CONTENT_RATING_SERVICE"),ARCHIVE_SERVICE:Symbol.for("ARCHIVE_SERVICE"),NETWORK_QUEUE:Symbol.for("NETWORK_QUEUE"),CLASS_ROOM_SERVICE:Symbol.for("CLASS_ROOM_SERVICE"),DISCUSSION_SERVICE:Symbol.for("DISCUSSION_SERVICE"),SEGMENTATION_SERVICE:Symbol.for("SEGMENTATION_SERVICE"),DEBUGGING_SERVICE:Symbol.for("DEBUGGING_SERVICE"),NOTIFICATION_SERVICE_V2:Symbol.for("NOTIFICATION_SERVICE_V2"),CERTIFICATE_SERVICE:Symbol.for("CERTIFICATE_SERVICE")};var d,h,E,f,p,_,O,S,g,A,N,T,C,v,y;!function(e){e.KEY_FIRST_ACCESS_TIMESTAMP="first_access_timestamp"}(d||(d={})),function(e){e.KEY_API_TOKEN="api_bearer_token_v2"}(h||(h={})),function(e){e.KEY_OAUTH_SESSION="oauth_token"}(E||(E={})),function(e){e.KEY_GROUP_SESSION="group_session"}(f||(f={})),function(e){e.KEY_USER_SESSION="session"}(p||(p={})),function(e){e.KEY_ACTIVE_CHANNEL_ID="channelId",e.KEY_ACTIVE_CHANNEL_ACTIVE_FRAMEWORK_ID="sunbirdcurrent_framework_id"}(_||(_={})),function(e){e.KEY_TO_DOWNLOAD_LIST="to_download_list"}(O||(O={})),function(e){e.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL="is_update_size_on_device_successful",e.KEY_CONTENT_DELETE_REQUEST_LIST="content_delete_request_list",e.KEY_LAST_MODIFIED="last_modified",e.UPDATE_CONTENT_STATE="update_content_state",e.COURSE_CONTEXT="sunbirdcontent_context"}(S||(S={})),function(e){e.KEY_STORAGE_DESTINATION="storage_destination",e.KEY_TO_TRANSFER_LIST="to_transfer_list"}(g||(g={})),function(e){e.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP="error_log_last_synced_time_stamp"}(A||(A={})),function(e){e.DEPLOYMENT_KEY="deployment_key"}(N||(N={})),function(e){e.DEFAULT_DEPLOYMENT_KEY="default_deployment_key",e.EXPERIMENT_KEY="experiment_key",e.EXPERIMENT_APP_VERSION="emperiment_app_version"}(T||(T={})),function(e){e.DEVICE_LOCATION="device_location_new"}(C||(C={})),function(e){e.KEY_LAST_SYNCED_TIME_STAMP="telemetry_last_synced_time_stamp",e.KEY_AUTO_SYNC_MODE="telemetry_auto_sync_mode"}(v||(v={})),function(e){e.KEY_ORGANISATION_ID="page_assemble_organisation_id"}(y||(y={}));var m=n(6),b=n.n(m);class I{static decodeJWT(e){return new Promise((t,n)=>sbutility.decodeJWTToken(e,e=>{t(e)},e=>{n(e)}))}static createJWTToken(e,t){return new Promise((n,r)=>{sbutility.getJWTToken(e,t,e=>{n(e)},e=>{r(e)})})}}var M,R,L=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class P{constructor(e,t,n){this.config=e,this.apiService=t,this.deviceInfo=n}refreshAuthToken(){return Object(c.from)(this.getBearerTokenFromKongV2())}getMobileDeviceConsumerKey(){return this.config.api_authentication.producerId+"-"+this.deviceInfo.getDeviceID()}buildGetMobileDeviceConsumerSecretAPIRequest(e){return L(this,void 0,void 0,(function*(){return(new a.CsRequest.Builder).withPath(e).withType(a.CsHttpRequestType.POST).withHeaders({"Content-Encoding":"gzip",Authorization:"Bearer "+(yield this.generateMobileAppConsumerBearerToken())}).withBody({id:P.ID,ver:P.VERSION,ts:b()().format(),request:{key:this.getMobileDeviceConsumerKey()}}).build()}))}getBearerTokenFromKongV2(){return L(this,void 0,void 0,(function*(){const e=`/api/api-manager/v2/consumer/${this.config.api_authentication.mobileAppConsumer}/credential/register`;let t=yield this.buildGetMobileDeviceConsumerSecretAPIRequest(e);return this.apiService.fetch(t).toPromise().then(e=>e.body.result.token).catch(e=>{if(!a.CsNetworkError.isInstance(e)){const t=`/api/api-manager/v1/consumer/${this.config.api_authentication.mobileAppConsumer}/credential/register`;if(e.response.responseCode===a.CsHttpResponseCode.HTTP_KONG_FAILURE){const n=e.response.headers,r=n?n.location:t;return this.getBearerTokenFromFallback(r||t)}return this.getBearerTokenFromFallback(t)}throw e})}))}getBearerTokenFromFallback(e){return L(this,void 0,void 0,(function*(){let t=yield this.buildGetMobileDeviceConsumerSecretAPIRequest(e);return this.apiService.fetch(t).toPromise().then(e=>L(this,void 0,void 0,(function*(){const t=e.body.result;return t.token?t.token:yield I.createJWTToken(this.getMobileDeviceConsumerKey(),t.secret)}))).catch(e=>{console.log("e ",e)})}))}generateMobileAppConsumerBearerToken(){return L(this,void 0,void 0,(function*(){const e=this.config.api_authentication.mobileAppKey,t=this.config.api_authentication.mobileAppSecret;return yield I.createJWTToken(e,t)}))}}P.VERSION="1.0",P.ID="ekstep.genie.device.register",function(e){e.AUTH="AUTH",e.TELEMETRY="TELEMETRY",e.DOWNLOADS="DOWNLOADS",e.CONTENT="CONTENT",e.ERROR="ERROR",e.STORAGE="STORAGE"}(M||(M={})),function(e){e.HTTP_SERVER_ERROR="HTTP_SERVER_ERROR",e.HTTP_CLIENT_ERROR="HTTP_CLIENT_ERROR",e.AUTH_TOKEN_REFRESH_ERROR="AUTH_TOKEN_REFRESH_ERROR",e.PLANNED_MAINTENANCE_PERIOD="PLANNED_MAINTENANCE_PERIOD"}(R||(R={}));var D=n(0),w=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class U{constructor(e,t,n,r){this.sharedPreferences=e,this.apiConfig=t,this.deviceInfo=n,this.apiService=r,this.apiTokenHandler=new P(this.apiConfig,this.apiService,this.deviceInfo)}interceptResponse(e,t){return t.responseCode===a.CsHttpResponseCode.HTTP_UNAUTHORISED&&"Unauthorized"===t.body.message||t.responseCode===a.CsHttpResponseCode.HTTP_FORBIDDEN?this.apiTokenHandler.refreshAuthToken().pipe(Object(D.tap)(e=>w(this,void 0,void 0,(function*(){yield this.sharedPreferences.putString(h.KEY_API_TOKEN,e).toPromise()}))),Object(D.mergeMap)(()=>this.apiService.fetch(e))):Object(c.of)(t)}}class j{constructor(e,t){this.apiService=e,this.authService=t}interceptResponse(e,t){return t.responseCode!==a.CsHttpResponseCode.HTTP_UNAUTHORISED||t.body.message?Object(c.of)(t):this.invokeRefreshSessionTokenApi().pipe(Object(D.mergeMap)(()=>this.apiService.fetch(e)))}invokeRefreshSessionTokenApi(){return this.authService.refreshSession()}}var F,k=n(3),x=n(25),B=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},V=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Y=function(e,t){return function(n,r){t(n,r,e)}};let G=F=class{constructor(e,t,n,r,i,o){this.container=e,this.sdkConfig=t,this.deviceInfo=n,this.sharedPreferences=r,this.eventsBusService=i,this.httpService=o,this.hasEmittedPlannedMaintenanceErrorEvent=!1,this.defaultRequestInterceptors=[],this.defaultResponseInterceptors=[],this.apiConfig=this.sdkConfig.apiConfig,this.apiConfig.debugMode&&(this.defaultRequestInterceptors=[new x.CsRequestLoggerInterceptor],this.defaultResponseInterceptors=[new x.CsResponseLoggerInterceptor])}get bearerTokenRefreshInterceptor(){return this._bearerTokenRefreshInterceptor||(this._bearerTokenRefreshInterceptor=new U(this.container.get(l.SHARED_PREFERENCES),this.container.get(l.SDK_CONFIG).apiConfig,this.container.get(l.DEVICE_INFO),this.container.get(l.API_SERVICE))),this._bearerTokenRefreshInterceptor}get userTokenRefreshInterceptor(){return this._userTokenRefreshInterceptor||(this._userTokenRefreshInterceptor=new j(this.container.get(l.API_SERVICE),this.container.get(l.AUTH_SERVICE))),this._userTokenRefreshInterceptor}onInit(){return this.sharedPreferences.addListener(h.KEY_API_TOKEN,e=>{k.CsModule.instance.config.core.api.authentication.bearerToken=e||void 0,k.CsModule.instance.updateConfig(k.CsModule.instance.config)}),this.sharedPreferences.getString(h.KEY_API_TOKEN).pipe(Object(D.mergeMap)(e=>e?(k.CsModule.instance.config.core.api.authentication.bearerToken=e,k.CsModule.instance.updateConfig(k.CsModule.instance.config),Object(c.of)(void 0)):new P(this.apiConfig,this,this.deviceInfo).refreshAuthToken().pipe(Object(D.mergeMap)(e=>this.sharedPreferences.putString(h.KEY_API_TOKEN,e)),Object(D.catchError)(()=>Object(c.of)(void 0)))))}fetch(e){if(this.defaultRequestInterceptors.forEach(t=>{-1===e.requestInterceptors.indexOf(t)&&e.requestInterceptors.push(t)}),this.defaultResponseInterceptors.forEach(t=>{-1===e.responseInterceptors.indexOf(t)&&e.responseInterceptors.push(t)}),e.withBearerToken){const t=e.responseInterceptors.indexOf(this.bearerTokenRefreshInterceptor);-1===t?e.responseInterceptors.push(this.bearerTokenRefreshInterceptor):e.responseInterceptors.splice(t,1)}if(e.withUserToken){const t=e.responseInterceptors.indexOf(this.userTokenRefreshInterceptor);-1===t?e.responseInterceptors.push(this.userTokenRefreshInterceptor):e.responseInterceptors.splice(t,1)}return this.httpService.fetch(e).pipe(Object(D.catchError)(e=>(a.CsHttpServerError.isInstance(e)?(this.eventsBusService.emit({namespace:M.ERROR,event:{type:R.HTTP_SERVER_ERROR,payload:e}}),e.response.responseCode===F.PLANNED_MAINTENANCE_ERROR_CODE&&(this.hasEmittedPlannedMaintenanceErrorEvent||(this.hasEmittedPlannedMaintenanceErrorEvent=!0,this.eventsBusService.emit({namespace:M.ERROR,event:{type:R.PLANNED_MAINTENANCE_PERIOD,payload:e}})))):a.CsHttpClientError.isInstance(e)&&this.eventsBusService.emit({namespace:M.ERROR,event:{type:R.HTTP_CLIENT_ERROR,payload:e}}),Object(c.throwError)(e))))}setDefaultRequestInterceptors(e){this.defaultRequestInterceptors=e,this.apiConfig.debugMode&&this.defaultRequestInterceptors.push(new x.CsRequestLoggerInterceptor)}setDefaultResponseInterceptors(e){this.defaultResponseInterceptors=e,this.apiConfig.debugMode&&this.defaultResponseInterceptors.push(new x.CsResponseLoggerInterceptor)}};G.PLANNED_MAINTENANCE_ERROR_CODE=531,G=F=B([Object(s.injectable)(),Y(0,Object(s.inject)(l.CONTAINER)),Y(1,Object(s.inject)(l.SDK_CONFIG)),Y(2,Object(s.inject)(l.DEVICE_INFO)),Y(3,Object(s.inject)(l.SHARED_PREFERENCES)),Y(4,Object(s.inject)(l.EVENTS_BUS_SERVICE)),Y(5,Object(s.inject)(u.HTTP_SERVICE)),V("design:paramtypes",[s.Container,Object,Object,Object,Object,Object])],G);var H=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ${constructor(e,t,n,r,i,o,s){this.sdkConfig=e,this.deviceInfo=t,this.sharedPreferences=n,this.frameworkService=r,this.appInfoService=i,this.apiService=o,this.getDeviceProfileHandler=s,this.deviceRegisterConfig=this.sdkConfig.deviceRegisterConfig,this.apiConfig=this.sdkConfig.apiConfig}handle(e){return this.registerDevice(e)}registerDevice(e){return Object(c.zip)(this.deviceInfo.getDeviceSpec(),this.frameworkService.getActiveChannelId(),this.appInfoService.getFirstAccessTimestamp(),this.sharedPreferences.getString(C.DEVICE_LOCATION)).pipe(Object(D.mergeMap)(t=>H(this,void 0,void 0,(function*(){const n=t[0],r=t[1],i=t[2],o=t[3];if(!(e=Object.assign(Object.assign({},e||{}),{dspec:n,channel:r,fcmToken:this.deviceRegisterConfig.fcmToken,producer:this.apiConfig.api_authentication.producerId,first_access:Number(i)})).userDeclaredLocation&&o&&(e.userDeclaredLocation=JSON.parse(o),!e.userDeclaredLocation.declaredOffline))try{const t=yield this.getDeviceProfileHandler.handle().toPromise();t.userDeclaredLocation&&t.userDeclaredLocation.state&&t.userDeclaredLocation.district||(delete e.userDeclaredLocation,this.sharedPreferences.putString(C.DEVICE_LOCATION,"").toPromise())}catch(t){console.error(t),delete e.userDeclaredLocation}e.userDeclaredLocation&&delete e.userDeclaredLocation.declaredOffline;const s=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.deviceRegisterConfig.apiPath+$.DEVICE_REGISTER_ENDPOINT+"/"+this.deviceInfo.getDeviceID()).withBearerToken(!0).withBody({request:e}).build();return this.apiService.fetch(s).pipe(Object(D.map)(e=>e.body),Object(D.tap)(()=>{e.userDeclaredLocation&&this.sharedPreferences.putString(C.DEVICE_LOCATION,JSON.stringify(e.userDeclaredLocation)).toPromise()})).toPromise()}))))}}$.DEVICE_REGISTER_ENDPOINT="/register";class q{constructor(e,t,n){this.sdkConfig=e,this.deviceInfo=t,this.apiService=n,this.deviceRegisterConfig=this.sdkConfig.deviceRegisterConfig,this.apiConfig=this.sdkConfig.apiConfig}handle(){return this.fetchFromServer()}fetchFromServer(){return this.apiService.fetch((new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.deviceRegisterConfig.apiPath+q.GET_DEVICE_PROFILE_ENDPOINT+"/"+this.deviceInfo.getDeviceID()).withBearerToken(!0).build()).pipe(Object(D.map)(e=>e.body.result))}}q.GET_DEVICE_PROFILE_ENDPOINT="/profile";var K=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},z=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},W=function(e,t){return function(n,r){t(n,r,e)}};let X=class{constructor(e,t,n,r,i,o){this.sdkConfig=e,this.deviceInfo=t,this.sharedPreferences=n,this.frameworkService=r,this.appInfoService=i,this.apiService=o,this.getDeviceProfileHandler=new q(this.sdkConfig,this.deviceInfo,this.apiService),this.deviceRegisterHandler=new $(this.sdkConfig,this.deviceInfo,this.sharedPreferences,this.frameworkService,this.appInfoService,this.apiService,this.getDeviceProfileHandler)}registerDevice(e){return this.deviceRegisterHandler.handle(e)}getDeviceProfile(){return this.getDeviceProfileHandler.handle()}};X=K([Object(s.injectable)(),W(0,Object(s.inject)(l.SDK_CONFIG)),W(1,Object(s.inject)(l.DEVICE_INFO)),W(2,Object(s.inject)(l.SHARED_PREFERENCES)),W(3,Object(s.inject)(l.FRAMEWORK_SERVICE)),W(4,Object(s.inject)(l.APP_INFO)),W(5,Object(s.inject)(l.API_SERVICE)),z("design:paramtypes",[Object,Object,Object,Object,Object,Object])],X);class J{}var Q,Z,ee,te,ne,re,ie,oe,se,ae,ce,ue,le,de,he;!function(e){e.NOTIFICATION="notification",e.USER="User",e.GROUP="Group",e.CONTENT="Content",e.QUESTION="Question"}(Q||(Q={})),function(e){e.PLAY="play"}(Z||(Z={})),function(e){e.NOTIFICATION="notification"}(ee||(ee={})),function(e){e.TRACE="TRACE",e.DEBUG="DEBUG",e.INFO="INFO",e.WARN="WARN",e.ERROR="ERROR",e.FATAL="FATAL"}(te||(te={})),function(e){e.IN="In",e.OUT="Out"}(ne||(ne={})),function(e){e.FILE="File",e.MESSAGE="Message",e.LINK="Link"}(re||(re={})),function(e){e.CONTENT="CONTENT",e.EXPLODEDCONTENT="EXPLODEDCONTENT",e.TELEMETRY="TELEMETRY",e.PROFILE="PROFILE"}(ie||(ie={}));class Ee{constructor(){this.RECEIVED="Received",this.DISPLAYED="Displayed"}}!function(e){e.TOUCH="TOUCH",e.OTHER="OTHER"}(oe||(oe={})),function(e){e.NETWORK_SPEED="network-speed",e.SUBTYPE_SPINE="spine",e.ONLINE="online",e.FULL="full",e.CONTENT_VARIANT="content-variant-download",e.DEVICE_TIME_OFFSET_FOUND="device-time-offset-found",e.CONTENT_DOWNLOAD_INITIATE="ContentDownload-Initiate",e.CONTENT_DOWNLOAD_SUCCESS="ContentDownload-Success",e.CONTENT_DOWNLOAD_CANCEL="ContentDownload-Cancel"}(se||(se={})),function(e){e.ERR_DOWNLOAD_FAILED="ERR_DOWNLOAD_FAILED"}(ae||(ae={})),function(e){e.SYSTEM="SYSTEM"}(ce||(ce={}));class fe{static toFixed(e){return Number(e.toFixed(2))}static parseInt(e){return e?parseInt(e,10):0}static round(e){return Number(Math.round(parseFloat(e+"e4"))+"e-4")}}class pe{constructor(){this.type=pe.TYPE_USER}}pe.TYPE_SYSTEM="System",pe.TYPE_USER="Guest user";class _e{}class Oe{constructor(){this.os="",this.make="",this.id="",this.mem=-1,this.idisk=-1,this.edisk=-1,this.scrn=-1,this.cpu="",this.sims=-1,this.cap=[]}}class Se{}class ge{}class Ae{}class Ne{}class Te{}class Ce{}class ve{ProducerData(){this.id="",this.pid="",this.ver=""}}class ye{}class me{constructor(e,t,n){this.id=e,this.type=t,this.version=n}setRollup(e){this.rollup=e}}class be{}!function(e){e.AUDIT_CREATED="Created",e.AUDIT_UPDATED="Updated",e.AUDIT_DELETED="Deleted"}(ue||(ue={})),function(e){class t{constructor(e){this.ver=t.TELEMETRY_VERSION,this.eid=e,this.ets=Date.now(),this.actor=new pe,this.context=new _e,this.edata={}}}t.TELEMETRY_VERSION="3.0",e.Telemetry=t;class n extends t{constructor(e,t,r,i,o,s,a="",c="",u="",l={},d=[],h){super(n.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e?{type:e}:{}),r?{duration:r}:{}),i?{pageid:i}:{}),t?{mode:t}:{}),o?{summaryList:o}:{}),this.context.cdata=d,this.context.env=s,this.object=new me(a,c,u),this.object.rollup=l,this.actor=h||new pe}}n.EID="END",e.End=n;class r extends t{constructor(e="",t,n,i,o,s,a,c="",u="",l="",d={},h=[],E){super(r.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e?{type:e}:{type:""}),t?{dspec:t}:{}),n?{loc:n}:{}),i?{mode:i}:{}),o?{mode:i}:{}),s?{pageid:s}:{}),this.context.cdata=h,this.context.env=a,this.object=new me(c,u,l),this.object.rollup=d||{},this.actor=E||new pe}}r.EID="START",e.Start=r;class i extends t{constructor(e,t,n,r,o,s,a,c,u,l,d,h,E=[],f="",p="",_="",O={}){super(i.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({type:e,starttime:t,endtime:n,timespent:r,pageviews:o,interactions:s},c?{mode:c}:{}),u?{envsummary:u}:{}),l?{eventsummary:l}:{}),d?{pagesummary:d}:{}),h?{extra:h}:{}),this.context.cdata=E,this.context.env=a,this.object=new me(f,p,_),this.object.rollup=O||{}}}i.EID="SUMMARY",e.Summary=i;class o extends t{constructor(e,t,n,r,i,s,a,c="",u="",l="",d={},h=[],E,f){super(o.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign({type:e},{subtype:t}),n?{id:n}:{}),r?{pageid:r}:{}),{extra:Object.assign(Object.assign({},i?{pos:i}:{}),s?{values:[s]}:{})}),this.context.cdata=h,this.context.env=a,this.context.pdata=E||new ve,this.actor=f||new pe,this.object=new me(c,u,l),this.object.rollup=d||{}}}o.EID="INTERACT",e.Interact=o;class s extends t{constructor(e,t,n,r,i,o="",a="",c="",u={},l=[],d){super(s.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e?{type:e}:{type:""}),t?{subtype:t}:{}),n?{pageid:n}:{}),n?{uri:n}:{}),r?{visits:r}:{}),this.context.cdata=l,this.context.env=i,this.object=new me(o||"",a||"",c||""),this.object.rollup=u||{},this.actor=d||new pe}}s.EID="IMPRESSION",e.Impression=s;class a extends t{constructor(e,t,n,r,i,o,s){super(a.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e?{type:e}:{type:""}),t?{level:t}:{}),n?{message:n}:{}),r?{pageid:r}:{}),i?{params:i}:{}),this.context.env=o;const c=new pe;c.type=s,this.actor=c}}a.EID="LOG",e.Log=a;class c extends t{constructor(e,t,n,r,i){super(c.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign({},e?{err:e}:{}),t?{errtype:t}:{}),n?{stacktrace:n}:{}),r?{pageid:r}:{}),this.actor=i||new pe}}c.EID="ERROR",e.Error=c;class u extends t{constructor(e,t,n){super(u.EID),this.edata=Object.assign({type:e},t?{pageid:t}:{}),this.actor=n||new pe}}u.EID="INTERRUPT",e.Interrupt=u;class l extends t{constructor(e,t,n,r=[],i="",o="",s="",a=new Te){super(l.EID),this.edata=Object.assign(Object.assign(Object.assign({},e?{dir:e}:{}),t?{type:t}:{}),n?{items:n}:{}),this.context.cdata=r,this.object=new me(i||"",o||"",s||""),this.object.rollup=a}addItem(e,t,n,r,i,o){const s={};if(s.origin=t,s.id=n,s.type=this.capitalize(e.valueOf()),e.valueOf()===ie.CONTENT.valueOf()||e.valueOf()===ie.EXPLODEDCONTENT.valueOf()){s.ver=r.toString();const e=[],t={};t.transfers=fe.parseInt(i),t.size=o,e.push(t),s.params=e}const a={};a.id=t,a.type="Device",s.origin=a,this.edata.items.push(s)}capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}}l.EID="SHARE",e.Share=l;class d extends t{constructor(e,t,n,r="",i="",o="",s,a){super(d.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign({},e?{rating:e}:{}),s?{commentid:s}:{}),a?{commenttxt:a}:{}),t?{comments:t}:{}),this.context.env=n,this.object=new me(r,i,o),this.object.rollup={}}}d.EID="FEEDBACK",e.Feedback=d;class h extends t{constructor(e,t,n,r,i,o="",s="",a="",c=[],u={}){super(h.EID),this.edata=Object.assign(Object.assign({state:n},r?{props:r}:{}),{type:i}),this.context.cdata=c,this.context.env=e,this.object=new me(o,s,a),this.object.rollup=u||{},this.actor=t}}h.EID="AUDIT",e.Audit=h}(le||(le={}));class Ie{constructor(){this.pos=[]}}class Me{}class Re{}class Le{}class Pe{}class De{}class we{}class Ue{}class je{}class Fe{constructor(){this.items=[]}}!function(e){e.OFF="OFF",e.OVER_WIFI="OVER_WIFI",e.ALWAYS_ON="ALWAYS_ON"}(de||(de={}));class ke extends Error{constructor(e,t){super(e),this._code=t,Object.setPrototypeOf(this,ke.prototype)}get code(){return this._code}}class xe extends ke{constructor(e){super(e,"SIGN_IN_ERROR"),Object.setPrototypeOf(this,xe.prototype)}}!function(e){e.AUTO_MIGRATE_SUCCESS="AUTO_MIGRATE_SUCCESS",e.AUTO_MIGRATE_FAIL="AUTO_MIGRATE_FAIL"}(he||(he={}));var Be=n(12);class Ve extends ke{constructor(e,t){super(e,t),Object.setPrototypeOf(this,Ve.prototype)}}class Ye extends Ve{constructor(e){super(e,"NO_INAPPBROWSER_SESSION_ASSERTION_FAIL"),Object.setPrototypeOf(this,Ve.prototype)}}class Ge extends Ve{constructor(e){super(e,"PARAM_NOT_CAPTURED"),Object.setPrototypeOf(this,Ge.prototype)}}var He,$e,qe,Ke,ze,We,Xe,Je,Qe,Ze,et,tt,nt,rt,it,ot,st,at,ct,ut,lt,dt,ht,Et,ft,pt,_t,Ot,St,gt,At,Nt,Tt,Ct,vt,yt,mt,bt,It,Mt,Rt,Lt,Pt,Dt,wt,Ut,jt,Ft,kt,xt,Bt,Vt,Yt=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Gt{constructor(){this.extras={},this.captured={}}static buildUrl(e,t,n){return`${e}${t}?${Be.stringify(n)}`}resetInAppBrowserEventListeners(){if(!this.inAppBrowser)throw new Ye("InAppBrowser Session not found when resetInAppBrowserEventListeners()");for(const e in this.inAppBrowser.listeners)this.inAppBrowser.listeners.hasOwnProperty(e)&&(this.inAppBrowser.listeners[e].forEach(t=>{this.inAppBrowser.ref.removeEventListener(e,t)}),this.inAppBrowser.listeners[e].clear())}launchWebview({host:e,path:t,params:n}){return Yt(this,void 0,void 0,(function*(){this.inAppBrowser={ref:cordova.InAppBrowser.open(Gt.buildUrl(e,t,n),"_blank","zoom=no,clearcache=yes,clearsessioncache=yes,cleardata=yes"),listeners:{loadstart:new Set,exit:new Set}};const r=()=>{this.resetInAppBrowserEventListeners(),this.inAppBrowser=void 0};this.inAppBrowser.listeners.exit.add(r),this.inAppBrowser.ref.addEventListener("exit",r)}))}closeWebview(){return Yt(this,void 0,void 0,(function*(){if(!this.inAppBrowser)throw new Ye("InAppBrowser Session not found");this.inAppBrowser.ref.close()}))}any(...e){return Object(c.race)(...e).pipe(Object(D.take)(1)).toPromise()}all(...e){return Object(c.zip)(...e).pipe(Object(D.take)(1),Object(D.mapTo)(void 0)).toPromise()}launchCustomTab({host:e,path:t,params:n,extraParams:r}){const i=Gt.buildUrl(e,t,n);return new Promise((e,t)=>{customtabs.isAvailable(()=>{customtabs.launch(i,t=>{this.captured=Object.assign(Object.assign({},this.captured),Be.parse(t)),e()},e=>{t(e)})},()=>{customtabs.launchInBrowser(i,r,t=>{this.captured=Object.assign(Object.assign({},this.captured),Be.parse(t)),e()},e=>{t(e)})})})}capture({host:e,path:t,params:n}){if(!this.inAppBrowser)throw new Ye("InAppBrowser Session not found");return new Promise(r=>{const i=o=>{if(o.url){const s=new URL(o.url);(t=>t.origin===e)(s)&&(e=>e.pathname===t)(s)&&(e=>n.map(e=>e).every(t=>"false"===t.exists?!e.searchParams.has(t.key):t.match?e.searchParams.has(t.key)&&e.searchParams.get(t.key)===t.match:e.searchParams.has(t.key)))(s)&&(this.captured=Object.assign(Object.assign({},this.captured),n.reduce((e,t)=>(e[t.resolveTo]=s.searchParams.get(t.key),e),{})),this.extras={},n.map(e=>e.key).forEach(e=>s.searchParams.delete(e)),s.searchParams.forEach((e,t)=>{this.extras[t]=e}),this.inAppBrowser&&(this.inAppBrowser.listeners.loadstart.delete(i),this.inAppBrowser.ref.removeEventListener("loadstart",i)),r())}};this.inAppBrowser&&(this.inAppBrowser.listeners.loadstart.add(i),this.inAppBrowser.ref.addEventListener("loadstart",i))})}resolveCaptured(e){return Yt(this,void 0,void 0,(function*(){if(!this.captured[e])throw new Ge(e+" was not captured");return this.captured[e]}))}clearCapture(){return Yt(this,void 0,void 0,(function*(){this.captured={}}))}redirectTo({host:e,path:t,params:n}){return Yt(this,void 0,void 0,(function*(){if(!this.inAppBrowser)throw new Ye("InAppBrowser Session not found");this.inAppBrowser.ref.executeScript({code:"(() => {\n window.location.href = `"+Gt.buildUrl(e,t,n)+"`;\n })()"})}))}success(){return Yt(this,void 0,void 0,(function*(){return Object.assign({},this.captured)}))}fail(){return Yt(this,void 0,void 0,(function*(){throw Object.assign({},this.captured)}))}getCaptureExtras(){return Yt(this,void 0,void 0,(function*(){return Object.assign({},this.extras)}))}}($e=He||(He={}))._ID="_id",$e.TABLE_NAME="telemetry",$e.COLUMN_NAME_EVENT_TYPE="event_type",$e.COLUMN_NAME_EVENT="event",$e.COLUMN_NAME_TIMESTAMP="timestamp",$e.COLUMN_NAME_PRIORITY="priority",$e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+$e.TABLE_NAME+" ("+$e._ID+r.SPACE+" INTEGER PRIMARY KEY,"+$e.COLUMN_NAME_EVENT_TYPE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+$e.COLUMN_NAME_EVENT+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+$e.COLUMN_NAME_TIMESTAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+$e.COLUMN_NAME_PRIORITY+r.SPACE+r.INT_TYPE+" )",$e.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+$e.TABLE_NAME,(Ke=qe||(qe={}))._ID="_id",Ke.TABLE_NAME="processed_telemetry",Ke.COLUMN_NAME_MSG_ID="msg_id",Ke.COLUMN_NAME_DATA="data",Ke.COLUMN_NAME_NUMBER_OF_EVENTS="event_count",Ke.COLUMN_NAME_PRIORITY="priority",Ke.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Ke.TABLE_NAME+" ("+Ke._ID+" INTEGER PRIMARY KEY,"+Ke.COLUMN_NAME_MSG_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Ke.COLUMN_NAME_DATA+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Ke.COLUMN_NAME_NUMBER_OF_EVENTS+r.SPACE+r.INT_TYPE+r.COMMA_SEP+Ke.COLUMN_NAME_PRIORITY+r.SPACE+r.INT_TYPE+" )",Ke.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+Ke.TABLE_NAME,(We=ze||(ze={}))._ID="_id",We.TABLE_NAME="event_priority",We.COLUMN_NAME_EVENT="event",We.COLUMN_NAME_PRIORITY="priority",We.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+We.TABLE_NAME+" ("+We._ID+" INTEGER PRIMARY KEY,"+We.COLUMN_NAME_EVENT+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+We.COLUMN_NAME_PRIORITY+r.SPACE+r.INT_TYPE+" )",We.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+We.TABLE_NAME,(Je=Xe||(Xe={}))._ID="_id",Je.TABLE_NAME="telemetry_tags",Je.COLUMN_NAME_NAME="name",Je.COLUMN_NAME_HASH="hash",Je.COLUMN_NAME_DESCRIPTION="description",Je.COLUMN_NAME_START_DATE="start_date",Je.COLUMN_NAME_END_DATE="end_date",Je.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Je.TABLE_NAME+" ("+Je._ID+" INTEGER PRIMARY KEY,"+Je.COLUMN_NAME_NAME+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Je.COLUMN_NAME_HASH+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Je.COLUMN_NAME_DESCRIPTION+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Je.COLUMN_NAME_START_DATE+r.SPACE+r.DATE_TYPE+r.COMMA_SEP+Je.COLUMN_NAME_END_DATE+r.SPACE+r.DATE_TYPE+" )",Je.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+Je.TABLE_NAME,(Ze=Qe||(Qe={}))._ID="_id",Ze.TABLE_NAME="meta_data",Ze.COLUMN_NAME_MSG_ID="key",Ze.COLUMN_NAME_DATA="value",Ze.getCreateEntry=()=>"CREATE TABLE "+Ze.TABLE_NAME+" ("+Ze._ID+" INTEGER PRIMARY KEY,"+Ze.COLUMN_NAME_MSG_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Ze.COLUMN_NAME_DATA+r.SPACE+r.TEXT_TYPE+" )",Ze.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+Ze.TABLE_NAME,(tt=et||(et={}))._ID="_id",tt.TABLE_NAME="profiles",tt.COLUMN_NAME_UID="uid",tt.COLUMN_NAME_HANDLE="handle",tt.COLUMN_NAME_AVATAR="avatar",tt.COLUMN_NAME_AGE="age",tt.COLUMN_NAME_GENDER="gender",tt.COLUMN_NAME_STANDARD="standard",tt.COLUMN_NAME_LANGUAGE="language",tt.COLUMN_NAME_DAY="day",tt.COLUMN_NAME_MONTH="month",tt.COLUMN_NAME_IS_GROUP_USER="is_group_user",tt.COLUMN_NAME_CREATED_AT="created_at",tt.COLUMN_NAME_MEDIUM="medium",tt.COLUMN_NAME_BOARD="board",tt.COLUMN_NAME_PROFILE_IMAGE="profile_image",tt.COLUMN_NAME_SUBJECT="subject",tt.COLUMN_NAME_PROFILE_TYPE="profile_type",tt.COLUMN_NAME_GRADE="grade",tt.COLUMN_NAME_SYLLABUS="syllabus",tt.COLUMN_NAME_SOURCE="source",tt.COLUMN_NAME_GRADE_VALUE="grade_value",tt.COLUMN_VALUE="value",tt.COLUMN_NAME_CATEGORIES="categories",tt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+tt.TABLE_NAME+"("+tt._ID+r.SPACE+"INTEGER PRIMARY KEY,"+tt.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+" UNIQUE NOT NULL"+r.COMMA_SEP+tt.COLUMN_NAME_HANDLE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_AVATAR+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_AGE+r.SPACE+r.INT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_GENDER+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_STANDARD+r.SPACE+r.INT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_LANGUAGE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_DAY+r.SPACE+r.INT_TYPE+" NOT NULL DEFAULT -1"+r.COMMA_SEP+tt.COLUMN_NAME_MONTH+r.SPACE+r.INT_TYPE+" NOT NULL DEFAULT -1"+r.COMMA_SEP+tt.COLUMN_NAME_IS_GROUP_USER+r.SPACE+r.INT_TYPE+" NOT NULL DEFAULT 0"+r.COMMA_SEP+tt.COLUMN_NAME_CREATED_AT+r.SPACE+r.INT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_MEDIUM+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_BOARD+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_SUBJECT+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_PROFILE_IMAGE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_PROFILE_TYPE+r.SPACE+r.TEXT_TYPE+' DEFAULT "teacher"'+r.COMMA_SEP+tt.COLUMN_NAME_GRADE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_CATEGORIES+r.SPACE+r.TEXT_TYPE+" DEFAULT ''"+r.COMMA_SEP+tt.COLUMN_NAME_SYLLABUS+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_SOURCE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_VALUE+r.SPACE+r.TEXT_TYPE+' DEFAULT ""'+r.COMMA_SEP+tt.COLUMN_NAME_GRADE_VALUE+r.SPACE+r.TEXT_TYPE+")",tt.deleteTable=()=>"DROP TABLE IF EXISTS "+tt.TABLE_NAME,tt.getAlterEntryForProfileSyllabus=()=>"ALTER TABLE "+tt.TABLE_NAME+" ADD COLUMN "+r.SPACE+tt.COLUMN_NAME_SYLLABUS+r.TEXT_TYPE+" DEFAULT '';",tt.getAlterEntryForProfileCategories=()=>"ALTER TABLE "+tt.TABLE_NAME+" ADD COLUMN "+r.SPACE+tt.COLUMN_NAME_CATEGORIES+r.SPACE+r.TEXT_TYPE+" DEFAULT '';",(rt=nt||(nt={}))._ID="_id",rt.TABLE_NAME="users",rt.COLUMN_NAME_UID="uid",rt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+rt.TABLE_NAME+" ("+rt._ID+" INTEGER PRIMARY KEY,"+rt.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+" )",rt.deleteTable=()=>"DROP TABLE IF EXISTS "+rt.TABLE_NAME,(ot=it||(it={})).TABLE_NAME="group_profile",ot._ID="_id",ot.COLUMN_NAME_UID="uid",ot.COLUMN_NAME_GID="gid",ot.COLUMN_NAME_EPOCH_TIMESTAMP="epoch_timestamp",ot.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+ot.TABLE_NAME+" ("+ot._ID+" INTEGER PRIMARY KEY"+r.COMMA_SEP+ot.COLUMN_NAME_GID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+ot.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+ot.COLUMN_NAME_EPOCH_TIMESTAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+"UNIQUE ("+ot.COLUMN_NAME_GID+r.COMMA_SEP+ot.COLUMN_NAME_UID+") ON CONFLICT REPLACE)",ot.deleteTable=()=>"DROP TABLE IF EXISTS"+ot.TABLE_NAME,(at=st||(st={})).TABLE_NAME="groups",at._ID="_id",at.COLUMN_NAME_GID="gid",at.COLUMN_NAME_NAME="name",at.COLUMN_NAME_SYLLABUS="syllabus",at.COLUMN_NAME_GRADE="grade",at.COLUMN_NAME_GRADE_VALUE="grade_value",at.COLUMN_NAME_CREATED_AT="created_at",at.COLUMN_NAME_UPDATED_AT="updated_at",at.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+at.TABLE_NAME+" ("+at._ID+" INTEGER PRIMARY KEY"+r.COMMA_SEP+at.COLUMN_NAME_GID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+at.COLUMN_NAME_NAME+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+at.COLUMN_NAME_SYLLABUS+r.SPACE+r.TEXT_TYPE+' DEFAULT ""'+r.COMMA_SEP+at.COLUMN_NAME_GRADE+r.SPACE+r.TEXT_TYPE+' DEFAULT ""'+r.COMMA_SEP+at.COLUMN_NAME_GRADE_VALUE+r.SPACE+r.TEXT_TYPE+' DEFAULT ""'+r.COMMA_SEP+at.COLUMN_NAME_CREATED_AT+" INTEGER"+r.COMMA_SEP+at.COLUMN_NAME_UPDATED_AT+" INTEGER )",at.deleteTable=()=>"DROP TABLE IF EXISTS"+at.TABLE_NAME,(ut=ct||(ct={}))._ID="_id",ut.TABLE_NAME="imported_metadata",ut.COLUMN_NAME_IMPORTED_ID="imported_id",ut.COLUMN_NAME_DEVICE_ID="device_id",ut.COLUMN_NAME_COUNT="count",ut.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+ut.TABLE_NAME+" ("+ut._ID+" INTEGER PRIMARY KEY,"+ut.COLUMN_NAME_IMPORTED_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+ut.COLUMN_NAME_DEVICE_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+ut.COLUMN_NAME_COUNT+r.SPACE+r.INT_TYPE+" )",ut.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+ut.TABLE_NAME,(dt=lt||(lt={}))._ID="_id",dt.TABLE_NAME="learner_assessments",dt.COLUMN_NAME_UID="uid",dt.COLUMN_NAME_CONTENT_ID="content_id",dt.COLUMN_NAME_QID="qid",dt.COLUMN_NAME_Q_INDEX="qindex",dt.COLUMN_NAME_CORRECT="correct",dt.COLUMN_NAME_SCORE="score",dt.COLUMN_NAME_MAX_SCORE="max_score",dt.COLUMN_NAME_TIME_SPENT="time_spent",dt.COLUMN_NAME_RES="res",dt.COLUMN_NAME_TIMESTAMP="timestamp",dt.COLUMN_NAME_Q_DESC="qdesc",dt.COLUMN_NAME_Q_TITLE="qtitle",dt.COLUMN_NAME_HIERARCHY_DATA="h_data",dt.COLUMN_NAME_TOTAL_TS="total_ts",dt.COLUMN_NAME_MARKS="marks",dt.COLUMN_NAME_COUNT="occurence_count",dt.COLUMN_NAME_TOTAL_MAX_SCORE="sum_max_score",dt.COLUMN_NAME_USERS_COUNT="users_count",dt.COLUMN_NAME_HANDLE="handle",dt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+dt.TABLE_NAME+" ("+dt._ID+" INTEGER PRIMARY KEY,"+dt.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+dt.COLUMN_NAME_CONTENT_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_QID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_Q_INDEX+r.SPACE+r.INT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_CORRECT+r.SPACE+r.INT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_SCORE+r.SPACE+r.INT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_MAX_SCORE+r.SPACE+r.INT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_TIME_SPENT+r.SPACE+r.INT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_RES+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_TIMESTAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_Q_DESC+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_Q_TITLE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_HIERARCHY_DATA+r.SPACE+r.TEXT_TYPE+" DEFAULT '' )",dt.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+dt.TABLE_NAME,(Et=ht||(ht={}))._ID="_id",Et.TABLE_NAME="learner_content_summary",Et.COLUMN_NAME_UID="uid",Et.COLUMN_NAME_CONTENT_ID="content_id",Et.COLUMN_NAME_AVG_TS="avg_ts",Et.COLUMN_NAME_SESSIONS="sessions",Et.COLUMN_NAME_TOTAL_TS="total_ts",Et.COLUMN_NAME_LAST_UPDATED_ON="last_updated_on",Et.COLUMN_NAME_HIERARCHY_DATA="h_data",Et.COLUMN_NAME_NO_OF_QUESTIONS="no_of_questions",Et.COLUMN_NAME_CORRECT_ANSWERS="correct_answers",Et.COLUMN_NAME_TOTAL_TIME_SPENT="total_time_spent",Et.COLUMN_NAME_TOTAL_MAX_SCORE="total_max_score",Et.COLUMN_NAME_TOTAL_SCORE="total_score",Et.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Et.TABLE_NAME+" ("+Et._ID+" INTEGER PRIMARY KEY,"+Et.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+Et.COLUMN_NAME_CONTENT_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Et.COLUMN_NAME_AVG_TS+r.SPACE+r.REAL_TYPE+r.COMMA_SEP+Et.COLUMN_NAME_SESSIONS+r.SPACE+r.INT_TYPE+r.COMMA_SEP+Et.COLUMN_NAME_TOTAL_TS+r.SPACE+r.INT_TYPE+r.COMMA_SEP+Et.COLUMN_NAME_LAST_UPDATED_ON+r.SPACE+r.SPACE+r.INT_TYPE+r.COMMA_SEP+Et.COLUMN_NAME_HIERARCHY_DATA+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+" UNIQUE ("+Et.COLUMN_NAME_UID+r.SPACE+r.COMMA_SEP+Et.COLUMN_NAME_CONTENT_ID+r.COMMA_SEP+Et.COLUMN_NAME_HIERARCHY_DATA+") ON CONFLICT REPLACE )",Et.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+Et.TABLE_NAME,function(e){e.TABLE_NAME="group_profile",e._ID="_id",e.COLUMN_NAME_UID="uid",e.COLUMN_NAME_GID="gid",e.COLUMN_NAME_EPOCH_TIMESTAMP="epoch_timestamp",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY"+r.COMMA_SEP+e.COLUMN_NAME_GID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_EPOCH_TIMESTAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+"UNIQUE ("+e.COLUMN_NAME_GID+r.COMMA_SEP+e.COLUMN_NAME_UID+") ON CONFLICT REPLACE)",e.deleteTable=()=>"DROP TABLE IF EXISTS"+e.TABLE_NAME}(ft||(ft={})),function(e){e.TABLE_NAME="groups",e._ID="_id",e.COLUMN_NAME_GID="gid",e.COLUMN_NAME_NAME="name",e.COLUMN_NAME_SYLLABUS="syllabus",e.COLUMN_NAME_GRADE="grade",e.COLUMN_NAME_GRADE_VALUE="grade_value",e.COLUMN_NAME_CREATED_AT="created_at",e.COLUMN_NAME_UPDATED_AT="updated_at",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY"+r.COMMA_SEP+e.COLUMN_NAME_GID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_NAME+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_SYLLABUS+r.SPACE+r.TEXT_TYPE+' DEFAULT ""'+r.COMMA_SEP+e.COLUMN_NAME_GRADE+r.SPACE+r.TEXT_TYPE+' DEFAULT ""'+r.COMMA_SEP+e.COLUMN_NAME_GRADE_VALUE+r.SPACE+r.TEXT_TYPE+' DEFAULT ""'+r.COMMA_SEP+e.COLUMN_NAME_CREATED_AT+" INTEGER"+r.COMMA_SEP+e.COLUMN_NAME_UPDATED_AT+" INTEGER )",e.deleteTable=()=>"DROP TABLE IF EXISTS"+e.TABLE_NAME}(pt||(pt={})),(Ot=_t||(_t={}))._ID="_id",Ot.TABLE_NAME="partners",Ot.COLUMN_NAME_PARTNER_ID="partnerID",Ot.COLUMN_NAME_KEY="publicKey",Ot.COLUMN_NAME_KEY_ID="publicKeyID",Ot.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Ot.TABLE_NAME+" ("+Ot._ID+" INTEGER PRIMARY KEY,"+Ot.COLUMN_NAME_PARTNER_ID+r.SPACE+r.TEXT_TYPE+" UNIQUE NOT NULL"+r.COMMA_SEP+Ot.COLUMN_NAME_KEY+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+Ot.COLUMN_NAME_KEY_ID+r.SPACE+r.INT_TYPE+" NOT NULL )",Ot.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+Ot.TABLE_NAME,(gt=St||(St={})).TABLE_NAME="content",gt._ID="_id",gt.COLUMN_NAME_IDENTIFIER="identifier",gt.COLUMN_NAME_SERVER_DATA="server_data",gt.COLUMN_NAME_LOCAL_DATA="local_data",gt.COLUMN_NAME_MIME_TYPE="mime_type",gt.COLUMN_NAME_PATH="path",gt.COLUMN_NAME_INDEX="search_index",gt.COLUMN_NAME_VISIBILITY="visibility",gt.COLUMN_NAME_SERVER_LAST_UPDATED_ON="server_last_updated_on",gt.COLUMN_NAME_LOCAL_LAST_UPDATED_ON="local_last_updated_on",gt.COLUMN_NAME_MANIFEST_VERSION="manifest_version",gt.COLUMN_NAME_REF_COUNT="ref_count",gt.COLUMN_NAME_CONTENT_STATE="content_state",gt.COLUMN_NAME_CONTENT_TYPE="content_type",gt.COLUMN_NAME_AUDIENCE="audience",gt.COLUMN_NAME_PRAGMA="pragma",gt.COLUMN_NAME_UID="uid",gt.COLUMN_NAME_SIZE_ON_DEVICE="size_on_device",gt.COLUMN_NAME_BOARD="board",gt.COLUMN_NAME_MEDIUM="medium",gt.COLUMN_NAME_GRADE="grade",gt.COLUMN_NAME_DIALCODES="dialcodes",gt.COLUMN_NAME_CHILD_NODES="child_nodes",gt.COLUMN_NAME_PRIMARY_CATEGORY="primary_category",gt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+gt.TABLE_NAME+" ("+gt._ID+" INTEGER PRIMARY KEY,"+gt.COLUMN_NAME_IDENTIFIER+r.SPACE+r.TEXT_TYPE+" UNIQUE NOT NULL"+r.COMMA_SEP+gt.COLUMN_NAME_SERVER_DATA+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_LOCAL_DATA+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_MIME_TYPE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_PATH+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_INDEX+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_VISIBILITY+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_SERVER_LAST_UPDATED_ON+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_LOCAL_LAST_UPDATED_ON+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_REF_COUNT+r.SPACE+r.INT_TYPE+" NOT NULL DEFAULT 1"+r.COMMA_SEP+gt.COLUMN_NAME_CONTENT_STATE+r.SPACE+r.INT_TYPE+" NOT NULL DEFAULT 2"+r.COMMA_SEP+gt.COLUMN_NAME_CONTENT_TYPE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_AUDIENCE+r.SPACE+r.TEXT_TYPE+" DEFAULT 'Learner'"+r.COMMA_SEP+gt.COLUMN_NAME_SIZE_ON_DEVICE+r.SPACE+r.INT_TYPE+" NOT NULL DEFAULT 0"+r.COMMA_SEP+gt.COLUMN_NAME_PRAGMA+r.SPACE+r.TEXT_TYPE+" DEFAULT ''"+r.COMMA_SEP+gt.COLUMN_NAME_BOARD+r.SPACE+r.TEXT_TYPE+" DEFAULT ''"+r.COMMA_SEP+gt.COLUMN_NAME_MEDIUM+r.SPACE+r.TEXT_TYPE+" DEFAULT ''"+r.COMMA_SEP+gt.COLUMN_NAME_GRADE+r.SPACE+r.TEXT_TYPE+" DEFAULT ''"+r.COMMA_SEP+gt.COLUMN_NAME_MANIFEST_VERSION+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_DIALCODES+r.SPACE+r.TEXT_TYPE+" DEFAULT ''"+r.COMMA_SEP+gt.COLUMN_NAME_CHILD_NODES+r.SPACE+r.TEXT_TYPE+" DEFAULT ''"+r.COMMA_SEP+gt.COLUMN_NAME_PRIMARY_CATEGORY+r.SPACE+r.TEXT_TYPE+" DEFAULT '' )",gt.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+gt.TABLE_NAME,gt.getAlterEntryForContentSize=()=>"ALTER TABLE "+gt.TABLE_NAME+" ADD COLUMN "+gt.COLUMN_NAME_SIZE_ON_DEVICE+r.INT_TYPE+" NOT NULL DEFAULT 0;",gt.getAlterEntryForPragma=()=>"ALTER TABLE "+gt.TABLE_NAME+" ADD COLUMN "+gt.COLUMN_NAME_PRAGMA+r.TEXT_TYPE+" DEFAULT '';",gt.getAlterEntryForBoard=()=>`ALTER TABLE ${gt.TABLE_NAME} ADD COLUMN ${gt.COLUMN_NAME_BOARD} TEXT DEFAULT ''`,gt.getAlterEntryForMedium=()=>`ALTER TABLE ${gt.TABLE_NAME} ADD COLUMN ${gt.COLUMN_NAME_MEDIUM} TEXT DEFAULT ''`,gt.getAlterEntryForGrade=()=>`ALTER TABLE ${gt.TABLE_NAME} ADD COLUMN ${gt.COLUMN_NAME_GRADE} TEXT DEFAULT ''`,gt.getAlterEntryForDialCode=()=>`ALTER TABLE ${gt.TABLE_NAME} ADD COLUMN ${gt.COLUMN_NAME_DIALCODES} TEXT DEFAULT ''`,gt.getAlterEntryForChildNodes=()=>`ALTER TABLE ${gt.TABLE_NAME} ADD COLUMN ${gt.COLUMN_NAME_CHILD_NODES} TEXT DEFAULT ''`,gt.getAlterEntryForPrimaryCategory=()=>`ALTER TABLE ${gt.TABLE_NAME} ADD COLUMN ${gt.COLUMN_NAME_PRIMARY_CATEGORY} TEXT DEFAULT ''`,(Nt=At||(At={}))._ID="_id",Nt.TABLE_NAME="content_access",Nt.COLUMN_NAME_UID="uid",Nt.COLUMN_NAME_CONTENT_IDENTIFIER="identifier",Nt.COLUMN_NAME_EPOCH_TIMESTAMP="epoch_timestamp",Nt.COLUMN_NAME_STATUS="status",Nt.COLUMN_NAME_CONTENT_TYPE="content_type",Nt.COLUMN_NAME_LEARNER_STATE="learner_state",Nt.COLUMN_NAME_PRIMARY_CATEGORY="primary_category",Nt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Nt.TABLE_NAME+" ("+Nt._ID+" INTEGER PRIMARY KEY,"+Nt.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+Nt.COLUMN_NAME_CONTENT_IDENTIFIER+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Nt.COLUMN_NAME_EPOCH_TIMESTAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+Nt.COLUMN_NAME_STATUS+r.SPACE+r.INT_TYPE+r.COMMA_SEP+Nt.COLUMN_NAME_CONTENT_TYPE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Nt.COLUMN_NAME_LEARNER_STATE+r.SPACE+r.BLOB_TYPE+" )",Nt.deleteTable=()=>"DROP TABLE IF EXISTS "+Nt.TABLE_NAME,Nt.getAlterEntryForPrimaryCategory=()=>`ALTER TABLE ${Nt.TABLE_NAME} ADD COLUMN ${Nt.COLUMN_NAME_PRIMARY_CATEGORY} TEXT DEFAULT ''`,(Ct=Tt||(Tt={}))._ID="_id",Ct.TABLE_NAME="feedback",Ct.COLUMN_NAME_CONTENT_ID="identifier",Ct.COLUMN_NAME_UID="uid",Ct.COLUMN_NAME_RATING="rating",Ct.COLUMN_NAME_COMMENTS="comments",Ct.COLUMN_NAME_CREATED_AT="createdAt",Ct.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Ct.TABLE_NAME+" ("+Ct._ID+" INTEGER PRIMARY KEY,"+Ct.COLUMN_NAME_CONTENT_ID+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+Ct.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+Ct.COLUMN_NAME_RATING+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+Ct.COLUMN_NAME_COMMENTS+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+Ct.COLUMN_NAME_CREATED_AT+r.SPACE+r.INT_TYPE+" )",Ct.deleteTable=()=>"DROP TABLE IF EXISTS "+Ct.TABLE_NAME,(yt=vt||(vt={}))._ID="_id",yt.TABLE_NAME="content_marker",yt.COLUMN_NAME_UID="uid",yt.COLUMN_NAME_CONTENT_IDENTIFIER="identifier",yt.COLUMN_NAME_EPOCH_TIMESTAMP="epoch_timestamp",yt.COLUMN_NAME_DATA="data",yt.COLUMN_NAME_EXTRA_INFO="extra_info",yt.COLUMN_NAME_MARKER="marker",yt.COLUMN_NAME_MIME_TYPE="mime_type",yt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+yt.TABLE_NAME+" ("+yt._ID+" INTEGER PRIMARY KEY,"+yt.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+yt.COLUMN_NAME_CONTENT_IDENTIFIER+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+yt.COLUMN_NAME_EPOCH_TIMESTAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+yt.COLUMN_NAME_DATA+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+yt.COLUMN_NAME_EXTRA_INFO+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+yt.COLUMN_NAME_MIME_TYPE+r.SPACE+r.TEXT_TYPE+" DEFAULT ''"+r.COMMA_SEP+yt.COLUMN_NAME_MARKER+r.SPACE+r.INT_TYPE+" )",yt.deleteTable=()=>"DROP TABLE IF EXISTS "+yt.TABLE_NAME,yt.getAlterEntryForMimeType=()=>`ALTER TABLE ${yt.TABLE_NAME} ADD COLUMN ${yt.COLUMN_NAME_MIME_TYPE} TEXT DEFAULT ''`,(bt=mt||(mt={}))._ID="_id",bt.TABLE_NAME="notifications",bt.COLUMN_NAME_MESSAGE_ID="message_id",bt.COLUMN_NAME_EXPIRY_TIME="expiry_time",bt.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME="display_time",bt.COLUMN_NAME_NOTIFICATION_RECEIVED_AT="received_at",bt.COLUMN_NAME_NOTIFICATION_JSON="notification_json",bt.COLUMN_NAME_IS_READ="is_read",bt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+bt.TABLE_NAME+" ("+bt._ID+" INTEGER PRIMARY KEY,"+bt.COLUMN_NAME_MESSAGE_ID+r.SPACE+r.INT_TYPE+r.COMMA_SEP+bt.COLUMN_NAME_EXPIRY_TIME+r.SPACE+r.INT_TYPE+r.COMMA_SEP+bt.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME+r.SPACE+r.INT_TYPE+r.COMMA_SEP+bt.COLUMN_NAME_NOTIFICATION_RECEIVED_AT+r.SPACE+r.INT_TYPE+r.COMMA_SEP+bt.COLUMN_NAME_NOTIFICATION_JSON+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+bt.COLUMN_NAME_IS_READ+r.SPACE+r.INT_TYPE+" )",bt.deleteTable=()=>"DROP TABLE IF EXISTS "+bt.TABLE_NAME,(Mt=It||(It={}))._ID="_id",Mt.TABLE_NAME="no_sql",Mt.COLUMN_NAME_KEY="key",Mt.COLUMN_NAME_VALUE="value",Mt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Mt.TABLE_NAME+" ("+Mt._ID+" INTEGER PRIMARY KEY,"+Mt.COLUMN_NAME_KEY+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+Mt.COLUMN_NAME_VALUE+r.SPACE+r.TEXT_TYPE+" )",Mt.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+Mt.TABLE_NAME,(Lt=Rt||(Rt={})).TABLE_NAME="error_stack",Lt._ID="_id",Lt.COLUMN_NAME_APP_VERSION="app_version",Lt.COLUMN_NAME_PAGE_ID="page_id",Lt.COLUMN_NAME_TIME_STAMP="time_stamp",Lt.COLUMN_NAME_ERROR_LOG="error_log",Lt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Lt.TABLE_NAME+" ("+Lt._ID+" INTEGER PRIMARY KEY"+r.COMMA_SEP+Lt.COLUMN_NAME_APP_VERSION+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Lt.COLUMN_NAME_PAGE_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Lt.COLUMN_NAME_TIME_STAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+Lt.COLUMN_NAME_ERROR_LOG+r.SPACE+r.TEXT_TYPE+" )",Lt.deleteTable=()=>"DROP TABLE IF EXISTS"+Lt.TABLE_NAME,(Dt=Pt||(Pt={})).TABLE_NAME="search_history",Dt._ID="_id",Dt.COLUMN_NAME_USER_ID="uid",Dt.COLUMN_NAME_QUERY="query",Dt.COLUMN_NAME_TIME_STAMP="time_stamp",Dt.COLUMN_NAME_NAMESPACE="namespace",Dt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Dt.TABLE_NAME+" ("+Dt._ID+" INTEGER PRIMARY KEY"+r.COMMA_SEP+Dt.COLUMN_NAME_USER_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Dt.COLUMN_NAME_QUERY+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Dt.COLUMN_NAME_TIME_STAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+Dt.COLUMN_NAME_NAMESPACE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+"UNIQUE ("+Dt.COLUMN_NAME_USER_ID+r.COMMA_SEP+Dt.COLUMN_NAME_QUERY+") ON CONFLICT REPLACE )",Dt.deleteTable=()=>"DROP TABLE IF EXISTS"+Dt.TABLE_NAME,(Ut=wt||(wt={})).TABLE_NAME="course_assessment",Ut._ID="_id",Ut.COLUMN_NAME_ASSESSMENT_EVENT="assessment_event",Ut.COLUMN_NAME_CREATED_AT="created_at",Ut.COLUMN_NAME_USER_ID="user_id",Ut.COLUMN_NAME_CONTENT_ID="content_id",Ut.COLUMN_NAME_COURSE_ID="course_id",Ut.COLUMN_NAME_BATCH_ID="batch_id",Ut.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS"+r.SPACE+Ut.TABLE_NAME+r.SPACE+"("+Ut._ID+r.SPACE+"INTEGER PRIMARY KEY,"+Ut.COLUMN_NAME_ASSESSMENT_EVENT+r.SPACE+r.TEXT_TYPE+","+Ut.COLUMN_NAME_CREATED_AT+r.SPACE+r.INT_TYPE+","+Ut.COLUMN_NAME_USER_ID+r.SPACE+r.TEXT_TYPE+","+Ut.COLUMN_NAME_CONTENT_ID+r.SPACE+r.TEXT_TYPE+","+Ut.COLUMN_NAME_COURSE_ID+r.SPACE+r.TEXT_TYPE+","+Ut.COLUMN_NAME_BATCH_ID+r.SPACE+r.TEXT_TYPE+")",Ut.deleteTable=()=>"DROP TABLE IF EXISTS"+Ut.TABLE_NAME,function(e){e.TABLE_NAME="network_queue",e._ID="_id",e.COLUMN_NAME_MSG_ID="msg_id",e.COLUMN_NAME_PRIORITY="priority",e.COLUMN_NAME_TIMESTAMP="timestamp",e.COLUMN_NAME_DATA="data",e.COLUMN_NAME_REQUEST="request",e.COLUMN_NAME_NUMBER_OF_ITEM="item_count",e.COLUMN_NAME_CONFIG="config",e.COLUMN_NAME_TYPE="type",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY"+r.COMMA_SEP+e.COLUMN_NAME_MSG_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_PRIORITY+r.SPACE+r.INT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_TIMESTAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_DATA+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_NUMBER_OF_ITEM+r.SPACE+r.INT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_CONFIG+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_TYPE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_REQUEST+r.SPACE+r.TEXT_TYPE+")",e.deleteTable=()=>"DROP TABLE IF EXISTS"+e.TABLE_NAME;e.Mapper=class{static networkQueueRequestToEntry(t){return{[e.COLUMN_NAME_MSG_ID]:t.msgId,[e.COLUMN_NAME_PRIORITY]:t.priority,[e.COLUMN_NAME_TIMESTAMP]:t.ts,[e.COLUMN_NAME_DATA]:t.data,[e.COLUMN_NAME_NUMBER_OF_ITEM]:t.itemCount,[e.COLUMN_NAME_CONFIG]:t.config,[e.COLUMN_NAME_TYPE]:t.type,[e.COLUMN_NAME_REQUEST]:t.networkRequest.toJSON()}}}}(jt||(jt={})),function(e){e.TELEMETRY="telemetry",e.COURSE_PROGRESS="course_progress",e.COURSE_ASSESMENT="course_assesment"}(Ft||(Ft={})),(xt=kt||(kt={})).TABLE_NAME="player_data",xt._ID="_id",xt.COLUMN_NAME_USER_ID="user_id",xt.COLUMN_PARENT_IDENTIFIER="parent_identifier",xt.COLUMN_IDENTIFIER="identifier",xt.COLUMN_PLAYER_CONFIG="player_config",xt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+xt.TABLE_NAME+" ("+xt._ID+" INTEGER PRIMARY KEY"+r.COMMA_SEP+xt.COLUMN_NAME_USER_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+xt.COLUMN_PARENT_IDENTIFIER+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+xt.COLUMN_IDENTIFIER+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+xt.COLUMN_PLAYER_CONFIG+r.SPACE+r.TEXT_TYPE+")",xt.deleteTable=()=>"DROP TABLE IF EXISTS "+xt.TABLE_NAME,xt.getAlterEntryForPlayerConfig=()=>`ALTER TABLE ${xt.TABLE_NAME} ADD COLUMN ${xt.COLUMN_PLAYER_CONFIG} TEXT DEFAULT ''`;class Ht{static mapPlayerDbEntryToPlayer(e){return{userId:e[kt.COLUMN_NAME_USER_ID],parentId:e[kt.COLUMN_PARENT_IDENTIFIER],contentId:e[kt.COLUMN_IDENTIFIER],saveState:e[kt.COLUMN_PLAYER_CONFIG]}}static mapPlayerStateToPlayerDbEntry(e,t,n,r){return{[kt.COLUMN_NAME_USER_ID]:e,[kt.COLUMN_PARENT_IDENTIFIER]:t,[kt.COLUMN_IDENTIFIER]:n,[kt.COLUMN_PLAYER_CONFIG]:r}}}(Vt=Bt||(Bt={}))._ID="_id",Vt.TABLE_NAME="certificate_public_key",Vt.COLUMN_NAME_IDENTIFIER="identifier",Vt.COLUMN_NAME_PUBLIC_KEY="public_key",Vt.COLUMN_NAME_ALGORITHM="alg",Vt.COLUMN_NAME_OWNER="owner",Vt.COLUMN_NAME_EXPIRY_TIME="expiry_time",Vt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Vt.TABLE_NAME+" ("+Vt._ID+" INTEGER PRIMARY KEY,"+Vt.COLUMN_NAME_IDENTIFIER+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Vt.COLUMN_NAME_PUBLIC_KEY+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Vt.COLUMN_NAME_ALGORITHM+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Vt.COLUMN_NAME_OWNER+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Vt.COLUMN_NAME_EXPIRY_TIME+r.SPACE+r.INT_TYPE+" )",Vt.deleteTable=()=>"DROP TABLE IF EXISTS "+Vt.TABLE_NAME;var $t=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class qt extends i{constructor(){super(1,16)}apply(e){return $t(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise()))}))}queries(){return[He.getCreateEntry(),qe.getCreateEntry(),Xe.getCreateEntry(),ze.getCreateEntry(),nt.getCreateEntry(),et.getCreateEntry(),ct.getCreateEntry(),_t.getCreateEntry(),St.getCreateEntry(),lt.getCreateEntry(),ht.getCreateEntry(),At.getCreateEntry(),Tt.getCreateEntry(),mt.getCreateEntry(),pt.getCreateEntry(),ft.getCreateEntry(),It.getCreateEntry(),vt.getCreateEntry(),Rt.getCreateEntry(),Pt.getCreateEntry(),wt.getCreateEntry(),jt.getCreateEntry(),kt.getCreateEntry(),Bt.getCreateEntry()]}}class Kt{constructor(){this.query=""}where(e){return this.query+=e.trim(),new Kt.WhereDecorator(this)}build(){return this.query}}Kt.ConstraintDecorator=class{constructor(e){this.queryBuilder=e}and(){return this.queryBuilder.query+=" AND ",this.queryBuilder}or(){return this.queryBuilder.query+=" OR ",this.queryBuilder}end(){return this.queryBuilder}},Kt.WhereDecorator=class{constructor(e){this.queryBuilder=e}args(e){return e.forEach(e=>{this.interpolate(e)}),new Kt.ConstraintDecorator(this.queryBuilder)}interpolate(e){isNaN(e)&&(e='"'+e+'"'),this.queryBuilder.query=this.queryBuilder.query.replace("?",e)}};var zt=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Wt=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Xt=function(e,t){return function(n,r){t(n,r,e)}},Jt=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let Qt=class{constructor(e,t,n){this.sdkConfig=e,this.dBVersion=t,this.appMigrationList=n,this.context=this.sdkConfig.dbConfig}update(e){return new c.Observable(t=>{db.update(e.table,e.selection||"",e.selectionArgs||[],e.modelJson,e.useExternalDb||!1,e=>{t.next(e),t.complete()},e=>{t.error(e)})})}init(){return Jt(this,void 0,void 0,(function*(){return new Promise(e=>{db.init(this.context.dbName,this.dBVersion,[],e=>Jt(this,void 0,void 0,(function*(){"onCreate"===e.method?yield this.onCreate():"onUpgrade"===e.method&&(yield this.onUpgrade(e.oldVersion,e.newVersion))}))),this.hasInitialized().subscribe(()=>{e(void 0)})})}))}hasInitialized(){return this.execute("DROP TABLE IF EXISTS dummy_init_table")}delete(e){const t=`\n DELETE FROM ${e.table}\n WHERE ${(new Kt).where(e.selection).args(e.selectionArgs).end().build()}\n `;return new c.Observable(n=>{db.execute(t,e.useExternalDb||!1,e=>{n.next(e),n.complete()},e=>{n.error(e)})})}onCreate(){return Jt(this,void 0,void 0,(function*(){return(new qt).apply(this)}))}onUpgrade(e,t){return Jt(this,void 0,void 0,(function*(){for(const n of this.appMigrationList){let r;r=n instanceof i?n:n(),console.log("Migration",r),r.required(e,t)&&(yield r.apply(this))}}))}execute(e,t){return new c.Observable(n=>{db.execute(e,t||!1,e=>{n.next(e),n.complete()},e=>{n.error(e)})})}read(e){return new c.Observable(t=>{db.read(!!e.distinct,e.table,e.columns||[],e.selection||"",e.selectionArgs||[],e.groupBy||"",e.having||"",e.orderBy||"",e.limit||"",e.useExternalDb||!1,e=>{t.next(e),t.complete()},e=>{t.error(e)})})}insert(e){return new c.Observable(t=>{db.insert(e.table,e.modelJson,e.useExternalDb||!1,e=>{t.next(e),t.complete()},e=>{t.error(e)})})}beginTransaction(){db.beginTransaction()}endTransaction(e,t){db.endTransaction(e,t||!1)}copyDatabase(e){return new c.Observable(t=>{db.copyDatabase(e,e=>{t.next(e),t.complete()},e=>{t.error(e)})})}open(e){return new Promise((t,n)=>{db.open(e,e=>{t(e)},e=>{n()})})}};Qt=zt([Object(s.injectable)(),Xt(0,Object(s.inject)(l.SDK_CONFIG)),Xt(1,Object(s.inject)(l.DB_VERSION)),Xt(2,Object(s.inject)(l.DB_MIGRATION_LIST)),Wt("design:paramtypes",[Object,Number,Array])],Qt);var Zt=n(46);class en{static generateUniqueId(){return Zt()}}var tn=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},nn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},rn=function(e,t){return function(n,r){t(n,r,e)}};let on=class{constructor(e,t,n,r){this.sdkConfig=e,this.deviceInfo=t,this.appInfo=n,this.codePushExperimentService=r,this.apiConfig=this.sdkConfig.apiConfig}decorate(e,t,n,r=0,i,o,s){const{uid:a,sid:c}=t;return e.ets+=r,e.mid||(e.mid=en.generateUniqueId()),a?this.patchActor(e,a):this.patchActor(e,""),this.patchContext(e,c,i,o,s),e.context.cdata=[...e.context.cdata,{id:t.managedSession?t.managedSession.sid:t.uid,type:"Guest user"}],e}patchActor(e,t){e.actor||(e.actor=new pe);const n=e.actor;n.id||(n.id=t),n.type||(n.type=pe.TYPE_USER)}patchContext(e,t,n,r,i){e.context||(e.context=new _e),e.context=this.buildContext(t,n,e.context,r,i)}patchPData(e){e.pdata||(e.pdata=new ve);const t=e.pdata;t.id||(t.id=this.apiConfig.api_authentication.producerId);const n=t.pid;n?t.pid=n:this.apiConfig.api_authentication.producerUniqueId?t.pid=this.apiConfig.api_authentication.producerUniqueId:t.pid="sunbird.android",t.ver||(t.ver=this.appInfo.getVersionName())}prepare(e,t){return{event:JSON.stringify(e),event_type:e.eid,timestamp:Date.now(),priority:1}}buildContext(e,t,n,r,i){n.channel=t,this.patchPData(n),n.env||(n.env="app");const o=this.codePushExperimentService.getExperimentKey();return"string"==typeof o&&(n.pdata.pid=n.pdata.pid+"-"+o),n.sid=e,n.did=this.deviceInfo.getDeviceID(),t!==this.apiConfig.api_authentication.channelId&&(n.rollup={l1:t}),n.cdata=n.cdata?n.cdata.concat(r||[]):r||[],n.cdata=n.cdata?n.cdata.concat(i||[]):i||[],n}};on=tn([Object(s.injectable)(),rn(0,Object(s.inject)(l.SDK_CONFIG)),rn(1,Object(s.inject)(l.DEVICE_INFO)),rn(2,Object(s.inject)(l.APP_INFO)),rn(3,Object(s.inject)(l.CODEPUSH_EXPERIMENT_SERVICE)),nn("design:paramtypes",[Object,Object,Object,Object])],on);class sn extends ke{constructor(e){super(e,"INVALID_INPUT_FOR_SYNC_PREPROCESSOR"),Object.setPrototypeOf(this,sn.prototype)}}var an=n(16);class cn{process(e){if("string"!=typeof e)throw new sn('StringToGzippedString expects input of type "string"');return Object(an.gzip)(e,{to:"string"})}}class un{process(e){if("object"!=typeof e)throw new sn('TelemetryEntriesToStringPreprocessor expects input of type "object"');return JSON.stringify(e)}}class ln{static get log(){return bd.instance.telemetryService}}var dn=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class hn{constructor(e,t){this.networkQueue=e,this.sdkConfig=t}handle(e){return this.networkQueue.enqueue(new En(this.sdkConfig).generateNetworkQueueRequest(Ft.COURSE_PROGRESS,{request:e},en.generateUniqueId(),e.contents?e.contents.length:0,!0),!0).pipe(Object(D.mergeMap)(()=>new c.Observable(e=>{sbsync.onSyncSucces(t=>dn(this,void 0,void 0,(function*(){const n=t.courseProgressResponse,r=t.course_progress_error;n?e.next(n):r&&e.error(r),e.complete()})),t=>dn(this,void 0,void 0,(function*(){e.error(t)})))})))}}hn.UPDATE_CONTENT_STATE_ENDPOINT="/content/state/update";class En{constructor(e){this.config=e}generateNetworkQueueRequest(e,t,n,r,i){let o,s;if(e===Ft.TELEMETRY){const e=t.split("").map(e=>e.charCodeAt(0));o=new Uint8Array(e),s=(new a.CsRequest.Builder).withSerializer(a.CsHttpSerializer.RAW).withHost(this.config.telemetryConfig.host).withType(a.CsHttpRequestType.POST).withPath(this.config.telemetryConfig.apiPath+pn.TELEMETRY_ENDPOINT).withHeaders({"Content-Type":"application/json","Content-Encoding":"gzip"}).withBody(o).withBearerToken(!0).build()}else o=t,s=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.PATCH).withPath(this.config.courseServiceConfig.apiPath+hn.UPDATE_CONTENT_STATE_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody(o).build();return{msgId:n,data:e===Ft.TELEMETRY?t:JSON.stringify(t),networkRequest:s,priority:e===Ft.TELEMETRY?2:1,itemCount:r,type:e,config:JSON.stringify({shouldPublishResult:i}),ts:Date.now()}}}var fn=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class pn{constructor(e,t,n,r,i,o,s,a,c){this.dbService=e,this.sdkConfig=t,this.deviceInfo=n,this.sharedPreferences=r,this.appInfoService=i,this.deviceRegisterService=o,this.keyValueStore=s,this.apiService=a,this.networkQueue=c,this.preprocessors=[new un,new cn],this.telemetryConfig=this.sdkConfig.telemetryConfig,this.apiConfig=this.sdkConfig.apiConfig}resetDeviceRegisterTTL(){return Object(c.zip)(this.keyValueStore.setValue(pn.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY,""),this.keyValueStore.setValue(pn.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY,"")).pipe(Object(D.mapTo)(void 0))}handle({ignoreSyncThreshold:e,ignoreAutoSyncMode:t}){const n=!(!e||!t);return this.registerDevice().pipe(Object(D.catchError)(()=>(e=!0,Object(c.of)(void 0))),Object(D.mergeMap)(()=>this.hasTelemetryThresholdCrossed().pipe(Object(D.mergeMap)(t=>t||e?Object(c.defer)(()=>fn(this,void 0,void 0,(function*(){switch(yield this.sharedPreferences.getString(v.KEY_AUTO_SYNC_MODE).toPromise()){case de.OFF:return{syncedEventCount:0,syncTime:Date.now(),syncedFileSize:0,error:new Error("AUTO_SYNC_MODE: "+de.OFF)};case de.OVER_WIFI:if(navigator.connection.type!==Connection.WIFI)return{syncedEventCount:0,syncTime:Date.now(),syncedFileSize:0,error:new Error("AUTO_SYNC_MODE: "+de.OVER_WIFI)};break;case de.ALWAYS_ON:}let e,t={syncedEventCount:0,syncTime:Date.now(),syncedFileSize:0};do{try{e=yield this.processEventsBatch(n).toPromise(),t={syncedEventCount:t.syncedEventCount+e,syncTime:Date.now(),syncedFileSize:0}}catch(e){t={syncedEventCount:t.syncedEventCount,syncTime:Date.now(),syncedFileSize:0,error:e}}}while(e&&!t.error);return t}))):Object(c.of)({syncedEventCount:0,syncTime:Date.now(),syncedFileSize:0})))))}processEventsBatch(e){return this.fetchEvents().pipe(Object(D.mergeMap)(t=>this.processEvents(t).pipe(Object(D.mergeMap)(n=>this.persistinNetworkQueue(n,n.processedEventsSize,e).pipe(Object(D.mergeMap)(()=>this.deleteEvents(t)),Object(D.mapTo)(t.length))))))}registerDevice(){return Object(c.zip)(this.keyValueStore.getValue(pn.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY),this.keyValueStore.getValue(pn.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY)).pipe(Object(D.mergeMap)(e=>{const t=e[0],n=e[1];if(t&&n){const e="false"===n?pn.REGISTER_API_FAILURE_TTL:pn.REGISTER_API_SUCCESS_TTL;if(Math.abs(parseInt(t,10)-Date.now())<e)return Object(c.of)(void 0)}return this.deviceRegisterService.registerDevice().pipe(Object(D.tap)(e=>fn(this,void 0,void 0,(function*(){e.result.actions.forEach(e=>{"experiment"===e.type&&e.key&&this.sharedPreferences.putString(N.DEPLOYMENT_KEY,e.data.key).toPromise()});const t=new Date(e.ts).getTime(),n=Date.now(),r=t-n,i=Math.abs(r)>this.telemetryConfig.telemetryLogMinAllowedOffset?r:0;i&&(yield ln.log.interact({type:oe.OTHER,subType:se.DEVICE_TIME_OFFSET_FOUND,env:"sdk",pageId:"sdk",id:"sdk",valueMap:{deviceTime:n,offsetTime:i}}).toPromise(),yield this.keyValueStore.setValue(pn.TELEMETRY_LOG_MIN_ALLOWED_OFFSET_KEY,i+"").toPromise())}))),Object(D.mergeMap)(()=>Object(c.zip)(this.keyValueStore.setValue(pn.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY,Date.now()+""),this.keyValueStore.setValue(pn.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY,"true")).pipe(Object(D.mapTo)(void 0))),Object(D.catchError)(e=>Object(c.zip)(this.keyValueStore.setValue(pn.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY,Date.now()+""),this.keyValueStore.setValue(pn.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY,"false")).pipe(Object(D.mergeMap)(()=>{throw console.error(e),new Error("Device Registration Failed")}))))}))}hasTelemetryThresholdCrossed(){return this.dbService.execute("\n SELECT count(*) as COUNT FROM "+He.TABLE_NAME).pipe(Object(D.map)(e=>!!(e&&e[0]&&e[0].COUNT>=this.telemetryConfig.telemetrySyncThreshold)))}fetchEvents(){return this.dbService.execute(`\n SELECT * FROM ${He.TABLE_NAME}\n WHERE ${He.COLUMN_NAME_PRIORITY} = (SELECT MIN (${He.COLUMN_NAME_PRIORITY})\n FROM ${He.TABLE_NAME})\n ORDER BY ${He.COLUMN_NAME_TIMESTAMP}\n LIMIT ${this.telemetryConfig.telemetrySyncBandwidth}`)}processEvents(e){if(!e.length)return Object(c.of)({processedEventsSize:0});const t=en.generateUniqueId();return Object(c.of)({processedEvents:this.preprocessors.reduce((e,t)=>t.process(e),{id:"ekstep.telemetry",ver:"1.0",ts:b()().format("YYYY-MM-DDTHH:mm:ss[Z]"),events:e.map(e=>JSON.parse(e[He.COLUMN_NAME_EVENT])),params:{did:this.deviceInfo.getDeviceID(),msgid:t,key:"",requesterId:""}}),processedEventsSize:e.length,messageId:t})}persistinNetworkQueue({processedEvents:e,messageId:t},n,r){return e?this.networkQueue.enqueue(new En(this.sdkConfig).generateNetworkQueueRequest(Ft.TELEMETRY,e,t,n,r),!0).pipe(Object(D.mapTo)(void 0)):Object(c.of)(void 0)}deleteEvents(e){return e.length?this.dbService.execute(`\n DELETE FROM ${He.TABLE_NAME}\n WHERE ${He._ID} IN (${e.map(e=>e[He._ID]).join(",")})\n `):Object(c.of)(void 0)}}pn.TELEMETRY_LOG_MIN_ALLOWED_OFFSET_KEY="telemetry_log_min_allowed_offset_key",pn.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY="last_synced_device_register_attempt_time_stamp",pn.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY="last_synced_device_register_is_successful",pn.TELEMETRY_ENDPOINT="/telemetry",pn.REGISTER_API_SUCCESS_TTL=864e5,pn.REGISTER_API_FAILURE_TTL=36e5;var _n,On,Sn,gn,An,Nn,Tn,Cn,vn,yn,mn,bn,In,Mn,Rn,Ln,Pn,Dn=n(7);!function(e){e[e.NOT_FOUND=-1]="NOT_FOUND",e[e.DELETED_SUCCESSFULLY=1]="DELETED_SUCCESSFULLY"}(_n||(_n={})),function(e){e.ASC="asc",e.DESC="desc"}(On||(On={})),function(e){e[e.NOTHING=0]="NOTHING",e[e.PREVIEWED=1]="PREVIEWED",e[e.BOOKMARKED=2]="BOOKMARKED"}(Sn||(Sn={})),function(e){e.SEARCH="search",e.FILTER="filter"}(gn||(gn={})),function(e){e[e.ALL=0]="ALL",e[e.DOWNLOADED=1]="DOWNLOADED",e[e.SPINE=2]="SPINE"}(An||(An={})),function(e){e[e.SEEN_BUT_NOT_AVAILABLE=0]="SEEN_BUT_NOT_AVAILABLE",e[e.ONLY_SPINE=1]="ONLY_SPINE",e[e.ARTIFACT_AVAILABLE=2]="ARTIFACT_AVAILABLE"}(Nn||(Nn={})),function(e){e.APK="application/vnd.android.package-archive",e.ECML="application/vnd.ekstep.ecml-archive",e.HTML="application/vnd.ekstep.html-archive",e.COLLECTION="application/vnd.ekstep.content-collection",e.H5P="application/vnd.ekstep.h5p-archive",e.VIDEO="video/mp4",e.YOUTUBE="video/x-youtube",e.WEBM="video/webm",e.QUESTION="application/vnd.sunbird.question",e.QUESTION_SET="application/vnd.sunbird.questionset",e.EPUB="application/epub",e.ZIP="application/zip",e.TXT="text/plain",e.ECAR="application/ecar",e.EPAR="application/epar"}(Tn||(Tn={})),function(e){e.DEFAULT="Default",e.PARENT="Parent"}(Cn||(Cn={})),function(e){e.LIVE="Live",e.DRAFT="Draft"}(vn||(vn={})),function(e){e.GZIP="gzip",e.IDENTITY="identity"}(yn||(yn={})),function(e){e.ATTACHMENT="attachment",e.INLINE="inline",e.ONLINE="online"}(mn||(mn={})),function(e){e.CONTENT="ecar",e.PROFILE="epar",e.TELEMETRY="gsa"}(bn||(bn={})),function(e){e[e.NOT_FOUND=-1]="NOT_FOUND",e[e.ENQUEUED_FOR_DOWNLOAD=0]="ENQUEUED_FOR_DOWNLOAD",e[e.DOWNLOAD_STARTED=1]="DOWNLOAD_STARTED",e[e.DOWNLOAD_FAILED=2]="DOWNLOAD_FAILED",e[e.DOWNLOAD_COMPLETED=3]="DOWNLOAD_COMPLETED",e[e.IMPORT_STARTED=4]="IMPORT_STARTED",e[e.IMPORT_FAILED=5]="IMPORT_FAILED",e[e.NOT_COMPATIBLE=6]="NOT_COMPATIBLE",e[e.CONTENT_EXPIRED=7]="CONTENT_EXPIRED",e[e.ALREADY_EXIST=8]="ALREADY_EXIST",e[e.IMPORT_COMPLETED=100]="IMPORT_COMPLETED"}(In||(In={})),function(e){e.NO_DATA_FOUND="NO_DATA_FOUND",e.INVALID_FILE="INVALID_FILE",e.ECAR_NOT_FOUND="ECAR_NOT_FOUND",e.IMPORT_FAILED_DEVICE_MEMORY_FULL="IMPORT_FAILED_DEVICE_MEMORY_FULL",e.IMPORT_FAILED_EXTRACT_ECAR="IMPORT_FAILED_EXTRACTION",e.IMPORT_FAILED_MANIFEST_FILE_NOT_FOUND="IMPORT_FAILED_MANIFEST_FILE_NOT_FOUND",e.IMPORT_FAILED_UNSUPPORTED_MANIFEST="IMPORT_FAILED_UNSUPPORTED_MANIFEST",e.IMPORT_FAILED_NO_CONTENT_METADATA="IMPORT_FAILED_NO_CONTENT_METADATA",e.DUPLICATE_CONTENT="DUPLICATE_CONTENT",e.IMPORT_FILE_EXIST="IMPORT_FILE_EXIST",e.ECAR_CLEANUP_FAILED="ECAR_CLEANUP_FAILED",e.EXPORT_FAILED_COPY_ASSET="EXPORT_FAILED_COPY_ASSET",e.EXPORT_FAILED_MEMORY_NOT_SUFFICIENT="EXPORT_FAILED_MEMORY_NOT_SUFFICIENT",e.EXPORT_FAILED_WRITING_MANIFEST="EXPORT_FAILED_WRITE_MANIFEST",e.EXPORT_FAILED_ECAR_BUNDLE="EXPORT_FAILED_ECAR_BUNDLE",e.EXPORT_FAILED_NOTHING_TO_EXPORT="EXPORT_FAILED_NOTHING_TO_EXPORT",e.EXPORT_FAILED_DELETING_ECAR="EXPORT_FAILED_DELETING_ECAR"}(Mn||(Mn={})),function(e){e.EXPORT_FAILED="EXPORT_FAILED",e.IMPORT_FAILED="IMPORT_FAILED"}(Rn||(Rn={})),function(e){e.MANIFEST="manifest.json",e.HIERARCHY="hierarchy.json"}(Ln||(Ln={})),function(e){e.UPDATE="UPDATE",e.IMPORT_COMPLETED="IMPORT_COMPLETED",e.IMPORT_PROGRESS="IMPORT_PROGRESS",e.SERVER_CONTENT_DATA="SERVER_CONTENT_DATA",e.COURSE_STATE_UPDATED="COURSE_STATE_UPDATED",e.CONTENT_EXTRACT_COMPLETED="CONTENT_EXTRACT_COMPLETED"}(Pn||(Pn={}));class wn{static joinPreservingQuotes(e){return e.map(e=>`'${e}'`).join(",")}static isEmpty(e){return!e||0===e.length}static contains(e,t){return e&&-1!==e.indexOf(t)}static deDupe(e){return e.filter((e,t,n)=>n.indexOf(e)===t)}}var Un,jn=n(17),Fn=n(18);class kn{static isAvailableLocally(e){return e===Nn.ARTIFACT_AVAILABLE}static isUpdateAvailable(e,t){let n=-1,r=-1;return e&&e.pkgVersion&&(r=parseFloat(e.pkgVersion)),t&&t.pkgVersion&&(n=parseFloat(t.pkgVersion)),r>0&&n>0&&r>n}static hasChildren(e){return!!e&&("string"==typeof e&&(e=JSON.parse(e)),e&&e.children)}static getContentRollup(e,t){let n,r,i,o;if(t&&0!==t.length)for(let e=0;e<t.length;e++)if(0===e)n=t[e].identifier;else if(1===e)r=t[e].identifier;else if(2===e)i=t[e].identifier;else{if(3!==e)break;o=t[e].identifier}else n=e;return{l1:n,l2:r,l3:i,l4:o}}static getChildContentsIdentifiers(e){const t=[];let n;n="string"==typeof e?JSON.parse(e):e;const r=n.children;return r&&r.length&&r.forEach(e=>{t.push(e.identifier)}),t}static getFirstPartOfThePathNameOnLastDelimiter(e){const t=e.lastIndexOf("/");if(t>0&&t<e.length)return e.substring(0,t)}static hasPreRequisites(e){return JSON.parse(e).pre_requisites}static readVisibility(e){const t=e.visibility;return t||Cn.DEFAULT}static isCompatible(e,t){return t>=e.minCompatibilityLevel&&t<=e.maxCompatibilityLevel}static readCompatibilityLevel(e){const t=e.compatibilityLevel;return t||this.defaultCompatibilityLevel}static isDraftContent(e){return e&&e===vn.DRAFT.valueOf()}static isExpired(e){if(e){const t=new Date(e).getTime();if((new Date).getTime()>t)return!0}return!1}static isDuplicateCheckRequired(e,t){return e&&0===t}static isImportFileExist(e,t){if(!e||!t)return!1;let n=!1;const r=e[St.COLUMN_NAME_IDENTIFIER],i=t.identifier,o=e[St.COLUMN_NAME_VISIBILITY],s=kn.readVisibility(t);return r===i&&o===s&&(n=this.readPkgVersion(JSON.parse(e[St.COLUMN_NAME_LOCAL_DATA]))>=this.readPkgVersion(t)),n}static readPkgVersion(e){return e.pkgVersion}static readContentType(e){let t=e.contentType;return t&&(t=t.toLowerCase()),t}static readPrimaryCategory(e){let t=e.primaryCategory;return t=t?t.toLowerCase():jn.CsPrimaryCategoryMapper.getPrimaryCategory(e.contentType.toLowerCase(),e.mimeType,e.resourceType).toLowerCase(),t}static readPrimaryCategoryServer(e){let t=e.primaryCategory;return t=t||jn.CsPrimaryCategoryMapper.getPrimaryCategory(e.contentType.toLowerCase(),e.mimeType,e.resourceType),t}static readAudience(e){const t=e.audience,n=[];return"string"==typeof t&&n.push(t),n&&n.length||n.push("Learner"),n.sort(),n.join(",")}static readPragma(e){let t=e.pragma;return t||(t=[]),t.join(",")}static doesContentExist(e,t,n,r){if(!e)return!1;let i=!1;const o=e[St.COLUMN_NAME_IDENTIFIER],s=JSON.parse(e[St.COLUMN_NAME_LOCAL_DATA]);if(o===t){let t=!1;r?t=!(kn.readPkgVersion(s)<n):kn.readPkgVersion(s)<n&&(t=!0),i=!(t||!r&&e[St.COLUMN_NAME_CONTENT_STATE]!==Nn.ARTIFACT_AVAILABLE.valueOf())}return i}static getContentRootDir(e){return"ios"===window.device.platform.toLowerCase()?e.concat("content/"):e.concat("content")}static addOrUpdateViralityMetadata(e,t){if(kn.isContentMetadataAbsent(e)){const n={};n.origin=t,n.transferCount=kn.INITIAL_VALUE_FOR_TRANSFER_COUNT;const r={};r.virality=n,e.contentMetadata=r}else if(kn.isContentMetadataPresentWithoutViralityMetadata(e)){const n={};n.origin=t,n.transferCount=kn.INITIAL_VALUE_FOR_TRANSFER_COUNT,e.contentMetaData.virality=n}else{const t=e.contentMetaData.virality;t.transferCount=kn.transferCount(t)+1}}static addViralityMetadataIfMissing(e,t){e.contentMetaData||(e.contentMetaData={});const n=e.contentMetaData;n.virality||(n.virality={});let r=e.virality;r||(r={}),r.origin||(r.origin=t),r.transferCount||(r.transferCount=kn.INITIAL_VALUE_FOR_TRANSFER_COUNT)}static isInlineIdentity(e,t){return e&&t&&mn.INLINE.valueOf()===e&&yn.IDENTITY.valueOf()===t}static isOnlineContent(e){const t=e.contentDisposition;return t&&mn.ONLINE.valueOf()===t}static addOrUpdateDialcodeMapping(e,t,n){let r;r=e?JSON.parse(e):{},r.hasOwnProperty("identifier")||(r.identifier=t);const i=new Set;return r.hasOwnProperty("rootNodes")&&r.forEach(e=>{i.add(e)}),i.add(n),r.rootNodes=i,JSON.stringify(r)}static deDupe(e,t){return e.filter((e,n,r)=>r.map(e=>e[t]).indexOf(e[t])===n)}static getExportedFileName(e,t){let n,r="blank.ecar",i=0;e.length>0&&(n=e[0]);if(e.forEach(e=>{Cn.DEFAULT.valueOf()===e[St.COLUMN_NAME_VISIBILITY]&&i++}),i>1&&"".concat((i-1).toString()),n){const e=JSON.parse(n[St.COLUMN_NAME_LOCAL_DATA]);let i=e.name;i&&i.length>kn.MAX_CONTENT_NAME&&(i=i.substring(0,kn.MAX_CONTENT_NAME-3)+"...");const o=e.pkgVersion;r=`${t.toLowerCase()}_${i}-v${o}.ecar`}return r}static readOriginFromContentMap(e){const t=e.contentMetadata,n=t&&t.virality;return n?n.origin:""}static readTransferCountFromContentMap(e){const t=e.contentMetadata,n=t&&t.virality;return n?fe.parseInt(n.transferCount):0}static readSizeFromContentMap(e){return e.size?e.size:""}static getUidnIdentifierFiler(e,t){const n=e&&`uid = '${e}'`,r=t&&`identifier = '${t}'`;let i="";return n&&r?i=`WHERE (${r} AND ${n})`:r?i=`WHERE (${r})`:n&&(i=`WHERE (${n})`),i}static getBasePath(e){return e?e=-1!==e.indexOf("file://")?e.replace("file://",""):"file://".concat(e):""}static getRollup(e,t){let n,r,i,o;if(t){let e;for(e=0;e<t.length;e++)switch(e){case 0:n=t[e].identifier;break;case 1:r=t[e].identifier;break;case 2:i=t[e].identifier;break;case 3:o=t[e].identifier}}else n=e;return{l1:n,l2:r,l3:i,l4:o}}static addOrUpdateRefCount(e){return e<0&&(e=0),e}static isNotUnit(e,t){return!(Tn.COLLECTION.valueOf()===e&&Cn.PARENT.valueOf()===t)}static getContentAttribute(e){let t=[];if(e&&("string"==typeof e?t.push(e):t=e,t&&t.length)){t.sort();let e="";for(let n=0;n<t.length;n++)e=n<t.length-1?e.concat("~",t[n]):e.concat("~",t[n],"~");return e.toLowerCase().trim()}return""}static getFindAllContentsWithIdentifierQuery(e){const t=wn.joinPreservingQuotes(e),n=` order by ${St.COLUMN_NAME_LOCAL_LAST_UPDATED_ON} desc, ${St.COLUMN_NAME_SERVER_LAST_UPDATED_ON} desc`,r=` where ${St.COLUMN_NAME_IDENTIFIER} in (${t}) AND ${St.COLUMN_NAME_REF_COUNT} > 0`;return`select * from ${St.TABLE_NAME} ${r} ${n}`}static getFindAllContentsQuery(){return`select * from ${St.TABLE_NAME} where ${St.COLUMN_NAME_REF_COUNT} > 0`}static constructContentDBModel(e,t,n,r,i,o,s,a,c,u,l,d,h,E,f,p){return{[St.COLUMN_NAME_IDENTIFIER]:e,[St.COLUMN_NAME_SERVER_DATA]:"",[St.COLUMN_NAME_PATH]:kn.getBasePath(s),[St.COLUMN_NAME_REF_COUNT]:a,[St.COLUMN_NAME_CONTENT_STATE]:c,[St.COLUMN_NAME_SIZE_ON_DEVICE]:d,[St.COLUMN_NAME_MANIFEST_VERSION]:t,[St.COLUMN_NAME_LOCAL_DATA]:n,[St.COLUMN_NAME_MIME_TYPE]:r,[St.COLUMN_NAME_CONTENT_TYPE]:i,[St.COLUMN_NAME_VISIBILITY]:o,[St.COLUMN_NAME_AUDIENCE]:u,[St.COLUMN_NAME_PRAGMA]:l,[St.COLUMN_NAME_LOCAL_LAST_UPDATED_ON]:b()().format(),[St.COLUMN_NAME_BOARD]:kn.getContentAttribute(h),[St.COLUMN_NAME_MEDIUM]:kn.getContentAttribute(E),[St.COLUMN_NAME_GRADE]:kn.getContentAttribute(f),[St.COLUMN_NAME_PRIMARY_CATEGORY]:p}}static getReferenceCount(e,t){let n;return e?(n=e[St.COLUMN_NAME_REF_COUNT],Cn.DEFAULT.valueOf()===e[St.COLUMN_NAME_VISIBILITY]&&Cn.DEFAULT.valueOf()===t||(n+=1)):n=1,n}static getContentVisibility(e,t,n){let r;return"Library"===t?r=Cn.PARENT.valueOf():e&&!Cn.PARENT.valueOf()===e[St.COLUMN_NAME_VISIBILITY]&&(r=e[St.COLUMN_NAME_VISIBILITY]),r||n}static getContentState(e,t){return e&&e[St.COLUMN_NAME_CONTENT_STATE]>t&&(t=e[St.COLUMN_NAME_CONTENT_STATE]),t}static isFreeSpaceAvailable(e,t,n){let r=10240;return n>0&&(r=n),e>0&&e>t+r}static transferCount(e){const t=e.transferCount;return parseInt(t,0)}static isContentMetadataAbsent(e){return!Boolean(e.contentMetaData)}static isContentMetadataPresentWithoutViralityMetadata(e){return!Boolean(e.contentMetaData.virality)}static isTrackable(e){return e.trackable&&"string"==typeof e.trackable&&(e.trackable=JSON.parse(e.trackable)),e.trackable&&e.trackable.enabled?e.trackable.enabled===Dn.TrackingEnabled.YES?1:e.mimeType===Tn.COLLECTION?0:-1:e.contentType.toLowerCase()===Fn.CsContentType.COURSE.toLowerCase()?1:e.mimeType===Tn.COLLECTION?0:-1}static getParseErrorObject(e){try{return JSON.parse(e)}catch(e){return}}}kn.defaultCompatibilityLevel=1,kn.DEFAULT_PACKAGE_VERSION=-1,kn.INITIAL_VALUE_FOR_TRANSFER_COUNT=0,kn.MAX_CONTENT_NAME=30;class xn{static mapContentDataToContentDBEntry(e,t){let n,r,i;return t?i=JSON.stringify(e):(n=e.lastUpdatedOn,r=JSON.stringify(e)),{[St.COLUMN_NAME_IDENTIFIER]:e.identifier,[St.COLUMN_NAME_SERVER_DATA]:r,[St.COLUMN_NAME_SERVER_LAST_UPDATED_ON]:n,[St.COLUMN_NAME_MANIFEST_VERSION]:t,[St.COLUMN_NAME_LOCAL_DATA]:i,[St.COLUMN_NAME_MIME_TYPE]:e.mimeType,[St.COLUMN_NAME_CONTENT_TYPE]:kn.readContentType(e),[St.COLUMN_NAME_VISIBILITY]:kn.readVisibility(e),[St.COLUMN_NAME_AUDIENCE]:kn.readAudience(e),[St.COLUMN_NAME_PRAGMA]:kn.readPragma(e),[St.COLUMN_NAME_PRIMARY_CATEGORY]:kn.readPrimaryCategory(e)}}static mapServerResponseToContent(e,t){let n,r,i;t?i=e:(n=e.lastUpdatedOn,r=e),!e.primaryCategory&&e.contentType&&e.mimeType&&(e.primaryCategory=jn.CsPrimaryCategoryMapper.getPrimaryCategory(e.contentType.toLowerCase(),e.mimeType,e.resourceType));const o=e.primaryCategory?e.primaryCategory:e.contentType;return!e.trackable&&o&&o.toLowerCase()===Fn.CsContentType.COURSE.toLowerCase()&&(e.trackable={enabled:Dn.TrackingEnabled.YES}),e.trackable||(e.trackable={enabled:Dn.TrackingEnabled.NO}),{identifier:e.identifier,name:e.name,contentData:e,isUpdateAvailable:kn.isUpdateAvailable(r,i),mimeType:e.mimeType,basePath:"",contentType:kn.readContentType(e),primaryCategory:kn.readPrimaryCategory(e),isAvailableLocally:!1,referenceCount:0,sizeOnDevice:0,lastUsedTime:0,lastUpdatedTime:0}}static mapContentDBEntryToContent(e,t){let n;const r=e[St.COLUMN_NAME_SERVER_DATA],i=e[St.COLUMN_NAME_LOCAL_DATA],o=r&&JSON.parse(r);let s,a=i&&JSON.parse(i),c=e[St.COLUMN_NAME_IDENTIFIER],u=e[St.COLUMN_NAME_MIME_TYPE],l=e[St.COLUMN_NAME_VISIBILITY],d=e[St.COLUMN_NAME_CONTENT_TYPE],h=e[St.COLUMN_NAME_PRIMARY_CATEGORY],E=0;e.hasOwnProperty(At.COLUMN_NAME_EPOCH_TIMESTAMP)&&(E=e[At.COLUMN_NAME_EPOCH_TIMESTAMP]),e.hasOwnProperty(vt.COLUMN_NAME_DATA)&&(a||(a=JSON.parse(e[vt.COLUMN_NAME_DATA])),a&&(c=a.identifier,u=a.mimeType,s=a.resourceType,l=kn.readVisibility(a),d=kn.readContentType(a),h=kn.readPrimaryCategory(a))),a&&(n=a),o&&(a&&kn.isAvailableLocally(e[St.COLUMN_NAME_CONTENT_STATE])?(a.streamingUrl||(a.streamingUrl=o.streamingUrl),a.previewUrl||(a.previewUrl=o.previewUrl),o.me_totalRatingsCount&&(a.me_totalRatingsCount=o.me_totalRatingsCount),o.me_averageRating&&(a.me_averageRating=o.me_averageRating),a.size||(a.size=o.size),o.licenseDetails&&(a.licenseDetails=o.licenseDetails),o.forumId&&(a.forumId=o.forumId)):n=o);let f=0;const p=e[St.COLUMN_NAME_LOCAL_LAST_UPDATED_ON];p&&(f=new Date(p).getTime());const _=Number(e[St.COLUMN_NAME_SIZE_ON_DEVICE]),O=_||Number(o?o.size:0);!n.trackable&&h&&h.toLowerCase()===Fn.CsContentType.COURSE.toLowerCase()&&(n.trackable={enabled:Dn.TrackingEnabled.YES}),n.trackable||(n.trackable={enabled:Dn.TrackingEnabled.NO}),s=n.resourceType,!n.primaryCategory&&d&&(n.primaryCategory=jn.CsPrimaryCategoryMapper.getPrimaryCategory(d.toLowerCase(),u,s));const S=e[St.COLUMN_NAME_PATH]||"";return"string"==typeof n.originData&&(n.originData=kn.getParseErrorObject(n.originData)),n.trackable&&"string"==typeof n.trackable&&(n.trackable=JSON.parse(n.trackable)),{identifier:c,name:n.name,contentData:n,isUpdateAvailable:kn.isUpdateAvailable(o,a),mimeType:u,basePath:t?"/_app_file_"+S:S,primaryCategory:h,contentType:d,isAvailableLocally:kn.isAvailableLocally(e[St.COLUMN_NAME_CONTENT_STATE]),referenceCount:Number(e[St.COLUMN_NAME_REF_COUNT])||0,sizeOnDevice:O,lastUsedTime:E||0,lastUpdatedTime:f}}}class Bn{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.open(e.sourceDBFilePath).then(()=>this.dbService.read({table:Qe.TABLE_NAME,useExternalDb:!0}).toPromise()).then(n=>{if(!n||!n.length)throw t.errorMesg=Rn.IMPORT_FAILED.valueOf(),t;const r={};n.forEach(e=>{r[e.key]=e.value}),e.metadata=r;const i=this.getImportTypes(r);if(i&&wn.contains(i,"telemetry")){const e=r.export_id,t=r.did;return this.dbService.read({table:ct.TABLE_NAME,selection:`${ct.COLUMN_NAME_IMPORTED_ID} = ?\n AND ${ct.COLUMN_NAME_DEVICE_ID} = ?`,selectionArgs:[e,t]}).toPromise()}throw t.errorMesg=Rn.IMPORT_FAILED.valueOf(),t}).then(n=>{if(n&&n.length)throw t.errorMesg=Rn.IMPORT_FAILED.valueOf(),t;return t.body=e,t})}getImportTypes(e){let t=[];return e.hasOwnProperty("types")&&(t=e.types),t}}!function(e){e.SAVE="SAVE"}(Un||(Un={}));var Vn,Yn=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Gn{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:qe.TABLE_NAME,useExternalDb:!0}).toPromise().then(e=>this.saveProccessedTelemetryToDB(e)).then(()=>(t.body=e,t))}saveProccessedTelemetryToDB(e){return Yn(this,void 0,void 0,(function*(){e.forEach(e=>Yn(this,void 0,void 0,(function*(){yield this.dbService.insert({table:qe.TABLE_NAME,modelJson:e})})))}))}}class Hn{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse,n=e.metadata.export_id,r=e.metadata.did,i={imported_id:n,device_id:r,count:e.metadata.events_count};return this.dbService.read({table:ct.TABLE_NAME,selection:`${ct.COLUMN_NAME_IMPORTED_ID} = ? AND ${ct.COLUMN_NAME_DEVICE_ID} = ?`,selectionArgs:[n,r],limit:"1"}).toPromise().then(e=>e&&e.length?this.dbService.update({table:ct.TABLE_NAME,modelJson:i}).toPromise():this.dbService.insert({table:ct.TABLE_NAME,modelJson:i}).toPromise()).then(()=>(t.body=e,t))}}class $n{constructor(e,t){this.dbService=e,this.telemetryService=t}execute(e){const t=new a.CsResponse;return this.dbService.read({table:ct.TABLE_NAME}).toPromise().then(e=>{const t=[];e.forEach(e=>{const n={type:ie.TELEMETRY,origin:e[ct.COLUMN_NAME_DEVICE_ID],identifier:e[ct.COLUMN_NAME_IMPORTED_ID],pkgVersion:0,transferCount:0,size:""};t.push(n)});const n={dir:ne.IN,type:re.FILE.valueOf(),items:t,env:"sdk"};return this.telemetryService.share(n).toPromise()}).then(()=>(t.body=e,t))}}!function(e){e.ONLINE="ONLINE",e.OFFLINE="OFFLINE"}(Vn||(Vn={}));var qn=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Kn{constructor(e,t){this.telemetryService=e,this.sharedPreferences=t,this.shouldSync=!1}static generateDownloadSpeedTelemetry(e){return qn(this,void 0,void 0,(function*(){const t=yield new Promise((e,t)=>{downloadManager.fetchSpeedLog?downloadManager.fetchSpeedLog((t,n)=>e(n),t):cordova.exec(e,t,"DownloadManagerPlugin","fetchSpeedLog",[])}),n={32:"0-32",64:"32-64",128:"64-128",256:"128-256",512:"256-512",1024:"512-1024",1536:"1024-1536",2048:"1536-2048",2560:"2048-2560",3072:"2560-3072",3584:"3072-3584",4096:"3584-above"};if(!Object.keys(null==t?void 0:t.distributionInKBPS).length)return;const r={duration:e/1e3,totalKBDownloaded:null==t?void 0:t.totalKBdownloaded,distributionInKBPS:Object.keys(n).reduce((e,r)=>((null==t?void 0:t.distributionInKBPS[r])?e[n[r]]=t.distributionInKBPS[r]:e[n[r]]=0,e),{})};return ln.log.interact({type:oe.OTHER,subType:se.NETWORK_SPEED,env:"sdk",pageId:"sdk",id:"sdk",valueMap:r}).pipe(Object(D.mapTo)(void 0)).toPromise()}))}getSyncMode(){return this.sharedPreferences.getString(v.KEY_AUTO_SYNC_MODE).pipe(Object(D.map)(e=>e))}setSyncMode(e){return this.sharedPreferences.putString(v.KEY_AUTO_SYNC_MODE,e)}start(e){return this.shouldSync=!0,Object(c.interval)(e).pipe(Object(D.tap)(t=>{t*e%Kn.DOWNLOAD_SPEED_TELEMETRY_SYNC_INTERVAL==0&&"ios"!==window.device.platform.toLowerCase()&&Kn.generateDownloadSpeedTelemetry(e)}),Object(D.filter)(()=>this.shouldSync),Object(D.tap)(()=>this.telemetryService.sync().pipe(Object(D.tap)(e=>{console.log("AUTO_SYNC_INVOKED_SYNC----------------------------------------------",e)}),Object(D.catchError)(e=>(console.error(e),Object(c.of)(void 0)))).toPromise()),Object(D.mapTo)(void 0))}pause(){this.shouldSync=!1}continue(){this.shouldSync=!0}}Kn.DOWNLOAD_SPEED_TELEMETRY_SYNC_INTERVAL=6e4;var zn,Wn,Xn,Jn,Qn=n(32);!function(e){e.STUDENT="student",e.TEACHER="teacher",e.ADMIN="administrator",e.PARENT="parent",e.OTHER="other",e.NONE="none"}(zn||(zn={})),function(e){e.SERVER="server",e.LOCAL="local"}(Wn||(Wn={}));class Zn{constructor(e,t){this.uid=e,this.sid=en.generateUniqueId(),this.createdTime=Date.now(),this.managedSession=t}}class er{}!function(e){e[e.NOT_PLAYED=0]="NOT_PLAYED",e[e.PLAYED=1]="PLAYED"}(Xn||(Xn={}));class tr{constructor(e,t){this.apiService=e,this.tenantServiceConfig=t,this.GET_TENANT_INFO_ENDPOINT="/info"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.tenantServiceConfig.tenantApiPath+this.GET_TENANT_INFO_ENDPOINT+"/"+e.slug).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result))}}!function(e){e.SERVER="server",e.CACHE="cache"}(Jn||(Jn={}));var nr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class rr{constructor(e,t,n,r){this.cachedItemStore=e,this.keyValueStore=t,this.container=n,this.profileServiceConfig=r,this.USER_PROFILE_DETAILS_KEY_PREFIX="userProfileDetails"}get csUserService(){return this.container.get(u.USER_SERVICE)}handle(e){return e.from=e.from||Jn.CACHE,Object(c.of)(e.from).pipe(Object(D.mergeMap)(t=>t===Jn.SERVER?this.fetchFromServer(e).pipe(Object(D.tap)(e=>nr(this,void 0,void 0,(function*(){return this.keyValueStore.setValue(this.USER_PROFILE_DETAILS_KEY_PREFIX+"-"+e.id,JSON.stringify(e)).toPromise()}))),Object(D.catchError)(t=>{if(e.forceRefresh)throw t;return this.fetchFromCache(e)})):this.fetchFromCache(e)))}fetchFromServer(e){return this.csUserService.getProfileDetails(e,{apiPath:this.profileServiceConfig.profileApiPath_V5})}fetchFromCache(e){return this.cachedItemStore.getCached(e.userId,this.USER_PROFILE_DETAILS_KEY_PREFIX,this.USER_PROFILE_DETAILS_KEY_PREFIX,()=>this.fetchFromServer(e))}}class ir{static mapProfileDBEntryToProfile(e){return{uid:e[et.COLUMN_NAME_UID],handle:e[et.COLUMN_NAME_HANDLE],createdAt:e[et.COLUMN_NAME_CREATED_AT],medium:e[et.COLUMN_NAME_MEDIUM]?e[et.COLUMN_NAME_MEDIUM].split(","):[],board:e[et.COLUMN_NAME_BOARD]?e[et.COLUMN_NAME_BOARD].split(","):[],subject:e[et.COLUMN_NAME_SUBJECT]?e[et.COLUMN_NAME_SUBJECT].split(","):[],profileType:e[et.COLUMN_NAME_PROFILE_TYPE],grade:e[et.COLUMN_NAME_GRADE]?e[et.COLUMN_NAME_GRADE].split(","):[],syllabus:e[et.COLUMN_NAME_SYLLABUS]?e[et.COLUMN_NAME_SYLLABUS].split(","):[],source:e[et.COLUMN_NAME_SOURCE],gradeValue:e[et.COLUMN_NAME_GRADE_VALUE]&&JSON.parse(e[et.COLUMN_NAME_GRADE_VALUE]),categories:e[et.COLUMN_NAME_CATEGORIES]}}static mapProfileToProfileDBEntry(e){return{[et.COLUMN_NAME_UID]:e.uid,[et.COLUMN_NAME_HANDLE]:e.handle,[et.COLUMN_NAME_CREATED_AT]:Number(e.createdAt),[et.COLUMN_NAME_MEDIUM]:e.medium?e.medium.join(","):"",[et.COLUMN_NAME_BOARD]:e.board?e.board.join(","):"",[et.COLUMN_NAME_SUBJECT]:e.subject?e.subject.join(","):"",[et.COLUMN_NAME_PROFILE_TYPE]:e.profileType,[et.COLUMN_NAME_GRADE]:e.grade?e.grade.join(","):"",[et.COLUMN_NAME_SYLLABUS]:e.syllabus?e.syllabus.join(","):"",[et.COLUMN_NAME_SOURCE]:e.source,[et.COLUMN_NAME_GRADE_VALUE]:e.gradeValue?JSON.stringify(e.gradeValue):"",[et.COLUMN_NAME_CATEGORIES]:e.categories?JSON.stringify(e.categories):""}}}class or{constructor(e,t){this.apiService=e,this.acceptTermsConditionApiConfig=t,this.GET_ACCEPT_TERM_CONDITIONS_ENDPOINT="/tnc/accept"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.acceptTermsConditionApiConfig.profileApiPath+this.GET_ACCEPT_TERM_CONDITIONS_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>"SUCCESS"===e.body.result.response))}}class sr extends ke{constructor(e){super(e,"INVALID_PROFILE_ERROR"),Object.setPrototypeOf(this,sr.prototype)}}class ar{constructor(e,t){this.apiService=e,this.profileAlreadyInUseConfig=t,this.GET_PROFILE_ALREADY_IN_USE_ENDPOINT="/get"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.profileAlreadyInUseConfig.profileApiPath_V2+this.GET_PROFILE_ALREADY_IN_USE_ENDPOINT+"/"+e.type+"/"+e.key).withBearerToken(!0).withUserToken(!0).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result))}}class cr{constructor(e,t){this.apiService=e,this.otpServiceConfig=t,this.GET_GENERATE_OTP_ENDPOINT="/generate"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.otpServiceConfig.otpApiPath+this.GET_GENERATE_OTP_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>"SUCCESS"===e.body.result.response))}}class ur{constructor(e,t){this.apiService=e,this.optServiceConfig=t,this.GET_VERIFY_OTP_ENDPOINT="/verify"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.optServiceConfig.otpApiPath+this.GET_VERIFY_OTP_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>"SUCCESS"===e.body.result.response))}}class lr{static dirPathFromFilePath(e){return e.substring(0,e.lastIndexOf("/"))}static fileNameFromFilePath(e){return e.substring(e.lastIndexOf("/")+1)}static getAssetPath(){return"ios"===window.device.platform.toLowerCase()?cordova.file.applicationDirectory+"www/assets":lr.ASSETS_PATH}}lr.ASSETS_PATH="file:///android_asset/www/assets";class dr{constructor(e,t,n,r){this.apiService=e,this.profileServiceConfig=t,this.fileService=n,this.cachedItemStore=r,this.LOCATION_LOCAL_KEY="location-"}handle(e){let t=e.filters.type;return e.filters.parentId&&(t=t+"_"+e.filters.parentId),this.cachedItemStore[e.from===Jn.SERVER?"get":"getCached"](t,this.LOCATION_LOCAL_KEY,"ttl_"+this.LOCATION_LOCAL_KEY,()=>this.fetchFromServer(e),()=>this.fetchFromFile(e),dr.LOCATION_TTL)}fetchFromServer(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.profileServiceConfig.searchLocationApiPath+dr.GET_SEARCH_LOCATION_ENDPOINT).withBearerToken(!0).withUserToken(!1).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result.response))}fetchFromFile(e){const t=lr.getAssetPath()+this.profileServiceConfig.locationDirPath;let n=e.filters.type;return e.filters.parentId&&(n=n+"-"+e.filters.parentId),n+=".json",Object(c.from)(this.fileService.readFileFromAssets(t.concat("/",n))).pipe(Object(D.map)(e=>JSON.parse(e).result.response))}}dr.GET_SEARCH_LOCATION_ENDPOINT="/location/search",dr.LOCATION_TTL=864e5;class hr{constructor(e){this.fileService=e}execute(e){const t=new a.CsResponse,n=`profiles_${b()().format("YYYYMMDDhhmmss")}.epar`;return this.fileService.createDir(e.destinationFolder.concat("Profile"),!1).then(e=>this.fileService.createFile(e.nativeURL,n,!0)).then(n=>(e.destinationDBFilePath=n.nativeURL,t.body=e,t))}}var Er=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class fr{constructor(e){this.dbService=e}execute(e){return Er(this,void 0,void 0,(function*(){const t=new a.CsResponse;return this.dbService.copyDatabase(e.destinationDBFilePath).toPromise().then(n=>(t.body=e,t)).then(()=>(t.body=e,t))}))}}var pr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class _r{constructor(e,t,n){this.dbService=e,this.fileService=t,this.deviceInfo=n}execute(e){return pr(this,void 0,void 0,(function*(){const t=new a.CsResponse,n=this.generateMetaData(e.userIds,e.groupIds);return this.dbService.open(e.destinationDBFilePath).then(()=>this.dbService.execute(Qe.getCreateEntry(),!0).toPromise()).then(()=>this.populateMetaData(n)).then(()=>(t.body=e,t)).catch(e=>{throw console.log("error",e),t})}))}generateMetaData(e,t){const n={version:20};return n.types=JSON.stringify(["userprofile"]),n.did=this.deviceInfo.getDeviceID(),n.export_id=en.generateUniqueId(),t||(t=[]),n.profiles_count=e.length+t.length,n}populateMetaData(e){return pr(this,void 0,void 0,(function*(){Object.keys(e).forEach(t=>pr(this,void 0,void 0,(function*(){const n={key:t,value:e[t]};yield this.dbService.insert({table:Qe.TABLE_NAME,modelJson:n,useExternalDb:!0}).toPromise()})))}))}}var Or=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Sr{constructor(e,t){this.dbService=e,this.fileService=t}execute(e){return Or(this,void 0,void 0,(function*(){const t=new a.CsResponse;return this.getAllTables().then(e=>{const t=e.map(e=>e.name);return this.removeTables(t,this.getAllTablesToExclude())}).then(()=>this.deleteUnwantedProfilesAndUsers(e.userIds)).then(()=>this.deleteUnwantedProfileSummary(e.userIds)).then(()=>this.deleteUnwantedGroups(e.groupIds)).then(()=>this.deleteUnwantedGroupProfiles(e.groupIds)).then(()=>this.keepAllFrameworknChannel()).then(()=>this.fileService.getMetaData(e.destinationDBFilePath)).then(t=>(e.size=t.size.toString(),this.populateMetaData({FILE_SIZE:t.size}))).then(()=>this.fileService.removeFile(e.destinationDBFilePath.concat("-journal"))).then(()=>(t.body=e,t)).catch(e=>{throw t.errorMesg=Rn.EXPORT_FAILED,t})}))}getAllTables(){return this.dbService.execute("SELECT name FROM sqlite_master WHERE type = 'table'",!0).toPromise()}getAllTablesToExclude(){return[Qe.TABLE_NAME,nt.TABLE_NAME,et.TABLE_NAME,lt.TABLE_NAME,ht.TABLE_NAME,pt.TABLE_NAME,ft.TABLE_NAME,It.TABLE_NAME]}removeTables(e,t){return Or(this,void 0,void 0,(function*(){for(const n of e)wn.contains(t,n)||(yield this.dbService.execute("DROP TABLE IF EXISTS "+n,!0).toPromise());return!0}))}populateMetaData(e){return Or(this,void 0,void 0,(function*(){Object.keys(e).forEach(t=>Or(this,void 0,void 0,(function*(){const n={key:t,value:e[t]};yield this.dbService.insert({table:Qe.TABLE_NAME,modelJson:n,useExternalDb:!0}).toPromise()})))}))}deleteUnwantedProfilesAndUsers(e){return Or(this,void 0,void 0,(function*(){const t=[],n=[];for(const r of e){const e=yield this.dbService.read({table:et.TABLE_NAME,useExternalDb:!0,selection:et.COLUMN_NAME_UID+"=?",selectionArgs:[r],limit:"1"}).toPromise();e&&e.length&&t.push(e[0][et.COLUMN_NAME_UID]);const i=yield this.dbService.read({table:nt.TABLE_NAME,useExternalDb:!0,selection:nt.COLUMN_NAME_UID+"=?",selectionArgs:[r],limit:"1"}).toPromise();i&&i.length&&n.push(i[0][nt.COLUMN_NAME_UID])}yield this.cleanTable(et.TABLE_NAME,et.COLUMN_NAME_UID,t),yield this.cleanTable(nt.TABLE_NAME,nt.COLUMN_NAME_UID,t)}))}deleteUnwantedProfileSummary(e){return Or(this,void 0,void 0,(function*(){yield this.cleanTable(lt.TABLE_NAME,lt.COLUMN_NAME_UID,e),yield this.cleanTable(ht.TABLE_NAME,ht.COLUMN_NAME_UID,e)}))}deleteUnwantedGroups(e){return Or(this,void 0,void 0,(function*(){if(!e||!e.length)return;const t=[];for(const n of e){const e=yield this.dbService.read({table:pt.TABLE_NAME,useExternalDb:!0,selection:pt.COLUMN_NAME_GID+"=?",selectionArgs:[n],limit:"1"}).toPromise();e&&e.length&&t.push(e[0][ft.COLUMN_NAME_GID])}yield this.cleanTable(pt.TABLE_NAME,pt.COLUMN_NAME_GID,t)}))}deleteUnwantedGroupProfiles(e){return Or(this,void 0,void 0,(function*(){if(!e||!e.length)return;const t=[];for(const n of e){const e=yield this.dbService.read({table:ft.TABLE_NAME,useExternalDb:!0,selection:ft.COLUMN_NAME_GID+"=?",selectionArgs:[n],limit:"1"}).toPromise();e&&e.length&&t.push(e[0][et.COLUMN_NAME_UID])}yield this.cleanTable(pt.TABLE_NAME,pt.COLUMN_NAME_GID,e)}))}keepAllFrameworknChannel(){return Or(this,void 0,void 0,(function*(){const e=`SELECT * FROM ${It.TABLE_NAME}\n WHERE ${It.COLUMN_NAME_KEY} LIKE 'channel_details_key-%'\n OR ${It.COLUMN_NAME_KEY} LIKE 'framework_details_key-%'\n OR ${It.COLUMN_NAME_KEY} LIKE 'form-%'`,t=yield this.dbService.execute(e,!0).toPromise();yield this.dbService.execute("DELETE FROM "+It.TABLE_NAME,!0),t.forEach(e=>Or(this,void 0,void 0,(function*(){yield this.dbService.insert({table:It.TABLE_NAME,useExternalDb:!0,modelJson:e})})))}))}cleanTable(e,t,n){return Or(this,void 0,void 0,(function*(){if(!n||!n.length)return;const r=wn.joinPreservingQuotes(n),i=`DELETE FROM ${e}\n WHERE ${t} NOT IN(${r})`;yield this.dbService.execute(i,!0).toPromise()}))}}class gr{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:ct.TABLE_NAME}).toPromise().then(e=>{const t=[];e.forEach(e=>{const n={type:ie.PROFILE,origin:e[ct.COLUMN_NAME_DEVICE_ID],identifier:e[ct.COLUMN_NAME_IMPORTED_ID],pkgVersion:0,transferCount:0,size:""};t.push(n)});const n={dir:ne.IN,type:re.FILE.valueOf(),items:t,env:"sdk"};return ln.log.share(n).toPromise()}).then(()=>(t.body=e,t))}}class Ar{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:ct.TABLE_NAME}).toPromise().then(e=>{const t=[];e.forEach(e=>{const n={type:ie.PROFILE,origin:e[ct.COLUMN_NAME_DEVICE_ID],identifier:e[ct.COLUMN_NAME_IMPORTED_ID],pkgVersion:0,transferCount:0,size:""};t.push(n)});const n={dir:ne.OUT,type:re.FILE.valueOf(),items:t,env:"sdk"};return ln.log.share(n).toPromise()}).then(()=>(t.body=e,t))}}class Nr{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.open(e.sourceDBFilePath).then(()=>this.dbService.read({table:Qe.TABLE_NAME,useExternalDb:!0}).toPromise()).then(n=>{if(!n||!n.length)throw t.errorMesg=Rn.IMPORT_FAILED.valueOf(),t;const r={};n.forEach(e=>{r[e.key]=e.value}),e.metadata=r;const i=this.getImportTypes(r);if(i&&!wn.contains(i,"userprofile"))throw t.errorMesg=Rn.IMPORT_FAILED.valueOf(),t;return t.body=e,t})}getImportTypes(e){let t=[];return e.hasOwnProperty("types")&&(t=JSON.parse(e.types)),t}}var Tr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Cr{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:nt.TABLE_NAME,useExternalDb:!0}).toPromise().then(t=>this.saveUsersToDb(e,t)).then(()=>(t.body=e,t))}saveUsersToDb(e,t){return Tr(this,void 0,void 0,(function*(){t.forEach(e=>Tr(this,void 0,void 0,(function*(){delete e[nt._ID];const t=yield this.dbService.read({table:et.TABLE_NAME,selection:nt.COLUMN_NAME_UID+" = ?",selectionArgs:[e[nt.COLUMN_NAME_UID]],limit:"1"}).toPromise();t&&t.length||(yield this.dbService.insert({table:nt.TABLE_NAME,modelJson:e}).toPromise())})))}))}}var vr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class yr{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:pt.TABLE_NAME,useExternalDb:!0}).toPromise().then(t=>this.saveGroupsToDb(e,t)).then(()=>(t.body=e,t))}saveGroupsToDb(e,t){return vr(this,void 0,void 0,(function*(){let n=0,r=0;t.forEach(e=>vr(this,void 0,void 0,(function*(){const t=yield this.dbService.read({table:pt.TABLE_NAME,selection:pt.COLUMN_NAME_GID+" = ?",selectionArgs:[e[pt.COLUMN_NAME_GID]],limit:"1"}).toPromise();t&&t.length?r++:(e[pt.COLUMN_NAME_CREATED_AT]||(e[pt.COLUMN_NAME_CREATED_AT]=Date.now()),yield this.dbService.insert({table:pt.TABLE_NAME,modelJson:e}).toPromise(),n++)}))),e.failed=e.failed?e.failed+r:r,e.imported=e.imported?e.imported+n:n}))}}var mr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class br{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:ft.TABLE_NAME,useExternalDb:!0}).toPromise().then(t=>this.saveGroupProfilesToDb(e,t)).then(()=>(t.body=e,t))}saveGroupProfilesToDb(e,t){return mr(this,void 0,void 0,(function*(){t.forEach(e=>mr(this,void 0,void 0,(function*(){delete e[ft._ID];const n=yield this.dbService.read({table:ft.TABLE_NAME,selection:`${ft.COLUMN_NAME_GID} = ? AND ${ft.COLUMN_NAME_UID} = ?`,selectionArgs:[t[ft.COLUMN_NAME_GID],e[ft.COLUMN_NAME_UID]],limit:"1"}).toPromise();n&&n.length||(yield this.dbService.insert({table:ft.TABLE_NAME,modelJson:e}))})))}))}}var Ir=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Mr{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:It.TABLE_NAME,useExternalDb:!0}).toPromise().then(e=>this.saveNoSqlEntryToDb(e)).then(()=>(t.body=e,t))}saveNoSqlEntryToDb(e){return Ir(this,void 0,void 0,(function*(){e.forEach(e=>Ir(this,void 0,void 0,(function*(){delete e[It._ID];const t=yield this.dbService.read({table:It.TABLE_NAME,selection:It.COLUMN_NAME_KEY+" = ?",selectionArgs:[e[It.COLUMN_NAME_KEY]],limit:"1"}).toPromise();t&&t.length||(yield this.dbService.insert({table:It.TABLE_NAME,modelJson:e}).toPromise())})))}))}}class Rr extends ke{constructor(e){super(e,"VALIDATION_ERROR"),Object.setPrototypeOf(this,Rr.prototype)}}var Lr=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Pr=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Dr=function(e,t){return function(n,r){t(n,r,e)}};let wr=class{constructor(e,t,n,r,i,o){this.dbService=e,this.contenService=t,this.eventsBusService=n,this.courseService=r,this.sharedPreference=i,this.profileService=o,this.summarizerTelemetryHandler=new Ai(this.courseService,this.sharedPreference,this,this.eventsBusService,this.contenService,this.profileService)}onInit(){return this.eventsBusService.registerObserver({namespace:M.TELEMETRY,observer:this}),Object(c.of)(void 0)}getDetailsPerQuestion(e){const t=kr.getQuetsionDetailsQuery(e.uids,e.contentId,e.qId);return this.dbService.execute(t).pipe(Object(D.map)(e=>Fr.mapDBEntriesToQuestionDetails(e)))}getLearnerAssessmentDetails(e){const t=kr.getDetailReportsQuery(e.uids,e.contentId);return this.dbService.execute(t).pipe(Object(D.map)(e=>Fr.mapDBEntriesToLearnerAssesmentDetails(e)))}getReportByQuestions(e){const t=kr.getQuestionReportsQuery(e.uids,e.contentId),n=kr.getReportAccuracyQuery(e.uids,e.contentId);return this.dbService.execute(n).pipe(Object(D.map)(e=>Fr.mapDBEntriesToAccuracy(e)),Object(D.mergeMap)(e=>this.dbService.execute(t).pipe(Object(D.map)(t=>Fr.mapDBEntriesToQuestionReports(e,t)))))}getReportsByUser(e){const t=kr.getReportsByUserQuery(e.uids,e.contentId);return this.dbService.execute(t).pipe(Object(D.map)(e=>Fr.mapDBEntriesToUserReports(e)))}getSummary(e){if(!e.uids)throw new Rr("uids are mandatory");const t=kr.getChildProgressQuery(e.uids);return this.getContentCache(e.uids).pipe(Object(D.mergeMap)(e=>this.dbService.execute(t).pipe(Object(D.map)(t=>Fr.mapDBEntriesToLearnerAssesmentSummary(t,e)))))}getContentCache(e){if(this.contentMap&&Object.keys(this.contentMap).length)return Object(c.of)(this.contentMap);{this.contentMap=new Map;const t={resourcesOnly:!0,primaryCategories:[],uid:e};return this.contenService.getContents(t).pipe(Object(D.map)(e=>(e.forEach(e=>{const t=new Ur;t.name=e.contentData&&e.contentData.name,t.totalScore=e.contentData&&e.contentData.totalScore,t.lastUsedTime=e.lastUsedTime,t.identifier=e.identifier,this.contentMap.set(e.identifier,t)}),this.contentMap)))}}saveLearnerAssessmentDetails(e){const t=Fr.mapTelemetryToLearnerAssesmentDetails(e),n=Fr.mapLearnerAssesmentDetailsToDbEntries(t),r=kr.getFilterForLearnerAssessmentDetails(t.qid,t.uid,t.contentId,t.hierarchyData),i=kr.getLearnerAssessmentsQuery(r);return this.dbService.execute(i).pipe(Object(D.mergeMap)(e=>e&&e.length?this.dbService.update({table:lt.TABLE_NAME,selection:kr.getUpdateSelection(),selectionArgs:[t.uid,t.contentId,t.hierarchyData?t.hierarchyData:"",t.qid],modelJson:n}).pipe(Object(D.map)(e=>e>0)):t.qid?this.dbService.insert({table:lt.TABLE_NAME,modelJson:n}).pipe(Object(D.map)(e=>e>0)):Object(c.of)(!1)))}saveLearnerContentSummaryDetails(e){const t=Fr.mapTelemetryToContentSummaryDetails(e),n=Fr.mapContentSummaryDetailsToDbEntries(t);return this.dbService.read({table:ht.TABLE_NAME,selection:kr.getLearnerSummaryReadSelection(t.hierarchyData),selectionArgs:[t.uid,t.contentId,t.hierarchyData]}).pipe(Object(D.mergeMap)(e=>e&&e.length?(n.sessions=e[0][ht.COLUMN_NAME_SESSIONS]+1,n.avg_ts=fe.toFixed(t.timespent/t.sessions),n.total_ts=t.timespent,n.last_updated_on=t.timestamp,this.dbService.update({table:ht.TABLE_NAME,selection:kr.getLearnerSummaryReadSelection(t.hierarchyData),selectionArgs:[t.uid,t.contentId,t.hierarchyData],modelJson:n}).pipe(Object(D.map)(e=>e>0))):(n.avg_ts=t.timespent,n.sessions=1,n.total_ts=t.timespent,n.last_updated_on=t.timestamp,this.dbService.insert({table:ht.TABLE_NAME,modelJson:n}).pipe(Object(D.map)(e=>e>0)))))}deletePreviousAssessmentDetails(e,t){return this.dbService.read({table:ht.TABLE_NAME,selection:`${ht.COLUMN_NAME_CONTENT_ID} = ? AND ${ht.COLUMN_NAME_UID} = ?`,selectionArgs:[t,e]}).pipe(Object(D.mergeMap)(n=>n&&n.length?this.dbService.delete({table:ht.TABLE_NAME,selection:`${ht.COLUMN_NAME_CONTENT_ID} = ? AND ${ht.COLUMN_NAME_UID} = ?`,selectionArgs:[t,e]}):Object(c.of)(void 0)),Object(D.mergeMap)(()=>this.dbService.read({table:lt.TABLE_NAME,selection:`${lt.COLUMN_NAME_CONTENT_ID} = ? AND ${lt.COLUMN_NAME_UID} = ?`,selectionArgs:[t,e]})),Object(D.mergeMap)(n=>n&&n.length?this.dbService.delete({table:lt.TABLE_NAME,selection:`${lt.COLUMN_NAME_CONTENT_ID} = ? AND ${lt.COLUMN_NAME_UID} = ?`,selectionArgs:[t,e]}):Object(c.of)(void 0)))}onEvent(e){return e.type===Un.SAVE?this.summarizerTelemetryHandler.handle(e.payload):Object(c.of)(void 0)}};wr=Lr([Object(s.injectable)(),Dr(0,Object(s.inject)(l.DB_SERVICE)),Dr(1,Object(s.inject)(l.CONTENT_SERVICE)),Dr(2,Object(s.inject)(l.EVENTS_BUS_SERVICE)),Dr(3,Object(s.inject)(l.COURSE_SERVICE)),Dr(4,Object(s.inject)(l.SHARED_PREFERENCES)),Dr(5,Object(s.inject)(l.PROFILE_SERVICE)),Pr("design:paramtypes",[o,Object,Object,Object,Object,Object])],wr);class Ur{}class jr{constructor(){this.reportDetailsList=[]}}class Fr{constructor(){}static mapLearnerAssesmentDetailsToDbEntries(e){return{[lt.COLUMN_NAME_UID]:e.uid,[lt.COLUMN_NAME_CONTENT_ID]:e.contentId,[lt.COLUMN_NAME_QID]:e.qid,[lt.COLUMN_NAME_Q_INDEX]:e.qindex,[lt.COLUMN_NAME_CORRECT]:e.correct,[lt.COLUMN_NAME_SCORE]:e.score,[lt.COLUMN_NAME_TIME_SPENT]:e.timespent,[lt.COLUMN_NAME_RES]:e.res,[lt.COLUMN_NAME_TIMESTAMP]:e.timestamp,[lt.COLUMN_NAME_Q_DESC]:e.qdesc,[lt.COLUMN_NAME_Q_TITLE]:e.qtitle,[lt.COLUMN_NAME_MAX_SCORE]:e.maxScore,[lt.COLUMN_NAME_HIERARCHY_DATA]:e.hierarchyData}}static mapContentSummaryDetailsToDbEntries(e){return{[ht.COLUMN_NAME_UID]:e.uid,[ht.COLUMN_NAME_CONTENT_ID]:e.contentId,[ht.COLUMN_NAME_AVG_TS]:e.avgts,[ht.COLUMN_NAME_TOTAL_TS]:e.totalts,[ht.COLUMN_NAME_LAST_UPDATED_ON]:e.lastUpdated,[lt.COLUMN_NAME_HIERARCHY_DATA]:e.hierarchyData}}static mapDBEntriesToLearnerAssesmentSummary(e,t){return e.map(e=>{const n=t.get(e[ht.COLUMN_NAME_CONTENT_ID]);return{uid:e[ht.COLUMN_NAME_UID].toString(),contentId:e[ht.COLUMN_NAME_CONTENT_ID].toString(),noOfQuestions:fe.parseInt(e[ht.COLUMN_NAME_NO_OF_QUESTIONS]),correctAnswers:fe.parseInt(e[ht.COLUMN_NAME_CORRECT_ANSWERS]),totalTimespent:Number(e[ht.COLUMN_NAME_TOTAL_TIME_SPENT]),hierarchyData:e[ht.COLUMN_NAME_HIERARCHY_DATA].toString(),totalMaxScore:fe.toFixed(e[ht.COLUMN_NAME_TOTAL_MAX_SCORE]),totalScore:fe.toFixed(e[ht.COLUMN_NAME_TOTAL_SCORE]),totalQuestionsScore:n?n.totalScore:0,name:n?n.name:e[ht.COLUMN_NAME_CONTENT_ID]}})}static mapDBEntriesToLearnerAssesmentDetails(e){const t=new Map;return e.map(e=>{const n={uid:e[lt.COLUMN_NAME_UID],contentId:e[lt.COLUMN_NAME_CONTENT_ID],qid:e[lt.COLUMN_NAME_QID],qindex:Number(e[lt.COLUMN_NAME_Q_INDEX]),correct:fe.parseInt(e[lt.COLUMN_NAME_CORRECT]),score:fe.toFixed(e[lt.COLUMN_NAME_SCORE]),timespent:Number(e[lt.COLUMN_NAME_TIME_SPENT]),res:e[lt[lt.COLUMN_NAME_RES]],timestamp:Number(e[lt.COLUMN_NAME_TIMESTAMP]),qdesc:e[lt.COLUMN_NAME_Q_DESC],qtitle:e[lt.COLUMN_NAME_Q_TITLE],maxScore:fe.toFixed(e[lt.COLUMN_NAME_MAX_SCORE]),hierarchyData:e[lt.COLUMN_NAME_HIERARCHY_DATA],total_ts:Number(e[lt.COLUMN_NAME_TOTAL_TS])};let r=t.get(n.uid);void 0===r&&(r=new jr,r.uid=n.uid,r.totalScore=0,r.maxTotalScore=0),r.reportDetailsList.push(n),r.totalScore+=n.score,r.totalTime=n.total_ts,r.maxTotalScore+=n.maxScore,r.totalScore=parseFloat(r.totalScore.toFixed(2)),t.set(n.uid,r)}),t}static mapDBEntriesToQuestionReports(e,t){return t.map(t=>{const n=t[lt.COLUMN_NAME_QID];let r=0;return e.hasOwnProperty(n)&&(r=fe.parseInt(e[n])),{uid:t[lt.COLUMN_NAME_UID],contentId:t[lt.COLUMN_NAME_CONTENT_ID],qid:t[lt.COLUMN_NAME_QID],qindex:Number(t[lt.COLUMN_NAME_Q_INDEX]),correct:fe.parseInt(t[lt.COLUMN_NAME_CORRECT]),score:fe.toFixed(t[lt.COLUMN_NAME_SCORE]),timespent:Number(t[lt.COLUMN_NAME_TIME_SPENT]),res:t[lt[lt.COLUMN_NAME_RES]],timestamp:Number(t[lt.COLUMN_NAME_TIMESTAMP]),qdesc:t[lt.COLUMN_NAME_Q_DESC],qtitle:t[lt.COLUMN_NAME_Q_TITLE],maxScore:fe.toFixed(t[lt.COLUMN_NAME_MAX_SCORE]),hierarchyData:t[lt.COLUMN_NAME_HIERARCHY_DATA],total_ts:Number(t[lt.COLUMN_NAME_TOTAL_TS]),marks:Number(t[lt.COLUMN_NAME_MARKS]),occurenceCount:t[lt.COLUMN_NAME_COUNT],sum_max_score:Number(t[lt.COLUMN_NAME_TOTAL_MAX_SCORE]),correct_users_count:r}})}static mapDBEntriesToAccuracy(e){const t={};return e.map(e=>{t[e[lt.COLUMN_NAME_QID]]=fe.parseInt(e[lt.COLUMN_NAME_USERS_COUNT])}),t}static mapDBEntriesToQuestionDetails(e){return e.map(e=>({uid:e.uid,time:Number(e.time),result:fe.round(e.result),max_score:fe.parseInt(e.max_score)}))}static mapDBEntriesToUserReports(e){return e.map(e=>({totalTimespent:Number(e[lt.COLUMN_NAME_TOTAL_TS]),score:fe.toFixed(e[lt.COLUMN_NAME_SCORE]),hData:e[lt.COLUMN_NAME_HIERARCHY_DATA],contentId:e[lt.COLUMN_NAME_CONTENT_ID],uid:e[lt.COLUMN_NAME_UID],userName:e[lt.COLUMN_NAME_HANDLE],timespent:Number(e[lt.COLUMN_NAME_TIME_SPENT])}))}static mapTelemetryToContentSummaryDetails(e){const t=e.edata,n=(t.item,e.context.cdata);return{uid:e.actor.id,contentId:e.object.id,timespent:Number(t.duration),timestamp:e.ets,hierarchyData:this.getHierarchyData(n)}}static mapTelemetryToLearnerAssesmentDetails(e){const t=e.edata,n=t.item,r=e.context.cdata;return{uid:e.actor.id,contentId:e.object.id,qid:n&&n.id,qindex:Number(t.index),correct:"Yes"===t.pass?1:0,score:Number(t.score),timespent:Number(t.duration),timestamp:e.ets,res:JSON.stringify(t.resvalues),qdesc:n&&n.desc,qtitle:n&&n.title,maxScore:n&&Number(n.maxscore),hierarchyData:this.getHierarchyData(r)}}static getHierarchyData(e){let t="";return e&&e.forEach(e=>{if("Collection"===e.type||"TextBook"===e.type)return t=e.id}),""}}class kr{static getChildProgressQuery(e){return`SELECT ${lt.COLUMN_NAME_UID}, ${lt.COLUMN_NAME_CONTENT_ID},\n COUNT (${lt.COLUMN_NAME_QID}) AS no_of_questions,\n SUM (${lt.COLUMN_NAME_CORRECT}) AS correct_answers,\n SUM (${lt.COLUMN_NAME_TIME_SPENT}) AS total_time_spent, h_data ,\n SUM (${lt.COLUMN_NAME_MAX_SCORE}) AS total_max_score,\n SUM (${lt.COLUMN_NAME_SCORE}) AS total_score\n FROM ${lt.TABLE_NAME}\n WHERE ${lt.COLUMN_NAME_UID} IN (${wn.joinPreservingQuotes(e)})\n GROUP BY ${lt.COLUMN_NAME_CONTENT_ID} `}static getDetailReportsQuery(e,t){return`SELECT *, lcs.${ht.COLUMN_NAME_TOTAL_TS}\n FROM ${lt.TABLE_NAME} la\n LEFT JOIN ${ht.TABLE_NAME} lcs\n ON (la.${ht.COLUMN_NAME_UID} = lcs.${lt.COLUMN_NAME_UID})\n AND la.${ht.COLUMN_NAME_CONTENT_ID} = lcs.${lt.COLUMN_NAME_CONTENT_ID}\n WHERE la.${lt.COLUMN_NAME_UID} IN(${wn.joinPreservingQuotes(e)})\n AND la.${lt.COLUMN_NAME_CONTENT_ID}='${t}'`}static getReportsByUserQuery(e,t){return`SELECT lcs.${ht.COLUMN_NAME_TOTAL_TS},\n SUM (${lt.COLUMN_NAME_SCORE}) AS score,\n la.${lt.COLUMN_NAME_HIERARCHY_DATA},la.${lt.COLUMN_NAME_CONTENT_ID},\n la.${lt.COLUMN_NAME_UID},p.${et.COLUMN_NAME_HANDLE},\n la.${lt.COLUMN_NAME_TIME_SPENT}\n FROM ${lt.TABLE_NAME} la\n LEFT JOIN ${ht.TABLE_NAME} lcs\n ON (la.${ht.COLUMN_NAME_UID} = lcs.${lt.COLUMN_NAME_UID})\n LEFT JOIN ${et.TABLE_NAME} p\n ON (la.${lt.COLUMN_NAME_UID} = p.${et.COLUMN_NAME_UID})\n WHERE la.${lt.COLUMN_NAME_UID} IN(${wn.joinPreservingQuotes(e)})\n AND la.${lt.COLUMN_NAME_CONTENT_ID}='${t}'\n GROUP BY la.${lt.COLUMN_NAME_UID}`}static getQuetsionDetailsQuery(e,t,n){return`SELECT ${lt.COLUMN_NAME_UID}, ${lt.COLUMN_NAME_TIME_SPENT} as time,\n ${lt.COLUMN_NAME_SCORE} as result,\n ${lt.COLUMN_NAME_MAX_SCORE} as max_score\n FROM ${lt.TABLE_NAME}\n WHERE ${lt.COLUMN_NAME_UID} IN(${wn.joinPreservingQuotes(e)})\n AND ${lt.COLUMN_NAME_CONTENT_ID}='${t}'\n AND ${lt.COLUMN_NAME_QID}='${n}'`}static getReportAccuracyQuery(e,t){return`SELECT ${lt.COLUMN_NAME_QID}, COUNT (*) as users_count\n FROM ${lt.TABLE_NAME}\n WHERE ${lt.COLUMN_NAME_UID} IN(${wn.joinPreservingQuotes(e)})\n AND ${lt.COLUMN_NAME_CONTENT_ID}='${t}'\n AND ${lt.COLUMN_NAME_SCORE} > 0\n GROUP BY ${lt.COLUMN_NAME_QID}`}static getQuestionReportsQuery(e,t){return`SELECT *, SUM(${lt.COLUMN_NAME_SCORE}) as marks,\n COUNT (${lt.COLUMN_NAME_Q_INDEX}) as occurence_count,\n SUM (${lt.COLUMN_NAME_MAX_SCORE}) as sum_max_score\n FROM ${lt.TABLE_NAME}\n WHERE ${lt.COLUMN_NAME_UID} IN(${wn.joinPreservingQuotes(e)})\n AND ${lt.COLUMN_NAME_CONTENT_ID}='${t}'\n GROUP BY ${lt.COLUMN_NAME_QID}`}static getFilterForLearnerAssessmentDetails(e,t,n,r){const i=`${lt.COLUMN_NAME_QID} = '${e}'`;return`WHERE ${`${lt.COLUMN_NAME_UID} = '${t}'`} AND ${`${lt.COLUMN_NAME_CONTENT_ID} = '${n}'`} AND ${`${lt.COLUMN_NAME_HIERARCHY_DATA} = '${r||""}'`} ${e?" AND "+i:""}`}static getLearnerAssessmentsQuery(e){return`SELECT * from ${lt.TABLE_NAME} ${e}\n ORDER BY ${lt.COLUMN_NAME_Q_INDEX}`}static getUpdateSelection(){return lt.COLUMN_NAME_UID+" = ? AND "+lt.COLUMN_NAME_CONTENT_ID+" = ? AND "+lt.COLUMN_NAME_HIERARCHY_DATA+" = ? AND "+lt.COLUMN_NAME_QID+" = ? "}static getLearnerSummaryReadSelection(e){return lt.COLUMN_NAME_UID+" = ? AND "+lt.COLUMN_NAME_CONTENT_ID+" = ? AND "+lt.COLUMN_NAME_HIERARCHY_DATA+" = ? "}}class xr{constructor(e,t){this.apiService=e,this.courseServiceConfig=t,this.GET_BATCH_DETAILS_ENDPOINT="/batch/read/"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.courseServiceConfig.apiPath+this.GET_BATCH_DETAILS_ENDPOINT+e.batchId).withBearerToken(!0).withUserToken(!0).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result.response))}}class Br{constructor(e,t){this.apiService=e,this.courseServiceConfig=t,this.GET_COURSE_BATCHES="/batch/list?creatorDetails"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.courseServiceConfig.apiPath+this.GET_COURSE_BATCHES).withBearerToken(!0).withUserToken(!1).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>Array.from(new Set(e.body.result.response.content))))}}var Vr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Yr{constructor(e,t,n,r,i){this.keyValueStore=e,this.apiService=t,this.courseServiceConfig=n,this.sharedPreference=r,this.apiHandler=i,this.GET_ENROLLED_COURSES_ENDPOINT="/user/enrollment/list/",this.STORED_ENROLLED_COURSES_PREFIX="enrolledCourses"}handle(e){return this.keyValueStore.getValue(this.STORED_ENROLLED_COURSES_PREFIX+e.userId).pipe(Object(D.mergeMap)(t=>{if(t){if(e.returnFreshCourses)return this.fetchFromServer(e).pipe(Object(D.mergeMap)(t=>this.keyValueStore.setValue(this.STORED_ENROLLED_COURSES_PREFIX+e.userId,JSON.stringify(t)).pipe(Object(D.mapTo)(t.result.courses),Object(D.tap)(e=>Object(c.from)(this.updateLastPlayedContent(e))))),Object(D.catchError)(()=>{const e=JSON.parse(t),n=e.result;let r;return r=n&&n.hasOwnProperty("courses")?n.courses:e.courses,Object(c.of)(r)}));{const e=JSON.parse(t),n=e.result;let r;return r=n&&n.hasOwnProperty("courses")?n.courses:e.courses,Object(c.of)(r)}}return this.fetchFromServer(e).pipe(Object(D.mergeMap)(t=>this.keyValueStore.setValue(this.STORED_ENROLLED_COURSES_PREFIX+e.userId,JSON.stringify(t)).pipe(Object(D.mapTo)(t.result.courses),Object(D.tap)(e=>Object(c.from)(this.updateLastPlayedContent(e))))))}))}updateLastPlayedContent(e){return Vr(this,void 0,void 0,(function*(){for(const t of e){const e=hi.LAST_READ_CONTENTID_PREFIX.concat("_").concat(t.userId).concat("_").concat(t.contentId).concat("_").concat(t.batchId),n=t.lastReadContentId;t.lastReadContentId&&(yield this.sharedPreference.putString(e,n).toPromise())}return Promise.resolve(!0)}))}fetchFromServer(e){if(this.apiHandler)return this.apiHandler.handle(e);const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.courseServiceConfig.apiPath+this.GET_ENROLLED_COURSES_ENDPOINT+e.userId+"?orgdetails=orgName,email&fields=contentType,topic,name,channel,pkgVersion,primaryCategory,trackable&batchDetails=name,endDate,startDate,status,enrollmentType,createdBy,certificates").withBearerToken(!0).withUserToken(!0).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body))}}class Gr{constructor(e,t){this.apiService=e,this.courseServiceConfig=t,this.ENROL_ENDPOINT="/enrol"}handle(e){delete e.batchStatus;const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.courseServiceConfig.apiPath+this.ENROL_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>"SUCCESS"===e.body.result.response),Object(D.tap)(()=>{this.generateAuditTelemetry(e)}))}generateAuditTelemetry(e){const t=new pe;t.id=e.userId,t.type=pe.TYPE_USER;const n=[{type:"CourseId",id:e.courseId},{type:"BatchId",id:e.batchId},{type:"UserId",id:e.userId}],r={env:"course",actor:t,currentState:ue.AUDIT_CREATED,updatedProperties:["courseId","userId","batchId"],objId:e.courseId,objType:"Course",rollUp:{l1:e.courseId},correlationData:n,type:"enrollment"};ln.log.audit(r).toPromise()}}class Hr{constructor(e,t){this.apiService=e,this.unenrollCourseServiceApiConfig=t,this.GET_UNENROLL_COURSE_ENDPOINT="/unenrol"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.unenrollCourseServiceApiConfig.apiPath+this.GET_UNENROLL_COURSE_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>"SUCCESS"===e.body.result.response))}}var $r,qr,Kr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class zr{constructor(e,t,n){this.apiService=e,this.courseServiceConfig=t,this.container=n}get csCourseService(){return this.container.get(u.COURSE_SERVICE)}get contentService(){return this.container.get(l.CONTENT_SERVICE)}handle(e){return delete e.returnRefreshedContentStates,Object(c.iif)(()=>!e.contentIds||!e.contentIds.length,Object(c.defer)(()=>Kr(this,void 0,void 0,(function*(){return e.contentIds=yield this.contentService.getContentDetails({contentId:e.courseId}).toPromise().then(e=>e.contentData.leafNodes||[]),this.fetchFromApi(e).toPromise()}))),Object(c.defer)(()=>this.fetchFromApi(e)))}fetchFromApi(e){return e.contentIds&&!e.contentIds.length&&delete e.contentIds,this.csCourseService.getContentState(e).pipe(Object(D.map)(e=>({contentList:e})))}}class Wr{constructor(e,t){this.keyValueStore=e,this.offlineContentStateHandler=t}updateEnrollCourses(e){const t=Wr.GET_ENROLLED_COURSES_KEY_PREFIX.concat(e.userId);return this.offlineContentStateHandler.getLocalContentStateResponse(e).pipe(Object(D.mergeMap)(n=>this.keyValueStore.getValue(t).pipe(Object(D.mergeMap)(r=>{if(r){const i=JSON.parse(r),o=i.result;let s;s=o&&o.hasOwnProperty("courses")?o.courses:i.courses;const a=[...s];return s.forEach(t=>{if(t.courseId===e.courseId&&t.batchId===e.batchId){const e=t;n.contentList.forEach(n=>{if(2===n.status){let r=t.contentsPlayedOffline;r||(r=[]),r.push(n.contentId),e.contentsPlayedOffline=wn.deDupe(r)}});const r=a.findIndex(e=>e.contentId===t.contentId&&e.batchId===t.batchId);a.splice(r,1,e)}}),a&&a.length?(o&&o.hasOwnProperty("courses")?o.courses=a:i.courses=a,this.keyValueStore.setValue(t,JSON.stringify(i)).pipe(Object(D.map)(()=>n))):Object(c.of)(n)}return Object(c.of)(n)}))))}}Wr.GET_ENROLLED_COURSES_KEY_PREFIX="enrolledCourses";class Xr{constructor(e){this.keyValueStore=e}getLocalContentStateResponse(e){const t=hi.GET_CONTENT_STATE_KEY_PREFIX.concat(e.userId,e.courseId);return this.keyValueStore.getValue(t).pipe(Object(D.map)(e=>{const t={contentList:[]};if(e){const n=JSON.parse(e),r=n.result;return r&&r.hasOwnProperty("contentList")?(t.contentList=r.contentList,t):(t.contentList=n.contentList,t)}return t.contentList=t.contentList.map(e=>("string"==typeof e.score&&(e.score=void 0),e)),t}))}manipulateEnrolledCoursesResponseLocally(e){const t=hi.GET_ENROLLED_COURSE_KEY_PREFIX.concat(e.userId);return this.keyValueStore.getValue(t).pipe(Object(D.mergeMap)(n=>{if(n){const r=JSON.parse(n),i=r.result;let o;if(o=i&&i.hasOwnProperty("courses")?i.courses:r.courses,o&&o.length){const n=[...o];return o.forEach(t=>{if(t.courseId===e.courseId&&t.batchId===e.batchId&&(t.contentsPlayedOffline&&t.contentsPlayedOffline.length||(t.contentsPlayedOffline=[]),1!==e.status&&(0===t.contentsPlayedOffline.length||t.contentsPlayedOffline.length>0&&!wn.contains(t.contentsPlayedOffline,e.contentId)))){t.progress=t.progress?t.progress:0,t.progress=t.progress+1,t.completionPercentage=this.getCourseCompletionPercentage(t.leafNodesCount,t.progress);const r=t;let i=r.contentsPlayedOffline;i||(i=[]),i.push(e.contentId),r.contentsPlayedOffline=i,r.progress=t.progress,r.completionPercentage=t.completionPercentage;const o=n.findIndex(e=>e.contentId===t.contentId||e.batchId===t.batchId);n.splice(o,1,r)}}),n&&n.length?(i&&i.hasOwnProperty("courses")?i.courses=n:r.courses=n,this.keyValueStore.setValue(t,JSON.stringify(r))):Object(c.of)(!1)}return Object(c.of)(!1)}return Object(c.of)(!1)}))}manipulateGetContentStateResponseLocally(e){const t=hi.GET_CONTENT_STATE_KEY_PREFIX.concat(e.userId,e.courseId);return this.keyValueStore.getValue(t).pipe(Object(D.mergeMap)(n=>{if(n){const r={contentList:[]},i=JSON.parse(n),o=i.result;if(o&&o.hasOwnProperty("contentList")?r.contentList=o.contentList:r.contentList=i.contentList,r){let n,i=r.contentList;return i&&i.length?(i.forEach(t=>{t.contentId===e.contentId?t.status!==e.status&&(e.score=t.score,e.bestScore=t.bestScore,n=this.getContentState(e),i=i.filter(e=>e.contentId!==t.contentId)):n=this.getContentState(e)}),n?(i.push(n),r.contentList=i,this.keyValueStore.setValue(t,JSON.stringify(r))):Object(c.of)(!1)):(n=this.getContentState(e),i=[],i.push(n),r.contentList=i,this.keyValueStore.setValue(t,JSON.stringify(r)))}return Object(c.of)(!1)}return Object(c.of)(!1)}))}getCourseCompletionPercentage(e,t){if(0===e||void 0===e)return 0;const n=t/e*100;return isNaN(n)?0:n>100?100:Math.floor(n)}getContentState(e){return{id:e.userId,userId:e.userId,courseId:e.courseId,contentId:e.contentId,batchId:e.batchId,result:e.result,grade:e.grade,score:e.score,bestScore:e.bestScore,status:e.status,progress:e.progress}}}!function(e){e.START="START",e.PROGRESS="PROGRESS",e.END="END"}($r||($r={})),function(e){e[e.STATUS_FAILED=16]="STATUS_FAILED",e[e.STATUS_PAUSED=4]="STATUS_PAUSED",e[e.STATUS_PENDING=1]="STATUS_PENDING",e[e.STATUS_RUNNING=2]="STATUS_RUNNING",e[e.STATUS_SUCCESSFUL=8]="STATUS_SUCCESSFUL"}(qr||(qr={}));var Jr=n(47);class Qr{static equals(e,t){const n=e=>{let t=0;for(const n in e)e.hasOwnProperty(n)&&t++;return t},r=(e,t)=>{if(typeof e!=typeof t)return!1;if("function"==typeof e)return e.toString()===t.toString();if(e instanceof Object&&t instanceof Object){if(n(e)!==n(t))return!1;let i=!0;for(const n in e)if(i=r(e[n],t[n]),!i)return!1;return!0}return e===t};return r(e,t)}static getPropDiff(e,t){return Object.keys(e).reduce((n,r)=>(Qr.equals(e[r],t[r])||n.push(r),n),[])}static getTruthyProps(e){return Object.keys(e).filter(t=>!!e[t])}static toOrderedString(e){return JSON.stringify(Object.keys(e).sort().reduce((t,n)=>(t[n]=e[n],t),{}))}static withDeeplyOrderedKeys(e){return Object.keys(e).sort().reduce((t,n)=>("object"!=typeof e[n]||Array.isArray(e[n])?t[n]=e[n]:t[n]=Qr.withDeeplyOrderedKeys(e[n]),t),{})}}var Zr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ei{constructor(e,t,n,r){this.courseService=e,this.sdkConfig=t,this.dbService=n,this.networkQueue=r,this.capturedAssessmentEvents={}}handle(e){return this.capturedAssessmentEvents=e,Object(c.from)(this.syncCapturedAssessmentEvents().then(()=>{this.capturedAssessmentEvents={}}).then(()=>this.syncPersistedAssessmentEvents()).catch(e=>{Object.keys(this.capturedAssessmentEvents).forEach(e=>{const t=JSON.parse(e);this.capturedAssessmentEvents[e].forEach(e=>{2!==t.batchStatus&&this.persistAssessEvent(e,t).toPromise()})})})).pipe(Object(D.mapTo)(void 0))}invokeSyncApi(e){return console.log("COURSE_ASSESSMENT_INVOKED_SYNC----------------------------------------------",e.assessments.map(e=>({assessmentTs:e.assessmentTs,userId:e.userId,contentId:e.contentId,courseId:e.courseId,batchId:e.batchId,attemptId:e.attemptId,events:e.events.length}))),this.networkQueue.enqueue(new En(this.sdkConfig).generateNetworkQueueRequest(Ft.COURSE_ASSESMENT,{request:e},en.generateUniqueId(),0,!0),!0).pipe(Object(D.mergeMap)(()=>new c.Observable(e=>{sbsync.onSyncSucces(t=>Zr(this,void 0,void 0,(function*(){const n=t.courseAssesmentResponse,r=t.course_assesment_error;n?e.next(n):r&&e.error(r),e.complete()})),t=>Zr(this,void 0,void 0,(function*(){e.error(t)})))}))).toPromise()}persistAssessEvent(e,t){return this.dbService.insert({table:wt.TABLE_NAME,modelJson:{[wt.COLUMN_NAME_ASSESSMENT_EVENT]:JSON.stringify(e),[wt.COLUMN_NAME_CONTENT_ID]:e.object.id,[wt.COLUMN_NAME_CREATED_AT]:e.ets,[wt.COLUMN_NAME_USER_ID]:t.userId,[wt.COLUMN_NAME_COURSE_ID]:t.courseId,[wt.COLUMN_NAME_BATCH_ID]:t.batchId}}).pipe(Object(D.mapTo)(void 0))}syncCapturedAssessmentEvents(){return Zr(this,void 0,void 0,(function*(){const e=Object.keys(this.capturedAssessmentEvents).reduce((e,t)=>{const n=JSON.parse(t),r=this.capturedAssessmentEvents[t];e.userId||(e.userId=n.userId);const i={contentId:r[0].object.id,courseId:n.courseId,batchId:n.batchId,status:2};e.contents.find(e=>Qr.equals(e,i))||e.contents.push(i);const o=r.reduce((e,t)=>t.ets<e?t.ets:e,r[0].ets);return e.assessments.push({assessmentTs:o,userId:n.userId,contentId:r[0].object.id,courseId:n.courseId,batchId:n.batchId,attemptId:this.courseService.generateAssessmentAttemptId({courseId:n.courseId,batchId:n.batchId,contentId:r[0].object.id,userId:n.userId,date:o}),events:r}),e},{userId:"",contents:[],assessments:[]});if(e.userId&&e.contents.length&&e.assessments.length)return this.invokeSyncApi(e)}))}syncPersistedAssessmentEvents(){return Zr(this,void 0,void 0,(function*(){this.dbService.execute(`\n SELECT\n ${wt.COLUMN_NAME_USER_ID},\n ${wt.COLUMN_NAME_CONTENT_ID},\n ${wt.COLUMN_NAME_COURSE_ID},\n ${wt.COLUMN_NAME_BATCH_ID},\n MIN(${wt.COLUMN_NAME_CREATED_AT}) as first_ts,\n GROUP_CONCAT(${wt.COLUMN_NAME_ASSESSMENT_EVENT},',') as events\n FROM ${wt.TABLE_NAME}\n GROUP BY\n ${wt.COLUMN_NAME_USER_ID},\n ${wt.COLUMN_NAME_CONTENT_ID},\n ${wt.COLUMN_NAME_COURSE_ID},\n ${wt.COLUMN_NAME_BATCH_ID}\n ORDER BY ${wt.COLUMN_NAME_CREATED_AT}\n `).pipe(Object(D.map)(e=>e.map(e=>({userId:e[wt.COLUMN_NAME_USER_ID],contentId:e[wt.COLUMN_NAME_CONTENT_ID],courseId:e[wt.COLUMN_NAME_COURSE_ID],batchId:e[wt.COLUMN_NAME_BATCH_ID],firstTs:e.first_ts,events:JSON.parse("["+e.events+"]")}))),Object(D.mergeMap)(e=>{if(!e.length)return Object(c.of)(void 0);const t=e.reduce((e,{firstTs:t,userId:n,contentId:r,courseId:i,batchId:o,events:s})=>{e.userId||(e.userId=n);const a={contentId:r,courseId:i,batchId:o,status:2};return e.contents.find(e=>Qr.equals(e,a))||e.contents.push(a),e.assessments.push({assessmentTs:t,userId:n,contentId:r,courseId:i,batchId:o,attemptId:this.courseService.generateAssessmentAttemptId({courseId:i,batchId:o,contentId:r,userId:n}),events:s}),e},{userId:"",contents:[],assessments:[]});return this.invokeSyncApi(t)}),Object(D.tap)(()=>Zr(this,void 0,void 0,(function*(){return yield this.dbService.execute("DELETE FROM "+wt.TABLE_NAME).toPromise()}))),Object(D.mapTo)(void 0)).toPromise()}))}}ei.UPDATE_CONTENT_STATE_ENDPOINT="/content/state/update";class ti{constructor(e,t){this.apiService=e,this.cachedItemStore=t}handle(e){return this.cachedItemStore.get(e.userId,ti.GET_LEARNER_CERTIFICATE_LOCAL_KEY,"ttl_"+ti.GET_LEARNER_CERTIFICATE_LOCAL_KEY,()=>this.fetchFromServer(e))}fetchFromServer(e){let t=Object.assign(Object.assign({},e.size?{size:e.size}:null),{_source:["data.badge.issuer.name","pdfUrl","data.issuedOn","data.badge.name","related.courseId","related.Id"],query:{bool:{must:[{match_phrase:{"recipient.id":e.userId}}]}}});const n=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(ti.CERTIFICATE_SEARCH_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:t}).build();return this.apiService.fetch(n).pipe(Object(D.map)(e=>e.body.result.response))}}ti.CERTIFICATE_SEARCH_ENDPOINT="/api/certreg/v1/certs/search",ti.GET_LEARNER_CERTIFICATE_LOCAL_KEY="learner-certificate";var ni=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ri{constructor(e,t){this.keyValueStore=e,this.sharedPreference=t}process(e){return ni(this,void 0,void 0,(function*(){if(1===(yield this.getCourseContext().toPromise()).batchStatus)for(const t of Object.keys(e)){const n=JSON.parse(t),r=e[t];if(!r)continue;const i=hi.GET_CONTENT_STATE_KEY_PREFIX.concat(n.userId,n.courseId),o=yield this.keyValueStore.getValue(i).toPromise(),s=o?JSON.parse(o):{contentList:[]},a=r.reduce((e,t)=>{try{const r=t.context.cdata.find(e=>"AttemptId"===e.type).id,i=t.object.id,o=t.edata.item.maxscore,a=t.edata.score;if(e[i]){const t=e[i];t.attemptId=r,t.lastAttemptedOn=Date.now()+"",t.totalMaxScore+=o,t.totalScore+=a}else e[i]={attemptId:r,lastAttemptedOn:Date.now()+"",totalMaxScore:o,totalScore:a};s.contentList.find(e=>e.contentId===i)||s.contentList.push({lastAccessTime:"2021-01-14 07:09:32:602+0000",contentId:i,progress:100,batchId:n.batchId,courseId:n.courseId,collectionId:n.courseId,lastCompletedTime:"2021-01-14 07:09:32:810+0000",status:2})}catch(e){console.error(e)}return e},{});s.contentList=s.contentList.map(e=>e.score&&e.score.length?a[e.contentId]?(e.score.push(a[e.contentId]),e.bestScore&&e.bestScore.totalScore<a[e.contentId].totalScore&&(e.bestScore=a[e.contentId]),e):e:(e.score=a[e.contentId]?[a[e.contentId]]:[],e.bestScore=e.score.reduce((e,t)=>e?e.totalScore<t.totalScore?t:e:t,void 0),e)),console.log(s),yield this.keyValueStore.setValue(i,JSON.stringify(s)).toPromise()}}))}getCourseContext(){return this.sharedPreference.getString(S.COURSE_CONTEXT).pipe(Object(D.map)(e=>e?JSON.parse(e):{}))}}var ii=n(21),oi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class si{constructor(e,t,n,r){this.profileService=e,this.fileService=t,this.keyValueStore=n,this.csCourseService=r}isCertificateCached(e){return Object(c.defer)(()=>oi(this,void 0,void 0,(function*(){try{return!!(yield this.getCertificateFromCache(e))}catch(e){return console.error(e),!1}})))}getCertificate(e){return this.csCourseService.getSignedCourseCertificate(e.certificate.identifier).pipe(Object(D.tap)(t=>oi(this,void 0,void 0,(function*(){yield this.keyValueStore.setValue(yield this.buildCertificatePersistenceId(e),Object(an.gzip)(t.printUri,{to:"string"})).toPromise()}))),Object(D.map)(e=>e.printUri),Object(D.catchError)(t=>Object(c.defer)(()=>oi(this,void 0,void 0,(function*(){const n=yield this.getCertificateFromCache(e);if(n)return n;throw t})))))}downloadCertificate({fileName:e,blob:t}){return Object(c.defer)(()=>oi(this,void 0,void 0,(function*(){return this.fileService.writeFile(cordova.file.externalDataDirectory,e,t,{replace:!0}).then(()=>({path:`${cordova.file.externalDataDirectory}${e}`}))})))}buildCertificatePersistenceId(e){return oi(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n=t.managedSession?t.managedSession.uid:t.uid;return`certificate_${e.certificate.identifier}_${e.courseId}_${n}`}))}getCertificateFromCache(e){return oi(this,void 0,void 0,(function*(){const t=yield this.keyValueStore.getValue(yield this.buildCertificatePersistenceId(e)).toPromise();return t?Object(ii.ungzip)(t,{to:"string"}):void 0}))}}var ai,ci=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},ui=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},li=function(e,t){return function(n,r){t(n,r,e)}},di=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let hi=ai=class{constructor(e,t,n,r,i,o,s,a,c,u,l,d,h){this.sdkConfig=e,this.apiService=t,this.profileService=n,this.keyValueStore=r,this.dbService=i,this.sharedPreferences=o,this.appInfo=s,this.fileService=a,this.cachedItemStore=c,this.csCourseService=u,this.networkQueue=l,this.container=d,this.authService=h,this.capturedAssessmentEvents={},this.courseServiceConfig=this.sdkConfig.courseServiceConfig,this.profileServiceConfig=this.sdkConfig.profileServiceConfig,this.syncAssessmentEventsHandler=new ei(this,this.sdkConfig,this.dbService,this.networkQueue),this.offlineAssessmentScoreProcessor=new ri(this.keyValueStore,this.sharedPreferences)}get certificateManager(){return this._certificateManager||(this._certificateManager=new si(this.profileService,this.fileService,this.keyValueStore,this.csCourseService)),this._certificateManager}static buildUrl(e,t,n){return`${e}${t}?${Be.stringify(n)}`}getBatchDetails(e){return new xr(this.apiService,this.courseServiceConfig).handle(e)}updateContentState(e){return e.target||(e.target=[Ei.LOCAL,Ei.SERVER]),Object(c.defer)(()=>di(this,void 0,void 0,(function*(){const t=new Xr(this.keyValueStore);if(e.target.indexOf(Ei.SERVER)>-1)try{yield new hn(this.networkQueue,this.sdkConfig).handle(class{static getUpdateContentStateRequest(e){const t=[];return t.push(this.getRequestMap(e)),{userId:e.userId,contents:t}}static getUpdateContentStateListRequest(e,t){const n=[];return t.forEach(e=>{n.push(this.getRequestMap(e))}),{userId:e,contents:n}}static getRequestMap(e){const t={userId:e.userId,contentId:e.contentId,courseId:e.courseId,batchId:e.batchId,status:e.status,progress:e.progress};return e.result&&(t.result=e.result),e.grade&&(t.grade=e.grade),e.score&&(t.score=e.score),t}}.getUpdateContentStateRequest(e)).toPromise()}catch(e){}return e.target.indexOf(Ei.LOCAL)>-1&&(yield t.manipulateEnrolledCoursesResponseLocally(e).toPromise(),yield t.manipulateGetContentStateResponseLocally(e).toPromise()),!0})))}getCourseBatches(e){return new Br(this.apiService,this.courseServiceConfig).handle(e)}getEnrolledCourses(e,t){return new Yr(this.keyValueStore,this.apiService,this.courseServiceConfig,this.sharedPreferences,t).handle(e)}getUserEnrolledCourses({request:e,from:t}){return this.cachedItemStore[t===Jn.SERVER?"get":"getCached"](e.userId+(e.filters?"_"+JSON.stringify(e.filters):""),ai.USER_ENROLLMENT_LIST_KEY_PREFIX,"ttl_"+ai.USER_ENROLLMENT_LIST_KEY_PREFIX,()=>this.csCourseService.getUserEnrolledCourses(e,{},{apiPath:"/api/course/v2",certRegistrationApiPath:""}))}enrollCourse(e){return new Gr(this.apiService,this.courseServiceConfig).handle(e).pipe(Object(D.mergeMap)(t=>{if(t){const n={};return n.userId=e.userId,n.batchStatus=e.batchStatus,this.sharedPreferences.putString(S.COURSE_CONTEXT,JSON.stringify(n)).pipe(Object(D.delay)(2e3),Object(D.concatMap)(()=>this.getEnrolledCourses({userId:e.userId,returnFreshCourses:!0})),Object(D.mapTo)(t))}return Object(c.of)(t)}))}getContentState(e){const t=ai.GET_CONTENT_STATE_KEY_PREFIX.concat(e.userId,e.courseId),n=new Xr(this.keyValueStore),r=new Wr(this.keyValueStore,n);return this.keyValueStore.getValue(t).pipe(Object(D.mergeMap)(i=>!i||e.returnRefreshedContentStates?new zr(this.apiService,this.courseServiceConfig,this.container).handle(e).pipe(Object(D.mergeMap)(i=>i?this.keyValueStore.setValue(t,JSON.stringify(i)).pipe(Object(D.mergeMap)(()=>n.getLocalContentStateResponse(e)),Object(D.mergeMap)(()=>r.updateEnrollCourses(e))):Object(c.of)(void 0)),Object(D.catchError)(t=>n.getLocalContentStateResponse(e).pipe(Object(D.mergeMap)(()=>r.updateEnrollCourses(e))))):n.getLocalContentStateResponse(e)))}unenrollCourse(e){return new Hr(this.apiService,this.courseServiceConfig).handle(e).pipe(Object(D.delay)(2e3),Object(D.concatMap)(()=>this.getEnrolledCourses({userId:e.userId,returnFreshCourses:!0})),Object(D.mapTo)(!0))}downloadCurrentProfileCourseCertificate(e){return Object(c.defer)(()=>di(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n=t.managedSession?t.managedSession.uid:t.uid;"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalRootDirectory,e.certificate.name,e.courseId;return{userId:n}}))).pipe(Object(D.mergeMap)(({userId:t})=>{const n=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(ai.CERTIFICATE_SIGN_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:{pdfUrl:e.certificate.url}}).build();return this.apiService.fetch(n).pipe(Object(D.map)(e=>({signedPdfUrl:e.body.result.signedUrl,userId:t})))}),Object(D.mergeMap)(({signedPdfUrl:t,userId:n})=>{const r={uri:t,title:e.certificate.token,description:"",mimeType:"application/pdf",visibleInDownloadsUi:!0,notificationVisibility:1,destinationInExternalPublicDir:{dirType:"Download",subPath:`/${e.certificate.name}_${e.courseId}_${n}.pdf`},headers:[]};return new c.Observable(e=>{downloadManager.enqueue(r,(t,n)=>{if(t)return e.error(t);e.next(n),e.complete()})})}),Object(D.mergeMap)(e=>Object(c.interval)(1e3).pipe(Object(D.mergeMap)(()=>new c.Observable(t=>{downloadManager.query({ids:[e]},(e,n)=>e||n[0].status===qr.STATUS_FAILED?t.error(e||new Error("Unknown Error")):t.next(n[0]))})),Object(D.filter)(e=>e.status===qr.STATUS_SUCCESSFUL),Object(D.take)(1))),Object(D.map)(e=>({path:e.localUri})))}hasCapturedAssessmentEvent({courseContext:e}){const t=Qr.toOrderedString(e);return!!this.capturedAssessmentEvents[t]}captureAssessmentEvent({event:e,courseContext:t}){const n=Qr.toOrderedString(t);this.capturedAssessmentEvents[n]||(this.capturedAssessmentEvents[n]=[]),this.capturedAssessmentEvents[n].push(e)}syncAssessmentEvents(e={persistedOnly:!1}){let t={};return e.persistedOnly||(t=this.capturedAssessmentEvents,this.resetCapturedAssessmentEvents()),this.offlineAssessmentScoreProcessor.process(t),this.syncAssessmentEventsHandler.handle(t)}resetCapturedAssessmentEvents(){this.capturedAssessmentEvents={}}generateAssessmentAttemptId(e){return Jr([e.courseId,e.batchId,e.contentId,e.userId,e.date?e.date:Date.now()].join("-")).toString()}displayDiscussionForum(e){return Object(c.defer)(()=>di(this,void 0,void 0,(function*(){const t=yield this.authService.getSession().toPromise();if(!t)return!1;const n=t.managed_access_token||t.access_token;return cordova.InAppBrowser.open(ai.buildUrl(this.sdkConfig.apiConfig.host,ai.DISCUSSION_FORUM_ENDPOINT,{access_token:n,returnTo:"/category/"+e.forumId}),"_blank","zoom=no,clearcache=yes,clearsessioncache=yes,cleardata=yes,hideurlbar=yes,hidenavigationbuttons=true"),!0})))}getLearnerCertificates(e){return new ti(this.apiService,this.cachedItemStore).handle(e)}syncCourseProgress(e){return this.csCourseService.updateContentState(e,{apiPath:"/api/course/v1"})}clearAssessments(){return this.sharedPreferences.getString(S.COURSE_CONTEXT).pipe(Object(D.map)(e=>{const t=e?JSON.parse(e):{};if(t){const e=Qr.toOrderedString(t);this.capturedAssessmentEvents[e]&&(this.capturedAssessmentEvents[e]=[])}}))}};var Ei,fi,pi;hi.USER_ENROLLMENT_LIST_KEY_PREFIX="userEnrollmentList",hi.GET_CONTENT_STATE_KEY_PREFIX="getContentState",hi.GET_ENROLLED_COURSE_KEY_PREFIX="enrolledCourses",hi.UPDATE_CONTENT_STATE_KEY_PREFIX="updateContentState",hi.LAST_READ_CONTENTID_PREFIX="lastReadContentId",hi.CERTIFICATE_SIGN_ENDPOINT="/api/certreg/v1/certs/download",hi.DISCUSSION_FORUM_ENDPOINT="/discussions/auth/sunbird-oidc/callback",hi=ai=ci([Object(s.injectable)(),li(0,Object(s.inject)(l.SDK_CONFIG)),li(1,Object(s.inject)(l.API_SERVICE)),li(2,Object(s.inject)(l.PROFILE_SERVICE)),li(3,Object(s.inject)(l.KEY_VALUE_STORE)),li(4,Object(s.inject)(l.DB_SERVICE)),li(5,Object(s.inject)(l.SHARED_PREFERENCES)),li(6,Object(s.inject)(l.APP_INFO)),li(7,Object(s.inject)(l.FILE_SERVICE)),li(8,Object(s.inject)(l.CACHED_ITEM_STORE)),li(9,Object(s.inject)(u.COURSE_SERVICE)),li(10,Object(s.inject)(l.NETWORK_QUEUE)),li(11,Object(s.inject)(l.CONTAINER)),li(12,Object(s.inject)(l.AUTH_SERVICE)),ui("design:paramtypes",[Object,Object,Object,Object,o,Object,Object,Object,Object,Object,Object,s.Container,Object])],hi),function(e){e.LOCAL="LOCAL",e.SERVER="SERVER"}(Ei||(Ei={})),function(e){e.OPEN="open",e.INVITE_ONLY="invite-only"}(fi||(fi={})),function(e){e.NOT_STARTED="0",e.IN_PROGRESS="1",e.COMPLETED="2"}(pi||(pi={}));class _i extends ke{constructor(e,t){super(e,"CERTIFICATE_ALREADY_DOWNLOADED"),this.filePath=t,Object.setPrototypeOf(this,_i.prototype)}}var Oi=n(48),Si=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class gi{constructor(e){this.contentService=e}provide(e,t){return e.objectType=gi.getCategoryMapper(t),this.trackableSessionContentCache?Object(c.iif)(()=>!!this.trackableSessionContentCache[e.contentId],Object(c.defer)(()=>Object(c.of)(this.trackableSessionContentCache[e.contentId])),Object(c.defer)(()=>this.contentService.getContentDetails(e).pipe(Object(D.tap)(t=>this.trackableSessionContentCache[e.contentId]=t)))):this.contentService.getContentDetails(e)}cache(e){this.trackableSessionContentCache&&(this.trackableSessionContentCache[e.identifier]=e)}init(){this.trackableSessionContentCache={}}dispose(){this.trackableSessionContentCache=void 0}static getCategoryMapper(e){switch(e){case Fn.CsPrimaryCategory.PRACTICE_QUESTION_SET:return"QuestionSet";case"Multiple Choice Question":return"Question"}}}class Ai{constructor(e,t,n,r,i,o){this.courseService=e,this.sharedPreference=t,this.summarizerService=n,this.eventBusService=r,this.contentService=i,this.profileService=o,this.currentUID=void 0,this.currentContentID=void 0,this.courseContext={},this.trackableSessionProxyContentProvider=new gi(this.contentService)}static checkPData(e){return null!=e&&null!==e.pid&&-1!==e.pid.indexOf(Ai.CONTENT_PLAYER_PID)}static isContentTrackable(e){return!!e.contentData.trackable&&e.contentData.trackable.enabled===Dn.TrackingEnabled.YES}static isCourseAssessmentContent(e){return e.primaryCategory&&e.primaryCategory.toLowerCase()===Fn.CsPrimaryCategory.COURSE_ASSESSMENT.toLowerCase()}updateContentState(e){return this.getCourseContext().pipe(Object(D.mergeMap)(t=>{const n=t.userId,r=t.courseId,i=t.batchId;let o=0;t.hasOwnProperty("batchStatus")&&(o=t.batchStatus);if(1===o){const o=e.object.id;return this.checkStatusOfContent(n,r,i,o).pipe(Object(D.mergeMap)(s=>{if("START"===e.eid&&0===s){const e={userId:n,contentId:o,courseId:r,batchId:i,status:1,progress:5};return this.courseService.updateContentState(e).pipe(Object(D.mapTo)(void 0))}return"END"===e.eid&&0===s||"END"===e.eid&&1===s?this.trackableSessionProxyContentProvider.provide({contentId:e.object.id},e.object.type).pipe(Object(D.mergeMap)(o=>this.validEndEvent(e,o,t).pipe(Object(D.mergeMap)(t=>{if(t){const t=Oi.CsContentProgressCalculator.calculate(e.edata.summary,o.mimeType),s={userId:n,contentId:o.identifier,courseId:r,batchId:i,status:100===t?2:1,progress:t,target:Ai.isCourseAssessmentContent(o)?[Ei.LOCAL]:[Ei.LOCAL,Ei.SERVER]};return this.generateAuditTelemetry(n,r,i,o,e.object?e.object.rollup:{}),this.courseService.updateContentState(s).pipe(Object(D.tap)(()=>{this.eventBusService.emit({namespace:M.CONTENT,event:{type:Pn.COURSE_STATE_UPDATED,payload:{contentId:s.courseId}}})}),Object(D.mapTo)(void 0))}return Object(c.of)(void 0)})))):Object(c.of)(void 0)}),Object(D.tap)(()=>{this.updateLastReadContentId(n,r,i,o).toPromise()}))}return Object(c.of)(void 0)}))}handle(e){return Object(c.defer)(()=>Si(this,void 0,void 0,(function*(){if("START"===e.eid){if(Ai.checkPData(e.context.pdata))return this.courseService.resetCapturedAssessmentEvents(),this.processOEStart(e).pipe(Object(D.tap)(()=>Si(this,void 0,void 0,(function*(){yield this.summarizerService.saveLearnerAssessmentDetails(e).pipe(Object(D.mapTo)(void 0)).toPromise()}))),Object(D.tap)(()=>Si(this,void 0,void 0,(function*(){yield this.getCourseContext().pipe(Object(D.mergeMap)(()=>this.updateContentState(e))).toPromise()}))),Object(D.tap)(()=>Si(this,void 0,void 0,(function*(){yield this.markContentAsPlayed(e).toPromise()})))).toPromise();if(e.object&&e.object.id){const t=yield this.trackableSessionProxyContentProvider.provide({contentId:e.object.id},e.object.type).toPromise();if(Ai.isContentTrackable(t))return this.trackableSessionProxyContentProvider.init(),this.trackableSessionProxyContentProvider.cache(t),this.getCourseContext().pipe(Object(D.mapTo)(void 0)).toPromise()}}else{if("ASSESS"===e.eid&&Ai.checkPData(e.context.pdata))return this.processOEAssess(e).pipe(Object(D.tap)(()=>Si(this,void 0,void 0,(function*(){const t=yield this.getCourseContext().toPromise();e.context.cdata.find(e=>"AttemptId"===e.type)&&t.userId&&t.courseId&&t.batchId&&(yield this.courseService.captureAssessmentEvent({event:e,courseContext:t}))}))),Object(D.tap)(()=>Si(this,void 0,void 0,(function*(){yield this.summarizerService.saveLearnerAssessmentDetails(e).pipe(Object(D.mapTo)(void 0)).toPromise()})))).toPromise();if("END"===e.eid){if(Ai.checkPData(e.context.pdata))return this.processOEEnd(e).pipe(Object(D.tap)(()=>Si(this,void 0,void 0,(function*(){yield this.summarizerService.saveLearnerContentSummaryDetails(e).pipe(Object(D.mapTo)(void 0)).toPromise()}))),Object(D.tap)(()=>Si(this,void 0,void 0,(function*(){yield this.getCourseContext().pipe(Object(D.mergeMap)(()=>this.updateContentState(e))).toPromise()})))).toPromise();if(e.object&&e.object.id){const t=yield this.trackableSessionProxyContentProvider.provide({contentId:e.object.id},e.object.type).toPromise();if(Ai.isContentTrackable(t))return this.trackableSessionProxyContentProvider.dispose(),this.setCourseContextEmpty().toPromise()}}}})))}setCourseContextEmpty(){return this.courseContext={},this.sharedPreference.putString(S.COURSE_CONTEXT,"")}validEndEvent(e,t,n){const r=()=>n&&(Ai.isCourseAssessmentContent(t)||t.contentType&&"onboardingresource"===t.contentType.toLowerCase()||t.primaryCategory&&"onboardingresource"===t.primaryCategory.toLowerCase())&&this.courseService.hasCapturedAssessmentEvent({courseContext:n});return Object(c.defer)(()=>Object(c.of)(void 0)).pipe(Object(D.delay)(2e3),Object(D.map)(()=>!r()&&(e.edata.summary&&!!e.edata.summary.find(e=>e.progress))),Object(D.tap)(()=>this.courseService.resetCapturedAssessmentEvents()))}updateLastReadContentId(e,t,n,r){const i=hi.LAST_READ_CONTENTID_PREFIX.concat("_").concat(e).concat("_").concat(t).concat("_").concat(n);return this.sharedPreference.putString(i,r)}markContentAsPlayed(e){const t=e.actor.id,n=e.object.id,r={contentId:n};return this.trackableSessionProxyContentProvider.provide(r,e.object.type).pipe(Object(D.mergeMap)(e=>{const r={status:Xn.PLAYED,contentId:n,contentType:e.contentType||e.primaryCategory};return this.profileService.addContentAccess(r).pipe(Object(D.mergeMap)(()=>{const r={uid:t,contentId:n,data:JSON.stringify(e.contentData),marker:Sn.PREVIEWED,isMarked:!0,extraInfo:{}};return this.contentService.setContentMarker(r).pipe(Object(D.mapTo)(!0))}))}))}getCourseContext(){return this.sharedPreference.getString(S.COURSE_CONTEXT).pipe(Object(D.map)(e=>e?JSON.parse(e):{}))}checkStatusOfContent(e,t,n,r){const i={userId:e,batchId:n,contentIds:[r],courseId:t};return this.courseService.getContentState(i).pipe(Object(D.map)(e=>{const t=e&&e.contentList;return this.getStatus(t,r)}))}getStatus(e=[],t){const n=e.find(e=>e.contentId===t);return n&&n.status||0}processOEStart(e){return this.currentUID=e.actor.id,this.currentContentID=e.object.id,Object(c.of)(void 0)}processOEAssess(e){return this.currentUID&&this.currentContentID&&this.currentUID.toLocaleLowerCase()===e.actor.id.toLocaleLowerCase()&&this.currentContentID.toLocaleLowerCase()===e.object.id.toLocaleLowerCase()?this.summarizerService.deletePreviousAssessmentDetails(this.currentUID,this.currentContentID).pipe(Object(D.tap)(()=>{this.currentUID=void 0,this.currentContentID=void 0}),Object(D.mapTo)(void 0)):Object(c.of)(void 0)}processOEEnd(e){return Object(c.of)(void 0)}generateAuditTelemetry(e,t,n,r,i){const o=new pe;o.id=e,o.type=pe.TYPE_USER;const s=[{type:"CourseId",id:t||""},{type:"BatchId",id:n||""},{type:"UserId",id:e||""},{type:"ContentId",id:r.identifier||""}],a={env:"course",actor:o,currentState:ue.AUDIT_UPDATED,updatedProperties:["progress"],objId:r.identifier,objType:r.contentData.contentType||"",objVer:r.contentData.pkgVersion||"",rollUp:i||{},correlationData:s,type:"content-progress"};ln.log.audit(a).toPromise()}}Ai.CONTENT_PLAYER_PID="contentplayer";var Ni=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ti{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:et.TABLE_NAME,orderBy:et.COLUMN_NAME_HANDLE+" asc",useExternalDb:!0}).toPromise().then(e=>{const t=e.map(e=>e[et.COLUMN_NAME_UID]);return this.deleteUnwantedAssesments(t)}).then(()=>this.saveLearnerAssesmentDetails()).then(()=>this.saveLearnerSummary()).then(()=>(t.body=e,t))}deleteUnwantedAssesments(e){return Ni(this,void 0,void 0,(function*(){const t=wn.joinPreservingQuotes(e),n=`DELETE FROM ${lt.TABLE_NAME}\n WHERE ${lt.COLUMN_NAME_UID} NOT IN(${t})`,r=`DELETE FROM ${ht.TABLE_NAME}\n WHERE ${ht.COLUMN_NAME_UID} NOT IN(${t})`;yield this.dbService.execute(n,!0).toPromise(),yield this.dbService.execute(r,!0).toPromise()}))}saveLearnerAssesmentDetails(){return Ni(this,void 0,void 0,(function*(){const e=yield this.dbService.read({table:lt.TABLE_NAME,orderBy:""+lt.COLUMN_NAME_Q_INDEX,useExternalDb:!0}).toPromise();for(const t of e){const e=t,n=kr.getFilterForLearnerAssessmentDetails(e[lt.COLUMN_NAME_QID],e[lt.COLUMN_NAME_UID],e[lt.COLUMN_NAME_CONTENT_ID],e[lt.COLUMN_NAME_HIERARCHY_DATA]),r=kr.getLearnerAssessmentsQuery(n),i=yield this.dbService.execute(r).toPromise();i&&i.length?yield this.dbService.update({table:lt.TABLE_NAME,selection:`${lt.COLUMN_NAME_CONTENT_ID} = ?\n AND ${lt.COLUMN_NAME_UID} = ?\n AND ${lt.COLUMN_NAME_QID} = ?`,selectionArgs:[e[lt.COLUMN_NAME_CONTENT_ID],e[lt.COLUMN_NAME_UID],e[lt.COLUMN_NAME_QID]],modelJson:e}).toPromise():yield this.dbService.insert({table:lt.TABLE_NAME,modelJson:e}).toPromise()}}))}saveLearnerSummary(){return Ni(this,void 0,void 0,(function*(){const e=yield this.dbService.read({table:ht.TABLE_NAME,useExternalDb:!0}).toPromise();for(const t of e){const e=t,n=yield this.dbService.read({table:ht.TABLE_NAME,selection:`${ht.COLUMN_NAME_CONTENT_ID} = ? AND ${ht.COLUMN_NAME_UID} = ?`,selectionArgs:[e[lt.COLUMN_NAME_CONTENT_ID],e[lt.COLUMN_NAME_UID]]}).toPromise();n&&n.length?yield this.dbService.update({table:ht.TABLE_NAME,selection:`${ht.COLUMN_NAME_CONTENT_ID} = ? AND ${ht.COLUMN_NAME_UID} = ?`,selectionArgs:[e[lt.COLUMN_NAME_CONTENT_ID],e[lt.COLUMN_NAME_UID]],modelJson:e}).toPromise():yield this.dbService.insert({table:ht.TABLE_NAME,modelJson:e}).toPromise()}e.forEach(e=>Ni(this,void 0,void 0,(function*(){const t=kr.getFilterForLearnerAssessmentDetails(e[lt.COLUMN_NAME_QID],e[lt.COLUMN_NAME_UID],e[lt.COLUMN_NAME_CONTENT_ID],e[lt.COLUMN_NAME_HIERARCHY_DATA]),n=kr.getLearnerAssessmentsQuery(t),r=yield this.dbService.execute(n).toPromise();r&&r.length?yield this.dbService.update({table:ht.TABLE_NAME,modelJson:r[0]}).toPromise():yield this.dbService.insert({table:ht.TABLE_NAME,modelJson:r[0]}).toPromise()})))}))}}class Ci{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse,n=e.metadata.export_id,r=e.metadata.did,i={imported_id:n,device_id:r,count:e.metadata.profiles_count};return this.dbService.read({table:ct.TABLE_NAME,selection:`${ct.COLUMN_NAME_IMPORTED_ID} =? AND ${ct.COLUMN_NAME_DEVICE_ID} = ?`,selectionArgs:[n,r],limit:"1"}).toPromise().then(e=>e&&e.length?this.dbService.update({table:ct.TABLE_NAME,modelJson:i,selection:`${ct.COLUMN_NAME_IMPORTED_ID} =? AND ${ct.COLUMN_NAME_DEVICE_ID} =?`,selectionArgs:[n,r]}).toPromise():this.dbService.insert({table:ct.TABLE_NAME,modelJson:i}).toPromise()).then(()=>(t.body=e,t))}}var vi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class yi{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:et.TABLE_NAME,orderBy:et.COLUMN_NAME_HANDLE+" asc",useExternalDb:!0}).toPromise().then(t=>this.saveProfilesToDb(e,t)).then(()=>(t.body=e,t))}saveProfilesToDb(e,t){return vi(this,void 0,void 0,(function*(){let n=0,r=0;for(const i of t){const t=yield this.dbService.read({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[i[et.COLUMN_NAME_UID]],limit:"1"}).toPromise();t&&t.length?(r++,e.failed=r):(i[et.COLUMN_NAME_CREATED_AT]||(i[et.COLUMN_NAME_CREATED_AT]=(new Date).getTime()),delete i[et._ID],yield this.dbService.insert({table:et.TABLE_NAME,modelJson:i}).toPromise(),n++,e.imported=n)}e.failed=r,e.imported=n}))}}class mi{constructor(e,t){this.sdkConfig=e,this.apiService=t,this.profileServiceConfig=this.sdkConfig.profileServiceConfig,this.apiConfig=this.sdkConfig.apiConfig}handle(e){return this.fetchFromServer(e)}fetchFromServer(e){console.log("Request",e);const t=(new a.CsRequest.Builder).withHost(this.apiConfig.host).withType(a.CsHttpRequestType.POST).withPath(this.profileServiceConfig.profileApiPath_V5+mi.USER_MIGRATE).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>(console.log("sucees",e),e.body)))}}mi.USER_MIGRATE="/migrate";var bi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ii{constructor(e,t,n,r,i,o,s,a){this.profileService=e,this.authService=t,this.profileServiceConfig=n,this.apiService=r,this.cachedItemStore=i,this.dbService=o,this.frameworkService=s,this.sharedPreferences=a,this.managedProfileAdded$=new c.Subject}addManagedProfile(e){return Object(c.defer)(()=>bi(this,void 0,void 0,(function*(){if(!(yield this.isLoggedInUser()))throw new ki("No active LoggedIn Session found");const{uid:t}=yield this.createManagedProfile(e);return setTimeout(()=>{this.managedProfileAdded$.next(!0)},1e3),{uid:t}})))}getManagedServerProfiles(e){return this.managedProfileAdded$.pipe(Object(D.startWith)(!1),Object(D.mergeMap)(t=>Object(c.defer)(()=>bi(this,void 0,void 0,(function*(){if(!(yield this.isLoggedInUser()))throw new ki("No active LoggedIn Session found");e.from!==Jn.SERVER&&(e.from=t?Jn.SERVER:Jn.CACHE);const n=yield this.profileService.getActiveSessionProfile({requiredFields:[]}).toPromise(),r=n.serverProfile&&n.serverProfile.managedBy?n.serverProfile.managedBy:n.uid,i=()=>Object(c.defer)(()=>bi(this,void 0,void 0,(function*(){const t=n.serverProfile&&!n.serverProfile.managedBy?n.serverProfile:yield this.profileService.getServerProfilesDetails({userId:n.serverProfile.managedBy,requiredFields:e.requiredFields}).toPromise(),i=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(`${this.profileServiceConfig.profileApiPath}/managed/${r}`).withParameters({withTokens:"true",sortBy:"createdDate",order:"desc"}).withBearerToken(!0).withUserToken(!0).build();return yield this.apiService.fetch(i).toPromise().then(e=>[t,...e.body.result.response.content.sort((e,t)=>new Date(t.createdDate).getTime()-new Date(e.createdDate).getTime())])}))).pipe(Object(D.tap)(e=>bi(this,void 0,void 0,(function*(){const t=yield this.dbService.execute(`\n SELECT * from ${et.TABLE_NAME}\n WHERE ${et.COLUMN_NAME_UID}\n IN (${wn.joinPreservingQuotes(e.map(e=>e.id))})\n `).toPromise().then(e=>e.map(e=>ir.mapProfileDBEntryToProfile(e))),n=e.filter(e=>!t.find(t=>t.uid===e.id));for(const e of n)this.persistManagedProfile(e)}))));return this.cachedItemStore[e.from===Jn.SERVER?"get":"getCached"](r,Ii.MANGED_SERVER_PROFILES_LOCAL_KEY,"ttl_"+Ii.MANGED_SERVER_PROFILES_LOCAL_KEY,()=>i()).toPromise()})))))}switchSessionToManagedProfile({uid:e}){return Object(c.defer)(()=>bi(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n=Object.assign({},t);yield ln.log.end({type:"session",env:"sdk",mode:"switch-user",duration:Math.floor((Date.now()-(n.managedSession||n).createdTime)/1e3),correlationData:[{type:"InitiatorId",id:n.managedSession?n.managedSession.uid:n.uid},{type:"ManagedUserId",id:e}]}).toPromise();const r=yield(()=>bi(this,void 0,void 0,(function*(){return this.dbService.read({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}).toPromise().then(e=>e&&e[0]&&ir.mapProfileDBEntryToProfile(e[0]))})))();if(!r)throw new xi("No Profile found with uid="+e);if(r.source!==Wn.SERVER)throw new xi("No Server Profile found with uid="+e);if(t.uid===e){t.managedSession=void 0;const e=yield this.authService.getSession().toPromise();e.managed_access_token=void 0,yield this.authService.setSession(new class{provide(){return bi(this,void 0,void 0,(function*(){return e}))}}).toPromise()}else{t.managedSession=new Zn(e);const n=(yield this.getManagedServerProfiles({from:Jn.CACHE,requiredFields:[]}).pipe(Object(D.take)(1)).toPromise()).find(t=>t.id===e),r=yield this.authService.getSession().toPromise();r.managed_access_token=n.managedToken,yield this.authService.setSession(new class{provide(){return bi(this,void 0,void 0,(function*(){return r}))}}).toPromise()}yield this.sharedPreferences.putString(p.KEY_USER_SESSION,JSON.stringify(t)).toPromise(),ln.log.start({type:"session",env:"sdk",mode:"switch-user",correlationData:[{type:"InitiatorId",id:n.managedSession?n.managedSession.uid:n.uid},{type:"ManagedUserId",id:t.managedSession?t.managedSession.uid:t.uid}]}).toPromise()}))).pipe(Object(D.mergeMap)(()=>this.authService.getSession().pipe(Object(D.mergeMap)(t=>this.authService.setSession(new class{provide(){return bi(this,void 0,void 0,(function*(){return Object.assign(Object.assign({},t),{userToken:e})}))}})))),Object(D.mergeMap)(()=>bi(this,void 0,void 0,(function*(){const t=yield this.profileService.getServerProfilesDetails({userId:e,requiredFields:[]}).toPromise(),n=t.rootOrg?t.rootOrg.hashTagId:t.rootOrgId;return this.frameworkService.setActiveChannelId(n).toPromise()}))),Object(D.mapTo)(void 0))}persistManagedProfile(e){return bi(this,void 0,void 0,(function*(){e.userId=e.id,e.rootOrg={hashTagId:e.rootOrgId},this.profileService.createProfile({uid:e.id,profileType:zn.STUDENT,source:Wn.SERVER,handle:e.firstName,board:e.framework&&e.framework.board||[],medium:e.framework&&e.framework.medium||[],grade:e.framework&&e.framework.gradeLevel||[],gradeValue:e.framework&&e.framework.gradeValue||"",subject:e.framework&&e.framework.subject||[],serverProfile:e},Wn.SERVER).toPromise(),this.cachedItemStore.getCached(e.id,Ii.USER_PROFILE_DETAILS_KEY_PREFIX,Ii.USER_PROFILE_DETAILS_KEY_PREFIX,()=>Object(c.of)(e)).toPromise()}))}createManagedProfile(e){return bi(this,void 0,void 0,(function*(){if((yield this.profileService.getActiveSessionProfile({requiredFields:[]}).toPromise()).source!==Wn.SERVER)throw new ki("No active session available");const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.profileServiceConfig.profileApiPath_V2+"/managed/create").withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return yield this.apiService.fetch(t).toPromise().then(e=>({uid:e.body.result.userId}))}))}isLoggedInUser(){return bi(this,void 0,void 0,(function*(){return!!(yield this.authService.getSession().toPromise())}))}}Ii.MANGED_SERVER_PROFILES_LOCAL_KEY="managed_server_profiles-",Ii.USER_PROFILE_DETAILS_KEY_PREFIX="userProfileDetails";var Mi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ri{constructor(e){this.dbService=e}delete(e){return Object(c.defer)(()=>Object(c.of)(this.dbService.beginTransaction())).pipe(Object(D.mergeMap)(()=>Object(c.zip)(this.dbService.delete({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:vt.TABLE_NAME,selection:vt.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:At.TABLE_NAME,selection:At.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:lt.TABLE_NAME,selection:lt.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:ht.TABLE_NAME,selection:ht.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:Tt.TABLE_NAME,selection:Tt.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:Pt.TABLE_NAME,selection:Pt.COLUMN_NAME_USER_ID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:it.TABLE_NAME,selection:it.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:nt.TABLE_NAME,selection:nt.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:kt.TABLE_NAME,selection:kt.COLUMN_NAME_USER_ID+" = ?",selectionArgs:[e]}),this.dbService.execute(`DELETE FROM ${It.TABLE_NAME} \n WHERE ${It.COLUMN_NAME_KEY} \n LIKE '%%${e}%%'`)).pipe(Object(D.mapTo)(!0))),Object(D.tap)(()=>Mi(this,void 0,void 0,(function*(){yield this.dbService.execute(`SELECT * FROM ${It.TABLE_NAME} \n WHERE ${It.COLUMN_NAME_KEY} \n LIKE '%%userProfileDetails%%'`).pipe(Object(D.map)(t=>t.filter(t=>JSON.parse(t.value).managedBy===e).map(e=>JSON.parse(e.value).userId)),Object(D.mergeMap)(e=>{const t=this.dbService.execute(`DELETE FROM ${It.TABLE_NAME} \n WHERE ${this.generateLikeQuery(e,It.COLUMN_NAME_KEY)}`);return e.length?t.pipe(Object(D.mapTo)(e)):Object(c.of)(!0).pipe(Object(D.mapTo)(e))}),Object(D.mergeMap)(e=>{const t=this.dbService.execute(`DELETE FROM ${et.TABLE_NAME} \n WHERE ${this.generateLikeQuery(e,et.COLUMN_NAME_UID)}`);return e.length?t.pipe(Object(D.mapTo)(!0)):Object(c.of)(!0).pipe(Object(D.mapTo)(!0))})).toPromise()}))),Object(D.tap)(()=>{this.dbService.endTransaction(!0)}),Object(D.catchError)(e=>(console.error(e),this.dbService.endTransaction(!1),Object(c.of)(!1))))}generateLikeQuery(e,t){let n="";const r=t+" LIKE ";for(let t=0;t<e.length;t++)n=t<e.length-1?n.concat(r,`'%%~${e[t].toLowerCase().trim()}~%%' OR `):n.concat(r,`'%%~${e[t].toLowerCase().trim()}~%%' `);return`(${n})`}}class Li{constructor(e,t){this.apiService=e,this.profileServiceConfig=t,this.DELETE_ENDPOINT="/delete"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.profileServiceConfig.profileApiPath+this.DELETE_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>"SUCCESS"===e.body.result.response))}}var Pi,Di=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},wi=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ui=function(e,t){return function(n,r){t(n,r,e)}},ji=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let Fi=Pi=class{constructor(e,t,n,r,i,o,s,a,c,u,l,d){this.container=e,this.sdkConfig=t,this.dbService=n,this.apiService=r,this.cachedItemStore=i,this.keyValueStore=o,this.sharedPreferences=s,this.frameworkService=a,this.fileService=c,this.deviceInfo=u,this.authService=l,this.userService=d,this.apiConfig=this.sdkConfig.apiConfig,this.profileServiceConfig=this.sdkConfig.profileServiceConfig,this.managedProfileManager=new Ii(this,this.authService,this.sdkConfig.profileServiceConfig,this.apiService,this.cachedItemStore,this.dbService,this.frameworkService,this.sharedPreferences)}get telemetryService(){return this.container.get(l.TELEMETRY_SERVICE)}preInit(){return this.sharedPreferences.getString(Pi.KEY_USER_SESSION).pipe(Object(D.map)(e=>e&&JSON.parse(e)),Object(D.mergeMap)(e=>{if(!e){const e={uid:"",handle:"",profileType:zn.TEACHER,source:Wn.LOCAL};return this.createProfile(e).pipe(Object(D.mergeMap)(e=>this.setActiveSessionForProfile(e.uid)),Object(D.mapTo)(void 0))}return e.managedSession?this.managedProfileManager.switchSessionToManagedProfile({uid:e.managedSession.uid}):this.setActiveSessionForProfile(e.uid).pipe(Object(D.mapTo)(void 0))}))}checkServerProfileExists(e){return this.userService.checkUserExists(e.matching,e.captchaResponseToken?{token:e.captchaResponseToken,app:"1"}:void 0)}createProfile(e,t=Wn.LOCAL){switch(t){case Wn.LOCAL:if(e.source!==Wn.LOCAL)throw new sr("Invalid value supplied for field 'source': "+e.source);if(e.serverProfile)throw new sr("Invalid value supplied for field 'serverProfile': "+e.serverProfile);e.uid=en.generateUniqueId();break;case Wn.SERVER:if(e.source!==Wn.SERVER)throw new sr("Invalid value supplied for field 'source': "+e.source);if(!e.serverProfile)throw new sr("Invalid value supplied for field 'serverProfile': "+e.serverProfile);if(!e.uid)throw new sr("Invalid value supplied for field 'uid': "+e.uid)}return e.createdAt=Date.now(),this.dbService.insert({table:et.TABLE_NAME,modelJson:ir.mapProfileToProfileDBEntry(e)}).pipe(Object(D.tap)(()=>ji(this,void 0,void 0,(function*(){yield this.getActiveProfileSession().pipe(Object(D.map)(e=>e.uid),Object(D.catchError)(t=>t instanceof ki?Object(c.of)(e.uid):Object(c.throwError)(t)),Object(D.mergeMap)(t=>{const n=new pe;n.id=t,n.type=pe.TYPE_SYSTEM;const r={env:"sdk",actor:n,currentState:ue.AUDIT_CREATED,updatedProperties:Qr.getTruthyProps(e),objId:e.uid,objType:Q.USER,correlationData:[{id:e.profileType,type:"UserRole"}]};return this.telemetryService.audit(r)})).toPromise()}))),Object(D.mergeMap)(()=>Object(c.of)(e)))}deleteProfile(e){return this.dbService.read({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}).pipe(Object(D.map)(t=>{if(!t||!t[0])throw new xi("No Profile found with ID "+e);return ir.mapProfileDBEntryToProfile(t[0])}),Object(D.tap)(t=>ji(this,void 0,void 0,(function*(){return yield this.getActiveProfileSession().pipe(Object(D.mergeMap)(n=>{const r=new pe;r.id=n.uid,r.type=pe.TYPE_SYSTEM;const i={env:"sdk",actor:r,currentState:ue.AUDIT_DELETED,objId:e,objType:Q.USER,correlationData:[{id:t.profileType,type:"UserRole"}]};return this.telemetryService.audit(i)})).toPromise()}))),Object(D.mergeMap)(()=>this.dbService.delete({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[e]})))}updateProfile(e){return this.dbService.read({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[e.uid]}).pipe(Object(D.map)(t=>{if(!t||!t[0])throw new xi("No Profile found with ID "+e.uid);return ir.mapProfileDBEntryToProfile(t[0])}),Object(D.tap)(t=>ji(this,void 0,void 0,(function*(){yield this.getActiveProfileSession().pipe(Object(D.mergeMap)(n=>{const r=new pe;r.id=n.uid,r.type=pe.TYPE_SYSTEM;const i={env:"sdk",actor:r,currentState:ue.AUDIT_UPDATED,updatedProperties:Qr.getPropDiff(e,t),objId:e.uid,objType:Q.USER,correlationData:[{id:e.profileType,type:"UserRole"}]};return this.telemetryService.audit(i)})).toPromise()}))),Object(D.mergeMap)(()=>{const t=ir.mapProfileToProfileDBEntry(e);return delete t[et.COLUMN_NAME_CREATED_AT],this.dbService.update({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[e.uid],modelJson:t}).pipe(Object(D.mergeMap)(()=>Object(c.of)(e)))}))}updateServerProfile(e){return this.userService.updateProfile(e,{apiPath:"/api/user/v3"})}getTenantInfo(e){return new tr(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}getAllProfiles(e){return e?e.groupId?e.groupId&&(e.local||e.server)?this.dbService.execute(`\n SELECT * FROM ${et.TABLE_NAME} LEFT JOIN ${it.TABLE_NAME}\n ON ${et.TABLE_NAME}.${et.COLUMN_NAME_UID} =\n ${it.TABLE_NAME}.${it.COLUMN_NAME_UID}\n WHERE ${it.COLUMN_NAME_GID} = "${e.groupId}" AND\n ${et.COLUMN_NAME_SOURCE} = "${e.local?Wn.LOCAL:Wn.SERVER}"\n `).pipe(Object(D.map)(e=>this.mapDbProfileEntriesToProfiles(e))):this.dbService.execute(`\n SELECT * FROM ${et.TABLE_NAME}\n LEFT JOIN ${it.TABLE_NAME} ON\n ${et.TABLE_NAME}.${et.COLUMN_NAME_UID} =\n ${it.TABLE_NAME}.${it.COLUMN_NAME_UID}\n WHERE ${it.TABLE_NAME}.${it.COLUMN_NAME_GID} = "${e.groupId}"\n `).pipe(Object(D.map)(e=>this.mapDbProfileEntriesToProfiles(e))):this.dbService.read({table:et.TABLE_NAME,selection:et.COLUMN_NAME_SOURCE+" = ?",selectionArgs:[e.local?Wn.LOCAL:Wn.SERVER],columns:[]}).pipe(Object(D.map)(e=>this.mapDbProfileEntriesToProfiles(e))):this.dbService.read({table:et.TABLE_NAME,columns:[]}).pipe(Object(D.map)(e=>this.mapDbProfileEntriesToProfiles(e)))}getServerProfilesDetails(e){return new rr(this.cachedItemStore,this.keyValueStore,this.container,this.profileServiceConfig).handle(e)}getActiveSessionProfile({requiredFields:e}){return this.getActiveProfileSession().pipe(Object(D.mergeMap)(t=>this.dbService.read({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[t.managedSession?t.managedSession.uid:t.uid]}).pipe(Object(D.map)(e=>{const n=e&&e[0];if(!n)throw new xi("No profile found for profileSession with uid "+(t.managedSession?t.managedSession.uid:t.uid));return ir.mapProfileDBEntryToProfile(n)}),Object(D.mergeMap)(t=>t.source===Wn.SERVER?this.getServerProfilesDetails({userId:t.uid,requiredFields:e}).pipe(Object(D.map)(e=>Object.assign(Object.assign({},t),{handle:e.firstName+(e.lastName?" "+e.lastName:""),serverProfile:e}))):Object(c.of)(t)))))}setActiveSessionForProfile(e){return Object(c.defer)(()=>this.generateSessionEndTelemetry()).pipe(Object(D.mergeMap)(()=>this.dbService.read({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[e]})),Object(D.map)(e=>e&&e[0]&&ir.mapProfileDBEntryToProfile(e[0])),Object(D.map)(e=>{if(!e)throw new xi("No Profile found");return e}),Object(D.mergeMap)(e=>Object(c.iif)(()=>e.source===Wn.SERVER,Object(c.defer)(()=>this.getServerProfilesDetails({userId:e.uid,requiredFields:[]}).pipe(Object(D.map)(t=>Object.assign(Object.assign({},e),{serverProfile:t})),Object(D.mergeMap)(e=>this.frameworkService.setActiveChannelId(e.serverProfile.rootOrg.hashTagId)),Object(D.catchError)(()=>Object(c.of)(void 0)))),this.frameworkService.setActiveChannelId(this.sdkConfig.apiConfig.api_authentication.channelId).pipe(Object(D.mapTo)(void 0))).pipe(Object(D.mapTo)(e))),Object(D.mergeMap)(e=>{const t=new Zn(e.uid);return k.CsModule.instance.isInitialised&&k.CsModule.instance.updateConfig(Object.assign(Object.assign({},k.CsModule.instance.config),{core:Object.assign(Object.assign({},k.CsModule.instance.config.core),{global:Object.assign(Object.assign({},k.CsModule.instance.config.core.global),{sessionId:t.sid})})})),this.sharedPreferences.putString(Pi.KEY_USER_SESSION,JSON.stringify(t)).pipe(Object(D.mapTo)(!0))}),Object(D.tap)(()=>ji(this,void 0,void 0,(function*(){return yield this.generateSessionStartTelemetry()}))))}getActiveProfileSession(){return this.sharedPreferences.getString(Pi.KEY_USER_SESSION).pipe(Object(D.map)(e=>{if(e)return JSON.parse(e);throw new ki("No active session available")}))}acceptTermsAndConditions(e){return new or(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}isProfileAlreadyInUse(e){return new ar(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}generateOTP(e){return new cr(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}verifyOTP(e){return new ur(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}searchLocation(e){return new dr(this.apiService,this.sdkConfig.profileServiceConfig,this.fileService,this.cachedItemStore).handle(e)}getAllContentAccess(e){const t=`SELECT * FROM ${At.TABLE_NAME} ${kn.getUidnIdentifierFiler(e.uid,e.contentId)}`;return this.dbService.execute(t).pipe(Object(D.map)(e=>e.map(e=>class{static mapDBEntryToContenetAccess(e){const t=e[At.COLUMN_NAME_LEARNER_STATE];return{status:Number(e[At.COLUMN_NAME_STATUS]),contentId:e[At.COLUMN_NAME_CONTENT_IDENTIFIER],contentType:e[At.COLUMN_NAME_CONTENT_TYPE],contentLearnerState:{learnerState:t&&JSON.parse(t)}}}}.mapDBEntryToContenetAccess(e))))}addContentAccess(e){return this.getActiveProfileSession().pipe(Object(D.mergeMap)(({uid:t})=>this.dbService.read({table:At.TABLE_NAME,selection:`${At.COLUMN_NAME_UID}= ? AND ${At.COLUMN_NAME_CONTENT_IDENTIFIER}= ?`,selectionArgs:[t,e.contentId],orderBy:At.COLUMN_NAME_EPOCH_TIMESTAMP+" DESC",limit:"1"}).pipe(Object(D.mergeMap)(n=>{const r={uid:t,identifier:e.contentId,epoch_timestamp:Date.now(),status:Xn.PLAYED.valueOf(),content_type:e.contentType&&e.contentType.toLowerCase(),learner_state:e.contentLearnerState&&JSON.stringify(e.contentLearnerState.learnerState)};return n&&n.length?(r.status=n[0][At.COLUMN_NAME_STATUS],this.dbService.update({table:At.TABLE_NAME,selection:`${At.COLUMN_NAME_UID}= ? AND ${At.COLUMN_NAME_CONTENT_IDENTIFIER}= ?`,selectionArgs:[t,e.contentId],modelJson:r}).pipe(Object(D.map)(e=>e>0))):this.dbService.insert({table:At.TABLE_NAME,modelJson:r}).pipe(Object(D.map)(e=>e>0))}))))}exportProfile(e){const t={userIds:e.userIds,destinationFolder:e.destinationFolder,groupIds:e.groupIds};return Object(c.from)(new hr(this.fileService).execute(t).then(e=>new fr(this.dbService).execute(e.body)).then(e=>new _r(this.dbService,this.fileService,this.deviceInfo).execute(e.body)).then(e=>new Sr(this.dbService,this.fileService).execute(e.body).catch(()=>e)).then(e=>new Ar(this.dbService).execute(e.body)).then(e=>({exportedFilePath:e.body.destinationDBFilePath})))}importProfile(e){const t={sourceDBFilePath:e.sourceFilePath};return Object(c.from)(new Nr(this.dbService).execute(t).then(e=>new Cr(this.dbService).execute(e.body)).then(e=>new yi(this.dbService).execute(e.body)).then(e=>new yr(this.dbService).execute(e.body)).then(e=>new br(this.dbService).execute(e.body)).then(e=>new Mr(this.dbService).execute(e.body)).then(e=>new Ti(this.dbService).execute(e.body)).then(e=>new Ci(this.dbService).execute(e.body)).then(e=>new gr(this.dbService).execute(e.body)).then(e=>({failed:e.body.failed,imported:e.body.imported})))}mergeServerProfiles(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.PATCH).withPath(Pi.MERGE_SERVER_PROFILES_PATH).withBearerToken(!0).withHeaders({"x-source-user-token":e.from.accessToken,"x-authenticated-user-token":e.to.accessToken}).withBody({request:{fromAccountId:e.from.userId,toAccountId:e.to.userId}}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>{console.log(e)}),Object(D.finalize)(()=>{const e=this.sdkConfig.apiConfig.user_authentication.mergeUserHost+this.sdkConfig.apiConfig.user_authentication.authUrl+"/logout?redirect_uri="+this.sdkConfig.apiConfig.host+"/oauth2callback",t=cordova.InAppBrowser.open(e,"_blank","zoom=no,hidden=yes");t.addEventListener("loadstart",e=>ji(this,void 0,void 0,(function*(){e.url.indexOf("/oauth2callback")>-1&&t.close()})))}))}isDefaultChannelProfile(){return Object(c.zip)(this.frameworkService.getDefaultChannelId(),this.frameworkService.getActiveChannelId()).pipe(Object(D.map)(e=>e[0]===e[1]))}getUserFeed(){return this.getActiveProfileSession().pipe(Object(D.mergeMap)(e=>this.userService.getUserFeed(e.managedSession?e.managedSession.uid:e.uid,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath_V5})))}updateUserFeedEntry(e){return this.getActiveProfileSession().pipe(Object(D.mergeMap)(t=>this.userService.updateUserFeedEntry(t.managedSession?t.managedSession.uid:t.uid,e.feedEntryId,e.category,e.request,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath_V5}).pipe(Object(D.mapTo)(!0),Object(D.catchError)(()=>Object(c.of)(!1)))))}deleteUserFeedEntry(e){return this.getActiveProfileSession().pipe(Object(D.mergeMap)(t=>this.userService.deleteUserFeedEntry(t.managedSession?t.managedSession.uid:t.uid,e.feedEntryId,e.category,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath}).pipe(Object(D.mapTo)(!0),Object(D.catchError)(()=>Object(c.of)(!1)))))}userMigrate(e){return new mi(this.sdkConfig,this.apiService).handle(e)}updateServerProfileDeclarations(e){return this.userService.updateUserDeclarations(e.declarations,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath})}getConsent(e){return this.userService.getConsent(e,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath})}updateConsent(e){return this.userService.updateConsent(e,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath})}mapDbProfileEntriesToProfiles(e){return e.map(e=>ir.mapProfileDBEntryToProfile(e))}generateSessionStartTelemetry(){return ji(this,void 0,void 0,(function*(){return ln.log.start({type:"session",env:"sdk"}).toPromise()}))}generateSessionEndTelemetry(){return ji(this,void 0,void 0,(function*(){const e=yield this.sharedPreferences.getString(Pi.KEY_USER_SESSION).toPromise();if(e){const t=JSON.parse(e);yield ln.log.end({type:"session",env:"sdk",duration:Math.floor((Date.now()-t.createdTime)/1e3)}).toPromise()}}))}deleteProfileData(e){return new Ri(this.dbService).delete(e)}deleteUser(e){return new Li(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}};Fi.KEY_USER_SESSION=p.KEY_USER_SESSION,Fi.MERGE_SERVER_PROFILES_PATH="/api/user/v1/account/merge",Fi=Pi=Di([Object(s.injectable)(),Ui(0,Object(s.inject)(l.CONTAINER)),Ui(1,Object(s.inject)(l.SDK_CONFIG)),Ui(2,Object(s.inject)(l.DB_SERVICE)),Ui(3,Object(s.inject)(l.API_SERVICE)),Ui(4,Object(s.inject)(l.CACHED_ITEM_STORE)),Ui(5,Object(s.inject)(l.KEY_VALUE_STORE)),Ui(6,Object(s.inject)(l.SHARED_PREFERENCES)),Ui(7,Object(s.inject)(l.FRAMEWORK_SERVICE)),Ui(8,Object(s.inject)(l.FILE_SERVICE)),Ui(9,Object(s.inject)(l.DEVICE_INFO)),Ui(10,Object(s.inject)(l.AUTH_SERVICE)),Ui(11,Object(s.inject)(u.USER_SERVICE)),wi("design:paramtypes",[s.Container,Object,o,Object,Object,Object,Object,Object,Object,Object,Object,Object])],Fi);class ki extends ke{constructor(e){super(e,"NO_ACTIVE_SESSION"),Object.setPrototypeOf(this,ki.prototype)}}class xi extends ke{constructor(e){super(e,"NO_PROFILE_FOUND"),Object.setPrototypeOf(this,xi.prototype)}}class Bi extends ke{constructor(e){super(e,"AUTH_TOKEN_REFRESH_ERROR"),Object.setPrototypeOf(this,Bi.prototype)}}var Vi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Yi{constructor(e,t,n,r){this.apiConfig=e,this.apiService=t,this.sharedPreferences=n,this.eventsBusService=r}refreshSession(){return Vi(this,void 0,void 0,(function*(){let e,t=yield this.getSessionData();if(!t)throw new ki("No Active Sessions found");e="ios"===window.device.platform.toLowerCase()?(new a.CsRequest.Builder).withPath("/auth/v1/refresh/token").withType(a.CsHttpRequestType.POST).withSerializer(a.CsHttpSerializer.URLENCODED).withHeaders({"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}).withBearerToken(!0).withBody({refresh_token:t.refresh_token}).build():(new a.CsRequest.Builder).withPath("/auth/v1/refresh/token").withType(a.CsHttpRequestType.POST).withSerializer(a.CsHttpSerializer.URLENCODED).withBearerToken(!0).withBody({refresh_token:t.refresh_token}).build();try{yield this.apiService.fetch(e).toPromise().catch(e=>{if(a.CsHttpClientError.isInstance(e)&&e.response.responseCode===a.CsHttpResponseCode.HTTP_BAD_REQUEST)throw new Bi(e.message);throw e}).then(e=>Vi(this,void 0,void 0,(function*(){if(e.body.result.access_token&&e.body.result.refresh_token){let n=yield I.decodeJWT(e.body.result.access_token);const r=JSON.parse(n),i=3===r.sub.split(":").length?r.sub.split(":").pop():r.sub,o=yield this.getSessionData();return t=Object.assign(Object.assign({},e.body.result),{userToken:o?o.userToken:i,managed_access_token:o?o.managed_access_token:void 0,accessTokenExpiresOn:1e3*r.exp}),yield this.sharedPreferences.putString(E.KEY_OAUTH_SESSION,JSON.stringify(t)).toPromise()}throw new Bi("No token found in server response")})))}catch(e){throw e instanceof Bi&&this.eventsBusService.emit({namespace:M.ERROR,event:{type:R.AUTH_TOKEN_REFRESH_ERROR,payload:e}}),e}}))}startSession(e){return Vi(this,void 0,void 0,(function*(){yield this.sharedPreferences.putString(E.KEY_OAUTH_SESSION,JSON.stringify(e)).toPromise()}))}endSession(){return Vi(this,void 0,void 0,(function*(){yield this.sharedPreferences.putString(E.KEY_OAUTH_SESSION,"").toPromise()}))}getSessionData(){return Vi(this,void 0,void 0,(function*(){const e=yield this.sharedPreferences.getString(E.KEY_OAUTH_SESSION).toPromise();if(e)return JSON.parse(e)}))}}var Gi=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Hi=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},$i=function(e,t){return function(n,r){t(n,r,e)}},qi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let Ki=class{constructor(e,t,n,r,i,o,s,a,u,l,d,h,E,f,p,_,O,S){this.dbService=e,this.decorator=t,this.profileService=n,this.groupService=r,this.keyValueStore=i,this.apiService=o,this.sdkConfig=s,this.deviceInfo=a,this.eventsBusService=u,this.fileService=l,this.frameworkService=d,this.networkInfoService=h,this.errorLoggerService=E,this.sharedPreferences=f,this.appInfoService=p,this.deviceRegisterService=_,this.courseService=O,this.networkQueue=S,this.campaignParameters=[],this.globalCdata=[],this.telemetryConfig=this.sdkConfig.telemetryConfig,this._lastSyncedTimestamp$=new c.BehaviorSubject(void 0)}get autoSync(){return this.telemetryAutoSyncService||(this.telemetryAutoSyncService=new Kn(this,this.sharedPreferences)),this.telemetryAutoSyncService}preInit(){return Object(c.defer)(()=>qi(this,void 0,void 0,(function*(){this.getInitialUtmParameters().then(e=>{e&&e.length&&this.updateCampaignParameters(e)})})))}onInit(){return Object(c.combineLatest)([Object(c.defer)(()=>qi(this,void 0,void 0,(function*(){const e=yield this.sharedPreferences.getString(v.KEY_LAST_SYNCED_TIME_STAMP).toPromise();if(e)try{this._lastSyncedTimestamp$.next(parseInt(e,10))}catch(e){console.error(e)}}))),new c.Observable(e=>{sbsync.onAuthorizationError(t=>qi(this,void 0,void 0,(function*(){const n=t.network_queue_error;n&&e.next(n)})),e=>qi(this,void 0,void 0,(function*(){})))}).pipe(Object(D.mergeMap)(e=>"API_TOKEN_EXPIRED"===e?new P(this.sdkConfig.apiConfig,this.apiService,this.deviceInfo).refreshAuthToken().pipe(Object(D.mergeMap)(e=>this.sharedPreferences.putString(h.KEY_API_TOKEN,e)),Object(D.catchError)(()=>Object(c.of)(void 0))):Object(c.from)(new Yi(this.sdkConfig.apiConfig,this.apiService,this.sharedPreferences,this.eventsBusService).refreshSession()).pipe(Object(D.catchError)(()=>Object(c.of)(void 0)))))]).pipe(Object(D.mapTo)(void 0))}saveTelemetry(e){return Object(c.defer)(()=>{try{const t=JSON.parse(e);return this.decorateAndPersist(t)}catch(e){return console.error(e),Object(c.of)(!1)}})}audit({env:e,actor:t,currentState:n,updatedProperties:r,type:i,objId:o,objType:s,objVer:a,correlationData:c,rollUp:u}){const l=new le.Audit(e,t,n,r,i,o,s,a,c,u);return this.decorateAndPersist(l)}end({type:e,mode:t,duration:n,pageId:r,summaryList:i,env:o,objId:s,objType:a,objVer:c,rollup:u,correlationData:l,actor:d}){const h=new le.End(e,t,n,r,i,o,s,a,c,u,l,d);return this.decorateAndPersist(h)}error(e){const t=new le.Error(e.errorCode,e.errorType,e.stacktrace,e.pageId,e.actor);return this.errorLoggerService.logError(e).toPromise().catch(e=>console.error(e)),this.decorateAndPersist(t)}impression({type:e,subType:t,pageId:n,visits:r,env:i,objId:o,objType:s,objVer:a,rollup:c,correlationData:u,actor:l}){const d=new le.Impression(e,t,n,r,i,o,s,a,c,u,l);return this.decorateAndPersist(d)}interact({type:e,subType:t,id:n,pageId:r,pos:i,env:o,rollup:s,valueMap:a,correlationData:c,objId:u,objType:l,objVer:d,pdata:h,actor:E}){const f=new le.Interact(e,t,n,r,i,a,o,u,l,d,s,c,h,E);return this.decorateAndPersist(f)}log({type:e,level:t,message:n,pageId:r,params:i,env:o,actorType:s}){const a=new le.Log(e,t,n,r,i,o,s);return this.decorateAndPersist(a)}share({dir:e,type:t,items:n,correlationData:r,objId:i,objType:o,objVer:s,rollUp:a}){const c=new le.Share(e,t,[],r,i,o,s,a);return n.forEach(e=>{c.addItem(e.type,e.origin,e.identifier,e.pkgVersion,e.transferCount,e.size)}),this.decorateAndPersist(c)}feedback({rating:e,comments:t,env:n,objId:r,objType:i,objVer:o,commentid:s,commenttxt:a}){const c=new le.Feedback(e,t,n,r,i,o,s,a);return this.decorateAndPersist(c)}start({type:e,deviceSpecification:t,loc:n,mode:r,duration:i,pageId:o,env:s,objId:a,objType:c,objVer:u,rollup:l,correlationData:d,actor:h}){const E=new le.Start(e,t,n,r,i,o,s,a,c,u,l,d,h);return this.decorateAndPersist(E)}summary({type:e,starttime:t,endtime:n,timespent:r,pageviews:i,interactions:o,env:s,mode:a,envsummary:c,eventsummary:u,pagesummary:l,extra:d,correlationData:h,objId:E,objType:f,objVer:p,rollup:_}){const O=new le.Summary(e,t,n,r,i,o,s,a,c,u,l,d,h,E,f,p,_);return this.decorateAndPersist(O)}interrupt({type:e,pageId:t,actor:n}){const r=new le.Interrupt(e,t,n);return this.decorateAndPersist(r)}importTelemetry(e){const t={sourceDBFilePath:e.sourceFilePath};return Object(c.from)(new Bn(this.dbService).execute(t).then(e=>new Gn(this.dbService).execute(e.body)).then(e=>new Hn(this.dbService).execute(e.body)).then(e=>new Hn(this.dbService).execute(e.body)).then(e=>new $n(this.dbService,this).execute(e.body)).then(e=>!0).catch(e=>(console.error(e),!1)))}getTelemetryStat(){const e=`\n SELECT COUNT(*) as TELEMETRY_COUNT\n FROM ${He.TABLE_NAME}\n `,t=`\n SELECT SUM(${qe.COLUMN_NAME_NUMBER_OF_EVENTS}) as PROCESSED_TELEMETRY_COUNT\n FROM ${qe.TABLE_NAME}\n `;return Object(c.zip)(this.dbService.execute(e),this.dbService.execute(t),this.keyValueStore.getValue(v.KEY_LAST_SYNCED_TIME_STAMP)).pipe(Object(D.map)(e=>({unSyncedEventCount:e[0][0].TELEMETRY_COUNT+e[1][0].PROCESSED_TELEMETRY_COUNT,lastSyncTime:e[2]?parseInt(e[2],10):0})))}resetDeviceRegisterTTL(){return new pn(this.dbService,this.sdkConfig,this.deviceInfo,this.sharedPreferences,this.appInfoService,this.deviceRegisterService,this.keyValueStore,this.apiService,this.networkQueue).resetDeviceRegisterTTL()}sync(e={ignoreSyncThreshold:!1,ignoreAutoSyncMode:!1}){return this.networkInfoService.networkStatus$.pipe(Object(D.take)(1),Object(D.mergeMap)(t=>(t===Vn.ONLINE&&(e.ignoreSyncThreshold=!0),Object(c.of)(e))),Object(D.mergeMap)(e=>new pn(this.dbService,this.sdkConfig,this.deviceInfo,this.sharedPreferences,this.appInfoService,this.deviceRegisterService,this.keyValueStore,this.apiService,this.networkQueue).handle(e).pipe(Object(D.tap)(e=>{if(!e.error&&e.syncedEventCount){const e=Date.now();this.sharedPreferences.putString(v.KEY_LAST_SYNCED_TIME_STAMP,e+"").toPromise(),this._lastSyncedTimestamp$.next(e)}}))))}lastSyncedTimestamp(){return this._lastSyncedTimestamp$.asObservable()}buildContext(){return this.profileService.getActiveProfileSession().pipe(Object(D.map)(e=>this.decorator.buildContext(e.sid,this.frameworkService.activeChannelId,new _e)))}decorateAndPersist(e){return Object(c.zip)(this.profileService.getActiveProfileSession(),this.groupService.getActiveGroupSession()).pipe(Object(D.mergeMap)(t=>{const n=t[0],r=t[1];return this.keyValueStore.getValue(pn.TELEMETRY_LOG_MIN_ALLOWED_OFFSET_KEY).pipe(Object(D.mergeMap)(t=>{t=t||"0";const i={table:He.TABLE_NAME,modelJson:this.decorator.prepare(this.decorator.decorate(e,n,r&&r.gid,Number(t),this.frameworkService.activeChannelId,this.campaignParameters,this.globalCdata),1)};return this.dbService.insert(i).pipe(Object(D.tap)(()=>this.eventsBusService.emit({namespace:M.TELEMETRY,event:{type:Un.SAVE,payload:e}})),Object(D.map)(e=>e>1))}))}))}updateCampaignParameters(e){this.campaignParameters=e}populateGlobalCorRelationData(e){this.globalCdata=e}getInitialUtmParameters(){return new Promise((e,t)=>{try{sbutility.getUtmInfo(t=>{e(t.val)},e=>{t(e)})}catch(e){t(e)}})}};Ki=Gi([Object(s.injectable)(),$i(0,Object(s.inject)(l.DB_SERVICE)),$i(1,Object(s.inject)(l.TELEMETRY_DECORATOR)),$i(2,Object(s.inject)(l.PROFILE_SERVICE)),$i(3,Object(s.inject)(l.GROUP_SERVICE_DEPRECATED)),$i(4,Object(s.inject)(l.KEY_VALUE_STORE)),$i(5,Object(s.inject)(l.API_SERVICE)),$i(6,Object(s.inject)(l.SDK_CONFIG)),$i(7,Object(s.inject)(l.DEVICE_INFO)),$i(8,Object(s.inject)(l.EVENTS_BUS_SERVICE)),$i(9,Object(s.inject)(l.FILE_SERVICE)),$i(10,Object(s.inject)(l.FRAMEWORK_SERVICE)),$i(11,Object(s.inject)(l.NETWORKINFO_SERVICE)),$i(12,Object(s.inject)(l.ERROR_LOGGER_SERVICE)),$i(13,Object(s.inject)(l.SHARED_PREFERENCES)),$i(14,Object(s.inject)(l.APP_INFO)),$i(15,Object(s.inject)(l.DEVICE_REGISTER_SERVICE)),$i(16,Object(s.inject)(l.COURSE_SERVICE)),$i(17,Object(s.inject)(l.NETWORK_QUEUE)),Hi("design:paramtypes",[o,J,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object])],Ki);var zi,Wi=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Xi=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ji=function(e,t){return function(n,r){t(n,r,e)}},Qi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let Zi=zi=class{constructor(e,t,n,r){this.sdkConfig=e,this.apiService=t,this.sharedPreferences=n,this.eventsBusService=r,this.apiConfig=this.sdkConfig.apiConfig,this.authUtil=new Yi(this.apiConfig,this.apiService,this.sharedPreferences,this.eventsBusService)}onInit(){return this.sharedPreferences.addListener(E.KEY_OAUTH_SESSION,e=>Qi(this,void 0,void 0,(function*(){if(e)try{const t=JSON.parse(yield this.sharedPreferences.getString(p.KEY_USER_SESSION).toPromise()),n=JSON.parse(e);k.CsModule.instance.config.core.api.authentication.userToken=n.access_token,k.CsModule.instance.config.core.api.authentication.managedUserToken=t.managedSession?n.managed_access_token:void 0}catch(e){console.error(e),k.CsModule.instance.config.core.api.authentication.userToken=void 0,k.CsModule.instance.config.core.api.authentication.managedUserToken=void 0}else k.CsModule.instance.config.core.api.authentication.userToken=void 0,k.CsModule.instance.config.core.api.authentication.managedUserToken=void 0;k.CsModule.instance.updateConfig(k.CsModule.instance.config)}))),this.sharedPreferences.addListener(p.KEY_USER_SESSION,e=>Qi(this,void 0,void 0,(function*(){if(e)try{const t=JSON.parse(e),n=JSON.parse(yield this.sharedPreferences.getString(E.KEY_OAUTH_SESSION).toPromise());k.CsModule.instance.config.core.api.authentication.userToken=n.access_token,k.CsModule.instance.config.core.api.authentication.managedUserToken=t.managedSession?n.managed_access_token:void 0}catch(e){console.error(e),k.CsModule.instance.config.core.api.authentication.userToken=void 0,k.CsModule.instance.config.core.api.authentication.managedUserToken=void 0}else k.CsModule.instance.config.core.api.authentication.userToken=void 0,k.CsModule.instance.config.core.api.authentication.managedUserToken=void 0;k.CsModule.instance.updateConfig(k.CsModule.instance.config)}))),Object(c.combineLatest)([Object(c.defer)(()=>this.getSession()).pipe(Object(D.mergeMap)(e=>Qi(this,void 0,void 0,(function*(){if(!e)return;const t=JSON.parse(yield this.sharedPreferences.getString(p.KEY_USER_SESSION).toPromise());k.CsModule.instance.config.core.api.authentication.userToken=e.access_token,k.CsModule.instance.config.core.api.authentication.managedUserToken=t.managedSession?e.managed_access_token:void 0,k.CsModule.instance.updateConfig(k.CsModule.instance.config)})))),Object(c.defer)(()=>this.onAccessTokenNearingExpiry()).pipe(Object(D.mergeMap)(e=>Qi(this,void 0,void 0,(function*(){if(e)return this.refreshSession().toPromise()}))))]).pipe(Object(D.mapTo)(void 0))}setSession(e){return Object(c.from)(e.provide().then(e=>{if(!e.access_token)throw this.authUtil.endSession(),e;this.authUtil.startSession(e),this.authUtil.refreshSession()}))}getSession(){return Object(c.from)(this.authUtil.getSessionData())}resignSession(){return Object(c.from)(this.authUtil.endSession())}refreshSession(){return Object(c.from)(this.authUtil.refreshSession())}onAccessTokenNearingExpiry(){const e=Object(c.defer)(()=>this.getSession()),t=new c.Observable(e=>{document.addEventListener("resume",()=>{setTimeout(()=>{e.next()},0)},!1)}).pipe(Object(D.mergeMap)(()=>this.getSession()));return Object(c.merge)(e,t).pipe(Object(D.map)(e=>!(!e||!e.accessTokenExpiresOn)&&e.accessTokenExpiresOn-Date.now()<zi.ACCESS_TOKEN_NEARING_EXPIRY_DELTA),Object(D.distinctUntilChanged)())}};Zi.ACCESS_TOKEN_NEARING_EXPIRY_DELTA=36e5,Zi=zi=Wi([Object(s.injectable)(),Ji(0,Object(s.inject)(l.SDK_CONFIG)),Ji(1,Object(s.inject)(l.API_SERVICE)),Ji(2,Object(s.inject)(l.SHARED_PREFERENCES)),Ji(3,Object(s.inject)(l.EVENTS_BUS_SERVICE)),Xi("design:paramtypes",[Object,Object,Object,Object])],Zi);class eo{constructor(e,t,n,r){this.apiService=e,this.frameworkServiceConfig=t,this.fileService=n,this.cachedItemStore=r,this.CHANNEL_FILE_KEY_PREFIX="channel-",this.CHANNEL_LOCAL_KEY="channel-",this.GET_FRAMEWORK_DETAILS_ENDPOINT="/read"}handle(e){return this.cachedItemStore[e.from===Jn.SERVER?"get":"getCached"](e.channelId,this.CHANNEL_LOCAL_KEY,"ttl_"+this.CHANNEL_LOCAL_KEY,()=>this.fetchFromServer(e),()=>this.fetchFromFile(e)).pipe(Object(D.map)(e=>(e.frameworks&&e.frameworks.sort((e,t)=>e.name.localeCompare(t.name)),e)))}fetchFromServer(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.frameworkServiceConfig.channelApiPath+this.GET_FRAMEWORK_DETAILS_ENDPOINT+"/"+e.channelId).withBearerToken(!0).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result.channel))}fetchFromFile(e){const t=lr.getAssetPath()+this.frameworkServiceConfig.channelConfigDirPath,n=this.CHANNEL_FILE_KEY_PREFIX+e.channelId+".json";return Object(c.from)(this.fileService.readFileFromAssets(t.concat("/",n))).pipe(Object(D.map)(e=>JSON.parse(e).result.channel))}}class to{static prepareFrameworkCategoryAssociations(e){return e.categories?(e.categories=e.categories.map((t,n)=>t.terms?Object.assign(Object.assign({},t),{terms:t.terms.map(t=>t.associations?(t.associations.length&&(t.associations=t.associations.filter(t=>n>=e.categories.length-1||t.category===e.categories[n+1].code)),t):t)}):t),Object.assign({},e)):e}static prepareFrameworkTranslations(e,t){return e.name=to.getTranslatedValue(e.translations,t,e.name),e.categories&&(e.categories=e.categories.map(e=>(e.name=to.getTranslatedValue(e.translations,t,e.name),e.terms&&(e.terms=e.terms.map(e=>(e.name=to.getTranslatedValue(e.translations,t,e.name),e))),e))),e}static prepareFrameworkCategoryTranslations(e,t){return e.name=to.getTranslatedValue(e.translations,t,e.name),e.terms&&(e.terms=e.terms.map(e=>(e.name=to.getTranslatedValue(e.translations,t,e.name),e))),e}static getTranslatedValue(e,t,n){if(!e)return n;return JSON.parse(e)[t]||n}}class no{constructor(e,t,n,r,i){this.frameworkService=e,this.apiService=t,this.frameworkServiceConfig=n,this.fileService=r,this.cachedItemStore=i,this.FRAMEWORK_FILE_KEY_PREFIX="framework-",this.FRAMEWORK_LOCAL_KEY="framework-",this.GET_FRAMEWORK_DETAILS_ENDPOINT="/read"}handle(e){return Object(c.iif)(()=>!!e.frameworkId,Object(c.defer)(()=>this.cachedItemStore[e.from===Jn.SERVER?"get":"getCached"](e.frameworkId,this.FRAMEWORK_LOCAL_KEY,"ttl_"+this.FRAMEWORK_LOCAL_KEY,()=>this.fetchFromServer(e),()=>this.fetchFromFile(e))),Object(c.defer)(()=>this.frameworkService.getDefaultChannelDetails().pipe(Object(D.mergeMap)(t=>this.frameworkService.getFrameworkDetails({from:e.from,frameworkId:t.defaultFramework,requiredCategories:e.requiredCategories})))))}fetchFromServer(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.frameworkServiceConfig.frameworkApiPath+this.GET_FRAMEWORK_DETAILS_ENDPOINT+"/"+e.frameworkId).withParameters({categories:e.requiredCategories.join(",")}).withBearerToken(!0).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result.framework),Object(D.map)(e=>to.prepareFrameworkCategoryAssociations(e)))}fetchFromFile(e){const t=lr.getAssetPath()+this.frameworkServiceConfig.frameworkConfigDirPath,n=this.FRAMEWORK_FILE_KEY_PREFIX+e.frameworkId+".json";return Object(c.from)(this.fileService.readFileFromAssets(t.concat("/",n))).pipe(Object(D.map)(e=>JSON.parse(e).result.framework),Object(D.map)(e=>to.prepareFrameworkCategoryAssociations(e)))}}class ro extends ke{constructor(e){super(e,"NO_ACTIVE_CHANNEL_FOUND_ERROR"),Object.setPrototypeOf(this,ro.prototype)}}var io,oo=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},so=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ao=function(e,t){return function(n,r){t(n,r,e)}};let co=io=class{constructor(e,t,n,r,i,o,s){this.sdkConfig=e,this.fileService=t,this.apiService=n,this.cachedItemStore=r,this.sharedPreferences=i,this.systemSettingsService=o,this.csFrameworkService=s}get activeChannelId(){return this._activeChannelId}preInit(){return this.getActiveChannelId().pipe(Object(D.tap)(e=>this._activeChannelId=e),Object(D.mapTo)(void 0),Object(D.catchError)(e=>{if(e instanceof ro)return this.setActiveChannelId(this.sdkConfig.apiConfig.api_authentication.channelId);throw e}))}getDefaultChannelId(){return Object(c.iif)(()=>!this.sdkConfig.frameworkServiceConfig.overriddenDefaultChannelId,Object(c.defer)(()=>this.systemSettingsService.getSystemSettings({id:this.sdkConfig.frameworkServiceConfig.systemSettingsDefaultChannelIdKey}).pipe(Object(D.map)(e=>e.value))),Object(c.defer)(()=>Object(c.of)(this.sdkConfig.frameworkServiceConfig.overriddenDefaultChannelId)))}getDefaultChannelDetails(e={from:Jn.CACHE}){return this.systemSettingsService.getSystemSettings({id:this.sdkConfig.frameworkServiceConfig.systemSettingsDefaultChannelIdKey}).pipe(Object(D.map)(e=>e.value),Object(D.mergeMap)(t=>this.getChannelDetails({from:e.from,channelId:this.sdkConfig.frameworkServiceConfig.overriddenDefaultChannelId||t})))}getChannelDetails(e){return new eo(this.apiService,this.sdkConfig.frameworkServiceConfig,this.fileService,this.cachedItemStore).handle(e)}getFrameworkDetails(e){return new no(this,this.apiService,this.sdkConfig.frameworkServiceConfig,this.fileService,this.cachedItemStore).handle(e)}getFrameworkConfig(e,t){let n;return t&&(n={type:t.type,subType:t.subType,action:t.action,rootOrgId:t.rootOrgId,framework:t.framework,component:t.component}),this.csFrameworkService.getFrameworkConfig(e,{apiPath:"/api/framework/v1"},{apiPath:"/api/data/v1/form",params:n})}searchOrganization(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.sdkConfig.frameworkServiceConfig.searchOrganizationApiPath+io.SEARCH_ORGANIZATION_ENDPOINT).withBody({request:e}).withBearerToken(!0).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result.response))}getActiveChannelId(){return this.sharedPreferences.getString(io.KEY_ACTIVE_CHANNEL_ID).pipe(Object(D.map)(e=>{if(!e)throw new ro("No Active channel ID set in preferences");return e}))}setActiveChannelId(e){return this._activeChannelId=e,k.CsModule.instance.isInitialised&&k.CsModule.instance.updateConfig(Object.assign(Object.assign({},k.CsModule.instance.config),{core:Object.assign(Object.assign({},k.CsModule.instance.config.core),{global:Object.assign(Object.assign({},k.CsModule.instance.config.core.global),{channelId:e})})})),this.sharedPreferences.putString(io.KEY_ACTIVE_CHANNEL_ID,e)}};var uo;co.KEY_ACTIVE_CHANNEL_ID=_.KEY_ACTIVE_CHANNEL_ID,co.SEARCH_ORGANIZATION_ENDPOINT="/search",co=io=oo([Object(s.injectable)(),ao(0,Object(s.inject)(l.SDK_CONFIG)),ao(1,Object(s.inject)(l.FILE_SERVICE)),ao(2,Object(s.inject)(l.API_SERVICE)),ao(3,Object(s.inject)(l.CACHED_ITEM_STORE)),ao(4,Object(s.inject)(l.SHARED_PREFERENCES)),ao(5,Object(s.inject)(l.SYSTEM_SETTINGS_SERVICE)),ao(6,Object(s.inject)(u.FRAMEWORK_SERVICE)),so("design:paramtypes",[Object,Object,Object,Object,Object,Object,Object])],co),function(e){e.BOARD="board",e.MEDIUM="medium",e.GRADE_LEVEL="gradeLevel",e.SUBJECT="subject",e.TOPIC="topic",e.PURPOSE="purpose"}(uo||(uo={}));class lo{}lo.DEFAULT_FRAMEWORK_CATEGORIES=[uo.BOARD,uo.MEDIUM,uo.GRADE_LEVEL,uo.SUBJECT],lo.COURSE_FRAMEWORK_CATEGORIES=[uo.TOPIC,uo.PURPOSE,uo.MEDIUM,uo.GRADE_LEVEL,uo.SUBJECT];var ho=n(9),Eo=n.n(ho),fo=n(11),po=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class _o{constructor(e,t,n){this.frameworkUtilService=e,this.frameworkService=t,this.sharedPreferences=n}handle(e){return(()=>e.frameworkId?this.getTranslatedFrameworkDetails(e.frameworkId,e.requiredCategories,e.language):this.getActiveChannelTranslatedDefaultFrameworkDetails(e))().pipe(Object(D.tap)(e=>po(this,void 0,void 0,(function*(){return yield this.sharedPreferences.putString(_.KEY_ACTIVE_CHANNEL_ACTIVE_FRAMEWORK_ID,e.identifier).toPromise()}))),Object(D.map)(t=>{let n=[];if(n=!e.prevCategoryCode&&e.currentCategoryCode?this.getCategoryTerms(t,e).toArray():this.getCategoryAssociationTerms(t,e).toArray(),"gradeLevel"===e.currentCategoryCode){const e=n.reduce((e,t)=>t.index&&t.index>e?t.index:e,0);n.sort((t,n)=>(t.index||e+1)-(n.index||e+1))}else n.sort((e,t)=>e.name.localeCompare(t.name));const r=n.indexOf(n.find(e=>"Others"===e.name));if(r>=0&&r!==n.length){const e=n[n.length-1];n[n.length-1]=n[r],n[r]=e}return n}))}getActiveChannelTranslatedDefaultFrameworkDetails(e){return this.frameworkUtilService.getActiveChannel({from:e.from}).pipe(Object(D.mergeMap)(t=>this.getTranslatedFrameworkDetails(t.defaultFramework,e.requiredCategories,e.language,e.from)))}getTranslatedFrameworkDetails(e,t,n,r){return this.frameworkService.getFrameworkDetails({from:r,frameworkId:e,requiredCategories:t}).pipe(Object(D.map)(e=>to.prepareFrameworkTranslations(e,n)))}getAllCategoriesTermsSet(e){return e.categories?e.categories.reduce((e,t)=>[...e,t.terms||[]],[]).reduce((e,t)=>e.concat(t),[]).reduce((e,t)=>(e.add(t),e),new Eo.a(e=>Object(fo.makeString)(e))):new Eo.a}getCategoryTerms(e,t){return e.categories.find(e=>e.code===t.currentCategoryCode).terms.reduce((e,t)=>(e.add(t),e),new Eo.a(e=>Object(fo.makeString)(e)))}getCategoryAssociationTerms(e,t){if(!e.categories)return new Eo.a;const n=e.categories.find(e=>e.code===t.prevCategoryCode).terms;if(!n)return new Eo.a;const r=n.filter(e=>t.selectedTermsCodes.find(t=>t===e.code)).map(e=>e.associations||[]);return r.some(e=>0===e.length)?e.categories.find(e=>e.code===t.currentCategoryCode).terms.reduce((e,t)=>(e.add(t),e),new Eo.a(e=>Object(fo.makeString)(e))):r.reduce((e,t)=>e.concat(t),[]).reduce((e,t)=>(e.add(t),e),new Eo.a(e=>Object(fo.makeString)(e))).toArray().map(t=>this.getAllCategoriesTermsSet(e).toArray().find(e=>e.identifier===t.identifier)).reduce((e,t)=>(e.add(t),e),new Eo.a(e=>Object(fo.makeString)(e)))}}var Oo=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},So=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},go=function(e,t){return function(n,r){t(n,r,e)}};let Ao=class{constructor(e,t,n){this.sharedPreferences=e,this.frameworkService=t,this.profileService=n}getActiveChannel(e={from:Jn.CACHE}){return this.frameworkService.getActiveChannelId().pipe(Object(D.mergeMap)(t=>this.frameworkService.getChannelDetails({from:e.from,channelId:t})))}getActiveChannelSuggestedFrameworkList(e){return this.profileService.getActiveSessionProfile({requiredFields:[]}).pipe(Object(D.mergeMap)(t=>Object(c.iif)(()=>!!t.serverProfile&&!e.ignoreActiveChannel,Object(c.defer)(()=>this.getActiveChannel({from:e.from})),Object(c.defer)(()=>this.frameworkService.getDefaultChannelDetails({from:e.from})))),Object(D.mergeMap)(t=>t.frameworks?Object(c.of)(t.frameworks).pipe(Object(D.map)(t=>t.map(e=>to.prepareFrameworkCategoryAssociations(e)).map(t=>to.prepareFrameworkTranslations(t,e.language)))):this.frameworkService.getFrameworkDetails({from:e.from,frameworkId:t.defaultFramework,requiredCategories:e.requiredCategories}).pipe(Object(D.map)(e=>(e.index=0,[e])))))}getFrameworkCategoryTerms(e){return new _o(this,this.frameworkService,this.sharedPreferences).handle(e)}};Ao=Oo([Object(s.injectable)(),go(0,Object(s.inject)(l.SHARED_PREFERENCES)),go(1,Object(s.inject)(l.FRAMEWORK_SERVICE)),go(2,Object(s.inject)(l.PROFILE_SERVICE)),So("design:paramtypes",[Object,Object,Object])],Ao);class No{constructor(e){this.dbService=e}getContentMarker(e,t){const n=`SELECT * FROM ${vt.TABLE_NAME}\n ${kn.getUidnIdentifierFiler(t,e)}\n ORDER BY ${vt.COLUMN_NAME_EPOCH_TIMESTAMP} DESC `;return this.dbService.execute(n).pipe(Object(D.map)(e=>this.mapDBEntriesToContentMarkerDetails(e)))}mapDBEntriesToContentMarkerDetails(e){return e.map(e=>({contentId:e[vt.COLUMN_NAME_CONTENT_IDENTIFIER],uid:e[vt.COLUMN_NAME_UID],extraInfoMap:e[vt.COLUMN_NAME_EXTRA_INFO]&&JSON.parse(e[vt.COLUMN_NAME_EXTRA_INFO]),marker:e[vt.COLUMN_NAME_MARKER]}))}}var To=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Co=St.COLUMN_NAME_MIME_TYPE,vo=St.COLUMN_NAME_VISIBILITY;class yo{constructor(e,t,n,r,i,o){this.contentFeedbackService=e,this.profileService=t,this.apiService=n,this.contentServiceConfig=r,this.dbService=i,this.eventsBusService=o,this.GET_CONTENT_DETAILS_ENDPOINT="/read"}static getReadContentQuery(e){return{table:St.TABLE_NAME,selection:(new Kt).where("? = ?").args([St.COLUMN_NAME_IDENTIFIER,e]).end().build(),limit:"1"}}static isUnit(e){return e[Co]===Tn.COLLECTION&&e[vo]===Cn.PARENT}handle(e){return e.emitUpdateIfAny=void 0===e.emitUpdateIfAny||e.emitUpdateIfAny,this.fetchFromDB(e.contentId).pipe(Object(D.mergeMap)(t=>t?Object(c.of)(xn.mapContentDBEntryToContent(t)).pipe(Object(D.mergeMap)(t=>("string"==typeof t.contentData.originData&&(t.contentData.originData=kn.getParseErrorObject(t.contentData.originData)),t.contentData.trackable&&"string"==typeof t.contentData.trackable&&(t.contentData.trackable=JSON.parse(t.contentData.trackable)),this.decorateContent({content:t,attachFeedback:e.attachFeedback,attachContentAccess:e.attachContentAccess,attachContentMarker:e.attachContentMarker}))),Object(D.tap)(n=>To(this,void 0,void 0,(function*(){if(!e.emitUpdateIfAny||yo.isUnit(t))return;let r=!1;const i=t[St.COLUMN_NAME_SERVER_DATA]&&JSON.parse(t[St.COLUMN_NAME_SERVER_DATA]);i&&i.streamingUrl||(r=!0);const o=yield this.fetchFromServer(e).toPromise();t[St.COLUMN_NAME_SERVER_DATA]=JSON.stringify(o),t[St.COLUMN_NAME_SERVER_LAST_UPDATED_ON]=o.lastUpdatedOn,t[St.COLUMN_NAME_AUDIENCE]=kn.readAudience(o),yield this.dbService.update({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" =?",selectionArgs:[t[St.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise(),kn.isUpdateAvailable(o,n.contentData)&&this.eventsBusService.emit({namespace:M.CONTENT,event:{type:Pn.UPDATE,payload:{contentId:n.contentData.identifier,size:o.size}}}),o&&this.eventsBusService.emit({namespace:M.CONTENT,event:{type:Pn.SERVER_CONTENT_DATA,payload:{contentId:o.identifier,streamingUrl:o.streamingUrl,licenseDetails:o.licenseDetails,size:o.size,serverContentData:o}}})})))):this.fetchAndDecorate(e)))}fetchFromDB(e){return this.dbService.read({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[e],limit:"1"}).pipe(Object(D.map)(e=>e[0]))}fetchFromDBForAll(e){return this.dbService.read({table:St.TABLE_NAME,selection:`${St.COLUMN_NAME_IDENTIFIER} IN (${e})`})}fetchFromServer(e){switch(e.objectType){case"QuestionSet":return this.apiService.fetch((new a.CsRequest.Builder).withHost(this.contentServiceConfig.host).withType(a.CsHttpRequestType.GET).withPath(this.contentServiceConfig.questionSetReadApiPath+this.GET_CONTENT_DETAILS_ENDPOINT+"/"+e.contentId).withBearerToken(!1).build()).pipe(Object(D.map)(e=>e.body.result.questionset));case"Question":return this.apiService.fetch((new a.CsRequest.Builder).withHost(this.contentServiceConfig.host).withType(a.CsHttpRequestType.GET).withPath(this.contentServiceConfig.questionReadApiPath+this.GET_CONTENT_DETAILS_ENDPOINT+"/"+e.contentId).withBearerToken(!1).build()).pipe(Object(D.map)(e=>e.body.result.question));default:return this.apiService.fetch((new a.CsRequest.Builder).withHost(this.contentServiceConfig.host).withType(a.CsHttpRequestType.GET).withPath(this.contentServiceConfig.apiPath+this.GET_CONTENT_DETAILS_ENDPOINT+"/"+e.contentId).withParameters({licenseDetails:"name,url,description"}).withBearerToken(!0).build()).pipe(Object(D.map)(e=>e.body.result.content))}}fetchAndDecorate(e){return this.fetchFromServer(e).pipe(Object(D.map)(e=>xn.mapServerResponseToContent(e)),Object(D.mergeMap)(t=>this.decorateContent({content:t,attachFeedback:e.attachFeedback,attachContentAccess:e.attachContentAccess,attachContentMarker:e.attachContentMarker})))}decorateContent(e){return Object(c.of)(e.content).pipe(Object(D.mergeMap)(t=>e.attachContentAccess?this.attachContentAccess(t):Object(c.of)(t)),Object(D.mergeMap)(t=>e.attachFeedback?this.attachFeedback(t):Object(c.of)(t)),Object(D.mergeMap)(t=>e.attachContentMarker?this.attachContentMarker(t):Object(c.of)(t)))}attachContentAccess(e){return this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(({uid:t})=>this.profileService.getAllContentAccess({contentId:e.identifier,uid:t}).pipe(Object(D.map)(t=>Object.assign(Object.assign({},e),{contentAccess:t})))))}attachFeedback(e){return this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(({uid:t})=>this.contentFeedbackService.getFeedback({contentId:e.identifier,uid:t}).pipe(Object(D.map)(t=>Object.assign(Object.assign({},e),{contentFeedback:t})))))}attachContentMarker(e){return this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(({uid:t})=>new No(this.dbService).getContentMarker(e.identifier,t).pipe(Object(D.map)(t=>Object.assign(Object.assign({},e),{contentMarkers:t})))))}}class mo{constructor(e){this._stack=e||[]}get count(){return this._stack.length}push(e){this._stack.push(e)}pop(){return this._stack.pop()}clear(){this._stack=[]}isEmpty(){return 0===this._stack.length}addAll(e){this._stack=[...this._stack,...e]}}var bo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Io{constructor(e,t,n,r){this.dbService=e,this.getContentDetailsHandler=t,this.appConfig=n,this.fileService=r}fetchChildrenOfContent(e,t,n,r,i){return bo(this,void 0,void 0,(function*(){const o=xn.mapContentDBEntryToContent(e),s=yield this.getSortedChildrenList(e[St.COLUMN_NAME_LOCAL_DATA],An.ALL,t);if(s&&s.length){let a=[];if(a=a.concat(i),a.push({identifier:e[St.COLUMN_NAME_IDENTIFIER],contentType:e[St.COLUMN_NAME_CONTENT_TYPE],primaryCategory:e[St.COLUMN_NAME_PRIMARY_CATEGORY]}),o.hierarchyInfo=a,-1===r||n<=r){const e=[];for(const i of s){const o=i,s=yield this.fetchChildrenOfContent(o,t,n+1,r,a);s.contentData.appIcon&&!s.contentData.appIcon.startsWith("http")&&(s.contentData.appIcon="_app_file_".concat(s.basePath).concat(s.contentData.appIcon)),"application/json"===s.contentData.mimeType&&(s.contentData.artifactUrl="_app_file_".concat(s.basePath).concat(s.contentData.artifactUrl)),e.push(s)}o.children=e}}else o.hierarchyInfo=i;return o}))}getContentsKeyList(e){return bo(this,void 0,void 0,(function*(){const t=[],n=new mo,r=[];let i,o="";for(n.push(e);!n.isEmpty();){if(i=n.pop(),kn.hasChildren(i[St.COLUMN_NAME_LOCAL_DATA])){(yield this.getSortedChildrenListOld(i[St.COLUMN_NAME_LOCAL_DATA],An.ALL)).forEach(e=>{n.push(e),r.push(i[St.COLUMN_NAME_IDENTIFIER].concat("/",e[St.COLUMN_NAME_IDENTIFIER]))})}if(o){let e;for(let e=o.split("/").length-1;e>=0;e--){const t=o.split("/")[e];if(wn.contains(r,t.concat("/",i[St.COLUMN_NAME_IDENTIFIER])))break;o=o.substring(0,o.lastIndexOf("/"))}Tn.COLLECTION.valueOf()===i[St.COLUMN_NAME_MIME_TYPE]?o=o+"/"+i[St.COLUMN_NAME_IDENTIFIER]:(e=o+"/"+i[St.COLUMN_NAME_IDENTIFIER],t.push(e))}else o=i[St.COLUMN_NAME_IDENTIFIER]}return t}))}getContentFromDB(e,t,n){return bo(this,void 0,void 0,(function*(){const e=[];let r;if(t){const i=t.split("/"),o=i.length;let s=!0;for(let t=0;t<o-1;t++){const n=yield this.getContentDetailsHandler.fetchFromDB(i[t]).toPromise();if(!n){s=!1;break}e.push({identifier:n[St.COLUMN_NAME_IDENTIFIER],contentType:n[St.COLUMN_NAME_CONTENT_TYPE],primaryCategory:n[St.COLUMN_NAME_PRIMARY_CATEGORY]})}if(s){const t=yield this.getContentDetailsHandler.fetchFromDB(i[o-1]).toPromise();if(t){r=xn.mapContentDBEntryToContent(t,n),r.hierarchyInfo=e,r.rollup=kn.getContentRollup(r.identifier,r.hierarchyInfo);const i=kn.readCompatibilityLevel(r.contentData),o=kn.isCompatible(this.appConfig,i);r.isCompatible=o;const s=e.map(e=>e.identifier),a=wn.joinPreservingQuotes(s);let c=yield this.getContentDetailsHandler.fetchFromDBForAll(a).toPromise();c=c.sort((e,t)=>s.indexOf(e.identifier)-s.indexOf(t.identifier));for(let t=0;t<c.length;t++){const n=c[t],i=JSON.parse(n[St.COLUMN_NAME_LOCAL_DATA]),o=kn.isTrackable(i);if(0===t&&1===o)break;if(1===o){n.identifier;let i=JSON.parse(JSON.stringify(e));i&&(i=i.slice(0,t),r.trackableParentInfo={identifier:n.identifier,hierarchyInfo:i});break}}}}}return r}))}getNextContentIdentifier(e,t,n){let r,i="";e.forEach(e=>{i=i?i.concat("/",e.identifier):e.identifier}),i=i.concat("/",t);const o=n.indexOf(i);return o>0&&(r=n[o-1]),r}getPreviousContentIdentifier(e,t,n){let r,i="";e.forEach(e=>{i=i?i.concat("/",e.identifier):e.identifier}),i=i.concat("/",t);const o=n.indexOf(i);return-1!==o&&o<n.length-1&&(r=n[o+1]),r}getSortedChildrenListOld(e,t){return bo(this,void 0,void 0,(function*(){let n=JSON.parse(e).children;if(!n||!n.length)return[];n=n.sort((e,t)=>e.index-t.index);const r=[];let i="",o=0;n.forEach(e=>{r.push(e.identifier),i=i.concat(` WHEN '${e.identifier}' THEN ${o}`),o+=1});let s="";o>0&&(s=s.concat(` ORDER BY CASE ${St.COLUMN_NAME_IDENTIFIER} ${i} END`));let a="";switch(t){case An.DOWNLOADED.valueOf():a=" AND "+St.COLUMN_NAME_CONTENT_STATE+"='"+Nn.ARTIFACT_AVAILABLE+"'";break;case An.SPINE.valueOf():a=" AND "+St.COLUMN_NAME_CONTENT_STATE+"='"+Nn.ONLY_SPINE+"'";break;case An.ALL.valueOf():default:a=""}const c=`SELECT * FROM ${St.TABLE_NAME}\n WHERE ${St.COLUMN_NAME_IDENTIFIER}\n IN (${wn.joinPreservingQuotes(r)}) ${a} ${s}`;return this.dbService.execute(c).toPromise()}))}getSortedChildrenList(e,t,n){return bo(this,void 0,void 0,(function*(){let r=JSON.parse(e).children;if(!r||!r.length)return[];r=r.sort((e,t)=>e.index-t.index);let i=[];for(const e of r){const t=n.get(e.identifier);if(t)i.push(t);else{const t=`SELECT * FROM ${St.TABLE_NAME}\n WHERE ${St.COLUMN_NAME_IDENTIFIER} = '${e.identifier}'`,n=yield this.dbService.execute(t).toPromise();n.length&&i.push(n[0])}}switch(t){case An.DOWNLOADED.valueOf():i=i.filter(e=>e[St.COLUMN_NAME_CONTENT_STATE]=Nn.ARTIFACT_AVAILABLE);break;case An.SPINE.valueOf():i=i.filter(e=>e[St.COLUMN_NAME_CONTENT_STATE]=Nn.ONLY_SPINE);break;case An.ALL.valueOf():}return i}))}getChildIdentifiersFromManifest(e){return bo(this,void 0,void 0,(function*(){const t="file:///"+e,n=[];return yield this.fileService.readAsText(t,Ln.MANIFEST.valueOf()).then(e=>bo(this,void 0,void 0,(function*(){console.log("fileContents",JSON.parse(e));const t=JSON.parse(e).archive.items;return t.shift(),t.forEach(e=>{n.push(e.identifier)}),n}))).catch(e=>{console.log("getChildIdentifiersFromManifest err",e)}),n}))}}class Mo{static getFileExtension(e){const t=e.substring(e.lastIndexOf(".")+1,e.length);return t||""}static getFileName(e){return e.substring(e.lastIndexOf("/")+1)}static getParentDir(e){return e.substr(0,e.lastIndexOf("/",e.length-2)).concat("/")}static getDirectoryName(e){const t=e.split("/");return t[t.length-2]}static getTempDirPath(e){return e+"/tmp"}static isFreeSpaceAvailable(e,t,n){let r=10240;return n>0&&(r=n),e>0&&e>t+r}static getDirecory(e){return e.substr(0,e.lastIndexOf("/"))}}var Ro=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Lo{constructor(e,t,n){this.dbService=e,this.fileService=t,this.sharedPreferences=n,this.updateNewContentModels=[],this.fileMapList=[]}deleteAllChildren(e,t){return Ro(this,void 0,void 0,(function*(){let n=!1;const r=kn.getBasePath(e[St.COLUMN_NAME_PATH]);yield this.fileService.readAsText(r,Ln.MANIFEST.valueOf()).then(e=>Ro(this,void 0,void 0,(function*(){const r=JSON.parse(e).archive.items;r.shift();const i=[];r.forEach(e=>{i.push(e.identifier)});(yield this.findAllContentsFromDbWithIdentifiers(i)).forEach(e=>Ro(this,void 0,void 0,(function*(){yield this.deleteOrUpdateContent(e,!0,t),n=!0;const r=e[St.COLUMN_NAME_PATH];if(r&&n){if(kn.getFirstPartOfThePathNameOnLastDelimiter(r))try{this.sharedPreferences.putString(S.KEY_LAST_MODIFIED,(new Date).getMilliseconds()+"").toPromise()}catch(e){console.log("Error",e)}}})))}))).catch(e=>{console.log("fileread err",e)});const i=yield this.getMetaData(this.fileMapList);if(this.updateNewContentModels.length){this.dbService.beginTransaction();for(const e of this.updateNewContentModels){const t=e,n=t[St.COLUMN_NAME_IDENTIFIER];let r=0;i&&(r=i[n]?i[n].size:0),t[St.COLUMN_NAME_SIZE_ON_DEVICE]=r,yield this.dbService.update({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[n],modelJson:t}).toPromise()}this.dbService.endTransaction(!0)}}))}deleteOrUpdateContent(e,t,n){return Ro(this,void 0,void 0,(function*(){let r,i=e[St.COLUMN_NAME_REF_COUNT],o=e[St.COLUMN_NAME_VISIBILITY];const s=e[St.COLUMN_NAME_MIME_TYPE],a=e[St.COLUMN_NAME_PATH];if(n?(i>1&&o===Cn.DEFAULT.valueOf()&&(i-=1,o=Cn.PARENT.valueOf()),r=s===Tn.COLLECTION?Nn.ARTIFACT_AVAILABLE.valueOf():Nn.ONLY_SPINE.valueOf()):(s===Tn.COLLECTION.valueOf()&&i>1||i>1&&t?r=Nn.ARTIFACT_AVAILABLE.valueOf():(o===Cn.DEFAULT.valueOf()&&(o=Cn.PARENT.valueOf()),r=Nn.ONLY_SPINE.valueOf()),i-=1),a){if(r===Nn.ONLY_SPINE.valueOf()){const t=e[St.COLUMN_NAME_LOCAL_DATA],n=t&&JSON.parse(t);let r="",i="";t&&(r=n.appIcon?Mo.getFileName(n.appIcon):"",i=n.itemSetPreviewUrl?Mo.getFileName(n.itemSetPreviewUrl):""),this.rm(kn.getBasePath(a),[r,i].join(":"))}if(e[St.COLUMN_NAME_VISIBILITY]=o,e[St.COLUMN_NAME_REF_COUNT]=kn.addOrUpdateRefCount(i),e[St.COLUMN_NAME_CONTENT_STATE]=r,t){const t={};t.identifier=e[St.COLUMN_NAME_IDENTIFIER],t.path=kn.getBasePath(a),this.fileMapList.push(t),this.updateNewContentModels.push(e)}else e[St.COLUMN_NAME_SIZE_ON_DEVICE]=0,yield this.dbService.update({table:St.TABLE_NAME,modelJson:e,selection:St.COLUMN_NAME_IDENTIFIER+" =?",selectionArgs:[e[St.COLUMN_NAME_IDENTIFIER]]}).pipe(Object(D.map)(e=>e>0)).toPromise()}}))}findAllContentsFromDbWithIdentifiers(e){const t=wn.joinPreservingQuotes(e),n=` WHERE ${St.COLUMN_NAME_IDENTIFIER} IN (${t}) AND ${St.COLUMN_NAME_REF_COUNT} > 0`,r=`SELECT * FROM ${St.TABLE_NAME} ${n}`;return this.dbService.execute(r).toPromise()}rm(e,t){return new Promise((n,r)=>{try{sbutility.rm(e,t,e=>{n(e)},e=>{console.error(e),r(!1)})}catch(e){console.error(e),r(!1)}})}getMetaData(e){return Ro(this,void 0,void 0,(function*(){return new Promise((t,n)=>{sbutility.getMetaData(e,e=>{t(e)},e=>{console.error(e),n(e)})})}))}}var Po=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Do{constructor(e,t,n){this.appConfig=e,this.contentServiceConfig=t,this.telemetryService=n}getSearchCriteria(e){const t=e.request,n=t.query,r=t.exists,i=t.limit,o=t.offset;let s;t.hasOwnProperty("mode")&&"soft"===t.mode&&(s="soft");const a=[];if(t.hasOwnProperty("sort_by")){const e=t.sort_by;Object.keys(e).forEach(t=>{const n={sortAttribute:t,sortOrder:this.getSortOrder(String(e[t]))};a.push(n)})}const c=Object.assign(Object.assign(Object.assign({},n?{query:n}:{}),r?{exists:r}:{}),{mode:s,sortCriteria:a,searchType:this.getSearchType(String(t.searchType)),offset:o||0,limit:i||100});let u,l,d,h;if(t.hasOwnProperty("filters")){const e=t.filters;e.contentType&&(u=e.contentType),e.primaryCategory&&(l=e.primaryCategory),d=this.mapFilterValues(e,c),c.impliedFilters=d,c.contentTypes=u,c.primaryCategories=l}return t.hasOwnProperty("facets")&&(h=t.facets,c.facets=h),c}getSearchContentRequest(e){return{query:e.query,offset:e.offset,limit:e.limit,mode:e.mode,exists:e.exists&&e.exists.length>0?e.exists:[],facets:e.facets&&e.facets.length>0?e.facets:[],sort_by:this.getSortByRequest(e.sortCriteria),filters:this.getSearchFilter(e),fields:e.fields}}getSearchFilter(e){return e.searchType.valueOf()===gn.SEARCH.valueOf()?this.getSearchRequest(e):e.searchType.valueOf()===gn.FILTER.valueOf()?this.getFilterRequest(e):{}}getFilterRequest(e){let t={};return this.addFiltersToRequest(t,e.facetFilters),this.addFiltersToRequest(t,e.impliedFilters),e.impliedFiltersMap&&e.impliedFiltersMap.length>0&&e.impliedFiltersMap.forEach(e=>{t=Object.assign(Object.assign({},t),e)}),t}addFiltersToRequest(e,t){t&&t.length&&t.forEach(t=>{const n=[];if(t.values.forEach(e=>{e.apply&&n.push(e.name)}),n.length){let r=t.name;if(t.alternative)switch(t.name){case"board":r="se_boards";break;case"medium":r="se_mediums";break;case"gradeLevel":case"grade":r="se_gradeLevels"}e[r]=n}})}getSearchRequest(e){const t=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({audience:e.audience&&e.audience.length>0?e.audience:[],status:e.contentStatusArray,objectType:["Content","QuestionSet"],contentType:e.contentTypes&&e.contentTypes.length>0?e.contentTypes:[],primaryCategory:e.primaryCategories&&e.primaryCategories.length>0?e.primaryCategories:[]},e.keywords&&e.keywords.length?{keywords:e.keywords}:{}),e.dialCodes&&e.dialCodes.length?{dialcodes:e.dialCodes}:{}),e.createdBy&&e.createdBy.length?{createdBy:e.createdBy}:{}),e.grade&&e.grade.length?{se_gradeLevels:e.grade}:{}),{se_mediums:e.medium&&e.medium.length>0?e.medium:[],se_boards:e.board&&e.board.length>0?e.board:[],language:e.language&&e.language.length>0?e.language:[],topic:e.topic&&e.topic.length>0?e.topic:[],purpose:e.purpose&&e.purpose.length>0?e.purpose:[],channel:e.channel&&e.channel.length>0?e.channel:[],mimeType:e.mimeType&&e.mimeType.length>0?e.mimeType:[],subject:e.subject&&e.subject.length>0?e.subject:[]});return e.impliedFiltersMap&&e.impliedFiltersMap.forEach(e=>{Object.keys(e).forEach(n=>{t[n]=e[n]})}),e.impliedFilters&&e.impliedFilters.forEach(e=>{Object.keys(e).forEach(n=>{const r=e.values,i=e.name,o=this.getImpliedFilterValues(r);if(t[i]||(t[i]=[]),t[i]){const e=t[i].concat(o);e&&(t[i]=e.filter((t,n)=>e.indexOf(t)===n))}})}),t}getImpliedFilterValues(e){const t=[];return e?(e.forEach(e=>{e.apply&&t.push(e.name)}),t):[]}getSortByRequest(e){return e?e.reduce((e,t)=>(e[t.sortAttribute]=t.sortOrder,e),{}):{}}createFilterCriteria(e,t,n){const r=[],i={query:e.query,limit:e.limit,offset:e.offset,facets:e.facets,contentTypes:e.contentTypes,primaryCategories:e.primaryCategories,sortCriteria:e.sortCriteria&&e.sortCriteria.length?e.sortCriteria:[],mode:"soft"===e.mode?"soft":"hard"};return t?(t.forEach(e=>{const t=n?n[e.name]:[],i=e.values,o=this.getSortedFilterValuesWithAppliedFilters(i,t);if(e.name){const t={name:e.name,values:o};r.push(t)}delete n[e.name]}),i.facetFilters=r,i.impliedFilters=this.mapFilterValues(n,i),i):i}addFilterValue(e,t){e&&e.length>0&&e.forEach(e=>{const n=e.name;e.values,t[n]})}getFilterValuesWithAppliedFilter(e,t){return e.forEach(e=>{let n=!1;t&&t.indexOf(name)>-1&&(n=!0),e.apply=n}),e}mapSearchResponse(e,t,n){const r=(t.result.content||[]).concat(t.result.QuestionSet||[]);return{id:t.id,responseMessageId:t.params.resmsgid,filterCriteria:this.createFilterCriteria(e,t.result.facets,n.filters),request:n,contentDataList:r,count:t.result.count,collectionDataList:t.result.collections?t.result.collections:[]}}getContentSearchFilter(e,t,n=[]){return{filters:{identifier:e.filter((t,n)=>e.indexOf(t)===n),status:t,objectType:["Content"]},fields:[...n,"downloadUrl","variants","mimeType","contentType","primaryCategory","pkgVersion"]}}getDownloadUrl(e,t){return Po(this,void 0,void 0,(function*(){let n,r,i;try{i=e.variants&&"string"==typeof e.variants?JSON.parse(e.variants):e.variants}catch(t){i=e.variants}if(e.mimeType===Tn.COLLECTION.valueOf()?i&&i.online?r="online":i&&i.spine&&(r="spine"):e.mimeType===Tn.QUESTION_SET&&(i&&i.full?r="full":i&&i.online&&(r="online")),i&&r&&i[r]){const o=i[r];n=o&&o.ecarUrl,yield this.buildContentLoadingEvent(r,t,e.primaryCategory||e.contentType,e.pkgVersion)}return n||(n=e.downloadUrl.trim(),yield this.buildContentLoadingEvent("full",t,e.primaryCategory||e.contentType,e.pkgVersion)),n}))}buildContentLoadingEvent(e,t,n,r){const i=new Ie;return i.type=oe.OTHER,i.subType=e,i.pageId="ImportContent",i.id="ImportContent",i.objId=t.contentId,i.objType=n,i.objVer=r,i.rollup=t.rollUp,i.correlationData=t.correlationData,this.telemetryService.interact(i).toPromise()}getSortOrder(e){let t;return t="asc"===e?On.ASC:On.DESC,t}getSearchType(e){let t;return t="search"===e?gn.SEARCH:"filter"===e?gn.FILTER:gn.SEARCH,t}getSortedFilterValuesWithAppliedFilters(e,t){return e.forEach(e=>{let n=!1;t&&t.forEach(t=>{t&&e.name&&e.name.toLowerCase()===t.toLowerCase()&&(n=!0)}),e.apply=n,e.count=fe.parseInt(e.count)}),e}mapFilterValues(e,t){const n=[],r=[];return Object.keys(e).forEach(t=>{const i=e[t];if(Array.isArray(i)&&i.length){const e=[];i.forEach(t=>{const n={name:t,apply:!0};e.push(n)}),n.push({name:t,values:e})}else if(i){const e={};e[t]=i,r.push(e)}}),t.impliedFiltersMap=r,n}}class wo{getAllLocalContentQuery(e){e.primaryCategories&&e.primaryCategories.length||(e.primaryCategories=["Course","Learning Resource","Explanation Content","Teacher Resource","Content Playlist","Digital Textbook","Practice Question Set","eTextBook","Course Assessment"]);const t=e.uid,n=e.resourcesOnly?"":`c.${St.COLUMN_NAME_VISIBILITY} = '${Cn.DEFAULT.valueOf()}' AND`,r=`c.${St.COLUMN_NAME_CONTENT_STATE} = '${Nn.ARTIFACT_AVAILABLE.valueOf()}'`;let i=`${n} ${r}`;if(e.resourcesOnly){i=`${i} AND (${`c.${St.COLUMN_NAME_MIME_TYPE} != '${Tn.COLLECTION.valueOf()}'`})`}else{const t=wn.joinPreservingQuotes(e.primaryCategories);i=`${i} AND (${`c.${St.COLUMN_NAME_PRIMARY_CATEGORY} IN(${t.toLowerCase()})`})`}const o=this.getAudienceFilter(e.audience),s=this.getPragmaFilter(e.exclPragma,e.pragma),a=this.generateFieldMatchQuery(e);o&&(i=`${i} AND (${o})`),s&&(i=`${i} AND (${s})`),a&&(i=`${i} AND (${a})`);let c=`WHERE (${i})`,u="";const l=e.resourcesOnly?"":this.generateSortByQuery(e.sortCriteria,t);return e.recentlyViewed?t&&(i=e.localOnly?`ca.${At.COLUMN_NAME_UID} = '${t}' AND ${r}\n AND cm.${St.COLUMN_NAME_MIME_TYPE} NOT IN ('${Tn.COLLECTION.valueOf()}', '')`:`ca.${At.COLUMN_NAME_UID} = '${t}'\n AND cm.${St.COLUMN_NAME_MIME_TYPE} NOT IN ('${Tn.COLLECTION.valueOf()}', '')`,c=`WHERE (${i})`,u=this.getRecentlyViewedQuery(c,l,e.limit)):u=t?this.getLocalOnlyQuery(c,l,t):`SELECT c.* FROM ${St.TABLE_NAME} c ${c} ${l}`,u}getAudienceFilter(e){let t="";return e&&e.forEach(e=>{t=t.concat(t.length>0?" OR ":"",`c.${St.COLUMN_NAME_AUDIENCE} LIKE '%%${e}%%'`)}),t}getPragmaFilter(e,t){let n="";return e?e.forEach(e=>{n=n.concat(n.length>0?" OR ":"",`c.${St.COLUMN_NAME_PRAGMA} NOT LIKE '%%${e}%%'`)}):t&&t.forEach(e=>{n=n.concat(n.length>0?" OR ":"",`c.${St.COLUMN_NAME_PRAGMA} LIKE '%%${e}%%'`)}),n}getRecentlyViewedQuery(e,t,n){return`SELECT c.*, ca.${At.COLUMN_NAME_EPOCH_TIMESTAMP},\n cm.${vt.COLUMN_NAME_DATA} FROM ${At.TABLE_NAME} ca LEFT JOIN\n ${vt.TABLE_NAME} cm ON\n (cm.${vt.COLUMN_NAME_UID} = ca.${At.COLUMN_NAME_UID}\n AND cm.${vt.COLUMN_NAME_CONTENT_IDENTIFIER} = ca.${At.COLUMN_NAME_CONTENT_IDENTIFIER})\n LEFT JOIN ${St.TABLE_NAME} c ON\n c.${St.COLUMN_NAME_IDENTIFIER} = ca.${At.COLUMN_NAME_CONTENT_IDENTIFIER}\n ${e} ${t} LIMIT ${n}`}getLocalOnlyQuery(e,t,n){let r="";return r=Array.isArray(n)?`ca.${At.COLUMN_NAME_UID} IN (${wn.joinPreservingQuotes(n)})`:`ca.${At.COLUMN_NAME_UID} ='${n}'`,`SELECT c.*, ca.${At.COLUMN_NAME_EPOCH_TIMESTAMP}\n FROM ${St.TABLE_NAME} c LEFT JOIN ${At.TABLE_NAME} ca\n ON c.${St.COLUMN_NAME_IDENTIFIER} = ca.${At.COLUMN_NAME_CONTENT_IDENTIFIER}\n AND ${r}\n ${e} ${t}`}generateSortByQuery(e,t){let n="",r=0;return e||((e=[]).push({sortAttribute:"lastUsedOn",sortOrder:On.DESC}),e.push({sortAttribute:"localLastUpdatedOn",sortOrder:On.DESC})),e.forEach(e=>{e&&("lastUsedOn"===e.sortAttribute.valueOf()&&t?(n=this.generateOrderByQuery(r,n," ca."+At.COLUMN_NAME_EPOCH_TIMESTAMP,e.sortOrder.valueOf()),r++):"localLastUpdatedOn"===e.sortAttribute.valueOf()?(n=this.generateOrderByQuery(r,n," c."+St.COLUMN_NAME_LOCAL_LAST_UPDATED_ON,e.sortOrder.valueOf()),r++):"sizeOnDevice"===e.sortAttribute.valueOf()&&(n=this.generateOrderByQuery(r,n," c."+St.COLUMN_NAME_SIZE_ON_DEVICE,e.sortOrder.valueOf()),r++))}),n}generateOrderByQuery(e,t,n,r){let i="";return i=e>0?t.concat(","):t.concat("ORDER BY"),i=i.concat(`${n} ${r}`),i}generateFieldMatchQuery(e){return[{field:"board",column:St.COLUMN_NAME_BOARD},{field:"medium",column:St.COLUMN_NAME_MEDIUM},{field:"grade",column:St.COLUMN_NAME_GRADE},{field:"dialcodes",column:St.COLUMN_NAME_DIALCODES},{field:"childNodes",column:St.COLUMN_NAME_CHILD_NODES}].reduce((t,{field:n,column:r})=>(e[n]&&e[n].length&&t.push(this.generateLikeQuery(e[n],r)),t),[]).join(" AND ")}generateLikeQuery(e,t){let n="";const r=t+" LIKE ";for(let t=0;t<e.length;t++)n=t<e.length-1?n.concat(r,`'%%~${e[t].toLowerCase().trim()}~%%' OR `):n.concat(r,`'%%~${e[t].toLowerCase().trim()}~%%' `);return`(${n})`}}var Uo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},jo=St.COLUMN_NAME_LOCAL_DATA,Fo=St.COLUMN_NAME_IDENTIFIER,ko=St.COLUMN_NAME_REF_COUNT;class xo{constructor(e,t,n){this.deviceInfo=e,this.dbService=t,this.fileService=n}populateItems(e){const t=[],n=[];let r=[];const i={};e.forEach(e=>{const t=JSON.parse(e[jo]);if(i[e[Fo]]=t,kn.addViralityMetadataIfMissing(t,this.deviceInfo.getDeviceID()),kn.hasChildren(t)){const e=kn.getChildContentsIdentifiers(t);r=r.concat(e)}n.push(e[Fo])});try{n.forEach(e=>{const n=i[e];wn.contains(r,e)&&(n.visibility=Cn.PARENT.valueOf()),t.push(n)})}catch(e){console.log(e)}return t}populateItemList(e){const t=[],n=[];let r=[];const i={};e.forEach(e=>{if(i[e.identifier]=e,kn.addViralityMetadataIfMissing(e,this.deviceInfo.getDeviceID()),kn.hasChildren(e)){const t=kn.getChildContentsIdentifiers(e);r=r.concat(t)}n.push(e.identifier)});try{n.forEach(e=>{const n=i[e];wn.contains(r,e)&&(n.visibility=Cn.PARENT.valueOf()),t.push(n)})}catch(e){console.log(e)}return t}getContentExportDBModelToExport(e){return Uo(this,void 0,void 0,(function*(){let t=[];const n=yield this.findAllContentsWithIdentifiers(e),r=kn.getBasePath(n[0][St.COLUMN_NAME_PATH]);return yield this.fileService.readAsText(r,Ln.MANIFEST.valueOf()).then(e=>Uo(this,void 0,void 0,(function*(){const n=JSON.parse(e).archive.items,r=[];n.forEach(e=>{r.push(e.identifier)}),t=yield this.findAllContentsWithIdentifiers(r,!0)}))).catch(e=>{console.log("fileRead error",e)}),Promise.resolve(kn.deDupe(t,"identifier"))}))}generateManifestForArchive(e){const t={},n={ttl:24};return n.count=e.length,n.items=e,t.id=xo.EKSTEP_CONTENT_ARCHIVE,t.ver=xo.SUPPORTED_MANIFEST_VERSION,t.ts=b()().format("YYYY-MM-DDTHH:mm:ss[Z]"),t.archive=n,t}findAllContentsWithIdentifiers(e,t){let n="";t&&e.length&&(n=e.reduce((e,t,n)=>e+` WHEN '${t}' THEN ${n}`," ORDER BY CASE "+Fo)+" END");const r=wn.joinPreservingQuotes(e),i=` where ${Fo} in (${r}) AND ${ko} > 0`,o=`select * from ${St.TABLE_NAME} ${i} ${n}`;return this.dbService.execute(o).toPromise()}}xo.EKSTEP_CONTENT_ARCHIVE="ekstep.content.archive",xo.SUPPORTED_MANIFEST_VERSION="1.1";class Bo{constructor(e,t){this.dbService=e,this.exportHandler=t}execute(e){const t=new a.CsResponse,n=this.exportHandler.populateItems(e.contentModelsToExport);e.items=[],e.manifest={},e.items=e.items.concat(n);const r={ttl:24};return r.count=e.items.length,r.items=e.items,e.manifest.id=Bo.EKSTEP_CONTENT_ARCHIVE,e.manifest.ver=Bo.SUPPORTED_MANIFEST_VERSION,e.manifest.ts=b()().format(),e.manifest.archive=r,t.body=e,Promise.resolve(t)}}Bo.EKSTEP_CONTENT_ARCHIVE="ekstep.content.archive",Bo.SUPPORTED_MANIFEST_VERSION="1.1";class Vo{constructor(e,t){this.fileService=e,this.deviceInfo=t}execute(e){const t=new a.CsResponse;return this.deviceInfo.getAvailableInternalMemorySize().toPromise().then(n=>{const r=Number(n);if(r>0&&r<1048576)throw t.errorMesg=Mn.EXPORT_FAILED_MEMORY_NOT_SUFFICIENT,t;return this.fileService.writeFile(e.tmpLocationPath,Ln.MANIFEST.valueOf(),JSON.stringify(e.manifest),{replace:!0})}).then(()=>(t.body=e,Promise.resolve(t))).catch(()=>(t.errorMesg=Mn.EXPORT_FAILED_WRITING_MANIFEST,Promise.reject(t)))}}var Yo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Go{constructor(e){this.zipService=e}execute(e){return Yo(this,void 0,void 0,(function*(){const t=new a.CsResponse;for(const t of e.contentModelsToExport){const n=t,r=JSON.parse(n[St.COLUMN_NAME_LOCAL_DATA]);if(!kn.isAvailableLocally(n[St.COLUMN_NAME_CONTENT_STATE])||kn.isOnlineContent(r)||kn.isInlineIdentity(r.contentDisposition,r.contentEncoding))continue;const i=r.artifactUrl;if(i){const t=e.tmpLocationPath.concat(i),r=n[St.COLUMN_NAME_PATH],o=[],s=[];o.push(n[St.COLUMN_NAME_IDENTIFIER]),s.push(n[St.COLUMN_NAME_IDENTIFIER].concat("/",Ln.MANIFEST.valueOf())),yield new Promise((e,n)=>{this.zipService.zip(r,{target:t},o,s,()=>{e()},()=>{n()})})}}return t.body=e,Promise.resolve(t)}))}}var Ho=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class $o{constructor(e){this.fileService=e}execute(e){return Ho(this,void 0,void 0,(function*(){const t=new a.CsResponse;return this.fileService.getFreeDiskSpace().then(n=>{this.getFileSize(e.items);return t.body=e,t})}))}getFileSize(e){let t=0;return e&&e.forEach(e=>{e.size&&(t+=Number(e.size))}),t}}var qo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ko{constructor(){}execute(e){return qo(this,void 0,void 0,(function*(){const t=new a.CsResponse;try{let n=0,r=[];null!=e.subContentIds&&e.subContentIds.length>0&&(r=this.excludeContentForSubModule(e.contentModelsToExport,e.subContentIds));let i=e.contentModelsToExport;r&&r.length>0&&(i=r);for(const t of i){const r=t,i=e.items[n],o=i.appIcon,s=i.itemSetPreviewUrl;for(const t of[o,s])if(t&&!t.startsWith("https:"))try{yield this.copyFile(r[St.COLUMN_NAME_PATH],e.tmpLocationPath,t)}catch(e){console.error(e)}const a=i.contentDisposition,c=i.contentEncoding;if(kn.isInlineIdentity(a,c)){const t=i.artifactUrl;if(t)try{yield this.copyFile(r[St.COLUMN_NAME_PATH],e.tmpLocationPath,t)}catch(e){console.error(e)}}n++}return t.body=e,t}catch(e){throw t.errorMesg=Mn.EXPORT_FAILED_COPY_ASSET,t}}))}excludeContentForSubModule(e,t){const n=[];return e.forEach(e=>{const r=e.identifier;t&&t.indexOf(r)>-1&&n.push(e)}),n}copyFile(e,t,n){return qo(this,void 0,void 0,(function*(){return new Promise((r,i)=>{sbutility.copyFile(e,t,n,()=>{r(!0)},e=>{console.error(e),r(e)})})}))}}var zo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Wo{constructor(e,t){this.fileService=e,this.zipService=t}execute(e){return zo(this,void 0,void 0,(function*(){const t=new a.CsResponse;yield new Promise((n,r)=>{this.zipService.zip(e.tmpLocationPath,{target:e.ecarFilePath},[],[],()=>{n()},()=>{throw t.errorMesg=Mn.EXPORT_FAILED_ECAR_BUNDLE,t})});const n=yield this.fileService.getMetaData(e.ecarFilePath);return e.metadata[Wo.FILE_SIZE]=n.size,t.body=e,t}))}}Wo.FILE_SIZE="FILE_SIZE";var Xo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Jo{constructor(e,t){this.fileService=e,this.zipService=t,this.FILE_SIZE="FILE_SIZE"}execute(e){const t=new a.CsResponse;let n;return this.fileService.getMetaData(e.ecarFilePath).then(t=>(n=t.size,this.fileService.createDir(e.tmpLocation.concat(en.generateUniqueId()),!0))).then(r=>Xo(this,void 0,void 0,(function*(){return e.tmpLocation=r.nativeURL,yield new Promise((t,n)=>{this.zipService.unzip(e.ecarFilePath,{target:r.nativeURL},()=>{t()},e=>{n(e)})}),e.metadata={},e.metadata.FILE_SIZE=n,t.body=e,Promise.resolve(t)}))).catch(e=>(t.errorMesg=Mn.IMPORT_FAILED_EXTRACT_ECAR.valueOf(),Promise.reject(t)))}}class Qo{constructor(){this.identifierList=new Set}hierarchyToManifestConversion(e){this.identifierList=new Set,this.archive={count:0,items:[]};const t=this.reorderData(e,1);return t&&(this.archive.count+=1,this.archive.items.push(t)),e.children&&e.children.length&&this.recurssiveFunc(e.children,1),this.archive}recurssiveFunc(e,t){for(let n=0;n<e.length;n++){const r=this.reorderData(e[n],t+1,Cn.PARENT.valueOf());r&&(this.archive.count+=1,this.archive.items.push(r)),e[n].children&&e[n].children.length&&this.recurssiveFunc(e[n].children,t+1)}}reorderData(e,t,n){if(this.identifierList.has(e.identifier))return null;const r=[],i=JSON.parse(JSON.stringify(e));if(i.children&&i.children.length){for(let e=0;e<i.children.length;e++)r.push({name:i.children[e].name,identifier:i.children[e].identifier,objectType:i.children[e].objectType,depth:t,index:e});i.children=r}return i.visibility=n||i.visibility,this.identifierList.add(i.identifier),i}}var Zo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class es{constructor(e,t,n,r){this.fileService=e,this.dbService=t,this.appConfig=n,this.getContentDetailsHandler=r}execute(e){return Zo(this,void 0,void 0,(function*(){const t=new a.CsResponse;let n;try{if(n=yield this.fileService.readAsText(e.tmpLocation,Ln.HIERARCHY.valueOf()),n){const e=JSON.parse(n);e.archive=(new Qo).hierarchyToManifestConversion(e.content),delete e.content,n=JSON.stringify(e)}}catch(t){console.log("err validating ecar",t),n=yield this.fileService.readAsText(e.tmpLocation,Ln.MANIFEST.valueOf())}if(!n)throw t.errorMesg=Mn.IMPORT_FAILED_MANIFEST_FILE_NOT_FOUND.valueOf(),yield this.fileService.removeRecursively(e.tmpLocation),console.log("response in err",t),t;const r=JSON.parse(n);if(1===r.ver)throw t.errorMesg=Mn.IMPORT_FAILED_UNSUPPORTED_MANIFEST.valueOf(),yield this.fileService.removeRecursively(e.tmpLocation),t;const i=r.archive;if(!i.items)throw t.errorMesg=Mn.IMPORT_FAILED_NO_CONTENT_METADATA.valueOf(),yield this.fileService.removeRecursively(e.tmpLocation),t;e.manifestVersion=r.ver,e.items=[];const o=i.items,s=[];for(const e of o){const t=e.identifier;s.push(t)}const c=wn.joinPreservingQuotes(s),u=(yield this.getContentDetailsHandler.fetchFromDBForAll(c).toPromise()).reduce((e,t)=>(e[t.identifier]=t,e),{});let l=!1;e.existedContentIdentifiers={};for(const t of o){const n=t,r=n.identifier,i=kn.readVisibility(n),s=n.status,a=kn.isDraftContent(s);if(a&&kn.isExpired(n.expires)){this.skipContent(e,r,i,In.CONTENT_EXPIRED,o);continue}i===Cn.DEFAULT.valueOf()&&(l=!1);const c=u[r];let d;if(c){const t=c[St.COLUMN_NAME_REF_COUNT];if(d=c[St.COLUMN_NAME_PATH],d&&i===Cn.DEFAULT.valueOf()&&t&&t>0){l=!0;const t=JSON.parse(c[St.COLUMN_NAME_LOCAL_DATA]);t&&n.pkgVersion>t.pkgVersion&&t.childNodes&&t.childNodes.length>0&&(e.contentIdsToDelete=new Set(t.childNodes))}}d&&i===Cn.DEFAULT.valueOf()&&!kn.isDuplicateCheckRequired(a,n.pkgVersion)&&kn.isImportFileExist(c,n)?(e.rootIdentifier=r,this.skipContent(e,r,i,In.ALREADY_EXIST,o)):(l&&e.contentIdsToDelete.delete(r)&&(e.existedContentIdentifiers[r]=!0),e.items.push(n))}return t.body=e,t}))}skipContent(e,t,n,r,i){n===Cn.DEFAULT&&(r===In.ALREADY_EXIST?i&&1===i.length&&e.contentImportResponseList.push({identifier:t,status:r}):e.contentImportResponseList.push({identifier:t,status:r})),e.skippedItemsIdentifier.push(t)}}var ts=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ns{constructor(e,t,n){this.dbService=e,this.sharedPreferences=t,this.fileService=n}execute(){return this.updateAllRootContentSize().toPromise()}findAllChildContents(e){const t=`SELECT * FROM ${St.TABLE_NAME}\n WHERE ${St.COLUMN_NAME_IDENTIFIER} IN (${wn.joinPreservingQuotes(e)})\n AND ${St.COLUMN_NAME_REF_COUNT} > 0`;return this.dbService.execute(t).toPromise()}updateAllRootContentSize(){const e=`SELECT * FROM ${St.TABLE_NAME} WHERE ${St.COLUMN_NAME_REF_COUNT} > 0\n AND ${St.COLUMN_NAME_VISIBILITY} = '${Cn.DEFAULT.valueOf()}'`;return this.dbService.execute(e).pipe(Object(D.tap)(()=>ts(this,void 0,void 0,(function*(){return this.sharedPreferences.putBoolean(S.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,!1).toPromise()}))),Object(D.mergeMap)(e=>ts(this,void 0,void 0,(function*(){const t=[];yield Promise.all(e.map(e=>ts(this,void 0,void 0,(function*(){let n=yield this.getSizeOnDevice(e);const r=JSON.parse(e[St.COLUMN_NAME_LOCAL_DATA]).childNodes;if(r){(yield this.findAllChildContents(r)).forEach(e=>{n+=e[St.COLUMN_NAME_SIZE_ON_DEVICE]||0}),e[St.COLUMN_NAME_SIZE_ON_DEVICE]=n,t.push(e)}})))),this.updateInDb(t)}))),Object(D.tap)(()=>ts(this,void 0,void 0,(function*(){return this.sharedPreferences.putBoolean(S.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,!0).toPromise()}))))}getSizeOnDevice(e){return ts(this,void 0,void 0,(function*(){let t=0;if(e[St.COLUMN_NAME_MIME_TYPE]===Tn.COLLECTION.valueOf()){if(e[St.COLUMN_NAME_VISIBILITY]===Cn.DEFAULT.valueOf()){const n=[],r={},i=e[St.COLUMN_NAME_IDENTIFIER];r.identifier=i,r.path=e[St.COLUMN_NAME_PATH],n.push(r);const o=yield this.getMetaData(n);t=o[i]?o[i].size:0}}else t=e[St.COLUMN_NAME_SIZE_ON_DEVICE]?e[St.COLUMN_NAME_SIZE_ON_DEVICE]:0;return Promise.resolve(t||0)}))}updateInDb(e){return ts(this,void 0,void 0,(function*(){this.dbService.beginTransaction();for(const t of e){const e=t,n=e[St.COLUMN_NAME_IDENTIFIER];this.dbService.update({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[n],modelJson:e}).toPromise()}this.dbService.endTransaction(!0)}))}getMetaData(e){return ts(this,void 0,void 0,(function*(){return new Promise((t,n)=>{sbutility.getMetaData(e,e=>{t(e)},e=>{console.error(e),n(e)})})}))}updateTextBookSize(e){console.log("in updateAllRootContentSize");const t=`SELECT * FROM ${St.TABLE_NAME} WHERE ${St.COLUMN_NAME_IDENTIFIER} == ${e}`;return this.dbService.execute(t).pipe(Object(D.tap)(()=>ts(this,void 0,void 0,(function*(){return this.sharedPreferences.putBoolean(S.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,!1).toPromise()}))),Object(D.mergeMap)(e=>ts(this,void 0,void 0,(function*(){const t=[];yield Promise.all(e.map(e=>ts(this,void 0,void 0,(function*(){let n=yield this.getSizeOnDevice(e);const r=JSON.parse(e[St.COLUMN_NAME_LOCAL_DATA]).childNodes;if(r){(yield this.findAllChildContents(r)).forEach(e=>{n+=e[St.COLUMN_NAME_SIZE_ON_DEVICE]||0}),e[St.COLUMN_NAME_SIZE_ON_DEVICE]=n,t.push(e)}})))),this.updateInDb(t)}))),Object(D.tap)(()=>ts(this,void 0,void 0,(function*(){return this.sharedPreferences.putBoolean(S.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,!0).toPromise()}))))}}var rs=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},is=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,i){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,i,(t=e[n](t)).done,t.value)}))}}},os=St.COLUMN_NAME_VISIBILITY;class ss{constructor(e,t,n,r,i,o,s,a){this.fileService=e,this.zipService=t,this.appConfig=n,this.dbService=r,this.deviceInfo=i,this.getContentDetailsHandler=o,this.eventsBusService=s,this.sharedPreferences=a}execute(e){return rs(this,void 0,void 0,(function*(){const t=new a.CsResponse;e.identifiers=[];const n=[],r=[],i=new Map,o=new Map;let s,c=0;this.postImportProgressEvent(c,e.items.length);const u=[],l=[],d=[];for(const t of e.items){const e=t,n=e.identifier,r=kn.readVisibility(e),i=e.appIcon;kn.isNotUnit(e.mimeType,r)&&(l.push(n),i&&!i.startsWith("https:")&&d.push(n+"/"+i.substring(0,i.lastIndexOf("/")))),u.push(n)}const h=kn.getContentRootDir(e.destinationFolder);let E;E=e.items[0].mimeType===Tn.QUESTION_SET?yield this.segregateQuestions(h,JSON.parse(JSON.stringify(e.items))):yield this.createDirectories(h,l);yield this.createDirectories(h,d);const f=wn.joinPreservingQuotes(u),p=(yield this.getContentDetailsHandler.fetchFromDBForAll(f).toPromise()).reduce((e,t)=>(e[t.identifier]=t,e),{});for(const t of e.items){let a=t;const u=a.identifier;if(e.skippedItemsIdentifier&&e.skippedItemsIdentifier.indexOf(u)>-1)continue;const l=a.mimeType,d=a.contentEncoding,h=a.contentDisposition,f=kn.readContentType(a),_=kn.readPrimaryCategory(a);let O=kn.readVisibility(a);const S=kn.readAudience(a),g=kn.readPragma(a),A=a.pkgVersion,N=a.artifactUrl,T=a.appIcon,C=a.itemSetPreviewUrl,v=a.board,y=a.medium,m=a.gradeLevel,b=a.dialcodes,I=a.childNodes;let M,R=Nn.ONLY_SPINE.valueOf();const L=p[u];let P,D;if(L&&(P=kn.getBasePath(L[St.COLUMN_NAME_PATH])),O===Cn.DEFAULT.valueOf()&&(D=u),kn.isNotUnit(l,O))if(E[u]&&E[u].path)M="ios"===window.device.platform.toLowerCase()?E[u].path.concat("/"):E[u].path;else{let t="ios"===window.device.platform.toLowerCase()?kn.getContentRootDir(e.destinationFolder).concat(u):kn.getContentRootDir(e.destinationFolder).concat("/",u);const n=yield this.fileService.createDir(t,!1);M=n.nativeURL}let w=!1,U=kn.doesContentExist(L,u,A,!1);if(U=!1,U&&a.status!==vn.DRAFT.valueOf())L[os]===Cn.DEFAULT.valueOf()&&(a=JSON.parse(L[St.COLUMN_NAME_LOCAL_DATA]));else{if(U=!1,N){if(!kn.isInlineIdentity(h,d)&&l===Tn.EPUB)try{yield this.copyAssets(e.tmpLocation,N,M),w=!0}catch(e){w=!1}if(!h||!d||h===mn.INLINE.valueOf()&&d===yn.GZIP.valueOf()){const t=e.tmpLocation.concat(N);yield new Promise((e,n)=>{this.zipService.unzip(t,{target:M},()=>{w=!0,e()},()=>{e()})})}else if(kn.isInlineIdentity(h,d))try{yield this.copyAssets(e.tmpLocation,N,M),w=!0}catch(e){w=!1}else mn.ONLINE.valueOf()===h&&(w=!0)}if(R=w||this.shouldDownloadQuestionSet(e.items,a)||Tn.COLLECTION.valueOf()===l?Nn.ARTIFACT_AVAILABLE.valueOf():Nn.ONLY_SPINE.valueOf(),kn.isNotUnit(l,O))try{T.startsWith("https:")||this.copyAssets(e.tmpLocation,T,M,!0)}catch(e){}try{C.startsWith("https:")||this.copyAssets(e.tmpLocation,C,M,!1)}catch(e){}}const j=this.getBasePath(M,U,P);O===Cn.DEFAULT.valueOf()?(s=j,e.rootIdentifier=u):kn.isNotUnit(l,O)&&e.identifiers.push(u);const F=this.getReferenceCount(L,O,e.isChildContent,e.existedContentIdentifiers);O=this.getContentVisibility(L,a.objectType,e.isChildContent,O),kn.addOrUpdateViralityMetadata(a,this.deviceInfo.getDeviceID().toString());const k=0;kn.isNotUnit(l,O)&&o.set(u,M);const x=this.constructContentDBModel(u,e.manifestVersion,JSON.stringify(a),l,f,O,j,F,R,S,g,k,v,y,m,b,I,_);if(L){this.getContentState(L,R)===Nn.ONLY_SPINE.valueOf()||w||Tn.COLLECTION.valueOf()===l?r.push(x):x[St.COLUMN_NAME_CONTENT_STATE]=this.getContentState(L,R)}else n.push(x);i.set(u,x),c++,c%20!=0&&c!==e.items.length||this.postImportProgressEvent(c,e.items.length)}this.updateContentDB(n,r);const _=setTimeout(()=>{this.updateContentFileSizeInDB(e,i,o,p)},5e3);if(s)try{yield this.fileService.copyFile(e.tmpLocation,Ln.MANIFEST.valueOf(),s,Ln.MANIFEST.valueOf())}catch(e){console.log("Exception Raised During Import")}return t.body=e,Promise.resolve([t,_])}))}updateContentFileSizeInDB(e,t,n,r){return rs(this,void 0,void 0,(function*(){const i=[];for(const o of e.items){const e=o.identifier,s=t.get(e).mimeType,a=t.get(e).visibility,c=n.get(e);let u=0;r[e];if(kn.isNotUnit(s,a))try{u=yield this.fileService.getDirectorySize(c),t.get(e).size_on_device=u,i.push(t.get(e))}catch(e){}}this.updateContentDB([],i,!0)}))}updateContentDB(e,t,n){return rs(this,void 0,void 0,(function*(){if(e=e&&e.length?this.filterQuestionSetContent(e):e,t=t&&t.length?this.filterQuestionSetContent(t):t,e.length||t.length){this.dbService.beginTransaction();for(const t of e){const e=t;yield this.dbService.insert({table:St.TABLE_NAME,modelJson:e}).toPromise()}for(const e of t){const t=e;yield this.dbService.update({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[St.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise()}this.dbService.endTransaction(!0)}n&&new ns(this.dbService,this.sharedPreferences,this.fileService).execute()}))}copyAssets(e,t,n,r){return rs(this,void 0,void 0,(function*(){console.log("tempLocationPath-",e),console.log("asset-",t),console.log("payloadDestinationPath-",n),console.log("useSubDirectories-",r),console.log("FileUtil.getFileName(asset),-",Mo.getFileName(t));try{if(t&&!t.startsWith("http://")&&!t.startsWith("https://")){let i=t.substring(0,t.lastIndexOf("/"));if(!r){let e=yield this.fileService.createDir(n.concat(i),!1);console.log("createRe-",e)}"ios"===window.device.platform.toLowerCase()&&(yield this.fileService.exists(n.concat("/",t)).then(e=>{e&&this.fileService.removeFile(n.concat("/",t)).then()}).catch(e=>{console.log("Error =>",e)}));let o=yield Mo.getFileName(t),s="";try{s=yield this.fileService.exists(e.concat(o))}catch(e){s=""}console.log("pathExist-",s),""!==s?yield this.fileService.copyFile(e.concat(o),o,n.concat(i),o):yield this.fileService.copyFile(e.concat(i),Mo.getFileName(t),n.concat(i),Mo.getFileName(t))}}catch(e){throw console.error("Cannot Copy Asset---000011---",e),e}}))}getContentVisibility(e,t,n,r){let i;return"Library"===t?i=Cn.PARENT.valueOf():e&&(n||Cn.PARENT.valueOf()!==e[os])&&(i=e[os]),i||r}getContentState(e,t){return e&&e[St.COLUMN_NAME_CONTENT_STATE]>t&&(t=e[St.COLUMN_NAME_CONTENT_STATE]),t}getBasePath(e,t,n){let r;return r=e&&!t?e:n,r}getReferenceCount(e,t,n,r){let i;if(e){i=e[St.COLUMN_NAME_REF_COUNT];(r?r[e[St.COLUMN_NAME_IDENTIFIER]]:void 0)||n||Cn.DEFAULT.valueOf()===e[os]&&Cn.DEFAULT.valueOf()===t||(i+=1)}else i=1;return i}postImportProgressEvent(e,t){this.eventsBusService.emit({namespace:M.CONTENT,event:{type:Pn.IMPORT_PROGRESS,payload:{totalCount:t,currentCount:e}}})}constructContentDBModel(e,t,n,r,i,o,s,a,c,u,l,d,h,E,f,p,_,O){return{[St.COLUMN_NAME_IDENTIFIER]:e,[St.COLUMN_NAME_SERVER_DATA]:"",[St.COLUMN_NAME_PATH]:kn.getBasePath(s),[St.COLUMN_NAME_REF_COUNT]:a,[St.COLUMN_NAME_CONTENT_STATE]:c,[St.COLUMN_NAME_SIZE_ON_DEVICE]:d,[St.COLUMN_NAME_MANIFEST_VERSION]:t,[St.COLUMN_NAME_LOCAL_DATA]:n,[St.COLUMN_NAME_MIME_TYPE]:r,[St.COLUMN_NAME_CONTENT_TYPE]:i,[St.COLUMN_NAME_VISIBILITY]:o,[St.COLUMN_NAME_AUDIENCE]:u,[St.COLUMN_NAME_PRAGMA]:l,[St.COLUMN_NAME_LOCAL_LAST_UPDATED_ON]:b()(Date.now()).format(),[St.COLUMN_NAME_BOARD]:kn.getContentAttribute(h),[St.COLUMN_NAME_MEDIUM]:kn.getContentAttribute(E),[St.COLUMN_NAME_GRADE]:kn.getContentAttribute(f),[St.COLUMN_NAME_DIALCODES]:kn.getContentAttribute(p),[St.COLUMN_NAME_CHILD_NODES]:kn.getContentAttribute(_),[St.COLUMN_NAME_PRIMARY_CATEGORY]:O}}createDirectories(e,t){return rs(this,void 0,void 0,(function*(){return new Promise((n,r)=>{e="ios"===window.device.platform.toLowerCase()?e.concat("/"):e,sbutility.createDirectories(kn.getBasePath(e),t,e=>{n(e)},e=>{console.error(e),r(e)})})}))}filterQuestionSetContent(e){return e.filter(e=>e.mimeType!==Tn.QUESTION&&e.mime_type!==Tn.QUESTION)}segregateQuestions(e,t){var n,r;return rs(this,void 0,void 0,(function*(){let i={};for(let e=0;e<t.length;e++)t[e].mimeType!==Tn.QUESTION_SET||i[t[e].identifier]?t[e].mimeType===Tn.QUESTION&&(i[t[e].parent]?i[t[e].parent].push(t[e].identifier):i[t[e].identifier]=[t[e].identifier]):i[t[e].identifier]=[];const o=Object.keys(i);let s=yield this.createDirectories(e,o);const a=[];for(const t in i)a.push({idArr:i[t],dir:`${e}/${t}`});try{for(var c,u=is(a);!(c=yield u.next()).done;){const e=c.value,t=yield this.createDirectories(e.dir,e.idArr);s=Object.assign(Object.assign({},s),t)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&(yield r.call(u))}finally{if(n)throw n.error}}return s}))}shouldDownloadQuestionSet(e,t){return t.mimeType===Tn.QUESTION_SET&&kn.readVisibility(t)===Cn.DEFAULT.valueOf()||this.checkParentQustionSet(e,t)}checkParentQustionSet(e,t){if(!t||!t.parent)return!1;const n=e.find(e=>e.identifier===t.parent);return!(!n||n.mimeType!==Tn.QUESTION_SET)&&(n.mimeType===Tn.QUESTION_SET&&kn.readVisibility(n)===Cn.DEFAULT.valueOf()||this.checkParentQustionSet(e,n))}}var as=n(49),cs=n.n(as),us=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ls{constructor(e,t,n){this.dbService=e,this.deviceInfo=t,this.fileService=n,this.contentDataMap={}}execute(e){return us(this,void 0,void 0,(function*(){const t=yield this.fileService.readAsText(e.tmpLocation,Ln.MANIFEST.valueOf());JSON.parse(t).archive.items.forEach(e=>{this.contentDataMap[e.identifier]=e});const n=new a.CsResponse;try{return yield this.createnWriteManifest(e.identifiers,e.destinationFolder),n.body=e,Promise.resolve(n)}catch(e){return console.error(e),Promise.reject(n)}}))}createnWriteManifest(e,t){return us(this,void 0,void 0,(function*(){const n=new xo(this.deviceInfo),r=[];for(const i of e){const e=this.contentDataMap[i],o=new cs.a;let s;o.add(e);let a=[];for(a.push(e);!o.isEmpty();)if(s=o.dequeue(),kn.hasChildren(s)){const e=kn.getChildContentsIdentifiers(s);if(e&&e.length){const t=[];e.forEach(e=>{const n=this.contentDataMap[e];n&&(o.add(n),t.push(n))}),a=a.concat(t)}}const c=n.populateItemList(a),u=n.generateManifestForArchive(c),l={};c&&c[0]&&c[0].parent&&c[0].mimeType===Tn.QUESTION?l.path=kn.getBasePath(kn.getContentRootDir(t).concat("/",c[0].parent,"/",i,"/")):l.path=kn.getBasePath(kn.getContentRootDir(t).concat("/",i,"/")),l.fileName=Ln.MANIFEST.valueOf(),l.data=JSON.stringify(u),r.push(l)}yield this.writeFile(r)}))}writeFile(e){return us(this,void 0,void 0,(function*(){return new Promise((t,n)=>{sbutility.writeFile(e,e=>{t()},e=>{console.error(e),n(e)})})}))}}class ds{constructor(e){this.fileService=e}execute(e){const t=new a.CsResponse;return this.fileService.removeRecursively(e.tmpLocation).then(()=>(t.body=e,Promise.resolve(t))).catch(()=>Promise.reject(t))}}class hs{constructor(e){this.fileService=e}execute(e){const t=new a.CsResponse;return this.fileService.createDir(e.tmpLocationPath.concat(en.generateUniqueId()),!1).then(n=>(e.tmpLocationPath=n.nativeURL,t.body=e,Promise.resolve(t))).catch(()=>Promise.reject(t))}}class Es{constructor(e,t,n,r){this.apiService=e,this.contentServiceConfig=t,this.framework=n,this.langCode=r,this.SEARCH_ENDPOINT="/search"}handle(e){const t=this.framework&&this.langCode&&`?framework=${this.framework}&lang=${this.langCode}&orgdetails=orgName`,n=(new a.CsRequest.Builder).withHost(this.contentServiceConfig.host).withType(a.CsHttpRequestType.POST).withPath(this.contentServiceConfig.searchApiPath.concat(this.SEARCH_ENDPOINT).concat(t||"")).withBearerToken(!0).withBody({request:e}).build();return this.apiService.fetch(n).pipe(Object(D.map)(e=>e.body))}}class fs{constructor(e){this.telemetryService=e}execute(e){e.metadata;const t=[];for(const n of e.items){const e={type:kn.readPrimaryCategoryServer(n),origin:kn.readOriginFromContentMap(n),identifier:n.identifier,pkgVersion:Number(n.pkgVersion),transferCount:kn.readTransferCountFromContentMap(n),size:kn.readSizeFromContentMap(n)};t.push(e)}const n={dir:ne.IN,type:re.FILE.valueOf(),items:t,env:"sdk",correlationData:e.correlationData,objId:e.items&&e.items.length?e.items[0].identifier:"",objType:e.items&&e.items.length?kn.readPrimaryCategoryServer(e.items[0]):"",objVer:e.items&&e.items.length?kn.readPkgVersion(e.items[0])+"":"",rollUp:e.rollUp},r=new a.CsResponse;return this.telemetryService.share(n).toPromise().then(()=>(r.body=e,Promise.resolve(r))).catch(()=>Promise.reject(r))}}class ps{constructor(e){this.telemetryService=e}execute(e,t,n){const r=new a.CsResponse;for(const t of e.items){ie.CONTENT,kn.readOriginFromContentMap(t),t.identifier,Number(t.pkgVersion),kn.readTransferCountFromContentMap(t),kn.readSizeFromContentMap(t)}const i={dir:ne.OUT,type:re.FILE.valueOf(),items:[],env:"sdk"};return this.telemetryService.share(i).toPromise().then(()=>{let e;if(n.saveLocally)e=n.destinationFolder.concat(t);else{e=("ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalCacheDirectory).concat(t)}const i={exportedFilePath:e};return r.body=i,Promise.resolve(r)}).catch(()=>Promise.reject(r))}}class _s{constructor(e){this.telemetryService=e}execute(e,t){const n=e.items&&e.items.length?e.items[0].identifier:"",r=new Ie;r.type=oe.OTHER,r.subType=t,r.pageId="ImportContent",r.id="ImportContent",r.env="sdk",r.objId=n||e.identifier,r.objType=e.items&&e.items.length?kn.readPrimaryCategoryServer(e.items[0]):"",r.objVer=e.items&&e.items.length?kn.readPkgVersion(e.items[0])+"":"",r.correlationData=e.correlationData;const i=new a.CsResponse;return i.body=e,this.telemetryService.interact(r).pipe(Object(D.map)(()=>i)).toPromise()}}var Os=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ss{constructor(e){this.dbService=e}getUsgaeSpace(e){const t=`SELECT SUM(${St.COLUMN_NAME_SIZE_ON_DEVICE}) as total_size\n FROM ${St.TABLE_NAME}\n WHERE ${St.COLUMN_NAME_VISIBILITY} = '${Cn.DEFAULT.valueOf()}'\n AND ${St.COLUMN_NAME_PATH} LIKE '${e.replace("file://","")}%'`;return this.dbService.execute(t).pipe(Object(D.map)(e=>e[0].total_size||0))}getContentUsageSummary(e){return Os(this,void 0,void 0,(function*(){const t=[];for(const n of e){const e=yield this.getUsgaeSpace(n).toPromise();t.push({path:n,sizeOnDevice:e})}return t}))}}class gs{constructor(e,t,n){this.sharedPreferences=e,this.key=t,this.toStringFunction=n,this.changes=new c.BehaviorSubject(void 0)}addAll(e){return this.asSet().pipe(Object(D.mergeMap)(t=>(e.forEach(e=>t.add(e)),this.sharedPreferences.putString(this.key,JSON.stringify(t.toArray())).pipe(Object(D.mapTo)(void 0)))),Object(D.tap)(()=>this.changes.next(void 0)))}add(e){return this.asSet().pipe(Object(D.mergeMap)(t=>(t.add(e),this.sharedPreferences.putString(this.key,JSON.stringify(t.toArray())).pipe(Object(D.mapTo)(void 0)))),Object(D.tap)(()=>this.changes.next(void 0)))}clear(){return this.sharedPreferences.putString(this.key,"[]").pipe(Object(D.mapTo)(void 0),Object(D.tap)(()=>this.changes.next(void 0)))}remove(e){return this.asSet().pipe(Object(D.mergeMap)(t=>{const n=t.remove(e);return this.sharedPreferences.putString(this.key,JSON.stringify(t.toArray())).pipe(Object(D.mapTo)(n))}),Object(D.tap)(()=>this.changes.next(void 0)))}contains(e){return this.asSet().pipe(Object(D.map)(t=>t.contains(e)))}asList(){return this.sharedPreferences.getString(this.key).pipe(Object(D.map)(e=>e?JSON.parse(e):[]))}asSet(){return this.asList().pipe(Object(D.map)(e=>e.reduce((e,t)=>(e.add(t),e),new Eo.a(this.toStringFunction))))}asListChanges(){return this.changes.asObservable().pipe(Object(D.mergeMap)(()=>this.asList()))}}var As=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ns{constructor(){}execute(e,t){return As(this,void 0,void 0,(function*(){return new Promise((n,r)=>{let i;i=t.saveLocally?t.destinationFolder:"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalCacheDirectory,sbutility.copyFile(Mo.getDirecory(e.body.ecarFilePath),i,Mo.getFileName(e.body.ecarFilePath),()=>{n(e)},e=>{console.error(e),n(e)})})}))}}class Ts{constructor(e,t){this.apiService=e,this.contentServiceConfig=t,this.GET_CONTENT_HEIRARCHY_ENDPOINT="/hierarchy"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.contentServiceConfig.contentHeirarchyAPIPath+this.GET_CONTENT_HEIRARCHY_ENDPOINT+"/"+e.contentId).withBearerToken(!0).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>this.mapContentFromContentHeirarchyData(e.body.result.content)))}mapContentFromContentHeirarchyData(e){return e.contentData=Object.assign({},e),e.children&&e.children.length&&(e.children=e.children.map(e=>this.mapContentFromContentHeirarchyData(Object.assign({},e)))),e}}var Cs=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class vs{constructor(){}execute(e){return Cs(this,void 0,void 0,(function*(){const t=new a.CsResponse;return new Promise((n,r)=>{const i=e.destinationFolder.concat("tmp/");sbutility.rm(i,"",()=>{t.body=e,n(t)},r=>{t.body=e,n(t)})})}))}}var ys=n(33),ms=n(14),bs=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Is{constructor(e,t,n,r,i,o,s,a){this.searchContentHandler=e,this.formService=t,this.contentService=n,this.cachedItemStore=r,this.courseService=i,this.profileService=o,this.apiService=s,this.networkInfoService=a}static buildRequestHash(e){return ms(JSON.stringify(Qr.withDeeplyOrderedKeys(e))).toString()}aggregate(e,t,n,r,i=!1){return Object(c.defer)(()=>bs(this,void 0,void 0,(function*(){if(!n&&!r)throw new Error("formRequest or formFields required");let o=[];n?(n.from=e.from,o=yield this.formService.getForm(n).toPromise().then(e=>e.form.data.fields)):r&&(o=r,i=!1),o=o.filter(e=>-1===t.indexOf(e.dataSrc.type));const s=o.map(t=>bs(this,void 0,void 0,(function*(){if(!t.dataSrc)throw new Error("INVALID_CONFIG");switch(t.dataSrc.type){case"CONTENT_FACETS":return yield this.buildFacetsTask(t,e);case"RECENTLY_VIEWED_CONTENTS":return yield this.buildRecentlyViewedTask(t,e);case"CONTENTS":return yield this.buildContentSearchTask(t,e);case"TRACKABLE_COLLECTIONS":return yield this.buildTrackableCollectionsTask(t,e);case"CONTENT_DISCOVERY_BANNER":return yield this.buildContentDiscoveryBannerTask(t);default:return console.error("UNKNOWN_DATA_SRC"),{requestHash:"",task:Object(c.of)([])}}}))),a=yield Promise.all(s),u=a.map(e=>e.requestHash).join("-"),l=Object(c.defer)(()=>bs(this,void 0,void 0,(function*(){const e=yield this.networkInfoService.networkStatus$.pipe(Object(D.take)(1)).toPromise();if(i&&e===Vn.OFFLINE)throw new Error("ContentAggregator: offline request");return Promise.all(a.map(e=>e.task.toPromise())).then(e=>e.reduce((e,t)=>[...e,...t],[]).sort((e,t)=>e.index-t.index))})));return Object(c.defer)(()=>i?this.cachedItemStore.get(u,Is.CONTENT_AGGREGATION_KEY,"ttl_"+Is.CONTENT_AGGREGATION_KEY,()=>l):l).pipe(Object(D.map)(e=>({result:e}))).toPromise()})))}buildRecentlyViewedTask(e,t){return bs(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n={uid:t.managedSession?t.managedSession.uid:t.uid,primaryCategories:[],recentlyViewed:!0,limit:20};return{requestHash:"RECENTLY_VIEWED_CONTENTS_"+Is.buildRequestHash(n),task:Object(c.defer)(()=>bs(this,void 0,void 0,(function*(){const t=yield this.contentService.getContents(n).toPromise();return e.sections.map(n=>({index:n.index,title:n.title,data:{name:n.index+"",sections:[{name:n.index+"",count:t.length,contents:t.map(e=>(e.contentData.cardImg=e.contentData.appIcon,e))}]},dataSrc:e.dataSrc,theme:n.theme,description:n.description,landingDetails:n.landingDetails,isEnabled:n.isEnabled}))})))}}))}buildContentDiscoveryBannerTask(e){return bs(this,void 0,void 0,(function*(){return{requestHash:"CONTENT_DISCOVERY_BANNER"+Is.buildRequestHash(e.dataSrc.type),task:Object(c.defer)(()=>bs(this,void 0,void 0,(function*(){return e.sections.map(t=>({index:t.index,code:t.code,title:t.title,data:e.dataSrc.values.filter(e=>Number(e.expiry)>Math.floor(Date.now()/1e3)),dataSrc:e.dataSrc,theme:t.theme,description:t.description,landingDetails:t.landingDetails,isEnabled:t.isEnabled}))})))}}))}buildFacetsTask(e,t){return bs(this,void 0,void 0,(function*(){if(e.dataSrc.values)return{requestHash:"",task:Object(c.defer)(()=>bs(this,void 0,void 0,(function*(){return e.sections.map(t=>({index:t.index,code:t.code,title:t.title,data:e.dataSrc.values.sort((e,t)=>e.index-t.index),dataSrc:e.dataSrc,theme:t.theme,description:t.description,landingDetails:t.landingDetails,isEnabled:t.isEnabled}))})))};const{searchRequest:n,searchCriteria:r}=this.buildSearchRequestAndCriteria(e,t);return r.facets=e.dataSrc.mapping.map(e=>e.facet),n.facets=r.facets,n.limit=0,n.offset=0,{requestHash:"CONTENT_FACETS_"+Is.buildRequestHash(n),task:Object(c.defer)(()=>bs(this,void 0,void 0,(function*(){const i=yield this.searchContents(e,r,n);return e.sections.map((n,o)=>{var s,a,c;let u=null!==(s=i.filterCriteria.facetFilters)&&void 0!==s?s:[];const l=[];u.map(t=>{var n,r;const i=null===(r=null===(n=e.dataSrc.params)||void 0===n?void 0:n.config)||void 0===r?void 0:r.find(e=>e.name===t.name);i&&i.mergeableAttributes.map(e=>{l.push(e);const n=u.find(t=>t.name===e);t.values=t.values.filter(e=>i.values.find(t=>t.code===e.name.replace(/\s+/g,"").toLowerCase()));const r=i.values.filter(t=>t.type=e);n&&(n.values=n.values.filter(e=>r.find(t=>t.code===e.name.replace(/\s+/g,""))),t.values=t.values.concat(n.values))})}),u=u.filter(e=>-1===l.indexOf(e.name));const d=u.find(t=>{var n;return t.name===(null===(n=e.dataSrc.mapping[o])||void 0===n?void 0:n.facet)});if(d){const i=null===(c=null===(a=e.dataSrc.params)||void 0===a?void 0:a.config)||void 0===c?void 0:c.find(e=>e.name===d.name);return{index:n.index,title:n.title,code:n.code,data:d.values.map(t=>{var n;const s=i?i.values.find(e=>e.code===t.name.replace(/\s+/g,"").toLowerCase()):[];return{facet:(null==s?void 0:s.name)?s.name:t.name,searchCriteria:Object.assign(Object.assign({},r),{primaryCategories:[],impliedFilters:(null===(n=null==s?void 0:s.searchCriteria)||void 0===n?void 0:n.impliedFilters)?s.searchCriteria.impliedFilters:[{name:d.name,values:[{name:t.name,apply:!0}]}]}),aggregate:e.dataSrc.mapping[o].aggregate,filterPillBy:e.dataSrc.mapping[o].filterPillBy}}).sort((e,n)=>{if(t.userPreferences){const r=t.userPreferences[d.name];if(!r||Array.isArray(r)&&r.indexOf(e.facet)>-1&&r.indexOf(n.facet)>-1||r===e.facet&&r===n.facet)return e.facet.localeCompare(n.facet);if(Array.isArray(r)&&r.indexOf(e.facet)>-1||r===e.facet)return-1;if(Array.isArray(r)&&r.indexOf(n.facet)>-1||r===n.facet)return 1}return e.facet.localeCompare(n.facet)}),dataSrc:e.dataSrc,theme:n.theme,description:n.description,landingDetails:n.landingDetails,isEnabled:n.isEnabled}}return{index:n.index,title:n.title,code:n.code,data:[],dataSrc:e.dataSrc,theme:n.theme,description:n.description,isEnabled:n.isEnabled}})})))}}))}buildTrackableCollectionsTask(e,t){return bs(this,void 0,void 0,(function*(){const t=this.apiService,n=yield this.profileService.getActiveProfileSession().toPromise();return{requestHash:"TRACKABLE_COLLECTIONS_"+Is.buildRequestHash({userId:n.managedSession?n.managedSession.uid:n.uid}),task:Object(c.defer)(()=>bs(this,void 0,void 0,(function*(){const r=yield this.courseService.getEnrolledCourses({userId:n.managedSession?n.managedSession.uid:n.uid,returnFreshCourses:!0},new class{handle({userId:n}){e.dataSrc.request.path&&(e.dataSrc.request.path=e.dataSrc.request.path.replace("${userId}",n));const r=a.CsRequest.fromJSON(e.dataSrc.request);return t.fetch(r).pipe(Object(D.map)(e=>e.body))}}).toPromise();return e.sections.map((t,n)=>{if(e.dataSrc.mapping[n]&&e.dataSrc.mapping[n].aggregate){const i=e.dataSrc.mapping[n].aggregate;return{index:t.index,title:t.title,data:ys.CsContentsGroupGenerator.generate({contents:r,groupBy:i.groupBy,sortBy:i.sortBy?this.buildSortByCriteria(i.sortBy):[],filterBy:i.filterBy?this.buildFilterByCriteria(i.filterBy):[],groupSortBy:i.groupSortBy?this.buildSortByCriteria(i.groupSortBy):[],groupFilterBy:i.groupFilterBy?this.buildFilterByCriteria(i.groupFilterBy):[],includeSearchable:!1}),dataSrc:e.dataSrc,theme:t.theme,description:t.description,landingDetails:t.landingDetails,isEnabled:t.isEnabled}}return{index:t.index,title:t.title,data:{name:t.index+"",sections:[{name:t.index+"",count:r.length,contents:r}]},dataSrc:e.dataSrc,theme:t.theme,description:t.description,landingDetails:t.landingDetails,isEnabled:t.isEnabled}})})))}}))}buildContentSearchTask(e,t){return bs(this,void 0,void 0,(function*(){const{searchRequest:n,searchCriteria:r}=this.buildSearchRequestAndCriteria(e,t);return{requestHash:"CONTENTS_"+Is.buildRequestHash(n),task:Object(c.defer)(()=>bs(this,void 0,void 0,(function*(){const i=yield(()=>bs(this,void 0,void 0,(function*(){return n.filters&&n.filters.primaryCategory||r.primaryCategories&&0===r.primaryCategories.length?[]:this.contentService.getContents({primaryCategories:r.primaryCategories&&r.primaryCategories.length&&r.primaryCategories||n.filters&&n.filters.primaryCategory||[],board:r.board,medium:r.medium,grade:r.grade}).pipe(Object(D.map)(e=>e.map(e=>(e.contentData.appIcon&&!e.contentData.appIcon.startsWith("https://")&&(e.contentData.appIcon=e.basePath+e.contentData.appIcon),e.contentData)))).toPromise()})))(),o=yield this.searchContents(e,r,n),s=(o.contentDataList||[]).filter(e=>!i.find(t=>t.identifier===e.identifier)),a=i.concat(s).map(e=>(e.cardImg=e.appIcon,e));return a.sort((e,t)=>e.lastPublishedOn>t.lastPublishedOn?-1:1),e.sections.map((i,s)=>{if(e.dataSrc.mapping[s]&&e.dataSrc.mapping[s].aggregate){const c=e.dataSrc.mapping[s].aggregate,u=(()=>{const n=ys.CsContentsGroupGenerator.generate({contents:a,groupBy:c.groupBy,sortBy:c.sortBy?this.buildSortByCriteria(c.sortBy):[],filterBy:c.filterBy?this.buildFilterByCriteria(c.filterBy):[],groupSortBy:c.groupSortBy?this.buildSortByCriteria(c.groupSortBy):[],groupFilterBy:c.groupFilterBy?this.buildFilterByCriteria(c.groupFilterBy):[],combination:e.dataSrc.mapping[s].applyFirstAvailableCombination&&t.applyFirstAvailableCombination,includeSearchable:!1});if(t.userPreferences&&t.userPreferences[c.groupBy]&&n.sections.sort((e,n)=>t.userPreferences[c.groupBy].indexOf(e.name.replace(/[^A-Z0-9]/gi,"").toLocaleLowerCase())>-1&&t.userPreferences[c.groupBy].indexOf(n.name.replace(/[^A-Z0-9]/gi,"").toLocaleLowerCase())>-1?e.name.localeCompare(n.name):t.userPreferences[c.groupBy].indexOf(e.name.replace(/[^A-Z0-9]/gi,"").toLocaleLowerCase())>-1?-1:t.userPreferences[c.groupBy].indexOf(n.name.replace(/[^A-Z0-9]/gi,"").toLocaleLowerCase())>-1?1:0),n.name){(o.filterCriteria.facetFilters||[]).map(e=>{let t=e.name==n.name?e.values:[];return n.sections.filter(e=>t.some(t=>(e.name.toLocaleLowerCase()===t.name.toLowerCase()&&(e.totalCount=t.count),e.name===t.name)))})}return n})();return{index:i.index,title:i.title,meta:{searchCriteria:r,filterCriteria:o.filterCriteria,searchRequest:n},data:u,dataSrc:e.dataSrc,theme:i.theme,description:i.description,landingDetails:i.landingDetails,isEnabled:i.isEnabled}}return{index:i.index,title:i.title,meta:{searchCriteria:r,filterCriteria:o.filterCriteria,searchRequest:n},data:{name:i.index+"",sections:[{count:a.length,contents:a}]},dataSrc:e.dataSrc,theme:i.theme,description:i.description,landingDetails:i.landingDetails,isEnabled:i.isEnabled}})})))}}))}buildFilterByCriteria(e){return e.reduce((e,t)=>(Object.keys(t).forEach(n=>e.push({filterAttribute:n,filterCondition:{operation:t[n].operation,value:t[n].value}})),e),[])}buildSortByCriteria(e){return e.reduce((e,t)=>(Object.keys(t).forEach(n=>e.push({sortAttribute:n,sortOrder:t[n]})),e),[])}buildSearchRequestAndCriteria(e,t){const n=e=>this.searchContentHandler.getSearchCriteria(e),r=e.dataSrc.request&&e.dataSrc.request.body?Object.assign({filters:{}},e.dataSrc.request.body.request):{filters:{}},i=t.interceptSearchCriteria?t.interceptSearchCriteria(n({request:r})):n({request:r});return{searchRequest:(e=>this.searchContentHandler.getSearchContentRequest(e))(i),searchCriteria:i}}searchContents(e,t,n){const r=this.apiService;return this.contentService.searchContent(t,void 0,new class{handle(t){if(n&&n.filters&&n.filters.mimeType){const e=(e,t)=>Dn.MimeTypeCategoryMapping[t]?e.concat(Dn.MimeTypeCategoryMapping[t]):e.concat([t]);n.filters.mimeType=n.filters.mimeType.reduce(e,[])}e.dataSrc.request&&e.dataSrc.request.body&&e.dataSrc.request.body.request?e.dataSrc.request.body={request:Object.assign(Object.assign({},e.dataSrc.request.body.request),n)}:e.dataSrc.request.body={request:n};const i=JSON.stringify(Qr.withDeeplyOrderedKeys(e.dataSrc.request));if(Is.searchContentCache.has(i))return Object(c.of)(Is.searchContentCache.get(i)).pipe(Object(D.map)(e=>e.body));const o=a.CsRequest.fromJSON(e.dataSrc.request);return r.fetch(o).pipe(Object(D.tap)(e=>{Is.searchContentCache.set(i,e)}),Object(D.map)(e=>e.body))}},!0).pipe(Object(D.catchError)(e=>(console.error(e),Object(c.of)({id:"OFFLINE_RESPONSE_ID",responseMessageId:"OFFLINE_RESPONSE_ID",filterCriteria:t,contentDataList:[]})))).toPromise()}}Is.searchContentCache=new Map,Is.CONTENT_AGGREGATION_KEY="content-aggregation";var Ms=n(50),Rs=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ls{constructor(e,t){this.storageService=e,this.fileService=t}getLocallyAvailableQuestion(e,t){const n=this.storageService.getStorageDestinationDirectoryPath();let r=[];return e.forEach(e=>Rs(this,void 0,void 0,(function*(){const i=this.fileService.readAsText("ios"===window.device.platform.toLowerCase()?`${n}/content/${t}/${e}`:`${n}content/${t}/${e}`,"index.json");r.push(i)}))),Object(c.from)(Promise.all(r)).pipe(Object(D.map)(e=>({questions:e.map(e=>{if(e&&"string"==typeof e){return JSON.parse(e).archive.items[0]}return e}),count:e.length})))}}var Ps=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Ds=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,i){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,i,(t=e[n](t)).done,t.value)}))}}};class ws{constructor(e,t,n,r){this.contentService=e,this.dbService=t,this.storageService=n,this.fileService=r}handle(e){return Ps(this,void 0,void 0,(function*(){const t=this.getQuery(e);let n;if(n=yield this.getQuestionSetFromQuery(t),!n||!n.isAvailableLocally)return yield this.fetchServerChildQuestions(e);if(!n.children)return[];const r=this.storageService.getStorageDestinationDirectoryPath();try{n=yield this.fetchDBChildQuestions(n,r)}catch(e){return n.children}return n.children}))}fetchDBChildQuestions(e,t){var n,r;return Ps(this,void 0,void 0,(function*(){if(!e||!e.children)return e;const i=[];try{for(var o,s=Ds(e.children);!(o=yield s.next()).done;){const n=o.value;if("QuestionSet"===n.objectType){let e;const r=this.getQuery(n.identifier);e=yield this.getQuestionSetFromQuery(r),e&&e.children&&(e=yield this.fetchDBChildQuestions(e,t),i.push(e))}else if("Question"===n.objectType){const r=yield this.fileService.readAsText(`${t}content/${e.identifier}/${n.identifier}`,"index.json");if(r&&"string"==typeof r){const e=JSON.parse(r);e&&e.archive&&e.archive.items.length&&i.push(e.archive.items[0])}}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=s.return)&&(yield r.call(s))}finally{if(n)throw n.error}}return e.children=i,e}))}getQuery(e){return`SELECT * FROM ${St.TABLE_NAME} WHERE (${St.COLUMN_NAME_IDENTIFIER} = '${e}')`}getQuestionSetFromQuery(e){return Ps(this,void 0,void 0,(function*(){try{const t=yield this.dbService.execute(e).toPromise();if(t&&t.length&&t[0][St.COLUMN_NAME_LOCAL_DATA]){const e=JSON.parse(t[0][St.COLUMN_NAME_LOCAL_DATA]);return e.isAvailableLocally=kn.isAvailableLocally(t[0][St.COLUMN_NAME_CONTENT_STATE]),e}return null}catch(e){return null}}))}fetchServerChildQuestions(e){return Ps(this,void 0,void 0,(function*(){const t=yield this.contentService.getQuestionSetHierarchy(e).toPromise();return t&&t.questionset&&t.questionset.children?t.questionset.children:[]}))}}var Us,js=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Fs=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ks=function(e,t){return function(n,r){t(n,r,e)}},xs=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let Bs=Us=class{constructor(e,t,n,r,i,o,s,a,c,u,l,d,h,E,f,p,_){this.sdkConfig=e,this.apiService=t,this.dbService=n,this.profileService=r,this.fileService=i,this.zipService=o,this.deviceInfo=s,this.telemetryService=a,this.contentFeedbackService=c,this.downloadService=u,this.sharedPreferences=l,this.eventsBusService=d,this.cachedItemStore=h,this.appInfo=E,this.networkInfoService=f,this.container=p,this.storageService=_,this.contentUpdateSizeOnDeviceTimeoutRef=new Map,this.contentServiceConfig=this.sdkConfig.contentServiceConfig,this.appConfig=this.sdkConfig.appConfig,this.getContentDetailsHandler=new yo(this.contentFeedbackService,this.profileService,this.apiService,this.contentServiceConfig,this.dbService,this.eventsBusService),this.getContentHeirarchyHandler=new Ts(this.apiService,this.contentServiceConfig),this.questionSetFileReadHandler=new Ls(this.storageService,this.fileService),this.getChildQuestionSetHandler=new ws(this,this.dbService,this.storageService,this.fileService),this.contentDeleteRequestSet=new gs(this.sharedPreferences,Us.KEY_CONTENT_DELETE_REQUEST_LIST,e=>e.contentId)}onInit(){return this.downloadService.registerOnDownloadCompleteDelegate(this),Object(c.combineLatest)([this.handleContentDeleteRequestSetChanges(),this.handleUpdateSizeOnDeviceFail()]).pipe(Object(D.mapTo)(void 0))}getContentDetails(e){return this.getContentDetailsHandler.handle(e)}getContentHeirarchy(e){return this.getContentHeirarchyHandler.handle(e)}getContents(e){const t=(new wo).getAllLocalContentQuery(e);return this.dbService.execute(t).pipe(Object(D.mergeMap)(t=>Object(c.defer)(()=>xs(this,void 0,void 0,(function*(){const n=[];for(const r of t){let t=xn.mapContentDBEntryToContent(r);t=yield this.getContentDetailsHandler.decorateContent({content:t,attachContentAccess:e.attachContentAccess,attachContentMarker:e.attachContentAccess,attachFeedback:e.attachFeedback}).toPromise(),n.push(t)}if(e.resourcesOnly){const t=e.uid,r=`SELECT * FROM ${vt.TABLE_NAME}\n WHERE UID IN (${wn.joinPreservingQuotes(t)})`;(yield this.dbService.execute(r).toPromise()).forEach(e=>{const t={identifier:e[vt.COLUMN_NAME_CONTENT_IDENTIFIER],name:"",contentData:e[vt.COLUMN_NAME_DATA]&&JSON.parse(e[vt.COLUMN_NAME_DATA]),isUpdateAvailable:!1,mimeType:"",basePath:"",contentType:"",primaryCategory:"",isAvailableLocally:!1,referenceCount:0,sizeOnDevice:0,lastUsedTime:0,lastUpdatedTime:0};n.push(t)})}return n})))))}cancelImport(e){return this.downloadService.cancel({identifier:e})}deleteContent(e){return Object(c.defer)(()=>xs(this,void 0,void 0,(function*(){e.contentDeleteList.forEach(e=>{const t=this.contentUpdateSizeOnDeviceTimeoutRef.get(e.contentId);t&&(clearTimeout(t),this.contentUpdateSizeOnDeviceTimeoutRef.delete(e.contentId))});const t=[],n=new Lo(this.dbService,this.fileService,this.sharedPreferences);for(const r of e.contentDeleteList){const e=yield this.getContentDetailsHandler.fetchFromDB(r.contentId).toPromise();e?(t.push({identifier:r.contentId,status:_n.DELETED_SUCCESSFULLY}),kn.hasChildren(e[St.COLUMN_NAME_LOCAL_DATA])&&(yield n.deleteAllChildren(e,r.isChildContent)),yield n.deleteOrUpdateContent(e,!1,r.isChildContent)):t.push({identifier:r.contentId,status:_n.NOT_FOUND})}return new ns(this.dbService,this.sharedPreferences,this.fileService).execute(),t}))).pipe(Object(D.tap)(()=>e.contentDeleteList.forEach(e=>{this.downloadService.onContentDelete(e.contentId)})))}enqueueContentDelete(e){return this.contentDeleteRequestSet.addAll(e.contentDeleteList)}clearContentDeleteQueue(){return this.contentDeleteRequestSet.clear()}getContentDeleteQueue(){return this.contentDeleteRequestSet.asListChanges()}exportContent(e){const t=new xo(this.deviceInfo,this.dbService,this.fileService);return Object(c.from)(t.getContentExportDBModelToExport(e.contentIds).then(n=>this.fileService.getTempLocation(e.destinationFolder).then(t=>{const r={},i=kn.getExportedFileName(n,this.appInfo.getAppName());r.content_count=n.length;const o={metadata:r,ecarFilePath:t.nativeURL.concat(i),destinationFolder:e.destinationFolder,contentModelsToExport:n,tmpLocationPath:t.nativeURL,subContentIds:e.subContentIds};return new hs(this.fileService).execute(o)}).then(e=>new Bo(this.dbService,t).execute(e.body)).then(e=>new Vo(this.fileService,this.deviceInfo).execute(e.body)).then(e=>new Go(this.zipService).execute(e.body)).then(e=>new $o(this.fileService).execute(e.body)).then(e=>(new Ko).execute(e.body)).then(e=>new Wo(this.fileService,this.zipService).execute(e.body)).then(t=>(new Ns).execute(t,e)).then(e=>(new vs).execute(e.body)).then(t=>{const r=kn.getExportedFileName(n,this.appInfo.getAppName());return new ps(this.telemetryService).execute(t.body,r,e)}).then(e=>e.body)))}getChildContents(e){e.level||(e.level=-1);const t=new Io(this.dbService,this.getContentDetailsHandler,this.appConfig);let n=e.hierarchyInfo;if(n){if(n.length>0&&n[n.length-1].identifier===e.contentId){const e=n.length;n.splice(e-1,1)}}else n=[];return this.dbService.read(yo.getReadContentQuery(e.contentId)).pipe(Object(D.mergeMap)(r=>xs(this,void 0,void 0,(function*(){const i=new Map,o=JSON.parse(r[0][St.COLUMN_NAME_LOCAL_DATA]).childNodes;if(console.log("childIdentifiers",o),o){const e=`SELECT * FROM ${St.TABLE_NAME}\n WHERE ${St.COLUMN_NAME_IDENTIFIER}\n IN (${wn.joinPreservingQuotes(o)})`;(yield this.dbService.execute(e).toPromise()).forEach(e=>{i.set(e.identifier,e)})}let s=yield t.fetchChildrenOfContent(r[0],i,0,e.level,n);return console.log("childContentHandler-",s),s}))))}getDownloadState(){throw new Error("Not Implemented yet")}importContent(e){const t=new Do(this.appConfig,this.contentServiceConfig,this.telemetryService),n=wn.deDupe(e.contentImportArray.map(e=>e.contentId)),r=t.getContentSearchFilter(n,e.contentStatusArray,e.fields);return new Es(this.apiService,this.contentServiceConfig).handle(r).pipe(Object(D.map)(e=>e.result.content&&e.result.content.length&&e.result.QuestionSet&&e.result.QuestionSet.length?e.result.content.concat(e.result.QuestionSet):e.result.content||e.result.QuestionSet),Object(D.mergeMap)(r=>Object(c.defer)(()=>xs(this,void 0,void 0,(function*(){const i=[];if(r&&r.length){const o=[];for(const s of n){const n=r.find(e=>e.identifier===s);if(n){const r=e.contentImportArray.find(e=>e.contentId===s),a=yield t.getDownloadUrl(n,r);let c=In.NOT_FOUND;if(a&&Mo.getFileExtension(a)===bn.CONTENT.valueOf()){c=In.ENQUEUED_FOR_DOWNLOAD;const t={identifier:s,downloadUrl:a,mimeType:Tn.ECAR,destinationFolder:r.destinationFolder,isChildContent:r.isChildContent,filename:s.concat(".",bn.CONTENT),correlationData:r.correlationData,rollUp:r.rollUp,contentMeta:n,withPriority:e.withPriority||(n.mimeType===Tn.COLLECTION.valueOf()?1:0),title:n.name?n.name.concat(".",bn.CONTENT):s.concat(".",bn.CONTENT)};o.push(t),console.log("downloadRequestList-",o)}i.push({identifier:s,status:c})}}this.downloadService.download(o).toPromise().then()}return i})))))}importEcar(e){return Object(c.from)(this.fileService.exists(e.sourceFilePath).then(t=>{const n={isChildContent:e.isChildContent,ecarFilePath:e.sourceFilePath,destinationFolder:e.destinationFolder,skippedItemsIdentifier:[],items:[],contentImportResponseList:[],correlationData:e.correlationData||[],rollUp:e.rollUp||new Te,contentIdsToDelete:new Set,identifier:e.identifier};return new _s(this.telemetryService).execute(n,"ContentImport-Initiated").then(()=>this.fileService.getTempLocation(e.destinationFolder)).then(e=>(n.tmpLocation=e.nativeURL,new Jo(this.fileService,this.zipService).execute(n))).then(e=>new es(this.fileService,this.dbService,this.appConfig,this.getContentDetailsHandler).execute(e.body)).then(e=>new ss(this.fileService,this.zipService,this.appConfig,this.dbService,this.deviceInfo,this.getContentDetailsHandler,this.eventsBusService,this.sharedPreferences).execute(e.body)).then(([e,t])=>{this.contentUpdateSizeOnDeviceTimeoutRef.set(n.rootIdentifier?n.rootIdentifier:n.identifiers[0],t),this.eventsBusService.emit({namespace:M.CONTENT,event:{type:Pn.CONTENT_EXTRACT_COMPLETED,payload:{contentId:n.rootIdentifier?n.rootIdentifier:n.identifiers[0]}}});new a.CsResponse;return new ls(this.dbService,this.deviceInfo,this.fileService).execute(e.body)}).then(e=>new ds(this.fileService).execute(e.body)).then(e=>{const t=new a.CsResponse;return this.cleanupContent(n).toPromise().then(()=>(t.body=n,Promise.resolve(t))).catch(()=>Promise.reject(t))}).then(e=>new fs(this.telemetryService).execute(e.body)).then(e=>new _s(this.telemetryService).execute(e.body,"ContentImport-Success")).then(e=>(this.eventsBusService.emit({namespace:M.CONTENT,event:{type:Pn.IMPORT_COMPLETED,payload:{contentId:n.rootIdentifier?n.rootIdentifier:n.identifiers[0]}}}),e.body.contentImportResponseList))}).catch(e=>(console.log("error",e),[{identifier:"",status:In.NOT_FOUND}])))}nextContent(e,t,n){const r=new Io(this.dbService,this.getContentDetailsHandler,this.appConfig);return this.dbService.read(yo.getReadContentQuery(e[0].identifier)).pipe(Object(D.mergeMap)(i=>xs(this,void 0,void 0,(function*(){const o=yield r.getContentsKeyList(i[0]),s=r.getNextContentIdentifier(e,t,o);return r.getContentFromDB(e,s,n)}))))}prevContent(e,t,n){const r=new Io(this.dbService,this.getContentDetailsHandler,this.appConfig);return this.dbService.read(yo.getReadContentQuery(e[0].identifier)).pipe(Object(D.mergeMap)(i=>xs(this,void 0,void 0,(function*(){const o=yield r.getContentsKeyList(i[0]),s=r.getPreviousContentIdentifier(e,t,o);return r.getContentFromDB(e,s,n)}))))}getRelevantContent(e){const t={};return Object(c.of)(t).pipe(Object(D.mergeMap)(n=>e.next?this.nextContent(e.hierarchyInfo,e.contentIdentifier,e.shouldConvertBasePath).pipe(Object(D.map)(e=>(t.nextContent=e,t))):Object(c.of)(t)),Object(D.mergeMap)(n=>e.prev?this.prevContent(e.hierarchyInfo,e.contentIdentifier,e.shouldConvertBasePath).pipe(Object(D.map)(e=>(t.previousContent=e,t))):Object(c.of)(t)),Object(D.map)(e=>{const t={};return t.next=e.nextContent?{content:e.nextContent}:void 0,t.prev=e.previousContent?{content:e.previousContent}:void 0,t}))}subscribeForImportStatus(e){throw new Error("Not Implemented yet")}searchContent(e,t,n,r){if((e=JSON.parse(JSON.stringify(e))).facetFilters){const t=e.facetFilters.find(e=>"mimeType"===e.name);t&&(t.values=t.values.filter(e=>e.apply).reduce((e,t)=>e=e.concat(t.values.map(e=>Object.assign(Object.assign({},e),{apply:!0}))),[]))}const i=new Do(this.appConfig,this.contentServiceConfig,this.telemetryService),o=e.languageCode;t?(e=i.getSearchCriteria(t),o&&(e.languageCode=o)):(e.limit=e.limit?e.limit:100,e.offset=e.offset?e.offset:0);const s=i.getSearchContentRequest(e);return this.sharedPreferences.getString(_.KEY_ACTIVE_CHANNEL_ACTIVE_FRAMEWORK_ID).pipe(Object(D.mergeMap)(t=>(n||(n=new Es(this.apiService,this.contentServiceConfig,t,e.languageCode)),n.handle(s).pipe(Object(D.map)(t=>(e.facetFilters||e.searchType!==gn.SEARCH||(r||(s.filters.contentType=[],s.filters.primaryCategory=[]),s.filters.audience=[]),i.mapSearchResponse(e,t,s))),Object(D.map)(t=>{if(!t.filterCriteria.facetFilters)return t;const n=t.filterCriteria.facetFilters.find(e=>"mimeType"===e.name);return n&&(n.values=Ms.CsMimeTypeFacetToMimeTypeCategoryAggregator.aggregate(n.values,"filter"===e.searchType?[Dn.MimeTypeCategory.ALL]:[])),t})))))}cancelDownload(e){return this.downloadService.cancel({identifier:e})}setContentMarker(e){const t=`SELECT * FROM ${vt.TABLE_NAME}\n WHERE ${vt.COLUMN_NAME_UID} = '${e.uid}'\n AND ${vt.COLUMN_NAME_CONTENT_IDENTIFIER}='${e.contentId}'\n AND ${vt.COLUMN_NAME_MARKER} = ${e.marker}`;return this.dbService.execute(t).pipe(Object(D.mergeMap)(t=>{const n={uid:e.uid,identifier:e.contentId,epoch_timestamp:Date.now(),data:e.data,extra_info:JSON.stringify(e.extraInfo),marker:e.marker.valueOf(),mime_type:this.getMimeType(e.data)};return wn.isEmpty(t)?this.dbService.insert({table:vt.TABLE_NAME,modelJson:n}).pipe(Object(D.map)(e=>e>0)):e.isMarked?this.dbService.update({table:vt.TABLE_NAME,selection:`${vt.COLUMN_NAME_UID}= ? AND ${vt.COLUMN_NAME_CONTENT_IDENTIFIER}= ? AND ${vt.COLUMN_NAME_MARKER}= ?`,selectionArgs:[e.uid,e.contentId,e.marker.valueOf().toString()],modelJson:n}).pipe(Object(D.map)(e=>e>0)):this.dbService.delete({table:vt.TABLE_NAME,selection:`${vt.COLUMN_NAME_UID} = ? AND ${vt.COLUMN_NAME_CONTENT_IDENTIFIER} = ? AND ${vt.COLUMN_NAME_MARKER} = ?`,selectionArgs:[e.uid,e.contentId,""+e.marker]}).pipe(Object(D.map)(e=>e))}))}onDownloadCompletion(e){const t={isChildContent:e.isChildContent,sourceFilePath:e.downloadedFilePath,destinationFolder:e.destinationFolder,correlationData:e.correlationData,rollUp:e.rollUp,identifier:e.identifier};return this.importEcar(t).pipe(Object(D.mergeMap)(()=>this.downloadService.cancel({identifier:e.identifier},!1)),Object(D.catchError)(()=>this.downloadService.cancel({identifier:e.identifier},!1)),Object(D.mapTo)(void 0))}getContentSpaceUsageSummary(e){const t=new Ss(this.dbService);return Object(c.from)(t.getContentUsageSummary(e.paths))}buildContentAggregator(e,t,n){return new Is(new Do(this.appConfig,this.contentServiceConfig,this.telemetryService),e,this,this.cachedItemStore,t,n,this.apiService,this.networkInfoService)}getQuestionList(e,t){return this.getContentDetails({contentId:t,objectType:"QuestionSet"}).pipe(Object(D.switchMap)(n=>n.isAvailableLocally&&t?this.questionSetFileReadHandler.getLocallyAvailableQuestion(e,t):this.contentServiceDelegate.getQuestionList(e)),Object(D.catchError)(t=>this.contentServiceDelegate.getQuestionList(e)))}getQuestionSetHierarchy(e){return this.contentServiceDelegate.getQuestionSetHierarchy(e)}getQuestionSetRead(e,t){return this.contentServiceDelegate.getQuestionSetRead(e,t)}getQuestionSetChildren(e){return xs(this,void 0,void 0,(function*(){try{return yield this.getChildQuestionSetHandler.handle(e)}catch(e){return[]}}))}formatSearchCriteria(e){return new Do(this.appConfig,this.contentServiceConfig,this.telemetryService).getSearchCriteria(e)}cleanupContent(e){const t=[];for(const n of Array.from(e.contentIdsToDelete.values())){const e={contentId:n,isChildContent:!1};t.push(e)}return this.deleteContent({contentDeleteList:t}).pipe(Object(D.mapTo)(void 0))}getMimeType(e){let t="";if(e){t=JSON.parse(e).mimeType}return t}handleContentDeleteRequestSetChanges(){return this.contentDeleteRequestSet.asListChanges().pipe(Object(D.mergeMap)(e=>{const t=e[0];return t?this.deleteContent({contentDeleteList:[t]}).pipe(Object(D.mergeMap)(()=>this.contentDeleteRequestSet.remove(t)),Object(D.mapTo)(void 0)):Object(c.of)(void 0)}))}handleUpdateSizeOnDeviceFail(){return this.sharedPreferences.getBoolean(Us.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL).pipe(Object(D.mergeMap)(e=>e?Object(c.of)(void 0):Object(c.from)(new ns(this.dbService,this.sharedPreferences,this.fileService).execute()).pipe(Object(D.mapTo)(void 0))))}get contentServiceDelegate(){return this.container.get(u.CONTENT_SERVICE)}downloadTranscriptFile(e){const t="ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalDataDirectory+Us.DOWNLOAD_DIR_NAME;return this.createTranscriptDir(e,t).then(()=>{const n={uri:e.downloadUrl,title:e.fileName,description:"",mimeType:"",visibleInDownloadsUi:!0,notificationVisibility:1,destinationInExternalPublicDir:{dirType:"Download",subPath:e.fileName},headers:[],destinationUri:e.destinationUrl};return this.downloadTranscript(n).toPromise().then(n=>{if(n&&n.path)return this.copyFile(n.path.split(/\/(?=[^\/]+$)/)[0],t.concat("/"+e.identifier),e.fileName).then(()=>{this.deleteFolder(n.path)}),n.path})})}createTranscriptDir(e,t){return this.fileService.exists(t.concat("/"+e.identifier)).then(e=>e.nativeURL).catch(()=>this.fileService.createDir(t,!1).then(n=>{this.fileService.createDir(t.concat("/"+e.identifier),!1).then(e=>e.nativeURL)}))}downloadTranscript(e){return new c.Observable(t=>{downloadManager.enqueue(e,(e,n)=>{if(e)return t.error(e);t.next(n),t.complete()})}).pipe(Object(D.mergeMap)(e=>Object(c.interval)(1e3).pipe(Object(D.mergeMap)(()=>new c.Observable(t=>{downloadManager.query({ids:[e]},(e,n)=>e||16===n[0].status?t.error(e||new Error("Unknown Error")):t.next(n[0]))})),Object(D.filter)(e=>8===e.status),Object(D.take)(1))),Object(D.map)(e=>({path:e.localUri})))}copyFile(e,t,n){return xs(this,void 0,void 0,(function*(){return new Promise((r,i)=>{sbutility.copyFile(e,t,n,()=>{r(!0)},e=>{console.error(e),r(e)})})}))}deleteFolder(e){return xs(this,void 0,void 0,(function*(){if(!e)return;return new Promise((t,n)=>{sbutility.rm(e,"",()=>{t(void 0)},e=>{n(e)})})}))}};Bs.DOWNLOAD_DIR_NAME="transcript",Bs.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL=S.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,Bs.KEY_CONTENT_DELETE_REQUEST_LIST=S.KEY_CONTENT_DELETE_REQUEST_LIST,Bs=Us=js([Object(s.injectable)(),ks(0,Object(s.inject)(l.SDK_CONFIG)),ks(1,Object(s.inject)(l.API_SERVICE)),ks(2,Object(s.inject)(l.DB_SERVICE)),ks(3,Object(s.inject)(l.PROFILE_SERVICE)),ks(4,Object(s.inject)(l.FILE_SERVICE)),ks(5,Object(s.inject)(l.ZIP_SERVICE)),ks(6,Object(s.inject)(l.DEVICE_INFO)),ks(7,Object(s.inject)(l.TELEMETRY_SERVICE)),ks(8,Object(s.inject)(l.CONTENT_FEEDBACK_SERVICE)),ks(9,Object(s.inject)(l.DOWNLOAD_SERVICE)),ks(10,Object(s.inject)(l.SHARED_PREFERENCES)),ks(11,Object(s.inject)(l.EVENTS_BUS_SERVICE)),ks(12,Object(s.inject)(l.CACHED_ITEM_STORE)),ks(13,Object(s.inject)(l.APP_INFO)),ks(14,Object(s.inject)(l.NETWORKINFO_SERVICE)),ks(15,Object(s.inject)(l.CONTAINER)),ks(16,Object(s.inject)(l.STORAGE_SERVICE)),Fs("design:paramtypes",[Object,Object,o,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,s.Container,Object])],Bs);var Vs=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ys=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Gs=function(e,t){return function(n,r){t(n,r,e)}};let Hs=class{constructor(e){this.dbService=e}getValue(e){return this.dbService.read({table:It.TABLE_NAME,columns:[],selection:It.COLUMN_NAME_KEY+" = ?",selectionArgs:[e]}).pipe(Object(D.map)(e=>e[0]&&e[0].value))}setValue(e,t){return this.getValue(e).pipe(Object(D.mergeMap)(n=>n?this.dbService.update({table:It.TABLE_NAME,selection:It.COLUMN_NAME_KEY+" = ?",selectionArgs:[e],modelJson:{[It.COLUMN_NAME_KEY]:e,[It.COLUMN_NAME_VALUE]:t}}).pipe(Object(D.map)(e=>e>0)):this.dbService.insert({table:It.TABLE_NAME,modelJson:{[It.COLUMN_NAME_KEY]:e,[It.COLUMN_NAME_VALUE]:t}}).pipe(Object(D.map)(e=>e>0))))}};Hs=Vs([Object(s.injectable)(),Gs(0,Object(s.inject)(l.DB_SERVICE)),Ys("design:paramtypes",[o])],Hs);class $s{constructor(e,t,n,r){this.apiService=e,this.formServiceConfig=t,this.fileService=n,this.cachedItemStore=r,this.FORM_FILE_KEY_PREFIX="form-",this.FORM_LOCAL_KEY="form-",this.GET_FORM_DETAILS_ENDPOINT="/read"}static getIdForRequest(e){let t=`${e.type}_${e.subType}_${e.action}`;return e.rootOrgId&&"*"!==e.rootOrgId&&(t+="_"+e.rootOrgId),e.framework&&(t+="_"+e.framework),e.component&&(t+="_"+e.component),t}handle(e){return this.cachedItemStore[e.from===Jn.SERVER?"get":"getCached"]($s.getIdForRequest(e),this.FORM_LOCAL_KEY,"ttl_"+this.FORM_LOCAL_KEY,()=>this.fetchFormServer(e),()=>this.fetchFromFile(e))}fetchFormServer(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.formServiceConfig.apiPath+this.GET_FORM_DETAILS_ENDPOINT).withBearerToken(!0).withHeaders({"X-Platform-Id":window.device.platform}).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result))}fetchFromFile(e){const t=lr.getAssetPath()+this.formServiceConfig.formConfigDirPath,n=this.FORM_FILE_KEY_PREFIX+$s.getIdForRequest(e)+".json";return Object(c.from)(this.fileService.readFileFromAssets(t.concat("/",n))).pipe(Object(D.map)(e=>JSON.parse(e).result))}}var qs=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ks=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},zs=function(e,t){return function(n,r){t(n,r,e)}};let Ws=class{constructor(e,t,n,r){this.sdkConfig=e,this.apiService=t,this.fileService=n,this.cachedItemStore=r,this.formServiceConfig=this.sdkConfig.formServiceConfig}getForm(e){return new $s(this.apiService,this.formServiceConfig,this.fileService,this.cachedItemStore).handle(e)}};Ws=qs([Object(s.injectable)(),zs(0,Object(s.inject)(l.SDK_CONFIG)),zs(1,Object(s.inject)(l.API_SERVICE)),zs(2,Object(s.inject)(l.FILE_SERVICE)),zs(3,Object(s.inject)(l.CACHED_ITEM_STORE)),Ks("design:paramtypes",[Object,Object,Object,Object])],Ws);var Xs,Js=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Qs=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Zs=function(e,t){return function(n,r){t(n,r,e)}},ea=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let ta=Xs=class{constructor(e,t,n){this.sdkConfig=e,this.keyValueStore=t,this.sharedPreferences=n,this.apiConfig=this.sdkConfig.apiConfig}static isItemEmpty(e){return!(!Array.isArray(e)||0!==e.length)||"object"==typeof e&&0===Object.keys(e).length}get(e,t,n,r,i,o,s){return r().pipe(Object(D.tap)(r=>{this.saveItemTTL(e,n).toPromise(),this.saveItemToDb(e,t,r).toPromise()}),Object(D.catchError)(()=>this.getCached(e,t,n,r,i,o,s)))}getCached(e,t,n,r,i,o,s){return this.isItemCachedInDb(n,e).pipe(Object(D.mergeMap)(a=>a?this.isItemTTLExpired(n,e,isNaN(o)?this.apiConfig.cached_requests.timeToLive:o).pipe(Object(D.mergeMap)(i=>i?this.keyValueStore.getValue(t+"-"+e).pipe(Object(D.map)(e=>JSON.parse(e)),Object(D.tap)(()=>ea(this,void 0,void 0,(function*(){try{yield r().pipe(Object(D.switchMap)(r=>this.saveItem(e,n,t,r,s))).toPromise()}catch(e){console.error(e)}})))):this.keyValueStore.getValue(t+"-"+e).pipe(Object(D.map)(e=>JSON.parse(e))))):i?i().pipe(Object(D.switchMap)(r=>this.saveItem(e,n,t,r,s)),Object(D.catchError)(i=>r().pipe(Object(D.switchMap)(r=>this.saveItem(e,n,t,r,s))))):r().pipe(Object(D.switchMap)(r=>this.saveItem(e,n,t,r,s)))))}isItemCachedInDb(e,t){return this.sharedPreferences.getString(e+"-"+t).pipe(Object(D.mergeMap)(e=>Object(c.iif)(()=>!!e,Object(c.defer)(()=>Object(c.of)(!0)),Object(c.defer)(()=>Object(c.of)(!1)))))}isItemTTLExpired(e,t,n){return this.sharedPreferences.getString(e+"-"+t).pipe(Object(D.map)(e=>{const t=Number(e);return!(Date.now()-t<n)}))}saveItem(e,t,n,r,i){return Xs.isItemEmpty(r)||i&&i(r)?Object(c.of)(r):Object(c.zip)(this.saveItemTTL(e,t),this.saveItemToDb(e,n,r)).pipe(Object(D.switchMap)(()=>Object(c.of)(r)))}saveItemTTL(e,t){return this.sharedPreferences.putString(t+"-"+e,Date.now()+"").pipe(Object(D.mergeMap)(e=>Object(c.of)(!0)))}saveItemToDb(e,t,n){return this.keyValueStore.setValue(t+"-"+e,JSON.stringify(n))}};var na;ta=Xs=Js([Object(s.injectable)(),Zs(0,Object(s.inject)(l.SDK_CONFIG)),Zs(1,Object(s.inject)(l.KEY_VALUE_STORE)),Zs(2,Object(s.inject)(l.SHARED_PREFERENCES)),Qs("design:paramtypes",[Object,Object,Object])],ta),function(e){e.RESOURCE="Resource",e.COURSE="Course",e.ANONYMOUS_COURSE="AnonymousCourse",e.DIAL_CODE="DIAL Code Consumption"}(na||(na={}));var ra=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ia{constructor(e,t,n,r,i,o,s,a){this.apiService=e,this.pageApiServiceConfig=t,this.sharedPreferences=n,this.cachedItemStore=r,this.keyValueStore=i,this.authService=o,this.profileService=s,this.systemSettingsService=a,this.PAGE_ASSEMBLE_LOCAL_KEY="page_assemble-",this.PAGE_ASSEMBLE_ENDPOINT="/page/assemble?orgdetails=orgName",this.DIALCODE_ASSEMBLE_ENDPOINT="/dial/assemble"}static getIdForDb(e){return e.name+"-"+(e.organisationId||"")+"-"+(e.source||"app")+"-"+(e.mode||"")+"-"+(e.filters?ms(JSON.stringify(e.filters)).toString():"")+(e.sections?ms(JSON.stringify(e.sections)).toString():"")}handle(e){return e.from=e.from||Jn.CACHE,Object(c.defer)(()=>ra(this,void 0,void 0,(function*(){if(e.name!==na.COURSE)return e;const t=yield this.sharedPreferences.getString(y.KEY_ORGANISATION_ID).toPromise();if(!t)return e;if(yield(()=>ra(this,void 0,void 0,(function*(){const e=!!(yield this.authService.getSession().toPromise()),t=yield this.profileService.isDefaultChannelProfile().toPromise();return e&&!t})))())return e;const n=yield this.systemSettingsService.getSystemSettings({id:ia.SYSTEM_SETTINGS_TENANT_COURSE_PAGE_ID}).toPromise().then(e=>{try{return JSON.parse(e.value)}catch(e){return console.error(e),[]}});e.organisationId=t;const r=n.find(e=>e.channelId===t);return r&&(e.name=r.page),e}))).pipe(Object(D.mergeMap)(e=>e.from===Jn.SERVER?this.fetchFromServer(e).pipe(Object(D.catchError)(()=>this.fetchFromCache(e))):this.fetchFromCache(e)))}fetchFromServer(e){const t=e.name===na.DIAL_CODE?this.DIALCODE_ASSEMBLE_ENDPOINT:this.PAGE_ASSEMBLE_ENDPOINT,n=(new a.CsRequest.Builder).withHost(this.pageApiServiceConfig.host).withType(a.CsHttpRequestType.POST).withPath(this.pageApiServiceConfig.apiPath+t).withBearerToken(!0).withBody({request:e}).build();return this.apiService.fetch(n).pipe(Object(D.map)(e=>e.body.result.response),Object(D.tap)(t=>{const n=JSON.stringify(t);this.sharedPreferences.putString("ttl_"+this.PAGE_ASSEMBLE_LOCAL_KEY+"-"+ia.getIdForDb(e),Date.now()+"").toPromise(),this.keyValueStore.setValue(this.PAGE_ASSEMBLE_LOCAL_KEY+"-"+ia.getIdForDb(e),n).toPromise()}))}fetchFromCache(e){return this.cachedItemStore.getCached(ia.getIdForDb(e),this.PAGE_ASSEMBLE_LOCAL_KEY,"ttl_"+this.PAGE_ASSEMBLE_LOCAL_KEY,()=>this.fetchFromServer(e))}}ia.SYSTEM_SETTINGS_TENANT_COURSE_PAGE_ID="tenantCoursePage";var oa=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class sa{constructor(e,t){this.defaultDelegate=e,this.dbService=t}handle(e){return Object(c.defer)(()=>oa(this,void 0,void 0,(function*(){let t;try{t=yield this.defaultDelegate.handle(e).toPromise()}catch(e){console.error(e)}if(e.filters&&e.filters.dialcodes){const n=`SELECT c.* FROM content c WHERE ref_count > 0 AND dialcodes LIKE '%%~${e.filters.dialcodes}~%%'`,r=(yield this.dbService.execute(n).toPromise()).map(e=>xn.mapContentDBEntryToContent(e).contentData);t&&t.sections[0]&&r.length?t=yield this.mergePageAssembleWithLocalContents(t,r):!t&&r.length&&(t=yield this.buildPageAssembleWithLocalContents(r))}if(!t)throw new Error("NO_DATA");return t})))}buildPageAssembleWithLocalContents(e){return oa(this,void 0,void 0,(function*(){const t={name:"",id:"",sections:[{display:"",count:0,index:0,sectionDataType:"",resmsgId:"",searchQuery:"",name:"",id:"",apiId:"",group:0,contents:e}]};return this.mergePageAssembleWithLocalCollections(t,e)}))}mergePageAssembleWithLocalContents(e,t){return oa(this,void 0,void 0,(function*(){const n=e.sections[0];if(n.contents&&n.contents.length){const r=t.filter(e=>!n.contents.find(t=>t.identifier===e.identifier));r.length&&(n.contents=[...r,...n.contents],e=yield this.mergePageAssembleWithLocalCollections(e,r))}else n.contents=t,e=yield this.mergePageAssembleWithLocalCollections(e,t);return e}))}mergePageAssembleWithLocalCollections(e,t){return oa(this,void 0,void 0,(function*(){const n=e.sections[0];n.collections||(n.collections=[]);for(const e of t){const t=`SELECT c.* FROM content c WHERE c.visibility = 'Default' AND ref_count > 0 AND child_nodes LIKE '%%~${e.identifier}~%%'`,r=(yield this.dbService.execute(t).toPromise()).map(e=>xn.mapContentDBEntryToContent(e).contentData);if(r.length)for(const t of r){const r=n.collections.find(e=>e.identifier===t.identifier);r?r.childNodes.indexOf(e.identifier)>=0||r.childNodes.push(e.identifier):n.collections.push(Object.assign(Object.assign({},t),{childNodes:[e.identifier]}))}}return e}))}}var aa=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ca{constructor(e,t,n,r){this.defaultDelegate=e,this.authService=t,this.frameworkService=n,this.systemSettingsService=r,this.ssoSectionIdMap=new Map}handle(e){return Object(c.defer)(()=>aa(this,void 0,void 0,(function*(){if(!!!(yield this.authService.getSession().toPromise()))return e;const t=yield this.frameworkService.getDefaultChannelId().toPromise(),n=this.frameworkService.activeChannelId;if(!(n===t)){let t;try{const e=yield this.systemSettingsService.getSystemSettings({id:ca.SSO_COURSE_SECTION_ID}).toPromise();t=e&&e.value}catch(e){console.error(e)}t&&(e.sections={[t]:{filters:{"batches.createdFor":[n]}}},this.ssoSectionIdMap.set(e.name+"-"+n,t))}return e}))).pipe(Object(D.mergeMap)(e=>this.defaultDelegate.handle(e)),Object(D.map)(t=>{const n=this.ssoSectionIdMap.get(e.name+"-"+this.frameworkService.activeChannelId);return n&&(t.ssoSectionId=n),t}))}}ca.SSO_COURSE_SECTION_ID="ssoCourseSection";class ua{constructor(e,t,n,r,i,o,s,a,c,u){this.apiService=e,this.pageApiServiceConfig=t,this.cachedItemStore=n,this.keyValueStore=r,this.sharedPreferences=i,this.frameworkService=o,this.authService=s,this.systemSettingsService=a,this.dbService=c,this.profileService=u,this.defaultRequestDelegate=new ia(e,t,i,n,r,s,u,a),this.dialcodeRequestDelegate=new sa(this.defaultRequestDelegate,c),this.courseRequestDelegate=new ca(this.defaultRequestDelegate,s,o,a)}handle(e){switch(e.from=e.from||Jn.CACHE,e.name){case na.COURSE:return this.courseRequestDelegate.handle(e);case na.DIAL_CODE:return this.dialcodeRequestDelegate.handle(e);default:return this.defaultRequestDelegate.handle(e)}}}var la=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},da=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ha=function(e,t){return function(n,r){t(n,r,e)}};let Ea=class{constructor(e,t,n,r,i,o,s,a,c,u){this.apiService=e,this.sdkConfig=t,this.cachedItemStore=n,this.keyValueStore=r,this.sharedPreferences=i,this.frameworkService=o,this.authService=s,this.systemSettingsService=a,this.dbService=c,this.profileService=u,this.pageAssembleServiceConfig=this.sdkConfig.pageServiceConfig}setPageAssembleChannel(e){this.sharedPreferences.putString(y.KEY_ORGANISATION_ID,e.channelId).toPromise()}getPageAssemble(e){return new ua(this.apiService,this.pageAssembleServiceConfig,this.cachedItemStore,this.keyValueStore,this.sharedPreferences,this.frameworkService,this.authService,this.systemSettingsService,this.dbService,this.profileService).handle(e)}};Ea=la([Object(s.injectable)(),ha(0,Object(s.inject)(l.API_SERVICE)),ha(1,Object(s.inject)(l.SDK_CONFIG)),ha(2,Object(s.inject)(l.CACHED_ITEM_STORE)),ha(3,Object(s.inject)(l.KEY_VALUE_STORE)),ha(4,Object(s.inject)(l.SHARED_PREFERENCES)),ha(5,Object(s.inject)(l.FRAMEWORK_SERVICE)),ha(6,Object(s.inject)(l.AUTH_SERVICE)),ha(7,Object(s.inject)(l.SYSTEM_SETTINGS_SERVICE)),ha(8,Object(s.inject)(l.DB_SERVICE)),ha(9,Object(s.inject)(l.PROFILE_SERVICE)),da("design:paramtypes",[Object,Object,Object,Object,Object,Object,Object,Object,o,Object])],Ea);var fa=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};let pa=class{constructor(){this.listeners=new Map}getString(e){return Object(c.defer)(()=>Object(c.of)(localStorage.getItem(e)).pipe(Object(D.map)(e=>e||void 0)))}putString(e,t){return Object(c.defer)(()=>Object(c.of)(localStorage.setItem(e,t)).pipe(Object(D.mapTo)(void 0)))}putBoolean(e,t){return Object(c.defer)(()=>Object(c.of)(localStorage.setItem(e,t+"")).pipe(Object(D.mapTo)(!0)))}getBoolean(e){return Object(c.defer)(()=>Object(c.of)("true"===localStorage.getItem(e)))}addListener(e,t){const n=this.listeners.get(e)||[];n.push(t),this.listeners.set(e,n)}removeListener(e,t){const n=this.listeners.get(e)||[];this.listeners.set(e,n.filter(e=>e!==t))}};pa=fa([Object(s.injectable)()],pa);var _a,Oa=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};let Sa=_a=class{constructor(){this.listeners=new Map,this.sharedPreferences=plugins.SharedPreferences.getInstance(_a.sharedPreferncesName)}getString(e){const t=localStorage.getItem(e);return t?(localStorage.removeItem(e),this.putString(e,t).pipe(Object(D.mapTo)(t))):new c.Observable(t=>{this.sharedPreferences.getString(e,"",e=>{t.next(e),t.complete()},e=>{t.error(e)})})}putString(e,t){return new c.Observable(n=>{this.sharedPreferences.putString(e,t,()=>{(this.listeners.get(e)||[]).forEach(e=>e(t)),n.next(void 0),n.complete()},e=>{n.error(e)})})}putBoolean(e,t){return new c.Observable(n=>{this.sharedPreferences.putBoolean(e,t,()=>{(this.listeners.get(e)||[]).forEach(e=>e(t)),n.next(!0),n.complete()},e=>{n.error(e)})})}getBoolean(e){const t=localStorage.getItem(e);return t?(localStorage.removeItem(e),this.putBoolean(e,"true"===t).pipe(Object(D.mapTo)("true"===t))):new c.Observable(t=>{this.sharedPreferences.getBoolean(e,!1,e=>{t.next(e),t.complete()},e=>{t.error(e)})})}addListener(e,t){const n=this.listeners.get(e)||[];n.push(t),this.listeners.set(e,n)}removeListener(e,t){const n=this.listeners.get(e)||[];this.listeners.set(e,n.filter(e=>e!==t))}};var ga;Sa.sharedPreferncesName="org.ekstep.genieservices.preference_file",Sa=_a=Oa([Object(s.injectable)()],Sa),function(e){e[e.PERSISTENT=1]="PERSISTENT",e[e.TEMPORARY=0]="TEMPORARY"}(ga||(ga={}));var Aa=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};let Na=class{constructor(){this.initialized=!1}init(){file.requestFileSystem(ga.PERSISTENT,0,e=>{this.initialized=!0,this.fileSystem=e},()=>{})}readAsText(e,t){return this.readFile(e,t,"Text")}readAsBinaryString(e,t){return this.readFile(e,t,"BinaryString")}readFileFromAssets(e){return new Promise((t,n)=>{try{sbutility.readFromAssets(e,e=>{t(e)},e=>{n(e)})}catch(e){n(e)}})}writeFile(e,t,n,r={}){const i={create:!r.append,exclusive:!r.replace};return this.resolveDirectoryUrl(e).then(e=>this.getFile(e,t,i)).then(e=>this.writeFileEntry(e,n,r))}createFile(e,t,n){const r={create:!0};return n||(r.exclusive=!0),this.resolveDirectoryUrl(e).then(e=>this.getFile(e,t,r))}getFile(e,t,n){return new Promise((r,i)=>{try{e.getFile(t,n,e=>{r(e)},e=>{i(e)})}catch(e){i(e)}})}removeFile(e){const t=Mo.getParentDir(e),n=Mo.getFileName(e).replace("/","");return this.resolveDirectoryUrl(t).then(e=>this.getFile(e,n,{create:!1})).then(e=>this.remove(e))}createDir(e,t){const n={create:!0};t||(n.exclusive=!0);const r=Mo.getParentDir(e),i=Mo.getFileName(e).replace("/","");return this.exists(e).then(()=>this.resolveDirectoryUrl(e)).catch(()=>this.resolveDirectoryUrl(r).then(e=>this.getDirectory(e,i,n)))}listDir(e){return this.resolveDirectoryUrl(Mo.getDirecory(e)).then(t=>this.getDirectory(t,Mo.getFileName(e),{create:!1,exclusive:!1})).then(e=>{const t=e.createReader();return this.readEntries(t)})}removeDir(e,t){return this.resolveDirectoryUrl(e).then(e=>this.getDirectory(e,t,{create:!1})).then(e=>this.remove(e))}removeRecursively(e){e=e.endsWith("/")?e.substring(0,e.length-1):e;const t=Mo.getParentDir(e),n=Mo.getFileName(e).replace("/","");return this.resolveDirectoryUrl(t).then(e=>this.getDirectory(e,n,{create:!1})).then(e=>this.rimraf(e))}copyDir(e,t,n,r){return this.resolveDirectoryUrl(e).then(e=>this.getDirectory(e,t,{create:!1})).then(e=>this.resolveDirectoryUrl(n).then(t=>this.copy(e,t,r)))}copyFile(e,t,n,r){return r=r||t,this.resolveDirectoryUrl(e).then(e=>this.getFile(e,t,{create:!1})).then(e=>this.resolveDirectoryUrl(n).then(t=>this.copy(e,t,r)))}exists(e){return this.resolveLocalFilesystemUrl(e)}getTempLocation(e){return this.resolveDirectoryUrl(e).then(t=>this.resolveDirectoryUrl(e.concat("tmp"))).catch(()=>this.createDir(e.concat("tmp"),!1))}getFreeDiskSpace(){return new Promise((e,t)=>{cordova.exec(()=>e,t,"File","getFreeDiskSpace",[])})}resolveLocalFilesystemUrl(e){return e.includes("file://")||(e="file://"+e),console.log(e),new Promise((t,n)=>{try{resolveLocalFileSystemURL(e,e=>{t(e)},e=>{n(e)})}catch(e){n(e)}})}getMetaData(e){if("string"==typeof e)return this.resolveLocalFilesystemUrl(e).then(e=>this.getMetaData(e));const t=e;return new Promise(e=>{t.getMetadata(t=>{e(t)},()=>e({modificationTime:new Date,size:1}))})}getExternalApplicationStorageDirectory(){return file.externalApplicationStorageDirectory}getDirectorySize(e){return this.resolveDirectoryUrl(e).then(e=>this.size(e)).catch(()=>0)}size(e){return e.isFile?new Promise((t,n)=>{e.getMetadata(e=>t(e.size),e=>n(e))}):e.isDirectory?new Promise((t,n)=>{e.createReader().readEntries(e=>{Promise.all(e.map(e=>this.size(e))).then(e=>{const n=e.reduce((e,t)=>e+t,0);t(n)}).catch(e=>n(e))},e=>n(e))}):Promise.resolve(0)}readEntries(e){return new Promise((t,n)=>{e.readEntries(e=>{t(e)},e=>{n(e)})})}getFileReader(){const e=new FileReader;return e.__zone_symbol__originalInstance||e}readFile(e,t,n){return this.resolveDirectoryUrl(e).then(e=>this.getFile(e,t,{create:!1})).then(e=>{let t=this.getFileReader();return new Promise((n,r)=>{e.file(e=>{t.onloadend=e=>{void 0!==t.result&&null!==t.result?n(t.result):void 0!==t.error&&null!==t.error?r(t.error):r({code:null,message:"READER_ONLOADEND_ERR"})},t.readAsText(e)},e=>{r(e)})})}).catch(e=>{throw e})}resolveDirectoryUrl(e){return this.resolveLocalFilesystemUrl(e).then(e=>e.isDirectory?e:Promise.reject("input is not a directory"))}remove(e){return new Promise((t,n)=>{e.remove(()=>{t({success:!0,fileRemoved:e})},e=>{n(e)})})}copy(e,t,n){return new Promise((r,i)=>{e.copyTo(t,n,e=>{r(e)},e=>{i(e)})})}getDirectory(e,t,n){return new Promise((r,i)=>{try{e.getDirectory(t,n,e=>{r(e)},e=>{i(e)})}catch(e){i(e)}})}rimraf(e){return new Promise((t,n)=>{e.removeRecursively(()=>{t({success:!0,fileRemoved:e})},e=>{n(e)})})}createWriter(e){return new Promise((t,n)=>{e.createWriter(e=>{t(e)},e=>{n(e)})})}writeFileEntry(e,t,n){return this.createWriter(e).then(e=>(n.append&&e.seek(e.length),n.truncate&&e.truncate(n.truncate),this.write(e,t))).then(()=>e)}write(e,t){return new Promise((n,r)=>{e.onwriteend=t=>{e.error?r(e.error):n(t)},e.write(t)})}};Na=Aa([Object(s.injectable)()],Na);var Ta=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ca extends i{constructor(){super(2,17)}apply(e){return Ta(this,void 0,void 0,(function*(){this.queries().forEach(t=>Ta(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()})))}))}queries(){return[et.getAlterEntryForProfileSyllabus()]}}var va=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ya extends i{constructor(){super(3,18)}apply(e){return va(this,void 0,void 0,(function*(){this.queries().forEach(t=>va(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()}))),yield e.read({table:et.TABLE_NAME,columns:[]}).pipe(Object(D.map)(t=>{t.forEach(t=>va(this,void 0,void 0,(function*(){t[et.COLUMN_NAME_UID]===t[et.COLUMN_NAME_HANDLE]?t[et.COLUMN_NAME_SOURCE]=Wn.SERVER.valueOf():t[et.COLUMN_NAME_SOURCE]=Wn.LOCAL.valueOf(),yield e.update({table:et.TABLE_NAME,modelJson:t}).toPromise()})))})).toPromise()}))}queries(){return[it.getCreateEntry(),st.getCreateEntry()]}updateProfileTable(){}}var ma=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ba extends i{constructor(){super(4,19)}apply(e){return ma(this,void 0,void 0,(function*(){yield e.read({table:lt.TABLE_NAME,columns:[]}).pipe(Object(D.map)(t=>{t.forEach(t=>ma(this,void 0,void 0,(function*(){const n=Number(t[ht.COLUMN_NAME_TOTAL_TS]);t[ht.COLUMN_NAME_TOTAL_TS]=Math.round(n/1e3),yield e.update({table:ht.TABLE_NAME,modelJson:t}).toPromise()})))})).toPromise()}))}queries(){return[]}}var Ia=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ma extends i{constructor(){super(7,22)}apply(e){return Ia(this,void 0,void 0,(function*(){this.queries().forEach(t=>Ia(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()})))}))}queries(){return[Rt.getCreateEntry()]}}var Ra=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class La extends i{constructor(){super(18,31)}apply(e){return Ra(this,void 0,void 0,(function*(){this.queries().forEach(t=>Ra(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()}))),this.updateProfileDB(e)}))}queries(){return[et.getAlterEntryForProfileCategories()]}updateProfileDB(e){return Ra(this,void 0,void 0,(function*(){try{(yield e.read({table:et.TABLE_NAME}).toPromise()).forEach(t=>Ra(this,void 0,void 0,(function*(){const n=this.getUpdateQueries(t),r={};r[et.COLUMN_NAME_CATEGORIES]=JSON.stringify(n),yield e.update({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[t.uid],modelJson:r}).toPromise()})))}catch(e){console.log("error",e)}}))}getUpdateQueries(e){const t={};return t.fwCategory1=e.board,t.fwCategory2=e.medium,t.fwCategory3=e.grade,t.fwCategory4=e.subject,t}}var Pa=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Da extends i{constructor(){super(5,20)}apply(e){return Pa(this,void 0,void 0,(function*(){this.queries().forEach(t=>Pa(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()})))}))}queries(){return[vt.getCreateEntry()]}}class wa{constructor(e,t,n,r){this.apiService=e,this.systemSettingsConfig=t,this.fileservice=n,this.cachedItemStore=r,this.SYSTEM_SETTINGS_FILE_KEY_PREFIX="system-setting-",this.SYSTEM_SETTINGS_LOCAL_KEY="system-settings-",this.GET_SYSTEM_SETTINGS_ENDPOINT="/system/settings/get"}handle(e){return this.cachedItemStore.getCached(e.id,this.SYSTEM_SETTINGS_LOCAL_KEY,"ttl_"+this.SYSTEM_SETTINGS_LOCAL_KEY,()=>this.fetchFromServer(e),()=>this.fetchFromFile(e))}fetchFromServer(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.systemSettingsConfig.systemSettingsApiPath+this.GET_SYSTEM_SETTINGS_ENDPOINT+"/"+e.id).withBearerToken(!0).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result.response))}fetchFromFile(e){const t=lr.getAssetPath()+this.systemSettingsConfig.systemSettingsDirPath,n=this.SYSTEM_SETTINGS_FILE_KEY_PREFIX+e.id+".json";return Object(c.from)(this.fileservice.readFileFromAssets(t.concat("/",n))).pipe(Object(D.map)(e=>JSON.parse(e).result.response))}}var Ua=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},ja=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Fa=function(e,t){return function(n,r){t(n,r,e)}};let ka=class{constructor(e,t,n,r){this.sdkConfig=e,this.apiService=t,this.fileService=n,this.cachedChannelItemStore=r,this.systemSettingsConfig=this.sdkConfig.systemSettingsConfig}getSystemSettings(e){return new wa(this.apiService,this.systemSettingsConfig,this.fileService,this.cachedChannelItemStore).handle(e)}};ka=Ua([Object(s.injectable)(),Fa(0,Object(s.inject)(l.SDK_CONFIG)),Fa(1,Object(s.inject)(l.API_SERVICE)),Fa(2,Object(s.inject)(l.FILE_SERVICE)),Fa(3,Object(s.inject)(l.CACHED_ITEM_STORE)),ja("design:paramtypes",[Object,Object,Object,Object])],ka);var xa=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};let Ba=class{unzip(e,t,n,r){JJzip.unzip(e,t,()=>{n&&n()},e=>{r&&r(e)})}zip(e,t,n,r,i,o){JJzip.zip(e,t,n,r,()=>{i&&i()},e=>{o&&o(e)})}};var Va,Ya,Ga;Ba=xa([Object(s.injectable)()],Ba),function(e){e.INTERNAL_STORAGE="INTERNAL_STORAGE",e.EXTERNAL_STORAGE="EXTERNAL_STORAGE"}(Va||(Va={})),function(e){e.TRANSFER_PROGRESS="TRANSFER_PROGRESS",e.TRANSFER_COMPLETED="TRANSFER_COMPLETED",e.TRANSFER_REVERT_COMPLETED="TRANSFER_REVERT_COMPLETED",e.TRANSFER_FAILED_DUPLICATE_CONTENT="TRANSFER_FAILED_DUPLICATE_CONTENT",e.TRANSFER_FAILED_LOW_MEMORY="TRANSFER_FAILED_LOW_MEMORY"}(Ya||(Ya={})),function(e){e.IGNORE="IGNORE",e.KEEP_HIGER_VERSION="KEEP_HIGER_VERSION",e.KEEP_LOWER_VERSION="KEEP_LOWER_VERSION",e.KEEP_SOURCE="KEEP_SOURCE",e.KEEP_DESTINATION="KEEP_DESTINATION"}(Ga||(Ga={}));class Ha extends ke{constructor(e){super(e,"TRANSFER_FAILED_DUPLICATE_CONTENT_ERROR"),Object.setPrototypeOf(this,Ha.prototype)}}class $a extends ke{constructor(e,t){super(e,"TRANSFER_FAILED_ERROR"),this.directory=t,Object.setPrototypeOf(this,$a.prototype)}}var qa=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ka=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};let za=class{constructor(){this.deviceId=ms(window.device.uuid).toString()}getDeviceID(){return this.deviceId}getDeviceSpec(){return this.deviceSpec?Object(c.of)(this.deviceSpec):new c.Observable(e=>{sbutility.getDeviceSpec(t=>{this.deviceSpec=t,e.next(t),e.complete()})})}getAvailableInternalMemorySize(){return new c.Observable(e=>{sbutility.getAvailableInternalMemorySize(t=>{e.next(t),e.complete()},t=>{e.error(t)})})}getStorageVolumes(){return c.Observable.create(e=>{sbutility.getStorageVolumes(t=>{e.next(t.map(e=>e.isRemovable?{storageDestination:Va.EXTERNAL_STORAGE,info:Object.assign({},e)}:{storageDestination:Va.INTERNAL_STORAGE,info:Object.assign({},e)})),e.complete()},t=>{e.error(t)})})}isKeyboardShown(){let e,t,n,r;return new c.Observable(i=>{e=()=>i.next(!0),t=()=>i.next(!0),n=()=>i.next(!1),r=()=>i.next(!1),window.addEventListener("native.keyboardshow",e),window.addEventListener("keyboardWillShow",t),window.addEventListener("native.keyboardhide",n),window.addEventListener("keyboardWillHide",n)}).pipe(Object(D.distinctUntilChanged)(),Object(D.tap)(()=>{console.log("Subscribed isKeyboardShown event")}),Object(D.finalize)(()=>{console.log("Unsubscribed isKeyboardShown event"),window.removeEventListener("native.keyboardshow",e),window.removeEventListener("keyboardWillShow",t),window.removeEventListener("native.keyboardhide",n),window.removeEventListener("keyboardWillHide",n)}))}};za=qa([Object(s.injectable)(),Ka("design:paramtypes",[])],za);var Wa=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Xa=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ja=function(e,t){return function(n,r){t(n,r,e)}};let Qa=class{constructor(e,t,n){this.dbService=e,this.profileService=t,this.telemetryService=n}getFeedback(e){const t=`SELECT * FROM ${Tt.TABLE_NAME} ${kn.getUidnIdentifierFiler(e.uid,e.contentId)}`;return this.dbService.execute(t).pipe(Object(D.map)(e=>e.map(e=>class{static mapFeedbackDBEntrytoResponseFeedback(e){return{contentId:e[Tt.COLUMN_NAME_CONTENT_ID],rating:Number(e[Tt.COLUMN_NAME_RATING]),comments:e[Tt.COLUMN_NAME_COMMENTS],createdAt:Number(e[Tt.COLUMN_NAME_CREATED_AT]),stageId:"",contentVersion:""}}}.mapFeedbackDBEntrytoResponseFeedback(e))))}sendFeedback(e){return this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(t=>{const n={table:Tt.TABLE_NAME,selection:(new Kt).where("? = ? AND ? = ?").args([Tt.COLUMN_NAME_CONTENT_ID,e.contentId,Tt.COLUMN_NAME_UID,t.uid]).end().build(),limit:"1"},r={uid:t.uid,identifier:e.contentId,rating:e.rating,comments:e.comments,createdAt:Date.now()};return this.telemetryService.feedback({env:"sdk",rating:e.rating,comments:e.comments,objId:e.contentId,objType:ie.CONTENT.valueOf(),objVer:e.contentVersion}).pipe(Object(D.mergeMap)(()=>this.dbService.read(n).pipe(Object(D.mergeMap)(n=>n&&n.length?this.dbService.update({table:Tt.TABLE_NAME,selection:`${Tt.COLUMN_NAME_UID}= ? AND ${Tt.COLUMN_NAME_CONTENT_ID}= ?`,selectionArgs:[t.uid,e.contentId],modelJson:r}).pipe(Object(D.map)(e=>e>0)):this.dbService.insert({table:Tt.TABLE_NAME,modelJson:r}).pipe(Object(D.map)(e=>e>0))))))}))}};Qa=Wa([Object(s.injectable)(),Ja(0,Object(s.inject)(l.DB_SERVICE)),Ja(1,Object(s.inject)(l.PROFILE_SERVICE)),Ja(2,Object(s.inject)(l.TELEMETRY_SERVICE)),Xa("design:paramtypes",[o,Object,Object])],Qa);var Za=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},ec=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},tc=function(e,t){return function(n,r){t(n,r,e)}},nc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let rc=class{constructor(e){this.sdkConfig=e,this.eventsBus=new c.Subject,this.eventDelegates=[],this.eventsBusConfig=this.sdkConfig.eventsBusConfig}onInit(){return this.eventsBus.pipe(Object(D.tap)(e=>{this.eventsBusConfig.debugMode&&console.log("SDK Telemetry Events",e)}),Object(D.tap)(e=>nc(this,void 0,void 0,(function*(){const t=this.eventDelegates.filter(t=>t.namespace===e.namespace).map(t=>t.observer.onEvent(e.event).pipe(Object(D.take)(1),Object(D.catchError)(e=>(console.error("Error: ",e,"EventObserver: ",t),Object(c.of)(void 0)))));try{yield Object(c.zip)(...t).toPromise()}catch(e){console.error("EVENT_BUS_DELEGATE_ERROR",e)}}))),Object(D.mapTo)(void 0))}events(e){return this.eventsBus.asObservable().pipe(Object(D.filter)(t=>!e||t.namespace===e),Object(D.map)(e=>e.event))}emit({namespace:e,event:t}){this.eventsBus.next({namespace:e,event:t})}registerObserver({namespace:e,observer:t}){this.eventDelegates.push({namespace:e,observer:t})}};rc=Za([Object(s.injectable)(),tc(0,Object(s.inject)(l.SDK_CONFIG)),ec("design:paramtypes",[Object])],rc);var ic,oc=n(51),sc=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},ac=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},cc=function(e,t){return function(n,r){t(n,r,e)}},uc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let lc=ic=class{constructor(e,t){this.eventsBusService=e,this.sharedPreferences=t,this.currentDownloadRequest$=new c.BehaviorSubject(void 0),this.completedDownloadRequestsCache=new Eo.a(e=>e.identifier),window.downloadManager=oc,this.sharedPreferencesSetCollection=new gs(this.sharedPreferences,ic.KEY_TO_DOWNLOAD_LIST,e=>e.identifier)}static generateDownloadStartTelemetry(e){return uc(this,void 0,void 0,(function*(){return ln.log.interact({type:oe.OTHER,subType:se.CONTENT_DOWNLOAD_INITIATE,env:"sdk",pageId:"ContentDetail",id:"ContentDetail",objId:e.identifier,objType:e.contentMeta&&e.contentMeta.primaryCategory?kn.readPrimaryCategoryServer(e.contentMeta):"Content",objVer:e.contentMeta&&e.contentMeta.pkgVersion?e.contentMeta.pkgVersion:"",correlationData:e.correlationData||[]}).pipe(Object(D.mapTo)(void 0)).toPromise()}))}static generateDownloadCompleteTelemetry(e){return uc(this,void 0,void 0,(function*(){return ln.log.interact({type:oe.OTHER,subType:se.CONTENT_DOWNLOAD_SUCCESS,env:"sdk",pageId:"ContentDetail",id:"ContentDetail",objId:e.identifier,objType:e.contentMeta&&e.contentMeta.primaryCategory?kn.readPrimaryCategoryServer(e.contentMeta):"Content",objVer:e.contentMeta&&e.contentMeta.pkgVersion?e.contentMeta.pkgVersion:"",correlationData:e.correlationData||[]}).pipe(Object(D.mapTo)(void 0)).toPromise()}))}static generateDownloadCancelTelemetry(e){return uc(this,void 0,void 0,(function*(){return ln.log.interact({type:oe.OTHER,subType:se.CONTENT_DOWNLOAD_CANCEL,env:"sdk",pageId:"ContentDetail",id:"ContentDetail",objId:e.identifier,objType:e.contentMeta&&e.contentMeta.primaryCategory?kn.readPrimaryCategoryServer(e.contentMeta):"Content",objVer:e.contentMeta&&e.contentMeta.pkgVersion?e.contentMeta.pkgVersion:"",correlationData:e.correlationData||[]}).pipe(Object(D.mapTo)(void 0)).toPromise()}))}onInit(){return this.switchToNextDownloadRequest().pipe(Object(D.mergeMap)(()=>this.listenForDownloadProgressChanges()))}download(e){return this.currentDownloadRequest$.pipe(Object(D.take)(1),Object(D.mergeMap)(t=>t?this.addToDownloadList(e):(console.log("SDK download downloadRequests -",e),this.addToDownloadList(e).pipe(Object(D.tap)(()=>this.switchToNextDownloadRequest().toPromise())))))}cancel(e,t=!0){return this.currentDownloadRequest$.pipe(Object(D.take)(1),Object(D.mergeMap)(n=>n&&n.identifier===e.identifier?new c.Observable(e=>{downloadManager.remove([n.downloadId],(t,n)=>{t&&e.error(t),e.next(!!n),e.complete()})}).pipe(Object(D.mergeMap)(()=>this.removeFromDownloadList(e,t)),Object(D.tap)(()=>this.switchToNextDownloadRequest().toPromise())):this.removeFromDownloadList(e,t)))}cancelAll(){return this.currentDownloadRequest$.pipe(Object(D.take)(1),Object(D.mergeMap)(e=>e?new c.Observable(t=>{downloadManager.remove([e.downloadId],(e,n)=>{e&&t.error(e),t.next(!!n),t.complete()})}).pipe(Object(D.mergeMap)(()=>this.removeAllFromDownloadList()),Object(D.mergeMap)(()=>this.switchToNextDownloadRequest())):this.removeAllFromDownloadList()))}registerOnDownloadCompleteDelegate(e){this.downloadCompleteDelegate=e}getActiveDownloadRequests(){return this.sharedPreferencesSetCollection.asListChanges().pipe(Object(D.map)(e=>e.sort((e,t)=>{const n=e.withPriority||0;return(t.withPriority||0)-n})))}switchToNextDownloadRequest(){return this.sharedPreferencesSetCollection.asSet().pipe(Object(D.mergeMap)(e=>{if(!e.size())return Object(c.of)(void 0).pipe(Object(D.tap)(()=>this.currentDownloadRequest$.next(void 0)));const t=e.toArray().sort((e,t)=>{const n=e.withPriority||0;return(t.withPriority||0)-n}).shift();return new c.Observable(e=>{downloadManager.enqueue({uri:t.downloadUrl,title:t.filename,description:"",mimeType:t.mimeType,visibleInDownloadsUi:!0,notificationVisibility:1,destinationInExternalFilesDir:{dirType:ic.DOWNLOAD_DIR_NAME,subPath:t.filename},headers:[]},(t,n)=>{if(t)return e.error(t);e.next(n)})}).pipe(Object(D.tap)(e=>{let n="ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalDataDirectory;t.downloadedFilePath=n+ic.DOWNLOAD_DIR_NAME+"/"+t.filename,t.downloadId=e,this.currentDownloadRequest$.next(t)}),Object(D.tap)(()=>uc(this,void 0,void 0,(function*(){return yield ic.generateDownloadStartTelemetry(t)}))),Object(D.mapTo)(void 0),Object(D.catchError)(()=>this.cancel({identifier:t.identifier})))}))}addToDownloadList(e){return console.log("addToDownloadList rq -",e),this.sharedPreferencesSetCollection.addAll(e).pipe(Object(D.mapTo)(void 0))}removeFromDownloadList(e,t){return this.sharedPreferencesSetCollection.asList().pipe(Object(D.mergeMap)(n=>{const r=n.find(t=>t.identifier===e.identifier);return r?this.sharedPreferencesSetCollection.remove(r).pipe(Object(D.mapTo)(void 0),Object(D.tap)(()=>uc(this,void 0,void 0,(function*(){return t&&(yield ic.generateDownloadCancelTelemetry(r))})))):Object(c.of)(void 0)}))}removeAllFromDownloadList(){return this.sharedPreferencesSetCollection.asList().pipe(Object(D.take)(1),Object(D.mergeMap)(e=>this.sharedPreferencesSetCollection.clear().pipe(Object(D.mergeMap)(()=>Object(c.from)(e).pipe(Object(D.tap)(e=>uc(this,void 0,void 0,(function*(){return yield ic.generateDownloadCancelTelemetry(e)}))),Object(D.concatMapTo)(Object(c.of)(void 0)))))))}handleDownloadCompletion(e){return this.currentDownloadRequest$.pipe(Object(D.take)(1),Object(D.mergeMap)(t=>e.payload.status===qr.STATUS_SUCCESSFUL?(this.completedDownloadRequestsCache.add(t),Object(c.iif)(()=>!!this.downloadCompleteDelegate,Object(c.defer)(()=>uc(this,void 0,void 0,(function*(){ic.generateDownloadCompleteTelemetry(t),this.downloadCompleteDelegate.onDownloadCompletion(t).toPromise()}))),Object(c.defer)(()=>Object(c.of)(void 0))).pipe(Object(D.mapTo)(void 0))):Object(c.of)(void 0)))}emitProgressInEventBus(e){return Object(c.defer)(()=>Object(c.of)(this.eventsBusService.emit({namespace:M.DOWNLOADS,event:e})).pipe(Object(D.mapTo)(void 0)))}getDownloadProgress(e){return new c.Observable(t=>{downloadManager.query({ids:[e.downloadId]},(n,r)=>{if(n)return t.next({type:$r.PROGRESS,payload:{downloadId:e.downloadId,identifier:e.identifier,progress:-1,bytesDownloaded:0,totalSizeInBytes:0,status:qr.STATUS_FAILED}}),t.complete(),void this.cancel({identifier:e.identifier}).toPromise();const i=r[0];t.next({type:$r.PROGRESS,payload:{downloadId:e.downloadId,identifier:e.identifier,progress:Math.round(i.totalSizeBytes>=0?i.bytesDownloadedSoFar/i.totalSizeBytes*100:-1),bytesDownloaded:i.bytesDownloadedSoFar,totalSizeInBytes:i.totalSizeBytes,status:i.status}}),t.complete()})})}listenForDownloadProgressChanges(){return this.currentDownloadRequest$.pipe(Object(D.switchMap)(e=>e?(this.eventsBusService.emit({namespace:M.DOWNLOADS,event:{type:$r.START,payload:void 0}}),Object(c.interval)(1e3).pipe(Object(D.mergeMap)(()=>this.getDownloadProgress(e)),Object(D.distinctUntilChanged)((e,t)=>JSON.stringify(e)===JSON.stringify(t)),Object(D.mergeMap)(e=>Object(c.zip)(this.handleDownloadCompletion(e),this.emitProgressInEventBus(e)).pipe(Object(D.mapTo)(e))),Object(D.tap)(e=>{e.payload.status!==qr.STATUS_FAILED&&e.payload.status!==qr.STATUS_SUCCESSFUL||this.eventsBusService.emit({namespace:M.DOWNLOADS,event:{type:$r.END,payload:void 0}})}),Object(D.mapTo)(void 0))):Object(c.of)(void 0)))}trackDownloads(e){return e.groupBy.fieldPath&&e.groupBy.value?this.getActiveDownloadRequests().pipe(Object(D.map)(t=>{const n=t=>e.groupBy.value===e.groupBy.fieldPath.split(".").reduce((e,t)=>{if(e&&e[t])return e[t]},t);return{completed:this.completedDownloadRequestsCache.size()?this.completedDownloadRequestsCache.toArray().filter(n):[],queued:t.length?t.filter(n):[]}})):c.EMPTY}onContentDelete(e){this.completedDownloadRequestsCache.remove({identifier:e})}};lc.KEY_TO_DOWNLOAD_LIST=O.KEY_TO_DOWNLOAD_LIST,lc.DOWNLOAD_DIR_NAME="Download",lc=ic=sc([Object(s.injectable)(),cc(0,Object(s.inject)(l.EVENTS_BUS_SERVICE)),cc(1,Object(s.inject)(l.SHARED_PREFERENCES)),ac("design:paramtypes",[Object,Object])],lc);var dc=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},hc=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ec=function(e,t){return function(n,r){t(n,r,e)}},fc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let pc=class{constructor(e,t){this.sdkConfig=e,this.sharedPreferences=t,"cordova"!==e.platform&&(this.versionName="sunbird-debug"),window.Capacitor.Plugins.App.getInfo().then(e=>{this.appName=e.name})}getVersionName(){return this.versionName}getAppName(){return this.appName}init(){return fc(this,void 0,void 0,(function*(){if(yield this.setFirstAccessTimestamp(),"cordova"!==this.sdkConfig.platform)return;this.sdkConfig.appConfig.buildConfigPackage&&this.sdkConfig.appConfig.buildConfigPackage;this.versionName="1.0-local",k.CsModule.instance.isInitialised&&k.CsModule.instance.updateConfig(Object.assign(Object.assign({},k.CsModule.instance.config),{core:Object.assign(Object.assign({},k.CsModule.instance.config.core),{global:Object.assign(Object.assign({},k.CsModule.instance.config.core.global),{appVersion:"1.0-local"})})})),console.log("version name",this.versionName)}))}getBuildConfigValue(e,t){return new Promise((n,r)=>{try{window.sbutility.getBuildConfigValue(e,t,e=>{n(e)},e=>{console.error(e),r(e)})}catch(e){console.error(e),r(e)}})}getFirstAccessTimestamp(){return this.sharedPreferences.getString(d.KEY_FIRST_ACCESS_TIMESTAMP).pipe(Object(D.map)(e=>e))}setFirstAccessTimestamp(){return fc(this,void 0,void 0,(function*(){return!(yield this.sharedPreferences.getString(d.KEY_FIRST_ACCESS_TIMESTAMP).toPromise())&&(yield this.sharedPreferences.putString(d.KEY_FIRST_ACCESS_TIMESTAMP,Date.now()+"").toPromise(),!0)}))}};pc=dc([Object(s.injectable)(),Ec(0,Object(s.inject)(l.SDK_CONFIG)),Ec(1,Object(s.inject)(l.SHARED_PREFERENCES)),hc("design:paramtypes",[Object,Object])],pc);var _c=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Oc=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Sc=function(e,t){return function(n,r){t(n,r,e)}},gc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let Ac=class{constructor(e,t,n,r,i,o,s){this.profileService=e,this.groupService=t,this.config=n,this.frameworkService=r,this.deviceInfo=i,this.appInfo=o,this.dbService=s}getPlayerConfig(e,t){const n={};n.did=this.deviceInfo.getDeviceID(),n.origin=this.config.apiConfig.host;const r=new ve;r.id=this.config.apiConfig.api_authentication.producerId,r.pid=this.config.apiConfig.api_authentication.producerUniqueId,r.ver=this.appInfo.getVersionName(),n.pdata=r;const i={};return e.rollup=kn.getRollup(e.identifier,e.hierarchyInfo),n.objectRollup=e.rollup,"ios"===window.device.platform.toLowerCase()?e.basePath=(e.basePath||(e.basePath="")).replace(/\/$/,""):e.basePath=e.basePath.replace(/\/$/,""),e.isAvailableLocally&&(e.contentData.streamingUrl=e.basePath,e.contentData.previewUrl=e.basePath),i.metadata=e,i.config=this.config.playerConfig,this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(t=>{n.sid=t?t.sid:"";const r=new pe;r.id=t?t.uid:"",n.actor=r;const o=this.config.appConfig.deepLinkBasePath;n.deeplinkBasePath=o||"";const s=e.rollup&&e.rollup.l1?e.rollup.l1:e.identifier;return this.fetchPlayerState(r.id,s,e.identifier).then(e=>{e&&i.config&&(i.config=Object.assign(Object.assign({},i.config),JSON.parse(e.saveState)))}),this.profileService.getActiveSessionProfile({requiredFields:[]})}),Object(D.mergeMap)(e=>{if(e&&e.serverProfile){const t=e.serverProfile.organisations;if(t){const e=t[0]&&t[0].organisationId;n.contextRollup={l1:e}}}return e&&e.profileType&&(t.correlationData=(t.correlationData||[]).concat([{id:e.profileType,type:"UserType"}])),this.groupService.getActiveGroupSession()}),Object(D.mergeMap)(e=>{let r=[];e&&e.gid&&r.push({id:e.gid,type:"group"});const o=t&&t.hasOwnProperty("streaming"),s=t.correlationData;s&&s.length&&(r=r.concat(s)),r.push({id:o?"streaming":"offline",type:"PlayerLaunch"}),n.cdata=r,i.context=n;const a={local:!0,server:!1};return a.groupId=e?e.gid:"",i.appContext=a,this.frameworkService.getActiveChannelId()}),Object(D.mergeMap)(e=>(n.channel=e||this.config.apiConfig.api_authentication.channelId,i.context=n,Object(c.of)(i))))}savePlayerState(e,t,n,r){return this.dbService.read({table:kt.TABLE_NAME,selection:`${kt.COLUMN_NAME_USER_ID} = ? AND ${kt.COLUMN_PARENT_IDENTIFIER} = ?\n AND ${kt.COLUMN_IDENTIFIER} = ?`,selectionArgs:[e,t,n]}).toPromise().then(i=>gc(this,void 0,void 0,(function*(){return i&&i.length?this.dbService.update({table:kt.TABLE_NAME,selection:`${kt.COLUMN_NAME_USER_ID} = ? AND ${kt.COLUMN_PARENT_IDENTIFIER} = ?\n AND ${kt.COLUMN_IDENTIFIER} = ?`,selectionArgs:[e,t,n],modelJson:Ht.mapPlayerStateToPlayerDbEntry(e,t,n,r)}).toPromise():this.dbService.insert({table:kt.TABLE_NAME,modelJson:Ht.mapPlayerStateToPlayerDbEntry(e,t,n,r)}).toPromise()})))}fetchPlayerState(e,t,n){return this.dbService.read({table:kt.TABLE_NAME,selection:`${kt.COLUMN_NAME_USER_ID} = ? AND ${kt.COLUMN_PARENT_IDENTIFIER} = ?\n AND ${kt.COLUMN_IDENTIFIER} = ?`,selectionArgs:[e,t,n]}).toPromise().then(e=>e&&e[0]&&Ht.mapPlayerDbEntryToPlayer(e[0]))}deletePlayerSaveState(e,t,n){return this.dbService.delete({table:kt.TABLE_NAME,selection:`${kt.COLUMN_NAME_USER_ID} =? AND ${kt.COLUMN_PARENT_IDENTIFIER} = ?\n AND ${kt.COLUMN_IDENTIFIER} = ?`,selectionArgs:[e,t,n]}).toPromise()}};Ac=_c([Object(s.injectable)(),Sc(0,Object(s.inject)(l.PROFILE_SERVICE)),Sc(1,Object(s.inject)(l.GROUP_SERVICE_DEPRECATED)),Sc(2,Object(s.inject)(l.SDK_CONFIG)),Sc(3,Object(s.inject)(l.FRAMEWORK_SERVICE)),Sc(4,Object(s.inject)(l.DEVICE_INFO)),Sc(5,Object(s.inject)(l.APP_INFO)),Sc(6,Object(s.inject)(l.DB_SERVICE)),Oc("design:paramtypes",[Object,Object,Object,Object,Object,Object,o])],Ac);var Nc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Tc extends i{constructor(){super(6,21)}apply(e){return Nc(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise())),yield e.read({table:St.TABLE_NAME,selection:St.COLUMN_NAME_CONTENT_TYPE+" = ?",selectionArgs:["textbook"]}).pipe(Object(D.map)(t=>{t.forEach(t=>Nc(this,void 0,void 0,(function*(){const n=t[St.COLUMN_NAME_LOCAL_DATA];if(n){const r=JSON.parse(n);t[St.COLUMN_NAME_BOARD]=kn.getContentAttribute(r.board),t[St.COLUMN_NAME_MEDIUM]=kn.getContentAttribute(r.medium),t[St.COLUMN_NAME_GRADE]=kn.getContentAttribute(r.gradeLevel),yield e.update({table:St.TABLE_NAME,modelJson:t,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[St.COLUMN_NAME_IDENTIFIER]]}).toPromise()}})))})).toPromise()}))}queries(){return[St.getAlterEntryForBoard(),St.getAlterEntryForMedium(),St.getAlterEntryForGrade()]}}class Cc extends ke{constructor(e){super(e,"LOW_MEMORY"),Object.setPrototypeOf(this,Cc.prototype)}}var vc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class yc{constructor(e){this.dbService=e}execute(e){return Object(c.defer)(()=>vc(this,void 0,void 0,(function*(){const t=yield this.getFreeUsableSpace(e.destinationFolder),n=new Ss(this.dbService),r=yield n.getContentUsageSummary([e.sourceFolder]);let i=0;if(r&&r.length&&(i=r[0].sizeOnDevice),kn.isFreeSpaceAvailable(t,i,0))return e;throw new Cc("Available memory not sufficient for transfer operation")})))}getFreeUsableSpace(e){return vc(this,void 0,void 0,(function*(){return new Promise((t,n)=>{sbutility.getFreeUsableSpace(e,e=>{t(Number(e))},e=>{n(e)})})}))}}var mc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class bc{constructor(e,t){this.fileService=e,this.appConfig=t}execute(e){return Object(c.defer)(()=>mc(this,void 0,void 0,(function*(){return e.validContentIdsInDestination=yield this.getSubdirectoriesEntries(e.destinationFolder).then(e=>this.extractValidContentIdsInDestination(e)),e})))}getSubdirectoriesEntries(e){return mc(this,void 0,void 0,(function*(){return this.fileService.listDir(e.replace(/\/$/,"")).then(e=>e.filter(e=>e.isDirectory))}))}extractValidContentIdsInDestination(e){return mc(this,void 0,void 0,(function*(){const t=[];for(const n of e)if(n.isDirectory){let e;try{e=yield this.extractManifest(n)}catch(e){}if(!e)continue;const r=e.archive.items;for(const e of r)kn.readVisibility(e)!==Cn.PARENT&&(kn.isDraftContent(e.status)&&kn.isExpired(e.expires)||t.push(n.name))}return t}))}extractManifest(e){return mc(this,void 0,void 0,(function*(){const t=yield this.fileService.readAsText(e.nativeURL,Ln.MANIFEST.valueOf());return JSON.parse(t)}))}}class Ic{constructor(){}execute(e){return Object(c.of)(e)}}class Mc extends ke{constructor(e){super(e,"DUPLICATE_CONTENT"),Object.setPrototypeOf(this,Mc.prototype)}}var Rc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Lc=St.COLUMN_NAME_IDENTIFIER,Pc=St.COLUMN_NAME_LOCAL_DATA;class Dc{constructor(e,t){this.dbService=e,this.fileService=t}execute(e){return Object(c.defer)(()=>Rc(this,void 0,void 0,(function*(){const t=yield this.getContentsInDb(e.contentIds);let n=[];e.validContentIdsInDestination&&e.validContentIdsInDestination.length&&(n=yield this.getContentsInDb(e.validContentIdsInDestination));const r=(yield this.generateMoveContentResponses(e,n)).moveContentDupContentList;if(e.contentsInSource=t,e.duplicateContents=r,e.duplicateContents.length&&!e.shouldMergeInDestination)throw new Mc("context.shouldMergeInDestination is false")}))).pipe(Object(D.mapTo)(e))}getContentsInDb(e){return Rc(this,void 0,void 0,(function*(){return e.length?this.dbService.execute(kn.getFindAllContentsWithIdentifierQuery(e)).toPromise():this.dbService.execute(kn.getFindAllContentsQuery()).toPromise()}))}getPkgVersionFromFile(e,t){return this.fileService.readAsText(e.concat(t),Ln.MANIFEST.valueOf()).then(e=>{const n=JSON.parse(e).archive.items;if(n){return n.find(e=>e.identifier===t).pkgVersion}return 0}).catch(()=>-1)}generateMoveContentResponses(e,t){return Rc(this,void 0,void 0,(function*(){const n=[],r=[];for(const i of t){const t=yield this.getPkgVersionFromFile(e.destinationFolder,i[Lc]),o=kn.readPkgVersion(JSON.parse(i[Pc]));if(-1!==t)if(t>o){const e={identifier:i[Lc],status:Jc.HIGHER_VERSION_IN_DESTINATION};n.push(e),r.push(e)}else if(t<o){const e={identifier:i[Lc],status:Jc.LOWER_VERSION_IN_DESTINATION};n.push(e),r.push(e)}else{const e={identifier:i[Lc],status:Jc.SAME_VERSION_IN_BOTH};r.push(e)}}return{moveContentDiffPkgList:n,moveContentDupContentList:r}}))}}class wc extends ke{constructor(e){super(e,"CANCELLED"),Object.setPrototypeOf(this,wc.prototype)}}var Uc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},jc=St.COLUMN_NAME_IDENTIFIER,Fc=St.COLUMN_NAME_PATH;class kc{constructor(e){this.eventsBusService=e,this.contentsTransferred=0}execute(e){return Object(c.defer)(()=>Uc(this,void 0,void 0,(function*(){for(const t of e.contentsInSource){if(e.hasTransferCancelled)throw yield this.deleteFolder(e.destinationFolder.concat("temp","/")),new wc("CANCELLED");const n=e.duplicateContents.find(e=>e.identifier===t[jc]);if(n&&!wn.isEmpty(e.duplicateContents))if(e.existingContentAction)if(n.status!==Jc.SAME_VERSION_IN_BOTH){switch(e.existingContentAction){case Ga.KEEP_HIGER_VERSION:if(n.status===Jc.HIGHER_VERSION_IN_DESTINATION)break;yield this.copyToTempDestination(e,t,n),yield this.removeSourceAndDestination(e,t,n);break;case Ga.KEEP_LOWER_VERSION:if(n.status===Jc.LOWER_VERSION_IN_DESTINATION)break;yield this.copyToTempDestination(e,t,n),yield this.removeSourceAndDestination(e,t,n);break;case Ga.KEEP_SOURCE:yield this.copyToTempDestination(e,t,n),yield this.removeSourceAndDestination(e,t,n);break;case Ga.IGNORE:case Ga.KEEP_DESTINATION:}this.emitContentTransferProgress(e)}else this.emitContentTransferProgress(e);else this.emitContentTransferProgress(e);else{const n=e.destinationFolder.concat("temp","/");try{yield this.copyFolder(t[Fc],n+t[jc])}catch(e){}this.emitContentTransferProgress(e)}}return e})))}emitContentTransferProgress(e){this.eventsBusService.emit({namespace:M.STORAGE,event:{type:Ya.TRANSFER_PROGRESS,payload:{progress:{transferredCount:++this.contentsTransferred,totalCount:e.contentsInSource.length}}}})}deleteFolder(e){return Uc(this,void 0,void 0,(function*(){if(e)return new Promise((t,n)=>{sbutility.rm(e,"",()=>{t(void 0)},e=>{n(e)})})}))}copyFolder(e,t){return Uc(this,void 0,void 0,(function*(){if(e&&t)return new Promise((n,r)=>{sbutility.copyDirectory(e,t,()=>{n(void 0)},e=>{r(e)})})}))}renameFolder(e,t){return Uc(this,void 0,void 0,(function*(){if(e)return new Promise((n,r)=>{sbutility.renameDirectory(e,t,()=>{n(void 0)},e=>{r(e)})})}))}copyToTempDestination(e,t,n){return Uc(this,void 0,void 0,(function*(){yield this.renameFolder(e.destinationFolder,n.identifier),yield this.copyFolder(t[Fc],e.destinationFolder+t[jc])}))}removeSourceAndDestination(e,t,n){return Uc(this,void 0,void 0,(function*(){yield this.deleteFolder(e.destinationFolder.concat(n.identifier,"_temp")),yield this.deleteFolder(t[Fc])}))}}var xc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Bc=St.COLUMN_NAME_PATH,Vc=St.COLUMN_NAME_IDENTIFIER;class Yc{constructor(e){this.dbService=e}execute(e){return Object(c.defer)(()=>xc(this,void 0,void 0,(function*(){this.dbService.beginTransaction();try{for(const t of e.contentsInSource)t[Bc]=kn.getBasePath(e.destinationFolder.concat(t[Vc],"/")),yield this.dbService.update({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[St.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise();this.dbService.endTransaction(!0)}catch(e){this.dbService.endTransaction(!1)}}))).pipe(Object(D.mapTo)(e))}}var Gc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Hc{constructor(e,t,n,r){this.appConfig=e,this.fileService=t,this.dbService=n,this.deviceInfo=r}execute(e){return Object(c.defer)(()=>Gc(this,void 0,void 0,(function*(){let t;for(const t of e.duplicateContents)switch(e.existingContentAction||Ga.IGNORE){case Ga.KEEP_HIGER_VERSION:t.status===Jc.HIGHER_VERSION_IN_DESTINATION&&this.addDestinationContentInDb(t.identifier,e.destinationFolder,!1);break;case Ga.KEEP_LOWER_VERSION:t.status===Jc.LOWER_VERSION_IN_DESTINATION&&this.addDestinationContentInDb(t.identifier,e.destinationFolder,!0);break;case Ga.KEEP_DESTINATION:case Ga.IGNORE:t.status===Jc.LOWER_VERSION_IN_DESTINATION?this.addDestinationContentInDb(t.identifier,e.destinationFolder,!0):this.addDestinationContentInDb(t.identifier,e.destinationFolder,!1)}if(e.validContentIdsInDestination&&e.validContentIdsInDestination.length&&e.duplicateContents&&e.duplicateContents.length?t=this.getNewlyAddedContents(e.validContentIdsInDestination,e.duplicateContents.map(e=>e.identifier)):e.validContentIdsInDestination&&e.duplicateContents.length||!e.validContentIdsInDestination||!e.validContentIdsInDestination.length||(t=e.validContentIdsInDestination),t)for(const n of t)yield this.addDestinationContentInDb(n,e.destinationFolder,!1)})))}getNewlyAddedContents(e,t){return e.filter(e=>t.find(t=>t!==e))}addDestinationContentInDb(e,t,n){const r=t.concat(e);return this.fileService.readAsText(t.concat(e),Ln.MANIFEST.valueOf()).then(e=>{const t=JSON.parse(e),i=t.archive.items;return this.extractContentFromItem(i,r.concat("/"),t.ver,n)}).catch(e=>{console.error(e)})}extractContentFromItem(e,t,n,r){return Gc(this,void 0,void 0,(function*(){const i=[],o=[];for(const s of e){let e=s;const a=e.identifier,c=e.mimeType,u=kn.readContentType(e),l=kn.readPrimaryCategory(e);let d=kn.readVisibility(e);const h=kn.readAudience(e),E=kn.readPragma(e),f=e.pkgVersion;let p=Nn.ONLY_SPINE.valueOf();const _=e.board,O=e.medium,S=e.gradeLevel,g=(yield this.dbService.read({table:St.TABLE_NAME,columns:[],selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[a]}).toPromise())[0],A=g&&kn.getBasePath(g[St.COLUMN_NAME_PATH]);let N=kn.doesContentExist(g,a,f,r);N&&e.status!==vn.DRAFT.valueOf()?g[St.COLUMN_NAME_VISIBILITY]===Cn.DEFAULT.valueOf()&&(e=JSON.parse(g[St.COLUMN_NAME_LOCAL_DATA])):(N=!1,p=(Tn.COLLECTION.valueOf(),Nn.ARTIFACT_AVAILABLE.valueOf()));const T=kn.getReferenceCount(g,d);d=kn.getContentVisibility(g,e.objectType,d),p=kn.getContentState(g,p);const C=N?A:t,v=yield this.fileService.getDirectorySize(C);kn.addOrUpdateViralityMetadata(e,this.deviceInfo.getDeviceID().toString());const y=kn.constructContentDBModel(a,n,JSON.stringify(e),c,u,d,C,T,p,h,E,v,_,O,S,l);g?o.push(y):i.push(y)}if(i.length||o.length){this.dbService.beginTransaction();for(const e of i){const t=e;yield this.dbService.insert({table:St.TABLE_NAME,modelJson:t}).toPromise()}for(const e of o){const t=e;yield this.dbService.update({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[St.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise()}this.dbService.endTransaction(!0)}}))}}var $c=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class qc{constructor(e){this.fileService=e}execute(e){return Object(c.defer)(()=>$c(this,void 0,void 0,(function*(){return e.destinationFolder=yield this.validate(e.destinationFolder).then(e=>this.createDirectory(e)),e})))}validate(e){return this.canWrite(e).then(()=>(e.endsWith("content/")||(e=e.concat("content")),e)).catch(()=>{throw Error("Destination is not writable")})}createDirectory(e){return this.fileService.exists(e).then(e=>e.nativeURL).catch(()=>this.fileService.createDir(e,!1).then(e=>e.nativeURL))}canWrite(e){return $c(this,void 0,void 0,(function*(){return new Promise((t,n)=>{sbutility.canWrite(e,()=>{t(void 0)},e=>{n(e)})})}))}}var Kc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},zc=St.COLUMN_NAME_IDENTIFIER,Wc=St.COLUMN_NAME_PATH;class Xc{constructor(e){this.eventsBusService=e}execute(e){return Object(c.defer)(()=>Kc(this,void 0,void 0,(function*(){for(let t=0;t<e.contentsInSource.length;t++){const n=e.contentsInSource[t],r=e.duplicateContents.find(e=>e.identifier===n[zc]),i=e.destinationFolder.concat("temp","/");if(r&&!wn.isEmpty(e.duplicateContents)){if(e.existingContentAction&&r.status!==Jc.SAME_VERSION_IN_BOTH){switch(e.existingContentAction){case Ga.KEEP_HIGER_VERSION:if(r.status===Jc.HIGHER_VERSION_IN_DESTINATION)break;yield this.removeSourceAndDestination(e,n,r);break;case Ga.KEEP_LOWER_VERSION:if(r.status===Jc.LOWER_VERSION_IN_DESTINATION)break;yield this.removeSourceAndDestination(e,n,r);break;case Ga.KEEP_SOURCE:yield this.removeSourceAndDestination(e,n,r);break;case Ga.IGNORE:case Ga.KEEP_DESTINATION:}t===e.contentsInSource.length-1&&(yield this.deleteFolder(i))}}else try{yield this.copyFolder(i.concat(n[zc]),e.destinationFolder+n[zc]),yield this.deleteFolder(i.concat(n[zc])),yield this.deleteFolder(n[Wc]),t===e.contentsInSource.length-1&&(yield this.deleteFolder(i))}catch(e){}}return e})))}deleteFolder(e){return Kc(this,void 0,void 0,(function*(){if(e)return new Promise((t,n)=>{sbutility.rm(e,"",()=>{t(void 0)},e=>{n(e)})})}))}copyFolder(e,t){return Kc(this,void 0,void 0,(function*(){if(e&&t)return new Promise((n,r)=>{sbutility.copyDirectory(e,t,()=>{n(void 0)},e=>{r(e)})})}))}renameFolder(e,t){return Kc(this,void 0,void 0,(function*(){if(e)return new Promise((n,r)=>{sbutility.renameDirectory(e,t,()=>{n(void 0)},e=>{r(e)})})}))}removeSourceAndDestination(e,t,n){return Kc(this,void 0,void 0,(function*(){yield this.deleteFolder(e.destinationFolder.concat(n.identifier,"_temp")),yield this.deleteFolder(t[Wc])}))}}var Jc,Qc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};!function(e){e.SAME_VERSION_IN_BOTH="SAME_VERSION_IN_BOTH",e.HIGHER_VERSION_IN_DESTINATION="HIGHER_VERSION_IN_DESTINATION",e.LOWER_VERSION_IN_DESTINATION="LOWER_VERSION_IN_DESTINATION"}(Jc||(Jc={}));class Zc{constructor(e,t,n,r,i){this.sdkConfig=e,this.fileService=t,this.dbService=n,this.eventsBusService=r,this.deviceInfo=i,this.context={}}transfer({contentIds:e,existingContentAction:t,deleteDestination:n,destinationFolder:r,shouldMergeInDestination:i,sourceFolder:o}){return this.context.hasTransferCancelled=!1,this.context.shouldMergeInDestination=i,this.context.contentIds=e,this.context.existingContentAction=t,this.context.deleteDestination=n,this.context.destinationFolder=r,this.context.sourceFolder=o,new qc(this.fileService).execute(this.context).pipe(Object(D.mergeMap)(e=>(new Ic).execute(e)),Object(D.mergeMap)(e=>new yc(this.dbService).execute(e)),Object(D.mergeMap)(e=>new bc(this.fileService,this.sdkConfig.appConfig).execute(e)),Object(D.mergeMap)(e=>new Dc(this.dbService,this.fileService).execute(e)),Object(D.mergeMap)(e=>new kc(this.eventsBusService).execute(e)),Object(D.mergeMap)(e=>new Xc(this.eventsBusService).execute(e)),Object(D.mergeMap)(e=>new Yc(this.dbService).execute(e)),Object(D.mergeMap)(e=>new Hc(this.sdkConfig.appConfig,this.fileService,this.dbService,this.deviceInfo).execute(e))).pipe(Object(D.tap)(()=>{this.eventsBusService.emit({namespace:M.STORAGE,event:{type:Ya.TRANSFER_COMPLETED}})}),Object(D.mapTo)(void 0),Object(D.catchError)(e=>(e instanceof wc?this.eventsBusService.emit({namespace:M.STORAGE,event:{type:Ya.TRANSFER_REVERT_COMPLETED}}):e instanceof Mc?this.eventsBusService.emit({namespace:M.STORAGE,event:{type:Ya.TRANSFER_FAILED_DUPLICATE_CONTENT}}):e instanceof Cc&&this.eventsBusService.emit({namespace:M.STORAGE,event:{type:Ya.TRANSFER_FAILED_LOW_MEMORY}}),console.error("Error",e),Object(c.throwError)(e))))}cancel(){return Object(c.defer)(()=>Qc(this,void 0,void 0,(function*(){this.context.hasTransferCancelled=!0}))).pipe(Object(D.mapTo)(void 0))}}var eu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class tu{constructor(e,t){this.fileService=e,this.dbService=t}execute(e){return Object(c.defer)(()=>eu(this,void 0,void 0,(function*(){const t=yield this.getContentsInDb();if(e.currentStoragePath){let n=kn.getContentRootDir(e.currentStoragePath).concat("/");"ios"===window.device.platform.toLowerCase()&&(n="file://"+n);const r=yield this.getFolderList(n);e.newlyAddedIdentifiers=yield this.getNewlyAddedContents(r,t),e.deletedIdentifiers=yield this.getDeletedContents(r,t)}else e.newlyAddedIdentifiers=[],e.deletedIdentifiers=t}))).pipe(Object(D.mapTo)(e))}doesDestinationStorageExist(e){return this.fileService.exists(e).then(()=>!0).catch(()=>!1)}getContentsInDb(){return eu(this,void 0,void 0,(function*(){return this.dbService.execute(kn.getFindAllContentsQuery()).pipe(Object(D.map)(e=>e.filter(e=>"textbookunit"!==e[St.COLUMN_NAME_CONTENT_TYPE].toLowerCase()).map(e=>e[St.COLUMN_NAME_IDENTIFIER]))).toPromise()}))}getNewlyAddedContents(e,t){return e.filter(e=>!wn.contains(t,e))}getDeletedContents(e,t){return t.filter(t=>!wn.contains(e,t))}getFolderList(e){return this.fileService.listDir(e.replace(/\/$/,"")).then(e=>e.map(e=>e.name)).catch(()=>[])}}var nu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ru{constructor(e){this.storageHandler=e}exexute(e){return Object(c.defer)(()=>nu(this,void 0,void 0,(function*(){if(e.deletedIdentifiers.length&&(yield this.storageHandler.deleteContentsFromDb(e.deletedIdentifiers)),e.newlyAddedIdentifiers.length)for(const t of e.newlyAddedIdentifiers)yield this.storageHandler.addDestinationContentInDb(t,kn.getContentRootDir(e.currentStoragePath).concat("/"),!1)}))).pipe(Object(D.mapTo)(e))}}var iu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ou{constructor(e,t,n,r){this.appConfig=e,this.fileService=t,this.dbService=n,this.deviceInfo=r}addDestinationContentInDb(e,t,n){return iu(this,void 0,void 0,(function*(){const r=t.concat(e);this.fileService.readAsText(t.concat(e),Ln.MANIFEST.valueOf()).then(e=>{const t=JSON.parse(e),i=t.archive.items;return this.extractContentFromItem(i,r.concat("/"),t.ver,n)}).catch(e=>{console.error(e)})}))}deleteContentsFromDb(e){return iu(this,void 0,void 0,(function*(){const t=yield this.dbService.execute(kn.getFindAllContentsWithIdentifierQuery(e)).toPromise();for(const e of t){const t=e;if(t[St.COLUMN_NAME_MIME_TYPE]===Tn.COLLECTION&&t[St.COLUMN_NAME_REF_COUNT]>1?t[St.COLUMN_NAME_CONTENT_STATE]=Nn.ARTIFACT_AVAILABLE:t[St.COLUMN_NAME_CONTENT_STATE]=Nn.ONLY_SPINE,t[St.COLUMN_NAME_VISIBILITY]===Cn.DEFAULT&&t[St.COLUMN_NAME_REF_COUNT]>0){const e=t[St.COLUMN_NAME_REF_COUNT];t[St.COLUMN_NAME_REF_COUNT]=kn.addOrUpdateRefCount(e-1)}t[St.COLUMN_NAME_VISIBILITY]=Cn.PARENT}this.dbService.beginTransaction();for(const e of t){const t=e;yield this.dbService.update({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[St.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise()}this.dbService.endTransaction(!0)}))}extractContentFromItem(e,t,n,r){return iu(this,void 0,void 0,(function*(){const i=[],o=[];for(const s of e){let e=s;const a=e.identifier,c=e.mimeType,u=kn.readContentType(e),l=kn.readPrimaryCategory(e);let d=kn.readVisibility(e);const h=kn.readAudience(e),E=kn.readPragma(e),f=e.pkgVersion;let p=Nn.ONLY_SPINE.valueOf();const _=e.board,O=e.medium,S=e.gradeLevel,g=(yield this.dbService.read({table:St.TABLE_NAME,columns:[],selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[a]}).toPromise())[0],A=g&&kn.getBasePath(g[St.COLUMN_NAME_PATH]);let N=kn.doesContentExist(g,a,f,r);N&&e.status!==vn.DRAFT.valueOf()?g[St.COLUMN_NAME_VISIBILITY]===Cn.DEFAULT.valueOf()&&(e=JSON.parse(g[St.COLUMN_NAME_LOCAL_DATA])):(N=!1,p=(Tn.COLLECTION.valueOf(),Nn.ARTIFACT_AVAILABLE.valueOf()));const T=kn.getReferenceCount(g,d);d=kn.getContentVisibility(g,e.objectType,d),p=kn.getContentState(g,p);const C=N?A:t,v=yield this.fileService.getDirectorySize(C);kn.addOrUpdateViralityMetadata(e,this.deviceInfo.getDeviceID().toString());const y=kn.constructContentDBModel(a,n,JSON.stringify(e),c,u,d,C,T,p,h,E,v,_,O,S,l);g?o.push(y):i.push(y)}if(i.length||o.length){this.dbService.beginTransaction();for(const e of i){const t=e;yield this.dbService.insert({table:St.TABLE_NAME,modelJson:t}).toPromise()}for(const e of o){const t=e;yield this.dbService.update({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[St.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise()}this.dbService.endTransaction(!0)}}))}}var su,au=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},cu=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},uu=function(e,t){return function(n,r){t(n,r,e)}},lu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let du=su=class{constructor(e,t,n,r,i,o){this.eventsBusService=e,this.sharedPreferences=t,this.dbService=n,this.deviceInfo=r,this.fileService=i,this.sdkConfig=o,this.contentsToTransfer=new gs(this.sharedPreferences,g.KEY_TO_TRANSFER_LIST,e=>e),this.transferContentHandler=new Zc(this.sdkConfig,this.fileService,this.dbService,this.eventsBusService,this.deviceInfo)}onInit(){return Object(c.zip)(this.deviceInfo.getStorageVolumes(),this.getStorageDestination()).pipe(Object(D.tap)(e=>{this.availableStorageVolumes=e[0],this.currentStorageDestination=e[1],this.scanStorage().toPromise()}),Object(D.mapTo)(void 0))}getStorageDestinationDirectoryPath(){const e=this.availableStorageVolumes.find(e=>e.storageDestination===this.currentStorageDestination);return e&&e.info.contentStoragePath}cancelTransfer(){return this.transferContentHandler.cancel()}getStorageDestination(){return this.sharedPreferences.getString(su.STORAGE_DESTINATION).pipe(Object(D.map)(e=>e||Va.INTERNAL_STORAGE))}getStorageDestinationVolumeInfo(){return this.getStorageDestination().pipe(Object(D.map)(e=>this.availableStorageVolumes.find(t=>t.storageDestination===e)))}getToTransferContents(){return Object(c.of)([])}getTransferringContent(){return Object(c.of)(void 0)}retryCurrentTransfer(){return this.lastTransferContentsRequest?this.transferContents(Object.assign(Object.assign({},this.lastTransferContentsRequest),{shouldMergeInDestination:!0})):Object(c.of)(void 0)}transferContents(e){return this.lastTransferContentsRequest=e,e.sourceFolder=this.getStorageDestinationDirectoryPath(),this.transferContentHandler.transfer(e).pipe(Object(D.mergeMap)(()=>this.getStorageDestination()),Object(D.map)(e=>e===Va.EXTERNAL_STORAGE?Va.INTERNAL_STORAGE:Va.EXTERNAL_STORAGE),Object(D.tap)(e=>{this.currentStorageDestination=e}),Object(D.mergeMap)(e=>this.sharedPreferences.putString(su.STORAGE_DESTINATION,e)))}scanStorage(){const e=this.getStorageDestinationDirectoryPath(),t={currentStoragePath:e};return e||this.resetStorageDestination(),new tu(this.fileService,this.dbService).execute(t).pipe(Object(D.mergeMap)(e=>{const t=new ou(this.sdkConfig.appConfig,this.fileService,this.dbService,this.deviceInfo);return new ru(t).exexute(e)}),Object(D.mapTo)(!0))}resetStorageDestination(){return lu(this,void 0,void 0,(function*(){return this.currentStorageDestination=Va.INTERNAL_STORAGE,this.sharedPreferences.putString(su.STORAGE_DESTINATION,Va.INTERNAL_STORAGE).toPromise()}))}};var hu,Eu;du.STORAGE_DESTINATION=g.KEY_STORAGE_DESTINATION,du=su=au([Object(s.injectable)(),uu(0,Object(s.inject)(l.EVENTS_BUS_SERVICE)),uu(1,Object(s.inject)(l.SHARED_PREFERENCES)),uu(2,Object(s.inject)(l.DB_SERVICE)),uu(3,Object(s.inject)(l.DEVICE_INFO)),uu(4,Object(s.inject)(l.FILE_SERVICE)),uu(5,Object(s.inject)(l.SDK_CONFIG)),cu("design:paramtypes",[Object,Object,o,Object,Object,Object])],du),function(e){e[e.ACTIONABLE_NOTIFICATION=1]="ACTIONABLE_NOTIFICATION",e[e.NOTIFY=2]="NOTIFY",e[e.CONFIG=3]="CONFIG"}(hu||(hu={})),function(e){e.READ="read",e.UNREAD="unread",e.ALL="all"}(Eu||(Eu={}));class fu{static constructNotificationDBModel(e){return{message_id:e.id,expiry_time:e.expiry,display_time:e.displayTime,received_at:Date.now(),notification_json:JSON.stringify(e),is_read:e.isRead}}static getFilterForNotification(e){let t,n;switch(e.notificationStatus){case Eu.ALL:t=`${mt.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME} <= ?\n AND ${mt.COLUMN_NAME_EXPIRY_TIME} > ?`,n=[Date.now().toString(),Date.now().toString()];break;case Eu.UNREAD:t=`${mt.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME} <= ?\n AND ${mt.COLUMN_NAME_EXPIRY_TIME} > ? AND\n AND ${mt.COLUMN_NAME_IS_READ} > ?`,n=[Date.now().toString(),Date.now().toString(),0];break;case Eu.READ:default:t=`${mt.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME} <= ?\n AND ${mt.COLUMN_NAME_EXPIRY_TIME} > ?\n AND ${mt.COLUMN_NAME_IS_READ} > ?`,n=[Date.now().toString(),Date.now().toString(),1]}return{table:mt.TABLE_NAME,orderBy:mt.COLUMN_NAME_NOTIFICATION_RECEIVED_AT+" desc"}}}var pu,_u=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ou=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Su=function(e,t){return function(n,r){t(n,r,e)}},gu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Au=mt.COLUMN_NAME_NOTIFICATION_JSON;let Nu=pu=class{constructor(e,t,n,r){this.dbService=e,this.sharedPreferences=t,this.profileService=n,this.keyValueStore=r,this._notifications$=new c.BehaviorSubject([]),this._notificationTrigger$=new c.Subject}get notifications$(){return this._notifications$}onInit(){const e=Object(c.interval)(36e5).pipe(Object(D.startWith)(null),Object(D.mapTo)(null)),t=this._notificationTrigger$.pipe(Object(D.startWith)(null),Object(D.throttleTime)(1e3));return Object(c.combineLatest)([e,t]).pipe(Object(D.switchMap)(()=>Object(c.defer)(()=>gu(this,void 0,void 0,(function*(){try{const e=yield this.fetchNotificationAndUserFeed();this._notifications$.next(e)}catch(e){console.error(e)}})))),Object(D.mapTo)(void 0))}addNotification(e){return e.actionData&&"codePush"===e.actionData.actionType&&e.actionData.deploymentKey&&this.sharedPreferences.putString(N.DEPLOYMENT_KEY,e.actionData.deploymentKey),this.dbService.read({table:mt.TABLE_NAME,selection:mt.COLUMN_NAME_MESSAGE_ID+"= ?",selectionArgs:[e.id.toString()],limit:"1"}).pipe(Object(D.mergeMap)(t=>t&&t.length?this.dbService.update({table:mt.TABLE_NAME,selection:mt.COLUMN_NAME_MESSAGE_ID+"= ?",selectionArgs:[e.id.toString()],modelJson:fu.constructNotificationDBModel(e)}).pipe(Object(D.mapTo)(!0)):this.dbService.insert({table:mt.TABLE_NAME,modelJson:fu.constructNotificationDBModel(e)}).pipe(Object(D.mapTo)(!0))),Object(D.tap)(()=>this.triggerNotificationChange()))}deleteNotification(e){if("USER_FEED"===e.source)return this.profileService.deleteUserFeedEntry({feedEntryId:e.id,category:Qn.UserFeedCategory.NOTIFICATION}).pipe(Object(D.tap)(()=>this.triggerNotificationChange()));const t=`DELETE FROM ${mt.TABLE_NAME} `.concat(e.id?`WHERE ${mt.COLUMN_NAME_MESSAGE_ID} = ${e.id}`:"");return this.dbService.execute(t).pipe(Object(D.mapTo)(!0),Object(D.tap)(()=>this.triggerNotificationChange()))}getAllNotifications(e){return this.dbService.read(fu.getFilterForNotification(e)).pipe(Object(D.map)(e=>e.map(e=>{const t=JSON.parse(e[Au]);return t.isRead=e[mt.COLUMN_NAME_IS_READ],t})))}updateNotification(e){return"USER_FEED"===e.source?this.profileService.updateUserFeedEntry({feedEntryId:e.id,category:Qn.UserFeedCategory.NOTIFICATION,request:{status:e.isRead?Qn.UserFeedStatus.READ:Qn.UserFeedStatus.UNREAD}}).pipe(Object(D.tap)(()=>this.triggerNotificationChange())):this.dbService.read({table:mt.TABLE_NAME,selection:mt.COLUMN_NAME_MESSAGE_ID+"= ?",selectionArgs:[e.id.toString()],limit:"1"}).pipe(Object(D.mergeMap)(t=>t&&t.length?this.dbService.update({table:mt.TABLE_NAME,selection:mt.COLUMN_NAME_MESSAGE_ID+"= ?",selectionArgs:[e.id.toString()],modelJson:fu.constructNotificationDBModel(e)}).pipe(Object(D.mapTo)(!0)):Object(c.of)(!1)),Object(D.tap)(()=>this.triggerNotificationChange()))}deleteAllNotifications(){return Object(c.defer)(()=>gu(this,void 0,void 0,(function*(){const e=this._notifications$.getValue();try{return yield Promise.all(e.map(e=>this.deleteNotification(e).toPromise())),!0}catch(e){return console.error(e),!1}})))}fetchNotificationAndUserFeed(){return gu(this,void 0,void 0,(function*(){const e=yield Promise.all([(()=>gu(this,void 0,void 0,(function*(){return this.getAllNotifications({notificationStatus:Eu.ALL}).toPromise()})))(),(()=>gu(this,void 0,void 0,(function*(){try{const e=yield this.profileService.getActiveProfileSession().toPromise(),t=`${pu.USER_NOTIFICATION_FEED_KEY}_${e.managedSession?e.managedSession.uid:e.uid}`;try{const e=yield this.profileService.getUserFeed().toPromise().then(e=>e.filter(e=>e.category===Qn.UserFeedCategory.NOTIFICATION));return this.keyValueStore.setValue(t,Object(an.gzip)(JSON.stringify(e))).toPromise(),e}catch(e){return this.keyValueStore.getValue(t).toPromise().then(e=>JSON.parse(Object(ii.ungzip)(e,{to:"string"}))).catch(e=>(console.error(e),[]))}}catch(e){return[]}})))()]),t=e[0],n=e[1];return t.concat(n.map(e=>({id:e.id,source:"USER_FEED",displayTime:new Date(e.createdOn).getTime(),expiry:e.expireOn?new Date(e.expireOn).getTime():0,isRead:"read"===e.status?1:0,actionData:e.data}))).sort((e,t)=>new Date(t.displayTime).getTime()-new Date(e.displayTime).getTime())}))}triggerNotificationChange(){return gu(this,void 0,void 0,(function*(){this._notificationTrigger$.next(null)}))}};var Tu;Nu.USER_NOTIFICATION_FEED_KEY="user_notification_feed",Nu=pu=_u([Object(s.injectable)(),Su(0,Object(s.inject)(l.DB_SERVICE)),Su(1,Object(s.inject)(l.SHARED_PREFERENCES)),Su(2,Object(s.inject)(l.PROFILE_SERVICE)),Su(3,Object(s.inject)(l.KEY_VALUE_STORE)),Ou("design:paramtypes",[o,Object,Object,Object])],Nu),function(e){e.CUSTODIAN_ORG_ID="custodianOrgId",e.COURSE_FRAMEWORK_ID="courseFrameworkId",e.ERROR_LOG_SYNC_SETTINGS="errorLogSyncSettings"}(Tu||(Tu={}));class Cu{static mapErrorSatckDBEntryToErrorStack(e){return{appver:e[Rt.COLUMN_NAME_APP_VERSION],pageid:e[Rt.COLUMN_NAME_PAGE_ID],ts:e[Rt.COLUMN_NAME_TIME_STAMP],log:e[Rt.COLUMN_NAME_ERROR_LOG]}}static mapErrorStackToErrorStackDBEntry(e){return{[Rt.COLUMN_NAME_APP_VERSION]:e.appver,[Rt.COLUMN_NAME_PAGE_ID]:e.pageid,[Rt.COLUMN_NAME_TIME_STAMP]:e.ts,[Rt.COLUMN_NAME_ERROR_LOG]:e.log}}}var vu=Rt._ID;class yu{constructor(e,t,n,r,i){this.apiService=e,this.dbService=t,this.errorLoggerConfig=n,this.networkInfoService=r,this.errorStackSyncRequestDecorator=i}handle(e){return this.processBatch(e).pipe(Object(D.expand)(t=>t>0?this.processBatch(e):c.EMPTY),Object(D.mapTo)(void 0),Object(D.catchError)(()=>Object(c.of)(void 0)))}processBatch(e){return this.getErrorStackBatch(e).pipe(Object(D.mergeMap)(e=>this.sync(e)),Object(D.mergeMap)(e=>this.clearLogs(e)),Object(D.map)(e=>e.length))}getErrorStackBatch(e){return this.dbService.execute(`\n SELECT * FROM ${Rt.TABLE_NAME}\n LIMIT ${e}\n `)}clearLogs(e){return e.length?this.dbService.execute(`\n DELETE FROM ${Rt.TABLE_NAME}\n WHERE ${Rt._ID} IN (${e.map(e=>e[vu]).join(",")})\n `).pipe(Object(D.mapTo)(e)):Object(c.of)(e)}sync(e){return e.length?this.networkInfoService.networkStatus$.pipe(Object(D.mergeMap)(t=>{if(t===Vn.OFFLINE)return Object(c.throwError)(new Error("Fake Error"));const n={pdata:void 0,context:void 0,logs:e.map(e=>Cu.mapErrorSatckDBEntryToErrorStack(e))};return this.errorStackSyncRequestDecorator.decorate(n).pipe(Object(D.mergeMap)(()=>{const e=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.errorLoggerConfig.errorLoggerApiPath).withBearerToken(!0).withBody({request:n}).build();return this.apiService.fetch(e)}))}),Object(D.mapTo)(e)):Object(c.of)(e)}}var mu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class bu{constructor(e,t,n){this.apiConfig=e,this.deviceInfo=t,this.appInfo=n}decorate(e){return Object(c.defer)(()=>mu(this,void 0,void 0,(function*(){return this.patchPData(e),yield this.patchContext(e),e})))}patchContext(e){return mu(this,void 0,void 0,(function*(){e.context={did:this.deviceInfo.getDeviceID(),spec:yield this.deviceInfo.getDeviceSpec().toPromise()}}))}patchPData(e){e.pdata=new ve,e.pdata.id=this.apiConfig.api_authentication.producerId;const t=e.pdata.pid;t?e.pdata.pid=t:this.apiConfig.api_authentication.producerUniqueId?e.pdata.pid=this.apiConfig.api_authentication.producerUniqueId:e.pdata.pid="sunbird.android",e.pdata.ver||(e.pdata.ver=this.appInfo.getVersionName())}}var Iu,Mu=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ru=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Lu=function(e,t){return function(n,r){t(n,r,e)}};let Pu=Iu=class{constructor(e,t,n,r,i,o,s,a){this.systemSettingsService=e,this.dbService=t,this.appInfo=n,this.apiService=r,this.sdkConfig=i,this.errorLoggerService=o,this.deviceInfo=s,this.sharedPreferences=a,this.errorLoggerConfig=this.sdkConfig.errorLoggerConfig,this.errorStackSyncRequestDecorator=new bu(this.sdkConfig.apiConfig,this.deviceInfo,this.appInfo),this.errorStackSyncHandler=new yu(this.apiService,this.dbService,this.errorLoggerConfig,this.errorLoggerService,this.errorStackSyncRequestDecorator)}onInit(){return this.sharedPreferences.getString(A.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP).pipe(Object(D.mergeMap)(e=>e?Object(c.of)(void 0):this.sharedPreferences.putString(A.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP,Date.now()+"")))}logError(e){const t={appver:this.appInfo.getVersionName(),pageid:e.pageId,ts:Date.now(),log:e.stacktrace};return this.dbService.insert({table:Rt.TABLE_NAME,modelJson:Cu.mapErrorStackToErrorStackDBEntry(t)}).pipe(Object(D.mergeMap)(()=>this.getErrorCount()),Object(D.mergeMap)(e=>this.getErrorLogSyncSettings().pipe(Object(D.map)(t=>Object.assign(Object.assign({},t),{errorCount:e})))),Object(D.map)(({errorCount:e,frequency:t,bandwidth:n})=>({errorCount:e,errorLogSyncFrequency:t,errorLogSyncBandwidth:n})),Object(D.mergeMap)(({errorCount:e,errorLogSyncFrequency:t,errorLogSyncBandwidth:n})=>this.hasErrorLogSyncFrequencyCrossed(e,t).pipe(Object(D.map)(e=>({shouldSync:e,errorLogSyncBandwidth:n})))),Object(D.mergeMap)(({shouldSync:e,errorLogSyncBandwidth:t})=>e?this.errorStackSyncHandler.handle(t).pipe(Object(D.mergeMap)(()=>this.sharedPreferences.putString(A.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP,Date.now()+""))):Object(c.of)(void 0)))}hasErrorLogSyncFrequencyCrossed(e,t){return this.sharedPreferences.getString(A.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP).pipe(Object(D.map)(e=>parseInt(e,10)),Object(D.map)(e=>e+t<Date.now()))}getErrorCount(){return this.dbService.execute("SELECT COUNT(*) as count FROM "+Rt.TABLE_NAME).pipe(Object(D.map)(e=>e[0].count))}getErrorLogSyncSettings(){const e={id:Iu.ERROR_LOG_SYNC_SETTINGS};return this.systemSettingsService.getSystemSettings(e).pipe(Object(D.map)(e=>JSON.parse(e.value)))}};Pu.ERROR_LOG_SYNC_SETTINGS=Tu.ERROR_LOG_SYNC_SETTINGS,Pu=Iu=Mu([Object(s.injectable)(),Lu(0,Object(s.inject)(l.SYSTEM_SETTINGS_SERVICE)),Lu(1,Object(s.inject)(l.DB_SERVICE)),Lu(2,Object(s.inject)(l.APP_INFO)),Lu(3,Object(s.inject)(l.API_SERVICE)),Lu(4,Object(s.inject)(l.SDK_CONFIG)),Lu(5,Object(s.inject)(l.NETWORKINFO_SERVICE)),Lu(6,Object(s.inject)(l.DEVICE_INFO)),Lu(7,Object(s.inject)(l.SHARED_PREFERENCES)),Ru("design:paramtypes",[Object,o,Object,Object,Object,Object,Object,Object])],Pu);var Du=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},wu=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};let Uu=class{constructor(){"none"===navigator.connection.type?this.networkStatusSource=new c.BehaviorSubject(Vn.OFFLINE):this.networkStatusSource=new c.BehaviorSubject(Vn.ONLINE),window.addEventListener("online",()=>{this.networkStatusSource.next(Vn.ONLINE)},!1),window.addEventListener("offline",()=>{this.networkStatusSource.next(Vn.OFFLINE)},!1),this.networkStatus$=this.networkStatusSource.asObservable()}};Uu=Du([Object(s.injectable)(),wu("design:paramtypes",[])],Uu);var ju=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Fu extends i{constructor(){super(8,23)}apply(e){return ju(this,void 0,void 0,(function*(){this.queries().forEach(t=>ju(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()})))}))}queries(){return[Pt.getCreateEntry()]}}var ku=Pt.COLUMN_NAME_USER_ID,xu=Pt.COLUMN_NAME_QUERY,Bu=Pt.COLUMN_NAME_TIME_STAMP;var Vu,Yu=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Gu=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Hu=function(e,t){return function(n,r){t(n,r,e)}};let $u=Vu=class{constructor(e,t){this.dbService=e,this.profileService=t}addEntry({query:e,namespace:t}){return this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(({uid:n})=>this.dbService.insert({table:Pt.TABLE_NAME,modelJson:{[Pt.COLUMN_NAME_QUERY]:e.trim(),[Pt.COLUMN_NAME_NAMESPACE]:t,[Pt.COLUMN_NAME_USER_ID]:n,[Pt.COLUMN_NAME_TIME_STAMP]:Date.now()}}).pipe(Object(D.mapTo)(n))),Object(D.mergeMap)(e=>this.dbService.execute(`\n DELETE FROM ${Pt.TABLE_NAME} WHERE\n ${Pt._ID} IN (SELECT ${Pt._ID} FROM ${Pt.TABLE_NAME} WHERE\n ${Pt.COLUMN_NAME_USER_ID} = "${e}" AND\n ${Pt.COLUMN_NAME_NAMESPACE} = "${t}"\n ORDER BY ${Pt.COLUMN_NAME_TIME_STAMP} DESC\n LIMIT -1 OFFSET ${Vu.MAX_USER_SEARCH_HISTORY_ENTRIES})\n `)),Object(D.mapTo)(void 0))}getEntries({like:e,limit:t,namespace:n}){return this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(({uid:r})=>{let i="";return e&&(i=`AND ${Pt.COLUMN_NAME_QUERY} LIKE "%${e.trim()}%"`),this.dbService.execute(`\n SELECT * FROM ${Pt.TABLE_NAME} WHERE\n ${Pt.COLUMN_NAME_USER_ID} = "${r}" AND\n ${Pt.COLUMN_NAME_NAMESPACE} = "${n}"\n ${i}\n ORDER BY ${Pt.COLUMN_NAME_TIME_STAMP} DESC\n LIMIT ${t}\n `)}),Object(D.map)(e=>e.map(e=>class{static mapSearchHistoryDbEntryToSearchEntry(e){return{uid:e[ku],query:e[xu],timestamp:e[Bu]}}}.mapSearchHistoryDbEntryToSearchEntry(e))))}};$u.MAX_USER_SEARCH_HISTORY_ENTRIES=10,$u=Vu=Yu([Object(s.injectable)(),Hu(0,Object(s.inject)(l.DB_SERVICE)),Hu(1,Object(s.inject)(l.PROFILE_SERVICE)),Gu("design:paramtypes",[o,Object])],$u);var qu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ku extends i{constructor(){super(9,24)}apply(e){return qu(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise())),yield e.read({table:vt.TABLE_NAME}).pipe(Object(D.map)(t=>{t.forEach(t=>qu(this,void 0,void 0,(function*(){const n=t[vt.COLUMN_NAME_DATA];if(n){const r=JSON.parse(n);t[St.COLUMN_NAME_MIME_TYPE]=r.mimeType,yield e.update({table:vt.TABLE_NAME,modelJson:t,selection:vt.COLUMN_NAME_CONTENT_IDENTIFIER+" = ?",selectionArgs:[t[vt.COLUMN_NAME_CONTENT_IDENTIFIER]]}).toPromise()}})))})).toPromise()}))}queries(){return[vt.getAlterEntryForMimeType()]}}var zu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Wu extends i{constructor(){super(10,25)}apply(e){return zu(this,void 0,void 0,(function*(){for(const t of this.queries())yield e.execute(t).toPromise()}))}queries(){return[wt.getCreateEntry()]}}var Xu=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ju=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Qu=function(e,t){return function(n,r){t(n,r,e)}};let Zu=class{constructor(e){this.sharedPreferences=e}setDefaultDeploymentKey(e){return this.sharedPreferences.putString(T.DEFAULT_DEPLOYMENT_KEY,e)}getDefaultDeploymentKey(){return this.sharedPreferences.getString(T.DEFAULT_DEPLOYMENT_KEY)}setExperimentKey(e){return this.sharedPreferences.putString(T.EXPERIMENT_KEY,e).pipe(Object(D.tap)(()=>{this.experimentKey||(this.experimentKey=e)}))}getExperimentKey(){return this.experimentKey?this.experimentKey:this.sharedPreferences.getString(T.EXPERIMENT_KEY).pipe(Object(D.tap)(e=>(this.experimentKey=e,e)))}setExperimentAppVersion(e){return this.sharedPreferences.putString(T.EXPERIMENT_APP_VERSION,e)}getExperimentAppVersion(){return this.sharedPreferences.getString(T.EXPERIMENT_APP_VERSION)}};Zu=Xu([Object(s.injectable)(),Qu(0,Object(s.inject)(l.SHARED_PREFERENCES)),Ju("design:paramtypes",[Object])],Zu);class el{constructor(e,t,n,r){this.apiService=e,this.faqServiceConfig=t,this.fileservice=n,this.cachedItemStore=r,this.FAQ_FILE_KEY_PREFIX="faq-",this.FAQ_LOCAL_KEY="faq-new-"}handle(e){return this.cachedItemStore.getCached(e.language,this.FAQ_LOCAL_KEY,"ttl_"+this.FAQ_LOCAL_KEY,()=>this.fetchFromServer(e),()=>this.fetchFromFile(e.language))}fetchFromServer(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withHost(e.faqUrl).withPath("/faq-"+e.language+".json").withBearerToken(!1).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>{let t;try{t=JSON.parse(e.body.trim())}catch(n){t=e.body}return t}))}fetchFromFile(e){const t=lr.getAssetPath()+this.faqServiceConfig.faqConfigDirPath,n=this.FAQ_FILE_KEY_PREFIX+e+".json";return Object(c.from)(this.fileservice.readFileFromAssets(t.concat("/",n))).pipe(Object(D.map)(e=>JSON.parse(e)))}}var tl=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},nl=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},rl=function(e,t){return function(n,r){t(n,r,e)}};let il=class{constructor(e,t,n,r){this.sdkConfig=e,this.fileService=t,this.apiService=n,this.cachedItemStore=r}getFaqDetails(e){return new el(this.apiService,this.sdkConfig.faqServiceConfig,this.fileService,this.cachedItemStore).handle(e)}};var ol;il=tl([Object(s.injectable)(),rl(0,Object(s.inject)(l.SDK_CONFIG)),rl(1,Object(s.inject)(l.FILE_SERVICE)),rl(2,Object(s.inject)(l.API_SERVICE)),rl(3,Object(s.inject)(l.CACHED_ITEM_STORE)),nl("design:paramtypes",[Object,Object,Object,Object])],il),function(e){e.CONTENT="content",e.PROFILE="profile",e.TELEMETRY="telemetry"}(ol||(ol={}));class sl extends ke{constructor(e,t){super(e,"ASSERTION_ERROR_"+t),Object.setPrototypeOf(this,sl.prototype)}}class al extends sl{constructor(e){super(e,"INVALID_REQUEST"),Object.setPrototypeOf(this,al.prototype)}}class cl extends sl{constructor(e){super(e,"OBJECT_NOT_FOUND"),Object.setPrototypeOf(this,cl.prototype)}}var ul=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ll{constructor(e,t){this.dbService=e,this.fileService=t}export(e,t){return new c.Observable(e=>{(()=>{ul(this,void 0,void 0,(function*(){let n={task:"",completed:[]};e.next(n=Object.assign(Object.assign({},n),{task:"VALIDATING"}));try{yield this.validate()}catch(t){return void e.error(t)}e.next(n=Object.assign(Object.assign({},n),{task:"PREPARING"})),yield this.prepare(t),e.next(n=Object.assign(Object.assign({},n),{task:"INITIALIZING"})),yield this.createWorkspace();const r=yield this.getMessageIds();try{for(;r.length;){const t=r.pop();yield this.processBatch(t).then(t=>{if(!t)return void e.next(n=Object.assign(Object.assign({},n),{task:"SKIPPING_BATCH"}));const{file:r,mid:i,eventsCount:o,size:s}=t;e.next(n=Object.assign(Object.assign({},n),{task:"BUILDING_BATCH",completed:[...n.completed,{file:r,mid:i,eventsCount:o,size:s,objectType:ol.TELEMETRY,contentEncoding:"gzip",explodedSize:-1}]}))})}}catch(t){return void e.error(t)}e.next(n=Object.assign(Object.assign({},n),{task:"OBJECT_ARCHIVE_COMPLETE"})),e.complete()}))})()})}validate(){return ul(this,void 0,void 0,(function*(){if(!(yield this.dbService.execute(`\n SELECT count(*) as COUNT FROM ${jt.TABLE_NAME} WHERE ${jt.COLUMN_NAME_TYPE} = '${Ft.TELEMETRY}'\n `.trim()).pipe(Object(D.map)(e=>e&&e[0]&&e[0].COUNT)).toPromise()))throw new cl("No telemetry to export")}))}prepare(e){return ul(this,void 0,void 0,(function*(){this.workspaceSubPath=""+e.workspacePath}))}createWorkspace(){return ul(this,void 0,void 0,(function*(){return this.fileService.createDir(this.workspaceSubPath,!1)}))}getMessageIds(){return ul(this,void 0,void 0,(function*(){return(yield this.dbService.read({table:jt.TABLE_NAME,columns:[jt.COLUMN_NAME_MSG_ID],selection:jt.COLUMN_NAME_TYPE+" = ?",selectionArgs:[Ft.TELEMETRY],distinct:!0}).toPromise()).map(e=>e[jt.COLUMN_NAME_MSG_ID])}))}processBatch(e){return ul(this,void 0,void 0,(function*(){const t=(yield this.dbService.read({table:jt.TABLE_NAME,selection:`${jt.COLUMN_NAME_MSG_ID} = ? AND ${jt.COLUMN_NAME_TYPE} = ?`,selectionArgs:[e,Ft.TELEMETRY]}).toPromise())[0];if(t)return yield this.fileService.writeFile(this.workspaceSubPath,t[jt.COLUMN_NAME_MSG_ID],t[jt.COLUMN_NAME_DATA],{replace:!0}),{size:[jt.COLUMN_NAME_DATA].length,eventsCount:t[jt.COLUMN_NAME_NUMBER_OF_ITEM],mid:t[jt.COLUMN_NAME_MSG_ID],file:""+t[jt.COLUMN_NAME_MSG_ID]}}))}}class dl extends ke{constructor(e,t){super(e,"ASSERTION_ERROR_"+t),Object.setPrototypeOf(this,dl.prototype)}}class hl extends dl{constructor(e){super(e,"UNKNOWN_OBJECT_ERROR"),Object.setPrototypeOf(this,hl.prototype)}}var El=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class fl{constructor(e,t,n,r){this.dbService=e,this.fileService=t,this.networkQueue=n,this.sdkConfig=r}import(e,t){return new c.Observable(e=>{(()=>{El(this,void 0,void 0,(function*(){let n={task:"",pending:[]};const r=t.items;e.next({task:"PREPARING",pending:[...r]}),yield this.prepare(t);try{for(;r.length;){const t=r.pop();if("gzip"!==t.contentEncoding)return void e.error(new hl("Unknown content encoding "+t.contentEncoding));yield this.processBatch(t).then(()=>{e.next(n=Object.assign(Object.assign({},n),{task:"IMPORTING_BATCH",pending:[...r]}))})}}catch(t){return void e.error(t)}e.next(n=Object.assign(Object.assign({},n),{task:"OBJECT_IMPORT_COMPLETE"})),e.complete()}))})()})}prepare(e){return El(this,void 0,void 0,(function*(){this.workspaceSubPath=""+e.workspacePath}))}processBatch(e){return El(this,void 0,void 0,(function*(){return this.fileService.readAsBinaryString(this.workspaceSubPath,e.file).then(t=>{this.networkQueue.enqueue(new En(this.sdkConfig).generateNetworkQueueRequest(Ft.TELEMETRY,t,e.mid,e.eventsCount,!1),!1).toPromise()})}))}}class pl extends dl{constructor(e){super(e,"INVALID_ARCHIVE"),Object.setPrototypeOf(this,pl.prototype)}}var _l,Ol=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Sl=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},gl=function(e,t){return function(n,r){t(n,r,e)}};let Al=_l=class{constructor(e,t,n,r,i,o,s){this.fileService=e,this.dbService=t,this.telemetryService=n,this.zipService=r,this.deviceInfo=i,this.networkQueue=o,this.sdkConfig=s}static reduceObjectProgressToArchiveObjectExportProgress(e){return e.reduce((e,{type:t,progress:n})=>(e.set(t,n),e),new Map)}static reduceObjectProgressToArchiveObjectImportProgress(e){return e.reduce((e,{type:t,progress:n})=>(e.set(t,n),e),new Map)}export(e){const t=`${"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalCacheDirectory}${en.generateUniqueId()}`;let n;return e.objects.length?Object(c.concat)(Object(c.defer)(()=>Object(c.from)(this.fileService.createDir(t,!1))).pipe(Object(D.concatMap)(()=>Object(c.combineLatest)(e.objects.map(n=>{switch(n.type){case ol.CONTENT:case ol.PROFILE:throw new Error("To be implemented");case ol.TELEMETRY:return new ll(this.dbService,this.fileService).export({filePath:e.filePath},{workspacePath:t}).pipe(Object(D.map)(e=>({type:ol.TELEMETRY,progress:e})))}}))),Object(D.map)(e=>({task:"BUILDING",progress:_l.reduceObjectProgressToArchiveObjectExportProgress(e)})),Object(D.tap)(e=>n=e)),Object(c.defer)(()=>this.generateManifestFile(n,t)),Object(c.defer)(()=>this.generateZipArchive(n,t)),Object(c.defer)(()=>this.generateExportTelemetries(n,t))).pipe(Object(D.tap)(e=>n=e)):Object(c.throwError)(new al("No archive objects to export"))}generateExportTelemetries(e,t){return e.progress.forEach((e,t)=>{switch(t){case ol.CONTENT:case ol.PROFILE:throw new Error("To be implemented");case ol.TELEMETRY:{const e={dir:ne.OUT,type:re.FILE,items:[],env:"sdk"};this.telemetryService.share(e).toPromise()}}}),Object(c.of)(Object.assign({},e))}generateZipArchive(e,t){const n=`${"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalCacheDirectory}archive-${(new Date).toISOString()}.zip`;return new c.Observable(e=>{this.zipService.zip(t,{target:n},[],[],()=>{e.next(),e.complete()},t=>{e.error(t)})}).pipe(Object(D.mapTo)(Object.assign(Object.assign({},e),{task:"COMPLETE",filePath:n})))}generateManifestFile({progress:e},t){return this.telemetryService.buildContext().pipe(Object(D.map)(e=>e.pdata),Object(D.concatMap)(n=>{const r=Array.from(e.entries()).reduce((e,[t,n])=>e.concat(n.completed),[]);return Object(c.from)(this.fileService.writeFile(t,"manifest.json",JSON.stringify({id:_l.ARCHIVE_ID,ver:_l.ARCHIVE_VERSION,ts:(new Date).toISOString(),producer:n,archive:{count:r.length,items:r}}),{replace:!0}))}),Object(D.mapTo)({progress:e,task:"BUILDING_MANIFEST"}))}import(e){const t=`${"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalCacheDirectory}${en.generateUniqueId()}`;if(!e.objects.length)return Object(c.throwError)(new al("No archive objects to export"));let n={task:"",progress:new Map,filePath:e.filePath};return Object(c.concat)(Object(c.defer)(()=>Object(c.from)(this.fileService.createDir(t,!1))).pipe(Object(D.concatMap)(()=>this.extractZipArchive(n,t))),Object(c.defer)(()=>this.readManifestFile(n,t,e.objects.map(e=>e.type))),Object(c.defer)(()=>this.generateImportTelemetries(n,t)),Object(c.defer)(()=>Object(c.combineLatest)(e.objects.map(r=>{switch(r.type){case ol.CONTENT:case ol.PROFILE:throw new Error("To be implemented");case ol.TELEMETRY:return new fl(this.dbService,this.fileService,this.networkQueue,this.sdkConfig).import({filePath:e.filePath},{workspacePath:t,items:n.progress.get(ol.TELEMETRY).pending}).pipe(Object(D.map)(e=>({type:ol.TELEMETRY,progress:e})))}})).pipe(Object(D.map)(e=>({task:"IMPORTING",progress:_l.reduceObjectProgressToArchiveObjectImportProgress(e)})))),Object(c.of)(Object.assign(Object.assign({},n),{task:"COMPLETE"}))).pipe(Object(D.tap)(e=>n=e))}generateImportTelemetries(e,t){return e.progress.forEach((e,t)=>{switch(t){case ol.CONTENT:case ol.PROFILE:throw new Error("To be implemented");case ol.TELEMETRY:{const e={dir:ne.IN,type:re.FILE.valueOf(),items:[],env:"sdk"};this.telemetryService.share(e).toPromise()}}}),Object(c.of)(Object.assign({},e))}extractZipArchive(e,t){const n=e.filePath;return new c.Observable(e=>{sbutility.copyFile(Mo.getDirecory(n),t+"/",Mo.getFileName(n),()=>{this.zipService.unzip(`${t}/${Mo.getFileName(n)}`,{target:t+"/"},()=>{e.next(),e.complete()},t=>e.error(t))},t=>{console.error(t),e.error(t)})}).pipe(Object(D.mapTo)(Object.assign(Object.assign({},e),{task:"EXTRACTING"})))}readManifestFile(e,t,n){return Object(c.from)(this.fileService.readAsText(t,"manifest.json")).pipe(Object(D.map)(e=>{try{return JSON.parse(e)}catch(e){throw new pl("Invalid manfiest.json")}}),Object(D.map)(t=>Object.assign(Object.assign({},e),{progress:(n.forEach(n=>{const r=t.archive.items.filter(e=>e.objectType===n);if(!r.length)throw new pl("Nothing to import");e.progress.set(n,{task:"INITIALISING",pending:r})}),e.progress),task:"VALIDATING"})))}};Al.ARCHIVE_ID="sunbird.data.archive",Al.ARCHIVE_VERSION="1.0",Al=_l=Ol([Object(s.injectable)(),gl(0,Object(s.inject)(l.FILE_SERVICE)),gl(1,Object(s.inject)(l.DB_SERVICE)),gl(2,Object(s.inject)(l.TELEMETRY_SERVICE)),gl(3,Object(s.inject)(l.ZIP_SERVICE)),gl(4,Object(s.inject)(l.DEVICE_INFO)),gl(5,Object(s.inject)(l.NETWORK_QUEUE)),gl(6,Object(s.inject)(l.SDK_CONFIG)),Sl("design:paramtypes",[Object,o,Object,Object,Object,Object,Object])],Al);var Nl=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Tl extends i{constructor(e,t){super(14,27),this.sdkConfig=e,this.networkQueue=t}apply(e){return Nl(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise())),yield e.read({table:qe.TABLE_NAME,selection:"",selectionArgs:[]}).pipe(Object(D.map)(t=>{const n=new En(this.sdkConfig);t.forEach(t=>Nl(this,void 0,void 0,(function*(){if(t){const r=t[qe.COLUMN_NAME_MSG_ID],i=t[qe.COLUMN_NAME_DATA],o=t[qe.COLUMN_NAME_NUMBER_OF_EVENTS];yield this.networkQueue.enqueue(n.generateNetworkQueueRequest(Ft.TELEMETRY,i,r,o,!1),!1).toPromise(),yield e.execute(`DELETE FROM ${qe.TABLE_NAME} WHERE ${qe.COLUMN_NAME_MSG_ID}='${r}'`).toPromise()}})))})).toPromise()}))}queries(){return[jt.getCreateEntry()]}}var Cl=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},vl=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},yl=function(e,t){return function(n,r){t(n,r,e)}},ml=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let bl=class{constructor(e,t,n,r){this.dbService=e,this.sharedPreferences=t,this.deviceInfo=n,this.sdkConfig=r}enqueue(e,t){const n="Uint8Array"===this.getTypeOf(e.networkRequest.body)?e.networkRequest.body.buffer:e.networkRequest.body;return new c.Observable(r=>{(()=>{ml(this,void 0,void 0,(function*(){e.networkRequest=yield this.interceptRequest(e.networkRequest).toPromise(),sbsync.enqueue(n,jt.Mapper.networkQueueRequestToEntry(e),t,()=>{r.next(void 0),r.complete()},e=>{r.error(e)})}))})()})}interceptRequest(e){return this.sharedPreferences.getString(h.KEY_API_TOKEN).pipe(Object(D.map)(t=>{if(t){const n=e.headers;n.Authorization="Bearer "+t,e.headers=n}return e}),Object(D.mergeMap)(()=>this.sharedPreferences.getString(E.KEY_OAUTH_SESSION).pipe(Object(D.map)(t=>{if(t){const n=JSON.parse(t),r=e.headers;r["X-Authenticated-User-Token"]=n.access_token,n.managed_access_token&&(r["X-Authenticated-For"]=n.managed_access_token),e.headers=r}return e}))),Object(D.map)(()=>{e.headers["X-Channel-Id"]=this.sdkConfig.apiConfig.api_authentication.channelId,e.headers["X-App-Id"]=this.sdkConfig.apiConfig.api_authentication.producerId,e.headers["X-Device-Id"]=this.deviceInfo.getDeviceID(),e.headers.Accept="application/json",e.headers["Content-Type"]="application/json",e.headers["Access-Control-Allow-Origin"]="*",e.body={};return(new a.CsRequest.Builder).withSerializer(e.serializer).withHost(this.sdkConfig.apiConfig.host).withType(e.type).withPath(e.path).withHeaders(e.headers).withBody({}).withBearerToken(!0).build()}))}getTypeOf(e){switch(Object.prototype.toString.call(e)){case"[object Uint8Array]":return"Uint8Array";default:return"Unknown"}}};bl=Cl([Object(s.injectable)(),yl(0,Object(s.inject)(l.DB_SERVICE)),yl(1,Object(s.inject)(l.SHARED_PREFERENCES)),yl(2,Object(s.inject)(l.DEVICE_INFO)),yl(3,Object(s.inject)(l.SDK_CONFIG)),vl("design:paramtypes",[o,Object,Object,Object])],bl);class Il{constructor(e,t){this.groupActivityService=e,this.cachedItemStore=t}getDataAggregation(e){return this.cachedItemStore[e.from===Jn.SERVER?"get":"getCached"](`group-${e.groupId}-activity-${e.activity.id}-${e.activity.type}`,Il.GROUP_ACTIVITY_DATA_AGGREGATION_KEY,"ttl_"+Il.GROUP_ACTIVITY_DATA_AGGREGATION_KEY,()=>this.groupActivityService.getDataAggregation(e.groupId,e.activity,e.mergeGroup,e.leafNodesCount))}getDataForDashlets(e,t){return this.groupActivityService.getDataForDashlets(e,t)}}Il.GROUP_ACTIVITY_DATA_AGGREGATION_KEY="GROUP_ACTIVITY_DATA_AGGREGATION-";var Ml,Rl=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ll=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Pl=function(e,t){return function(n,r){t(n,r,e)}};let Dl=Ml=class{constructor(e,t){this.container=e,this.cachedItemStore=t}get activityService(){return this._groupActivityService||(this._groupActivityService=new Il(this.groupServiceDelegate.activityService,this.cachedItemStore)),this._groupActivityService}get groupServiceDelegate(){return this.container.get(u.GROUP_SERVICE)}create(e){return this.groupServiceDelegate.create(e)}getById(e){return this.cachedItemStore[e.from===Jn.SERVER?"get":"getCached"](`${e.id}-${e.userId}`+(e.options&&e.options.includeMembers?"-includeMembers:"+e.options.includeMembers:"")+(e.options&&e.options.includeActivities?"-includeActivities:"+e.options.includeActivities:"")+(e.options&&e.options.groupActivities?"-groupActivities:"+e.options.groupActivities:""),Ml.GROUP_LOCAL_KEY,"ttl_"+Ml.GROUP_LOCAL_KEY,()=>this.groupServiceDelegate.getById(e.id,e.options))}search({request:e,from:t}){return this.cachedItemStore[t===Jn.SERVER?"get":"getCached"](""+e.filters.userId,Ml.GROUP_SEARCH_LOCAL_KEY,"ttl_"+Ml.GROUP_SEARCH_LOCAL_KEY,()=>this.groupServiceDelegate.search(e))}updateById(e){return this.groupServiceDelegate.updateById(e.id,e.updateRequest)}deleteById(e){return this.groupServiceDelegate.deleteById(e.id)}addMembers(e){return this.groupServiceDelegate.addMembers(e.groupId,e.addMembersRequest)}updateMembers(e){return this.groupServiceDelegate.updateMembers(e.groupId,e.updateMembersRequest)}removeMembers(e){return this.groupServiceDelegate.removeMembers(e.groupId,e.removeMembersRequest)}addActivities(e){return this.groupServiceDelegate.addActivities(e.groupId,e.addActivitiesRequest)}updateActivities(e){return this.groupServiceDelegate.updateActivities(e.groupId,e.updateActivitiesRequest)}removeActivities(e){return this.groupServiceDelegate.removeActivities(e.groupId,e.removeActivitiesRequest)}getSupportedActivities(){return this.groupServiceDelegate.getSupportedActivities()}suspendById(e){return this.groupServiceDelegate.suspendById(e.id)}reactivateById(e){return this.groupServiceDelegate.reactivateById(e.id)}updateGroupGuidelines(e){return this.groupServiceDelegate.updateGroupGuidelines(e)}};Dl.GROUP_LOCAL_KEY="GROUP-",Dl.GROUP_SEARCH_LOCAL_KEY="GROUP_SEARCH-",Dl=Ml=Rl([Object(s.injectable)(),Pl(0,Object(s.inject)(l.CONTAINER)),Pl(1,Object(s.inject)(l.CACHED_ITEM_STORE)),Ll("design:paramtypes",[s.Container,Object])],Dl);class wl{constructor(e){this._gid=e,this._sid=en.generateUniqueId(),this._createdTime=Date.now()}get gid(){return this._gid}get sid(){return this._sid}get createdTime(){return this._createdTime}}class Ul extends ke{constructor(e){super(e,"NO_GROUP_FOUND"),Object.setPrototypeOf(this,Ul.prototype)}}class jl extends ke{constructor(e){super(e,"NO_ACTIVE_SESSION"),Object.setPrototypeOf(this,jl.prototype)}}class Fl{static mapGroupDBEntryToGroup(e){return{gid:e[pt.COLUMN_NAME_GID],name:e[pt.COLUMN_NAME_NAME],syllabus:e[pt.COLUMN_NAME_SYLLABUS].split(","),grade:e[pt.COLUMN_NAME_GRADE].split(","),gradeValue:JSON.parse(e[pt.COLUMN_NAME_GRADE_VALUE]),createdAt:e[pt.COLUMN_NAME_CREATED_AT],updatedAt:e[pt.COLUMN_NAME_UPDATED_AT]}}static mapGroupToGroupDBEntry(e){return{[pt.COLUMN_NAME_GID]:e.gid,[pt.COLUMN_NAME_SYLLABUS]:e.syllabus?e.syllabus.join(","):"",[pt.COLUMN_NAME_GRADE]:e.grade?e.grade.join(","):"",[pt.COLUMN_NAME_NAME]:e.name,[pt.COLUMN_NAME_GRADE_VALUE]:JSON.stringify(e.gradeValue),[pt.COLUMN_NAME_CREATED_AT]:e.createdAt,[pt.COLUMN_NAME_UPDATED_AT]:e.updatedAt}}}var kl,xl=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Bl=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Vl=function(e,t){return function(n,r){t(n,r,e)}},Yl=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let Gl=kl=class{constructor(e,t,n,r){this.container=e,this.dbService=t,this.profileService=n,this.sharedPreferences=r}get telemetryService(){return this.container.get(l.TELEMETRY_SERVICE)}createGroup(e){return e.gid=en.generateUniqueId(),e.createdAt=Date.now(),e.updatedAt=Date.now(),this.dbService.insert({table:pt.TABLE_NAME,modelJson:Fl.mapGroupToGroupDBEntry(e)}).pipe(Object(D.tap)(()=>Yl(this,void 0,void 0,(function*(){yield this.profileService.getActiveProfileSession().pipe(Object(D.map)(e=>e.uid),Object(D.mergeMap)(t=>{const n=new pe;n.id=t,n.type=pe.TYPE_SYSTEM;const r={env:"sdk",actor:n,currentState:ue.AUDIT_CREATED,updatedProperties:Qr.getTruthyProps(e),objId:e.gid,objType:Q.GROUP};return this.telemetryService.audit(r)})).toPromise()}))),Object(D.map)(()=>e))}deleteGroup(e){return Object(c.defer)(()=>Object(c.of)(this.dbService.beginTransaction())).pipe(Object(D.mergeMap)(()=>Object(c.zip)(this.dbService.delete({table:pt.TABLE_NAME,selection:pt.COLUMN_NAME_GID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:ft.TABLE_NAME,selection:ft.COLUMN_NAME_GID+" = ?",selectionArgs:[e]})).pipe(Object(D.mapTo)(void 0))),Object(D.tap)(()=>{this.dbService.endTransaction(!0)}),Object(D.tap)(()=>Yl(this,void 0,void 0,(function*(){yield this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(t=>{const n=new pe;n.id=t.uid,n.type=pe.TYPE_SYSTEM;const r={env:"sdk",actor:n,currentState:ue.AUDIT_DELETED,objId:e,objType:Q.GROUP};return this.telemetryService.audit(r)})).toPromise()}))),Object(D.catchError)(e=>(this.dbService.endTransaction(!1),c.Observable.throw(e))))}updateGroup(e){return this.dbService.read({table:pt.TABLE_NAME,selection:"gid = ?",selectionArgs:[e.gid]}).pipe(Object(D.map)(t=>t&&t[0]?Fl.mapGroupDBEntryToGroup(t[0]):c.Observable.throw(new Ul("No Group found with ID "+e.gid))),Object(D.tap)(t=>Yl(this,void 0,void 0,(function*(){yield this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(n=>{const r=new pe;r.id=n.uid,r.type=pe.TYPE_SYSTEM;const i={env:"sdk",actor:r,currentState:ue.AUDIT_UPDATED,updatedProperties:Qr.getPropDiff(e,t),objId:e.gid,objType:Q.GROUP};return this.telemetryService.audit(i)})).toPromise()}))),Object(D.mergeMap)(()=>this.dbService.update({table:pt.TABLE_NAME,selection:"gid = ?",selectionArgs:[e.gid],modelJson:{[pt.COLUMN_NAME_NAME]:e.name,[pt.COLUMN_NAME_SYLLABUS]:e.syllabus.join(","),[pt.COLUMN_NAME_UPDATED_AT]:Date.now(),[pt.COLUMN_NAME_GRADE]:e.grade.join(","),[pt.COLUMN_NAME_GRADE_VALUE]:JSON.stringify(e.gradeValue)}}).pipe(Object(D.mapTo)(e))))}getActiveSessionGroup(){return this.getActiveGroupSession().pipe(Object(D.map)(e=>{if(!e)throw new jl("No active session available");return e}),Object(D.mergeMap)(e=>this.dbService.read({table:pt.TABLE_NAME,selection:pt.COLUMN_NAME_GID+" = ?",selectionArgs:[e.gid]}).pipe(Object(D.map)(e=>e&&e[0]))))}setActiveSessionForGroup(e){return this.dbService.read({table:pt.TABLE_NAME,selection:pt.COLUMN_NAME_GID+" = ?",selectionArgs:[e]}).pipe(Object(D.map)(e=>e&&e[0]&&Fl.mapGroupDBEntryToGroup(e[0])),Object(D.map)(e=>{if(!e)throw new Ul("No Profile found");return e}),Object(D.mergeMap)(e=>{const t=new wl(e.gid);return this.sharedPreferences.putString(kl.KEY_GROUP_SESSION,JSON.stringify({gid:t.gid,sid:t.sid,createdTime:t.createdTime})).pipe(Object(D.mapTo)(!0))}))}getActiveGroupSession(){return this.sharedPreferences.getString(kl.KEY_GROUP_SESSION).pipe(Object(D.map)(e=>{if(e)return JSON.parse(e)}))}getAllGroups(e){return Object(c.defer)(()=>e?this.dbService.execute(`\n SELECT * FROM ${pt.TABLE_NAME}\n LEFT JOIN ${ft.TABLE_NAME} ON\n ${pt.TABLE_NAME}.${pt.COLUMN_NAME_GID} =\n ${ft.TABLE_NAME}.${ft.COLUMN_NAME_GID}\n WHERE ${ft.COLUMN_NAME_UID} = "${e.uid}"`).pipe(Object(D.map)(e=>e.map(e=>Fl.mapGroupDBEntryToGroup(e)))):this.dbService.read({table:pt.TABLE_NAME,columns:[]}).pipe(Object(D.map)(e=>e.map(e=>Fl.mapGroupDBEntryToGroup(e))))).pipe(Object(D.mergeMap)(e=>Object(c.from)(e)),Object(D.mergeMap)(e=>this.profileService.getAllProfiles({groupId:e.gid}).pipe(Object(D.map)(t=>Object.assign(Object.assign({},e),{profilesCount:t.length})))),Object(D.reduce)((e,t)=>[...e,t],[]))}addProfilesToGroup(e){return Object(c.defer)(()=>Object(c.of)(this.dbService.beginTransaction())).pipe(Object(D.mergeMap)(()=>this.dbService.delete({table:ft.TABLE_NAME,selection:ft.COLUMN_NAME_GID+" = ?",selectionArgs:[e.groupId]})),Object(D.mergeMap)(()=>e.uidList.length?Object(c.zip)(...e.uidList.map(t=>this.dbService.insert({table:ft.TABLE_NAME,modelJson:{[ft.COLUMN_NAME_GID]:e.groupId,[ft.COLUMN_NAME_UID]:t}}))).pipe(Object(D.mapTo)(e.uidList.length)):Object(c.of)(0)),Object(D.tap)(()=>{this.dbService.endTransaction(!0)}),Object(D.catchError)(e=>(this.dbService.endTransaction(!1),Object(c.throwError)(e))))}removeActiveGroupSession(){return this.getActiveGroupSession().pipe(Object(D.mergeMap)(e=>e?this.sharedPreferences.putString(kl.KEY_GROUP_SESSION,""):Object(c.of)(void 0)))}};Gl.KEY_GROUP_SESSION=f.KEY_GROUP_SESSION,Gl=kl=xl([Object(s.injectable)(),Vl(0,Object(s.inject)(l.CONTAINER)),Vl(1,Object(s.inject)(l.DB_SERVICE)),Vl(2,Object(s.inject)(l.PROFILE_SERVICE)),Vl(3,Object(s.inject)(l.SHARED_PREFERENCES)),Bl("design:paramtypes",[s.Container,o,Object,Object])],Gl);var Hl=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class $l extends i{constructor(){super(15,28)}apply(e){return Hl(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise())),yield this.updateContentTable(e)}))}updateContentTable(e){return Hl(this,void 0,void 0,(function*(){e.beginTransaction();try{const t=(yield e.read({table:St.TABLE_NAME}).toPromise()).reduce((e,t)=>{let n;t[St.COLUMN_NAME_LOCAL_DATA]&&kn.isAvailableLocally(t[St.COLUMN_NAME_CONTENT_STATE])?n=JSON.parse(t[St.COLUMN_NAME_LOCAL_DATA]):t[St.COLUMN_NAME_SERVER_DATA]&&(n=JSON.parse(t[St.COLUMN_NAME_SERVER_DATA]));const r=n?n.resourceType:void 0,i=jn.CsPrimaryCategoryMapper.getPrimaryCategory(t[St.COLUMN_NAME_CONTENT_TYPE],t[St.COLUMN_NAME_MIME_TYPE],r).toLowerCase();return e.set(t[St.COLUMN_NAME_IDENTIFIER],i),e},new Map);if(!t.size)return void e.endTransaction(!0);const n=this.buildPrimaryCategoryCases(t),r=`UPDATE ${St.TABLE_NAME} SET ${n};`.trim();yield e.execute(r).toPromise(),e.endTransaction(!0)}catch(t){throw console.error(t),e.endTransaction(!1),t}}))}buildPrimaryCategoryCases(e){return Array.from(e.entries()).reduce((e,[t,n])=>n?e.concat(` WHEN '${t}' THEN '${n}' `):e,` ${St.COLUMN_NAME_PRIMARY_CATEGORY} = CASE ${St.COLUMN_NAME_IDENTIFIER} `).concat(" ELSE '' END ")}queries(){return[St.getAlterEntryForPrimaryCategory()]}}var ql=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Kl=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},zl=function(e,t){return function(n,r){t(n,r,e)}};let Wl=class{constructor(e){this.container=e}get discussionServiceDelegate(){return this.container.get(u.DISCUSSION_SERVICE)}getForumIds(e){return this.discussionServiceDelegate.getForumIds(e)}createUser(e){return this.discussionServiceDelegate.createUser(e)}attachForum(e){return this.discussionServiceDelegate.attachForum(e)}removeForum(e){return this.discussionServiceDelegate.removeForum(e)}createForum(e){return this.discussionServiceDelegate.createForum(e)}};Wl=ql([Object(s.injectable)(),zl(0,Object(s.inject)(l.CONTAINER)),Kl("design:paramtypes",[s.Container])],Wl);class Xl{constructor(e){this.keyValueStore=e,this.TAG_KEY="segment-tag_"}handle(e){return this.keyValueStore.getValue(this.TAG_KEY+e).pipe(Object(D.map)(e=>e||null))}}class Jl{constructor(e){this.keyValueStore=e,this.COMMAND_KEY="segment-command_"}handle(e){return this.keyValueStore.getValue(this.COMMAND_KEY+e).pipe(Object(D.map)(e=>e||null))}}class Ql{constructor(e){this.keyValueStore=e,this.TAG_KEY="segment-tag_"}handle(e,t){return this.keyValueStore.setValue(this.TAG_KEY+t,e)}}class Zl{constructor(e){this.keyValueStore=e,this.COMMAND_KEY="segment-command_"}handle(e,t){return this.keyValueStore.setValue(this.COMMAND_KEY+t,e)}}var ed=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},td=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},nd=function(e,t){return function(n,r){t(n,r,e)}};let rd=class{constructor(e){this.keyValueStore=e}saveTags(e,t){return new Ql(this.keyValueStore).handle(e,t)}getTags(e){return new Xl(this.keyValueStore).handle(e)}removeTagsForId(e){throw new Error("Method not implemented.")}clearAllTags(){throw new Error("Method not implemented.")}saveCommandList(e,t){return new Zl(this.keyValueStore).handle(e,t)}getCommand(e){return new Jl(this.keyValueStore).handle(e)}};rd=ed([Object(s.injectable)(),nd(0,Object(s.inject)(l.KEY_VALUE_STORE)),td("design:paramtypes",[Object])],rd);var id=n(22),od=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class sd{constructor(e,t){this.sharedPreferences=e,this.debuggingServiceImpl=t}handle(e){return od(this,void 0,void 0,(function*(){let t=yield this.sharedPreferences.getString("debug_started_at").toPromise();if(console.log(t),t){let n=setInterval(()=>od(this,void 0,void 0,(function*(){var r=((new Date).getTime()-new Date(parseInt(t)).getTime())/1e3;r/=60,console.log("diff",Math.abs(Math.round(r))),Math.abs(Math.round(r))>=10?(this.sharedPreferences.putString("debug_started_at","").toPromise(),this.debuggingServiceImpl.disableDebugging(),yield this.sharedPreferences.putString(id.CsClientStorage.TRACE_ID,"").toPromise(),e.next(!1),e.complete(),clearInterval(n),this.debuggingServiceImpl.watcher.interval=null,this.debuggingServiceImpl.watcher.observer=null,this.debuggingServiceImpl.watcher.debugStatus=!1):e.next(!0)})),6e4);this.debuggingServiceImpl.watcher.interval=n,this.debuggingServiceImpl.watcher.observer=e,this.debuggingServiceImpl.watcher.debugStatus=!0}else e.next(!1),e.complete()}))}}var ad=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},cd=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ud=function(e,t){return function(n,r){t(n,r,e)}},ld=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let dd=class{constructor(e,t){this.sharedPreferences=e,this.profileService=t,this.watcher={interval:null,observer:null,debugStatus:!1}}set userId(e){this._userId=e}get userId(){return this._userId}set deviceId(e){this._deviceId=e}get deviceId(){return this._deviceId}enableDebugging(e){return new c.Observable(t=>{this.profileService.getActiveProfileSession().toPromise().then(n=>ld(this,void 0,void 0,(function*(){if(null==n?void 0:n.uid){this._userId=n.uid;const r=yield I.createJWTToken(this._deviceId,this.userId);e?yield this.sharedPreferences.putString(id.CsClientStorage.TRACE_ID,e).toPromise():yield this.sharedPreferences.putString(id.CsClientStorage.TRACE_ID,r).toPromise(),new sd(this.sharedPreferences,this).handle(t),console.log("Watcher Value:",this.watcher)}})))})}disableDebugging(){return this.watcher.debugStatus?(clearTimeout(this.watcher.interval),this.watcher.observer.complete(),this.watcher={interval:null,observer:null,debugStatus:!1},this.sharedPreferences.putString("debug_started_at","").toPromise(),this.sharedPreferences.putString(id.CsClientStorage.TRACE_ID,"").toPromise(),Object(c.of)(!0)):Object(c.of)(!1)}isDebugOn(){return!!this.watcher.debugStatus}};dd=ad([Object(s.injectable)(),ud(0,Object(s.inject)(l.SHARED_PREFERENCES)),ud(1,Object(s.inject)(l.PROFILE_SERVICE)),cd("design:paramtypes",[Object,Object])],dd);var hd=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ed=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},fd=function(e,t){return function(n,r){t(n,r,e)}};let pd=class{constructor(e){this.container=e}get NotificationServiceV2Delegate(){return this.container.get(u.NOTIFICATION_SERVICE_V2)}notificationRead(e){return this.NotificationServiceV2Delegate.notificationRead(e)}notificationUpdate(e){return this.NotificationServiceV2Delegate.notificationUpdate(e)}notificationDelete(e){return this.NotificationServiceV2Delegate.notificationDelete(e)}};pd=hd([Object(s.injectable)(),fd(0,Object(s.inject)(l.CONTAINER)),Ed("design:paramtypes",[s.Container])],pd);var _d=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Od extends i{constructor(){super(16,29)}apply(e){return _d(this,void 0,void 0,(function*(){this.queries().forEach(t=>_d(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()})))}))}queries(){return[kt.getAlterEntryForPlayerConfig()]}}var Sd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class gd extends i{constructor(){super(17,30)}apply(e){return Sd(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise()))}))}queries(){return[Bt.getCreateEntry()]}}class Ad{constructor(e,t,n,r){this.dbService=e,this.container=t,this.certificateServiceConfig=n,this.apiConfig=r}get csCertificateService(){return this.container.get(u.CERTIFICATE_SERVICE)}handle(e){return this.dbService.read({table:Bt.TABLE_NAME,selection:Bt.COLUMN_NAME_IDENTIFIER+"= ?",selectionArgs:[e.osid.toString()]}).pipe(Object(D.mergeMap)(t=>t&&t.length?t[0].expiry_time<Date.now()?this.fetchFromServer(e).pipe(Object(D.mergeMap)(e=>this.updatePublicKey(e))):Object(c.of)({osid:t[0].identifier,value:t[0].public_key,alg:t[0].alg,osOwner:t[0].owner?t[0].owner.split(","):[]}):this.fetchFromServer(e).pipe(Object(D.mergeMap)(e=>this.insertPublicKey(e)))))}updatePublicKey(e){return this.dbService.update({table:Bt.TABLE_NAME,selection:Bt.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[e.osid],modelJson:{identifier:e.osid,public_key:e.value,alg:e.alg,owner:e.osOwner&&e.osOwner.length?e.osOwner.join(","):"",expiry_time:Date.now()+this.apiConfig.cached_requests.timeToLive}}).pipe(Object(D.mapTo)(e))}insertPublicKey(e){return this.dbService.insert({table:Bt.TABLE_NAME,modelJson:{identifier:e.osid,public_key:e.value,alg:e.alg,owner:e.osOwner&&e.osOwner.length?e.osOwner.join(","):"",expiry_time:Date.now()+this.apiConfig.cached_requests.timeToLive}}).pipe(Object(D.mapTo)(e))}fetchFromServer(e){return this.csCertificateService.getPublicKey(e)}}var Nd=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Td=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Cd=function(e,t){return function(n,r){t(n,r,e)}},vd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let yd=class{constructor(e,t,n,r,i,o){this.container=e,this.dbService=t,this.sdkConfig=n,this.profileService=r,this.keyValueStore=i,this.fileService=o}getCertificates(e){return this.csCertificateService.fetchCertificates(e)}getPublicKey(e){return new Ad(this.dbService,this.container,this.sdkConfig.certificateServiceConfig,this.sdkConfig.apiConfig).handle(e)}getCertificate(e){return this.csCertificateService.getCerificateDownloadURI({certificateId:e.certificate.identifier,type:e.certificate.type,schemaName:"certificate",templateUrl:e.certificate.templateUrl}).pipe(Object(D.tap)(t=>vd(this,void 0,void 0,(function*(){yield this.keyValueStore.setValue(yield this.buildCertificatePersistenceId(e),Object(an.gzip)(t.printUri,{to:"string"})).toPromise()}))),Object(D.map)(e=>e.printUri),Object(D.catchError)(t=>Object(c.defer)(()=>vd(this,void 0,void 0,(function*(){const n=yield this.getCertificateFromCache(e);if(n)return n;throw t})))))}downloadCertificate({fileName:e,blob:t}){return Object(c.defer)(()=>vd(this,void 0,void 0,(function*(){return this.fileService.writeFile(cordova.file.externalDataDirectory,e,t,{replace:!0}).then(()=>({path:`${cordova.file.externalDataDirectory}${e}`}))})))}downloadLegacyeCertificate(e){return Object(c.defer)(()=>vd(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n=t.managedSession?t.managedSession.uid:t.uid;"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalRootDirectory,e.certificate.name,e.courseId;return{userId:n}}))).pipe(Object(D.mergeMap)(({userId:t})=>this.csCertificateService.getLegacyCerificateDownloadURI({pdfUrl:e.certificate.url}).pipe(Object(D.map)(e=>({signedPdfUrl:e.signedUrl,userId:t})))),Object(D.mergeMap)(({signedPdfUrl:t,userId:n})=>{const r={uri:t,title:e.certificate.token,description:"",mimeType:"application/pdf",visibleInDownloadsUi:!0,notificationVisibility:1,destinationInExternalPublicDir:{dirType:"Download",subPath:`/${e.certificate.name}_${e.courseId}_${n}.pdf`},headers:[]};return new c.Observable(e=>{downloadManager.enqueue(r,(t,n)=>{if(t)return e.error(t);e.next(n),e.complete()})})}),Object(D.mergeMap)(e=>Object(c.interval)(1e3).pipe(Object(D.mergeMap)(()=>new c.Observable(t=>{downloadManager.query({ids:[e]},(e,n)=>e||n[0].status===DownloadStatus.STATUS_FAILED?t.error(e||new Error("Unknown Error")):t.next(n[0]))})),Object(D.filter)(e=>e.status===DownloadStatus.STATUS_SUCCESSFUL),Object(D.take)(1))),Object(D.map)(e=>({path:e.localUri})))}isCertificateCached(e){return Object(c.defer)(()=>vd(this,void 0,void 0,(function*(){try{return!!(yield this.getCertificateFromCache(e))}catch(e){return console.error(e),!1}})))}getEncodedData(e){return this.csCertificateService.getEncodedData(e)}verifyCertificate(e){return this.csCertificateService.verifyCertificate(e)}get csCertificateService(){return this.container.get(u.CERTIFICATE_SERVICE)}buildCertificatePersistenceId(e){return vd(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n=t.managedSession?t.managedSession.uid:t.uid;return`certificate_${e.certificate.identifier}_${e.courseId}_${n}`}))}getCertificateFromCache(e){return vd(this,void 0,void 0,(function*(){const t=yield this.keyValueStore.getValue(yield this.buildCertificatePersistenceId(e)).toPromise();return t?Object(ii.ungzip)(t,{to:"string"}):void 0}))}};yd=Nd([Object(s.injectable)(),Cd(0,Object(s.inject)(l.CONTAINER)),Cd(1,Object(s.inject)(l.DB_SERVICE)),Cd(2,Object(s.inject)(l.SDK_CONFIG)),Cd(3,Object(s.inject)(l.PROFILE_SERVICE)),Cd(4,Object(s.inject)(l.KEY_VALUE_STORE)),Cd(5,Object(s.inject)(l.FILE_SERVICE)),Td("design:paramtypes",[s.Container,o,Object,Object,Object,Object])],yd);var md=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class bd{constructor(){this._isInitialised=!1}static get instance(){return bd._instance||(bd._instance=new bd),bd._instance}get isInitialised(){return this._isInitialised}get sdkConfig(){return this._container.get(l.SDK_CONFIG)}get appInfo(){return this._container.get(l.APP_INFO)}get pageAssembleService(){return this._container.get(l.PAGE_ASSEMBLE_SERVICE)}get dbService(){return this._container.get(l.DB_SERVICE)}get telemetryService(){return this._container.get(l.TELEMETRY_SERVICE)}get authService(){return this._container.get(l.AUTH_SERVICE)}get apiService(){return this._container.get(l.API_SERVICE)}get keyValueStore(){return this._container.get(l.KEY_VALUE_STORE)}get profileService(){return this._container.get(l.PROFILE_SERVICE)}get groupService(){return this._container.get(l.GROUP_SERVICE)}get groupServiceDeprecated(){return this._container.get(l.GROUP_SERVICE_DEPRECATED)}get contentService(){return this._container.get(l.CONTENT_SERVICE)}get contentFeedbackService(){return this._container.get(l.CONTENT_FEEDBACK_SERVICE)}get courseService(){return this._container.get(l.COURSE_SERVICE)}get formService(){return this._container.get(l.FORM_SERVICE)}get frameworkService(){return this._container.get(l.FRAMEWORK_SERVICE)}get frameworkUtilService(){return this._container.get(l.FRAMEWORK_UTIL_SERVICE)}get sharedPreferences(){return this._container.get(l.SHARED_PREFERENCES)}get systemSettingsService(){return this._container.get(l.SYSTEM_SETTINGS_SERVICE)}get eventsBusService(){return this._container.get(l.EVENTS_BUS_SERVICE)}get summarizerService(){return this._container.get(l.SUMMARIZER_SERVICE)}get downloadService(){return this._container.get(l.DOWNLOAD_SERVICE)}get playerService(){return this._container.get(l.PLAYER_SERVICE)}get deviceInfo(){return this._container.get(l.DEVICE_INFO)}get storageService(){return this._container.get(l.STORAGE_SERVICE)}get notificationService(){return this._container.get(l.NOTIFICATION_SERVICE)}get errorLoggerService(){return this._container.get(l.ERROR_LOGGER_SERVICE)}get networkInfoService(){return this._container.get(l.NETWORKINFO_SERVICE)}get searchHistoryService(){return this._container.get(l.SEARCH_HISTORY_SERVICE)}get codePushExperimentService(){return this._container.get(l.CODEPUSH_EXPERIMENT_SERVICE)}get faqService(){return this._container.get(l.FAQ_SERVICE)}get deviceRegisterService(){return this._container.get(l.DEVICE_REGISTER_SERVICE)}get archiveService(){return this._container.get(l.ARCHIVE_SERVICE)}get networkQueueService(){return this._container.get(l.NETWORK_QUEUE)}get discussionService(){return this._container.get(l.DISCUSSION_SERVICE)}get segmentationService(){return this._container.get(l.SEGMENTATION_SERVICE)}get debuggingService(){return this._container.get(l.DEBUGGING_SERVICE)}get notificationServiceV2(){return this._container.get(l.NOTIFICATION_SERVICE_V2)}get certificateService(){return this._container.get(l.CERTIFICATE_SERVICE)}init(e){return md(this,void 0,void 0,(function*(){switch(this._container=new s.Container,this._container.bind(l.CONTAINER).toConstantValue(this._container),this._container.bind(l.DB_VERSION).toConstantValue(31),this._container.bind(l.DB_MIGRATION_LIST).toConstantValue([new Ca,new ya,new ba,new Da,new Tc,new Ma,new Fu,new Ku,new Wu,()=>new Tl(e,this._container.get(l.NETWORK_QUEUE)),new $l,new Od,new gd,new La]),e.platform){case"cordova":this._container.bind(l.SHARED_PREFERENCES).to(Sa).inSingletonScope();break;case"web":this._container.bind(l.SHARED_PREFERENCES).to(pa).inSingletonScope();break;default:throw new Error("FATAL_ERROR: Invalid platform")}this._container.bind(l.DB_SERVICE).to(Qt).inSingletonScope(),this._container.bind(l.FILE_SERVICE).to(Na).inSingletonScope(),this._container.bind(l.SDK_CONFIG).toConstantValue(e),this._container.bind(l.DEVICE_INFO).to(za).inSingletonScope(),this._container.bind(l.EVENTS_BUS_SERVICE).to(rc).inSingletonScope(),this._container.bind(l.APP_INFO).to(pc).inSingletonScope(),this._container.bind(l.API_SERVICE).to(G).inSingletonScope(),this._container.bind(l.AUTH_SERVICE).to(Zi).inSingletonScope(),this._container.bind(l.KEY_VALUE_STORE).to(Hs).inSingletonScope(),this._container.bind(l.SYSTEM_SETTINGS_SERVICE).to(ka).inSingletonScope(),this._container.bind(l.FRAMEWORK_SERVICE).to(co).inSingletonScope(),this._container.bind(l.PROFILE_SERVICE).to(Fi).inSingletonScope(),this._container.bind(l.GROUP_SERVICE).to(Dl).inSingletonScope(),this._container.bind(l.GROUP_SERVICE_DEPRECATED).to(Gl).inSingletonScope(),this._container.bind(l.ERROR_LOGGER_SERVICE).to(Pu).inSingletonScope(),this._container.bind(l.ZIP_SERVICE).to(Ba).inSingletonScope(),this._container.bind(l.TELEMETRY_SERVICE).to(Ki).inSingletonScope(),this._container.bind(l.CONTENT_FEEDBACK_SERVICE).to(Qa).inSingletonScope(),this._container.bind(l.FORM_SERVICE).to(Ws).inSingletonScope(),this._container.bind(l.PAGE_ASSEMBLE_SERVICE).to(Ea).inSingletonScope(),this._container.bind(l.FRAMEWORK_UTIL_SERVICE).to(Ao).inSingletonScope(),this._container.bind(l.DOWNLOAD_SERVICE).to(lc).inSingletonScope(),this._container.bind(l.CONTENT_SERVICE).to(Bs).inSingletonScope(),this._container.bind(l.COURSE_SERVICE).to(hi).inSingletonScope(),this._container.bind(l.SUMMARIZER_SERVICE).to(wr).inSingletonScope(),this._container.bind(l.PLAYER_SERVICE).to(Ac).inSingletonScope(),this._container.bind(l.CACHED_ITEM_STORE).to(ta).inSingletonScope(),this._container.bind(l.TELEMETRY_DECORATOR).to(on).inSingletonScope(),this._container.bind(l.STORAGE_SERVICE).to(du).inSingletonScope(),this._container.bind(l.NOTIFICATION_SERVICE).to(Nu).inSingletonScope(),this._container.bind(l.NETWORKINFO_SERVICE).to(Uu).inSingletonScope(),this._container.bind(l.SEARCH_HISTORY_SERVICE).to($u).inSingletonScope(),this._container.bind(l.CODEPUSH_EXPERIMENT_SERVICE).to(Zu).inSingletonScope(),this._container.bind(l.DEVICE_REGISTER_SERVICE).to(X).inSingletonScope(),this._container.bind(l.FAQ_SERVICE).to(il).inSingletonScope(),this._container.bind(l.ARCHIVE_SERVICE).to(Al).inSingletonScope(),this._container.bind(l.NETWORK_QUEUE).to(bl).inSingletonScope(),this._container.bind(l.DISCUSSION_SERVICE).to(Wl).inSingletonScope(),this._container.bind(l.SEGMENTATION_SERVICE).to(rd).inSingletonScope(),this._container.bind(l.DEBUGGING_SERVICE).to(dd).inSingletonScope(),this._container.bind(l.NOTIFICATION_SERVICE_V2).to(pd).inSingletonScope(),this._container.bind(l.CERTIFICATE_SERVICE).to(yd).inSingletonScope();const t=this.sharedPreferences;yield k.CsModule.instance.init({core:{httpAdapter:"web"===e.platform?"HttpClientBrowserAdapter":"HttpClientCordovaAdapter",global:{channelId:e.apiConfig.api_authentication.channelId,producerId:e.apiConfig.api_authentication.producerId,deviceId:ms(window.device.uuid).toString()},api:{host:e.apiConfig.host,authentication:{}}},services:{contentServiceConfig:{hierarchyApiPath:"/api/questionset/v2",questionListApiPath:"/api/question/v2"},courseServiceConfig:{apiPath:"/api/course/v1",certRegistrationApiPath:"/api/certreg/v2/certs"},groupServiceConfig:{apiPath:"/api/group/v1",dataApiPath:"/api/data/v1/group",updateGroupGuidelinesApiPath:"/api/group/membership/v1"},userServiceConfig:{apiPath:"/api/user/v2"},formServiceConfig:{apiPath:"/api/data/v1/form"},discussionServiceConfig:{apiPath:"/discussion"},notificationServiceConfig:{apiPath:"/api/notification/v1/feed"},certificateServiceConfig:{apiPath:e.certificateServiceConfig.apiPath,apiPathLegacy:e.certificateServiceConfig.apiPathLegacy,rcApiPath:e.certificateServiceConfig.rcApiPath},frameworkServiceConfig:{apiPath:"/api/framework/v1"}}},(()=>{this._container.rebind(u.HTTP_SERVICE).toConstantValue(k.CsModule.instance.httpService),this._container.rebind(u.GROUP_SERVICE).toConstantValue(k.CsModule.instance.groupService),this._container.rebind(u.COURSE_SERVICE).toConstantValue(k.CsModule.instance.courseService),this._container.rebind(u.USER_SERVICE).toConstantValue(k.CsModule.instance.userService),this._container.rebind(u.DISCUSSION_SERVICE).toConstantValue(k.CsModule.instance.discussionService),this._container.rebind(u.CONTENT_SERVICE).toConstantValue(k.CsModule.instance.contentService),this._container.rebind(u.NOTIFICATION_SERVICE_V2).toConstantValue(k.CsModule.instance.notificationService),this._container.rebind(u.CERTIFICATE_SERVICE).toConstantValue(k.CsModule.instance.certificateService),this._container.rebind(u.FRAMEWORK_SERVICE).toConstantValue(k.CsModule.instance.frameworkService)}).bind(this),new class{setItem(e,n){return t.putString(e,n).toPromise()}getItem(e){return t.getString(e).toPromise()}}),this._container.bind(u.HTTP_SERVICE).toConstantValue(k.CsModule.instance.httpService),this._container.bind(u.GROUP_SERVICE).toConstantValue(k.CsModule.instance.groupService),this._container.bind(u.COURSE_SERVICE).toConstantValue(k.CsModule.instance.courseService),this._container.bind(u.USER_SERVICE).toConstantValue(k.CsModule.instance.userService),this._container.bind(u.DISCUSSION_SERVICE).toConstantValue(k.CsModule.instance.discussionService),this._container.bind(u.CONTENT_SERVICE).toConstantValue(k.CsModule.instance.contentService),this._container.bind(u.NOTIFICATION_SERVICE_V2).toConstantValue(k.CsModule.instance.notificationService),this._container.bind(u.CERTIFICATE_SERVICE).toConstantValue(k.CsModule.instance.certificateService),this._container.bind(u.FRAMEWORK_SERVICE).toConstantValue(k.CsModule.instance.frameworkService),yield this.dbService.init(),yield this.appInfo.init(),yield this.preInit().toPromise(),this._isInitialised=!0,this.postInit().subscribe()}))}updateTelemetryConfig(e){for(const t in e)e.hasOwnProperty(t)&&(this.sdkConfig.telemetryConfig[t]=e[t])}updateDeviceRegisterConfig(e){for(const t in e)e.hasOwnProperty(t)&&(this.sdkConfig.deviceRegisterConfig[t]=e[t],"fcmToken"===t&&this.telemetryService.resetDeviceRegisterTTL())}updateContentServiceConfig(e){for(const t in e)e.hasOwnProperty(t)&&(this.sdkConfig.contentServiceConfig[t]=e[t])}updatePageServiceConfig(e){for(const t in e)e.hasOwnProperty(t)&&(this.sdkConfig.pageServiceConfig[t]=e[t])}preInit(){return this.telemetryService.preInit().pipe(Object(D.concatMap)(()=>this.frameworkService.preInit().pipe(Object(D.concatMap)(()=>this.profileService.preInit()))))}postInit(){return Object(c.combineLatest)([this.apiService.onInit(),this.authService.onInit(),this.summarizerService.onInit(),this.errorLoggerService.onInit(),this.eventsBusService.onInit(),this.downloadService.onInit(),this.contentService.onInit(),this.storageService.onInit(),this.telemetryService.onInit(),this.notificationService.onInit()])}}var Id=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Md{constructor(e,t,n){this.apiConfig=e,this.apiService=t,this.eventsBusService=n}static parseAccessToken(e){return Id(this,void 0,void 0,(function*(){let t=yield I.decodeJWT(e);const n=JSON.parse(t);return{userToken:3===n.sub.split(":").length?n.sub.split(":").pop():n.sub,accessTokenExpiresOn:1e3*n.exp}}))}buildGoogleTargetUrl(e,t){const n=new URL(e.googleRedirectUrl);return delete t.redirect_uri,n.searchParams.set("redirect_uri",this.apiConfig.user_authentication.redirectUrl),delete t.error_callback,n.searchParams.set("error_callback",this.apiConfig.user_authentication.redirectUrl),Object.keys(t).forEach(e=>n.searchParams.set(e,t[e])),n}buildPasswordSessionProvider(e,t){return e.capture({host:t.when.host,path:t.when.path,params:t.when.params}).then(()=>e.closeWebview()).then(()=>e.success()).then(e=>this.resolvePasswordSession(e))}buildStateSessionProvider(e,t){return e.capture({host:t.when.host,path:t.when.path,params:t.when.params}).then(()=>e.closeWebview()).then(()=>e.success()).then(e=>this.resolveStateSession(e))}buildGoogleSessionProvider(e,t,n){return e.capture({host:t.when.host,path:t.when.path,params:t.when.params}).then(()=>e.closeWebview()).then(()=>e.success()).then(t=>e.getCaptureExtras().then(r=>{const i=this.buildGoogleTargetUrl(t,r);return e.launchCustomTab({host:i.origin,path:i.pathname,params:Be.parse(i.searchParams.toString(),{ignoreQueryPrefix:!0}),extraParams:n.get("extraParam")}).then(()=>e.success()).then(e=>this.resolveGoogleSession(e))}))}resolvePasswordSession(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.apiConfig.user_authentication.authUrl+"/token").withBody({redirect_uri:this.apiConfig.host+"/oauth2callback",code:e.code,grant_type:"authorization_code",client_id:"android"}).withHeaders({"Content-Type":"application/x-www-form-urlencoded"}).withSerializer(a.CsHttpSerializer.URLENCODED).withBearerToken(!1).withUserToken(!1).build();return this.apiService.fetch(t).toPromise().then(e=>Id(this,void 0,void 0,(function*(){if(e.body.access_token&&e.body.refresh_token){const{userToken:t,accessTokenExpiresOn:n}=yield Md.parseAccessToken(e.body.access_token);return{access_token:e.body.access_token,refresh_token:e.body.refresh_token,accessTokenExpiresOn:n,userToken:t}}throw new xe("Server Error")}))).catch(()=>{throw new xe("Server Error")})}resolveStateSession(e){const t="/v1/sso/create/session?id="+("ios"===window.device.platform.toLowerCase()?encodeURIComponent(e.id):e.id),n=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(t).withUserToken(!1).withBearerToken(!1).build();return this.apiService.fetch(n).toPromise().then(e=>Id(this,void 0,void 0,(function*(){if(e.body.access_token&&e.body.refresh_token){const{userToken:t,accessTokenExpiresOn:n}=yield Md.parseAccessToken(e.body.access_token);return{access_token:e.body.access_token,refresh_token:e.body.refresh_token,accessTokenExpiresOn:n,userToken:t}}throw new xe("Server Error")}))).catch(()=>{throw new xe("Server Error")})}resolveGoogleSession(e){return Id(this,void 0,void 0,(function*(){if(e.access_token&&e.refresh_token){const{userToken:t,accessTokenExpiresOn:n}=yield Md.parseAccessToken(e.access_token);return{access_token:e.access_token,refresh_token:e.refresh_token,accessTokenExpiresOn:n,userToken:t}}if(e.error_message)throw new xe(e.error_message);throw new xe("Server Error")}))}}var Rd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ld extends Md{constructor(e,t,n){super(bd.instance.sdkConfig.apiConfig,bd.instance.apiService,bd.instance.eventsBusService),this.autoMergeConfig=e,this.webviewRunner=t,this.captured=n,this.telemetryService=bd.instance.telemetryService}provide(){return Rd(this,void 0,void 0,(function*(){const e=this.webviewRunner,t=yield this.telemetryService.buildContext().toPromise();return this.autoMergeConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)}),Object.keys(this.captured).forEach(e=>{this.autoMergeConfig.target.params.push({key:e,value:this.captured[e]})}),e.redirectTo({host:this.autoMergeConfig.target.host,path:this.autoMergeConfig.target.path,params:this.autoMergeConfig.target.params.reduce((e,t)=>(e[t.key]=t.value,e),{})}).then(()=>e.any(...this.autoMergeConfig.return.reduce((t,n)=>{switch(n.type){case"password":t.push(this.buildPasswordSessionProvider(e,n).then(e=>this.performAutoMerge({payload:this.captured.payload,session:e})));break;case"state":t.push(this.buildStateSessionProvider(e,n));break;case"google":t.push(this.buildGoogleSessionProvider(e,n).then(e=>this.performAutoMerge({payload:this.captured.payload,session:e})))}return t},[])))}))}performAutoMerge({payload:e,session:t}){const n=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.apiConfig.user_authentication.autoMergeApiPath).withParameters({client_id:"android"}).withHeaders({"x-authenticated-user-token":t.access_token,"x-authenticated-user-data":e}).build();return this.apiService.fetch(n).pipe(Object(D.mapTo)(void 0)).toPromise().then(()=>(this.eventsBusService.emit({namespace:M.AUTH,event:{type:he.AUTO_MIGRATE_SUCCESS,payload:void 0}}),t)).catch(e=>(console.error(e),this.eventsBusService.emit({namespace:M.AUTH,event:{type:he.AUTO_MIGRATE_FAIL,payload:void 0}}),t))}}var Pd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Dd extends Md{constructor(e,t,n,r){super(bd.instance.sdkConfig.apiConfig,bd.instance.apiService,bd.instance.eventsBusService),this.loginConfig=e,this.autoMergeConfig=t,this.customWebViewConfig=n,this.telemetryService=bd.instance.telemetryService,this.webviewRunner=r||new Gt}provide(){return Pd(this,void 0,void 0,(function*(){const e=this.webviewRunner,t=yield this.telemetryService.buildContext().toPromise();return"password"==this.loginConfig.context&&(this.loginConfig.target.path="/recover/identify/account"),this.loginConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)}),"ios"===window.device.platform.toLowerCase()&&"login"===this.loginConfig.context&&(yield e.launchWebview({host:this.loginConfig.target.host,path:"logoff",params:this.loginConfig.target.params.reduce((e,t)=>(e[t.key]=t.value,e),Object.assign({},this.resetParams))})),e.launchWebview({host:this.loginConfig.target.host,path:this.loginConfig.target.path,params:this.loginConfig.target.params.reduce((e,t)=>(e[t.key]=t.value,e),Object.assign({},this.resetParams))}).then(()=>e.any(...this.loginConfig.return.reduce((t,n)=>{switch(n.type){case"password":t.push(this.buildPasswordSessionProvider(e,n)),this.resetParams&&"password"==this.loginConfig.context&&e.closeWebview();break;case"state":t.push(this.buildStateSessionProvider(e,n));break;case"google":t.push(this.buildGoogleSessionProvider(e,n,this.customWebViewConfig));break;case"state-error":t.push(e.capture({host:n.when.host,path:n.when.path,params:n.when.params}).then(()=>e.closeWebview().then(()=>e.resolveCaptured("error_message").catch(()=>{throw new xe("Server Error")}).then(e=>{throw new xe(e)}))));break;case"migrate":t.push(e.capture({host:n.when.host,path:n.when.path,params:n.when.params}).then(()=>e.success()).then(t=>(e.resetInAppBrowserEventListeners(),e.clearCapture().then(()=>new Ld(this.autoMergeConfig,this.webviewRunner,t).provide()))));break;case"reset":t.push(e.capture({host:n.when.host,path:n.when.path,params:[...n.when.params,{key:"client_id",resolveTo:"client_id",match:"portal"},{key:"automerge",resolveTo:"automerge",exists:"false"}]}).then(()=>e.getCaptureExtras().then(t=>(this.resetParams=t,e.closeWebview().then(()=>new Promise(e=>setTimeout(e,500)).then(()=>this.provide()))))))}return t},[])))}))}}var wd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ud extends Md{constructor(e,t){super(bd.instance.sdkConfig.apiConfig,bd.instance.apiService,bd.instance.eventsBusService),this.manualMergeConfig=e,this.telemetryService=bd.instance.telemetryService,this.webviewRunner=t||new Gt}provide(){return wd(this,void 0,void 0,(function*(){const e=this.webviewRunner,t=yield this.telemetryService.buildContext().toPromise();return this.manualMergeConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)}),e.launchWebview({host:this.manualMergeConfig.target.host,path:this.manualMergeConfig.target.path,params:this.manualMergeConfig.target.params.reduce((e,t)=>(e[t.key]=t.value,e),{})}).then(()=>e.any(...this.manualMergeConfig.return.reduce((t,n)=>{switch(n.type){case"password":t.push(this.buildPasswordSessionProvider(e,n));break;case"google":t.push(this.buildGoogleSessionProvider(e,n));break;case"exit":t.push(e.capture({host:n.when.host,path:n.when.path,params:n.when.params}).then(()=>e.closeWebview().then(()=>e.clearCapture().then(()=>wd(this,void 0,void 0,(function*(){throw new jd("EXIT param found")}))))))}return t},[])))}))}}class jd extends Ve{constructor(e){super(e,"INTERRUPT_ERROR"),Object.setPrototypeOf(this,Ve.prototype)}}var Fd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class kd{constructor(e){this.nativeGoogleTokenProvider=e,this.apiService=bd.instance.apiService}static parseAccessToken(e){return Fd(this,void 0,void 0,(function*(){let t=yield I.decodeJWT(e);const n=JSON.parse(t);return{userToken:3===n.sub.split(":").length?n.sub.split(":").pop():n.sub,accessTokenExpiresOn:1e3*n.exp}}))}provide(){return Fd(this,void 0,void 0,(function*(){const e=yield this.nativeGoogleTokenProvider();return this.callGoogleNativeLogin(e.idToken,e.email).toPromise()}))}callGoogleNativeLogin(e,t){const n="ios"===window.device.platform.toLowerCase()?"ios":null,r=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(kd.LOGIN_API_ENDPOINT).withBearerToken(!1).withUserToken(!1).withBody({emailId:t,platform:n}).withHeaders({"X-GOOGLE-ID-TOKEN":e}).build();return this.apiService.fetch(r).pipe(Object(D.map)(e=>Fd(this,void 0,void 0,(function*(){return e.body&&k.CsModule.instance.updateAuthTokenConfig(e.body.access_token),{access_token:e.body.access_token,refresh_token:e.body.refresh_token,userToken:(yield kd.parseAccessToken(e.body.access_token)).userToken}}))))}}kd.LOGIN_API_ENDPOINT="/google/auth/android";var xd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Bd{constructor(e){this.nativeAppleTokenProvider=e,this.apiService=bd.instance.apiService,console.log(this.apiService)}static parseAccessToken(e){return xd(this,void 0,void 0,(function*(){let t=yield I.decodeJWT(e);const n=JSON.parse(t);return{userToken:3===n.sub.split(":").length?n.sub.split(":").pop():n.sub,accessTokenExpiresOn:1e3*n.exp}}))}provide(){return xd(this,void 0,void 0,(function*(){const e=yield this.nativeAppleTokenProvider();return this.callAppleNativeLogin(e).toPromise()}))}callAppleNativeLogin(e){const t="ios"===window.device.platform.toLowerCase()?"ios":null,n=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(Bd.LOGIN_API_ENDPOINT).withBearerToken(!1).withUserToken(!1).withBody(Object.assign({emailId:e.email,platform:t},e)).build();return this.apiService.fetch(n).pipe(Object(D.map)(e=>xd(this,void 0,void 0,(function*(){return e.body&&k.CsModule.instance.updateAuthTokenConfig(e.body.sessionId.access_token),{access_token:e.body.sessionId.access_token,refresh_token:e.body.sessionId.refresh_token,userToken:(yield Bd.parseAccessToken(e.body.sessionId.access_token)).userToken}}))))}}Bd.LOGIN_API_ENDPOINT="/apple/auth/ios";var Vd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Yd extends Md{constructor(e,t,n){super(bd.instance.sdkConfig.apiConfig,bd.instance.apiService,bd.instance.eventsBusService),this.stateSessionConfig=e,this.autoMergeConfig=t,this.telemetryService=bd.instance.telemetryService,this.webViewRunner=n||new Gt}provide(){return Vd(this,void 0,void 0,(function*(){const e=this.webViewRunner,t=yield this.telemetryService.buildContext().toPromise();return this.stateSessionConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)}),e.launchWebview({host:this.stateSessionConfig.target.host,path:this.stateSessionConfig.target.path,params:this.stateSessionConfig.target.params.reduce((e,t)=>(e[t.key]=t.value,e),Object.assign({},this.resetParams))}).then(()=>e.any(...this.stateSessionConfig.return.reduce((t,n)=>{switch(n.type){case"state":t.push(this.buildStateSessionProvider(e,n));break;case"state-error":t.push(e.capture({host:n.when.host,path:n.when.path,params:n.when.params}).then(()=>e.closeWebview().then(()=>e.resolveCaptured("error_message").catch(()=>{throw new xe("Server Error")}).then(e=>{throw new xe(e)}))));break;case"migrate":t.push(e.capture({host:n.when.host,path:n.when.path,params:n.when.params}).then(()=>e.success()).then(t=>(e.resetInAppBrowserEventListeners(),e.clearCapture().then(()=>new Ld(this.autoMergeConfig,this.webViewRunner,t).provide()))))}return t},[])))}))}}var Gd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Hd{constructor(e,t){this.loginConfig=e,this.nativeKeycloakTokenProvider=t,this.apiService=bd.instance.apiService}static parseAccessToken(e){return Gd(this,void 0,void 0,(function*(){let t=yield I.decodeJWT(e);const n=JSON.parse(t);return{userToken:3===n.sub.split(":").length?n.sub.split(":").pop():n.sub,accessTokenExpiresOn:1e3*n.exp}}))}provide(){return Gd(this,void 0,void 0,(function*(){return this.callKeycloakNativeLogin(this.nativeKeycloakTokenProvider.username,this.nativeKeycloakTokenProvider.password).toPromise()}))}callKeycloakNativeLogin(e,t){const n="ios"===window.device.platform.toLowerCase()?"ios":window.device.platform.toLowerCase(),r=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(Hd.LOGIN_API_ENDPOINT).withBearerToken(!1).withUserToken(!1).withBody({client_id:n,emailId:e,password:t,loginConfig:this.loginConfig.target}).build();return this.apiService.fetch(r).pipe(Object(D.map)(e=>Gd(this,void 0,void 0,(function*(){var t;return(null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.access_token)?(k.CsModule.instance.updateAuthTokenConfig(e.body.access_token),{access_token:e.body.access_token,refresh_token:e.body.refresh_token,userToken:(yield Hd.parseAccessToken(e.body.access_token)).userToken}):e.body}))))}}Hd.LOGIN_API_ENDPOINT="/keycloak/login";var $d=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class qd{constructor(e,t,n){this.loginConfig=e,this.customWebViewConfig=t,this.apiConfig=bd.instance.sdkConfig.apiConfig,this.telemetryService=bd.instance.telemetryService,this.webviewRunner=n||new Gt}static parseAccessToken(e){return $d(this,void 0,void 0,(function*(){let t=yield I.decodeJWT(e);const n=JSON.parse(t);return{userToken:3===n.sub.split(":").length?n.sub.split(":").pop():n.sub,accessTokenExpiresOn:1e3*n.exp}}))}buildGoogleTargetUrl(e,t){const n=new URL(e.googleRedirectUrl);return delete t.redirect_uri,n.searchParams.set("redirect_uri",this.apiConfig.user_authentication.redirectUrl),delete t.error_callback,n.searchParams.set("error_callback",this.apiConfig.user_authentication.redirectUrl),Object.keys(t).forEach(e=>n.searchParams.set(e,t[e])),n}provide(){return $d(this,void 0,void 0,(function*(){const e=this.webviewRunner,t=yield this.telemetryService.buildContext().toPromise();this.loginConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)});let n="",r={};this.loginConfig.target.params.forEach(e=>{"redirect_uri"==e.key&&(n=e.value),r[e.key]=e.value});const i=this.buildGoogleTargetUrl({googleRedirectUrl:`${this.loginConfig.target.host}/${qd.LOGIN_API_ENDPOINT}?redirect_uri=${n}`},r);return e.launchCustomTab({host:i.origin,path:i.pathname,params:Be.parse(i.searchParams.toString(),{ignoreQueryPrefix:!0}),extraParams:this.customWebViewConfig.get("extraParam")}).then(()=>e.success()).then(e=>$d(this,void 0,void 0,(function*(){return{access_token:e.access_token,refresh_token:e.refresh_token,userToken:(yield qd.parseAccessToken(e.access_token)).userToken}})))}))}}qd.LOGIN_API_ENDPOINT="/google/auth";var Kd=n(26)}])}));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("rxjs/operators"),require("rxjs"),require("@project-sunbird/client-services"),require("@project-sunbird/client-services/core/http-service"),require("@project-sunbird/client-services/models/content/index"),require("@project-sunbird/client-services/services/content/utilities/primary-category-mapper"),require("@project-sunbird/client-services/services/content"),require("@project-sunbird/client-services/core"),require("@project-sunbird/client-services/core/http-service/utilities/interceptors"),require("@project-sunbird/client-services/models/group"),require("@project-sunbird/client-services/models/user"),require("@project-sunbird/client-services/services/content/utilities/content-group-generator"),require("@project-sunbird/client-services/services/content/utilities/content-progress-calculator"),require("@project-sunbird/client-services/services/content/utilities/mime-type-facet-to-mime-type-category-aggregator"));else if("function"==typeof define&&define.amd)define(["rxjs/operators","rxjs","@project-sunbird/client-services","@project-sunbird/client-services/core/http-service","@project-sunbird/client-services/models/content/index","@project-sunbird/client-services/services/content/utilities/primary-category-mapper","@project-sunbird/client-services/services/content","@project-sunbird/client-services/core","@project-sunbird/client-services/core/http-service/utilities/interceptors","@project-sunbird/client-services/models/group","@project-sunbird/client-services/models/user","@project-sunbird/client-services/services/content/utilities/content-group-generator","@project-sunbird/client-services/services/content/utilities/content-progress-calculator","@project-sunbird/client-services/services/content/utilities/mime-type-facet-to-mime-type-category-aggregator"],t);else{var n="object"==typeof exports?t(require("rxjs/operators"),require("rxjs"),require("@project-sunbird/client-services"),require("@project-sunbird/client-services/core/http-service"),require("@project-sunbird/client-services/models/content/index"),require("@project-sunbird/client-services/services/content/utilities/primary-category-mapper"),require("@project-sunbird/client-services/services/content"),require("@project-sunbird/client-services/core"),require("@project-sunbird/client-services/core/http-service/utilities/interceptors"),require("@project-sunbird/client-services/models/group"),require("@project-sunbird/client-services/models/user"),require("@project-sunbird/client-services/services/content/utilities/content-group-generator"),require("@project-sunbird/client-services/services/content/utilities/content-progress-calculator"),require("@project-sunbird/client-services/services/content/utilities/mime-type-facet-to-mime-type-category-aggregator")):t(e.rxjs.operators,e.rxjs,e["@project-sunbird"]["client-services"],e["@project-sunbird"]["client-services"].core["http-service"],e["@project-sunbird"]["client-services"].models.content.index,e["@project-sunbird"]["client-services"].services.content.utilities["primary-category-mapper"],e["@project-sunbird"]["client-services"].services.content,e["@project-sunbird"]["client-services"].core,e["@project-sunbird"]["client-services"].core["http-service"].utilities.interceptors,e["@project-sunbird"]["client-services"].models.group,e["@project-sunbird"]["client-services"].models.user,e["@project-sunbird"]["client-services"].services.content.utilities["content-group-generator"],e["@project-sunbird"]["client-services"].services.content.utilities["content-progress-calculator"],e["@project-sunbird"]["client-services"].services.content.utilities["mime-type-facet-to-mime-type-category-aggregator"]);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(e,t,n,r,i,o,s,a,c,u,l,d,h,E){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=104)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiBindToService=t.getServiceIdentifierAsString=t.typeConstraint=t.namedConstraint=t.taggedConstraint=t.traverseAncerstors=t.decorate=t.id=t.MetadataReader=t.postConstruct=t.targetName=t.multiInject=t.unmanaged=t.optional=t.LazyServiceIdentifer=t.inject=t.named=t.tagged=t.injectable=t.ContainerModule=t.AsyncContainerModule=t.TargetTypeEnum=t.BindingTypeEnum=t.BindingScopeEnum=t.Container=t.METADATA_KEY=void 0;var r=n(5);t.METADATA_KEY=r;var i=n(53);Object.defineProperty(t,"Container",{enumerable:!0,get:function(){return i.Container}});var o=n(13);Object.defineProperty(t,"BindingScopeEnum",{enumerable:!0,get:function(){return o.BindingScopeEnum}}),Object.defineProperty(t,"BindingTypeEnum",{enumerable:!0,get:function(){return o.BindingTypeEnum}}),Object.defineProperty(t,"TargetTypeEnum",{enumerable:!0,get:function(){return o.TargetTypeEnum}});var s=n(69);Object.defineProperty(t,"AsyncContainerModule",{enumerable:!0,get:function(){return s.AsyncContainerModule}}),Object.defineProperty(t,"ContainerModule",{enumerable:!0,get:function(){return s.ContainerModule}});var a=n(70);Object.defineProperty(t,"injectable",{enumerable:!0,get:function(){return a.injectable}});var c=n(71);Object.defineProperty(t,"tagged",{enumerable:!0,get:function(){return c.tagged}});var u=n(72);Object.defineProperty(t,"named",{enumerable:!0,get:function(){return u.named}});var l=n(37);Object.defineProperty(t,"inject",{enumerable:!0,get:function(){return l.inject}}),Object.defineProperty(t,"LazyServiceIdentifer",{enumerable:!0,get:function(){return l.LazyServiceIdentifer}});var d=n(73);Object.defineProperty(t,"optional",{enumerable:!0,get:function(){return d.optional}});var h=n(74);Object.defineProperty(t,"unmanaged",{enumerable:!0,get:function(){return h.unmanaged}});var E=n(75);Object.defineProperty(t,"multiInject",{enumerable:!0,get:function(){return E.multiInject}});var f=n(76);Object.defineProperty(t,"targetName",{enumerable:!0,get:function(){return f.targetName}});var p=n(77);Object.defineProperty(t,"postConstruct",{enumerable:!0,get:function(){return p.postConstruct}});var _=n(35);Object.defineProperty(t,"MetadataReader",{enumerable:!0,get:function(){return _.MetadataReader}});var O=n(19);Object.defineProperty(t,"id",{enumerable:!0,get:function(){return O.id}});var S=n(15);Object.defineProperty(t,"decorate",{enumerable:!0,get:function(){return S.decorate}});var g=n(40);Object.defineProperty(t,"traverseAncerstors",{enumerable:!0,get:function(){return g.traverseAncerstors}}),Object.defineProperty(t,"taggedConstraint",{enumerable:!0,get:function(){return g.taggedConstraint}}),Object.defineProperty(t,"namedConstraint",{enumerable:!0,get:function(){return g.namedConstraint}}),Object.defineProperty(t,"typeConstraint",{enumerable:!0,get:function(){return g.typeConstraint}});var A=n(23);Object.defineProperty(t,"getServiceIdentifierAsString",{enumerable:!0,get:function(){return A.getServiceIdentifierAsString}});var N=n(78);Object.defineProperty(t,"multiBindToService",{enumerable:!0,get:function(){return N.multiBindToService}})},function(e,t){e.exports=n},function(e,t){e.exports=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NON_CUSTOM_TAG_KEYS=t.POST_CONSTRUCT=t.DESIGN_PARAM_TYPES=t.PARAM_TYPES=t.TAGGED_PROP=t.TAGGED=t.MULTI_INJECT_TAG=t.INJECT_TAG=t.OPTIONAL_TAG=t.UNMANAGED_TAG=t.NAME_TAG=t.NAMED_TAG=void 0,t.NAMED_TAG="named",t.NAME_TAG="name",t.UNMANAGED_TAG="unmanaged",t.OPTIONAL_TAG="optional",t.INJECT_TAG="inject",t.MULTI_INJECT_TAG="multi_inject",t.TAGGED="inversify:tagged",t.TAGGED_PROP="inversify:tagged_props",t.PARAM_TYPES="inversify:paramtypes",t.DESIGN_PARAM_TYPES="design:paramtypes",t.POST_CONSTRUCT="post_construct",t.NON_CUSTOM_TAG_KEYS=[t.INJECT_TAG,t.MULTI_INJECT_TAG,t.NAME_TAG,t.UNMANAGED_TAG,t.NAMED_TAG,t.OPTIONAL_TAG]},function(e,t,n){e.exports=function(){"use strict";var e=6e4,t=36e5,n="millisecond",r="second",i="minute",o="hour",s="day",a="week",c="month",u="quarter",l="year",d="date",h="Invalid Date",E=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,f=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,p={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:""+Array(t+1-r.length).join(n)+e},O={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?"+":"-")+_(r,2,"0")+":"+_(i,2,"0")},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,c),o=n-i<0,s=t.clone().add(r+(o?-1:1),c);return+(-(r+(n-i)/(o?i-s:s-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:c,y:l,w:a,d:s,D:d,h:o,m:i,s:r,ms:n,Q:u}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},S="en",g={};g[S]=p;var A="$isDayjsObject",N=function(e){return e instanceof y||!(!e||!e[A])},T=function e(t,n,r){var i;if(!t)return S;if("string"==typeof t){var o=t.toLowerCase();g[o]&&(i=o),n&&(g[o]=n,i=o);var s=t.split("-");if(!i&&s.length>1)return e(s[0])}else{var a=t.name;g[a]=t,i=a}return!r&&i&&(S=i),i||!r&&S},C=function(e,t){if(N(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new y(n)},v=O;v.l=T,v.i=N,v.w=function(e,t){return C(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var y=function(){function p(e){this.$L=T(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[A]=!0}var _=p.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(v.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var r=t.match(E);if(r){var i=r[2]-1||0,o=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,o)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,o)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return v},_.isValid=function(){return!(this.$d.toString()===h)},_.isSame=function(e,t){var n=C(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return C(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<C(e)},_.$g=function(e,t,n){return v.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,u=!!v.u(t)||t,h=v.p(e),E=function(e,t){var r=v.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return u?r:r.endOf(s)},f=function(e,t){return v.w(n.toDate()[e].apply(n.toDate("s"),(u?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},p=this.$W,_=this.$M,O=this.$D,S="set"+(this.$u?"UTC":"");switch(h){case l:return u?E(1,0):E(31,11);case c:return u?E(1,_):E(0,_+1);case a:var g=this.$locale().weekStart||0,A=(p<g?p+7:p)-g;return E(u?O-A:O+(6-A),_);case s:case d:return f(S+"Hours",0);case o:return f(S+"Minutes",1);case i:return f(S+"Seconds",2);case r:return f(S+"Milliseconds",3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var a,u=v.p(e),h="set"+(this.$u?"UTC":""),E=(a={},a[s]=h+"Date",a[d]=h+"Date",a[c]=h+"Month",a[l]=h+"FullYear",a[o]=h+"Hours",a[i]=h+"Minutes",a[r]=h+"Seconds",a[n]=h+"Milliseconds",a)[u],f=u===s?this.$D+(t-this.$W):t;if(u===c||u===l){var p=this.clone().set(d,1);p.$d[E](f),p.init(),this.$d=p.set(d,Math.min(this.$D,p.daysInMonth())).$d}else E&&this.$d[E](f);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[v.p(e)]()},_.add=function(n,u){var d,h=this;n=Number(n);var E=v.p(u),f=function(e){var t=C(h);return v.w(t.date(t.date()+Math.round(e*n)),h)};if(E===c)return this.set(c,this.$M+n);if(E===l)return this.set(l,this.$y+n);if(E===s)return f(1);if(E===a)return f(7);var p=(d={},d[i]=e,d[o]=t,d[r]=1e3,d)[E]||1,_=this.$d.getTime()+n*p;return v.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||h;var r=e||"YYYY-MM-DDTHH:mm:ssZ",i=v.z(this),o=this.$H,s=this.$m,a=this.$M,c=n.weekdays,u=n.months,l=n.meridiem,d=function(e,n,i,o){return e&&(e[n]||e(t,r))||i[n].slice(0,o)},E=function(e){return v.s(o%12||12,e,"0")},p=l||function(e,t,n){var r=e<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(f,(function(e,r){return r||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return v.s(t.$y,4,"0");case"M":return a+1;case"MM":return v.s(a+1,2,"0");case"MMM":return d(n.monthsShort,a,u,3);case"MMMM":return d(u,a);case"D":return t.$D;case"DD":return v.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return d(n.weekdaysMin,t.$W,c,2);case"ddd":return d(n.weekdaysShort,t.$W,c,3);case"dddd":return c[t.$W];case"H":return String(o);case"HH":return v.s(o,2,"0");case"h":return E(1);case"hh":return E(2);case"a":return p(o,s,!0);case"A":return p(o,s,!1);case"m":return String(s);case"mm":return v.s(s,2,"0");case"s":return String(t.$s);case"ss":return v.s(t.$s,2,"0");case"SSS":return v.s(t.$ms,3,"0");case"Z":return i}return null}(e)||i.replace(":","")}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(n,d,h){var E,f=this,p=v.p(d),_=C(n),O=(_.utcOffset()-this.utcOffset())*e,S=this-_,g=function(){return v.m(f,_)};switch(p){case l:E=g()/12;break;case c:E=g();break;case u:E=g()/3;break;case a:E=(S-O)/6048e5;break;case s:E=(S-O)/864e5;break;case o:E=S/t;break;case i:E=S/e;break;case r:E=S/1e3;break;default:E=S}return h?E:v.a(E)},_.daysInMonth=function(){return this.endOf(c).$D},_.$locale=function(){return g[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=T(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return v.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},p}(),m=y.prototype;return C.prototype=m,[["$ms",n],["$s",r],["$m",i],["$H",o],["$W",s],["$M",c],["$y",l],["$D",d]].forEach((function(e){m[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),C.extend=function(e,t){return e.$i||(e(t,y,C),e.$i=!0),C},C.locale=T,C.isDayjs=N,C.unix=function(e){return C(1e3*e)},C.en=g[S],C.Ls=g,C.p={},C}()},function(e,t){e.exports=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.STACK_OVERFLOW=t.CIRCULAR_DEPENDENCY_IN_FACTORY=t.POST_CONSTRUCT_ERROR=t.MULTIPLE_POST_CONSTRUCT_METHODS=t.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK=t.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE=t.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE=t.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT=t.ARGUMENTS_LENGTH_MISMATCH=t.INVALID_DECORATOR_OPERATION=t.INVALID_TO_SELF_VALUE=t.INVALID_FUNCTION_BINDING=t.INVALID_MIDDLEWARE_RETURN=t.NO_MORE_SNAPSHOTS_AVAILABLE=t.INVALID_BINDING_TYPE=t.NOT_IMPLEMENTED=t.CIRCULAR_DEPENDENCY=t.UNDEFINED_INJECT_ANNOTATION=t.MISSING_INJECT_ANNOTATION=t.MISSING_INJECTABLE_ANNOTATION=t.NOT_REGISTERED=t.CANNOT_UNBIND=t.AMBIGUOUS_MATCH=t.KEY_NOT_FOUND=t.NULL_ARGUMENT=t.DUPLICATED_METADATA=t.DUPLICATED_INJECTABLE_DECORATOR=void 0,t.DUPLICATED_INJECTABLE_DECORATOR="Cannot apply @injectable decorator multiple times.",t.DUPLICATED_METADATA="Metadata key was used more than once in a parameter:",t.NULL_ARGUMENT="NULL argument",t.KEY_NOT_FOUND="Key Not Found",t.AMBIGUOUS_MATCH="Ambiguous match found for serviceIdentifier:",t.CANNOT_UNBIND="Could not unbind serviceIdentifier:",t.NOT_REGISTERED="No matching bindings found for serviceIdentifier:",t.MISSING_INJECTABLE_ANNOTATION="Missing required @injectable annotation in:",t.MISSING_INJECT_ANNOTATION="Missing required @inject or @multiInject annotation in:";t.UNDEFINED_INJECT_ANNOTATION=function(e){return"@inject called with undefined this could mean that the class "+e+" has a circular dependency problem. You can use a LazyServiceIdentifer to overcome this limitation."},t.CIRCULAR_DEPENDENCY="Circular dependency found:",t.NOT_IMPLEMENTED="Sorry, this feature is not fully implemented yet.",t.INVALID_BINDING_TYPE="Invalid binding type:",t.NO_MORE_SNAPSHOTS_AVAILABLE="No snapshot available to restore.",t.INVALID_MIDDLEWARE_RETURN="Invalid return type in middleware. Middleware must return!",t.INVALID_FUNCTION_BINDING="Value provided to function binding must be a function!",t.INVALID_TO_SELF_VALUE="The toSelf function can only be applied when a constructor is used as service identifier",t.INVALID_DECORATOR_OPERATION="The @inject @multiInject @tagged and @named decorators must be applied to the parameters of a class constructor or a class property.";t.ARGUMENTS_LENGTH_MISMATCH=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"The number of constructor arguments in the derived class "+e[0]+" must be >= than the number of constructor arguments of its base class."},t.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT="Invalid Container constructor argument. Container options must be an object.",t.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE="Invalid Container option. Default scope must be a string ('singleton' or 'transient').",t.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE="Invalid Container option. Auto bind injectable must be a boolean",t.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK="Invalid Container option. Skip base check must be a boolean",t.MULTIPLE_POST_CONSTRUCT_METHODS="Cannot apply @postConstruct decorator multiple times in the same class";t.POST_CONSTRUCT_ERROR=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"@postConstruct error in class "+e[0]+": "+e[1]};t.CIRCULAR_DEPENDENCY_IN_FACTORY=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"It looks like there is a circular dependency in one of the '"+e[0]+"' bindings. Please investigate bindings withservice identifier '"+e[1]+"'."},t.STACK_OVERFLOW="Maximum call stack size exceeded"},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(11),i=n(45),o=n(101),s=function(){function e(e){this.dictionary=new o.default(e)}return e.prototype.contains=function(e){return this.dictionary.containsKey(e)},e.prototype.add=function(e){return!this.contains(e)&&!r.isUndefined(e)&&(this.dictionary.setValue(e,e),!0)},e.prototype.intersection=function(e){var t=this;this.forEach((function(n){return e.contains(n)||t.remove(n),!0}))},e.prototype.union=function(e){var t=this;e.forEach((function(e){return t.add(e),!0}))},e.prototype.difference=function(e){var t=this;e.forEach((function(e){return t.remove(e),!0}))},e.prototype.isSubsetOf=function(e){if(this.size()>e.size())return!1;var t=!0;return this.forEach((function(n){return!!e.contains(n)||(t=!1,!1)})),t},e.prototype.remove=function(e){return!!this.contains(e)&&(this.dictionary.remove(e),!0)},e.prototype.forEach=function(e){this.dictionary.forEach((function(t,n){return e(n)}))},e.prototype.toArray=function(){return this.dictionary.values()},e.prototype.isEmpty=function(){return this.dictionary.isEmpty()},e.prototype.size=function(){return this.dictionary.size()},e.prototype.clear=function(){this.dictionary.clear()},e.prototype.toString=function(){return i.toString(this.toArray())},e}();t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Metadata=void 0;var r=n(5),i=function(){function e(e,t){this.key=e,this.value=t}return e.prototype.toString=function(){return this.key===r.NAMED_TAG?"named: "+this.value.toString()+" ":"tagged: { key:"+this.key.toString()+", value: "+this.value+" }"},e}();t.Metadata=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=Object.prototype.hasOwnProperty;function i(e){return"function"==typeof e}function o(e){return void 0===e}function s(e){return"[object String]"===Object.prototype.toString.call(e)}t.has=function(e,t){return r.call(e,t)},t.defaultCompare=function(e,t){return e<t?-1:e===t?0:1},t.defaultEquals=function(e,t){return e===t},t.defaultToString=function(e){return null===e?"COLLECTION_NULL":o(e)?"COLLECTION_UNDEFINED":s(e)?"$s"+e:"$o"+e.toString()},t.makeString=function(e,n){if(void 0===n&&(n=","),null===e)return"COLLECTION_NULL";if(o(e))return"COLLECTION_UNDEFINED";if(s(e))return e.toString();var r="{",i=!0;for(var a in e)t.has(e,a)&&(i?i=!1:r+=n,r=r+a+":"+e[a]);return r+"}"},t.isFunction=i,t.isUndefined=o,t.isString=s,t.reverseCompareFunction=function(e){return o(e)||!i(e)?function(e,t){return e<t?1:e===t?0:-1}:function(t,n){return-1*e(t,n)}},t.compareToEquals=function(e){return function(t,n){return 0===e(t,n)}}},function(e,t,n){"use strict";var r=n(79),i=n(98),o=n(31);e.exports={formats:o,parse:i,stringify:r}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TargetTypeEnum=t.BindingTypeEnum=t.BindingScopeEnum=void 0;t.BindingScopeEnum={Request:"Request",Singleton:"Singleton",Transient:"Transient"};t.BindingTypeEnum={ConstantValue:"ConstantValue",Constructor:"Constructor",DynamicValue:"DynamicValue",Factory:"Factory",Function:"Function",Instance:"Instance",Invalid:"Invalid",Provider:"Provider"};t.TargetTypeEnum={ClassProperty:"ClassProperty",ConstructorArgument:"ConstructorArgument",Variable:"Variable"}},function(e,t,n){var r,i,o,s,a,c,u,l;e.exports=(l=n(44),i=(r=l).lib,o=i.WordArray,s=i.Hasher,a=r.algo,c=[],u=a.SHA1=s.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],s=n[3],a=n[4],u=0;u<80;u++){if(u<16)c[u]=0|e[t+u];else{var l=c[u-3]^c[u-8]^c[u-14]^c[u-16];c[u]=l<<1|l>>>31}var d=(r<<5|r>>>27)+a+c[u];d+=u<20?1518500249+(i&o|~i&s):u<40?1859775393+(i^o^s):u<60?(i&o|i&s|o&s)-1894007588:(i^o^s)-899497514,a=s,s=o,o=i<<30|i>>>2,i=r,r=d}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[14+(r+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(r+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=s._createHelper(u),r.HmacSHA1=s._createHmacHelper(u),l.SHA1)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagProperty=t.tagParameter=t.decorate=void 0;var r=n(8),i=n(5);function o(e,t,n,i,o){var s={},a="number"==typeof o,c=void 0!==o&&a?o.toString():n;if(a&&void 0!==n)throw new Error(r.INVALID_DECORATOR_OPERATION);Reflect.hasOwnMetadata(e,t)&&(s=Reflect.getMetadata(e,t));var u=s[c];if(Array.isArray(u))for(var l=0,d=u;l<d.length;l++){var h=d[l];if(h.key===i.key)throw new Error(r.DUPLICATED_METADATA+" "+h.key.toString())}else u=[];u.push(i),s[c]=u,Reflect.defineMetadata(e,s,t)}function s(e,t){Reflect.decorate(e,t)}function a(e,t){return function(n,r){t(n,r,e)}}t.tagParameter=function(e,t,n,r){o(i.TAGGED,e,t,r,n)},t.tagProperty=function(e,t,n){o(i.TAGGED_PROP,e.constructor,t,n)},t.decorate=function(e,t,n){"number"==typeof n?s([a(n,e)],t):"string"==typeof n?Reflect.decorate([e],t,n):s([e],t)}},function(e,t,n){e.exports=function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};t[s][0].call(u.exports,(function(e){return i(t[s][1][e]||e)}),u,u.exports,e,t,n,r)}return n[s].exports}for(var o=!1,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}n.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var r in n)i(n,r)&&(e[r]=n[r])}}return e},n.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var o={arraySet:function(e,t,n,r,i){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+r),i);else for(var o=0;o<r;o++)e[i+o]=t[n+o]},flattenChunks:function(e){var t,n,r,i,o,s;for(r=0,t=0,n=e.length;t<n;t++)r+=e[t].length;for(s=new Uint8Array(r),i=0,t=0,n=e.length;t<n;t++)o=e[t],s.set(o,i),i+=o.length;return s}},s={arraySet:function(e,t,n,r,i){for(var o=0;o<r;o++)e[i+o]=t[n+o]},flattenChunks:function(e){return[].concat.apply([],e)}};n.setTyped=function(e){e?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,o)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,s))},n.setTyped(r)},{}],2:[function(e,t,n){"use strict";var r=e("./common"),i=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){o=!1}for(var s=new r.Buf8(256),a=0;a<256;a++)s[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;function c(e,t){if(t<65534&&(e.subarray&&o||!e.subarray&&i))return String.fromCharCode.apply(null,r.shrinkBuf(e,t));for(var n="",s=0;s<t;s++)n+=String.fromCharCode(e[s]);return n}s[254]=s[254]=1,n.string2buf=function(e){var t,n,i,o,s,a=e.length,c=0;for(o=0;o<a;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(i-56320),o++),c+=n<128?1:n<2048?2:n<65536?3:4;for(t=new r.Buf8(c),s=0,o=0;s<c;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(i-56320),o++),n<128?t[s++]=n:n<2048?(t[s++]=192|n>>>6,t[s++]=128|63&n):n<65536?(t[s++]=224|n>>>12,t[s++]=128|n>>>6&63,t[s++]=128|63&n):(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63,t[s++]=128|n>>>6&63,t[s++]=128|63&n);return t},n.buf2binstring=function(e){return c(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n<i;n++)t[n]=e.charCodeAt(n);return t},n.buf2string=function(e,t){var n,r,i,o,a=t||e.length,u=new Array(2*a);for(r=0,n=0;n<a;)if((i=e[n++])<128)u[r++]=i;else if((o=s[i])>4)u[r++]=65533,n+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&n<a;)i=i<<6|63&e[n++],o--;o>1?u[r++]=65533:i<65536?u[r++]=i:(i-=65536,u[r++]=55296|i>>10&1023,u[r++]=56320|1023&i)}return c(u,r)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+s[e[n]]>t?n:t}},{"./common":1}],3:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){for(var i=65535&e|0,o=e>>>16&65535|0,s=0;0!==n;){n-=s=n>2e3?2e3:n;do{o=o+(i=i+t[r++]|0)|0}while(--s);i%=65521,o%=65521}return i|o<<16|0}},{}],4:[function(e,t,n){"use strict";var r=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var o=r,s=i+n;e^=-1;for(var a=i;a<s;a++)e=e>>>8^o[255&(e^t[a])];return-1^e}},{}],5:[function(e,t,n){"use strict";var r,i=e("../utils/common"),o=e("./trees"),s=e("./adler32"),a=e("./crc32"),c=e("./messages");function u(e,t){return e.msg=c[t],t}function l(e){return(e<<1)-(e>4?9:0)}function d(e){for(var t=e.length;--t>=0;)e[t]=0}function h(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function E(e,t){o._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,h(e.strm)}function f(e,t){e.pending_buf[e.pending++]=t}function p(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function _(e,t){var n,r,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match,c=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,u=e.window,l=e.w_mask,d=e.prev,h=e.strstart+258,E=u[o+s-1],f=u[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(u[(n=t)+s]===f&&u[n+s-1]===E&&u[n]===u[o]&&u[++n]===u[o+1]){o+=2,n++;do{}while(u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&u[++o]===u[++n]&&o<h);if(r=258-(h-o),o=h-258,r>s){if(e.match_start=t,s=r,r>=a)break;E=u[o+s-1],f=u[o+s]}}}while((t=d[t&l])>c&&0!=--i);return s<=e.lookahead?s:e.lookahead}function O(e){var t,n,r,o,c,u,l,d,h,E,f=e.w_size;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=f+(f-262)){i.arraySet(e.window,e.window,f,f,0),e.match_start-=f,e.strstart-=f,e.block_start-=f,t=n=e.hash_size;do{r=e.head[--t],e.head[t]=r>=f?r-f:0}while(--n);t=n=f;do{r=e.prev[--t],e.prev[t]=r>=f?r-f:0}while(--n);o+=f}if(0===e.strm.avail_in)break;if(u=e.strm,l=e.window,d=e.strstart+e.lookahead,h=o,E=void 0,(E=u.avail_in)>h&&(E=h),n=0===E?0:(u.avail_in-=E,i.arraySet(l,u.input,u.next_in,E,d),1===u.state.wrap?u.adler=s(u.adler,l,E,d):2===u.state.wrap&&(u.adler=a(u.adler,l,E,d)),u.next_in+=E,u.total_in+=E,E),e.lookahead+=n,e.lookahead+e.insert>=3)for(c=e.strstart-e.insert,e.ins_h=e.window[c],e.ins_h=(e.ins_h<<e.hash_shift^e.window[c+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[c+3-1])&e.hash_mask,e.prev[c&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=c,c++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<262&&0!==e.strm.avail_in)}function S(e,t){for(var n,r;;){if(e.lookahead<262){if(O(e),e.lookahead<262&&0===t)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-262&&(e.match_length=_(e,n)),e.match_length>=3)if(r=o._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else r=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(E(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(E(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(E(e,!1),0===e.strm.avail_out)?1:2}function g(e,t){for(var n,r,i;;){if(e.lookahead<262){if(O(e),e.lookahead<262&&0===t)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-262&&(e.match_length=_(e,n),e.match_length<=5&&(1===e.strategy||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,r=o._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(E(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((r=o._tr_tally(e,0,e.window[e.strstart-1]))&&E(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=o._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(E(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(E(e,!1),0===e.strm.avail_out)?1:2}function A(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}function N(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(1146),this.dyn_dtree=new i.Buf16(122),this.bl_tree=new i.Buf16(78),d(this.dyn_ltree),d(this.dyn_dtree),d(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(16),this.heap=new i.Buf16(573),d(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(573),d(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function T(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:113,e.adler=2===t.wrap?0:1,t.last_flush=0,o._tr_init(t),0):u(e,-2)}function C(e){var t,n=T(e);return 0===n&&((t=e.state).window_size=2*t.w_size,d(t.head),t.max_lazy_match=r[t.level].max_lazy,t.good_match=r[t.level].good_length,t.nice_match=r[t.level].nice_length,t.max_chain_length=r[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),n}function v(e,t,n,r,o,s){if(!e)return-2;var a=1;if(-1===t&&(t=6),r<0?(a=0,r=-r):r>15&&(a=2,r-=16),o<1||o>9||8!==n||r<8||r>15||t<0||t>9||s<0||s>4)return u(e,-2);8===r&&(r=9);var c=new N;return e.state=c,c.strm=e,c.wrap=a,c.gzhead=null,c.w_bits=r,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.hash_bits=o+7,c.hash_size=1<<c.hash_bits,c.hash_mask=c.hash_size-1,c.hash_shift=~~((c.hash_bits+3-1)/3),c.window=new i.Buf8(2*c.w_size),c.head=new i.Buf16(c.hash_size),c.prev=new i.Buf16(c.w_size),c.lit_bufsize=1<<o+6,c.pending_buf_size=4*c.lit_bufsize,c.pending_buf=new i.Buf8(c.pending_buf_size),c.d_buf=1*c.lit_bufsize,c.l_buf=3*c.lit_bufsize,c.level=t,c.strategy=s,c.method=n,C(e)}r=[new A(0,0,0,0,(function(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(O(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,E(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-262&&(E(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(E(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(E(e,!1),e.strm.avail_out),1)})),new A(4,4,8,4,S),new A(4,5,16,8,S),new A(4,6,32,32,S),new A(4,4,16,16,g),new A(8,16,32,32,g),new A(8,16,128,128,g),new A(8,32,128,256,g),new A(32,128,258,1024,g),new A(32,258,258,4096,g)],n.deflateInit=function(e,t){return v(e,t,8,15,8,0)},n.deflateInit2=v,n.deflateReset=C,n.deflateResetKeep=T,n.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?-2:(e.state.gzhead=t,0):-2},n.deflate=function(e,t){var n,i,s,c;if(!e||!e.state||t>5||t<0)return e?u(e,-2):-2;if(i=e.state,!e.output||!e.input&&0!==e.avail_in||666===i.status&&4!==t)return u(e,0===e.avail_out?-5:-2);if(i.strm=e,n=i.last_flush,i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,f(i,31),f(i,139),f(i,8),i.gzhead?(f(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),f(i,255&i.gzhead.time),f(i,i.gzhead.time>>8&255),f(i,i.gzhead.time>>16&255),f(i,i.gzhead.time>>24&255),f(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),f(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(f(i,255&i.gzhead.extra.length),f(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=a(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(f(i,0),f(i,0),f(i,0),f(i,0),f(i,0),f(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),f(i,3),i.status=113);else{var _=8+(i.w_bits-8<<4)<<8;_|=(i.strategy>=2||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(_|=32),_+=31-_%31,i.status=113,p(i,_),0!==i.strstart&&(p(i,e.adler>>>16),p(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(s=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),h(e),s=i.pending,i.pending!==i.pending_buf_size));)f(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),h(e),s=i.pending,i.pending===i.pending_buf_size)){c=1;break}c=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,f(i,c)}while(0!==c);i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),0===c&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),h(e),s=i.pending,i.pending===i.pending_buf_size)){c=1;break}c=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,f(i,c)}while(0!==c);i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),0===c&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&h(e),i.pending+2<=i.pending_buf_size&&(f(i,255&e.adler),f(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(h(e),0===e.avail_out)return i.last_flush=-1,0}else if(0===e.avail_in&&l(t)<=l(n)&&4!==t)return u(e,-5);if(666===i.status&&0!==e.avail_in)return u(e,-5);if(0!==e.avail_in||0!==i.lookahead||0!==t&&666!==i.status){var S=2===i.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(O(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(E(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(E(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(E(e,!1),0===e.strm.avail_out)?1:2}(i,t):3===i.strategy?function(e,t){for(var n,r,i,s,a=e.window;;){if(e.lookahead<=258){if(O(e),e.lookahead<=258&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=a[i=e.strstart-1])===a[++i]&&r===a[++i]&&r===a[++i]){s=e.strstart+258;do{}while(r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&i<s);e.match_length=258-(s-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=o._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(E(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(E(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(E(e,!1),0===e.strm.avail_out)?1:2}(i,t):r[i.level].func(i,t);if(3!==S&&4!==S||(i.status=666),1===S||3===S)return 0===e.avail_out&&(i.last_flush=-1),0;if(2===S&&(1===t?o._tr_align(i):5!==t&&(o._tr_stored_block(i,0,0,!1),3===t&&(d(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),h(e),0===e.avail_out))return i.last_flush=-1,0}return 4!==t?0:i.wrap<=0?1:(2===i.wrap?(f(i,255&e.adler),f(i,e.adler>>8&255),f(i,e.adler>>16&255),f(i,e.adler>>24&255),f(i,255&e.total_in),f(i,e.total_in>>8&255),f(i,e.total_in>>16&255),f(i,e.total_in>>24&255)):(p(i,e.adler>>>16),p(i,65535&e.adler)),h(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?0:1)},n.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?u(e,-2):(e.state=null,113===t?u(e,-3):0):-2},n.deflateSetDictionary=function(e,t){var n,r,o,a,c,u,l,h,E=t.length;if(!e||!e.state)return-2;if(2===(a=(n=e.state).wrap)||1===a&&42!==n.status||n.lookahead)return-2;for(1===a&&(e.adler=s(e.adler,t,E,0)),n.wrap=0,E>=n.w_size&&(0===a&&(d(n.head),n.strstart=0,n.block_start=0,n.insert=0),h=new i.Buf8(n.w_size),i.arraySet(h,t,E-n.w_size,n.w_size,0),t=h,E=n.w_size),c=e.avail_in,u=e.next_in,l=e.input,e.avail_in=E,e.next_in=0,e.input=t,O(n);n.lookahead>=3;){r=n.strstart,o=n.lookahead-2;do{n.ins_h=(n.ins_h<<n.hash_shift^n.window[r+3-1])&n.hash_mask,n.prev[r&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=r,r++}while(--o);n.strstart=r,n.lookahead=2,O(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=u,e.input=l,e.avail_in=c,n.wrap=a,0},n.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":4,"./messages":6,"./trees":7}],6:[function(e,t,n){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],7:[function(e,t,n){"use strict";var r=e("../utils/common");function i(e){for(var t=e.length;--t>=0;)e[t]=0}var o=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],s=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],c=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],u=new Array(576);i(u);var l=new Array(60);i(l);var d=new Array(512);i(d);var h=new Array(256);i(h);var E=new Array(29);i(E);var f,p,_,O=new Array(30);function S(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}function g(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function A(e){return e<256?d[e]:d[256+(e>>>7)]}function N(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function T(e,t,n){e.bi_valid>16-n?(e.bi_buf|=t<<e.bi_valid&65535,N(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function C(e,t,n){T(e,n[2*t],n[2*t+1])}function v(e,t){var n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1}function y(e,t,n){var r,i,o=new Array(16),s=0;for(r=1;r<=15;r++)o[r]=s=s+n[r-1]<<1;for(i=0;i<=t;i++){var a=e[2*i+1];0!==a&&(e[2*i]=v(o[a]++,a))}}function m(e){var t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function b(e){e.bi_valid>8?N(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function I(e,t,n,r){var i=2*t,o=2*n;return e[i]<e[o]||e[i]===e[o]&&r[t]<=r[n]}function M(e,t,n){for(var r=e.heap[n],i=n<<1;i<=e.heap_len&&(i<e.heap_len&&I(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!I(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r}function R(e,t,n){var r,i,a,c,u=0;if(0!==e.last_lit)do{r=e.pending_buf[e.d_buf+2*u]<<8|e.pending_buf[e.d_buf+2*u+1],i=e.pending_buf[e.l_buf+u],u++,0===r?C(e,i,t):(C(e,(a=h[i])+256+1,t),0!==(c=o[a])&&T(e,i-=E[a],c),C(e,a=A(--r),n),0!==(c=s[a])&&T(e,r-=O[a],c))}while(u<e.last_lit);C(e,256,t)}function L(e,t){var n,r,i,o=t.dyn_tree,s=t.stat_desc.static_tree,a=t.stat_desc.has_stree,c=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=573,n=0;n<c;n++)0!==o[2*n]?(e.heap[++e.heap_len]=u=n,e.depth[n]=0):o[2*n+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,a&&(e.static_len-=s[2*i+1]);for(t.max_code=u,n=e.heap_len>>1;n>=1;n--)M(e,o,n);i=c;do{n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],M(e,o,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,o[2*i]=o[2*n]+o[2*r],e.depth[i]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,o[2*n+1]=o[2*r+1]=i,e.heap[1]=i++,M(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,i,o,s,a,c=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,d=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,E=t.stat_desc.extra_base,f=t.stat_desc.max_length,p=0;for(o=0;o<=15;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<573;n++)(o=c[2*c[2*(r=e.heap[n])+1]+1]+1)>f&&(o=f,p++),c[2*r+1]=o,r>u||(e.bl_count[o]++,s=0,r>=E&&(s=h[r-E]),a=c[2*r],e.opt_len+=a*(o+s),d&&(e.static_len+=a*(l[2*r+1]+s)));if(0!==p){do{for(o=f-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[f]--,p-=2}while(p>0);for(o=f;0!==o;o--)for(r=e.bl_count[o];0!==r;)(i=e.heap[--n])>u||(c[2*i+1]!==o&&(e.opt_len+=(o-c[2*i+1])*c[2*i],c[2*i+1]=o),r--)}}(e,t),y(o,u,e.bl_count)}function P(e,t,n){var r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)i=s,s=t[2*(r+1)+1],++a<c&&i===s||(a<u?e.bl_tree[2*i]+=a:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[32]++):a<=10?e.bl_tree[34]++:e.bl_tree[36]++,a=0,o=i,0===s?(c=138,u=3):i===s?(c=6,u=3):(c=7,u=4))}function D(e,t,n){var r,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),r=0;r<=n;r++)if(i=s,s=t[2*(r+1)+1],!(++a<c&&i===s)){if(a<u)do{C(e,i,e.bl_tree)}while(0!=--a);else 0!==i?(i!==o&&(C(e,i,e.bl_tree),a--),C(e,16,e.bl_tree),T(e,a-3,2)):a<=10?(C(e,17,e.bl_tree),T(e,a-3,3)):(C(e,18,e.bl_tree),T(e,a-11,7));a=0,o=i,0===s?(c=138,u=3):i===s?(c=6,u=3):(c=7,u=4)}}i(O);var w=!1;function U(e,t,n,i){T(e,0+(i?1:0),3),function(e,t,n,i){b(e),i&&(N(e,n),N(e,~n)),r.arraySet(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}(e,t,n,!0)}n._tr_init=function(e){w||(function(){var e,t,n,r,i,c=new Array(16);for(n=0,r=0;r<28;r++)for(E[r]=n,e=0;e<1<<o[r];e++)h[n++]=r;for(h[n-1]=r,i=0,r=0;r<16;r++)for(O[r]=i,e=0;e<1<<s[r];e++)d[i++]=r;for(i>>=7;r<30;r++)for(O[r]=i<<7,e=0;e<1<<s[r]-7;e++)d[256+i++]=r;for(t=0;t<=15;t++)c[t]=0;for(e=0;e<=143;)u[2*e+1]=8,e++,c[8]++;for(;e<=255;)u[2*e+1]=9,e++,c[9]++;for(;e<=279;)u[2*e+1]=7,e++,c[7]++;for(;e<=287;)u[2*e+1]=8,e++,c[8]++;for(y(u,287,c),e=0;e<30;e++)l[2*e+1]=5,l[2*e]=v(e,5);f=new S(u,o,257,286,15),p=new S(l,s,0,30,15),_=new S(new Array(0),a,0,19,7)}(),w=!0),e.l_desc=new g(e.dyn_ltree,f),e.d_desc=new g(e.dyn_dtree,p),e.bl_desc=new g(e.bl_tree,_),e.bi_buf=0,e.bi_valid=0,m(e)},n._tr_stored_block=U,n._tr_flush_block=function(e,t,n,r){var i,o,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),L(e,e.l_desc),L(e,e.d_desc),s=function(e){var t;for(P(e,e.dyn_ltree,e.l_desc.max_code),P(e,e.dyn_dtree,e.d_desc.max_code),L(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*c[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=n+5,n+4<=i&&-1!==t?U(e,t,n,r):4===e.strategy||o===i?(T(e,2+(r?1:0),3),R(e,u,l)):(T(e,4+(r?1:0),3),function(e,t,n,r){var i;for(T(e,t-257,5),T(e,n-1,5),T(e,r-4,4),i=0;i<r;i++)T(e,e.bl_tree[2*c[i]+1],3);D(e,e.dyn_ltree,t-1),D(e,e.dyn_dtree,n-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),R(e,e.dyn_ltree,e.dyn_dtree)),m(e),r&&b(e)},n._tr_tally=function(e,t,n){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(h[n]+256+1)]++,e.dyn_dtree[2*A(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){T(e,2,3),C(e,256,u),function(e){16===e.bi_valid?(N(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":1}],8:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],"/lib/deflate.js":[function(e,t,n){"use strict";var r=e("./zlib/deflate"),i=e("./utils/common"),o=e("./utils/strings"),s=e("./zlib/messages"),a=e("./zlib/zstream"),c=Object.prototype.toString;function u(e){if(!(this instanceof u))return new u(e);this.options=i.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var n=r.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==n)throw new Error(s[n]);if(t.header&&r.deflateSetHeader(this.strm,t.header),t.dictionary){var l;if(l="string"==typeof t.dictionary?o.string2buf(t.dictionary):"[object ArrayBuffer]"===c.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(n=r.deflateSetDictionary(this.strm,l)))throw new Error(s[n]);this._dict_set=!0}}function l(e,t){var n=new u(t);if(n.push(e,!0),n.err)throw n.msg||s[n.err];return n.result}u.prototype.push=function(e,t){var n,s,a=this.strm,u=this.options.chunkSize;if(this.ended)return!1;s=t===~~t?t:!0===t?4:0,"string"==typeof e?a.input=o.string2buf(e):"[object ArrayBuffer]"===c.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new i.Buf8(u),a.next_out=0,a.avail_out=u),1!==(n=r.deflate(a,s))&&0!==n)return this.onEnd(n),this.ended=!0,!1;0!==a.avail_out&&(0!==a.avail_in||4!==s&&2!==s)||("string"===this.options.to?this.onData(o.buf2binstring(i.shrinkBuf(a.output,a.next_out))):this.onData(i.shrinkBuf(a.output,a.next_out)))}while((a.avail_in>0||0===a.avail_out)&&1!==n);return 4===s?(n=r.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,0===n):2!==s||(this.onEnd(0),a.avail_out=0,!0)},u.prototype.onData=function(e){this.chunks.push(e)},u.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Deflate=u,n.deflate=l,n.deflateRaw=function(e,t){return(t=t||{}).raw=!0,l(e,t)},n.gzip=function(e,t){return(t=t||{}).gzip=!0,l(e,t)}},{"./utils/common":1,"./utils/strings":2,"./zlib/deflate":5,"./zlib/messages":6,"./zlib/zstream":8}]},{},[])("/lib/deflate.js")},function(e,t){e.exports=o},function(e,t){e.exports=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.id=void 0;var r=0;t.id=function(){return r++}},function(e,t,n){"use strict";var r=n(81),i=n(82),o=n(83),s=n(84),a=n(41),c=n(24),u=n(85),l=Function,d=function(e){try{return l('"use strict"; return ('+e+").constructor;")()}catch(e){}},h=Object.getOwnPropertyDescriptor;if(h)try{h({},"")}catch(e){h=null}var E=function(){throw new c},f=h?function(){try{return E}catch(e){try{return h(arguments,"callee").get}catch(e){return E}}}():E,p=n(86)(),_=n(88)(),O=Object.getPrototypeOf||(_?function(e){return e.__proto__}:null),S={},g="undefined"!=typeof Uint8Array&&O?O(Uint8Array):void 0,A={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":p&&O?O([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":S,"%AsyncGenerator%":S,"%AsyncGeneratorFunction%":S,"%AsyncIteratorPrototype%":S,"%Atomics%":"undefined"==typeof Atomics?void 0:Atomics,"%BigInt%":"undefined"==typeof BigInt?void 0:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?void 0:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?void 0:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":r,"%eval%":eval,"%EvalError%":i,"%Float32Array%":"undefined"==typeof Float32Array?void 0:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?void 0:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?void 0:FinalizationRegistry,"%Function%":l,"%GeneratorFunction%":S,"%Int8Array%":"undefined"==typeof Int8Array?void 0:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?void 0:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":p&&O?O(O([][Symbol.iterator]())):void 0,"%JSON%":"object"==typeof JSON?JSON:void 0,"%Map%":"undefined"==typeof Map?void 0:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&p&&O?O((new Map)[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?void 0:Promise,"%Proxy%":"undefined"==typeof Proxy?void 0:Proxy,"%RangeError%":o,"%ReferenceError%":s,"%Reflect%":"undefined"==typeof Reflect?void 0:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?void 0:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&p&&O?O((new Set)[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":p&&O?O(""[Symbol.iterator]()):void 0,"%Symbol%":p?Symbol:void 0,"%SyntaxError%":a,"%ThrowTypeError%":f,"%TypedArray%":g,"%TypeError%":c,"%Uint8Array%":"undefined"==typeof Uint8Array?void 0:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?void 0:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?void 0:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?void 0:Uint32Array,"%URIError%":u,"%WeakMap%":"undefined"==typeof WeakMap?void 0:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?void 0:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?void 0:WeakSet};if(O)try{null.error}catch(e){var N=O(O(e));A["%Error.prototype%"]=N}var T={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},C=n(29),v=n(90),y=C.call(Function.call,Array.prototype.concat),m=C.call(Function.apply,Array.prototype.splice),b=C.call(Function.call,String.prototype.replace),I=C.call(Function.call,String.prototype.slice),M=C.call(Function.call,RegExp.prototype.exec),R=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,L=/\\(\\)?/g,P=function(e){var t=I(e,0,1),n=I(e,-1);if("%"===t&&"%"!==n)throw new a("invalid intrinsic syntax, expected closing `%`");if("%"===n&&"%"!==t)throw new a("invalid intrinsic syntax, expected opening `%`");var r=[];return b(e,R,(function(e,t,n,i){r[r.length]=n?b(i,L,"$1"):t||e})),r},D=function(e,t){var n,r=e;if(v(T,r)&&(r="%"+(n=T[r])[0]+"%"),v(A,r)){var i=A[r];if(i===S&&(i=function e(t){var n;if("%AsyncFunction%"===t)n=d("async function () {}");else if("%GeneratorFunction%"===t)n=d("function* () {}");else if("%AsyncGeneratorFunction%"===t)n=d("async function* () {}");else if("%AsyncGenerator%"===t){var r=e("%AsyncGeneratorFunction%");r&&(n=r.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&O&&(n=O(i.prototype))}return A[t]=n,n}(r)),void 0===i&&!t)throw new c("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:n,name:r,value:i}}throw new a("intrinsic "+e+" does not exist!")};e.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new c("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new c('"allowMissing" argument must be a boolean');if(null===M(/^%?[^%]*%?$/,e))throw new a("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=P(e),r=n.length>0?n[0]:"",i=D("%"+r+"%",t),o=i.name,s=i.value,u=!1,l=i.alias;l&&(r=l[0],m(n,y([0,1],l)));for(var d=1,E=!0;d<n.length;d+=1){var f=n[d],p=I(f,0,1),_=I(f,-1);if(('"'===p||"'"===p||"`"===p||'"'===_||"'"===_||"`"===_)&&p!==_)throw new a("property names with quotes must have matching quotes");if("constructor"!==f&&E||(u=!0),v(A,o="%"+(r+="."+f)+"%"))s=A[o];else if(null!=s){if(!(f in s)){if(!t)throw new c("base intrinsic for "+e+" exists, but the property is not available.");return}if(h&&d+1>=n.length){var O=h(s,f);s=(E=!!O)&&"get"in O&&!("originalValue"in O.get)?O.get:s[f]}else E=v(s,f),s=s[f];E&&!u&&(A[o]=s)}}return s}},function(e,t,n){e.exports=function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[s]={exports:{}};t[s][0].call(u.exports,(function(e){return i(t[s][1][e]||e)}),u,u.exports,e,t,n,r)}return n[s].exports}for(var o=!1,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}n.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var r in n)i(n,r)&&(e[r]=n[r])}}return e},n.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var o={arraySet:function(e,t,n,r,i){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+r),i);else for(var o=0;o<r;o++)e[i+o]=t[n+o]},flattenChunks:function(e){var t,n,r,i,o,s;for(r=0,t=0,n=e.length;t<n;t++)r+=e[t].length;for(s=new Uint8Array(r),i=0,t=0,n=e.length;t<n;t++)o=e[t],s.set(o,i),i+=o.length;return s}},s={arraySet:function(e,t,n,r,i){for(var o=0;o<r;o++)e[i+o]=t[n+o]},flattenChunks:function(e){return[].concat.apply([],e)}};n.setTyped=function(e){e?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,o)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,s))},n.setTyped(r)},{}],2:[function(e,t,n){"use strict";var r=e("./common"),i=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){o=!1}for(var s=new r.Buf8(256),a=0;a<256;a++)s[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;function c(e,t){if(t<65534&&(e.subarray&&o||!e.subarray&&i))return String.fromCharCode.apply(null,r.shrinkBuf(e,t));for(var n="",s=0;s<t;s++)n+=String.fromCharCode(e[s]);return n}s[254]=s[254]=1,n.string2buf=function(e){var t,n,i,o,s,a=e.length,c=0;for(o=0;o<a;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(i-56320),o++),c+=n<128?1:n<2048?2:n<65536?3:4;for(t=new r.Buf8(c),s=0,o=0;s<c;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(i-56320),o++),n<128?t[s++]=n:n<2048?(t[s++]=192|n>>>6,t[s++]=128|63&n):n<65536?(t[s++]=224|n>>>12,t[s++]=128|n>>>6&63,t[s++]=128|63&n):(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63,t[s++]=128|n>>>6&63,t[s++]=128|63&n);return t},n.buf2binstring=function(e){return c(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n<i;n++)t[n]=e.charCodeAt(n);return t},n.buf2string=function(e,t){var n,r,i,o,a=t||e.length,u=new Array(2*a);for(r=0,n=0;n<a;)if((i=e[n++])<128)u[r++]=i;else if((o=s[i])>4)u[r++]=65533,n+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&n<a;)i=i<<6|63&e[n++],o--;o>1?u[r++]=65533:i<65536?u[r++]=i:(i-=65536,u[r++]=55296|i>>10&1023,u[r++]=56320|1023&i)}return c(u,r)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+s[e[n]]>t?n:t}},{"./common":1}],3:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){for(var i=65535&e|0,o=e>>>16&65535|0,s=0;0!==n;){n-=s=n>2e3?2e3:n;do{o=o+(i=i+t[r++]|0)|0}while(--s);i%=65521,o%=65521}return i|o<<16|0}},{}],4:[function(e,t,n){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],5:[function(e,t,n){"use strict";var r=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var o=r,s=i+n;e^=-1;for(var a=i;a<s;a++)e=e>>>8^o[255&(e^t[a])];return-1^e}},{}],6:[function(e,t,n){"use strict";t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],7:[function(e,t,n){"use strict";t.exports=function(e,t){var n,r,i,o,s,a,c,u,l,d,h,E,f,p,_,O,S,g,A,N,T,C,v,y,m;n=e.state,r=e.next_in,y=e.input,i=r+(e.avail_in-5),o=e.next_out,m=e.output,s=o-(t-e.avail_out),a=o+(e.avail_out-257),c=n.dmax,u=n.wsize,l=n.whave,d=n.wnext,h=n.window,E=n.hold,f=n.bits,p=n.lencode,_=n.distcode,O=(1<<n.lenbits)-1,S=(1<<n.distbits)-1;e:do{f<15&&(E+=y[r++]<<f,f+=8,E+=y[r++]<<f,f+=8),g=p[E&O];t:for(;;){if(E>>>=A=g>>>24,f-=A,0==(A=g>>>16&255))m[o++]=65535&g;else{if(!(16&A)){if(0==(64&A)){g=p[(65535&g)+(E&(1<<A)-1)];continue t}if(32&A){n.mode=12;break e}e.msg="invalid literal/length code",n.mode=30;break e}N=65535&g,(A&=15)&&(f<A&&(E+=y[r++]<<f,f+=8),N+=E&(1<<A)-1,E>>>=A,f-=A),f<15&&(E+=y[r++]<<f,f+=8,E+=y[r++]<<f,f+=8),g=_[E&S];n:for(;;){if(E>>>=A=g>>>24,f-=A,!(16&(A=g>>>16&255))){if(0==(64&A)){g=_[(65535&g)+(E&(1<<A)-1)];continue n}e.msg="invalid distance code",n.mode=30;break e}if(T=65535&g,f<(A&=15)&&(E+=y[r++]<<f,(f+=8)<A&&(E+=y[r++]<<f,f+=8)),(T+=E&(1<<A)-1)>c){e.msg="invalid distance too far back",n.mode=30;break e}if(E>>>=A,f-=A,T>(A=o-s)){if((A=T-A)>l&&n.sane){e.msg="invalid distance too far back",n.mode=30;break e}if(C=0,v=h,0===d){if(C+=u-A,A<N){N-=A;do{m[o++]=h[C++]}while(--A);C=o-T,v=m}}else if(d<A){if(C+=u+d-A,(A-=d)<N){N-=A;do{m[o++]=h[C++]}while(--A);if(C=0,d<N){N-=A=d;do{m[o++]=h[C++]}while(--A);C=o-T,v=m}}}else if(C+=d-A,A<N){N-=A;do{m[o++]=h[C++]}while(--A);C=o-T,v=m}for(;N>2;)m[o++]=v[C++],m[o++]=v[C++],m[o++]=v[C++],N-=3;N&&(m[o++]=v[C++],N>1&&(m[o++]=v[C++]))}else{C=o-T;do{m[o++]=m[C++],m[o++]=m[C++],m[o++]=m[C++],N-=3}while(N>2);N&&(m[o++]=m[C++],N>1&&(m[o++]=m[C++]))}break}}break}}while(r<i&&o<a);r-=N=f>>3,E&=(1<<(f-=N<<3))-1,e.next_in=r,e.next_out=o,e.avail_in=r<i?i-r+5:5-(r-i),e.avail_out=o<a?a-o+257:257-(o-a),n.hold=E,n.bits=f}},{}],8:[function(e,t,n){"use strict";var r=e("../utils/common"),i=e("./adler32"),o=e("./crc32"),s=e("./inffast"),a=e("./inftrees");function c(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function u(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function l(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new r.Buf32(852),t.distcode=t.distdyn=new r.Buf32(592),t.sane=1,t.back=-1,0):-2}function d(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,l(e)):-2}function h(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?-2:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,d(e))):-2}function E(e,t){var n,r;return e?(r=new u,e.state=r,r.window=null,0!==(n=h(e,t))&&(e.state=null),n):-2}var f,p,_=!0;function O(e){if(_){var t;for(f=new r.Buf32(512),p=new r.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(a(1,e.lens,0,288,f,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(2,e.lens,0,32,p,0,e.work,{bits:5}),_=!1}e.lencode=f,e.lenbits=9,e.distcode=p,e.distbits=5}function S(e,t,n,i){var o,s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new r.Buf8(s.wsize)),i>=s.wsize?(r.arraySet(s.window,t,n-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):((o=s.wsize-s.wnext)>i&&(o=i),r.arraySet(s.window,t,n-i,o,s.wnext),(i-=o)?(r.arraySet(s.window,t,n-i,i,0),s.wnext=i,s.whave=s.wsize):(s.wnext+=o,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=o))),0}n.inflateReset=d,n.inflateReset2=h,n.inflateResetKeep=l,n.inflateInit=function(e){return E(e,15)},n.inflateInit2=E,n.inflate=function(e,t){var n,u,l,d,h,E,f,p,_,g,A,N,T,C,v,y,m,b,I,M,R,L,P,D,w=0,U=new r.Buf8(4),j=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return-2;12===(n=e.state).mode&&(n.mode=13),h=e.next_out,l=e.output,f=e.avail_out,d=e.next_in,u=e.input,E=e.avail_in,p=n.hold,_=n.bits,g=E,A=f,L=0;e:for(;;)switch(n.mode){case 1:if(0===n.wrap){n.mode=13;break}for(;_<16;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(2&n.wrap&&35615===p){n.check=0,U[0]=255&p,U[1]=p>>>8&255,n.check=o(n.check,U,2,0),p=0,_=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&p)<<8)+(p>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&p)){e.msg="unknown compression method",n.mode=30;break}if(_-=4,R=8+(15&(p>>>=4)),0===n.wbits)n.wbits=R;else if(R>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<<R,e.adler=n.check=1,n.mode=512&p?10:12,p=0,_=0;break;case 2:for(;_<16;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(n.flags=p,8!=(255&n.flags)){e.msg="unknown compression method",n.mode=30;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=30;break}n.head&&(n.head.text=p>>8&1),512&n.flags&&(U[0]=255&p,U[1]=p>>>8&255,n.check=o(n.check,U,2,0)),p=0,_=0,n.mode=3;case 3:for(;_<32;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}n.head&&(n.head.time=p),512&n.flags&&(U[0]=255&p,U[1]=p>>>8&255,U[2]=p>>>16&255,U[3]=p>>>24&255,n.check=o(n.check,U,4,0)),p=0,_=0,n.mode=4;case 4:for(;_<16;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}n.head&&(n.head.xflags=255&p,n.head.os=p>>8),512&n.flags&&(U[0]=255&p,U[1]=p>>>8&255,n.check=o(n.check,U,2,0)),p=0,_=0,n.mode=5;case 5:if(1024&n.flags){for(;_<16;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}n.length=p,n.head&&(n.head.extra_len=p),512&n.flags&&(U[0]=255&p,U[1]=p>>>8&255,n.check=o(n.check,U,2,0)),p=0,_=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&((N=n.length)>E&&(N=E),N&&(n.head&&(R=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),r.arraySet(n.head.extra,u,d,N,R)),512&n.flags&&(n.check=o(n.check,u,N,d)),E-=N,d+=N,n.length-=N),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===E)break e;N=0;do{R=u[d+N++],n.head&&R&&n.length<65536&&(n.head.name+=String.fromCharCode(R))}while(R&&N<E);if(512&n.flags&&(n.check=o(n.check,u,N,d)),E-=N,d+=N,R)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=8;case 8:if(4096&n.flags){if(0===E)break e;N=0;do{R=u[d+N++],n.head&&R&&n.length<65536&&(n.head.comment+=String.fromCharCode(R))}while(R&&N<E);if(512&n.flags&&(n.check=o(n.check,u,N,d)),E-=N,d+=N,R)break e}else n.head&&(n.head.comment=null);n.mode=9;case 9:if(512&n.flags){for(;_<16;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(p!==(65535&n.check)){e.msg="header crc mismatch",n.mode=30;break}p=0,_=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;_<32;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}e.adler=n.check=c(p),p=0,_=0,n.mode=11;case 11:if(0===n.havedict)return e.next_out=h,e.avail_out=f,e.next_in=d,e.avail_in=E,n.hold=p,n.bits=_,2;e.adler=n.check=1,n.mode=12;case 12:if(5===t||6===t)break e;case 13:if(n.last){p>>>=7&_,_-=7&_,n.mode=27;break}for(;_<3;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}switch(n.last=1&p,_-=1,3&(p>>>=1)){case 0:n.mode=14;break;case 1:if(O(n),n.mode=20,6===t){p>>>=2,_-=2;break e}break;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}p>>>=2,_-=2;break;case 14:for(p>>>=7&_,_-=7&_;_<32;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if((65535&p)!=(p>>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&p,p=0,_=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(N=n.length){if(N>E&&(N=E),N>f&&(N=f),0===N)break e;r.arraySet(l,u,d,N,h),E-=N,d+=N,f-=N,h+=N,n.length-=N;break}n.mode=12;break;case 17:for(;_<14;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(n.nlen=257+(31&p),p>>>=5,_-=5,n.ndist=1+(31&p),p>>>=5,_-=5,n.ncode=4+(15&p),p>>>=4,_-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=30;break}n.have=0,n.mode=18;case 18:for(;n.have<n.ncode;){for(;_<3;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}n.lens[j[n.have++]]=7&p,p>>>=3,_-=3}for(;n.have<19;)n.lens[j[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,P={bits:n.lenbits},L=a(0,n.lens,0,19,n.lencode,0,n.work,P),n.lenbits=P.bits,L){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have<n.nlen+n.ndist;){for(;y=(w=n.lencode[p&(1<<n.lenbits)-1])>>>16&255,m=65535&w,!((v=w>>>24)<=_);){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(m<16)p>>>=v,_-=v,n.lens[n.have++]=m;else{if(16===m){for(D=v+2;_<D;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(p>>>=v,_-=v,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}R=n.lens[n.have-1],N=3+(3&p),p>>>=2,_-=2}else if(17===m){for(D=v+3;_<D;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}_-=v,R=0,N=3+(7&(p>>>=v)),p>>>=3,_-=3}else{for(D=v+7;_<D;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}_-=v,R=0,N=11+(127&(p>>>=v)),p>>>=7,_-=7}if(n.have+N>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;N--;)n.lens[n.have++]=R}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,P={bits:n.lenbits},L=a(1,n.lens,0,n.nlen,n.lencode,0,n.work,P),n.lenbits=P.bits,L){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,P={bits:n.distbits},L=a(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,P),n.distbits=P.bits,L){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(E>=6&&f>=258){e.next_out=h,e.avail_out=f,e.next_in=d,e.avail_in=E,n.hold=p,n.bits=_,s(e,A),h=e.next_out,l=e.output,f=e.avail_out,d=e.next_in,u=e.input,E=e.avail_in,p=n.hold,_=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;y=(w=n.lencode[p&(1<<n.lenbits)-1])>>>16&255,m=65535&w,!((v=w>>>24)<=_);){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(y&&0==(240&y)){for(b=v,I=y,M=m;y=(w=n.lencode[M+((p&(1<<b+I)-1)>>b)])>>>16&255,m=65535&w,!(b+(v=w>>>24)<=_);){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}p>>>=b,_-=b,n.back+=b}if(p>>>=v,_-=v,n.back+=v,n.length=m,0===y){n.mode=26;break}if(32&y){n.back=-1,n.mode=12;break}if(64&y){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&y,n.mode=22;case 22:if(n.extra){for(D=n.extra;_<D;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}n.length+=p&(1<<n.extra)-1,p>>>=n.extra,_-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;y=(w=n.distcode[p&(1<<n.distbits)-1])>>>16&255,m=65535&w,!((v=w>>>24)<=_);){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(0==(240&y)){for(b=v,I=y,M=m;y=(w=n.distcode[M+((p&(1<<b+I)-1)>>b)])>>>16&255,m=65535&w,!(b+(v=w>>>24)<=_);){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}p>>>=b,_-=b,n.back+=b}if(p>>>=v,_-=v,n.back+=v,64&y){e.msg="invalid distance code",n.mode=30;break}n.offset=m,n.extra=15&y,n.mode=24;case 24:if(n.extra){for(D=n.extra;_<D;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}n.offset+=p&(1<<n.extra)-1,p>>>=n.extra,_-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===f)break e;if(N=A-f,n.offset>N){if((N=n.offset-N)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}N>n.wnext?(N-=n.wnext,T=n.wsize-N):T=n.wnext-N,N>n.length&&(N=n.length),C=n.window}else C=l,T=h-n.offset,N=n.length;N>f&&(N=f),f-=N,n.length-=N;do{l[h++]=C[T++]}while(--N);0===n.length&&(n.mode=21);break;case 26:if(0===f)break e;l[h++]=n.length,f--,n.mode=21;break;case 27:if(n.wrap){for(;_<32;){if(0===E)break e;E--,p|=u[d++]<<_,_+=8}if(A-=f,e.total_out+=A,n.total+=A,A&&(e.adler=n.check=n.flags?o(n.check,l,A,h-A):i(n.check,l,A,h-A)),A=f,(n.flags?p:c(p))!==n.check){e.msg="incorrect data check",n.mode=30;break}p=0,_=0}n.mode=28;case 28:if(n.wrap&&n.flags){for(;_<32;){if(0===E)break e;E--,p+=u[d++]<<_,_+=8}if(p!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=30;break}p=0,_=0}n.mode=29;case 29:L=1;break e;case 30:L=-3;break e;case 31:return-4;case 32:default:return-2}return e.next_out=h,e.avail_out=f,e.next_in=d,e.avail_in=E,n.hold=p,n.bits=_,(n.wsize||A!==e.avail_out&&n.mode<30&&(n.mode<27||4!==t))&&S(e,e.output,e.next_out,A-e.avail_out)?(n.mode=31,-4):(g-=e.avail_in,A-=e.avail_out,e.total_in+=g,e.total_out+=A,n.total+=A,n.wrap&&A&&(e.adler=n.check=n.flags?o(n.check,l,A,e.next_out-A):i(n.check,l,A,e.next_out-A)),e.data_type=n.bits+(n.last?64:0)+(12===n.mode?128:0)+(20===n.mode||15===n.mode?256:0),(0===g&&0===A||4===t)&&0===L&&(L=-5),L)},n.inflateEnd=function(e){if(!e||!e.state)return-2;var t=e.state;return t.window&&(t.window=null),e.state=null,0},n.inflateGetHeader=function(e,t){var n;return e&&e.state?0==(2&(n=e.state).wrap)?-2:(n.head=t,t.done=!1,0):-2},n.inflateSetDictionary=function(e,t){var n,r=t.length;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?-2:11===n.mode&&i(1,t,r,0)!==n.check?-3:S(e,t,r,r)?(n.mode=31,-4):(n.havedict=1,0):-2},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":5,"./inffast":7,"./inftrees":9}],9:[function(e,t,n){"use strict";var r=e("../utils/common"),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],s=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],a=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,n,c,u,l,d,h){var E,f,p,_,O,S,g,A,N,T=h.bits,C=0,v=0,y=0,m=0,b=0,I=0,M=0,R=0,L=0,P=0,D=null,w=0,U=new r.Buf16(16),j=new r.Buf16(16),F=null,k=0;for(C=0;C<=15;C++)U[C]=0;for(v=0;v<c;v++)U[t[n+v]]++;for(b=T,m=15;m>=1&&0===U[m];m--);if(b>m&&(b=m),0===m)return u[l++]=20971520,u[l++]=20971520,h.bits=1,0;for(y=1;y<m&&0===U[y];y++);for(b<y&&(b=y),R=1,C=1;C<=15;C++)if(R<<=1,(R-=U[C])<0)return-1;if(R>0&&(0===e||1!==m))return-1;for(j[1]=0,C=1;C<15;C++)j[C+1]=j[C]+U[C];for(v=0;v<c;v++)0!==t[n+v]&&(d[j[t[n+v]]++]=v);if(0===e?(D=F=d,S=19):1===e?(D=i,w-=257,F=o,k-=257,S=256):(D=s,F=a,S=-1),P=0,v=0,C=y,O=l,I=b,M=0,p=-1,_=(L=1<<b)-1,1===e&&L>852||2===e&&L>592)return 1;for(;;){g=C-M,d[v]<S?(A=0,N=d[v]):d[v]>S?(A=F[k+d[v]],N=D[w+d[v]]):(A=96,N=0),E=1<<C-M,y=f=1<<I;do{u[O+(P>>M)+(f-=E)]=g<<24|A<<16|N|0}while(0!==f);for(E=1<<C-1;P&E;)E>>=1;if(0!==E?(P&=E-1,P+=E):P=0,v++,0==--U[C]){if(C===m)break;C=t[n+d[v]]}if(C>b&&(P&_)!==p){for(0===M&&(M=b),O+=y,R=1<<(I=C-M);I+M<m&&!((R-=U[I+M])<=0);)I++,R<<=1;if(L+=1<<I,1===e&&L>852||2===e&&L>592)return 1;u[p=P&_]=b<<24|I<<16|O-l|0}}return 0!==P&&(u[O+P]=C-M<<24|64<<16|0),h.bits=b,0}},{"../utils/common":1}],10:[function(e,t,n){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],11:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],"/lib/inflate.js":[function(e,t,n){"use strict";var r=e("./zlib/inflate"),i=e("./utils/common"),o=e("./utils/strings"),s=e("./zlib/constants"),a=e("./zlib/messages"),c=e("./zlib/zstream"),u=e("./zlib/gzheader"),l=Object.prototype.toString;function d(e){if(!(this instanceof d))return new d(e);this.options=i.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var n=r.inflateInit2(this.strm,t.windowBits);if(n!==s.Z_OK)throw new Error(a[n]);if(this.header=new u,r.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=o.string2buf(t.dictionary):"[object ArrayBuffer]"===l.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=r.inflateSetDictionary(this.strm,t.dictionary))!==s.Z_OK))throw new Error(a[n])}function h(e,t){var n=new d(t);if(n.push(e,!0),n.err)throw n.msg||a[n.err];return n.result}d.prototype.push=function(e,t){var n,a,c,u,d,h=this.strm,E=this.options.chunkSize,f=this.options.dictionary,p=!1;if(this.ended)return!1;a=t===~~t?t:!0===t?s.Z_FINISH:s.Z_NO_FLUSH,"string"==typeof e?h.input=o.binstring2buf(e):"[object ArrayBuffer]"===l.call(e)?h.input=new Uint8Array(e):h.input=e,h.next_in=0,h.avail_in=h.input.length;do{if(0===h.avail_out&&(h.output=new i.Buf8(E),h.next_out=0,h.avail_out=E),(n=r.inflate(h,s.Z_NO_FLUSH))===s.Z_NEED_DICT&&f&&(n=r.inflateSetDictionary(this.strm,f)),n===s.Z_BUF_ERROR&&!0===p&&(n=s.Z_OK,p=!1),n!==s.Z_STREAM_END&&n!==s.Z_OK)return this.onEnd(n),this.ended=!0,!1;h.next_out&&(0!==h.avail_out&&n!==s.Z_STREAM_END&&(0!==h.avail_in||a!==s.Z_FINISH&&a!==s.Z_SYNC_FLUSH)||("string"===this.options.to?(c=o.utf8border(h.output,h.next_out),u=h.next_out-c,d=o.buf2string(h.output,c),h.next_out=u,h.avail_out=E-u,u&&i.arraySet(h.output,h.output,c,u,0),this.onData(d)):this.onData(i.shrinkBuf(h.output,h.next_out)))),0===h.avail_in&&0===h.avail_out&&(p=!0)}while((h.avail_in>0||0===h.avail_out)&&n!==s.Z_STREAM_END);return n===s.Z_STREAM_END&&(a=s.Z_FINISH),a===s.Z_FINISH?(n=r.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===s.Z_OK):a!==s.Z_SYNC_FLUSH||(this.onEnd(s.Z_OK),h.avail_out=0,!0)},d.prototype.onData=function(e){this.chunks.push(e)},d.prototype.onEnd=function(e){e===s.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Inflate=d,n.inflate=h,n.inflateRaw=function(e,t){return(t=t||{}).raw=!0,h(e,t)},n.ungzip=h},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")},function(e,t){e.exports=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.circularDependencyToException=t.listMetadataForTarget=t.listRegisteredBindingsForServiceIdentifier=t.getServiceIdentifierAsString=t.getFunctionName=void 0;var r=n(8);function i(e){return"function"==typeof e?e.name:"symbol"==typeof e?e.toString():e}function o(e){if(e.name)return e.name;var t=e.toString(),n=t.match(/^function\s*([^\s(]+)/);return n?n[1]:"Anonymous function: "+t}t.getServiceIdentifierAsString=i,t.listRegisteredBindingsForServiceIdentifier=function(e,t,n){var r="",i=n(e,t);return 0!==i.length&&(r="\nRegistered bindings:",i.forEach((function(e){var t="Object";null!==e.implementationType&&(t=o(e.implementationType)),r=r+"\n "+t,e.constraint.metaData&&(r=r+" - "+e.constraint.metaData)}))),r},t.circularDependencyToException=function e(t){t.childRequests.forEach((function(t){if(function e(t,n){return null!==t.parentRequest&&(t.parentRequest.serviceIdentifier===n||e(t.parentRequest,n))}(t,t.serviceIdentifier)){var n=function(e){return function e(t,n){void 0===n&&(n=[]);var r=i(t.serviceIdentifier);return n.push(r),null!==t.parentRequest?e(t.parentRequest,n):n}(e).reverse().join(" --\x3e ")}(t);throw new Error(r.CIRCULAR_DEPENDENCY+" "+n)}e(t)}))},t.listMetadataForTarget=function(e,t){if(t.isTagged()||t.isNamed()){var n="",r=t.getNamedTag(),i=t.getCustomTags();return null!==r&&(n+=r.toString()+"\n"),null!==i&&i.forEach((function(e){n+=e.toString()+"\n"}))," "+e+"\n "+e+" - "+n}return" "+e},t.getFunctionName=o},function(e,t,n){"use strict";e.exports=TypeError},function(e,t){e.exports=c},function(e,t){e.exports=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingOnSyntax=void 0;var r=n(28),i=function(){function e(e){this._binding=e}return e.prototype.onActivation=function(e){return this._binding.onActivation=e,new r.BindingWhenSyntax(this._binding)},e}();t.BindingOnSyntax=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingWhenSyntax=void 0;var r=n(27),i=n(40),o=function(){function e(e){this._binding=e}return e.prototype.when=function(e){return this._binding.constraint=e,new r.BindingOnSyntax(this._binding)},e.prototype.whenTargetNamed=function(e){return this._binding.constraint=i.namedConstraint(e),new r.BindingOnSyntax(this._binding)},e.prototype.whenTargetIsDefault=function(){return this._binding.constraint=function(e){return null!==e.target&&!e.target.isNamed()&&!e.target.isTagged()},new r.BindingOnSyntax(this._binding)},e.prototype.whenTargetTagged=function(e,t){return this._binding.constraint=i.taggedConstraint(e)(t),new r.BindingOnSyntax(this._binding)},e.prototype.whenInjectedInto=function(e){return this._binding.constraint=function(t){return i.typeConstraint(e)(t.parentRequest)},new r.BindingOnSyntax(this._binding)},e.prototype.whenParentNamed=function(e){return this._binding.constraint=function(t){return i.namedConstraint(e)(t.parentRequest)},new r.BindingOnSyntax(this._binding)},e.prototype.whenParentTagged=function(e,t){return this._binding.constraint=function(n){return i.taggedConstraint(e)(t)(n.parentRequest)},new r.BindingOnSyntax(this._binding)},e.prototype.whenAnyAncestorIs=function(e){return this._binding.constraint=function(t){return i.traverseAncerstors(t,i.typeConstraint(e))},new r.BindingOnSyntax(this._binding)},e.prototype.whenNoAncestorIs=function(e){return this._binding.constraint=function(t){return!i.traverseAncerstors(t,i.typeConstraint(e))},new r.BindingOnSyntax(this._binding)},e.prototype.whenAnyAncestorNamed=function(e){return this._binding.constraint=function(t){return i.traverseAncerstors(t,i.namedConstraint(e))},new r.BindingOnSyntax(this._binding)},e.prototype.whenNoAncestorNamed=function(e){return this._binding.constraint=function(t){return!i.traverseAncerstors(t,i.namedConstraint(e))},new r.BindingOnSyntax(this._binding)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._binding.constraint=function(n){return i.traverseAncerstors(n,i.taggedConstraint(e)(t))},new r.BindingOnSyntax(this._binding)},e.prototype.whenNoAncestorTagged=function(e,t){return this._binding.constraint=function(n){return!i.traverseAncerstors(n,i.taggedConstraint(e)(t))},new r.BindingOnSyntax(this._binding)},e.prototype.whenAnyAncestorMatches=function(e){return this._binding.constraint=function(t){return i.traverseAncerstors(t,e)},new r.BindingOnSyntax(this._binding)},e.prototype.whenNoAncestorMatches=function(e){return this._binding.constraint=function(t){return!i.traverseAncerstors(t,e)},new r.BindingOnSyntax(this._binding)},e}();t.BindingWhenSyntax=o},function(e,t,n){"use strict";var r=n(89);e.exports=Function.prototype.bind||r},function(e,t,n){"use strict";var r=n(20)("%Object.defineProperty%",!0)||!1;if(r)try{r({},"a",{value:1})}catch(e){r=!1}e.exports=r},function(e,t,n){"use strict";var r=String.prototype.replace,i=/%20/g,o="RFC1738",s="RFC3986";e.exports={default:s,formatters:{RFC1738:function(e){return r.call(e,i,"+")},RFC3986:function(e){return String(e)}},RFC1738:o,RFC3986:s}},function(e,t){e.exports=l},function(e,t){e.exports=d},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataReader=void 0;var r=n(5),i=function(){function e(){}return e.prototype.getConstructorMetadata=function(e){return{compilerGeneratedMetadata:Reflect.getMetadata(r.PARAM_TYPES,e),userGeneratedMetadata:Reflect.getMetadata(r.TAGGED,e)||{}}},e.prototype.getPropertiesMetadata=function(e){return Reflect.getMetadata(r.TAGGED_PROP,e)||[]},e}();t.MetadataReader=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isStackOverflowExeption=void 0;var r=n(8);t.isStackOverflowExeption=function(e){return e instanceof RangeError||e.message===r.STACK_OVERFLOW}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.inject=t.LazyServiceIdentifer=void 0;var r=n(8),i=n(5),o=n(10),s=n(15),a=function(){function e(e){this._cb=e}return e.prototype.unwrap=function(){return this._cb()},e}();t.LazyServiceIdentifer=a,t.inject=function(e){return function(t,n,a){if(void 0===e)throw new Error(r.UNDEFINED_INJECT_ANNOTATION(t.name));var c=new o.Metadata(i.INJECT_TAG,e);"number"==typeof a?s.tagParameter(t,n,a,c):s.tagProperty(t,n,c)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Target=void 0;var r=n(5),i=n(19),o=n(10),s=n(60),a=function(){function e(e,t,n,a){this.id=i.id(),this.type=e,this.serviceIdentifier=n,this.name=new s.QueryableString(t||""),this.metadata=new Array;var c=null;"string"==typeof a?c=new o.Metadata(r.NAMED_TAG,a):a instanceof o.Metadata&&(c=a),null!==c&&this.metadata.push(c)}return e.prototype.hasTag=function(e){for(var t=0,n=this.metadata;t<n.length;t++){if(n[t].key===e)return!0}return!1},e.prototype.isArray=function(){return this.hasTag(r.MULTI_INJECT_TAG)},e.prototype.matchesArray=function(e){return this.matchesTag(r.MULTI_INJECT_TAG)(e)},e.prototype.isNamed=function(){return this.hasTag(r.NAMED_TAG)},e.prototype.isTagged=function(){return this.metadata.some((function(e){return r.NON_CUSTOM_TAG_KEYS.every((function(t){return e.key!==t}))}))},e.prototype.isOptional=function(){return this.matchesTag(r.OPTIONAL_TAG)(!0)},e.prototype.getNamedTag=function(){return this.isNamed()?this.metadata.filter((function(e){return e.key===r.NAMED_TAG}))[0]:null},e.prototype.getCustomTags=function(){return this.isTagged()?this.metadata.filter((function(e){return r.NON_CUSTOM_TAG_KEYS.every((function(t){return e.key!==t}))})):null},e.prototype.matchesNamedTag=function(e){return this.matchesTag(r.NAMED_TAG)(e)},e.prototype.matchesTag=function(e){var t=this;return function(n){for(var r=0,i=t.metadata;r<i.length;r++){var o=i[r];if(o.key===e&&o.value===n)return!0}return!1}},e}();t.Target=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingWhenOnSyntax=void 0;var r=n(27),i=n(28),o=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new i.BindingWhenSyntax(this._binding),this._bindingOnSyntax=new r.BindingOnSyntax(this._binding)}return e.prototype.when=function(e){return this._bindingWhenSyntax.when(e)},e.prototype.whenTargetNamed=function(e){return this._bindingWhenSyntax.whenTargetNamed(e)},e.prototype.whenTargetIsDefault=function(){return this._bindingWhenSyntax.whenTargetIsDefault()},e.prototype.whenTargetTagged=function(e,t){return this._bindingWhenSyntax.whenTargetTagged(e,t)},e.prototype.whenInjectedInto=function(e){return this._bindingWhenSyntax.whenInjectedInto(e)},e.prototype.whenParentNamed=function(e){return this._bindingWhenSyntax.whenParentNamed(e)},e.prototype.whenParentTagged=function(e,t){return this._bindingWhenSyntax.whenParentTagged(e,t)},e.prototype.whenAnyAncestorIs=function(e){return this._bindingWhenSyntax.whenAnyAncestorIs(e)},e.prototype.whenNoAncestorIs=function(e){return this._bindingWhenSyntax.whenNoAncestorIs(e)},e.prototype.whenAnyAncestorNamed=function(e){return this._bindingWhenSyntax.whenAnyAncestorNamed(e)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenAnyAncestorTagged(e,t)},e.prototype.whenNoAncestorNamed=function(e){return this._bindingWhenSyntax.whenNoAncestorNamed(e)},e.prototype.whenNoAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenNoAncestorTagged(e,t)},e.prototype.whenAnyAncestorMatches=function(e){return this._bindingWhenSyntax.whenAnyAncestorMatches(e)},e.prototype.whenNoAncestorMatches=function(e){return this._bindingWhenSyntax.whenNoAncestorMatches(e)},e.prototype.onActivation=function(e){return this._bindingOnSyntax.onActivation(e)},e}();t.BindingWhenOnSyntax=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.typeConstraint=t.namedConstraint=t.taggedConstraint=t.traverseAncerstors=void 0;var r=n(5),i=n(10),o=function(e,t){var n=e.parentRequest;return null!==n&&(!!t(n)||o(n,t))};t.traverseAncerstors=o;var s=function(e){return function(t){var n=function(n){return null!==n&&null!==n.target&&n.target.matchesTag(e)(t)};return n.metaData=new i.Metadata(e,t),n}};t.taggedConstraint=s;var a=s(r.NAMED_TAG);t.namedConstraint=a;t.typeConstraint=function(e){return function(t){var n=null;if(null!==t){if(n=t.bindings[0],"string"==typeof e)return n.serviceIdentifier===e;var r=t.bindings[0].implementationType;return e===r}return!1}}},function(e,t,n){"use strict";e.exports=SyntaxError},function(e,t,n){"use strict";var r=n(20)("%Object.getOwnPropertyDescriptor%",!0);if(r)try{r([],"length")}catch(e){r=null}e.exports=r},function(e,t,n){"use strict";var r=n(31),i=Object.prototype.hasOwnProperty,o=Array.isArray,s=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),a=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r<e.length;++r)void 0!==e[r]&&(n[r]=e[r]);return n};e.exports={arrayToObject:a,assign:function(e,t){return Object.keys(t).reduce((function(e,n){return e[n]=t[n],e}),e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],n=[],r=0;r<t.length;++r)for(var i=t[r],s=i.obj[i.prop],a=Object.keys(s),c=0;c<a.length;++c){var u=a[c],l=s[u];"object"==typeof l&&null!==l&&-1===n.indexOf(l)&&(t.push({obj:s,prop:u}),n.push(l))}return function(e){for(;e.length>1;){var t=e.pop(),n=t.obj[t.prop];if(o(n)){for(var r=[],i=0;i<n.length;++i)void 0!==n[i]&&r.push(n[i]);t.obj[t.prop]=r}}}(t),e},decode:function(e,t,n){var r=e.replace(/\+/g," ");if("iso-8859-1"===n)return r.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(r)}catch(e){return r}},encode:function(e,t,n,i,o){if(0===e.length)return e;var a=e;if("symbol"==typeof e?a=Symbol.prototype.toString.call(e):"string"!=typeof e&&(a=String(e)),"iso-8859-1"===n)return escape(a).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var c="",u=0;u<a.length;u+=1024){for(var l=a.length>=1024?a.slice(u,u+1024):a,d=[],h=0;h<l.length;++h){var E=l.charCodeAt(h);45===E||46===E||95===E||126===E||E>=48&&E<=57||E>=65&&E<=90||E>=97&&E<=122||o===r.RFC1738&&(40===E||41===E)?d[d.length]=l.charAt(h):E<128?d[d.length]=s[E]:E<2048?d[d.length]=s[192|E>>6]+s[128|63&E]:E<55296||E>=57344?d[d.length]=s[224|E>>12]+s[128|E>>6&63]+s[128|63&E]:(h+=1,E=65536+((1023&E)<<10|1023&l.charCodeAt(h)),d[d.length]=s[240|E>>18]+s[128|E>>12&63]+s[128|E>>6&63]+s[128|63&E])}c+=d.join("")}return c},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(o(e)){for(var n=[],r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)},merge:function e(t,n,r){if(!n)return t;if("object"!=typeof n){if(o(t))t.push(n);else{if(!t||"object"!=typeof t)return[t,n];(r&&(r.plainObjects||r.allowPrototypes)||!i.call(Object.prototype,n))&&(t[n]=!0)}return t}if(!t||"object"!=typeof t)return[t].concat(n);var s=t;return o(t)&&!o(n)&&(s=a(t,r)),o(t)&&o(n)?(n.forEach((function(n,o){if(i.call(t,o)){var s=t[o];s&&"object"==typeof s&&n&&"object"==typeof n?t[o]=e(s,n,r):t.push(n)}else t[o]=n})),t):Object.keys(n).reduce((function(t,o){var s=n[o];return i.call(t,o)?t[o]=e(t[o],s,r):t[o]=s,t}),s)}}},function(e,t,n){var r;e.exports=(r=r||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),r={},i=r.lib={},o=i.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},s=i.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var o=0;o<i;o++){var s=n[o>>>2]>>>24-o%4*8&255;t[r+o>>>2]|=s<<24-(r+o)%4*8}else for(o=0;o<i;o+=4)t[r+o>>>2]=n[o>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,r=[],i=function(t){t=t;var n=987654321,r=4294967295;return function(){var i=((n=36969*(65535&n)+(n>>16)&r)<<16)+(t=18e3*(65535&t)+(t>>16)&r)&r;return i/=4294967296,(i+=.5)*(e.random()>.5?1:-1)}},o=0;o<t;o+=4){var a=i(4294967296*(n||e.random()));n=987654071*a(),r.push(4294967296*a()|0)}return new s.init(r,t)}}),a=r.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},d=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,i=n.sigBytes,o=this.blockSize,a=i/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,u=e.min(4*c,i);if(c){for(var l=0;l<c;l+=o)this._doProcessBlock(r,l);var d=r.splice(0,c);n.sigBytes-=u}return new s.init(d,u)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),h=(i.Hasher=d.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new h.HMAC.init(e,n).finalize(t)}}}),r.algo={});return r}(Math),r)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(11);function i(e,t,n){for(var i=n||r.defaultEquals,o=e.length,s=0;s<o;s++)if(i(e[s],t))return s;return-1}t.indexOf=i,t.lastIndexOf=function(e,t,n){for(var i=n||r.defaultEquals,o=e.length-1;o>=0;o--)if(i(e[o],t))return o;return-1},t.contains=function(e,t,n){return i(e,t,n)>=0},t.remove=function(e,t,n){var r=i(e,t,n);return!(r<0)&&(e.splice(r,1),!0)},t.frequency=function(e,t,n){for(var i=n||r.defaultEquals,o=e.length,s=0,a=0;a<o;a++)i(e[a],t)&&s++;return s},t.equals=function(e,t,n){var i=n||r.defaultEquals;if(e.length!==t.length)return!1;for(var o=e.length,s=0;s<o;s++)if(!i(e[s],t[s]))return!1;return!0},t.copy=function(e){return e.concat()},t.swap=function(e,t,n){if(t<0||t>=e.length||n<0||n>=e.length)return!1;var r=e[t];return e[t]=e[n],e[n]=r,!0},t.toString=function(e){return"["+e.toString()+"]"},t.forEach=function(e,t){for(var n=0,r=e;n<r.length;n++){if(!1===t(r[n]))return}}},function(e,t,n){var r=n(99),i=n(100);e.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[o+a]=s[a];return t||i(s)}},function(e,t,n){var r;e.exports=(r=n(44),function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,s=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=s.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var r=t+n,i=e[r];e[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,s=e[t+0],c=e[t+1],E=e[t+2],f=e[t+3],p=e[t+4],_=e[t+5],O=e[t+6],S=e[t+7],g=e[t+8],A=e[t+9],N=e[t+10],T=e[t+11],C=e[t+12],v=e[t+13],y=e[t+14],m=e[t+15],b=o[0],I=o[1],M=o[2],R=o[3];b=u(b,I,M,R,s,7,a[0]),R=u(R,b,I,M,c,12,a[1]),M=u(M,R,b,I,E,17,a[2]),I=u(I,M,R,b,f,22,a[3]),b=u(b,I,M,R,p,7,a[4]),R=u(R,b,I,M,_,12,a[5]),M=u(M,R,b,I,O,17,a[6]),I=u(I,M,R,b,S,22,a[7]),b=u(b,I,M,R,g,7,a[8]),R=u(R,b,I,M,A,12,a[9]),M=u(M,R,b,I,N,17,a[10]),I=u(I,M,R,b,T,22,a[11]),b=u(b,I,M,R,C,7,a[12]),R=u(R,b,I,M,v,12,a[13]),M=u(M,R,b,I,y,17,a[14]),b=l(b,I=u(I,M,R,b,m,22,a[15]),M,R,c,5,a[16]),R=l(R,b,I,M,O,9,a[17]),M=l(M,R,b,I,T,14,a[18]),I=l(I,M,R,b,s,20,a[19]),b=l(b,I,M,R,_,5,a[20]),R=l(R,b,I,M,N,9,a[21]),M=l(M,R,b,I,m,14,a[22]),I=l(I,M,R,b,p,20,a[23]),b=l(b,I,M,R,A,5,a[24]),R=l(R,b,I,M,y,9,a[25]),M=l(M,R,b,I,f,14,a[26]),I=l(I,M,R,b,g,20,a[27]),b=l(b,I,M,R,v,5,a[28]),R=l(R,b,I,M,E,9,a[29]),M=l(M,R,b,I,S,14,a[30]),b=d(b,I=l(I,M,R,b,C,20,a[31]),M,R,_,4,a[32]),R=d(R,b,I,M,g,11,a[33]),M=d(M,R,b,I,T,16,a[34]),I=d(I,M,R,b,y,23,a[35]),b=d(b,I,M,R,c,4,a[36]),R=d(R,b,I,M,p,11,a[37]),M=d(M,R,b,I,S,16,a[38]),I=d(I,M,R,b,N,23,a[39]),b=d(b,I,M,R,v,4,a[40]),R=d(R,b,I,M,s,11,a[41]),M=d(M,R,b,I,f,16,a[42]),I=d(I,M,R,b,O,23,a[43]),b=d(b,I,M,R,A,4,a[44]),R=d(R,b,I,M,C,11,a[45]),M=d(M,R,b,I,m,16,a[46]),b=h(b,I=d(I,M,R,b,E,23,a[47]),M,R,s,6,a[48]),R=h(R,b,I,M,S,10,a[49]),M=h(M,R,b,I,y,15,a[50]),I=h(I,M,R,b,_,21,a[51]),b=h(b,I,M,R,C,6,a[52]),R=h(R,b,I,M,f,10,a[53]),M=h(M,R,b,I,N,15,a[54]),I=h(I,M,R,b,c,21,a[55]),b=h(b,I,M,R,g,6,a[56]),R=h(R,b,I,M,m,10,a[57]),M=h(M,R,b,I,O,15,a[58]),I=h(I,M,R,b,v,21,a[59]),b=h(b,I,M,R,p,6,a[60]),R=h(R,b,I,M,T,10,a[61]),M=h(M,R,b,I,E,15,a[62]),I=h(I,M,R,b,A,21,a[63]),o[0]=o[0]+b|0,o[1]=o[1]+I|0,o[2]=o[2]+M|0,o[3]=o[3]+R|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var o=e.floor(r/4294967296),s=r;n[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(i+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,r,i,o,s){var a=e+(t&n|~t&r)+i+s;return(a<<o|a>>>32-o)+t}function l(e,t,n,r,i,o,s){var a=e+(t&r|n&~r)+i+s;return(a<<o|a>>>32-o)+t}function d(e,t,n,r,i,o,s){var a=e+(t^n^r)+i+s;return(a<<o|a>>>32-o)+t}function h(e,t,n,r,i,o,s){var a=e+(n^(t|~r))+i+s;return(a<<o|a>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),r.MD5)},function(e,t){e.exports=h},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(102),i=function(){function e(){this.list=new r.default}return e.prototype.enqueue=function(e){return this.list.add(e)},e.prototype.add=function(e){return this.list.add(e)},e.prototype.dequeue=function(){if(0!==this.list.size()){var e=this.list.first();return this.list.removeElementAtIndex(0),e}},e.prototype.peek=function(){if(0!==this.list.size())return this.list.first()},e.prototype.size=function(){return this.list.size()},e.prototype.contains=function(e,t){return this.list.contains(e,t)},e.prototype.isEmpty=function(){return this.list.size()<=0},e.prototype.clear=function(){this.list.clear()},e.prototype.forEach=function(e){this.list.forEach(e)},e}();t.default=i},function(e,t){e.exports=E},function(e,t,n){var r=n(103);function i(){}function o(e,t,n){null==n&&(n=s),cordova.exec((function(){var e=Array.prototype.slice.call(arguments);e.unshift(null),n.apply(null,e)}),(function(e){e=e instanceof Error?e:new Error(e),n(e)}),"DownloadManagerPlugin",e,t||[])}function s(){}e.exports=new i,i.prototype.enqueue=function(e,t){"string"==typeof e&&(e={uri:e}),e.url&&(e.uri=e.url),r("string"==typeof e.uri,"req.uri must be string"),r(null==t||"function"==typeof t,"cb must be function"),r(null==e.title||"string"==typeof e.title,"req.title must be string"),r(null==e.description||"string"==typeof e.description,"req.description must be string"),r(null==e.mimeType||"string"==typeof e.mimeType,"req.mimeType must be string"),r(null==e.destinationInExternalFilesDir||"string"==typeof e.destinationInExternalFilesDir.dirType,"req.destinationInExternalFilesDir.dirType must be string"),r(null==e.destinationInExternalFilesDir||"string"==typeof e.destinationInExternalFilesDir.subPath,"req.destinationInExternalFilesDir.subPath must be string"),r(null==e.destinationInExternalPublicDir||"string"==typeof e.destinationInExternalPublicDir.dirType,"req.destinationInExternalPublicDir.dirType must be string"),r(null==e.destinationInExternalPublicDir||"string"==typeof e.destinationInExternalPublicDir.subPath,"req.destinationInExternalPublicDir.subPath must be string"),r(null==e.destinationUri||"string"==typeof e.destinationUri,"req.destinationUri must be string"),r(null==e.visibleInDownloadsUi||"boolean"==typeof e.visibleInDownloadsUi,"req.visibleInDownloadsUi must be boolean"),r(null==e.notificationVisibility||Number.isSafeInteger(e.notificationVisibility),"req.notificationVisibility must be safe integer"),o("enqueue",[e],t)},i.prototype.query=function(e,t){"function"==typeof e&&(t=e,e=null),null==e&&(e={}),r("function"==typeof t,"cb must be function"),o("query",[e],t)},i.prototype.remove=function(e,t){r(Array.isArray(e),"ids must be array"),r(null==t||"function"==typeof t,"cb must be function"),o("remove",e,t)},i.prototype.addCompletedDownload=function(e,t){o("addCompletedDownload",[e],t)},i.prototype.fetchSpeedLog=function(e){o("fetchSpeedLog",[],e)}},function(e,t,n){"use strict";(function(e){var t="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==e&&e||{},n="URLSearchParams"in t,r="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(e){return!1}}(),o="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(e){return e&&a.indexOf(Object.prototype.toString.call(e))>-1};function u(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function d(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r&&(t[Symbol.iterator]=function(){return t}),t}function h(e){this.map={},e instanceof h?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){if(2!=e.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function E(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function f(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function p(e){var t=new FileReader,n=f(t);return t.readAsArrayBuffer(e),n}function _(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function O(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:i&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:o&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:n&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():s&&i&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=_(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(e)||c(e))?this._bodyArrayBuffer=_(e):this._bodyText=e=Object.prototype.toString.call(e):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var e=E(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=E(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(i)return this.blob().then(p);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e,t,n,r,i,o=E(this);if(o)return o;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=f(t),r=/charset=([A-Za-z0-9_-]+)/.exec(e.type),i=r?r[1]:"utf-8",t.readAsText(e,i),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(A)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(e,t){e=u(e),t=l(t);var n=this.map[e];this.map[e]=n?n+", "+t:t},h.prototype.delete=function(e){delete this.map[u(e)]},h.prototype.get=function(e){return e=u(e),this.has(e)?this.map[e]:null},h.prototype.has=function(e){return this.map.hasOwnProperty(u(e))},h.prototype.set=function(e,t){this.map[u(e)]=l(t)},h.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},h.prototype.keys=function(){var e=[];return this.forEach((function(t,n){e.push(n)})),d(e)},h.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),d(e)},h.prototype.entries=function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),d(e)},r&&(h.prototype[Symbol.iterator]=h.prototype.entries);var S=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function g(e,n){if(!(this instanceof g))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,i,o=(n=n||{}).body;if(e instanceof g){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,n.headers||(this.headers=new h(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,o||null==e._bodyInit||(o=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=n.credentials||this.credentials||"same-origin",!n.headers&&this.headers||(this.headers=new h(n.headers)),this.method=(r=n.method||this.method||"GET",i=r.toUpperCase(),S.indexOf(i)>-1?i:r),this.mode=n.mode||this.mode||null,this.signal=n.signal||this.signal||function(){if("AbortController"in t)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(o),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==n.cache&&"no-cache"!==n.cache)){var s=/([?&])_=[^&]*/;if(s.test(this.url))this.url=this.url.replace(s,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function A(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(i))}})),t}function N(e,t){if(!(this instanceof N))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new h(t.headers),this.url=t.url||"",this._initBody(e)}g.prototype.clone=function(){return new g(this,{body:this._bodyInit})},O.call(g.prototype),O.call(N.prototype),N.prototype.clone=function(){return new N(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},N.error=function(){var e=new N(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var T=[301,302,303,307,308];N.redirect=function(e,t){if(-1===T.indexOf(t))throw new RangeError("Invalid status code");return new N(null,{status:t,headers:{location:e}})};var C=t.DOMException;try{new C}catch(e){(C=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),C.prototype.constructor=C}function v(e,n){return new Promise((function(r,o){var a=new g(e,n);if(a.signal&&a.signal.aborted)return o(new C("Aborted","AbortError"));var c=new XMLHttpRequest;function d(){c.abort()}if(c.onload=function(){var e,t,n={statusText:c.statusText,headers:(e=c.getAllResponseHeaders()||"",t=new h,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();try{t.append(r,i)}catch(e){console.warn("Response "+e.message)}}})),t)};0===a.url.indexOf("file://")&&(c.status<200||c.status>599)?n.status=200:n.status=c.status,n.url="responseURL"in c?c.responseURL:n.headers.get("X-Request-URL");var i="response"in c?c.response:c.responseText;setTimeout((function(){r(new N(i,n))}),0)},c.onerror=function(){setTimeout((function(){o(new TypeError("Network request failed"))}),0)},c.ontimeout=function(){setTimeout((function(){o(new TypeError("Network request timed out"))}),0)},c.onabort=function(){setTimeout((function(){o(new C("Aborted","AbortError"))}),0)},c.open(a.method,function(e){try{return""===e&&t.location.href?t.location.href:e}catch(t){return e}}(a.url),!0),"include"===a.credentials?c.withCredentials=!0:"omit"===a.credentials&&(c.withCredentials=!1),"responseType"in c&&(i?c.responseType="blob":s&&(c.responseType="arraybuffer")),n&&"object"==typeof n.headers&&!(n.headers instanceof h||t.Headers&&n.headers instanceof t.Headers)){var E=[];Object.getOwnPropertyNames(n.headers).forEach((function(e){E.push(u(e)),c.setRequestHeader(e,l(n.headers[e]))})),a.headers.forEach((function(e,t){-1===E.indexOf(t)&&c.setRequestHeader(t,e)}))}else a.headers.forEach((function(e,t){c.setRequestHeader(t,e)}));a.signal&&(a.signal.addEventListener("abort",d),c.onreadystatechange=function(){4===c.readyState&&a.signal.removeEventListener("abort",d)}),c.send(void 0===a._bodyInit?null:a._bodyInit)}))}v.polyfill=!0,t.fetch||(t.fetch=v,t.Headers=h,t.Request=g,t.Response=N)}).call(this,n(34))},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},o=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.Container=void 0;var s=n(54),a=n(8),c=n(13),u=n(5),l=n(35),d=n(55),h=n(62),E=n(64),f=n(19),p=n(23),_=n(67),O=n(68),S=function(){function e(e){this._appliedMiddleware=[];var t=e||{};if("object"!=typeof t)throw new Error(""+a.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT);if(void 0===t.defaultScope)t.defaultScope=c.BindingScopeEnum.Transient;else if(t.defaultScope!==c.BindingScopeEnum.Singleton&&t.defaultScope!==c.BindingScopeEnum.Transient&&t.defaultScope!==c.BindingScopeEnum.Request)throw new Error(""+a.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE);if(void 0===t.autoBindInjectable)t.autoBindInjectable=!1;else if("boolean"!=typeof t.autoBindInjectable)throw new Error(""+a.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE);if(void 0===t.skipBaseClassChecks)t.skipBaseClassChecks=!1;else if("boolean"!=typeof t.skipBaseClassChecks)throw new Error(""+a.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK);this.options={autoBindInjectable:t.autoBindInjectable,defaultScope:t.defaultScope,skipBaseClassChecks:t.skipBaseClassChecks},this.id=f.id(),this._bindingDictionary=new O.Lookup,this._snapshots=[],this._middleware=null,this.parent=null,this._metadataReader=new l.MetadataReader}return e.merge=function(t,n){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];var s=new e,a=o([t,n],r).map((function(e){return d.getBindingDictionary(e)})),c=d.getBindingDictionary(s);function u(e,t){e.traverse((function(e,n){n.forEach((function(e){t.add(e.serviceIdentifier,e.clone())}))}))}return a.forEach((function(e){u(e,c)})),s},e.prototype.load=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=this._getContainerModuleHelpersFactory(),r=0,i=e;r<i.length;r++){var o=i[r],s=n(o.id);o.registry(s.bindFunction,s.unbindFunction,s.isboundFunction,s.rebindFunction)}},e.prototype.loadAsync=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r(this,void 0,void 0,(function(){var t,n,r,o,s;return i(this,(function(i){switch(i.label){case 0:t=this._getContainerModuleHelpersFactory(),n=0,r=e,i.label=1;case 1:return n<r.length?(o=r[n],s=t(o.id),[4,o.registry(s.bindFunction,s.unbindFunction,s.isboundFunction,s.rebindFunction)]):[3,4];case 2:i.sent(),i.label=3;case 3:return n++,[3,1];case 4:return[2]}}))}))},e.prototype.unload=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=function(e){return function(t){return t.moduleId===e}};t.forEach((function(t){var n=r(t.id);e._bindingDictionary.removeByCondition(n)}))},e.prototype.bind=function(e){var t=this.options.defaultScope||c.BindingScopeEnum.Transient,n=new s.Binding(e,t);return this._bindingDictionary.add(e,n),new E.BindingToSyntax(n)},e.prototype.rebind=function(e){return this.unbind(e),this.bind(e)},e.prototype.unbind=function(e){try{this._bindingDictionary.remove(e)}catch(t){throw new Error(a.CANNOT_UNBIND+" "+p.getServiceIdentifierAsString(e))}},e.prototype.unbindAll=function(){this._bindingDictionary=new O.Lookup},e.prototype.isBound=function(e){var t=this._bindingDictionary.hasKey(e);return!t&&this.parent&&(t=this.parent.isBound(e)),t},e.prototype.isBoundNamed=function(e,t){return this.isBoundTagged(e,u.NAMED_TAG,t)},e.prototype.isBoundTagged=function(e,t,n){var r=!1;if(this._bindingDictionary.hasKey(e)){var i=this._bindingDictionary.get(e),o=d.createMockRequest(this,e,t,n);r=i.some((function(e){return e.constraint(o)}))}return!r&&this.parent&&(r=this.parent.isBoundTagged(e,t,n)),r},e.prototype.snapshot=function(){this._snapshots.push(_.ContainerSnapshot.of(this._bindingDictionary.clone(),this._middleware))},e.prototype.restore=function(){var e=this._snapshots.pop();if(void 0===e)throw new Error(a.NO_MORE_SNAPSHOTS_AVAILABLE);this._bindingDictionary=e.bindings,this._middleware=e.middleware},e.prototype.createChild=function(t){var n=new e(t||this.options);return n.parent=this,n},e.prototype.applyMiddleware=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._appliedMiddleware=this._appliedMiddleware.concat(e);var n=this._middleware?this._middleware:this._planAndResolve();this._middleware=e.reduce((function(e,t){return t(e)}),n)},e.prototype.applyCustomMetadataReader=function(e){this._metadataReader=e},e.prototype.get=function(e){return this._get(!1,!1,c.TargetTypeEnum.Variable,e)},e.prototype.getTagged=function(e,t,n){return this._get(!1,!1,c.TargetTypeEnum.Variable,e,t,n)},e.prototype.getNamed=function(e,t){return this.getTagged(e,u.NAMED_TAG,t)},e.prototype.getAll=function(e){return this._get(!0,!0,c.TargetTypeEnum.Variable,e)},e.prototype.getAllTagged=function(e,t,n){return this._get(!1,!0,c.TargetTypeEnum.Variable,e,t,n)},e.prototype.getAllNamed=function(e,t){return this.getAllTagged(e,u.NAMED_TAG,t)},e.prototype.resolve=function(e){var t=this.createChild();return t.bind(e).toSelf(),this._appliedMiddleware.forEach((function(e){t.applyMiddleware(e)})),t.get(e)},e.prototype._getContainerModuleHelpersFactory=function(){var e=this,t=function(e,t){e._binding.moduleId=t},n=function(n){return function(r){var i=e.rebind.bind(e)(r);return t(i,n),i}};return function(r){return{bindFunction:(i=r,function(n){var r=e.bind.bind(e)(n);return t(r,i),r}),isboundFunction:function(t){return e.isBound.bind(e)(t)},rebindFunction:n(r),unbindFunction:function(t){e.unbind.bind(e)(t)}};var i}},e.prototype._get=function(e,t,n,r,i,o){var s=null,c={avoidConstraints:e,contextInterceptor:function(e){return e},isMultiInject:t,key:i,serviceIdentifier:r,targetType:n,value:o};if(this._middleware){if(null==(s=this._middleware(c)))throw new Error(a.INVALID_MIDDLEWARE_RETURN)}else s=this._planAndResolve()(c);return s},e.prototype._planAndResolve=function(){var e=this;return function(t){var n=d.plan(e._metadataReader,e,t.isMultiInject,t.targetType,t.serviceIdentifier,t.key,t.value,t.avoidConstraints);return n=t.contextInterceptor(n),h.resolve(n)}},e}();t.Container=S},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Binding=void 0;var r=n(13),i=n(19),o=function(){function e(e,t){this.id=i.id(),this.activated=!1,this.serviceIdentifier=e,this.scope=t,this.type=r.BindingTypeEnum.Invalid,this.constraint=function(e){return!0},this.implementationType=null,this.cache=null,this.factory=null,this.provider=null,this.onActivation=null,this.dynamicValue=null}return e.prototype.clone=function(){var t=new e(this.serviceIdentifier,this.scope);return t.activated=t.scope===r.BindingScopeEnum.Singleton&&this.activated,t.implementationType=this.implementationType,t.dynamicValue=this.dynamicValue,t.scope=this.scope,t.type=this.type,t.factory=this.factory,t.provider=this.provider,t.constraint=this.constraint,t.onActivation=this.onActivation,t.cache=this.cache,t},e}();t.Binding=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getBindingDictionary=t.createMockRequest=t.plan=void 0;var r=n(56),i=n(8),o=n(13),s=n(5),a=n(36),c=n(23),u=n(57),l=n(10),d=n(58),h=n(59),E=n(61),f=n(38);function p(e){return e._bindingDictionary}function _(e,t,n,o,s){var a=O(n.container,s.serviceIdentifier),u=[];return a.length===r.BindingCount.NoBindingsAvailable&&n.container.options.autoBindInjectable&&"function"==typeof s.serviceIdentifier&&e.getConstructorMetadata(s.serviceIdentifier).compilerGeneratedMetadata&&(n.container.bind(s.serviceIdentifier).toSelf(),a=O(n.container,s.serviceIdentifier)),u=t?a:a.filter((function(e){var t=new E.Request(e.serviceIdentifier,n,o,e,s);return e.constraint(t)})),function(e,t,n,o){switch(t.length){case r.BindingCount.NoBindingsAvailable:if(n.isOptional())return t;var s=c.getServiceIdentifierAsString(e),a=i.NOT_REGISTERED;throw a+=c.listMetadataForTarget(s,n),a+=c.listRegisteredBindingsForServiceIdentifier(o,s,O),new Error(a);case r.BindingCount.OnlyOneBindingAvailable:if(!n.isArray())return t;case r.BindingCount.MultipleBindingsAvailable:default:if(n.isArray())return t;s=c.getServiceIdentifierAsString(e),a=i.AMBIGUOUS_MATCH+" "+s;throw a+=c.listRegisteredBindingsForServiceIdentifier(o,s,O),new Error(a)}}(s.serviceIdentifier,u,s,n.container),u}function O(e,t){var n=[],r=p(e);return r.hasKey(t)?n=r.get(t):null!==e.parent&&(n=O(e.parent,t)),n}t.getBindingDictionary=p,t.plan=function(e,t,n,r,p,O,S,g){void 0===g&&(g=!1);var A=new u.Context(t),N=function(e,t,n,r,i,o){var a=e?s.MULTI_INJECT_TAG:s.INJECT_TAG,c=new l.Metadata(a,n),u=new f.Target(t,r,n,c);if(void 0!==i){var d=new l.Metadata(i,o);u.metadata.push(d)}return u}(n,r,p,"",O,S);try{return function e(t,n,r,s,a,c){var u,l;if(null===a){u=_(t,n,s,null,c),l=new E.Request(r,s,null,u,c);var f=new d.Plan(s,l);s.addPlan(f)}else u=_(t,n,s,a,c),l=a.addChildRequest(c.serviceIdentifier,u,c);u.forEach((function(n){var r=null;if(c.isArray())r=l.addChildRequest(n.serviceIdentifier,n,c);else{if(n.cache)return;r=l}if(n.type===o.BindingTypeEnum.Instance&&null!==n.implementationType){var a=h.getDependencies(t,n.implementationType);if(!s.container.options.skipBaseClassChecks){var u=h.getBaseClassDependencyCount(t,n.implementationType);if(a.length<u){var d=i.ARGUMENTS_LENGTH_MISMATCH(h.getFunctionName(n.implementationType));throw new Error(d)}}a.forEach((function(n){e(t,!1,n.serviceIdentifier,s,r,n)}))}}))}(e,g,p,A,null,N),A}catch(e){throw a.isStackOverflowExeption(e)&&A.plan&&c.circularDependencyToException(A.plan.rootRequest),e}},t.createMockRequest=function(e,t,n,r){var i=new f.Target(o.TargetTypeEnum.Variable,"",t,new l.Metadata(n,r)),s=new u.Context(e);return new E.Request(t,s,null,[],i)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingCount=void 0;t.BindingCount={MultipleBindingsAvailable:2,NoBindingsAvailable:0,OnlyOneBindingAvailable:1}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Context=void 0;var r=n(19),i=function(){function e(e){this.id=r.id(),this.container=e}return e.prototype.addPlan=function(e){this.plan=e},e.prototype.setCurrentRequest=function(e){this.currentRequest=e},e}();t.Context=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Plan=void 0;var r=function(e,t){this.parentContext=e,this.rootRequest=t};t.Plan=r},function(e,t,n){"use strict";var r=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.getFunctionName=t.getBaseClassDependencyCount=t.getDependencies=void 0;var i=n(37),o=n(8),s=n(13),a=n(5),c=n(23);Object.defineProperty(t,"getFunctionName",{enumerable:!0,get:function(){return c.getFunctionName}});var u=n(38);function l(e,t,n,i){var a=e.getConstructorMetadata(n),c=a.compilerGeneratedMetadata;if(void 0===c){var l=o.MISSING_INJECTABLE_ANNOTATION+" "+t+".";throw new Error(l)}var E=a.userGeneratedMetadata,f=Object.keys(E),p=0===n.length&&f.length>0,_=f.length>n.length,O=function(e,t,n,r,i){for(var o=[],s=0;s<i;s++){var a=d(s,e,t,n,r);null!==a&&o.push(a)}return o}(i,t,c,E,p||_?f.length:n.length),S=function e(t,n){for(var i=t.getPropertiesMetadata(n),o=[],a=Object.keys(i),c=0,l=a;c<l.length;c++){var d=l[c],E=i[d],f=h(i[d]),p=f.targetName||d,_=f.inject||f.multiInject,O=new u.Target(s.TargetTypeEnum.ClassProperty,p,_);O.metadata=E,o.push(O)}var S=Object.getPrototypeOf(n.prototype).constructor;if(S!==Object){var g=e(t,S);o=r(r([],o),g)}return o}(e,n);return r(r([],O),S)}function d(e,t,n,r,a){var c=a[e.toString()]||[],l=h(c),d=!0!==l.unmanaged,E=r[e],f=l.inject||l.multiInject;if((E=f||E)instanceof i.LazyServiceIdentifer&&(E=E.unwrap()),d){if(!t&&(E===Object||E===Function||void 0===E)){var p=o.MISSING_INJECT_ANNOTATION+" argument "+e+" in class "+n+".";throw new Error(p)}var _=new u.Target(s.TargetTypeEnum.ConstructorArgument,l.targetName,E);return _.metadata=c,_}return null}function h(e){var t={};return e.forEach((function(e){t[e.key.toString()]=e.value})),{inject:t[a.INJECT_TAG],multiInject:t[a.MULTI_INJECT_TAG],targetName:t[a.NAME_TAG],unmanaged:t[a.UNMANAGED_TAG]}}t.getDependencies=function(e,t){return l(e,c.getFunctionName(t),t,!1)},t.getBaseClassDependencyCount=function e(t,n){var r=Object.getPrototypeOf(n.prototype).constructor;if(r!==Object){var i=l(t,c.getFunctionName(r),r,!0),o=i.map((function(e){return e.metadata.filter((function(e){return e.key===a.UNMANAGED_TAG}))})),s=[].concat.apply([],o).length,u=i.length-s;return u>0?u:e(t,r)}return 0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.QueryableString=void 0;var r=function(){function e(e){this.str=e}return e.prototype.startsWith=function(e){return 0===this.str.indexOf(e)},e.prototype.endsWith=function(e){var t,n=e.split("").reverse().join("");return t=this.str.split("").reverse().join(""),this.startsWith.call({str:t},n)},e.prototype.contains=function(e){return-1!==this.str.indexOf(e)},e.prototype.equals=function(e){return this.str===e},e.prototype.value=function(){return this.str},e}();t.QueryableString=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Request=void 0;var r=n(19),i=function(){function e(e,t,n,i,o){this.id=r.id(),this.serviceIdentifier=e,this.parentContext=t,this.parentRequest=n,this.target=o,this.childRequests=[],this.bindings=Array.isArray(i)?i:[i],this.requestScope=null===n?new Map:null}return e.prototype.addChildRequest=function(t,n,r){var i=new e(t,this.parentContext,this,n,r);return this.childRequests.push(i),i},e}();t.Request=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolve=void 0;var r=n(8),i=n(13),o=n(36),s=n(23),a=n(63),c=function(e,t,n){try{return n()}catch(n){throw o.isStackOverflowExeption(n)?new Error(r.CIRCULAR_DEPENDENCY_IN_FACTORY(e,t.toString())):n}},u=function(e){return function(t){t.parentContext.setCurrentRequest(t);var n=t.bindings,o=t.childRequests,l=t.target&&t.target.isArray(),d=!(t.parentRequest&&t.parentRequest.target&&t.target&&t.parentRequest.target.matchesArray(t.target.serviceIdentifier));if(l&&d)return o.map((function(t){return u(e)(t)}));var h=null;if(!t.target.isOptional()||0!==n.length){var E=n[0],f=E.scope===i.BindingScopeEnum.Singleton,p=E.scope===i.BindingScopeEnum.Request;if(f&&E.activated)return E.cache;if(p&&null!==e&&e.has(E.id))return e.get(E.id);if(E.type===i.BindingTypeEnum.ConstantValue)h=E.cache,E.activated=!0;else if(E.type===i.BindingTypeEnum.Function)h=E.cache,E.activated=!0;else if(E.type===i.BindingTypeEnum.Constructor)h=E.implementationType;else if(E.type===i.BindingTypeEnum.DynamicValue&&null!==E.dynamicValue)h=c("toDynamicValue",E.serviceIdentifier,(function(){return E.dynamicValue(t.parentContext)}));else if(E.type===i.BindingTypeEnum.Factory&&null!==E.factory)h=c("toFactory",E.serviceIdentifier,(function(){return E.factory(t.parentContext)}));else if(E.type===i.BindingTypeEnum.Provider&&null!==E.provider)h=c("toProvider",E.serviceIdentifier,(function(){return E.provider(t.parentContext)}));else{if(E.type!==i.BindingTypeEnum.Instance||null===E.implementationType){var _=s.getServiceIdentifierAsString(t.serviceIdentifier);throw new Error(r.INVALID_BINDING_TYPE+" "+_)}h=a.resolveInstance(E.implementationType,o,u(e))}return"function"==typeof E.onActivation&&(h=E.onActivation(t.parentContext,h)),f&&(E.cache=h,E.activated=!0),p&&null!==e&&!e.has(E.id)&&e.set(E.id,h),h}}};t.resolve=function(e){return u(e.plan.rootRequest.requestScope)(e.plan.rootRequest)}},function(e,t,n){"use strict";var r=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveInstance=void 0;var i=n(8),o=n(13),s=n(5);t.resolveInstance=function(e,t,n){var a,c,u=null;if(t.length>0){var l=t.filter((function(e){return null!==e.target&&e.target.type===o.TargetTypeEnum.ConstructorArgument})).map(n);c=l,u=function(e,t,n){var r=t.filter((function(e){return null!==e.target&&e.target.type===o.TargetTypeEnum.ClassProperty})),i=r.map(n);return r.forEach((function(t,n){var r;r=t.target.name.value();var o=i[n];e[r]=o})),e}(u=new((a=e).bind.apply(a,r([void 0],c))),t,n)}else u=new e;return function(e,t){if(Reflect.hasMetadata(s.POST_CONSTRUCT,e)){var n=Reflect.getMetadata(s.POST_CONSTRUCT,e);try{t[n.value]()}catch(t){throw new Error(i.POST_CONSTRUCT_ERROR(e.name,t.message))}}}(e,u),u}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingToSyntax=void 0;var r=n(8),i=n(13),o=n(65),s=n(39),a=function(){function e(e){this._binding=e}return e.prototype.to=function(e){return this._binding.type=i.BindingTypeEnum.Instance,this._binding.implementationType=e,new o.BindingInWhenOnSyntax(this._binding)},e.prototype.toSelf=function(){if("function"!=typeof this._binding.serviceIdentifier)throw new Error(""+r.INVALID_TO_SELF_VALUE);var e=this._binding.serviceIdentifier;return this.to(e)},e.prototype.toConstantValue=function(e){return this._binding.type=i.BindingTypeEnum.ConstantValue,this._binding.cache=e,this._binding.dynamicValue=null,this._binding.implementationType=null,this._binding.scope=i.BindingScopeEnum.Singleton,new s.BindingWhenOnSyntax(this._binding)},e.prototype.toDynamicValue=function(e){return this._binding.type=i.BindingTypeEnum.DynamicValue,this._binding.cache=null,this._binding.dynamicValue=e,this._binding.implementationType=null,new o.BindingInWhenOnSyntax(this._binding)},e.prototype.toConstructor=function(e){return this._binding.type=i.BindingTypeEnum.Constructor,this._binding.implementationType=e,this._binding.scope=i.BindingScopeEnum.Singleton,new s.BindingWhenOnSyntax(this._binding)},e.prototype.toFactory=function(e){return this._binding.type=i.BindingTypeEnum.Factory,this._binding.factory=e,this._binding.scope=i.BindingScopeEnum.Singleton,new s.BindingWhenOnSyntax(this._binding)},e.prototype.toFunction=function(e){if("function"!=typeof e)throw new Error(r.INVALID_FUNCTION_BINDING);var t=this.toConstantValue(e);return this._binding.type=i.BindingTypeEnum.Function,this._binding.scope=i.BindingScopeEnum.Singleton,t},e.prototype.toAutoFactory=function(e){return this._binding.type=i.BindingTypeEnum.Factory,this._binding.factory=function(t){return function(){return t.container.get(e)}},this._binding.scope=i.BindingScopeEnum.Singleton,new s.BindingWhenOnSyntax(this._binding)},e.prototype.toProvider=function(e){return this._binding.type=i.BindingTypeEnum.Provider,this._binding.provider=e,this._binding.scope=i.BindingScopeEnum.Singleton,new s.BindingWhenOnSyntax(this._binding)},e.prototype.toService=function(e){this.toDynamicValue((function(t){return t.container.get(e)}))},e}();t.BindingToSyntax=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingInWhenOnSyntax=void 0;var r=n(66),i=n(27),o=n(28),s=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new o.BindingWhenSyntax(this._binding),this._bindingOnSyntax=new i.BindingOnSyntax(this._binding),this._bindingInSyntax=new r.BindingInSyntax(e)}return e.prototype.inRequestScope=function(){return this._bindingInSyntax.inRequestScope()},e.prototype.inSingletonScope=function(){return this._bindingInSyntax.inSingletonScope()},e.prototype.inTransientScope=function(){return this._bindingInSyntax.inTransientScope()},e.prototype.when=function(e){return this._bindingWhenSyntax.when(e)},e.prototype.whenTargetNamed=function(e){return this._bindingWhenSyntax.whenTargetNamed(e)},e.prototype.whenTargetIsDefault=function(){return this._bindingWhenSyntax.whenTargetIsDefault()},e.prototype.whenTargetTagged=function(e,t){return this._bindingWhenSyntax.whenTargetTagged(e,t)},e.prototype.whenInjectedInto=function(e){return this._bindingWhenSyntax.whenInjectedInto(e)},e.prototype.whenParentNamed=function(e){return this._bindingWhenSyntax.whenParentNamed(e)},e.prototype.whenParentTagged=function(e,t){return this._bindingWhenSyntax.whenParentTagged(e,t)},e.prototype.whenAnyAncestorIs=function(e){return this._bindingWhenSyntax.whenAnyAncestorIs(e)},e.prototype.whenNoAncestorIs=function(e){return this._bindingWhenSyntax.whenNoAncestorIs(e)},e.prototype.whenAnyAncestorNamed=function(e){return this._bindingWhenSyntax.whenAnyAncestorNamed(e)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenAnyAncestorTagged(e,t)},e.prototype.whenNoAncestorNamed=function(e){return this._bindingWhenSyntax.whenNoAncestorNamed(e)},e.prototype.whenNoAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenNoAncestorTagged(e,t)},e.prototype.whenAnyAncestorMatches=function(e){return this._bindingWhenSyntax.whenAnyAncestorMatches(e)},e.prototype.whenNoAncestorMatches=function(e){return this._bindingWhenSyntax.whenNoAncestorMatches(e)},e.prototype.onActivation=function(e){return this._bindingOnSyntax.onActivation(e)},e}();t.BindingInWhenOnSyntax=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BindingInSyntax=void 0;var r=n(13),i=n(39),o=function(){function e(e){this._binding=e}return e.prototype.inRequestScope=function(){return this._binding.scope=r.BindingScopeEnum.Request,new i.BindingWhenOnSyntax(this._binding)},e.prototype.inSingletonScope=function(){return this._binding.scope=r.BindingScopeEnum.Singleton,new i.BindingWhenOnSyntax(this._binding)},e.prototype.inTransientScope=function(){return this._binding.scope=r.BindingScopeEnum.Transient,new i.BindingWhenOnSyntax(this._binding)},e}();t.BindingInSyntax=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ContainerSnapshot=void 0;var r=function(){function e(){}return e.of=function(t,n){var r=new e;return r.bindings=t,r.middleware=n,r},e}();t.ContainerSnapshot=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Lookup=void 0;var r=n(8),i=function(){function e(){this._map=new Map}return e.prototype.getMap=function(){return this._map},e.prototype.add=function(e,t){if(null==e)throw new Error(r.NULL_ARGUMENT);if(null==t)throw new Error(r.NULL_ARGUMENT);var n=this._map.get(e);void 0!==n?(n.push(t),this._map.set(e,n)):this._map.set(e,[t])},e.prototype.get=function(e){if(null==e)throw new Error(r.NULL_ARGUMENT);var t=this._map.get(e);if(void 0!==t)return t;throw new Error(r.KEY_NOT_FOUND)},e.prototype.remove=function(e){if(null==e)throw new Error(r.NULL_ARGUMENT);if(!this._map.delete(e))throw new Error(r.KEY_NOT_FOUND)},e.prototype.removeByCondition=function(e){var t=this;this._map.forEach((function(n,r){var i=n.filter((function(t){return!e(t)}));i.length>0?t._map.set(r,i):t._map.delete(r)}))},e.prototype.hasKey=function(e){if(null==e)throw new Error(r.NULL_ARGUMENT);return this._map.has(e)},e.prototype.clone=function(){var t=new e;return this._map.forEach((function(e,n){e.forEach((function(e){return t.add(n,e.clone())}))})),t},e.prototype.traverse=function(e){this._map.forEach((function(t,n){e(n,t)}))},e}();t.Lookup=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncContainerModule=t.ContainerModule=void 0;var r=n(19),i=function(e){this.id=r.id(),this.registry=e};t.ContainerModule=i;var o=function(e){this.id=r.id(),this.registry=e};t.AsyncContainerModule=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.injectable=void 0;var r=n(8),i=n(5);t.injectable=function(){return function(e){if(Reflect.hasOwnMetadata(i.PARAM_TYPES,e))throw new Error(r.DUPLICATED_INJECTABLE_DECORATOR);var t=Reflect.getMetadata(i.DESIGN_PARAM_TYPES,e)||[];return Reflect.defineMetadata(i.PARAM_TYPES,t,e),e}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tagged=void 0;var r=n(10),i=n(15);t.tagged=function(e,t){return function(n,o,s){var a=new r.Metadata(e,t);"number"==typeof s?i.tagParameter(n,o,s,a):i.tagProperty(n,o,a)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.named=void 0;var r=n(5),i=n(10),o=n(15);t.named=function(e){return function(t,n,s){var a=new i.Metadata(r.NAMED_TAG,e);"number"==typeof s?o.tagParameter(t,n,s,a):o.tagProperty(t,n,a)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.optional=void 0;var r=n(5),i=n(10),o=n(15);t.optional=function(){return function(e,t,n){var s=new i.Metadata(r.OPTIONAL_TAG,!0);"number"==typeof n?o.tagParameter(e,t,n,s):o.tagProperty(e,t,s)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unmanaged=void 0;var r=n(5),i=n(10),o=n(15);t.unmanaged=function(){return function(e,t,n){var s=new i.Metadata(r.UNMANAGED_TAG,!0);o.tagParameter(e,t,n,s)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiInject=void 0;var r=n(5),i=n(10),o=n(15);t.multiInject=function(e){return function(t,n,s){var a=new i.Metadata(r.MULTI_INJECT_TAG,e);"number"==typeof s?o.tagParameter(t,n,s,a):o.tagProperty(t,n,a)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.targetName=void 0;var r=n(5),i=n(10),o=n(15);t.targetName=function(e){return function(t,n,s){var a=new i.Metadata(r.NAME_TAG,e);o.tagParameter(t,n,s,a)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.postConstruct=void 0;var r=n(8),i=n(5),o=n(10);t.postConstruct=function(){return function(e,t,n){var s=new o.Metadata(i.POST_CONSTRUCT,t);if(Reflect.hasOwnMetadata(i.POST_CONSTRUCT,e.constructor))throw new Error(r.MULTIPLE_POST_CONSTRUCT_METHODS);Reflect.defineMetadata(i.POST_CONSTRUCT,s,e.constructor)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.multiBindToService=void 0;t.multiBindToService=function(e){return function(t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return n.forEach((function(n){return e.bind(n).toService(t)}))}}}},function(e,t,n){"use strict";var r=n(80),i=n(43),o=n(31),s=Object.prototype.hasOwnProperty,a={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},c=Array.isArray,u=Array.prototype.push,l=function(e,t){u.apply(e,c(t)?t:[t])},d=Date.prototype.toISOString,h=o.default,E={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:i.encode,encodeValuesOnly:!1,format:h,formatter:o.formatters[h],indices:!1,serializeDate:function(e){return d.call(e)},skipNulls:!1,strictNullHandling:!1},f={},p=function e(t,n,o,s,a,u,d,h,p,_,O,S,g,A,N,T,C,v){for(var y,m=t,b=v,I=0,M=!1;void 0!==(b=b.get(f))&&!M;){var R=b.get(t);if(I+=1,void 0!==R){if(R===I)throw new RangeError("Cyclic object value");M=!0}void 0===b.get(f)&&(I=0)}if("function"==typeof _?m=_(n,m):m instanceof Date?m=g(m):"comma"===o&&c(m)&&(m=i.maybeMap(m,(function(e){return e instanceof Date?g(e):e}))),null===m){if(u)return p&&!T?p(n,E.encoder,C,"key",A):n;m=""}if("string"==typeof(y=m)||"number"==typeof y||"boolean"==typeof y||"symbol"==typeof y||"bigint"==typeof y||i.isBuffer(m))return p?[N(T?n:p(n,E.encoder,C,"key",A))+"="+N(p(m,E.encoder,C,"value",A))]:[N(n)+"="+N(String(m))];var L,P=[];if(void 0===m)return P;if("comma"===o&&c(m))T&&p&&(m=i.maybeMap(m,p)),L=[{value:m.length>0?m.join(",")||null:void 0}];else if(c(_))L=_;else{var D=Object.keys(m);L=O?D.sort(O):D}var w=h?n.replace(/\./g,"%2E"):n,U=s&&c(m)&&1===m.length?w+"[]":w;if(a&&c(m)&&0===m.length)return U+"[]";for(var j=0;j<L.length;++j){var F=L[j],k="object"==typeof F&&void 0!==F.value?F.value:m[F];if(!d||null!==k){var x=S&&h?F.replace(/\./g,"%2E"):F,B=c(m)?"function"==typeof o?o(U,x):U:U+(S?"."+x:"["+x+"]");v.set(t,I);var V=r();V.set(f,v),l(P,e(k,B,o,s,a,u,d,h,"comma"===o&&T&&c(m)?null:p,_,O,S,g,A,N,T,C,V))}}return P};e.exports=function(e,t){var n,i=e,u=function(e){if(!e)return E;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||E.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var n=o.default;if(void 0!==e.format){if(!s.call(o.formatters,e.format))throw new TypeError("Unknown format option provided.");n=e.format}var r,i=o.formatters[n],u=E.filter;if(("function"==typeof e.filter||c(e.filter))&&(u=e.filter),r=e.arrayFormat in a?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":E.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var l=void 0===e.allowDots?!0===e.encodeDotInKeys||E.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:E.addQueryPrefix,allowDots:l,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:E.allowEmptyArrays,arrayFormat:r,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:E.charsetSentinel,commaRoundTrip:e.commaRoundTrip,delimiter:void 0===e.delimiter?E.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:E.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:E.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:E.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:E.encodeValuesOnly,filter:u,format:n,formatter:i,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:E.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:E.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:E.strictNullHandling}}(t);"function"==typeof u.filter?i=(0,u.filter)("",i):c(u.filter)&&(n=u.filter);var d=[];if("object"!=typeof i||null===i)return"";var h=a[u.arrayFormat],f="comma"===h&&u.commaRoundTrip;n||(n=Object.keys(i)),u.sort&&n.sort(u.sort);for(var _=r(),O=0;O<n.length;++O){var S=n[O];u.skipNulls&&null===i[S]||l(d,p(i[S],S,h,f,u.allowEmptyArrays,u.strictNullHandling,u.skipNulls,u.encodeDotInKeys,u.encode?u.encoder:null,u.filter,u.sort,u.allowDots,u.serializeDate,u.format,u.formatter,u.encodeValuesOnly,u.charset,_))}var g=d.join(u.delimiter),A=!0===u.addQueryPrefix?"?":"";return u.charsetSentinel&&("iso-8859-1"===u.charset?A+="utf8=%26%2310003%3B&":A+="utf8=%E2%9C%93&"),g.length>0?A+g:""}},function(e,t,n){"use strict";var r=n(20),i=n(91),o=n(96),s=n(24),a=r("%WeakMap%",!0),c=r("%Map%",!0),u=i("WeakMap.prototype.get",!0),l=i("WeakMap.prototype.set",!0),d=i("WeakMap.prototype.has",!0),h=i("Map.prototype.get",!0),E=i("Map.prototype.set",!0),f=i("Map.prototype.has",!0),p=function(e,t){for(var n,r=e;null!==(n=r.next);r=n)if(n.key===t)return r.next=n.next,n.next=e.next,e.next=n,n};e.exports=function(){var e,t,n,r={assert:function(e){if(!r.has(e))throw new s("Side channel does not contain "+o(e))},get:function(r){if(a&&r&&("object"==typeof r||"function"==typeof r)){if(e)return u(e,r)}else if(c){if(t)return h(t,r)}else if(n)return function(e,t){var n=p(e,t);return n&&n.value}(n,r)},has:function(r){if(a&&r&&("object"==typeof r||"function"==typeof r)){if(e)return d(e,r)}else if(c){if(t)return f(t,r)}else if(n)return function(e,t){return!!p(e,t)}(n,r);return!1},set:function(r,i){a&&r&&("object"==typeof r||"function"==typeof r)?(e||(e=new a),l(e,r,i)):c?(t||(t=new c),E(t,r,i)):(n||(n={key:{},next:null}),function(e,t,n){var r=p(e,t);r?r.value=n:e.next={key:t,next:e.next,value:n}}(n,r,i))}};return r}},function(e,t,n){"use strict";e.exports=Error},function(e,t,n){"use strict";e.exports=EvalError},function(e,t,n){"use strict";e.exports=RangeError},function(e,t,n){"use strict";e.exports=ReferenceError},function(e,t,n){"use strict";e.exports=URIError},function(e,t,n){"use strict";var r="undefined"!=typeof Symbol&&Symbol,i=n(87);e.exports=function(){return"function"==typeof r&&("function"==typeof Symbol&&("symbol"==typeof r("foo")&&("symbol"==typeof Symbol("bar")&&i())))}},function(e,t,n){"use strict";e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),n=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(n))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var r=Object.getOwnPropertySymbols(e);if(1!==r.length||r[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(e,t);if(42!==i.value||!0!==i.enumerable)return!1}return!0}},function(e,t,n){"use strict";var r={__proto__:null,foo:{}},i=Object;e.exports=function(){return{__proto__:r}.foo===r.foo&&!(r instanceof i)}},function(e,t,n){"use strict";var r="Function.prototype.bind called on incompatible ",i=Object.prototype.toString,o=Math.max,s=function(e,t){for(var n=[],r=0;r<e.length;r+=1)n[r]=e[r];for(var i=0;i<t.length;i+=1)n[i+e.length]=t[i];return n},a=function(e,t){for(var n=[],r=t||0,i=0;r<e.length;r+=1,i+=1)n[i]=e[r];return n},c=function(e,t){for(var n="",r=0;r<e.length;r+=1)n+=e[r],r+1<e.length&&(n+=t);return n};e.exports=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==i.apply(t))throw new TypeError(r+t);for(var n,u=a(arguments,1),l=function(){if(this instanceof n){var r=t.apply(this,s(u,arguments));return Object(r)===r?r:this}return t.apply(e,s(u,arguments))},d=o(0,t.length-u.length),h=[],E=0;E<d;E++)h[E]="$"+E;if(n=Function("binder","return function ("+c(h,",")+"){ return binder.apply(this,arguments); }")(l),t.prototype){var f=function(){};f.prototype=t.prototype,n.prototype=new f,f.prototype=null}return n}},function(e,t,n){"use strict";var r=Function.prototype.call,i=Object.prototype.hasOwnProperty,o=n(29);e.exports=o.call(r,i)},function(e,t,n){"use strict";var r=n(20),i=n(92),o=i(r("String.prototype.indexOf"));e.exports=function(e,t){var n=r(e,!!t);return"function"==typeof n&&o(e,".prototype.")>-1?i(n):n}},function(e,t,n){"use strict";var r=n(29),i=n(20),o=n(93),s=n(24),a=i("%Function.prototype.apply%"),c=i("%Function.prototype.call%"),u=i("%Reflect.apply%",!0)||r.call(c,a),l=n(30),d=i("%Math.max%");e.exports=function(e){if("function"!=typeof e)throw new s("a function is required");var t=u(r,c,arguments);return o(t,1+d(0,e.length-(arguments.length-1)),!0)};var h=function(){return u(r,a,arguments)};l?l(e.exports,"apply",{value:h}):e.exports.apply=h},function(e,t,n){"use strict";var r=n(20),i=n(94),o=n(95)(),s=n(42),a=n(24),c=r("%Math.floor%");e.exports=function(e,t){if("function"!=typeof e)throw new a("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||c(t)!==t)throw new a("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],r=!0,u=!0;if("length"in e&&s){var l=s(e,"length");l&&!l.configurable&&(r=!1),l&&!l.writable&&(u=!1)}return(r||u||!n)&&(o?i(e,"length",t,!0,!0):i(e,"length",t)),e}},function(e,t,n){"use strict";var r=n(30),i=n(41),o=n(24),s=n(42);e.exports=function(e,t,n){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new o("`obj` must be an object or a function`");if("string"!=typeof t&&"symbol"!=typeof t)throw new o("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new o("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new o("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new o("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new o("`loose`, if provided, must be a boolean");var a=arguments.length>3?arguments[3]:null,c=arguments.length>4?arguments[4]:null,u=arguments.length>5?arguments[5]:null,l=arguments.length>6&&arguments[6],d=!!s&&s(e,t);if(r)r(e,t,{configurable:null===u&&d?d.configurable:!u,enumerable:null===a&&d?d.enumerable:!a,value:n,writable:null===c&&d?d.writable:!c});else{if(!l&&(a||c||u))throw new i("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=n}}},function(e,t,n){"use strict";var r=n(30),i=function(){return!!r};i.hasArrayLengthDefineBug=function(){if(!r)return null;try{return 1!==r([],"length",{value:1}).length}catch(e){return!0}},e.exports=i},function(e,t,n){(function(t){var r="function"==typeof Map&&Map.prototype,i=Object.getOwnPropertyDescriptor&&r?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,o=r&&i&&"function"==typeof i.get?i.get:null,s=r&&Map.prototype.forEach,a="function"==typeof Set&&Set.prototype,c=Object.getOwnPropertyDescriptor&&a?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,u=a&&c&&"function"==typeof c.get?c.get:null,l=a&&Set.prototype.forEach,d="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,h="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,E="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,f=Boolean.prototype.valueOf,p=Object.prototype.toString,_=Function.prototype.toString,O=String.prototype.match,S=String.prototype.slice,g=String.prototype.replace,A=String.prototype.toUpperCase,N=String.prototype.toLowerCase,T=RegExp.prototype.test,C=Array.prototype.concat,v=Array.prototype.join,y=Array.prototype.slice,m=Math.floor,b="function"==typeof BigInt?BigInt.prototype.valueOf:null,I=Object.getOwnPropertySymbols,M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,R="function"==typeof Symbol&&"object"==typeof Symbol.iterator,L="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===R||"symbol")?Symbol.toStringTag:null,P=Object.prototype.propertyIsEnumerable,D=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function w(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||T.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-m(-e):m(e);if(r!==e){var i=String(r),o=S.call(t,i.length+1);return g.call(i,n,"$&_")+"."+g.call(g.call(o,/([0-9]{3})/g,"$&_"),/_$/,"")}}return g.call(t,n,"$&_")}var U=n(97),j=U.custom,F=Y(j)?j:null;function k(e,t,n){var r="double"===(n.quoteStyle||t)?'"':"'";return r+e+r}function x(e){return g.call(String(e),/"/g,"&quot;")}function B(e){return!("[object Array]"!==$(e)||L&&"object"==typeof e&&L in e)}function V(e){return!("[object RegExp]"!==$(e)||L&&"object"==typeof e&&L in e)}function Y(e){if(R)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!M)return!1;try{return M.call(e),!0}catch(e){}return!1}e.exports=function e(n,r,i,a){var c=r||{};if(H(c,"quoteStyle")&&"single"!==c.quoteStyle&&"double"!==c.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(H(c,"maxStringLength")&&("number"==typeof c.maxStringLength?c.maxStringLength<0&&c.maxStringLength!==1/0:null!==c.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var p=!H(c,"customInspect")||c.customInspect;if("boolean"!=typeof p&&"symbol"!==p)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(H(c,"indent")&&null!==c.indent&&"\t"!==c.indent&&!(parseInt(c.indent,10)===c.indent&&c.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(H(c,"numericSeparator")&&"boolean"!=typeof c.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var A=c.numericSeparator;if(void 0===n)return"undefined";if(null===n)return"null";if("boolean"==typeof n)return n?"true":"false";if("string"==typeof n)return function e(t,n){if(t.length>n.maxStringLength){var r=t.length-n.maxStringLength,i="... "+r+" more character"+(r>1?"s":"");return e(S.call(t,0,n.maxStringLength),n)+i}return k(g.call(g.call(t,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,K),"single",n)}(n,c);if("number"==typeof n){if(0===n)return 1/0/n>0?"0":"-0";var T=String(n);return A?w(n,T):T}if("bigint"==typeof n){var m=String(n)+"n";return A?w(n,m):m}var I=void 0===c.depth?5:c.depth;if(void 0===i&&(i=0),i>=I&&I>0&&"object"==typeof n)return B(n)?"[Array]":"[Object]";var j=function(e,t){var n;if("\t"===e.indent)n="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;n=v.call(Array(e.indent+1)," ")}return{base:n,prev:v.call(Array(t+1),n)}}(c,i);if(void 0===a)a=[];else if(q(a,n)>=0)return"[Circular]";function G(t,n,r){if(n&&(a=y.call(a)).push(n),r){var o={depth:c.depth};return H(c,"quoteStyle")&&(o.quoteStyle=c.quoteStyle),e(t,o,i+1,a)}return e(t,c,i+1,a)}if("function"==typeof n&&!V(n)){var Z=function(e){if(e.name)return e.name;var t=O.call(_.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(n),ee=Q(n,G);return"[Function"+(Z?": "+Z:" (anonymous)")+"]"+(ee.length>0?" { "+v.call(ee,", ")+" }":"")}if(Y(n)){var te=R?g.call(String(n),/^(Symbol\(.*\))_[^)]*$/,"$1"):M.call(n);return"object"!=typeof n||R?te:z(te)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(n)){for(var ne="<"+N.call(String(n.nodeName)),re=n.attributes||[],ie=0;ie<re.length;ie++)ne+=" "+re[ie].name+"="+k(x(re[ie].value),"double",c);return ne+=">",n.childNodes&&n.childNodes.length&&(ne+="..."),ne+="</"+N.call(String(n.nodeName))+">"}if(B(n)){if(0===n.length)return"[]";var oe=Q(n,G);return j&&!function(e){for(var t=0;t<e.length;t++)if(q(e[t],"\n")>=0)return!1;return!0}(oe)?"["+J(oe,j)+"]":"[ "+v.call(oe,", ")+" ]"}if(function(e){return!("[object Error]"!==$(e)||L&&"object"==typeof e&&L in e)}(n)){var se=Q(n,G);return"cause"in Error.prototype||!("cause"in n)||P.call(n,"cause")?0===se.length?"["+String(n)+"]":"{ ["+String(n)+"] "+v.call(se,", ")+" }":"{ ["+String(n)+"] "+v.call(C.call("[cause]: "+G(n.cause),se),", ")+" }"}if("object"==typeof n&&p){if(F&&"function"==typeof n[F]&&U)return U(n,{depth:I-i});if("symbol"!==p&&"function"==typeof n.inspect)return n.inspect()}if(function(e){if(!o||!e||"object"!=typeof e)return!1;try{o.call(e);try{u.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(n)){var ae=[];return s&&s.call(n,(function(e,t){ae.push(G(t,n,!0)+" => "+G(e,n))})),X("Map",o.call(n),ae,j)}if(function(e){if(!u||!e||"object"!=typeof e)return!1;try{u.call(e);try{o.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(n)){var ce=[];return l&&l.call(n,(function(e){ce.push(G(e,n))})),X("Set",u.call(n),ce,j)}if(function(e){if(!d||!e||"object"!=typeof e)return!1;try{d.call(e,d);try{h.call(e,h)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(n))return W("WeakMap");if(function(e){if(!h||!e||"object"!=typeof e)return!1;try{h.call(e,h);try{d.call(e,d)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(n))return W("WeakSet");if(function(e){if(!E||!e||"object"!=typeof e)return!1;try{return E.call(e),!0}catch(e){}return!1}(n))return W("WeakRef");if(function(e){return!("[object Number]"!==$(e)||L&&"object"==typeof e&&L in e)}(n))return z(G(Number(n)));if(function(e){if(!e||"object"!=typeof e||!b)return!1;try{return b.call(e),!0}catch(e){}return!1}(n))return z(G(b.call(n)));if(function(e){return!("[object Boolean]"!==$(e)||L&&"object"==typeof e&&L in e)}(n))return z(f.call(n));if(function(e){return!("[object String]"!==$(e)||L&&"object"==typeof e&&L in e)}(n))return z(G(String(n)));if("undefined"!=typeof window&&n===window)return"{ [object Window] }";if("undefined"!=typeof globalThis&&n===globalThis||void 0!==t&&n===t)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==$(e)||L&&"object"==typeof e&&L in e)}(n)&&!V(n)){var ue=Q(n,G),le=D?D(n)===Object.prototype:n instanceof Object||n.constructor===Object,de=n instanceof Object?"":"null prototype",he=!le&&L&&Object(n)===n&&L in n?S.call($(n),8,-1):de?"Object":"",Ee=(le||"function"!=typeof n.constructor?"":n.constructor.name?n.constructor.name+" ":"")+(he||de?"["+v.call(C.call([],he||[],de||[]),": ")+"] ":"");return 0===ue.length?Ee+"{}":j?Ee+"{"+J(ue,j)+"}":Ee+"{ "+v.call(ue,", ")+" }"}return String(n)};var G=Object.prototype.hasOwnProperty||function(e){return e in this};function H(e,t){return G.call(e,t)}function $(e){return p.call(e)}function q(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}function K(e){var t=e.charCodeAt(0),n={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return n?"\\"+n:"\\x"+(t<16?"0":"")+A.call(t.toString(16))}function z(e){return"Object("+e+")"}function W(e){return e+" { ? }"}function X(e,t,n,r){return e+" ("+t+") {"+(r?J(n,r):v.call(n,", "))+"}"}function J(e,t){if(0===e.length)return"";var n="\n"+t.prev+t.base;return n+v.call(e,","+n)+"\n"+t.prev}function Q(e,t){var n=B(e),r=[];if(n){r.length=e.length;for(var i=0;i<e.length;i++)r[i]=H(e,i)?t(e[i],e):""}var o,s="function"==typeof I?I(e):[];if(R){o={};for(var a=0;a<s.length;a++)o["$"+s[a]]=s[a]}for(var c in e)H(e,c)&&(n&&String(Number(c))===c&&c<e.length||R&&o["$"+c]instanceof Symbol||(T.call(/[^\w$]/,c)?r.push(t(c,e)+": "+t(e[c],e)):r.push(c+": "+t(e[c],e))));if("function"==typeof I)for(var u=0;u<s.length;u++)P.call(e,s[u])&&r.push("["+t(s[u])+"]: "+t(e[s[u]],e));return r}}).call(this,n(34))},function(e,t){},function(e,t,n){"use strict";var r=n(43),i=Object.prototype.hasOwnProperty,o=Array.isArray,s={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:r.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1},a=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},c=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},u=function(e,t,n,r){if(e){var o=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,s=/(\[[^[\]]*])/g,a=n.depth>0&&/(\[[^[\]]*])/.exec(o),u=a?o.slice(0,a.index):o,l=[];if(u){if(!n.plainObjects&&i.call(Object.prototype,u)&&!n.allowPrototypes)return;l.push(u)}for(var d=0;n.depth>0&&null!==(a=s.exec(o))&&d<n.depth;){if(d+=1,!n.plainObjects&&i.call(Object.prototype,a[1].slice(1,-1))&&!n.allowPrototypes)return;l.push(a[1])}if(a){if(!0===n.strictDepth)throw new RangeError("Input depth exceeded depth option of "+n.depth+" and strictDepth is true");l.push("["+o.slice(a.index)+"]")}return function(e,t,n,r){for(var i=r?t:c(t,n),o=e.length-1;o>=0;--o){var s,a=e[o];if("[]"===a&&n.parseArrays)s=n.allowEmptyArrays&&(""===i||n.strictNullHandling&&null===i)?[]:[].concat(i);else{s=n.plainObjects?Object.create(null):{};var u="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,l=n.decodeDotInKeys?u.replace(/%2E/g,"."):u,d=parseInt(l,10);n.parseArrays||""!==l?!isNaN(d)&&a!==l&&String(d)===l&&d>=0&&n.parseArrays&&d<=n.arrayLimit?(s=[])[d]=i:"__proto__"!==l&&(s[l]=i):s={0:i}}i=s}return i}(l,t,n,r)}};e.exports=function(e,t){var n=function(e){if(!e)return s;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.decodeDotInKeys&&"boolean"!=typeof e.decodeDotInKeys)throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?s.charset:e.charset,n=void 0===e.duplicates?s.duplicates:e.duplicates;if("combine"!==n&&"first"!==n&&"last"!==n)throw new TypeError("The duplicates option must be either combine, first, or last");return{allowDots:void 0===e.allowDots?!0===e.decodeDotInKeys||s.allowDots:!!e.allowDots,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:s.allowEmptyArrays,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:s.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:s.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:s.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:s.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:s.comma,decodeDotInKeys:"boolean"==typeof e.decodeDotInKeys?e.decodeDotInKeys:s.decodeDotInKeys,decoder:"function"==typeof e.decoder?e.decoder:s.decoder,delimiter:"string"==typeof e.delimiter||r.isRegExp(e.delimiter)?e.delimiter:s.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:s.depth,duplicates:n,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:s.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:s.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:s.plainObjects,strictDepth:"boolean"==typeof e.strictDepth?!!e.strictDepth:s.strictDepth,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:s.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var l="string"==typeof e?function(e,t){var n={__proto__:null},u=t.ignoreQueryPrefix?e.replace(/^\?/,""):e;u=u.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var l,d=t.parameterLimit===1/0?void 0:t.parameterLimit,h=u.split(t.delimiter,d),E=-1,f=t.charset;if(t.charsetSentinel)for(l=0;l<h.length;++l)0===h[l].indexOf("utf8=")&&("utf8=%E2%9C%93"===h[l]?f="utf-8":"utf8=%26%2310003%3B"===h[l]&&(f="iso-8859-1"),E=l,l=h.length);for(l=0;l<h.length;++l)if(l!==E){var p,_,O=h[l],S=O.indexOf("]="),g=-1===S?O.indexOf("="):S+1;-1===g?(p=t.decoder(O,s.decoder,f,"key"),_=t.strictNullHandling?null:""):(p=t.decoder(O.slice(0,g),s.decoder,f,"key"),_=r.maybeMap(c(O.slice(g+1),t),(function(e){return t.decoder(e,s.decoder,f,"value")}))),_&&t.interpretNumericEntities&&"iso-8859-1"===f&&(_=a(_)),O.indexOf("[]=")>-1&&(_=o(_)?[_]:_);var A=i.call(n,p);A&&"combine"===t.duplicates?n[p]=r.combine(n[p],_):A&&"last"!==t.duplicates||(n[p]=_)}return n}(e,n):e,d=n.plainObjects?Object.create(null):{},h=Object.keys(l),E=0;E<h.length;++E){var f=h[E],p=u(f,l[f],n,"string"==typeof e);d=r.merge(d,p,n)}return!0===n.allowSparse?d:r.compact(d)}},function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var r=new Uint8Array(16);e.exports=function(){return n(r),r}}else{var i=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),i[t]=e>>>((3&t)<<3)&255;return i}}},function(e,t){for(var n=[],r=0;r<256;++r)n[r]=(r+256).toString(16).substr(1);e.exports=function(e,t){var r=t||0,i=n;return[i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]]].join("")}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(11),i=function(){function e(e){this.table={},this.nElements=0,this.toStr=e||r.defaultToString}return e.prototype.getValue=function(e){var t=this.table["$"+this.toStr(e)];if(!r.isUndefined(t))return t.value},e.prototype.setValue=function(e,t){if(!r.isUndefined(e)&&!r.isUndefined(t)){var n,i="$"+this.toStr(e),o=this.table[i];return r.isUndefined(o)?(this.nElements++,n=void 0):n=o.value,this.table[i]={key:e,value:t},n}},e.prototype.remove=function(e){var t="$"+this.toStr(e),n=this.table[t];if(!r.isUndefined(n))return delete this.table[t],this.nElements--,n.value},e.prototype.keys=function(){var e=[];for(var t in this.table)if(r.has(this.table,t)){var n=this.table[t];e.push(n.key)}return e},e.prototype.values=function(){var e=[];for(var t in this.table)if(r.has(this.table,t)){var n=this.table[t];e.push(n.value)}return e},e.prototype.forEach=function(e){for(var t in this.table)if(r.has(this.table,t)){var n=this.table[t];if(!1===e(n.key,n.value))return}},e.prototype.containsKey=function(e){return!r.isUndefined(this.getValue(e))},e.prototype.clear=function(){this.table={},this.nElements=0},e.prototype.size=function(){return this.nElements},e.prototype.isEmpty=function(){return this.nElements<=0},e.prototype.toString=function(){var e="{";return this.forEach((function(t,n){e+="\n\t"+t+" : "+n})),e+"\n}"},e}();t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(11),i=n(45),o=function(){function e(){this.firstNode=null,this.lastNode=null,this.nElements=0}return e.prototype.add=function(e,t){if(r.isUndefined(t)&&(t=this.nElements),t<0||t>this.nElements||r.isUndefined(e))return!1;var n=this.createNode(e);if(0===this.nElements||null===this.lastNode)this.firstNode=n,this.lastNode=n;else if(t===this.nElements)this.lastNode.next=n,this.lastNode=n;else if(0===t)n.next=this.firstNode,this.firstNode=n;else{var i=this.nodeAtIndex(t-1);if(null===i)return!1;n.next=i.next,i.next=n}return this.nElements++,!0},e.prototype.first=function(){if(null!==this.firstNode)return this.firstNode.element},e.prototype.last=function(){if(null!==this.lastNode)return this.lastNode.element},e.prototype.elementAtIndex=function(e){var t=this.nodeAtIndex(e);if(null!==t)return t.element},e.prototype.indexOf=function(e,t){var n=t||r.defaultEquals;if(r.isUndefined(e))return-1;for(var i=this.firstNode,o=0;null!==i;){if(n(i.element,e))return o;o++,i=i.next}return-1},e.prototype.contains=function(e,t){return this.indexOf(e,t)>=0},e.prototype.remove=function(e,t){var n=t||r.defaultEquals;if(this.nElements<1||r.isUndefined(e))return!1;for(var i=null,o=this.firstNode;null!==o;){if(n(o.element,e))return null===i?(this.firstNode=o.next,o===this.lastNode&&(this.lastNode=null)):o===this.lastNode?(this.lastNode=i,i.next=o.next,o.next=null):(i.next=o.next,o.next=null),this.nElements--,!0;i=o,o=o.next}return!1},e.prototype.clear=function(){this.firstNode=null,this.lastNode=null,this.nElements=0},e.prototype.equals=function(t,n){var i=n||r.defaultEquals;return t instanceof e&&(this.size()===t.size()&&this.equalsAux(this.firstNode,t.firstNode,i))},e.prototype.equalsAux=function(e,t,n){for(;null!==e&&null!==t;){if(!n(e.element,t.element))return!1;e=e.next,t=t.next}return!0},e.prototype.removeElementAtIndex=function(e){if(!(e<0||e>=this.nElements||null===this.firstNode||null===this.lastNode)){var t;if(1===this.nElements)t=this.firstNode.element,this.firstNode=null,this.lastNode=null;else{var n=this.nodeAtIndex(e-1);null===n?(t=this.firstNode.element,this.firstNode=this.firstNode.next):n.next===this.lastNode&&(t=this.lastNode.element,this.lastNode=n),null!==n&&null!==n.next&&(t=n.next.element,n.next=n.next.next)}return this.nElements--,t}},e.prototype.forEach=function(e){for(var t=this.firstNode;null!==t&&!1!==e(t.element);)t=t.next},e.prototype.reverse=function(){for(var e=null,t=this.firstNode,n=null;null!==t;)n=t.next,t.next=e,e=t,t=n;n=this.firstNode,this.firstNode=this.lastNode,this.lastNode=n},e.prototype.toArray=function(){for(var e=[],t=this.firstNode;null!==t;)e.push(t.element),t=t.next;return e},e.prototype.size=function(){return this.nElements},e.prototype.isEmpty=function(){return this.nElements<=0},e.prototype.toString=function(){return i.toString(this.toArray())},e.prototype.nodeAtIndex=function(e){if(e<0||e>=this.nElements)return null;if(e===this.nElements-1)return this.lastNode;for(var t=this.firstNode,n=0;n<e&&null!==t;n++)t=t.next;return t},e.prototype.createNode=function(e){return{element:e,next:null}},e}();t.default=o},function(e,t){function n(e,t){if(!e)throw new Error(t||"AssertionError")}n.notEqual=function(e,t,r){n(e!=t,r)},n.notOk=function(e,t){n(!e,t)},n.equal=function(e,t,r){n(e==t,r)},n.ok=n,e.exports=n},function(e,t,n){"use strict";n.r(t),n.d(t,"DbConstants",(function(){return r})),n.d(t,"Migration",(function(){return i})),n.d(t,"DbService",(function(){return o})),n.d(t,"DeviceRegisterServiceImpl",(function(){return X})),n.d(t,"HttpRequestType",(function(){return a.CsHttpRequestType})),n.d(t,"ResponseCode",(function(){return a.CsHttpResponseCode})),n.d(t,"HttpSerializer",(function(){return a.CsHttpSerializer})),n.d(t,"Request",(function(){return a.CsRequest})),n.d(t,"Response",(function(){return a.CsResponse})),n.d(t,"NetworkError",(function(){return a.CsNetworkError})),n.d(t,"HttpClientError",(function(){return a.CsHttpClientError})),n.d(t,"HttpServerError",(function(){return a.CsHttpServerError})),n.d(t,"ApiServiceImpl",(function(){return G})),n.d(t,"TelemetryDecorator",(function(){return J})),n.d(t,"Actor",(function(){return pe})),n.d(t,"Context",(function(){return _e})),n.d(t,"DeviceSpecification",(function(){return Oe})),n.d(t,"Etags",(function(){return Se})),n.d(t,"ExData",(function(){return ge})),n.d(t,"GameData",(function(){return Ae})),n.d(t,"CorrelationData",(function(){return Ne})),n.d(t,"Rollup",(function(){return Te})),n.d(t,"Visit",(function(){return Ce})),n.d(t,"ProducerData",(function(){return ve})),n.d(t,"Search",(function(){return ye})),n.d(t,"TelemetryObject",(function(){return me})),n.d(t,"ProcessedEventModel",(function(){return be})),n.d(t,"AuditState",(function(){return ue})),n.d(t,"SunbirdTelemetry",(function(){return le})),n.d(t,"ObjectType",(function(){return Q})),n.d(t,"Mode",(function(){return Z})),n.d(t,"LogType",(function(){return ee})),n.d(t,"LogLevel",(function(){return te})),n.d(t,"ShareDirection",(function(){return ne})),n.d(t,"ShareType",(function(){return re})),n.d(t,"ShareItemType",(function(){return ie})),n.d(t,"LogMessage",(function(){return Ee})),n.d(t,"InteractType",(function(){return oe})),n.d(t,"InteractSubType",(function(){return se})),n.d(t,"TelemetryErrorCode",(function(){return ae})),n.d(t,"ErrorType",(function(){return ce})),n.d(t,"TelemetryInteractRequest",(function(){return Ie})),n.d(t,"TelemetryErrorRequest",(function(){return Me})),n.d(t,"TelemetryInterruptRequest",(function(){return Re})),n.d(t,"TelemetryImpressionRequest",(function(){return Le})),n.d(t,"TelemetryStartRequest",(function(){return Pe})),n.d(t,"TelemetrySummaryRequest",(function(){return De})),n.d(t,"TelemetryEndRequest",(function(){return we})),n.d(t,"TelemetryFeedbackRequest",(function(){return Ue})),n.d(t,"TelemetryLogRequest",(function(){return je})),n.d(t,"TelemetryShareRequest",(function(){return Fe})),n.d(t,"TelemetryAutoSyncModes",(function(){return de})),n.d(t,"SignInError",(function(){return xe})),n.d(t,"AuthEventType",(function(){return he})),n.d(t,"WebviewLoginSessionProvider",(function(){return Dd})),n.d(t,"WebviewManualMergeSessionProvider",(function(){return Ud})),n.d(t,"WebviewAutoMergeSessionProvider",(function(){return Ld})),n.d(t,"WebviewRunnerError",(function(){return Ve})),n.d(t,"InterruptError",(function(){return jd})),n.d(t,"NoInappbrowserSessionAssertionFailError",(function(){return Ye})),n.d(t,"ParamNotCapturedError",(function(){return Ge})),n.d(t,"NativeGoogleSessionProvider",(function(){return kd})),n.d(t,"NativeAppleSessionProvider",(function(){return Bd})),n.d(t,"WebviewStateSessionProvider",(function(){return Yd})),n.d(t,"NativeKeycloakSessionProvider",(function(){return Hd})),n.d(t,"NativeCustomBrowserSessionProvider",(function(){return qd})),n.d(t,"CourseServiceImpl",(function(){return hi})),n.d(t,"UpdateContentStateTarget",(function(){return Ei})),n.d(t,"CourseEnrollmentType",(function(){return fi})),n.d(t,"CourseBatchStatus",(function(){return pi})),n.d(t,"CertificateAlreadyDownloaded",(function(){return _i})),n.d(t,"FrameworkServiceImpl",(function(){return co})),n.d(t,"FrameworkCategoryCode",(function(){return uo})),n.d(t,"FrameworkCategoryCodesGroup",(function(){return lo})),n.d(t,"FrameworkUtilServiceImpl",(function(){return Ao})),n.d(t,"TrackingEnabled",(function(){return Dn.TrackingEnabled})),n.d(t,"ContentDeleteStatus",(function(){return _n})),n.d(t,"SortOrder",(function(){return On})),n.d(t,"MarkerType",(function(){return Sn})),n.d(t,"SearchType",(function(){return gn})),n.d(t,"ChildContents",(function(){return An})),n.d(t,"State",(function(){return Nn})),n.d(t,"MimeType",(function(){return Tn})),n.d(t,"Visibility",(function(){return Cn})),n.d(t,"ContentStatus",(function(){return vn})),n.d(t,"ContentEncoding",(function(){return yn})),n.d(t,"ContentDisposition",(function(){return mn})),n.d(t,"FileExtension",(function(){return bn})),n.d(t,"ContentImportStatus",(function(){return In})),n.d(t,"ContentErrorCode",(function(){return Mn})),n.d(t,"ErrorCode",(function(){return Rn})),n.d(t,"FileName",(function(){return Ln})),n.d(t,"ContentEventType",(function(){return Pn})),n.d(t,"ContentMapper",(function(){return xn})),n.d(t,"UserFeedCategory",(function(){return Qn.UserFeedCategory})),n.d(t,"UserFeedStatus",(function(){return Qn.UserFeedStatus})),n.d(t,"ProfileType",(function(){return zn})),n.d(t,"ProfileSource",(function(){return Wn})),n.d(t,"ProfileSession",(function(){return Zn})),n.d(t,"ContentAccess",(function(){return er})),n.d(t,"ContentAccessStatus",(function(){return Xn})),n.d(t,"ProfileServiceImpl",(function(){return Fi})),n.d(t,"NoActiveSessionError",(function(){return ki})),n.d(t,"NoProfileFoundError",(function(){return xi})),n.d(t,"GroupMembershipType",(function(){return Kd.GroupMembershipType})),n.d(t,"GroupMemberRole",(function(){return Kd.GroupMemberRole})),n.d(t,"GroupEntityStatus",(function(){return Kd.GroupEntityStatus})),n.d(t,"GroupSessionDeprecated",(function(){return wl})),n.d(t,"NoGroupFoundError",(function(){return Ul})),n.d(t,"NoActiveGroupSessionError",(function(){return jl})),n.d(t,"PageName",(function(){return na})),n.d(t,"SunbirdSdk",(function(){return bd})),n.d(t,"EventNamespace",(function(){return M})),n.d(t,"ErrorEventType",(function(){return R})),n.d(t,"SystemSettingsServiceImpl",(function(){return ka})),n.d(t,"SummarizerServiceImpl",(function(){return wr})),n.d(t,"ContentCache",(function(){return Ur})),n.d(t,"ReportDetailPerUser",(function(){return jr})),n.d(t,"SummarizerHandler",(function(){return Fr})),n.d(t,"SummarizerQueries",(function(){return kr})),n.d(t,"SummaryTelemetryEventHandler",(function(){return Ai})),n.d(t,"CachedItemRequestSourceFrom",(function(){return Jn})),n.d(t,"StorageDestination",(function(){return Va})),n.d(t,"StorageEventType",(function(){return Ya})),n.d(t,"ExistingContentAction",(function(){return Ga})),n.d(t,"TransferFailedDuplicateContentError",(function(){return Ha})),n.d(t,"TransferFailedError",(function(){return $a})),n.d(t,"NotificationType",(function(){return hu})),n.d(t,"NotificationStatus",(function(){return Eu})),n.d(t,"CodePUshExperimentServiceImpl",(function(){return Zu})),n.d(t,"FaqServiceImpl",(function(){return il})),n.d(t,"ArchiveObjectType",(function(){return ol})),n.d(t,"ExportAssertionError",(function(){return sl})),n.d(t,"InvalidRequestError",(function(){return al})),n.d(t,"ObjectNotFoundError",(function(){return cl})),n.d(t,"FetchSegmentationTagHandler",(function(){return Xl})),n.d(t,"FetchSegmentationCommandHandler",(function(){return Jl})),n.d(t,"StoreSegmentationTagHandler",(function(){return Ql})),n.d(t,"StoreSegmentationCommandHandler",(function(){return Zl})),n.d(t,"SegmentationServiceImpl",(function(){return rd})),n.d(t,"DebuggingDurationHandler",(function(){return sd})),n.d(t,"DebuggingServiceImpl",(function(){return dd})),n.d(t,"CertificateServiceImpl",(function(){return yd})),n.d(t,"DownloadEventType",(function(){return $r})),n.d(t,"DownloadStatus",(function(){return qr})),n.d(t,"PlayerServiceImpl",(function(){return Ac})),n.d(t,"NetworkStatus",(function(){return Vn})),n.d(t,"ValidationError",(function(){return Rr}));n(52);class r{}r.DATE_TYPE="DATE",r.TEXT_TYPE="TEXT",r.INT_TYPE="INTEGER",r.REAL_TYPE="REAL",r.COMMA_SEP=",",r.SPACE=" ",r.MAX_NUM_OF_EVENTS=1e3,r.MAX_NUM_OF_PROCESSED_EVENTS=1,r.ERROR="DB_ERROR",r.BLOB_TYPE="BLOB",r.NOT_NULL="NOT NULL",r.NULL="NULL";class i{constructor(e,t){this.targetDbVersion=t,this.migrationNumber=e}required(e,t){return e<this.targetDbVersion&&this.targetDbVersion<=t}}class o{}var s=n(2),a=n(4),c=n(1);const u={HTTP_SERVICE:Symbol.for("CS_HTTP_SERVICE"),GROUP_SERVICE:Symbol.for("CS_GROUP_SERVICE"),COURSE_SERVICE:Symbol.for("CS_COURSE_SERVICE"),USER_SERVICE:Symbol.for("CS_USER_SERVICE"),DISCUSSION_SERVICE:Symbol.for("CS_DISCUSSION_SERVICE"),CONTENT_SERVICE:Symbol.for("CS_CONTENT_SERVICE"),NOTIFICATION_SERVICE_V2:Symbol.for("CS_NOTIFICATION_SERVICE"),CERTIFICATE_SERVICE:Symbol.for("CS_CERTIFICATE_SERVICE"),FRAMEWORK_SERVICE:Symbol.for("CS_FRAMEWORK_SERVICE")},l={CONTAINER:Symbol.for("CONTAINER"),DB_VERSION:Symbol.for("DB_VERSION"),DB_MIGRATION_LIST:Symbol.for("DB_MIGRATION_LIST"),SDK_CONFIG:Symbol.for("SDK_CONFIG"),DEVICE_INFO:Symbol.for("DEVICE_INFO"),SHARED_PREFERENCES:Symbol.for("SHARED_PREFERENCES"),EVENTS_BUS_SERVICE:Symbol.for("EVENTS_BUS_SERVICE"),DB_SERVICE:Symbol.for("DB_SERVICE"),APP_INFO:Symbol.for("APP_INFO"),API_SERVICE:Symbol.for("API_SERVICE"),AUTH_SERVICE:Symbol.for("AUTH_SERVICE"),FILE_SERVICE:Symbol.for("FILE_SERVICE"),SYSTEM_SETTINGS_SERVICE:Symbol.for("SYSTEM_SETTINGS_SERVICE"),FRAMEWORK_SERVICE:Symbol.for("FRAMEWORK_SERVICE"),PROFILE_SERVICE:Symbol.for("PROFILE_SERVICE"),GROUP_SERVICE:Symbol.for("GROUP_SERVICE"),GROUP_SERVICE_DEPRECATED:Symbol.for("GROUP_SERVICE_DEPRECATED"),ZIP_SERVICE:Symbol.for("ZIP_SERVICE"),TELEMETRY_SERVICE:Symbol.for("TELEMETRY_SERVICE"),CONTENT_FEEDBACK_SERVICE:Symbol.for("CONTENT_FEEDBACK_SERVICE"),FORM_SERVICE:Symbol.for("FORM_SERVICE"),PAGE_ASSEMBLE_SERVICE:Symbol.for("PAGE_ASSEMBLE_SERVICE"),FRAMEWORK_UTIL_SERVICE:Symbol.for("FRAMEWORK_UTIL_SERVICE"),DOWNLOAD_SERVICE:Symbol.for("DOWNLOAD_SERVICE"),CONTENT_SERVICE:Symbol.for("CONTENT_SERVICE"),COURSE_SERVICE:Symbol.for("COURSE_SERVICE"),SUMMARIZER_SERVICE:Symbol.for("SUMMARIZER_SERVICE"),PLAYER_SERVICE:Symbol.for("PLAYER_SERVICE"),CACHED_ITEM_STORE:Symbol.for("CACHED_ITEM_STORE"),KEY_VALUE_STORE:Symbol.for("KEY_VALUE_STORE"),TELEMETRY_DECORATOR:Symbol.for("TELEMETRY_DECORATOR"),STORAGE_SERVICE:Symbol.for("STORAGE_SERVICE"),NOTIFICATION_SERVICE:Symbol.for("NOTIFICATION_SERVICE"),ERROR_LOGGER_SERVICE:Symbol.for("ERROR_LOGGER_SERVICE"),NETWORKINFO_SERVICE:Symbol.for("NETWORKINFO_SERVICE"),SEARCH_HISTORY_SERVICE:Symbol.for("SEARCH_HISTORY_SERVICE"),CODEPUSH_EXPERIMENT_SERVICE:Symbol.for("CODEPUSH_EXPERIMENT_SERVICE"),FAQ_SERVICE:Symbol.for("FAQ_SERVICE"),DEVICE_REGISTER_SERVICE:Symbol.for("DEVICE_REGISTER_SERVICE"),CONTENT_RATING_SERVICE:Symbol.for("CONTENT_RATING_SERVICE"),ARCHIVE_SERVICE:Symbol.for("ARCHIVE_SERVICE"),NETWORK_QUEUE:Symbol.for("NETWORK_QUEUE"),CLASS_ROOM_SERVICE:Symbol.for("CLASS_ROOM_SERVICE"),DISCUSSION_SERVICE:Symbol.for("DISCUSSION_SERVICE"),SEGMENTATION_SERVICE:Symbol.for("SEGMENTATION_SERVICE"),DEBUGGING_SERVICE:Symbol.for("DEBUGGING_SERVICE"),NOTIFICATION_SERVICE_V2:Symbol.for("NOTIFICATION_SERVICE_V2"),CERTIFICATE_SERVICE:Symbol.for("CERTIFICATE_SERVICE")};var d,h,E,f,p,_,O,S,g,A,N,T,C,v,y;!function(e){e.KEY_FIRST_ACCESS_TIMESTAMP="first_access_timestamp"}(d||(d={})),function(e){e.KEY_API_TOKEN="api_bearer_token_v2"}(h||(h={})),function(e){e.KEY_OAUTH_SESSION="oauth_token"}(E||(E={})),function(e){e.KEY_GROUP_SESSION="group_session"}(f||(f={})),function(e){e.KEY_USER_SESSION="session"}(p||(p={})),function(e){e.KEY_ACTIVE_CHANNEL_ID="channelId",e.KEY_ACTIVE_CHANNEL_ACTIVE_FRAMEWORK_ID="sunbirdcurrent_framework_id"}(_||(_={})),function(e){e.KEY_TO_DOWNLOAD_LIST="to_download_list"}(O||(O={})),function(e){e.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL="is_update_size_on_device_successful",e.KEY_CONTENT_DELETE_REQUEST_LIST="content_delete_request_list",e.KEY_LAST_MODIFIED="last_modified",e.UPDATE_CONTENT_STATE="update_content_state",e.COURSE_CONTEXT="sunbirdcontent_context"}(S||(S={})),function(e){e.KEY_STORAGE_DESTINATION="storage_destination",e.KEY_TO_TRANSFER_LIST="to_transfer_list"}(g||(g={})),function(e){e.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP="error_log_last_synced_time_stamp"}(A||(A={})),function(e){e.DEPLOYMENT_KEY="deployment_key"}(N||(N={})),function(e){e.DEFAULT_DEPLOYMENT_KEY="default_deployment_key",e.EXPERIMENT_KEY="experiment_key",e.EXPERIMENT_APP_VERSION="emperiment_app_version"}(T||(T={})),function(e){e.DEVICE_LOCATION="device_location_new"}(C||(C={})),function(e){e.KEY_LAST_SYNCED_TIME_STAMP="telemetry_last_synced_time_stamp",e.KEY_AUTO_SYNC_MODE="telemetry_auto_sync_mode"}(v||(v={})),function(e){e.KEY_ORGANISATION_ID="page_assemble_organisation_id"}(y||(y={}));var m=n(6),b=n.n(m);class I{static decodeJWT(e){return new Promise((t,n)=>sbutility.decodeJWTToken(e,e=>{t(e)},e=>{n(e)}))}static createJWTToken(e,t){return new Promise((n,r)=>{sbutility.getJWTToken(e,t,e=>{n(e)},e=>{r(e)})})}}var M,R,L=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class P{constructor(e,t,n){this.config=e,this.apiService=t,this.deviceInfo=n}refreshAuthToken(){return Object(c.from)(this.getBearerTokenFromKongV2())}getMobileDeviceConsumerKey(){return this.config.api_authentication.producerId+"-"+this.deviceInfo.getDeviceID()}buildGetMobileDeviceConsumerSecretAPIRequest(e){return L(this,void 0,void 0,(function*(){return(new a.CsRequest.Builder).withPath(e).withType(a.CsHttpRequestType.POST).withHeaders({"Content-Encoding":"gzip",Authorization:"Bearer "+(yield this.generateMobileAppConsumerBearerToken())}).withBody({id:P.ID,ver:P.VERSION,ts:b()().format(),request:{key:this.getMobileDeviceConsumerKey()}}).build()}))}getBearerTokenFromKongV2(){return L(this,void 0,void 0,(function*(){const e=`/api/api-manager/v2/consumer/${this.config.api_authentication.mobileAppConsumer}/credential/register`;let t=yield this.buildGetMobileDeviceConsumerSecretAPIRequest(e);return this.apiService.fetch(t).toPromise().then(e=>e.body.result.token).catch(e=>{if(!a.CsNetworkError.isInstance(e)){const t=`/api/api-manager/v1/consumer/${this.config.api_authentication.mobileAppConsumer}/credential/register`;if(e.response.responseCode===a.CsHttpResponseCode.HTTP_KONG_FAILURE){const n=e.response.headers,r=n?n.location:t;return this.getBearerTokenFromFallback(r||t)}return this.getBearerTokenFromFallback(t)}throw e})}))}getBearerTokenFromFallback(e){return L(this,void 0,void 0,(function*(){let t=yield this.buildGetMobileDeviceConsumerSecretAPIRequest(e);return this.apiService.fetch(t).toPromise().then(e=>L(this,void 0,void 0,(function*(){const t=e.body.result;return t.token?t.token:yield I.createJWTToken(this.getMobileDeviceConsumerKey(),t.secret)}))).catch(e=>{console.log("e ",e)})}))}generateMobileAppConsumerBearerToken(){return L(this,void 0,void 0,(function*(){const e=this.config.api_authentication.mobileAppKey,t=this.config.api_authentication.mobileAppSecret;return yield I.createJWTToken(e,t)}))}}P.VERSION="1.0",P.ID="ekstep.genie.device.register",function(e){e.AUTH="AUTH",e.TELEMETRY="TELEMETRY",e.DOWNLOADS="DOWNLOADS",e.CONTENT="CONTENT",e.ERROR="ERROR",e.STORAGE="STORAGE"}(M||(M={})),function(e){e.HTTP_SERVER_ERROR="HTTP_SERVER_ERROR",e.HTTP_CLIENT_ERROR="HTTP_CLIENT_ERROR",e.AUTH_TOKEN_REFRESH_ERROR="AUTH_TOKEN_REFRESH_ERROR",e.PLANNED_MAINTENANCE_PERIOD="PLANNED_MAINTENANCE_PERIOD"}(R||(R={}));var D=n(0),w=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class U{constructor(e,t,n,r){this.sharedPreferences=e,this.apiConfig=t,this.deviceInfo=n,this.apiService=r,this.apiTokenHandler=new P(this.apiConfig,this.apiService,this.deviceInfo)}interceptResponse(e,t){return t.responseCode===a.CsHttpResponseCode.HTTP_UNAUTHORISED&&"Unauthorized"===t.body.message||t.responseCode===a.CsHttpResponseCode.HTTP_FORBIDDEN?this.apiTokenHandler.refreshAuthToken().pipe(Object(D.tap)(e=>w(this,void 0,void 0,(function*(){yield this.sharedPreferences.putString(h.KEY_API_TOKEN,e).toPromise()}))),Object(D.mergeMap)(()=>this.apiService.fetch(e))):Object(c.of)(t)}}class j{constructor(e,t){this.apiService=e,this.authService=t}interceptResponse(e,t){return t.responseCode!==a.CsHttpResponseCode.HTTP_UNAUTHORISED||t.body.message?Object(c.of)(t):this.invokeRefreshSessionTokenApi().pipe(Object(D.mergeMap)(()=>this.apiService.fetch(e)))}invokeRefreshSessionTokenApi(){return this.authService.refreshSession()}}var F,k=n(3),x=n(25),B=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},V=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Y=function(e,t){return function(n,r){t(n,r,e)}};let G=F=class{constructor(e,t,n,r,i,o){this.container=e,this.sdkConfig=t,this.deviceInfo=n,this.sharedPreferences=r,this.eventsBusService=i,this.httpService=o,this.hasEmittedPlannedMaintenanceErrorEvent=!1,this.defaultRequestInterceptors=[],this.defaultResponseInterceptors=[],this.apiConfig=this.sdkConfig.apiConfig,this.apiConfig.debugMode&&(this.defaultRequestInterceptors=[new x.CsRequestLoggerInterceptor],this.defaultResponseInterceptors=[new x.CsResponseLoggerInterceptor])}get bearerTokenRefreshInterceptor(){return this._bearerTokenRefreshInterceptor||(this._bearerTokenRefreshInterceptor=new U(this.container.get(l.SHARED_PREFERENCES),this.container.get(l.SDK_CONFIG).apiConfig,this.container.get(l.DEVICE_INFO),this.container.get(l.API_SERVICE))),this._bearerTokenRefreshInterceptor}get userTokenRefreshInterceptor(){return this._userTokenRefreshInterceptor||(this._userTokenRefreshInterceptor=new j(this.container.get(l.API_SERVICE),this.container.get(l.AUTH_SERVICE))),this._userTokenRefreshInterceptor}onInit(){return this.sharedPreferences.addListener(h.KEY_API_TOKEN,e=>{k.CsModule.instance.config.core.api.authentication.bearerToken=e||void 0,k.CsModule.instance.updateConfig(k.CsModule.instance.config)}),this.sharedPreferences.getString(h.KEY_API_TOKEN).pipe(Object(D.mergeMap)(e=>e?(k.CsModule.instance.config.core.api.authentication.bearerToken=e,k.CsModule.instance.updateConfig(k.CsModule.instance.config),Object(c.of)(void 0)):new P(this.apiConfig,this,this.deviceInfo).refreshAuthToken().pipe(Object(D.mergeMap)(e=>this.sharedPreferences.putString(h.KEY_API_TOKEN,e)),Object(D.catchError)(()=>Object(c.of)(void 0)))))}fetch(e){if(this.defaultRequestInterceptors.forEach(t=>{-1===e.requestInterceptors.indexOf(t)&&e.requestInterceptors.push(t)}),this.defaultResponseInterceptors.forEach(t=>{-1===e.responseInterceptors.indexOf(t)&&e.responseInterceptors.push(t)}),e.withBearerToken){const t=e.responseInterceptors.indexOf(this.bearerTokenRefreshInterceptor);-1===t?e.responseInterceptors.push(this.bearerTokenRefreshInterceptor):e.responseInterceptors.splice(t,1)}if(e.withUserToken){const t=e.responseInterceptors.indexOf(this.userTokenRefreshInterceptor);-1===t?e.responseInterceptors.push(this.userTokenRefreshInterceptor):e.responseInterceptors.splice(t,1)}return this.httpService.fetch(e).pipe(Object(D.catchError)(e=>(a.CsHttpServerError.isInstance(e)?(this.eventsBusService.emit({namespace:M.ERROR,event:{type:R.HTTP_SERVER_ERROR,payload:e}}),e.response.responseCode===F.PLANNED_MAINTENANCE_ERROR_CODE&&(this.hasEmittedPlannedMaintenanceErrorEvent||(this.hasEmittedPlannedMaintenanceErrorEvent=!0,this.eventsBusService.emit({namespace:M.ERROR,event:{type:R.PLANNED_MAINTENANCE_PERIOD,payload:e}})))):a.CsHttpClientError.isInstance(e)&&this.eventsBusService.emit({namespace:M.ERROR,event:{type:R.HTTP_CLIENT_ERROR,payload:e}}),Object(c.throwError)(e))))}setDefaultRequestInterceptors(e){this.defaultRequestInterceptors=e,this.apiConfig.debugMode&&this.defaultRequestInterceptors.push(new x.CsRequestLoggerInterceptor)}setDefaultResponseInterceptors(e){this.defaultResponseInterceptors=e,this.apiConfig.debugMode&&this.defaultResponseInterceptors.push(new x.CsResponseLoggerInterceptor)}};G.PLANNED_MAINTENANCE_ERROR_CODE=531,G=F=B([Object(s.injectable)(),Y(0,Object(s.inject)(l.CONTAINER)),Y(1,Object(s.inject)(l.SDK_CONFIG)),Y(2,Object(s.inject)(l.DEVICE_INFO)),Y(3,Object(s.inject)(l.SHARED_PREFERENCES)),Y(4,Object(s.inject)(l.EVENTS_BUS_SERVICE)),Y(5,Object(s.inject)(u.HTTP_SERVICE)),V("design:paramtypes",[s.Container,Object,Object,Object,Object,Object])],G);var H=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ${constructor(e,t,n,r,i,o,s){this.sdkConfig=e,this.deviceInfo=t,this.sharedPreferences=n,this.frameworkService=r,this.appInfoService=i,this.apiService=o,this.getDeviceProfileHandler=s,this.deviceRegisterConfig=this.sdkConfig.deviceRegisterConfig,this.apiConfig=this.sdkConfig.apiConfig}handle(e){return this.registerDevice(e)}registerDevice(e){return Object(c.zip)(this.deviceInfo.getDeviceSpec(),this.frameworkService.getActiveChannelId(),this.appInfoService.getFirstAccessTimestamp(),this.sharedPreferences.getString(C.DEVICE_LOCATION)).pipe(Object(D.mergeMap)(t=>H(this,void 0,void 0,(function*(){const n=t[0],r=t[1],i=t[2],o=t[3];if(!(e=Object.assign(Object.assign({},e||{}),{dspec:n,channel:r,fcmToken:this.deviceRegisterConfig.fcmToken,producer:this.apiConfig.api_authentication.producerId,first_access:Number(i)})).userDeclaredLocation&&o&&(e.userDeclaredLocation=JSON.parse(o),!e.userDeclaredLocation.declaredOffline))try{const t=yield this.getDeviceProfileHandler.handle().toPromise();t.userDeclaredLocation&&t.userDeclaredLocation.state&&t.userDeclaredLocation.district||(delete e.userDeclaredLocation,this.sharedPreferences.putString(C.DEVICE_LOCATION,"").toPromise())}catch(t){console.error(t),delete e.userDeclaredLocation}e.userDeclaredLocation&&delete e.userDeclaredLocation.declaredOffline;const s=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.deviceRegisterConfig.apiPath+$.DEVICE_REGISTER_ENDPOINT+"/"+this.deviceInfo.getDeviceID()).withBearerToken(!0).withBody({request:e}).build();return this.apiService.fetch(s).pipe(Object(D.map)(e=>e.body),Object(D.tap)(()=>{e.userDeclaredLocation&&this.sharedPreferences.putString(C.DEVICE_LOCATION,JSON.stringify(e.userDeclaredLocation)).toPromise()})).toPromise()}))))}}$.DEVICE_REGISTER_ENDPOINT="/register";class q{constructor(e,t,n){this.sdkConfig=e,this.deviceInfo=t,this.apiService=n,this.deviceRegisterConfig=this.sdkConfig.deviceRegisterConfig,this.apiConfig=this.sdkConfig.apiConfig}handle(){return this.fetchFromServer()}fetchFromServer(){return this.apiService.fetch((new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.deviceRegisterConfig.apiPath+q.GET_DEVICE_PROFILE_ENDPOINT+"/"+this.deviceInfo.getDeviceID()).withBearerToken(!0).build()).pipe(Object(D.map)(e=>e.body.result))}}q.GET_DEVICE_PROFILE_ENDPOINT="/profile";var K=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},z=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},W=function(e,t){return function(n,r){t(n,r,e)}};let X=class{constructor(e,t,n,r,i,o){this.sdkConfig=e,this.deviceInfo=t,this.sharedPreferences=n,this.frameworkService=r,this.appInfoService=i,this.apiService=o,this.getDeviceProfileHandler=new q(this.sdkConfig,this.deviceInfo,this.apiService),this.deviceRegisterHandler=new $(this.sdkConfig,this.deviceInfo,this.sharedPreferences,this.frameworkService,this.appInfoService,this.apiService,this.getDeviceProfileHandler)}registerDevice(e){return this.deviceRegisterHandler.handle(e)}getDeviceProfile(){return this.getDeviceProfileHandler.handle()}};X=K([Object(s.injectable)(),W(0,Object(s.inject)(l.SDK_CONFIG)),W(1,Object(s.inject)(l.DEVICE_INFO)),W(2,Object(s.inject)(l.SHARED_PREFERENCES)),W(3,Object(s.inject)(l.FRAMEWORK_SERVICE)),W(4,Object(s.inject)(l.APP_INFO)),W(5,Object(s.inject)(l.API_SERVICE)),z("design:paramtypes",[Object,Object,Object,Object,Object,Object])],X);class J{}var Q,Z,ee,te,ne,re,ie,oe,se,ae,ce,ue,le,de,he;!function(e){e.NOTIFICATION="notification",e.USER="User",e.GROUP="Group",e.CONTENT="Content",e.QUESTION="Question"}(Q||(Q={})),function(e){e.PLAY="play"}(Z||(Z={})),function(e){e.NOTIFICATION="notification"}(ee||(ee={})),function(e){e.TRACE="TRACE",e.DEBUG="DEBUG",e.INFO="INFO",e.WARN="WARN",e.ERROR="ERROR",e.FATAL="FATAL"}(te||(te={})),function(e){e.IN="In",e.OUT="Out"}(ne||(ne={})),function(e){e.FILE="File",e.MESSAGE="Message",e.LINK="Link"}(re||(re={})),function(e){e.CONTENT="CONTENT",e.EXPLODEDCONTENT="EXPLODEDCONTENT",e.TELEMETRY="TELEMETRY",e.PROFILE="PROFILE"}(ie||(ie={}));class Ee{constructor(){this.RECEIVED="Received",this.DISPLAYED="Displayed"}}!function(e){e.TOUCH="TOUCH",e.OTHER="OTHER"}(oe||(oe={})),function(e){e.NETWORK_SPEED="network-speed",e.SUBTYPE_SPINE="spine",e.ONLINE="online",e.FULL="full",e.CONTENT_VARIANT="content-variant-download",e.DEVICE_TIME_OFFSET_FOUND="device-time-offset-found",e.CONTENT_DOWNLOAD_INITIATE="ContentDownload-Initiate",e.CONTENT_DOWNLOAD_SUCCESS="ContentDownload-Success",e.CONTENT_DOWNLOAD_CANCEL="ContentDownload-Cancel"}(se||(se={})),function(e){e.ERR_DOWNLOAD_FAILED="ERR_DOWNLOAD_FAILED"}(ae||(ae={})),function(e){e.SYSTEM="SYSTEM"}(ce||(ce={}));class fe{static toFixed(e){return Number(e.toFixed(2))}static parseInt(e){return e?parseInt(e,10):0}static round(e){return Number(Math.round(parseFloat(e+"e4"))+"e-4")}}class pe{constructor(){this.type=pe.TYPE_USER}}pe.TYPE_SYSTEM="System",pe.TYPE_USER="Guest user";class _e{}class Oe{constructor(){this.os="",this.make="",this.id="",this.mem=-1,this.idisk=-1,this.edisk=-1,this.scrn=-1,this.cpu="",this.sims=-1,this.cap=[]}}class Se{}class ge{}class Ae{}class Ne{}class Te{}class Ce{}class ve{ProducerData(){this.id="",this.pid="",this.ver="",this.platform=""}}class ye{}class me{constructor(e,t,n){this.id=e,this.type=t,this.version=n}setRollup(e){this.rollup=e}}class be{}!function(e){e.AUDIT_CREATED="Created",e.AUDIT_UPDATED="Updated",e.AUDIT_DELETED="Deleted"}(ue||(ue={})),function(e){class t{constructor(e){this.ver=t.TELEMETRY_VERSION,this.eid=e,this.ets=Date.now(),this.actor=new pe,this.context=new _e,this.edata={}}}t.TELEMETRY_VERSION="3.0",e.Telemetry=t;class n extends t{constructor(e,t,r,i,o,s,a="",c="",u="",l={},d=[],h){super(n.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e?{type:e}:{}),r?{duration:r}:{}),i?{pageid:i}:{}),t?{mode:t}:{}),o?{summaryList:o}:{}),this.context.cdata=d,this.context.env=s,this.object=new me(a,c,u),this.object.rollup=l,this.actor=h||new pe}}n.EID="END",e.End=n;class r extends t{constructor(e="",t,n,i,o,s,a,c="",u="",l="",d={},h=[],E){super(r.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e?{type:e}:{type:""}),t?{dspec:t}:{}),n?{loc:n}:{}),i?{mode:i}:{}),o?{mode:i}:{}),s?{pageid:s}:{}),this.context.cdata=h,this.context.env=a,this.object=new me(c,u,l),this.object.rollup=d||{},this.actor=E||new pe}}r.EID="START",e.Start=r;class i extends t{constructor(e,t,n,r,o,s,a,c,u,l,d,h,E=[],f="",p="",_="",O={}){super(i.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({type:e,starttime:t,endtime:n,timespent:r,pageviews:o,interactions:s},c?{mode:c}:{}),u?{envsummary:u}:{}),l?{eventsummary:l}:{}),d?{pagesummary:d}:{}),h?{extra:h}:{}),this.context.cdata=E,this.context.env=a,this.object=new me(f,p,_),this.object.rollup=O||{}}}i.EID="SUMMARY",e.Summary=i;class o extends t{constructor(e,t,n,r,i,s,a,c="",u="",l="",d={},h=[],E,f){super(o.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign({type:e},{subtype:t}),n?{id:n}:{}),r?{pageid:r}:{}),{extra:Object.assign(Object.assign({},i?{pos:i}:{}),s?{values:[s]}:{})}),this.context.cdata=h,this.context.env=a,this.context.pdata=E||new ve,this.actor=f||new pe,this.object=new me(c,u,l),this.object.rollup=d||{}}}o.EID="INTERACT",e.Interact=o;class s extends t{constructor(e,t,n,r,i,o="",a="",c="",u={},l=[],d){super(s.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e?{type:e}:{type:""}),t?{subtype:t}:{}),n?{pageid:n}:{}),n?{uri:n}:{}),r?{visits:r}:{}),this.context.cdata=l,this.context.env=i,this.object=new me(o||"",a||"",c||""),this.object.rollup=u||{},this.actor=d||new pe}}s.EID="IMPRESSION",e.Impression=s;class a extends t{constructor(e,t,n,r,i,o,s){super(a.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e?{type:e}:{type:""}),t?{level:t}:{}),n?{message:n}:{}),r?{pageid:r}:{}),i?{params:i}:{}),this.context.env=o;const c=new pe;c.type=s,this.actor=c}}a.EID="LOG",e.Log=a;class c extends t{constructor(e,t,n,r,i){super(c.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign({},e?{err:e}:{}),t?{errtype:t}:{}),n?{stacktrace:n}:{}),r?{pageid:r}:{}),this.actor=i||new pe}}c.EID="ERROR",e.Error=c;class u extends t{constructor(e,t,n){super(u.EID),this.edata=Object.assign({type:e},t?{pageid:t}:{}),this.actor=n||new pe}}u.EID="INTERRUPT",e.Interrupt=u;class l extends t{constructor(e,t,n,r=[],i="",o="",s="",a=new Te){super(l.EID),this.edata=Object.assign(Object.assign(Object.assign({},e?{dir:e}:{}),t?{type:t}:{}),n?{items:n}:{}),this.context.cdata=r,this.object=new me(i||"",o||"",s||""),this.object.rollup=a}addItem(e,t,n,r,i,o){const s={};if(s.origin=t,s.id=n,s.type=this.capitalize(e.valueOf()),e.valueOf()===ie.CONTENT.valueOf()||e.valueOf()===ie.EXPLODEDCONTENT.valueOf()){s.ver=r.toString();const e=[],t={};t.transfers=fe.parseInt(i),t.size=o,e.push(t),s.params=e}const a={};a.id=t,a.type="Device",s.origin=a,this.edata.items.push(s)}capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}}l.EID="SHARE",e.Share=l;class d extends t{constructor(e,t,n,r="",i="",o="",s,a){super(d.EID),this.edata=Object.assign(Object.assign(Object.assign(Object.assign({},e?{rating:e}:{}),s?{commentid:s}:{}),a?{commenttxt:a}:{}),t?{comments:t}:{}),this.context.env=n,this.object=new me(r,i,o),this.object.rollup={}}}d.EID="FEEDBACK",e.Feedback=d;class h extends t{constructor(e,t,n,r,i,o="",s="",a="",c=[],u={}){super(h.EID),this.edata=Object.assign(Object.assign({state:n},r?{props:r}:{}),{type:i}),this.context.cdata=c,this.context.env=e,this.object=new me(o,s,a),this.object.rollup=u||{},this.actor=t}}h.EID="AUDIT",e.Audit=h}(le||(le={}));class Ie{constructor(){this.pos=[]}}class Me{}class Re{}class Le{}class Pe{}class De{}class we{}class Ue{}class je{}class Fe{constructor(){this.items=[]}}!function(e){e.OFF="OFF",e.OVER_WIFI="OVER_WIFI",e.ALWAYS_ON="ALWAYS_ON"}(de||(de={}));class ke extends Error{constructor(e,t){super(e),this._code=t,Object.setPrototypeOf(this,ke.prototype)}get code(){return this._code}}class xe extends ke{constructor(e){super(e,"SIGN_IN_ERROR"),Object.setPrototypeOf(this,xe.prototype)}}!function(e){e.AUTO_MIGRATE_SUCCESS="AUTO_MIGRATE_SUCCESS",e.AUTO_MIGRATE_FAIL="AUTO_MIGRATE_FAIL"}(he||(he={}));var Be=n(12);class Ve extends ke{constructor(e,t){super(e,t),Object.setPrototypeOf(this,Ve.prototype)}}class Ye extends Ve{constructor(e){super(e,"NO_INAPPBROWSER_SESSION_ASSERTION_FAIL"),Object.setPrototypeOf(this,Ve.prototype)}}class Ge extends Ve{constructor(e){super(e,"PARAM_NOT_CAPTURED"),Object.setPrototypeOf(this,Ge.prototype)}}var He,$e,qe,Ke,ze,We,Xe,Je,Qe,Ze,et,tt,nt,rt,it,ot,st,at,ct,ut,lt,dt,ht,Et,ft,pt,_t,Ot,St,gt,At,Nt,Tt,Ct,vt,yt,mt,bt,It,Mt,Rt,Lt,Pt,Dt,wt,Ut,jt,Ft,kt,xt,Bt,Vt,Yt=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Gt{constructor(){this.extras={},this.captured={}}static buildUrl(e,t,n){return`${e}${t}?${Be.stringify(n)}`}resetInAppBrowserEventListeners(){if(!this.inAppBrowser)throw new Ye("InAppBrowser Session not found when resetInAppBrowserEventListeners()");for(const e in this.inAppBrowser.listeners)this.inAppBrowser.listeners.hasOwnProperty(e)&&(this.inAppBrowser.listeners[e].forEach(t=>{this.inAppBrowser.ref.removeEventListener(e,t)}),this.inAppBrowser.listeners[e].clear())}launchWebview({host:e,path:t,params:n}){return Yt(this,void 0,void 0,(function*(){this.inAppBrowser={ref:cordova.InAppBrowser.open(Gt.buildUrl(e,t,n),"_blank","zoom=no,clearcache=yes,clearsessioncache=yes,cleardata=yes"),listeners:{loadstart:new Set,exit:new Set}};const r=()=>{this.resetInAppBrowserEventListeners(),this.inAppBrowser=void 0};this.inAppBrowser.listeners.exit.add(r),this.inAppBrowser.ref.addEventListener("exit",r)}))}closeWebview(){return Yt(this,void 0,void 0,(function*(){if(!this.inAppBrowser)throw new Ye("InAppBrowser Session not found");this.inAppBrowser.ref.close()}))}any(...e){return Object(c.race)(...e).pipe(Object(D.take)(1)).toPromise()}all(...e){return Object(c.zip)(...e).pipe(Object(D.take)(1),Object(D.mapTo)(void 0)).toPromise()}launchCustomTab({host:e,path:t,params:n,extraParams:r}){const i=Gt.buildUrl(e,t,n);return new Promise((e,t)=>{customtabs.isAvailable(()=>{customtabs.launch(i,t=>{this.captured=Object.assign(Object.assign({},this.captured),Be.parse(t)),e()},e=>{t(e)})},()=>{customtabs.launchInBrowser(i,r,t=>{this.captured=Object.assign(Object.assign({},this.captured),Be.parse(t)),e()},e=>{t(e)})})})}capture({host:e,path:t,params:n}){if(!this.inAppBrowser)throw new Ye("InAppBrowser Session not found");return new Promise(r=>{const i=o=>{if(o.url){const s=new URL(o.url);(t=>t.origin===e)(s)&&(e=>e.pathname===t)(s)&&(e=>n.map(e=>e).every(t=>"false"===t.exists?!e.searchParams.has(t.key):t.match?e.searchParams.has(t.key)&&e.searchParams.get(t.key)===t.match:e.searchParams.has(t.key)))(s)&&(this.captured=Object.assign(Object.assign({},this.captured),n.reduce((e,t)=>(e[t.resolveTo]=s.searchParams.get(t.key),e),{})),this.extras={},n.map(e=>e.key).forEach(e=>s.searchParams.delete(e)),s.searchParams.forEach((e,t)=>{this.extras[t]=e}),this.inAppBrowser&&(this.inAppBrowser.listeners.loadstart.delete(i),this.inAppBrowser.ref.removeEventListener("loadstart",i)),r())}};this.inAppBrowser&&(this.inAppBrowser.listeners.loadstart.add(i),this.inAppBrowser.ref.addEventListener("loadstart",i))})}resolveCaptured(e){return Yt(this,void 0,void 0,(function*(){if(!this.captured[e])throw new Ge(e+" was not captured");return this.captured[e]}))}clearCapture(){return Yt(this,void 0,void 0,(function*(){this.captured={}}))}redirectTo({host:e,path:t,params:n}){return Yt(this,void 0,void 0,(function*(){if(!this.inAppBrowser)throw new Ye("InAppBrowser Session not found");this.inAppBrowser.ref.executeScript({code:"(() => {\n window.location.href = `"+Gt.buildUrl(e,t,n)+"`;\n })()"})}))}success(){return Yt(this,void 0,void 0,(function*(){return Object.assign({},this.captured)}))}fail(){return Yt(this,void 0,void 0,(function*(){throw Object.assign({},this.captured)}))}getCaptureExtras(){return Yt(this,void 0,void 0,(function*(){return Object.assign({},this.extras)}))}}($e=He||(He={}))._ID="_id",$e.TABLE_NAME="telemetry",$e.COLUMN_NAME_EVENT_TYPE="event_type",$e.COLUMN_NAME_EVENT="event",$e.COLUMN_NAME_TIMESTAMP="timestamp",$e.COLUMN_NAME_PRIORITY="priority",$e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+$e.TABLE_NAME+" ("+$e._ID+r.SPACE+" INTEGER PRIMARY KEY,"+$e.COLUMN_NAME_EVENT_TYPE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+$e.COLUMN_NAME_EVENT+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+$e.COLUMN_NAME_TIMESTAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+$e.COLUMN_NAME_PRIORITY+r.SPACE+r.INT_TYPE+" )",$e.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+$e.TABLE_NAME,(Ke=qe||(qe={}))._ID="_id",Ke.TABLE_NAME="processed_telemetry",Ke.COLUMN_NAME_MSG_ID="msg_id",Ke.COLUMN_NAME_DATA="data",Ke.COLUMN_NAME_NUMBER_OF_EVENTS="event_count",Ke.COLUMN_NAME_PRIORITY="priority",Ke.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Ke.TABLE_NAME+" ("+Ke._ID+" INTEGER PRIMARY KEY,"+Ke.COLUMN_NAME_MSG_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Ke.COLUMN_NAME_DATA+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Ke.COLUMN_NAME_NUMBER_OF_EVENTS+r.SPACE+r.INT_TYPE+r.COMMA_SEP+Ke.COLUMN_NAME_PRIORITY+r.SPACE+r.INT_TYPE+" )",Ke.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+Ke.TABLE_NAME,(We=ze||(ze={}))._ID="_id",We.TABLE_NAME="event_priority",We.COLUMN_NAME_EVENT="event",We.COLUMN_NAME_PRIORITY="priority",We.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+We.TABLE_NAME+" ("+We._ID+" INTEGER PRIMARY KEY,"+We.COLUMN_NAME_EVENT+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+We.COLUMN_NAME_PRIORITY+r.SPACE+r.INT_TYPE+" )",We.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+We.TABLE_NAME,(Je=Xe||(Xe={}))._ID="_id",Je.TABLE_NAME="telemetry_tags",Je.COLUMN_NAME_NAME="name",Je.COLUMN_NAME_HASH="hash",Je.COLUMN_NAME_DESCRIPTION="description",Je.COLUMN_NAME_START_DATE="start_date",Je.COLUMN_NAME_END_DATE="end_date",Je.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Je.TABLE_NAME+" ("+Je._ID+" INTEGER PRIMARY KEY,"+Je.COLUMN_NAME_NAME+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Je.COLUMN_NAME_HASH+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Je.COLUMN_NAME_DESCRIPTION+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Je.COLUMN_NAME_START_DATE+r.SPACE+r.DATE_TYPE+r.COMMA_SEP+Je.COLUMN_NAME_END_DATE+r.SPACE+r.DATE_TYPE+" )",Je.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+Je.TABLE_NAME,(Ze=Qe||(Qe={}))._ID="_id",Ze.TABLE_NAME="meta_data",Ze.COLUMN_NAME_MSG_ID="key",Ze.COLUMN_NAME_DATA="value",Ze.getCreateEntry=()=>"CREATE TABLE "+Ze.TABLE_NAME+" ("+Ze._ID+" INTEGER PRIMARY KEY,"+Ze.COLUMN_NAME_MSG_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Ze.COLUMN_NAME_DATA+r.SPACE+r.TEXT_TYPE+" )",Ze.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+Ze.TABLE_NAME,(tt=et||(et={}))._ID="_id",tt.TABLE_NAME="profiles",tt.COLUMN_NAME_UID="uid",tt.COLUMN_NAME_HANDLE="handle",tt.COLUMN_NAME_AVATAR="avatar",tt.COLUMN_NAME_AGE="age",tt.COLUMN_NAME_GENDER="gender",tt.COLUMN_NAME_STANDARD="standard",tt.COLUMN_NAME_LANGUAGE="language",tt.COLUMN_NAME_DAY="day",tt.COLUMN_NAME_MONTH="month",tt.COLUMN_NAME_IS_GROUP_USER="is_group_user",tt.COLUMN_NAME_CREATED_AT="created_at",tt.COLUMN_NAME_MEDIUM="medium",tt.COLUMN_NAME_BOARD="board",tt.COLUMN_NAME_PROFILE_IMAGE="profile_image",tt.COLUMN_NAME_SUBJECT="subject",tt.COLUMN_NAME_PROFILE_TYPE="profile_type",tt.COLUMN_NAME_GRADE="grade",tt.COLUMN_NAME_SYLLABUS="syllabus",tt.COLUMN_NAME_SOURCE="source",tt.COLUMN_NAME_GRADE_VALUE="grade_value",tt.COLUMN_VALUE="value",tt.COLUMN_NAME_CATEGORIES="categories",tt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+tt.TABLE_NAME+"("+tt._ID+r.SPACE+"INTEGER PRIMARY KEY,"+tt.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+" UNIQUE NOT NULL"+r.COMMA_SEP+tt.COLUMN_NAME_HANDLE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_AVATAR+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_AGE+r.SPACE+r.INT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_GENDER+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_STANDARD+r.SPACE+r.INT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_LANGUAGE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_DAY+r.SPACE+r.INT_TYPE+" NOT NULL DEFAULT -1"+r.COMMA_SEP+tt.COLUMN_NAME_MONTH+r.SPACE+r.INT_TYPE+" NOT NULL DEFAULT -1"+r.COMMA_SEP+tt.COLUMN_NAME_IS_GROUP_USER+r.SPACE+r.INT_TYPE+" NOT NULL DEFAULT 0"+r.COMMA_SEP+tt.COLUMN_NAME_CREATED_AT+r.SPACE+r.INT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_MEDIUM+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_BOARD+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_SUBJECT+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_PROFILE_IMAGE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_PROFILE_TYPE+r.SPACE+r.TEXT_TYPE+' DEFAULT "teacher"'+r.COMMA_SEP+tt.COLUMN_NAME_GRADE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_CATEGORIES+r.SPACE+r.TEXT_TYPE+" DEFAULT ''"+r.COMMA_SEP+tt.COLUMN_NAME_SYLLABUS+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_NAME_SOURCE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+tt.COLUMN_VALUE+r.SPACE+r.TEXT_TYPE+' DEFAULT ""'+r.COMMA_SEP+tt.COLUMN_NAME_GRADE_VALUE+r.SPACE+r.TEXT_TYPE+")",tt.deleteTable=()=>"DROP TABLE IF EXISTS "+tt.TABLE_NAME,tt.getAlterEntryForProfileSyllabus=()=>"ALTER TABLE "+tt.TABLE_NAME+" ADD COLUMN "+r.SPACE+tt.COLUMN_NAME_SYLLABUS+r.TEXT_TYPE+" DEFAULT '';",tt.getAlterEntryForProfileCategories=()=>"ALTER TABLE "+tt.TABLE_NAME+" ADD COLUMN "+r.SPACE+tt.COLUMN_NAME_CATEGORIES+r.SPACE+r.TEXT_TYPE+" DEFAULT '';",(rt=nt||(nt={}))._ID="_id",rt.TABLE_NAME="users",rt.COLUMN_NAME_UID="uid",rt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+rt.TABLE_NAME+" ("+rt._ID+" INTEGER PRIMARY KEY,"+rt.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+" )",rt.deleteTable=()=>"DROP TABLE IF EXISTS "+rt.TABLE_NAME,(ot=it||(it={})).TABLE_NAME="group_profile",ot._ID="_id",ot.COLUMN_NAME_UID="uid",ot.COLUMN_NAME_GID="gid",ot.COLUMN_NAME_EPOCH_TIMESTAMP="epoch_timestamp",ot.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+ot.TABLE_NAME+" ("+ot._ID+" INTEGER PRIMARY KEY"+r.COMMA_SEP+ot.COLUMN_NAME_GID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+ot.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+ot.COLUMN_NAME_EPOCH_TIMESTAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+"UNIQUE ("+ot.COLUMN_NAME_GID+r.COMMA_SEP+ot.COLUMN_NAME_UID+") ON CONFLICT REPLACE)",ot.deleteTable=()=>"DROP TABLE IF EXISTS"+ot.TABLE_NAME,(at=st||(st={})).TABLE_NAME="groups",at._ID="_id",at.COLUMN_NAME_GID="gid",at.COLUMN_NAME_NAME="name",at.COLUMN_NAME_SYLLABUS="syllabus",at.COLUMN_NAME_GRADE="grade",at.COLUMN_NAME_GRADE_VALUE="grade_value",at.COLUMN_NAME_CREATED_AT="created_at",at.COLUMN_NAME_UPDATED_AT="updated_at",at.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+at.TABLE_NAME+" ("+at._ID+" INTEGER PRIMARY KEY"+r.COMMA_SEP+at.COLUMN_NAME_GID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+at.COLUMN_NAME_NAME+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+at.COLUMN_NAME_SYLLABUS+r.SPACE+r.TEXT_TYPE+' DEFAULT ""'+r.COMMA_SEP+at.COLUMN_NAME_GRADE+r.SPACE+r.TEXT_TYPE+' DEFAULT ""'+r.COMMA_SEP+at.COLUMN_NAME_GRADE_VALUE+r.SPACE+r.TEXT_TYPE+' DEFAULT ""'+r.COMMA_SEP+at.COLUMN_NAME_CREATED_AT+" INTEGER"+r.COMMA_SEP+at.COLUMN_NAME_UPDATED_AT+" INTEGER )",at.deleteTable=()=>"DROP TABLE IF EXISTS"+at.TABLE_NAME,(ut=ct||(ct={}))._ID="_id",ut.TABLE_NAME="imported_metadata",ut.COLUMN_NAME_IMPORTED_ID="imported_id",ut.COLUMN_NAME_DEVICE_ID="device_id",ut.COLUMN_NAME_COUNT="count",ut.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+ut.TABLE_NAME+" ("+ut._ID+" INTEGER PRIMARY KEY,"+ut.COLUMN_NAME_IMPORTED_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+ut.COLUMN_NAME_DEVICE_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+ut.COLUMN_NAME_COUNT+r.SPACE+r.INT_TYPE+" )",ut.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+ut.TABLE_NAME,(dt=lt||(lt={}))._ID="_id",dt.TABLE_NAME="learner_assessments",dt.COLUMN_NAME_UID="uid",dt.COLUMN_NAME_CONTENT_ID="content_id",dt.COLUMN_NAME_QID="qid",dt.COLUMN_NAME_Q_INDEX="qindex",dt.COLUMN_NAME_CORRECT="correct",dt.COLUMN_NAME_SCORE="score",dt.COLUMN_NAME_MAX_SCORE="max_score",dt.COLUMN_NAME_TIME_SPENT="time_spent",dt.COLUMN_NAME_RES="res",dt.COLUMN_NAME_TIMESTAMP="timestamp",dt.COLUMN_NAME_Q_DESC="qdesc",dt.COLUMN_NAME_Q_TITLE="qtitle",dt.COLUMN_NAME_HIERARCHY_DATA="h_data",dt.COLUMN_NAME_TOTAL_TS="total_ts",dt.COLUMN_NAME_MARKS="marks",dt.COLUMN_NAME_COUNT="occurence_count",dt.COLUMN_NAME_TOTAL_MAX_SCORE="sum_max_score",dt.COLUMN_NAME_USERS_COUNT="users_count",dt.COLUMN_NAME_HANDLE="handle",dt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+dt.TABLE_NAME+" ("+dt._ID+" INTEGER PRIMARY KEY,"+dt.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+dt.COLUMN_NAME_CONTENT_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_QID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_Q_INDEX+r.SPACE+r.INT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_CORRECT+r.SPACE+r.INT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_SCORE+r.SPACE+r.INT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_MAX_SCORE+r.SPACE+r.INT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_TIME_SPENT+r.SPACE+r.INT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_RES+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_TIMESTAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_Q_DESC+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_Q_TITLE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+dt.COLUMN_NAME_HIERARCHY_DATA+r.SPACE+r.TEXT_TYPE+" DEFAULT '' )",dt.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+dt.TABLE_NAME,(Et=ht||(ht={}))._ID="_id",Et.TABLE_NAME="learner_content_summary",Et.COLUMN_NAME_UID="uid",Et.COLUMN_NAME_CONTENT_ID="content_id",Et.COLUMN_NAME_AVG_TS="avg_ts",Et.COLUMN_NAME_SESSIONS="sessions",Et.COLUMN_NAME_TOTAL_TS="total_ts",Et.COLUMN_NAME_LAST_UPDATED_ON="last_updated_on",Et.COLUMN_NAME_HIERARCHY_DATA="h_data",Et.COLUMN_NAME_NO_OF_QUESTIONS="no_of_questions",Et.COLUMN_NAME_CORRECT_ANSWERS="correct_answers",Et.COLUMN_NAME_TOTAL_TIME_SPENT="total_time_spent",Et.COLUMN_NAME_TOTAL_MAX_SCORE="total_max_score",Et.COLUMN_NAME_TOTAL_SCORE="total_score",Et.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Et.TABLE_NAME+" ("+Et._ID+" INTEGER PRIMARY KEY,"+Et.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+Et.COLUMN_NAME_CONTENT_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Et.COLUMN_NAME_AVG_TS+r.SPACE+r.REAL_TYPE+r.COMMA_SEP+Et.COLUMN_NAME_SESSIONS+r.SPACE+r.INT_TYPE+r.COMMA_SEP+Et.COLUMN_NAME_TOTAL_TS+r.SPACE+r.INT_TYPE+r.COMMA_SEP+Et.COLUMN_NAME_LAST_UPDATED_ON+r.SPACE+r.SPACE+r.INT_TYPE+r.COMMA_SEP+Et.COLUMN_NAME_HIERARCHY_DATA+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+" UNIQUE ("+Et.COLUMN_NAME_UID+r.SPACE+r.COMMA_SEP+Et.COLUMN_NAME_CONTENT_ID+r.COMMA_SEP+Et.COLUMN_NAME_HIERARCHY_DATA+") ON CONFLICT REPLACE )",Et.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+Et.TABLE_NAME,function(e){e.TABLE_NAME="group_profile",e._ID="_id",e.COLUMN_NAME_UID="uid",e.COLUMN_NAME_GID="gid",e.COLUMN_NAME_EPOCH_TIMESTAMP="epoch_timestamp",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY"+r.COMMA_SEP+e.COLUMN_NAME_GID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_EPOCH_TIMESTAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+"UNIQUE ("+e.COLUMN_NAME_GID+r.COMMA_SEP+e.COLUMN_NAME_UID+") ON CONFLICT REPLACE)",e.deleteTable=()=>"DROP TABLE IF EXISTS"+e.TABLE_NAME}(ft||(ft={})),function(e){e.TABLE_NAME="groups",e._ID="_id",e.COLUMN_NAME_GID="gid",e.COLUMN_NAME_NAME="name",e.COLUMN_NAME_SYLLABUS="syllabus",e.COLUMN_NAME_GRADE="grade",e.COLUMN_NAME_GRADE_VALUE="grade_value",e.COLUMN_NAME_CREATED_AT="created_at",e.COLUMN_NAME_UPDATED_AT="updated_at",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY"+r.COMMA_SEP+e.COLUMN_NAME_GID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_NAME+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_SYLLABUS+r.SPACE+r.TEXT_TYPE+' DEFAULT ""'+r.COMMA_SEP+e.COLUMN_NAME_GRADE+r.SPACE+r.TEXT_TYPE+' DEFAULT ""'+r.COMMA_SEP+e.COLUMN_NAME_GRADE_VALUE+r.SPACE+r.TEXT_TYPE+' DEFAULT ""'+r.COMMA_SEP+e.COLUMN_NAME_CREATED_AT+" INTEGER"+r.COMMA_SEP+e.COLUMN_NAME_UPDATED_AT+" INTEGER )",e.deleteTable=()=>"DROP TABLE IF EXISTS"+e.TABLE_NAME}(pt||(pt={})),(Ot=_t||(_t={}))._ID="_id",Ot.TABLE_NAME="partners",Ot.COLUMN_NAME_PARTNER_ID="partnerID",Ot.COLUMN_NAME_KEY="publicKey",Ot.COLUMN_NAME_KEY_ID="publicKeyID",Ot.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Ot.TABLE_NAME+" ("+Ot._ID+" INTEGER PRIMARY KEY,"+Ot.COLUMN_NAME_PARTNER_ID+r.SPACE+r.TEXT_TYPE+" UNIQUE NOT NULL"+r.COMMA_SEP+Ot.COLUMN_NAME_KEY+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+Ot.COLUMN_NAME_KEY_ID+r.SPACE+r.INT_TYPE+" NOT NULL )",Ot.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+Ot.TABLE_NAME,(gt=St||(St={})).TABLE_NAME="content",gt._ID="_id",gt.COLUMN_NAME_IDENTIFIER="identifier",gt.COLUMN_NAME_SERVER_DATA="server_data",gt.COLUMN_NAME_LOCAL_DATA="local_data",gt.COLUMN_NAME_MIME_TYPE="mime_type",gt.COLUMN_NAME_PATH="path",gt.COLUMN_NAME_INDEX="search_index",gt.COLUMN_NAME_VISIBILITY="visibility",gt.COLUMN_NAME_SERVER_LAST_UPDATED_ON="server_last_updated_on",gt.COLUMN_NAME_LOCAL_LAST_UPDATED_ON="local_last_updated_on",gt.COLUMN_NAME_MANIFEST_VERSION="manifest_version",gt.COLUMN_NAME_REF_COUNT="ref_count",gt.COLUMN_NAME_CONTENT_STATE="content_state",gt.COLUMN_NAME_CONTENT_TYPE="content_type",gt.COLUMN_NAME_AUDIENCE="audience",gt.COLUMN_NAME_PRAGMA="pragma",gt.COLUMN_NAME_UID="uid",gt.COLUMN_NAME_SIZE_ON_DEVICE="size_on_device",gt.COLUMN_NAME_BOARD="board",gt.COLUMN_NAME_MEDIUM="medium",gt.COLUMN_NAME_GRADE="grade",gt.COLUMN_NAME_DIALCODES="dialcodes",gt.COLUMN_NAME_CHILD_NODES="child_nodes",gt.COLUMN_NAME_PRIMARY_CATEGORY="primary_category",gt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+gt.TABLE_NAME+" ("+gt._ID+" INTEGER PRIMARY KEY,"+gt.COLUMN_NAME_IDENTIFIER+r.SPACE+r.TEXT_TYPE+" UNIQUE NOT NULL"+r.COMMA_SEP+gt.COLUMN_NAME_SERVER_DATA+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_LOCAL_DATA+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_MIME_TYPE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_PATH+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_INDEX+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_VISIBILITY+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_SERVER_LAST_UPDATED_ON+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_LOCAL_LAST_UPDATED_ON+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_REF_COUNT+r.SPACE+r.INT_TYPE+" NOT NULL DEFAULT 1"+r.COMMA_SEP+gt.COLUMN_NAME_CONTENT_STATE+r.SPACE+r.INT_TYPE+" NOT NULL DEFAULT 2"+r.COMMA_SEP+gt.COLUMN_NAME_CONTENT_TYPE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_AUDIENCE+r.SPACE+r.TEXT_TYPE+" DEFAULT 'Learner'"+r.COMMA_SEP+gt.COLUMN_NAME_SIZE_ON_DEVICE+r.SPACE+r.INT_TYPE+" NOT NULL DEFAULT 0"+r.COMMA_SEP+gt.COLUMN_NAME_PRAGMA+r.SPACE+r.TEXT_TYPE+" DEFAULT ''"+r.COMMA_SEP+gt.COLUMN_NAME_BOARD+r.SPACE+r.TEXT_TYPE+" DEFAULT ''"+r.COMMA_SEP+gt.COLUMN_NAME_MEDIUM+r.SPACE+r.TEXT_TYPE+" DEFAULT ''"+r.COMMA_SEP+gt.COLUMN_NAME_GRADE+r.SPACE+r.TEXT_TYPE+" DEFAULT ''"+r.COMMA_SEP+gt.COLUMN_NAME_MANIFEST_VERSION+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+gt.COLUMN_NAME_DIALCODES+r.SPACE+r.TEXT_TYPE+" DEFAULT ''"+r.COMMA_SEP+gt.COLUMN_NAME_CHILD_NODES+r.SPACE+r.TEXT_TYPE+" DEFAULT ''"+r.COMMA_SEP+gt.COLUMN_NAME_PRIMARY_CATEGORY+r.SPACE+r.TEXT_TYPE+" DEFAULT '' )",gt.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+gt.TABLE_NAME,gt.getAlterEntryForContentSize=()=>"ALTER TABLE "+gt.TABLE_NAME+" ADD COLUMN "+gt.COLUMN_NAME_SIZE_ON_DEVICE+r.INT_TYPE+" NOT NULL DEFAULT 0;",gt.getAlterEntryForPragma=()=>"ALTER TABLE "+gt.TABLE_NAME+" ADD COLUMN "+gt.COLUMN_NAME_PRAGMA+r.TEXT_TYPE+" DEFAULT '';",gt.getAlterEntryForBoard=()=>`ALTER TABLE ${gt.TABLE_NAME} ADD COLUMN ${gt.COLUMN_NAME_BOARD} TEXT DEFAULT ''`,gt.getAlterEntryForMedium=()=>`ALTER TABLE ${gt.TABLE_NAME} ADD COLUMN ${gt.COLUMN_NAME_MEDIUM} TEXT DEFAULT ''`,gt.getAlterEntryForGrade=()=>`ALTER TABLE ${gt.TABLE_NAME} ADD COLUMN ${gt.COLUMN_NAME_GRADE} TEXT DEFAULT ''`,gt.getAlterEntryForDialCode=()=>`ALTER TABLE ${gt.TABLE_NAME} ADD COLUMN ${gt.COLUMN_NAME_DIALCODES} TEXT DEFAULT ''`,gt.getAlterEntryForChildNodes=()=>`ALTER TABLE ${gt.TABLE_NAME} ADD COLUMN ${gt.COLUMN_NAME_CHILD_NODES} TEXT DEFAULT ''`,gt.getAlterEntryForPrimaryCategory=()=>`ALTER TABLE ${gt.TABLE_NAME} ADD COLUMN ${gt.COLUMN_NAME_PRIMARY_CATEGORY} TEXT DEFAULT ''`,(Nt=At||(At={}))._ID="_id",Nt.TABLE_NAME="content_access",Nt.COLUMN_NAME_UID="uid",Nt.COLUMN_NAME_CONTENT_IDENTIFIER="identifier",Nt.COLUMN_NAME_EPOCH_TIMESTAMP="epoch_timestamp",Nt.COLUMN_NAME_STATUS="status",Nt.COLUMN_NAME_CONTENT_TYPE="content_type",Nt.COLUMN_NAME_LEARNER_STATE="learner_state",Nt.COLUMN_NAME_PRIMARY_CATEGORY="primary_category",Nt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Nt.TABLE_NAME+" ("+Nt._ID+" INTEGER PRIMARY KEY,"+Nt.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+Nt.COLUMN_NAME_CONTENT_IDENTIFIER+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Nt.COLUMN_NAME_EPOCH_TIMESTAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+Nt.COLUMN_NAME_STATUS+r.SPACE+r.INT_TYPE+r.COMMA_SEP+Nt.COLUMN_NAME_CONTENT_TYPE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Nt.COLUMN_NAME_LEARNER_STATE+r.SPACE+r.BLOB_TYPE+" )",Nt.deleteTable=()=>"DROP TABLE IF EXISTS "+Nt.TABLE_NAME,Nt.getAlterEntryForPrimaryCategory=()=>`ALTER TABLE ${Nt.TABLE_NAME} ADD COLUMN ${Nt.COLUMN_NAME_PRIMARY_CATEGORY} TEXT DEFAULT ''`,(Ct=Tt||(Tt={}))._ID="_id",Ct.TABLE_NAME="feedback",Ct.COLUMN_NAME_CONTENT_ID="identifier",Ct.COLUMN_NAME_UID="uid",Ct.COLUMN_NAME_RATING="rating",Ct.COLUMN_NAME_COMMENTS="comments",Ct.COLUMN_NAME_CREATED_AT="createdAt",Ct.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Ct.TABLE_NAME+" ("+Ct._ID+" INTEGER PRIMARY KEY,"+Ct.COLUMN_NAME_CONTENT_ID+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+Ct.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+Ct.COLUMN_NAME_RATING+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+Ct.COLUMN_NAME_COMMENTS+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+Ct.COLUMN_NAME_CREATED_AT+r.SPACE+r.INT_TYPE+" )",Ct.deleteTable=()=>"DROP TABLE IF EXISTS "+Ct.TABLE_NAME,(yt=vt||(vt={}))._ID="_id",yt.TABLE_NAME="content_marker",yt.COLUMN_NAME_UID="uid",yt.COLUMN_NAME_CONTENT_IDENTIFIER="identifier",yt.COLUMN_NAME_EPOCH_TIMESTAMP="epoch_timestamp",yt.COLUMN_NAME_DATA="data",yt.COLUMN_NAME_EXTRA_INFO="extra_info",yt.COLUMN_NAME_MARKER="marker",yt.COLUMN_NAME_MIME_TYPE="mime_type",yt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+yt.TABLE_NAME+" ("+yt._ID+" INTEGER PRIMARY KEY,"+yt.COLUMN_NAME_UID+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+yt.COLUMN_NAME_CONTENT_IDENTIFIER+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+yt.COLUMN_NAME_EPOCH_TIMESTAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+yt.COLUMN_NAME_DATA+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+yt.COLUMN_NAME_EXTRA_INFO+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+yt.COLUMN_NAME_MIME_TYPE+r.SPACE+r.TEXT_TYPE+" DEFAULT ''"+r.COMMA_SEP+yt.COLUMN_NAME_MARKER+r.SPACE+r.INT_TYPE+" )",yt.deleteTable=()=>"DROP TABLE IF EXISTS "+yt.TABLE_NAME,yt.getAlterEntryForMimeType=()=>`ALTER TABLE ${yt.TABLE_NAME} ADD COLUMN ${yt.COLUMN_NAME_MIME_TYPE} TEXT DEFAULT ''`,(bt=mt||(mt={}))._ID="_id",bt.TABLE_NAME="notifications",bt.COLUMN_NAME_MESSAGE_ID="message_id",bt.COLUMN_NAME_EXPIRY_TIME="expiry_time",bt.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME="display_time",bt.COLUMN_NAME_NOTIFICATION_RECEIVED_AT="received_at",bt.COLUMN_NAME_NOTIFICATION_JSON="notification_json",bt.COLUMN_NAME_IS_READ="is_read",bt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+bt.TABLE_NAME+" ("+bt._ID+" INTEGER PRIMARY KEY,"+bt.COLUMN_NAME_MESSAGE_ID+r.SPACE+r.INT_TYPE+r.COMMA_SEP+bt.COLUMN_NAME_EXPIRY_TIME+r.SPACE+r.INT_TYPE+r.COMMA_SEP+bt.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME+r.SPACE+r.INT_TYPE+r.COMMA_SEP+bt.COLUMN_NAME_NOTIFICATION_RECEIVED_AT+r.SPACE+r.INT_TYPE+r.COMMA_SEP+bt.COLUMN_NAME_NOTIFICATION_JSON+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+bt.COLUMN_NAME_IS_READ+r.SPACE+r.INT_TYPE+" )",bt.deleteTable=()=>"DROP TABLE IF EXISTS "+bt.TABLE_NAME,(Mt=It||(It={}))._ID="_id",Mt.TABLE_NAME="no_sql",Mt.COLUMN_NAME_KEY="key",Mt.COLUMN_NAME_VALUE="value",Mt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Mt.TABLE_NAME+" ("+Mt._ID+" INTEGER PRIMARY KEY,"+Mt.COLUMN_NAME_KEY+r.SPACE+r.TEXT_TYPE+" NOT NULL"+r.COMMA_SEP+Mt.COLUMN_NAME_VALUE+r.SPACE+r.TEXT_TYPE+" )",Mt.getDeleteEntry=()=>"DROP TABLE IF EXISTS "+Mt.TABLE_NAME,(Lt=Rt||(Rt={})).TABLE_NAME="error_stack",Lt._ID="_id",Lt.COLUMN_NAME_APP_VERSION="app_version",Lt.COLUMN_NAME_PAGE_ID="page_id",Lt.COLUMN_NAME_TIME_STAMP="time_stamp",Lt.COLUMN_NAME_ERROR_LOG="error_log",Lt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Lt.TABLE_NAME+" ("+Lt._ID+" INTEGER PRIMARY KEY"+r.COMMA_SEP+Lt.COLUMN_NAME_APP_VERSION+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Lt.COLUMN_NAME_PAGE_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Lt.COLUMN_NAME_TIME_STAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+Lt.COLUMN_NAME_ERROR_LOG+r.SPACE+r.TEXT_TYPE+" )",Lt.deleteTable=()=>"DROP TABLE IF EXISTS"+Lt.TABLE_NAME,(Dt=Pt||(Pt={})).TABLE_NAME="search_history",Dt._ID="_id",Dt.COLUMN_NAME_USER_ID="uid",Dt.COLUMN_NAME_QUERY="query",Dt.COLUMN_NAME_TIME_STAMP="time_stamp",Dt.COLUMN_NAME_NAMESPACE="namespace",Dt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Dt.TABLE_NAME+" ("+Dt._ID+" INTEGER PRIMARY KEY"+r.COMMA_SEP+Dt.COLUMN_NAME_USER_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Dt.COLUMN_NAME_QUERY+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Dt.COLUMN_NAME_TIME_STAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+Dt.COLUMN_NAME_NAMESPACE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+"UNIQUE ("+Dt.COLUMN_NAME_USER_ID+r.COMMA_SEP+Dt.COLUMN_NAME_QUERY+") ON CONFLICT REPLACE )",Dt.deleteTable=()=>"DROP TABLE IF EXISTS"+Dt.TABLE_NAME,(Ut=wt||(wt={})).TABLE_NAME="course_assessment",Ut._ID="_id",Ut.COLUMN_NAME_ASSESSMENT_EVENT="assessment_event",Ut.COLUMN_NAME_CREATED_AT="created_at",Ut.COLUMN_NAME_USER_ID="user_id",Ut.COLUMN_NAME_CONTENT_ID="content_id",Ut.COLUMN_NAME_COURSE_ID="course_id",Ut.COLUMN_NAME_BATCH_ID="batch_id",Ut.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS"+r.SPACE+Ut.TABLE_NAME+r.SPACE+"("+Ut._ID+r.SPACE+"INTEGER PRIMARY KEY,"+Ut.COLUMN_NAME_ASSESSMENT_EVENT+r.SPACE+r.TEXT_TYPE+","+Ut.COLUMN_NAME_CREATED_AT+r.SPACE+r.INT_TYPE+","+Ut.COLUMN_NAME_USER_ID+r.SPACE+r.TEXT_TYPE+","+Ut.COLUMN_NAME_CONTENT_ID+r.SPACE+r.TEXT_TYPE+","+Ut.COLUMN_NAME_COURSE_ID+r.SPACE+r.TEXT_TYPE+","+Ut.COLUMN_NAME_BATCH_ID+r.SPACE+r.TEXT_TYPE+")",Ut.deleteTable=()=>"DROP TABLE IF EXISTS"+Ut.TABLE_NAME,function(e){e.TABLE_NAME="network_queue",e._ID="_id",e.COLUMN_NAME_MSG_ID="msg_id",e.COLUMN_NAME_PRIORITY="priority",e.COLUMN_NAME_TIMESTAMP="timestamp",e.COLUMN_NAME_DATA="data",e.COLUMN_NAME_REQUEST="request",e.COLUMN_NAME_NUMBER_OF_ITEM="item_count",e.COLUMN_NAME_CONFIG="config",e.COLUMN_NAME_TYPE="type",e.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+e.TABLE_NAME+" ("+e._ID+" INTEGER PRIMARY KEY"+r.COMMA_SEP+e.COLUMN_NAME_MSG_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_PRIORITY+r.SPACE+r.INT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_TIMESTAMP+r.SPACE+r.INT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_DATA+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_NUMBER_OF_ITEM+r.SPACE+r.INT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_CONFIG+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_TYPE+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+e.COLUMN_NAME_REQUEST+r.SPACE+r.TEXT_TYPE+")",e.deleteTable=()=>"DROP TABLE IF EXISTS"+e.TABLE_NAME;e.Mapper=class{static networkQueueRequestToEntry(t){return{[e.COLUMN_NAME_MSG_ID]:t.msgId,[e.COLUMN_NAME_PRIORITY]:t.priority,[e.COLUMN_NAME_TIMESTAMP]:t.ts,[e.COLUMN_NAME_DATA]:t.data,[e.COLUMN_NAME_NUMBER_OF_ITEM]:t.itemCount,[e.COLUMN_NAME_CONFIG]:t.config,[e.COLUMN_NAME_TYPE]:t.type,[e.COLUMN_NAME_REQUEST]:t.networkRequest.toJSON()}}}}(jt||(jt={})),function(e){e.TELEMETRY="telemetry",e.COURSE_PROGRESS="course_progress",e.COURSE_ASSESMENT="course_assesment"}(Ft||(Ft={})),(xt=kt||(kt={})).TABLE_NAME="player_data",xt._ID="_id",xt.COLUMN_NAME_USER_ID="user_id",xt.COLUMN_PARENT_IDENTIFIER="parent_identifier",xt.COLUMN_IDENTIFIER="identifier",xt.COLUMN_PLAYER_CONFIG="player_config",xt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+xt.TABLE_NAME+" ("+xt._ID+" INTEGER PRIMARY KEY"+r.COMMA_SEP+xt.COLUMN_NAME_USER_ID+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+xt.COLUMN_PARENT_IDENTIFIER+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+xt.COLUMN_IDENTIFIER+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+xt.COLUMN_PLAYER_CONFIG+r.SPACE+r.TEXT_TYPE+")",xt.deleteTable=()=>"DROP TABLE IF EXISTS "+xt.TABLE_NAME,xt.getAlterEntryForPlayerConfig=()=>`ALTER TABLE ${xt.TABLE_NAME} ADD COLUMN ${xt.COLUMN_PLAYER_CONFIG} TEXT DEFAULT ''`;class Ht{static mapPlayerDbEntryToPlayer(e){return{userId:e[kt.COLUMN_NAME_USER_ID],parentId:e[kt.COLUMN_PARENT_IDENTIFIER],contentId:e[kt.COLUMN_IDENTIFIER],saveState:e[kt.COLUMN_PLAYER_CONFIG]}}static mapPlayerStateToPlayerDbEntry(e,t,n,r){return{[kt.COLUMN_NAME_USER_ID]:e,[kt.COLUMN_PARENT_IDENTIFIER]:t,[kt.COLUMN_IDENTIFIER]:n,[kt.COLUMN_PLAYER_CONFIG]:r}}}(Vt=Bt||(Bt={}))._ID="_id",Vt.TABLE_NAME="certificate_public_key",Vt.COLUMN_NAME_IDENTIFIER="identifier",Vt.COLUMN_NAME_PUBLIC_KEY="public_key",Vt.COLUMN_NAME_ALGORITHM="alg",Vt.COLUMN_NAME_OWNER="owner",Vt.COLUMN_NAME_EXPIRY_TIME="expiry_time",Vt.getCreateEntry=()=>"CREATE TABLE IF NOT EXISTS "+Vt.TABLE_NAME+" ("+Vt._ID+" INTEGER PRIMARY KEY,"+Vt.COLUMN_NAME_IDENTIFIER+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Vt.COLUMN_NAME_PUBLIC_KEY+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Vt.COLUMN_NAME_ALGORITHM+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Vt.COLUMN_NAME_OWNER+r.SPACE+r.TEXT_TYPE+r.COMMA_SEP+Vt.COLUMN_NAME_EXPIRY_TIME+r.SPACE+r.INT_TYPE+" )",Vt.deleteTable=()=>"DROP TABLE IF EXISTS "+Vt.TABLE_NAME;var $t=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class qt extends i{constructor(){super(1,16)}apply(e){return $t(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise()))}))}queries(){return[He.getCreateEntry(),qe.getCreateEntry(),Xe.getCreateEntry(),ze.getCreateEntry(),nt.getCreateEntry(),et.getCreateEntry(),ct.getCreateEntry(),_t.getCreateEntry(),St.getCreateEntry(),lt.getCreateEntry(),ht.getCreateEntry(),At.getCreateEntry(),Tt.getCreateEntry(),mt.getCreateEntry(),pt.getCreateEntry(),ft.getCreateEntry(),It.getCreateEntry(),vt.getCreateEntry(),Rt.getCreateEntry(),Pt.getCreateEntry(),wt.getCreateEntry(),jt.getCreateEntry(),kt.getCreateEntry(),Bt.getCreateEntry()]}}class Kt{constructor(){this.query=""}where(e){return this.query+=e.trim(),new Kt.WhereDecorator(this)}build(){return this.query}}Kt.ConstraintDecorator=class{constructor(e){this.queryBuilder=e}and(){return this.queryBuilder.query+=" AND ",this.queryBuilder}or(){return this.queryBuilder.query+=" OR ",this.queryBuilder}end(){return this.queryBuilder}},Kt.WhereDecorator=class{constructor(e){this.queryBuilder=e}args(e){return e.forEach(e=>{this.interpolate(e)}),new Kt.ConstraintDecorator(this.queryBuilder)}interpolate(e){isNaN(e)&&(e='"'+e+'"'),this.queryBuilder.query=this.queryBuilder.query.replace("?",e)}};var zt=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Wt=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Xt=function(e,t){return function(n,r){t(n,r,e)}},Jt=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let Qt=class{constructor(e,t,n){this.sdkConfig=e,this.dBVersion=t,this.appMigrationList=n,this.context=this.sdkConfig.dbConfig}update(e){return new c.Observable(t=>{db.update(e.table,e.selection||"",e.selectionArgs||[],e.modelJson,e.useExternalDb||!1,e=>{t.next(e),t.complete()},e=>{t.error(e)})})}init(){return Jt(this,void 0,void 0,(function*(){return new Promise(e=>{db.init(this.context.dbName,this.dBVersion,[],e=>Jt(this,void 0,void 0,(function*(){"onCreate"===e.method?yield this.onCreate():"onUpgrade"===e.method&&(yield this.onUpgrade(e.oldVersion,e.newVersion))}))),this.hasInitialized().subscribe(()=>{e(void 0)})})}))}hasInitialized(){return this.execute("DROP TABLE IF EXISTS dummy_init_table")}delete(e){const t=`\n DELETE FROM ${e.table}\n WHERE ${(new Kt).where(e.selection).args(e.selectionArgs).end().build()}\n `;return new c.Observable(n=>{db.execute(t,e.useExternalDb||!1,e=>{n.next(e),n.complete()},e=>{n.error(e)})})}onCreate(){return Jt(this,void 0,void 0,(function*(){return(new qt).apply(this)}))}onUpgrade(e,t){return Jt(this,void 0,void 0,(function*(){for(const n of this.appMigrationList){let r;r=n instanceof i?n:n(),console.log("Migration",r),r.required(e,t)&&(yield r.apply(this))}}))}execute(e,t){return new c.Observable(n=>{db.execute(e,t||!1,e=>{n.next(e),n.complete()},e=>{n.error(e)})})}read(e){return new c.Observable(t=>{db.read(!!e.distinct,e.table,e.columns||[],e.selection||"",e.selectionArgs||[],e.groupBy||"",e.having||"",e.orderBy||"",e.limit||"",e.useExternalDb||!1,e=>{t.next(e),t.complete()},e=>{t.error(e)})})}insert(e){return new c.Observable(t=>{db.insert(e.table,e.modelJson,e.useExternalDb||!1,e=>{t.next(e),t.complete()},e=>{t.error(e)})})}beginTransaction(){db.beginTransaction()}endTransaction(e,t){db.endTransaction(e,t||!1)}copyDatabase(e){return new c.Observable(t=>{db.copyDatabase(e,e=>{t.next(e),t.complete()},e=>{t.error(e)})})}open(e){return new Promise((t,n)=>{db.open(e,e=>{t(e)},e=>{n()})})}};Qt=zt([Object(s.injectable)(),Xt(0,Object(s.inject)(l.SDK_CONFIG)),Xt(1,Object(s.inject)(l.DB_VERSION)),Xt(2,Object(s.inject)(l.DB_MIGRATION_LIST)),Wt("design:paramtypes",[Object,Number,Array])],Qt);var Zt=n(46);class en{static generateUniqueId(){return Zt()}}var tn=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},nn=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},rn=function(e,t){return function(n,r){t(n,r,e)}};let on=class{constructor(e,t,n,r){this.sdkConfig=e,this.deviceInfo=t,this.appInfo=n,this.codePushExperimentService=r,this.apiConfig=this.sdkConfig.apiConfig}decorate(e,t,n,r=0,i,o,s){const{uid:a,sid:c}=t;return e.ets+=r,e.mid||(e.mid=en.generateUniqueId()),a?this.patchActor(e,a):this.patchActor(e,""),this.patchContext(e,c,i,o,s),e.context.cdata=[...e.context.cdata,{id:t.managedSession?t.managedSession.sid:t.uid,type:"Guest user"}],e}patchActor(e,t){e.actor||(e.actor=new pe);const n=e.actor;n.id||(n.id=t),n.type||(n.type=pe.TYPE_USER)}patchContext(e,t,n,r,i){e.context||(e.context=new _e),e.context=this.buildContext(t,n,e.context,r,i)}patchPData(e){var t,n,r;e.pdata||(e.pdata=new ve);const i=e.pdata;i.id||(i.id=this.apiConfig.api_authentication.producerId);const o=i.pid;o?i.pid=o:this.apiConfig.api_authentication.producerUniqueId?i.pid=this.apiConfig.api_authentication.producerUniqueId:i.pid="sunbird.android",i.ver||(i.ver=this.appInfo.getVersionName()),i.platform||(i.platform=`${null===(t=window.device)||void 0===t?void 0:t.platform}-${(null===(n=window.device)||void 0===n?void 0:n.version)||(null===(r=window.device)||void 0===r?void 0:r.sdkVersion)}`)}prepare(e,t){return{event:JSON.stringify(e),event_type:e.eid,timestamp:Date.now(),priority:1}}buildContext(e,t,n,r,i){n.channel=t,this.patchPData(n),n.env||(n.env="app");const o=this.codePushExperimentService.getExperimentKey();return"string"==typeof o&&(n.pdata.pid=n.pdata.pid+"-"+o),n.sid=e,n.did=this.deviceInfo.getDeviceID(),t!==this.apiConfig.api_authentication.channelId&&(n.rollup={l1:t}),n.cdata=n.cdata?n.cdata.concat(r||[]):r||[],n.cdata=n.cdata?n.cdata.concat(i||[]):i||[],n}};on=tn([Object(s.injectable)(),rn(0,Object(s.inject)(l.SDK_CONFIG)),rn(1,Object(s.inject)(l.DEVICE_INFO)),rn(2,Object(s.inject)(l.APP_INFO)),rn(3,Object(s.inject)(l.CODEPUSH_EXPERIMENT_SERVICE)),nn("design:paramtypes",[Object,Object,Object,Object])],on);class sn extends ke{constructor(e){super(e,"INVALID_INPUT_FOR_SYNC_PREPROCESSOR"),Object.setPrototypeOf(this,sn.prototype)}}var an=n(16);class cn{process(e){if("string"!=typeof e)throw new sn('StringToGzippedString expects input of type "string"');return Object(an.gzip)(e,{to:"string"})}}class un{process(e){if("object"!=typeof e)throw new sn('TelemetryEntriesToStringPreprocessor expects input of type "object"');return JSON.stringify(e)}}class ln{static get log(){return bd.instance.telemetryService}}var dn=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class hn{constructor(e,t){this.networkQueue=e,this.sdkConfig=t}handle(e){return this.networkQueue.enqueue(new En(this.sdkConfig).generateNetworkQueueRequest(Ft.COURSE_PROGRESS,{request:e},en.generateUniqueId(),e.contents?e.contents.length:0,!0),!0).pipe(Object(D.mergeMap)(()=>new c.Observable(e=>{sbsync.onSyncSucces(t=>dn(this,void 0,void 0,(function*(){const n=t.courseProgressResponse,r=t.course_progress_error;n?e.next(n):r&&e.error(r),e.complete()})),t=>dn(this,void 0,void 0,(function*(){e.error(t)})))})))}}hn.UPDATE_CONTENT_STATE_ENDPOINT="/content/state/update";class En{constructor(e){this.config=e}generateNetworkQueueRequest(e,t,n,r,i){let o,s;if(e===Ft.TELEMETRY){const e=t.split("").map(e=>e.charCodeAt(0));o=new Uint8Array(e),s=(new a.CsRequest.Builder).withSerializer(a.CsHttpSerializer.RAW).withHost(this.config.telemetryConfig.host).withType(a.CsHttpRequestType.POST).withPath(this.config.telemetryConfig.apiPath+pn.TELEMETRY_ENDPOINT).withHeaders({"Content-Type":"application/json","Content-Encoding":"gzip"}).withBody(o).withBearerToken(!0).build()}else o=t,s=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.PATCH).withPath(this.config.courseServiceConfig.apiPath+hn.UPDATE_CONTENT_STATE_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody(o).build();return{msgId:n,data:e===Ft.TELEMETRY?t:JSON.stringify(t),networkRequest:s,priority:e===Ft.TELEMETRY?2:1,itemCount:r,type:e,config:JSON.stringify({shouldPublishResult:i}),ts:Date.now()}}}var fn=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class pn{constructor(e,t,n,r,i,o,s,a,c){this.dbService=e,this.sdkConfig=t,this.deviceInfo=n,this.sharedPreferences=r,this.appInfoService=i,this.deviceRegisterService=o,this.keyValueStore=s,this.apiService=a,this.networkQueue=c,this.preprocessors=[new un,new cn],this.telemetryConfig=this.sdkConfig.telemetryConfig,this.apiConfig=this.sdkConfig.apiConfig}resetDeviceRegisterTTL(){return Object(c.zip)(this.keyValueStore.setValue(pn.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY,""),this.keyValueStore.setValue(pn.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY,"")).pipe(Object(D.mapTo)(void 0))}handle({ignoreSyncThreshold:e,ignoreAutoSyncMode:t}){const n=!(!e||!t);return this.registerDevice().pipe(Object(D.catchError)(()=>(e=!0,Object(c.of)(void 0))),Object(D.mergeMap)(()=>this.hasTelemetryThresholdCrossed().pipe(Object(D.mergeMap)(t=>t||e?Object(c.defer)(()=>fn(this,void 0,void 0,(function*(){switch(yield this.sharedPreferences.getString(v.KEY_AUTO_SYNC_MODE).toPromise()){case de.OFF:return{syncedEventCount:0,syncTime:Date.now(),syncedFileSize:0,error:new Error("AUTO_SYNC_MODE: "+de.OFF)};case de.OVER_WIFI:if(navigator.connection.type!==Connection.WIFI)return{syncedEventCount:0,syncTime:Date.now(),syncedFileSize:0,error:new Error("AUTO_SYNC_MODE: "+de.OVER_WIFI)};break;case de.ALWAYS_ON:}let e,t={syncedEventCount:0,syncTime:Date.now(),syncedFileSize:0};do{try{e=yield this.processEventsBatch(n).toPromise(),t={syncedEventCount:t.syncedEventCount+e,syncTime:Date.now(),syncedFileSize:0}}catch(e){t={syncedEventCount:t.syncedEventCount,syncTime:Date.now(),syncedFileSize:0,error:e}}}while(e&&!t.error);return t}))):Object(c.of)({syncedEventCount:0,syncTime:Date.now(),syncedFileSize:0})))))}processEventsBatch(e){return this.fetchEvents().pipe(Object(D.mergeMap)(t=>this.processEvents(t).pipe(Object(D.mergeMap)(n=>this.persistinNetworkQueue(n,n.processedEventsSize,e).pipe(Object(D.mergeMap)(()=>this.deleteEvents(t)),Object(D.mapTo)(t.length))))))}registerDevice(){return Object(c.zip)(this.keyValueStore.getValue(pn.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY),this.keyValueStore.getValue(pn.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY)).pipe(Object(D.mergeMap)(e=>{const t=e[0],n=e[1];if(t&&n){const e="false"===n?pn.REGISTER_API_FAILURE_TTL:pn.REGISTER_API_SUCCESS_TTL;if(Math.abs(parseInt(t,10)-Date.now())<e)return Object(c.of)(void 0)}return this.deviceRegisterService.registerDevice().pipe(Object(D.tap)(e=>fn(this,void 0,void 0,(function*(){e.result.actions.forEach(e=>{"experiment"===e.type&&e.key&&this.sharedPreferences.putString(N.DEPLOYMENT_KEY,e.data.key).toPromise()});const t=new Date(e.ts).getTime(),n=Date.now(),r=t-n,i=Math.abs(r)>this.telemetryConfig.telemetryLogMinAllowedOffset?r:0;i&&(yield ln.log.interact({type:oe.OTHER,subType:se.DEVICE_TIME_OFFSET_FOUND,env:"sdk",pageId:"sdk",id:"sdk",valueMap:{deviceTime:n,offsetTime:i}}).toPromise(),yield this.keyValueStore.setValue(pn.TELEMETRY_LOG_MIN_ALLOWED_OFFSET_KEY,i+"").toPromise())}))),Object(D.mergeMap)(()=>Object(c.zip)(this.keyValueStore.setValue(pn.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY,Date.now()+""),this.keyValueStore.setValue(pn.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY,"true")).pipe(Object(D.mapTo)(void 0))),Object(D.catchError)(e=>Object(c.zip)(this.keyValueStore.setValue(pn.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY,Date.now()+""),this.keyValueStore.setValue(pn.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY,"false")).pipe(Object(D.mergeMap)(()=>{throw console.error(e),new Error("Device Registration Failed")}))))}))}hasTelemetryThresholdCrossed(){return this.dbService.execute("\n SELECT count(*) as COUNT FROM "+He.TABLE_NAME).pipe(Object(D.map)(e=>!!(e&&e[0]&&e[0].COUNT>=this.telemetryConfig.telemetrySyncThreshold)))}fetchEvents(){return this.dbService.execute(`\n SELECT * FROM ${He.TABLE_NAME}\n WHERE ${He.COLUMN_NAME_PRIORITY} = (SELECT MIN (${He.COLUMN_NAME_PRIORITY})\n FROM ${He.TABLE_NAME})\n ORDER BY ${He.COLUMN_NAME_TIMESTAMP}\n LIMIT ${this.telemetryConfig.telemetrySyncBandwidth}`)}processEvents(e){if(!e.length)return Object(c.of)({processedEventsSize:0});const t=en.generateUniqueId();return Object(c.of)({processedEvents:this.preprocessors.reduce((e,t)=>t.process(e),{id:"ekstep.telemetry",ver:"1.0",ts:b()().format("YYYY-MM-DDTHH:mm:ss[Z]"),events:e.map(e=>JSON.parse(e[He.COLUMN_NAME_EVENT])),params:{did:this.deviceInfo.getDeviceID(),msgid:t,key:"",requesterId:""}}),processedEventsSize:e.length,messageId:t})}persistinNetworkQueue({processedEvents:e,messageId:t},n,r){return e?this.networkQueue.enqueue(new En(this.sdkConfig).generateNetworkQueueRequest(Ft.TELEMETRY,e,t,n,r),!0).pipe(Object(D.mapTo)(void 0)):Object(c.of)(void 0)}deleteEvents(e){return e.length?this.dbService.execute(`\n DELETE FROM ${He.TABLE_NAME}\n WHERE ${He._ID} IN (${e.map(e=>e[He._ID]).join(",")})\n `):Object(c.of)(void 0)}}pn.TELEMETRY_LOG_MIN_ALLOWED_OFFSET_KEY="telemetry_log_min_allowed_offset_key",pn.LAST_SYNCED_DEVICE_REGISTER_ATTEMPT_TIME_STAMP_KEY="last_synced_device_register_attempt_time_stamp",pn.LAST_SYNCED_DEVICE_REGISTER_IS_SUCCESSFUL_KEY="last_synced_device_register_is_successful",pn.TELEMETRY_ENDPOINT="/telemetry",pn.REGISTER_API_SUCCESS_TTL=864e5,pn.REGISTER_API_FAILURE_TTL=36e5;var _n,On,Sn,gn,An,Nn,Tn,Cn,vn,yn,mn,bn,In,Mn,Rn,Ln,Pn,Dn=n(7);!function(e){e[e.NOT_FOUND=-1]="NOT_FOUND",e[e.DELETED_SUCCESSFULLY=1]="DELETED_SUCCESSFULLY"}(_n||(_n={})),function(e){e.ASC="asc",e.DESC="desc"}(On||(On={})),function(e){e[e.NOTHING=0]="NOTHING",e[e.PREVIEWED=1]="PREVIEWED",e[e.BOOKMARKED=2]="BOOKMARKED"}(Sn||(Sn={})),function(e){e.SEARCH="search",e.FILTER="filter"}(gn||(gn={})),function(e){e[e.ALL=0]="ALL",e[e.DOWNLOADED=1]="DOWNLOADED",e[e.SPINE=2]="SPINE"}(An||(An={})),function(e){e[e.SEEN_BUT_NOT_AVAILABLE=0]="SEEN_BUT_NOT_AVAILABLE",e[e.ONLY_SPINE=1]="ONLY_SPINE",e[e.ARTIFACT_AVAILABLE=2]="ARTIFACT_AVAILABLE"}(Nn||(Nn={})),function(e){e.APK="application/vnd.android.package-archive",e.ECML="application/vnd.ekstep.ecml-archive",e.HTML="application/vnd.ekstep.html-archive",e.COLLECTION="application/vnd.ekstep.content-collection",e.H5P="application/vnd.ekstep.h5p-archive",e.VIDEO="video/mp4",e.YOUTUBE="video/x-youtube",e.WEBM="video/webm",e.QUESTION="application/vnd.sunbird.question",e.QUESTION_SET="application/vnd.sunbird.questionset",e.EPUB="application/epub",e.ZIP="application/zip",e.TXT="text/plain",e.ECAR="application/ecar",e.EPAR="application/epar"}(Tn||(Tn={})),function(e){e.DEFAULT="Default",e.PARENT="Parent"}(Cn||(Cn={})),function(e){e.LIVE="Live",e.DRAFT="Draft"}(vn||(vn={})),function(e){e.GZIP="gzip",e.IDENTITY="identity"}(yn||(yn={})),function(e){e.ATTACHMENT="attachment",e.INLINE="inline",e.ONLINE="online"}(mn||(mn={})),function(e){e.CONTENT="ecar",e.PROFILE="epar",e.TELEMETRY="gsa"}(bn||(bn={})),function(e){e[e.NOT_FOUND=-1]="NOT_FOUND",e[e.ENQUEUED_FOR_DOWNLOAD=0]="ENQUEUED_FOR_DOWNLOAD",e[e.DOWNLOAD_STARTED=1]="DOWNLOAD_STARTED",e[e.DOWNLOAD_FAILED=2]="DOWNLOAD_FAILED",e[e.DOWNLOAD_COMPLETED=3]="DOWNLOAD_COMPLETED",e[e.IMPORT_STARTED=4]="IMPORT_STARTED",e[e.IMPORT_FAILED=5]="IMPORT_FAILED",e[e.NOT_COMPATIBLE=6]="NOT_COMPATIBLE",e[e.CONTENT_EXPIRED=7]="CONTENT_EXPIRED",e[e.ALREADY_EXIST=8]="ALREADY_EXIST",e[e.IMPORT_COMPLETED=100]="IMPORT_COMPLETED"}(In||(In={})),function(e){e.NO_DATA_FOUND="NO_DATA_FOUND",e.INVALID_FILE="INVALID_FILE",e.ECAR_NOT_FOUND="ECAR_NOT_FOUND",e.IMPORT_FAILED_DEVICE_MEMORY_FULL="IMPORT_FAILED_DEVICE_MEMORY_FULL",e.IMPORT_FAILED_EXTRACT_ECAR="IMPORT_FAILED_EXTRACTION",e.IMPORT_FAILED_MANIFEST_FILE_NOT_FOUND="IMPORT_FAILED_MANIFEST_FILE_NOT_FOUND",e.IMPORT_FAILED_UNSUPPORTED_MANIFEST="IMPORT_FAILED_UNSUPPORTED_MANIFEST",e.IMPORT_FAILED_NO_CONTENT_METADATA="IMPORT_FAILED_NO_CONTENT_METADATA",e.DUPLICATE_CONTENT="DUPLICATE_CONTENT",e.IMPORT_FILE_EXIST="IMPORT_FILE_EXIST",e.ECAR_CLEANUP_FAILED="ECAR_CLEANUP_FAILED",e.EXPORT_FAILED_COPY_ASSET="EXPORT_FAILED_COPY_ASSET",e.EXPORT_FAILED_MEMORY_NOT_SUFFICIENT="EXPORT_FAILED_MEMORY_NOT_SUFFICIENT",e.EXPORT_FAILED_WRITING_MANIFEST="EXPORT_FAILED_WRITE_MANIFEST",e.EXPORT_FAILED_ECAR_BUNDLE="EXPORT_FAILED_ECAR_BUNDLE",e.EXPORT_FAILED_NOTHING_TO_EXPORT="EXPORT_FAILED_NOTHING_TO_EXPORT",e.EXPORT_FAILED_DELETING_ECAR="EXPORT_FAILED_DELETING_ECAR"}(Mn||(Mn={})),function(e){e.EXPORT_FAILED="EXPORT_FAILED",e.IMPORT_FAILED="IMPORT_FAILED"}(Rn||(Rn={})),function(e){e.MANIFEST="manifest.json",e.HIERARCHY="hierarchy.json"}(Ln||(Ln={})),function(e){e.UPDATE="UPDATE",e.IMPORT_COMPLETED="IMPORT_COMPLETED",e.IMPORT_PROGRESS="IMPORT_PROGRESS",e.SERVER_CONTENT_DATA="SERVER_CONTENT_DATA",e.COURSE_STATE_UPDATED="COURSE_STATE_UPDATED",e.CONTENT_EXTRACT_COMPLETED="CONTENT_EXTRACT_COMPLETED"}(Pn||(Pn={}));class wn{static joinPreservingQuotes(e){return e.map(e=>`'${e}'`).join(",")}static isEmpty(e){return!e||0===e.length}static contains(e,t){return e&&-1!==e.indexOf(t)}static deDupe(e){return e.filter((e,t,n)=>n.indexOf(e)===t)}}var Un,jn=n(17),Fn=n(18);class kn{static isAvailableLocally(e){return e===Nn.ARTIFACT_AVAILABLE}static isUpdateAvailable(e,t){let n=-1,r=-1;return e&&e.pkgVersion&&(r=parseFloat(e.pkgVersion)),t&&t.pkgVersion&&(n=parseFloat(t.pkgVersion)),r>0&&n>0&&r>n}static hasChildren(e){return!!e&&("string"==typeof e&&(e=JSON.parse(e)),e&&e.children)}static getContentRollup(e,t){let n,r,i,o;if(t&&0!==t.length)for(let e=0;e<t.length;e++)if(0===e)n=t[e].identifier;else if(1===e)r=t[e].identifier;else if(2===e)i=t[e].identifier;else{if(3!==e)break;o=t[e].identifier}else n=e;return{l1:n,l2:r,l3:i,l4:o}}static getChildContentsIdentifiers(e){const t=[];let n;n="string"==typeof e?JSON.parse(e):e;const r=n.children;return r&&r.length&&r.forEach(e=>{t.push(e.identifier)}),t}static getFirstPartOfThePathNameOnLastDelimiter(e){const t=e.lastIndexOf("/");if(t>0&&t<e.length)return e.substring(0,t)}static hasPreRequisites(e){return JSON.parse(e).pre_requisites}static readVisibility(e){const t=e.visibility;return t||Cn.DEFAULT}static isCompatible(e,t){return t>=e.minCompatibilityLevel&&t<=e.maxCompatibilityLevel}static readCompatibilityLevel(e){const t=e.compatibilityLevel;return t||this.defaultCompatibilityLevel}static isDraftContent(e){return e&&e===vn.DRAFT.valueOf()}static isExpired(e){if(e){const t=new Date(e).getTime();if((new Date).getTime()>t)return!0}return!1}static isDuplicateCheckRequired(e,t){return e&&0===t}static isImportFileExist(e,t){if(!e||!t)return!1;let n=!1;const r=e[St.COLUMN_NAME_IDENTIFIER],i=t.identifier,o=e[St.COLUMN_NAME_VISIBILITY],s=kn.readVisibility(t);return r===i&&o===s&&(n=this.readPkgVersion(JSON.parse(e[St.COLUMN_NAME_LOCAL_DATA]))>=this.readPkgVersion(t)),n}static readPkgVersion(e){return e.pkgVersion}static readContentType(e){let t=e.contentType;return t&&(t=t.toLowerCase()),t}static readPrimaryCategory(e){let t=e.primaryCategory;return t=t?t.toLowerCase():jn.CsPrimaryCategoryMapper.getPrimaryCategory(e.contentType.toLowerCase(),e.mimeType,e.resourceType).toLowerCase(),t}static readPrimaryCategoryServer(e){let t=e.primaryCategory;return t=t||jn.CsPrimaryCategoryMapper.getPrimaryCategory(e.contentType.toLowerCase(),e.mimeType,e.resourceType),t}static readAudience(e){const t=e.audience,n=[];return"string"==typeof t&&n.push(t),n&&n.length||n.push("Learner"),n.sort(),n.join(",")}static readPragma(e){let t=e.pragma;return t||(t=[]),t.join(",")}static doesContentExist(e,t,n,r){if(!e)return!1;let i=!1;const o=e[St.COLUMN_NAME_IDENTIFIER],s=JSON.parse(e[St.COLUMN_NAME_LOCAL_DATA]);if(o===t){let t=!1;r?t=!(kn.readPkgVersion(s)<n):kn.readPkgVersion(s)<n&&(t=!0),i=!(t||!r&&e[St.COLUMN_NAME_CONTENT_STATE]!==Nn.ARTIFACT_AVAILABLE.valueOf())}return i}static getContentRootDir(e){return"ios"===window.device.platform.toLowerCase()?e.concat("content/"):e.concat("content")}static addOrUpdateViralityMetadata(e,t){if(kn.isContentMetadataAbsent(e)){const n={};n.origin=t,n.transferCount=kn.INITIAL_VALUE_FOR_TRANSFER_COUNT;const r={};r.virality=n,e.contentMetadata=r}else if(kn.isContentMetadataPresentWithoutViralityMetadata(e)){const n={};n.origin=t,n.transferCount=kn.INITIAL_VALUE_FOR_TRANSFER_COUNT,e.contentMetaData.virality=n}else{const t=e.contentMetaData.virality;t.transferCount=kn.transferCount(t)+1}}static addViralityMetadataIfMissing(e,t){e.contentMetaData||(e.contentMetaData={});const n=e.contentMetaData;n.virality||(n.virality={});let r=e.virality;r||(r={}),r.origin||(r.origin=t),r.transferCount||(r.transferCount=kn.INITIAL_VALUE_FOR_TRANSFER_COUNT)}static isInlineIdentity(e,t){return e&&t&&mn.INLINE.valueOf()===e&&yn.IDENTITY.valueOf()===t}static isOnlineContent(e){const t=e.contentDisposition;return t&&mn.ONLINE.valueOf()===t}static addOrUpdateDialcodeMapping(e,t,n){let r;r=e?JSON.parse(e):{},r.hasOwnProperty("identifier")||(r.identifier=t);const i=new Set;return r.hasOwnProperty("rootNodes")&&r.forEach(e=>{i.add(e)}),i.add(n),r.rootNodes=i,JSON.stringify(r)}static deDupe(e,t){return e.filter((e,n,r)=>r.map(e=>e[t]).indexOf(e[t])===n)}static getExportedFileName(e,t){let n,r="blank.ecar",i=0;e.length>0&&(n=e[0]);if(e.forEach(e=>{Cn.DEFAULT.valueOf()===e[St.COLUMN_NAME_VISIBILITY]&&i++}),i>1&&"".concat((i-1).toString()),n){const e=JSON.parse(n[St.COLUMN_NAME_LOCAL_DATA]);let i=e.name;i&&i.length>kn.MAX_CONTENT_NAME&&(i=i.substring(0,kn.MAX_CONTENT_NAME-3)+"...");const o=e.pkgVersion;r=`${t.toLowerCase()}_${i}-v${o}.ecar`}return r}static readOriginFromContentMap(e){const t=e.contentMetadata,n=t&&t.virality;return n?n.origin:""}static readTransferCountFromContentMap(e){const t=e.contentMetadata,n=t&&t.virality;return n?fe.parseInt(n.transferCount):0}static readSizeFromContentMap(e){return e.size?e.size:""}static getUidnIdentifierFiler(e,t){const n=e&&`uid = '${e}'`,r=t&&`identifier = '${t}'`;let i="";return n&&r?i=`WHERE (${r} AND ${n})`:r?i=`WHERE (${r})`:n&&(i=`WHERE (${n})`),i}static getBasePath(e){return e?e=-1!==e.indexOf("file://")?e.replace("file://",""):"file://".concat(e):""}static getRollup(e,t){let n,r,i,o;if(t){let e;for(e=0;e<t.length;e++)switch(e){case 0:n=t[e].identifier;break;case 1:r=t[e].identifier;break;case 2:i=t[e].identifier;break;case 3:o=t[e].identifier}}else n=e;return{l1:n,l2:r,l3:i,l4:o}}static addOrUpdateRefCount(e){return e<0&&(e=0),e}static isNotUnit(e,t){return!(Tn.COLLECTION.valueOf()===e&&Cn.PARENT.valueOf()===t)}static getContentAttribute(e){let t=[];if(e&&("string"==typeof e?t.push(e):t=e,t&&t.length)){t.sort();let e="";for(let n=0;n<t.length;n++)e=n<t.length-1?e.concat("~",t[n]):e.concat("~",t[n],"~");return e.toLowerCase().trim()}return""}static getFindAllContentsWithIdentifierQuery(e){const t=wn.joinPreservingQuotes(e),n=` order by ${St.COLUMN_NAME_LOCAL_LAST_UPDATED_ON} desc, ${St.COLUMN_NAME_SERVER_LAST_UPDATED_ON} desc`,r=` where ${St.COLUMN_NAME_IDENTIFIER} in (${t}) AND ${St.COLUMN_NAME_REF_COUNT} > 0`;return`select * from ${St.TABLE_NAME} ${r} ${n}`}static getFindAllContentsQuery(){return`select * from ${St.TABLE_NAME} where ${St.COLUMN_NAME_REF_COUNT} > 0`}static constructContentDBModel(e,t,n,r,i,o,s,a,c,u,l,d,h,E,f,p){return{[St.COLUMN_NAME_IDENTIFIER]:e,[St.COLUMN_NAME_SERVER_DATA]:"",[St.COLUMN_NAME_PATH]:kn.getBasePath(s),[St.COLUMN_NAME_REF_COUNT]:a,[St.COLUMN_NAME_CONTENT_STATE]:c,[St.COLUMN_NAME_SIZE_ON_DEVICE]:d,[St.COLUMN_NAME_MANIFEST_VERSION]:t,[St.COLUMN_NAME_LOCAL_DATA]:n,[St.COLUMN_NAME_MIME_TYPE]:r,[St.COLUMN_NAME_CONTENT_TYPE]:i,[St.COLUMN_NAME_VISIBILITY]:o,[St.COLUMN_NAME_AUDIENCE]:u,[St.COLUMN_NAME_PRAGMA]:l,[St.COLUMN_NAME_LOCAL_LAST_UPDATED_ON]:b()().format(),[St.COLUMN_NAME_BOARD]:kn.getContentAttribute(h),[St.COLUMN_NAME_MEDIUM]:kn.getContentAttribute(E),[St.COLUMN_NAME_GRADE]:kn.getContentAttribute(f),[St.COLUMN_NAME_PRIMARY_CATEGORY]:p}}static getReferenceCount(e,t){let n;return e?(n=e[St.COLUMN_NAME_REF_COUNT],Cn.DEFAULT.valueOf()===e[St.COLUMN_NAME_VISIBILITY]&&Cn.DEFAULT.valueOf()===t||(n+=1)):n=1,n}static getContentVisibility(e,t,n){let r;return"Library"===t?r=Cn.PARENT.valueOf():e&&!Cn.PARENT.valueOf()===e[St.COLUMN_NAME_VISIBILITY]&&(r=e[St.COLUMN_NAME_VISIBILITY]),r||n}static getContentState(e,t){return e&&e[St.COLUMN_NAME_CONTENT_STATE]>t&&(t=e[St.COLUMN_NAME_CONTENT_STATE]),t}static isFreeSpaceAvailable(e,t,n){let r=10240;return n>0&&(r=n),e>0&&e>t+r}static transferCount(e){const t=e.transferCount;return parseInt(t,0)}static isContentMetadataAbsent(e){return!Boolean(e.contentMetaData)}static isContentMetadataPresentWithoutViralityMetadata(e){return!Boolean(e.contentMetaData.virality)}static isTrackable(e){return e.trackable&&"string"==typeof e.trackable&&(e.trackable=JSON.parse(e.trackable)),e.trackable&&e.trackable.enabled?e.trackable.enabled===Dn.TrackingEnabled.YES?1:e.mimeType===Tn.COLLECTION?0:-1:e.contentType.toLowerCase()===Fn.CsContentType.COURSE.toLowerCase()?1:e.mimeType===Tn.COLLECTION?0:-1}static getParseErrorObject(e){try{return JSON.parse(e)}catch(e){return}}}kn.defaultCompatibilityLevel=1,kn.DEFAULT_PACKAGE_VERSION=-1,kn.INITIAL_VALUE_FOR_TRANSFER_COUNT=0,kn.MAX_CONTENT_NAME=30;class xn{static mapContentDataToContentDBEntry(e,t){let n,r,i;return t?i=JSON.stringify(e):(n=e.lastUpdatedOn,r=JSON.stringify(e)),{[St.COLUMN_NAME_IDENTIFIER]:e.identifier,[St.COLUMN_NAME_SERVER_DATA]:r,[St.COLUMN_NAME_SERVER_LAST_UPDATED_ON]:n,[St.COLUMN_NAME_MANIFEST_VERSION]:t,[St.COLUMN_NAME_LOCAL_DATA]:i,[St.COLUMN_NAME_MIME_TYPE]:e.mimeType,[St.COLUMN_NAME_CONTENT_TYPE]:kn.readContentType(e),[St.COLUMN_NAME_VISIBILITY]:kn.readVisibility(e),[St.COLUMN_NAME_AUDIENCE]:kn.readAudience(e),[St.COLUMN_NAME_PRAGMA]:kn.readPragma(e),[St.COLUMN_NAME_PRIMARY_CATEGORY]:kn.readPrimaryCategory(e)}}static mapServerResponseToContent(e,t){let n,r,i;t?i=e:(n=e.lastUpdatedOn,r=e),!e.primaryCategory&&e.contentType&&e.mimeType&&(e.primaryCategory=jn.CsPrimaryCategoryMapper.getPrimaryCategory(e.contentType.toLowerCase(),e.mimeType,e.resourceType));const o=e.primaryCategory?e.primaryCategory:e.contentType;return!e.trackable&&o&&o.toLowerCase()===Fn.CsContentType.COURSE.toLowerCase()&&(e.trackable={enabled:Dn.TrackingEnabled.YES}),e.trackable||(e.trackable={enabled:Dn.TrackingEnabled.NO}),{identifier:e.identifier,name:e.name,contentData:e,isUpdateAvailable:kn.isUpdateAvailable(r,i),mimeType:e.mimeType,basePath:"",contentType:kn.readContentType(e),primaryCategory:kn.readPrimaryCategory(e),isAvailableLocally:!1,referenceCount:0,sizeOnDevice:0,lastUsedTime:0,lastUpdatedTime:0}}static mapContentDBEntryToContent(e,t){let n;const r=e[St.COLUMN_NAME_SERVER_DATA],i=e[St.COLUMN_NAME_LOCAL_DATA],o=r&&JSON.parse(r);let s,a=i&&JSON.parse(i),c=e[St.COLUMN_NAME_IDENTIFIER],u=e[St.COLUMN_NAME_MIME_TYPE],l=e[St.COLUMN_NAME_VISIBILITY],d=e[St.COLUMN_NAME_CONTENT_TYPE],h=e[St.COLUMN_NAME_PRIMARY_CATEGORY],E=0;e.hasOwnProperty(At.COLUMN_NAME_EPOCH_TIMESTAMP)&&(E=e[At.COLUMN_NAME_EPOCH_TIMESTAMP]),e.hasOwnProperty(vt.COLUMN_NAME_DATA)&&(a||(a=JSON.parse(e[vt.COLUMN_NAME_DATA])),a&&(c=a.identifier,u=a.mimeType,s=a.resourceType,l=kn.readVisibility(a),d=kn.readContentType(a),h=kn.readPrimaryCategory(a))),a&&(n=a),o&&(a&&kn.isAvailableLocally(e[St.COLUMN_NAME_CONTENT_STATE])?(a.streamingUrl||(a.streamingUrl=o.streamingUrl),a.previewUrl||(a.previewUrl=o.previewUrl),o.me_totalRatingsCount&&(a.me_totalRatingsCount=o.me_totalRatingsCount),o.me_averageRating&&(a.me_averageRating=o.me_averageRating),a.size||(a.size=o.size),o.licenseDetails&&(a.licenseDetails=o.licenseDetails),o.forumId&&(a.forumId=o.forumId)):n=o);let f=0;const p=e[St.COLUMN_NAME_LOCAL_LAST_UPDATED_ON];p&&(f=new Date(p).getTime());const _=Number(e[St.COLUMN_NAME_SIZE_ON_DEVICE]),O=_||Number(o?o.size:0);!n.trackable&&h&&h.toLowerCase()===Fn.CsContentType.COURSE.toLowerCase()&&(n.trackable={enabled:Dn.TrackingEnabled.YES}),n.trackable||(n.trackable={enabled:Dn.TrackingEnabled.NO}),s=n.resourceType,!n.primaryCategory&&d&&(n.primaryCategory=jn.CsPrimaryCategoryMapper.getPrimaryCategory(d.toLowerCase(),u,s));const S=e[St.COLUMN_NAME_PATH]||"";return"string"==typeof n.originData&&(n.originData=kn.getParseErrorObject(n.originData)),n.trackable&&"string"==typeof n.trackable&&(n.trackable=JSON.parse(n.trackable)),{identifier:c,name:n.name,contentData:n,isUpdateAvailable:kn.isUpdateAvailable(o,a),mimeType:u,basePath:t?"/_app_file_"+S:S,primaryCategory:h,contentType:d,isAvailableLocally:kn.isAvailableLocally(e[St.COLUMN_NAME_CONTENT_STATE]),referenceCount:Number(e[St.COLUMN_NAME_REF_COUNT])||0,sizeOnDevice:O,lastUsedTime:E||0,lastUpdatedTime:f}}}class Bn{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.open(e.sourceDBFilePath).then(()=>this.dbService.read({table:Qe.TABLE_NAME,useExternalDb:!0}).toPromise()).then(n=>{if(!n||!n.length)throw t.errorMesg=Rn.IMPORT_FAILED.valueOf(),t;const r={};n.forEach(e=>{r[e.key]=e.value}),e.metadata=r;const i=this.getImportTypes(r);if(i&&wn.contains(i,"telemetry")){const e=r.export_id,t=r.did;return this.dbService.read({table:ct.TABLE_NAME,selection:`${ct.COLUMN_NAME_IMPORTED_ID} = ?\n AND ${ct.COLUMN_NAME_DEVICE_ID} = ?`,selectionArgs:[e,t]}).toPromise()}throw t.errorMesg=Rn.IMPORT_FAILED.valueOf(),t}).then(n=>{if(n&&n.length)throw t.errorMesg=Rn.IMPORT_FAILED.valueOf(),t;return t.body=e,t})}getImportTypes(e){let t=[];return e.hasOwnProperty("types")&&(t=e.types),t}}!function(e){e.SAVE="SAVE"}(Un||(Un={}));var Vn,Yn=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Gn{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:qe.TABLE_NAME,useExternalDb:!0}).toPromise().then(e=>this.saveProccessedTelemetryToDB(e)).then(()=>(t.body=e,t))}saveProccessedTelemetryToDB(e){return Yn(this,void 0,void 0,(function*(){e.forEach(e=>Yn(this,void 0,void 0,(function*(){yield this.dbService.insert({table:qe.TABLE_NAME,modelJson:e})})))}))}}class Hn{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse,n=e.metadata.export_id,r=e.metadata.did,i={imported_id:n,device_id:r,count:e.metadata.events_count};return this.dbService.read({table:ct.TABLE_NAME,selection:`${ct.COLUMN_NAME_IMPORTED_ID} = ? AND ${ct.COLUMN_NAME_DEVICE_ID} = ?`,selectionArgs:[n,r],limit:"1"}).toPromise().then(e=>e&&e.length?this.dbService.update({table:ct.TABLE_NAME,modelJson:i}).toPromise():this.dbService.insert({table:ct.TABLE_NAME,modelJson:i}).toPromise()).then(()=>(t.body=e,t))}}class $n{constructor(e,t){this.dbService=e,this.telemetryService=t}execute(e){const t=new a.CsResponse;return this.dbService.read({table:ct.TABLE_NAME}).toPromise().then(e=>{const t=[];e.forEach(e=>{const n={type:ie.TELEMETRY,origin:e[ct.COLUMN_NAME_DEVICE_ID],identifier:e[ct.COLUMN_NAME_IMPORTED_ID],pkgVersion:0,transferCount:0,size:""};t.push(n)});const n={dir:ne.IN,type:re.FILE.valueOf(),items:t,env:"sdk"};return this.telemetryService.share(n).toPromise()}).then(()=>(t.body=e,t))}}!function(e){e.ONLINE="ONLINE",e.OFFLINE="OFFLINE"}(Vn||(Vn={}));var qn=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Kn{constructor(e,t){this.telemetryService=e,this.sharedPreferences=t,this.shouldSync=!1}static generateDownloadSpeedTelemetry(e){return qn(this,void 0,void 0,(function*(){const t=yield new Promise((e,t)=>{downloadManager.fetchSpeedLog?downloadManager.fetchSpeedLog((t,n)=>e(n),t):cordova.exec(e,t,"DownloadManagerPlugin","fetchSpeedLog",[])}),n={32:"0-32",64:"32-64",128:"64-128",256:"128-256",512:"256-512",1024:"512-1024",1536:"1024-1536",2048:"1536-2048",2560:"2048-2560",3072:"2560-3072",3584:"3072-3584",4096:"3584-above"};if(!Object.keys(null==t?void 0:t.distributionInKBPS).length)return;const r={duration:e/1e3,totalKBDownloaded:null==t?void 0:t.totalKBdownloaded,distributionInKBPS:Object.keys(n).reduce((e,r)=>((null==t?void 0:t.distributionInKBPS[r])?e[n[r]]=t.distributionInKBPS[r]:e[n[r]]=0,e),{})};return ln.log.interact({type:oe.OTHER,subType:se.NETWORK_SPEED,env:"sdk",pageId:"sdk",id:"sdk",valueMap:r}).pipe(Object(D.mapTo)(void 0)).toPromise()}))}getSyncMode(){return this.sharedPreferences.getString(v.KEY_AUTO_SYNC_MODE).pipe(Object(D.map)(e=>e))}setSyncMode(e){return this.sharedPreferences.putString(v.KEY_AUTO_SYNC_MODE,e)}start(e){return this.shouldSync=!0,Object(c.interval)(e).pipe(Object(D.tap)(t=>{t*e%Kn.DOWNLOAD_SPEED_TELEMETRY_SYNC_INTERVAL==0&&"ios"!==window.device.platform.toLowerCase()&&Kn.generateDownloadSpeedTelemetry(e)}),Object(D.filter)(()=>this.shouldSync),Object(D.tap)(()=>this.telemetryService.sync().pipe(Object(D.tap)(e=>{console.log("AUTO_SYNC_INVOKED_SYNC----------------------------------------------",e)}),Object(D.catchError)(e=>(console.error(e),Object(c.of)(void 0)))).toPromise()),Object(D.mapTo)(void 0))}pause(){this.shouldSync=!1}continue(){this.shouldSync=!0}}Kn.DOWNLOAD_SPEED_TELEMETRY_SYNC_INTERVAL=6e4;var zn,Wn,Xn,Jn,Qn=n(32);!function(e){e.STUDENT="student",e.TEACHER="teacher",e.ADMIN="administrator",e.PARENT="parent",e.OTHER="other",e.NONE="none"}(zn||(zn={})),function(e){e.SERVER="server",e.LOCAL="local"}(Wn||(Wn={}));class Zn{constructor(e,t){this.uid=e,this.sid=en.generateUniqueId(),this.createdTime=Date.now(),this.managedSession=t}}class er{}!function(e){e[e.NOT_PLAYED=0]="NOT_PLAYED",e[e.PLAYED=1]="PLAYED"}(Xn||(Xn={}));class tr{constructor(e,t){this.apiService=e,this.tenantServiceConfig=t,this.GET_TENANT_INFO_ENDPOINT="/info"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.tenantServiceConfig.tenantApiPath+this.GET_TENANT_INFO_ENDPOINT+"/"+e.slug).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result))}}!function(e){e.SERVER="server",e.CACHE="cache"}(Jn||(Jn={}));var nr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class rr{constructor(e,t,n,r){this.cachedItemStore=e,this.keyValueStore=t,this.container=n,this.profileServiceConfig=r,this.USER_PROFILE_DETAILS_KEY_PREFIX="userProfileDetails"}get csUserService(){return this.container.get(u.USER_SERVICE)}handle(e){return e.from=e.from||Jn.CACHE,Object(c.of)(e.from).pipe(Object(D.mergeMap)(t=>t===Jn.SERVER?this.fetchFromServer(e).pipe(Object(D.tap)(e=>nr(this,void 0,void 0,(function*(){return this.keyValueStore.setValue(this.USER_PROFILE_DETAILS_KEY_PREFIX+"-"+e.id,JSON.stringify(e)).toPromise()}))),Object(D.catchError)(t=>{if(e.forceRefresh)throw t;return this.fetchFromCache(e)})):this.fetchFromCache(e)))}fetchFromServer(e){return this.csUserService.getProfileDetails(e,{apiPath:this.profileServiceConfig.profileApiPath_V5})}fetchFromCache(e){return this.cachedItemStore.getCached(e.userId,this.USER_PROFILE_DETAILS_KEY_PREFIX,this.USER_PROFILE_DETAILS_KEY_PREFIX,()=>this.fetchFromServer(e))}}class ir{static mapProfileDBEntryToProfile(e){return{uid:e[et.COLUMN_NAME_UID],handle:e[et.COLUMN_NAME_HANDLE],createdAt:e[et.COLUMN_NAME_CREATED_AT],medium:e[et.COLUMN_NAME_MEDIUM]?e[et.COLUMN_NAME_MEDIUM].split(","):[],board:e[et.COLUMN_NAME_BOARD]?e[et.COLUMN_NAME_BOARD].split(","):[],subject:e[et.COLUMN_NAME_SUBJECT]?e[et.COLUMN_NAME_SUBJECT].split(","):[],profileType:e[et.COLUMN_NAME_PROFILE_TYPE],grade:e[et.COLUMN_NAME_GRADE]?e[et.COLUMN_NAME_GRADE].split(","):[],syllabus:e[et.COLUMN_NAME_SYLLABUS]?e[et.COLUMN_NAME_SYLLABUS].split(","):[],source:e[et.COLUMN_NAME_SOURCE],gradeValue:e[et.COLUMN_NAME_GRADE_VALUE]&&JSON.parse(e[et.COLUMN_NAME_GRADE_VALUE]),categories:e[et.COLUMN_NAME_CATEGORIES]}}static mapProfileToProfileDBEntry(e){return{[et.COLUMN_NAME_UID]:e.uid,[et.COLUMN_NAME_HANDLE]:e.handle,[et.COLUMN_NAME_CREATED_AT]:Number(e.createdAt),[et.COLUMN_NAME_MEDIUM]:e.medium?e.medium.join(","):"",[et.COLUMN_NAME_BOARD]:e.board?e.board.join(","):"",[et.COLUMN_NAME_SUBJECT]:e.subject?e.subject.join(","):"",[et.COLUMN_NAME_PROFILE_TYPE]:e.profileType,[et.COLUMN_NAME_GRADE]:e.grade?e.grade.join(","):"",[et.COLUMN_NAME_SYLLABUS]:e.syllabus?e.syllabus.join(","):"",[et.COLUMN_NAME_SOURCE]:e.source,[et.COLUMN_NAME_GRADE_VALUE]:e.gradeValue?JSON.stringify(e.gradeValue):"",[et.COLUMN_NAME_CATEGORIES]:e.categories?JSON.stringify(e.categories):""}}}class or{constructor(e,t){this.apiService=e,this.acceptTermsConditionApiConfig=t,this.GET_ACCEPT_TERM_CONDITIONS_ENDPOINT="/tnc/accept"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.acceptTermsConditionApiConfig.profileApiPath+this.GET_ACCEPT_TERM_CONDITIONS_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>"SUCCESS"===e.body.result.response))}}class sr extends ke{constructor(e){super(e,"INVALID_PROFILE_ERROR"),Object.setPrototypeOf(this,sr.prototype)}}class ar{constructor(e,t){this.apiService=e,this.profileAlreadyInUseConfig=t,this.GET_PROFILE_ALREADY_IN_USE_ENDPOINT="/get"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.profileAlreadyInUseConfig.profileApiPath_V2+this.GET_PROFILE_ALREADY_IN_USE_ENDPOINT+"/"+e.type+"/"+e.key).withBearerToken(!0).withUserToken(!0).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result))}}class cr{constructor(e,t){this.apiService=e,this.otpServiceConfig=t,this.GET_GENERATE_OTP_ENDPOINT="/generate"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.otpServiceConfig.otpApiPath+this.GET_GENERATE_OTP_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>"SUCCESS"===e.body.result.response))}}class ur{constructor(e,t){this.apiService=e,this.optServiceConfig=t,this.GET_VERIFY_OTP_ENDPOINT="/verify"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.optServiceConfig.otpApiPath+this.GET_VERIFY_OTP_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>"SUCCESS"===e.body.result.response))}}class lr{static dirPathFromFilePath(e){return e.substring(0,e.lastIndexOf("/"))}static fileNameFromFilePath(e){return e.substring(e.lastIndexOf("/")+1)}static getAssetPath(){return"ios"===window.device.platform.toLowerCase()?cordova.file.applicationDirectory+"www/assets":lr.ASSETS_PATH}}lr.ASSETS_PATH="file:///android_asset/www/assets";class dr{constructor(e,t,n,r){this.apiService=e,this.profileServiceConfig=t,this.fileService=n,this.cachedItemStore=r,this.LOCATION_LOCAL_KEY="location-"}handle(e){let t=e.filters.type;return e.filters.parentId&&(t=t+"_"+e.filters.parentId),this.cachedItemStore[e.from===Jn.SERVER?"get":"getCached"](t,this.LOCATION_LOCAL_KEY,"ttl_"+this.LOCATION_LOCAL_KEY,()=>this.fetchFromServer(e),()=>this.fetchFromFile(e),dr.LOCATION_TTL)}fetchFromServer(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.profileServiceConfig.searchLocationApiPath+dr.GET_SEARCH_LOCATION_ENDPOINT).withBearerToken(!0).withUserToken(!1).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result.response))}fetchFromFile(e){const t=lr.getAssetPath()+this.profileServiceConfig.locationDirPath;let n=e.filters.type;return e.filters.parentId&&(n=n+"-"+e.filters.parentId),n+=".json",Object(c.from)(this.fileService.readFileFromAssets(t.concat("/",n))).pipe(Object(D.map)(e=>JSON.parse(e).result.response))}}dr.GET_SEARCH_LOCATION_ENDPOINT="/location/search",dr.LOCATION_TTL=864e5;class hr{constructor(e){this.fileService=e}execute(e){const t=new a.CsResponse,n=`profiles_${b()().format("YYYYMMDDhhmmss")}.epar`;return this.fileService.createDir(e.destinationFolder.concat("Profile"),!1).then(e=>this.fileService.createFile(e.nativeURL,n,!0)).then(n=>(e.destinationDBFilePath=n.nativeURL,t.body=e,t))}}var Er=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class fr{constructor(e){this.dbService=e}execute(e){return Er(this,void 0,void 0,(function*(){const t=new a.CsResponse;return this.dbService.copyDatabase(e.destinationDBFilePath).toPromise().then(n=>(t.body=e,t)).then(()=>(t.body=e,t))}))}}var pr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class _r{constructor(e,t,n){this.dbService=e,this.fileService=t,this.deviceInfo=n}execute(e){return pr(this,void 0,void 0,(function*(){const t=new a.CsResponse,n=this.generateMetaData(e.userIds,e.groupIds);return this.dbService.open(e.destinationDBFilePath).then(()=>this.dbService.execute(Qe.getCreateEntry(),!0).toPromise()).then(()=>this.populateMetaData(n)).then(()=>(t.body=e,t)).catch(e=>{throw console.log("error",e),t})}))}generateMetaData(e,t){const n={version:20};return n.types=JSON.stringify(["userprofile"]),n.did=this.deviceInfo.getDeviceID(),n.export_id=en.generateUniqueId(),t||(t=[]),n.profiles_count=e.length+t.length,n}populateMetaData(e){return pr(this,void 0,void 0,(function*(){Object.keys(e).forEach(t=>pr(this,void 0,void 0,(function*(){const n={key:t,value:e[t]};yield this.dbService.insert({table:Qe.TABLE_NAME,modelJson:n,useExternalDb:!0}).toPromise()})))}))}}var Or=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Sr{constructor(e,t){this.dbService=e,this.fileService=t}execute(e){return Or(this,void 0,void 0,(function*(){const t=new a.CsResponse;return this.getAllTables().then(e=>{const t=e.map(e=>e.name);return this.removeTables(t,this.getAllTablesToExclude())}).then(()=>this.deleteUnwantedProfilesAndUsers(e.userIds)).then(()=>this.deleteUnwantedProfileSummary(e.userIds)).then(()=>this.deleteUnwantedGroups(e.groupIds)).then(()=>this.deleteUnwantedGroupProfiles(e.groupIds)).then(()=>this.keepAllFrameworknChannel()).then(()=>this.fileService.getMetaData(e.destinationDBFilePath)).then(t=>(e.size=t.size.toString(),this.populateMetaData({FILE_SIZE:t.size}))).then(()=>this.fileService.removeFile(e.destinationDBFilePath.concat("-journal"))).then(()=>(t.body=e,t)).catch(e=>{throw t.errorMesg=Rn.EXPORT_FAILED,t})}))}getAllTables(){return this.dbService.execute("SELECT name FROM sqlite_master WHERE type = 'table'",!0).toPromise()}getAllTablesToExclude(){return[Qe.TABLE_NAME,nt.TABLE_NAME,et.TABLE_NAME,lt.TABLE_NAME,ht.TABLE_NAME,pt.TABLE_NAME,ft.TABLE_NAME,It.TABLE_NAME]}removeTables(e,t){return Or(this,void 0,void 0,(function*(){for(const n of e)wn.contains(t,n)||(yield this.dbService.execute("DROP TABLE IF EXISTS "+n,!0).toPromise());return!0}))}populateMetaData(e){return Or(this,void 0,void 0,(function*(){Object.keys(e).forEach(t=>Or(this,void 0,void 0,(function*(){const n={key:t,value:e[t]};yield this.dbService.insert({table:Qe.TABLE_NAME,modelJson:n,useExternalDb:!0}).toPromise()})))}))}deleteUnwantedProfilesAndUsers(e){return Or(this,void 0,void 0,(function*(){const t=[],n=[];for(const r of e){const e=yield this.dbService.read({table:et.TABLE_NAME,useExternalDb:!0,selection:et.COLUMN_NAME_UID+"=?",selectionArgs:[r],limit:"1"}).toPromise();e&&e.length&&t.push(e[0][et.COLUMN_NAME_UID]);const i=yield this.dbService.read({table:nt.TABLE_NAME,useExternalDb:!0,selection:nt.COLUMN_NAME_UID+"=?",selectionArgs:[r],limit:"1"}).toPromise();i&&i.length&&n.push(i[0][nt.COLUMN_NAME_UID])}yield this.cleanTable(et.TABLE_NAME,et.COLUMN_NAME_UID,t),yield this.cleanTable(nt.TABLE_NAME,nt.COLUMN_NAME_UID,t)}))}deleteUnwantedProfileSummary(e){return Or(this,void 0,void 0,(function*(){yield this.cleanTable(lt.TABLE_NAME,lt.COLUMN_NAME_UID,e),yield this.cleanTable(ht.TABLE_NAME,ht.COLUMN_NAME_UID,e)}))}deleteUnwantedGroups(e){return Or(this,void 0,void 0,(function*(){if(!e||!e.length)return;const t=[];for(const n of e){const e=yield this.dbService.read({table:pt.TABLE_NAME,useExternalDb:!0,selection:pt.COLUMN_NAME_GID+"=?",selectionArgs:[n],limit:"1"}).toPromise();e&&e.length&&t.push(e[0][ft.COLUMN_NAME_GID])}yield this.cleanTable(pt.TABLE_NAME,pt.COLUMN_NAME_GID,t)}))}deleteUnwantedGroupProfiles(e){return Or(this,void 0,void 0,(function*(){if(!e||!e.length)return;const t=[];for(const n of e){const e=yield this.dbService.read({table:ft.TABLE_NAME,useExternalDb:!0,selection:ft.COLUMN_NAME_GID+"=?",selectionArgs:[n],limit:"1"}).toPromise();e&&e.length&&t.push(e[0][et.COLUMN_NAME_UID])}yield this.cleanTable(pt.TABLE_NAME,pt.COLUMN_NAME_GID,e)}))}keepAllFrameworknChannel(){return Or(this,void 0,void 0,(function*(){const e=`SELECT * FROM ${It.TABLE_NAME}\n WHERE ${It.COLUMN_NAME_KEY} LIKE 'channel_details_key-%'\n OR ${It.COLUMN_NAME_KEY} LIKE 'framework_details_key-%'\n OR ${It.COLUMN_NAME_KEY} LIKE 'form-%'`,t=yield this.dbService.execute(e,!0).toPromise();yield this.dbService.execute("DELETE FROM "+It.TABLE_NAME,!0),t.forEach(e=>Or(this,void 0,void 0,(function*(){yield this.dbService.insert({table:It.TABLE_NAME,useExternalDb:!0,modelJson:e})})))}))}cleanTable(e,t,n){return Or(this,void 0,void 0,(function*(){if(!n||!n.length)return;const r=wn.joinPreservingQuotes(n),i=`DELETE FROM ${e}\n WHERE ${t} NOT IN(${r})`;yield this.dbService.execute(i,!0).toPromise()}))}}class gr{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:ct.TABLE_NAME}).toPromise().then(e=>{const t=[];e.forEach(e=>{const n={type:ie.PROFILE,origin:e[ct.COLUMN_NAME_DEVICE_ID],identifier:e[ct.COLUMN_NAME_IMPORTED_ID],pkgVersion:0,transferCount:0,size:""};t.push(n)});const n={dir:ne.IN,type:re.FILE.valueOf(),items:t,env:"sdk"};return ln.log.share(n).toPromise()}).then(()=>(t.body=e,t))}}class Ar{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:ct.TABLE_NAME}).toPromise().then(e=>{const t=[];e.forEach(e=>{const n={type:ie.PROFILE,origin:e[ct.COLUMN_NAME_DEVICE_ID],identifier:e[ct.COLUMN_NAME_IMPORTED_ID],pkgVersion:0,transferCount:0,size:""};t.push(n)});const n={dir:ne.OUT,type:re.FILE.valueOf(),items:t,env:"sdk"};return ln.log.share(n).toPromise()}).then(()=>(t.body=e,t))}}class Nr{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.open(e.sourceDBFilePath).then(()=>this.dbService.read({table:Qe.TABLE_NAME,useExternalDb:!0}).toPromise()).then(n=>{if(!n||!n.length)throw t.errorMesg=Rn.IMPORT_FAILED.valueOf(),t;const r={};n.forEach(e=>{r[e.key]=e.value}),e.metadata=r;const i=this.getImportTypes(r);if(i&&!wn.contains(i,"userprofile"))throw t.errorMesg=Rn.IMPORT_FAILED.valueOf(),t;return t.body=e,t})}getImportTypes(e){let t=[];return e.hasOwnProperty("types")&&(t=JSON.parse(e.types)),t}}var Tr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Cr{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:nt.TABLE_NAME,useExternalDb:!0}).toPromise().then(t=>this.saveUsersToDb(e,t)).then(()=>(t.body=e,t))}saveUsersToDb(e,t){return Tr(this,void 0,void 0,(function*(){t.forEach(e=>Tr(this,void 0,void 0,(function*(){delete e[nt._ID];const t=yield this.dbService.read({table:et.TABLE_NAME,selection:nt.COLUMN_NAME_UID+" = ?",selectionArgs:[e[nt.COLUMN_NAME_UID]],limit:"1"}).toPromise();t&&t.length||(yield this.dbService.insert({table:nt.TABLE_NAME,modelJson:e}).toPromise())})))}))}}var vr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class yr{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:pt.TABLE_NAME,useExternalDb:!0}).toPromise().then(t=>this.saveGroupsToDb(e,t)).then(()=>(t.body=e,t))}saveGroupsToDb(e,t){return vr(this,void 0,void 0,(function*(){let n=0,r=0;t.forEach(e=>vr(this,void 0,void 0,(function*(){const t=yield this.dbService.read({table:pt.TABLE_NAME,selection:pt.COLUMN_NAME_GID+" = ?",selectionArgs:[e[pt.COLUMN_NAME_GID]],limit:"1"}).toPromise();t&&t.length?r++:(e[pt.COLUMN_NAME_CREATED_AT]||(e[pt.COLUMN_NAME_CREATED_AT]=Date.now()),yield this.dbService.insert({table:pt.TABLE_NAME,modelJson:e}).toPromise(),n++)}))),e.failed=e.failed?e.failed+r:r,e.imported=e.imported?e.imported+n:n}))}}var mr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class br{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:ft.TABLE_NAME,useExternalDb:!0}).toPromise().then(t=>this.saveGroupProfilesToDb(e,t)).then(()=>(t.body=e,t))}saveGroupProfilesToDb(e,t){return mr(this,void 0,void 0,(function*(){t.forEach(e=>mr(this,void 0,void 0,(function*(){delete e[ft._ID];const n=yield this.dbService.read({table:ft.TABLE_NAME,selection:`${ft.COLUMN_NAME_GID} = ? AND ${ft.COLUMN_NAME_UID} = ?`,selectionArgs:[t[ft.COLUMN_NAME_GID],e[ft.COLUMN_NAME_UID]],limit:"1"}).toPromise();n&&n.length||(yield this.dbService.insert({table:ft.TABLE_NAME,modelJson:e}))})))}))}}var Ir=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Mr{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:It.TABLE_NAME,useExternalDb:!0}).toPromise().then(e=>this.saveNoSqlEntryToDb(e)).then(()=>(t.body=e,t))}saveNoSqlEntryToDb(e){return Ir(this,void 0,void 0,(function*(){e.forEach(e=>Ir(this,void 0,void 0,(function*(){delete e[It._ID];const t=yield this.dbService.read({table:It.TABLE_NAME,selection:It.COLUMN_NAME_KEY+" = ?",selectionArgs:[e[It.COLUMN_NAME_KEY]],limit:"1"}).toPromise();t&&t.length||(yield this.dbService.insert({table:It.TABLE_NAME,modelJson:e}).toPromise())})))}))}}class Rr extends ke{constructor(e){super(e,"VALIDATION_ERROR"),Object.setPrototypeOf(this,Rr.prototype)}}var Lr=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Pr=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Dr=function(e,t){return function(n,r){t(n,r,e)}};let wr=class{constructor(e,t,n,r,i,o){this.dbService=e,this.contenService=t,this.eventsBusService=n,this.courseService=r,this.sharedPreference=i,this.profileService=o,this.summarizerTelemetryHandler=new Ai(this.courseService,this.sharedPreference,this,this.eventsBusService,this.contenService,this.profileService)}onInit(){return this.eventsBusService.registerObserver({namespace:M.TELEMETRY,observer:this}),Object(c.of)(void 0)}getDetailsPerQuestion(e){const t=kr.getQuetsionDetailsQuery(e.uids,e.contentId,e.qId);return this.dbService.execute(t).pipe(Object(D.map)(e=>Fr.mapDBEntriesToQuestionDetails(e)))}getLearnerAssessmentDetails(e){const t=kr.getDetailReportsQuery(e.uids,e.contentId);return this.dbService.execute(t).pipe(Object(D.map)(e=>Fr.mapDBEntriesToLearnerAssesmentDetails(e)))}getReportByQuestions(e){const t=kr.getQuestionReportsQuery(e.uids,e.contentId),n=kr.getReportAccuracyQuery(e.uids,e.contentId);return this.dbService.execute(n).pipe(Object(D.map)(e=>Fr.mapDBEntriesToAccuracy(e)),Object(D.mergeMap)(e=>this.dbService.execute(t).pipe(Object(D.map)(t=>Fr.mapDBEntriesToQuestionReports(e,t)))))}getReportsByUser(e){const t=kr.getReportsByUserQuery(e.uids,e.contentId);return this.dbService.execute(t).pipe(Object(D.map)(e=>Fr.mapDBEntriesToUserReports(e)))}getSummary(e){if(!e.uids)throw new Rr("uids are mandatory");const t=kr.getChildProgressQuery(e.uids);return this.getContentCache(e.uids).pipe(Object(D.mergeMap)(e=>this.dbService.execute(t).pipe(Object(D.map)(t=>Fr.mapDBEntriesToLearnerAssesmentSummary(t,e)))))}getContentCache(e){if(this.contentMap&&Object.keys(this.contentMap).length)return Object(c.of)(this.contentMap);{this.contentMap=new Map;const t={resourcesOnly:!0,primaryCategories:[],uid:e};return this.contenService.getContents(t).pipe(Object(D.map)(e=>(e.forEach(e=>{const t=new Ur;t.name=e.contentData&&e.contentData.name,t.totalScore=e.contentData&&e.contentData.totalScore,t.lastUsedTime=e.lastUsedTime,t.identifier=e.identifier,this.contentMap.set(e.identifier,t)}),this.contentMap)))}}saveLearnerAssessmentDetails(e){const t=Fr.mapTelemetryToLearnerAssesmentDetails(e),n=Fr.mapLearnerAssesmentDetailsToDbEntries(t),r=kr.getFilterForLearnerAssessmentDetails(t.qid,t.uid,t.contentId,t.hierarchyData),i=kr.getLearnerAssessmentsQuery(r);return this.dbService.execute(i).pipe(Object(D.mergeMap)(e=>e&&e.length?this.dbService.update({table:lt.TABLE_NAME,selection:kr.getUpdateSelection(),selectionArgs:[t.uid,t.contentId,t.hierarchyData?t.hierarchyData:"",t.qid],modelJson:n}).pipe(Object(D.map)(e=>e>0)):t.qid?this.dbService.insert({table:lt.TABLE_NAME,modelJson:n}).pipe(Object(D.map)(e=>e>0)):Object(c.of)(!1)))}saveLearnerContentSummaryDetails(e){const t=Fr.mapTelemetryToContentSummaryDetails(e),n=Fr.mapContentSummaryDetailsToDbEntries(t);return this.dbService.read({table:ht.TABLE_NAME,selection:kr.getLearnerSummaryReadSelection(t.hierarchyData),selectionArgs:[t.uid,t.contentId,t.hierarchyData]}).pipe(Object(D.mergeMap)(e=>e&&e.length?(n.sessions=e[0][ht.COLUMN_NAME_SESSIONS]+1,n.avg_ts=fe.toFixed(t.timespent/t.sessions),n.total_ts=t.timespent,n.last_updated_on=t.timestamp,this.dbService.update({table:ht.TABLE_NAME,selection:kr.getLearnerSummaryReadSelection(t.hierarchyData),selectionArgs:[t.uid,t.contentId,t.hierarchyData],modelJson:n}).pipe(Object(D.map)(e=>e>0))):(n.avg_ts=t.timespent,n.sessions=1,n.total_ts=t.timespent,n.last_updated_on=t.timestamp,this.dbService.insert({table:ht.TABLE_NAME,modelJson:n}).pipe(Object(D.map)(e=>e>0)))))}deletePreviousAssessmentDetails(e,t){return this.dbService.read({table:ht.TABLE_NAME,selection:`${ht.COLUMN_NAME_CONTENT_ID} = ? AND ${ht.COLUMN_NAME_UID} = ?`,selectionArgs:[t,e]}).pipe(Object(D.mergeMap)(n=>n&&n.length?this.dbService.delete({table:ht.TABLE_NAME,selection:`${ht.COLUMN_NAME_CONTENT_ID} = ? AND ${ht.COLUMN_NAME_UID} = ?`,selectionArgs:[t,e]}):Object(c.of)(void 0)),Object(D.mergeMap)(()=>this.dbService.read({table:lt.TABLE_NAME,selection:`${lt.COLUMN_NAME_CONTENT_ID} = ? AND ${lt.COLUMN_NAME_UID} = ?`,selectionArgs:[t,e]})),Object(D.mergeMap)(n=>n&&n.length?this.dbService.delete({table:lt.TABLE_NAME,selection:`${lt.COLUMN_NAME_CONTENT_ID} = ? AND ${lt.COLUMN_NAME_UID} = ?`,selectionArgs:[t,e]}):Object(c.of)(void 0)))}onEvent(e){return e.type===Un.SAVE?this.summarizerTelemetryHandler.handle(e.payload):Object(c.of)(void 0)}};wr=Lr([Object(s.injectable)(),Dr(0,Object(s.inject)(l.DB_SERVICE)),Dr(1,Object(s.inject)(l.CONTENT_SERVICE)),Dr(2,Object(s.inject)(l.EVENTS_BUS_SERVICE)),Dr(3,Object(s.inject)(l.COURSE_SERVICE)),Dr(4,Object(s.inject)(l.SHARED_PREFERENCES)),Dr(5,Object(s.inject)(l.PROFILE_SERVICE)),Pr("design:paramtypes",[o,Object,Object,Object,Object,Object])],wr);class Ur{}class jr{constructor(){this.reportDetailsList=[]}}class Fr{constructor(){}static mapLearnerAssesmentDetailsToDbEntries(e){return{[lt.COLUMN_NAME_UID]:e.uid,[lt.COLUMN_NAME_CONTENT_ID]:e.contentId,[lt.COLUMN_NAME_QID]:e.qid,[lt.COLUMN_NAME_Q_INDEX]:e.qindex,[lt.COLUMN_NAME_CORRECT]:e.correct,[lt.COLUMN_NAME_SCORE]:e.score,[lt.COLUMN_NAME_TIME_SPENT]:e.timespent,[lt.COLUMN_NAME_RES]:e.res,[lt.COLUMN_NAME_TIMESTAMP]:e.timestamp,[lt.COLUMN_NAME_Q_DESC]:e.qdesc,[lt.COLUMN_NAME_Q_TITLE]:e.qtitle,[lt.COLUMN_NAME_MAX_SCORE]:e.maxScore,[lt.COLUMN_NAME_HIERARCHY_DATA]:e.hierarchyData}}static mapContentSummaryDetailsToDbEntries(e){return{[ht.COLUMN_NAME_UID]:e.uid,[ht.COLUMN_NAME_CONTENT_ID]:e.contentId,[ht.COLUMN_NAME_AVG_TS]:e.avgts,[ht.COLUMN_NAME_TOTAL_TS]:e.totalts,[ht.COLUMN_NAME_LAST_UPDATED_ON]:e.lastUpdated,[lt.COLUMN_NAME_HIERARCHY_DATA]:e.hierarchyData}}static mapDBEntriesToLearnerAssesmentSummary(e,t){return e.map(e=>{const n=t.get(e[ht.COLUMN_NAME_CONTENT_ID]);return{uid:e[ht.COLUMN_NAME_UID].toString(),contentId:e[ht.COLUMN_NAME_CONTENT_ID].toString(),noOfQuestions:fe.parseInt(e[ht.COLUMN_NAME_NO_OF_QUESTIONS]),correctAnswers:fe.parseInt(e[ht.COLUMN_NAME_CORRECT_ANSWERS]),totalTimespent:Number(e[ht.COLUMN_NAME_TOTAL_TIME_SPENT]),hierarchyData:e[ht.COLUMN_NAME_HIERARCHY_DATA].toString(),totalMaxScore:fe.toFixed(e[ht.COLUMN_NAME_TOTAL_MAX_SCORE]),totalScore:fe.toFixed(e[ht.COLUMN_NAME_TOTAL_SCORE]),totalQuestionsScore:n?n.totalScore:0,name:n?n.name:e[ht.COLUMN_NAME_CONTENT_ID]}})}static mapDBEntriesToLearnerAssesmentDetails(e){const t=new Map;return e.map(e=>{const n={uid:e[lt.COLUMN_NAME_UID],contentId:e[lt.COLUMN_NAME_CONTENT_ID],qid:e[lt.COLUMN_NAME_QID],qindex:Number(e[lt.COLUMN_NAME_Q_INDEX]),correct:fe.parseInt(e[lt.COLUMN_NAME_CORRECT]),score:fe.toFixed(e[lt.COLUMN_NAME_SCORE]),timespent:Number(e[lt.COLUMN_NAME_TIME_SPENT]),res:e[lt[lt.COLUMN_NAME_RES]],timestamp:Number(e[lt.COLUMN_NAME_TIMESTAMP]),qdesc:e[lt.COLUMN_NAME_Q_DESC],qtitle:e[lt.COLUMN_NAME_Q_TITLE],maxScore:fe.toFixed(e[lt.COLUMN_NAME_MAX_SCORE]),hierarchyData:e[lt.COLUMN_NAME_HIERARCHY_DATA],total_ts:Number(e[lt.COLUMN_NAME_TOTAL_TS])};let r=t.get(n.uid);void 0===r&&(r=new jr,r.uid=n.uid,r.totalScore=0,r.maxTotalScore=0),r.reportDetailsList.push(n),r.totalScore+=n.score,r.totalTime=n.total_ts,r.maxTotalScore+=n.maxScore,r.totalScore=parseFloat(r.totalScore.toFixed(2)),t.set(n.uid,r)}),t}static mapDBEntriesToQuestionReports(e,t){return t.map(t=>{const n=t[lt.COLUMN_NAME_QID];let r=0;return e.hasOwnProperty(n)&&(r=fe.parseInt(e[n])),{uid:t[lt.COLUMN_NAME_UID],contentId:t[lt.COLUMN_NAME_CONTENT_ID],qid:t[lt.COLUMN_NAME_QID],qindex:Number(t[lt.COLUMN_NAME_Q_INDEX]),correct:fe.parseInt(t[lt.COLUMN_NAME_CORRECT]),score:fe.toFixed(t[lt.COLUMN_NAME_SCORE]),timespent:Number(t[lt.COLUMN_NAME_TIME_SPENT]),res:t[lt[lt.COLUMN_NAME_RES]],timestamp:Number(t[lt.COLUMN_NAME_TIMESTAMP]),qdesc:t[lt.COLUMN_NAME_Q_DESC],qtitle:t[lt.COLUMN_NAME_Q_TITLE],maxScore:fe.toFixed(t[lt.COLUMN_NAME_MAX_SCORE]),hierarchyData:t[lt.COLUMN_NAME_HIERARCHY_DATA],total_ts:Number(t[lt.COLUMN_NAME_TOTAL_TS]),marks:Number(t[lt.COLUMN_NAME_MARKS]),occurenceCount:t[lt.COLUMN_NAME_COUNT],sum_max_score:Number(t[lt.COLUMN_NAME_TOTAL_MAX_SCORE]),correct_users_count:r}})}static mapDBEntriesToAccuracy(e){const t={};return e.map(e=>{t[e[lt.COLUMN_NAME_QID]]=fe.parseInt(e[lt.COLUMN_NAME_USERS_COUNT])}),t}static mapDBEntriesToQuestionDetails(e){return e.map(e=>({uid:e.uid,time:Number(e.time),result:fe.round(e.result),max_score:fe.parseInt(e.max_score)}))}static mapDBEntriesToUserReports(e){return e.map(e=>({totalTimespent:Number(e[lt.COLUMN_NAME_TOTAL_TS]),score:fe.toFixed(e[lt.COLUMN_NAME_SCORE]),hData:e[lt.COLUMN_NAME_HIERARCHY_DATA],contentId:e[lt.COLUMN_NAME_CONTENT_ID],uid:e[lt.COLUMN_NAME_UID],userName:e[lt.COLUMN_NAME_HANDLE],timespent:Number(e[lt.COLUMN_NAME_TIME_SPENT])}))}static mapTelemetryToContentSummaryDetails(e){const t=e.edata,n=(t.item,e.context.cdata);return{uid:e.actor.id,contentId:e.object.id,timespent:Number(t.duration),timestamp:e.ets,hierarchyData:this.getHierarchyData(n)}}static mapTelemetryToLearnerAssesmentDetails(e){const t=e.edata,n=t.item,r=e.context.cdata;return{uid:e.actor.id,contentId:e.object.id,qid:n&&n.id,qindex:Number(t.index),correct:"Yes"===t.pass?1:0,score:Number(t.score),timespent:Number(t.duration),timestamp:e.ets,res:JSON.stringify(t.resvalues),qdesc:n&&n.desc,qtitle:n&&n.title,maxScore:n&&Number(n.maxscore),hierarchyData:this.getHierarchyData(r)}}static getHierarchyData(e){let t="";return e&&e.forEach(e=>{if("Collection"===e.type||"TextBook"===e.type)return t=e.id}),""}}class kr{static getChildProgressQuery(e){return`SELECT ${lt.COLUMN_NAME_UID}, ${lt.COLUMN_NAME_CONTENT_ID},\n COUNT (${lt.COLUMN_NAME_QID}) AS no_of_questions,\n SUM (${lt.COLUMN_NAME_CORRECT}) AS correct_answers,\n SUM (${lt.COLUMN_NAME_TIME_SPENT}) AS total_time_spent, h_data ,\n SUM (${lt.COLUMN_NAME_MAX_SCORE}) AS total_max_score,\n SUM (${lt.COLUMN_NAME_SCORE}) AS total_score\n FROM ${lt.TABLE_NAME}\n WHERE ${lt.COLUMN_NAME_UID} IN (${wn.joinPreservingQuotes(e)})\n GROUP BY ${lt.COLUMN_NAME_CONTENT_ID} `}static getDetailReportsQuery(e,t){return`SELECT *, lcs.${ht.COLUMN_NAME_TOTAL_TS}\n FROM ${lt.TABLE_NAME} la\n LEFT JOIN ${ht.TABLE_NAME} lcs\n ON (la.${ht.COLUMN_NAME_UID} = lcs.${lt.COLUMN_NAME_UID})\n AND la.${ht.COLUMN_NAME_CONTENT_ID} = lcs.${lt.COLUMN_NAME_CONTENT_ID}\n WHERE la.${lt.COLUMN_NAME_UID} IN(${wn.joinPreservingQuotes(e)})\n AND la.${lt.COLUMN_NAME_CONTENT_ID}='${t}'`}static getReportsByUserQuery(e,t){return`SELECT lcs.${ht.COLUMN_NAME_TOTAL_TS},\n SUM (${lt.COLUMN_NAME_SCORE}) AS score,\n la.${lt.COLUMN_NAME_HIERARCHY_DATA},la.${lt.COLUMN_NAME_CONTENT_ID},\n la.${lt.COLUMN_NAME_UID},p.${et.COLUMN_NAME_HANDLE},\n la.${lt.COLUMN_NAME_TIME_SPENT}\n FROM ${lt.TABLE_NAME} la\n LEFT JOIN ${ht.TABLE_NAME} lcs\n ON (la.${ht.COLUMN_NAME_UID} = lcs.${lt.COLUMN_NAME_UID})\n LEFT JOIN ${et.TABLE_NAME} p\n ON (la.${lt.COLUMN_NAME_UID} = p.${et.COLUMN_NAME_UID})\n WHERE la.${lt.COLUMN_NAME_UID} IN(${wn.joinPreservingQuotes(e)})\n AND la.${lt.COLUMN_NAME_CONTENT_ID}='${t}'\n GROUP BY la.${lt.COLUMN_NAME_UID}`}static getQuetsionDetailsQuery(e,t,n){return`SELECT ${lt.COLUMN_NAME_UID}, ${lt.COLUMN_NAME_TIME_SPENT} as time,\n ${lt.COLUMN_NAME_SCORE} as result,\n ${lt.COLUMN_NAME_MAX_SCORE} as max_score\n FROM ${lt.TABLE_NAME}\n WHERE ${lt.COLUMN_NAME_UID} IN(${wn.joinPreservingQuotes(e)})\n AND ${lt.COLUMN_NAME_CONTENT_ID}='${t}'\n AND ${lt.COLUMN_NAME_QID}='${n}'`}static getReportAccuracyQuery(e,t){return`SELECT ${lt.COLUMN_NAME_QID}, COUNT (*) as users_count\n FROM ${lt.TABLE_NAME}\n WHERE ${lt.COLUMN_NAME_UID} IN(${wn.joinPreservingQuotes(e)})\n AND ${lt.COLUMN_NAME_CONTENT_ID}='${t}'\n AND ${lt.COLUMN_NAME_SCORE} > 0\n GROUP BY ${lt.COLUMN_NAME_QID}`}static getQuestionReportsQuery(e,t){return`SELECT *, SUM(${lt.COLUMN_NAME_SCORE}) as marks,\n COUNT (${lt.COLUMN_NAME_Q_INDEX}) as occurence_count,\n SUM (${lt.COLUMN_NAME_MAX_SCORE}) as sum_max_score\n FROM ${lt.TABLE_NAME}\n WHERE ${lt.COLUMN_NAME_UID} IN(${wn.joinPreservingQuotes(e)})\n AND ${lt.COLUMN_NAME_CONTENT_ID}='${t}'\n GROUP BY ${lt.COLUMN_NAME_QID}`}static getFilterForLearnerAssessmentDetails(e,t,n,r){const i=`${lt.COLUMN_NAME_QID} = '${e}'`;return`WHERE ${`${lt.COLUMN_NAME_UID} = '${t}'`} AND ${`${lt.COLUMN_NAME_CONTENT_ID} = '${n}'`} AND ${`${lt.COLUMN_NAME_HIERARCHY_DATA} = '${r||""}'`} ${e?" AND "+i:""}`}static getLearnerAssessmentsQuery(e){return`SELECT * from ${lt.TABLE_NAME} ${e}\n ORDER BY ${lt.COLUMN_NAME_Q_INDEX}`}static getUpdateSelection(){return lt.COLUMN_NAME_UID+" = ? AND "+lt.COLUMN_NAME_CONTENT_ID+" = ? AND "+lt.COLUMN_NAME_HIERARCHY_DATA+" = ? AND "+lt.COLUMN_NAME_QID+" = ? "}static getLearnerSummaryReadSelection(e){return lt.COLUMN_NAME_UID+" = ? AND "+lt.COLUMN_NAME_CONTENT_ID+" = ? AND "+lt.COLUMN_NAME_HIERARCHY_DATA+" = ? "}}class xr{constructor(e,t){this.apiService=e,this.courseServiceConfig=t,this.GET_BATCH_DETAILS_ENDPOINT="/batch/read/"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.courseServiceConfig.apiPath+this.GET_BATCH_DETAILS_ENDPOINT+e.batchId).withBearerToken(!0).withUserToken(!0).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result.response))}}class Br{constructor(e,t){this.apiService=e,this.courseServiceConfig=t,this.GET_COURSE_BATCHES="/batch/list?creatorDetails"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.courseServiceConfig.apiPath+this.GET_COURSE_BATCHES).withBearerToken(!0).withUserToken(!1).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>Array.from(new Set(e.body.result.response.content))))}}var Vr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Yr{constructor(e,t,n,r,i){this.keyValueStore=e,this.apiService=t,this.courseServiceConfig=n,this.sharedPreference=r,this.apiHandler=i,this.GET_ENROLLED_COURSES_ENDPOINT="/user/enrollment/list/",this.STORED_ENROLLED_COURSES_PREFIX="enrolledCourses"}handle(e){return this.keyValueStore.getValue(this.STORED_ENROLLED_COURSES_PREFIX+e.userId).pipe(Object(D.mergeMap)(t=>{if(t){if(e.returnFreshCourses)return this.fetchFromServer(e).pipe(Object(D.mergeMap)(t=>this.keyValueStore.setValue(this.STORED_ENROLLED_COURSES_PREFIX+e.userId,JSON.stringify(t)).pipe(Object(D.mapTo)(t.result.courses),Object(D.tap)(e=>Object(c.from)(this.updateLastPlayedContent(e))))),Object(D.catchError)(()=>{const e=JSON.parse(t),n=e.result;let r;return r=n&&n.hasOwnProperty("courses")?n.courses:e.courses,Object(c.of)(r)}));{const e=JSON.parse(t),n=e.result;let r;return r=n&&n.hasOwnProperty("courses")?n.courses:e.courses,Object(c.of)(r)}}return this.fetchFromServer(e).pipe(Object(D.mergeMap)(t=>this.keyValueStore.setValue(this.STORED_ENROLLED_COURSES_PREFIX+e.userId,JSON.stringify(t)).pipe(Object(D.mapTo)(t.result.courses),Object(D.tap)(e=>Object(c.from)(this.updateLastPlayedContent(e))))))}))}updateLastPlayedContent(e){return Vr(this,void 0,void 0,(function*(){for(const t of e){const e=hi.LAST_READ_CONTENTID_PREFIX.concat("_").concat(t.userId).concat("_").concat(t.contentId).concat("_").concat(t.batchId),n=t.lastReadContentId;t.lastReadContentId&&(yield this.sharedPreference.putString(e,n).toPromise())}return Promise.resolve(!0)}))}fetchFromServer(e){if(this.apiHandler)return this.apiHandler.handle(e);const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.courseServiceConfig.apiPath+this.GET_ENROLLED_COURSES_ENDPOINT+e.userId+"?orgdetails=orgName,email&fields=contentType,topic,name,channel,pkgVersion,primaryCategory,trackable&batchDetails=name,endDate,startDate,status,enrollmentType,createdBy,certificates").withBearerToken(!0).withUserToken(!0).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body))}}class Gr{constructor(e,t){this.apiService=e,this.courseServiceConfig=t,this.ENROL_ENDPOINT="/enrol"}handle(e){delete e.batchStatus;const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.courseServiceConfig.apiPath+this.ENROL_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>"SUCCESS"===e.body.result.response),Object(D.tap)(()=>{this.generateAuditTelemetry(e)}))}generateAuditTelemetry(e){const t=new pe;t.id=e.userId,t.type=pe.TYPE_USER;const n=[{type:"CourseId",id:e.courseId},{type:"BatchId",id:e.batchId},{type:"UserId",id:e.userId}],r={env:"course",actor:t,currentState:ue.AUDIT_CREATED,updatedProperties:["courseId","userId","batchId"],objId:e.courseId,objType:"Course",rollUp:{l1:e.courseId},correlationData:n,type:"enrollment"};ln.log.audit(r).toPromise()}}class Hr{constructor(e,t){this.apiService=e,this.unenrollCourseServiceApiConfig=t,this.GET_UNENROLL_COURSE_ENDPOINT="/unenrol"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.unenrollCourseServiceApiConfig.apiPath+this.GET_UNENROLL_COURSE_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>"SUCCESS"===e.body.result.response))}}var $r,qr,Kr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class zr{constructor(e,t,n){this.apiService=e,this.courseServiceConfig=t,this.container=n}get csCourseService(){return this.container.get(u.COURSE_SERVICE)}get contentService(){return this.container.get(l.CONTENT_SERVICE)}handle(e){return delete e.returnRefreshedContentStates,Object(c.iif)(()=>!e.contentIds||!e.contentIds.length,Object(c.defer)(()=>Kr(this,void 0,void 0,(function*(){return e.contentIds=yield this.contentService.getContentDetails({contentId:e.courseId}).toPromise().then(e=>e.contentData.leafNodes||[]),this.fetchFromApi(e).toPromise()}))),Object(c.defer)(()=>this.fetchFromApi(e)))}fetchFromApi(e){return e.contentIds&&!e.contentIds.length&&delete e.contentIds,this.csCourseService.getContentState(e).pipe(Object(D.map)(e=>({contentList:e})))}}class Wr{constructor(e,t){this.keyValueStore=e,this.offlineContentStateHandler=t}updateEnrollCourses(e){const t=Wr.GET_ENROLLED_COURSES_KEY_PREFIX.concat(e.userId);return this.offlineContentStateHandler.getLocalContentStateResponse(e).pipe(Object(D.mergeMap)(n=>this.keyValueStore.getValue(t).pipe(Object(D.mergeMap)(r=>{if(r){const i=JSON.parse(r),o=i.result;let s;s=o&&o.hasOwnProperty("courses")?o.courses:i.courses;const a=[...s];return s.forEach(t=>{if(t.courseId===e.courseId&&t.batchId===e.batchId){const e=t;n.contentList.forEach(n=>{if(2===n.status){let r=t.contentsPlayedOffline;r||(r=[]),r.push(n.contentId),e.contentsPlayedOffline=wn.deDupe(r)}});const r=a.findIndex(e=>e.contentId===t.contentId&&e.batchId===t.batchId);a.splice(r,1,e)}}),a&&a.length?(o&&o.hasOwnProperty("courses")?o.courses=a:i.courses=a,this.keyValueStore.setValue(t,JSON.stringify(i)).pipe(Object(D.map)(()=>n))):Object(c.of)(n)}return Object(c.of)(n)}))))}}Wr.GET_ENROLLED_COURSES_KEY_PREFIX="enrolledCourses";class Xr{constructor(e){this.keyValueStore=e}getLocalContentStateResponse(e){const t=hi.GET_CONTENT_STATE_KEY_PREFIX.concat(e.userId,e.courseId);return this.keyValueStore.getValue(t).pipe(Object(D.map)(e=>{const t={contentList:[]};if(e){const n=JSON.parse(e),r=n.result;return r&&r.hasOwnProperty("contentList")?(t.contentList=r.contentList,t):(t.contentList=n.contentList,t)}return t.contentList=t.contentList.map(e=>("string"==typeof e.score&&(e.score=void 0),e)),t}))}manipulateEnrolledCoursesResponseLocally(e){const t=hi.GET_ENROLLED_COURSE_KEY_PREFIX.concat(e.userId);return this.keyValueStore.getValue(t).pipe(Object(D.mergeMap)(n=>{if(n){const r=JSON.parse(n),i=r.result;let o;if(o=i&&i.hasOwnProperty("courses")?i.courses:r.courses,o&&o.length){const n=[...o];return o.forEach(t=>{if(t.courseId===e.courseId&&t.batchId===e.batchId&&(t.contentsPlayedOffline&&t.contentsPlayedOffline.length||(t.contentsPlayedOffline=[]),1!==e.status&&(0===t.contentsPlayedOffline.length||t.contentsPlayedOffline.length>0&&!wn.contains(t.contentsPlayedOffline,e.contentId)))){t.progress=t.progress?t.progress:0,t.progress=t.progress+1,t.completionPercentage=this.getCourseCompletionPercentage(t.leafNodesCount,t.progress);const r=t;let i=r.contentsPlayedOffline;i||(i=[]),i.push(e.contentId),r.contentsPlayedOffline=i,r.progress=t.progress,r.completionPercentage=t.completionPercentage;const o=n.findIndex(e=>e.contentId===t.contentId||e.batchId===t.batchId);n.splice(o,1,r)}}),n&&n.length?(i&&i.hasOwnProperty("courses")?i.courses=n:r.courses=n,this.keyValueStore.setValue(t,JSON.stringify(r))):Object(c.of)(!1)}return Object(c.of)(!1)}return Object(c.of)(!1)}))}manipulateGetContentStateResponseLocally(e){const t=hi.GET_CONTENT_STATE_KEY_PREFIX.concat(e.userId,e.courseId);return this.keyValueStore.getValue(t).pipe(Object(D.mergeMap)(n=>{if(n){const r={contentList:[]},i=JSON.parse(n),o=i.result;if(o&&o.hasOwnProperty("contentList")?r.contentList=o.contentList:r.contentList=i.contentList,r){let n,i=r.contentList;return i&&i.length?(i.forEach(t=>{t.contentId===e.contentId?t.status!==e.status&&(e.score=t.score,e.bestScore=t.bestScore,n=this.getContentState(e),i=i.filter(e=>e.contentId!==t.contentId)):n=this.getContentState(e)}),n?(i.push(n),r.contentList=i,this.keyValueStore.setValue(t,JSON.stringify(r))):Object(c.of)(!1)):(n=this.getContentState(e),i=[],i.push(n),r.contentList=i,this.keyValueStore.setValue(t,JSON.stringify(r)))}return Object(c.of)(!1)}return Object(c.of)(!1)}))}getCourseCompletionPercentage(e,t){if(0===e||void 0===e)return 0;const n=t/e*100;return isNaN(n)?0:n>100?100:Math.floor(n)}getContentState(e){return{id:e.userId,userId:e.userId,courseId:e.courseId,contentId:e.contentId,batchId:e.batchId,result:e.result,grade:e.grade,score:e.score,bestScore:e.bestScore,status:e.status,progress:e.progress}}}!function(e){e.START="START",e.PROGRESS="PROGRESS",e.END="END"}($r||($r={})),function(e){e[e.STATUS_FAILED=16]="STATUS_FAILED",e[e.STATUS_PAUSED=4]="STATUS_PAUSED",e[e.STATUS_PENDING=1]="STATUS_PENDING",e[e.STATUS_RUNNING=2]="STATUS_RUNNING",e[e.STATUS_SUCCESSFUL=8]="STATUS_SUCCESSFUL"}(qr||(qr={}));var Jr=n(47);class Qr{static equals(e,t){const n=e=>{let t=0;for(const n in e)e.hasOwnProperty(n)&&t++;return t},r=(e,t)=>{if(typeof e!=typeof t)return!1;if("function"==typeof e)return e.toString()===t.toString();if(e instanceof Object&&t instanceof Object){if(n(e)!==n(t))return!1;let i=!0;for(const n in e)if(i=r(e[n],t[n]),!i)return!1;return!0}return e===t};return r(e,t)}static getPropDiff(e,t){return Object.keys(e).reduce((n,r)=>(Qr.equals(e[r],t[r])||n.push(r),n),[])}static getTruthyProps(e){return Object.keys(e).filter(t=>!!e[t])}static toOrderedString(e){return JSON.stringify(Object.keys(e).sort().reduce((t,n)=>(t[n]=e[n],t),{}))}static withDeeplyOrderedKeys(e){return Object.keys(e).sort().reduce((t,n)=>("object"!=typeof e[n]||Array.isArray(e[n])?t[n]=e[n]:t[n]=Qr.withDeeplyOrderedKeys(e[n]),t),{})}}var Zr=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ei{constructor(e,t,n,r){this.courseService=e,this.sdkConfig=t,this.dbService=n,this.networkQueue=r,this.capturedAssessmentEvents={}}handle(e){return this.capturedAssessmentEvents=e,Object(c.from)(this.syncCapturedAssessmentEvents().then(()=>{this.capturedAssessmentEvents={}}).then(()=>this.syncPersistedAssessmentEvents()).catch(e=>{Object.keys(this.capturedAssessmentEvents).forEach(e=>{const t=JSON.parse(e);this.capturedAssessmentEvents[e].forEach(e=>{2!==t.batchStatus&&this.persistAssessEvent(e,t).toPromise()})})})).pipe(Object(D.mapTo)(void 0))}invokeSyncApi(e){return console.log("COURSE_ASSESSMENT_INVOKED_SYNC----------------------------------------------",e.assessments.map(e=>({assessmentTs:e.assessmentTs,userId:e.userId,contentId:e.contentId,courseId:e.courseId,batchId:e.batchId,attemptId:e.attemptId,events:e.events.length}))),this.networkQueue.enqueue(new En(this.sdkConfig).generateNetworkQueueRequest(Ft.COURSE_ASSESMENT,{request:e},en.generateUniqueId(),0,!0),!0).pipe(Object(D.mergeMap)(()=>new c.Observable(e=>{sbsync.onSyncSucces(t=>Zr(this,void 0,void 0,(function*(){const n=t.courseAssesmentResponse,r=t.course_assesment_error;n?e.next(n):r&&e.error(r),e.complete()})),t=>Zr(this,void 0,void 0,(function*(){e.error(t)})))}))).toPromise()}persistAssessEvent(e,t){return this.dbService.insert({table:wt.TABLE_NAME,modelJson:{[wt.COLUMN_NAME_ASSESSMENT_EVENT]:JSON.stringify(e),[wt.COLUMN_NAME_CONTENT_ID]:e.object.id,[wt.COLUMN_NAME_CREATED_AT]:e.ets,[wt.COLUMN_NAME_USER_ID]:t.userId,[wt.COLUMN_NAME_COURSE_ID]:t.courseId,[wt.COLUMN_NAME_BATCH_ID]:t.batchId}}).pipe(Object(D.mapTo)(void 0))}syncCapturedAssessmentEvents(){return Zr(this,void 0,void 0,(function*(){const e=Object.keys(this.capturedAssessmentEvents).reduce((e,t)=>{const n=JSON.parse(t),r=this.capturedAssessmentEvents[t];e.userId||(e.userId=n.userId);const i={contentId:r[0].object.id,courseId:n.courseId,batchId:n.batchId,status:2};e.contents.find(e=>Qr.equals(e,i))||e.contents.push(i);const o=r.reduce((e,t)=>t.ets<e?t.ets:e,r[0].ets);return e.assessments.push({assessmentTs:o,userId:n.userId,contentId:r[0].object.id,courseId:n.courseId,batchId:n.batchId,attemptId:this.courseService.generateAssessmentAttemptId({courseId:n.courseId,batchId:n.batchId,contentId:r[0].object.id,userId:n.userId,date:o}),events:r}),e},{userId:"",contents:[],assessments:[]});if(e.userId&&e.contents.length&&e.assessments.length)return this.invokeSyncApi(e)}))}syncPersistedAssessmentEvents(){return Zr(this,void 0,void 0,(function*(){this.dbService.execute(`\n SELECT\n ${wt.COLUMN_NAME_USER_ID},\n ${wt.COLUMN_NAME_CONTENT_ID},\n ${wt.COLUMN_NAME_COURSE_ID},\n ${wt.COLUMN_NAME_BATCH_ID},\n MIN(${wt.COLUMN_NAME_CREATED_AT}) as first_ts,\n GROUP_CONCAT(${wt.COLUMN_NAME_ASSESSMENT_EVENT},',') as events\n FROM ${wt.TABLE_NAME}\n GROUP BY\n ${wt.COLUMN_NAME_USER_ID},\n ${wt.COLUMN_NAME_CONTENT_ID},\n ${wt.COLUMN_NAME_COURSE_ID},\n ${wt.COLUMN_NAME_BATCH_ID}\n ORDER BY ${wt.COLUMN_NAME_CREATED_AT}\n `).pipe(Object(D.map)(e=>e.map(e=>({userId:e[wt.COLUMN_NAME_USER_ID],contentId:e[wt.COLUMN_NAME_CONTENT_ID],courseId:e[wt.COLUMN_NAME_COURSE_ID],batchId:e[wt.COLUMN_NAME_BATCH_ID],firstTs:e.first_ts,events:JSON.parse("["+e.events+"]")}))),Object(D.mergeMap)(e=>{if(!e.length)return Object(c.of)(void 0);const t=e.reduce((e,{firstTs:t,userId:n,contentId:r,courseId:i,batchId:o,events:s})=>{e.userId||(e.userId=n);const a={contentId:r,courseId:i,batchId:o,status:2};return e.contents.find(e=>Qr.equals(e,a))||e.contents.push(a),e.assessments.push({assessmentTs:t,userId:n,contentId:r,courseId:i,batchId:o,attemptId:this.courseService.generateAssessmentAttemptId({courseId:i,batchId:o,contentId:r,userId:n}),events:s}),e},{userId:"",contents:[],assessments:[]});return this.invokeSyncApi(t)}),Object(D.tap)(()=>Zr(this,void 0,void 0,(function*(){return yield this.dbService.execute("DELETE FROM "+wt.TABLE_NAME).toPromise()}))),Object(D.mapTo)(void 0)).toPromise()}))}}ei.UPDATE_CONTENT_STATE_ENDPOINT="/content/state/update";class ti{constructor(e,t){this.apiService=e,this.cachedItemStore=t}handle(e){return this.cachedItemStore.get(e.userId,ti.GET_LEARNER_CERTIFICATE_LOCAL_KEY,"ttl_"+ti.GET_LEARNER_CERTIFICATE_LOCAL_KEY,()=>this.fetchFromServer(e))}fetchFromServer(e){let t=Object.assign(Object.assign({},e.size?{size:e.size}:null),{_source:["data.badge.issuer.name","pdfUrl","data.issuedOn","data.badge.name","related.courseId","related.Id"],query:{bool:{must:[{match_phrase:{"recipient.id":e.userId}}]}}});const n=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(ti.CERTIFICATE_SEARCH_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:t}).build();return this.apiService.fetch(n).pipe(Object(D.map)(e=>e.body.result.response))}}ti.CERTIFICATE_SEARCH_ENDPOINT="/api/certreg/v1/certs/search",ti.GET_LEARNER_CERTIFICATE_LOCAL_KEY="learner-certificate";var ni=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ri{constructor(e,t){this.keyValueStore=e,this.sharedPreference=t}process(e){return ni(this,void 0,void 0,(function*(){if(1===(yield this.getCourseContext().toPromise()).batchStatus)for(const t of Object.keys(e)){const n=JSON.parse(t),r=e[t];if(!r)continue;const i=hi.GET_CONTENT_STATE_KEY_PREFIX.concat(n.userId,n.courseId),o=yield this.keyValueStore.getValue(i).toPromise(),s=o?JSON.parse(o):{contentList:[]},a=r.reduce((e,t)=>{try{const r=t.context.cdata.find(e=>"AttemptId"===e.type).id,i=t.object.id,o=t.edata.item.maxscore,a=t.edata.score;if(e[i]){const t=e[i];t.attemptId=r,t.lastAttemptedOn=Date.now()+"",t.totalMaxScore+=o,t.totalScore+=a}else e[i]={attemptId:r,lastAttemptedOn:Date.now()+"",totalMaxScore:o,totalScore:a};s.contentList.find(e=>e.contentId===i)||s.contentList.push({lastAccessTime:"2021-01-14 07:09:32:602+0000",contentId:i,progress:100,batchId:n.batchId,courseId:n.courseId,collectionId:n.courseId,lastCompletedTime:"2021-01-14 07:09:32:810+0000",status:2})}catch(e){console.error(e)}return e},{});s.contentList=s.contentList.map(e=>e.score&&e.score.length?a[e.contentId]?(e.score.push(a[e.contentId]),e.bestScore&&e.bestScore.totalScore<a[e.contentId].totalScore&&(e.bestScore=a[e.contentId]),e):e:(e.score=a[e.contentId]?[a[e.contentId]]:[],e.bestScore=e.score.reduce((e,t)=>e?e.totalScore<t.totalScore?t:e:t,void 0),e)),console.log(s),yield this.keyValueStore.setValue(i,JSON.stringify(s)).toPromise()}}))}getCourseContext(){return this.sharedPreference.getString(S.COURSE_CONTEXT).pipe(Object(D.map)(e=>e?JSON.parse(e):{}))}}var ii=n(21),oi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class si{constructor(e,t,n,r){this.profileService=e,this.fileService=t,this.keyValueStore=n,this.csCourseService=r}isCertificateCached(e){return Object(c.defer)(()=>oi(this,void 0,void 0,(function*(){try{return!!(yield this.getCertificateFromCache(e))}catch(e){return console.error(e),!1}})))}getCertificate(e){return this.csCourseService.getSignedCourseCertificate(e.certificate.identifier).pipe(Object(D.tap)(t=>oi(this,void 0,void 0,(function*(){yield this.keyValueStore.setValue(yield this.buildCertificatePersistenceId(e),Object(an.gzip)(t.printUri,{to:"string"})).toPromise()}))),Object(D.map)(e=>e.printUri),Object(D.catchError)(t=>Object(c.defer)(()=>oi(this,void 0,void 0,(function*(){const n=yield this.getCertificateFromCache(e);if(n)return n;throw t})))))}downloadCertificate({fileName:e,blob:t}){return Object(c.defer)(()=>oi(this,void 0,void 0,(function*(){return this.fileService.writeFile(cordova.file.externalDataDirectory,e,t,{replace:!0}).then(()=>({path:`${cordova.file.externalDataDirectory}${e}`}))})))}buildCertificatePersistenceId(e){return oi(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n=t.managedSession?t.managedSession.uid:t.uid;return`certificate_${e.certificate.identifier}_${e.courseId}_${n}`}))}getCertificateFromCache(e){return oi(this,void 0,void 0,(function*(){const t=yield this.keyValueStore.getValue(yield this.buildCertificatePersistenceId(e)).toPromise();return t?Object(ii.ungzip)(t,{to:"string"}):void 0}))}}var ai,ci=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},ui=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},li=function(e,t){return function(n,r){t(n,r,e)}},di=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let hi=ai=class{constructor(e,t,n,r,i,o,s,a,c,u,l,d,h){this.sdkConfig=e,this.apiService=t,this.profileService=n,this.keyValueStore=r,this.dbService=i,this.sharedPreferences=o,this.appInfo=s,this.fileService=a,this.cachedItemStore=c,this.csCourseService=u,this.networkQueue=l,this.container=d,this.authService=h,this.capturedAssessmentEvents={},this.courseServiceConfig=this.sdkConfig.courseServiceConfig,this.profileServiceConfig=this.sdkConfig.profileServiceConfig,this.syncAssessmentEventsHandler=new ei(this,this.sdkConfig,this.dbService,this.networkQueue),this.offlineAssessmentScoreProcessor=new ri(this.keyValueStore,this.sharedPreferences)}get certificateManager(){return this._certificateManager||(this._certificateManager=new si(this.profileService,this.fileService,this.keyValueStore,this.csCourseService)),this._certificateManager}static buildUrl(e,t,n){return`${e}${t}?${Be.stringify(n)}`}getBatchDetails(e){return new xr(this.apiService,this.courseServiceConfig).handle(e)}updateContentState(e){return e.target||(e.target=[Ei.LOCAL,Ei.SERVER]),Object(c.defer)(()=>di(this,void 0,void 0,(function*(){const t=new Xr(this.keyValueStore);if(e.target.indexOf(Ei.SERVER)>-1)try{yield new hn(this.networkQueue,this.sdkConfig).handle(class{static getUpdateContentStateRequest(e){const t=[];return t.push(this.getRequestMap(e)),{userId:e.userId,contents:t}}static getUpdateContentStateListRequest(e,t){const n=[];return t.forEach(e=>{n.push(this.getRequestMap(e))}),{userId:e,contents:n}}static getRequestMap(e){const t={userId:e.userId,contentId:e.contentId,courseId:e.courseId,batchId:e.batchId,status:e.status,progress:e.progress};return e.result&&(t.result=e.result),e.grade&&(t.grade=e.grade),e.score&&(t.score=e.score),t}}.getUpdateContentStateRequest(e)).toPromise()}catch(e){}return e.target.indexOf(Ei.LOCAL)>-1&&(yield t.manipulateEnrolledCoursesResponseLocally(e).toPromise(),yield t.manipulateGetContentStateResponseLocally(e).toPromise()),!0})))}getCourseBatches(e){return new Br(this.apiService,this.courseServiceConfig).handle(e)}getEnrolledCourses(e,t){return new Yr(this.keyValueStore,this.apiService,this.courseServiceConfig,this.sharedPreferences,t).handle(e)}getUserEnrolledCourses({request:e,from:t}){return this.cachedItemStore[t===Jn.SERVER?"get":"getCached"](e.userId+(e.filters?"_"+JSON.stringify(e.filters):""),ai.USER_ENROLLMENT_LIST_KEY_PREFIX,"ttl_"+ai.USER_ENROLLMENT_LIST_KEY_PREFIX,()=>this.csCourseService.getUserEnrolledCourses(e,{},{apiPath:"/api/course/v2",certRegistrationApiPath:""}))}enrollCourse(e){return new Gr(this.apiService,this.courseServiceConfig).handle(e).pipe(Object(D.mergeMap)(t=>{if(t){const n={};return n.userId=e.userId,n.batchStatus=e.batchStatus,this.sharedPreferences.putString(S.COURSE_CONTEXT,JSON.stringify(n)).pipe(Object(D.delay)(2e3),Object(D.concatMap)(()=>this.getEnrolledCourses({userId:e.userId,returnFreshCourses:!0})),Object(D.mapTo)(t))}return Object(c.of)(t)}))}getContentState(e){const t=ai.GET_CONTENT_STATE_KEY_PREFIX.concat(e.userId,e.courseId),n=new Xr(this.keyValueStore),r=new Wr(this.keyValueStore,n);return this.keyValueStore.getValue(t).pipe(Object(D.mergeMap)(i=>!i||e.returnRefreshedContentStates?new zr(this.apiService,this.courseServiceConfig,this.container).handle(e).pipe(Object(D.mergeMap)(i=>i?this.keyValueStore.setValue(t,JSON.stringify(i)).pipe(Object(D.mergeMap)(()=>n.getLocalContentStateResponse(e)),Object(D.mergeMap)(()=>r.updateEnrollCourses(e))):Object(c.of)(void 0)),Object(D.catchError)(t=>n.getLocalContentStateResponse(e).pipe(Object(D.mergeMap)(()=>r.updateEnrollCourses(e))))):n.getLocalContentStateResponse(e)))}unenrollCourse(e){return new Hr(this.apiService,this.courseServiceConfig).handle(e).pipe(Object(D.delay)(2e3),Object(D.concatMap)(()=>this.getEnrolledCourses({userId:e.userId,returnFreshCourses:!0})),Object(D.mapTo)(!0))}downloadCurrentProfileCourseCertificate(e){return Object(c.defer)(()=>di(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n=t.managedSession?t.managedSession.uid:t.uid;"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalRootDirectory,e.certificate.name,e.courseId;return{userId:n}}))).pipe(Object(D.mergeMap)(({userId:t})=>{const n=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(ai.CERTIFICATE_SIGN_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:{pdfUrl:e.certificate.url}}).build();return this.apiService.fetch(n).pipe(Object(D.map)(e=>({signedPdfUrl:e.body.result.signedUrl,userId:t})))}),Object(D.mergeMap)(({signedPdfUrl:t,userId:n})=>{const r={uri:t,title:e.certificate.token,description:"",mimeType:"application/pdf",visibleInDownloadsUi:!0,notificationVisibility:1,destinationInExternalPublicDir:{dirType:"Download",subPath:`/${e.certificate.name}_${e.courseId}_${n}.pdf`},headers:[]};return new c.Observable(e=>{downloadManager.enqueue(r,(t,n)=>{if(t)return e.error(t);e.next(n),e.complete()})})}),Object(D.mergeMap)(e=>Object(c.interval)(1e3).pipe(Object(D.mergeMap)(()=>new c.Observable(t=>{downloadManager.query({ids:[e]},(e,n)=>e||n[0].status===qr.STATUS_FAILED?t.error(e||new Error("Unknown Error")):t.next(n[0]))})),Object(D.filter)(e=>e.status===qr.STATUS_SUCCESSFUL),Object(D.take)(1))),Object(D.map)(e=>({path:e.localUri})))}hasCapturedAssessmentEvent({courseContext:e}){const t=Qr.toOrderedString(e);return!!this.capturedAssessmentEvents[t]}captureAssessmentEvent({event:e,courseContext:t}){const n=Qr.toOrderedString(t);this.capturedAssessmentEvents[n]||(this.capturedAssessmentEvents[n]=[]),this.capturedAssessmentEvents[n].push(e)}syncAssessmentEvents(e={persistedOnly:!1}){let t={};return e.persistedOnly||(t=this.capturedAssessmentEvents,this.resetCapturedAssessmentEvents()),this.offlineAssessmentScoreProcessor.process(t),this.syncAssessmentEventsHandler.handle(t)}resetCapturedAssessmentEvents(){this.capturedAssessmentEvents={}}generateAssessmentAttemptId(e){return Jr([e.courseId,e.batchId,e.contentId,e.userId,e.date?e.date:Date.now()].join("-")).toString()}displayDiscussionForum(e){return Object(c.defer)(()=>di(this,void 0,void 0,(function*(){const t=yield this.authService.getSession().toPromise();if(!t)return!1;const n=t.managed_access_token||t.access_token;return cordova.InAppBrowser.open(ai.buildUrl(this.sdkConfig.apiConfig.host,ai.DISCUSSION_FORUM_ENDPOINT,{access_token:n,returnTo:"/category/"+e.forumId}),"_blank","zoom=no,clearcache=yes,clearsessioncache=yes,cleardata=yes,hideurlbar=yes,hidenavigationbuttons=true"),!0})))}getLearnerCertificates(e){return new ti(this.apiService,this.cachedItemStore).handle(e)}syncCourseProgress(e){return this.csCourseService.updateContentState(e,{apiPath:"/api/course/v1"})}clearAssessments(){return this.sharedPreferences.getString(S.COURSE_CONTEXT).pipe(Object(D.map)(e=>{const t=e?JSON.parse(e):{};if(t){const e=Qr.toOrderedString(t);this.capturedAssessmentEvents[e]&&(this.capturedAssessmentEvents[e]=[])}}))}};var Ei,fi,pi;hi.USER_ENROLLMENT_LIST_KEY_PREFIX="userEnrollmentList",hi.GET_CONTENT_STATE_KEY_PREFIX="getContentState",hi.GET_ENROLLED_COURSE_KEY_PREFIX="enrolledCourses",hi.UPDATE_CONTENT_STATE_KEY_PREFIX="updateContentState",hi.LAST_READ_CONTENTID_PREFIX="lastReadContentId",hi.CERTIFICATE_SIGN_ENDPOINT="/api/certreg/v1/certs/download",hi.DISCUSSION_FORUM_ENDPOINT="/discussions/auth/sunbird-oidc/callback",hi=ai=ci([Object(s.injectable)(),li(0,Object(s.inject)(l.SDK_CONFIG)),li(1,Object(s.inject)(l.API_SERVICE)),li(2,Object(s.inject)(l.PROFILE_SERVICE)),li(3,Object(s.inject)(l.KEY_VALUE_STORE)),li(4,Object(s.inject)(l.DB_SERVICE)),li(5,Object(s.inject)(l.SHARED_PREFERENCES)),li(6,Object(s.inject)(l.APP_INFO)),li(7,Object(s.inject)(l.FILE_SERVICE)),li(8,Object(s.inject)(l.CACHED_ITEM_STORE)),li(9,Object(s.inject)(u.COURSE_SERVICE)),li(10,Object(s.inject)(l.NETWORK_QUEUE)),li(11,Object(s.inject)(l.CONTAINER)),li(12,Object(s.inject)(l.AUTH_SERVICE)),ui("design:paramtypes",[Object,Object,Object,Object,o,Object,Object,Object,Object,Object,Object,s.Container,Object])],hi),function(e){e.LOCAL="LOCAL",e.SERVER="SERVER"}(Ei||(Ei={})),function(e){e.OPEN="open",e.INVITE_ONLY="invite-only"}(fi||(fi={})),function(e){e.NOT_STARTED="0",e.IN_PROGRESS="1",e.COMPLETED="2"}(pi||(pi={}));class _i extends ke{constructor(e,t){super(e,"CERTIFICATE_ALREADY_DOWNLOADED"),this.filePath=t,Object.setPrototypeOf(this,_i.prototype)}}var Oi=n(48),Si=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class gi{constructor(e){this.contentService=e}provide(e,t){return e.objectType=gi.getCategoryMapper(t),this.trackableSessionContentCache?Object(c.iif)(()=>!!this.trackableSessionContentCache[e.contentId],Object(c.defer)(()=>Object(c.of)(this.trackableSessionContentCache[e.contentId])),Object(c.defer)(()=>this.contentService.getContentDetails(e).pipe(Object(D.tap)(t=>this.trackableSessionContentCache[e.contentId]=t)))):this.contentService.getContentDetails(e)}cache(e){this.trackableSessionContentCache&&(this.trackableSessionContentCache[e.identifier]=e)}init(){this.trackableSessionContentCache={}}dispose(){this.trackableSessionContentCache=void 0}static getCategoryMapper(e){switch(e){case Fn.CsPrimaryCategory.PRACTICE_QUESTION_SET:return"QuestionSet";case"Multiple Choice Question":return"Question"}}}class Ai{constructor(e,t,n,r,i,o){this.courseService=e,this.sharedPreference=t,this.summarizerService=n,this.eventBusService=r,this.contentService=i,this.profileService=o,this.currentUID=void 0,this.currentContentID=void 0,this.courseContext={},this.trackableSessionProxyContentProvider=new gi(this.contentService)}static checkPData(e){return null!=e&&null!==e.pid&&-1!==e.pid.indexOf(Ai.CONTENT_PLAYER_PID)}static isContentTrackable(e){return!!e.contentData.trackable&&e.contentData.trackable.enabled===Dn.TrackingEnabled.YES}static isCourseAssessmentContent(e){return e.primaryCategory&&e.primaryCategory.toLowerCase()===Fn.CsPrimaryCategory.COURSE_ASSESSMENT.toLowerCase()}updateContentState(e){return this.getCourseContext().pipe(Object(D.mergeMap)(t=>{const n=t.userId,r=t.courseId,i=t.batchId;let o=0;t.hasOwnProperty("batchStatus")&&(o=t.batchStatus);if(1===o){const o=e.object.id;return this.checkStatusOfContent(n,r,i,o).pipe(Object(D.mergeMap)(s=>{if("START"===e.eid&&0===s){const e={userId:n,contentId:o,courseId:r,batchId:i,status:1,progress:5};return this.courseService.updateContentState(e).pipe(Object(D.mapTo)(void 0))}return"END"===e.eid&&0===s||"END"===e.eid&&1===s?this.trackableSessionProxyContentProvider.provide({contentId:e.object.id},e.object.type).pipe(Object(D.mergeMap)(o=>this.validEndEvent(e,o,t).pipe(Object(D.mergeMap)(t=>{if(t){const t=Oi.CsContentProgressCalculator.calculate(e.edata.summary,o.mimeType),s={userId:n,contentId:o.identifier,courseId:r,batchId:i,status:100===t?2:1,progress:t,target:Ai.isCourseAssessmentContent(o)?[Ei.LOCAL]:[Ei.LOCAL,Ei.SERVER]};return this.generateAuditTelemetry(n,r,i,o,e.object?e.object.rollup:{}),this.courseService.updateContentState(s).pipe(Object(D.tap)(()=>{this.eventBusService.emit({namespace:M.CONTENT,event:{type:Pn.COURSE_STATE_UPDATED,payload:{contentId:s.courseId}}})}),Object(D.mapTo)(void 0))}return Object(c.of)(void 0)})))):Object(c.of)(void 0)}),Object(D.tap)(()=>{this.updateLastReadContentId(n,r,i,o).toPromise()}))}return Object(c.of)(void 0)}))}handle(e){return Object(c.defer)(()=>Si(this,void 0,void 0,(function*(){if("START"===e.eid){if(Ai.checkPData(e.context.pdata))return this.courseService.resetCapturedAssessmentEvents(),this.processOEStart(e).pipe(Object(D.tap)(()=>Si(this,void 0,void 0,(function*(){yield this.summarizerService.saveLearnerAssessmentDetails(e).pipe(Object(D.mapTo)(void 0)).toPromise()}))),Object(D.tap)(()=>Si(this,void 0,void 0,(function*(){yield this.getCourseContext().pipe(Object(D.mergeMap)(()=>this.updateContentState(e))).toPromise()}))),Object(D.tap)(()=>Si(this,void 0,void 0,(function*(){yield this.markContentAsPlayed(e).toPromise()})))).toPromise();if(e.object&&e.object.id){const t=yield this.trackableSessionProxyContentProvider.provide({contentId:e.object.id},e.object.type).toPromise();if(Ai.isContentTrackable(t))return this.trackableSessionProxyContentProvider.init(),this.trackableSessionProxyContentProvider.cache(t),this.getCourseContext().pipe(Object(D.mapTo)(void 0)).toPromise()}}else{if("ASSESS"===e.eid&&Ai.checkPData(e.context.pdata))return this.processOEAssess(e).pipe(Object(D.tap)(()=>Si(this,void 0,void 0,(function*(){const t=yield this.getCourseContext().toPromise();e.context.cdata.find(e=>"AttemptId"===e.type)&&t.userId&&t.courseId&&t.batchId&&(yield this.courseService.captureAssessmentEvent({event:e,courseContext:t}))}))),Object(D.tap)(()=>Si(this,void 0,void 0,(function*(){yield this.summarizerService.saveLearnerAssessmentDetails(e).pipe(Object(D.mapTo)(void 0)).toPromise()})))).toPromise();if("END"===e.eid){if(Ai.checkPData(e.context.pdata))return this.processOEEnd(e).pipe(Object(D.tap)(()=>Si(this,void 0,void 0,(function*(){yield this.summarizerService.saveLearnerContentSummaryDetails(e).pipe(Object(D.mapTo)(void 0)).toPromise()}))),Object(D.tap)(()=>Si(this,void 0,void 0,(function*(){yield this.getCourseContext().pipe(Object(D.mergeMap)(()=>this.updateContentState(e))).toPromise()})))).toPromise();if(e.object&&e.object.id){const t=yield this.trackableSessionProxyContentProvider.provide({contentId:e.object.id},e.object.type).toPromise();if(Ai.isContentTrackable(t))return this.trackableSessionProxyContentProvider.dispose(),this.setCourseContextEmpty().toPromise()}}}})))}setCourseContextEmpty(){return this.courseContext={},this.sharedPreference.putString(S.COURSE_CONTEXT,"")}validEndEvent(e,t,n){const r=()=>n&&(Ai.isCourseAssessmentContent(t)||t.contentType&&"onboardingresource"===t.contentType.toLowerCase()||t.primaryCategory&&"onboardingresource"===t.primaryCategory.toLowerCase())&&this.courseService.hasCapturedAssessmentEvent({courseContext:n});return Object(c.defer)(()=>Object(c.of)(void 0)).pipe(Object(D.delay)(2e3),Object(D.map)(()=>!r()&&(e.edata.summary&&!!e.edata.summary.find(e=>e.progress))),Object(D.tap)(()=>this.courseService.resetCapturedAssessmentEvents()))}updateLastReadContentId(e,t,n,r){const i=hi.LAST_READ_CONTENTID_PREFIX.concat("_").concat(e).concat("_").concat(t).concat("_").concat(n);return this.sharedPreference.putString(i,r)}markContentAsPlayed(e){const t=e.actor.id,n=e.object.id,r={contentId:n};return this.trackableSessionProxyContentProvider.provide(r,e.object.type).pipe(Object(D.mergeMap)(e=>{const r={status:Xn.PLAYED,contentId:n,contentType:e.contentType||e.primaryCategory};return this.profileService.addContentAccess(r).pipe(Object(D.mergeMap)(()=>{const r={uid:t,contentId:n,data:JSON.stringify(e.contentData),marker:Sn.PREVIEWED,isMarked:!0,extraInfo:{}};return this.contentService.setContentMarker(r).pipe(Object(D.mapTo)(!0))}))}))}getCourseContext(){return this.sharedPreference.getString(S.COURSE_CONTEXT).pipe(Object(D.map)(e=>e?JSON.parse(e):{}))}checkStatusOfContent(e,t,n,r){const i={userId:e,batchId:n,contentIds:[r],courseId:t};return this.courseService.getContentState(i).pipe(Object(D.map)(e=>{const t=e&&e.contentList;return this.getStatus(t,r)}))}getStatus(e=[],t){const n=e.find(e=>e.contentId===t);return n&&n.status||0}processOEStart(e){return this.currentUID=e.actor.id,this.currentContentID=e.object.id,Object(c.of)(void 0)}processOEAssess(e){return this.currentUID&&this.currentContentID&&this.currentUID.toLocaleLowerCase()===e.actor.id.toLocaleLowerCase()&&this.currentContentID.toLocaleLowerCase()===e.object.id.toLocaleLowerCase()?this.summarizerService.deletePreviousAssessmentDetails(this.currentUID,this.currentContentID).pipe(Object(D.tap)(()=>{this.currentUID=void 0,this.currentContentID=void 0}),Object(D.mapTo)(void 0)):Object(c.of)(void 0)}processOEEnd(e){return Object(c.of)(void 0)}generateAuditTelemetry(e,t,n,r,i){const o=new pe;o.id=e,o.type=pe.TYPE_USER;const s=[{type:"CourseId",id:t||""},{type:"BatchId",id:n||""},{type:"UserId",id:e||""},{type:"ContentId",id:r.identifier||""}],a={env:"course",actor:o,currentState:ue.AUDIT_UPDATED,updatedProperties:["progress"],objId:r.identifier,objType:r.contentData.contentType||"",objVer:r.contentData.pkgVersion||"",rollUp:i||{},correlationData:s,type:"content-progress"};ln.log.audit(a).toPromise()}}Ai.CONTENT_PLAYER_PID="contentplayer";var Ni=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ti{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:et.TABLE_NAME,orderBy:et.COLUMN_NAME_HANDLE+" asc",useExternalDb:!0}).toPromise().then(e=>{const t=e.map(e=>e[et.COLUMN_NAME_UID]);return this.deleteUnwantedAssesments(t)}).then(()=>this.saveLearnerAssesmentDetails()).then(()=>this.saveLearnerSummary()).then(()=>(t.body=e,t))}deleteUnwantedAssesments(e){return Ni(this,void 0,void 0,(function*(){const t=wn.joinPreservingQuotes(e),n=`DELETE FROM ${lt.TABLE_NAME}\n WHERE ${lt.COLUMN_NAME_UID} NOT IN(${t})`,r=`DELETE FROM ${ht.TABLE_NAME}\n WHERE ${ht.COLUMN_NAME_UID} NOT IN(${t})`;yield this.dbService.execute(n,!0).toPromise(),yield this.dbService.execute(r,!0).toPromise()}))}saveLearnerAssesmentDetails(){return Ni(this,void 0,void 0,(function*(){const e=yield this.dbService.read({table:lt.TABLE_NAME,orderBy:""+lt.COLUMN_NAME_Q_INDEX,useExternalDb:!0}).toPromise();for(const t of e){const e=t,n=kr.getFilterForLearnerAssessmentDetails(e[lt.COLUMN_NAME_QID],e[lt.COLUMN_NAME_UID],e[lt.COLUMN_NAME_CONTENT_ID],e[lt.COLUMN_NAME_HIERARCHY_DATA]),r=kr.getLearnerAssessmentsQuery(n),i=yield this.dbService.execute(r).toPromise();i&&i.length?yield this.dbService.update({table:lt.TABLE_NAME,selection:`${lt.COLUMN_NAME_CONTENT_ID} = ?\n AND ${lt.COLUMN_NAME_UID} = ?\n AND ${lt.COLUMN_NAME_QID} = ?`,selectionArgs:[e[lt.COLUMN_NAME_CONTENT_ID],e[lt.COLUMN_NAME_UID],e[lt.COLUMN_NAME_QID]],modelJson:e}).toPromise():yield this.dbService.insert({table:lt.TABLE_NAME,modelJson:e}).toPromise()}}))}saveLearnerSummary(){return Ni(this,void 0,void 0,(function*(){const e=yield this.dbService.read({table:ht.TABLE_NAME,useExternalDb:!0}).toPromise();for(const t of e){const e=t,n=yield this.dbService.read({table:ht.TABLE_NAME,selection:`${ht.COLUMN_NAME_CONTENT_ID} = ? AND ${ht.COLUMN_NAME_UID} = ?`,selectionArgs:[e[lt.COLUMN_NAME_CONTENT_ID],e[lt.COLUMN_NAME_UID]]}).toPromise();n&&n.length?yield this.dbService.update({table:ht.TABLE_NAME,selection:`${ht.COLUMN_NAME_CONTENT_ID} = ? AND ${ht.COLUMN_NAME_UID} = ?`,selectionArgs:[e[lt.COLUMN_NAME_CONTENT_ID],e[lt.COLUMN_NAME_UID]],modelJson:e}).toPromise():yield this.dbService.insert({table:ht.TABLE_NAME,modelJson:e}).toPromise()}e.forEach(e=>Ni(this,void 0,void 0,(function*(){const t=kr.getFilterForLearnerAssessmentDetails(e[lt.COLUMN_NAME_QID],e[lt.COLUMN_NAME_UID],e[lt.COLUMN_NAME_CONTENT_ID],e[lt.COLUMN_NAME_HIERARCHY_DATA]),n=kr.getLearnerAssessmentsQuery(t),r=yield this.dbService.execute(n).toPromise();r&&r.length?yield this.dbService.update({table:ht.TABLE_NAME,modelJson:r[0]}).toPromise():yield this.dbService.insert({table:ht.TABLE_NAME,modelJson:r[0]}).toPromise()})))}))}}class Ci{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse,n=e.metadata.export_id,r=e.metadata.did,i={imported_id:n,device_id:r,count:e.metadata.profiles_count};return this.dbService.read({table:ct.TABLE_NAME,selection:`${ct.COLUMN_NAME_IMPORTED_ID} =? AND ${ct.COLUMN_NAME_DEVICE_ID} = ?`,selectionArgs:[n,r],limit:"1"}).toPromise().then(e=>e&&e.length?this.dbService.update({table:ct.TABLE_NAME,modelJson:i,selection:`${ct.COLUMN_NAME_IMPORTED_ID} =? AND ${ct.COLUMN_NAME_DEVICE_ID} =?`,selectionArgs:[n,r]}).toPromise():this.dbService.insert({table:ct.TABLE_NAME,modelJson:i}).toPromise()).then(()=>(t.body=e,t))}}var vi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class yi{constructor(e){this.dbService=e}execute(e){const t=new a.CsResponse;return this.dbService.read({table:et.TABLE_NAME,orderBy:et.COLUMN_NAME_HANDLE+" asc",useExternalDb:!0}).toPromise().then(t=>this.saveProfilesToDb(e,t)).then(()=>(t.body=e,t))}saveProfilesToDb(e,t){return vi(this,void 0,void 0,(function*(){let n=0,r=0;for(const i of t){const t=yield this.dbService.read({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[i[et.COLUMN_NAME_UID]],limit:"1"}).toPromise();t&&t.length?(r++,e.failed=r):(i[et.COLUMN_NAME_CREATED_AT]||(i[et.COLUMN_NAME_CREATED_AT]=(new Date).getTime()),delete i[et._ID],yield this.dbService.insert({table:et.TABLE_NAME,modelJson:i}).toPromise(),n++,e.imported=n)}e.failed=r,e.imported=n}))}}class mi{constructor(e,t){this.sdkConfig=e,this.apiService=t,this.profileServiceConfig=this.sdkConfig.profileServiceConfig,this.apiConfig=this.sdkConfig.apiConfig}handle(e){return this.fetchFromServer(e)}fetchFromServer(e){console.log("Request",e);const t=(new a.CsRequest.Builder).withHost(this.apiConfig.host).withType(a.CsHttpRequestType.POST).withPath(this.profileServiceConfig.profileApiPath_V5+mi.USER_MIGRATE).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>(console.log("sucees",e),e.body)))}}mi.USER_MIGRATE="/migrate";var bi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ii{constructor(e,t,n,r,i,o,s,a){this.profileService=e,this.authService=t,this.profileServiceConfig=n,this.apiService=r,this.cachedItemStore=i,this.dbService=o,this.frameworkService=s,this.sharedPreferences=a,this.managedProfileAdded$=new c.Subject}addManagedProfile(e){return Object(c.defer)(()=>bi(this,void 0,void 0,(function*(){if(!(yield this.isLoggedInUser()))throw new ki("No active LoggedIn Session found");const{uid:t}=yield this.createManagedProfile(e);return setTimeout(()=>{this.managedProfileAdded$.next(!0)},1e3),{uid:t}})))}getManagedServerProfiles(e){return this.managedProfileAdded$.pipe(Object(D.startWith)(!1),Object(D.mergeMap)(t=>Object(c.defer)(()=>bi(this,void 0,void 0,(function*(){if(!(yield this.isLoggedInUser()))throw new ki("No active LoggedIn Session found");e.from!==Jn.SERVER&&(e.from=t?Jn.SERVER:Jn.CACHE);const n=yield this.profileService.getActiveSessionProfile({requiredFields:[]}).toPromise(),r=n.serverProfile&&n.serverProfile.managedBy?n.serverProfile.managedBy:n.uid,i=()=>Object(c.defer)(()=>bi(this,void 0,void 0,(function*(){const t=n.serverProfile&&!n.serverProfile.managedBy?n.serverProfile:yield this.profileService.getServerProfilesDetails({userId:n.serverProfile.managedBy,requiredFields:e.requiredFields}).toPromise(),i=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(`${this.profileServiceConfig.profileApiPath}/managed/${r}`).withParameters({withTokens:"true",sortBy:"createdDate",order:"desc"}).withBearerToken(!0).withUserToken(!0).build();return yield this.apiService.fetch(i).toPromise().then(e=>[t,...e.body.result.response.content.sort((e,t)=>new Date(t.createdDate).getTime()-new Date(e.createdDate).getTime())])}))).pipe(Object(D.tap)(e=>bi(this,void 0,void 0,(function*(){const t=yield this.dbService.execute(`\n SELECT * from ${et.TABLE_NAME}\n WHERE ${et.COLUMN_NAME_UID}\n IN (${wn.joinPreservingQuotes(e.map(e=>e.id))})\n `).toPromise().then(e=>e.map(e=>ir.mapProfileDBEntryToProfile(e))),n=e.filter(e=>!t.find(t=>t.uid===e.id));for(const e of n)this.persistManagedProfile(e)}))));return this.cachedItemStore[e.from===Jn.SERVER?"get":"getCached"](r,Ii.MANGED_SERVER_PROFILES_LOCAL_KEY,"ttl_"+Ii.MANGED_SERVER_PROFILES_LOCAL_KEY,()=>i()).toPromise()})))))}switchSessionToManagedProfile({uid:e}){return Object(c.defer)(()=>bi(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n=Object.assign({},t);yield ln.log.end({type:"session",env:"sdk",mode:"switch-user",duration:Math.floor((Date.now()-(n.managedSession||n).createdTime)/1e3),correlationData:[{type:"InitiatorId",id:n.managedSession?n.managedSession.uid:n.uid},{type:"ManagedUserId",id:e}]}).toPromise();const r=yield(()=>bi(this,void 0,void 0,(function*(){return this.dbService.read({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}).toPromise().then(e=>e&&e[0]&&ir.mapProfileDBEntryToProfile(e[0]))})))();if(!r)throw new xi("No Profile found with uid="+e);if(r.source!==Wn.SERVER)throw new xi("No Server Profile found with uid="+e);if(t.uid===e){t.managedSession=void 0;const e=yield this.authService.getSession().toPromise();e.managed_access_token=void 0,yield this.authService.setSession(new class{provide(){return bi(this,void 0,void 0,(function*(){return e}))}}).toPromise()}else{t.managedSession=new Zn(e);const n=(yield this.getManagedServerProfiles({from:Jn.CACHE,requiredFields:[]}).pipe(Object(D.take)(1)).toPromise()).find(t=>t.id===e),r=yield this.authService.getSession().toPromise();r.managed_access_token=n.managedToken,yield this.authService.setSession(new class{provide(){return bi(this,void 0,void 0,(function*(){return r}))}}).toPromise()}yield this.sharedPreferences.putString(p.KEY_USER_SESSION,JSON.stringify(t)).toPromise(),ln.log.start({type:"session",env:"sdk",mode:"switch-user",correlationData:[{type:"InitiatorId",id:n.managedSession?n.managedSession.uid:n.uid},{type:"ManagedUserId",id:t.managedSession?t.managedSession.uid:t.uid}]}).toPromise()}))).pipe(Object(D.mergeMap)(()=>this.authService.getSession().pipe(Object(D.mergeMap)(t=>this.authService.setSession(new class{provide(){return bi(this,void 0,void 0,(function*(){return Object.assign(Object.assign({},t),{userToken:e})}))}})))),Object(D.mergeMap)(()=>bi(this,void 0,void 0,(function*(){const t=yield this.profileService.getServerProfilesDetails({userId:e,requiredFields:[]}).toPromise(),n=t.rootOrg?t.rootOrg.hashTagId:t.rootOrgId;return this.frameworkService.setActiveChannelId(n).toPromise()}))),Object(D.mapTo)(void 0))}persistManagedProfile(e){return bi(this,void 0,void 0,(function*(){e.userId=e.id,e.rootOrg={hashTagId:e.rootOrgId},this.profileService.createProfile({uid:e.id,profileType:zn.STUDENT,source:Wn.SERVER,handle:e.firstName,board:e.framework&&e.framework.board||[],medium:e.framework&&e.framework.medium||[],grade:e.framework&&e.framework.gradeLevel||[],gradeValue:e.framework&&e.framework.gradeValue||"",subject:e.framework&&e.framework.subject||[],serverProfile:e},Wn.SERVER).toPromise(),this.cachedItemStore.getCached(e.id,Ii.USER_PROFILE_DETAILS_KEY_PREFIX,Ii.USER_PROFILE_DETAILS_KEY_PREFIX,()=>Object(c.of)(e)).toPromise()}))}createManagedProfile(e){return bi(this,void 0,void 0,(function*(){if((yield this.profileService.getActiveSessionProfile({requiredFields:[]}).toPromise()).source!==Wn.SERVER)throw new ki("No active session available");const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.profileServiceConfig.profileApiPath_V2+"/managed/create").withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return yield this.apiService.fetch(t).toPromise().then(e=>({uid:e.body.result.userId}))}))}isLoggedInUser(){return bi(this,void 0,void 0,(function*(){return!!(yield this.authService.getSession().toPromise())}))}}Ii.MANGED_SERVER_PROFILES_LOCAL_KEY="managed_server_profiles-",Ii.USER_PROFILE_DETAILS_KEY_PREFIX="userProfileDetails";var Mi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ri{constructor(e){this.dbService=e}delete(e){return Object(c.defer)(()=>Object(c.of)(this.dbService.beginTransaction())).pipe(Object(D.mergeMap)(()=>Object(c.zip)(this.dbService.delete({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:vt.TABLE_NAME,selection:vt.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:At.TABLE_NAME,selection:At.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:lt.TABLE_NAME,selection:lt.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:ht.TABLE_NAME,selection:ht.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:Tt.TABLE_NAME,selection:Tt.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:Pt.TABLE_NAME,selection:Pt.COLUMN_NAME_USER_ID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:it.TABLE_NAME,selection:it.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:nt.TABLE_NAME,selection:nt.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:kt.TABLE_NAME,selection:kt.COLUMN_NAME_USER_ID+" = ?",selectionArgs:[e]}),this.dbService.execute(`DELETE FROM ${It.TABLE_NAME} \n WHERE ${It.COLUMN_NAME_KEY} \n LIKE '%%${e}%%'`)).pipe(Object(D.mapTo)(!0))),Object(D.tap)(()=>Mi(this,void 0,void 0,(function*(){yield this.dbService.execute(`SELECT * FROM ${It.TABLE_NAME} \n WHERE ${It.COLUMN_NAME_KEY} \n LIKE '%%userProfileDetails%%'`).pipe(Object(D.map)(t=>t.filter(t=>JSON.parse(t.value).managedBy===e).map(e=>JSON.parse(e.value).userId)),Object(D.mergeMap)(e=>{const t=this.dbService.execute(`DELETE FROM ${It.TABLE_NAME} \n WHERE ${this.generateLikeQuery(e,It.COLUMN_NAME_KEY)}`);return e.length?t.pipe(Object(D.mapTo)(e)):Object(c.of)(!0).pipe(Object(D.mapTo)(e))}),Object(D.mergeMap)(e=>{const t=this.dbService.execute(`DELETE FROM ${et.TABLE_NAME} \n WHERE ${this.generateLikeQuery(e,et.COLUMN_NAME_UID)}`);return e.length?t.pipe(Object(D.mapTo)(!0)):Object(c.of)(!0).pipe(Object(D.mapTo)(!0))})).toPromise()}))),Object(D.tap)(()=>{this.dbService.endTransaction(!0)}),Object(D.catchError)(e=>(console.error(e),this.dbService.endTransaction(!1),Object(c.of)(!1))))}generateLikeQuery(e,t){let n="";const r=t+" LIKE ";for(let t=0;t<e.length;t++)n=t<e.length-1?n.concat(r,`'%%~${e[t].toLowerCase().trim()}~%%' OR `):n.concat(r,`'%%~${e[t].toLowerCase().trim()}~%%' `);return`(${n})`}}class Li{constructor(e,t){this.apiService=e,this.profileServiceConfig=t,this.DELETE_ENDPOINT="/delete"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.profileServiceConfig.profileApiPath+this.DELETE_ENDPOINT).withBearerToken(!0).withUserToken(!0).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>"SUCCESS"===e.body.result.response))}}var Pi,Di=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},wi=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ui=function(e,t){return function(n,r){t(n,r,e)}},ji=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let Fi=Pi=class{constructor(e,t,n,r,i,o,s,a,c,u,l,d){this.container=e,this.sdkConfig=t,this.dbService=n,this.apiService=r,this.cachedItemStore=i,this.keyValueStore=o,this.sharedPreferences=s,this.frameworkService=a,this.fileService=c,this.deviceInfo=u,this.authService=l,this.userService=d,this.apiConfig=this.sdkConfig.apiConfig,this.profileServiceConfig=this.sdkConfig.profileServiceConfig,this.managedProfileManager=new Ii(this,this.authService,this.sdkConfig.profileServiceConfig,this.apiService,this.cachedItemStore,this.dbService,this.frameworkService,this.sharedPreferences)}get telemetryService(){return this.container.get(l.TELEMETRY_SERVICE)}preInit(){return this.sharedPreferences.getString(Pi.KEY_USER_SESSION).pipe(Object(D.map)(e=>e&&JSON.parse(e)),Object(D.mergeMap)(e=>{if(!e){const e={uid:"",handle:"",profileType:zn.TEACHER,source:Wn.LOCAL};return this.createProfile(e).pipe(Object(D.mergeMap)(e=>this.setActiveSessionForProfile(e.uid)),Object(D.mapTo)(void 0))}return e.managedSession?this.managedProfileManager.switchSessionToManagedProfile({uid:e.managedSession.uid}):this.setActiveSessionForProfile(e.uid).pipe(Object(D.mapTo)(void 0))}))}checkServerProfileExists(e){return this.userService.checkUserExists(e.matching,e.captchaResponseToken?{token:e.captchaResponseToken,app:"1"}:void 0)}createProfile(e,t=Wn.LOCAL){switch(t){case Wn.LOCAL:if(e.source!==Wn.LOCAL)throw new sr("Invalid value supplied for field 'source': "+e.source);if(e.serverProfile)throw new sr("Invalid value supplied for field 'serverProfile': "+e.serverProfile);e.uid=en.generateUniqueId();break;case Wn.SERVER:if(e.source!==Wn.SERVER)throw new sr("Invalid value supplied for field 'source': "+e.source);if(!e.serverProfile)throw new sr("Invalid value supplied for field 'serverProfile': "+e.serverProfile);if(!e.uid)throw new sr("Invalid value supplied for field 'uid': "+e.uid)}return e.createdAt=Date.now(),this.dbService.insert({table:et.TABLE_NAME,modelJson:ir.mapProfileToProfileDBEntry(e)}).pipe(Object(D.tap)(()=>ji(this,void 0,void 0,(function*(){yield this.getActiveProfileSession().pipe(Object(D.map)(e=>e.uid),Object(D.catchError)(t=>t instanceof ki?Object(c.of)(e.uid):Object(c.throwError)(t)),Object(D.mergeMap)(t=>{const n=new pe;n.id=t,n.type=pe.TYPE_SYSTEM;const r={env:"sdk",actor:n,currentState:ue.AUDIT_CREATED,updatedProperties:Qr.getTruthyProps(e),objId:e.uid,objType:Q.USER,correlationData:[{id:e.profileType,type:"UserRole"}]};return this.telemetryService.audit(r)})).toPromise()}))),Object(D.mergeMap)(()=>Object(c.of)(e)))}deleteProfile(e){return this.dbService.read({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[e]}).pipe(Object(D.map)(t=>{if(!t||!t[0])throw new xi("No Profile found with ID "+e);return ir.mapProfileDBEntryToProfile(t[0])}),Object(D.tap)(t=>ji(this,void 0,void 0,(function*(){return yield this.getActiveProfileSession().pipe(Object(D.mergeMap)(n=>{const r=new pe;r.id=n.uid,r.type=pe.TYPE_SYSTEM;const i={env:"sdk",actor:r,currentState:ue.AUDIT_DELETED,objId:e,objType:Q.USER,correlationData:[{id:t.profileType,type:"UserRole"}]};return this.telemetryService.audit(i)})).toPromise()}))),Object(D.mergeMap)(()=>this.dbService.delete({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[e]})))}updateProfile(e){return this.dbService.read({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[e.uid]}).pipe(Object(D.map)(t=>{if(!t||!t[0])throw new xi("No Profile found with ID "+e.uid);return ir.mapProfileDBEntryToProfile(t[0])}),Object(D.tap)(t=>ji(this,void 0,void 0,(function*(){yield this.getActiveProfileSession().pipe(Object(D.mergeMap)(n=>{const r=new pe;r.id=n.uid,r.type=pe.TYPE_SYSTEM;const i={env:"sdk",actor:r,currentState:ue.AUDIT_UPDATED,updatedProperties:Qr.getPropDiff(e,t),objId:e.uid,objType:Q.USER,correlationData:[{id:e.profileType,type:"UserRole"}]};return this.telemetryService.audit(i)})).toPromise()}))),Object(D.mergeMap)(()=>{const t=ir.mapProfileToProfileDBEntry(e);return delete t[et.COLUMN_NAME_CREATED_AT],this.dbService.update({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[e.uid],modelJson:t}).pipe(Object(D.mergeMap)(()=>Object(c.of)(e)))}))}updateServerProfile(e){return this.userService.updateProfile(e,{apiPath:"/api/user/v3"})}getTenantInfo(e){return new tr(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}getAllProfiles(e){return e?e.groupId?e.groupId&&(e.local||e.server)?this.dbService.execute(`\n SELECT * FROM ${et.TABLE_NAME} LEFT JOIN ${it.TABLE_NAME}\n ON ${et.TABLE_NAME}.${et.COLUMN_NAME_UID} =\n ${it.TABLE_NAME}.${it.COLUMN_NAME_UID}\n WHERE ${it.COLUMN_NAME_GID} = "${e.groupId}" AND\n ${et.COLUMN_NAME_SOURCE} = "${e.local?Wn.LOCAL:Wn.SERVER}"\n `).pipe(Object(D.map)(e=>this.mapDbProfileEntriesToProfiles(e))):this.dbService.execute(`\n SELECT * FROM ${et.TABLE_NAME}\n LEFT JOIN ${it.TABLE_NAME} ON\n ${et.TABLE_NAME}.${et.COLUMN_NAME_UID} =\n ${it.TABLE_NAME}.${it.COLUMN_NAME_UID}\n WHERE ${it.TABLE_NAME}.${it.COLUMN_NAME_GID} = "${e.groupId}"\n `).pipe(Object(D.map)(e=>this.mapDbProfileEntriesToProfiles(e))):this.dbService.read({table:et.TABLE_NAME,selection:et.COLUMN_NAME_SOURCE+" = ?",selectionArgs:[e.local?Wn.LOCAL:Wn.SERVER],columns:[]}).pipe(Object(D.map)(e=>this.mapDbProfileEntriesToProfiles(e))):this.dbService.read({table:et.TABLE_NAME,columns:[]}).pipe(Object(D.map)(e=>this.mapDbProfileEntriesToProfiles(e)))}getServerProfilesDetails(e){return new rr(this.cachedItemStore,this.keyValueStore,this.container,this.profileServiceConfig).handle(e)}getActiveSessionProfile({requiredFields:e}){return this.getActiveProfileSession().pipe(Object(D.mergeMap)(t=>this.dbService.read({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[t.managedSession?t.managedSession.uid:t.uid]}).pipe(Object(D.map)(e=>{const n=e&&e[0];if(!n)throw new xi("No profile found for profileSession with uid "+(t.managedSession?t.managedSession.uid:t.uid));return ir.mapProfileDBEntryToProfile(n)}),Object(D.mergeMap)(t=>t.source===Wn.SERVER?this.getServerProfilesDetails({userId:t.uid,requiredFields:e}).pipe(Object(D.map)(e=>Object.assign(Object.assign({},t),{handle:e.firstName+(e.lastName?" "+e.lastName:""),serverProfile:e}))):Object(c.of)(t)))))}setActiveSessionForProfile(e){return Object(c.defer)(()=>this.generateSessionEndTelemetry()).pipe(Object(D.mergeMap)(()=>this.dbService.read({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[e]})),Object(D.map)(e=>e&&e[0]&&ir.mapProfileDBEntryToProfile(e[0])),Object(D.map)(e=>{if(!e)throw new xi("No Profile found");return e}),Object(D.mergeMap)(e=>Object(c.iif)(()=>e.source===Wn.SERVER,Object(c.defer)(()=>this.getServerProfilesDetails({userId:e.uid,requiredFields:[]}).pipe(Object(D.map)(t=>Object.assign(Object.assign({},e),{serverProfile:t})),Object(D.mergeMap)(e=>this.frameworkService.setActiveChannelId(e.serverProfile.rootOrg.hashTagId)),Object(D.catchError)(()=>Object(c.of)(void 0)))),this.frameworkService.setActiveChannelId(this.sdkConfig.apiConfig.api_authentication.channelId).pipe(Object(D.mapTo)(void 0))).pipe(Object(D.mapTo)(e))),Object(D.mergeMap)(e=>{const t=new Zn(e.uid);return k.CsModule.instance.isInitialised&&k.CsModule.instance.updateConfig(Object.assign(Object.assign({},k.CsModule.instance.config),{core:Object.assign(Object.assign({},k.CsModule.instance.config.core),{global:Object.assign(Object.assign({},k.CsModule.instance.config.core.global),{sessionId:t.sid})})})),this.sharedPreferences.putString(Pi.KEY_USER_SESSION,JSON.stringify(t)).pipe(Object(D.mapTo)(!0))}),Object(D.tap)(()=>ji(this,void 0,void 0,(function*(){return yield this.generateSessionStartTelemetry()}))))}getActiveProfileSession(){return this.sharedPreferences.getString(Pi.KEY_USER_SESSION).pipe(Object(D.map)(e=>{if(e)return JSON.parse(e);throw new ki("No active session available")}))}acceptTermsAndConditions(e){return new or(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}isProfileAlreadyInUse(e){return new ar(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}generateOTP(e){return new cr(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}verifyOTP(e){return new ur(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}searchLocation(e){return new dr(this.apiService,this.sdkConfig.profileServiceConfig,this.fileService,this.cachedItemStore).handle(e)}getAllContentAccess(e){const t=`SELECT * FROM ${At.TABLE_NAME} ${kn.getUidnIdentifierFiler(e.uid,e.contentId)}`;return this.dbService.execute(t).pipe(Object(D.map)(e=>e.map(e=>class{static mapDBEntryToContenetAccess(e){const t=e[At.COLUMN_NAME_LEARNER_STATE];return{status:Number(e[At.COLUMN_NAME_STATUS]),contentId:e[At.COLUMN_NAME_CONTENT_IDENTIFIER],contentType:e[At.COLUMN_NAME_CONTENT_TYPE],contentLearnerState:{learnerState:t&&JSON.parse(t)}}}}.mapDBEntryToContenetAccess(e))))}addContentAccess(e){return this.getActiveProfileSession().pipe(Object(D.mergeMap)(({uid:t})=>this.dbService.read({table:At.TABLE_NAME,selection:`${At.COLUMN_NAME_UID}= ? AND ${At.COLUMN_NAME_CONTENT_IDENTIFIER}= ?`,selectionArgs:[t,e.contentId],orderBy:At.COLUMN_NAME_EPOCH_TIMESTAMP+" DESC",limit:"1"}).pipe(Object(D.mergeMap)(n=>{const r={uid:t,identifier:e.contentId,epoch_timestamp:Date.now(),status:Xn.PLAYED.valueOf(),content_type:e.contentType&&e.contentType.toLowerCase(),learner_state:e.contentLearnerState&&JSON.stringify(e.contentLearnerState.learnerState)};return n&&n.length?(r.status=n[0][At.COLUMN_NAME_STATUS],this.dbService.update({table:At.TABLE_NAME,selection:`${At.COLUMN_NAME_UID}= ? AND ${At.COLUMN_NAME_CONTENT_IDENTIFIER}= ?`,selectionArgs:[t,e.contentId],modelJson:r}).pipe(Object(D.map)(e=>e>0))):this.dbService.insert({table:At.TABLE_NAME,modelJson:r}).pipe(Object(D.map)(e=>e>0))}))))}exportProfile(e){const t={userIds:e.userIds,destinationFolder:e.destinationFolder,groupIds:e.groupIds};return Object(c.from)(new hr(this.fileService).execute(t).then(e=>new fr(this.dbService).execute(e.body)).then(e=>new _r(this.dbService,this.fileService,this.deviceInfo).execute(e.body)).then(e=>new Sr(this.dbService,this.fileService).execute(e.body).catch(()=>e)).then(e=>new Ar(this.dbService).execute(e.body)).then(e=>({exportedFilePath:e.body.destinationDBFilePath})))}importProfile(e){const t={sourceDBFilePath:e.sourceFilePath};return Object(c.from)(new Nr(this.dbService).execute(t).then(e=>new Cr(this.dbService).execute(e.body)).then(e=>new yi(this.dbService).execute(e.body)).then(e=>new yr(this.dbService).execute(e.body)).then(e=>new br(this.dbService).execute(e.body)).then(e=>new Mr(this.dbService).execute(e.body)).then(e=>new Ti(this.dbService).execute(e.body)).then(e=>new Ci(this.dbService).execute(e.body)).then(e=>new gr(this.dbService).execute(e.body)).then(e=>({failed:e.body.failed,imported:e.body.imported})))}mergeServerProfiles(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.PATCH).withPath(Pi.MERGE_SERVER_PROFILES_PATH).withBearerToken(!0).withHeaders({"x-source-user-token":e.from.accessToken,"x-authenticated-user-token":e.to.accessToken}).withBody({request:{fromAccountId:e.from.userId,toAccountId:e.to.userId}}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>{console.log(e)}),Object(D.finalize)(()=>{const e=this.sdkConfig.apiConfig.user_authentication.mergeUserHost+this.sdkConfig.apiConfig.user_authentication.authUrl+"/logout?redirect_uri="+this.sdkConfig.apiConfig.host+"/oauth2callback",t=cordova.InAppBrowser.open(e,"_blank","zoom=no,hidden=yes");t.addEventListener("loadstart",e=>ji(this,void 0,void 0,(function*(){e.url.indexOf("/oauth2callback")>-1&&t.close()})))}))}isDefaultChannelProfile(){return Object(c.zip)(this.frameworkService.getDefaultChannelId(),this.frameworkService.getActiveChannelId()).pipe(Object(D.map)(e=>e[0]===e[1]))}getUserFeed(){return this.getActiveProfileSession().pipe(Object(D.mergeMap)(e=>this.userService.getUserFeed(e.managedSession?e.managedSession.uid:e.uid,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath_V5})))}updateUserFeedEntry(e){return this.getActiveProfileSession().pipe(Object(D.mergeMap)(t=>this.userService.updateUserFeedEntry(t.managedSession?t.managedSession.uid:t.uid,e.feedEntryId,e.category,e.request,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath_V5}).pipe(Object(D.mapTo)(!0),Object(D.catchError)(()=>Object(c.of)(!1)))))}deleteUserFeedEntry(e){return this.getActiveProfileSession().pipe(Object(D.mergeMap)(t=>this.userService.deleteUserFeedEntry(t.managedSession?t.managedSession.uid:t.uid,e.feedEntryId,e.category,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath}).pipe(Object(D.mapTo)(!0),Object(D.catchError)(()=>Object(c.of)(!1)))))}userMigrate(e){return new mi(this.sdkConfig,this.apiService).handle(e)}updateServerProfileDeclarations(e){return this.userService.updateUserDeclarations(e.declarations,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath})}getConsent(e){return this.userService.getConsent(e,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath})}updateConsent(e){return this.userService.updateConsent(e,{apiPath:this.sdkConfig.profileServiceConfig.profileApiPath})}mapDbProfileEntriesToProfiles(e){return e.map(e=>ir.mapProfileDBEntryToProfile(e))}generateSessionStartTelemetry(){return ji(this,void 0,void 0,(function*(){return ln.log.start({type:"session",env:"sdk"}).toPromise()}))}generateSessionEndTelemetry(){return ji(this,void 0,void 0,(function*(){const e=yield this.sharedPreferences.getString(Pi.KEY_USER_SESSION).toPromise();if(e){const t=JSON.parse(e);yield ln.log.end({type:"session",env:"sdk",duration:Math.floor((Date.now()-t.createdTime)/1e3)}).toPromise()}}))}deleteProfileData(e){return new Ri(this.dbService).delete(e)}deleteUser(e){return new Li(this.apiService,this.sdkConfig.profileServiceConfig).handle(e)}};Fi.KEY_USER_SESSION=p.KEY_USER_SESSION,Fi.MERGE_SERVER_PROFILES_PATH="/api/user/v1/account/merge",Fi=Pi=Di([Object(s.injectable)(),Ui(0,Object(s.inject)(l.CONTAINER)),Ui(1,Object(s.inject)(l.SDK_CONFIG)),Ui(2,Object(s.inject)(l.DB_SERVICE)),Ui(3,Object(s.inject)(l.API_SERVICE)),Ui(4,Object(s.inject)(l.CACHED_ITEM_STORE)),Ui(5,Object(s.inject)(l.KEY_VALUE_STORE)),Ui(6,Object(s.inject)(l.SHARED_PREFERENCES)),Ui(7,Object(s.inject)(l.FRAMEWORK_SERVICE)),Ui(8,Object(s.inject)(l.FILE_SERVICE)),Ui(9,Object(s.inject)(l.DEVICE_INFO)),Ui(10,Object(s.inject)(l.AUTH_SERVICE)),Ui(11,Object(s.inject)(u.USER_SERVICE)),wi("design:paramtypes",[s.Container,Object,o,Object,Object,Object,Object,Object,Object,Object,Object,Object])],Fi);class ki extends ke{constructor(e){super(e,"NO_ACTIVE_SESSION"),Object.setPrototypeOf(this,ki.prototype)}}class xi extends ke{constructor(e){super(e,"NO_PROFILE_FOUND"),Object.setPrototypeOf(this,xi.prototype)}}class Bi extends ke{constructor(e){super(e,"AUTH_TOKEN_REFRESH_ERROR"),Object.setPrototypeOf(this,Bi.prototype)}}var Vi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Yi{constructor(e,t,n,r){this.apiConfig=e,this.apiService=t,this.sharedPreferences=n,this.eventsBusService=r}refreshSession(){return Vi(this,void 0,void 0,(function*(){let e,t=yield this.getSessionData();if(!t)throw new ki("No Active Sessions found");e="ios"===window.device.platform.toLowerCase()?(new a.CsRequest.Builder).withPath("/auth/v1/refresh/token").withType(a.CsHttpRequestType.POST).withSerializer(a.CsHttpSerializer.URLENCODED).withHeaders({"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}).withBearerToken(!0).withBody({refresh_token:t.refresh_token}).build():(new a.CsRequest.Builder).withPath("/auth/v1/refresh/token").withType(a.CsHttpRequestType.POST).withSerializer(a.CsHttpSerializer.URLENCODED).withBearerToken(!0).withBody({refresh_token:t.refresh_token}).build();try{yield this.apiService.fetch(e).toPromise().catch(e=>{if(a.CsHttpClientError.isInstance(e)&&e.response.responseCode===a.CsHttpResponseCode.HTTP_BAD_REQUEST)throw new Bi(e.message);throw e}).then(e=>Vi(this,void 0,void 0,(function*(){if(e.body.result.access_token&&e.body.result.refresh_token){let n=yield I.decodeJWT(e.body.result.access_token);const r=JSON.parse(n),i=3===r.sub.split(":").length?r.sub.split(":").pop():r.sub,o=yield this.getSessionData();return t=Object.assign(Object.assign({},e.body.result),{userToken:o?o.userToken:i,managed_access_token:o?o.managed_access_token:void 0,accessTokenExpiresOn:1e3*r.exp}),yield this.sharedPreferences.putString(E.KEY_OAUTH_SESSION,JSON.stringify(t)).toPromise()}throw new Bi("No token found in server response")})))}catch(e){throw e instanceof Bi&&this.eventsBusService.emit({namespace:M.ERROR,event:{type:R.AUTH_TOKEN_REFRESH_ERROR,payload:e}}),e}}))}startSession(e){return Vi(this,void 0,void 0,(function*(){yield this.sharedPreferences.putString(E.KEY_OAUTH_SESSION,JSON.stringify(e)).toPromise()}))}endSession(){return Vi(this,void 0,void 0,(function*(){yield this.sharedPreferences.putString(E.KEY_OAUTH_SESSION,"").toPromise()}))}getSessionData(){return Vi(this,void 0,void 0,(function*(){const e=yield this.sharedPreferences.getString(E.KEY_OAUTH_SESSION).toPromise();if(e)return JSON.parse(e)}))}}var Gi=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Hi=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},$i=function(e,t){return function(n,r){t(n,r,e)}},qi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let Ki=class{constructor(e,t,n,r,i,o,s,a,u,l,d,h,E,f,p,_,O,S){this.dbService=e,this.decorator=t,this.profileService=n,this.groupService=r,this.keyValueStore=i,this.apiService=o,this.sdkConfig=s,this.deviceInfo=a,this.eventsBusService=u,this.fileService=l,this.frameworkService=d,this.networkInfoService=h,this.errorLoggerService=E,this.sharedPreferences=f,this.appInfoService=p,this.deviceRegisterService=_,this.courseService=O,this.networkQueue=S,this.campaignParameters=[],this.globalCdata=[],this.telemetryConfig=this.sdkConfig.telemetryConfig,this._lastSyncedTimestamp$=new c.BehaviorSubject(void 0)}get autoSync(){return this.telemetryAutoSyncService||(this.telemetryAutoSyncService=new Kn(this,this.sharedPreferences)),this.telemetryAutoSyncService}preInit(){return Object(c.defer)(()=>qi(this,void 0,void 0,(function*(){this.getInitialUtmParameters().then(e=>{e&&e.length&&this.updateCampaignParameters(e)})})))}onInit(){return Object(c.combineLatest)([Object(c.defer)(()=>qi(this,void 0,void 0,(function*(){const e=yield this.sharedPreferences.getString(v.KEY_LAST_SYNCED_TIME_STAMP).toPromise();if(e)try{this._lastSyncedTimestamp$.next(parseInt(e,10))}catch(e){console.error(e)}}))),new c.Observable(e=>{sbsync.onAuthorizationError(t=>qi(this,void 0,void 0,(function*(){const n=t.network_queue_error;n&&e.next(n)})),e=>qi(this,void 0,void 0,(function*(){})))}).pipe(Object(D.mergeMap)(e=>"API_TOKEN_EXPIRED"===e?new P(this.sdkConfig.apiConfig,this.apiService,this.deviceInfo).refreshAuthToken().pipe(Object(D.mergeMap)(e=>this.sharedPreferences.putString(h.KEY_API_TOKEN,e)),Object(D.catchError)(()=>Object(c.of)(void 0))):Object(c.from)(new Yi(this.sdkConfig.apiConfig,this.apiService,this.sharedPreferences,this.eventsBusService).refreshSession()).pipe(Object(D.catchError)(()=>Object(c.of)(void 0)))))]).pipe(Object(D.mapTo)(void 0))}saveTelemetry(e){return Object(c.defer)(()=>{try{const t=JSON.parse(e);return this.decorateAndPersist(t)}catch(e){return console.error(e),Object(c.of)(!1)}})}audit({env:e,actor:t,currentState:n,updatedProperties:r,type:i,objId:o,objType:s,objVer:a,correlationData:c,rollUp:u}){const l=new le.Audit(e,t,n,r,i,o,s,a,c,u);return this.decorateAndPersist(l)}end({type:e,mode:t,duration:n,pageId:r,summaryList:i,env:o,objId:s,objType:a,objVer:c,rollup:u,correlationData:l,actor:d}){const h=new le.End(e,t,n,r,i,o,s,a,c,u,l,d);return this.decorateAndPersist(h)}error(e){const t=new le.Error(e.errorCode,e.errorType,e.stacktrace,e.pageId,e.actor);return this.errorLoggerService.logError(e).toPromise().catch(e=>console.error(e)),this.decorateAndPersist(t)}impression({type:e,subType:t,pageId:n,visits:r,env:i,objId:o,objType:s,objVer:a,rollup:c,correlationData:u,actor:l}){const d=new le.Impression(e,t,n,r,i,o,s,a,c,u,l);return this.decorateAndPersist(d)}interact({type:e,subType:t,id:n,pageId:r,pos:i,env:o,rollup:s,valueMap:a,correlationData:c,objId:u,objType:l,objVer:d,pdata:h,actor:E}){const f=new le.Interact(e,t,n,r,i,a,o,u,l,d,s,c,h,E);return this.decorateAndPersist(f)}log({type:e,level:t,message:n,pageId:r,params:i,env:o,actorType:s}){const a=new le.Log(e,t,n,r,i,o,s);return this.decorateAndPersist(a)}share({dir:e,type:t,items:n,correlationData:r,objId:i,objType:o,objVer:s,rollUp:a}){const c=new le.Share(e,t,[],r,i,o,s,a);return n.forEach(e=>{c.addItem(e.type,e.origin,e.identifier,e.pkgVersion,e.transferCount,e.size)}),this.decorateAndPersist(c)}feedback({rating:e,comments:t,env:n,objId:r,objType:i,objVer:o,commentid:s,commenttxt:a}){const c=new le.Feedback(e,t,n,r,i,o,s,a);return this.decorateAndPersist(c)}start({type:e,deviceSpecification:t,loc:n,mode:r,duration:i,pageId:o,env:s,objId:a,objType:c,objVer:u,rollup:l,correlationData:d,actor:h}){const E=new le.Start(e,t,n,r,i,o,s,a,c,u,l,d,h);return this.decorateAndPersist(E)}summary({type:e,starttime:t,endtime:n,timespent:r,pageviews:i,interactions:o,env:s,mode:a,envsummary:c,eventsummary:u,pagesummary:l,extra:d,correlationData:h,objId:E,objType:f,objVer:p,rollup:_}){const O=new le.Summary(e,t,n,r,i,o,s,a,c,u,l,d,h,E,f,p,_);return this.decorateAndPersist(O)}interrupt({type:e,pageId:t,actor:n}){const r=new le.Interrupt(e,t,n);return this.decorateAndPersist(r)}importTelemetry(e){const t={sourceDBFilePath:e.sourceFilePath};return Object(c.from)(new Bn(this.dbService).execute(t).then(e=>new Gn(this.dbService).execute(e.body)).then(e=>new Hn(this.dbService).execute(e.body)).then(e=>new Hn(this.dbService).execute(e.body)).then(e=>new $n(this.dbService,this).execute(e.body)).then(e=>!0).catch(e=>(console.error(e),!1)))}getTelemetryStat(){const e=`\n SELECT COUNT(*) as TELEMETRY_COUNT\n FROM ${He.TABLE_NAME}\n `,t=`\n SELECT SUM(${qe.COLUMN_NAME_NUMBER_OF_EVENTS}) as PROCESSED_TELEMETRY_COUNT\n FROM ${qe.TABLE_NAME}\n `;return Object(c.zip)(this.dbService.execute(e),this.dbService.execute(t),this.keyValueStore.getValue(v.KEY_LAST_SYNCED_TIME_STAMP)).pipe(Object(D.map)(e=>({unSyncedEventCount:e[0][0].TELEMETRY_COUNT+e[1][0].PROCESSED_TELEMETRY_COUNT,lastSyncTime:e[2]?parseInt(e[2],10):0})))}resetDeviceRegisterTTL(){return new pn(this.dbService,this.sdkConfig,this.deviceInfo,this.sharedPreferences,this.appInfoService,this.deviceRegisterService,this.keyValueStore,this.apiService,this.networkQueue).resetDeviceRegisterTTL()}sync(e={ignoreSyncThreshold:!1,ignoreAutoSyncMode:!1}){return this.networkInfoService.networkStatus$.pipe(Object(D.take)(1),Object(D.mergeMap)(t=>(t===Vn.ONLINE&&(e.ignoreSyncThreshold=!0),Object(c.of)(e))),Object(D.mergeMap)(e=>new pn(this.dbService,this.sdkConfig,this.deviceInfo,this.sharedPreferences,this.appInfoService,this.deviceRegisterService,this.keyValueStore,this.apiService,this.networkQueue).handle(e).pipe(Object(D.tap)(e=>{if(!e.error&&e.syncedEventCount){const e=Date.now();this.sharedPreferences.putString(v.KEY_LAST_SYNCED_TIME_STAMP,e+"").toPromise(),this._lastSyncedTimestamp$.next(e)}}))))}lastSyncedTimestamp(){return this._lastSyncedTimestamp$.asObservable()}buildContext(){return this.profileService.getActiveProfileSession().pipe(Object(D.map)(e=>this.decorator.buildContext(e.sid,this.frameworkService.activeChannelId,new _e)))}decorateAndPersist(e){return Object(c.zip)(this.profileService.getActiveProfileSession(),this.groupService.getActiveGroupSession()).pipe(Object(D.mergeMap)(t=>{const n=t[0],r=t[1];return this.keyValueStore.getValue(pn.TELEMETRY_LOG_MIN_ALLOWED_OFFSET_KEY).pipe(Object(D.mergeMap)(t=>{t=t||"0";const i={table:He.TABLE_NAME,modelJson:this.decorator.prepare(this.decorator.decorate(e,n,r&&r.gid,Number(t),this.frameworkService.activeChannelId,this.campaignParameters,this.globalCdata),1)};return this.dbService.insert(i).pipe(Object(D.tap)(()=>this.eventsBusService.emit({namespace:M.TELEMETRY,event:{type:Un.SAVE,payload:e}})),Object(D.map)(e=>e>1))}))}))}updateCampaignParameters(e){this.campaignParameters=e}populateGlobalCorRelationData(e){this.globalCdata=e}getInitialUtmParameters(){return new Promise((e,t)=>{try{sbutility.getUtmInfo(t=>{e(t.val)},e=>{t(e)})}catch(e){t(e)}})}};Ki=Gi([Object(s.injectable)(),$i(0,Object(s.inject)(l.DB_SERVICE)),$i(1,Object(s.inject)(l.TELEMETRY_DECORATOR)),$i(2,Object(s.inject)(l.PROFILE_SERVICE)),$i(3,Object(s.inject)(l.GROUP_SERVICE_DEPRECATED)),$i(4,Object(s.inject)(l.KEY_VALUE_STORE)),$i(5,Object(s.inject)(l.API_SERVICE)),$i(6,Object(s.inject)(l.SDK_CONFIG)),$i(7,Object(s.inject)(l.DEVICE_INFO)),$i(8,Object(s.inject)(l.EVENTS_BUS_SERVICE)),$i(9,Object(s.inject)(l.FILE_SERVICE)),$i(10,Object(s.inject)(l.FRAMEWORK_SERVICE)),$i(11,Object(s.inject)(l.NETWORKINFO_SERVICE)),$i(12,Object(s.inject)(l.ERROR_LOGGER_SERVICE)),$i(13,Object(s.inject)(l.SHARED_PREFERENCES)),$i(14,Object(s.inject)(l.APP_INFO)),$i(15,Object(s.inject)(l.DEVICE_REGISTER_SERVICE)),$i(16,Object(s.inject)(l.COURSE_SERVICE)),$i(17,Object(s.inject)(l.NETWORK_QUEUE)),Hi("design:paramtypes",[o,J,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object])],Ki);var zi,Wi=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Xi=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ji=function(e,t){return function(n,r){t(n,r,e)}},Qi=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let Zi=zi=class{constructor(e,t,n,r){this.sdkConfig=e,this.apiService=t,this.sharedPreferences=n,this.eventsBusService=r,this.apiConfig=this.sdkConfig.apiConfig,this.authUtil=new Yi(this.apiConfig,this.apiService,this.sharedPreferences,this.eventsBusService)}onInit(){return this.sharedPreferences.addListener(E.KEY_OAUTH_SESSION,e=>Qi(this,void 0,void 0,(function*(){if(e)try{const t=JSON.parse(yield this.sharedPreferences.getString(p.KEY_USER_SESSION).toPromise()),n=JSON.parse(e);k.CsModule.instance.config.core.api.authentication.userToken=n.access_token,k.CsModule.instance.config.core.api.authentication.managedUserToken=t.managedSession?n.managed_access_token:void 0}catch(e){console.error(e),k.CsModule.instance.config.core.api.authentication.userToken=void 0,k.CsModule.instance.config.core.api.authentication.managedUserToken=void 0}else k.CsModule.instance.config.core.api.authentication.userToken=void 0,k.CsModule.instance.config.core.api.authentication.managedUserToken=void 0;k.CsModule.instance.updateConfig(k.CsModule.instance.config)}))),this.sharedPreferences.addListener(p.KEY_USER_SESSION,e=>Qi(this,void 0,void 0,(function*(){if(e)try{const t=JSON.parse(e),n=JSON.parse(yield this.sharedPreferences.getString(E.KEY_OAUTH_SESSION).toPromise());k.CsModule.instance.config.core.api.authentication.userToken=n.access_token,k.CsModule.instance.config.core.api.authentication.managedUserToken=t.managedSession?n.managed_access_token:void 0}catch(e){console.error(e),k.CsModule.instance.config.core.api.authentication.userToken=void 0,k.CsModule.instance.config.core.api.authentication.managedUserToken=void 0}else k.CsModule.instance.config.core.api.authentication.userToken=void 0,k.CsModule.instance.config.core.api.authentication.managedUserToken=void 0;k.CsModule.instance.updateConfig(k.CsModule.instance.config)}))),Object(c.combineLatest)([Object(c.defer)(()=>this.getSession()).pipe(Object(D.mergeMap)(e=>Qi(this,void 0,void 0,(function*(){if(!e)return;const t=JSON.parse(yield this.sharedPreferences.getString(p.KEY_USER_SESSION).toPromise());k.CsModule.instance.config.core.api.authentication.userToken=e.access_token,k.CsModule.instance.config.core.api.authentication.managedUserToken=t.managedSession?e.managed_access_token:void 0,k.CsModule.instance.updateConfig(k.CsModule.instance.config)})))),Object(c.defer)(()=>this.onAccessTokenNearingExpiry()).pipe(Object(D.mergeMap)(e=>Qi(this,void 0,void 0,(function*(){if(e)return this.refreshSession().toPromise()}))))]).pipe(Object(D.mapTo)(void 0))}setSession(e){return Object(c.from)(e.provide().then(e=>{if(!e.access_token)throw this.authUtil.endSession(),e;this.authUtil.startSession(e),this.authUtil.refreshSession()}))}getSession(){return Object(c.from)(this.authUtil.getSessionData())}resignSession(){return Object(c.from)(this.authUtil.endSession())}refreshSession(){return Object(c.from)(this.authUtil.refreshSession())}onAccessTokenNearingExpiry(){const e=Object(c.defer)(()=>this.getSession()),t=new c.Observable(e=>{document.addEventListener("resume",()=>{setTimeout(()=>{e.next()},0)},!1)}).pipe(Object(D.mergeMap)(()=>this.getSession()));return Object(c.merge)(e,t).pipe(Object(D.map)(e=>!(!e||!e.accessTokenExpiresOn)&&e.accessTokenExpiresOn-Date.now()<zi.ACCESS_TOKEN_NEARING_EXPIRY_DELTA),Object(D.distinctUntilChanged)())}};Zi.ACCESS_TOKEN_NEARING_EXPIRY_DELTA=36e5,Zi=zi=Wi([Object(s.injectable)(),Ji(0,Object(s.inject)(l.SDK_CONFIG)),Ji(1,Object(s.inject)(l.API_SERVICE)),Ji(2,Object(s.inject)(l.SHARED_PREFERENCES)),Ji(3,Object(s.inject)(l.EVENTS_BUS_SERVICE)),Xi("design:paramtypes",[Object,Object,Object,Object])],Zi);class eo{constructor(e,t,n,r){this.apiService=e,this.frameworkServiceConfig=t,this.fileService=n,this.cachedItemStore=r,this.CHANNEL_FILE_KEY_PREFIX="channel-",this.CHANNEL_LOCAL_KEY="channel-",this.GET_FRAMEWORK_DETAILS_ENDPOINT="/read"}handle(e){return this.cachedItemStore[e.from===Jn.SERVER?"get":"getCached"](e.channelId,this.CHANNEL_LOCAL_KEY,"ttl_"+this.CHANNEL_LOCAL_KEY,()=>this.fetchFromServer(e),()=>this.fetchFromFile(e)).pipe(Object(D.map)(e=>(e.frameworks&&e.frameworks.sort((e,t)=>e.name.localeCompare(t.name)),e)))}fetchFromServer(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.frameworkServiceConfig.channelApiPath+this.GET_FRAMEWORK_DETAILS_ENDPOINT+"/"+e.channelId).withBearerToken(!0).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result.channel))}fetchFromFile(e){const t=lr.getAssetPath()+this.frameworkServiceConfig.channelConfigDirPath,n=this.CHANNEL_FILE_KEY_PREFIX+e.channelId+".json";return Object(c.from)(this.fileService.readFileFromAssets(t.concat("/",n))).pipe(Object(D.map)(e=>JSON.parse(e).result.channel))}}class to{static prepareFrameworkCategoryAssociations(e){return e.categories?(e.categories=e.categories.map((t,n)=>t.terms?Object.assign(Object.assign({},t),{terms:t.terms.map(t=>t.associations?(t.associations.length&&(t.associations=t.associations.filter(t=>n>=e.categories.length-1||t.category===e.categories[n+1].code)),t):t)}):t),Object.assign({},e)):e}static prepareFrameworkTranslations(e,t){return e.name=to.getTranslatedValue(e.translations,t,e.name),e.categories&&(e.categories=e.categories.map(e=>(e.name=to.getTranslatedValue(e.translations,t,e.name),e.terms&&(e.terms=e.terms.map(e=>(e.name=to.getTranslatedValue(e.translations,t,e.name),e))),e))),e}static prepareFrameworkCategoryTranslations(e,t){return e.name=to.getTranslatedValue(e.translations,t,e.name),e.terms&&(e.terms=e.terms.map(e=>(e.name=to.getTranslatedValue(e.translations,t,e.name),e))),e}static getTranslatedValue(e,t,n){if(!e)return n;return JSON.parse(e)[t]||n}}class no{constructor(e,t,n,r,i){this.frameworkService=e,this.apiService=t,this.frameworkServiceConfig=n,this.fileService=r,this.cachedItemStore=i,this.FRAMEWORK_FILE_KEY_PREFIX="framework-",this.FRAMEWORK_LOCAL_KEY="framework-",this.GET_FRAMEWORK_DETAILS_ENDPOINT="/read"}handle(e){return Object(c.iif)(()=>!!e.frameworkId,Object(c.defer)(()=>this.cachedItemStore[e.from===Jn.SERVER?"get":"getCached"](e.frameworkId,this.FRAMEWORK_LOCAL_KEY,"ttl_"+this.FRAMEWORK_LOCAL_KEY,()=>this.fetchFromServer(e),()=>this.fetchFromFile(e))),Object(c.defer)(()=>this.frameworkService.getDefaultChannelDetails().pipe(Object(D.mergeMap)(t=>this.frameworkService.getFrameworkDetails({from:e.from,frameworkId:t.defaultFramework,requiredCategories:e.requiredCategories})))))}fetchFromServer(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.frameworkServiceConfig.frameworkApiPath+this.GET_FRAMEWORK_DETAILS_ENDPOINT+"/"+e.frameworkId).withParameters({categories:e.requiredCategories.join(",")}).withBearerToken(!0).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result.framework),Object(D.map)(e=>to.prepareFrameworkCategoryAssociations(e)))}fetchFromFile(e){const t=lr.getAssetPath()+this.frameworkServiceConfig.frameworkConfigDirPath,n=this.FRAMEWORK_FILE_KEY_PREFIX+e.frameworkId+".json";return Object(c.from)(this.fileService.readFileFromAssets(t.concat("/",n))).pipe(Object(D.map)(e=>JSON.parse(e).result.framework),Object(D.map)(e=>to.prepareFrameworkCategoryAssociations(e)))}}class ro extends ke{constructor(e){super(e,"NO_ACTIVE_CHANNEL_FOUND_ERROR"),Object.setPrototypeOf(this,ro.prototype)}}var io,oo=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},so=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ao=function(e,t){return function(n,r){t(n,r,e)}};let co=io=class{constructor(e,t,n,r,i,o,s){this.sdkConfig=e,this.fileService=t,this.apiService=n,this.cachedItemStore=r,this.sharedPreferences=i,this.systemSettingsService=o,this.csFrameworkService=s}get activeChannelId(){return this._activeChannelId}preInit(){return this.getActiveChannelId().pipe(Object(D.tap)(e=>this._activeChannelId=e),Object(D.mapTo)(void 0),Object(D.catchError)(e=>{if(e instanceof ro)return this.setActiveChannelId(localStorage.getItem(io.KEY_ACTIVE_CHANNEL_ID)||this.sdkConfig.apiConfig.api_authentication.channelId);throw e}))}getDefaultChannelId(){return Object(c.iif)(()=>!this.sdkConfig.frameworkServiceConfig.overriddenDefaultChannelId,Object(c.defer)(()=>this.systemSettingsService.getSystemSettings({id:this.sdkConfig.frameworkServiceConfig.systemSettingsDefaultChannelIdKey}).pipe(Object(D.map)(e=>e.value))),Object(c.defer)(()=>Object(c.of)(this.sdkConfig.frameworkServiceConfig.overriddenDefaultChannelId)))}getDefaultChannelDetails(e={from:Jn.CACHE}){return this.systemSettingsService.getSystemSettings({id:this.sdkConfig.frameworkServiceConfig.systemSettingsDefaultChannelIdKey}).pipe(Object(D.map)(e=>e.value),Object(D.mergeMap)(t=>this.getChannelDetails({from:e.from,channelId:this.sdkConfig.frameworkServiceConfig.overriddenDefaultChannelId||t})))}getChannelDetails(e){return new eo(this.apiService,this.sdkConfig.frameworkServiceConfig,this.fileService,this.cachedItemStore).handle(e)}getFrameworkDetails(e){return new no(this,this.apiService,this.sdkConfig.frameworkServiceConfig,this.fileService,this.cachedItemStore).handle(e)}getFrameworkConfig(e,t){let n;return t&&(n={type:t.type,subType:t.subType,action:t.action,rootOrgId:t.rootOrgId,framework:t.framework,component:t.component}),this.csFrameworkService.getFrameworkConfig(e,{apiPath:"/api/framework/v1"},{apiPath:"/api/data/v1/form",params:n})}searchOrganization(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.sdkConfig.frameworkServiceConfig.searchOrganizationApiPath+io.SEARCH_ORGANIZATION_ENDPOINT).withBody({request:e}).withBearerToken(!0).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result.response))}getActiveChannelId(){return this.sharedPreferences.getString(io.KEY_ACTIVE_CHANNEL_ID).pipe(Object(D.map)(e=>{if(!e)throw new ro("No Active channel ID set in preferences");return e}))}setActiveChannelId(e){return this._activeChannelId=localStorage.getItem(io.KEY_ACTIVE_CHANNEL_ID)||e,k.CsModule.instance.isInitialised&&k.CsModule.instance.updateConfig(Object.assign(Object.assign({},k.CsModule.instance.config),{core:Object.assign(Object.assign({},k.CsModule.instance.config.core),{global:Object.assign(Object.assign({},k.CsModule.instance.config.core.global),{channelId:e})})})),this.sharedPreferences.putString(io.KEY_ACTIVE_CHANNEL_ID,e)}};var uo;co.KEY_ACTIVE_CHANNEL_ID=_.KEY_ACTIVE_CHANNEL_ID,co.SEARCH_ORGANIZATION_ENDPOINT="/search",co=io=oo([Object(s.injectable)(),ao(0,Object(s.inject)(l.SDK_CONFIG)),ao(1,Object(s.inject)(l.FILE_SERVICE)),ao(2,Object(s.inject)(l.API_SERVICE)),ao(3,Object(s.inject)(l.CACHED_ITEM_STORE)),ao(4,Object(s.inject)(l.SHARED_PREFERENCES)),ao(5,Object(s.inject)(l.SYSTEM_SETTINGS_SERVICE)),ao(6,Object(s.inject)(u.FRAMEWORK_SERVICE)),so("design:paramtypes",[Object,Object,Object,Object,Object,Object,Object])],co),function(e){e.BOARD="board",e.MEDIUM="medium",e.GRADE_LEVEL="gradeLevel",e.SUBJECT="subject",e.TOPIC="topic",e.PURPOSE="purpose"}(uo||(uo={}));class lo{}lo.DEFAULT_FRAMEWORK_CATEGORIES=[uo.BOARD,uo.MEDIUM,uo.GRADE_LEVEL,uo.SUBJECT],lo.COURSE_FRAMEWORK_CATEGORIES=[uo.TOPIC,uo.PURPOSE,uo.MEDIUM,uo.GRADE_LEVEL,uo.SUBJECT];var ho=n(9),Eo=n.n(ho),fo=n(11),po=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class _o{constructor(e,t,n){this.frameworkUtilService=e,this.frameworkService=t,this.sharedPreferences=n}handle(e){return(()=>e.frameworkId?this.getTranslatedFrameworkDetails(e.frameworkId,e.requiredCategories,e.language):this.getActiveChannelTranslatedDefaultFrameworkDetails(e))().pipe(Object(D.tap)(e=>po(this,void 0,void 0,(function*(){return yield this.sharedPreferences.putString(_.KEY_ACTIVE_CHANNEL_ACTIVE_FRAMEWORK_ID,e.identifier).toPromise()}))),Object(D.map)(t=>{let n=[];if(n=!e.prevCategoryCode&&e.currentCategoryCode?this.getCategoryTerms(t,e).toArray():this.getCategoryAssociationTerms(t,e).toArray(),"gradeLevel"===e.currentCategoryCode){const e=n.reduce((e,t)=>t.index&&t.index>e?t.index:e,0);n.sort((t,n)=>(t.index||e+1)-(n.index||e+1))}else n.sort((e,t)=>e.name.localeCompare(t.name));const r=n.indexOf(n.find(e=>"Others"===e.name));if(r>=0&&r!==n.length){const e=n[n.length-1];n[n.length-1]=n[r],n[r]=e}return n}))}getActiveChannelTranslatedDefaultFrameworkDetails(e){return this.frameworkUtilService.getActiveChannel({from:e.from}).pipe(Object(D.mergeMap)(t=>this.getTranslatedFrameworkDetails(t.defaultFramework,e.requiredCategories,e.language,e.from)))}getTranslatedFrameworkDetails(e,t,n,r){return this.frameworkService.getFrameworkDetails({from:r,frameworkId:e,requiredCategories:t}).pipe(Object(D.map)(e=>to.prepareFrameworkTranslations(e,n)))}getAllCategoriesTermsSet(e){return e.categories?e.categories.reduce((e,t)=>[...e,t.terms||[]],[]).reduce((e,t)=>e.concat(t),[]).reduce((e,t)=>(e.add(t),e),new Eo.a(e=>Object(fo.makeString)(e))):new Eo.a}getCategoryTerms(e,t){return e.categories.find(e=>e.code===t.currentCategoryCode).terms.reduce((e,t)=>(e.add(t),e),new Eo.a(e=>Object(fo.makeString)(e)))}getCategoryAssociationTerms(e,t){if(!e.categories)return new Eo.a;const n=e.categories.find(e=>e.code===t.prevCategoryCode).terms;if(!n)return new Eo.a;const r=n.filter(e=>t.selectedTermsCodes.find(t=>t===e.code)).map(e=>e.associations||[]);return r.some(e=>0===e.length)?e.categories.find(e=>e.code===t.currentCategoryCode).terms.reduce((e,t)=>(e.add(t),e),new Eo.a(e=>Object(fo.makeString)(e))):r.reduce((e,t)=>e.concat(t),[]).reduce((e,t)=>(e.add(t),e),new Eo.a(e=>Object(fo.makeString)(e))).toArray().map(t=>this.getAllCategoriesTermsSet(e).toArray().find(e=>e.identifier===t.identifier)).reduce((e,t)=>(e.add(t),e),new Eo.a(e=>Object(fo.makeString)(e)))}}var Oo=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},So=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},go=function(e,t){return function(n,r){t(n,r,e)}};let Ao=class{constructor(e,t,n){this.sharedPreferences=e,this.frameworkService=t,this.profileService=n}getActiveChannel(e={from:Jn.CACHE}){return this.frameworkService.getActiveChannelId().pipe(Object(D.mergeMap)(t=>this.frameworkService.getChannelDetails({from:e.from,channelId:t})))}getActiveChannelSuggestedFrameworkList(e){return this.profileService.getActiveSessionProfile({requiredFields:[]}).pipe(Object(D.mergeMap)(t=>Object(c.iif)(()=>!!t.serverProfile&&!e.ignoreActiveChannel,Object(c.defer)(()=>this.getActiveChannel({from:e.from})),Object(c.defer)(()=>this.frameworkService.getDefaultChannelDetails({from:e.from})))),Object(D.mergeMap)(t=>t.frameworks?Object(c.of)(t.frameworks).pipe(Object(D.map)(t=>t.map(e=>to.prepareFrameworkCategoryAssociations(e)).map(t=>to.prepareFrameworkTranslations(t,e.language)))):this.frameworkService.getFrameworkDetails({from:e.from,frameworkId:t.defaultFramework,requiredCategories:e.requiredCategories}).pipe(Object(D.map)(e=>(e.index=0,[e])))))}getFrameworkCategoryTerms(e){return new _o(this,this.frameworkService,this.sharedPreferences).handle(e)}};Ao=Oo([Object(s.injectable)(),go(0,Object(s.inject)(l.SHARED_PREFERENCES)),go(1,Object(s.inject)(l.FRAMEWORK_SERVICE)),go(2,Object(s.inject)(l.PROFILE_SERVICE)),So("design:paramtypes",[Object,Object,Object])],Ao);class No{constructor(e){this.dbService=e}getContentMarker(e,t){const n=`SELECT * FROM ${vt.TABLE_NAME}\n ${kn.getUidnIdentifierFiler(t,e)}\n ORDER BY ${vt.COLUMN_NAME_EPOCH_TIMESTAMP} DESC `;return this.dbService.execute(n).pipe(Object(D.map)(e=>this.mapDBEntriesToContentMarkerDetails(e)))}mapDBEntriesToContentMarkerDetails(e){return e.map(e=>({contentId:e[vt.COLUMN_NAME_CONTENT_IDENTIFIER],uid:e[vt.COLUMN_NAME_UID],extraInfoMap:e[vt.COLUMN_NAME_EXTRA_INFO]&&JSON.parse(e[vt.COLUMN_NAME_EXTRA_INFO]),marker:e[vt.COLUMN_NAME_MARKER]}))}}var To=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Co=St.COLUMN_NAME_MIME_TYPE,vo=St.COLUMN_NAME_VISIBILITY;class yo{constructor(e,t,n,r,i,o){this.contentFeedbackService=e,this.profileService=t,this.apiService=n,this.contentServiceConfig=r,this.dbService=i,this.eventsBusService=o,this.GET_CONTENT_DETAILS_ENDPOINT="/read"}static getReadContentQuery(e){return{table:St.TABLE_NAME,selection:(new Kt).where("? = ?").args([St.COLUMN_NAME_IDENTIFIER,e]).end().build(),limit:"1"}}static isUnit(e){return e[Co]===Tn.COLLECTION&&e[vo]===Cn.PARENT}handle(e){return e.emitUpdateIfAny=void 0===e.emitUpdateIfAny||e.emitUpdateIfAny,this.fetchFromDB(e.contentId).pipe(Object(D.mergeMap)(t=>t?Object(c.of)(xn.mapContentDBEntryToContent(t)).pipe(Object(D.mergeMap)(t=>("string"==typeof t.contentData.originData&&(t.contentData.originData=kn.getParseErrorObject(t.contentData.originData)),t.contentData.trackable&&"string"==typeof t.contentData.trackable&&(t.contentData.trackable=JSON.parse(t.contentData.trackable)),this.decorateContent({content:t,attachFeedback:e.attachFeedback,attachContentAccess:e.attachContentAccess,attachContentMarker:e.attachContentMarker}))),Object(D.tap)(n=>To(this,void 0,void 0,(function*(){if(!e.emitUpdateIfAny||yo.isUnit(t))return;let r=!1;const i=t[St.COLUMN_NAME_SERVER_DATA]&&JSON.parse(t[St.COLUMN_NAME_SERVER_DATA]);i&&i.streamingUrl||(r=!0);const o=yield this.fetchFromServer(e).toPromise();t[St.COLUMN_NAME_SERVER_DATA]=JSON.stringify(o),t[St.COLUMN_NAME_SERVER_LAST_UPDATED_ON]=o.lastUpdatedOn,t[St.COLUMN_NAME_AUDIENCE]=kn.readAudience(o),yield this.dbService.update({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" =?",selectionArgs:[t[St.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise(),kn.isUpdateAvailable(o,n.contentData)&&this.eventsBusService.emit({namespace:M.CONTENT,event:{type:Pn.UPDATE,payload:{contentId:n.contentData.identifier,size:o.size}}}),o&&this.eventsBusService.emit({namespace:M.CONTENT,event:{type:Pn.SERVER_CONTENT_DATA,payload:{contentId:o.identifier,streamingUrl:o.streamingUrl,licenseDetails:o.licenseDetails,size:o.size,serverContentData:o}}})})))):this.fetchAndDecorate(e)))}fetchFromDB(e){return this.dbService.read({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[e],limit:"1"}).pipe(Object(D.map)(e=>e[0]))}fetchFromDBForAll(e){return this.dbService.read({table:St.TABLE_NAME,selection:`${St.COLUMN_NAME_IDENTIFIER} IN (${e})`})}fetchFromServer(e){switch(e.objectType){case"QuestionSet":return this.apiService.fetch((new a.CsRequest.Builder).withHost(this.contentServiceConfig.host).withType(a.CsHttpRequestType.GET).withPath(this.contentServiceConfig.questionSetReadApiPath+this.GET_CONTENT_DETAILS_ENDPOINT+"/"+e.contentId).withBearerToken(!1).build()).pipe(Object(D.map)(e=>e.body.result.questionset));case"Question":return this.apiService.fetch((new a.CsRequest.Builder).withHost(this.contentServiceConfig.host).withType(a.CsHttpRequestType.GET).withPath(this.contentServiceConfig.questionReadApiPath+this.GET_CONTENT_DETAILS_ENDPOINT+"/"+e.contentId).withBearerToken(!1).build()).pipe(Object(D.map)(e=>e.body.result.question));default:return this.apiService.fetch((new a.CsRequest.Builder).withHost(this.contentServiceConfig.host).withType(a.CsHttpRequestType.GET).withPath(this.contentServiceConfig.apiPath+this.GET_CONTENT_DETAILS_ENDPOINT+"/"+e.contentId).withParameters({licenseDetails:"name,url,description"}).withBearerToken(!0).build()).pipe(Object(D.map)(e=>e.body.result.content))}}fetchAndDecorate(e){return this.fetchFromServer(e).pipe(Object(D.map)(e=>xn.mapServerResponseToContent(e)),Object(D.mergeMap)(t=>this.decorateContent({content:t,attachFeedback:e.attachFeedback,attachContentAccess:e.attachContentAccess,attachContentMarker:e.attachContentMarker})))}decorateContent(e){return Object(c.of)(e.content).pipe(Object(D.mergeMap)(t=>e.attachContentAccess?this.attachContentAccess(t):Object(c.of)(t)),Object(D.mergeMap)(t=>e.attachFeedback?this.attachFeedback(t):Object(c.of)(t)),Object(D.mergeMap)(t=>e.attachContentMarker?this.attachContentMarker(t):Object(c.of)(t)))}attachContentAccess(e){return this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(({uid:t})=>this.profileService.getAllContentAccess({contentId:e.identifier,uid:t}).pipe(Object(D.map)(t=>Object.assign(Object.assign({},e),{contentAccess:t})))))}attachFeedback(e){return this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(({uid:t})=>this.contentFeedbackService.getFeedback({contentId:e.identifier,uid:t}).pipe(Object(D.map)(t=>Object.assign(Object.assign({},e),{contentFeedback:t})))))}attachContentMarker(e){return this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(({uid:t})=>new No(this.dbService).getContentMarker(e.identifier,t).pipe(Object(D.map)(t=>Object.assign(Object.assign({},e),{contentMarkers:t})))))}}class mo{constructor(e){this._stack=e||[]}get count(){return this._stack.length}push(e){this._stack.push(e)}pop(){return this._stack.pop()}clear(){this._stack=[]}isEmpty(){return 0===this._stack.length}addAll(e){this._stack=[...this._stack,...e]}}var bo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Io{constructor(e,t,n,r){this.dbService=e,this.getContentDetailsHandler=t,this.appConfig=n,this.fileService=r}fetchChildrenOfContent(e,t,n,r,i){return bo(this,void 0,void 0,(function*(){const o=xn.mapContentDBEntryToContent(e),s=yield this.getSortedChildrenList(e[St.COLUMN_NAME_LOCAL_DATA],An.ALL,t);if(s&&s.length){let a=[];if(a=a.concat(i),a.push({identifier:e[St.COLUMN_NAME_IDENTIFIER],contentType:e[St.COLUMN_NAME_CONTENT_TYPE],primaryCategory:e[St.COLUMN_NAME_PRIMARY_CATEGORY]}),o.hierarchyInfo=a,-1===r||n<=r){const e=[];for(const i of s){const o=i,s=yield this.fetchChildrenOfContent(o,t,n+1,r,a);s.contentData.appIcon&&!s.contentData.appIcon.startsWith("http")&&(s.contentData.appIcon="_app_file_".concat(s.basePath).concat(s.contentData.appIcon)),"application/json"===s.contentData.mimeType&&(s.contentData.artifactUrl="_app_file_".concat(s.basePath).concat(s.contentData.artifactUrl)),e.push(s)}o.children=e}}else o.hierarchyInfo=i;return o}))}getContentsKeyList(e){return bo(this,void 0,void 0,(function*(){const t=[],n=new mo,r=[];let i,o="";for(n.push(e);!n.isEmpty();){if(i=n.pop(),kn.hasChildren(i[St.COLUMN_NAME_LOCAL_DATA])){(yield this.getSortedChildrenListOld(i[St.COLUMN_NAME_LOCAL_DATA],An.ALL)).forEach(e=>{n.push(e),r.push(i[St.COLUMN_NAME_IDENTIFIER].concat("/",e[St.COLUMN_NAME_IDENTIFIER]))})}if(o){let e;for(let e=o.split("/").length-1;e>=0;e--){const t=o.split("/")[e];if(wn.contains(r,t.concat("/",i[St.COLUMN_NAME_IDENTIFIER])))break;o=o.substring(0,o.lastIndexOf("/"))}Tn.COLLECTION.valueOf()===i[St.COLUMN_NAME_MIME_TYPE]?o=o+"/"+i[St.COLUMN_NAME_IDENTIFIER]:(e=o+"/"+i[St.COLUMN_NAME_IDENTIFIER],t.push(e))}else o=i[St.COLUMN_NAME_IDENTIFIER]}return t}))}getContentFromDB(e,t,n){return bo(this,void 0,void 0,(function*(){const e=[];let r;if(t){const i=t.split("/"),o=i.length;let s=!0;for(let t=0;t<o-1;t++){const n=yield this.getContentDetailsHandler.fetchFromDB(i[t]).toPromise();if(!n){s=!1;break}e.push({identifier:n[St.COLUMN_NAME_IDENTIFIER],contentType:n[St.COLUMN_NAME_CONTENT_TYPE],primaryCategory:n[St.COLUMN_NAME_PRIMARY_CATEGORY]})}if(s){const t=yield this.getContentDetailsHandler.fetchFromDB(i[o-1]).toPromise();if(t){r=xn.mapContentDBEntryToContent(t,n),r.hierarchyInfo=e,r.rollup=kn.getContentRollup(r.identifier,r.hierarchyInfo);const i=kn.readCompatibilityLevel(r.contentData),o=kn.isCompatible(this.appConfig,i);r.isCompatible=o;const s=e.map(e=>e.identifier),a=wn.joinPreservingQuotes(s);let c=yield this.getContentDetailsHandler.fetchFromDBForAll(a).toPromise();c=c.sort((e,t)=>s.indexOf(e.identifier)-s.indexOf(t.identifier));for(let t=0;t<c.length;t++){const n=c[t],i=JSON.parse(n[St.COLUMN_NAME_LOCAL_DATA]),o=kn.isTrackable(i);if(0===t&&1===o)break;if(1===o){n.identifier;let i=JSON.parse(JSON.stringify(e));i&&(i=i.slice(0,t),r.trackableParentInfo={identifier:n.identifier,hierarchyInfo:i});break}}}}}return r}))}getNextContentIdentifier(e,t,n){let r,i="";e.forEach(e=>{i=i?i.concat("/",e.identifier):e.identifier}),i=i.concat("/",t);const o=n.indexOf(i);return o>0&&(r=n[o-1]),r}getPreviousContentIdentifier(e,t,n){let r,i="";e.forEach(e=>{i=i?i.concat("/",e.identifier):e.identifier}),i=i.concat("/",t);const o=n.indexOf(i);return-1!==o&&o<n.length-1&&(r=n[o+1]),r}getSortedChildrenListOld(e,t){return bo(this,void 0,void 0,(function*(){let n=JSON.parse(e).children;if(!n||!n.length)return[];n=n.sort((e,t)=>e.index-t.index);const r=[];let i="",o=0;n.forEach(e=>{r.push(e.identifier),i=i.concat(` WHEN '${e.identifier}' THEN ${o}`),o+=1});let s="";o>0&&(s=s.concat(` ORDER BY CASE ${St.COLUMN_NAME_IDENTIFIER} ${i} END`));let a="";switch(t){case An.DOWNLOADED.valueOf():a=" AND "+St.COLUMN_NAME_CONTENT_STATE+"='"+Nn.ARTIFACT_AVAILABLE+"'";break;case An.SPINE.valueOf():a=" AND "+St.COLUMN_NAME_CONTENT_STATE+"='"+Nn.ONLY_SPINE+"'";break;case An.ALL.valueOf():default:a=""}const c=`SELECT * FROM ${St.TABLE_NAME}\n WHERE ${St.COLUMN_NAME_IDENTIFIER}\n IN (${wn.joinPreservingQuotes(r)}) ${a} ${s}`;return this.dbService.execute(c).toPromise()}))}getSortedChildrenList(e,t,n){return bo(this,void 0,void 0,(function*(){let r=JSON.parse(e).children;if(!r||!r.length)return[];r=r.sort((e,t)=>e.index-t.index);let i=[];for(const e of r){const t=n.get(e.identifier);if(t)i.push(t);else{const t=`SELECT * FROM ${St.TABLE_NAME}\n WHERE ${St.COLUMN_NAME_IDENTIFIER} = '${e.identifier}'`,n=yield this.dbService.execute(t).toPromise();n.length&&i.push(n[0])}}switch(t){case An.DOWNLOADED.valueOf():i=i.filter(e=>e[St.COLUMN_NAME_CONTENT_STATE]=Nn.ARTIFACT_AVAILABLE);break;case An.SPINE.valueOf():i=i.filter(e=>e[St.COLUMN_NAME_CONTENT_STATE]=Nn.ONLY_SPINE);break;case An.ALL.valueOf():}return i}))}getChildIdentifiersFromManifest(e){return bo(this,void 0,void 0,(function*(){const t="file:///"+e,n=[];return yield this.fileService.readAsText(t,Ln.MANIFEST.valueOf()).then(e=>bo(this,void 0,void 0,(function*(){console.log("fileContents",JSON.parse(e));const t=JSON.parse(e).archive.items;return t.shift(),t.forEach(e=>{n.push(e.identifier)}),n}))).catch(e=>{console.log("getChildIdentifiersFromManifest err",e)}),n}))}}class Mo{static getFileExtension(e){const t=e.substring(e.lastIndexOf(".")+1,e.length);return t||""}static getFileName(e){return e.substring(e.lastIndexOf("/")+1)}static getParentDir(e){return e.substr(0,e.lastIndexOf("/",e.length-2)).concat("/")}static getDirectoryName(e){const t=e.split("/");return t[t.length-2]}static getTempDirPath(e){return e+"/tmp"}static isFreeSpaceAvailable(e,t,n){let r=10240;return n>0&&(r=n),e>0&&e>t+r}static getDirecory(e){return e.substr(0,e.lastIndexOf("/"))}}var Ro=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Lo{constructor(e,t,n){this.dbService=e,this.fileService=t,this.sharedPreferences=n,this.updateNewContentModels=[],this.fileMapList=[]}deleteAllChildren(e,t){return Ro(this,void 0,void 0,(function*(){let n=!1;const r=kn.getBasePath(e[St.COLUMN_NAME_PATH]);yield this.fileService.readAsText(r,Ln.MANIFEST.valueOf()).then(e=>Ro(this,void 0,void 0,(function*(){const r=JSON.parse(e).archive.items;r.shift();const i=[];r.forEach(e=>{i.push(e.identifier)});(yield this.findAllContentsFromDbWithIdentifiers(i)).forEach(e=>Ro(this,void 0,void 0,(function*(){yield this.deleteOrUpdateContent(e,!0,t),n=!0;const r=e[St.COLUMN_NAME_PATH];if(r&&n){if(kn.getFirstPartOfThePathNameOnLastDelimiter(r))try{this.sharedPreferences.putString(S.KEY_LAST_MODIFIED,(new Date).getMilliseconds()+"").toPromise()}catch(e){console.log("Error",e)}}})))}))).catch(e=>{console.log("fileread err",e)});const i=yield this.getMetaData(this.fileMapList);if(this.updateNewContentModels.length){this.dbService.beginTransaction();for(const e of this.updateNewContentModels){const t=e,n=t[St.COLUMN_NAME_IDENTIFIER];let r=0;i&&(r=i[n]?i[n].size:0),t[St.COLUMN_NAME_SIZE_ON_DEVICE]=r,yield this.dbService.update({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[n],modelJson:t}).toPromise()}this.dbService.endTransaction(!0)}}))}deleteOrUpdateContent(e,t,n){return Ro(this,void 0,void 0,(function*(){let r,i=e[St.COLUMN_NAME_REF_COUNT],o=e[St.COLUMN_NAME_VISIBILITY];const s=e[St.COLUMN_NAME_MIME_TYPE],a=e[St.COLUMN_NAME_PATH];if(n?(i>1&&o===Cn.DEFAULT.valueOf()&&(i-=1,o=Cn.PARENT.valueOf()),r=s===Tn.COLLECTION?Nn.ARTIFACT_AVAILABLE.valueOf():Nn.ONLY_SPINE.valueOf()):(s===Tn.COLLECTION.valueOf()&&i>1||i>1&&t?r=Nn.ARTIFACT_AVAILABLE.valueOf():(o===Cn.DEFAULT.valueOf()&&(o=Cn.PARENT.valueOf()),r=Nn.ONLY_SPINE.valueOf()),i-=1),a){if(r===Nn.ONLY_SPINE.valueOf()){const t=e[St.COLUMN_NAME_LOCAL_DATA],n=t&&JSON.parse(t);let r="",i="";t&&(r=n.appIcon?Mo.getFileName(n.appIcon):"",i=n.itemSetPreviewUrl?Mo.getFileName(n.itemSetPreviewUrl):""),this.rm(kn.getBasePath(a),[r,i].join(":"))}if(e[St.COLUMN_NAME_VISIBILITY]=o,e[St.COLUMN_NAME_REF_COUNT]=kn.addOrUpdateRefCount(i),e[St.COLUMN_NAME_CONTENT_STATE]=r,t){const t={};t.identifier=e[St.COLUMN_NAME_IDENTIFIER],t.path=kn.getBasePath(a),this.fileMapList.push(t),this.updateNewContentModels.push(e)}else e[St.COLUMN_NAME_SIZE_ON_DEVICE]=0,yield this.dbService.update({table:St.TABLE_NAME,modelJson:e,selection:St.COLUMN_NAME_IDENTIFIER+" =?",selectionArgs:[e[St.COLUMN_NAME_IDENTIFIER]]}).pipe(Object(D.map)(e=>e>0)).toPromise()}}))}findAllContentsFromDbWithIdentifiers(e){const t=wn.joinPreservingQuotes(e),n=` WHERE ${St.COLUMN_NAME_IDENTIFIER} IN (${t}) AND ${St.COLUMN_NAME_REF_COUNT} > 0`,r=`SELECT * FROM ${St.TABLE_NAME} ${n}`;return this.dbService.execute(r).toPromise()}rm(e,t){return new Promise((n,r)=>{try{sbutility.rm(e,t,e=>{n(e)},e=>{console.error(e),r(!1)})}catch(e){console.error(e),r(!1)}})}getMetaData(e){return Ro(this,void 0,void 0,(function*(){return new Promise((t,n)=>{sbutility.getMetaData(e,e=>{t(e)},e=>{console.error(e),n(e)})})}))}}var Po=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Do{constructor(e,t,n){this.appConfig=e,this.contentServiceConfig=t,this.telemetryService=n}getSearchCriteria(e){const t=e.request,n=t.query,r=t.exists,i=t.limit,o=t.offset;let s;t.hasOwnProperty("mode")&&"soft"===t.mode&&(s="soft");const a=[];if(t.hasOwnProperty("sort_by")){const e=t.sort_by;Object.keys(e).forEach(t=>{const n={sortAttribute:t,sortOrder:this.getSortOrder(String(e[t]))};a.push(n)})}const c=Object.assign(Object.assign(Object.assign({},n?{query:n}:{}),r?{exists:r}:{}),{mode:s,sortCriteria:a,searchType:this.getSearchType(String(t.searchType)),offset:o||0,limit:i||100});let u,l,d,h;if(t.hasOwnProperty("filters")){const e=t.filters;e.contentType&&(u=e.contentType),e.primaryCategory&&(l=e.primaryCategory),d=this.mapFilterValues(e,c),c.impliedFilters=d,c.contentTypes=u,c.primaryCategories=l}return t.hasOwnProperty("facets")&&(h=t.facets,c.facets=h),c}getSearchContentRequest(e){return{query:e.query,offset:e.offset,limit:e.limit,mode:e.mode,exists:e.exists&&e.exists.length>0?e.exists:[],facets:e.facets&&e.facets.length>0?e.facets:[],sort_by:this.getSortByRequest(e.sortCriteria),filters:this.getSearchFilter(e),fields:e.fields}}getSearchFilter(e){return e.searchType.valueOf()===gn.SEARCH.valueOf()?this.getSearchRequest(e):e.searchType.valueOf()===gn.FILTER.valueOf()?this.getFilterRequest(e):{}}getFilterRequest(e){let t={};return this.addFiltersToRequest(t,e.facetFilters),this.addFiltersToRequest(t,e.impliedFilters),e.impliedFiltersMap&&e.impliedFiltersMap.length>0&&e.impliedFiltersMap.forEach(e=>{t=Object.assign(Object.assign({},t),e)}),t}addFiltersToRequest(e,t){t&&t.length&&t.forEach(t=>{const n=[];if(t.values.forEach(e=>{e.apply&&n.push(e.name)}),n.length){let r=t.name;if(t.alternative)switch(t.name){case"board":r="se_boards";break;case"medium":r="se_mediums";break;case"gradeLevel":case"grade":r="se_gradeLevels"}e[r]=n}})}getSearchRequest(e){const t=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({audience:e.audience&&e.audience.length>0?e.audience:[],status:e.contentStatusArray,objectType:["Content","QuestionSet"],contentType:e.contentTypes&&e.contentTypes.length>0?e.contentTypes:[],primaryCategory:e.primaryCategories&&e.primaryCategories.length>0?e.primaryCategories:[]},e.keywords&&e.keywords.length?{keywords:e.keywords}:{}),e.dialCodes&&e.dialCodes.length?{dialcodes:e.dialCodes}:{}),e.createdBy&&e.createdBy.length?{createdBy:e.createdBy}:{}),e.grade&&e.grade.length?{se_gradeLevels:e.grade}:{}),{se_mediums:e.medium&&e.medium.length>0?e.medium:[],se_boards:e.board&&e.board.length>0?e.board:[],language:e.language&&e.language.length>0?e.language:[],topic:e.topic&&e.topic.length>0?e.topic:[],purpose:e.purpose&&e.purpose.length>0?e.purpose:[],channel:e.channel&&e.channel.length>0?e.channel:[],mimeType:e.mimeType&&e.mimeType.length>0?e.mimeType:[],subject:e.subject&&e.subject.length>0?e.subject:[]});return e.impliedFiltersMap&&e.impliedFiltersMap.forEach(e=>{Object.keys(e).forEach(n=>{t[n]=e[n]})}),e.impliedFilters&&e.impliedFilters.forEach(e=>{Object.keys(e).forEach(n=>{const r=e.values,i=e.name,o=this.getImpliedFilterValues(r);if(t[i]||(t[i]=[]),t[i]){const e=t[i].concat(o);e&&(t[i]=e.filter((t,n)=>e.indexOf(t)===n))}})}),t}getImpliedFilterValues(e){const t=[];return e?(e.forEach(e=>{e.apply&&t.push(e.name)}),t):[]}getSortByRequest(e){return e?e.reduce((e,t)=>(e[t.sortAttribute]=t.sortOrder,e),{}):{}}createFilterCriteria(e,t,n){const r=[],i={query:e.query,limit:e.limit,offset:e.offset,facets:e.facets,contentTypes:e.contentTypes,primaryCategories:e.primaryCategories,sortCriteria:e.sortCriteria&&e.sortCriteria.length?e.sortCriteria:[],mode:"soft"===e.mode?"soft":"hard"};return t?(t.forEach(e=>{const t=n?n[e.name]:[],i=e.values,o=this.getSortedFilterValuesWithAppliedFilters(i,t);if(e.name){const t={name:e.name,values:o};r.push(t)}delete n[e.name]}),i.facetFilters=r,i.impliedFilters=this.mapFilterValues(n,i),i):i}addFilterValue(e,t){e&&e.length>0&&e.forEach(e=>{const n=e.name;e.values,t[n]})}getFilterValuesWithAppliedFilter(e,t){return e.forEach(e=>{let n=!1;t&&t.indexOf(name)>-1&&(n=!0),e.apply=n}),e}mapSearchResponse(e,t,n){const r=(t.result.content||[]).concat(t.result.QuestionSet||[]);return{id:t.id,responseMessageId:t.params.resmsgid,filterCriteria:this.createFilterCriteria(e,t.result.facets,n.filters),request:n,contentDataList:r,count:t.result.count,collectionDataList:t.result.collections?t.result.collections:[]}}getContentSearchFilter(e,t,n=[]){return{filters:{identifier:e.filter((t,n)=>e.indexOf(t)===n),status:t,objectType:["Content"]},fields:[...n,"downloadUrl","variants","mimeType","contentType","primaryCategory","pkgVersion"]}}getDownloadUrl(e,t){return Po(this,void 0,void 0,(function*(){let n,r,i;try{i=e.variants&&"string"==typeof e.variants?JSON.parse(e.variants):e.variants}catch(t){i=e.variants}if(e.mimeType===Tn.COLLECTION.valueOf()?i&&i.online?r="online":i&&i.spine&&(r="spine"):e.mimeType===Tn.QUESTION_SET&&(i&&i.full?r="full":i&&i.online&&(r="online")),i&&r&&i[r]){const o=i[r];n=o&&o.ecarUrl,yield this.buildContentLoadingEvent(r,t,e.primaryCategory||e.contentType,e.pkgVersion)}return n||(n=e.downloadUrl.trim(),yield this.buildContentLoadingEvent("full",t,e.primaryCategory||e.contentType,e.pkgVersion)),n}))}buildContentLoadingEvent(e,t,n,r){const i=new Ie;return i.type=oe.OTHER,i.subType=e,i.pageId="ImportContent",i.id="ImportContent",i.objId=t.contentId,i.objType=n,i.objVer=r,i.rollup=t.rollUp,i.correlationData=t.correlationData,this.telemetryService.interact(i).toPromise()}getSortOrder(e){let t;return t="asc"===e?On.ASC:On.DESC,t}getSearchType(e){let t;return t="search"===e?gn.SEARCH:"filter"===e?gn.FILTER:gn.SEARCH,t}getSortedFilterValuesWithAppliedFilters(e,t){return e.forEach(e=>{let n=!1;t&&t.forEach(t=>{t&&e.name&&e.name.toLowerCase()===t.toLowerCase()&&(n=!0)}),e.apply=n,e.count=fe.parseInt(e.count)}),e}mapFilterValues(e,t){const n=[],r=[];return Object.keys(e).forEach(t=>{const i=e[t];if(Array.isArray(i)&&i.length){const e=[];i.forEach(t=>{const n={name:t,apply:!0};e.push(n)}),n.push({name:t,values:e})}else if(i){const e={};e[t]=i,r.push(e)}}),t.impliedFiltersMap=r,n}}class wo{getAllLocalContentQuery(e){e.primaryCategories&&e.primaryCategories.length||(e.primaryCategories=["Course","Learning Resource","Explanation Content","Teacher Resource","Content Playlist","Digital Textbook","Practice Question Set","eTextBook","Course Assessment"]);const t=e.uid,n=e.resourcesOnly?"":`c.${St.COLUMN_NAME_VISIBILITY} = '${Cn.DEFAULT.valueOf()}' AND`,r=`c.${St.COLUMN_NAME_CONTENT_STATE} = '${Nn.ARTIFACT_AVAILABLE.valueOf()}'`;let i=`${n} ${r}`;if(e.resourcesOnly){i=`${i} AND (${`c.${St.COLUMN_NAME_MIME_TYPE} != '${Tn.COLLECTION.valueOf()}'`})`}else{const t=wn.joinPreservingQuotes(e.primaryCategories);i=`${i} AND (${`c.${St.COLUMN_NAME_PRIMARY_CATEGORY} IN(${t.toLowerCase()})`})`}const o=this.getAudienceFilter(e.audience),s=this.getPragmaFilter(e.exclPragma,e.pragma),a=this.generateFieldMatchQuery(e);o&&(i=`${i} AND (${o})`),s&&(i=`${i} AND (${s})`),a&&(i=`${i} AND (${a})`);let c=`WHERE (${i})`,u="";const l=e.resourcesOnly?"":this.generateSortByQuery(e.sortCriteria,t);return e.recentlyViewed?t&&(i=e.localOnly?`ca.${At.COLUMN_NAME_UID} = '${t}' AND ${r}\n AND cm.${St.COLUMN_NAME_MIME_TYPE} NOT IN ('${Tn.COLLECTION.valueOf()}', '')`:`ca.${At.COLUMN_NAME_UID} = '${t}'\n AND cm.${St.COLUMN_NAME_MIME_TYPE} NOT IN ('${Tn.COLLECTION.valueOf()}', '')`,c=`WHERE (${i})`,u=this.getRecentlyViewedQuery(c,l,e.limit)):u=t?this.getLocalOnlyQuery(c,l,t):`SELECT c.* FROM ${St.TABLE_NAME} c ${c} ${l}`,u}getAudienceFilter(e){let t="";return e&&e.forEach(e=>{t=t.concat(t.length>0?" OR ":"",`c.${St.COLUMN_NAME_AUDIENCE} LIKE '%%${e}%%'`)}),t}getPragmaFilter(e,t){let n="";return e?e.forEach(e=>{n=n.concat(n.length>0?" OR ":"",`c.${St.COLUMN_NAME_PRAGMA} NOT LIKE '%%${e}%%'`)}):t&&t.forEach(e=>{n=n.concat(n.length>0?" OR ":"",`c.${St.COLUMN_NAME_PRAGMA} LIKE '%%${e}%%'`)}),n}getRecentlyViewedQuery(e,t,n){return`SELECT c.*, ca.${At.COLUMN_NAME_EPOCH_TIMESTAMP},\n cm.${vt.COLUMN_NAME_DATA} FROM ${At.TABLE_NAME} ca LEFT JOIN\n ${vt.TABLE_NAME} cm ON\n (cm.${vt.COLUMN_NAME_UID} = ca.${At.COLUMN_NAME_UID}\n AND cm.${vt.COLUMN_NAME_CONTENT_IDENTIFIER} = ca.${At.COLUMN_NAME_CONTENT_IDENTIFIER})\n LEFT JOIN ${St.TABLE_NAME} c ON\n c.${St.COLUMN_NAME_IDENTIFIER} = ca.${At.COLUMN_NAME_CONTENT_IDENTIFIER}\n ${e} ${t} LIMIT ${n}`}getLocalOnlyQuery(e,t,n){let r="";return r=Array.isArray(n)?`ca.${At.COLUMN_NAME_UID} IN (${wn.joinPreservingQuotes(n)})`:`ca.${At.COLUMN_NAME_UID} ='${n}'`,`SELECT c.*, ca.${At.COLUMN_NAME_EPOCH_TIMESTAMP}\n FROM ${St.TABLE_NAME} c LEFT JOIN ${At.TABLE_NAME} ca\n ON c.${St.COLUMN_NAME_IDENTIFIER} = ca.${At.COLUMN_NAME_CONTENT_IDENTIFIER}\n AND ${r}\n ${e} ${t}`}generateSortByQuery(e,t){let n="",r=0;return e||((e=[]).push({sortAttribute:"lastUsedOn",sortOrder:On.DESC}),e.push({sortAttribute:"localLastUpdatedOn",sortOrder:On.DESC})),e.forEach(e=>{e&&("lastUsedOn"===e.sortAttribute.valueOf()&&t?(n=this.generateOrderByQuery(r,n," ca."+At.COLUMN_NAME_EPOCH_TIMESTAMP,e.sortOrder.valueOf()),r++):"localLastUpdatedOn"===e.sortAttribute.valueOf()?(n=this.generateOrderByQuery(r,n," c."+St.COLUMN_NAME_LOCAL_LAST_UPDATED_ON,e.sortOrder.valueOf()),r++):"sizeOnDevice"===e.sortAttribute.valueOf()&&(n=this.generateOrderByQuery(r,n," c."+St.COLUMN_NAME_SIZE_ON_DEVICE,e.sortOrder.valueOf()),r++))}),n}generateOrderByQuery(e,t,n,r){let i="";return i=e>0?t.concat(","):t.concat("ORDER BY"),i=i.concat(`${n} ${r}`),i}generateFieldMatchQuery(e){return[{field:"board",column:St.COLUMN_NAME_BOARD},{field:"medium",column:St.COLUMN_NAME_MEDIUM},{field:"grade",column:St.COLUMN_NAME_GRADE},{field:"dialcodes",column:St.COLUMN_NAME_DIALCODES},{field:"childNodes",column:St.COLUMN_NAME_CHILD_NODES}].reduce((t,{field:n,column:r})=>(e[n]&&e[n].length&&t.push(this.generateLikeQuery(e[n],r)),t),[]).join(" AND ")}generateLikeQuery(e,t){let n="";const r=t+" LIKE ";for(let t=0;t<e.length;t++)n=t<e.length-1?n.concat(r,`'%%~${e[t].toLowerCase().trim()}~%%' OR `):n.concat(r,`'%%~${e[t].toLowerCase().trim()}~%%' `);return`(${n})`}}var Uo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},jo=St.COLUMN_NAME_LOCAL_DATA,Fo=St.COLUMN_NAME_IDENTIFIER,ko=St.COLUMN_NAME_REF_COUNT;class xo{constructor(e,t,n){this.deviceInfo=e,this.dbService=t,this.fileService=n}populateItems(e){const t=[],n=[];let r=[];const i={};e.forEach(e=>{const t=JSON.parse(e[jo]);if(i[e[Fo]]=t,kn.addViralityMetadataIfMissing(t,this.deviceInfo.getDeviceID()),kn.hasChildren(t)){const e=kn.getChildContentsIdentifiers(t);r=r.concat(e)}n.push(e[Fo])});try{n.forEach(e=>{const n=i[e];wn.contains(r,e)&&(n.visibility=Cn.PARENT.valueOf()),t.push(n)})}catch(e){console.log(e)}return t}populateItemList(e){const t=[],n=[];let r=[];const i={};e.forEach(e=>{if(i[e.identifier]=e,kn.addViralityMetadataIfMissing(e,this.deviceInfo.getDeviceID()),kn.hasChildren(e)){const t=kn.getChildContentsIdentifiers(e);r=r.concat(t)}n.push(e.identifier)});try{n.forEach(e=>{const n=i[e];wn.contains(r,e)&&(n.visibility=Cn.PARENT.valueOf()),t.push(n)})}catch(e){console.log(e)}return t}getContentExportDBModelToExport(e){return Uo(this,void 0,void 0,(function*(){let t=[];const n=yield this.findAllContentsWithIdentifiers(e),r=kn.getBasePath(n[0][St.COLUMN_NAME_PATH]);return yield this.fileService.readAsText(r,Ln.MANIFEST.valueOf()).then(e=>Uo(this,void 0,void 0,(function*(){const n=JSON.parse(e).archive.items,r=[];n.forEach(e=>{r.push(e.identifier)}),t=yield this.findAllContentsWithIdentifiers(r,!0)}))).catch(e=>{console.log("fileRead error",e)}),Promise.resolve(kn.deDupe(t,"identifier"))}))}generateManifestForArchive(e){const t={},n={ttl:24};return n.count=e.length,n.items=e,t.id=xo.EKSTEP_CONTENT_ARCHIVE,t.ver=xo.SUPPORTED_MANIFEST_VERSION,t.ts=b()().format("YYYY-MM-DDTHH:mm:ss[Z]"),t.archive=n,t}findAllContentsWithIdentifiers(e,t){let n="";t&&e.length&&(n=e.reduce((e,t,n)=>e+` WHEN '${t}' THEN ${n}`," ORDER BY CASE "+Fo)+" END");const r=wn.joinPreservingQuotes(e),i=` where ${Fo} in (${r}) AND ${ko} > 0`,o=`select * from ${St.TABLE_NAME} ${i} ${n}`;return this.dbService.execute(o).toPromise()}}xo.EKSTEP_CONTENT_ARCHIVE="ekstep.content.archive",xo.SUPPORTED_MANIFEST_VERSION="1.1";class Bo{constructor(e,t){this.dbService=e,this.exportHandler=t}execute(e){const t=new a.CsResponse,n=this.exportHandler.populateItems(e.contentModelsToExport);e.items=[],e.manifest={},e.items=e.items.concat(n);const r={ttl:24};return r.count=e.items.length,r.items=e.items,e.manifest.id=Bo.EKSTEP_CONTENT_ARCHIVE,e.manifest.ver=Bo.SUPPORTED_MANIFEST_VERSION,e.manifest.ts=b()().format(),e.manifest.archive=r,t.body=e,Promise.resolve(t)}}Bo.EKSTEP_CONTENT_ARCHIVE="ekstep.content.archive",Bo.SUPPORTED_MANIFEST_VERSION="1.1";class Vo{constructor(e,t){this.fileService=e,this.deviceInfo=t}execute(e){const t=new a.CsResponse;return this.deviceInfo.getAvailableInternalMemorySize().toPromise().then(n=>{const r=Number(n);if(r>0&&r<1048576)throw t.errorMesg=Mn.EXPORT_FAILED_MEMORY_NOT_SUFFICIENT,t;return this.fileService.writeFile(e.tmpLocationPath,Ln.MANIFEST.valueOf(),JSON.stringify(e.manifest),{replace:!0})}).then(()=>(t.body=e,Promise.resolve(t))).catch(()=>(t.errorMesg=Mn.EXPORT_FAILED_WRITING_MANIFEST,Promise.reject(t)))}}var Yo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Go{constructor(e){this.zipService=e}execute(e){return Yo(this,void 0,void 0,(function*(){const t=new a.CsResponse;for(const t of e.contentModelsToExport){const n=t,r=JSON.parse(n[St.COLUMN_NAME_LOCAL_DATA]);if(!kn.isAvailableLocally(n[St.COLUMN_NAME_CONTENT_STATE])||kn.isOnlineContent(r)||kn.isInlineIdentity(r.contentDisposition,r.contentEncoding))continue;const i=r.artifactUrl;if(i){const t=e.tmpLocationPath.concat(i),r=n[St.COLUMN_NAME_PATH],o=[],s=[];o.push(n[St.COLUMN_NAME_IDENTIFIER]),s.push(n[St.COLUMN_NAME_IDENTIFIER].concat("/",Ln.MANIFEST.valueOf())),yield new Promise((e,n)=>{this.zipService.zip(r,{target:t},o,s,()=>{e()},()=>{n()})})}}return t.body=e,Promise.resolve(t)}))}}var Ho=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class $o{constructor(e){this.fileService=e}execute(e){return Ho(this,void 0,void 0,(function*(){const t=new a.CsResponse;return this.fileService.getFreeDiskSpace().then(n=>{this.getFileSize(e.items);return t.body=e,t})}))}getFileSize(e){let t=0;return e&&e.forEach(e=>{e.size&&(t+=Number(e.size))}),t}}var qo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ko{constructor(){}execute(e){return qo(this,void 0,void 0,(function*(){const t=new a.CsResponse;try{let n=0,r=[];null!=e.subContentIds&&e.subContentIds.length>0&&(r=this.excludeContentForSubModule(e.contentModelsToExport,e.subContentIds));let i=e.contentModelsToExport;r&&r.length>0&&(i=r);for(const t of i){const r=t,i=e.items[n],o=i.appIcon,s=i.itemSetPreviewUrl;for(const t of[o,s])if(t&&!t.startsWith("https:"))try{yield this.copyFile(r[St.COLUMN_NAME_PATH],e.tmpLocationPath,t)}catch(e){console.error(e)}const a=i.contentDisposition,c=i.contentEncoding;if(kn.isInlineIdentity(a,c)){const t=i.artifactUrl;if(t)try{yield this.copyFile(r[St.COLUMN_NAME_PATH],e.tmpLocationPath,t)}catch(e){console.error(e)}}n++}return t.body=e,t}catch(e){throw t.errorMesg=Mn.EXPORT_FAILED_COPY_ASSET,t}}))}excludeContentForSubModule(e,t){const n=[];return e.forEach(e=>{const r=e.identifier;t&&t.indexOf(r)>-1&&n.push(e)}),n}copyFile(e,t,n){return qo(this,void 0,void 0,(function*(){return new Promise((r,i)=>{sbutility.copyFile(e,t,n,()=>{r(!0)},e=>{console.error(e),r(e)})})}))}}var zo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Wo{constructor(e,t){this.fileService=e,this.zipService=t}execute(e){return zo(this,void 0,void 0,(function*(){const t=new a.CsResponse;yield new Promise((n,r)=>{this.zipService.zip(e.tmpLocationPath,{target:e.ecarFilePath},[],[],()=>{n()},()=>{throw t.errorMesg=Mn.EXPORT_FAILED_ECAR_BUNDLE,t})});const n=yield this.fileService.getMetaData(e.ecarFilePath);return e.metadata[Wo.FILE_SIZE]=n.size,t.body=e,t}))}}Wo.FILE_SIZE="FILE_SIZE";var Xo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Jo{constructor(e,t){this.fileService=e,this.zipService=t,this.FILE_SIZE="FILE_SIZE"}execute(e){const t=new a.CsResponse;let n;return this.fileService.getMetaData(e.ecarFilePath).then(t=>(n=t.size,this.fileService.createDir(e.tmpLocation.concat(en.generateUniqueId()),!0))).then(r=>Xo(this,void 0,void 0,(function*(){return e.tmpLocation=r.nativeURL,yield new Promise((t,n)=>{this.zipService.unzip(e.ecarFilePath,{target:r.nativeURL},()=>{t()},e=>{n(e)})}),e.metadata={},e.metadata.FILE_SIZE=n,t.body=e,Promise.resolve(t)}))).catch(e=>(t.errorMesg=Mn.IMPORT_FAILED_EXTRACT_ECAR.valueOf(),Promise.reject(t)))}}class Qo{constructor(){this.identifierList=new Set}hierarchyToManifestConversion(e){this.identifierList=new Set,this.archive={count:0,items:[]};const t=this.reorderData(e,1);return t&&(this.archive.count+=1,this.archive.items.push(t)),e.children&&e.children.length&&this.recurssiveFunc(e.children,1),this.archive}recurssiveFunc(e,t){for(let n=0;n<e.length;n++){const r=this.reorderData(e[n],t+1,Cn.PARENT.valueOf());r&&(this.archive.count+=1,this.archive.items.push(r)),e[n].children&&e[n].children.length&&this.recurssiveFunc(e[n].children,t+1)}}reorderData(e,t,n){if(this.identifierList.has(e.identifier))return null;const r=[],i=JSON.parse(JSON.stringify(e));if(i.children&&i.children.length){for(let e=0;e<i.children.length;e++)r.push({name:i.children[e].name,identifier:i.children[e].identifier,objectType:i.children[e].objectType,depth:t,index:e});i.children=r}return i.visibility=n||i.visibility,this.identifierList.add(i.identifier),i}}var Zo=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class es{constructor(e,t,n,r){this.fileService=e,this.dbService=t,this.appConfig=n,this.getContentDetailsHandler=r}execute(e){return Zo(this,void 0,void 0,(function*(){const t=new a.CsResponse;let n;try{if(n=yield this.fileService.readAsText(e.tmpLocation,Ln.HIERARCHY.valueOf()),n){const e=JSON.parse(n);e.archive=(new Qo).hierarchyToManifestConversion(e.content),delete e.content,n=JSON.stringify(e)}}catch(t){console.log("err validating ecar",t),n=yield this.fileService.readAsText(e.tmpLocation,Ln.MANIFEST.valueOf())}if(!n)throw t.errorMesg=Mn.IMPORT_FAILED_MANIFEST_FILE_NOT_FOUND.valueOf(),yield this.fileService.removeRecursively(e.tmpLocation),console.log("response in err",t),t;const r=JSON.parse(n);if(1===r.ver)throw t.errorMesg=Mn.IMPORT_FAILED_UNSUPPORTED_MANIFEST.valueOf(),yield this.fileService.removeRecursively(e.tmpLocation),t;const i=r.archive;if(!i.items)throw t.errorMesg=Mn.IMPORT_FAILED_NO_CONTENT_METADATA.valueOf(),yield this.fileService.removeRecursively(e.tmpLocation),t;e.manifestVersion=r.ver,e.items=[];const o=i.items,s=[];for(const e of o){const t=e.identifier;s.push(t)}const c=wn.joinPreservingQuotes(s),u=(yield this.getContentDetailsHandler.fetchFromDBForAll(c).toPromise()).reduce((e,t)=>(e[t.identifier]=t,e),{});let l=!1;e.existedContentIdentifiers={};for(const t of o){const n=t,r=n.identifier,i=kn.readVisibility(n),s=n.status,a=kn.isDraftContent(s);if(a&&kn.isExpired(n.expires)){this.skipContent(e,r,i,In.CONTENT_EXPIRED,o);continue}i===Cn.DEFAULT.valueOf()&&(l=!1);const c=u[r];let d;if(c){const t=c[St.COLUMN_NAME_REF_COUNT];if(d=c[St.COLUMN_NAME_PATH],d&&i===Cn.DEFAULT.valueOf()&&t&&t>0){l=!0;const t=JSON.parse(c[St.COLUMN_NAME_LOCAL_DATA]);t&&n.pkgVersion>t.pkgVersion&&t.childNodes&&t.childNodes.length>0&&(e.contentIdsToDelete=new Set(t.childNodes))}}d&&i===Cn.DEFAULT.valueOf()&&!kn.isDuplicateCheckRequired(a,n.pkgVersion)&&kn.isImportFileExist(c,n)?(e.rootIdentifier=r,this.skipContent(e,r,i,In.ALREADY_EXIST,o)):(l&&e.contentIdsToDelete.delete(r)&&(e.existedContentIdentifiers[r]=!0),e.items.push(n))}return t.body=e,t}))}skipContent(e,t,n,r,i){n===Cn.DEFAULT&&(r===In.ALREADY_EXIST?i&&1===i.length&&e.contentImportResponseList.push({identifier:t,status:r}):e.contentImportResponseList.push({identifier:t,status:r})),e.skippedItemsIdentifier.push(t)}}var ts=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ns{constructor(e,t,n){this.dbService=e,this.sharedPreferences=t,this.fileService=n}execute(){return this.updateAllRootContentSize().toPromise()}findAllChildContents(e){const t=`SELECT * FROM ${St.TABLE_NAME}\n WHERE ${St.COLUMN_NAME_IDENTIFIER} IN (${wn.joinPreservingQuotes(e)})\n AND ${St.COLUMN_NAME_REF_COUNT} > 0`;return this.dbService.execute(t).toPromise()}updateAllRootContentSize(){const e=`SELECT * FROM ${St.TABLE_NAME} WHERE ${St.COLUMN_NAME_REF_COUNT} > 0\n AND ${St.COLUMN_NAME_VISIBILITY} = '${Cn.DEFAULT.valueOf()}'`;return this.dbService.execute(e).pipe(Object(D.tap)(()=>ts(this,void 0,void 0,(function*(){return this.sharedPreferences.putBoolean(S.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,!1).toPromise()}))),Object(D.mergeMap)(e=>ts(this,void 0,void 0,(function*(){const t=[];yield Promise.all(e.map(e=>ts(this,void 0,void 0,(function*(){let n=yield this.getSizeOnDevice(e);const r=JSON.parse(e[St.COLUMN_NAME_LOCAL_DATA]).childNodes;if(r){(yield this.findAllChildContents(r)).forEach(e=>{n+=e[St.COLUMN_NAME_SIZE_ON_DEVICE]||0}),e[St.COLUMN_NAME_SIZE_ON_DEVICE]=n,t.push(e)}})))),this.updateInDb(t)}))),Object(D.tap)(()=>ts(this,void 0,void 0,(function*(){return this.sharedPreferences.putBoolean(S.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,!0).toPromise()}))))}getSizeOnDevice(e){return ts(this,void 0,void 0,(function*(){let t=0;if(e[St.COLUMN_NAME_MIME_TYPE]===Tn.COLLECTION.valueOf()){if(e[St.COLUMN_NAME_VISIBILITY]===Cn.DEFAULT.valueOf()){const n=[],r={},i=e[St.COLUMN_NAME_IDENTIFIER];r.identifier=i,r.path=e[St.COLUMN_NAME_PATH],n.push(r);const o=yield this.getMetaData(n);t=o[i]?o[i].size:0}}else t=e[St.COLUMN_NAME_SIZE_ON_DEVICE]?e[St.COLUMN_NAME_SIZE_ON_DEVICE]:0;return Promise.resolve(t||0)}))}updateInDb(e){return ts(this,void 0,void 0,(function*(){this.dbService.beginTransaction();for(const t of e){const e=t,n=e[St.COLUMN_NAME_IDENTIFIER];this.dbService.update({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[n],modelJson:e}).toPromise()}this.dbService.endTransaction(!0)}))}getMetaData(e){return ts(this,void 0,void 0,(function*(){return new Promise((t,n)=>{sbutility.getMetaData(e,e=>{t(e)},e=>{console.error(e),n(e)})})}))}updateTextBookSize(e){console.log("in updateAllRootContentSize");const t=`SELECT * FROM ${St.TABLE_NAME} WHERE ${St.COLUMN_NAME_IDENTIFIER} == ${e}`;return this.dbService.execute(t).pipe(Object(D.tap)(()=>ts(this,void 0,void 0,(function*(){return this.sharedPreferences.putBoolean(S.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,!1).toPromise()}))),Object(D.mergeMap)(e=>ts(this,void 0,void 0,(function*(){const t=[];yield Promise.all(e.map(e=>ts(this,void 0,void 0,(function*(){let n=yield this.getSizeOnDevice(e);const r=JSON.parse(e[St.COLUMN_NAME_LOCAL_DATA]).childNodes;if(r){(yield this.findAllChildContents(r)).forEach(e=>{n+=e[St.COLUMN_NAME_SIZE_ON_DEVICE]||0}),e[St.COLUMN_NAME_SIZE_ON_DEVICE]=n,t.push(e)}})))),this.updateInDb(t)}))),Object(D.tap)(()=>ts(this,void 0,void 0,(function*(){return this.sharedPreferences.putBoolean(S.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,!0).toPromise()}))))}}var rs=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},is=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,i){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,i,(t=e[n](t)).done,t.value)}))}}},os=St.COLUMN_NAME_VISIBILITY;class ss{constructor(e,t,n,r,i,o,s,a){this.fileService=e,this.zipService=t,this.appConfig=n,this.dbService=r,this.deviceInfo=i,this.getContentDetailsHandler=o,this.eventsBusService=s,this.sharedPreferences=a}execute(e){return rs(this,void 0,void 0,(function*(){const t=new a.CsResponse;e.identifiers=[];const n=[],r=[],i=new Map,o=new Map;let s,c=0;this.postImportProgressEvent(c,e.items.length);const u=[],l=[],d=[];for(const t of e.items){const e=t,n=e.identifier,r=kn.readVisibility(e),i=e.appIcon;kn.isNotUnit(e.mimeType,r)&&(l.push(n),i&&!i.startsWith("https:")&&d.push(n+"/"+i.substring(0,i.lastIndexOf("/")))),u.push(n)}const h=kn.getContentRootDir(e.destinationFolder);let E;E=e.items[0].mimeType===Tn.QUESTION_SET?yield this.segregateQuestions(h,JSON.parse(JSON.stringify(e.items))):yield this.createDirectories(h,l);yield this.createDirectories(h,d);const f=wn.joinPreservingQuotes(u),p=(yield this.getContentDetailsHandler.fetchFromDBForAll(f).toPromise()).reduce((e,t)=>(e[t.identifier]=t,e),{});for(const t of e.items){let a=t;const u=a.identifier;if(e.skippedItemsIdentifier&&e.skippedItemsIdentifier.indexOf(u)>-1)continue;const l=a.mimeType,d=a.contentEncoding,h=a.contentDisposition,f=kn.readContentType(a),_=kn.readPrimaryCategory(a);let O=kn.readVisibility(a);const S=kn.readAudience(a),g=kn.readPragma(a),A=a.pkgVersion,N=a.artifactUrl,T=a.appIcon,C=a.itemSetPreviewUrl,v=a.board,y=a.medium,m=a.gradeLevel,b=a.dialcodes,I=a.childNodes;let M,R=Nn.ONLY_SPINE.valueOf();const L=p[u];let P,D;if(L&&(P=kn.getBasePath(L[St.COLUMN_NAME_PATH])),O===Cn.DEFAULT.valueOf()&&(D=u),kn.isNotUnit(l,O))if(E[u]&&E[u].path)M="ios"===window.device.platform.toLowerCase()?E[u].path.concat("/"):E[u].path;else{let t="ios"===window.device.platform.toLowerCase()?kn.getContentRootDir(e.destinationFolder).concat(u):kn.getContentRootDir(e.destinationFolder).concat("/",u);const n=yield this.fileService.createDir(t,!1);M=n.nativeURL}let w=!1,U=kn.doesContentExist(L,u,A,!1);if(U=!1,U&&a.status!==vn.DRAFT.valueOf())L[os]===Cn.DEFAULT.valueOf()&&(a=JSON.parse(L[St.COLUMN_NAME_LOCAL_DATA]));else{if(U=!1,N){if(!kn.isInlineIdentity(h,d)&&l===Tn.EPUB)try{yield this.copyAssets(e.tmpLocation,N,M),w=!0}catch(e){w=!1}if(!h||!d||h===mn.INLINE.valueOf()&&d===yn.GZIP.valueOf()){const t=e.tmpLocation.concat(N);yield new Promise((e,n)=>{this.zipService.unzip(t,{target:M},()=>{w=!0,e()},()=>{e()})})}else if(kn.isInlineIdentity(h,d))try{yield this.copyAssets(e.tmpLocation,N,M),w=!0}catch(e){w=!1}else mn.ONLINE.valueOf()===h&&(w=!0)}if(R=w||this.shouldDownloadQuestionSet(e.items,a)||Tn.COLLECTION.valueOf()===l?Nn.ARTIFACT_AVAILABLE.valueOf():Nn.ONLY_SPINE.valueOf(),kn.isNotUnit(l,O))try{T.startsWith("https:")||this.copyAssets(e.tmpLocation,T,M,!0)}catch(e){}try{C.startsWith("https:")||this.copyAssets(e.tmpLocation,C,M,!1)}catch(e){}}const j=this.getBasePath(M,U,P);O===Cn.DEFAULT.valueOf()?(s=j,e.rootIdentifier=u):kn.isNotUnit(l,O)&&e.identifiers.push(u);const F=this.getReferenceCount(L,O,e.isChildContent,e.existedContentIdentifiers);O=this.getContentVisibility(L,a.objectType,e.isChildContent,O),kn.addOrUpdateViralityMetadata(a,this.deviceInfo.getDeviceID().toString());const k=0;kn.isNotUnit(l,O)&&o.set(u,M);const x=this.constructContentDBModel(u,e.manifestVersion,JSON.stringify(a),l,f,O,j,F,R,S,g,k,v,y,m,b,I,_);if(L){this.getContentState(L,R)===Nn.ONLY_SPINE.valueOf()||w||Tn.COLLECTION.valueOf()===l?r.push(x):x[St.COLUMN_NAME_CONTENT_STATE]=this.getContentState(L,R)}else n.push(x);i.set(u,x),c++,c%20!=0&&c!==e.items.length||this.postImportProgressEvent(c,e.items.length)}this.updateContentDB(n,r);const _=setTimeout(()=>{this.updateContentFileSizeInDB(e,i,o,p)},5e3);if(s)try{yield this.fileService.copyFile(e.tmpLocation,Ln.MANIFEST.valueOf(),s,Ln.MANIFEST.valueOf())}catch(e){console.log("Exception Raised During Import")}return t.body=e,Promise.resolve([t,_])}))}updateContentFileSizeInDB(e,t,n,r){return rs(this,void 0,void 0,(function*(){const i=[];for(const o of e.items){const e=o.identifier,s=t.get(e).mimeType,a=t.get(e).visibility,c=n.get(e);let u=0;r[e];if(kn.isNotUnit(s,a))try{u=yield this.fileService.getDirectorySize(c),t.get(e).size_on_device=u,i.push(t.get(e))}catch(e){}}this.updateContentDB([],i,!0)}))}updateContentDB(e,t,n){return rs(this,void 0,void 0,(function*(){if(e=e&&e.length?this.filterQuestionSetContent(e):e,t=t&&t.length?this.filterQuestionSetContent(t):t,e.length||t.length){this.dbService.beginTransaction();for(const t of e){const e=t;yield this.dbService.insert({table:St.TABLE_NAME,modelJson:e}).toPromise()}for(const e of t){const t=e;yield this.dbService.update({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[St.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise()}this.dbService.endTransaction(!0)}n&&new ns(this.dbService,this.sharedPreferences,this.fileService).execute()}))}copyAssets(e,t,n,r){return rs(this,void 0,void 0,(function*(){console.log("tempLocationPath-",e),console.log("asset-",t),console.log("payloadDestinationPath-",n),console.log("useSubDirectories-",r),console.log("FileUtil.getFileName(asset),-",Mo.getFileName(t));try{if(t&&!t.startsWith("http://")&&!t.startsWith("https://")){let i=t.substring(0,t.lastIndexOf("/"));if(!r){let e=yield this.fileService.createDir(n.concat(i),!1);console.log("createRe-",e)}"ios"===window.device.platform.toLowerCase()&&(yield this.fileService.exists(n.concat("/",t)).then(e=>{e&&this.fileService.removeFile(n.concat("/",t)).then()}).catch(e=>{console.log("Error =>",e)}));let o=yield Mo.getFileName(t),s="";try{s=yield this.fileService.exists(e.concat(o))}catch(e){s=""}console.log("pathExist-",s),""!==s?yield this.fileService.copyFile(e.concat(o),o,n.concat(i),o):yield this.fileService.copyFile(e.concat(i),Mo.getFileName(t),n.concat(i),Mo.getFileName(t))}}catch(e){throw console.error("Cannot Copy Asset---000011---",e),e}}))}getContentVisibility(e,t,n,r){let i;return"Library"===t?i=Cn.PARENT.valueOf():e&&(n||Cn.PARENT.valueOf()!==e[os])&&(i=e[os]),i||r}getContentState(e,t){return e&&e[St.COLUMN_NAME_CONTENT_STATE]>t&&(t=e[St.COLUMN_NAME_CONTENT_STATE]),t}getBasePath(e,t,n){let r;return r=e&&!t?e:n,r}getReferenceCount(e,t,n,r){let i;if(e){i=e[St.COLUMN_NAME_REF_COUNT];(r?r[e[St.COLUMN_NAME_IDENTIFIER]]:void 0)||n||Cn.DEFAULT.valueOf()===e[os]&&Cn.DEFAULT.valueOf()===t||(i+=1)}else i=1;return i}postImportProgressEvent(e,t){this.eventsBusService.emit({namespace:M.CONTENT,event:{type:Pn.IMPORT_PROGRESS,payload:{totalCount:t,currentCount:e}}})}constructContentDBModel(e,t,n,r,i,o,s,a,c,u,l,d,h,E,f,p,_,O){return{[St.COLUMN_NAME_IDENTIFIER]:e,[St.COLUMN_NAME_SERVER_DATA]:"",[St.COLUMN_NAME_PATH]:kn.getBasePath(s),[St.COLUMN_NAME_REF_COUNT]:a,[St.COLUMN_NAME_CONTENT_STATE]:c,[St.COLUMN_NAME_SIZE_ON_DEVICE]:d,[St.COLUMN_NAME_MANIFEST_VERSION]:t,[St.COLUMN_NAME_LOCAL_DATA]:n,[St.COLUMN_NAME_MIME_TYPE]:r,[St.COLUMN_NAME_CONTENT_TYPE]:i,[St.COLUMN_NAME_VISIBILITY]:o,[St.COLUMN_NAME_AUDIENCE]:u,[St.COLUMN_NAME_PRAGMA]:l,[St.COLUMN_NAME_LOCAL_LAST_UPDATED_ON]:b()(Date.now()).format(),[St.COLUMN_NAME_BOARD]:kn.getContentAttribute(h),[St.COLUMN_NAME_MEDIUM]:kn.getContentAttribute(E),[St.COLUMN_NAME_GRADE]:kn.getContentAttribute(f),[St.COLUMN_NAME_DIALCODES]:kn.getContentAttribute(p),[St.COLUMN_NAME_CHILD_NODES]:kn.getContentAttribute(_),[St.COLUMN_NAME_PRIMARY_CATEGORY]:O}}createDirectories(e,t){return rs(this,void 0,void 0,(function*(){return new Promise((n,r)=>{e="ios"===window.device.platform.toLowerCase()?e.concat("/"):e,sbutility.createDirectories(kn.getBasePath(e),t,e=>{n(e)},e=>{console.error(e),r(e)})})}))}filterQuestionSetContent(e){return e.filter(e=>e.mimeType!==Tn.QUESTION&&e.mime_type!==Tn.QUESTION)}segregateQuestions(e,t){var n,r;return rs(this,void 0,void 0,(function*(){let i={};for(let e=0;e<t.length;e++)t[e].mimeType!==Tn.QUESTION_SET||i[t[e].identifier]?t[e].mimeType===Tn.QUESTION&&(i[t[e].parent]?i[t[e].parent].push(t[e].identifier):i[t[e].identifier]=[t[e].identifier]):i[t[e].identifier]=[];const o=Object.keys(i);let s=yield this.createDirectories(e,o);const a=[];for(const t in i)a.push({idArr:i[t],dir:`${e}/${t}`});try{for(var c,u=is(a);!(c=yield u.next()).done;){const e=c.value,t=yield this.createDirectories(e.dir,e.idArr);s=Object.assign(Object.assign({},s),t)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&(yield r.call(u))}finally{if(n)throw n.error}}return s}))}shouldDownloadQuestionSet(e,t){return t.mimeType===Tn.QUESTION_SET&&kn.readVisibility(t)===Cn.DEFAULT.valueOf()||this.checkParentQustionSet(e,t)}checkParentQustionSet(e,t){if(!t||!t.parent)return!1;const n=e.find(e=>e.identifier===t.parent);return!(!n||n.mimeType!==Tn.QUESTION_SET)&&(n.mimeType===Tn.QUESTION_SET&&kn.readVisibility(n)===Cn.DEFAULT.valueOf()||this.checkParentQustionSet(e,n))}}var as=n(49),cs=n.n(as),us=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ls{constructor(e,t,n){this.dbService=e,this.deviceInfo=t,this.fileService=n,this.contentDataMap={}}execute(e){return us(this,void 0,void 0,(function*(){const t=yield this.fileService.readAsText(e.tmpLocation,Ln.MANIFEST.valueOf());JSON.parse(t).archive.items.forEach(e=>{this.contentDataMap[e.identifier]=e});const n=new a.CsResponse;try{return yield this.createnWriteManifest(e.identifiers,e.destinationFolder),n.body=e,Promise.resolve(n)}catch(e){return console.error(e),Promise.reject(n)}}))}createnWriteManifest(e,t){return us(this,void 0,void 0,(function*(){const n=new xo(this.deviceInfo),r=[];for(const i of e){const e=this.contentDataMap[i],o=new cs.a;let s;o.add(e);let a=[];for(a.push(e);!o.isEmpty();)if(s=o.dequeue(),kn.hasChildren(s)){const e=kn.getChildContentsIdentifiers(s);if(e&&e.length){const t=[];e.forEach(e=>{const n=this.contentDataMap[e];n&&(o.add(n),t.push(n))}),a=a.concat(t)}}const c=n.populateItemList(a),u=n.generateManifestForArchive(c),l={};c&&c[0]&&c[0].parent&&c[0].mimeType===Tn.QUESTION?l.path=kn.getBasePath(kn.getContentRootDir(t).concat("/",c[0].parent,"/",i,"/")):l.path=kn.getBasePath(kn.getContentRootDir(t).concat("/",i,"/")),l.fileName=Ln.MANIFEST.valueOf(),l.data=JSON.stringify(u),r.push(l)}yield this.writeFile(r)}))}writeFile(e){return us(this,void 0,void 0,(function*(){return new Promise((t,n)=>{sbutility.writeFile(e,e=>{t()},e=>{console.error(e),n(e)})})}))}}class ds{constructor(e){this.fileService=e}execute(e){const t=new a.CsResponse;return this.fileService.removeRecursively(e.tmpLocation).then(()=>(t.body=e,Promise.resolve(t))).catch(()=>Promise.reject(t))}}class hs{constructor(e){this.fileService=e}execute(e){const t=new a.CsResponse;return this.fileService.createDir(e.tmpLocationPath.concat(en.generateUniqueId()),!1).then(n=>(e.tmpLocationPath=n.nativeURL,t.body=e,Promise.resolve(t))).catch(()=>Promise.reject(t))}}class Es{constructor(e,t,n,r){this.apiService=e,this.contentServiceConfig=t,this.framework=n,this.langCode=r,this.SEARCH_ENDPOINT="/search"}handle(e){const t=this.framework&&this.langCode&&`?framework=${this.framework}&lang=${this.langCode}&orgdetails=orgName`,n=(new a.CsRequest.Builder).withHost(this.contentServiceConfig.host).withType(a.CsHttpRequestType.POST).withPath(this.contentServiceConfig.searchApiPath.concat(this.SEARCH_ENDPOINT).concat(t||"")).withBearerToken(!0).withBody({request:e}).build();return this.apiService.fetch(n).pipe(Object(D.map)(e=>e.body))}}class fs{constructor(e){this.telemetryService=e}execute(e){e.metadata;const t=[];for(const n of e.items){const e={type:kn.readPrimaryCategoryServer(n),origin:kn.readOriginFromContentMap(n),identifier:n.identifier,pkgVersion:Number(n.pkgVersion),transferCount:kn.readTransferCountFromContentMap(n),size:kn.readSizeFromContentMap(n)};t.push(e)}const n={dir:ne.IN,type:re.FILE.valueOf(),items:t,env:"sdk",correlationData:e.correlationData,objId:e.items&&e.items.length?e.items[0].identifier:"",objType:e.items&&e.items.length?kn.readPrimaryCategoryServer(e.items[0]):"",objVer:e.items&&e.items.length?kn.readPkgVersion(e.items[0])+"":"",rollUp:e.rollUp},r=new a.CsResponse;return this.telemetryService.share(n).toPromise().then(()=>(r.body=e,Promise.resolve(r))).catch(()=>Promise.reject(r))}}class ps{constructor(e){this.telemetryService=e}execute(e,t,n){const r=new a.CsResponse;for(const t of e.items){ie.CONTENT,kn.readOriginFromContentMap(t),t.identifier,Number(t.pkgVersion),kn.readTransferCountFromContentMap(t),kn.readSizeFromContentMap(t)}const i={dir:ne.OUT,type:re.FILE.valueOf(),items:[],env:"sdk"};return this.telemetryService.share(i).toPromise().then(()=>{let e;if(n.saveLocally)e=n.destinationFolder.concat(t);else{e=("ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalCacheDirectory).concat(t)}const i={exportedFilePath:e};return r.body=i,Promise.resolve(r)}).catch(()=>Promise.reject(r))}}class _s{constructor(e){this.telemetryService=e}execute(e,t){const n=e.items&&e.items.length?e.items[0].identifier:"",r=new Ie;r.type=oe.OTHER,r.subType=t,r.pageId="ImportContent",r.id="ImportContent",r.env="sdk",r.objId=n||e.identifier,r.objType=e.items&&e.items.length?kn.readPrimaryCategoryServer(e.items[0]):"",r.objVer=e.items&&e.items.length?kn.readPkgVersion(e.items[0])+"":"",r.correlationData=e.correlationData;const i=new a.CsResponse;return i.body=e,this.telemetryService.interact(r).pipe(Object(D.map)(()=>i)).toPromise()}}var Os=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ss{constructor(e){this.dbService=e}getUsgaeSpace(e){const t=`SELECT SUM(${St.COLUMN_NAME_SIZE_ON_DEVICE}) as total_size\n FROM ${St.TABLE_NAME}\n WHERE ${St.COLUMN_NAME_VISIBILITY} = '${Cn.DEFAULT.valueOf()}'\n AND ${St.COLUMN_NAME_PATH} LIKE '${e.replace("file://","")}%'`;return this.dbService.execute(t).pipe(Object(D.map)(e=>e[0].total_size||0))}getContentUsageSummary(e){return Os(this,void 0,void 0,(function*(){const t=[];for(const n of e){const e=yield this.getUsgaeSpace(n).toPromise();t.push({path:n,sizeOnDevice:e})}return t}))}}class gs{constructor(e,t,n){this.sharedPreferences=e,this.key=t,this.toStringFunction=n,this.changes=new c.BehaviorSubject(void 0)}addAll(e){return this.asSet().pipe(Object(D.mergeMap)(t=>(e.forEach(e=>t.add(e)),this.sharedPreferences.putString(this.key,JSON.stringify(t.toArray())).pipe(Object(D.mapTo)(void 0)))),Object(D.tap)(()=>this.changes.next(void 0)))}add(e){return this.asSet().pipe(Object(D.mergeMap)(t=>(t.add(e),this.sharedPreferences.putString(this.key,JSON.stringify(t.toArray())).pipe(Object(D.mapTo)(void 0)))),Object(D.tap)(()=>this.changes.next(void 0)))}clear(){return this.sharedPreferences.putString(this.key,"[]").pipe(Object(D.mapTo)(void 0),Object(D.tap)(()=>this.changes.next(void 0)))}remove(e){return this.asSet().pipe(Object(D.mergeMap)(t=>{const n=t.remove(e);return this.sharedPreferences.putString(this.key,JSON.stringify(t.toArray())).pipe(Object(D.mapTo)(n))}),Object(D.tap)(()=>this.changes.next(void 0)))}contains(e){return this.asSet().pipe(Object(D.map)(t=>t.contains(e)))}asList(){return this.sharedPreferences.getString(this.key).pipe(Object(D.map)(e=>e?JSON.parse(e):[]))}asSet(){return this.asList().pipe(Object(D.map)(e=>e.reduce((e,t)=>(e.add(t),e),new Eo.a(this.toStringFunction))))}asListChanges(){return this.changes.asObservable().pipe(Object(D.mergeMap)(()=>this.asList()))}}var As=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ns{constructor(){}execute(e,t){return As(this,void 0,void 0,(function*(){return new Promise((n,r)=>{let i;i=t.saveLocally?t.destinationFolder:"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalCacheDirectory,sbutility.copyFile(Mo.getDirecory(e.body.ecarFilePath),i,Mo.getFileName(e.body.ecarFilePath),()=>{n(e)},e=>{console.error(e),n(e)})})}))}}class Ts{constructor(e,t){this.apiService=e,this.contentServiceConfig=t,this.GET_CONTENT_HEIRARCHY_ENDPOINT="/hierarchy"}handle(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.contentServiceConfig.contentHeirarchyAPIPath+this.GET_CONTENT_HEIRARCHY_ENDPOINT+"/"+e.contentId).withBearerToken(!0).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>this.mapContentFromContentHeirarchyData(e.body.result.content)))}mapContentFromContentHeirarchyData(e){return e.contentData=Object.assign({},e),e.children&&e.children.length&&(e.children=e.children.map(e=>this.mapContentFromContentHeirarchyData(Object.assign({},e)))),e}}var Cs=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class vs{constructor(){}execute(e){return Cs(this,void 0,void 0,(function*(){const t=new a.CsResponse;return new Promise((n,r)=>{const i=e.destinationFolder.concat("tmp/");sbutility.rm(i,"",()=>{t.body=e,n(t)},r=>{t.body=e,n(t)})})}))}}var ys=n(33),ms=n(14),bs=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Is{constructor(e,t,n,r,i,o,s,a){this.searchContentHandler=e,this.formService=t,this.contentService=n,this.cachedItemStore=r,this.courseService=i,this.profileService=o,this.apiService=s,this.networkInfoService=a}static buildRequestHash(e){return ms(JSON.stringify(Qr.withDeeplyOrderedKeys(e))).toString()}aggregate(e,t,n,r,i=!1){return Object(c.defer)(()=>bs(this,void 0,void 0,(function*(){if(!n&&!r)throw new Error("formRequest or formFields required");let o=[];n?(n.from=e.from,o=yield this.formService.getForm(n).toPromise().then(e=>e.form.data.fields)):r&&(o=r,i=!1),o=o.filter(e=>-1===t.indexOf(e.dataSrc.type));const s=o.map(t=>bs(this,void 0,void 0,(function*(){if(!t.dataSrc)throw new Error("INVALID_CONFIG");switch(t.dataSrc.type){case"CONTENT_FACETS":return yield this.buildFacetsTask(t,e);case"RECENTLY_VIEWED_CONTENTS":return yield this.buildRecentlyViewedTask(t,e);case"CONTENTS":return yield this.buildContentSearchTask(t,e);case"TRACKABLE_COLLECTIONS":return yield this.buildTrackableCollectionsTask(t,e);case"CONTENT_DISCOVERY_BANNER":return yield this.buildContentDiscoveryBannerTask(t);default:return console.error("UNKNOWN_DATA_SRC"),{requestHash:"",task:Object(c.of)([])}}}))),a=yield Promise.all(s),u=a.map(e=>e.requestHash).join("-"),l=Object(c.defer)(()=>bs(this,void 0,void 0,(function*(){const e=yield this.networkInfoService.networkStatus$.pipe(Object(D.take)(1)).toPromise();if(i&&e===Vn.OFFLINE)throw new Error("ContentAggregator: offline request");return Promise.all(a.map(e=>e.task.toPromise())).then(e=>e.reduce((e,t)=>[...e,...t],[]).sort((e,t)=>e.index-t.index))})));return Object(c.defer)(()=>i?this.cachedItemStore.get(u,Is.CONTENT_AGGREGATION_KEY,"ttl_"+Is.CONTENT_AGGREGATION_KEY,()=>l):l).pipe(Object(D.map)(e=>({result:e}))).toPromise()})))}buildRecentlyViewedTask(e,t){return bs(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n={uid:t.managedSession?t.managedSession.uid:t.uid,primaryCategories:[],recentlyViewed:!0,limit:20};return{requestHash:"RECENTLY_VIEWED_CONTENTS_"+Is.buildRequestHash(n),task:Object(c.defer)(()=>bs(this,void 0,void 0,(function*(){const t=yield this.contentService.getContents(n).toPromise();return e.sections.map(n=>({index:n.index,title:n.title,data:{name:n.index+"",sections:[{name:n.index+"",count:t.length,contents:t.map(e=>(e.contentData.cardImg=e.contentData.appIcon,e))}]},dataSrc:e.dataSrc,theme:n.theme,description:n.description,landingDetails:n.landingDetails,isEnabled:n.isEnabled}))})))}}))}buildContentDiscoveryBannerTask(e){return bs(this,void 0,void 0,(function*(){return{requestHash:"CONTENT_DISCOVERY_BANNER"+Is.buildRequestHash(e.dataSrc.type),task:Object(c.defer)(()=>bs(this,void 0,void 0,(function*(){return e.sections.map(t=>({index:t.index,code:t.code,title:t.title,data:e.dataSrc.values.filter(e=>Number(e.expiry)>Math.floor(Date.now()/1e3)),dataSrc:e.dataSrc,theme:t.theme,description:t.description,landingDetails:t.landingDetails,isEnabled:t.isEnabled}))})))}}))}buildFacetsTask(e,t){return bs(this,void 0,void 0,(function*(){if(e.dataSrc.values)return{requestHash:"",task:Object(c.defer)(()=>bs(this,void 0,void 0,(function*(){return e.sections.map(t=>({index:t.index,code:t.code,title:t.title,data:e.dataSrc.values.sort((e,t)=>e.index-t.index),dataSrc:e.dataSrc,theme:t.theme,description:t.description,landingDetails:t.landingDetails,isEnabled:t.isEnabled}))})))};const{searchRequest:n,searchCriteria:r}=this.buildSearchRequestAndCriteria(e,t);return r.facets=e.dataSrc.mapping.map(e=>e.facet),n.facets=r.facets,n.limit=0,n.offset=0,{requestHash:"CONTENT_FACETS_"+Is.buildRequestHash(n),task:Object(c.defer)(()=>bs(this,void 0,void 0,(function*(){const i=yield this.searchContents(e,r,n);return e.sections.map((n,o)=>{var s,a,c;let u=null!==(s=i.filterCriteria.facetFilters)&&void 0!==s?s:[];const l=[];u.map(t=>{var n,r;const i=null===(r=null===(n=e.dataSrc.params)||void 0===n?void 0:n.config)||void 0===r?void 0:r.find(e=>e.name===t.name);i&&i.mergeableAttributes.map(e=>{l.push(e);const n=u.find(t=>t.name===e);t.values=t.values.filter(e=>i.values.find(t=>t.code===e.name.replace(/\s+/g,"").toLowerCase()));const r=i.values.filter(t=>t.type=e);n&&(n.values=n.values.filter(e=>r.find(t=>t.code===e.name.replace(/\s+/g,""))),t.values=t.values.concat(n.values))})}),u=u.filter(e=>-1===l.indexOf(e.name));const d=u.find(t=>{var n;return t.name===(null===(n=e.dataSrc.mapping[o])||void 0===n?void 0:n.facet)});if(d){const i=null===(c=null===(a=e.dataSrc.params)||void 0===a?void 0:a.config)||void 0===c?void 0:c.find(e=>e.name===d.name);return{index:n.index,title:n.title,code:n.code,data:d.values.map(t=>{var n;const s=i?i.values.find(e=>e.code===t.name.replace(/\s+/g,"").toLowerCase()):[];return{facet:(null==s?void 0:s.name)?s.name:t.name,searchCriteria:Object.assign(Object.assign({},r),{primaryCategories:[],impliedFilters:(null===(n=null==s?void 0:s.searchCriteria)||void 0===n?void 0:n.impliedFilters)?s.searchCriteria.impliedFilters:[{name:d.name,values:[{name:t.name,apply:!0}]}]}),aggregate:e.dataSrc.mapping[o].aggregate,filterPillBy:e.dataSrc.mapping[o].filterPillBy}}).sort((e,n)=>{if(t.userPreferences){const r=t.userPreferences[d.name];if(!r||Array.isArray(r)&&r.indexOf(e.facet)>-1&&r.indexOf(n.facet)>-1||r===e.facet&&r===n.facet)return e.facet.localeCompare(n.facet);if(Array.isArray(r)&&r.indexOf(e.facet)>-1||r===e.facet)return-1;if(Array.isArray(r)&&r.indexOf(n.facet)>-1||r===n.facet)return 1}return e.facet.localeCompare(n.facet)}),dataSrc:e.dataSrc,theme:n.theme,description:n.description,landingDetails:n.landingDetails,isEnabled:n.isEnabled}}return{index:n.index,title:n.title,code:n.code,data:[],dataSrc:e.dataSrc,theme:n.theme,description:n.description,isEnabled:n.isEnabled}})})))}}))}buildTrackableCollectionsTask(e,t){return bs(this,void 0,void 0,(function*(){const t=this.apiService,n=yield this.profileService.getActiveProfileSession().toPromise();return{requestHash:"TRACKABLE_COLLECTIONS_"+Is.buildRequestHash({userId:n.managedSession?n.managedSession.uid:n.uid}),task:Object(c.defer)(()=>bs(this,void 0,void 0,(function*(){const r=yield this.courseService.getEnrolledCourses({userId:n.managedSession?n.managedSession.uid:n.uid,returnFreshCourses:!0},new class{handle({userId:n}){e.dataSrc.request.path&&(e.dataSrc.request.path=e.dataSrc.request.path.replace("${userId}",n));const r=a.CsRequest.fromJSON(e.dataSrc.request);return t.fetch(r).pipe(Object(D.map)(e=>e.body))}}).toPromise();return e.sections.map((t,n)=>{if(e.dataSrc.mapping[n]&&e.dataSrc.mapping[n].aggregate){const i=e.dataSrc.mapping[n].aggregate;return{index:t.index,title:t.title,data:ys.CsContentsGroupGenerator.generate({contents:r,groupBy:i.groupBy,sortBy:i.sortBy?this.buildSortByCriteria(i.sortBy):[],filterBy:i.filterBy?this.buildFilterByCriteria(i.filterBy):[],groupSortBy:i.groupSortBy?this.buildSortByCriteria(i.groupSortBy):[],groupFilterBy:i.groupFilterBy?this.buildFilterByCriteria(i.groupFilterBy):[],includeSearchable:!1}),dataSrc:e.dataSrc,theme:t.theme,description:t.description,landingDetails:t.landingDetails,isEnabled:t.isEnabled}}return{index:t.index,title:t.title,data:{name:t.index+"",sections:[{name:t.index+"",count:r.length,contents:r}]},dataSrc:e.dataSrc,theme:t.theme,description:t.description,landingDetails:t.landingDetails,isEnabled:t.isEnabled}})})))}}))}buildContentSearchTask(e,t){return bs(this,void 0,void 0,(function*(){const{searchRequest:n,searchCriteria:r}=this.buildSearchRequestAndCriteria(e,t);return{requestHash:"CONTENTS_"+Is.buildRequestHash(n),task:Object(c.defer)(()=>bs(this,void 0,void 0,(function*(){const i=yield(()=>bs(this,void 0,void 0,(function*(){return n.filters&&n.filters.primaryCategory||r.primaryCategories&&0===r.primaryCategories.length?[]:this.contentService.getContents({primaryCategories:r.primaryCategories&&r.primaryCategories.length&&r.primaryCategories||n.filters&&n.filters.primaryCategory||[],board:r.board,medium:r.medium,grade:r.grade}).pipe(Object(D.map)(e=>e.map(e=>(e.contentData.appIcon&&!e.contentData.appIcon.startsWith("https://")&&(e.contentData.appIcon=e.basePath+e.contentData.appIcon),e.contentData)))).toPromise()})))(),o=yield this.searchContents(e,r,n),s=(o.contentDataList||[]).filter(e=>!i.find(t=>t.identifier===e.identifier)),a=i.concat(s).map(e=>(e.cardImg=e.appIcon,e));return a.sort((e,t)=>e.lastPublishedOn>t.lastPublishedOn?-1:1),e.sections.map((i,s)=>{if(e.dataSrc.mapping[s]&&e.dataSrc.mapping[s].aggregate){const c=e.dataSrc.mapping[s].aggregate,u=(()=>{const n=ys.CsContentsGroupGenerator.generate({contents:a,groupBy:c.groupBy,sortBy:c.sortBy?this.buildSortByCriteria(c.sortBy):[],filterBy:c.filterBy?this.buildFilterByCriteria(c.filterBy):[],groupSortBy:c.groupSortBy?this.buildSortByCriteria(c.groupSortBy):[],groupFilterBy:c.groupFilterBy?this.buildFilterByCriteria(c.groupFilterBy):[],combination:e.dataSrc.mapping[s].applyFirstAvailableCombination&&t.applyFirstAvailableCombination,includeSearchable:!1});if(t.userPreferences&&t.userPreferences[c.groupBy]&&n.sections.sort((e,n)=>t.userPreferences[c.groupBy].indexOf(e.name.replace(/[^A-Z0-9]/gi,"").toLocaleLowerCase())>-1&&t.userPreferences[c.groupBy].indexOf(n.name.replace(/[^A-Z0-9]/gi,"").toLocaleLowerCase())>-1?e.name.localeCompare(n.name):t.userPreferences[c.groupBy].indexOf(e.name.replace(/[^A-Z0-9]/gi,"").toLocaleLowerCase())>-1?-1:t.userPreferences[c.groupBy].indexOf(n.name.replace(/[^A-Z0-9]/gi,"").toLocaleLowerCase())>-1?1:0),n.name){(o.filterCriteria.facetFilters||[]).map(e=>{let t=e.name==n.name?e.values:[];return n.sections.filter(e=>t.some(t=>(e.name.toLocaleLowerCase()===t.name.toLowerCase()&&(e.totalCount=t.count),e.name===t.name)))})}return n})();return{index:i.index,title:i.title,meta:{searchCriteria:r,filterCriteria:o.filterCriteria,searchRequest:n},data:u,dataSrc:e.dataSrc,theme:i.theme,description:i.description,landingDetails:i.landingDetails,isEnabled:i.isEnabled}}return{index:i.index,title:i.title,meta:{searchCriteria:r,filterCriteria:o.filterCriteria,searchRequest:n},data:{name:i.index+"",sections:[{count:a.length,contents:a}]},dataSrc:e.dataSrc,theme:i.theme,description:i.description,landingDetails:i.landingDetails,isEnabled:i.isEnabled}})})))}}))}buildFilterByCriteria(e){return e.reduce((e,t)=>(Object.keys(t).forEach(n=>e.push({filterAttribute:n,filterCondition:{operation:t[n].operation,value:t[n].value}})),e),[])}buildSortByCriteria(e){return e.reduce((e,t)=>(Object.keys(t).forEach(n=>e.push({sortAttribute:n,sortOrder:t[n]})),e),[])}buildSearchRequestAndCriteria(e,t){const n=e=>this.searchContentHandler.getSearchCriteria(e),r=e.dataSrc.request&&e.dataSrc.request.body?Object.assign({filters:{}},e.dataSrc.request.body.request):{filters:{}},i=t.interceptSearchCriteria?t.interceptSearchCriteria(n({request:r})):n({request:r});return{searchRequest:(e=>this.searchContentHandler.getSearchContentRequest(e))(i),searchCriteria:i}}searchContents(e,t,n){const r=this.apiService;return this.contentService.searchContent(t,void 0,new class{handle(t){if(n&&n.filters&&n.filters.mimeType){const e=(e,t)=>Dn.MimeTypeCategoryMapping[t]?e.concat(Dn.MimeTypeCategoryMapping[t]):e.concat([t]);n.filters.mimeType=n.filters.mimeType.reduce(e,[])}e.dataSrc.request&&e.dataSrc.request.body&&e.dataSrc.request.body.request?e.dataSrc.request.body={request:Object.assign(Object.assign({},e.dataSrc.request.body.request),n)}:e.dataSrc.request.body={request:n};const i=JSON.stringify(Qr.withDeeplyOrderedKeys(e.dataSrc.request));if(Is.searchContentCache.has(i))return Object(c.of)(Is.searchContentCache.get(i)).pipe(Object(D.map)(e=>e.body));const o=a.CsRequest.fromJSON(e.dataSrc.request);return r.fetch(o).pipe(Object(D.tap)(e=>{Is.searchContentCache.set(i,e)}),Object(D.map)(e=>e.body))}},!0).pipe(Object(D.catchError)(e=>(console.error(e),Object(c.of)({id:"OFFLINE_RESPONSE_ID",responseMessageId:"OFFLINE_RESPONSE_ID",filterCriteria:t,contentDataList:[]})))).toPromise()}}Is.searchContentCache=new Map,Is.CONTENT_AGGREGATION_KEY="content-aggregation";var Ms=n(50),Rs=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ls{constructor(e,t){this.storageService=e,this.fileService=t}getLocallyAvailableQuestion(e,t){const n=this.storageService.getStorageDestinationDirectoryPath();let r=[];return e.forEach(e=>Rs(this,void 0,void 0,(function*(){const i=this.fileService.readAsText("ios"===window.device.platform.toLowerCase()?`${n}/content/${t}/${e}`:`${n}content/${t}/${e}`,"index.json");r.push(i)}))),Object(c.from)(Promise.all(r)).pipe(Object(D.map)(e=>({questions:e.map(e=>{if(e&&"string"==typeof e){return JSON.parse(e).archive.items[0]}return e}),count:e.length})))}}var Ps=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Ds=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,i){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,i,(t=e[n](t)).done,t.value)}))}}};class ws{constructor(e,t,n,r){this.contentService=e,this.dbService=t,this.storageService=n,this.fileService=r}handle(e){return Ps(this,void 0,void 0,(function*(){const t=this.getQuery(e);let n;if(n=yield this.getQuestionSetFromQuery(t),!n||!n.isAvailableLocally)return yield this.fetchServerChildQuestions(e);if(!n.children)return[];const r=this.storageService.getStorageDestinationDirectoryPath();try{n=yield this.fetchDBChildQuestions(n,r)}catch(e){return n.children}return n.children}))}fetchDBChildQuestions(e,t){var n,r;return Ps(this,void 0,void 0,(function*(){if(!e||!e.children)return e;const i=[];try{for(var o,s=Ds(e.children);!(o=yield s.next()).done;){const n=o.value;if("QuestionSet"===n.objectType){let e;const r=this.getQuery(n.identifier);e=yield this.getQuestionSetFromQuery(r),e&&e.children&&(e=yield this.fetchDBChildQuestions(e,t),i.push(e))}else if("Question"===n.objectType){const r=yield this.fileService.readAsText(`${t}content/${e.identifier}/${n.identifier}`,"index.json");if(r&&"string"==typeof r){const e=JSON.parse(r);e&&e.archive&&e.archive.items.length&&i.push(e.archive.items[0])}}}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=s.return)&&(yield r.call(s))}finally{if(n)throw n.error}}return e.children=i,e}))}getQuery(e){return`SELECT * FROM ${St.TABLE_NAME} WHERE (${St.COLUMN_NAME_IDENTIFIER} = '${e}')`}getQuestionSetFromQuery(e){return Ps(this,void 0,void 0,(function*(){try{const t=yield this.dbService.execute(e).toPromise();if(t&&t.length&&t[0][St.COLUMN_NAME_LOCAL_DATA]){const e=JSON.parse(t[0][St.COLUMN_NAME_LOCAL_DATA]);return e.isAvailableLocally=kn.isAvailableLocally(t[0][St.COLUMN_NAME_CONTENT_STATE]),e}return null}catch(e){return null}}))}fetchServerChildQuestions(e){return Ps(this,void 0,void 0,(function*(){const t=yield this.contentService.getQuestionSetHierarchy(e).toPromise();return t&&t.questionset&&t.questionset.children?t.questionset.children:[]}))}}var Us,js=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Fs=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ks=function(e,t){return function(n,r){t(n,r,e)}},xs=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let Bs=Us=class{constructor(e,t,n,r,i,o,s,a,c,u,l,d,h,E,f,p,_){this.sdkConfig=e,this.apiService=t,this.dbService=n,this.profileService=r,this.fileService=i,this.zipService=o,this.deviceInfo=s,this.telemetryService=a,this.contentFeedbackService=c,this.downloadService=u,this.sharedPreferences=l,this.eventsBusService=d,this.cachedItemStore=h,this.appInfo=E,this.networkInfoService=f,this.container=p,this.storageService=_,this.contentUpdateSizeOnDeviceTimeoutRef=new Map,this.contentServiceConfig=this.sdkConfig.contentServiceConfig,this.appConfig=this.sdkConfig.appConfig,this.getContentDetailsHandler=new yo(this.contentFeedbackService,this.profileService,this.apiService,this.contentServiceConfig,this.dbService,this.eventsBusService),this.getContentHeirarchyHandler=new Ts(this.apiService,this.contentServiceConfig),this.questionSetFileReadHandler=new Ls(this.storageService,this.fileService),this.getChildQuestionSetHandler=new ws(this,this.dbService,this.storageService,this.fileService),this.contentDeleteRequestSet=new gs(this.sharedPreferences,Us.KEY_CONTENT_DELETE_REQUEST_LIST,e=>e.contentId)}onInit(){return this.downloadService.registerOnDownloadCompleteDelegate(this),Object(c.combineLatest)([this.handleContentDeleteRequestSetChanges(),this.handleUpdateSizeOnDeviceFail()]).pipe(Object(D.mapTo)(void 0))}getContentDetails(e){return this.getContentDetailsHandler.handle(e)}getContentHeirarchy(e){return this.getContentHeirarchyHandler.handle(e)}getContents(e){const t=(new wo).getAllLocalContentQuery(e);return this.dbService.execute(t).pipe(Object(D.mergeMap)(t=>Object(c.defer)(()=>xs(this,void 0,void 0,(function*(){const n=[];for(const r of t){let t=xn.mapContentDBEntryToContent(r);t=yield this.getContentDetailsHandler.decorateContent({content:t,attachContentAccess:e.attachContentAccess,attachContentMarker:e.attachContentAccess,attachFeedback:e.attachFeedback}).toPromise(),n.push(t)}if(e.resourcesOnly){const t=e.uid,r=`SELECT * FROM ${vt.TABLE_NAME}\n WHERE UID IN (${wn.joinPreservingQuotes(t)})`;(yield this.dbService.execute(r).toPromise()).forEach(e=>{const t={identifier:e[vt.COLUMN_NAME_CONTENT_IDENTIFIER],name:"",contentData:e[vt.COLUMN_NAME_DATA]&&JSON.parse(e[vt.COLUMN_NAME_DATA]),isUpdateAvailable:!1,mimeType:"",basePath:"",contentType:"",primaryCategory:"",isAvailableLocally:!1,referenceCount:0,sizeOnDevice:0,lastUsedTime:0,lastUpdatedTime:0};n.push(t)})}return n})))))}cancelImport(e){return this.downloadService.cancel({identifier:e})}deleteContent(e){return Object(c.defer)(()=>xs(this,void 0,void 0,(function*(){e.contentDeleteList.forEach(e=>{const t=this.contentUpdateSizeOnDeviceTimeoutRef.get(e.contentId);t&&(clearTimeout(t),this.contentUpdateSizeOnDeviceTimeoutRef.delete(e.contentId))});const t=[],n=new Lo(this.dbService,this.fileService,this.sharedPreferences);for(const r of e.contentDeleteList){const e=yield this.getContentDetailsHandler.fetchFromDB(r.contentId).toPromise();e?(t.push({identifier:r.contentId,status:_n.DELETED_SUCCESSFULLY}),kn.hasChildren(e[St.COLUMN_NAME_LOCAL_DATA])&&(yield n.deleteAllChildren(e,r.isChildContent)),yield n.deleteOrUpdateContent(e,!1,r.isChildContent)):t.push({identifier:r.contentId,status:_n.NOT_FOUND})}return new ns(this.dbService,this.sharedPreferences,this.fileService).execute(),t}))).pipe(Object(D.tap)(()=>e.contentDeleteList.forEach(e=>{this.downloadService.onContentDelete(e.contentId)})))}enqueueContentDelete(e){return this.contentDeleteRequestSet.addAll(e.contentDeleteList)}clearContentDeleteQueue(){return this.contentDeleteRequestSet.clear()}getContentDeleteQueue(){return this.contentDeleteRequestSet.asListChanges()}exportContent(e){const t=new xo(this.deviceInfo,this.dbService,this.fileService);return Object(c.from)(t.getContentExportDBModelToExport(e.contentIds).then(n=>this.fileService.getTempLocation(e.destinationFolder).then(t=>{const r={},i=kn.getExportedFileName(n,this.appInfo.getAppName());r.content_count=n.length;const o={metadata:r,ecarFilePath:t.nativeURL.concat(i),destinationFolder:e.destinationFolder,contentModelsToExport:n,tmpLocationPath:t.nativeURL,subContentIds:e.subContentIds};return new hs(this.fileService).execute(o)}).then(e=>new Bo(this.dbService,t).execute(e.body)).then(e=>new Vo(this.fileService,this.deviceInfo).execute(e.body)).then(e=>new Go(this.zipService).execute(e.body)).then(e=>new $o(this.fileService).execute(e.body)).then(e=>(new Ko).execute(e.body)).then(e=>new Wo(this.fileService,this.zipService).execute(e.body)).then(t=>(new Ns).execute(t,e)).then(e=>(new vs).execute(e.body)).then(t=>{const r=kn.getExportedFileName(n,this.appInfo.getAppName());return new ps(this.telemetryService).execute(t.body,r,e)}).then(e=>e.body)))}getChildContents(e){e.level||(e.level=-1);const t=new Io(this.dbService,this.getContentDetailsHandler,this.appConfig);let n=e.hierarchyInfo;if(n){if(n.length>0&&n[n.length-1].identifier===e.contentId){const e=n.length;n.splice(e-1,1)}}else n=[];return this.dbService.read(yo.getReadContentQuery(e.contentId)).pipe(Object(D.mergeMap)(r=>xs(this,void 0,void 0,(function*(){const i=new Map,o=JSON.parse(r[0][St.COLUMN_NAME_LOCAL_DATA]).childNodes;if(console.log("childIdentifiers",o),o){const e=`SELECT * FROM ${St.TABLE_NAME}\n WHERE ${St.COLUMN_NAME_IDENTIFIER}\n IN (${wn.joinPreservingQuotes(o)})`;(yield this.dbService.execute(e).toPromise()).forEach(e=>{i.set(e.identifier,e)})}let s=yield t.fetchChildrenOfContent(r[0],i,0,e.level,n);return console.log("childContentHandler-",s),s}))))}getDownloadState(){throw new Error("Not Implemented yet")}importContent(e){const t=new Do(this.appConfig,this.contentServiceConfig,this.telemetryService),n=wn.deDupe(e.contentImportArray.map(e=>e.contentId)),r=t.getContentSearchFilter(n,e.contentStatusArray,e.fields);return new Es(this.apiService,this.contentServiceConfig).handle(r).pipe(Object(D.map)(e=>e.result.content&&e.result.content.length&&e.result.QuestionSet&&e.result.QuestionSet.length?e.result.content.concat(e.result.QuestionSet):e.result.content||e.result.QuestionSet),Object(D.mergeMap)(r=>Object(c.defer)(()=>xs(this,void 0,void 0,(function*(){const i=[];if(r&&r.length){const o=[];for(const s of n){const n=r.find(e=>e.identifier===s);if(n){const r=e.contentImportArray.find(e=>e.contentId===s),a=yield t.getDownloadUrl(n,r);let c=In.NOT_FOUND;if(a&&Mo.getFileExtension(a)===bn.CONTENT.valueOf()){c=In.ENQUEUED_FOR_DOWNLOAD;const t={identifier:s,downloadUrl:a,mimeType:Tn.ECAR,destinationFolder:r.destinationFolder,isChildContent:r.isChildContent,filename:s.concat(".",bn.CONTENT),correlationData:r.correlationData,rollUp:r.rollUp,contentMeta:n,withPriority:e.withPriority||(n.mimeType===Tn.COLLECTION.valueOf()?1:0),title:n.name?n.name.concat(".",bn.CONTENT):s.concat(".",bn.CONTENT)};o.push(t),console.log("downloadRequestList-",o)}i.push({identifier:s,status:c})}}this.downloadService.download(o).toPromise().then()}return i})))))}importEcar(e){return Object(c.from)(this.fileService.exists(e.sourceFilePath).then(t=>{const n={isChildContent:e.isChildContent,ecarFilePath:e.sourceFilePath,destinationFolder:e.destinationFolder,skippedItemsIdentifier:[],items:[],contentImportResponseList:[],correlationData:e.correlationData||[],rollUp:e.rollUp||new Te,contentIdsToDelete:new Set,identifier:e.identifier};return new _s(this.telemetryService).execute(n,"ContentImport-Initiated").then(()=>this.fileService.getTempLocation(e.destinationFolder)).then(e=>(n.tmpLocation=e.nativeURL,new Jo(this.fileService,this.zipService).execute(n))).then(e=>new es(this.fileService,this.dbService,this.appConfig,this.getContentDetailsHandler).execute(e.body)).then(e=>new ss(this.fileService,this.zipService,this.appConfig,this.dbService,this.deviceInfo,this.getContentDetailsHandler,this.eventsBusService,this.sharedPreferences).execute(e.body)).then(([e,t])=>{this.contentUpdateSizeOnDeviceTimeoutRef.set(n.rootIdentifier?n.rootIdentifier:n.identifiers[0],t),this.eventsBusService.emit({namespace:M.CONTENT,event:{type:Pn.CONTENT_EXTRACT_COMPLETED,payload:{contentId:n.rootIdentifier?n.rootIdentifier:n.identifiers[0]}}});new a.CsResponse;return new ls(this.dbService,this.deviceInfo,this.fileService).execute(e.body)}).then(e=>new ds(this.fileService).execute(e.body)).then(e=>{const t=new a.CsResponse;return this.cleanupContent(n).toPromise().then(()=>(t.body=n,Promise.resolve(t))).catch(()=>Promise.reject(t))}).then(e=>new fs(this.telemetryService).execute(e.body)).then(e=>new _s(this.telemetryService).execute(e.body,"ContentImport-Success")).then(e=>(this.eventsBusService.emit({namespace:M.CONTENT,event:{type:Pn.IMPORT_COMPLETED,payload:{contentId:n.rootIdentifier?n.rootIdentifier:n.identifiers[0]}}}),e.body.contentImportResponseList))}).catch(e=>(console.log("error",e),[{identifier:"",status:In.NOT_FOUND}])))}nextContent(e,t,n){const r=new Io(this.dbService,this.getContentDetailsHandler,this.appConfig);return this.dbService.read(yo.getReadContentQuery(e[0].identifier)).pipe(Object(D.mergeMap)(i=>xs(this,void 0,void 0,(function*(){const o=yield r.getContentsKeyList(i[0]),s=r.getNextContentIdentifier(e,t,o);return r.getContentFromDB(e,s,n)}))))}prevContent(e,t,n){const r=new Io(this.dbService,this.getContentDetailsHandler,this.appConfig);return this.dbService.read(yo.getReadContentQuery(e[0].identifier)).pipe(Object(D.mergeMap)(i=>xs(this,void 0,void 0,(function*(){const o=yield r.getContentsKeyList(i[0]),s=r.getPreviousContentIdentifier(e,t,o);return r.getContentFromDB(e,s,n)}))))}getRelevantContent(e){const t={};return Object(c.of)(t).pipe(Object(D.mergeMap)(n=>e.next?this.nextContent(e.hierarchyInfo,e.contentIdentifier,e.shouldConvertBasePath).pipe(Object(D.map)(e=>(t.nextContent=e,t))):Object(c.of)(t)),Object(D.mergeMap)(n=>e.prev?this.prevContent(e.hierarchyInfo,e.contentIdentifier,e.shouldConvertBasePath).pipe(Object(D.map)(e=>(t.previousContent=e,t))):Object(c.of)(t)),Object(D.map)(e=>{const t={};return t.next=e.nextContent?{content:e.nextContent}:void 0,t.prev=e.previousContent?{content:e.previousContent}:void 0,t}))}subscribeForImportStatus(e){throw new Error("Not Implemented yet")}searchContent(e,t,n,r){if((e=JSON.parse(JSON.stringify(e))).facetFilters){const t=e.facetFilters.find(e=>"mimeType"===e.name);t&&(t.values=t.values.filter(e=>e.apply).reduce((e,t)=>e=e.concat(t.values.map(e=>Object.assign(Object.assign({},e),{apply:!0}))),[]))}const i=new Do(this.appConfig,this.contentServiceConfig,this.telemetryService),o=e.languageCode;t?(e=i.getSearchCriteria(t),o&&(e.languageCode=o)):(e.limit=e.limit?e.limit:100,e.offset=e.offset?e.offset:0);const s=i.getSearchContentRequest(e);return this.sharedPreferences.getString(_.KEY_ACTIVE_CHANNEL_ACTIVE_FRAMEWORK_ID).pipe(Object(D.mergeMap)(t=>(n||(n=new Es(this.apiService,this.contentServiceConfig,t,e.languageCode)),n.handle(s).pipe(Object(D.map)(t=>(e.facetFilters||e.searchType!==gn.SEARCH||(r||(s.filters.contentType=[],s.filters.primaryCategory=[]),s.filters.audience=[]),i.mapSearchResponse(e,t,s))),Object(D.map)(t=>{if(!t.filterCriteria.facetFilters)return t;const n=t.filterCriteria.facetFilters.find(e=>"mimeType"===e.name);return n&&(n.values=Ms.CsMimeTypeFacetToMimeTypeCategoryAggregator.aggregate(n.values,"filter"===e.searchType?[Dn.MimeTypeCategory.ALL]:[])),t})))))}cancelDownload(e){return this.downloadService.cancel({identifier:e})}setContentMarker(e){const t=`SELECT * FROM ${vt.TABLE_NAME}\n WHERE ${vt.COLUMN_NAME_UID} = '${e.uid}'\n AND ${vt.COLUMN_NAME_CONTENT_IDENTIFIER}='${e.contentId}'\n AND ${vt.COLUMN_NAME_MARKER} = ${e.marker}`;return this.dbService.execute(t).pipe(Object(D.mergeMap)(t=>{const n={uid:e.uid,identifier:e.contentId,epoch_timestamp:Date.now(),data:e.data,extra_info:JSON.stringify(e.extraInfo),marker:e.marker.valueOf(),mime_type:this.getMimeType(e.data)};return wn.isEmpty(t)?this.dbService.insert({table:vt.TABLE_NAME,modelJson:n}).pipe(Object(D.map)(e=>e>0)):e.isMarked?this.dbService.update({table:vt.TABLE_NAME,selection:`${vt.COLUMN_NAME_UID}= ? AND ${vt.COLUMN_NAME_CONTENT_IDENTIFIER}= ? AND ${vt.COLUMN_NAME_MARKER}= ?`,selectionArgs:[e.uid,e.contentId,e.marker.valueOf().toString()],modelJson:n}).pipe(Object(D.map)(e=>e>0)):this.dbService.delete({table:vt.TABLE_NAME,selection:`${vt.COLUMN_NAME_UID} = ? AND ${vt.COLUMN_NAME_CONTENT_IDENTIFIER} = ? AND ${vt.COLUMN_NAME_MARKER} = ?`,selectionArgs:[e.uid,e.contentId,""+e.marker]}).pipe(Object(D.map)(e=>e))}))}onDownloadCompletion(e){const t={isChildContent:e.isChildContent,sourceFilePath:e.downloadedFilePath,destinationFolder:e.destinationFolder,correlationData:e.correlationData,rollUp:e.rollUp,identifier:e.identifier};return this.importEcar(t).pipe(Object(D.mergeMap)(()=>this.downloadService.cancel({identifier:e.identifier},!1)),Object(D.catchError)(()=>this.downloadService.cancel({identifier:e.identifier},!1)),Object(D.mapTo)(void 0))}getContentSpaceUsageSummary(e){const t=new Ss(this.dbService);return Object(c.from)(t.getContentUsageSummary(e.paths))}buildContentAggregator(e,t,n){return new Is(new Do(this.appConfig,this.contentServiceConfig,this.telemetryService),e,this,this.cachedItemStore,t,n,this.apiService,this.networkInfoService)}getQuestionList(e,t){return this.getContentDetails({contentId:t,objectType:"QuestionSet"}).pipe(Object(D.switchMap)(n=>n.isAvailableLocally&&t?this.questionSetFileReadHandler.getLocallyAvailableQuestion(e,t):this.contentServiceDelegate.getQuestionList(e)),Object(D.catchError)(t=>this.contentServiceDelegate.getQuestionList(e)))}getQuestionSetHierarchy(e){return this.contentServiceDelegate.getQuestionSetHierarchy(e)}getQuestionSetRead(e,t){return this.contentServiceDelegate.getQuestionSetRead(e,t)}getQuestionSetChildren(e){return xs(this,void 0,void 0,(function*(){try{return yield this.getChildQuestionSetHandler.handle(e)}catch(e){return[]}}))}formatSearchCriteria(e){return new Do(this.appConfig,this.contentServiceConfig,this.telemetryService).getSearchCriteria(e)}cleanupContent(e){const t=[];for(const n of Array.from(e.contentIdsToDelete.values())){const e={contentId:n,isChildContent:!1};t.push(e)}return this.deleteContent({contentDeleteList:t}).pipe(Object(D.mapTo)(void 0))}getMimeType(e){let t="";if(e){t=JSON.parse(e).mimeType}return t}handleContentDeleteRequestSetChanges(){return this.contentDeleteRequestSet.asListChanges().pipe(Object(D.mergeMap)(e=>{const t=e[0];return t?this.deleteContent({contentDeleteList:[t]}).pipe(Object(D.mergeMap)(()=>this.contentDeleteRequestSet.remove(t)),Object(D.mapTo)(void 0)):Object(c.of)(void 0)}))}handleUpdateSizeOnDeviceFail(){return this.sharedPreferences.getBoolean(Us.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL).pipe(Object(D.mergeMap)(e=>e?Object(c.of)(void 0):Object(c.from)(new ns(this.dbService,this.sharedPreferences,this.fileService).execute()).pipe(Object(D.mapTo)(void 0))))}get contentServiceDelegate(){return this.container.get(u.CONTENT_SERVICE)}downloadTranscriptFile(e){const t="ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalDataDirectory+Us.DOWNLOAD_DIR_NAME;return this.createTranscriptDir(e,t).then(()=>{const n={uri:e.downloadUrl,title:e.fileName,description:"",mimeType:"",visibleInDownloadsUi:!0,notificationVisibility:1,destinationInExternalPublicDir:{dirType:"Download",subPath:e.fileName},headers:[],destinationUri:e.destinationUrl};return this.downloadTranscript(n).toPromise().then(n=>{if(n&&n.path)return this.copyFile(n.path.split(/\/(?=[^\/]+$)/)[0],t.concat("/"+e.identifier),e.fileName).then(()=>{this.deleteFolder(n.path)}),n.path})})}createTranscriptDir(e,t){return this.fileService.exists(t.concat("/"+e.identifier)).then(e=>e.nativeURL).catch(()=>this.fileService.createDir(t,!1).then(n=>{this.fileService.createDir(t.concat("/"+e.identifier),!1).then(e=>e.nativeURL)}))}downloadTranscript(e){return new c.Observable(t=>{downloadManager.enqueue(e,(e,n)=>{if(e)return t.error(e);t.next(n),t.complete()})}).pipe(Object(D.mergeMap)(e=>Object(c.interval)(1e3).pipe(Object(D.mergeMap)(()=>new c.Observable(t=>{downloadManager.query({ids:[e]},(e,n)=>e||16===n[0].status?t.error(e||new Error("Unknown Error")):t.next(n[0]))})),Object(D.filter)(e=>8===e.status),Object(D.take)(1))),Object(D.map)(e=>({path:e.localUri})))}copyFile(e,t,n){return xs(this,void 0,void 0,(function*(){return new Promise((r,i)=>{sbutility.copyFile(e,t,n,()=>{r(!0)},e=>{console.error(e),r(e)})})}))}deleteFolder(e){return xs(this,void 0,void 0,(function*(){if(!e)return;return new Promise((t,n)=>{sbutility.rm(e,"",()=>{t(void 0)},e=>{n(e)})})}))}};Bs.DOWNLOAD_DIR_NAME="transcript",Bs.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL=S.KEY_IS_UPDATE_SIZE_ON_DEVICE_SUCCESSFUL,Bs.KEY_CONTENT_DELETE_REQUEST_LIST=S.KEY_CONTENT_DELETE_REQUEST_LIST,Bs=Us=js([Object(s.injectable)(),ks(0,Object(s.inject)(l.SDK_CONFIG)),ks(1,Object(s.inject)(l.API_SERVICE)),ks(2,Object(s.inject)(l.DB_SERVICE)),ks(3,Object(s.inject)(l.PROFILE_SERVICE)),ks(4,Object(s.inject)(l.FILE_SERVICE)),ks(5,Object(s.inject)(l.ZIP_SERVICE)),ks(6,Object(s.inject)(l.DEVICE_INFO)),ks(7,Object(s.inject)(l.TELEMETRY_SERVICE)),ks(8,Object(s.inject)(l.CONTENT_FEEDBACK_SERVICE)),ks(9,Object(s.inject)(l.DOWNLOAD_SERVICE)),ks(10,Object(s.inject)(l.SHARED_PREFERENCES)),ks(11,Object(s.inject)(l.EVENTS_BUS_SERVICE)),ks(12,Object(s.inject)(l.CACHED_ITEM_STORE)),ks(13,Object(s.inject)(l.APP_INFO)),ks(14,Object(s.inject)(l.NETWORKINFO_SERVICE)),ks(15,Object(s.inject)(l.CONTAINER)),ks(16,Object(s.inject)(l.STORAGE_SERVICE)),Fs("design:paramtypes",[Object,Object,o,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,s.Container,Object])],Bs);var Vs=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ys=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Gs=function(e,t){return function(n,r){t(n,r,e)}};let Hs=class{constructor(e){this.dbService=e}getValue(e){return this.dbService.read({table:It.TABLE_NAME,columns:[],selection:It.COLUMN_NAME_KEY+" = ?",selectionArgs:[e]}).pipe(Object(D.map)(e=>e[0]&&e[0].value))}setValue(e,t){return this.getValue(e).pipe(Object(D.mergeMap)(n=>n?this.dbService.update({table:It.TABLE_NAME,selection:It.COLUMN_NAME_KEY+" = ?",selectionArgs:[e],modelJson:{[It.COLUMN_NAME_KEY]:e,[It.COLUMN_NAME_VALUE]:t}}).pipe(Object(D.map)(e=>e>0)):this.dbService.insert({table:It.TABLE_NAME,modelJson:{[It.COLUMN_NAME_KEY]:e,[It.COLUMN_NAME_VALUE]:t}}).pipe(Object(D.map)(e=>e>0))))}};Hs=Vs([Object(s.injectable)(),Gs(0,Object(s.inject)(l.DB_SERVICE)),Ys("design:paramtypes",[o])],Hs);class $s{constructor(e,t,n,r){this.apiService=e,this.formServiceConfig=t,this.fileService=n,this.cachedItemStore=r,this.FORM_FILE_KEY_PREFIX="form-",this.FORM_LOCAL_KEY="form-",this.GET_FORM_DETAILS_ENDPOINT="/read"}static getIdForRequest(e){let t=`${e.type}_${e.subType}_${e.action}`;return e.rootOrgId&&"*"!==e.rootOrgId&&(t+="_"+e.rootOrgId),e.framework&&(t+="_"+e.framework),e.component&&(t+="_"+e.component),t}handle(e){return this.cachedItemStore[e.from===Jn.SERVER?"get":"getCached"]($s.getIdForRequest(e),this.FORM_LOCAL_KEY,"ttl_"+this.FORM_LOCAL_KEY,()=>this.fetchFormServer(e),()=>this.fetchFromFile(e))}fetchFormServer(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.formServiceConfig.apiPath+this.GET_FORM_DETAILS_ENDPOINT).withBearerToken(!0).withHeaders({"X-Platform-Id":window.device.platform}).withBody({request:e}).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result))}fetchFromFile(e){const t=lr.getAssetPath()+this.formServiceConfig.formConfigDirPath,n=this.FORM_FILE_KEY_PREFIX+$s.getIdForRequest(e)+".json";return Object(c.from)(this.fileService.readFileFromAssets(t.concat("/",n))).pipe(Object(D.map)(e=>JSON.parse(e).result))}}var qs=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ks=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},zs=function(e,t){return function(n,r){t(n,r,e)}};let Ws=class{constructor(e,t,n,r){this.sdkConfig=e,this.apiService=t,this.fileService=n,this.cachedItemStore=r,this.formServiceConfig=this.sdkConfig.formServiceConfig}getForm(e){return new $s(this.apiService,this.formServiceConfig,this.fileService,this.cachedItemStore).handle(e)}};Ws=qs([Object(s.injectable)(),zs(0,Object(s.inject)(l.SDK_CONFIG)),zs(1,Object(s.inject)(l.API_SERVICE)),zs(2,Object(s.inject)(l.FILE_SERVICE)),zs(3,Object(s.inject)(l.CACHED_ITEM_STORE)),Ks("design:paramtypes",[Object,Object,Object,Object])],Ws);var Xs,Js=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Qs=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Zs=function(e,t){return function(n,r){t(n,r,e)}},ea=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let ta=Xs=class{constructor(e,t,n){this.sdkConfig=e,this.keyValueStore=t,this.sharedPreferences=n,this.apiConfig=this.sdkConfig.apiConfig}static isItemEmpty(e){return!(!Array.isArray(e)||0!==e.length)||"object"==typeof e&&0===Object.keys(e).length}get(e,t,n,r,i,o,s){return r().pipe(Object(D.tap)(r=>{this.saveItemTTL(e,n).toPromise(),this.saveItemToDb(e,t,r).toPromise()}),Object(D.catchError)(()=>this.getCached(e,t,n,r,i,o,s)))}getCached(e,t,n,r,i,o,s){return this.isItemCachedInDb(n,e).pipe(Object(D.mergeMap)(a=>a?this.isItemTTLExpired(n,e,isNaN(o)?this.apiConfig.cached_requests.timeToLive:o).pipe(Object(D.mergeMap)(i=>i?this.keyValueStore.getValue(t+"-"+e).pipe(Object(D.map)(e=>JSON.parse(e)),Object(D.tap)(()=>ea(this,void 0,void 0,(function*(){try{yield r().pipe(Object(D.switchMap)(r=>this.saveItem(e,n,t,r,s))).toPromise()}catch(e){console.error(e)}})))):this.keyValueStore.getValue(t+"-"+e).pipe(Object(D.map)(e=>JSON.parse(e))))):i?i().pipe(Object(D.switchMap)(r=>this.saveItem(e,n,t,r,s)),Object(D.catchError)(i=>r().pipe(Object(D.switchMap)(r=>this.saveItem(e,n,t,r,s))))):r().pipe(Object(D.switchMap)(r=>this.saveItem(e,n,t,r,s)))))}isItemCachedInDb(e,t){return this.sharedPreferences.getString(e+"-"+t).pipe(Object(D.mergeMap)(e=>Object(c.iif)(()=>!!e,Object(c.defer)(()=>Object(c.of)(!0)),Object(c.defer)(()=>Object(c.of)(!1)))))}isItemTTLExpired(e,t,n){return this.sharedPreferences.getString(e+"-"+t).pipe(Object(D.map)(e=>{const t=Number(e);return!(Date.now()-t<n)}))}saveItem(e,t,n,r,i){return Xs.isItemEmpty(r)||i&&i(r)?Object(c.of)(r):Object(c.zip)(this.saveItemTTL(e,t),this.saveItemToDb(e,n,r)).pipe(Object(D.switchMap)(()=>Object(c.of)(r)))}saveItemTTL(e,t){return this.sharedPreferences.putString(t+"-"+e,Date.now()+"").pipe(Object(D.mergeMap)(e=>Object(c.of)(!0)))}saveItemToDb(e,t,n){return this.keyValueStore.setValue(t+"-"+e,JSON.stringify(n))}};var na;ta=Xs=Js([Object(s.injectable)(),Zs(0,Object(s.inject)(l.SDK_CONFIG)),Zs(1,Object(s.inject)(l.KEY_VALUE_STORE)),Zs(2,Object(s.inject)(l.SHARED_PREFERENCES)),Qs("design:paramtypes",[Object,Object,Object])],ta),function(e){e.RESOURCE="Resource",e.COURSE="Course",e.ANONYMOUS_COURSE="AnonymousCourse",e.DIAL_CODE="DIAL Code Consumption"}(na||(na={}));var ra=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ia{constructor(e,t,n,r,i,o,s,a){this.apiService=e,this.pageApiServiceConfig=t,this.sharedPreferences=n,this.cachedItemStore=r,this.keyValueStore=i,this.authService=o,this.profileService=s,this.systemSettingsService=a,this.PAGE_ASSEMBLE_LOCAL_KEY="page_assemble-",this.PAGE_ASSEMBLE_ENDPOINT="/page/assemble?orgdetails=orgName",this.DIALCODE_ASSEMBLE_ENDPOINT="/dial/assemble"}static getIdForDb(e){return e.name+"-"+(e.organisationId||"")+"-"+(e.source||"app")+"-"+(e.mode||"")+"-"+(e.filters?ms(JSON.stringify(e.filters)).toString():"")+(e.sections?ms(JSON.stringify(e.sections)).toString():"")}handle(e){return e.from=e.from||Jn.CACHE,Object(c.defer)(()=>ra(this,void 0,void 0,(function*(){if(e.name!==na.COURSE)return e;const t=yield this.sharedPreferences.getString(y.KEY_ORGANISATION_ID).toPromise();if(!t)return e;if(yield(()=>ra(this,void 0,void 0,(function*(){const e=!!(yield this.authService.getSession().toPromise()),t=yield this.profileService.isDefaultChannelProfile().toPromise();return e&&!t})))())return e;const n=yield this.systemSettingsService.getSystemSettings({id:ia.SYSTEM_SETTINGS_TENANT_COURSE_PAGE_ID}).toPromise().then(e=>{try{return JSON.parse(e.value)}catch(e){return console.error(e),[]}});e.organisationId=t;const r=n.find(e=>e.channelId===t);return r&&(e.name=r.page),e}))).pipe(Object(D.mergeMap)(e=>e.from===Jn.SERVER?this.fetchFromServer(e).pipe(Object(D.catchError)(()=>this.fetchFromCache(e))):this.fetchFromCache(e)))}fetchFromServer(e){const t=e.name===na.DIAL_CODE?this.DIALCODE_ASSEMBLE_ENDPOINT:this.PAGE_ASSEMBLE_ENDPOINT,n=(new a.CsRequest.Builder).withHost(this.pageApiServiceConfig.host).withType(a.CsHttpRequestType.POST).withPath(this.pageApiServiceConfig.apiPath+t).withBearerToken(!0).withBody({request:e}).build();return this.apiService.fetch(n).pipe(Object(D.map)(e=>e.body.result.response),Object(D.tap)(t=>{const n=JSON.stringify(t);this.sharedPreferences.putString("ttl_"+this.PAGE_ASSEMBLE_LOCAL_KEY+"-"+ia.getIdForDb(e),Date.now()+"").toPromise(),this.keyValueStore.setValue(this.PAGE_ASSEMBLE_LOCAL_KEY+"-"+ia.getIdForDb(e),n).toPromise()}))}fetchFromCache(e){return this.cachedItemStore.getCached(ia.getIdForDb(e),this.PAGE_ASSEMBLE_LOCAL_KEY,"ttl_"+this.PAGE_ASSEMBLE_LOCAL_KEY,()=>this.fetchFromServer(e))}}ia.SYSTEM_SETTINGS_TENANT_COURSE_PAGE_ID="tenantCoursePage";var oa=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class sa{constructor(e,t){this.defaultDelegate=e,this.dbService=t}handle(e){return Object(c.defer)(()=>oa(this,void 0,void 0,(function*(){let t;try{t=yield this.defaultDelegate.handle(e).toPromise()}catch(e){console.error(e)}if(e.filters&&e.filters.dialcodes){const n=`SELECT c.* FROM content c WHERE ref_count > 0 AND dialcodes LIKE '%%~${e.filters.dialcodes}~%%'`,r=(yield this.dbService.execute(n).toPromise()).map(e=>xn.mapContentDBEntryToContent(e).contentData);t&&t.sections[0]&&r.length?t=yield this.mergePageAssembleWithLocalContents(t,r):!t&&r.length&&(t=yield this.buildPageAssembleWithLocalContents(r))}if(!t)throw new Error("NO_DATA");return t})))}buildPageAssembleWithLocalContents(e){return oa(this,void 0,void 0,(function*(){const t={name:"",id:"",sections:[{display:"",count:0,index:0,sectionDataType:"",resmsgId:"",searchQuery:"",name:"",id:"",apiId:"",group:0,contents:e}]};return this.mergePageAssembleWithLocalCollections(t,e)}))}mergePageAssembleWithLocalContents(e,t){return oa(this,void 0,void 0,(function*(){const n=e.sections[0];if(n.contents&&n.contents.length){const r=t.filter(e=>!n.contents.find(t=>t.identifier===e.identifier));r.length&&(n.contents=[...r,...n.contents],e=yield this.mergePageAssembleWithLocalCollections(e,r))}else n.contents=t,e=yield this.mergePageAssembleWithLocalCollections(e,t);return e}))}mergePageAssembleWithLocalCollections(e,t){return oa(this,void 0,void 0,(function*(){const n=e.sections[0];n.collections||(n.collections=[]);for(const e of t){const t=`SELECT c.* FROM content c WHERE c.visibility = 'Default' AND ref_count > 0 AND child_nodes LIKE '%%~${e.identifier}~%%'`,r=(yield this.dbService.execute(t).toPromise()).map(e=>xn.mapContentDBEntryToContent(e).contentData);if(r.length)for(const t of r){const r=n.collections.find(e=>e.identifier===t.identifier);r?r.childNodes.indexOf(e.identifier)>=0||r.childNodes.push(e.identifier):n.collections.push(Object.assign(Object.assign({},t),{childNodes:[e.identifier]}))}}return e}))}}var aa=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ca{constructor(e,t,n,r){this.defaultDelegate=e,this.authService=t,this.frameworkService=n,this.systemSettingsService=r,this.ssoSectionIdMap=new Map}handle(e){return Object(c.defer)(()=>aa(this,void 0,void 0,(function*(){if(!!!(yield this.authService.getSession().toPromise()))return e;const t=yield this.frameworkService.getDefaultChannelId().toPromise(),n=this.frameworkService.activeChannelId;if(!(n===t)){let t;try{const e=yield this.systemSettingsService.getSystemSettings({id:ca.SSO_COURSE_SECTION_ID}).toPromise();t=e&&e.value}catch(e){console.error(e)}t&&(e.sections={[t]:{filters:{"batches.createdFor":[n]}}},this.ssoSectionIdMap.set(e.name+"-"+n,t))}return e}))).pipe(Object(D.mergeMap)(e=>this.defaultDelegate.handle(e)),Object(D.map)(t=>{const n=this.ssoSectionIdMap.get(e.name+"-"+this.frameworkService.activeChannelId);return n&&(t.ssoSectionId=n),t}))}}ca.SSO_COURSE_SECTION_ID="ssoCourseSection";class ua{constructor(e,t,n,r,i,o,s,a,c,u){this.apiService=e,this.pageApiServiceConfig=t,this.cachedItemStore=n,this.keyValueStore=r,this.sharedPreferences=i,this.frameworkService=o,this.authService=s,this.systemSettingsService=a,this.dbService=c,this.profileService=u,this.defaultRequestDelegate=new ia(e,t,i,n,r,s,u,a),this.dialcodeRequestDelegate=new sa(this.defaultRequestDelegate,c),this.courseRequestDelegate=new ca(this.defaultRequestDelegate,s,o,a)}handle(e){switch(e.from=e.from||Jn.CACHE,e.name){case na.COURSE:return this.courseRequestDelegate.handle(e);case na.DIAL_CODE:return this.dialcodeRequestDelegate.handle(e);default:return this.defaultRequestDelegate.handle(e)}}}var la=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},da=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ha=function(e,t){return function(n,r){t(n,r,e)}};let Ea=class{constructor(e,t,n,r,i,o,s,a,c,u){this.apiService=e,this.sdkConfig=t,this.cachedItemStore=n,this.keyValueStore=r,this.sharedPreferences=i,this.frameworkService=o,this.authService=s,this.systemSettingsService=a,this.dbService=c,this.profileService=u,this.pageAssembleServiceConfig=this.sdkConfig.pageServiceConfig}setPageAssembleChannel(e){this.sharedPreferences.putString(y.KEY_ORGANISATION_ID,e.channelId).toPromise()}getPageAssemble(e){return new ua(this.apiService,this.pageAssembleServiceConfig,this.cachedItemStore,this.keyValueStore,this.sharedPreferences,this.frameworkService,this.authService,this.systemSettingsService,this.dbService,this.profileService).handle(e)}};Ea=la([Object(s.injectable)(),ha(0,Object(s.inject)(l.API_SERVICE)),ha(1,Object(s.inject)(l.SDK_CONFIG)),ha(2,Object(s.inject)(l.CACHED_ITEM_STORE)),ha(3,Object(s.inject)(l.KEY_VALUE_STORE)),ha(4,Object(s.inject)(l.SHARED_PREFERENCES)),ha(5,Object(s.inject)(l.FRAMEWORK_SERVICE)),ha(6,Object(s.inject)(l.AUTH_SERVICE)),ha(7,Object(s.inject)(l.SYSTEM_SETTINGS_SERVICE)),ha(8,Object(s.inject)(l.DB_SERVICE)),ha(9,Object(s.inject)(l.PROFILE_SERVICE)),da("design:paramtypes",[Object,Object,Object,Object,Object,Object,Object,Object,o,Object])],Ea);var fa=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};let pa=class{constructor(){this.listeners=new Map}getString(e){return Object(c.defer)(()=>Object(c.of)(localStorage.getItem(e)).pipe(Object(D.map)(e=>e||void 0)))}putString(e,t){return Object(c.defer)(()=>Object(c.of)(localStorage.setItem(e,t)).pipe(Object(D.mapTo)(void 0)))}putBoolean(e,t){return Object(c.defer)(()=>Object(c.of)(localStorage.setItem(e,t+"")).pipe(Object(D.mapTo)(!0)))}getBoolean(e){return Object(c.defer)(()=>Object(c.of)("true"===localStorage.getItem(e)))}addListener(e,t){const n=this.listeners.get(e)||[];n.push(t),this.listeners.set(e,n)}removeListener(e,t){const n=this.listeners.get(e)||[];this.listeners.set(e,n.filter(e=>e!==t))}};pa=fa([Object(s.injectable)()],pa);var _a,Oa=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};let Sa=_a=class{constructor(){this.listeners=new Map,this.sharedPreferences=plugins.SharedPreferences.getInstance(_a.sharedPreferncesName)}getString(e){const t=localStorage.getItem(e);return t?(localStorage.removeItem(e),this.putString(e,t).pipe(Object(D.mapTo)(t))):new c.Observable(t=>{this.sharedPreferences.getString(e,"",e=>{t.next(e),t.complete()},e=>{t.error(e)})})}putString(e,t){return new c.Observable(n=>{this.sharedPreferences.putString(e,t,()=>{(this.listeners.get(e)||[]).forEach(e=>e(t)),n.next(void 0),n.complete()},e=>{n.error(e)})})}putBoolean(e,t){return new c.Observable(n=>{this.sharedPreferences.putBoolean(e,t,()=>{(this.listeners.get(e)||[]).forEach(e=>e(t)),n.next(!0),n.complete()},e=>{n.error(e)})})}getBoolean(e){const t=localStorage.getItem(e);return t?(localStorage.removeItem(e),this.putBoolean(e,"true"===t).pipe(Object(D.mapTo)("true"===t))):new c.Observable(t=>{this.sharedPreferences.getBoolean(e,!1,e=>{t.next(e),t.complete()},e=>{t.error(e)})})}addListener(e,t){const n=this.listeners.get(e)||[];n.push(t),this.listeners.set(e,n)}removeListener(e,t){const n=this.listeners.get(e)||[];this.listeners.set(e,n.filter(e=>e!==t))}};var ga;Sa.sharedPreferncesName="org.ekstep.genieservices.preference_file",Sa=_a=Oa([Object(s.injectable)()],Sa),function(e){e[e.PERSISTENT=1]="PERSISTENT",e[e.TEMPORARY=0]="TEMPORARY"}(ga||(ga={}));var Aa=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};let Na=class{constructor(){this.initialized=!1}init(){file.requestFileSystem(ga.PERSISTENT,0,e=>{this.initialized=!0,this.fileSystem=e},()=>{})}readAsText(e,t){return this.readFile(e,t,"Text")}readAsBinaryString(e,t){return this.readFile(e,t,"BinaryString")}readFileFromAssets(e){return new Promise((t,n)=>{try{sbutility.readFromAssets(e,e=>{t(e)},e=>{n(e)})}catch(e){n(e)}})}writeFile(e,t,n,r={}){const i={create:!r.append,exclusive:!r.replace};return this.resolveDirectoryUrl(e).then(e=>this.getFile(e,t,i)).then(e=>this.writeFileEntry(e,n,r))}createFile(e,t,n){const r={create:!0};return n||(r.exclusive=!0),this.resolveDirectoryUrl(e).then(e=>this.getFile(e,t,r))}getFile(e,t,n){return new Promise((r,i)=>{try{e.getFile(t,n,e=>{r(e)},e=>{i(e)})}catch(e){i(e)}})}removeFile(e){const t=Mo.getParentDir(e),n=Mo.getFileName(e).replace("/","");return this.resolveDirectoryUrl(t).then(e=>this.getFile(e,n,{create:!1})).then(e=>this.remove(e))}createDir(e,t){const n={create:!0};t||(n.exclusive=!0);const r=Mo.getParentDir(e),i=Mo.getFileName(e).replace("/","");return this.exists(e).then(()=>this.resolveDirectoryUrl(e)).catch(()=>this.resolveDirectoryUrl(r).then(e=>this.getDirectory(e,i,n)))}listDir(e){return this.resolveDirectoryUrl(Mo.getDirecory(e)).then(t=>this.getDirectory(t,Mo.getFileName(e),{create:!1,exclusive:!1})).then(e=>{const t=e.createReader();return this.readEntries(t)})}removeDir(e,t){return this.resolveDirectoryUrl(e).then(e=>this.getDirectory(e,t,{create:!1})).then(e=>this.remove(e))}removeRecursively(e){e=e.endsWith("/")?e.substring(0,e.length-1):e;const t=Mo.getParentDir(e),n=Mo.getFileName(e).replace("/","");return this.resolveDirectoryUrl(t).then(e=>this.getDirectory(e,n,{create:!1})).then(e=>this.rimraf(e))}copyDir(e,t,n,r){return this.resolveDirectoryUrl(e).then(e=>this.getDirectory(e,t,{create:!1})).then(e=>this.resolveDirectoryUrl(n).then(t=>this.copy(e,t,r)))}copyFile(e,t,n,r){return r=r||t,this.resolveDirectoryUrl(e).then(e=>this.getFile(e,t,{create:!1})).then(e=>this.resolveDirectoryUrl(n).then(t=>this.copy(e,t,r)))}exists(e){return this.resolveLocalFilesystemUrl(e)}getTempLocation(e){return this.resolveDirectoryUrl(e).then(t=>this.resolveDirectoryUrl(e.concat("tmp"))).catch(()=>this.createDir(e.concat("tmp"),!1))}getFreeDiskSpace(){return new Promise((e,t)=>{cordova.exec(()=>e,t,"File","getFreeDiskSpace",[])})}resolveLocalFilesystemUrl(e){return e.includes("file://")||(e="file://"+e),console.log(e),new Promise((t,n)=>{try{resolveLocalFileSystemURL(e,e=>{t(e)},e=>{n(e)})}catch(e){n(e)}})}getMetaData(e){if("string"==typeof e)return this.resolveLocalFilesystemUrl(e).then(e=>this.getMetaData(e));const t=e;return new Promise(e=>{t.getMetadata(t=>{e(t)},()=>e({modificationTime:new Date,size:1}))})}getExternalApplicationStorageDirectory(){return file.externalApplicationStorageDirectory}getDirectorySize(e){return this.resolveDirectoryUrl(e).then(e=>this.size(e)).catch(()=>0)}size(e){return e.isFile?new Promise((t,n)=>{e.getMetadata(e=>t(e.size),e=>n(e))}):e.isDirectory?new Promise((t,n)=>{e.createReader().readEntries(e=>{Promise.all(e.map(e=>this.size(e))).then(e=>{const n=e.reduce((e,t)=>e+t,0);t(n)}).catch(e=>n(e))},e=>n(e))}):Promise.resolve(0)}readEntries(e){return new Promise((t,n)=>{e.readEntries(e=>{t(e)},e=>{n(e)})})}getFileReader(){const e=new FileReader;return e.__zone_symbol__originalInstance||e}readFile(e,t,n){return this.resolveDirectoryUrl(e).then(e=>this.getFile(e,t,{create:!1})).then(e=>{let t=this.getFileReader();return new Promise((n,r)=>{e.file(e=>{t.onloadend=e=>{void 0!==t.result&&null!==t.result?n(t.result):void 0!==t.error&&null!==t.error?r(t.error):r({code:null,message:"READER_ONLOADEND_ERR"})},t.readAsText(e)},e=>{r(e)})})}).catch(e=>{throw e})}resolveDirectoryUrl(e){return this.resolveLocalFilesystemUrl(e).then(e=>e.isDirectory?e:Promise.reject("input is not a directory"))}remove(e){return new Promise((t,n)=>{e.remove(()=>{t({success:!0,fileRemoved:e})},e=>{n(e)})})}copy(e,t,n){return new Promise((r,i)=>{e.copyTo(t,n,e=>{r(e)},e=>{i(e)})})}getDirectory(e,t,n){return new Promise((r,i)=>{try{e.getDirectory(t,n,e=>{r(e)},e=>{i(e)})}catch(e){i(e)}})}rimraf(e){return new Promise((t,n)=>{e.removeRecursively(()=>{t({success:!0,fileRemoved:e})},e=>{n(e)})})}createWriter(e){return new Promise((t,n)=>{e.createWriter(e=>{t(e)},e=>{n(e)})})}writeFileEntry(e,t,n){return this.createWriter(e).then(e=>(n.append&&e.seek(e.length),n.truncate&&e.truncate(n.truncate),this.write(e,t))).then(()=>e)}write(e,t){return new Promise((n,r)=>{e.onwriteend=t=>{e.error?r(e.error):n(t)},e.write(t)})}};Na=Aa([Object(s.injectable)()],Na);var Ta=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ca extends i{constructor(){super(2,17)}apply(e){return Ta(this,void 0,void 0,(function*(){this.queries().forEach(t=>Ta(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()})))}))}queries(){return[et.getAlterEntryForProfileSyllabus()]}}var va=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ya extends i{constructor(){super(3,18)}apply(e){return va(this,void 0,void 0,(function*(){this.queries().forEach(t=>va(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()}))),yield e.read({table:et.TABLE_NAME,columns:[]}).pipe(Object(D.map)(t=>{t.forEach(t=>va(this,void 0,void 0,(function*(){t[et.COLUMN_NAME_UID]===t[et.COLUMN_NAME_HANDLE]?t[et.COLUMN_NAME_SOURCE]=Wn.SERVER.valueOf():t[et.COLUMN_NAME_SOURCE]=Wn.LOCAL.valueOf(),yield e.update({table:et.TABLE_NAME,modelJson:t}).toPromise()})))})).toPromise()}))}queries(){return[it.getCreateEntry(),st.getCreateEntry()]}updateProfileTable(){}}var ma=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ba extends i{constructor(){super(4,19)}apply(e){return ma(this,void 0,void 0,(function*(){yield e.read({table:lt.TABLE_NAME,columns:[]}).pipe(Object(D.map)(t=>{t.forEach(t=>ma(this,void 0,void 0,(function*(){const n=Number(t[ht.COLUMN_NAME_TOTAL_TS]);t[ht.COLUMN_NAME_TOTAL_TS]=Math.round(n/1e3),yield e.update({table:ht.TABLE_NAME,modelJson:t}).toPromise()})))})).toPromise()}))}queries(){return[]}}var Ia=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ma extends i{constructor(){super(7,22)}apply(e){return Ia(this,void 0,void 0,(function*(){this.queries().forEach(t=>Ia(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()})))}))}queries(){return[Rt.getCreateEntry()]}}var Ra=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class La extends i{constructor(){super(18,31)}apply(e){return Ra(this,void 0,void 0,(function*(){this.queries().forEach(t=>Ra(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()}))),this.updateProfileDB(e)}))}queries(){return[et.getAlterEntryForProfileCategories()]}updateProfileDB(e){return Ra(this,void 0,void 0,(function*(){try{(yield e.read({table:et.TABLE_NAME}).toPromise()).forEach(t=>Ra(this,void 0,void 0,(function*(){const n=this.getUpdateQueries(t),r={};r[et.COLUMN_NAME_CATEGORIES]=JSON.stringify(n),yield e.update({table:et.TABLE_NAME,selection:et.COLUMN_NAME_UID+" = ?",selectionArgs:[t.uid],modelJson:r}).toPromise()})))}catch(e){console.log("error",e)}}))}getUpdateQueries(e){const t={};return t.fwCategory1=e.board,t.fwCategory2=e.medium,t.fwCategory3=e.grade,t.fwCategory4=e.subject,t}}var Pa=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Da extends i{constructor(){super(5,20)}apply(e){return Pa(this,void 0,void 0,(function*(){this.queries().forEach(t=>Pa(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()})))}))}queries(){return[vt.getCreateEntry()]}}class wa{constructor(e,t,n,r){this.apiService=e,this.systemSettingsConfig=t,this.fileservice=n,this.cachedItemStore=r,this.SYSTEM_SETTINGS_FILE_KEY_PREFIX="system-setting-",this.SYSTEM_SETTINGS_LOCAL_KEY="system-settings-",this.GET_SYSTEM_SETTINGS_ENDPOINT="/system/settings/get"}handle(e){return this.cachedItemStore.getCached(e.id,this.SYSTEM_SETTINGS_LOCAL_KEY,"ttl_"+this.SYSTEM_SETTINGS_LOCAL_KEY,()=>this.fetchFromServer(e),()=>this.fetchFromFile(e))}fetchFromServer(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.systemSettingsConfig.systemSettingsApiPath+this.GET_SYSTEM_SETTINGS_ENDPOINT+"/"+e.id).withBearerToken(!0).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>e.body.result.response))}fetchFromFile(e){const t=lr.getAssetPath()+this.systemSettingsConfig.systemSettingsDirPath,n=this.SYSTEM_SETTINGS_FILE_KEY_PREFIX+e.id+".json";return Object(c.from)(this.fileservice.readFileFromAssets(t.concat("/",n))).pipe(Object(D.map)(e=>JSON.parse(e).result.response))}}var Ua=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},ja=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Fa=function(e,t){return function(n,r){t(n,r,e)}};let ka=class{constructor(e,t,n,r){this.sdkConfig=e,this.apiService=t,this.fileService=n,this.cachedChannelItemStore=r,this.systemSettingsConfig=this.sdkConfig.systemSettingsConfig}getSystemSettings(e){return new wa(this.apiService,this.systemSettingsConfig,this.fileService,this.cachedChannelItemStore).handle(e)}};ka=Ua([Object(s.injectable)(),Fa(0,Object(s.inject)(l.SDK_CONFIG)),Fa(1,Object(s.inject)(l.API_SERVICE)),Fa(2,Object(s.inject)(l.FILE_SERVICE)),Fa(3,Object(s.inject)(l.CACHED_ITEM_STORE)),ja("design:paramtypes",[Object,Object,Object,Object])],ka);var xa=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s};let Ba=class{unzip(e,t,n,r){JJzip.unzip(e,t,()=>{n&&n()},e=>{r&&r(e)})}zip(e,t,n,r,i,o){JJzip.zip(e,t,n,r,()=>{i&&i()},e=>{o&&o(e)})}};var Va,Ya,Ga;Ba=xa([Object(s.injectable)()],Ba),function(e){e.INTERNAL_STORAGE="INTERNAL_STORAGE",e.EXTERNAL_STORAGE="EXTERNAL_STORAGE"}(Va||(Va={})),function(e){e.TRANSFER_PROGRESS="TRANSFER_PROGRESS",e.TRANSFER_COMPLETED="TRANSFER_COMPLETED",e.TRANSFER_REVERT_COMPLETED="TRANSFER_REVERT_COMPLETED",e.TRANSFER_FAILED_DUPLICATE_CONTENT="TRANSFER_FAILED_DUPLICATE_CONTENT",e.TRANSFER_FAILED_LOW_MEMORY="TRANSFER_FAILED_LOW_MEMORY"}(Ya||(Ya={})),function(e){e.IGNORE="IGNORE",e.KEEP_HIGER_VERSION="KEEP_HIGER_VERSION",e.KEEP_LOWER_VERSION="KEEP_LOWER_VERSION",e.KEEP_SOURCE="KEEP_SOURCE",e.KEEP_DESTINATION="KEEP_DESTINATION"}(Ga||(Ga={}));class Ha extends ke{constructor(e){super(e,"TRANSFER_FAILED_DUPLICATE_CONTENT_ERROR"),Object.setPrototypeOf(this,Ha.prototype)}}class $a extends ke{constructor(e,t){super(e,"TRANSFER_FAILED_ERROR"),this.directory=t,Object.setPrototypeOf(this,$a.prototype)}}var qa=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ka=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};let za=class{constructor(){this.deviceId=ms(window.device.uuid).toString()}getDeviceID(){return this.deviceId}getDeviceSpec(){return this.deviceSpec?Object(c.of)(this.deviceSpec):new c.Observable(e=>{sbutility.getDeviceSpec(t=>{this.deviceSpec=t,e.next(t),e.complete()})})}getAvailableInternalMemorySize(){return new c.Observable(e=>{sbutility.getAvailableInternalMemorySize(t=>{e.next(t),e.complete()},t=>{e.error(t)})})}getStorageVolumes(){return c.Observable.create(e=>{sbutility.getStorageVolumes(t=>{e.next(t.map(e=>e.isRemovable?{storageDestination:Va.EXTERNAL_STORAGE,info:Object.assign({},e)}:{storageDestination:Va.INTERNAL_STORAGE,info:Object.assign({},e)})),e.complete()},t=>{e.error(t)})})}isKeyboardShown(){let e,t,n,r;return new c.Observable(i=>{e=()=>i.next(!0),t=()=>i.next(!0),n=()=>i.next(!1),r=()=>i.next(!1),window.addEventListener("native.keyboardshow",e),window.addEventListener("keyboardWillShow",t),window.addEventListener("native.keyboardhide",n),window.addEventListener("keyboardWillHide",n)}).pipe(Object(D.distinctUntilChanged)(),Object(D.tap)(()=>{console.log("Subscribed isKeyboardShown event")}),Object(D.finalize)(()=>{console.log("Unsubscribed isKeyboardShown event"),window.removeEventListener("native.keyboardshow",e),window.removeEventListener("keyboardWillShow",t),window.removeEventListener("native.keyboardhide",n),window.removeEventListener("keyboardWillHide",n)}))}};za=qa([Object(s.injectable)(),Ka("design:paramtypes",[])],za);var Wa=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Xa=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ja=function(e,t){return function(n,r){t(n,r,e)}};let Qa=class{constructor(e,t,n){this.dbService=e,this.profileService=t,this.telemetryService=n}getFeedback(e){const t=`SELECT * FROM ${Tt.TABLE_NAME} ${kn.getUidnIdentifierFiler(e.uid,e.contentId)}`;return this.dbService.execute(t).pipe(Object(D.map)(e=>e.map(e=>class{static mapFeedbackDBEntrytoResponseFeedback(e){return{contentId:e[Tt.COLUMN_NAME_CONTENT_ID],rating:Number(e[Tt.COLUMN_NAME_RATING]),comments:e[Tt.COLUMN_NAME_COMMENTS],createdAt:Number(e[Tt.COLUMN_NAME_CREATED_AT]),stageId:"",contentVersion:""}}}.mapFeedbackDBEntrytoResponseFeedback(e))))}sendFeedback(e){return this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(t=>{const n={table:Tt.TABLE_NAME,selection:(new Kt).where("? = ? AND ? = ?").args([Tt.COLUMN_NAME_CONTENT_ID,e.contentId,Tt.COLUMN_NAME_UID,t.uid]).end().build(),limit:"1"},r={uid:t.uid,identifier:e.contentId,rating:e.rating,comments:e.comments,createdAt:Date.now()};return this.telemetryService.feedback({env:"sdk",rating:e.rating,comments:e.comments,objId:e.contentId,objType:ie.CONTENT.valueOf(),objVer:e.contentVersion}).pipe(Object(D.mergeMap)(()=>this.dbService.read(n).pipe(Object(D.mergeMap)(n=>n&&n.length?this.dbService.update({table:Tt.TABLE_NAME,selection:`${Tt.COLUMN_NAME_UID}= ? AND ${Tt.COLUMN_NAME_CONTENT_ID}= ?`,selectionArgs:[t.uid,e.contentId],modelJson:r}).pipe(Object(D.map)(e=>e>0)):this.dbService.insert({table:Tt.TABLE_NAME,modelJson:r}).pipe(Object(D.map)(e=>e>0))))))}))}};Qa=Wa([Object(s.injectable)(),Ja(0,Object(s.inject)(l.DB_SERVICE)),Ja(1,Object(s.inject)(l.PROFILE_SERVICE)),Ja(2,Object(s.inject)(l.TELEMETRY_SERVICE)),Xa("design:paramtypes",[o,Object,Object])],Qa);var Za=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},ec=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},tc=function(e,t){return function(n,r){t(n,r,e)}},nc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let rc=class{constructor(e){this.sdkConfig=e,this.eventsBus=new c.Subject,this.eventDelegates=[],this.eventsBusConfig=this.sdkConfig.eventsBusConfig}onInit(){return this.eventsBus.pipe(Object(D.tap)(e=>{this.eventsBusConfig.debugMode&&console.log("SDK Telemetry Events",e)}),Object(D.tap)(e=>nc(this,void 0,void 0,(function*(){const t=this.eventDelegates.filter(t=>t.namespace===e.namespace).map(t=>t.observer.onEvent(e.event).pipe(Object(D.take)(1),Object(D.catchError)(e=>(console.error("Error: ",e,"EventObserver: ",t),Object(c.of)(void 0)))));try{yield Object(c.zip)(...t).toPromise()}catch(e){console.error("EVENT_BUS_DELEGATE_ERROR",e)}}))),Object(D.mapTo)(void 0))}events(e){return this.eventsBus.asObservable().pipe(Object(D.filter)(t=>!e||t.namespace===e),Object(D.map)(e=>e.event))}emit({namespace:e,event:t}){this.eventsBus.next({namespace:e,event:t})}registerObserver({namespace:e,observer:t}){this.eventDelegates.push({namespace:e,observer:t})}};rc=Za([Object(s.injectable)(),tc(0,Object(s.inject)(l.SDK_CONFIG)),ec("design:paramtypes",[Object])],rc);var ic,oc=n(51),sc=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},ac=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},cc=function(e,t){return function(n,r){t(n,r,e)}},uc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let lc=ic=class{constructor(e,t){this.eventsBusService=e,this.sharedPreferences=t,this.currentDownloadRequest$=new c.BehaviorSubject(void 0),this.completedDownloadRequestsCache=new Eo.a(e=>e.identifier),window.downloadManager=oc,this.sharedPreferencesSetCollection=new gs(this.sharedPreferences,ic.KEY_TO_DOWNLOAD_LIST,e=>e.identifier)}static generateDownloadStartTelemetry(e){return uc(this,void 0,void 0,(function*(){return ln.log.interact({type:oe.OTHER,subType:se.CONTENT_DOWNLOAD_INITIATE,env:"sdk",pageId:"ContentDetail",id:"ContentDetail",objId:e.identifier,objType:e.contentMeta&&e.contentMeta.primaryCategory?kn.readPrimaryCategoryServer(e.contentMeta):"Content",objVer:e.contentMeta&&e.contentMeta.pkgVersion?e.contentMeta.pkgVersion:"",correlationData:e.correlationData||[]}).pipe(Object(D.mapTo)(void 0)).toPromise()}))}static generateDownloadCompleteTelemetry(e){return uc(this,void 0,void 0,(function*(){return ln.log.interact({type:oe.OTHER,subType:se.CONTENT_DOWNLOAD_SUCCESS,env:"sdk",pageId:"ContentDetail",id:"ContentDetail",objId:e.identifier,objType:e.contentMeta&&e.contentMeta.primaryCategory?kn.readPrimaryCategoryServer(e.contentMeta):"Content",objVer:e.contentMeta&&e.contentMeta.pkgVersion?e.contentMeta.pkgVersion:"",correlationData:e.correlationData||[]}).pipe(Object(D.mapTo)(void 0)).toPromise()}))}static generateDownloadCancelTelemetry(e){return uc(this,void 0,void 0,(function*(){return ln.log.interact({type:oe.OTHER,subType:se.CONTENT_DOWNLOAD_CANCEL,env:"sdk",pageId:"ContentDetail",id:"ContentDetail",objId:e.identifier,objType:e.contentMeta&&e.contentMeta.primaryCategory?kn.readPrimaryCategoryServer(e.contentMeta):"Content",objVer:e.contentMeta&&e.contentMeta.pkgVersion?e.contentMeta.pkgVersion:"",correlationData:e.correlationData||[]}).pipe(Object(D.mapTo)(void 0)).toPromise()}))}onInit(){return this.switchToNextDownloadRequest().pipe(Object(D.mergeMap)(()=>this.listenForDownloadProgressChanges()))}download(e){return this.currentDownloadRequest$.pipe(Object(D.take)(1),Object(D.mergeMap)(t=>t?this.addToDownloadList(e):(console.log("SDK download downloadRequests -",e),this.addToDownloadList(e).pipe(Object(D.tap)(()=>this.switchToNextDownloadRequest().toPromise())))))}cancel(e,t=!0){return this.currentDownloadRequest$.pipe(Object(D.take)(1),Object(D.mergeMap)(n=>n&&n.identifier===e.identifier?new c.Observable(e=>{downloadManager.remove([n.downloadId],(t,n)=>{t&&e.error(t),e.next(!!n),e.complete()})}).pipe(Object(D.mergeMap)(()=>this.removeFromDownloadList(e,t)),Object(D.tap)(()=>this.switchToNextDownloadRequest().toPromise())):this.removeFromDownloadList(e,t)))}cancelAll(){return this.currentDownloadRequest$.pipe(Object(D.take)(1),Object(D.mergeMap)(e=>e?new c.Observable(t=>{downloadManager.remove([e.downloadId],(e,n)=>{e&&t.error(e),t.next(!!n),t.complete()})}).pipe(Object(D.mergeMap)(()=>this.removeAllFromDownloadList()),Object(D.mergeMap)(()=>this.switchToNextDownloadRequest())):this.removeAllFromDownloadList()))}registerOnDownloadCompleteDelegate(e){this.downloadCompleteDelegate=e}getActiveDownloadRequests(){return this.sharedPreferencesSetCollection.asListChanges().pipe(Object(D.map)(e=>e.sort((e,t)=>{const n=e.withPriority||0;return(t.withPriority||0)-n})))}switchToNextDownloadRequest(){return this.sharedPreferencesSetCollection.asSet().pipe(Object(D.mergeMap)(e=>{if(!e.size())return Object(c.of)(void 0).pipe(Object(D.tap)(()=>this.currentDownloadRequest$.next(void 0)));const t=e.toArray().sort((e,t)=>{const n=e.withPriority||0;return(t.withPriority||0)-n}).shift();return new c.Observable(e=>{downloadManager.enqueue({uri:t.downloadUrl,title:t.filename,description:"",mimeType:t.mimeType,visibleInDownloadsUi:!0,notificationVisibility:1,destinationInExternalFilesDir:{dirType:ic.DOWNLOAD_DIR_NAME,subPath:t.filename},headers:[]},(t,n)=>{if(t)return e.error(t);e.next(n)})}).pipe(Object(D.tap)(e=>{let n="ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalDataDirectory;t.downloadedFilePath=n+ic.DOWNLOAD_DIR_NAME+"/"+t.filename,t.downloadId=e,this.currentDownloadRequest$.next(t)}),Object(D.tap)(()=>uc(this,void 0,void 0,(function*(){return yield ic.generateDownloadStartTelemetry(t)}))),Object(D.mapTo)(void 0),Object(D.catchError)(()=>this.cancel({identifier:t.identifier})))}))}addToDownloadList(e){return console.log("addToDownloadList rq -",e),this.sharedPreferencesSetCollection.addAll(e).pipe(Object(D.mapTo)(void 0))}removeFromDownloadList(e,t){return this.sharedPreferencesSetCollection.asList().pipe(Object(D.mergeMap)(n=>{const r=n.find(t=>t.identifier===e.identifier);return r?this.sharedPreferencesSetCollection.remove(r).pipe(Object(D.mapTo)(void 0),Object(D.tap)(()=>uc(this,void 0,void 0,(function*(){return t&&(yield ic.generateDownloadCancelTelemetry(r))})))):Object(c.of)(void 0)}))}removeAllFromDownloadList(){return this.sharedPreferencesSetCollection.asList().pipe(Object(D.take)(1),Object(D.mergeMap)(e=>this.sharedPreferencesSetCollection.clear().pipe(Object(D.mergeMap)(()=>Object(c.from)(e).pipe(Object(D.tap)(e=>uc(this,void 0,void 0,(function*(){return yield ic.generateDownloadCancelTelemetry(e)}))),Object(D.concatMapTo)(Object(c.of)(void 0)))))))}handleDownloadCompletion(e){return this.currentDownloadRequest$.pipe(Object(D.take)(1),Object(D.mergeMap)(t=>e.payload.status===qr.STATUS_SUCCESSFUL?(this.completedDownloadRequestsCache.add(t),Object(c.iif)(()=>!!this.downloadCompleteDelegate,Object(c.defer)(()=>uc(this,void 0,void 0,(function*(){ic.generateDownloadCompleteTelemetry(t),this.downloadCompleteDelegate.onDownloadCompletion(t).toPromise()}))),Object(c.defer)(()=>Object(c.of)(void 0))).pipe(Object(D.mapTo)(void 0))):Object(c.of)(void 0)))}emitProgressInEventBus(e){return Object(c.defer)(()=>Object(c.of)(this.eventsBusService.emit({namespace:M.DOWNLOADS,event:e})).pipe(Object(D.mapTo)(void 0)))}getDownloadProgress(e){return new c.Observable(t=>{downloadManager.query({ids:[e.downloadId]},(n,r)=>{if(n)return t.next({type:$r.PROGRESS,payload:{downloadId:e.downloadId,identifier:e.identifier,progress:-1,bytesDownloaded:0,totalSizeInBytes:0,status:qr.STATUS_FAILED}}),t.complete(),void this.cancel({identifier:e.identifier}).toPromise();const i=r[0];t.next({type:$r.PROGRESS,payload:{downloadId:e.downloadId,identifier:e.identifier,progress:Math.round(i.totalSizeBytes>=0?i.bytesDownloadedSoFar/i.totalSizeBytes*100:-1),bytesDownloaded:i.bytesDownloadedSoFar,totalSizeInBytes:i.totalSizeBytes,status:i.status}}),t.complete()})})}listenForDownloadProgressChanges(){return this.currentDownloadRequest$.pipe(Object(D.switchMap)(e=>e?(this.eventsBusService.emit({namespace:M.DOWNLOADS,event:{type:$r.START,payload:void 0}}),Object(c.interval)(1e3).pipe(Object(D.mergeMap)(()=>this.getDownloadProgress(e)),Object(D.distinctUntilChanged)((e,t)=>JSON.stringify(e)===JSON.stringify(t)),Object(D.mergeMap)(e=>Object(c.zip)(this.handleDownloadCompletion(e),this.emitProgressInEventBus(e)).pipe(Object(D.mapTo)(e))),Object(D.tap)(e=>{e.payload.status!==qr.STATUS_FAILED&&e.payload.status!==qr.STATUS_SUCCESSFUL||this.eventsBusService.emit({namespace:M.DOWNLOADS,event:{type:$r.END,payload:void 0}})}),Object(D.mapTo)(void 0))):Object(c.of)(void 0)))}trackDownloads(e){return e.groupBy.fieldPath&&e.groupBy.value?this.getActiveDownloadRequests().pipe(Object(D.map)(t=>{const n=t=>e.groupBy.value===e.groupBy.fieldPath.split(".").reduce((e,t)=>{if(e&&e[t])return e[t]},t);return{completed:this.completedDownloadRequestsCache.size()?this.completedDownloadRequestsCache.toArray().filter(n):[],queued:t.length?t.filter(n):[]}})):c.EMPTY}onContentDelete(e){this.completedDownloadRequestsCache.remove({identifier:e})}};lc.KEY_TO_DOWNLOAD_LIST=O.KEY_TO_DOWNLOAD_LIST,lc.DOWNLOAD_DIR_NAME="Download",lc=ic=sc([Object(s.injectable)(),cc(0,Object(s.inject)(l.EVENTS_BUS_SERVICE)),cc(1,Object(s.inject)(l.SHARED_PREFERENCES)),ac("design:paramtypes",[Object,Object])],lc);var dc=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},hc=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Ec=function(e,t){return function(n,r){t(n,r,e)}},fc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let pc=class{constructor(e,t){this.sdkConfig=e,this.sharedPreferences=t,"cordova"!==e.platform&&(this.versionName="sunbird-debug"),window.Capacitor.Plugins.App.getInfo().then(e=>{this.appInformation=e,this.appName=e.name})}getVersionName(){return this.versionName}getAppName(){return this.appName}init(){var e,t;return fc(this,void 0,void 0,(function*(){if(yield this.setFirstAccessTimestamp(),"cordova"!==this.sdkConfig.platform)return;this.sdkConfig.appConfig.buildConfigPackage&&this.sdkConfig.appConfig.buildConfigPackage;this.appInformation=this.appInformation||this.sdkConfig.apiConfig.api_authentication,this.versionName=`${null===(e=this.appInformation)||void 0===e?void 0:e.version}-${null===(t=this.appInformation)||void 0===t?void 0:t.build}`,k.CsModule.instance.isInitialised&&k.CsModule.instance.updateConfig(Object.assign(Object.assign({},k.CsModule.instance.config),{core:Object.assign(Object.assign({},k.CsModule.instance.config.core),{global:Object.assign(Object.assign({},k.CsModule.instance.config.core.global),{appVersion:this.versionName})})})),console.log("version name",this.versionName)}))}getBuildConfigValue(e,t){return new Promise((n,r)=>{try{window.sbutility.getBuildConfigValue(e,t,e=>{n(e)},e=>{console.error(e),r(e)})}catch(e){console.error(e),r(e)}})}getFirstAccessTimestamp(){return this.sharedPreferences.getString(d.KEY_FIRST_ACCESS_TIMESTAMP).pipe(Object(D.map)(e=>e))}setFirstAccessTimestamp(){return fc(this,void 0,void 0,(function*(){return!(yield this.sharedPreferences.getString(d.KEY_FIRST_ACCESS_TIMESTAMP).toPromise())&&(yield this.sharedPreferences.putString(d.KEY_FIRST_ACCESS_TIMESTAMP,Date.now()+"").toPromise(),!0)}))}};pc=dc([Object(s.injectable)(),Ec(0,Object(s.inject)(l.SDK_CONFIG)),Ec(1,Object(s.inject)(l.SHARED_PREFERENCES)),hc("design:paramtypes",[Object,Object])],pc);var _c=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Oc=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Sc=function(e,t){return function(n,r){t(n,r,e)}},gc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let Ac=class{constructor(e,t,n,r,i,o,s){this.profileService=e,this.groupService=t,this.config=n,this.frameworkService=r,this.deviceInfo=i,this.appInfo=o,this.dbService=s}getPlayerConfig(e,t){const n={};n.did=this.deviceInfo.getDeviceID(),n.origin=this.config.apiConfig.host;const r=new ve;r.id=this.config.apiConfig.api_authentication.producerId,r.pid=this.config.apiConfig.api_authentication.producerUniqueId,r.ver=this.appInfo.getVersionName(),n.pdata=r;const i={};return e.rollup=kn.getRollup(e.identifier,e.hierarchyInfo),n.objectRollup=e.rollup,"ios"===window.device.platform.toLowerCase()?e.basePath=(e.basePath||(e.basePath="")).replace(/\/$/,""):e.basePath=e.basePath.replace(/\/$/,""),e.isAvailableLocally&&(e.contentData.streamingUrl=e.basePath,e.contentData.previewUrl=e.basePath),i.metadata=e,i.config=this.config.playerConfig,this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(t=>{n.sid=t?t.sid:"";const r=new pe;r.id=t?t.uid:"",n.actor=r;const o=this.config.appConfig.deepLinkBasePath;n.deeplinkBasePath=o||"";const s=e.rollup&&e.rollup.l1?e.rollup.l1:e.identifier;return this.fetchPlayerState(r.id,s,e.identifier).then(e=>{e&&i.config&&(i.config=Object.assign(Object.assign({},i.config),JSON.parse(e.saveState)))}),this.profileService.getActiveSessionProfile({requiredFields:[]})}),Object(D.mergeMap)(e=>{if(e&&e.serverProfile){const t=e.serverProfile.organisations;if(t){const e=t[0]&&t[0].organisationId;n.contextRollup={l1:e}}}return e&&e.profileType&&(t.correlationData=(t.correlationData||[]).concat([{id:e.profileType,type:"UserType"}])),this.groupService.getActiveGroupSession()}),Object(D.mergeMap)(e=>{let r=[];e&&e.gid&&r.push({id:e.gid,type:"group"});const o=t&&t.hasOwnProperty("streaming"),s=t.correlationData;s&&s.length&&(r=r.concat(s)),r.push({id:o?"streaming":"offline",type:"PlayerLaunch"}),n.cdata=r,i.context=n;const a={local:!0,server:!1};return a.groupId=e?e.gid:"",i.appContext=a,this.frameworkService.getActiveChannelId()}),Object(D.mergeMap)(e=>(n.channel=e||this.config.apiConfig.api_authentication.channelId,i.context=n,Object(c.of)(i))))}savePlayerState(e,t,n,r){return this.dbService.read({table:kt.TABLE_NAME,selection:`${kt.COLUMN_NAME_USER_ID} = ? AND ${kt.COLUMN_PARENT_IDENTIFIER} = ?\n AND ${kt.COLUMN_IDENTIFIER} = ?`,selectionArgs:[e,t,n]}).toPromise().then(i=>gc(this,void 0,void 0,(function*(){return i&&i.length?this.dbService.update({table:kt.TABLE_NAME,selection:`${kt.COLUMN_NAME_USER_ID} = ? AND ${kt.COLUMN_PARENT_IDENTIFIER} = ?\n AND ${kt.COLUMN_IDENTIFIER} = ?`,selectionArgs:[e,t,n],modelJson:Ht.mapPlayerStateToPlayerDbEntry(e,t,n,r)}).toPromise():this.dbService.insert({table:kt.TABLE_NAME,modelJson:Ht.mapPlayerStateToPlayerDbEntry(e,t,n,r)}).toPromise()})))}fetchPlayerState(e,t,n){return this.dbService.read({table:kt.TABLE_NAME,selection:`${kt.COLUMN_NAME_USER_ID} = ? AND ${kt.COLUMN_PARENT_IDENTIFIER} = ?\n AND ${kt.COLUMN_IDENTIFIER} = ?`,selectionArgs:[e,t,n]}).toPromise().then(e=>e&&e[0]&&Ht.mapPlayerDbEntryToPlayer(e[0]))}deletePlayerSaveState(e,t,n){return this.dbService.delete({table:kt.TABLE_NAME,selection:`${kt.COLUMN_NAME_USER_ID} =? AND ${kt.COLUMN_PARENT_IDENTIFIER} = ?\n AND ${kt.COLUMN_IDENTIFIER} = ?`,selectionArgs:[e,t,n]}).toPromise()}};Ac=_c([Object(s.injectable)(),Sc(0,Object(s.inject)(l.PROFILE_SERVICE)),Sc(1,Object(s.inject)(l.GROUP_SERVICE_DEPRECATED)),Sc(2,Object(s.inject)(l.SDK_CONFIG)),Sc(3,Object(s.inject)(l.FRAMEWORK_SERVICE)),Sc(4,Object(s.inject)(l.DEVICE_INFO)),Sc(5,Object(s.inject)(l.APP_INFO)),Sc(6,Object(s.inject)(l.DB_SERVICE)),Oc("design:paramtypes",[Object,Object,Object,Object,Object,Object,o])],Ac);var Nc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Tc extends i{constructor(){super(6,21)}apply(e){return Nc(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise())),yield e.read({table:St.TABLE_NAME,selection:St.COLUMN_NAME_CONTENT_TYPE+" = ?",selectionArgs:["textbook"]}).pipe(Object(D.map)(t=>{t.forEach(t=>Nc(this,void 0,void 0,(function*(){const n=t[St.COLUMN_NAME_LOCAL_DATA];if(n){const r=JSON.parse(n);t[St.COLUMN_NAME_BOARD]=kn.getContentAttribute(r.board),t[St.COLUMN_NAME_MEDIUM]=kn.getContentAttribute(r.medium),t[St.COLUMN_NAME_GRADE]=kn.getContentAttribute(r.gradeLevel),yield e.update({table:St.TABLE_NAME,modelJson:t,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[St.COLUMN_NAME_IDENTIFIER]]}).toPromise()}})))})).toPromise()}))}queries(){return[St.getAlterEntryForBoard(),St.getAlterEntryForMedium(),St.getAlterEntryForGrade()]}}class Cc extends ke{constructor(e){super(e,"LOW_MEMORY"),Object.setPrototypeOf(this,Cc.prototype)}}var vc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class yc{constructor(e){this.dbService=e}execute(e){return Object(c.defer)(()=>vc(this,void 0,void 0,(function*(){const t=yield this.getFreeUsableSpace(e.destinationFolder),n=new Ss(this.dbService),r=yield n.getContentUsageSummary([e.sourceFolder]);let i=0;if(r&&r.length&&(i=r[0].sizeOnDevice),kn.isFreeSpaceAvailable(t,i,0))return e;throw new Cc("Available memory not sufficient for transfer operation")})))}getFreeUsableSpace(e){return vc(this,void 0,void 0,(function*(){return new Promise((t,n)=>{sbutility.getFreeUsableSpace(e,e=>{t(Number(e))},e=>{n(e)})})}))}}var mc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class bc{constructor(e,t){this.fileService=e,this.appConfig=t}execute(e){return Object(c.defer)(()=>mc(this,void 0,void 0,(function*(){return e.validContentIdsInDestination=yield this.getSubdirectoriesEntries(e.destinationFolder).then(e=>this.extractValidContentIdsInDestination(e)),e})))}getSubdirectoriesEntries(e){return mc(this,void 0,void 0,(function*(){return this.fileService.listDir(e.replace(/\/$/,"")).then(e=>e.filter(e=>e.isDirectory))}))}extractValidContentIdsInDestination(e){return mc(this,void 0,void 0,(function*(){const t=[];for(const n of e)if(n.isDirectory){let e;try{e=yield this.extractManifest(n)}catch(e){}if(!e)continue;const r=e.archive.items;for(const e of r)kn.readVisibility(e)!==Cn.PARENT&&(kn.isDraftContent(e.status)&&kn.isExpired(e.expires)||t.push(n.name))}return t}))}extractManifest(e){return mc(this,void 0,void 0,(function*(){const t=yield this.fileService.readAsText(e.nativeURL,Ln.MANIFEST.valueOf());return JSON.parse(t)}))}}class Ic{constructor(){}execute(e){return Object(c.of)(e)}}class Mc extends ke{constructor(e){super(e,"DUPLICATE_CONTENT"),Object.setPrototypeOf(this,Mc.prototype)}}var Rc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Lc=St.COLUMN_NAME_IDENTIFIER,Pc=St.COLUMN_NAME_LOCAL_DATA;class Dc{constructor(e,t){this.dbService=e,this.fileService=t}execute(e){return Object(c.defer)(()=>Rc(this,void 0,void 0,(function*(){const t=yield this.getContentsInDb(e.contentIds);let n=[];e.validContentIdsInDestination&&e.validContentIdsInDestination.length&&(n=yield this.getContentsInDb(e.validContentIdsInDestination));const r=(yield this.generateMoveContentResponses(e,n)).moveContentDupContentList;if(e.contentsInSource=t,e.duplicateContents=r,e.duplicateContents.length&&!e.shouldMergeInDestination)throw new Mc("context.shouldMergeInDestination is false")}))).pipe(Object(D.mapTo)(e))}getContentsInDb(e){return Rc(this,void 0,void 0,(function*(){return e.length?this.dbService.execute(kn.getFindAllContentsWithIdentifierQuery(e)).toPromise():this.dbService.execute(kn.getFindAllContentsQuery()).toPromise()}))}getPkgVersionFromFile(e,t){return this.fileService.readAsText(e.concat(t),Ln.MANIFEST.valueOf()).then(e=>{const n=JSON.parse(e).archive.items;if(n){return n.find(e=>e.identifier===t).pkgVersion}return 0}).catch(()=>-1)}generateMoveContentResponses(e,t){return Rc(this,void 0,void 0,(function*(){const n=[],r=[];for(const i of t){const t=yield this.getPkgVersionFromFile(e.destinationFolder,i[Lc]),o=kn.readPkgVersion(JSON.parse(i[Pc]));if(-1!==t)if(t>o){const e={identifier:i[Lc],status:Jc.HIGHER_VERSION_IN_DESTINATION};n.push(e),r.push(e)}else if(t<o){const e={identifier:i[Lc],status:Jc.LOWER_VERSION_IN_DESTINATION};n.push(e),r.push(e)}else{const e={identifier:i[Lc],status:Jc.SAME_VERSION_IN_BOTH};r.push(e)}}return{moveContentDiffPkgList:n,moveContentDupContentList:r}}))}}class wc extends ke{constructor(e){super(e,"CANCELLED"),Object.setPrototypeOf(this,wc.prototype)}}var Uc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},jc=St.COLUMN_NAME_IDENTIFIER,Fc=St.COLUMN_NAME_PATH;class kc{constructor(e){this.eventsBusService=e,this.contentsTransferred=0}execute(e){return Object(c.defer)(()=>Uc(this,void 0,void 0,(function*(){for(const t of e.contentsInSource){if(e.hasTransferCancelled)throw yield this.deleteFolder(e.destinationFolder.concat("temp","/")),new wc("CANCELLED");const n=e.duplicateContents.find(e=>e.identifier===t[jc]);if(n&&!wn.isEmpty(e.duplicateContents))if(e.existingContentAction)if(n.status!==Jc.SAME_VERSION_IN_BOTH){switch(e.existingContentAction){case Ga.KEEP_HIGER_VERSION:if(n.status===Jc.HIGHER_VERSION_IN_DESTINATION)break;yield this.copyToTempDestination(e,t,n),yield this.removeSourceAndDestination(e,t,n);break;case Ga.KEEP_LOWER_VERSION:if(n.status===Jc.LOWER_VERSION_IN_DESTINATION)break;yield this.copyToTempDestination(e,t,n),yield this.removeSourceAndDestination(e,t,n);break;case Ga.KEEP_SOURCE:yield this.copyToTempDestination(e,t,n),yield this.removeSourceAndDestination(e,t,n);break;case Ga.IGNORE:case Ga.KEEP_DESTINATION:}this.emitContentTransferProgress(e)}else this.emitContentTransferProgress(e);else this.emitContentTransferProgress(e);else{const n=e.destinationFolder.concat("temp","/");try{yield this.copyFolder(t[Fc],n+t[jc])}catch(e){}this.emitContentTransferProgress(e)}}return e})))}emitContentTransferProgress(e){this.eventsBusService.emit({namespace:M.STORAGE,event:{type:Ya.TRANSFER_PROGRESS,payload:{progress:{transferredCount:++this.contentsTransferred,totalCount:e.contentsInSource.length}}}})}deleteFolder(e){return Uc(this,void 0,void 0,(function*(){if(e)return new Promise((t,n)=>{sbutility.rm(e,"",()=>{t(void 0)},e=>{n(e)})})}))}copyFolder(e,t){return Uc(this,void 0,void 0,(function*(){if(e&&t)return new Promise((n,r)=>{sbutility.copyDirectory(e,t,()=>{n(void 0)},e=>{r(e)})})}))}renameFolder(e,t){return Uc(this,void 0,void 0,(function*(){if(e)return new Promise((n,r)=>{sbutility.renameDirectory(e,t,()=>{n(void 0)},e=>{r(e)})})}))}copyToTempDestination(e,t,n){return Uc(this,void 0,void 0,(function*(){yield this.renameFolder(e.destinationFolder,n.identifier),yield this.copyFolder(t[Fc],e.destinationFolder+t[jc])}))}removeSourceAndDestination(e,t,n){return Uc(this,void 0,void 0,(function*(){yield this.deleteFolder(e.destinationFolder.concat(n.identifier,"_temp")),yield this.deleteFolder(t[Fc])}))}}var xc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Bc=St.COLUMN_NAME_PATH,Vc=St.COLUMN_NAME_IDENTIFIER;class Yc{constructor(e){this.dbService=e}execute(e){return Object(c.defer)(()=>xc(this,void 0,void 0,(function*(){this.dbService.beginTransaction();try{for(const t of e.contentsInSource)t[Bc]=kn.getBasePath(e.destinationFolder.concat(t[Vc],"/")),yield this.dbService.update({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[St.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise();this.dbService.endTransaction(!0)}catch(e){this.dbService.endTransaction(!1)}}))).pipe(Object(D.mapTo)(e))}}var Gc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Hc{constructor(e,t,n,r){this.appConfig=e,this.fileService=t,this.dbService=n,this.deviceInfo=r}execute(e){return Object(c.defer)(()=>Gc(this,void 0,void 0,(function*(){let t;for(const t of e.duplicateContents)switch(e.existingContentAction||Ga.IGNORE){case Ga.KEEP_HIGER_VERSION:t.status===Jc.HIGHER_VERSION_IN_DESTINATION&&this.addDestinationContentInDb(t.identifier,e.destinationFolder,!1);break;case Ga.KEEP_LOWER_VERSION:t.status===Jc.LOWER_VERSION_IN_DESTINATION&&this.addDestinationContentInDb(t.identifier,e.destinationFolder,!0);break;case Ga.KEEP_DESTINATION:case Ga.IGNORE:t.status===Jc.LOWER_VERSION_IN_DESTINATION?this.addDestinationContentInDb(t.identifier,e.destinationFolder,!0):this.addDestinationContentInDb(t.identifier,e.destinationFolder,!1)}if(e.validContentIdsInDestination&&e.validContentIdsInDestination.length&&e.duplicateContents&&e.duplicateContents.length?t=this.getNewlyAddedContents(e.validContentIdsInDestination,e.duplicateContents.map(e=>e.identifier)):e.validContentIdsInDestination&&e.duplicateContents.length||!e.validContentIdsInDestination||!e.validContentIdsInDestination.length||(t=e.validContentIdsInDestination),t)for(const n of t)yield this.addDestinationContentInDb(n,e.destinationFolder,!1)})))}getNewlyAddedContents(e,t){return e.filter(e=>t.find(t=>t!==e))}addDestinationContentInDb(e,t,n){const r=t.concat(e);return this.fileService.readAsText(t.concat(e),Ln.MANIFEST.valueOf()).then(e=>{const t=JSON.parse(e),i=t.archive.items;return this.extractContentFromItem(i,r.concat("/"),t.ver,n)}).catch(e=>{console.error(e)})}extractContentFromItem(e,t,n,r){return Gc(this,void 0,void 0,(function*(){const i=[],o=[];for(const s of e){let e=s;const a=e.identifier,c=e.mimeType,u=kn.readContentType(e),l=kn.readPrimaryCategory(e);let d=kn.readVisibility(e);const h=kn.readAudience(e),E=kn.readPragma(e),f=e.pkgVersion;let p=Nn.ONLY_SPINE.valueOf();const _=e.board,O=e.medium,S=e.gradeLevel,g=(yield this.dbService.read({table:St.TABLE_NAME,columns:[],selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[a]}).toPromise())[0],A=g&&kn.getBasePath(g[St.COLUMN_NAME_PATH]);let N=kn.doesContentExist(g,a,f,r);N&&e.status!==vn.DRAFT.valueOf()?g[St.COLUMN_NAME_VISIBILITY]===Cn.DEFAULT.valueOf()&&(e=JSON.parse(g[St.COLUMN_NAME_LOCAL_DATA])):(N=!1,p=(Tn.COLLECTION.valueOf(),Nn.ARTIFACT_AVAILABLE.valueOf()));const T=kn.getReferenceCount(g,d);d=kn.getContentVisibility(g,e.objectType,d),p=kn.getContentState(g,p);const C=N?A:t,v=yield this.fileService.getDirectorySize(C);kn.addOrUpdateViralityMetadata(e,this.deviceInfo.getDeviceID().toString());const y=kn.constructContentDBModel(a,n,JSON.stringify(e),c,u,d,C,T,p,h,E,v,_,O,S,l);g?o.push(y):i.push(y)}if(i.length||o.length){this.dbService.beginTransaction();for(const e of i){const t=e;yield this.dbService.insert({table:St.TABLE_NAME,modelJson:t}).toPromise()}for(const e of o){const t=e;yield this.dbService.update({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[St.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise()}this.dbService.endTransaction(!0)}}))}}var $c=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class qc{constructor(e){this.fileService=e}execute(e){return Object(c.defer)(()=>$c(this,void 0,void 0,(function*(){return e.destinationFolder=yield this.validate(e.destinationFolder).then(e=>this.createDirectory(e)),e})))}validate(e){return this.canWrite(e).then(()=>(e.endsWith("content/")||(e=e.concat("content")),e)).catch(()=>{throw Error("Destination is not writable")})}createDirectory(e){return this.fileService.exists(e).then(e=>e.nativeURL).catch(()=>this.fileService.createDir(e,!1).then(e=>e.nativeURL))}canWrite(e){return $c(this,void 0,void 0,(function*(){return new Promise((t,n)=>{sbutility.canWrite(e,()=>{t(void 0)},e=>{n(e)})})}))}}var Kc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},zc=St.COLUMN_NAME_IDENTIFIER,Wc=St.COLUMN_NAME_PATH;class Xc{constructor(e){this.eventsBusService=e}execute(e){return Object(c.defer)(()=>Kc(this,void 0,void 0,(function*(){for(let t=0;t<e.contentsInSource.length;t++){const n=e.contentsInSource[t],r=e.duplicateContents.find(e=>e.identifier===n[zc]),i=e.destinationFolder.concat("temp","/");if(r&&!wn.isEmpty(e.duplicateContents)){if(e.existingContentAction&&r.status!==Jc.SAME_VERSION_IN_BOTH){switch(e.existingContentAction){case Ga.KEEP_HIGER_VERSION:if(r.status===Jc.HIGHER_VERSION_IN_DESTINATION)break;yield this.removeSourceAndDestination(e,n,r);break;case Ga.KEEP_LOWER_VERSION:if(r.status===Jc.LOWER_VERSION_IN_DESTINATION)break;yield this.removeSourceAndDestination(e,n,r);break;case Ga.KEEP_SOURCE:yield this.removeSourceAndDestination(e,n,r);break;case Ga.IGNORE:case Ga.KEEP_DESTINATION:}t===e.contentsInSource.length-1&&(yield this.deleteFolder(i))}}else try{yield this.copyFolder(i.concat(n[zc]),e.destinationFolder+n[zc]),yield this.deleteFolder(i.concat(n[zc])),yield this.deleteFolder(n[Wc]),t===e.contentsInSource.length-1&&(yield this.deleteFolder(i))}catch(e){}}return e})))}deleteFolder(e){return Kc(this,void 0,void 0,(function*(){if(e)return new Promise((t,n)=>{sbutility.rm(e,"",()=>{t(void 0)},e=>{n(e)})})}))}copyFolder(e,t){return Kc(this,void 0,void 0,(function*(){if(e&&t)return new Promise((n,r)=>{sbutility.copyDirectory(e,t,()=>{n(void 0)},e=>{r(e)})})}))}renameFolder(e,t){return Kc(this,void 0,void 0,(function*(){if(e)return new Promise((n,r)=>{sbutility.renameDirectory(e,t,()=>{n(void 0)},e=>{r(e)})})}))}removeSourceAndDestination(e,t,n){return Kc(this,void 0,void 0,(function*(){yield this.deleteFolder(e.destinationFolder.concat(n.identifier,"_temp")),yield this.deleteFolder(t[Wc])}))}}var Jc,Qc=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};!function(e){e.SAME_VERSION_IN_BOTH="SAME_VERSION_IN_BOTH",e.HIGHER_VERSION_IN_DESTINATION="HIGHER_VERSION_IN_DESTINATION",e.LOWER_VERSION_IN_DESTINATION="LOWER_VERSION_IN_DESTINATION"}(Jc||(Jc={}));class Zc{constructor(e,t,n,r,i){this.sdkConfig=e,this.fileService=t,this.dbService=n,this.eventsBusService=r,this.deviceInfo=i,this.context={}}transfer({contentIds:e,existingContentAction:t,deleteDestination:n,destinationFolder:r,shouldMergeInDestination:i,sourceFolder:o}){return this.context.hasTransferCancelled=!1,this.context.shouldMergeInDestination=i,this.context.contentIds=e,this.context.existingContentAction=t,this.context.deleteDestination=n,this.context.destinationFolder=r,this.context.sourceFolder=o,new qc(this.fileService).execute(this.context).pipe(Object(D.mergeMap)(e=>(new Ic).execute(e)),Object(D.mergeMap)(e=>new yc(this.dbService).execute(e)),Object(D.mergeMap)(e=>new bc(this.fileService,this.sdkConfig.appConfig).execute(e)),Object(D.mergeMap)(e=>new Dc(this.dbService,this.fileService).execute(e)),Object(D.mergeMap)(e=>new kc(this.eventsBusService).execute(e)),Object(D.mergeMap)(e=>new Xc(this.eventsBusService).execute(e)),Object(D.mergeMap)(e=>new Yc(this.dbService).execute(e)),Object(D.mergeMap)(e=>new Hc(this.sdkConfig.appConfig,this.fileService,this.dbService,this.deviceInfo).execute(e))).pipe(Object(D.tap)(()=>{this.eventsBusService.emit({namespace:M.STORAGE,event:{type:Ya.TRANSFER_COMPLETED}})}),Object(D.mapTo)(void 0),Object(D.catchError)(e=>(e instanceof wc?this.eventsBusService.emit({namespace:M.STORAGE,event:{type:Ya.TRANSFER_REVERT_COMPLETED}}):e instanceof Mc?this.eventsBusService.emit({namespace:M.STORAGE,event:{type:Ya.TRANSFER_FAILED_DUPLICATE_CONTENT}}):e instanceof Cc&&this.eventsBusService.emit({namespace:M.STORAGE,event:{type:Ya.TRANSFER_FAILED_LOW_MEMORY}}),console.error("Error",e),Object(c.throwError)(e))))}cancel(){return Object(c.defer)(()=>Qc(this,void 0,void 0,(function*(){this.context.hasTransferCancelled=!0}))).pipe(Object(D.mapTo)(void 0))}}var eu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class tu{constructor(e,t){this.fileService=e,this.dbService=t}execute(e){return Object(c.defer)(()=>eu(this,void 0,void 0,(function*(){const t=yield this.getContentsInDb();if(e.currentStoragePath){let n=kn.getContentRootDir(e.currentStoragePath).concat("/");"ios"===window.device.platform.toLowerCase()&&(n="file://"+n);const r=yield this.getFolderList(n);e.newlyAddedIdentifiers=yield this.getNewlyAddedContents(r,t),e.deletedIdentifiers=yield this.getDeletedContents(r,t)}else e.newlyAddedIdentifiers=[],e.deletedIdentifiers=t}))).pipe(Object(D.mapTo)(e))}doesDestinationStorageExist(e){return this.fileService.exists(e).then(()=>!0).catch(()=>!1)}getContentsInDb(){return eu(this,void 0,void 0,(function*(){return this.dbService.execute(kn.getFindAllContentsQuery()).pipe(Object(D.map)(e=>e.filter(e=>"textbookunit"!==e[St.COLUMN_NAME_CONTENT_TYPE].toLowerCase()).map(e=>e[St.COLUMN_NAME_IDENTIFIER]))).toPromise()}))}getNewlyAddedContents(e,t){return e.filter(e=>!wn.contains(t,e))}getDeletedContents(e,t){return t.filter(t=>!wn.contains(e,t))}getFolderList(e){return this.fileService.listDir(e.replace(/\/$/,"")).then(e=>e.map(e=>e.name)).catch(()=>[])}}var nu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ru{constructor(e){this.storageHandler=e}exexute(e){return Object(c.defer)(()=>nu(this,void 0,void 0,(function*(){if(e.deletedIdentifiers.length&&(yield this.storageHandler.deleteContentsFromDb(e.deletedIdentifiers)),e.newlyAddedIdentifiers.length)for(const t of e.newlyAddedIdentifiers)yield this.storageHandler.addDestinationContentInDb(t,kn.getContentRootDir(e.currentStoragePath).concat("/"),!1)}))).pipe(Object(D.mapTo)(e))}}var iu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ou{constructor(e,t,n,r){this.appConfig=e,this.fileService=t,this.dbService=n,this.deviceInfo=r}addDestinationContentInDb(e,t,n){return iu(this,void 0,void 0,(function*(){const r=t.concat(e);this.fileService.readAsText(t.concat(e),Ln.MANIFEST.valueOf()).then(e=>{const t=JSON.parse(e),i=t.archive.items;return this.extractContentFromItem(i,r.concat("/"),t.ver,n)}).catch(e=>{console.error(e)})}))}deleteContentsFromDb(e){return iu(this,void 0,void 0,(function*(){const t=yield this.dbService.execute(kn.getFindAllContentsWithIdentifierQuery(e)).toPromise();for(const e of t){const t=e;if(t[St.COLUMN_NAME_MIME_TYPE]===Tn.COLLECTION&&t[St.COLUMN_NAME_REF_COUNT]>1?t[St.COLUMN_NAME_CONTENT_STATE]=Nn.ARTIFACT_AVAILABLE:t[St.COLUMN_NAME_CONTENT_STATE]=Nn.ONLY_SPINE,t[St.COLUMN_NAME_VISIBILITY]===Cn.DEFAULT&&t[St.COLUMN_NAME_REF_COUNT]>0){const e=t[St.COLUMN_NAME_REF_COUNT];t[St.COLUMN_NAME_REF_COUNT]=kn.addOrUpdateRefCount(e-1)}t[St.COLUMN_NAME_VISIBILITY]=Cn.PARENT}this.dbService.beginTransaction();for(const e of t){const t=e;yield this.dbService.update({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[St.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise()}this.dbService.endTransaction(!0)}))}extractContentFromItem(e,t,n,r){return iu(this,void 0,void 0,(function*(){const i=[],o=[];for(const s of e){let e=s;const a=e.identifier,c=e.mimeType,u=kn.readContentType(e),l=kn.readPrimaryCategory(e);let d=kn.readVisibility(e);const h=kn.readAudience(e),E=kn.readPragma(e),f=e.pkgVersion;let p=Nn.ONLY_SPINE.valueOf();const _=e.board,O=e.medium,S=e.gradeLevel,g=(yield this.dbService.read({table:St.TABLE_NAME,columns:[],selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[a]}).toPromise())[0],A=g&&kn.getBasePath(g[St.COLUMN_NAME_PATH]);let N=kn.doesContentExist(g,a,f,r);N&&e.status!==vn.DRAFT.valueOf()?g[St.COLUMN_NAME_VISIBILITY]===Cn.DEFAULT.valueOf()&&(e=JSON.parse(g[St.COLUMN_NAME_LOCAL_DATA])):(N=!1,p=(Tn.COLLECTION.valueOf(),Nn.ARTIFACT_AVAILABLE.valueOf()));const T=kn.getReferenceCount(g,d);d=kn.getContentVisibility(g,e.objectType,d),p=kn.getContentState(g,p);const C=N?A:t,v=yield this.fileService.getDirectorySize(C);kn.addOrUpdateViralityMetadata(e,this.deviceInfo.getDeviceID().toString());const y=kn.constructContentDBModel(a,n,JSON.stringify(e),c,u,d,C,T,p,h,E,v,_,O,S,l);g?o.push(y):i.push(y)}if(i.length||o.length){this.dbService.beginTransaction();for(const e of i){const t=e;yield this.dbService.insert({table:St.TABLE_NAME,modelJson:t}).toPromise()}for(const e of o){const t=e;yield this.dbService.update({table:St.TABLE_NAME,selection:St.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[t[St.COLUMN_NAME_IDENTIFIER]],modelJson:t}).toPromise()}this.dbService.endTransaction(!0)}}))}}var su,au=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},cu=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},uu=function(e,t){return function(n,r){t(n,r,e)}},lu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let du=su=class{constructor(e,t,n,r,i,o){this.eventsBusService=e,this.sharedPreferences=t,this.dbService=n,this.deviceInfo=r,this.fileService=i,this.sdkConfig=o,this.contentsToTransfer=new gs(this.sharedPreferences,g.KEY_TO_TRANSFER_LIST,e=>e),this.transferContentHandler=new Zc(this.sdkConfig,this.fileService,this.dbService,this.eventsBusService,this.deviceInfo)}onInit(){return Object(c.zip)(this.deviceInfo.getStorageVolumes(),this.getStorageDestination()).pipe(Object(D.tap)(e=>{this.availableStorageVolumes=e[0],this.currentStorageDestination=e[1],this.scanStorage().toPromise()}),Object(D.mapTo)(void 0))}getStorageDestinationDirectoryPath(){const e=this.availableStorageVolumes.find(e=>e.storageDestination===this.currentStorageDestination);return e&&e.info.contentStoragePath}cancelTransfer(){return this.transferContentHandler.cancel()}getStorageDestination(){return this.sharedPreferences.getString(su.STORAGE_DESTINATION).pipe(Object(D.map)(e=>e||Va.INTERNAL_STORAGE))}getStorageDestinationVolumeInfo(){return this.getStorageDestination().pipe(Object(D.map)(e=>this.availableStorageVolumes.find(t=>t.storageDestination===e)))}getToTransferContents(){return Object(c.of)([])}getTransferringContent(){return Object(c.of)(void 0)}retryCurrentTransfer(){return this.lastTransferContentsRequest?this.transferContents(Object.assign(Object.assign({},this.lastTransferContentsRequest),{shouldMergeInDestination:!0})):Object(c.of)(void 0)}transferContents(e){return this.lastTransferContentsRequest=e,e.sourceFolder=this.getStorageDestinationDirectoryPath(),this.transferContentHandler.transfer(e).pipe(Object(D.mergeMap)(()=>this.getStorageDestination()),Object(D.map)(e=>e===Va.EXTERNAL_STORAGE?Va.INTERNAL_STORAGE:Va.EXTERNAL_STORAGE),Object(D.tap)(e=>{this.currentStorageDestination=e}),Object(D.mergeMap)(e=>this.sharedPreferences.putString(su.STORAGE_DESTINATION,e)))}scanStorage(){const e=this.getStorageDestinationDirectoryPath(),t={currentStoragePath:e};return e||this.resetStorageDestination(),new tu(this.fileService,this.dbService).execute(t).pipe(Object(D.mergeMap)(e=>{const t=new ou(this.sdkConfig.appConfig,this.fileService,this.dbService,this.deviceInfo);return new ru(t).exexute(e)}),Object(D.mapTo)(!0))}resetStorageDestination(){return lu(this,void 0,void 0,(function*(){return this.currentStorageDestination=Va.INTERNAL_STORAGE,this.sharedPreferences.putString(su.STORAGE_DESTINATION,Va.INTERNAL_STORAGE).toPromise()}))}};var hu,Eu;du.STORAGE_DESTINATION=g.KEY_STORAGE_DESTINATION,du=su=au([Object(s.injectable)(),uu(0,Object(s.inject)(l.EVENTS_BUS_SERVICE)),uu(1,Object(s.inject)(l.SHARED_PREFERENCES)),uu(2,Object(s.inject)(l.DB_SERVICE)),uu(3,Object(s.inject)(l.DEVICE_INFO)),uu(4,Object(s.inject)(l.FILE_SERVICE)),uu(5,Object(s.inject)(l.SDK_CONFIG)),cu("design:paramtypes",[Object,Object,o,Object,Object,Object])],du),function(e){e[e.ACTIONABLE_NOTIFICATION=1]="ACTIONABLE_NOTIFICATION",e[e.NOTIFY=2]="NOTIFY",e[e.CONFIG=3]="CONFIG"}(hu||(hu={})),function(e){e.READ="read",e.UNREAD="unread",e.ALL="all"}(Eu||(Eu={}));class fu{static constructNotificationDBModel(e){return{message_id:e.id,expiry_time:e.expiry,display_time:e.displayTime,received_at:Date.now(),notification_json:JSON.stringify(e),is_read:e.isRead}}static getFilterForNotification(e){let t,n;switch(e.notificationStatus){case Eu.ALL:t=`${mt.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME} <= ?\n AND ${mt.COLUMN_NAME_EXPIRY_TIME} > ?`,n=[Date.now().toString(),Date.now().toString()];break;case Eu.UNREAD:t=`${mt.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME} <= ?\n AND ${mt.COLUMN_NAME_EXPIRY_TIME} > ? AND\n AND ${mt.COLUMN_NAME_IS_READ} > ?`,n=[Date.now().toString(),Date.now().toString(),0];break;case Eu.READ:default:t=`${mt.COLUMN_NAME_NOTIFICATION_DISPLAY_TIME} <= ?\n AND ${mt.COLUMN_NAME_EXPIRY_TIME} > ?\n AND ${mt.COLUMN_NAME_IS_READ} > ?`,n=[Date.now().toString(),Date.now().toString(),1]}return{table:mt.TABLE_NAME,orderBy:mt.COLUMN_NAME_NOTIFICATION_RECEIVED_AT+" desc"}}}var pu,_u=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ou=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Su=function(e,t){return function(n,r){t(n,r,e)}},gu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},Au=mt.COLUMN_NAME_NOTIFICATION_JSON;let Nu=pu=class{constructor(e,t,n,r){this.dbService=e,this.sharedPreferences=t,this.profileService=n,this.keyValueStore=r,this._notifications$=new c.BehaviorSubject([]),this._notificationTrigger$=new c.Subject}get notifications$(){return this._notifications$}onInit(){const e=Object(c.interval)(36e5).pipe(Object(D.startWith)(null),Object(D.mapTo)(null)),t=this._notificationTrigger$.pipe(Object(D.startWith)(null),Object(D.throttleTime)(1e3));return Object(c.combineLatest)([e,t]).pipe(Object(D.switchMap)(()=>Object(c.defer)(()=>gu(this,void 0,void 0,(function*(){try{const e=yield this.fetchNotificationAndUserFeed();this._notifications$.next(e)}catch(e){console.error(e)}})))),Object(D.mapTo)(void 0))}addNotification(e){return e.actionData&&"codePush"===e.actionData.actionType&&e.actionData.deploymentKey&&this.sharedPreferences.putString(N.DEPLOYMENT_KEY,e.actionData.deploymentKey),this.dbService.read({table:mt.TABLE_NAME,selection:mt.COLUMN_NAME_MESSAGE_ID+"= ?",selectionArgs:[e.id.toString()],limit:"1"}).pipe(Object(D.mergeMap)(t=>t&&t.length?this.dbService.update({table:mt.TABLE_NAME,selection:mt.COLUMN_NAME_MESSAGE_ID+"= ?",selectionArgs:[e.id.toString()],modelJson:fu.constructNotificationDBModel(e)}).pipe(Object(D.mapTo)(!0)):this.dbService.insert({table:mt.TABLE_NAME,modelJson:fu.constructNotificationDBModel(e)}).pipe(Object(D.mapTo)(!0))),Object(D.tap)(()=>this.triggerNotificationChange()))}deleteNotification(e){if("USER_FEED"===e.source)return this.profileService.deleteUserFeedEntry({feedEntryId:e.id,category:Qn.UserFeedCategory.NOTIFICATION}).pipe(Object(D.tap)(()=>this.triggerNotificationChange()));const t=`DELETE FROM ${mt.TABLE_NAME} `.concat(e.id?`WHERE ${mt.COLUMN_NAME_MESSAGE_ID} = ${e.id}`:"");return this.dbService.execute(t).pipe(Object(D.mapTo)(!0),Object(D.tap)(()=>this.triggerNotificationChange()))}getAllNotifications(e){return this.dbService.read(fu.getFilterForNotification(e)).pipe(Object(D.map)(e=>e.map(e=>{const t=JSON.parse(e[Au]);return t.isRead=e[mt.COLUMN_NAME_IS_READ],t})))}updateNotification(e){return"USER_FEED"===e.source?this.profileService.updateUserFeedEntry({feedEntryId:e.id,category:Qn.UserFeedCategory.NOTIFICATION,request:{status:e.isRead?Qn.UserFeedStatus.READ:Qn.UserFeedStatus.UNREAD}}).pipe(Object(D.tap)(()=>this.triggerNotificationChange())):this.dbService.read({table:mt.TABLE_NAME,selection:mt.COLUMN_NAME_MESSAGE_ID+"= ?",selectionArgs:[e.id.toString()],limit:"1"}).pipe(Object(D.mergeMap)(t=>t&&t.length?this.dbService.update({table:mt.TABLE_NAME,selection:mt.COLUMN_NAME_MESSAGE_ID+"= ?",selectionArgs:[e.id.toString()],modelJson:fu.constructNotificationDBModel(e)}).pipe(Object(D.mapTo)(!0)):Object(c.of)(!1)),Object(D.tap)(()=>this.triggerNotificationChange()))}deleteAllNotifications(){return Object(c.defer)(()=>gu(this,void 0,void 0,(function*(){const e=this._notifications$.getValue();try{return yield Promise.all(e.map(e=>this.deleteNotification(e).toPromise())),!0}catch(e){return console.error(e),!1}})))}fetchNotificationAndUserFeed(){return gu(this,void 0,void 0,(function*(){const e=yield Promise.all([(()=>gu(this,void 0,void 0,(function*(){return this.getAllNotifications({notificationStatus:Eu.ALL}).toPromise()})))(),(()=>gu(this,void 0,void 0,(function*(){try{const e=yield this.profileService.getActiveProfileSession().toPromise(),t=`${pu.USER_NOTIFICATION_FEED_KEY}_${e.managedSession?e.managedSession.uid:e.uid}`;try{const e=yield this.profileService.getUserFeed().toPromise().then(e=>e.filter(e=>e.category===Qn.UserFeedCategory.NOTIFICATION));return this.keyValueStore.setValue(t,Object(an.gzip)(JSON.stringify(e))).toPromise(),e}catch(e){return this.keyValueStore.getValue(t).toPromise().then(e=>JSON.parse(Object(ii.ungzip)(e,{to:"string"}))).catch(e=>(console.error(e),[]))}}catch(e){return[]}})))()]),t=e[0],n=e[1];return t.concat(n.map(e=>({id:e.id,source:"USER_FEED",displayTime:new Date(e.createdOn).getTime(),expiry:e.expireOn?new Date(e.expireOn).getTime():0,isRead:"read"===e.status?1:0,actionData:e.data}))).sort((e,t)=>new Date(t.displayTime).getTime()-new Date(e.displayTime).getTime())}))}triggerNotificationChange(){return gu(this,void 0,void 0,(function*(){this._notificationTrigger$.next(null)}))}};var Tu;Nu.USER_NOTIFICATION_FEED_KEY="user_notification_feed",Nu=pu=_u([Object(s.injectable)(),Su(0,Object(s.inject)(l.DB_SERVICE)),Su(1,Object(s.inject)(l.SHARED_PREFERENCES)),Su(2,Object(s.inject)(l.PROFILE_SERVICE)),Su(3,Object(s.inject)(l.KEY_VALUE_STORE)),Ou("design:paramtypes",[o,Object,Object,Object])],Nu),function(e){e.CUSTODIAN_ORG_ID="custodianOrgId",e.COURSE_FRAMEWORK_ID="courseFrameworkId",e.ERROR_LOG_SYNC_SETTINGS="errorLogSyncSettings"}(Tu||(Tu={}));class Cu{static mapErrorSatckDBEntryToErrorStack(e){return{appver:e[Rt.COLUMN_NAME_APP_VERSION],pageid:e[Rt.COLUMN_NAME_PAGE_ID],ts:e[Rt.COLUMN_NAME_TIME_STAMP],log:e[Rt.COLUMN_NAME_ERROR_LOG]}}static mapErrorStackToErrorStackDBEntry(e){return{[Rt.COLUMN_NAME_APP_VERSION]:e.appver,[Rt.COLUMN_NAME_PAGE_ID]:e.pageid,[Rt.COLUMN_NAME_TIME_STAMP]:e.ts,[Rt.COLUMN_NAME_ERROR_LOG]:e.log}}}var vu=Rt._ID;class yu{constructor(e,t,n,r,i){this.apiService=e,this.dbService=t,this.errorLoggerConfig=n,this.networkInfoService=r,this.errorStackSyncRequestDecorator=i}handle(e){return this.processBatch(e).pipe(Object(D.expand)(t=>t>0?this.processBatch(e):c.EMPTY),Object(D.mapTo)(void 0),Object(D.catchError)(()=>Object(c.of)(void 0)))}processBatch(e){return this.getErrorStackBatch(e).pipe(Object(D.mergeMap)(e=>this.sync(e)),Object(D.mergeMap)(e=>this.clearLogs(e)),Object(D.map)(e=>e.length))}getErrorStackBatch(e){return this.dbService.execute(`\n SELECT * FROM ${Rt.TABLE_NAME}\n LIMIT ${e}\n `)}clearLogs(e){return e.length?this.dbService.execute(`\n DELETE FROM ${Rt.TABLE_NAME}\n WHERE ${Rt._ID} IN (${e.map(e=>e[vu]).join(",")})\n `).pipe(Object(D.mapTo)(e)):Object(c.of)(e)}sync(e){return e.length?this.networkInfoService.networkStatus$.pipe(Object(D.mergeMap)(t=>{if(t===Vn.OFFLINE)return Object(c.throwError)(new Error("Fake Error"));const n={pdata:void 0,context:void 0,logs:e.map(e=>Cu.mapErrorSatckDBEntryToErrorStack(e))};return this.errorStackSyncRequestDecorator.decorate(n).pipe(Object(D.mergeMap)(()=>{const e=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.errorLoggerConfig.errorLoggerApiPath).withBearerToken(!0).withBody({request:n}).build();return this.apiService.fetch(e)}))}),Object(D.mapTo)(e)):Object(c.of)(e)}}var mu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class bu{constructor(e,t,n){this.apiConfig=e,this.deviceInfo=t,this.appInfo=n}decorate(e){return Object(c.defer)(()=>mu(this,void 0,void 0,(function*(){return this.patchPData(e),yield this.patchContext(e),e})))}patchContext(e){return mu(this,void 0,void 0,(function*(){e.context={did:this.deviceInfo.getDeviceID(),spec:yield this.deviceInfo.getDeviceSpec().toPromise()}}))}patchPData(e){e.pdata=new ve,e.pdata.id=this.apiConfig.api_authentication.producerId;const t=e.pdata.pid;t?e.pdata.pid=t:this.apiConfig.api_authentication.producerUniqueId?e.pdata.pid=this.apiConfig.api_authentication.producerUniqueId:e.pdata.pid="sunbird.android",e.pdata.ver||(e.pdata.ver=this.appInfo.getVersionName())}}var Iu,Mu=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ru=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Lu=function(e,t){return function(n,r){t(n,r,e)}};let Pu=Iu=class{constructor(e,t,n,r,i,o,s,a){this.systemSettingsService=e,this.dbService=t,this.appInfo=n,this.apiService=r,this.sdkConfig=i,this.errorLoggerService=o,this.deviceInfo=s,this.sharedPreferences=a,this.errorLoggerConfig=this.sdkConfig.errorLoggerConfig,this.errorStackSyncRequestDecorator=new bu(this.sdkConfig.apiConfig,this.deviceInfo,this.appInfo),this.errorStackSyncHandler=new yu(this.apiService,this.dbService,this.errorLoggerConfig,this.errorLoggerService,this.errorStackSyncRequestDecorator)}onInit(){return this.sharedPreferences.getString(A.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP).pipe(Object(D.mergeMap)(e=>e?Object(c.of)(void 0):this.sharedPreferences.putString(A.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP,Date.now()+"")))}logError(e){const t={appver:this.appInfo.getVersionName(),pageid:e.pageId,ts:Date.now(),log:e.stacktrace};return this.dbService.insert({table:Rt.TABLE_NAME,modelJson:Cu.mapErrorStackToErrorStackDBEntry(t)}).pipe(Object(D.mergeMap)(()=>this.getErrorCount()),Object(D.mergeMap)(e=>this.getErrorLogSyncSettings().pipe(Object(D.map)(t=>Object.assign(Object.assign({},t),{errorCount:e})))),Object(D.map)(({errorCount:e,frequency:t,bandwidth:n})=>({errorCount:e,errorLogSyncFrequency:t,errorLogSyncBandwidth:n})),Object(D.mergeMap)(({errorCount:e,errorLogSyncFrequency:t,errorLogSyncBandwidth:n})=>this.hasErrorLogSyncFrequencyCrossed(e,t).pipe(Object(D.map)(e=>({shouldSync:e,errorLogSyncBandwidth:n})))),Object(D.mergeMap)(({shouldSync:e,errorLogSyncBandwidth:t})=>e?this.errorStackSyncHandler.handle(t).pipe(Object(D.mergeMap)(()=>this.sharedPreferences.putString(A.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP,Date.now()+""))):Object(c.of)(void 0)))}hasErrorLogSyncFrequencyCrossed(e,t){return this.sharedPreferences.getString(A.KEY_ERROR_LOG_LAST_SYNCED_TIME_STAMP).pipe(Object(D.map)(e=>parseInt(e,10)),Object(D.map)(e=>e+t<Date.now()))}getErrorCount(){return this.dbService.execute("SELECT COUNT(*) as count FROM "+Rt.TABLE_NAME).pipe(Object(D.map)(e=>e[0].count))}getErrorLogSyncSettings(){const e={id:Iu.ERROR_LOG_SYNC_SETTINGS};return this.systemSettingsService.getSystemSettings(e).pipe(Object(D.map)(e=>JSON.parse(e.value)))}};Pu.ERROR_LOG_SYNC_SETTINGS=Tu.ERROR_LOG_SYNC_SETTINGS,Pu=Iu=Mu([Object(s.injectable)(),Lu(0,Object(s.inject)(l.SYSTEM_SETTINGS_SERVICE)),Lu(1,Object(s.inject)(l.DB_SERVICE)),Lu(2,Object(s.inject)(l.APP_INFO)),Lu(3,Object(s.inject)(l.API_SERVICE)),Lu(4,Object(s.inject)(l.SDK_CONFIG)),Lu(5,Object(s.inject)(l.NETWORKINFO_SERVICE)),Lu(6,Object(s.inject)(l.DEVICE_INFO)),Lu(7,Object(s.inject)(l.SHARED_PREFERENCES)),Ru("design:paramtypes",[Object,o,Object,Object,Object,Object,Object,Object])],Pu);var Du=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},wu=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};let Uu=class{constructor(){"none"===navigator.connection.type?this.networkStatusSource=new c.BehaviorSubject(Vn.OFFLINE):this.networkStatusSource=new c.BehaviorSubject(Vn.ONLINE),window.addEventListener("online",()=>{this.networkStatusSource.next(Vn.ONLINE)},!1),window.addEventListener("offline",()=>{this.networkStatusSource.next(Vn.OFFLINE)},!1),this.networkStatus$=this.networkStatusSource.asObservable()}};Uu=Du([Object(s.injectable)(),wu("design:paramtypes",[])],Uu);var ju=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Fu extends i{constructor(){super(8,23)}apply(e){return ju(this,void 0,void 0,(function*(){this.queries().forEach(t=>ju(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()})))}))}queries(){return[Pt.getCreateEntry()]}}var ku=Pt.COLUMN_NAME_USER_ID,xu=Pt.COLUMN_NAME_QUERY,Bu=Pt.COLUMN_NAME_TIME_STAMP;var Vu,Yu=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Gu=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Hu=function(e,t){return function(n,r){t(n,r,e)}};let $u=Vu=class{constructor(e,t){this.dbService=e,this.profileService=t}addEntry({query:e,namespace:t}){return this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(({uid:n})=>this.dbService.insert({table:Pt.TABLE_NAME,modelJson:{[Pt.COLUMN_NAME_QUERY]:e.trim(),[Pt.COLUMN_NAME_NAMESPACE]:t,[Pt.COLUMN_NAME_USER_ID]:n,[Pt.COLUMN_NAME_TIME_STAMP]:Date.now()}}).pipe(Object(D.mapTo)(n))),Object(D.mergeMap)(e=>this.dbService.execute(`\n DELETE FROM ${Pt.TABLE_NAME} WHERE\n ${Pt._ID} IN (SELECT ${Pt._ID} FROM ${Pt.TABLE_NAME} WHERE\n ${Pt.COLUMN_NAME_USER_ID} = "${e}" AND\n ${Pt.COLUMN_NAME_NAMESPACE} = "${t}"\n ORDER BY ${Pt.COLUMN_NAME_TIME_STAMP} DESC\n LIMIT -1 OFFSET ${Vu.MAX_USER_SEARCH_HISTORY_ENTRIES})\n `)),Object(D.mapTo)(void 0))}getEntries({like:e,limit:t,namespace:n}){return this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(({uid:r})=>{let i="";return e&&(i=`AND ${Pt.COLUMN_NAME_QUERY} LIKE "%${e.trim()}%"`),this.dbService.execute(`\n SELECT * FROM ${Pt.TABLE_NAME} WHERE\n ${Pt.COLUMN_NAME_USER_ID} = "${r}" AND\n ${Pt.COLUMN_NAME_NAMESPACE} = "${n}"\n ${i}\n ORDER BY ${Pt.COLUMN_NAME_TIME_STAMP} DESC\n LIMIT ${t}\n `)}),Object(D.map)(e=>e.map(e=>class{static mapSearchHistoryDbEntryToSearchEntry(e){return{uid:e[ku],query:e[xu],timestamp:e[Bu]}}}.mapSearchHistoryDbEntryToSearchEntry(e))))}};$u.MAX_USER_SEARCH_HISTORY_ENTRIES=10,$u=Vu=Yu([Object(s.injectable)(),Hu(0,Object(s.inject)(l.DB_SERVICE)),Hu(1,Object(s.inject)(l.PROFILE_SERVICE)),Gu("design:paramtypes",[o,Object])],$u);var qu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ku extends i{constructor(){super(9,24)}apply(e){return qu(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise())),yield e.read({table:vt.TABLE_NAME}).pipe(Object(D.map)(t=>{t.forEach(t=>qu(this,void 0,void 0,(function*(){const n=t[vt.COLUMN_NAME_DATA];if(n){const r=JSON.parse(n);t[St.COLUMN_NAME_MIME_TYPE]=r.mimeType,yield e.update({table:vt.TABLE_NAME,modelJson:t,selection:vt.COLUMN_NAME_CONTENT_IDENTIFIER+" = ?",selectionArgs:[t[vt.COLUMN_NAME_CONTENT_IDENTIFIER]]}).toPromise()}})))})).toPromise()}))}queries(){return[vt.getAlterEntryForMimeType()]}}var zu=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Wu extends i{constructor(){super(10,25)}apply(e){return zu(this,void 0,void 0,(function*(){for(const t of this.queries())yield e.execute(t).toPromise()}))}queries(){return[wt.getCreateEntry()]}}var Xu=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ju=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Qu=function(e,t){return function(n,r){t(n,r,e)}};let Zu=class{constructor(e){this.sharedPreferences=e}setDefaultDeploymentKey(e){return this.sharedPreferences.putString(T.DEFAULT_DEPLOYMENT_KEY,e)}getDefaultDeploymentKey(){return this.sharedPreferences.getString(T.DEFAULT_DEPLOYMENT_KEY)}setExperimentKey(e){return this.sharedPreferences.putString(T.EXPERIMENT_KEY,e).pipe(Object(D.tap)(()=>{this.experimentKey||(this.experimentKey=e)}))}getExperimentKey(){return this.experimentKey?this.experimentKey:this.sharedPreferences.getString(T.EXPERIMENT_KEY).pipe(Object(D.tap)(e=>(this.experimentKey=e,e)))}setExperimentAppVersion(e){return this.sharedPreferences.putString(T.EXPERIMENT_APP_VERSION,e)}getExperimentAppVersion(){return this.sharedPreferences.getString(T.EXPERIMENT_APP_VERSION)}};Zu=Xu([Object(s.injectable)(),Qu(0,Object(s.inject)(l.SHARED_PREFERENCES)),Ju("design:paramtypes",[Object])],Zu);class el{constructor(e,t,n,r){this.apiService=e,this.faqServiceConfig=t,this.fileservice=n,this.cachedItemStore=r,this.FAQ_FILE_KEY_PREFIX="faq-",this.FAQ_LOCAL_KEY="faq-new-"}handle(e){return this.cachedItemStore.getCached(e.language,this.FAQ_LOCAL_KEY,"ttl_"+this.FAQ_LOCAL_KEY,()=>this.fetchFromServer(e),()=>this.fetchFromFile(e.language))}fetchFromServer(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withHost(e.faqUrl).withPath("/faq-"+e.language+".json").withBearerToken(!1).build();return this.apiService.fetch(t).pipe(Object(D.map)(e=>{let t;try{t=JSON.parse(e.body.trim())}catch(n){t=e.body}return t}))}fetchFromFile(e){const t=lr.getAssetPath()+this.faqServiceConfig.faqConfigDirPath,n=this.FAQ_FILE_KEY_PREFIX+e+".json";return Object(c.from)(this.fileservice.readFileFromAssets(t.concat("/",n))).pipe(Object(D.map)(e=>JSON.parse(e)))}}var tl=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},nl=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},rl=function(e,t){return function(n,r){t(n,r,e)}};let il=class{constructor(e,t,n,r){this.sdkConfig=e,this.fileService=t,this.apiService=n,this.cachedItemStore=r}getFaqDetails(e){return new el(this.apiService,this.sdkConfig.faqServiceConfig,this.fileService,this.cachedItemStore).handle(e)}};var ol;il=tl([Object(s.injectable)(),rl(0,Object(s.inject)(l.SDK_CONFIG)),rl(1,Object(s.inject)(l.FILE_SERVICE)),rl(2,Object(s.inject)(l.API_SERVICE)),rl(3,Object(s.inject)(l.CACHED_ITEM_STORE)),nl("design:paramtypes",[Object,Object,Object,Object])],il),function(e){e.CONTENT="content",e.PROFILE="profile",e.TELEMETRY="telemetry"}(ol||(ol={}));class sl extends ke{constructor(e,t){super(e,"ASSERTION_ERROR_"+t),Object.setPrototypeOf(this,sl.prototype)}}class al extends sl{constructor(e){super(e,"INVALID_REQUEST"),Object.setPrototypeOf(this,al.prototype)}}class cl extends sl{constructor(e){super(e,"OBJECT_NOT_FOUND"),Object.setPrototypeOf(this,cl.prototype)}}var ul=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class ll{constructor(e,t){this.dbService=e,this.fileService=t}export(e,t){return new c.Observable(e=>{(()=>{ul(this,void 0,void 0,(function*(){let n={task:"",completed:[]};e.next(n=Object.assign(Object.assign({},n),{task:"VALIDATING"}));try{yield this.validate()}catch(t){return void e.error(t)}e.next(n=Object.assign(Object.assign({},n),{task:"PREPARING"})),yield this.prepare(t),e.next(n=Object.assign(Object.assign({},n),{task:"INITIALIZING"})),yield this.createWorkspace();const r=yield this.getMessageIds();try{for(;r.length;){const t=r.pop();yield this.processBatch(t).then(t=>{if(!t)return void e.next(n=Object.assign(Object.assign({},n),{task:"SKIPPING_BATCH"}));const{file:r,mid:i,eventsCount:o,size:s}=t;e.next(n=Object.assign(Object.assign({},n),{task:"BUILDING_BATCH",completed:[...n.completed,{file:r,mid:i,eventsCount:o,size:s,objectType:ol.TELEMETRY,contentEncoding:"gzip",explodedSize:-1}]}))})}}catch(t){return void e.error(t)}e.next(n=Object.assign(Object.assign({},n),{task:"OBJECT_ARCHIVE_COMPLETE"})),e.complete()}))})()})}validate(){return ul(this,void 0,void 0,(function*(){if(!(yield this.dbService.execute(`\n SELECT count(*) as COUNT FROM ${jt.TABLE_NAME} WHERE ${jt.COLUMN_NAME_TYPE} = '${Ft.TELEMETRY}'\n `.trim()).pipe(Object(D.map)(e=>e&&e[0]&&e[0].COUNT)).toPromise()))throw new cl("No telemetry to export")}))}prepare(e){return ul(this,void 0,void 0,(function*(){this.workspaceSubPath=""+e.workspacePath}))}createWorkspace(){return ul(this,void 0,void 0,(function*(){return this.fileService.createDir(this.workspaceSubPath,!1)}))}getMessageIds(){return ul(this,void 0,void 0,(function*(){return(yield this.dbService.read({table:jt.TABLE_NAME,columns:[jt.COLUMN_NAME_MSG_ID],selection:jt.COLUMN_NAME_TYPE+" = ?",selectionArgs:[Ft.TELEMETRY],distinct:!0}).toPromise()).map(e=>e[jt.COLUMN_NAME_MSG_ID])}))}processBatch(e){return ul(this,void 0,void 0,(function*(){const t=(yield this.dbService.read({table:jt.TABLE_NAME,selection:`${jt.COLUMN_NAME_MSG_ID} = ? AND ${jt.COLUMN_NAME_TYPE} = ?`,selectionArgs:[e,Ft.TELEMETRY]}).toPromise())[0];if(t)return yield this.fileService.writeFile(this.workspaceSubPath,t[jt.COLUMN_NAME_MSG_ID],t[jt.COLUMN_NAME_DATA],{replace:!0}),{size:[jt.COLUMN_NAME_DATA].length,eventsCount:t[jt.COLUMN_NAME_NUMBER_OF_ITEM],mid:t[jt.COLUMN_NAME_MSG_ID],file:""+t[jt.COLUMN_NAME_MSG_ID]}}))}}class dl extends ke{constructor(e,t){super(e,"ASSERTION_ERROR_"+t),Object.setPrototypeOf(this,dl.prototype)}}class hl extends dl{constructor(e){super(e,"UNKNOWN_OBJECT_ERROR"),Object.setPrototypeOf(this,hl.prototype)}}var El=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class fl{constructor(e,t,n,r){this.dbService=e,this.fileService=t,this.networkQueue=n,this.sdkConfig=r}import(e,t){return new c.Observable(e=>{(()=>{El(this,void 0,void 0,(function*(){let n={task:"",pending:[]};const r=t.items;e.next({task:"PREPARING",pending:[...r]}),yield this.prepare(t);try{for(;r.length;){const t=r.pop();if("gzip"!==t.contentEncoding)return void e.error(new hl("Unknown content encoding "+t.contentEncoding));yield this.processBatch(t).then(()=>{e.next(n=Object.assign(Object.assign({},n),{task:"IMPORTING_BATCH",pending:[...r]}))})}}catch(t){return void e.error(t)}e.next(n=Object.assign(Object.assign({},n),{task:"OBJECT_IMPORT_COMPLETE"})),e.complete()}))})()})}prepare(e){return El(this,void 0,void 0,(function*(){this.workspaceSubPath=""+e.workspacePath}))}processBatch(e){return El(this,void 0,void 0,(function*(){return this.fileService.readAsBinaryString(this.workspaceSubPath,e.file).then(t=>{this.networkQueue.enqueue(new En(this.sdkConfig).generateNetworkQueueRequest(Ft.TELEMETRY,t,e.mid,e.eventsCount,!1),!1).toPromise()})}))}}class pl extends dl{constructor(e){super(e,"INVALID_ARCHIVE"),Object.setPrototypeOf(this,pl.prototype)}}var _l,Ol=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Sl=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},gl=function(e,t){return function(n,r){t(n,r,e)}};let Al=_l=class{constructor(e,t,n,r,i,o,s){this.fileService=e,this.dbService=t,this.telemetryService=n,this.zipService=r,this.deviceInfo=i,this.networkQueue=o,this.sdkConfig=s}static reduceObjectProgressToArchiveObjectExportProgress(e){return e.reduce((e,{type:t,progress:n})=>(e.set(t,n),e),new Map)}static reduceObjectProgressToArchiveObjectImportProgress(e){return e.reduce((e,{type:t,progress:n})=>(e.set(t,n),e),new Map)}export(e){const t=`${"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalCacheDirectory}${en.generateUniqueId()}`;let n;return e.objects.length?Object(c.concat)(Object(c.defer)(()=>Object(c.from)(this.fileService.createDir(t,!1))).pipe(Object(D.concatMap)(()=>Object(c.combineLatest)(e.objects.map(n=>{switch(n.type){case ol.CONTENT:case ol.PROFILE:throw new Error("To be implemented");case ol.TELEMETRY:return new ll(this.dbService,this.fileService).export({filePath:e.filePath},{workspacePath:t}).pipe(Object(D.map)(e=>({type:ol.TELEMETRY,progress:e})))}}))),Object(D.map)(e=>({task:"BUILDING",progress:_l.reduceObjectProgressToArchiveObjectExportProgress(e)})),Object(D.tap)(e=>n=e)),Object(c.defer)(()=>this.generateManifestFile(n,t)),Object(c.defer)(()=>this.generateZipArchive(n,t)),Object(c.defer)(()=>this.generateExportTelemetries(n,t))).pipe(Object(D.tap)(e=>n=e)):Object(c.throwError)(new al("No archive objects to export"))}generateExportTelemetries(e,t){return e.progress.forEach((e,t)=>{switch(t){case ol.CONTENT:case ol.PROFILE:throw new Error("To be implemented");case ol.TELEMETRY:{const e={dir:ne.OUT,type:re.FILE,items:[],env:"sdk"};this.telemetryService.share(e).toPromise()}}}),Object(c.of)(Object.assign({},e))}generateZipArchive(e,t){const n=`${"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalCacheDirectory}archive-${(new Date).toISOString()}.zip`;return new c.Observable(e=>{this.zipService.zip(t,{target:n},[],[],()=>{e.next(),e.complete()},t=>{e.error(t)})}).pipe(Object(D.mapTo)(Object.assign(Object.assign({},e),{task:"COMPLETE",filePath:n})))}generateManifestFile({progress:e},t){return this.telemetryService.buildContext().pipe(Object(D.map)(e=>e.pdata),Object(D.concatMap)(n=>{const r=Array.from(e.entries()).reduce((e,[t,n])=>e.concat(n.completed),[]);return Object(c.from)(this.fileService.writeFile(t,"manifest.json",JSON.stringify({id:_l.ARCHIVE_ID,ver:_l.ARCHIVE_VERSION,ts:(new Date).toISOString(),producer:n,archive:{count:r.length,items:r}}),{replace:!0}))}),Object(D.mapTo)({progress:e,task:"BUILDING_MANIFEST"}))}import(e){const t=`${"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalCacheDirectory}${en.generateUniqueId()}`;if(!e.objects.length)return Object(c.throwError)(new al("No archive objects to export"));let n={task:"",progress:new Map,filePath:e.filePath};return Object(c.concat)(Object(c.defer)(()=>Object(c.from)(this.fileService.createDir(t,!1))).pipe(Object(D.concatMap)(()=>this.extractZipArchive(n,t))),Object(c.defer)(()=>this.readManifestFile(n,t,e.objects.map(e=>e.type))),Object(c.defer)(()=>this.generateImportTelemetries(n,t)),Object(c.defer)(()=>Object(c.combineLatest)(e.objects.map(r=>{switch(r.type){case ol.CONTENT:case ol.PROFILE:throw new Error("To be implemented");case ol.TELEMETRY:return new fl(this.dbService,this.fileService,this.networkQueue,this.sdkConfig).import({filePath:e.filePath},{workspacePath:t,items:n.progress.get(ol.TELEMETRY).pending}).pipe(Object(D.map)(e=>({type:ol.TELEMETRY,progress:e})))}})).pipe(Object(D.map)(e=>({task:"IMPORTING",progress:_l.reduceObjectProgressToArchiveObjectImportProgress(e)})))),Object(c.of)(Object.assign(Object.assign({},n),{task:"COMPLETE"}))).pipe(Object(D.tap)(e=>n=e))}generateImportTelemetries(e,t){return e.progress.forEach((e,t)=>{switch(t){case ol.CONTENT:case ol.PROFILE:throw new Error("To be implemented");case ol.TELEMETRY:{const e={dir:ne.IN,type:re.FILE.valueOf(),items:[],env:"sdk"};this.telemetryService.share(e).toPromise()}}}),Object(c.of)(Object.assign({},e))}extractZipArchive(e,t){const n=e.filePath;return new c.Observable(e=>{sbutility.copyFile(Mo.getDirecory(n),t+"/",Mo.getFileName(n),()=>{this.zipService.unzip(`${t}/${Mo.getFileName(n)}`,{target:t+"/"},()=>{e.next(),e.complete()},t=>e.error(t))},t=>{console.error(t),e.error(t)})}).pipe(Object(D.mapTo)(Object.assign(Object.assign({},e),{task:"EXTRACTING"})))}readManifestFile(e,t,n){return Object(c.from)(this.fileService.readAsText(t,"manifest.json")).pipe(Object(D.map)(e=>{try{return JSON.parse(e)}catch(e){throw new pl("Invalid manfiest.json")}}),Object(D.map)(t=>Object.assign(Object.assign({},e),{progress:(n.forEach(n=>{const r=t.archive.items.filter(e=>e.objectType===n);if(!r.length)throw new pl("Nothing to import");e.progress.set(n,{task:"INITIALISING",pending:r})}),e.progress),task:"VALIDATING"})))}};Al.ARCHIVE_ID="sunbird.data.archive",Al.ARCHIVE_VERSION="1.0",Al=_l=Ol([Object(s.injectable)(),gl(0,Object(s.inject)(l.FILE_SERVICE)),gl(1,Object(s.inject)(l.DB_SERVICE)),gl(2,Object(s.inject)(l.TELEMETRY_SERVICE)),gl(3,Object(s.inject)(l.ZIP_SERVICE)),gl(4,Object(s.inject)(l.DEVICE_INFO)),gl(5,Object(s.inject)(l.NETWORK_QUEUE)),gl(6,Object(s.inject)(l.SDK_CONFIG)),Sl("design:paramtypes",[Object,o,Object,Object,Object,Object,Object])],Al);var Nl=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Tl extends i{constructor(e,t){super(14,27),this.sdkConfig=e,this.networkQueue=t}apply(e){return Nl(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise())),yield e.read({table:qe.TABLE_NAME,selection:"",selectionArgs:[]}).pipe(Object(D.map)(t=>{const n=new En(this.sdkConfig);t.forEach(t=>Nl(this,void 0,void 0,(function*(){if(t){const r=t[qe.COLUMN_NAME_MSG_ID],i=t[qe.COLUMN_NAME_DATA],o=t[qe.COLUMN_NAME_NUMBER_OF_EVENTS];yield this.networkQueue.enqueue(n.generateNetworkQueueRequest(Ft.TELEMETRY,i,r,o,!1),!1).toPromise(),yield e.execute(`DELETE FROM ${qe.TABLE_NAME} WHERE ${qe.COLUMN_NAME_MSG_ID}='${r}'`).toPromise()}})))})).toPromise()}))}queries(){return[jt.getCreateEntry()]}}var Cl=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},vl=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},yl=function(e,t){return function(n,r){t(n,r,e)}},ml=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let bl=class{constructor(e,t,n,r){this.dbService=e,this.sharedPreferences=t,this.deviceInfo=n,this.sdkConfig=r}enqueue(e,t){const n="Uint8Array"===this.getTypeOf(e.networkRequest.body)?e.networkRequest.body.buffer:e.networkRequest.body;return new c.Observable(r=>{(()=>{ml(this,void 0,void 0,(function*(){e.networkRequest=yield this.interceptRequest(e.networkRequest).toPromise(),sbsync.enqueue(n,jt.Mapper.networkQueueRequestToEntry(e),t,()=>{r.next(void 0),r.complete()},e=>{r.error(e)})}))})()})}interceptRequest(e){return this.sharedPreferences.getString(h.KEY_API_TOKEN).pipe(Object(D.map)(t=>{if(t){const n=e.headers;n.Authorization="Bearer "+t,e.headers=n}return e}),Object(D.mergeMap)(()=>this.sharedPreferences.getString(E.KEY_OAUTH_SESSION).pipe(Object(D.map)(t=>{if(t){const n=JSON.parse(t),r=e.headers;r["X-Authenticated-User-Token"]=n.access_token,n.managed_access_token&&(r["X-Authenticated-For"]=n.managed_access_token),e.headers=r}return e}))),Object(D.map)(()=>{e.headers["X-Channel-Id"]=this.sdkConfig.apiConfig.api_authentication.channelId,e.headers["X-App-Id"]=this.sdkConfig.apiConfig.api_authentication.producerId,e.headers["X-Device-Id"]=this.deviceInfo.getDeviceID(),e.headers.Accept="application/json",e.headers["Content-Type"]="application/json",e.headers["Access-Control-Allow-Origin"]="*",e.body={};return(new a.CsRequest.Builder).withSerializer(e.serializer).withHost(this.sdkConfig.apiConfig.host).withType(e.type).withPath(e.path).withHeaders(e.headers).withBody({}).withBearerToken(!0).build()}))}getTypeOf(e){switch(Object.prototype.toString.call(e)){case"[object Uint8Array]":return"Uint8Array";default:return"Unknown"}}};bl=Cl([Object(s.injectable)(),yl(0,Object(s.inject)(l.DB_SERVICE)),yl(1,Object(s.inject)(l.SHARED_PREFERENCES)),yl(2,Object(s.inject)(l.DEVICE_INFO)),yl(3,Object(s.inject)(l.SDK_CONFIG)),vl("design:paramtypes",[o,Object,Object,Object])],bl);class Il{constructor(e,t){this.groupActivityService=e,this.cachedItemStore=t}getDataAggregation(e){return this.cachedItemStore[e.from===Jn.SERVER?"get":"getCached"](`group-${e.groupId}-activity-${e.activity.id}-${e.activity.type}`,Il.GROUP_ACTIVITY_DATA_AGGREGATION_KEY,"ttl_"+Il.GROUP_ACTIVITY_DATA_AGGREGATION_KEY,()=>this.groupActivityService.getDataAggregation(e.groupId,e.activity,e.mergeGroup,e.leafNodesCount))}getDataForDashlets(e,t){return this.groupActivityService.getDataForDashlets(e,t)}}Il.GROUP_ACTIVITY_DATA_AGGREGATION_KEY="GROUP_ACTIVITY_DATA_AGGREGATION-";var Ml,Rl=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ll=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Pl=function(e,t){return function(n,r){t(n,r,e)}};let Dl=Ml=class{constructor(e,t){this.container=e,this.cachedItemStore=t}get activityService(){return this._groupActivityService||(this._groupActivityService=new Il(this.groupServiceDelegate.activityService,this.cachedItemStore)),this._groupActivityService}get groupServiceDelegate(){return this.container.get(u.GROUP_SERVICE)}create(e){return this.groupServiceDelegate.create(e)}getById(e){return this.cachedItemStore[e.from===Jn.SERVER?"get":"getCached"](`${e.id}-${e.userId}`+(e.options&&e.options.includeMembers?"-includeMembers:"+e.options.includeMembers:"")+(e.options&&e.options.includeActivities?"-includeActivities:"+e.options.includeActivities:"")+(e.options&&e.options.groupActivities?"-groupActivities:"+e.options.groupActivities:""),Ml.GROUP_LOCAL_KEY,"ttl_"+Ml.GROUP_LOCAL_KEY,()=>this.groupServiceDelegate.getById(e.id,e.options))}search({request:e,from:t}){return this.cachedItemStore[t===Jn.SERVER?"get":"getCached"](""+e.filters.userId,Ml.GROUP_SEARCH_LOCAL_KEY,"ttl_"+Ml.GROUP_SEARCH_LOCAL_KEY,()=>this.groupServiceDelegate.search(e))}updateById(e){return this.groupServiceDelegate.updateById(e.id,e.updateRequest)}deleteById(e){return this.groupServiceDelegate.deleteById(e.id)}addMembers(e){return this.groupServiceDelegate.addMembers(e.groupId,e.addMembersRequest)}updateMembers(e){return this.groupServiceDelegate.updateMembers(e.groupId,e.updateMembersRequest)}removeMembers(e){return this.groupServiceDelegate.removeMembers(e.groupId,e.removeMembersRequest)}addActivities(e){return this.groupServiceDelegate.addActivities(e.groupId,e.addActivitiesRequest)}updateActivities(e){return this.groupServiceDelegate.updateActivities(e.groupId,e.updateActivitiesRequest)}removeActivities(e){return this.groupServiceDelegate.removeActivities(e.groupId,e.removeActivitiesRequest)}getSupportedActivities(){return this.groupServiceDelegate.getSupportedActivities()}suspendById(e){return this.groupServiceDelegate.suspendById(e.id)}reactivateById(e){return this.groupServiceDelegate.reactivateById(e.id)}updateGroupGuidelines(e){return this.groupServiceDelegate.updateGroupGuidelines(e)}};Dl.GROUP_LOCAL_KEY="GROUP-",Dl.GROUP_SEARCH_LOCAL_KEY="GROUP_SEARCH-",Dl=Ml=Rl([Object(s.injectable)(),Pl(0,Object(s.inject)(l.CONTAINER)),Pl(1,Object(s.inject)(l.CACHED_ITEM_STORE)),Ll("design:paramtypes",[s.Container,Object])],Dl);class wl{constructor(e){this._gid=e,this._sid=en.generateUniqueId(),this._createdTime=Date.now()}get gid(){return this._gid}get sid(){return this._sid}get createdTime(){return this._createdTime}}class Ul extends ke{constructor(e){super(e,"NO_GROUP_FOUND"),Object.setPrototypeOf(this,Ul.prototype)}}class jl extends ke{constructor(e){super(e,"NO_ACTIVE_SESSION"),Object.setPrototypeOf(this,jl.prototype)}}class Fl{static mapGroupDBEntryToGroup(e){return{gid:e[pt.COLUMN_NAME_GID],name:e[pt.COLUMN_NAME_NAME],syllabus:e[pt.COLUMN_NAME_SYLLABUS].split(","),grade:e[pt.COLUMN_NAME_GRADE].split(","),gradeValue:JSON.parse(e[pt.COLUMN_NAME_GRADE_VALUE]),createdAt:e[pt.COLUMN_NAME_CREATED_AT],updatedAt:e[pt.COLUMN_NAME_UPDATED_AT]}}static mapGroupToGroupDBEntry(e){return{[pt.COLUMN_NAME_GID]:e.gid,[pt.COLUMN_NAME_SYLLABUS]:e.syllabus?e.syllabus.join(","):"",[pt.COLUMN_NAME_GRADE]:e.grade?e.grade.join(","):"",[pt.COLUMN_NAME_NAME]:e.name,[pt.COLUMN_NAME_GRADE_VALUE]:JSON.stringify(e.gradeValue),[pt.COLUMN_NAME_CREATED_AT]:e.createdAt,[pt.COLUMN_NAME_UPDATED_AT]:e.updatedAt}}}var kl,xl=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Bl=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Vl=function(e,t){return function(n,r){t(n,r,e)}},Yl=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let Gl=kl=class{constructor(e,t,n,r){this.container=e,this.dbService=t,this.profileService=n,this.sharedPreferences=r}get telemetryService(){return this.container.get(l.TELEMETRY_SERVICE)}createGroup(e){return e.gid=en.generateUniqueId(),e.createdAt=Date.now(),e.updatedAt=Date.now(),this.dbService.insert({table:pt.TABLE_NAME,modelJson:Fl.mapGroupToGroupDBEntry(e)}).pipe(Object(D.tap)(()=>Yl(this,void 0,void 0,(function*(){yield this.profileService.getActiveProfileSession().pipe(Object(D.map)(e=>e.uid),Object(D.mergeMap)(t=>{const n=new pe;n.id=t,n.type=pe.TYPE_SYSTEM;const r={env:"sdk",actor:n,currentState:ue.AUDIT_CREATED,updatedProperties:Qr.getTruthyProps(e),objId:e.gid,objType:Q.GROUP};return this.telemetryService.audit(r)})).toPromise()}))),Object(D.map)(()=>e))}deleteGroup(e){return Object(c.defer)(()=>Object(c.of)(this.dbService.beginTransaction())).pipe(Object(D.mergeMap)(()=>Object(c.zip)(this.dbService.delete({table:pt.TABLE_NAME,selection:pt.COLUMN_NAME_GID+" = ?",selectionArgs:[e]}),this.dbService.delete({table:ft.TABLE_NAME,selection:ft.COLUMN_NAME_GID+" = ?",selectionArgs:[e]})).pipe(Object(D.mapTo)(void 0))),Object(D.tap)(()=>{this.dbService.endTransaction(!0)}),Object(D.tap)(()=>Yl(this,void 0,void 0,(function*(){yield this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(t=>{const n=new pe;n.id=t.uid,n.type=pe.TYPE_SYSTEM;const r={env:"sdk",actor:n,currentState:ue.AUDIT_DELETED,objId:e,objType:Q.GROUP};return this.telemetryService.audit(r)})).toPromise()}))),Object(D.catchError)(e=>(this.dbService.endTransaction(!1),c.Observable.throw(e))))}updateGroup(e){return this.dbService.read({table:pt.TABLE_NAME,selection:"gid = ?",selectionArgs:[e.gid]}).pipe(Object(D.map)(t=>t&&t[0]?Fl.mapGroupDBEntryToGroup(t[0]):c.Observable.throw(new Ul("No Group found with ID "+e.gid))),Object(D.tap)(t=>Yl(this,void 0,void 0,(function*(){yield this.profileService.getActiveProfileSession().pipe(Object(D.mergeMap)(n=>{const r=new pe;r.id=n.uid,r.type=pe.TYPE_SYSTEM;const i={env:"sdk",actor:r,currentState:ue.AUDIT_UPDATED,updatedProperties:Qr.getPropDiff(e,t),objId:e.gid,objType:Q.GROUP};return this.telemetryService.audit(i)})).toPromise()}))),Object(D.mergeMap)(()=>this.dbService.update({table:pt.TABLE_NAME,selection:"gid = ?",selectionArgs:[e.gid],modelJson:{[pt.COLUMN_NAME_NAME]:e.name,[pt.COLUMN_NAME_SYLLABUS]:e.syllabus.join(","),[pt.COLUMN_NAME_UPDATED_AT]:Date.now(),[pt.COLUMN_NAME_GRADE]:e.grade.join(","),[pt.COLUMN_NAME_GRADE_VALUE]:JSON.stringify(e.gradeValue)}}).pipe(Object(D.mapTo)(e))))}getActiveSessionGroup(){return this.getActiveGroupSession().pipe(Object(D.map)(e=>{if(!e)throw new jl("No active session available");return e}),Object(D.mergeMap)(e=>this.dbService.read({table:pt.TABLE_NAME,selection:pt.COLUMN_NAME_GID+" = ?",selectionArgs:[e.gid]}).pipe(Object(D.map)(e=>e&&e[0]))))}setActiveSessionForGroup(e){return this.dbService.read({table:pt.TABLE_NAME,selection:pt.COLUMN_NAME_GID+" = ?",selectionArgs:[e]}).pipe(Object(D.map)(e=>e&&e[0]&&Fl.mapGroupDBEntryToGroup(e[0])),Object(D.map)(e=>{if(!e)throw new Ul("No Profile found");return e}),Object(D.mergeMap)(e=>{const t=new wl(e.gid);return this.sharedPreferences.putString(kl.KEY_GROUP_SESSION,JSON.stringify({gid:t.gid,sid:t.sid,createdTime:t.createdTime})).pipe(Object(D.mapTo)(!0))}))}getActiveGroupSession(){return this.sharedPreferences.getString(kl.KEY_GROUP_SESSION).pipe(Object(D.map)(e=>{if(e)return JSON.parse(e)}))}getAllGroups(e){return Object(c.defer)(()=>e?this.dbService.execute(`\n SELECT * FROM ${pt.TABLE_NAME}\n LEFT JOIN ${ft.TABLE_NAME} ON\n ${pt.TABLE_NAME}.${pt.COLUMN_NAME_GID} =\n ${ft.TABLE_NAME}.${ft.COLUMN_NAME_GID}\n WHERE ${ft.COLUMN_NAME_UID} = "${e.uid}"`).pipe(Object(D.map)(e=>e.map(e=>Fl.mapGroupDBEntryToGroup(e)))):this.dbService.read({table:pt.TABLE_NAME,columns:[]}).pipe(Object(D.map)(e=>e.map(e=>Fl.mapGroupDBEntryToGroup(e))))).pipe(Object(D.mergeMap)(e=>Object(c.from)(e)),Object(D.mergeMap)(e=>this.profileService.getAllProfiles({groupId:e.gid}).pipe(Object(D.map)(t=>Object.assign(Object.assign({},e),{profilesCount:t.length})))),Object(D.reduce)((e,t)=>[...e,t],[]))}addProfilesToGroup(e){return Object(c.defer)(()=>Object(c.of)(this.dbService.beginTransaction())).pipe(Object(D.mergeMap)(()=>this.dbService.delete({table:ft.TABLE_NAME,selection:ft.COLUMN_NAME_GID+" = ?",selectionArgs:[e.groupId]})),Object(D.mergeMap)(()=>e.uidList.length?Object(c.zip)(...e.uidList.map(t=>this.dbService.insert({table:ft.TABLE_NAME,modelJson:{[ft.COLUMN_NAME_GID]:e.groupId,[ft.COLUMN_NAME_UID]:t}}))).pipe(Object(D.mapTo)(e.uidList.length)):Object(c.of)(0)),Object(D.tap)(()=>{this.dbService.endTransaction(!0)}),Object(D.catchError)(e=>(this.dbService.endTransaction(!1),Object(c.throwError)(e))))}removeActiveGroupSession(){return this.getActiveGroupSession().pipe(Object(D.mergeMap)(e=>e?this.sharedPreferences.putString(kl.KEY_GROUP_SESSION,""):Object(c.of)(void 0)))}};Gl.KEY_GROUP_SESSION=f.KEY_GROUP_SESSION,Gl=kl=xl([Object(s.injectable)(),Vl(0,Object(s.inject)(l.CONTAINER)),Vl(1,Object(s.inject)(l.DB_SERVICE)),Vl(2,Object(s.inject)(l.PROFILE_SERVICE)),Vl(3,Object(s.inject)(l.SHARED_PREFERENCES)),Bl("design:paramtypes",[s.Container,o,Object,Object])],Gl);var Hl=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class $l extends i{constructor(){super(15,28)}apply(e){return Hl(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise())),yield this.updateContentTable(e)}))}updateContentTable(e){return Hl(this,void 0,void 0,(function*(){e.beginTransaction();try{const t=(yield e.read({table:St.TABLE_NAME}).toPromise()).reduce((e,t)=>{let n;t[St.COLUMN_NAME_LOCAL_DATA]&&kn.isAvailableLocally(t[St.COLUMN_NAME_CONTENT_STATE])?n=JSON.parse(t[St.COLUMN_NAME_LOCAL_DATA]):t[St.COLUMN_NAME_SERVER_DATA]&&(n=JSON.parse(t[St.COLUMN_NAME_SERVER_DATA]));const r=n?n.resourceType:void 0,i=jn.CsPrimaryCategoryMapper.getPrimaryCategory(t[St.COLUMN_NAME_CONTENT_TYPE],t[St.COLUMN_NAME_MIME_TYPE],r).toLowerCase();return e.set(t[St.COLUMN_NAME_IDENTIFIER],i),e},new Map);if(!t.size)return void e.endTransaction(!0);const n=this.buildPrimaryCategoryCases(t),r=`UPDATE ${St.TABLE_NAME} SET ${n};`.trim();yield e.execute(r).toPromise(),e.endTransaction(!0)}catch(t){throw console.error(t),e.endTransaction(!1),t}}))}buildPrimaryCategoryCases(e){return Array.from(e.entries()).reduce((e,[t,n])=>n?e.concat(` WHEN '${t}' THEN '${n}' `):e,` ${St.COLUMN_NAME_PRIMARY_CATEGORY} = CASE ${St.COLUMN_NAME_IDENTIFIER} `).concat(" ELSE '' END ")}queries(){return[St.getAlterEntryForPrimaryCategory()]}}var ql=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Kl=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},zl=function(e,t){return function(n,r){t(n,r,e)}};let Wl=class{constructor(e){this.container=e}get discussionServiceDelegate(){return this.container.get(u.DISCUSSION_SERVICE)}getForumIds(e){return this.discussionServiceDelegate.getForumIds(e)}createUser(e){return this.discussionServiceDelegate.createUser(e)}attachForum(e){return this.discussionServiceDelegate.attachForum(e)}removeForum(e){return this.discussionServiceDelegate.removeForum(e)}createForum(e){return this.discussionServiceDelegate.createForum(e)}};Wl=ql([Object(s.injectable)(),zl(0,Object(s.inject)(l.CONTAINER)),Kl("design:paramtypes",[s.Container])],Wl);class Xl{constructor(e){this.keyValueStore=e,this.TAG_KEY="segment-tag_"}handle(e){return this.keyValueStore.getValue(this.TAG_KEY+e).pipe(Object(D.map)(e=>e||null))}}class Jl{constructor(e){this.keyValueStore=e,this.COMMAND_KEY="segment-command_"}handle(e){return this.keyValueStore.getValue(this.COMMAND_KEY+e).pipe(Object(D.map)(e=>e||null))}}class Ql{constructor(e){this.keyValueStore=e,this.TAG_KEY="segment-tag_"}handle(e,t){return this.keyValueStore.setValue(this.TAG_KEY+t,e)}}class Zl{constructor(e){this.keyValueStore=e,this.COMMAND_KEY="segment-command_"}handle(e,t){return this.keyValueStore.setValue(this.COMMAND_KEY+t,e)}}var ed=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},td=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},nd=function(e,t){return function(n,r){t(n,r,e)}};let rd=class{constructor(e){this.keyValueStore=e}saveTags(e,t){return new Ql(this.keyValueStore).handle(e,t)}getTags(e){return new Xl(this.keyValueStore).handle(e)}removeTagsForId(e){throw new Error("Method not implemented.")}clearAllTags(){throw new Error("Method not implemented.")}saveCommandList(e,t){return new Zl(this.keyValueStore).handle(e,t)}getCommand(e){return new Jl(this.keyValueStore).handle(e)}};rd=ed([Object(s.injectable)(),nd(0,Object(s.inject)(l.KEY_VALUE_STORE)),td("design:paramtypes",[Object])],rd);var id=n(22),od=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class sd{constructor(e,t){this.sharedPreferences=e,this.debuggingServiceImpl=t}handle(e){return od(this,void 0,void 0,(function*(){let t=yield this.sharedPreferences.getString("debug_started_at").toPromise();if(console.log(t),t){let n=setInterval(()=>od(this,void 0,void 0,(function*(){var r=((new Date).getTime()-new Date(parseInt(t)).getTime())/1e3;r/=60,console.log("diff",Math.abs(Math.round(r))),Math.abs(Math.round(r))>=10?(this.sharedPreferences.putString("debug_started_at","").toPromise(),this.debuggingServiceImpl.disableDebugging(),yield this.sharedPreferences.putString(id.CsClientStorage.TRACE_ID,"").toPromise(),e.next(!1),e.complete(),clearInterval(n),this.debuggingServiceImpl.watcher.interval=null,this.debuggingServiceImpl.watcher.observer=null,this.debuggingServiceImpl.watcher.debugStatus=!1):e.next(!0)})),6e4);this.debuggingServiceImpl.watcher.interval=n,this.debuggingServiceImpl.watcher.observer=e,this.debuggingServiceImpl.watcher.debugStatus=!0}else e.next(!1),e.complete()}))}}var ad=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},cd=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ud=function(e,t){return function(n,r){t(n,r,e)}},ld=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let dd=class{constructor(e,t){this.sharedPreferences=e,this.profileService=t,this.watcher={interval:null,observer:null,debugStatus:!1}}set userId(e){this._userId=e}get userId(){return this._userId}set deviceId(e){this._deviceId=e}get deviceId(){return this._deviceId}enableDebugging(e){return new c.Observable(t=>{this.profileService.getActiveProfileSession().toPromise().then(n=>ld(this,void 0,void 0,(function*(){if(null==n?void 0:n.uid){this._userId=n.uid;const r=yield I.createJWTToken(this._deviceId,this.userId);e?yield this.sharedPreferences.putString(id.CsClientStorage.TRACE_ID,e).toPromise():yield this.sharedPreferences.putString(id.CsClientStorage.TRACE_ID,r).toPromise(),new sd(this.sharedPreferences,this).handle(t),console.log("Watcher Value:",this.watcher)}})))})}disableDebugging(){return this.watcher.debugStatus?(clearTimeout(this.watcher.interval),this.watcher.observer.complete(),this.watcher={interval:null,observer:null,debugStatus:!1},this.sharedPreferences.putString("debug_started_at","").toPromise(),this.sharedPreferences.putString(id.CsClientStorage.TRACE_ID,"").toPromise(),Object(c.of)(!0)):Object(c.of)(!1)}isDebugOn(){return!!this.watcher.debugStatus}};dd=ad([Object(s.injectable)(),ud(0,Object(s.inject)(l.SHARED_PREFERENCES)),ud(1,Object(s.inject)(l.PROFILE_SERVICE)),cd("design:paramtypes",[Object,Object])],dd);var hd=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Ed=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},fd=function(e,t){return function(n,r){t(n,r,e)}};let pd=class{constructor(e){this.container=e}get NotificationServiceV2Delegate(){return this.container.get(u.NOTIFICATION_SERVICE_V2)}notificationRead(e){return this.NotificationServiceV2Delegate.notificationRead(e)}notificationUpdate(e){return this.NotificationServiceV2Delegate.notificationUpdate(e)}notificationDelete(e){return this.NotificationServiceV2Delegate.notificationDelete(e)}};pd=hd([Object(s.injectable)(),fd(0,Object(s.inject)(l.CONTAINER)),Ed("design:paramtypes",[s.Container])],pd);var _d=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Od extends i{constructor(){super(16,29)}apply(e){return _d(this,void 0,void 0,(function*(){this.queries().forEach(t=>_d(this,void 0,void 0,(function*(){yield e.execute(t).toPromise()})))}))}queries(){return[kt.getAlterEntryForPlayerConfig()]}}var Sd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class gd extends i{constructor(){super(17,30)}apply(e){return Sd(this,void 0,void 0,(function*(){yield Promise.all(this.queries().map(t=>e.execute(t).toPromise()))}))}queries(){return[Bt.getCreateEntry()]}}class Ad{constructor(e,t,n,r){this.dbService=e,this.container=t,this.certificateServiceConfig=n,this.apiConfig=r}get csCertificateService(){return this.container.get(u.CERTIFICATE_SERVICE)}handle(e){return this.dbService.read({table:Bt.TABLE_NAME,selection:Bt.COLUMN_NAME_IDENTIFIER+"= ?",selectionArgs:[e.osid.toString()]}).pipe(Object(D.mergeMap)(t=>t&&t.length?t[0].expiry_time<Date.now()?this.fetchFromServer(e).pipe(Object(D.mergeMap)(e=>this.updatePublicKey(e))):Object(c.of)({osid:t[0].identifier,value:t[0].public_key,alg:t[0].alg,osOwner:t[0].owner?t[0].owner.split(","):[]}):this.fetchFromServer(e).pipe(Object(D.mergeMap)(e=>this.insertPublicKey(e)))))}updatePublicKey(e){return this.dbService.update({table:Bt.TABLE_NAME,selection:Bt.COLUMN_NAME_IDENTIFIER+" = ?",selectionArgs:[e.osid],modelJson:{identifier:e.osid,public_key:e.value,alg:e.alg,owner:e.osOwner&&e.osOwner.length?e.osOwner.join(","):"",expiry_time:Date.now()+this.apiConfig.cached_requests.timeToLive}}).pipe(Object(D.mapTo)(e))}insertPublicKey(e){return this.dbService.insert({table:Bt.TABLE_NAME,modelJson:{identifier:e.osid,public_key:e.value,alg:e.alg,owner:e.osOwner&&e.osOwner.length?e.osOwner.join(","):"",expiry_time:Date.now()+this.apiConfig.cached_requests.timeToLive}}).pipe(Object(D.mapTo)(e))}fetchFromServer(e){return this.csCertificateService.getPublicKey(e)}}var Nd=function(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s},Td=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Cd=function(e,t){return function(n,r){t(n,r,e)}},vd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};let yd=class{constructor(e,t,n,r,i,o){this.container=e,this.dbService=t,this.sdkConfig=n,this.profileService=r,this.keyValueStore=i,this.fileService=o}getCertificates(e){return this.csCertificateService.fetchCertificates(e)}getPublicKey(e){return new Ad(this.dbService,this.container,this.sdkConfig.certificateServiceConfig,this.sdkConfig.apiConfig).handle(e)}getCertificate(e){return this.csCertificateService.getCerificateDownloadURI({certificateId:e.certificate.identifier,type:e.certificate.type,schemaName:"certificate",templateUrl:e.certificate.templateUrl}).pipe(Object(D.tap)(t=>vd(this,void 0,void 0,(function*(){yield this.keyValueStore.setValue(yield this.buildCertificatePersistenceId(e),Object(an.gzip)(t.printUri,{to:"string"})).toPromise()}))),Object(D.map)(e=>e.printUri),Object(D.catchError)(t=>Object(c.defer)(()=>vd(this,void 0,void 0,(function*(){const n=yield this.getCertificateFromCache(e);if(n)return n;throw t})))))}downloadCertificate({fileName:e,blob:t}){return Object(c.defer)(()=>vd(this,void 0,void 0,(function*(){return this.fileService.writeFile(cordova.file.externalDataDirectory,e,t,{replace:!0}).then(()=>({path:`${cordova.file.externalDataDirectory}${e}`}))})))}downloadLegacyeCertificate(e){return Object(c.defer)(()=>vd(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n=t.managedSession?t.managedSession.uid:t.uid;"ios"===window.device.platform.toLowerCase()?cordova.file.documentsDirectory:cordova.file.externalRootDirectory,e.certificate.name,e.courseId;return{userId:n}}))).pipe(Object(D.mergeMap)(({userId:t})=>this.csCertificateService.getLegacyCerificateDownloadURI({pdfUrl:e.certificate.url}).pipe(Object(D.map)(e=>({signedPdfUrl:e.signedUrl,userId:t})))),Object(D.mergeMap)(({signedPdfUrl:t,userId:n})=>{const r={uri:t,title:e.certificate.token,description:"",mimeType:"application/pdf",visibleInDownloadsUi:!0,notificationVisibility:1,destinationInExternalPublicDir:{dirType:"Download",subPath:`/${e.certificate.name}_${e.courseId}_${n}.pdf`},headers:[]};return new c.Observable(e=>{downloadManager.enqueue(r,(t,n)=>{if(t)return e.error(t);e.next(n),e.complete()})})}),Object(D.mergeMap)(e=>Object(c.interval)(1e3).pipe(Object(D.mergeMap)(()=>new c.Observable(t=>{downloadManager.query({ids:[e]},(e,n)=>e||n[0].status===DownloadStatus.STATUS_FAILED?t.error(e||new Error("Unknown Error")):t.next(n[0]))})),Object(D.filter)(e=>e.status===DownloadStatus.STATUS_SUCCESSFUL),Object(D.take)(1))),Object(D.map)(e=>({path:e.localUri})))}isCertificateCached(e){return Object(c.defer)(()=>vd(this,void 0,void 0,(function*(){try{return!!(yield this.getCertificateFromCache(e))}catch(e){return console.error(e),!1}})))}getEncodedData(e){return this.csCertificateService.getEncodedData(e)}verifyCertificate(e){return this.csCertificateService.verifyCertificate(e)}get csCertificateService(){return this.container.get(u.CERTIFICATE_SERVICE)}buildCertificatePersistenceId(e){return vd(this,void 0,void 0,(function*(){const t=yield this.profileService.getActiveProfileSession().toPromise(),n=t.managedSession?t.managedSession.uid:t.uid;return`certificate_${e.certificate.identifier}_${e.courseId}_${n}`}))}getCertificateFromCache(e){return vd(this,void 0,void 0,(function*(){const t=yield this.keyValueStore.getValue(yield this.buildCertificatePersistenceId(e)).toPromise();return t?Object(ii.ungzip)(t,{to:"string"}):void 0}))}};yd=Nd([Object(s.injectable)(),Cd(0,Object(s.inject)(l.CONTAINER)),Cd(1,Object(s.inject)(l.DB_SERVICE)),Cd(2,Object(s.inject)(l.SDK_CONFIG)),Cd(3,Object(s.inject)(l.PROFILE_SERVICE)),Cd(4,Object(s.inject)(l.KEY_VALUE_STORE)),Cd(5,Object(s.inject)(l.FILE_SERVICE)),Td("design:paramtypes",[s.Container,o,Object,Object,Object,Object])],yd);var md=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class bd{constructor(){this._isInitialised=!1}static get instance(){return bd._instance||(bd._instance=new bd),bd._instance}get isInitialised(){return this._isInitialised}get sdkConfig(){return this._container.get(l.SDK_CONFIG)}get appInfo(){return this._container.get(l.APP_INFO)}get pageAssembleService(){return this._container.get(l.PAGE_ASSEMBLE_SERVICE)}get dbService(){return this._container.get(l.DB_SERVICE)}get telemetryService(){return this._container.get(l.TELEMETRY_SERVICE)}get authService(){return this._container.get(l.AUTH_SERVICE)}get apiService(){return this._container.get(l.API_SERVICE)}get keyValueStore(){return this._container.get(l.KEY_VALUE_STORE)}get profileService(){return this._container.get(l.PROFILE_SERVICE)}get groupService(){return this._container.get(l.GROUP_SERVICE)}get groupServiceDeprecated(){return this._container.get(l.GROUP_SERVICE_DEPRECATED)}get contentService(){return this._container.get(l.CONTENT_SERVICE)}get contentFeedbackService(){return this._container.get(l.CONTENT_FEEDBACK_SERVICE)}get courseService(){return this._container.get(l.COURSE_SERVICE)}get formService(){return this._container.get(l.FORM_SERVICE)}get frameworkService(){return this._container.get(l.FRAMEWORK_SERVICE)}get frameworkUtilService(){return this._container.get(l.FRAMEWORK_UTIL_SERVICE)}get sharedPreferences(){return this._container.get(l.SHARED_PREFERENCES)}get systemSettingsService(){return this._container.get(l.SYSTEM_SETTINGS_SERVICE)}get eventsBusService(){return this._container.get(l.EVENTS_BUS_SERVICE)}get summarizerService(){return this._container.get(l.SUMMARIZER_SERVICE)}get downloadService(){return this._container.get(l.DOWNLOAD_SERVICE)}get playerService(){return this._container.get(l.PLAYER_SERVICE)}get deviceInfo(){return this._container.get(l.DEVICE_INFO)}get storageService(){return this._container.get(l.STORAGE_SERVICE)}get notificationService(){return this._container.get(l.NOTIFICATION_SERVICE)}get errorLoggerService(){return this._container.get(l.ERROR_LOGGER_SERVICE)}get networkInfoService(){return this._container.get(l.NETWORKINFO_SERVICE)}get searchHistoryService(){return this._container.get(l.SEARCH_HISTORY_SERVICE)}get codePushExperimentService(){return this._container.get(l.CODEPUSH_EXPERIMENT_SERVICE)}get faqService(){return this._container.get(l.FAQ_SERVICE)}get deviceRegisterService(){return this._container.get(l.DEVICE_REGISTER_SERVICE)}get archiveService(){return this._container.get(l.ARCHIVE_SERVICE)}get networkQueueService(){return this._container.get(l.NETWORK_QUEUE)}get discussionService(){return this._container.get(l.DISCUSSION_SERVICE)}get segmentationService(){return this._container.get(l.SEGMENTATION_SERVICE)}get debuggingService(){return this._container.get(l.DEBUGGING_SERVICE)}get notificationServiceV2(){return this._container.get(l.NOTIFICATION_SERVICE_V2)}get certificateService(){return this._container.get(l.CERTIFICATE_SERVICE)}init(e){return md(this,void 0,void 0,(function*(){switch(this._container=new s.Container,this._container.bind(l.CONTAINER).toConstantValue(this._container),this._container.bind(l.DB_VERSION).toConstantValue(31),this._container.bind(l.DB_MIGRATION_LIST).toConstantValue([new Ca,new ya,new ba,new Da,new Tc,new Ma,new Fu,new Ku,new Wu,()=>new Tl(e,this._container.get(l.NETWORK_QUEUE)),new $l,new Od,new gd,new La]),e.platform){case"cordova":this._container.bind(l.SHARED_PREFERENCES).to(Sa).inSingletonScope();break;case"web":this._container.bind(l.SHARED_PREFERENCES).to(pa).inSingletonScope();break;default:throw new Error("FATAL_ERROR: Invalid platform")}this._container.bind(l.DB_SERVICE).to(Qt).inSingletonScope(),this._container.bind(l.FILE_SERVICE).to(Na).inSingletonScope(),this._container.bind(l.SDK_CONFIG).toConstantValue(e),this._container.bind(l.DEVICE_INFO).to(za).inSingletonScope(),this._container.bind(l.EVENTS_BUS_SERVICE).to(rc).inSingletonScope(),this._container.bind(l.APP_INFO).to(pc).inSingletonScope(),this._container.bind(l.API_SERVICE).to(G).inSingletonScope(),this._container.bind(l.AUTH_SERVICE).to(Zi).inSingletonScope(),this._container.bind(l.KEY_VALUE_STORE).to(Hs).inSingletonScope(),this._container.bind(l.SYSTEM_SETTINGS_SERVICE).to(ka).inSingletonScope(),this._container.bind(l.FRAMEWORK_SERVICE).to(co).inSingletonScope(),this._container.bind(l.PROFILE_SERVICE).to(Fi).inSingletonScope(),this._container.bind(l.GROUP_SERVICE).to(Dl).inSingletonScope(),this._container.bind(l.GROUP_SERVICE_DEPRECATED).to(Gl).inSingletonScope(),this._container.bind(l.ERROR_LOGGER_SERVICE).to(Pu).inSingletonScope(),this._container.bind(l.ZIP_SERVICE).to(Ba).inSingletonScope(),this._container.bind(l.TELEMETRY_SERVICE).to(Ki).inSingletonScope(),this._container.bind(l.CONTENT_FEEDBACK_SERVICE).to(Qa).inSingletonScope(),this._container.bind(l.FORM_SERVICE).to(Ws).inSingletonScope(),this._container.bind(l.PAGE_ASSEMBLE_SERVICE).to(Ea).inSingletonScope(),this._container.bind(l.FRAMEWORK_UTIL_SERVICE).to(Ao).inSingletonScope(),this._container.bind(l.DOWNLOAD_SERVICE).to(lc).inSingletonScope(),this._container.bind(l.CONTENT_SERVICE).to(Bs).inSingletonScope(),this._container.bind(l.COURSE_SERVICE).to(hi).inSingletonScope(),this._container.bind(l.SUMMARIZER_SERVICE).to(wr).inSingletonScope(),this._container.bind(l.PLAYER_SERVICE).to(Ac).inSingletonScope(),this._container.bind(l.CACHED_ITEM_STORE).to(ta).inSingletonScope(),this._container.bind(l.TELEMETRY_DECORATOR).to(on).inSingletonScope(),this._container.bind(l.STORAGE_SERVICE).to(du).inSingletonScope(),this._container.bind(l.NOTIFICATION_SERVICE).to(Nu).inSingletonScope(),this._container.bind(l.NETWORKINFO_SERVICE).to(Uu).inSingletonScope(),this._container.bind(l.SEARCH_HISTORY_SERVICE).to($u).inSingletonScope(),this._container.bind(l.CODEPUSH_EXPERIMENT_SERVICE).to(Zu).inSingletonScope(),this._container.bind(l.DEVICE_REGISTER_SERVICE).to(X).inSingletonScope(),this._container.bind(l.FAQ_SERVICE).to(il).inSingletonScope(),this._container.bind(l.ARCHIVE_SERVICE).to(Al).inSingletonScope(),this._container.bind(l.NETWORK_QUEUE).to(bl).inSingletonScope(),this._container.bind(l.DISCUSSION_SERVICE).to(Wl).inSingletonScope(),this._container.bind(l.SEGMENTATION_SERVICE).to(rd).inSingletonScope(),this._container.bind(l.DEBUGGING_SERVICE).to(dd).inSingletonScope(),this._container.bind(l.NOTIFICATION_SERVICE_V2).to(pd).inSingletonScope(),this._container.bind(l.CERTIFICATE_SERVICE).to(yd).inSingletonScope();const t=this.sharedPreferences;yield k.CsModule.instance.init({core:{httpAdapter:"web"===e.platform?"HttpClientBrowserAdapter":"HttpClientCordovaAdapter",global:{channelId:e.apiConfig.api_authentication.channelId,producerId:e.apiConfig.api_authentication.producerId,deviceId:ms(window.device.uuid).toString()},api:{host:e.apiConfig.host,authentication:{}}},services:{contentServiceConfig:{hierarchyApiPath:"/api/questionset/v2",questionListApiPath:"/api/question/v2"},courseServiceConfig:{apiPath:"/api/course/v1",certRegistrationApiPath:"/api/certreg/v2/certs"},groupServiceConfig:{apiPath:"/api/group/v1",dataApiPath:"/api/data/v1/group",updateGroupGuidelinesApiPath:"/api/group/membership/v1"},userServiceConfig:{apiPath:"/api/user/v2"},formServiceConfig:{apiPath:"/api/data/v1/form"},discussionServiceConfig:{apiPath:"/discussion"},notificationServiceConfig:{apiPath:"/api/notification/v1/feed"},certificateServiceConfig:{apiPath:e.certificateServiceConfig.apiPath,apiPathLegacy:e.certificateServiceConfig.apiPathLegacy,rcApiPath:e.certificateServiceConfig.rcApiPath},frameworkServiceConfig:{apiPath:"/api/framework/v1"}}},(()=>{this._container.rebind(u.HTTP_SERVICE).toConstantValue(k.CsModule.instance.httpService),this._container.rebind(u.GROUP_SERVICE).toConstantValue(k.CsModule.instance.groupService),this._container.rebind(u.COURSE_SERVICE).toConstantValue(k.CsModule.instance.courseService),this._container.rebind(u.USER_SERVICE).toConstantValue(k.CsModule.instance.userService),this._container.rebind(u.DISCUSSION_SERVICE).toConstantValue(k.CsModule.instance.discussionService),this._container.rebind(u.CONTENT_SERVICE).toConstantValue(k.CsModule.instance.contentService),this._container.rebind(u.NOTIFICATION_SERVICE_V2).toConstantValue(k.CsModule.instance.notificationService),this._container.rebind(u.CERTIFICATE_SERVICE).toConstantValue(k.CsModule.instance.certificateService),this._container.rebind(u.FRAMEWORK_SERVICE).toConstantValue(k.CsModule.instance.frameworkService)}).bind(this),new class{setItem(e,n){return t.putString(e,n).toPromise()}getItem(e){return t.getString(e).toPromise()}}),this._container.bind(u.HTTP_SERVICE).toConstantValue(k.CsModule.instance.httpService),this._container.bind(u.GROUP_SERVICE).toConstantValue(k.CsModule.instance.groupService),this._container.bind(u.COURSE_SERVICE).toConstantValue(k.CsModule.instance.courseService),this._container.bind(u.USER_SERVICE).toConstantValue(k.CsModule.instance.userService),this._container.bind(u.DISCUSSION_SERVICE).toConstantValue(k.CsModule.instance.discussionService),this._container.bind(u.CONTENT_SERVICE).toConstantValue(k.CsModule.instance.contentService),this._container.bind(u.NOTIFICATION_SERVICE_V2).toConstantValue(k.CsModule.instance.notificationService),this._container.bind(u.CERTIFICATE_SERVICE).toConstantValue(k.CsModule.instance.certificateService),this._container.bind(u.FRAMEWORK_SERVICE).toConstantValue(k.CsModule.instance.frameworkService),yield this.dbService.init(),yield this.appInfo.init(),yield this.preInit().toPromise(),this._isInitialised=!0,this.postInit().subscribe()}))}updateTelemetryConfig(e){for(const t in e)e.hasOwnProperty(t)&&(this.sdkConfig.telemetryConfig[t]=e[t])}updateDeviceRegisterConfig(e){for(const t in e)e.hasOwnProperty(t)&&(this.sdkConfig.deviceRegisterConfig[t]=e[t],"fcmToken"===t&&this.telemetryService.resetDeviceRegisterTTL())}updateContentServiceConfig(e){for(const t in e)e.hasOwnProperty(t)&&(this.sdkConfig.contentServiceConfig[t]=e[t])}updatePageServiceConfig(e){for(const t in e)e.hasOwnProperty(t)&&(this.sdkConfig.pageServiceConfig[t]=e[t])}preInit(){return this.telemetryService.preInit().pipe(Object(D.concatMap)(()=>this.frameworkService.preInit().pipe(Object(D.concatMap)(()=>this.profileService.preInit()))))}postInit(){return Object(c.combineLatest)([this.apiService.onInit(),this.authService.onInit(),this.summarizerService.onInit(),this.errorLoggerService.onInit(),this.eventsBusService.onInit(),this.downloadService.onInit(),this.contentService.onInit(),this.storageService.onInit(),this.telemetryService.onInit(),this.notificationService.onInit()])}}var Id=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Md{constructor(e,t,n){this.apiConfig=e,this.apiService=t,this.eventsBusService=n}static parseAccessToken(e){return Id(this,void 0,void 0,(function*(){let t=yield I.decodeJWT(e);const n=JSON.parse(t);return{userToken:3===n.sub.split(":").length?n.sub.split(":").pop():n.sub,accessTokenExpiresOn:1e3*n.exp}}))}buildGoogleTargetUrl(e,t){const n=new URL(e.googleRedirectUrl);return delete t.redirect_uri,n.searchParams.set("redirect_uri",this.apiConfig.user_authentication.redirectUrl),delete t.error_callback,n.searchParams.set("error_callback",this.apiConfig.user_authentication.redirectUrl),Object.keys(t).forEach(e=>n.searchParams.set(e,t[e])),n}buildPasswordSessionProvider(e,t){return e.capture({host:t.when.host,path:t.when.path,params:t.when.params}).then(()=>e.closeWebview()).then(()=>e.success()).then(e=>this.resolvePasswordSession(e))}buildStateSessionProvider(e,t){return e.capture({host:t.when.host,path:t.when.path,params:t.when.params}).then(()=>e.closeWebview()).then(()=>e.success()).then(e=>this.resolveStateSession(e))}buildGoogleSessionProvider(e,t,n){return e.capture({host:t.when.host,path:t.when.path,params:t.when.params}).then(()=>e.closeWebview()).then(()=>e.success()).then(t=>e.getCaptureExtras().then(r=>{const i=this.buildGoogleTargetUrl(t,r);return e.launchCustomTab({host:i.origin,path:i.pathname,params:Be.parse(i.searchParams.toString(),{ignoreQueryPrefix:!0}),extraParams:n.get("extraParam")}).then(()=>e.success()).then(e=>this.resolveGoogleSession(e))}))}resolvePasswordSession(e){const t=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(this.apiConfig.user_authentication.authUrl+"/token").withBody({redirect_uri:this.apiConfig.host+"/oauth2callback",code:e.code,grant_type:"authorization_code",client_id:"android"}).withHeaders({"Content-Type":"application/x-www-form-urlencoded"}).withSerializer(a.CsHttpSerializer.URLENCODED).withBearerToken(!1).withUserToken(!1).build();return this.apiService.fetch(t).toPromise().then(e=>Id(this,void 0,void 0,(function*(){if(e.body.access_token&&e.body.refresh_token){const{userToken:t,accessTokenExpiresOn:n}=yield Md.parseAccessToken(e.body.access_token);return{access_token:e.body.access_token,refresh_token:e.body.refresh_token,accessTokenExpiresOn:n,userToken:t}}throw new xe("Server Error")}))).catch(()=>{throw new xe("Server Error")})}resolveStateSession(e){const t="/v1/sso/create/session?id="+("ios"===window.device.platform.toLowerCase()?encodeURIComponent(e.id):e.id),n=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(t).withUserToken(!1).withBearerToken(!1).build();return this.apiService.fetch(n).toPromise().then(e=>Id(this,void 0,void 0,(function*(){if(e.body.access_token&&e.body.refresh_token){const{userToken:t,accessTokenExpiresOn:n}=yield Md.parseAccessToken(e.body.access_token);return{access_token:e.body.access_token,refresh_token:e.body.refresh_token,accessTokenExpiresOn:n,userToken:t}}throw new xe("Server Error")}))).catch(()=>{throw new xe("Server Error")})}resolveGoogleSession(e){return Id(this,void 0,void 0,(function*(){if(e.access_token&&e.refresh_token){const{userToken:t,accessTokenExpiresOn:n}=yield Md.parseAccessToken(e.access_token);return{access_token:e.access_token,refresh_token:e.refresh_token,accessTokenExpiresOn:n,userToken:t}}if(e.error_message)throw new xe(e.error_message);throw new xe("Server Error")}))}}var Rd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ld extends Md{constructor(e,t,n){super(bd.instance.sdkConfig.apiConfig,bd.instance.apiService,bd.instance.eventsBusService),this.autoMergeConfig=e,this.webviewRunner=t,this.captured=n,this.telemetryService=bd.instance.telemetryService}provide(){return Rd(this,void 0,void 0,(function*(){const e=this.webviewRunner,t=yield this.telemetryService.buildContext().toPromise();return this.autoMergeConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)}),Object.keys(this.captured).forEach(e=>{this.autoMergeConfig.target.params.push({key:e,value:this.captured[e]})}),e.redirectTo({host:this.autoMergeConfig.target.host,path:this.autoMergeConfig.target.path,params:this.autoMergeConfig.target.params.reduce((e,t)=>(e[t.key]=t.value,e),{})}).then(()=>e.any(...this.autoMergeConfig.return.reduce((t,n)=>{switch(n.type){case"password":t.push(this.buildPasswordSessionProvider(e,n).then(e=>this.performAutoMerge({payload:this.captured.payload,session:e})));break;case"state":t.push(this.buildStateSessionProvider(e,n));break;case"google":t.push(this.buildGoogleSessionProvider(e,n).then(e=>this.performAutoMerge({payload:this.captured.payload,session:e})))}return t},[])))}))}performAutoMerge({payload:e,session:t}){const n=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.GET).withPath(this.apiConfig.user_authentication.autoMergeApiPath).withParameters({client_id:"android"}).withHeaders({"x-authenticated-user-token":t.access_token,"x-authenticated-user-data":e}).build();return this.apiService.fetch(n).pipe(Object(D.mapTo)(void 0)).toPromise().then(()=>(this.eventsBusService.emit({namespace:M.AUTH,event:{type:he.AUTO_MIGRATE_SUCCESS,payload:void 0}}),t)).catch(e=>(console.error(e),this.eventsBusService.emit({namespace:M.AUTH,event:{type:he.AUTO_MIGRATE_FAIL,payload:void 0}}),t))}}var Pd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Dd extends Md{constructor(e,t,n,r){super(bd.instance.sdkConfig.apiConfig,bd.instance.apiService,bd.instance.eventsBusService),this.loginConfig=e,this.autoMergeConfig=t,this.customWebViewConfig=n,this.telemetryService=bd.instance.telemetryService,this.webviewRunner=r||new Gt}provide(){return Pd(this,void 0,void 0,(function*(){const e=this.webviewRunner,t=yield this.telemetryService.buildContext().toPromise();return"password"==this.loginConfig.context&&(this.loginConfig.target.path="/recover/identify/account"),this.loginConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)}),"ios"===window.device.platform.toLowerCase()&&"login"===this.loginConfig.context&&(yield e.launchWebview({host:this.loginConfig.target.host,path:"logoff",params:this.loginConfig.target.params.reduce((e,t)=>(e[t.key]=t.value,e),Object.assign({},this.resetParams))})),e.launchWebview({host:this.loginConfig.target.host,path:this.loginConfig.target.path,params:this.loginConfig.target.params.reduce((e,t)=>(e[t.key]=t.value,e),Object.assign({},this.resetParams))}).then(()=>e.any(...this.loginConfig.return.reduce((t,n)=>{switch(n.type){case"password":t.push(this.buildPasswordSessionProvider(e,n)),this.resetParams&&"password"==this.loginConfig.context&&e.closeWebview();break;case"state":t.push(this.buildStateSessionProvider(e,n));break;case"google":t.push(this.buildGoogleSessionProvider(e,n,this.customWebViewConfig));break;case"state-error":t.push(e.capture({host:n.when.host,path:n.when.path,params:n.when.params}).then(()=>e.closeWebview().then(()=>e.resolveCaptured("error_message").catch(()=>{throw new xe("Server Error")}).then(e=>{throw new xe(e)}))));break;case"migrate":t.push(e.capture({host:n.when.host,path:n.when.path,params:n.when.params}).then(()=>e.success()).then(t=>(e.resetInAppBrowserEventListeners(),e.clearCapture().then(()=>new Ld(this.autoMergeConfig,this.webviewRunner,t).provide()))));break;case"reset":t.push(e.capture({host:n.when.host,path:n.when.path,params:[...n.when.params,{key:"client_id",resolveTo:"client_id",match:"portal"},{key:"automerge",resolveTo:"automerge",exists:"false"}]}).then(()=>e.getCaptureExtras().then(t=>(this.resetParams=t,e.closeWebview().then(()=>new Promise(e=>setTimeout(e,500)).then(()=>this.provide()))))))}return t},[])))}))}}var wd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Ud extends Md{constructor(e,t){super(bd.instance.sdkConfig.apiConfig,bd.instance.apiService,bd.instance.eventsBusService),this.manualMergeConfig=e,this.telemetryService=bd.instance.telemetryService,this.webviewRunner=t||new Gt}provide(){return wd(this,void 0,void 0,(function*(){const e=this.webviewRunner,t=yield this.telemetryService.buildContext().toPromise();return this.manualMergeConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)}),e.launchWebview({host:this.manualMergeConfig.target.host,path:this.manualMergeConfig.target.path,params:this.manualMergeConfig.target.params.reduce((e,t)=>(e[t.key]=t.value,e),{})}).then(()=>e.any(...this.manualMergeConfig.return.reduce((t,n)=>{switch(n.type){case"password":t.push(this.buildPasswordSessionProvider(e,n));break;case"google":t.push(this.buildGoogleSessionProvider(e,n));break;case"exit":t.push(e.capture({host:n.when.host,path:n.when.path,params:n.when.params}).then(()=>e.closeWebview().then(()=>e.clearCapture().then(()=>wd(this,void 0,void 0,(function*(){throw new jd("EXIT param found")}))))))}return t},[])))}))}}class jd extends Ve{constructor(e){super(e,"INTERRUPT_ERROR"),Object.setPrototypeOf(this,Ve.prototype)}}var Fd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class kd{constructor(e){this.nativeGoogleTokenProvider=e,this.apiService=bd.instance.apiService}static parseAccessToken(e){return Fd(this,void 0,void 0,(function*(){let t=yield I.decodeJWT(e);const n=JSON.parse(t);return{userToken:3===n.sub.split(":").length?n.sub.split(":").pop():n.sub,accessTokenExpiresOn:1e3*n.exp}}))}provide(){return Fd(this,void 0,void 0,(function*(){const e=yield this.nativeGoogleTokenProvider();return this.callGoogleNativeLogin(e.idToken,e.email).toPromise()}))}callGoogleNativeLogin(e,t){const n="ios"===window.device.platform.toLowerCase()?"ios":null,r=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(kd.LOGIN_API_ENDPOINT).withBearerToken(!1).withUserToken(!1).withBody({emailId:t,platform:n}).withHeaders({"X-GOOGLE-ID-TOKEN":e}).build();return this.apiService.fetch(r).pipe(Object(D.map)(e=>Fd(this,void 0,void 0,(function*(){return e.body&&k.CsModule.instance.updateAuthTokenConfig(e.body.access_token),{access_token:e.body.access_token,refresh_token:e.body.refresh_token,userToken:(yield kd.parseAccessToken(e.body.access_token)).userToken}}))))}}kd.LOGIN_API_ENDPOINT="/google/auth/android";var xd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Bd{constructor(e){this.nativeAppleTokenProvider=e,this.apiService=bd.instance.apiService,console.log(this.apiService)}static parseAccessToken(e){return xd(this,void 0,void 0,(function*(){let t=yield I.decodeJWT(e);const n=JSON.parse(t);return{userToken:3===n.sub.split(":").length?n.sub.split(":").pop():n.sub,accessTokenExpiresOn:1e3*n.exp}}))}provide(){return xd(this,void 0,void 0,(function*(){const e=yield this.nativeAppleTokenProvider();return this.callAppleNativeLogin(e).toPromise()}))}callAppleNativeLogin(e){const t="ios"===window.device.platform.toLowerCase()?"ios":null,n=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(Bd.LOGIN_API_ENDPOINT).withBearerToken(!1).withUserToken(!1).withBody(Object.assign({emailId:e.email,platform:t},e)).build();return this.apiService.fetch(n).pipe(Object(D.map)(e=>xd(this,void 0,void 0,(function*(){return e.body&&k.CsModule.instance.updateAuthTokenConfig(e.body.sessionId.access_token),{access_token:e.body.sessionId.access_token,refresh_token:e.body.sessionId.refresh_token,userToken:(yield Bd.parseAccessToken(e.body.sessionId.access_token)).userToken}}))))}}Bd.LOGIN_API_ENDPOINT="/apple/auth/ios";var Vd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Yd extends Md{constructor(e,t,n){super(bd.instance.sdkConfig.apiConfig,bd.instance.apiService,bd.instance.eventsBusService),this.stateSessionConfig=e,this.autoMergeConfig=t,this.telemetryService=bd.instance.telemetryService,this.webViewRunner=n||new Gt}provide(){return Vd(this,void 0,void 0,(function*(){const e=this.webViewRunner,t=yield this.telemetryService.buildContext().toPromise();return this.stateSessionConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)}),e.launchWebview({host:this.stateSessionConfig.target.host,path:this.stateSessionConfig.target.path,params:this.stateSessionConfig.target.params.reduce((e,t)=>(e[t.key]=t.value,e),Object.assign({},this.resetParams))}).then(()=>e.any(...this.stateSessionConfig.return.reduce((t,n)=>{switch(n.type){case"state":t.push(this.buildStateSessionProvider(e,n));break;case"state-error":t.push(e.capture({host:n.when.host,path:n.when.path,params:n.when.params}).then(()=>e.closeWebview().then(()=>e.resolveCaptured("error_message").catch(()=>{throw new xe("Server Error")}).then(e=>{throw new xe(e)}))));break;case"migrate":t.push(e.capture({host:n.when.host,path:n.when.path,params:n.when.params}).then(()=>e.success()).then(t=>(e.resetInAppBrowserEventListeners(),e.clearCapture().then(()=>new Ld(this.autoMergeConfig,this.webViewRunner,t).provide()))))}return t},[])))}))}}var Gd=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class Hd{constructor(e,t){this.loginConfig=e,this.nativeKeycloakTokenProvider=t,this.apiService=bd.instance.apiService}static parseAccessToken(e){return Gd(this,void 0,void 0,(function*(){let t=yield I.decodeJWT(e);const n=JSON.parse(t);return{userToken:3===n.sub.split(":").length?n.sub.split(":").pop():n.sub,accessTokenExpiresOn:1e3*n.exp}}))}provide(){return Gd(this,void 0,void 0,(function*(){return this.callKeycloakNativeLogin(this.nativeKeycloakTokenProvider.username,this.nativeKeycloakTokenProvider.password).toPromise()}))}callKeycloakNativeLogin(e,t){const n="ios"===window.device.platform.toLowerCase()?"ios":window.device.platform.toLowerCase(),r=(new a.CsRequest.Builder).withType(a.CsHttpRequestType.POST).withPath(Hd.LOGIN_API_ENDPOINT).withBearerToken(!1).withUserToken(!1).withBody({client_id:n,emailId:e,password:t,loginConfig:this.loginConfig.target}).build();return this.apiService.fetch(r).pipe(Object(D.map)(e=>Gd(this,void 0,void 0,(function*(){var t;return(null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.access_token)?(k.CsModule.instance.updateAuthTokenConfig(e.body.access_token),{access_token:e.body.access_token,refresh_token:e.body.refresh_token,userToken:(yield Hd.parseAccessToken(e.body.access_token)).userToken}):e.body}))))}}Hd.LOGIN_API_ENDPOINT="/keycloak/login";var $d=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};class qd{constructor(e,t,n){this.loginConfig=e,this.customWebViewConfig=t,this.apiConfig=bd.instance.sdkConfig.apiConfig,this.telemetryService=bd.instance.telemetryService,this.webviewRunner=n||new Gt}static parseAccessToken(e){return $d(this,void 0,void 0,(function*(){let t=yield I.decodeJWT(e);const n=JSON.parse(t);return{userToken:3===n.sub.split(":").length?n.sub.split(":").pop():n.sub,accessTokenExpiresOn:1e3*n.exp}}))}buildGoogleTargetUrl(e,t){const n=new URL(e.googleRedirectUrl);return delete t.redirect_uri,n.searchParams.set("redirect_uri",this.apiConfig.user_authentication.redirectUrl),delete t.error_callback,n.searchParams.set("error_callback",this.apiConfig.user_authentication.redirectUrl),Object.keys(t).forEach(e=>n.searchParams.set(e,t[e])),n}provide(){return $d(this,void 0,void 0,(function*(){const e=this.webviewRunner,t=yield this.telemetryService.buildContext().toPromise();this.loginConfig.target.params.push({key:"pdata",value:JSON.stringify(t.pdata)});let n="",r={};this.loginConfig.target.params.forEach(e=>{"redirect_uri"==e.key&&(n=e.value),r[e.key]=e.value});const i=this.buildGoogleTargetUrl({googleRedirectUrl:`${this.loginConfig.target.host}/${qd.LOGIN_API_ENDPOINT}?redirect_uri=${n}`},r);return e.launchCustomTab({host:i.origin,path:i.pathname,params:Be.parse(i.searchParams.toString(),{ignoreQueryPrefix:!0}),extraParams:this.customWebViewConfig.get("extraParam")}).then(()=>e.success()).then(e=>$d(this,void 0,void 0,(function*(){return{access_token:e.access_token,refresh_token:e.refresh_token,userToken:(yield qd.parseAccessToken(e.access_token)).userToken}})))}))}}qd.LOGIN_API_ENDPOINT="/google/auth";var Kd=n(26)}])}));