var __awaiter=this&&this.__awaiter||function(t,e,n,i){function s(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,r){function a(t){try{c(i.next(t))}catch(t){r(t)}}function o(t){try{c(i["throw"](t))}catch(t){r(t)}}function c(t){t.done?n(t.value):s(t.value).then(a,o)}c((i=i.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,s,r,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(t){return function(e){return c([t,e])}}function c(a){if(i)throw new TypeError("Generator is already executing.");while(n)try{if(i=1,s&&(r=a[0]&2?s["return"]:a[0]?s["throw"]||((r=s["return"])&&r.call(s),0):s.next)&&!(r=r.call(s,a[1])).done)return r;if(s=0,r)a=[a[0]&2,r.value];switch(a[0]){case 0:case 1:r=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;s=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(r=n.trys,r=r.length>0&&r[r.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!r||a[1]>r[0]&&a[1]<r[3])){n.label=a[1];break}if(a[0]===6&&n.label<r[1]){n.label=r[1];r=a;break}if(r&&n.label<r[2]){n.label=r[2];n.ops.push(a);break}if(r[2])n.ops.pop();n.trys.pop();continue}a=e.call(t,n)}catch(t){a=[6,t];s=0}finally{i=r=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};System.register(["./p-5b6828db.system.js","./p-805e81fb.system.js","./p-0bbf3c73.system.js","./p-da593370.system.js","./p-3b429006.system.js","./p-2957c5d8.system.js","./p-58f2f536.system.js","./p-9424fd5c.system.js","./p-f1345828.system.js","./p-fa32c614.system.js","./p-ac291838.system.js","./p-b42ad17a.system.js","./p-5f835359.system.js","./p-9cd38fce.system.js","./p-23628d1c.system.js","./p-62034033.system.js","./p-1b089731.system.js","./p-90b7d919.system.js","./p-2db4f08c.system.js","./p-c67a319b.system.js","./p-cae65cfa.system.js","./p-fe1f76a3.system.js","./p-66d9c61b.system.js"],(function(t){"use strict";var e,n,i,s,r,a,o,c,u,f,l;return{setters:[function(t){e=t.r;n=t.c;i=t.h;s=t.H},function(){},function(){},function(){},function(t){r=t.c;a=t.I;o=t.M;c=t.C;u=t.a},function(t){f=t.g;l=t.m},function(){},function(){},function(){},function(){},function(){},function(){},function(){},function(){},function(){},function(){},function(){},function(){},function(){},function(){},function(){},function(){},function(){}],execute:function(){var p=undefined&&undefined.__rest||function(t,e){var n={};for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0)n[i]=t[i];if(t!=null&&typeof Object.getOwnPropertySymbols==="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++){if(e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s]))n[i[s]]=t[i[s]]}return n};var y=t("mentornity_accept_application_button",function(){function t(t){var i=this;e(this,t);this.acceptApplication=n(this,"acceptApplication",7);this.isProgressing=false;this.isInvitationSent=false;this.onInviteClick=function(){return __awaiter(i,void 0,void 0,(function(){var t,e,n,i,s,y,m,d,h,g,b,v,j,w,_,P;var I=this;return __generator(this,(function(S){switch(S.label){case 0:t=f(),e=t.context.organisationId,n=t.headers;i=this.item,s=i.role,y=i.firstName,m=i.lastName,d=i.email,h=i.language,g=i._id,b=i.applicationStatus,v=i.createdAt,j=p(i,["role","firstName","lastName","email","language","_id","applicationStatus","createdAt"]);this.isProgressing=true;w=r(l,n);return[4,w.importUser(e,s,{email:d,firstName:y,lastName:m,metadata:{data:j}}).catch((function(t){I.error=t;I.isProgressing=false}))];case 1:_=S.sent();if(!_)return[2];return[4,w.createInvitation(new a({accountType:s,firstName:y,invitee:new o(_._id,c.Users),issuedFor:d,language:h,lastName:m,organisation:new o(e,c.Organisations),skills:[],status:u.Pending})).catch((function(t){I.error=t;I.isProgressing=false}))];case 2:P=S.sent();if(!P)return[2];this.isInvitationSent=true;this.isProgressing=false;this.acceptApplication.emit();return[2]}}))}))}}t.prototype.render=function(){var t=this.item.applicationStatus==="invited"||this.isInvitationSent;return i(s,{class:"d-block"},i("dvn-button",{leaned:true,scale:"small",tagMode:t,tint:t?"secondary":"primary",view:t?"ghost":"solid",onClick:this.onInviteClick,progressing:this.isProgressing,disabled:this.isProgressing},t?"Invited":"Accept & Invite"))};return t}())}}}));