UNPKG

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.12 kB
import{n as l}from"./chunk-VNJCZCB4.js";var m=function(e,r,n,a){return new(n||(n=Promise))(function(o,t){function s(i){try{f(a.next(i))}catch(c){t(c)}}function u(i){try{f(a.throw(i))}catch(c){t(c)}}function f(i){i.done?o(i.value):new n(function(c){c(i.value)}).then(s,u)}f((a=a.apply(e,r||[])).next())})},h=function(e,r){var n={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},a,o,t,s;return s={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function u(i){return function(c){return f([i,c])}}function f(i){if(a)throw new TypeError("Generator is already executing.");for(;n;)try{if(a=1,o&&(t=i[0]&2?o.return:i[0]?o.throw||((t=o.return)&&t.call(o),0):o.next)&&!(t=t.call(o,i[1])).done)return t;switch(o=0,t&&(i=[i[0]&2,t.value]),i[0]){case 0:case 1:t=i;break;case 4:return n.label++,{value:i[1],done:!1};case 5:n.label++,o=i[1],i=[0];continue;case 7:i=n.ops.pop(),n.trys.pop();continue;default:if(t=n.trys,!(t=t.length>0&&t[t.length-1])&&(i[0]===6||i[0]===2)){n=0;continue}if(i[0]===3&&(!t||i[1]>t[0]&&i[1]<t[3])){n.label=i[1];break}if(i[0]===6&&n.label<t[1]){n.label=t[1],t=i;break}if(t&&n.label<t[2]){n.label=t[2],n.ops.push(i);break}t[2]&&n.ops.pop(),n.trys.pop();continue}i=r.call(e,n)}catch(c){i=[6,c],o=0}finally{a=t=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},k=void 0,y=0,p=function(e){return{create:function(r){return A(e,r)},dismiss:function(r,n,a){return x(document,r,n,e,a)},getTop:function(){return m(this,void 0,void 0,function(){return h(this,function(r){return[2,v(document,e)]})})}}},S=p("ion-alert"),P=p("ion-action-sheet"),j=p("ion-picker"),q=p("ion-popover"),G=function(e){var r=document;C(r);var n=y++;e.overlayIndex=n,e.hasAttribute("id")||(e.id="ion-overlay-"+n)},A=function(e,r){return customElements.whenDefined(e).then(function(){var n=document,a=n.createElement(e);return a.classList.add("overlay-hidden"),Object.assign(a,r),D(n).appendChild(a),a.componentOnReady()})},C=function(e){y===0&&(y=1,e.addEventListener("focusin",function(r){var n=v(e);if(n&&n.backdropDismiss&&!O(n,r.target)){var a=n.querySelector("input,button");a&&a.focus()}}),e.addEventListener("ionBackButton",function(r){var n=v(e);n&&n.backdropDismiss&&r.detail.register(100,function(){return n.dismiss(void 0,w)})}),e.addEventListener("keyup",function(r){if(r.key==="Escape"){var n=v(e);n&&n.backdropDismiss&&n.dismiss(void 0,w)}}))},x=function(e,r,n,a,o){var t=v(e,a,o);return t?t.dismiss(r,n):Promise.reject("overlay does not exist")},E=function(e,r){return r===void 0&&(r="ion-alert,ion-action-sheet,ion-loading,ion-modal,ion-picker,ion-popover,ion-toast"),Array.from(e.querySelectorAll(r)).filter(function(n){return n.overlayIndex>0})},v=function(e,r,n){var a=E(e,r);return n===void 0?a[a.length-1]:a.find(function(o){return o.id===n})},I=function(e,r,n,a,o){return m(k,void 0,void 0,function(){var t,s;return h(this,function(u){switch(u.label){case 0:return e.presented?[2]:(e.presented=!0,e.willPresent.emit(),t=e.enterAnimation?e.enterAnimation:l.get(r,e.mode==="ios"?n:a),[4,g(e,t,e.el,o)]);case 1:return s=u.sent(),s&&e.didPresent.emit(),[2]}})})},_=function(e,r,n,a,o,t,s){return m(k,void 0,void 0,function(){var u,f;return h(this,function(i){switch(i.label){case 0:if(!e.presented)return[2,!1];e.presented=!1,i.label=1;case 1:return i.trys.push([1,3,,4]),e.willDismiss.emit({data:r,role:n}),u=e.leaveAnimation?e.leaveAnimation:l.get(a,e.mode==="ios"?o:t),[4,g(e,u,e.el,s)];case 2:return i.sent(),e.didDismiss.emit({data:r,role:n}),[3,4];case 3:return f=i.sent(),console.error(f),[3,4];case 4:return e.el.remove(),[2,!0]}})})},D=function(e){return e.querySelector("ion-app")||e.body},g=function(e,r,n,a){return m(k,void 0,void 0,function(){var o,t,s,u,f,i,c;return h(this,function(d){switch(d.label){case 0:if(e.animation)return e.animation.destroy(),e.animation=void 0,[2,!1];n.classList.remove("overlay-hidden"),o=n.shadowRoot||e.el,s=!0,d.label=1;case 1:return d.trys.push([1,4,,5]),[4,import("./index-db7d5039-SD4G6O3S.js")];case 2:return u=d.sent(),[4,u.create(r,o,a)];case 3:return t=d.sent(),[3,5];case 4:return f=d.sent(),t=r(o,a),t.fill("both"),s=!1,[3,5];case 5:return e.animation=t,(!e.animated||!l.getBoolean("animated",!0))&&t.duration(0),e.keyboardClose&&t.beforeAddWrite(function(){var b=n.ownerDocument.activeElement;b&&b.matches("input, ion-input, ion-textarea")&&b.blur()}),[4,t.playAsync()];case 6:return i=d.sent(),c=typeof i>"u"?!0:t.hasCompleted,s&&t.destroy(),e.animation=void 0,[2,c]}})})},T=function(e,r){var n,a=new Promise(function(o){return n=o});return L(e,r,function(o){n(o.detail)}),a},L=function(e,r,n){var a=function(o){e.removeEventListener(r,a),n(o)};e.addEventListener(r,a)},z=function(e){return e==="cancel"||e===w},O=function(e,r){for(;r;){if(r===e)return!0;r=r.parentElement}return!1},B=function(e){return e()},K=function(e,r){if(typeof e=="function"){var n=l.get("_zoneGate",B);return n(function(){try{return e(r)}catch(a){console.error(a)}})}},w="backdrop";export{S as a,P as b,j as c,q as d,G as e,A as f,x as g,v as h,I as i,_ as j,T as k,z as l,K as m,w as n};