; (self.AMP=self.AMP||[]).push({m:0,v:"2601162341000",n:"amp-install-serviceworker",ev:"0.1",l:!0,f:function(t,n){!function(){function n(t,r){return(n=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t})(t,r)}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,n){if(n&&("object"===e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}var o=Object.prototype;function u(t,n){void 0===n&&(n=t.hasAttribute("hidden")),n?t.removeAttribute("hidden"):t.setAttribute("hidden","")}o.hasOwnProperty,o.toString;var c=/(?:^[#?]?|&)([^=&]+)(?:=([^&]*))?/g;function a(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";try{return decodeURIComponent(t)}catch(t){return n}}function f(t){var n=(t||self).location;return function(t){var n,r=Object.create(null);if(!t)return r;for(;n=c.exec(t);){var e=a(n[1],n[1]),i=n[2]?a(n[2].replace(/\+/g," "),n[2]):"";r[e]=i}return r}(n.originalHash||n.hash)}var s="";function l(t){var n;return s||(s=(null===(n=t.AMP_CONFIG)||void 0===n?void 0:n.v)||"01".concat("2601162341000")),s}function h(t,n){var r=n||f(t);return["1","actions","amp","amp4ads","amp4email"].includes(r.development)||!!t.AMP_DEV_MODE}self.__AMP_LOG=self.__AMP_LOG||{user:null,dev:null,userForEmbed:null};var v=self.__AMP_LOG;function d(t){return v.user||(v.user=p()),function(t,n){return n&&n.ownerDocument.defaultView!=t}(v.user.win,t)?v.userForEmbed||(v.userForEmbed=p()):v.user}function p(t){return function(t,n){throw new Error("failed to call initLogConstructor")}()}function m(t,n,r,e,i,o,u,c,a,f,s){return t}function b(t,n,r,e,i,o,u,c,a,f,s){return d().assert(t,n,r,e,i,o,u,c,a,f,s)}function y(t,n){return g(t=function(t){return t.__AMP_TOP||(t.__AMP_TOP=t)}(t),n)}function w(t){return t.nodeType?(r=t,n=(r.ownerDocument||r).defaultView,y(n,"ampdoc")).getAmpDoc(t):t;var n,r}function k(t){var n=w(t);return n.isSingleDoc()?n.win:n}function g(t,n){m(S(t,n));var r=function(t){var n=t.__AMP_SERVICES;return n||(n=t.__AMP_SERVICES={}),n}(t)[n];return r.obj||(m(r.ctor),m(r.context),r.obj=new r.ctor(r.context),m(r.obj),r.context=null,r.resolve&&r.resolve(r.obj)),r.obj}function S(t,n){var r=t.__AMP_SERVICES&&t.__AMP_SERVICES[n];return!(!r||!r.ctor)}var R,j=function(t){return"url",S(n=k(w(t)),"url")?g(n,"url"):null;var n};function I(t){var n=t.indexOf("#");return-1==n?t:t.substring(0,n)}var O=function(){return self.AMP.config.urls}(),E="amp-install-serviceworker",x=function(t){!function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),r&&n(t,r)}(a,t);var e,o,c=(e=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,n=r(e);if(o){var u=r(this).constructor;t=Reflect.construct(n,arguments,u)}else t=n.apply(this,arguments);return i(this,t)});function a(t){var n,r;return(n=c.call(this,t)).rR=null,n.iR=null,n.oR=(r=n.win,y(r,"platform")).isSafari(),n}var s=a.prototype;return s.buildCallback=function(){var t=this,n=this.win;if("serviceWorker"in n.navigator){var r=this.xj(),e=this.element.getAttribute("src");if(r.assertHttpsUrl(e,this.element),!r.isProxyOrigin(e)&&!r.isProxyOrigin(n.location.href)||this.oR)r.parse(n.location.href).origin==r.parse(e).origin?this.uR().then((function(){return function(t,n,r){var e={};return r.hasAttribute("data-scope")&&(e.scope=r.getAttribute("data-scope")),t.navigator.serviceWorker.register(n,e).then((function(n){(function(t){var n=self;return n.__AMP_MODE?n.__AMP_MODE:n.__AMP_MODE=function(t){return{localDev:!1,development:h(t,f(t)),esm:!1,test:!1,rtvVersion:l(t),ssrReady:!1}}(n)})().development&&d().info(E,"ServiceWorker registration successful with scope: ",n.scope);var e=n.installing;return e?e.addEventListener("statechange",(function(e){"activated"===e.target.state&&C(n,t,r)})):n.active&&C(n,t,r),n}),(function(t){d().error(E,"ServiceWorker registration failed:",t)}))}(t.win,e,t.element)})):this.user().error(E,"Did not install ServiceWorker because it does not match the current origin: "+e);else{var i=this.element.getAttribute("data-iframe-src");if(i){r.assertHttpsUrl(i,this.element);var o=r.parse(i).origin,u=function(t,n){return g(k(w(t)),"documentInfo")}(this.element).get(),c=r.parse(u.sourceUrl),a=r.parse(u.canonicalUrl);b(o==c.origin||o==a.origin,"data-iframe-src (%s) should be a URL on the same origin as the source (%s) or canonical URL (%s) of the AMP-document.",o,c.origin,a.origin),this.rR=i,this.uR().then((function(){return t.cR()}))}}(r.isProxyOrigin(e)||r.isProxyOrigin(n.location.href))&&this.oR&&this.user().error(E,"Did not install ServiceWorker because of safari double keyring caching as it will not have any effect")}else this.aR()},s.uR=function(){return Promise.all([this.loadPromise(this.win),this.getAmpDoc().whenFirstVisible()])},s.cR=function(){var t=this;return this.mutateElement((function(){u(t.element,!1);var n=t.win.document.createElement("iframe");n.setAttribute("sandbox","allow-same-origin allow-scripts"),n.src=t.rR,t.element.appendChild(n)}))},s.aR=function(){if(this.getAmpDoc().isSingleDoc()){var t=this.getAmpDoc(),n=this.win,r=this.xj(),e=r.parse(n.location.href),i=this.element.getAttribute("data-no-service-worker-fallback-url-match"),o=this.element.getAttribute("data-no-service-worker-fallback-shell-url");if(i||o){var u;b(i&&o,'Both, "%s" and "%s" must be specified for url-rewrite',"data-no-service-worker-fallback-url-match","data-no-service-worker-fallback-shell-url"),o=I(o);try{u=new RegExp(i)}catch(t){throw d().createError('Invalid "data-no-service-worker-fallback-url-match" expression',t)}b(r.getSourceOrigin(e)==r.parse(o).origin,'Shell source origin "%s" must be the same as source origin "%s"',o,e.href),this.iR=new A(t,u,o,this.element),r.isSecure(o)&&this.fR(o)}}},s.fR=function(t){var n=this;return this.uR().then((function(){n.mutateElement((function(){return n.sR(t)}))}))},s.sR=function(t){var n=this.win.document.createElement("iframe");n.id="i-amphtml-shell-preload",n.setAttribute("src",t+"#preload"),u(n,!1),n.setAttribute("sandbox","allow-scripts allow-same-origin"),this.loadPromise(n).then((function(){var t,r;null===(r=(t=n).parentElement)||void 0===r||r.removeChild(t)})),this.element.appendChild(n)},s.xj=function(){return j(this.element)},a}(t.BaseElement),A=function(){function t(t,n,r,e){this.win=t.win,this.lR=n,this.hR=r,this.wx=j(e),this.vR=this.wx.parse(r),function(t,n,r,e){!function(t,n,r,e){var i=t,o=r,u=function(){if(void 0!==R)return R;R=!1;try{var t={get capture(){return R=!0,!1}};self.addEventListener("test-options",null,t),self.removeEventListener("test-options",null,t)}catch(t){}return R}();i.addEventListener("click",(function(t){try{return o(t)}catch(t){var n,r;throw null===(n=(r=self).__AMP_REPORT_ERROR)||void 0===n||n.call(r,t),t}}),!!u&&e)}(t,0,r,void 0)}(t.getRootNode(),0,this._u.bind(this))}return t.prototype._u=function(t){if(!t.defaultPrevented){var n,r=(n=t.target).closest?n.closest("A"):function(t,n,r){var e;for(e=t;e&&void 0!==e;e=e.parentElement)if(n(e))return e;return null}(n,(function(t){return function(t,n){var r=t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector;return!!r&&r.call(t,"A")}(t)}));if(r&&r.href){var e=this.wx.parse(r.href);if(e.origin==this.vR.origin&&e.pathname!=this.vR.pathname&&this.lR.test(e.href)&&!r.getAttribute("i-amphtml-orig-href")){var i=this.win;I(e.href)!=I(i.location.href)&&(r.setAttribute("i-amphtml-orig-href",r.href),r.href=this.hR+"#href="proxy.php?url=+encodeURIComponent("".concat(e.pathname).concat(e.search).concat(e.hash)))}}}},t}();function C(t,n,r){!function(t,n){if("performance"in t){var r=t.performance.getEntriesByType("resource").filter((function(t){return"script"===t.initiatorType&&t.name.startsWith(O.cdn)})).map((function(t){return t.name})),e=n.active;e.postMessage&&e.postMessage(JSON.stringify({"type":"AMP__FIRST-VISIT-CACHING","payload":r}))}}(n,t),r.hasAttribute("data-prefetch")&&function(t,n){var r,e=n.document,i=[].map.call(e.querySelectorAll("a[data-rel=prefetch]"),(function(t){return t.href}));if((r=e.createElement("link")).relList&&r.relList.supports&&r.relList.supports("prefetch"))i.forEach((function(t){var n=e.createElement("link");n.setAttribute("rel","prefetch"),n.setAttribute("href",t),e.head.appendChild(n)}));else{var o=t.active;o.postMessage&&o.postMessage(JSON.stringify({"type":"AMP__LINK-PREFETCH","payload":i}))}}(t,n)}t.registerElement(E,x)}(); /*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */}}); //# sourceMappingURL=amp-install-serviceworker-0.1.js.map