text: !function(e,t){function n(t,r){if("."!=t[0]&&"/"!=t[0])return e(t);r=r||"root";var o=n.resolve(t);if(!o&&/\.json$/i.test(t))return e("./"+n.basename(t));var a=n.cache[o];if(!a)try{return e(t)}catch(e){throw new Error('failed to require "'+t+'" from '+r+"\n"+e.message+"\n"+e.stack)}return a.exports||(a.exports={},a.call(a.exports,a,a.exports,n.relative(o))),a.exports}n.cache={},n.basename=e("path").basename,n.resolve=function(t){if("."!=t[0])return e.resolve(t);var r="/"===t.slice(-1)?t:t+"/",o=[t,t+".js",r+"index.js",t+".json",r+"index.json"];for(var a in o){var i=o[a];if(n.cache[i])return i}},n.register=function(e,t){n.cache[e]=t},n.relative=function(e){function t(t){if("."!=t[0])return n(t);var r=e.split("/"),o=t.split("/");for(var a in r.pop(),o){var i=o[a];".."==i?r.pop():"."!=i&&r.push(i)}return n(r.join("/"),e)}return t.resolve=n.resolve,t.cache=n.cache,t},n.register("./cli.js",function(e,t,n){"use strict";var r=c(n("./cli/Api")),o=c(n("commander")),a=c(n("readline")),i=c(n("util"));function c(e){return e&&e.__esModule?e:{default:e}}o.default.version("1.0.0").option("-l, --login <login>","login of your bitshares account").option("-p, --password  [password]","password of your bitshares account").option("-k, --privateKey [privateKey]","private key of your bitshares account").option("-u, --url <nodeUrl>","url of node to connect").parse(process.argv),o.default.password||o.default.privateKey||(console.log("Error: you must provide password or privateKey for accessing to your bitshares account"),process.exit());var u=a.default.createInterface({input:process.stdin,output:process.stdout}),l=">",s=function(e,t,n){console.log(i.default.inspect(t,!1,null)),u.setPrompt(l,l.length),u.prompt()};r.default.getPrograms(o.default.url,o.default.login,o.default.password,o.default.privateKey,s).then(function(e){function t(e,t){var n=t.split(" "),r=n[0],o=["",""].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(n)),a=!1,i=!0,c=!1,u=void 0;try{for(var l,f=e[Symbol.iterator]();!(i=(l=f.next()).done);i=!0){var d=l.value;try{r===d.name()&&(a=!0),d.parse(o)}catch(e){console.log(e)}}}catch(e){c=!0,u=e}finally{try{!i&&f.return&&f.return()}finally{if(c)throw u}}a||s(null,"Unknown command "+r,!0)}e.push(new o.default.Command("help").action(function(t){if("help"===t){var n=!0,r=!1,o=void 0;try{for(var a,i=e[Symbol.iterator]();!(n=(a=i.next()).done);n=!0){a.value.outputHelp(),console.log("\n--------------------------\n")}}catch(e){r=!0,o=e}finally{try{!n&&i.return&&i.return()}finally{if(r)throw o}}s(t,"",!1)}})),e.push(new o.default.Command("exit").action(function(e){"exit"===e&&u.close()})),u.on("line",function(n){t(e,n.trim())}).on("close",function(){process.exit(0)}),u.setPrompt(l,l.length),u.prompt()}).catch(function(e){console.log(e)})}),n.register("./main.js",function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n("./api/Api");t.default=r.Api}),n.register("./api/Api.js",function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Api=void 0;var r,o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n("../common/Account"),i=n("./StudentApi"),c=n("./TeacherApi"),u=n("./BlockchainApi"),l=n("bitsharesjs"),s=n("../common/Configs"),f=n("request-promise"),d=(r=f)&&r.__esModule?r:{default:r};var h=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.account=new a.Account(t,n),this.studentApi=new i.StudentApi(this.account),this.teacherApi=new c.TeacherApi(this.account)}return o(e,null,[{key:"init",value:function(t,n,r){var o=new e(n,r);return new Promise(function(e,n){u.BlockchainApi.init(t).then(function(){return e(o)}).catch(n)})}},{key:"generateKeys",value:function(e,t){return l.Login.generateKeys(e,t)}}]),o(e,[{key:"setPrivateKey",value:function(e){this.account.setPrivateKey(e)}},{key:"register",value:function(t,n){return new Promise(function(r,o){var a=e.generateKeys(t,n);(0,d.default)({method:"POST",url:s.utSchoolFaucetAddress,body:{account:{active_key:a.pubKeys.active,memo_key:a.pubKeys.memo,owner_key:a.pubKeys.owner,name:t,referrer:s.utSchoolFaucet}},json:!0}).then(function(e){r(e)}).catch(function(e){o("Faucet "+s.utSchoolFaucetAddress+" failed. "+e)})})}}]),e}();t.Api=h}),n.register("./api/BitsharesApiExtends.js",function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BitsharesApiExtends=void 0;var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n("bitsharesjs-ws"),a=n("bitsharesjs");var i=a.ChainTypes.object_type,c=parseInt(i.operation_history,10),u=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return r(e,null,[{key:"_fetchHistory",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,n=arguments[2],r=arguments[3],a=this,i=arguments[4],u=arguments[5];return void 0===r&&(r="1."+c+".0"),void 0===i&&(i="1."+c+".0"),new Promise(function(c,l){o.Apis.instance().history_api().exec("get_account_history",[e.get("id"),r,t,i]).then(function(r){var o=!0,i=!1,s=void 0;try{for(var f,d=r[Symbol.iterator]();!(o=(f=d.next()).done);o=!0){var h=f.value;h.op[0]!=n&&void 0!==n||u.push(h)}}catch(e){i=!0,s=e}finally{try{!o&&d.return&&d.return()}finally{if(i)throw s}}r.length==t?a._fetchHistory(e,t,n,void 0,r[0].id,u).then(c,l):c(u)})})}},{key:"fetchHistory",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,n=arguments[2],r=arguments[3],o=arguments[4],i=e;if(!a.ChainValidation.is_object_id(i)&&e.toJS&&(i=e.get("id")),a.ChainValidation.is_object_id(i)&&(e=a.ChainStore.objects_by_id.get(i))){var c=a.ChainTypes.operations[n];if(void 0!==n&&void 0===c)throw new Error("unknown operation: "+n);return this._fetchHistory(e,t,c,r,o,[])}}}]),e}();t.BitsharesApiExtends=u}),n.register("./api/BlockchainApi.js",function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BlockchainApi=void 0;var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n("bitsharesjs"),a=n("bitsharesjs-ws");var i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return r(e,null,[{key:"init",value:function(e){return new Promise(function(t,n){a.Apis.instance(e,!0).init_promise.then(function(e){Promise.all([(new o.TransactionBuilder).update_head_block(),o.ChainStore.init()]).then(function(){console.log("connected to:",e[0].network_name,"network"),t()}).catch(n)}).catch(n)})}}]),e}();t.BlockchainApi=i}),n.register("./api/StudentApi.js",function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.StudentApi=void 0;var r,o=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,o=!1,a=void 0;try{for(var i,c=e[Symbol.iterator]();!(r=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{!r&&c.return&&c.return()}finally{if(o)throw a}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=n("bitsharesjs"),c=n("./BitsharesApiExtends"),u=n("../common/Configs"),l=n("assert"),s=(r=l)&&r.__esModule?r:{default:r};var f=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.account=t,this.feeAsset="BTS"}return a(e,[{key:"applyForLecture",value:function(e){var t=this;return new Promise(function(n,r){(0,s.default)(null!==t.account.privateKey,"You must provide private key for executing this method"),Promise.all([(0,i.FetchChain)("getAccount",e),(0,i.FetchChain)("getAccount",t.account.name),(0,i.FetchChain)("getAsset",u.utSchoolTokenTicket),(0,i.FetchChain)("getAsset",t.feeAsset)]).then(function(a){var c=o(a,4),l=c[0],f=c[1],d=c[2],h=c[3];(0,s.default)(null!==l,"Invalid lecture account "+e),(0,s.default)(null!==f,"Invalid student account "+t.account.name),(0,s.default)(null!==d,"Invalid ticket token "+u.utSchoolTokenTicket),(0,s.default)(null!==h,"Invalid fee asset name "+t.feeAsset);var p=new i.TransactionBuilder;p.add_type_operation("transfer",{fee:{amount:0,asset_id:h.get("id")},from:l.get("id"),to:f.get("id"),amount:{asset_id:d.get("id"),amount:1}}),p.set_required_fees().then(function(){p.propose({fee_paying_account:f.get("id")}),p.set_required_fees().then(function(){p.add_signer(t.account.privateKey,t.account.privateKey.toPublicKey().toPublicKeyString()),p.broadcast().then(function(e){n(p.serialize())}).catch(r)}).catch(r)}).catch(r)}).catch(r)})}},{key:"getLectureStats",value:function(e){var t=this;return new Promise(function(n,r){var a=[u.utSchoolTokenTicket,u.utSchoolTokenSession,u.utSchoolTokenGrade];Promise.all([(0,i.FetchChain)("getAccount",e),(0,i.FetchChain)("getAccount",t.account.name),(0,i.FetchChain)("getAsset",a)]).then(function(e){var u=o(e,3),l=u[0],f=u[1],d=u[2];d=d.toJS(),(0,s.default)(null!==l,"Invalid lecture account "+l),(0,s.default)(null!==f,"Invalid student account "+t.account.name),(0,s.default)(null!==d[0],"Invalid ticket token "+a[0]),(0,s.default)(null!==d[1],"Invalid session token "+a[1]),(0,s.default)(null!==d[2],"Invalid grade token "+a[2]);var h=l.get("id"),p=f.get("id"),v={},y=!0,m=!1,g=void 0;try{for(var A,b=d[Symbol.iterator]();!(y=(A=b.next()).done);y=!0){var k=A.value;v[k.id]={id:k.id,symbol:k.symbol,accepted:!1,balance:i.ChainStore.getAccountBalance(l,k.id)}}}catch(e){m=!0,g=e}finally{try{!y&&b.return&&b.return()}finally{if(m)throw g}}c.BitsharesApiExtends.fetchHistory(h,100,"transfer").then(function(e){var t=!0,r=!1,o=void 0;try{for(var a,i=e[Symbol.iterator]();!(t=(a=i.next()).done);t=!0){var c=a.value.op[1];c.from===h&&c.to===p&&v[c.amount.asset_id]&&(v[c.amount.asset_id].accepted=!0)}}catch(e){r=!0,o=e}finally{try{!t&&i.return&&i.return()}finally{if(r)throw o}}n(v)}).catch(r)}).catch(r)})}},{key:"getLectures",value:function(){var e=this,t=[];return new Promise(function(n,r){Promise.all([(0,i.FetchChain)("getAccount",u.utSchoolAccount),(0,i.FetchChain)("getAsset",u.utSchoolToken)]).then(function(a){var l=o(a,2),f=l[0],d=l[1];(0,s.default)(null!==f,"Invalid utSchoolAccount "+u.utSchoolAccount),(0,s.default)(null!==d,"Invalid utSchoolToken "+u.utSchoolToken),f=f.get("id"),d=d.get("id"),c.BitsharesApiExtends.fetchHistory(f,100,"transfer").then(function(o){var a=[],c=!0,u=!1,l=void 0;try{for(var s,h=o[Symbol.iterator]();!(c=(s=h.next()).done);c=!0){var p=s.value.op[1];p.from===f&&p.amount.asset_id===d&&a.push(p.to)}}catch(e){u=!0,l=e}finally{try{!c&&h.return&&h.return()}finally{if(u)throw l}}0!==a.length?(0,i.FetchChain)("getAccount",a).then(function(o){o=o.toJS();var c=[],u=-1,l=!0,s=!1,f=void 0;try{for(var d,h=o[Symbol.iterator]();!(l=(d=h.next()).done);l=!0){var p=d.value;u++,p?(t.push({id:p.id,name:p.name,teacher:{id:p.active.account_auths[0][0]}}),c.push(p.active.account_auths[0][0])):console.log("Have no information about lecture with id "+a[u])}}catch(e){s=!0,f=e}finally{try{!l&&h.return&&h.return()}finally{if(s)throw f}}(0,i.FetchChain)("getAccount",c).then(function(o){var a={},i=-1;o=o.toJS();var u=!0,l=!1,s=void 0;try{for(var f,d=o[Symbol.iterator]();!(u=(f=d.next()).done);u=!0){var h=f.value;i++,h?a[h.id]=h:console.log("Have no information about teacher with id "+c[i])}}catch(e){l=!0,s=e}finally{try{!u&&d.return&&d.return()}finally{if(l)throw s}}var p=[],v=!0,y=!1,m=void 0;try{for(var g,A=t[Symbol.iterator]();!(v=(g=A.next()).done);v=!0){var b=g.value,k=a[b.teacher.id];k&&(b.teacher.name=k.name),p.push(e.getLectureStats(b.name))}}catch(e){y=!0,m=e}finally{try{!v&&A.return&&A.return()}finally{if(y)throw m}}Promise.all(p).then(function(e){for(var r=0;r<t.length;r++)t[r].stats=e[r];n(t)}).catch(r)}).catch(r)}).catch(r):n(t)}).catch(r)}).catch(r)})}}]),e}();t.StudentApi=f}),n.register("./api/TeacherApi.js",function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TeacherApi=void 0;var r,o=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,o=!1,a=void 0;try{for(var i,c=e[Symbol.iterator]();!(r=(i=c.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{!r&&c.return&&c.return()}finally{if(o)throw a}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=n("bitsharesjs"),c=n("./BitsharesApiExtends"),u=n("../common/Configs"),l=n("assert"),s=(r=l)&&r.__esModule?r:{default:r};var f=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.account=t,this.feeAsset="BTS"}return a(e,[{key:"_sendToken",value:function(e,t,n){var r=this;return new Promise(function(a,c){(0,s.default)(null!==r.account.privateKey,"You must provide private key for executing this method"),Promise.all([(0,i.FetchChain)("getAccount",e),(0,i.FetchChain)("getAccount",t),(0,i.FetchChain)("getAsset",n),(0,i.FetchChain)("getAsset",r.feeAsset)]).then(function(u){var l=o(u,4),f=l[0],d=l[1],h=l[2],p=l[3];(0,s.default)(null!==f,"Invalid lecture account "+e),(0,s.default)(null!==d,"Invalid student account "+t),(0,s.default)(null!==h,"Invalid education token "+n),(0,s.default)(null!==p,"Invalid fee asset "+r.feeAsset);var v=new i.TransactionBuilder;v.add_type_operation("transfer",{fee:{amount:0,asset_id:p.get("id")},from:f.get("id"),to:d.get("id"),amount:{asset_id:h.get("id"),amount:1}}),v.set_required_fees().then(function(){v.add_signer(r.account.privateKey,r.account.privateKey.toPublicKey().toPublicKeyString()),v.broadcast().then(function(e){a(v.serialize())}).catch(c)}).catch(c)}).catch(c)})}},{key:"sendSessionToken",value:function(e,t){return this._sendToken(e,t,u.utSchoolTokenSession)}},{key:"sendGradeToken",value:function(e,t){return this._sendToken(e,t,u.utSchoolTokenGrade)}},{key:"getLectureParticipants",value:function(e){return new Promise(function(t,n){var r=[u.utSchoolTokenTicket,u.utSchoolTokenSession,u.utSchoolTokenGrade];Promise.all([(0,i.FetchChain)("getAccount",e),(0,i.FetchChain)("getAsset",r)]).then(function(a){var u=o(a,2),l=u[0],f=u[1];f=f.toJS(),(0,s.default)(null!==l,"Invalid lecture account "+e),(0,s.default)(null!==f[0],"Invalid ticket token "+r[0]),(0,s.default)(null!==f[1],"Invalid session token "+r[1]),(0,s.default)(null!==f[2],"Invalid grade token "+r[2]);var d=l.get("id"),h={},p=f.map(function(e){return e.id}),v=f[0].id;c.BitsharesApiExtends.fetchHistory(d,100,"transfer").then(function(e){var r=[],o=!0,a=!1,c=void 0;try{for(var u,l=e[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var s=u.value.op[1];if(s.from===d){if(-1===p.indexOf(s.amount.asset_id))continue;var y=s.amount.asset_id;if(y===v&&r.push(s.to),-1!==p.indexOf(y)){var m=h[s.to];if(!m){h[s.to]=m={};var g=!0,A=!1,b=void 0;try{for(var k,S=f[Symbol.iterator]();!(g=(k=S.next()).done);g=!0){var _=k.value;m[_.id]={id:_.id,symbol:_.symbol,accepted:!1}}}catch(e){A=!0,b=e}finally{try{!g&&S.return&&S.return()}finally{if(A)throw b}}}m[y].accepted=!0}}}}catch(e){a=!0,c=e}finally{try{!o&&l.return&&l.return()}finally{if(a)throw c}}(0,i.FetchChain)("getAccount",r).then(function(e){e=e.toJS();var n={},o=-1,a=!0,i=!1,c=void 0;try{for(var u,l=e[Symbol.iterator]();!(a=(u=l.next()).done);a=!0){var s=u.value;o++,s?n[s.id]=s:console.log("Have no information about account "+f[o])}}catch(e){i=!0,c=e}finally{try{!a&&l.return&&l.return()}finally{if(i)throw c}}var f=[],d=!0,p=!1,v=void 0;try{for(var y,m=r[Symbol.iterator]();!(d=(y=m.next()).done);d=!0){var g=n[y.value];g&&f.push({id:g.id,name:g.name,stats:h[g.id]})}}catch(e){p=!0,v=e}finally{try{!d&&m.return&&m.return()}finally{if(p)throw v}}t(f)}).catch(n)}).catch(n)}).catch(n)})}},{key:"getLectureApplications",value:function(e){return new Promise(function(t,n){Promise.all([(0,i.FetchChain)("getAccount",e),(0,i.FetchChain)("getAsset",u.utSchoolTokenTicket)]).then(function(r){var a=o(r,2),c=a[0],l=a[1];(0,s.default)(null!==c,"Invalid lecture account "+e),(0,s.default)(null!==l,"Invalid ticket token "+u.utSchoolTokenTicket);var f=c.get("id");l=l.get("id");var d=c.toJS().proposals;if(0!=d.length){var h=[];(0,i.FetchChain)("getObject",d).then(function(e){e=e.toJS();var r=[],o=-1,a=!0,c=!1,u=void 0;try{for(var s,p=e[Symbol.iterator]();!(a=(s=p.next()).done);a=!0){var v=s.value;if(o++,v){if(!(Date.parse(v.proposed_transaction.expiration)<new Date/1e3)){var y=v.proposed_transaction.operations,m=void 0,g=!0,A=!1,b=void 0;try{for(var k,S=y[Symbol.iterator]();!(g=(k=S.next()).done);g=!0){var _=k.value[1];if(_.amount.asset_id==l&&_.from==f){m=_;break}}}catch(e){A=!0,b=e}finally{try{!g&&S.return&&S.return()}finally{if(A)throw b}}m&&(r.push(m.to),h.push({id:v.id,operation:m}))}}else console.log("Have no information about proposal "+d[o])}}catch(e){c=!0,u=e}finally{try{!a&&p.return&&p.return()}finally{if(c)throw u}}0!=h.length?(0,i.FetchChain)("getAccount",r).then(function(e){e=e.toJS();var n={},o=-1,a=!0,i=!1,c=void 0;try{for(var u,l=e[Symbol.iterator]();!(a=(u=l.next()).done);a=!0){var s=u.value,f=r[++o];s||(console.log("Have no information about account "+f),s={id:f}),n[f]=s}}catch(e){i=!0,c=e}finally{try{!a&&l.return&&l.return()}finally{if(i)throw c}}var d=!0,p=!1,v=void 0;try{for(var y,m=h[Symbol.iterator]();!(d=(y=m.next()).done);d=!0){var g=y.value,A=n[g.operation.to];delete g.operation,g.account={id:A.id,name:A.name}}}catch(e){p=!0,v=e}finally{try{!d&&m.return&&m.return()}finally{if(p)throw v}}t(h)}).catch(n):t([])}).catch(n)}else t([])}).catch(n)})}},{key:"acceptApplication",value:function(e){var t=this;return new Promise(function(n,r){(0,s.default)(null!==t.account.privateKey,"You must provide private key for executing this method"),Promise.all([(0,i.FetchChain)("getAccount",t.account.name),(0,i.FetchChain)("getAsset",t.feeAsset)]).then(function(a){var c=o(a,3),u=c[0],l=c[1];c[2];(0,s.default)(null!==u,"Invalid teacher account "+t.account.name),(0,s.default)(null!==l,"Invalid fee asset "+t.feeAsset);var f=new i.TransactionBuilder;f.add_type_operation("proposal_update",{fee:{amount:0,asset_id:l.get("id")},fee_paying_account:u.get("id"),proposal:e,active_approvals_to_add:[u.get("id")]}),f.set_required_fees().then(function(){f.add_signer(t.account.privateKey,t.account.privateKey.toPublicKey().toPublicKeyString()),f.broadcast().then(function(e){n(f.serialize())}).catch(r)}).catch(r)}).catch(r)})}},{key:"getLectureStats",value:function(e){return Promise.all([this.getLectureParticipants(e),this.getLectureApplications(e)])}},{key:"__processLectureQueue",value:function(e,t,n){var r=this;t>=e.length?n(e):this.getLectureStats(e[t].name).then(function(a){var i=o(a,2),c=i[0],u=i[1];e[t].participants=c,e[t].applications=u,r.__processLectureQueue(e,t+1,n)})}},{key:"getLectures",value:function(){var e=this;return new Promise(function(t,n){Promise.all([(0,i.FetchChain)("getAccount",u.utSchoolAccount),(0,i.FetchChain)("getAccount",e.account.name),(0,i.FetchChain)("getAsset",u.utSchoolToken)]).then(function(r){var a=o(r,3),l=a[0],f=a[1],d=a[2];(0,s.default)(null!==l,"Invalid utSchoolAccount "+u.utSchoolAccount),(0,s.default)(null!==f,"Invalid teacher account "+e.account.name),(0,s.default)(null!==d,"Invalid utSchoolToken "+u.utSchoolToken),l=l.get("id"),f=f.get("id"),d=d.get("id"),c.BitsharesApiExtends.fetchHistory(l,100,"transfer").then(function(r){var o=[],a=!0,c=!1,u=void 0;try{for(var s,h=r[Symbol.iterator]();!(a=(s=h.next()).done);a=!0){var p=s.value.op[1];p.from===l&&p.amount.asset_id===d&&o.push(p.to)}}catch(e){c=!0,u=e}finally{try{!a&&h.return&&h.return()}finally{if(c)throw u}}0!==o.length?(0,i.FetchChain)("getAccount",o).then(function(n){n=n.toJS();var r=[],a=-1,i=!0,c=!1,u=void 0;try{for(var l,s=n[Symbol.iterator]();!(i=(l=s.next()).done);i=!0){var d=l.value;if(a++,d){var h=d.active.account_auths;if(0!==h.length&&0!==h[0].length){var p=h[0],v=!0,y=!1,m=void 0;try{for(var g,A=p[Symbol.iterator]();!(v=(g=A.next()).done);v=!0){if(g.value===f){r.push({id:d.id,name:d.name});break}}}catch(e){y=!0,m=e}finally{try{!v&&A.return&&A.return()}finally{if(y)throw m}}}}else console.log("Have no information about lecture "+o[a])}}catch(e){c=!0,u=e}finally{try{!i&&s.return&&s.return()}finally{if(c)throw u}}0!==r.length?e.__processLectureQueue(r,0,t):t([])}).catch(n):t([])}).catch(n)}).catch(n)})}}]),e}();t.TeacherApi=f}),n.register("./cli/Api.js",function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,o,a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=s(n("./StudentApi")),c=s(n("./TeacherApi")),u=n("../api/Api"),l=n("./ProgramsGenerator");function s(e){return e&&e.__esModule?e:{default:e}}function f(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var d=(o=r=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return a(e,null,[{key:"getPrograms",value:function(t,n,r,o,a){return u.Api.init(t,n,o).then(function(t){return o||(o=u.Api.generateKeys(n,r).privKeys.active,t.account.privateKey=o),[].concat(f((0,l.generatePrograms)(e.programs,t,a)),f((0,l.generatePrograms)(i.default.programs,t.studentApi,a)),f((0,l.generatePrograms)(c.default.programs,t.teacherApi,a)))})}}]),e}(),r.programs=[{command:{name:"setPrivateKey",description:"set private key of current user"},options:[{key:"privateKey",name:"-p, --privateKey <privateKey>",description:"private key",required:!0}],exec:"setPrivateKey"},{command:{name:"register",description:"register user by login, password"},options:[{key:"login",name:"-l, --login <login>",description:"name of the new bitshares account",required:!0},{key:"password",name:"-p, --password <password>",description:"password for generating bitshares keys",required:!0}],exec:"register"}],o);t.default=d}),n.register("./cli/ProgramsGenerator.js",function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.generatePrograms=void 0;var r,o=n("commander"),a=(r=o)&&r.__esModule?r:{default:r};t.generatePrograms=function(e,t,n){var r=[],o=!0,i=!1,c=void 0;try{for(var u,l=function(){var e=u.value,o=new a.default.Command(e.command.name);o.description(e.command.description);var i=!0,c=!1,l=void 0;try{for(var s,f=e.options[Symbol.iterator]();!(i=(s=f.next()).done);i=!0){var d=s.value;o.option(d.name,d.description)}}catch(e){c=!0,l=e}finally{try{!i&&f.return&&f.return()}finally{if(c)throw l}}o.action(function(r,o){if(r===e.command.name){var a=[],i=!0,c=!1,u=void 0;try{for(var l,s=e.options[Symbol.iterator]();!(i=(l=s.next()).done);i=!0){var f=l.value,d=o[f.key];if(null==d&&f.required)return void n(r,"Option "+f.name+" is required for method "+r,!0);a.push(d)}}catch(e){c=!0,u=e}finally{try{!i&&s.return&&s.return()}finally{if(c)throw u}}t[e.exec].apply(t,a).then(function(e){n(r,e,!1)}).catch(function(e){n(r,e,!0)})}}),r.push(o)},s=e[Symbol.iterator]();!(o=(u=s.next()).done);o=!0)l()}catch(e){i=!0,c=e}finally{try{!o&&s.return&&s.return()}finally{if(i)throw c}}return r}}),n.register("./cli/StudentApi.js",function(e,t,n){"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0});var o=(r=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)},[{command:{name:"studentApi.applyForLecture",description:"apply current user for the lecture"},options:[{key:"lectureAccount",name:"-l, --lectureAccount <lectureAccount>",description:"name of the bitshares lecture account",required:!0}],exec:"applyForLecture"},{command:{name:"studentApi.getLectureStats",description:"collect information about lecture"},options:[{key:"lectureAccount",name:"-l, --lectureAccount <lectureAccount>",description:"name of the bitshares lecture account",required:!0}],exec:"getLectureStats"},{command:{name:"studentApi.getLectures",description:"return all available lectures for current user"},options:[],exec:"getLectures"}],r);t.default=o}),n.register("./cli/TeacherApi.js",function(e,t,n){"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0});var o=(r=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)},[{command:{name:"teacherApi.sendSessionToken",description:"send session token from lecture account to particular student"},options:[{key:"lectureAccount",name:"-l, --lectureAccount <lectureAccount>",description:"name of the bitshares lecture account",required:!0},{key:"studentAccount",name:"-s, --studentAccount <studentAccount>",description:"name of the bitshares student account",required:!0}],exec:"sendSessionToken"},{command:{name:"teacherApi.sendGradeToken",description:"send grade token from lecture account to particular student"},options:[{key:"lectureAccount",name:"-l, --lectureAccount <lectureAccount>",description:"name of the bitshares lecture account",required:!0},{key:"studentAccount",name:"-s, --studentAccount <studentAccount>",description:"name of the bitshares student account",required:!0}],exec:"sendGradeToken"},{command:{name:"teacherApi.getLectureParticipants",description:"fetch from blockchain information about participants of the lecture"},options:[{key:"lectureAccount",name:"-l, --lectureAccount <lectureAccount>",description:"name of the bitshares lecture account",required:!0}],exec:"getLectureParticipants"},{command:{name:"teacherApi.getLectureApplications",description:"fetch from blockchain information about applications for the lecture"},options:[{key:"lectureAccount",name:"-l, --lectureAccount <lectureAccount>",description:"name of the bitshares lecture account",required:!0}],exec:"getLectureApplications"},{command:{name:"teacherApi.acceptApplication",description:"accept proposal for application for the lecture"},options:[{key:"lectureApplicationId",name:"-i, --lectureApplicationId <lectureApplicationId>",description:"id of the proposal for application for the lecture",required:!0}],exec:"acceptApplication"},{command:{name:"teacherApi.getLectureStats",description:"return statistics about particular lecture"},options:[{key:"lectureAccount",name:"-l, --lectureAccount <lectureAccount>",description:"name of the bitshares lecture account",required:!0}],exec:"getLectureStats"},{command:{name:"teacherApi.getLectures",description:"collect all lectures of the current user"},options:[],exec:"getLectures"}],r);t.default=o}),n.register("./common/Account.js",function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Account=void 0;var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n("bitsharesjs");n("bs58");var a=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name=t,this.setPrivateKey(n)}return r(e,[{key:"setPrivateKey",value:function(e){this.privateKey=e?o.PrivateKey.fromWif(e):null}}]),e}();t.Account=a}),n.register("./common/Configs.js",function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="UTSCHOOL";t.utSchoolToken=r,t.utSchoolTokenTicket="UTSCHOOL.TICKET",t.utSchoolTokenSession="UTSCHOOL.SESSION",t.utSchoolTokenGrade="UTSCHOOL.GRADE",t.utSchoolAccount="ut-school",t.utSchoolFaucetAddress="https://transnet.tech:10443/api/v1/accounts",t.utSchoolFaucet="u-tech-faucet"}),t.exports=n("./main.js")}(require,module);
  //# sourceMappingURL=app.min.js.map
  