;
(self.AMP=self.AMP||[]).push({m:1,v:"2608131752000",n:"amp-viewer-integration",ev:"0.1",l:!0,p:"high",f:function(t,s){(()=>{var s;function e(){return s||(s=Promise.resolve(void 0))}var{isArray:n}=Array;function i(t,s){const e=t.length-s.length;return e>=0&&t.indexOf(s,e)==e}var{hasOwnProperty:r,toString:o}=Object.prototype;function h(t){const s=Object.create(null);return t&&Object.assign(s,t),s}function c(t,s,e,n,i,r,o,h,c,u,l){return t}var u=/(?:^[#?]?|&)([^=&]+)(?:=([^&]*))?/g;function l(t,s=""){try{return decodeURIComponent(t)}catch(t){return s}}function a(t){const s=Object.getOwnPropertyDescriptor(t,"message");if(null!=s&&s.writable)return t;const{message:e,stack:n}=t,i=new Error(e);for(const s in t)i[s]=t[s];return i.stack=n,i}function f(t){let s=null,e="";for(const t of arguments)t instanceof Error&&!s?s=a(t):(e&&(e+=" "),e+=t);return s?e&&(s.message=e+": "+s.message):s=new Error(e),s}function d(t,...s){const e=f.apply(null,s);e.name=t||e.name,function(t){var s,e;null===(s=(e=self).__AMP_REPORT_ERROR)||void 0===s||s.call(e,t)}(e)}self.__AMP_LOG=self.__AMP_LOG||{user:null,dev:null,userForEmbed:null};var _=self.__AMP_LOG;function p(t,s){throw new Error("failed to call initLogConstructor")}function P(t){return _.user||(_.user=A()),function(t,s){return s&&s.ownerDocument.defaultView!=t}(_.user.win,t)?_.userForEmbed||(_.userForEmbed=A()):_.user}function A(t){return p()}function m(){return _.dev||(_.dev=p())}function E(t,s,e,n,i,r,o,h,c,u,l){return t}function g(t,s,e,n,i,r,o,h,c,u,l){return P().assert(t,s,e,n,i,r,o,h,c,u,l)}function T(t,s){return y(t=function(t){return t.__AMP_TOP||(t.__AMP_TOP=t)}(t),s)}function v(t,s){return y(M(w(t)),s)}function w(t){return t.nodeType?(e=t,s=(e.ownerDocument||e).defaultView,T(s,"ampdoc")).getAmpDoc(t):t;var s,e}function M(t){const s=w(t);return s.isSingleDoc()?s.win:s}function y(t,s){E(I(t,s));const e=function(t){let s=t.__AMP_SERVICES;return s||(s=t.__AMP_SERVICES={}),s}(t)[s];return e.obj||(E(e.ctor),E(e.context),e.obj=new e.ctor(e.context),E(e.obj),e.context=null,e.resolve&&e.resolve(e.obj)),e.obj}function I(t,s){const e=t.__AMP_SERVICES&&t.__AMP_SERVICES[s];return!(!e||!e.ctor)}var R,V=t=>T(t,"platform"),b=t=>v(t,"viewer"),x=t=>v(t,"viewport"),k=["Webkit","webkit","Moz","moz","ms","O","o"],S={"getPropertyPriority":()=>"","getPropertyValue":()=>""};function F(t){const s=t.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()));return k.some((t=>s.startsWith(t+"-")))?`-${s}`:s}function N(t,s,e){if(Y(s))return s;R||(R=h());let n=R[s];if(!n||e){if(n=s,void 0===t[s]){const e=function(t){return t.charAt(0).toUpperCase()+t.slice(1)}(s),i=function(t,s){for(let e=0;e<k.length;e++){const n=k[e]+s;if(void 0!==t[n])return n}return""}(t,e);void 0!==t[i]&&(n=i)}e||(R[s]=n)}return n}function H(t,s){const{style:e}=t;for(const t in s)e.setProperty(F(N(e,t)),String(s[t]),"important")}function O(t,s,e,n,i){const r=N(t.style,s,i);if(!r)return;const o=n?e+n:e;t.style.setProperty(F(r),o)}function C(t,s,e){const n=N(t.style,s,e);if(n)return Y(n)?t.style.getPropertyValue(n):t.style[n]}function L(t,s){for(const e in s)O(t,e,s[e])}function U(t,s){const{style:e}=t;c(""!==s&&"none"!==s),c(!e.display),e.display=s}function D(t,s){return t.getComputedStyle(s)||S}function z(t,s){for(let e=0;e<s.length;e++)O(t,s[e],null)}function Y(t){return t.startsWith("--")}var q=class t{static solveYValueFromXValue(s,e,n,i,r,o,h,c,u){return t.rr(t.hr(s,e,i,o,c),n,r,h,u)}static hr(s,e,n,i,r){const o=1e-6;let h=(s-e)/(r-e);if(h<=0)return 0;if(h>=1)return 1;let c=0,u=1,l=0;for(let a=0;a<8;a++){l=t.ur(h,e,n,i,r);const a=(t.ur(h+o,e,n,i,r)-l)/o;if(Math.abs(l-s)<o)return h;if(Math.abs(a)<o)break;l<s?c=h:u=h,h-=(l-s)/a}for(let a=0;Math.abs(l-s)>o&&a<8;a++)l<s?(c=h,h=(h+u)/2):(u=h,h=(h+c)/2),l=t.ur(h,e,n,i,r);return h}static ur(s,e,n,i,r){if(0==s)return e;if(1==s)return r;let o=t.lr(e,n,s),h=t.lr(n,i,s);const c=t.lr(i,r,s);return o=t.lr(o,h,s),h=t.lr(h,c,s),t.lr(o,h,s)}static rr(s,e,n,i,r){if(0==s)return e;if(1==s)return r;let o=t.lr(e,n,s),h=t.lr(n,i,s);const c=t.lr(i,r,s);return o=t.lr(o,h,s),h=t.lr(h,c,s),t.lr(o,h,s)}static lr(t,s,e){return t+e*(s-t)}},X={LINEAR:t=>t,EASE:t=>q.solveYValueFromXValue(t,0,0,.25,.1,.25,1,1,1),EASE_IN:t=>q.solveYValueFromXValue(t,0,0,.42,0,1,1,1,1),EASE_OUT:t=>q.solveYValueFromXValue(t,0,0,0,0,.58,1,1,1),EASE_IN_OUT:t=>q.solveYValueFromXValue(t,0,0,.42,0,.58,1,1,1)},K={"linear":X.LINEAR,"ease":X.EASE,"ease-in":X.EASE_IN,"ease-out":X.EASE_OUT,"ease-in-out":X.EASE_IN_OUT};function $(t){if(!t)return null;if("string"==typeof t){if(-1!=t.indexOf("cubic-bezier")){const r=t.match(/cubic-bezier\((.+)\)/);if(r){const t=r[1].split(",").map(parseFloat);if(4==t.length){for(let s=0;s<4;s++)if(isNaN(t[s]))return null;return s=t[0],e=t[1],n=t[2],i=t[3],t=>q.solveYValueFromXValue(t,0,0,s,e,n,i,1,1)}}return null}return K[t]}var s,e,n,i;return t}var j,W="Animation",J=function(){},B=class t{static animate(s,e,n,i){return new t(s).setCurve(i).add(0,e,1).start(n)}constructor(t,s){this.cr=t,this.ar=s||T(self,"vsync"),this.dr=null,this.pr=[]}setCurve(t){return t&&(this.dr=$(t)),this}add(t,s,e,n){return this.pr.push({delay:t,func:s,duration:e,curve:$(n)}),this}start(t){return new G(this.ar,this.cr,this.pr,this.dr,t)}},G=class{constructor(t,s,e,n,i){this.ar=t,this.cr=s,this.pr=[];for(let t=0;t<e.length;t++){const s=e[t];this.pr.push({delay:s.delay,func:s.func,duration:s.duration,curve:s.curve||n,started:!1,completed:!1})}this.mr=i,this.zn=Date.now(),this._e=!0,this.ri={};const r=new class{constructor(){this.promise=new Promise(((t,s)=>{this.resolve=t,this.reject=s}))}};this._r=r.promise,this.Hs=r.resolve,this.Ar=r.reject,this.gr=this.ar.createAnimTask(this.cr,{mutate:this.Pr.bind(this)}),this.ar.canAnimate(this.cr)?this.gr(this.ri):this.vr(!1,0)}then(t,s){return t||s?this._r.then(t,s):this._r}thenAlways(t){const s=t||J;return this.then(s,s)}halt(t){this.vr(!1,t||0)}vr(t,s){if(this._e){if(this._e=!1,0!=s){this.pr.length>1&&this.pr.sort(((t,s)=>t.delay+t.duration-(s.delay+s.duration)));try{if(s>0)for(let t=0;t<this.pr.length;t++)this.pr[t].func(1,!0);else for(let t=this.pr.length-1;t>=0;t--)this.pr[t].func(0,!1)}catch(s){m().error(W,"completion failed: "+s,s),t=!1}}t?this.Hs():this.Ar()}}Pr(t){if(!this._e)return;const s=Date.now(),e=Math.min((s-this.zn)/this.mr,1);for(let t=0;t<this.pr.length;t++){const s=this.pr[t];!s.started&&e>=s.delay&&(s.started=!0)}for(let t=0;t<this.pr.length;t++){const s=this.pr[t];s.started&&!s.completed&&this.Er(s,e)}1==e?this.vr(!0,0):this.ar.canAnimate(this.cr)?this.gr(this.ri):this.vr(!1,0)}Er(t,s){let e,n;if(t.duration>0){if(e=Math.min((s-t.delay)/t.duration,1),n=e,t.curve&&1!=n)try{n=t.curve(e)}catch(t){return m().error(W,"step curve failed: "+t,t),void this.vr(!1,0)}}else e=1,n=1;1==e&&(t.completed=!0);try{t.func(n,t.completed)}catch(t){return m().error(W,"step mutate failed: "+t,t),void this.vr(!1,0)}}},Z="FixedLayer",Q="i-amphtml-lightbox",tt="i-amphtml-lightbox-element";function st(t){return-1!==t.tagName.indexOf("LIGHTBOX")}function et(t,s,e,n){let i=t,r=e,o=t=>{try{return r(t)}catch(t){var s,e;throw null===(s=(e=self).__AMP_REPORT_ERROR)||void 0===s||s.call(e,t),t}};const h=function(){if(void 0!==j)return j;j=!1;try{const t={get capture(){return j=!0,!1}};self.addEventListener("test-options",null,t),self.removeEventListener("test-options",null,t)}catch(t){}return j}(),c=!(null==n||!n.capture);return i.addEventListener(s,o,h?n:c),()=>{null==i||i.removeEventListener(s,o,h?n:c),r=null,i=null,o=null}}function nt(t,s,e,n){return et(t,s,e,n)}function it(t,s,e,n){let i=e;const r=et(t,s,(t=>{try{i(t)}finally{i=null,r()}}),n);return r}function rt(t){return"loading"!=t.readyState&&"uninitialized"!=t.readyState}function ot(t,s,e){return 0==s&&0==e||0==t.width&&0==t.height?t:{left:n=t.left+s,top:i=t.top+e,width:r=t.width,height:o=t.height,bottom:i+o,right:n+r,x:n,y:i};var n,i,r,o}function ht(t){return t.node.wholeText[t.offset]}var ct=/[,.\s\u2022()]/;function ut(t){return"’"==t||"‘"==t?"'":"“"==t||"”"==t?'"':t.toLowerCase()}function lt(t){const s=[];for(let e=0;e<t.length;e++){const n=t[e];ct.test(n)||s.push(ut(n))}return s.join("")}var at=class{constructor(t,s){this.hE=t,this.cE=s,this.matches=[],this.fE={},this.dE=t.length-1;for(let s=0;s<t.length;s++){const e=t[s];this.fE[e]=t.length-1-s}}update(){if(this.dE>0)return void this.dE--;const{cE:t,hE:s}=this,e=t.size();for(let n=0;n<s.length;n++){const i=ut(ht(t.get(e-1-n).pos));if(s[s.length-1-n]==i)continue;let r=this.fE[i];return null==r&&(r=s.length),r-=n,r<1&&(r=1),void(this.dE=r-1)}const n=t.get(e-1),i=n.pos;this.matches.push({start:t.get(e-s.length),end:{pos:{node:i.node,offset:i.offset+1},idx:n.idx+1}})}};function ft(t,s,e,n){for(let i=e;i<n.length;i++){const e=n[i];if(t.node!=e.start.node)return;if(e.start.node=s,e.start.offset-=t.offset,t.node!=e.end.node)return;e.end.node=s,e.end.offset-=t.offset}}function dt(t,s,e,n,i,r){for(;;){if(s.node==e.node){const o=_t(t,s.node,s.offset,e.offset,r);return void(o&&ft(e,o,i+1,n))}const o=pt(t,s.node);if(_t(t,s.node,s.offset,s.node.wholeText.length,r),!o)break;s={node:o,offset:0}}}function _t(t,s,e,n,i){if(e>=n)return null;const r=t.document,{parentNode:o,wholeText:h}=s;e>0&&o.insertBefore(r.createTextNode(h.substring(0,e)),s);const c=r.createElement("span");c.appendChild(r.createTextNode(h.substring(e,n))),o.insertBefore(c,s),i.push(c);let u=null;return n<h.length&&(u=r.createTextNode(h.substring(n)),o.insertBefore(u,s)),o.removeChild(s),u}function pt(t,s){let e=!0,n=s;for(;;){if(null==n)return null;if(e){const t=n.nextSibling;t?(n=t,e=!1):n=n.parentNode}else{if(n instanceof t.Text)return n;n.firstChild?n=n.firstChild:e=!0}}}var Pt=["key","code","location","ctrlKey","shiftKey","altKey","metaKey","repeat","isComposing","charCode","keyCode","which"],At="amp-viewer-messaging",mt="channelOpen",Et="__AMPHTML__";function gt(t){if("string"!=typeof t)return t;if("{"!=t.charAt(0))return null;try{return JSON.parse(t)}catch(t){return null}}var Tt,vt=class{constructor(t,s,e){this.i=t,this.h=s,this.o=e}addEventListener(t,s){this.i.addEventListener("message",(t=>{t.origin==this.h&&t.source==this.o&&s(t)}))}postMessage(t){const s="null"===this.h?"*":this.h;this.o.postMessage(t,s)}start(){}},wt=class t{static initiateHandshakeWithDocument(s,e){return new Promise((n=>{const i=setInterval((()=>{const r=new MessageChannel,o={app:Et,name:"handshake-poll"};s.postMessage(o,"*",[r.port2]);const h=r.port1,c=s=>{const r=gt(s.data);if(r&&r.app===Et&&r.name===mt){clearInterval(i),h.removeEventListener("message",c);const s=new t(null,h,!1,e,!0);s.t(r.requestid,mt,null),n(s)}};h.addEventListener("message",c),h.start()}),1e3)}))}static waitForHandshakeFromDocument(s,e,n,i,r){return new Promise((o=>{const h=c=>{const u=gt(c.data);if(u&&(c.origin==n||r&&r.test(c.origin))&&(!c.source||c.source==e)&&u.app===Et&&u.name===mt){s.removeEventListener("message",h);const n=new vt(s,c.origin,e),r=new t(null,n,!1,i,!0);r.t(u.requestid,mt,null),o(r)}};s.addEventListener("message",h)}))}constructor(t,s,e,n,i){this.i=t,this.l=s,this.u=!!e,this._=n||null,this.p=!!i,this.g=0,this.m={},this.P={},this.A=null,this.l.addEventListener("message",this.R.bind(this)),this.l.start()}registerHandler(t,s){this.P[t]=s}unregisterHandler(t){delete this.P[t]}setDefaultHandler(t){this.A=t}R(t){const s=gt(t.data);s&&s.app===Et&&(this._&&this.p&&s.messagingToken!==this._?this.M(At+": handleMessage_ error: ","invalid token"):"q"===s.type?this.q(s):"s"===s.type&&this.v(s))}sendRequest(t,s,e){const n=++this.g;let i;return e&&(i=new Promise(((t,s)=>{this.m[n]={resolve:t,reject:s}}))),this.I({app:Et,requestid:n,type:"q",name:t,data:s,rsvp:e}),i}t(t,s,e){this.I({app:Et,requestid:t,type:"s",name:s,data:e})}T(t,s,e){const n=this.V(e);this.M(At+": sendResponseError_, message name: "+s,n),this.I({app:Et,requestid:t,type:"s",name:s,data:null,error:n})}I(t){const s=Object.assign(t,{});this._&&!this.p&&(s.messagingToken=this._),this.l.postMessage(this.u?JSON.stringify(s):s)}q(t){let s=this.P[t.name];if(s||(s=this.A),!s){const s=new Error("Cannot handle request because no default handler is set!");throw s.args=t.name,s}const e=s(t.name,t.data,!!t.rsvp);if(t.rsvp){const s=t.requestid;if(!e)throw this.T(s,t.name,new Error("no response")),new Error("expected response but none given: "+t.name);e.then((e=>{this.t(s,t.name,e)}),(e=>{this.T(s,t.name,e)}))}}v(t){const s=t.requestid,e=this.m[s];e&&(delete this.m[s],t.error?(this.M(At+": handleResponse_ error: ",t.error),e.reject(new Error(`Request ${t.name} failed: ${t.error}`))):e.resolve(t.data))}M(t,s){if(!this.i)return;let e="amp-messaging-error-logger: "+t;e+=" data: "+this.V(s),this.i.viewerState=e}V(t){return t?t.message?t.message:String(t):"unknown error"}},Mt=["altKey","charCode","ctrlKey","detail","eventPhase","key","layerX","layerY","metaKey","pageX","pageY","returnValue","shiftKey","timeStamp","type","which"],yt=["clientX","clientY","force","identifier","pageX","pageY","radiusX","radiusY","screenX","screenY"],It=(()=>self.AMP.config.urls)(),Rt=new Set(["c","v","a","ad"]),Vt=t=>"string"==typeof t?function(t,s){return Tt||(Tt=self.document.createElement("a")),function(t,s,e){return t.href="",new URL(s,t.href)}(Tt,t)}(t):t;new class{constructor(t){this.win=t,this._E=!1,this.pE=!1,this.PE=null}init(){const t=w(this.win.document),s=b(t);this._E="1"==s.getParam("webview"),this.pE=s.hasCapability("handshakepoll");const n=s.getParam("messagingToken"),r=s.getParam("origin")||"";if(!this._E&&!r)return e();if(x(t).createFixedLayer(class{constructor(t,s,e,n,i){this.ampdoc=t,this.ar=s,this.AE=e,this.br=n,this.mE=n,this.EE=i&&t.isSingleDoc(),this.gE=null,this.TE=0,this.ct=[],this.vE=new class{constructor(t,s,e){this.ae=y(t,"timer"),this.de=s,this.fe=e||0,this.pe=-1,this.me=0,this._e=!1,this.Ae=()=>{this.ge()}}isPending(){return-1!=this.pe}schedule(t){let s=t||this.fe;this._e&&s<10&&(s=10);const e=Date.now()+s;return(!this.isPending()||e-this.me<-10)&&(this.cancel(),this.me=e,this.pe=this.ae.delay(this.Ae,s),!0)}ge(){this.pe=-1,this.me=0,this._e=!0,this.de(),this._e=!1}cancel(){this.isPending()&&(this.ae.cancel(this.pe),this.pe=-1)}}(t.win,(()=>this.update())),this.wE=null,this.ME=[],this.yE=[]}enterLightbox(t,s){const e=this.IE();e&&e.setLightboxMode(!0),t&&s&&s.then((()=>this.RE(t,!0)))}leaveLightbox(){const t=this.IE();t&&t.setLightboxMode(!1);const s=function(t,s){const e=[];let n=0;for(let s=0;s<t.length;s++){const i=t[s];i.lightboxed?e.push(i):(n<s&&(t[n]=i),n++)}return n<t.length&&(t.length=n),e}(this.ct);this.VE(s),this.ct.length||this.bE()}setup(){if(!b(this.ampdoc).isEmbedded())return!1;const t=this.ampdoc.getRootNode(),s=t.styleSheets;if(!s)return!0;this.ME.length=0,this.yE.length=0;for(let t=0;t<s.length;t++){const e=s[t];if(!e)return m().error(Z,"Aborting setup due to null stylesheet."),!0;const{disabled:n,ownerNode:i}=e;n||!i||"STYLE"!=i.tagName||i.hasAttribute("amp-boilerplate")||i.hasAttribute("amp-runtime")||i.hasAttribute("amp-extension")||this.xE(e.cssRules)}this.RE(t),this.ct.length>0&&this.observeHiddenMutations();const e=V(this.ampdoc.win);return this.ct.length>0&&!this.EE&&e.isIos(),!0}RE(t,s){this.kE(t,s),this.SE(),this.update()}observeHiddenMutations(){this.FE()}bE(){this.vE.cancel();const t=this.wE;t&&(t(),this.wE=null)}FE(){if(this.wE)return;const t=this.ampdoc.getRootNode(),s=(t=>function(t,s){const e=M(w(t));return I(e,s)?y(e,s):null}(t,"hidden-observer"))(t.documentElement||t);this.wE=s.add((()=>{this.vE.isPending()||this.vE.schedule(16)}))}updatePaddingTop(t,s){this.br=t,s||(this.mE=t),this.update()}transformMutate(t){t?this.ct.forEach((s=>{s.fixedNow&&s.top&&(O(s.element,"transition","none"),s.transform&&"none"!=s.transform?O(s.element,"transform",s.transform+" "+t):O(s.element,"transform",t))})):this.ct.forEach((t=>{t.fixedNow&&t.top&&L(t.element,{transform:"",transition:""})}))}addElement(t,s){return this.NE(t,"*","fixed",s)?(this.SE(),this.observeHiddenMutations(),this.update()):e()}removeElement(t){const s=this.HE(t);this.VE(s)}VE(t){t.length>0&&this.gE&&this.ar.mutate((()=>{for(let s=0;s<t.length;s++){const e=t[s];"fixed"==e.position&&this.gE.returnFrom(e)}}))}isDeclaredFixed(t){return!!t.__AMP_DECLFIXED}isDeclaredSticky(t){return!!t.__AMP_DECLSTICKY}update(){if(this.ct.filter((t=>!this.ampdoc.contains(t.element))).forEach((t=>this.HE(t.element))),0==this.ct.length)return e();this.vE.cancel();let t=!1;return this.ar.runPromise({measure:s=>{const e=this.ct,n=[],{win:r}=this.ampdoc;for(let t=0;t<e.length;t++)H(e[t].element,{top:"",bottom:"-9999vh",transition:"none"});for(let t=0;t<e.length;t++)n.push(D(r,e[t].element).top);for(let t=0;t<e.length;t++)O(e[t].element,"bottom","");for(let o=0;o<e.length;o++){const h=e[o],{element:c,forceTransfer:u}=h,l=D(r,c),{offsetHeight:a,offsetTop:f,offsetWidth:d}=c,{bottom:_,display:p="",position:P="",zIndex:A}=l,m=parseFloat(l.opacity),E=l[N(l,"transform")];let{top:g}=l;const T="fixed"===P&&(u||d>0&&a>0),v=i(P,"sticky");if("none"===p||!T&&!v){s[h.id]={fixed:!1,sticky:!1,transferrable:!1,top:"",zIndex:""};continue}"auto"!==g&&n[o]===g||(g=T&&f===this.mE+this.AE?"0px":"");let w=!1;T&&(w=!0===u||!1!==u&&m>0&&a<300&&!(!g&&!_)),w&&(t=!0),s[h.id]={fixed:T,sticky:v,transferrable:w,top:g,zIndex:A,transform:E}}},mutate:s=>{t&&this.EE&&this.IE().update();const e=this.ct;for(let t=0;t<e.length;t++){const n=e[t],i=s[n.id];O(n.element,"transition","none"),O(n.element,"transition",""),i&&this.OE(n,t,i)}}},{}).catch((t=>{m().error(Z,"Failed to mutate fixed elements:",t)}))}kE(t,s){try{this.CE(t,s)}catch(t){m().error(Z,"Failed to setup fixed elements:",t)}}CE(t,s){for(let e=0;e<this.ME.length;e++){const n=this.ME[e],i=t.querySelectorAll(n);for(let t=0;t<i.length&&!(this.ct.length>10);t++)this.NE(i[t],n,"fixed",void 0,s)}for(let e=0;e<this.yE.length;e++){const n=this.yE[e],i=t.querySelectorAll(n);for(let t=0;t<i.length;t++)this.NE(i[t],n,"sticky",void 0,s)}}LE(t){t.hasAttribute("style")&&(C(t,"top")||C(t,"bottom"))&&P().error(Z,"Inline styles with `top`, `bottom` and other CSS rules are not supported yet for fixed or sticky elements (#14186). Unexpected behavior may occur.",t)}NE(t,s,e,n,i){if(n||this.LE(t),st(t))return!1;const r=function(t,s,e){let n;for(n=t;n&&void 0!==n;n=n.parentElement)if(s(n))return n;return null}(t,st);if(!i&&r)return!1;const o=this.ct,h=[];for(let s=0;s<o.length;s++){const e=o[s].element;if(e===t)break;if(e.contains(t))return!1;t.contains(e)&&h.push(e)}for(let t=0;t<h.length;t++)this.removeElement(h[t]);let c=null;for(let s=0;s<o.length;s++){const n=o[s];if(n.element==t&&n.position==e){c=n;break}}const u="fixed"==e;if(c)c.selectors.includes(s)||c.selectors.push(s);else{const n="F"+this.TE++;t.setAttribute("i-amphtml-fixedid",n),u?t.__AMP_DECLFIXED=!0:t.__AMP_DECLSTICKY=!0,c={id:n,element:t,position:e,selectors:[s],fixedNow:!1,stickyNow:!1,lightboxed:!!r},o.push(c)}return c.forceTransfer=!!u&&n,!0}HE(t){const s=[];for(let e=0;e<this.ct.length;e++){const n=this.ct[e];n.element===t&&(n.lightboxed||this.ar.mutate((()=>{O(t,"top","")})),this.ct.splice(e,1),s.push(n))}return this.ct.length||this.bE(),s}SE(){this.ct.sort(((t,s)=>{return(e=t.element)===(n=s.element)?0:e.compareDocumentPosition(n)&(Node.DOCUMENT_POSITION_PRECEDING|Node.DOCUMENT_POSITION_CONTAINS)?1:-1;var e,n}))}OE(t,s,e){const{element:n,fixedNow:i}=t;t.fixedNow=e.fixed,t.stickyNow=e.sticky,t.top=e.fixed||e.sticky?e.top:"",t.transform=e.transform,!i||e.fixed&&e.transferrable||!this.gE||this.gE.returnFrom(t),e.top&&(e.fixed||e.sticky)&&!t.lightboxed&&(e.fixed||!this.EE?O(n,"top",`calc(${e.top} + ${this.br}px)`):this.mE===this.br?O(n,"top",e.top):O(n,"top",`calc(${e.top} - ${this.mE}px)`)),this.EE&&e.fixed&&e.transferrable&&this.IE().transferTo(t,s,e)}IE(){if(!this.EE||this.gE)return this.gE;const t=this.ampdoc.win.document;return this.gE=new class{constructor(t,s){var e;this.yf=t,this.ar=s,this.UE=t.body.cloneNode(!1),this.UE.removeAttribute("style"),L(this.UE,("display"in(e={position:"absolute",top:0,left:0,height:0,width:0,pointerEvents:"none",overflow:"hidden",animation:"none",background:"none",border:"none",borderImage:"none",boxSizing:"border-box",boxShadow:"none",float:"none",margin:0,opacity:1,outline:"none",padding:"none",transform:"none",transition:"none"})&&d("STYLE","`display` style detected. You must use toggle instead."),e)),U(this.UE,"block"),t.documentElement.appendChild(this.UE)}getRoot(){return this.UE}setLightboxMode(t){this.ar.mutate((()=>{const s=this.getRoot();t?s.setAttribute(Q,""):s.removeAttribute(Q)}))}update(){const{body:t}=this.yf,s=this.UE,e=t.attributes,n=s.attributes;for(let t=0;t<e.length;t++){const s=e[t];"style"!==s.name&&n.setNamedItem(s.cloneNode(!1))}for(let e=0;e<n.length;e++){const{name:i}=n[e];"style"===i||i===Q||t.hasAttribute(i)||(s.removeAttribute(i),e--)}}transferTo(t,s,e){const{element:n}=t;if(n.parentElement!=this.UE){if(!t.placeholder){O(n,"pointer-events","initial");const s=t.placeholder=this.yf.createElement("i-amphtml-fpa");!function(t,s){void 0===s&&(s=t.hasAttribute("hidden")),s?t.removeAttribute("hidden"):t.setAttribute("hidden","")}(s,!1),s.setAttribute("i-amphtml-fixedid",t.id)}O(n,"zIndex",`calc(${1e4+s} + ${e.zIndex||0})`),t.lightboxed&&n.classList.add(tt),n.parentElement.replaceChild(t.placeholder,n),this.UE.appendChild(n),t.selectors.some((t=>this.DE(n,t)))||this.returnFrom(t)}}returnFrom(t){if(!t.placeholder||!this.yf.contains(t.placeholder))return;const{element:s,placeholder:e}=t;t.lightboxed&&s.classList.remove(tt),this.yf.contains(s)?(O(t.element,"zIndex",""),e.parentElement.replaceChild(s,e)):e.parentElement.removeChild(e)}DE(t,s){try{return function(t,s){return t.matches(s)}(t,s)}catch(t){return m().error(Z,"Failed to test query match:",t),!1}}}(t,this.ar),this.gE}xE(t){for(let s=0;s<t.length;s++){const e=t[s];if(4!=e.type&&12!=e.type){if(1==e.type){const{selectorText:t}=e,{position:s}=e.style;if("*"===t||!s)continue;"fixed"===s?this.ME.push(t):i(s,"sticky")&&this.yE.push(t)}}else this.xE(e.cssRules)}}animateFixedElements(t,s,n,i,r){return this.updatePaddingTop(t,r),n<=0?e():B.animate(this.ampdoc.getRootNode(),(e=>{const n=(e=>s-t+(t-s)*e)(e);this.transformMutate(`translateY(${n}px)`)}),n,i).thenAlways((()=>{this.transformMutate(null)}))}}),this._E||this.pE){const e=(o=this.win).parent&&o.parent!=o?this.win.parent:null;return this.zE(e,r).then((e=>this.YE(s,t,r,new wt(this.win,e,this._E,n))))}var o;const c=function(t){const s=function(t){const s=h();if(!t)return s;let e;for(;e=u.exec(t);){const t=l(e[1],e[1]),n=e[2]?l(e[2].replace(/\+/g," "),e[2]):"";s[t]=n}return s}(t.win.location.hash).highlight;if(!s||s.length>102400)return null;const e=(n=s,JSON.parse(n));var n;const i=e.s;if(!(i instanceof Array)||i.length>15)return null;let r=0;for(let t=0;t<i.length;t++){const s=i[t];if("string"!=typeof s||!s)return null;if(r+=s.length,r>1500)return null}let o=!1;e.n&&(o=!0);let c=!1;return e.na&&(c=!0),{sentences:i,skipScrollAnimation:c,skipRendering:o}}(t);c&&(this.PE=new class{constructor(t,s){this.Ri=t,this.be=b(t),this.Uu=x(this.Ri),this.qE=null;const e=V(this.Ri.win);var n;"fragmentDirective"in document&&e.isChrome()&&e.getMajorVersion()>=93?t.whenFirstVisible().then((()=>this.XE(s))):(n=t.win.document,new Promise((t=>{!function(t,s){!function(t,s,e){let n=s(t);if(n)e(t);else{const i=()=>{s(t)&&(n||(n=!0,e(t)),t.removeEventListener("readystatechange",i))};t.addEventListener("readystatechange",i)}}(t,rt,s)}(n,t)}))).then((()=>{this.KE(s)}))}XE(t){const{sentences:s}=t;if(null==s||!s.length)return;const e=s.map((t=>"text="+encodeURIComponent(t))).join("&");this.$E(e)}$E(t){const{hash:s}=this.Ri.win.location;s?this.Ri.win.location.replace(s+":~:"+t):this.Ri.win.location.replace("#:~:"+t)}jE(t,s){const e={"state":t};for(const t in s)e[t]=s[t];this.be.sendMessage("highlightState",e)}WE(t){const{win:s}=this.Ri,e=function(t,s,e){if(e=function(t){const s=[];for(let e=0;e<t.length;e++){const n=lt(t[e]);n&&s.push(n)}return s}(e),e.length<=0)return null;const n=new class t{constructor(s,e){if(this.i=s,this.JE=e,this.BE=-1,this.GE=null,e instanceof s.Text)this.BE=0;else if(e instanceof s.Element){const{display:n}=D(s,e);if("none"==n)return;const i=e.firstChild;null!=i&&(this.GE=new t(s,i))}}next(){if(this.BE>=0)return this.ZE();for(;null!=this.GE;){const s=this.GE.next();if(null!=s)return s;const e=this.GE.JE.nextSibling;this.GE=null!=e?new t(this.i,e):null}return null}ZE(){const t=this.JE.wholeText;if(this.BE<t.length){const t=this.BE;return this.BE++,{node:this.JE,offset:t}}return null}}(t,s),i=new class{constructor(t){this.QE=t,this.tT=[],this.Ee=0}push(t){this.tT[this.Ee]=t,this.Ee=(this.Ee+1)%this.QE}get(t){return this.tT.length>=this.QE&&(t=(this.Ee+t)%this.QE),this.tT[t]}size(){return this.tT.length}}(e.map((t=>t.length)).reduce(((t,s)=>Math.max(t,s)))),r=[new at(e[0],i)];let o=-1;for(;;){o++;const t=n.next();if(null==t)return null;if(!ct.test(ht(t))){i.push({pos:t,idx:o});for(let t=0;t<r.length;t++)r[t].update();if(0!=r[r.length-1].matches.length){if(r.length==e.length)break;r.push(new at(e[r.length],i))}}}const h=[];t:for(let t=e.length-1;t>=0;t--){const s=r[t].matches;if(0==h.length){h.push(s[s.length-1]);continue}const e=h[h.length-1];for(let t=s.length-1;t>=0;t--){const n=s[t];if(e.start.idx>=n.end.idx){h.push(n);continue t}}E(!1)}const c=[];for(let t=h.length-1;t>=0;t--){const s=h[t];c.push({start:s.start.pos,end:s.end.pos})}return c}(s,this.Ri.getBody(),t.sentences);if(!e)return;const n=function(t,s){s=function(t){const s=[];let e=null;for(let n=0;n<t.length;n++){const i=t[n];e&&e.end.node==i.start.node&&e.end.offset==i.start.offset?e.end=i.end:(e=i,s.push(i))}return s}(s);const e=[];for(let n=0;n<s.length;n++){const i=s[n];dt(t,i.start,i.end,s,n,e)}return e}(s,e);n&&0!=n.length&&(this.qE=n)}onVisibleOnce(t){t=function(t){let s=!1,e=null,n=t;return(...t)=>(s||(e=n.apply(self,t),s=!0,n=null),e)}(t),this.Ri.onVisibilityChanged((()=>{"visible"==this.Ri.getVisibilityState()&&t()}))}KE(t){if(this.Ri.win.document.querySelector('script[id="amp-access"]'))return void this.jE("has_amp_access");if(this.WE(t),!this.qE)return void this.jE("not_found");const s=this.sT();if(this.jE("found",{"scroll":s}),t.skipRendering)return;for(let t=0;t<this.qE.length;t++)L(this.qE[t],{backgroundColor:"#fcff00",color:"#000"});const e=this.Ri.getVisibilityState();t.skipScrollAnimation?"visible"==e?this.eT(s):(this.Uu.setScrollTop(s),this.onVisibleOnce((()=>{this.eT(this.sT())}))):"visible"==e?this.nT(s):(this.iT(s),this.onVisibleOnce((()=>{this.nT(this.sT())}))),it(this.Ri.getBody(),"click",this.rT.bind(this))}sT(){const t=this.qE;if(!t)return 0;const s=this.Uu;let e=Number.MAX_VALUE,n=0;const i=s.getPaddingTop();for(let r=0;r<t.length;r++){const{bottom:o,top:h}=ot(s.getLayoutRect(t[r]),0,-i);e=Math.min(e,h),n=Math.max(n,o)}if(e>=n)return 0;let r=(n+e-(s.getHeight()-i))/2;return r>e-80&&(r=e-80),r>0?r:0}eT(t){this.jE("auto_scroll"),this.Uu.setScrollTop(t),this.jE("shown")}iT(t){const s=Math.max(0,t-500);this.Uu.setScrollTop(s)}oT(t){const s=this.sT(),e=this.Uu.getScrollTop();if(e==s&&e==t)return null;const n={};return e!=s&&(this.Uu.setScrollTop(s),n.nd=e-s),e!=t&&(n.od=e-t),n}nT(t){this.iT(t);const s=this.Ri.win.document.createElement("div");U(s,"block"),L(s,{"position":"absolute","top":Math.floor(t)+"px","height":"1px","left":"0","width":"1px","pointer-events":"none"});const e=this.Ri.getBody();e.appendChild(s),this.jE("auto_scroll"),this.Uu.animateScrollIntoView(s).then((()=>{e.removeChild(s),this.jE("shown",this.oT(t))}))}setupMessaging(t){t.registerHandler("highlightDismiss",this.rT.bind(this))}rT(){if(this.qE)for(let t=0;t<this.qE.length;t++)z(this.qE[t],["backgroundColor","color"])}}(t,c));const a=new vt(this.win,r,this.win.parent);return this.YE(s,t,r,new wt(this.win,a,this._E,n))}zE(t,s){return new Promise((e=>{const n=nt(this.win,"message",(i=>{const r=gt(i.data);if(r&&i.origin===s&&i.source===t&&"__AMPHTML__"==r.app&&"handshake-poll"==r.name){if(this._E&&(!i.ports||!i.ports.length))throw new Error("Did not receive communication port from the Viewer!");const t=i.ports&&i.ports.length>0?i.ports[0]:new vt(this.win,s,this.win.parent);e(t),n()}}))}))}YE(t,s,e,n){const i=s.getUrl(),r=function(t){if(!function(t){return It.cdnProxyRegex.test(Vt(t).origin)}(t=Vt(t)))return t.href;const s=t.pathname.split("/"),e=s[1];g(Rt.has(e),"Unknown path prefix in url %s",t.href);const n=s[2],i="s"==n?"https://"+decodeURIComponent(s[3]):"http://"+decodeURIComponent(n);return g(i.indexOf(".")>0,"Expected a . in origin %s",i),s.splice(1,"s"==n?3:2),i+s.join("/")+function(t,s){if(!t||"?"==t)return"";const e=new RegExp("[?&](amp_(js[^&=]*|gsa|r|kit)|usqp)\\b[^&]*","g"),n=t.replace(e,"").replace(/^[?&]/,"");return n?"?"+n:""}(t.search)+(t.hash||"")}(i);return n.sendRequest("channelOpen",{"url":i,"sourceUrl":r},!0).then((()=>{this.Sr(n,t,e)}))}Sr(t,s,e){t.setDefaultHandler(((t,e,n)=>s.receiveMessage(t,e,n))),s.setMessageDeliverer(t.sendRequest.bind(t),e),it(this.win,"unload",this.hT.bind(this,t)),(s.hasCapability("swipe")||s.hasCapability("touch"))&&this.cT(t),s.hasCapability("keyboard")&&this.uT(t),s.hasCapability("focus-rect")&&this.lT(t),null!=this.PE&&this.PE.setupMessaging(t)}hT(t){return t.sendRequest("unloaded",{},!0)}lT(t){new class{constructor(t,s){this.win=t,this.S=s,this.aT()}aT(){nt(this.win.document,"focusin",this.fT.bind(this),{capture:!1})}fT(t){t.defaultPrevented||this.S.sendRequest(t.type,{"focusTargetRect":t.target.getBoundingClientRect()},!1)}}(this.win,t)}cT(t){new class{constructor(t,s){this.win=t,this.S=s,this.dT=!1,this._T=[],s.registerHandler("scrollLock",this.pT.bind(this)),this.PT()}PT(){const t=this.my.bind(this),s=this.win.document,e={capture:!1,passive:!this.dT};this._T.push(nt(s,"touchstart",t,e),nt(s,"touchend",t,e),nt(s,"touchmove",t,e))}bb(){this._T.forEach((t=>t())),this._T.length=0}my(t){switch(t.type){case"touchstart":case"touchend":case"touchmove":this.AT(t);break;default:return}}AT(t){if(null!=t&&t.shouldViewerCancelPropagation)t.stopImmediatePropagation();else{if(t&&t.type){const s=this.mT(t);this.S.sendRequest(t.type,s,!1)}this.dT&&t.cancelable&&t.preventDefault()}}mT(t){const s=this.ET(t,Mt);return t.touches&&(s.touches=this.gT(t.touches)),t.changedTouches&&(s.changedTouches=this.gT(t.changedTouches)),s}gT(t){const s=[];for(let e=0;e<t.length;e++)s.push(this.ET(t[e],yt));return s}ET(t,s){const e={};for(let n=0;n<s.length;n++){const i=s[n];void 0!==t[i]&&(e[i]=t[i])}return e}pT(t,s,e){return this.dT=!!s,this.bb(),this.PT(),e?Promise.resolve({}):void 0}}(this.win,t)}uT(t){new class{constructor(t,s){this.win=t,this.S=s,this.TT()}TT(){const t=this.my.bind(this);nt(this.win,"keydown",t),nt(this.win,"keypress",t),nt(this.win,"keyup",t)}my(t){(function(t){if(t.defaultPrevented)return!0;if("Escape"==t.key)return!1;switch(t.target.nodeName){case"INPUT":return"checkbox"!=t.target.type||" "==t.key;case"TEXTAREA":case"BUTTON":case"SELECT":case"OPTION":return!0}return t.target.hasAttribute&&t.target.hasAttribute("contenteditable")})(t)||this.fT(t)}fT(t){this.S.sendRequest(t.type,function(t){const s={};return Pt.forEach((e=>{void 0!==t[e]&&(s[e]=t[e])})),s}(t),!1)}}(this.win,t)}}(t.win).init()})();
/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */}});
//# sourceMappingURL=amp-viewer-integration-0.1.mjs.map