UNPKG

lath

Version:

Seamless connection of pages.

168 lines 93.6 kB
function testHasSmoothSnapScrolling(){return!(!("scrollSnapAlign"in document.documentElement.style||"webkitScrollSnapAlign"in document.documentElement.style||"msScrollSnapAlign"in document.documentElement.style)||!testHasSmoothScrolling())}function testHasSlotBug(){var t=getIOSversion();return!!(t&&t[0]<=13)}function testHasSnapReset(){var t=getIOSversion();return!!(t&&t[0]<15)}function getCSSUnits(t){if(t)return"string"==typeof t?t:t+"px"}var manifestProcess,setTimeout$1,requestIdleCallback,rAF,sleep,index$1,openWindow,tapHighlight,cssVar,waitAllAnimations,clearAllAnimations,provider,index;import{t as typeError,g as getIOSversion,a as testHasSmoothScrolling,_ as __awaiter,b as getEnv,c as testHasScrolling,l as loadWebAnimations,P as Preset,d as buildAppletSlot}from"./launcher-f761b2d6.js";const EventGroupSymbol=Symbol("__EventGroupName__");class EventProvider{constructor(){this._events={}}on(t,e,i){return Object.defineProperty(e,EventGroupSymbol,{value:i,writable:!0}),this._events[t]||(this._events[t]=[]),null!=(i=this._events[t])&&i.push(e),this}one(e,i,t){const s=(...t)=>{i(...t),this.off(e,s)};return Object.defineProperty(s,EventGroupSymbol,{value:t,writable:!0}),this._events[e]||(this._events[e]=[]),null!=(t=this._events[e])&&t.push(s),this}off(t,e){var i;return this._events[t]&&-1<(e=null!=(i=null==(i=this._events[t])?void 0:i.indexOf(e))?i:-1)&&null!=(i=this._events[t])&&i.splice(e,1),this}removeEventGroup(e){var t=t=>{return null==(t=this._events[t])?void 0:t.filter(t=>t[EventGroupSymbol]!==e)};for(const i in this._events)this._events[i]=t(i);return this}trigger(i,...t){var e;return this._events[i]&&null!=(e=this._events[i])&&e.forEach(e=>{try{e(...t)}catch(t){this.off(i,e),this.trigger("error",t)}}),this}}class ApplicationBase extends EventProvider{constructor(){super(...arguments),this.applets={},this.residentApplets=[],this.presetAppletsView={},this.historyNodeLocation=history.length,this.routerRegExp=/([^#/]+)(.+)?/}resolveURL(t){var t=new URL(t,window.location.toString()),e=t;return void 0===t.href&&(e.href=String(t)),e}verifyAppletSrcLegitimacy(t){var e=this.config.capture;if(e)return this.captureAppletSrc(t,e);e=this.config.allowHosts||[];if(0===e.length)return!0;e.push(location.host);var i=new URL(decodeURIComponent(t),window.location.toString()).host;for(const s of e)if(i===s)return!0;return!1}captureAppletSrc(t,e=this.config.capture){var i=this.resolveURL(t),s=i.origin+i.pathname;if("string"==typeof e){if(e===s)return!0}else if("function"==typeof e&&e(i,t))return!0;return!1}promiseApplet(t){return Promise.resolve(t())}checkIsPresetAppletsView(t){return this.residentApplets.includes(t)}delPresetAppletsView(t,e=!1){e&&!this.checkIsPresetAppletsView(t)&&(e=this.presetAppletsView[t])&&e.parentElement&&e.parentElement.removeChild(e),delete this.presetAppletsView[t]}setPrestAppletsView(t){this.residentApplets=Object.keys(t),this.presetAppletsView=t}setting(t){t.applets.frameworks.config.prerender||(t.applets.frameworks.config.prerender=Object.keys(t.applets)),this.options=t}}class ApplicationState extends ApplicationBase{constructor(){var t;super(...arguments),this.overscrollHistoryNavigation={moment:0,type:""},this.properties={darkTheme:null==(t=null==(t=window.matchMedia)?void 0:t.call(window,"(prefers-color-scheme: dark)"))?void 0:t.matches},this.activeState="active"}get route(){var t=this.routerRegExp.exec(location.hash)||[],e=t[1],t=t[2],i=location.search;return{id:e?decodeURIComponent(e):"",param:t?decodeURIComponent(t):"",search:i}}get exists(){try{return parseInt(sessionStorage.getItem(location.pathname+"__EXISTS")||"-1",10)===history.length}catch(t){return!1}}get activityApplet(){var t=this.segue.id;return this.applets[t]}get prevActivityApplet(){var t=this.segue.prevId;return this.applets[t]}get activityLevel(){var t;return(null!=(t=null==(t=this.activityApplet)?void 0:t.level)?t:0)+1}get isFullscreen(){return document.body.offsetHeight===screen.height}setExists(){const i=location.pathname+"__EXISTS",s=String(history.length);return new Promise((t,e)=>{try{sessionStorage.setItem(i,s),t()}catch(t){try{sessionStorage.clear(),sessionStorage.setItem(i,s)}catch(t){e()}}})}activate(t){var t=t?"active":"frozen",e="application-"+t;if(window.applicationActiveState!==t){this.activeState=t,this.trigger(t),window.applicationActiveState=t,window.postMessage({type:e},"*");for(const s in this.applets){var i=this.applets[s];i.sandbox&&!i.sameOrigin&&i.triggerWindow(e)}}}}manifestProcess=(t,e)=>{var i=t.config;if(("frameworks"===e||"system"===e)&&(i.free&&typeError(1101,"warn"),null!=(s=i.source)&&s.html||null!=(s=i.source)&&s.src)&&typeError(1102,"warn"),!i.portal||i.free||typeError(1103,"warn"),1e4<(null!=(s=i.level)?s:0)&&typeError(1104,"warn"),"frameworks"===e||(null!=(s=i.source)&&s.html||null!=(e=i.source)&&e.src)){var s=["smart-setTimeout","proxy-link","tap-highlight"];const{apply:o=s,unApply:r}=i;i.apply=o,null!==r&&void 0!==r&&r.length&&(i.apply=null==o?void 0:o.filter(t=>!r.includes(t)))}else i.apply&&typeError(1202,"warn");return 0===(null==(e=i.modality)?void 0:e.indexOf("sheet"))?(i.animation&&typeError(1105,"warn"),i.animation="popup"):"popup"===i.animation&&(i.modality="sheet",typeError(1106,"warn")),i.modality&&(0===(null==(s=i.modality)?void 0:s.indexOf("paper"))?(i.animation&&typeError(1105,"warn"),{maskOpacity:e,swipeClosable:s}=i.paperOptions||{maskOpacity:.5},i.animation="grow",i.sheetOptions={stillBackdrop:!0,noHandlebar:!0,maskOpacity:e,swipeClosable:s,borderRadius:"0px",top:"0px"}):0===(null==(e=i.modality)?void 0:e.indexOf("overlay"))&&(i.animation&&typeError(1105,"warn"),i.color||(i.color="transparent"),{maskOpacity:s,swipeClosable:e}=i.overlayOptions||{maskOpacity:.5},i.animation="popup",i.sheetOptions={stillBackdrop:!0,noHandlebar:!0,maskOpacity:s,swipeClosable:e,borderRadius:"0px",top:"0px",useFade:!0}),i.sheetOptions||(i.sheetOptions={}),getIOSversion()||(i.sheetOptions.stillBackdrop=!0)),i.animation||(i.disableSwipeModel=!0),i.swipeTransitionType||(i.swipeTransitionType=null!=(s=i.swipeTransitionType)?s:getIOSversion()?"slide":"zoom"),t};class AppletBase extends EventProvider{constructor(t,e,i){super(),this.param="",this.slide=null,this.modality=null,this.view=null,this.img=null,this.snapshot=null,this.snapshotTime=-1,this.visitTime=-1,this.events={transformStart:()=>{},transformEnd:()=>{},boot:()=>{},load:()=>{},loadError:()=>{},preload:()=>{},destroy:()=>{}},this.darkTask=[],this.createTime=Date.now(),this.transient=!1,this.config={title:"",level:0,source:{},prerender:[],apply:void 0,background:"auto",free:!1},this.components=[],this.resources={script:[],image:[],worker:[],video:[],audio:[],font:[],style:[]},this.setDefaultConfig=manifestProcess,this.id=t,this.model=e,this.application=i;var{config:i,resources:e,events:t,components:s}=this.setDefaultConfig(e,t);Object.assign(this.config,i),Object.assign(this.resources,e),Object.assign(this.events,t),s&&(this.components=s),this.application.segue.preloadAnimation(this.self)}get self(){return this.application.applets[this.id]||this}}class AppletState extends AppletBase{constructor(){super(...arguments),this.visibility=!1,this.transforming=!1,this.viewLevel=0,this.status={preload:!1,prefetch:!1,prerender:!1,refreshing:!1,requestRefresh:!1}}get swipeModel(){var t;return"default"!==this.application.config.swipeModel||"ontouchend"in document&&9<=(null!=(t=null==(t=getIOSversion())?void 0:t[0])?t:0)&&"default"}get sameOrigin(){return this.uri?new URL(this.uri,window.location.toString()).host===window.location.host:void 0===this.config.sandbox||!!this.config.sandbox.includes("allow-same-origin")}get level(){var t;return null!=(t=this.config.level)?t:0}setLevel(t){this.viewLevel=t}get rel(){return"system"===this.id?"system":"frameworks"===this.id?"frameworks":"applet"}get uri(){var t;return(null==(t=null==(t=this.config)?void 0:t.source)?void 0:t.src)||""}get source(){var t=(null==(t=null==(t=this.config)?void 0:t.source)?void 0:t.html)||"";return"string"==typeof t?t:t()}get hasSource(){var t;return!!(this.uri||null!=(t=null==(t=this.config)?void 0:t.source)&&t.html)}get noSource(){return!this.hasSource&&!this.config.render}get viewType(){var t;return"applet"===this.rel&&this.hasSource?null!=(t=this.config)&&t.portal&&this.sameOrigin?"portal":"iframe":"shadow"}get color(){var t,e;return"applet"!==this.rel?"transparent":(e=(t=this.application).properties.darkTheme,e=""+(this.config.color||(e?"#000":"#fff")),"frameworks"!==this.id&&"inherit"==e&&t.applets.frameworks.config.color||e)}get expired(){var t;return!!this.view&&!(null!=(t=this.application.prevActivityApplet)&&t.config.modality||!(this.status.requestRefresh||Date.now()-this.createTime>=(null!=(t=this.config.timeout)?t:6e7)))}get isModality(){return!!this.config.modality}get isFullscreen(){return!this.isModality}get isPresetAppletsView(){return this.application.checkIsPresetAppletsView(this.id)}get useControls(){return!0!==this.config.disableSwipeModel&&this.swipeModel&&"applet"===this.rel&&this.isFullscreen}get noShadowDom(){return"shadow"===this.viewType&&!!this.config.noShadowDom}get mirroringString(){try{return localStorage.getItem("__MODULE_IMG__"+this.id)||""}catch(t){return""}}get contentWindow(){var t;return null!=(t=null==(t=null==(t=this.sandbox)?void 0:t.window)?void 0:t.window)?t:window}get contentDocument(){var t;if(this.sameOrigin)return"shadow"===this.viewType?this.viewport:null==(t=this.sandbox)?void 0:t.document}get mirroringHTML(){if("shadow"===this.viewType)return null!=(t=null==(t=this.view)?void 0:t.outerHTML)?t:"";if(!this.sameOrigin)return"";var t=null==(t=this.sandbox)?void 0:t.sandbox;const i=["script","template"];try{var e=t.contentDocument;if(!e)return"";var s=e.querySelectorAll("*");const o=[];return s.forEach(t=>{var e=t.tagName;i.includes(e)||(-1!==e.indexOf("-")&&(t.style.visibility="hidden"),o.push(t.outerHTML))}),o.join("\n")}catch(t){return""}}get subApplet(){if(this.slide)return this.application.applets[this.slide.activeId]}get allSubAppletIds(){var t=[];if(this.slide)for(const e of this.slide.slideViewApplets)t.push(e.id);return t}resume(){this.status={preload:!1,prefetch:!1,prerender:!1,refreshing:!1,requestRefresh:!1},this.darkTask=[],this.view=null,this.img=null,this.slide&&(this.slide=null),this.modality&&(this.modality=null)}saveMirroring(){if(!this.config.useMirroring||!this.sameOrigin)return Promise.resolve(!1);var e="__MODULE_IMG__"+this.id,i=null!=(i=this.mirroringHTML)?i:"";try{return localStorage.setItem(e,i),Promise.resolve(!0)}catch(t){return localStorage.clear(),localStorage.setItem(e,i),Promise.resolve(!1)}}setActionOrigin(t){t&&(this.segueActionOrigin=t)}getActionOrigin(){return this.segueActionOrigin}injectWindowVisibilityState(t){var e;this.sameOrigin&&(e=this.contentWindow)&&(e.appletVisibilityState=t)}triggerWindow(t){var e;null!=(e=this.contentWindow)&&e.postMessage({type:t,appletId:this.id,historyDirection:this.application.segue.historyDirection},"*")}}setTimeout$1=window.setBackgroundTimeout||window.setTimeout,requestIdleCallback=window.requestIdleCallback||((t,e)=>{const i=Date.now();return setTimeout$1(function(){t({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-i))}})},Math.min(null!=(e=null==e?void 0:e.timeout)?e:1,1))}),rAF=window.requestAnimationFrame||setTimeout$1,sleep=(e=0)=>new Promise(t=>{setTimeout$1(t,e)});class AppletLifeCycle extends AppletState{attach(t,e,i){t&&(this.viewport=t,this.parentApplet=e,this.mountBehavior=i)}removeContainer(){var t;this.isPresetAppletsView||(null!=(t=null==(t=this.contentView)?void 0:t.parentElement)&&t.removeChild(this.contentView),null!=(t=null==(t=this.viewport)?void 0:t.parentNode)&&t.removeChild(this.viewport),this.viewport=void 0,this.delPresetView())}clearContainer(){var t;this.isPresetAppletsView||(null!=(t=null==(t=this.contentView)?void 0:t.parentElement)&&t.removeChild(this.contentView),this.viewport&&(this.viewport.innerHTML=""),this.delPresetView())}delPresetView(){this.contentView=void 0,this.application.delPresetAppletsView(this.id,!0)}setParam(t){return this.param!==t?(this.param=t,this.destroy(!0)):Promise.resolve(!0)}show(){var t,e=this.viewType;if("portal"===e)null!=(t=this.view)&&t.activate();else{for(const i of this.darkTask)i();this.transforming=!1,this.darkTask=[],this.visibility=!0,this.visitTime=Date.now(),this.trigger("show"),"iframe"===e&&(this.triggerWindow("applet-show"),this.injectWindowVisibilityState("visible")),null!=(t=this.subApplet)&&t.show()}}hide(){var t;this.transforming=!1,this.visibility=!1,this.trigger("hide"),"iframe"===this.viewType&&(this.triggerWindow("applet-hidden"),this.injectWindowVisibilityState("hidden")),null!=(t=this.subApplet)&&t.hide()}willShow(){var t;this.transforming=!0,this.trigger("willShow"),"iframe"===this.viewType&&(this.triggerWindow("applet-will-show"),this.injectWindowVisibilityState("willVisible")),null!=(t=this.subApplet)&&t.willShow()}willHide(){var t;this.transforming=!0,this.trigger("willHide"),"iframe"===this.viewType&&(this.triggerWindow("applet-will-hide"),this.injectWindowVisibilityState("willHidden")),null!=(t=this.subApplet)&&t.willHide()}willSegueShow(){this.trigger("willSegueShow")}willSegueHide(){this.trigger("willSegueHide")}destroy(i=!1,t=!0){return t&&[...this.allSubAppletIds,...null!=(t=null==(t=this.parentApplet)?void 0:t.allSubAppletIds)?t:[]].forEach(t=>{return null==(t=this.application.applets[t])?void 0:t.destroy(!1,!1)}),new Promise(t=>{var e;return this.view?this.isPresetAppletsView||"frameworks"===this.rel||"system"===this.rel||(null==(e=this.application.segue)?void 0:e.id)===this.id&&!1===i?t(!1):("iframe"===this.viewType&&this.unload(),!1===i?this.removeContainer():this.clearContainer(),this.resume(),null!=(e=this.events)&&e.destroy(this.self),this.application.removeEventGroup(this.id),this.trigger("destroy"),void t(!0)):t(!0)})}observer(e){var t,i=this.sandbox?null==(i=this.sandbox.document)?void 0:i.documentElement:this.view;if(i)return(t=new MutationObserver(t=>{e(t)})).observe(i,{subtree:!0,attributes:!0,childList:!0,characterData:!0,attributeOldValue:!0,characterDataOldValue:!0}),t}collectAllElements(t){function s(e){for(let t=0;t<e.length;t++){var i=e[t];o.push(i),i.shadowRoot&&s(i.shadowRoot.querySelectorAll("*"))}}const o=[];return t.shadowRoot&&s(t.shadowRoot.querySelectorAll("*")),s(t.querySelectorAll("*")),o}autoMediaController(r){return new Promise((t,e)=>{try{if("iframe"!==this.viewType)return t();if(void 0===this.sandbox)return t();var i=r.filter(t=>"video"===t.tagName||"audio"===t.tagName);for(const s in i){const o=i[s];null!==o&&void 0!==o&&o.paused||(o.pause(),this.darkTask.push(()=>{o.play()}))}}catch(t){e()}})}destructiveTags(t){const e=["object","embed","applet","iframe"];return!!t.filter(t=>e.includes(t.tagName)).length}guarding(){return new Promise(e=>{var t;if("applet"!==this.rel)return e(!0);if(void 0===this.sandbox)return e(!0);if(!0===this.config.background)return e(!0);if(!1===this.config.background)return e(!1);if(!1===this.sameOrigin)return e(!1);var i=this.view;try{var s=null==(t=i.contentDocument)?void 0:t.documentElement;if(!s)return e(!0);var o=this.collectAllElements(s);if(this.config.mediaGuard&&this.autoMediaController(o).catch(e),this.destructiveTags(o))return e(!1);if(this.config.observerGuard){const n={times:0};var r=this.observer(()=>{n.times++,1e4<n.times&&(e(!1),this.mutationObserver.disconnect())});r&&(this.mutationObserver=r,setTimeout$1(()=>{10<n.times&&e(!1)},3e3))}}catch(t){e(!0)}})}cancelGuard(){var t;null!=(t=this.mutationObserver)&&t.disconnect()}unload(r){var t;return void 0===r&&(r=null==(t=this.sandbox)?void 0:t.sandbox),new Promise(t=>{var e,i;if(this.cancelGuard(),!r)return t();r===(null==(i=this.sandbox)?void 0:i.sandbox)&&this.saveMirroring();try{r.contentWindow&&(r.contentWindow.onunload=null),r.style.display="none",r.src="about:blank";var s=null==(e=r.contentWindow)?void 0:e.window,o=r.contentDocument;null!=s&&s.location.reload(),null!=o&&o.open(),null!=o&&o.write(""),null!=o&&o.close()}catch(t){}null!=(i=r.parentNode)&&i.removeChild(r),t()})}}class Sandbox{constructor(t,e,i="src"){this.blankURL="about:blank";var s=this.sandbox=document.createElement("iframe");return s["source"===i&&t?"srcdoc":"src"]=t||this.blankURL,s.style.display="none",this.setting=e,this}get window(){return this.sandbox.contentWindow}get document(){return this.sandbox.contentDocument}get origin(){return this.src===this.blankURL?null:this.src}set src(t){this.sandbox.src=t}setOnUnload(t){try{return this.window.onunload=t,Promise.resolve()}catch(t){return Promise.reject(t)}}setOnLoad(t){try{return this.sandbox.onload=t,Promise.resolve()}catch(t){return Promise.reject(t)}}setOnError(t){try{return this.sandbox.onerror=t,Promise.resolve()}catch(t){return Promise.reject(t)}}set(t=this.setting){void 0!==t&&this.sandbox.setAttribute("sandbox",t)}reset(t){return this.exit(),this.set(t),this}open(){var t;return null!=(t=this.document)&&t.open(),this}write(t='<head><meta charset="utf-8"></head>'){var e;return t="<!DOCTYPE html>"+t,null!=(e=this.document)&&e.write(t),this}close(){var t;return null!=(t=this.document)&&t.close(),this}append(t){this.open(),this.write(t),this.close()}enter(t){this.set(),t.appendChild(this.sandbox)}exit(){var t=this.sandbox.parentNode;t&&t.removeChild(this.sandbox)}}class AppletPrefetch extends AppletLifeCycle{dependenciesLoad(o,r="src"){return new Promise((e,i)=>{var t=document.head;const s=new Sandbox(o,"",r);s.setOnLoad(t=>{setTimeout(()=>{s.exit()},2e3),e(t)}),s.setOnError(t=>{s.exit(),i(t)}),s.enter(t)})}preload(){return __awaiter(this,void 0,void 0,function*(){return this.dependenciesLoad(this.uri||(yield this.source),this.uri?"src":"source").then(()=>{var t;this.status.preload=!0,null!=(t=this.events)&&t.preload(this.self),this.trigger("preload")})})}prefetch(){return new Promise((t,e)=>{Promise.all([this.prefetchStatic(this.resources.script,"script"),this.prefetchStatic(this.resources.image,"image"),this.prefetchStatic(this.resources.worker,"worker"),this.prefetchStatic(this.resources.video,"video"),this.prefetchStatic(this.resources.audio,"audio"),this.prefetchStatic(this.resources.font,"font"),this.prefetchStatic(this.resources.style,"style"),this.prefetchStatic(this.resources.html,"document")]).then(()=>{this.status.prefetch=!0,this.trigger("prefetch"),t(!0)}).catch(e)})}prefetchStatic(i=[],s="script"){return new Promise((t,e)=>{Promise.all([].concat(i).map(t=>this.prelink(t,"preload",s))).then(t).catch(e)})}prelink(o,r="preload",n="worker | video | audio | font | script | style | image | document"){return o?new Promise((i,s)=>{requestIdleCallback(()=>{var t,e=document.createElement("link");if(e.rel=r,e.href=o,e.as=n,e.onload=i,e.onerror=s,"preload"===r&&"document"===n&&this.dependenciesLoad(o),null==(t=e.relList)||!t.supports(r))return i(void 0);document.getElementsByTagName("head")[0].appendChild(e),i(void 0)},{timeout:15e3})}):Promise.resolve(void 0)}prerender(){return __awaiter(this,void 0,void 0,function*(){return this.status.preload||this.status.prerender||(yield this.preload(),yield this.prefetch()),Promise.resolve()})}}class AppletEventTarget extends AppletPrefetch{constructor(){super(...arguments),this.borderHolder=[],this.getTouchBorderType=t=>{var e=this.viewport,i=e.offsetWidth,e=e.offsetHeight,t=t.touches[0],s=t.clientX,t=t.clientY,o=[],r=null!=(r=this.config.borderTouchSize)?r:100;return s<=r?o.push("left"):i-r<=s&&o.push("right"),t<=r?o.push("top"):e-r<=t&&o.push("bottom"),o}}attachEvent(){this.registerBorderTouch(),this.bindOverscrollHistoryNavigation(),this.registerTapStatusBarToScrollToTop(),this.registerPullToRefresh()}scrollToTop(){const e=this.getMainScroller();e&&Promise.resolve().then(function(){return index$1}).then(({SmoothScroller:t})=>{new t(e).scrollTo(0,0)}).catch(t=>{console.warn(t)})}registerPullToRefresh(){if(this.config.pullToRefresh)if(this.application.pullRefreshHolder.holder){const e=this.application.pullRefreshHolder.holder,i=this.application.pullRefreshHolder.spinner,s=this.application.pullRefreshHolder.holdLayer,o=this.getMainScroller(this.config.pullToRefreshTargetScrollId);o&&import("./index-5bdc1381.js").then(t=>{t.registerPullDownEvent(this.self,o,e,i,s)}).catch(t=>{console.warn(t)})}else this.application.on("pullToRefreshAvailable",()=>{this.registerPullToRefresh()})}registerTapStatusBarToScrollToTop(){this.config.tapStatusBarToScrollToTop&&this.borderHolder[0].addEventListener("touchend",()=>{this.scrollToTop()})}getMainScroller(t=this.config.mainScrollId){var e;let i;return"shadow"===this.viewType?i=t?(null==(e=null==(e=this.view)?void 0:e.shadowRoot)?void 0:e.getElementById(t))||document.getElementById(t):this.contentView:this.sameOrigin&&(e=null==(e=this.sandbox)?void 0:e.window,i=t?null==e?void 0:e.document.getElementById(t):null==e?void 0:e.document.body),i}bindOverscrollHistoryNavigation(){this.on("touchBorder",(t,e)=>{"touchmove"===e.type&&(t.includes("left")||t.includes("right")||t.includes("wipe"))&&(e=Date.now(),t=t.join(" "),this.application.overscrollHistoryNavigation.moment=e,this.application.overscrollHistoryNavigation.type=t,parent.postMessage({type:"overscrollHistoryNavigationStatusChange",data:[e,t]},"*"))})}addBorderPanMoveHolder(t){var e=null!=(e=this.config.borderTouchSize)?e:15,i=document.createElement("div"),s=document.createElement("div"),o=document.createElement("div"),r=document.createElement("div"),n=document.createElement("div"),l="position: absolute; z-index: 3;";return i.style.cssText=l+` top: 0; right: 0; left: 0; height: env(safe-area-inset-top); mini-height: ${e}px;`,s.style.cssText=l+` top: 0; right: 0; bottom: 0; z-index: 3; width: ${e}px;`,o.style.cssText=l+` right: 0; bottom: 0; left: 0; z-index: 3; height: ${e}px;`,r.style.cssText=l+` top: 0; bottom: 0; left: 0; z-index: 3; width: ${e}px;`,n.style.cssText=`display: none; ${l} top: 0; right: 0; bottom: 0; left: 0; z-index: 4;`,t.appendChild(i),t.appendChild(s),t.appendChild(o),t.appendChild(r),t.appendChild(n),this.borderHolder=[i,s,o,r,n]}registerBorderHolderTouch(){const[e,i,s,o,r]=this.addBorderPanMoveHolder(this.viewport),n=[],l=r.addEventListener,t=r.removeEventListener,a=t=>{this.trigger("touchBorder",n,t)},h=t=>{n.length=0,t.target===e?n.push("top"):t.target===i?n.push("right"):t.target===s?n.push("bottom"):t.target===o&&n.push("left"),r.style.display="block",l("touchmove",a,!0),l("touchend",a,!0),l("touchcancel",a,!0)},p=()=>{r.style.display="none",t("touchmove",a,!0),t("touchend",a,!0),t("touchcancel",a,!0)};var c=t=>{t=t.addEventListener;t("touchstart",h,!0),t("touchmove",h,!0),t("touchcancel",p,!0),t("touchend",p,!0)};c(e),c(i),c(s),c(o)}registerBorderTouch(){var t;if(this.sandbox&&!this.sameOrigin)return this.registerBorderHolderTouch();const e=(null==(t=null==(t=this.sandbox)?void 0:t.window)?void 0:t.document)||this.viewport,i=[],s=t=>{this.trigger("touchBorder",i,t),"touchend"!==t.type&&"touchcancel"!==t.type||(e.removeEventListener("touchmove",s,!0),e.removeEventListener("touchend",s,!0),e.removeEventListener("touchcancel",s,!0))};e.addEventListener("touchstart",t=>{i.length=0,i.push(...this.getTouchBorderType(t)),this.transforming&&i.push("wipe"),0<i.length&&(e.addEventListener("touchmove",s,!0),e.addEventListener("touchend",s,!0),e.addEventListener("touchcancel",s,!0))},!0)}}class AppletControlsBase{constructor(t){this.backdropReducedScale=.03,this.applet=t,this.application=t.application,this.appletViewport=this.applet.viewport}}class AppletControlsState extends AppletControlsBase{constructor(){super(...arguments),this.advanceDegree=0,this.swipeTransitionType=this.application.config.swipeTransitionType}get visibility(){return 0!==Math.round(this.controlsView.scrollLeft/this.appletViewport.offsetWidth)}get viewports(){return this.fromViewports||(this.fromViewports=this.application.segue.viewports)}get degree(){return this.controlsView.scrollLeft/this.appletViewport.offsetWidth}get activity(){return this.application.activityApplet===this.applet}clearFromViewports(){this.fromViewports=void 0}}class AppletControlsEventTarget extends AppletControlsState{constructor(){super(...arguments),this.available=!0,this.toggleLock=!1,this.slidingListener=this.sliding.bind(this)}requestGoBack(t){this.applet.transforming||!1===this.toggleLock&&t<=this.advanceDegree&&this.activity&&(this.toggleLock=!0,setTimeout(()=>{this.toggleLock=!1},300),this.application.segue.back("controls").then(()=>{this.fromViewports=void 0}))}sliding(){var t=this.applet,e=this.viewports[1],i=this.swipeTransitionType,s=this.degree;this.requestGoBack(s),this.backdropView.animate([{opacity:s}],{duration:0,fill:"forwards"}).play();let o=1<s?`rgba(0, 0, 0, ${.5+3*(s-1)})`:"transparent";if(this.controlsView.animate([{backgroundColor:o}],{duration:0,fill:"forwards"}).play(),e&&t.visibility&&!t.transforming&&!this.toggleLock){let t="slide"===i?`translate3d(${30*-s}%, 0, 0)`:`scale(${1-.03*s})`;e.animate([{transform:t}],{duration:0,fill:"forwards"}).play()}this.application.trigger("transition",s,this.application.segue.appletGroup)}bindSlidingEvent(){this.controlsView.addEventListener("scroll",this.slidingListener)}removeSlidingEvent(){this.controlsView.removeEventListener("scroll",this.slidingListener)}bindBaseEvent(){this.backdropView.addEventListener("touchstart",()=>__awaiter(this,void 0,void 0,function*(){yield this.hide(),this.requestGoBack(this.degree)})),this.controlsOverlay.addEventListener("touchstart",t=>{t.stopPropagation(),t.preventDefault()},!1),this.applet.on("willShow",()=>{this.application.segue.stackUp&&this.clearFromViewports()}),this.applet.on("show",()=>{this.visibility||this.appearImmediately(),this.application.segue.stackUp&&this.prepare()}),this.applet.on("hide",()=>{this.visibility&&this.application.segue.fromOverscrollHistoryNavigation&&this.disappearImmediately()})}prepare(e=!1){var i=this.viewports,s=this.swipeTransitionType,i=i[1];if(i){let t="";t="slide"===s?e?"translate3d(0, 0, 0)":"translate3d(-30%, 0, 0)":e?"scale(1)":`scale(${1-this.backdropReducedScale})`,i.animate([{transform:t}],{duration:0,fill:"forwards"}).play()}}switch(t){return __awaiter(this,void 0,void 0,function*(){return this.controlsOverlay.style.display="block",this.toggleLock=!0,this.scroll.snapTo(t?this.appletViewport.offsetWidth:0,0).then(()=>{this.toggleLock=!1,this.controlsOverlay.style.display="none"})})}disappearImmediately(){return __awaiter(this,void 0,void 0,function*(){this.controlsView.style.scrollBehavior="auto",this.controlsView.scrollLeft=1+this.advanceDegree})}appearImmediately(){return __awaiter(this,void 0,void 0,function*(){this.controlsView.style.scrollBehavior="auto",this.controlsView.scrollLeft=this.appletViewport.offsetWidth})}show(){return __awaiter(this,void 0,void 0,function*(){return this.switch(!0).then(()=>{this.bindSlidingEvent()})})}hide(){return __awaiter(this,void 0,void 0,function*(){return this.switch(!1).then(()=>{this.removeSlidingEvent()})})}disable(){this.available=!1}enable(){this.available=!0}activate(){!1!==this.available&&(this.backdropView.style.display="block",this.controlsView.style.overflow="auto",this.controlsView.scrollLeft=this.appletViewport.offsetWidth,this.bindSlidingEvent())}freeze(){this.removeSlidingEvent(),this.backdropView.style.display="none",this.controlsView.style.overflow="hidden"}}const now=window.performance&&window.performance.now?window.performance.now.bind(window.performance):Date.now,easeInOutCubic=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,hasSmoothScrolling=testHasSmoothScrolling(),hasSmoothSnapScrolling=testHasSmoothSnapScrolling(),breakSmoothSnap=!hasSmoothScrolling&&/Mac OS X [0-9][0-9]_/g.exec(navigator.userAgent);class SmoothScroller{constructor(t,e=!1){this.touchHold=!1,this.scrollType="scroll",this.scrollHold=null,this.scrolling=!1,this.reservePlanId=-1,this.scrollDuration=400,this.checkScrollEnd=(t,e)=>this.element.scrollLeft===t&&this.element.scrollTop===e,this.element=t,!hasSmoothScrolling&&e&&(t.addEventListener("touchstart",this.scrollStop,!0),t.addEventListener("touchend",this.scrollContinue,!0),t.addEventListener("touchcancel",this.scrollContinue,!0))}snapTo(t,e,i){return __awaiter(this,void 0,void 0,function*(){return this.touchHold=!1,this.scrollType="snap",this.smoothScroll(t,e,i)})}scrollTo(t,e,i){return __awaiter(this,void 0,void 0,function*(){return this.touchHold=!1,this.scrollType="scroll",this.smoothScroll(t,e,i)})}scrollStop(){this.touchHold=!0}scrollContinue(){var t;this.touchHold=!1,null!=(t=this.scrollHold)&&t.call(this)}catchDefaultStyle(){var t;!0!==this.scrolling&&(t=this.element.style,this.defaultScrollBehavior=t.scrollBehavior||"smooth")}isBreak(){return!("ontouchend"in document||void 0===this.preStep||this.preStep[0]===this.element.scrollLeft&&this.preStep[1]===this.element.scrollTop||(this.scrollStop(),0))}step(t){if(this.touchHold){if("scroll"===this.scrollType)return t.end();this.scrollHold=()=>{this.step(t)}}var e=now(),e=Math.min((e-t.startTime)/t.duration,1),e=easeInOutCubic(e);let i=t.startX+(t.x-t.startX)*e,s=t.startY+(t.y-t.startY)*e;var e=0<t.x-t.startX?1:-1,o=0<t.y-t.startY?1:-1;(1==e&&i>t.x||-1==e&&i<t.x)&&(i=t.x),(1==o&&s>t.y||-1==o&&s<t.y)&&(s=t.y),this.isBreak()||(this.element.scrollLeft=i,this.element.scrollTop=s,this.element.scrollTo(i,s),this.preStep=[this.element.scrollLeft,this.element.scrollTop],i!==t.x||s!==t.y?rAF(()=>{this.step(t)}):(t.end(),this.scrollHold=null))}openSmooth(){this.element.style.scrollBehavior="smooth",breakSmoothSnap&&(this.element.style.scrollSnapType=this.defaultScrollSnapType)}closeSmooth(){this.element.style.scrollBehavior="auto",breakSmoothSnap&&(this.defaultScrollSnapType=this.element.style.scrollSnapType,this.element.style.scrollSnapType="none")}beforeScrolling(){this.catchDefaultStyle(),this.preStep=void 0,this.scrolling=!0}endScrolling(){this.element.style.scrollBehavior=this.defaultScrollBehavior||"smooth",this.scrolling=!1}smoothScroll(i,s,o){if("scroll"===this.scrollType&&!hasSmoothScrolling||"snap"===this.scrollType&&!hasSmoothSnapScrolling)return this.smoothScrollByStep(i,s);let r=-1;return new Promise(t=>{const e=()=>{clearTimeout(r),r=setTimeout$1(()=>__awaiter(this,void 0,void 0,function*(){this.element.removeEventListener("scroll",e,!1),t()}),100)};this.element.addEventListener("scroll",e,!1),this.beforeScrolling(),this.openSmooth(),this.checkScrollEnd(i,s)&&(this.endScrolling(),t()),this.element.scrollTo(i,s),clearTimeout(this.reservePlanId),this.reservePlanId=setTimeout$1(()=>__awaiter(this,void 0,void 0,function*(){-1===r&&(yield this.smoothScrollByStep(i,s,o),t())}),600)})}smoothScrollByStep(e,i,s=this.scrollDuration){return this.beforeScrolling(),this.closeSmooth(),new Promise(t=>{this.step({startTime:now(),startX:this.element.scrollLeft,startY:this.element.scrollTop,x:e,y:i,duration:s,end:()=>{this.endScrolling(),t()}})})}}index$1=Object.freeze({__proto__:null,SmoothScroller:SmoothScroller});const coveredCSSText=` width: 100%; height: 100%; min-width: 100%; min-height: 100%; max-width: 100%; max-height: 100%; `,USE_PERCENTAGE$1=getEnv()["USE_PERCENTAGE"],fullscreenBaseCSSText=` top: 0px; right: 0px; bottom: 0px; left: 0px; width: ${USE_PERCENTAGE$1?"100%":"100vw"}; height: ${USE_PERCENTAGE$1?"100%":"100vh"}; min-width: ${USE_PERCENTAGE$1?"100%":"100vw"}; min-height: ${USE_PERCENTAGE$1?"100%":"100vh"}; max-width: ${USE_PERCENTAGE$1?"100%":"100vw"}; max-height: ${USE_PERCENTAGE$1?"100%":"100vh"}; `,snapItemCSSText=` position: relative; display: flex; ${coveredCSSText} scroll-snap-align: start; scroll-snap-stop: always; `,sheetViewCSSText=` applet-controls::-webkit-scrollbar { display: none; } applet-controls::scrollbar { display: none; } `,backdropViewCSSText=` ${snapItemCSSText} background: rgba(0, 0, 0, .3); opacity: 0; `,controlsViewCSSText=` position: relative; display: flex; ${coveredCSSText} flex-direction: row; overflow: auto; scroll-behavior: auto; scroll-snap-type: both mandatory; `,controlsOverlayCSSText=` position: fixed; ${fullscreenBaseCSSText} z-index: 9; display: none; `;class AppletControlsView extends AppletControlsEventTarget{attach(){this.controlsView=document.createElement("applet-controls"),this.contentContainer=document.createElement("applet-container"),this.backdropView=document.createElement("applet-backdrop"),this.controlsOverlay=document.createElement("applet-controls-overlay"),this.scroll=new SmoothScroller(this.controlsView)}buildControlsView(){var t=document.createElement("style");t.innerHTML=sheetViewCSSText,this.contentContainer.style.cssText=snapItemCSSText,this.backdropView.style.cssText=backdropViewCSSText,this.controlsView.style.cssText=controlsViewCSSText,!1===testHasScrolling()&&(this.controlsView.style.cssText+="-webkit-overflow-scrolling: touch;"),this.controlsOverlay.style.cssText=controlsOverlayCSSText,this.controlsView.appendChild(this.backdropView),this.controlsView.appendChild(this.contentContainer),this.appletViewport.appendChild(t),this.appletViewport.appendChild(this.controlsView),this.appletViewport.appendChild(this.controlsOverlay)}create(){this.attach(),this.buildControlsView(),this.bindBaseEvent();var t=this.applet;return("applet"!==t.rel||!1===t.swipeModel||null!=(t=t.mountBehavior)&&t.noSwipeModel)&&this.freeze(),this.contentContainer}}class AppletControls extends AppletControlsView{}class SlideBase{constructor(t,e={openSlideViewLeftHolder:!0,slideViewSnapType:"x",slideViewGridRepeat:0},i=t.viewport){this.scrolling=!1,this.switching=!1,this.distance=0,this.activeId="",this.snapType="x";var s=t.config.defaultSlideViewApplets;s&&i&&(this.applet=t,this.application=t.application,this.slideViewApplets=s,this.options=e,this.snapType=e.slideViewSnapType)}}class SlideState extends SlideBase{get index(){var t=this.slideView;return(Math.round(t.scrollLeft/t.offsetWidth)+1)*(Math.round(t.scrollTop/t.offsetHeight)+1)-1}get slidingState(){if(this.slidingStateCatch)return this.slidingStateCatch;const t=this.slideView;return this.slidingStateCatch={get x(){return t.scrollLeft},get y(){return t.scrollTop},get xIndex(){return Math.round(t.scrollLeft/t.offsetWidth)},get yIndex(){return Math.round(t.scrollTop/t.offsetHeight)}}}getAppletIdByIndex(t){return null==(t=this.slideViewApplets[t])?void 0:t.id}getAppletIndexById(t){if("number"==typeof t)return t;let e=0;for(const i of this.slideViewApplets){if(i.id===t)return e;e++}return 0}}class SlideEventTarget extends SlideState{constructor(){super(...arguments),this.hasSmoothSnapScrolling=testHasSmoothSnapScrolling(),this.scrollCancelTimeoutId=-1,this.scrollCycleTimeout=300}closeOverlay(){this.slideViewOverlay.style.display="none"}openOverlay(){this.slideViewOverlay.style.display="block"}bindHolderEvent(){var t=t=>{t.stopPropagation(),this.openOverlay(),this.slideView.style.overflowX="hidden"};const e=()=>{this.closeOverlay(),this.slideView.style.overflowX="auto",this.slideView.removeEventListener("touchcancel",e,!0),this.slideView.removeEventListener("touchend",e,!0)};this.slideViewHolder.addEventListener("touchstart",t,!0),this.slideViewHolder.addEventListener("touchmove",t,!0),this.slideViewHolder.addEventListener("touchcancel",e,!0),this.slideViewHolder.addEventListener("touchend",e,!0)}dispatchScrollEvent(){this.application.activate(!1),this.applet.trigger("sliding",this.slidingState)}bindScrollEvent(){const t=this.slideView;t.addEventListener("scroll",()=>{this.switching||(this.scrolling||(this.freezeAll(),this.scrolling=!0),this.dispatchScrollEvent(),clearTimeout(this.scrollCancelTimeoutId),this.scrollCancelTimeoutId=setTimeout$1(()=>__awaiter(this,void 0,void 0,function*(){this.hasSmoothSnapScrolling||(yield this.scroller.scrollTo(this.slidingState.xIndex*this.slideView.offsetWidth,this.slidingState.yIndex*t.offsetHeight)),this.scrolling=!1,this.activate(this.index),this.application.activate(!0)}),this.scrollCycleTimeout))})}destroy(e){return __awaiter(this,void 0,void 0,function*(){var t=this.getAppletIdByIndex(e);return(t=t&&this.application.applets[t])?!1!==t.config.background?Promise.resolve(!1):t.destroy(!0):Promise.resolve(!0)})}freeze(e){return __awaiter(this,void 0,void 0,function*(){var t=this.getAppletIdByIndex(e);return t?this.application.get(t).then(t=>{t.hide(),this.applet.trigger("slideOut",t)}):Promise.resolve()})}activate(t){return __awaiter(this,void 0,void 0,function*(){const e=this.getAppletIdByIndex(t);return e?this.application.get(e).then(t=>__awaiter(this,void 0,void 0,function*(){return t.show(),this.applet.trigger("slideEnter",t),e!==this.activeId&&this.destroy(this.getAppletIndexById(this.activeId)),this.activeId=e,t.view&&t.visibility?Promise.resolve():t.build()})):Promise.resolve()})}freezeAll(){var e=this.slideViewApplets.length;for(let t=0;t<=e;t++)this.freeze(t)}to(n,l=!0){return __awaiter(this,void 0,void 0,function*(){var t,e,i=this.getAppletIndexById(n),s=this.slideView;let o=0,r=0;return"x"===this.options.slideViewSnapType?(e=(t=s.offsetWidth)*this.slideViewApplets.length,o=Math.min(Math.max(i*t,0),e)):(e=(t=s.offsetHeight)*this.slideViewApplets.length,r=Math.min(Math.max(i*t,0),e)),this.index!==i&&(yield this.freeze(this.index)),!1===l?(s.style.scrollBehavior="auto",s.scrollLeft=o,s.scrollTop=r,s.style.scrollBehavior="smooth",Promise.resolve()):(this.switching=!0,this.openOverlay(),this.application.activate(!1),this.scroller.snapTo(o,r).then(()=>{this.closeOverlay(),this.switching=!1,this.activate(this.index),this.application.activate(!0)}))})}}const viewportCSSText=` display: flex; ${coveredCSSText} scroll-snap-align: start; scroll-snap-stop: always; transform: translate3d(0, 0, 0); `,slideBaseCSSText=` slideView-viewport::-webkit-scrollbar { display: none; } slideView-viewport::scrollbar { display: none; } `,getSlideViewCSSText=(t,e,i)=>` ${"y"===t?"overflow-y: auto; overflow-x: hidden;":"x"===t?"display: flex; overflow-x: auto; overflow-y: hidden;":` display: grid; overflow: auto; grid-template-columns: repeat(${e}, 100%); grid-template-rows: repeat(${e}, 100%); `} position: absolute; ${fullscreenBaseCSSText} z-index: 2; scroll-behavior: ${i?"smooth":"auto"}; scroll-snap-type: ${t} mandatory; `,slideViewHolderCSSText=` position: absolute; top: 15%; bottom: 15%; left: 0; width: 15px; z-index: 5; `,slideViewOverlayCSSText=` position: fixed; ${fullscreenBaseCSSText} z-index: 7; display: none; `;class SlideView extends SlideEventTarget{constructor(t,e,i){super(t,e,i),this.scrolling=!1,this.switching=!1,this.distance=0,this.activeId="",this.createSlideView(this.slideViewApplets,i),this.bindScrollEvent(),this.bindHolderEvent(),this.scroller=new SmoothScroller(this.slideView)}resetViewportStyle(t){t.style.cssText=viewportCSSText}createSlideView(t,e){const r=document.createElement("slideView-viewport");var i=document.createElement("style");const n=document.createElement("slideView-holder");var s=document.createElement("slideView-overlay"),o=this.snapType,l=null!=(l=this.options.slideViewGridRepeat)?l:2;i.innerHTML=slideBaseCSSText,r.style.cssText=getSlideViewCSSText(o,l,this.hasSmoothSnapScrolling),!1===testHasScrolling()&&(r.style.cssText+="-webkit-overflow-scrolling: touch;"),n.style.cssText=slideViewHolderCSSText,s.style.cssText=slideViewOverlayCSSText,s.addEventListener("touchstart",t=>{t.stopPropagation(),t.preventDefault()},!0),s.addEventListener("touchend",()=>{this.closeOverlay()},!0),t.forEach((t,e)=>{const{id:i,activate:s}=t,o=document.createElement("applet-viewport");o.id="applet-viewport-"+i,this.resetViewportStyle(o),0===e&&(this.activeId=i,this.options.openSlideViewLeftHolder)&&o.appendChild(n),r.appendChild(o),this.application.get(i).then(t=>{t.attach(o,this.applet,{agentSegue:()=>__awaiter(this,void 0,void 0,function*(){return this.application.to(this.applet.id).then(()=>{var t;null!=(t=this.applet.slide)&&t.to(i)})}),noSwipeModel:!0}),"instant"===s||0===e?(t.build(),0===e&&t.show()):"lazy"===s&&requestIdleCallback(()=>{t.build()},{timeout:3e3})})}),e.appendChild(i),e.appendChild(r),e.appendChild(s),this.slideView=r,this.slideViewHolder=n,this.slideViewOverlay=s}}class Slide extends SlideView{}class ModalityBase{constructor(t){this.switching=!1,this.scrolling=!1,this.backdropReducedScale=.1,this.backdropRotateX=-10,this.backdropPerspective=3e3,this.backdropBorderRadius=20,this.advanceDegree=800/window.innerHeight*.03,this.applet=t,this.application=this.applet.application,this.modalityContainer=document.createElement("modality-container"),this.appletViewport=this.applet.viewport,this.options=this.applet.config.sheetOptions,this.defaultToLarge="large"===(null==(t=this.options)?void 0:t.defaultCardSize)}}class ModalityState extends ModalityBase{get viewports(){return this.fromViewports&&this.activity||(this.fromViewports=this.application.segue.viewports,this.updateOverlapViewport()),this.fromViewports}get maxDegree(){var t;return this.maxDegreeCache||(t=null!=(t=null==(t=this.miniCard)?void 0:t.offsetHeight)?t:0,this.maxDegreeCache=1+t/this.contentContainer.offsetHeight)}get degree(){var t;return this.modalityContainer.scrollTop/Math.min(this.contentContainer.offsetHeight+(null!=(t=null==(t=this.miniCard)?void 0:t.offsetHeight)?t:0),this.modalityContainer.offsetHeight)}get visibility(){return!(this.degree<=.1)}get hasMiniCard(){return!!this.miniCard}get prevViewport(){return this.viewports[1]}get activity(){return this.applet.transforming||this.application.activityApplet===this.applet}setBackdropViewport(t){this.fromViewports||(this.fromViewports=this.viewports),this.fromViewports[1]=t}updateOverlapViewport(){var t=this.application.prevActivityApplet;null!=t&&t.modality&&this.setBackdropViewport(t.modality.viewports[1])}checkScrollStop(){return new Promise(t=>{const e=t=>{setTimeout(()=>this.scrolling?e(t):t(),100)};e(()=>t(!0))})}}const NoSmoothSnapScrolling=!1===testHasSmoothSnapScrolling(),HasSnapReset$1=testHasSnapReset();class ModalityEventTarget extends ModalityState{constructor(){super(...arguments),this.scrollingTimeoutId=-1,this.freezePosition=-1,this.fixSnapReset=!HasSnapReset$1,this.fallHeight=this.application.isFullscreen?40:0,this.slidingListener=this.sliding.bind(this)}switchSheet(t=1.5){return __awaiter(this,void 0,void 0,function*(){return this.activity?this.degree<=this.maxDegree/t?this.hide():this.rise():Promise.resolve()})}switchOverlay(t=!1){this.modalityOverlay.style.display=t?"block":"none"}switchSmooth(t=!0){this.modalityContainer.style.scrollBehavior=t?"smooth":"auto"}switchSnap(t=!0){this.modalityContainer.style.scrollSnapType=t?"y mandatory":"none"}switchBackdropColor(t=!0){this.application.segue.applicationViewport.style.backgroundColor=t?null!=(t=null==(t=this.options)?void 0:t.backdropColor)?t:"#000":""}freezeSnap(){this.modalityPlaceholder.style.display="none",this.modalityContainer.scrollTop=0}activateSnap(){var t;return __awaiter(this,void 0,void 0,function*(){this.switchSmooth(!1),HasSnapReset$1||this.switchSnap(!1),this.modalityPlaceholder.style.display="flex",this.modalityContainer.scrollTop=this.modalityContainer.offsetHeight+(null!=(t=null==(t=this.miniCard)?void 0:t.offsetHeight)?t:0),yield sleep(0),this.switchSmooth(!0),HasSnapReset$1||this.switchSnap(!0)})}rise(){var e;return __awaiter(this,void 0,void 0,function*(){if(this.switching)return this.processPromise;this.switching=!0,this.switchOverlay(!0);var t=this.modalityContainer.offsetHeight+(this.defaultToLarge?this.contentContainer.offsetHeight:0)+(this.miniCard&&this.degree>=1+(this.maxDegree-1)/2&&null!=(e=null==(e=this.miniCard)?void 0:e.offsetHeight)?e:0);return this.processPromise=this.scroller.snapTo(0,t).then(()=>{this.switching=!1,this.switchOverlay(!1)})})}fall(){return __awaiter(this,void 0,void 0,function*(){return this.switching?this.processPromise:(this.switching=!0,this.switchOverlay(!0),this.processPromise=this.scroller.snapTo(0,0).then(()=>__awaiter(this,void 0,void 0,function*(){this.switching=!1,this.switchOverlay(!1)})))})}hide(){return __awaiter(this,void 0,void 0,function*(){return this.switching?this.processPromise:(this.switching=!0,this.activity?(this.removeSlidingEvent(),this.segueTransition(!1),this.fall().then(()=>__awaiter(this,void 0,void 0,function*(){this.switching=!1,this.activity&&(yield this.application.segue.back())}))):Promise.resolve())})}segueTransition(t=!0){var e,i=this.prevViewport,s=!t||this.miniCard&&!this.defaultToLarge?0:1,o=this.options,r=null!=(r=null==o?void 0:o.maskOpacity)?r:.3,o=null==o?void 0:o.useFade;(null==(e=this.options)?void 0:e.stillBackdrop)||i.animate([{borderRadius:s*this.backdropBorderRadius+"px",transform:` translate3d(0, ${s*this.fallHeight}px, -100px) perspective(${this.backdropPerspective}px) rotateX(${s*this.backdropRotateX}deg) scale(${1-Math.max(s*this.backdropReducedScale,0)}) `}],{duration:500,delay:100,fill:"forwards"}).play(),this.modalityContainer.animate([{backgroundColor:`rgba(0, 0, 0, ${t?r:0})`}],{duration:500,delay:100,fill:"forwards"}).play(),o&&!t&&this.contentContainer.animate([{opacity:"1"}],{duration:0,fill:"forwards"}).play()}sliding(){if(this.activity){const r=this.degree;var t,e=this.maxDegree,i=this.prevViewport,s=this.options,o=null!=(o=null==s?void 0:s.maskOpacity)?o:.3,s=null==s?void 0:s.useFade;r>e?this.contentContainer.animate([{backgroundColor:`rgba(0, 0, 0, ${o+(1-o)*(r-e)/.2})`}],{duration:0,fill:"forwards"}).play():(e=this.miniCard?(r-1)/(e-1):r,t=null!=(t=null==(t=this.options)?void 0:t.stillBackdrop)?t:this.miniCard&&r<=1,this.activity&&i&&!t&&i.animate([{borderRadius:Math.min(e,1)*this.backdropBorderRadius+"px",transform:` translate3d(0, ${e*this.fallHeight}px, -100px) perspective(${this.backdropPerspective}px) rotateX(${e*this.backdropRotateX}deg) scale(${1-Math.max(e*this.backdropReducedScale,0)}) `}],{duration:0,fill:"forwards"}).play(),this.modalityContainer.animate([{backgroundColor:`rgba(0, 0, 0, ${o*Math.min(r,1)})`}],{duration:0,fill:"forwards"}).play(),s&&this.contentContainer.animate([{opacity:""+(e-2*(1-e))}],{duration:0,fill:"forwards"}).play(),this.scrolling=!0,clearTimeout(this.scrollingTimeoutId),this.scrollingTimeoutId=setTimeout$1(()=>{this.scrolling=!1,NoSmoothSnapScrolling&&this.degree===r&&(r<=.7?this.hide():this.rise())},100),this.switching||r<=this.advanceDegree&&this.hide())}}bindSlidingEvent(){this.modalityContainer.addEventListener("scroll",this.slidingListener)}removeSlidingEvent(){this.modalityContainer.removeEventListener("scroll",this.slidingListener)}bindDragContentEvent(){var t=this.applet.contentDocument;if(t){const s={x:0,y:0,swipe:void 0},o=this.modalityContainer,r=o.offsetHeight/o.offsetWidth;t.addEventListener("touchstart",t=>{t=t.changedTouches,t=t[0];s.x=t.pageX,s.y=t.pageY,s.swipe=void 0},!0),t.addEventListener("touchend",()=>__awaiter(this,void 0,void 0,function*(){s.swipe&&(s.swipe=!1,yield this.checkScrollStop())&&(this.switchSmooth(!0),this.switchSnap(!0),this.switchSheet(this.miniCard?2:1.25).then(()=>{this.switchOverlay(!1),this.switching=!1}))}),!0),t.addEventListener("touchmove",t=>{var t=t["changedTouches"],t=t[0],e=t.pageX-s.x,i=t.pageY-s.y;this.switching||!1!==s.swipe&&(20<Math.abs(e)-Math.abs(i)&&Math.abs(i)<=10&&(s.swipe=!0,this.switchOverlay(!0),this.switchSmooth(!1),this.switchSnap(!1)),s.swipe)&&(o.scrollTop-=Math.ceil(e)*r,s.x=t.pageX,s.y=t.pageY)},!0)}}bindBaseEvent(){this.applet.on("willShow",()=>{this.switchBackdropColor(!0),this.application.segue.stackUp&&(this.fromViewports=void 0)}),this.applet.on("willSegueShow",()=>{this.segueTransition(!0)}),this.applet.on("show",()=>{this.bindSlidingEvent()}),this.applet.on("willHide",()=>{this.removeSlidingEvent()}),this.applet.on("willSegueHide",()=>{this.segueTransition(!1)}),this.applet.on("hide",()=>{this.switchBackdropColor(!1)})}freeze(){this.removeSlidingEvent(),!1===this.fixSnapReset&&(this.freezePosition=this.modalityContainer.scrollTop||this.contentContainer.offsetTop,this.modalityPlaceholder.style.display="none")}activate(){var t;!1===this.fixSnapReset&&-1!==this.freezePosition&&(this.modalityPlaceholder.style.display="block",t=this.freezePosition,this.modalityContainer.scrollTop=t,this.scroller.snapTo(0,t,0),this.freezePosition=-1,this.fixSnapReset=!0),this.bindSlidingEvent()}}const baseCSSText=` applet-viewport { background: transparent !important; } modality-container { display: flex; height: 100%; overflow-y: scroll !important; scroll-behavior: smooth; scroll-snap-type: y mandatory; flex-direction: column; } modality-container::-webkit-scrollbar { display: none; } modality-container::scrollbar { display: none; } modality-placeholder { position: relative; display: block; ${coveredCSSText} scroll-snap-align: start; scroll-snap-stop: always; box-sizing: content-box; } modality-handle { display: block; position: absolute; top: 100%; height: 20px; width: 100%; z-index: 2; } modality-handle::before { content: ' '; display: block; width: 36px; height: 5px; margin: 5px auto; border-radius: 5px; background: #777; opacity: .5; } modality-handle:hover::before { opacity: 1; } blocked-holder { position: absolute; top: 200px; left: 0; bottom: 200px; width: 40px; z-index: 5; overflow-y: hidden; overflow-x: scroll; overscroll-behavior-y: none; display: flex; flex-flow: row-reverse; } blocked-holder::-webkit-scrollbar { display: none; } blocked-holder::scrollbar { display: none; } blocked-holder::before { content: ' '; display: flex; min-width: 100vw; height: 100%; } `,NoScrolling=!1===testHasScrolling();class ModalityView extends ModalityEventTarget{constructor(t){super(t),this.scroller=new SmoothScroller(this.modalityContainer),this.buildModalityOverlay(),null!=(t=t.viewport)&&t.appendChild(this.modalityContainer)}