UNPKG

on-screen-keyboard-detector

Version:

Detects presence of the On-Screen-Keyboard in mobile browsers

31 lines (30 loc) 43.4 kB
/* @license On-screen keyboard detector (OSKD) v.2.3.0 (c) 2020-2021 Matthias Seemann OSKD may be freely distributed under the MIT license. */ /** @license MIT License (c) copyright 2010-2016 original author or authors */ function t(t,n){if(t<0)throw new TypeError("i must be >= 0");var e=n.length;return 0===e||t>=e?n:1===e?[]:function(t,n,e){var r,i=new Array(e);for(r=0;r<t;++r)i[r]=n[r];for(r=t;r<e;++r)i[r]=n[r+1];return i}(t,n,e-1)} /** @license MIT License (c) copyright 2010-2016 original author or authors */ var n=function(t){return t};function e(t){return function n(e,r){switch(arguments.length){case 0:return n;case 1:return function(n){return t(e,n)};default:return t(e,r)}}}function r(t){return function n(r,i,s){switch(arguments.length){case 0:return n;case 1:return e((function(n,e){return t(r,n,e)}));case 2:return function(n){return t(r,i,n)};default:return t(r,i,s)}}}var i=function(){function t(t,n){this.origin=t,this.scheduler=n}return t.prototype.currentTime=function(){return this.scheduler.currentTime()-this.origin},t.prototype.scheduleTask=function(t,n,e,r){return this.scheduler.scheduleTask(t+this.origin,n,e,r)},t.prototype.relative=function(n){return new t(n+this.origin,this.scheduler)},t.prototype.cancel=function(t){return this.scheduler.cancel(t)},t.prototype.cancelAll=function(t){return this.scheduler.cancelAll(t)},t}(),s=e((function(t,n){return n.scheduleTask(0,0,-1,t)})),o=r((function(t,n,e){return e.scheduleTask(0,t,-1,n)})),u=function(t){return t.dispose()},c=e((function(t,n){return new i(t,n)}));function h(t,n,e){for(var r=n,i=0,s=e.length;i<s;++i)r=t(r,e[i],i);return r}function f(t){return function n(e,r){switch(arguments.length){case 0:return n;case 1:return function(n){return t(e,n)};default:return t(e,r)}}}var a=function(){return p},p=new(function(){function t(){}return t.prototype.dispose=function(){},t}()),l=function(t){return new d(t)},d=function(){function t(t){this.disposed=!1,this.disposable=t}return t.prototype.dispose=function(){this.disposed||(this.disposed=!0,this.disposable&&(this.disposable.dispose(),this.disposable=void 0))},t}(),v=function(t){var n=h(m,[],t);return 0===n.length?a():new g(n)},y=f((function(t,n){return v([t,n])})),m=function(t,n){return function(t){return t===p}(n)?t:n instanceof g?function(t,n){var e=t.length,r=n.length,i=new Array(e+r),s=0;for(s=0;s<e;s++)i[s]=t[s];for(var o=0;o<r;o++)i[s++]=n[o];return i}(t,n.disposables): /** @license MIT License (c) copyright 2010-2016 original author or authors */ function(t,n){for(var e=n.length,r=new Array(e+1),i=0;i<e;++i)r[i]=n[i];return r[e]=t,r}(n,t)},g=function(){function t(t){this.disposables=t}return t.prototype.dispose=function(){b(k(this.disposables))},t}(),k=function(t){return h(w,[],t)},w=function(t,n){try{n.dispose()}catch(n){t.push(n)}return t},b=function(t){if(t.length>0)throw new _(t.length+" errors",t)},_=function t(n,e){this.name="DisposeAllError",this.message=n,this.errors=e,Error.call(this,n),Error.captureStackTrace&&Error.captureStackTrace(this,t),this.stack=""+this.stack+E(this.errors)};_.prototype=Object.create(Error.prototype);var A,E=function(t){return h(O,"",t)},O=function(t,n,e){return t+"\n["+(e+1)+"] "+n.stack},x=(A=function(t,n,e){try{n.dispose()}catch(n){e.error(t,n)}},function t(n,e,r){switch(arguments.length){case 0:return t;case 1:return f((function(t,e){return A(n,t,e)}));case 2:return function(t){return A(n,e,t)};default:return A(n,e,r)}}),T=function(t,n){return(T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)};function S(t,n){function e(){this.constructor=t}T(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)} /** @license MIT License (c) copyright 2010-2016 original author or authors */function j(t){throw t} /** @license MIT License (c) copyright 2010-2016 original author or authors */var I=function(t,n){return new V(t,n)},H=function(t){return new z(t)},q=function(){function t(t){this.sink=t,this.active=!0}return t.prototype.dispose=function(){this.active=!1},t.prototype.run=function(t){this.active&&this.runIfActive(t)},t.prototype.error=function(t,n){if(!this.active)return function(t){setTimeout(j,0,t)}(n);this.sink.error(t,n)},t}(),R=function(t){function n(n,e,r){var i=t.call(this,r)||this;return i.runEvent=n,i.value=e,i}return S(n,t),n.prototype.runIfActive=function(t){this.runEvent(t,this.value,this.sink)},n}(q),V=function(t){function n(n,e){var r=t.call(this,e)||this;return r.value=n,r}return S(n,t),n.prototype.runIfActive=function(t){this.sink.event(t,this.value)},n}(q),z=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return S(n,t),n.prototype.runIfActive=function(t){this.sink.end(t)},n}(q),N=(function(t){function n(n,e){var r=t.call(this,e)||this;return r.value=n,r}S(n,t),n.prototype.runIfActive=function(t){this.sink.error(t,this.value)}}(q),function(){return C}),P=function(t){return t===C},C=new(function(){function t(){}return t.prototype.run=function(t,n){return s(H(t),n)},t}()),M=function(t,n){return new D(t,n)},D=function(){function t(t,n){this.time=t,this.value=n}return t.prototype.run=function(t,n){return o(this.time,function(t,n,e){return new R(t,n,e)}(B,this.value,t),n)},t}();function B(t,n,e){e.event(t,n),e.end(t)} /** @license MIT License (c) copyright 2010-2017 original author or authors */var F=function(t){return M(0,t)},U=function(){function t(){this.disposable=void 0,this.disposed=!1}return t.prototype.setDisposable=function(t){if(void 0!==this.disposable)throw new Error("setDisposable called more than once");this.disposable=t,this.disposed&&t.dispose()},t.prototype.dispose=function(){this.disposed||(this.disposed=!0,void 0!==this.disposable&&this.disposable.dispose())},t}(),W=e((function(t,n){return new Promise((function(e,r){return function(t,n,e,r){var i=new U,s=new J(e,r,i);i.setDisposable(t.run(s,n))}(t,n,e,r)}))}));var J=function(){function t(t,n,e){this._end=t,this._error=n,this._disposable=e,this.active=!0}return t.prototype.event=function(){},t.prototype.end=function(){this.active&&this.dispose(this._error,this._end,void 0)},t.prototype.error=function(t,n){this.dispose(this._error,this._error,n)},t.prototype.dispose=function(t,n,e){this.active=!1,function(t,n,e,r){try{r.dispose()}catch(n){return void t(n)}n(e)}(t,n,e,this._disposable)},t}();var L=function(){function t(t,n){this.sink=n,this.offset=t}return t.prototype.event=function(t,n){this.sink.event(t+this.offset,n)},t.prototype.error=function(t,n){this.sink.error(t+this.offset,n)},t.prototype.end=function(t){this.sink.end(t+this.offset)},t}(),K=function(){function t(t,n){this.origin=t,this.source=n}return t.prototype.run=function(t,n){return this.source.run(X(this.origin,t),c(this.origin,n))},t}(),X=function(t,n){return n instanceof L?new L(t+n.offset,n.sink):new L(t,n)},G=function(){function t(t){this.sink=t}return t.prototype.end=function(t){return this.sink.end(t)},t.prototype.error=function(t,n){return this.sink.error(t,n)},t}(),Q=(function(t){function n(n,e,r){var i=t.call(this,r)||this;return i.step=n,i.seed=e,i}S(n,t),n.prototype.event=function(t,n){var e=this.step(this.seed,n);this.seed=e.seed,this.sink.event(t,e.value)}}(G),function(){function t(t,n,e){this.source=e,this.f=t,this.value=n}return t.prototype.run=function(t,n){var e=s(I(this.value,t),n),r=this.source.run(new Y(this.f,this.value,t),n);return y(e,r)},t}()),Y=function(t){function n(n,e,r){var i=t.call(this,r)||this;return i.f=n,i.value=e,i}return S(n,t),n.prototype.event=function(t,n){var e=this.f;this.value=e(this.value,n),this.sink.event(t,this.value)},n}(G),Z=function(){function t(t,n){this.f=t,this.source=n}return t.prototype.run=function(t,n){return new $(this.f,this.source,t,n)},t}(),$=function(t){function n(n,e,r,i){var s=t.call(this,r)||this;return s.f=n,s.scheduler=i,s.active=!0,s.disposable=l(e.run(s,i)),s}return S(n,t),n.prototype.event=function(t,n){this.active&&this.sink.event(t,n)},n.prototype.end=function(t){this.active&&(x(t,this.disposable,this.sink),this.startNext(t,this.sink))},n.prototype.startNext=function(t,n){try{this.disposable=this.continue(this.f,t,n)}catch(e){n.error(t,e)}},n.prototype.continue=function(t,n,e){return function(t,n,e){return e.run(t,n)}(e,this.scheduler,(r=n,i=t(),new K(r,i)));var r,i},n.prototype.dispose=function(){return this.active=!1,this.disposable.dispose()},n}(G),tt=function(){function t(t,n){this.p=t,this.source=n}return t.prototype.run=function(t,n){return this.source.run(new nt(this.p,t),n)},t.create=function(n,e){return P(e)?e:e instanceof t?new t(et(e.p,n),e.source):new t(n,e)},t}(),nt=function(t){function n(n,e){var r=t.call(this,e)||this;return r.p=n,r}return S(n,t),n.prototype.event=function(t,n){(0,this.p)(n)&&this.sink.event(t,n)},n}(G),et=function(t,n){return function(e){return t(e)&&n(e)}},rt=function(){function t(t,n,e){this.p=t,this.f=n,this.source=e}return t.prototype.run=function(t,n){return this.source.run(new it(this.p,this.f,t),n)},t}(),it=function(t){function n(n,e,r){var i=t.call(this,r)||this;return i.p=n,i.f=e,i}return S(n,t),n.prototype.event=function(t,n){var e=this.f;(0,this.p)(n)&&this.sink.event(t,e(n))},n}(G),st=function(){function t(t,n){this.f=t,this.source=n}return t.prototype.run=function(t,n){return this.source.run(new ot(this.f,t),n)},t.create=function(n,e){return P(e)?N():e instanceof t?new t(function(t,n){return function(e){return t(n(e))}}(n,e.f),e.source):e instanceof tt?new rt(e.p,n,e.source):new t(n,e)},t}(),ot=function(t){function n(n,e){var r=t.call(this,e)||this;return r.f=n,r}return S(n,t),n.prototype.event=function(t,n){var e=this.f;this.sink.event(t,e(n))},n}(G),ut=function(){function t(t,n){this.source=n,this.f=t}return t.prototype.run=function(t,n){return this.source.run(new ct(this.f,t),n)},t}(),ct=function(t){function n(n,e){var r=t.call(this,e)||this;return r.f=n,r}return S(n,t),n.prototype.event=function(t,n){(0,this.f)(n),this.sink.event(t,n)},n}(G),ht=function(t){function n(n,e){var r=t.call(this,e)||this;return r.index=n,r.active=!0,r.value=void 0,r}return S(n,t),n.prototype.event=function(t,n){this.active&&(this.value=n,this.sink.event(t,this))},n.prototype.end=function(t){this.active&&(this.active=!1,this.sink.event(t,this))},n}(G); /** @license MIT License (c) copyright 2010-2016 original author or authors */ function ft(t,n){switch(n.length){case 0:return t();case 1:return t(n[0]);case 2:return t(n[0],n[1]);case 3:return t(n[0],n[1],n[2]);case 4:return t(n[0],n[1],n[2],n[3]);case 5:return t(n[0],n[1],n[2],n[3],n[4]);default:return t.apply(void 0,n)}}!function(t){function n(n,e,r,i){var s=t.call(this,r)||this;return s.disposables=n,s.f=i,s.awaiting=e,s.values=new Array(e),s.hasValue=new Array(e).fill(!1),s.activeCount=e,s}S(n,t),n.prototype.event=function(t,n){if(n.active){var e=n.index,r=this.updateReady(e);this.values[e]=n.value,0===r&&this.sink.event(t,ft(this.f,this.values))}else this.dispose(t,n.index)},n.prototype.updateReady=function(t){return this.awaiting>0&&(this.hasValue[t]||(this.hasValue[t]=!0,this.awaiting-=1)),this.awaiting},n.prototype.dispose=function(t,n){x(t,this.disposables[n],this.sink),0==--this.activeCount&&this.sink.end(t)}}(G); /** @license MIT License (c) copyright 2010 original author or authors */var at=function(t,n,e){return P(e)?N():new pt(t,n,e)},pt=function(){function t(t,n,e){this.f=t,this.concurrency=n,this.source=e}return t.prototype.run=function(t,n){return new lt(this.f,this.concurrency,this.source,t,n)},t}(),lt=function(){function t(t,n,e,r,i){this.f=t,this.concurrency=n,this.sink=r,this.scheduler=i,this.pending=[],this.current=[],this.disposable=l(e.run(this,i)),this.active=!0}return t.prototype.event=function(t,n){this.addInner(t,n)},t.prototype.addInner=function(t,n){this.current.length<this.concurrency?this.startInner(t,n):this.pending.push(n)},t.prototype.startInner=function(t,n){try{this.initInner(t,n)}catch(n){this.error(t,n)}},t.prototype.initInner=function(t,n){var e=new vt(t,this,this.sink);e.disposable=dt(this.f,t,n,e,this.scheduler),this.current.push(e)},t.prototype.end=function(t){this.active=!1,x(t,this.disposable,this.sink),this.checkEnd(t)},t.prototype.error=function(t,n){this.active=!1,this.sink.error(t,n)},t.prototype.dispose=function(){this.active=!1,this.pending.length=0,this.disposable.dispose(),v(this.current).dispose()},t.prototype.endInner=function(t,n){var e=this.current.indexOf(n);e>=0&&this.current.splice(e,1),x(t,n,this);var r=this.pending;r.length>0?this.startInner(t,r.shift()):this.checkEnd(t)},t.prototype.checkEnd=function(t){this.active||0!==this.current.length||this.sink.end(t)},t}(),dt=function(t,n,e,r,i){return t(e).run(r,c(n,i))},vt=function(){function t(t,n,e){this.time=t,this.outer=n,this.sink=e,this.disposable=a()}return t.prototype.event=function(t,n){this.sink.event(t+this.time,n)},t.prototype.end=function(t){this.outer.endInner(t+this.time,this)},t.prototype.error=function(t,n){this.outer.error(t+this.time,n)},t.prototype.dispose=function(){return this.disposable.dispose()},t}(),yt=function(t){return function(t,e){return at(n,t,e)}(1/0,t)};var mt=function(t){return gt(kt(t))},gt=function(t){return 0===t.length?N():1===t.length?t[0]:new _t(function(t,n,e){for(var r=n,i=0,s=e.length;i<s;++i)r=t(r,e[i],i);return r}(bt,[],t))},kt=function(t){return t.filter(wt)},wt=function(t){return!P(t)},bt=function(t,n){return t.concat(n instanceof _t?n.sources:n)},_t=function(){function t(t){this.sources=t}return t.prototype.run=function(t,n){for(var e=this.sources.length,r=new Array(e),i=new Array(e),s=new At(r,i,t),o=void 0,u=0;u<e;++u)o=i[u]=new ht(u,s),r[u]=this.sources[u].run(o,n);return v(r)},t}(),At=function(t){function n(n,e,r){var i=t.call(this,r)||this;return i.disposables=n,i.activeCount=e.length,i}return S(n,t),n.prototype.event=function(t,n){n.active?this.sink.event(t,n.value):this.dispose(t,n.index)},n.prototype.dispose=function(t,n){x(t,this.disposables[n],this.sink),0==--this.activeCount&&this.sink.end(t)},n}(G),Et=function(){function t(t,n,e){this.f=t,this.values=n,this.sampler=e}return t.prototype.run=function(t,n){var e=new Ot(this.f,t),r=this.values.run(e.latest,n),i=this.sampler.run(e,n);return y(i,r)},t}(),Ot=function(t){function n(n,e){var r=t.call(this,e)||this;return r.f=n,r.latest=new xt(r),r}return S(n,t),n.prototype.event=function(t,n){if(this.latest.hasValue){var e=this.f;this.sink.event(t,e(this.latest.value,n))}},n}(G),xt=function(t){function n(n){var e=t.call(this,n)||this;return e.hasValue=!1,e}return S(n,t),n.prototype.event=function(t,n){this.value=n,this.hasValue=!0},n.prototype.end=function(){},n}(G),Tt=(function(t){function n(n,e,r,i){var s=t.call(this,r)||this;return s.skip=n,s.take=e,s.disposable=i,s}S(n,t),n.prototype.event=function(t,n){this.skip>0?this.skip-=1:0!==this.take&&(this.take-=1,this.sink.event(t,n),0===this.take&&(this.disposable.dispose(),this.sink.end(t)))}}(G),function(t){function n(n,e,r){var i=t.call(this,e)||this;return i.p=n,i.active=!0,i.disposable=r,i}S(n,t),n.prototype.event=function(t,n){if(this.active){var e=this.p;this.active=e(n),this.active?this.sink.event(t,n):(this.disposable.dispose(),this.sink.end(t))}}}(G),function(t){function n(n,e){var r=t.call(this,e)||this;return r.p=n,r.skipping=!0,r}S(n,t),n.prototype.event=function(t,n){if(this.skipping){var e=this.p;if(this.skipping=e(n),this.skipping)return}this.sink.event(t,n)}}(G),function(){function t(t,n){this.p=t,this.source=n}return t.prototype.run=function(t,n){return this.source.run(new St(this.p,t),n)},t}()),St=function(t){function n(n,e){var r=t.call(this,e)||this;return r.p=n,r.skipping=!1,r}return S(n,t),n.prototype.event=function(t,n){if(!this.skipping){var e=this.p;this.skipping=e(n),this.sink.event(t,n),this.skipping&&this.sink.end(t)}},n}(G),jt=(function(t){function n(n,e,r){var i=t.call(this,r)||this;return i.f=n,i.items=e,i.index=0,i}S(n,t),n.prototype.event=function(t,n){var e=this.f;this.sink.event(t,e(this.items[this.index],n)),this.index+=1}}(G),function(t){function n(n,e,r,i){var s=t.call(this,i)||this;return s.f=n,s.sinks=r,s.buffers=e,s}S(n,t),n.prototype.event=function(t,n){if(n.active){var e=this.buffers,r=e[n.index];if(r.push(n.value),1===r.length()){if(!function(t){for(var n=0,e=t.length;n<e;++n)if(t[n].isEmpty())return!1;return!0} /** @license MIT License (c) copyright 2010-2016 original author or authors */(e))return;jt(this.f,t,e,this.sink),function(t,n){for(var e=0,r=t.length;e<r;++e)if(t[e].isEmpty()&&!n[e].active)return!0;return!1}(this.buffers,this.sinks)&&this.sink.end(t)}}else this.dispose(t,n.index)},n.prototype.dispose=function(t,n){this.buffers[n].isEmpty()&&this.sink.end(t)}}(G),function(t,n,e,r){return r.event(n,ft(t,function(t,n){for(var e=n.length,r=new Array(e),i=0;i<e;++i)r[i]=t(n[i]);return r}(It,e)))}),It=function(t){return t.shift()};var Ht=function(t){return P(t)?N():new qt(t)},qt=function(){function t(t){this.source=t}return t.prototype.run=function(t,n){var e=new Rt(t,n);return y(e,this.source.run(e,n))},t}(),Rt=function(){function t(t,n){this.sink=t,this.scheduler=n,this.current=null,this.ended=!1}return t.prototype.event=function(t,n){this.disposeCurrent(t),this.current=new Vt(n,t,1/0,this,this.sink,this.scheduler)},t.prototype.end=function(t){this.ended=!0,this.checkEnd(t)},t.prototype.error=function(t,n){this.ended=!0,this.sink.error(t,n)},t.prototype.dispose=function(){return this.disposeCurrent(this.scheduler.currentTime())},t.prototype.disposeCurrent=function(t){if(null!==this.current)return this.current.dispose(t)},t.prototype.disposeInner=function(t,n){n.dispose(t),n===this.current&&(this.current=null)},t.prototype.checkEnd=function(t){this.ended&&null===this.current&&this.sink.end(t)},t.prototype.endInner=function(t,n){this.disposeInner(t,n),this.checkEnd(t)},t.prototype.errorInner=function(t,n,e){this.disposeInner(t,e),this.sink.error(t,n)},t}(),Vt=function(){function t(t,n,e,r,i,s){this.min=n,this.max=e,this.outer=r,this.sink=i,this.disposable=t.run(this,c(n,s))}return t.prototype.event=function(t,n){var e=Math.max(0,t+this.min);e<this.max&&this.sink.event(e,n)},t.prototype.end=function(t){this.outer.endInner(t+this.min,this)},t.prototype.error=function(t,n){this.outer.errorInner(t+this.min,n,this)},t.prototype.dispose=function(t){x(t,this.disposable,this.sink)},t}();var zt=function(t){return Nt(Mt,t)},Nt=function(t,n){return P(n)?N():new Pt(t,n)},Pt=function(){function t(t,n){this.equals=t,this.source=n}return t.prototype.run=function(t,n){return this.source.run(new Ct(this.equals,t),n)},t}(),Ct=function(t){function n(n,e){var r=t.call(this,e)||this;return r.equals=n,r.value=void 0,r.init=!0,r}return S(n,t),n.prototype.event=function(t,n){this.init?(this.init=!1,this.value=n,this.sink.event(t,n)):this.equals(this.value,n)||(this.value=n,this.sink.event(t,n))},n}(G);function Mt(t,n){return t===n} /** @license MIT License (c) copyright 2010-2016 original author or authors */var Dt=function(){function t(t,n){this.maxSignal=t,this.source=n}return t.prototype.run=function(t,n){var e=new U,r=this.source.run(t,n),i=this.maxSignal.run(new Bt(t,e),n);return e.setDisposable(y(r,i)),e},t}(),Bt=(function(t){function n(n,e){var r=t.call(this,e)||this;return r.min=n,r}S(n,t),n.prototype.event=function(t,n){this.min.allow&&this.sink.event(t,n)}}(G),function(t){function n(n,e,r){var i=t.call(this,e)||this;return i.allow=!1,i.disposable=n.run(i,r),i}S(n,t),n.prototype.event=function(){this.allow=!0,this.dispose()},n.prototype.end=function(){},n.prototype.dispose=function(){this.disposable.dispose()}}(G),function(t){function n(n,e){var r=t.call(this,n)||this;return r.disposable=e,r}return S(n,t),n.prototype.event=function(t){this.disposable.dispose(),this.sink.end(t)},n.prototype.end=function(){},n}(G)),Ft=function(){function t(t,n){this.dt=t,this.source=n}return t.prototype.run=function(t,n){var e=new Ut(this.dt,t,n);return y(e,this.source.run(e,n))},t}(),Ut=function(t){function n(n,e,r){var i=t.call(this,e)||this;return i.dt=n,i.scheduler=r,i.tasks=[],i}return S(n,t),n.prototype.dispose=function(){this.tasks.forEach(u)},n.prototype.event=function(t,n){this.tasks.push(o(this.dt,I(n,this.sink),this.scheduler))},n.prototype.end=function(){this.tasks.push(o(this.dt,H(this.sink),this.scheduler))},n}(G),Wt=(function(t){function n(n,e){var r=t.call(this,e)||this;return r.time=0,r.period=n,r}S(n,t),n.prototype.event=function(t,n){t>=this.time&&(this.time=t+this.period,this.sink.event(t,n))}}(G),function(){function t(t,n){this.dt=t,this.source=n}return t.prototype.run=function(t,n){return new Jt(this.dt,this.source,t,n)},t}()),Jt=function(){function t(t,n,e,r){this.dt=t,this.sink=e,this.scheduler=r,this.timer=null,this.disposable=n.run(this,r)}return t.prototype.event=function(t,n){this.clearTimer(),this.value=n,this.timer=o(this.dt,new Lt(this,n),this.scheduler)},t.prototype.handleEventFromTask=function(t,n){this.clearTimer(),this.sink.event(t,n)},t.prototype.end=function(t){this.clearTimer()&&(this.sink.event(t,this.value),this.value=void 0),this.sink.end(t)},t.prototype.error=function(t,n){this.clearTimer(),this.sink.error(t,n)},t.prototype.dispose=function(){this.clearTimer(),this.disposable.dispose()},t.prototype.clearTimer=function(){return null!==this.timer&&(this.timer.dispose(),this.timer=null,!0)},t}(),Lt=function(){function t(t,n){this.sink=t,this.value=n}return t.prototype.run=function(t){this.sink.handleEventFromTask(t,this.value)},t.prototype.error=function(t,n){this.sink.error(t,n)},t.prototype.dispose=function(){},t}(); /** @license MIT License (c) copyright 2010-2016 original author or authors */ function Kt(t,n,e){try{e.event(t,n)}catch(n){e.error(t,n)}}function Xt(t,n){try{n.end(t)}catch(e){n.error(t,e)}}var Gt=function(t){return t instanceof Qt||P(t)?t:new Qt(t)},Qt=function(){function t(t){this.source=new Yt(t)}return t.prototype.run=function(t,n){return this.source.run(t,n)},t}(),Yt=function(){function n(t){this.source=t,this.sinks=[],this.disposable=a()}return n.prototype.run=function(t,n){return 1===this.add(t)&&(this.disposable=this.source.run(this,n)),l(new Zt(this,t))},n.prototype.dispose=function(){var t=this.disposable;return this.disposable=a(),t.dispose()},n.prototype.add=function(t){return this.sinks=function(t,n){for(var e=n.length,r=new Array(e+1),i=0;i<e;++i)r[i]=n[i];return r[e]=t,r}(t,this.sinks),this.sinks.length},n.prototype.remove=function(n){var e=function(t,n){for(var e=0,r=n.length;e<r;++e)if(t===n[e])return e;return-1}(n,this.sinks);return e>=0&&(this.sinks=t(e,this.sinks)),this.sinks.length},n.prototype.event=function(t,n){var e=this.sinks;if(1===e.length)return e[0].event(t,n);for(var r=0;r<e.length;++r)Kt(t,n,e[r])},n.prototype.end=function(t){for(var n=this.sinks,e=0;e<n.length;++e)Xt(t,n[e])},n.prototype.error=function(t,n){for(var e=this.sinks,r=0;r<e.length;++r)e[r].error(t,n)},n}(),Zt=function(){function t(t,n){this.source=t,this.sink=n}return t.prototype.dispose=function(){0===this.source.remove(this.sink)&&this.source.dispose()},t}(),$t=r((function(t,n,e){return new Q(t,n,e)})),tn=e((function(t,n){return function(t,n){return new Z(t,n)}((function(){return n}),F(t))})),nn=e((function(t,n){return st.create(t,n)})),en=e((function(t,n){return new ut(t,n)})),rn=e(( /** @license MIT License (c) copyright 2010-2016 original author or authors */ function(t,n){return mt([t,n])})),sn=r((function(t,n,e){return P(e)||P(n)?N():new Et(t,n,e)})),on=e(( /** @license MIT License (c) copyright 2010-2016 original author or authors */ function(t,n){return tt.create(t,n)})),un=e((function(t,n){return P(n)?N():new Tt(t,n)})),cn=e((function(t,n){return new Dt(t,n)})),hn=e((function(t,n){return t<=0?n:new Ft(t,n)})),fn=e((function(t,n){return P(n)?N():new Wt(t,n)}));var an=function(){function t(t,n,e,r,i){this.time=t,this.localOffset=n,this.period=e,this.task=r,this.scheduler=i,this.active=!0}return t.prototype.run=function(){return this.task.run(this.time-this.localOffset)},t.prototype.error=function(t){return this.task.error(this.time-this.localOffset,t)},t.prototype.dispose=function(){return this.active=!1,this.scheduler.cancel(this),this.task.dispose()},t}(),pn=function(){function t(t,n){this.origin=t,this.scheduler=n}return t.prototype.currentTime=function(){return this.scheduler.currentTime()-this.origin},t.prototype.scheduleTask=function(t,n,e,r){return this.scheduler.scheduleTask(t+this.origin,n,e,r)},t.prototype.relative=function(n){return new t(n+this.origin,this.scheduler)},t.prototype.cancel=function(t){return this.scheduler.cancel(t)},t.prototype.cancelAll=function(t){return this.scheduler.cancelAll(t)},t}(),ln=function(t){return Promise.resolve(t).then(dn)};function dn(t){try{return t.run()}catch(n){return t.error(n)}} /** @license MIT License (c) copyright 2010-2017 original author or authors */var vn=function(){function t(t,n){var e=this;this._runReadyTasksBound=function(){return e._runReadyTasks()},this.timer=t,this.timeline=n,this._timer=null,this._nextArrival=1/0}return t.prototype.currentTime=function(){return this.timer.now()},t.prototype.scheduleTask=function(t,n,e,r){var i=this.currentTime()+Math.max(0,n),s=new an(i,t,e,r,this);return this.timeline.add(s),this._scheduleNextRun(),s},t.prototype.relative=function(t){return new pn(t,this)},t.prototype.cancel=function(t){t.active=!1,this.timeline.remove(t)&&this._reschedule()},t.prototype.cancelAll=function(t){this.timeline.removeAll(t),this._reschedule()},t.prototype._reschedule=function(){this.timeline.isEmpty()?this._unschedule():this._scheduleNextRun()},t.prototype._unschedule=function(){this.timer.clearTimer(this._timer),this._timer=null},t.prototype._scheduleNextRun=function(){if(!this.timeline.isEmpty()){var t=this.timeline.nextArrival();null===this._timer?this._scheduleNextArrival(t):t<this._nextArrival&&(this._unschedule(),this._scheduleNextArrival(t))}},t.prototype._scheduleNextArrival=function(t){this._nextArrival=t;var n=Math.max(0,t-this.currentTime());this._timer=this.timer.setTimer(this._runReadyTasksBound,n)},t.prototype._runReadyTasks=function(){this._timer=null,this.timeline.runTasks(this.currentTime(),dn),this._scheduleNextRun()},t}(),yn=function(){function t(){this.tasks=[]}return t.prototype.nextArrival=function(){return this.isEmpty()?1/0:this.tasks[0].time},t.prototype.isEmpty=function(){return 0===this.tasks.length},t.prototype.add=function(t){gn(t,this.tasks)},t.prototype.remove=function(t){var n=bn(kn(t),this.tasks);if(n>=0&&n<this.tasks.length){var e=this.tasks[n].events,r=function(t,n){for(var e=0,r=n.length;e<r;++e)if(t===n[e])return e;return-1}(t,e);if(r>=0)return e.splice(r,1),0===e.length&&this.tasks.splice(n,1),!0}return!1},t.prototype.removeAll=function(t){for(var n=0;n<this.tasks.length;++n)wn(t,this.tasks[n])},t.prototype.runTasks=function(t,n){for(var e=this.tasks,r=e.length,i=0;i<r&&e[i].time<=t;)++i;this.tasks=e.slice(i);for(var s=0;s<i;++s)this.tasks=mn(n,e[s].events,this.tasks)},t}(); /** @license MIT License (c) copyright 2010-2017 original author or authors */function mn(t,n,e){for(var r=0;r<n.length;++r){var i=n[r];i.active&&(t(i),i.period>=0&&i.active&&(i.time=i.time+i.period,gn(i,e)))}return e}function gn(t,n){var e=n.length,r=kn(t);if(0!==e){var i=bn(r,n);i>=e?n.push(_n(r,[t])):function(t,n,e,r){var i=n[r];e===i.time?function(t,n){0===n.length||t.time>=n[n.length-1].time?n.push(t):function(t,n){for(var e=0;e<n.length;e++)if(t.time<n[e].time){n.splice(e,0,t);break}}(t,n)}(t,i.events):n.splice(r,0,_n(e,[t]))}(t,n,r,i)}else n.push(_n(r,[t]))}function kn(t){return Math.floor(t.time)}function wn(t,n){n.events= /** @license MIT License (c) copyright 2010-2016 original author or authors */ function(t,n){for(var e=n.length,r=new Array(e),i=0,s=void 0,o=0;o<e;++o)t(s=n[o])||(r[i]=s,++i);return r.length=i,r}(t,n.events)}function bn(t,n){for(var e,r,i=0,s=n.length;i<s;){if(t===(r=n[e=Math.floor((i+s)/2)]).time)return e;t<r.time?s=e:i=e+1}return s}var _n=function(t,n){return{time:t,events:n}},An=function(){function t(t){this._clock=t}return t.prototype.now=function(){return this._clock.now()},t.prototype.setTimer=function(t,n){return n<=0?function(t){var n=new En(t);return ln(n),n}(t):setTimeout(t,n)},t.prototype.clearTimer=function(t){return t instanceof En?t.cancel():clearTimeout(t)},t}(),En=function(){function t(t){this.f=t,this.active=!0}return t.prototype.run=function(){if(this.active)return this.f()},t.prototype.error=function(t){throw t},t.prototype.cancel=function(){this.active=!1},t}(); /** @license MIT License (c) copyright 2010-2017 original author or authors */var On=function(){function t(t,n){this.origin=n,this.clock=t}return t.prototype.now=function(){return this.clock.now()-this.origin},t}(),xn=function(){function t(t,n){this.origin=n,this.hrtime=t}return t.prototype.now=function(){var t=this.hrtime(this.origin);return(1e9*t[0]+t[1])/1e6},t}(),Tn=function(t){return new On(t,t.now())},Sn=function(){return"undefined"!=typeof performance&&"function"==typeof performance.now?Tn(performance):"undefined"!=typeof process&&"function"==typeof process.hrtime?new xn(process.hrtime,process.hrtime()):Tn(Date)},jn=function(){return new vn(In(),new yn)},In=function(){return new An(Sn())},Hn=function(t,n,e){return void 0===e&&(e=!1),new Pn(t,n,e)},qn=function(t,n){return void 0===n&&(n=!1),Hn("focusin",t,n)},Rn=function(t,n){return void 0===n&&(n=!1),Hn("focusout",t,n)},Vn=function(t,n){return void 0===n&&(n=!1),Hn("change",t,n)},zn=function(t,n){return void 0===n&&(n=!1),Hn("resize",t,n)},Nn=function(t,n){return void 0===n&&(n=!1),Hn("scroll",t,n)},Pn=function(t,n,e){this.event=t,this.node=n,this.capture=e};Pn.prototype.run=function(t,n){var e=this,r=function(e){return function(t,n,e){try{e.event(t,n)}catch(n){e.error(t,n)}}(n.currentTime(),e,t)};return this.node.addEventListener(this.event,r,this.capture),{dispose:function(){return e.node.removeEventListener(e.event,r,e.capture)}}};var Cn=function(){var t=[];return[function(n){return Mn(t,n)},new Dn(t)]},Mn=function(t,n){return t.forEach((function(t){var e=t.sink;return function(t,n,e){try{e.event(t,n)}catch(n){e.error(t,n)}}(t.scheduler.currentTime(),n,e)}))},Dn=function(){function t(t){this.sinks=t}return t.prototype.run=function(t,n){var e={sink:t,scheduler:n};return this.sinks.push(e),new Bn(e,this.sinks)},t}(),Bn=function(){function t(t,n){this.sink=t,this.sinks=n}return t.prototype.dispose=function(){var t=this.sinks.indexOf(this.sink);t>=0&&this.sinks.splice(t,1)},t}();function Fn(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function Un(t){return function n(e){return 0===arguments.length||Fn(e)?n:t.apply(this,arguments)}}function Wn(t){return function n(e,r){switch(arguments.length){case 0:return n;case 1:return Fn(e)?n:Un((function(n){return t(e,n)}));default:return Fn(e)&&Fn(r)?n:Fn(e)?Un((function(n){return t(n,r)})):Fn(r)?Un((function(n){return t(e,n)})):t(e,r)}}}function Jn(t,n){switch(t){case 0:return function(){return n.apply(this,arguments)};case 1:return function(t){return n.apply(this,arguments)};case 2:return function(t,e){return n.apply(this,arguments)};case 3:return function(t,e,r){return n.apply(this,arguments)};case 4:return function(t,e,r,i){return n.apply(this,arguments)};case 5:return function(t,e,r,i,s){return n.apply(this,arguments)};case 6:return function(t,e,r,i,s,o){return n.apply(this,arguments)};case 7:return function(t,e,r,i,s,o,u){return n.apply(this,arguments)};case 8:return function(t,e,r,i,s,o,u,c){return n.apply(this,arguments)};case 9:return function(t,e,r,i,s,o,u,c,h){return n.apply(this,arguments)};case 10:return function(t,e,r,i,s,o,u,c,h,f){return n.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}var Ln=Wn((function(t,n){return 1===t?Un(n):Jn(t,function t(n,e,r){return function(){for(var i=[],s=0,o=n,u=0;u<e.length||s<arguments.length;){var c;u<e.length&&(!Fn(e[u])||s>=arguments.length)?c=e[u]:(c=arguments[s],s+=1),i[u]=c,Fn(c)||(o-=1),u+=1}return o<=0?r.apply(this,i):Jn(o,t(n,i,r))}}(t,[],n))}));function Kn(t){return function n(e,r,i){switch(arguments.length){case 0:return n;case 1:return Fn(e)?n:Wn((function(n,r){return t(e,n,r)}));case 2:return Fn(e)&&Fn(r)?n:Fn(e)?Wn((function(n,e){return t(n,r,e)})):Fn(r)?Wn((function(n,r){return t(e,n,r)})):Un((function(n){return t(e,r,n)}));default:return Fn(e)&&Fn(r)&&Fn(i)?n:Fn(e)&&Fn(r)?Wn((function(n,e){return t(n,e,i)})):Fn(e)&&Fn(i)?Wn((function(n,e){return t(n,r,e)})):Fn(r)&&Fn(i)?Wn((function(n,r){return t(e,n,r)})):Fn(e)?Un((function(n){return t(n,r,i)})):Fn(r)?Un((function(n){return t(e,n,i)})):Fn(i)?Un((function(n){return t(e,r,n)})):t(e,r,i)}}}var Xn=Array.isArray||function(t){return null!=t&&t.length>=0&&"[object Array]"===Object.prototype.toString.call(t)};function Gn(t){return"[object String]"===Object.prototype.toString.call(t)}var Qn=Un((function(t){return!!Xn(t)||!!t&&("object"==typeof t&&(!Gn(t)&&(1===t.nodeType?!!t.length:0===t.length||t.length>0&&(t.hasOwnProperty(0)&&t.hasOwnProperty(t.length-1)))))})),Yn=function(){function t(t){this.f=t}return t.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},t.prototype["@@transducer/result"]=function(t){return t},t.prototype["@@transducer/step"]=function(t,n){return this.f(t,n)},t}();var Zn=Wn((function(t,n){return Jn(t.length,(function(){return t.apply(n,arguments)}))}));function $n(t,n,e){for(var r=e.next();!r.done;){if((n=t["@@transducer/step"](n,r.value))&&n["@@transducer/reduced"]){n=n["@@transducer/value"];break}r=e.next()}return t["@@transducer/result"](n)}function te(t,n,e,r){return t["@@transducer/result"](e[r](Zn(t["@@transducer/step"],t),n))}var ne="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";function ee(t,n,e){if("function"==typeof t&&(t=function(t){return new Yn(t)}(t)),Qn(e))return function(t,n,e){for(var r=0,i=e.length;r<i;){if((n=t["@@transducer/step"](n,e[r]))&&n["@@transducer/reduced"]){n=n["@@transducer/value"];break}r+=1}return t["@@transducer/result"](n)}(t,n,e);if("function"==typeof e["fantasy-land/reduce"])return te(t,n,e,"fantasy-land/reduce");if(null!=e[ne])return $n(t,n,e[ne]());if("function"==typeof e.next)return $n(t,n,e);if("function"==typeof e.reduce)return te(t,n,e,"reduce");throw new TypeError("reduce: list must be array or iterable")}function re(t,n){return Object.prototype.hasOwnProperty.call(n,t)}var ie=Object.prototype.toString,se=function(){return"[object Arguments]"===ie.call(arguments)?function(t){return"[object Arguments]"===ie.call(t)}:function(t){return re("callee",t)}}(),oe=!{toString:null}.propertyIsEnumerable("toString"),ue=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],ce=function(){return arguments.propertyIsEnumerable("length")}(),he=function(t,n){for(var e=0;e<t.length;){if(t[e]===n)return!0;e+=1}return!1},fe="function"!=typeof Object.keys||ce?Un((function(t){if(Object(t)!==t)return[];var n,e,r=[],i=ce&&se(t);for(n in t)!re(n,t)||i&&"length"===n||(r[r.length]=n);if(oe)for(e=ue.length-1;e>=0;)re(n=ue[e],t)&&!he(r,n)&&(r[r.length]=n),e-=1;return r})):Un((function(t){return Object(t)!==t?[]:Object.keys(t)})),ae=Kn(ee),pe=Un((function(t){return function(){return t}})),le=Wn((function(t,n){return n(t)})),de=Kn((function(t,n,e){var r={};for(var i in e)r[i]=e[i];return r[t]=n,r})),ve=Un((function(t){return Ln(t.length,t)})),ye=Un((function(t){return null===t?"Null":void 0===t?"Undefined":Object.prototype.toString.call(t).slice(8,-1)}));function me(t,n){return function(){return n.call(this,t.apply(this,arguments))}}function ge(t,n){return function(){var e=arguments.length;if(0===e)return n();var r=arguments[e-1];return Xn(r)||"function"!=typeof r[t]?n.apply(this,arguments):r[t].apply(r,Array.prototype.slice.call(arguments,0,e-1))}}var ke=Un(ge("tail",Kn(ge("slice",(function(t,n,e){return Array.prototype.slice.call(e,t,n)})))(1,1/0)));function we(){if(0===arguments.length)throw new Error("pipe requires at least one argument");return Jn(arguments[0].length,ae(me,arguments[0],ke(arguments)))}var be=Un((function(t){return Gn(t)?t.split("").reverse().join(""):Array.prototype.slice.call(t,0).reverse()}));function _e(){if(0===arguments.length)throw new Error("compose requires at least one argument");return we.apply(this,be(arguments))}function Ae(t){for(var n,e=[];!(n=t.next()).done;)e.push(n.value);return e}function Ee(t,n,e){for(var r=0,i=e.length;r<i;){if(t(n,e[r]))return!0;r+=1}return!1}var Oe="function"==typeof Object.is?Object.is:function(t,n){return t===n?0!==t||1/t==1/n:t!=t&&n!=n};function xe(t,n,e,r){var i=Ae(t);function s(t,n){return Te(t,n,e.slice(),r.slice())}return!Ee((function(t,n){return!Ee(s,n,t)}),Ae(n),i)}function Te(t,n,e,r){if(Oe(t,n))return!0;var i=ye(t);if(i!==ye(n))return!1;if(null==t||null==n)return!1;if("function"==typeof t["fantasy-land/equals"]||"function"==typeof n["fantasy-land/equals"])return"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](n)&&"function"==typeof n["fantasy-land/equals"]&&n["fantasy-land/equals"](t);if("function"==typeof t.equals||"function"==typeof n.equals)return"function"==typeof t.equals&&t.equals(n)&&"function"==typeof n.equals&&n.equals(t);switch(i){case"Arguments":case"Array":case"Object":if("function"==typeof t.constructor&&"Promise"===function(t){var n=String(t).match(/^function (\w*)/);return null==n?"":n[1]}(t.constructor))return t===n;break;case"Boolean":case"Number":case"String":if(typeof t!=typeof n||!Oe(t.valueOf(),n.valueOf()))return!1;break;case"Date":if(!Oe(t.valueOf(),n.valueOf()))return!1;break;case"Error":return t.name===n.name&&t.message===n.message;case"RegExp":if(t.source!==n.source||t.global!==n.global||t.ignoreCase!==n.ignoreCase||t.multiline!==n.multiline||t.sticky!==n.sticky||t.unicode!==n.unicode)return!1}for(var s=e.length-1;s>=0;){if(e[s]===t)return r[s]===n;s-=1}switch(i){case"Map":return t.size===n.size&&xe(t.entries(),n.entries(),e.concat([t]),r.concat([n]));case"Set":return t.size===n.size&&xe(t.values(),n.values(),e.concat([t]),r.concat([n]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var o=fe(t);if(o.length!==fe(n).length)return!1;var u=e.concat([t]),c=r.concat([n]);for(s=o.length-1;s>=0;){var h=o[s];if(!re(h,n)||!Te(n[h],t[h],u,c))return!1;s-=1}return!0}var Se=Wn((function(t,n){return Te(t,n,[],[])}));function je(t,n){return function(t,n,e){var r,i;if("function"==typeof t.indexOf)switch(typeof n){case"number":if(0===n){for(r=1/n;e<t.length;){if(0===(i=t[e])&&1/i===r)return e;e+=1}return-1}if(n!=n){for(;e<t.length;){if("number"==typeof(i=t[e])&&i!=i)return e;e+=1}return-1}return t.indexOf(n,e);case"string":case"boolean":case"function":case"undefined":return t.indexOf(n,e);case"object":if(null===n)return t.indexOf(n,e)}for(;e<t.length;){if(Se(t[e],n))return e;e+=1}return-1}(n,t,0)>=0}var Ie=function(){function t(){this._nativeSet="function"==typeof Set?new Set:null,this._items={}}return t.prototype.add=function(t){return!He(t,!0,this)},t.prototype.has=function(t){return He(t,!1,this)},t}();function He(t,n,e){var r,i=typeof t;switch(i){case"string":case"number":return 0===t&&1/t==-1/0?!!e._items["-0"]||(n&&(e._items["-0"]=!0),!1):null!==e._nativeSet?n?(r=e._nativeSet.size,e._nativeSet.add(t),e._nativeSet.size===r):e._nativeSet.has(t):i in e._items?t in e._items[i]||(n&&(e._items[i][t]=!0),!1):(n&&(e._items[i]={},e._items[i][t]=!0),!1);case"boolean":if(i in e._items){var s=t?1:0;return!!e._items[i][s]||(n&&(e._items[i][s]=!0),!1)}return n&&(e._items[i]=t?[!1,!0]:[!0,!1]),!1;case"function":return null!==e._nativeSet?n?(r=e._nativeSet.size,e._nativeSet.add(t),e._nativeSet.size===r):e._nativeSet.has(t):i in e._items?!!je(t,e._items[i])||(n&&e._items[i].push(t),!1):(n&&(e._items[i]=[t]),!1);case"undefined":return!!e._items[i]||(n&&(e._items[i]=!0),!1);case"object":if(null===t)return!!e._items.null||(n&&(e._items.null=!0),!1);default:return(i=Object.prototype.toString.call(t))in e._items?!!je(t,e._items[i])||(n&&e._items[i].push(t),!1):(n&&(e._items[i]=[t]),!1)}}var qe=Wn((function(t,n){for(var e=[],r=0,i=t.length,s=n.length,o=new Ie,u=0;u<s;u+=1)o.add(n[u]);for(;r<i;)o.add(t[r])&&(e[e.length]=t[r]),r+=1;return e})),Re=Un((function(t){return null!=t&&"function"==typeof t["fantasy-land/empty"]?t["fantasy-land/empty"]():null!=t&&null!=t.constructor&&"function"==typeof t.constructor["fantasy-land/empty"]?t.constructor["fantasy-land/empty"]():null!=t&&"function"==typeof t.empty?t.empty():null!=t&&null!=t.constructor&&"function"==typeof t.constructor.empty?t.constructor.empty():Xn(t)?[]:Gn(t)?"":function(t){return"[object Object]"===Object.prototype.toString.call(t)}(t)?{}:se(t)?function(){return arguments}():void 0})),Ve=Wn(Oe),ze=Un((function(t){return null!=t&&Se(t,Re(t))})),Ne=Kn((function(t,n,e){return Se(n,e[t])}));const Pe="visualViewport"in window;function Ce(){return Pe}const Me=navigator.userAgent,De="ontouchend"in document,Be=/\b(\w*Macintosh\w*)\b/.test(Me)&&De,Fe=/\b(\w*iPhone\w*)\b/.test(Me)&&/\b(\w*Mobile\w*)\b/.test(Me)&&De,Ue=Be||Fe,We=()=>screen.orientation.type.startsWith("portrait")?"portrait":"landscape",Je=ve(_e(yt,sn((t,n)=>t?N():F(n)))),Le=()=>document.activeElement&&document.activeElement!==document.body;function Ke(){return Ue?Ce():De}function Xe(t){if(Ue)return function(t){if(!Ce())return console.warn("On-Screen-Keyboard detection not supported on this version of iOS"),()=>void 0;const[n,e]=Cn(),r=jn(),i=we(()=>mt([Nn(visualViewport),zn(visualViewport),Nn(window)]),fn(800),en(()=>{console.log(visualViewport.height*visualViewport.scale/document.documentElement.clientHeight)}),nn(()=>visualViewport.height*visualViewport.scale/document.documentElement.clientHeight<.85),zt,nn(t=>t?"visible":"hidden"),cn(e))();return W(en(t,i),r),n}(t);const n=Math.max(700,700)-500+200,[e,r]=Cn(),i=jn(),s=window.innerHeight,o=screen.availHeight-window.innerHeight,u=rn(qn(document.documentElement),Rn(document.documentElement)),c=le(Hn("visibilitychange",document))(we(nn(()=>document.visibilityState),tn(document.visibilityState))),h=le(u)(we(nn(t=>"focusin"===t.type?F(!1):M(700,!0)),Ht,tn(!Le()),zt,Gt)),f=le(Vn(screen.orientation))(we(sn(t=>t||window.innerHeight===s,h),fn(700),nn(t=>({screenOrientation:We(),height:t?window.innerHeight:screen.availHeight-o})))),a=le(h)(we(on(Ve(!0)),nn(()=>({screenOrientation:We(),height:window.innerHeight})))),p=le(mt([a,f]))(we(hn(1e3),Je(nn(Se("hidden"),c)),$t((t,{screenOrientation:n,height:e})=>de(n,e,t),{[We()]:window.innerHeight}),un(_e(ze,qe(["portrait","landscape"]),fe)))),l=le(zn(window))(we(fn(500),nn(t=>({width:t.target.innerWidth,height:t.target.innerHeight})),$t((t,n)=>({...n,isJustHeightResize:t.width===n.width,dH:n.height-t.height}),{width:window.innerWidth,height:window.innerHeight,isJustHeightResize:!1,dH:0}),on(Ne("isJustHeightResize",!0)))),d=le(l)(we(hn(n),sn((t,{height:n,dH:e})=>{const r=t[We()];return r?n<.9*r&&e<0?F("visible"):n===r&&e>0?F("hidden"):N():e>.1*screen.availHeight?F("hidden"):e<-.1*screen.availHeight?F("visible"):N()},p),yt,rn(le(h)(we(on(Ve(!0)),nn(pe("hidden"))))),cn(r),zt));return W(en(t,d),i),e}export{Ke as isSupported,Xe as subscribe};