UNPKG

@tindtechnologies/universalviewer

Version:

The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎

1 lines 23.7 kB
"use strict";(self.webpackChunkUV=self.webpackChunkUV||[]).push([[6956],{8882(e,t,n){n.d(t,{P:()=>r,g:()=>i});var r=function(e,t){this.x=e,this.y=t},i=function(e,t,n,r,i){var a=s(e.y,t.y,n.y,r.y,i);return o(e.x,t.x,n.x,r.x,a[0])},o=function(e,t,n,r,i){return i*(3*t*Math.pow(i-1,2)+i*(-3*n*i+3*n+r*i))-e*Math.pow(i-1,3)},s=function(e,t,n,r,i){return a((r-=i)-3*(n-=i)+3*(t-=i)-(e-=i),3*n-6*t+3*e,3*t-3*e,e).filter((function(e){return e>=0&&e<=1}))},a=function(e,t,n,r){if(0===e)return function(e,t,n){var r=t*t-4*e*n;return r<0?[]:[(-t+Math.sqrt(r))/(2*e),(-t-Math.sqrt(r))/(2*e)]}(t,n,r);var i=(3*(n/=e)-(t/=e)*t)/3,o=(2*t*t*t-9*t*n+27*(r/=e))/27;if(0===i)return[Math.pow(-o,1/3)];if(0===o)return[Math.sqrt(-i),-Math.sqrt(-i)];var s=Math.pow(o/2,2)+Math.pow(i/3,3);if(0===s)return[Math.pow(o/2,.5)-t/3];if(s>0)return[Math.pow(-o/2+Math.sqrt(s),1/3)-Math.pow(o/2+Math.sqrt(s),1/3)-t/3];var a=Math.sqrt(Math.pow(-i/3,3)),u=Math.acos(-o/(2*Math.sqrt(Math.pow(-i/3,3)))),c=2*Math.pow(a,1/3);return[c*Math.cos(u/3)-t/3,c*Math.cos((u+2*Math.PI)/3)-t/3,c*Math.cos((u+4*Math.PI)/3)-t/3]}},5721(e,t,n){n.d(t,{a:()=>r,d:()=>i});var r=function(e,t,n,r,i){return o=void 0,s=void 0,u=function(){var o;return 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=(i=s.trys).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])}}}(this,(function(s){switch(s.label){case 0:if(e)return[2,e.attachViewToDom(t,n,i,r)];if("string"!=typeof n&&!(n instanceof HTMLElement))throw new Error("framework delegate is missing");return o="string"==typeof n?t.ownerDocument&&t.ownerDocument.createElement(n):n,r&&r.forEach((function(e){return o.classList.add(e)})),i&&Object.assign(o,i),t.appendChild(o),o.componentOnReady?[4,o.componentOnReady()]:[3,2];case 1:s.sent(),s.label=2;case 2:return[2,o]}}))},new((a=void 0)||(a=Promise))((function(e,t){function n(e){try{i(u.next(e))}catch(e){t(e)}}function r(e){try{i(u.throw(e))}catch(e){t(e)}}function i(t){t.done?e(t.value):new a((function(e){e(t.value)})).then(n,r)}i((u=u.apply(o,s||[])).next())}));var o,s,a,u},i=function(e,t){if(t){if(e){var n=t.parentElement;return e.removeViewFromDom(n,t)}t.remove()}return Promise.resolve()}},884(e,t,n){n.d(t,{a:()=>r,b:()=>u,c:()=>a,d:()=>v,e:()=>f,f:()=>o,h:()=>i,i:()=>h,n:()=>c,p:()=>l,r:()=>s});var r=function(e){return"function"==typeof __zone_symbol__requestAnimationFrame?__zone_symbol__requestAnimationFrame(e):"function"==typeof requestAnimationFrame?requestAnimationFrame(e):setTimeout(e)},i=function(e){return!!e.shadowRoot&&!!e.attachShadow},o=function(e){var t=e.closest("ion-item");return t?t.querySelector("ion-label"):null},s=function(e,t,n,r,o){if(e||i(t)){var s=t.querySelector("input.aux-input");s||((s=t.ownerDocument.createElement("input")).type="hidden",s.classList.add("aux-input"),t.appendChild(s)),s.disabled=o,s.name=n,s.value=r||""}},a=function(e,t,n){return Math.max(e,Math.min(t,n))},u=function(e,t){if(!e){var n="ASSERT: "+t;throw console.error(n),new Error(n)}},c=function(e){return e.timeStamp||Date.now()},l=function(e){if(e){var t=e.changedTouches;if(t&&t.length>0){var n=t[0];return{x:n.clientX,y:n.clientY}}if(void 0!==e.pageX)return{x:e.pageX,y:e.pageY}}return{x:0,y:0}},h=function(e){var t="rtl"===document.dir;switch(e){case"start":return t;case"end":return!t;default:throw new Error('"'+e+'" is not a valid value for [side]. Use "start" or "end" instead.')}},v=function(e,t){var n=e._original||e;return{_original:e,emit:f(n.emit.bind(n),t)}},f=function(e,t){var n;return void 0===t&&(t=0),function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];clearTimeout(n),n=setTimeout.apply(void 0,[e,t].concat(r))}}},1761(e,t,n){n.d(t,{L:()=>c,a:()=>a,b:()=>u,d:()=>T,g:()=>P,l:()=>E,s:()=>C,t:()=>l});var r=n(5873),i=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(s,a)}u((r=r.apply(e,t||[])).next())}))},o=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=(i=s.trys).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])}}},s=void 0,a="ionViewWillLeave",u="ionViewDidLeave",c="ionViewWillUnload",l=function(e){return new Promise((function(t,n){(0,r.w)((function(){h(e),v(e).then((function(n){n.animation&&n.animation.destroy(),f(e),t(n)}),(function(t){f(e),n(t)}))}))}))},h=function(e){var t=e.enteringEl,n=e.leavingEl;V(t,n,e.direction),e.showGoBack?t.classList.add("can-go-back"):t.classList.remove("can-go-back"),C(t,!1),n&&C(n,!1)},v=function(e){return i(s,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return[4,p(e)];case 1:return[2,(t=n.sent())?d(t,e):m(e)]}}))}))},f=function(e){var t=e.enteringEl,n=e.leavingEl;t.classList.remove("ion-page-invisible"),void 0!==n&&n.classList.remove("ion-page-invisible")},p=function(e){return i(s,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return e.leavingEl&&e.animated&&0!==e.duration?e.animationBuilder?[2,e.animationBuilder]:"ios"!==e.mode?[3,2]:[4,Promise.all([n.e(6653),n.e(5480)]).then(n.bind(n,5480))]:[2,void 0];case 1:return t=r.sent().iosTransitionAnimation,[3,4];case 2:return[4,Promise.all([n.e(6653),n.e(3203)]).then(n.bind(n,3203))];case 3:t=r.sent().mdTransitionAnimation,r.label=4;case 4:return[2,t]}}))}))},d=function(e,t){return i(s,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return[4,w(t,!0)];case 1:o.sent(),o.label=2;case 2:return o.trys.push([2,5,,6]),[4,n.e(1605).then(n.bind(n,1605))];case 3:return[4,o.sent().create(e,t.baseEl,t)];case 4:return r=o.sent(),[3,6];case 5:return o.sent(),r=e(t.baseEl,t),[3,6];case 6:return y(t.enteringEl,t.leavingEl),[4,b(r,t)];case 7:return i=o.sent(),t.progressCallback&&t.progressCallback(void 0),i&&S(t.enteringEl,t.leavingEl),[2,{hasCompleted:i,animation:r}]}}))}))},m=function(e){return i(s,void 0,void 0,(function(){var t,n;return o(this,(function(r){switch(r.label){case 0:return t=e.enteringEl,n=e.leavingEl,[4,w(e,!1)];case 1:return r.sent(),y(t,n),S(t,n),[2,{hasCompleted:!0}]}}))}))},w=function(e,t){return i(s,void 0,void 0,(function(){var n,r;return o(this,(function(i){switch(i.label){case 0:return n=void 0!==e.deepWait?e.deepWait:t,r=n?[T(e.enteringEl),T(e.leavingEl)]:[k(e.enteringEl),k(e.leavingEl)],[4,Promise.all(r)];case 1:return i.sent(),[4,g(e.viewIsReady,e.enteringEl)];case 2:return i.sent(),[2]}}))}))},g=function(e,t){return i(s,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return e?[4,e(t)]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))},b=function(e,t){var n=t.progressCallback,r=new Promise((function(t){e.onFinish((function(n){"number"==typeof n?t(1===n):void 0!==e.hasCompleted&&t(e.hasCompleted)}))}));return n?(e.progressStart(!0),n(e)):e.play(),r},y=function(e,t){E(t,a),E(e,"ionViewWillEnter")},S=function(e,t){E(e,"ionViewDidEnter"),E(t,u)},E=function(e,t){if(e){var n=new CustomEvent(t,{bubbles:!1,cancelable:!1});e.dispatchEvent(n)}},k=function(e){return e&&e.componentOnReady?e.componentOnReady():Promise.resolve()},T=function(e){return i(s,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return(t=e)?null==t.componentOnReady?[3,2]:[4,t.componentOnReady()]:[3,4];case 1:if(null!=n.sent())return[2];n.label=2;case 2:return[4,Promise.all(Array.from(t.children).map(T))];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},C=function(e,t){t?(e.setAttribute("aria-hidden","true"),e.classList.add("ion-page-hidden")):(e.hidden=!1,e.removeAttribute("aria-hidden"),e.classList.remove("ion-page-hidden"))},V=function(e,t,n){void 0!==e&&(e.style.zIndex="back"===n?"99":"101"),void 0!==t&&(t.style.zIndex="100")},P=function(e){return e.classList.contains("ion-page")?e:e.querySelector(":scope > .ion-page, :scope > ion-nav, :scope > ion-tabs")||e}},6956(e,t,n){n.r(t),n.d(t,{ion_nav:()=>f});var r=n(5873),i=n(884),o=n(5721),s=n(8882),a=n(1761),u=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{u(r.next(e))}catch(e){o(e)}}function a(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(s,a)}u((r=r.apply(e,t||[])).next())}))},c=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=(i=s.trys).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])}}},l=function(){function e(e,t){this.component=e,this.params=t,this.state=1}return e.prototype.init=function(e){return u(this,void 0,void 0,(function(){var t,n;return c(this,(function(r){switch(r.label){case 0:return this.state=2,this.element?[3,2]:(t=this.component,n=this,[4,(0,o.a)(this.delegate,e,t,["ion-page","ion-page-invisible"],this.params)]);case 1:n.element=r.sent(),r.label=2;case 2:return[2]}}))}))},e.prototype._destroy=function(){(0,i.b)(3!==this.state,"view state must be ATTACHED");var e=this.element;e&&(this.delegate?this.delegate.removeViewFromDom(e.parentElement,e):e.remove()),this.nav=void 0,this.state=3},e}(),h=function(e,t,n){if(!e)return!1;if(e.component!==t)return!1;var r=e.params;if(r===n)return!0;if(!r&&!n)return!0;if(!r||!n)return!1;var i=Object.keys(r),o=Object.keys(n);if(i.length!==o.length)return!1;for(var s=0,a=i;s<a.length;s++){var u=a[s];if(r[u]!==n[u])return!1}return!0},v=function(e,t){return e?e instanceof l?e:new l(e,t):null},f=function(){function e(e){(0,r.r)(this,e),this.transInstr=[],this.animationEnabled=!0,this.useRouter=!1,this.isTransitioning=!1,this.destroyed=!1,this.views=[],this.animated=!0,this.ionNavWillLoad=(0,r.c)(this,"ionNavWillLoad",7),this.ionNavWillChange=(0,r.c)(this,"ionNavWillChange",3),this.ionNavDidChange=(0,r.c)(this,"ionNavDidChange",3)}return e.prototype.swipeGestureChanged=function(){this.gesture&&this.gesture.setDisabled(!0!==this.swipeGesture)},e.prototype.rootChanged=function(){void 0!==this.root&&(this.useRouter||this.setRoot(this.root,this.rootParams))},e.prototype.componentWillLoad=function(){if(this.useRouter=!!document.querySelector("ion-router")&&!this.el.closest("[no-router]"),void 0===this.swipeGesture){var e=(0,r.f)(this);this.swipeGesture=r.i.getBoolean("swipeBackEnabled","ios"===e)}this.ionNavWillLoad.emit()},e.prototype.componentDidLoad=function(){return u(this,void 0,void 0,(function(){var e;return c(this,(function(t){switch(t.label){case 0:return this.rootChanged(),e=this,[4,n.e(5857).then(n.bind(n,5857))];case 1:return e.gesture=t.sent().createSwipeBackGesture(this.el,this.canStart.bind(this),this.onStart.bind(this),this.onMove.bind(this),this.onEnd.bind(this)),this.swipeGestureChanged(),[2]}}))}))},e.prototype.componentDidUnload=function(){for(var e=0,t=this.views;e<t.length;e++){var n=t[e];(0,a.l)(n.element,a.L),n._destroy()}this.gesture&&(this.gesture.destroy(),this.gesture=void 0),this.transInstr.length=this.views.length=0,this.destroyed=!0},e.prototype.push=function(e,t,n,r){return this.queueTrns({insertStart:-1,insertViews:[{page:e,params:t}],opts:n},r)},e.prototype.insert=function(e,t,n,r,i){return this.queueTrns({insertStart:e,insertViews:[{page:t,params:n}],opts:r},i)},e.prototype.insertPages=function(e,t,n,r){return this.queueTrns({insertStart:e,insertViews:t,opts:n},r)},e.prototype.pop=function(e,t){return this.queueTrns({removeStart:-1,removeCount:1,opts:e},t)},e.prototype.popTo=function(e,t,n){var r={removeStart:-1,removeCount:-1,opts:t};return"object"==typeof e&&e.component?(r.removeView=e,r.removeStart=1):"number"==typeof e&&(r.removeStart=e+1),this.queueTrns(r,n)},e.prototype.popToRoot=function(e,t){return this.queueTrns({removeStart:1,removeCount:-1,opts:e},t)},e.prototype.removeIndex=function(e,t,n,r){return void 0===t&&(t=1),this.queueTrns({removeStart:e,removeCount:t,opts:n},r)},e.prototype.setRoot=function(e,t,n,r){return this.setPages([{page:e,params:t}],n,r)},e.prototype.setPages=function(e,t,n){return null==t&&(t={}),!0!==t.animated&&(t.animated=!1),this.queueTrns({insertStart:0,insertViews:e,removeStart:0,removeCount:-1,opts:t},n)},e.prototype.setRouteId=function(e,t,n){var r,i=this,o=this.getActiveSync();if(h(o,e,t))return Promise.resolve({changed:!1,element:o.element});var s,a=new Promise((function(e){return r=e})),l={updateURL:!1,viewIsReady:function(e){var t,n=new Promise((function(e){return t=e}));return r({changed:!0,element:e,markVisible:function(){return u(i,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return t(),[4,s];case 1:return e.sent(),[2]}}))}))}}),n}};if("root"===n)s=this.setRoot(e,t,l);else{var v=this.views.find((function(n){return h(n,e,t)}));v?s=this.popTo(v,Object.assign(Object.assign({},l),{direction:"back"})):"forward"===n?s=this.push(e,t,l):"back"===n&&(s=this.setRoot(e,t,Object.assign(Object.assign({},l),{direction:"back",animated:!0})))}return a},e.prototype.getRouteId=function(){return u(this,void 0,void 0,(function(){var e;return c(this,(function(t){return[2,(e=this.getActiveSync())?{id:e.element.tagName,params:e.params,element:e.element}:void 0]}))}))},e.prototype.getActive=function(){return Promise.resolve(this.getActiveSync())},e.prototype.getByIndex=function(e){return Promise.resolve(this.views[e])},e.prototype.canGoBack=function(e){return Promise.resolve(this.canGoBackSync(e))},e.prototype.getPrevious=function(e){return Promise.resolve(this.getPreviousSync(e))},e.prototype.getLength=function(){return this.views.length},e.prototype.getActiveSync=function(){return this.views[this.views.length-1]},e.prototype.canGoBackSync=function(e){return void 0===e&&(e=this.getActiveSync()),!(!e||!this.getPreviousSync(e))},e.prototype.getPreviousSync=function(e){if(void 0===e&&(e=this.getActiveSync()),e){var t=this.views,n=t.indexOf(e);return n>0?t[n-1]:void 0}},e.prototype.queueTrns=function(e,t){if(this.isTransitioning&&null!=e.opts&&e.opts.skipIfBusy)return Promise.resolve(!1);var n=new Promise((function(t,n){e.resolve=t,e.reject=n}));return e.done=t,e.insertViews&&0===e.insertViews.length&&(e.insertViews=void 0),this.transInstr.push(e),this.nextTrns(),n},e.prototype.success=function(e,t){if(this.destroyed)this.fireError("nav controller was destroyed",t);else if(t.done&&t.done(e.hasCompleted,e.requiresTransition,e.enteringView,e.leavingView,e.direction),t.resolve(e.hasCompleted),!1!==t.opts.updateURL&&this.useRouter){var n=document.querySelector("ion-router");if(n){var r="back"===e.direction?"back":"forward";n.navChanged(r)}}},e.prototype.failed=function(e,t){this.destroyed?this.fireError("nav controller was destroyed",t):(this.transInstr.length=0,this.fireError(e,t))},e.prototype.fireError=function(e,t){t.done&&t.done(!1,!1,e),t.reject&&!this.destroyed?t.reject(e):t.resolve(!1)},e.prototype.nextTrns=function(){if(this.isTransitioning)return!1;var e=this.transInstr.shift();return!!e&&(this.runTransition(e),!0)},e.prototype.runTransition=function(e){return u(this,void 0,void 0,(function(){var t,n,r,i,o;return c(this,(function(s){switch(s.label){case 0:if(s.trys.push([0,6,,7]),this.ionNavWillChange.emit(),this.isTransitioning=!0,this.prepareTI(e),t=this.getActiveSync(),n=this.getEnteringView(e,t),!t&&!n)throw new Error("no views in the stack to be removed");return n&&1===n.state?[4,n.init(this.el)]:[3,2];case 1:s.sent(),s.label=2;case 2:return this.postViewInit(n,t,e),(e.enteringRequiresTransition||e.leavingRequiresTransition)&&n!==t?[4,this.transition(n,t,e)]:[3,4];case 3:return i=s.sent(),[3,5];case 4:i={hasCompleted:!0,requiresTransition:!1},s.label=5;case 5:return r=i,this.success(r,e),this.ionNavDidChange.emit(),[3,7];case 6:return o=s.sent(),this.failed(o,e),[3,7];case 7:return this.isTransitioning=!1,this.nextTrns(),[2]}}))}))},e.prototype.prepareTI=function(e){var t=this.views.length;if(e.opts=e.opts||{},void 0===e.opts.delegate&&(e.opts.delegate=this.delegate),void 0!==e.removeView){(0,i.b)(void 0!==e.removeStart,"removeView needs removeStart"),(0,i.b)(void 0!==e.removeCount,"removeView needs removeCount");var n=this.views.indexOf(e.removeView);if(n<0)throw new Error("removeView was not found");e.removeStart+=n}void 0!==e.removeStart&&(e.removeStart<0&&(e.removeStart=t-1),e.removeCount<0&&(e.removeCount=t-e.removeStart),e.leavingRequiresTransition=e.removeCount>0&&e.removeStart+e.removeCount===t),e.insertViews&&((e.insertStart<0||e.insertStart>t)&&(e.insertStart=t),e.enteringRequiresTransition=e.insertStart===t);var r=e.insertViews;if(r){(0,i.b)(r.length>0,"length can not be zero");var o=r.map((function(e){return e instanceof l?e:"page"in e?v(e.page,e.params):v(e,void 0)})).filter((function(e){return null!==e}));if(0===o.length)throw new Error("invalid views to insert");for(var s=0,a=o;s<a.length;s++){var u=a[s];u.delegate=e.opts.delegate;var c=u.nav;if(c&&c!==this)throw new Error("inserted view was already inserted");if(3===u.state)throw new Error("inserted view was already destroyed")}e.insertViews=o}},e.prototype.getEnteringView=function(e,t){var n=e.insertViews;if(void 0!==n)return n[n.length-1];var r=e.removeStart;if(void 0!==r)for(var i=this.views,o=r+e.removeCount,s=i.length-1;s>=0;s--){var a=i[s];if((s<r||s>=o)&&a!==t)return a}},e.prototype.postViewInit=function(e,t,n){(0,i.b)(t||e,"Both leavingView and enteringView are null"),(0,i.b)(n.resolve,"resolve must be valid"),(0,i.b)(n.reject,"reject must be valid");var r,o=n.opts,s=n.insertViews,u=n.removeStart,c=n.removeCount;if(void 0!==u&&void 0!==c){(0,i.b)(u>=0,"removeStart can not be negative"),(0,i.b)(c>=0,"removeCount can not be negative"),r=[];for(var l=0;l<c;l++)(d=this.views[l+u])&&d!==e&&d!==t&&r.push(d);o.direction=o.direction||"back"}var h=this.views.length+(void 0!==s?s.length:0)-(void 0!==c?c:0);if((0,i.b)(h>=0,"final balance can not be negative"),0===h)throw console.warn("You can't remove all the pages in the navigation stack. nav.pop() is probably called too many times.",this,this.el),new Error("navigation stack needs at least one root page");if(s){for(var v=n.insertStart,f=0,p=s;f<p.length;f++){var d=p[f];this.insertViewAt(d,v),v++}n.enteringRequiresTransition&&(o.direction=o.direction||"forward")}if(r&&r.length>0){for(var m=0,w=r;m<w.length;m++)d=w[m],(0,a.l)(d.element,a.a),(0,a.l)(d.element,a.b),(0,a.l)(d.element,a.L);for(var g=0,b=r;g<b.length;g++)d=b[g],this.destroyView(d)}},e.prototype.transition=function(e,t,n){return u(this,void 0,void 0,(function(){var i,o,s,u,l,h,v,f=this;return c(this,(function(c){switch(c.label){case 0:return i=n.opts,o=i.progressAnimation?function(e){return f.sbAni=e}:void 0,s=(0,r.f)(this),u=e.element,l=t&&t.element,h=Object.assign({mode:s,showGoBack:this.canGoBackSync(e),baseEl:this.el,animationBuilder:this.animation||i.animationBuilder||r.i.get("navAnimation"),progressCallback:o,animated:this.animated&&r.i.getBoolean("animated",!0),enteringEl:u,leavingEl:l},i),[4,(0,a.t)(h)];case 1:return v=c.sent().hasCompleted,[2,this.transitionFinish(v,e,t,i)]}}))}))},e.prototype.transitionFinish=function(e,t,n,r){var i=e?t:n;return i&&this.cleanup(i),{hasCompleted:e,requiresTransition:!0,enteringView:t,leavingView:n,direction:r.direction}},e.prototype.insertViewAt=function(e,t){var n=this.views,r=n.indexOf(e);r>-1?((0,i.b)(e.nav===this,"view is not part of the nav"),n.splice(t,0,n.splice(r,1)[0])):((0,i.b)(!e.nav,"nav is used"),e.nav=this,n.splice(t,0,e))},e.prototype.removeView=function(e){(0,i.b)(2===e.state||3===e.state,"view state should be loaded or destroyed");var t=this.views,n=t.indexOf(e);(0,i.b)(n>-1,"view must be part of the stack"),n>=0&&t.splice(n,1)},e.prototype.destroyView=function(e){e._destroy(),this.removeView(e)},e.prototype.cleanup=function(e){if(!this.destroyed)for(var t=this.views,n=t.indexOf(e),r=t.length-1;r>=0;r--){var i=t[r],o=i.element;r>n?((0,a.l)(o,a.L),this.destroyView(i)):r<n&&(0,a.s)(o,!0)}},e.prototype.canStart=function(){return!!this.swipeGesture&&!this.isTransitioning&&0===this.transInstr.length&&this.animationEnabled&&this.canGoBackSync()},e.prototype.onStart=function(){this.queueTrns({removeStart:-1,removeCount:1,opts:{direction:"back",progressAnimation:!0}},void 0)},e.prototype.onMove=function(e){this.sbAni&&this.sbAni.progressStep(e)},e.prototype.onEnd=function(e,t,n){var r=this;if(this.sbAni){this.animationEnabled=!1,this.sbAni.onFinish((function(){r.animationEnabled=!0}),{oneTimeCallback:!0});var i=e?-.001:.001;e?i+=(0,s.g)(new s.P(0,0),new s.P(.32,.72),new s.P(0,1),new s.P(1,1),t):(this.sbAni.easing("cubic-bezier(1, 0, 0.68, 0.28)"),i+=(0,s.g)(new s.P(0,0),new s.P(1,0),new s.P(.68,.28),new s.P(1,1),t)),this.sbAni.progressEnd(e?1:0,i,n)}},e.prototype.render=function(){return(0,r.h)("slot",null)},Object.defineProperty(e.prototype,"el",{get:function(){return(0,r.d)(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"watchers",{get:function(){return{swipeGesture:["swipeGestureChanged"],root:["rootChanged"]}},enumerable:!0,configurable:!0}),Object.defineProperty(e,"style",{get:function(){return":host{left:0;right:0;top:0;bottom:0;position:absolute;contain:layout size style;overflow:hidden;z-index:0}"},enumerable:!0,configurable:!0}),e}()}}]);