var __awaiter=this&&this.__awaiter||function(t,i,e,n){function r(t){return t instanceof e?t:new e((function(i){i(t)}))}return new(e||(e=Promise))((function(e,s){function u(t){try{a(n.next(t))}catch(t){s(t)}}function o(t){try{a(n["throw"](t))}catch(t){s(t)}}function a(t){t.done?e(t.value):r(t.value).then(u,o)}a((n=n.apply(t,i||[])).next())}))};var __generator=this&&this.__generator||function(t,i){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,r,s,u;return u={next:o(0),throw:o(1),return:o(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function o(t){return function(i){return a([t,i])}}function a(o){if(n)throw new TypeError("Generator is already executing.");while(u&&(u=0,o[0]&&(e=0)),e)try{if(n=1,r&&(s=o[0]&2?r["return"]:o[0]?r["throw"]||((s=r["return"])&&s.call(r),0):r.next)&&!(s=s.call(r,o[1])).done)return s;if(r=0,s)o=[o[0]&2,s.value];switch(o[0]){case 0:case 1:s=o;break;case 4:e.label++;return{value:o[1],done:false};case 5:e.label++;r=o[1];o=[0];continue;case 7:o=e.ops.pop();e.trys.pop();continue;default:if(!(s=e.trys,s=s.length>0&&s[s.length-1])&&(o[0]===6||o[0]===2)){e=0;continue}if(o[0]===3&&(!s||o[1]>s[0]&&o[1]0?i[e-1]:undefined};t.prototype.queueTrns=function(t,i){return __awaiter(this,void 0,void 0,(function(){var e,n,r,s,u;return __generator(this,(function(o){switch(o.label){case 0:if(this.isTransitioning&&((e=t.opts)===null||e===void 0?void 0:e.skipIfBusy)){return[2,false]}r=new Promise((function(i,e){t.resolve=i;t.reject=e}));t.done=i;if(!(t.opts&&t.opts.updateURL!==false&&this.useRouter))return[3,2];s=document.querySelector("ion-router");if(!s)return[3,2];return[4,s.canTransition()];case 1:u=o.sent();if(u===false){return[2,false]}if(typeof u==="string"){s.push(u,t.opts.direction||"back");return[2,false]}o.label=2;case 2:if(((n=t.insertViews)===null||n===void 0?void 0:n.length)===0){t.insertViews=undefined}this.transInstr.push(t);this.nextTrns();return[2,r]}}))}))};t.prototype.success=function(t,i){if(this.destroyed){this.fireError("nav controller was destroyed",i);return}if(i.done){i.done(t.hasCompleted,t.requiresTransition,t.enteringView,t.leavingView,t.direction)}i.resolve(t.hasCompleted);if(i.opts.updateURL!==false&&this.useRouter){var e=document.querySelector("ion-router");if(e){var n=t.direction==="back"?"back":"forward";e.navChanged(n)}}};t.prototype.failed=function(t,i){if(this.destroyed){this.fireError("nav controller was destroyed",i);return}this.transInstr.length=0;this.fireError(t,i)};t.prototype.fireError=function(t,i){if(i.done){i.done(false,false,t)}if(i.reject&&!this.destroyed){i.reject(t)}else{i.resolve(false)}};t.prototype.nextTrns=function(){if(this.isTransitioning){return false}var t=this.transInstr.shift();if(!t){return false}this.runTransition(t);return true};t.prototype.runTransition=function(t){return __awaiter(this,void 0,void 0,(function(){var i,e,n,r,s,u;return __generator(this,(function(o){switch(o.label){case 0:o.trys.push([0,6,,7]);this.ionNavWillChange.emit();this.isTransitioning=true;this.prepareTI(t);i=this.getActiveSync();e=this.getEnteringView(t,i);if(!i&&!e){throw new Error("no views in the stack to be removed")}if(!(e&&e.state===p))return[3,2];return[4,e.init(this.el)];case 1:o.sent();o.label=2;case 2:this.postViewInit(e,i,t);n=(t.enteringRequiresTransition||t.leavingRequiresTransition)&&e!==i;if(n&&t.opts&&i){r=t.opts.direction==="back";if(r){t.opts.animationBuilder=t.opts.animationBuilder||(e===null||e===void 0?void 0:e.animationBuilder)}i.animationBuilder=t.opts.animationBuilder}s=void 0;if(!n)return[3,4];return[4,this.transition(e,i,t)];case 3:s=o.sent();return[3,5];case 4:s={hasCompleted:true,requiresTransition:false};o.label=5;case 5:this.success(s,t);this.ionNavDidChange.emit();return[3,7];case 6:u=o.sent();this.failed(u,t);return[3,7];case 7:this.isTransitioning=false;this.nextTrns();return[2]}}))}))};t.prototype.prepareTI=function(t){var i,e;var n;var r=this.views.length;(i=t.opts)!==null&&i!==void 0?i:t.opts={};(e=(n=t.opts).delegate)!==null&&e!==void 0?e:n.delegate=this.delegate;if(t.removeView!==undefined){a(t.removeStart!==undefined,"removeView needs removeStart");a(t.removeCount!==undefined,"removeView needs removeCount");var s=this.views.indexOf(t.removeView);if(s<0){throw new Error("removeView was not found")}t.removeStart+=s}if(t.removeStart!==undefined){if(t.removeStart<0){t.removeStart=r-1}if(t.removeCount<0){t.removeCount=r-t.removeStart}t.leavingRequiresTransition=t.removeCount>0&&t.removeStart+t.removeCount===r}if(t.insertViews){if(t.insertStart<0||t.insertStart>r){t.insertStart=r}t.enteringRequiresTransition=t.insertStart===r}var u=t.insertViews;if(!u){return}a(u.length>0,"length can not be zero");var o=B(u);if(o.length===0){throw new Error("invalid views to insert")}for(var f=0,h=o;f=0;u--){var o=r[u];if((u=s)&&o!==i){return o}}}return undefined};t.prototype.postViewInit=function(t,i,e){var n,r,s;a(i||t,"Both leavingView and enteringView are null");a(e.resolve,"resolve must be valid");a(e.reject,"reject must be valid");var u=e.opts;var o=e.insertViews,f=e.removeStart,c=e.removeCount;var d;if(f!==undefined&&c!==undefined){a(f>=0,"removeStart can not be negative");a(c>=0,"removeCount can not be negative");d=[];for(var m=f;m=0,"final balance can not be negative");if(_===0){console.warn("You can't remove all the pages in the navigation stack. nav.pop() is probably called too many times.",this,this.el);throw new Error("navigation stack needs at least one root page")}if(o){var p=e.insertStart;for(var g=0,y=o;g0){for(var k=0,j=d;k-1){a(t.nav===this,"view is not part of the nav");e.splice(n,1);e.splice(i,0,t)}else{a(!t.nav,"nav is used");t.nav=this;e.splice(i,0,t)}};t.prototype.removeView=function(t){a(t.state===g||t.state===y,"view state should be loaded or destroyed");var i=this.views;var e=i.indexOf(t);a(e>-1,"view must be part of the stack");if(e>=0){i.splice(e,1)}};t.prototype.destroyView=function(t){t._destroy();this.removeView(t)};t.prototype.unmountInactiveViews=function(t){if(this.destroyed){return}var i=this.views;var e=i.indexOf(t);for(var n=i.length-1;n>=0;n--){var r=i[n];var s=r.element;if(s){if(n>e){h(s,v);this.destroyView(r)}else if(n