universalviewer
Version:
The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎
2 lines (1 loc) • 5.75 kB
JavaScript
import{a as p}from"./chunk-47FI7OS3.js";var h=function(o,u,a,c){return new(a||(a=Promise))(function(s,i){function v(e){try{g(c.next(e))}catch(f){i(f)}}function w(e){try{g(c.throw(e))}catch(f){i(f)}}function g(e){e.done?s(e.value):new a(function(f){f(e.value)}).then(v,w)}g((c=c.apply(o,u||[])).next())})},m=function(o,u){var a={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},c,s,i,v;return v={next:w(0),throw:w(1),return:w(2)},typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function w(e){return function(f){return g([e,f])}}function g(e){if(c)throw new TypeError("Generator is already executing.");for(;a;)try{if(c=1,s&&(i=e[0]&2?s.return:e[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,e[1])).done)return i;switch(s=0,i&&(e=[e[0]&2,i.value]),e[0]){case 0:case 1:i=e;break;case 4:return a.label++,{value:e[1],done:!1};case 5:a.label++,s=e[1],e=[0];continue;case 7:e=a.ops.pop(),a.trys.pop();continue;default:if(i=a.trys,!(i=i.length>0&&i[i.length-1])&&(e[0]===6||e[0]===2)){a=0;continue}if(e[0]===3&&(!i||e[1]>i[0]&&e[1]<i[3])){a.label=e[1];break}if(e[0]===6&&a.label<i[1]){a.label=i[1],i=e;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(e);break}i[2]&&a.ops.pop(),a.trys.pop();continue}e=u.call(o,a)}catch(f){e=[6,f],s=0}finally{c=i=0}if(e[0]&5)throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}},b=void 0,x=function(){return p().easing("cubic-bezier(0.0, 0.0, 0.2, 1)").duration(300)},C=function(o){var u,a,c=8,s=o.width+c,i=p(),v=p();return o.isEndSide?(u=s+"px",a="0px"):(u=-s+"px",a="0px"),i.addElement(o.menuInnerEl).fromTo("transform","translateX("+u+")","translateX("+a+")"),v.addElement(o.backdropEl).fromTo("opacity",.01,.32),x().addAnimation([i,v])},B=function(o){var u,a,c=o.width;o.isEndSide?(u=-c+"px",a=c+"px"):(u=c+"px",a=-c+"px");var s=p().addElement(o.menuInnerEl).fromTo("transform","translateX("+a+")","translateX(0px)"),i=p().addElement(o.contentEl).fromTo("transform","translateX(0px)","translateX("+u+")"),v=p().addElement(o.backdropEl).fromTo("opacity",.01,.32);return x().addAnimation([s,v,i])},D=function(o){var u=o.width*(o.isEndSide?-1:1)+"px",a=p().addElement(o.contentEl).fromTo("transform","translateX(0px)","translateX("+u+")");return x().addAnimation(a)},H=function(){var o=new Map,u=[],a=function(n){return h(b,void 0,void 0,function(){var t;return m(this,function(r){switch(r.label){case 0:return[4,e(n)];case 1:return t=r.sent(),t?[2,t.open()]:[2,!1]}})})},c=function(n){return h(b,void 0,void 0,function(){var t;return m(this,function(r){switch(r.label){case 0:return[4,n!==void 0?e(n):f()];case 1:return t=r.sent(),t!==void 0?[2,t.close()]:[2,!1]}})})},s=function(n){return h(b,void 0,void 0,function(){var t;return m(this,function(r){switch(r.label){case 0:return[4,e(n)];case 1:return t=r.sent(),t?[2,t.toggle()]:[2,!1]}})})},i=function(n,t){return h(b,void 0,void 0,function(){var r;return m(this,function(l){switch(l.label){case 0:return[4,e(t)];case 1:return r=l.sent(),r&&(r.disabled=!n),[2,r]}})})},v=function(n,t){return h(b,void 0,void 0,function(){var r;return m(this,function(l){switch(l.label){case 0:return[4,e(t)];case 1:return r=l.sent(),r&&(r.swipeGesture=n),[2,r]}})})},w=function(n){return h(b,void 0,void 0,function(){var t,t;return m(this,function(r){switch(r.label){case 0:return n==null?[3,2]:[4,e(n)];case 1:return t=r.sent(),[2,t!==void 0&&t.isOpen()];case 2:return[4,f()];case 3:return t=r.sent(),[2,t!==void 0]}})})},g=function(n){return h(b,void 0,void 0,function(){var t;return m(this,function(r){switch(r.label){case 0:return[4,e(n)];case 1:return t=r.sent(),t?[2,!t.disabled]:[2,!1]}})})},e=function(n){return h(b,void 0,void 0,function(){var t,r;return m(this,function(l){switch(l.label){case 0:return[4,A()];case 1:return l.sent(),n==="start"||n==="end"?(t=E(function(d){return d.side===n&&!d.disabled}),t?[2,t]:[2,E(function(d){return d.side===n})]):n!=null?[2,E(function(d){return d.menuId===n})]:(r=E(function(d){return!d.disabled}),r?[2,r]:[2,u.length>0?u[0].el:void 0])}})})},f=function(){return h(b,void 0,void 0,function(){return m(this,function(n){switch(n.label){case 0:return[4,A()];case 1:return n.sent(),[2,X()]}})})},_=function(){return h(b,void 0,void 0,function(){return m(this,function(n){switch(n.label){case 0:return[4,A()];case 1:return n.sent(),[2,R()]}})})},k=function(){return h(b,void 0,void 0,function(){return m(this,function(n){switch(n.label){case 0:return[4,A()];case 1:return n.sent(),[2,S()]}})})},y=function(n,t){o.set(n,t)},M=function(n){u.indexOf(n)<0&&(n.disabled||O(n),u.push(n))},T=function(n){var t=u.indexOf(n);t>-1&&u.splice(t,1)},O=function(n){var t=n.side;u.filter(function(r){return r.side===t&&r!==n}).forEach(function(r){return r.disabled=!0})},G=function(n,t,r){return h(b,void 0,void 0,function(){var l;return m(this,function(d){switch(d.label){case 0:return S()?[2,!1]:t?[4,f()]:[3,3];case 1:return l=d.sent(),l&&n.el!==l?[4,l.setOpen(!1,!1)]:[3,3];case 2:d.sent(),d.label=3;case 3:return[2,n._setOpen(t,r)]}})})},I=function(n,t){var r=o.get(n);if(!r)throw new Error("animation not registered");var l=r(t);return l},X=function(){return E(function(n){return n._isOpen})},R=function(){return u.map(function(n){return n.el})},S=function(){return u.some(function(n){return n.isAnimating})},E=function(n){var t=u.find(n);if(t!==void 0)return t.el},A=function(){return Promise.all(Array.from(document.querySelectorAll("ion-menu")).map(function(n){return n.componentOnReady()}))};return y("reveal",D),y("push",B),y("overlay",C),{registerAnimation:y,get:e,getMenus:_,getOpen:f,isEnabled:g,swipeGesture:v,isAnimating:k,isOpen:w,enable:i,toggle:s,close:c,open:a,_getOpenSync:X,_createAnimation:I,_register:M,_unregister:T,_setOpen:G,_setActiveMenu:O}},q=H();export{q as a};