;
(self.AMP=self.AMP||[]).push({m:1,v:"2601162341000",n:"amp-user-notification",ev:"0.1",l:!0,f:function(t,i){(()=>{var i;function s(){return i||(i=Promise.resolve(void 0))}var n=class{constructor(){this.promise=new Promise(((t,i)=>{this.resolve=t,this.reject=i}))}},{isArray:e}=Array,{hasOwnProperty:o,toString:r}=Object.prototype;function h(t){const i=Object.getOwnPropertyDescriptor(t,"message");if(null!=i&&i.writable)return t;const{message:s,stack:n}=t,e=new Error(s);for(const i in t)e[i]=t[i];return e.stack=n,e}function u(t){let i=null,s="";for(const t of arguments)t instanceof Error&&!i?i=h(t):(s&&(s+=" "),s+=t);return i?s&&(i.message=s+": "+i.message):i=new Error(s),i}function c(t){var i,s;null===(i=(s=self).__AMP_REPORT_ERROR)||void 0===i||i.call(s,t)}function l(t){const i=u.apply(null,arguments);setTimeout((()=>{throw c(i),i}))}self.__AMP_LOG=self.__AMP_LOG||{user:null,dev:null,userForEmbed:null};var a=self.__AMP_LOG;function f(t,i){throw new Error("failed to call initLogConstructor")}function d(t){return f()}function m(){return a.dev||(a.dev=f())}function p(t,i,s,n,e,o,r,h,u,c,l){return t}function v(t,i,s,n,e,o,r,h,u,c,l){return(a.user||(a.user=d()),void a.user.win?a.userForEmbed||(a.userForEmbed=d()):a.user).assert(t,i,s,n,e,o,r,h,u,c,l)}function _(t,i){return g(t=function(t){return t.__AMP_TOP||(t.__AMP_TOP=t)}(t),i)}function P(t,i){return function(t,i){const s=I(t,i);if(s)return s;const e=E(t);return e[i]=function(){const t=new n,{promise:i,reject:s,resolve:e}=t;return i.catch((()=>{})),{obj:null,promise:i,resolve:e,reject:s,context:null,ctor:null}}(),e[i].promise}(b(t),i)}function w(t,i){return I(b(t),i)}function A(t){return t.nodeType?(s=t,i=(s.ownerDocument||s).defaultView,_(i,"ampdoc")).getAmpDoc(t):t;var i,s}function b(t){const i=A(t);return i.isSingleDoc()?i.win:i}function g(t,i){p(y(t,i));const s=E(t)[i];return s.obj||(p(s.ctor),p(s.context),s.obj=new s.ctor(s.context),p(s.obj),s.context=null,s.resolve&&s.resolve(s.obj)),s.obj}function I(t,i){const s=E(t)[i];return s?s.promise?s.promise:(g(t,i),s.promise=Promise.resolve(s.obj)):null}function E(t){let i=t.__AMP_SERVICES;return i||(i=t.__AMP_SERVICES={}),i}function y(t,i){const s=t.__AMP_SERVICES&&t.__AMP_SERVICES[i];return!(!s||!s.ctor)}var R,T=t=>_(t,"xhr"),M="notificationUIManager";function C(t,i,s="source"){var n;return v(null!=t,"%s %s must be available",i,s),v("https:"==(n=(t=>"string"==typeof t?function(t,i){return R||(R=self.document.createElement("a")),function(t,i,s){return t.href="",new URL(i,t.href)}(R,t)}(t):t)(n=t)).protocol||"localhost"==n.hostname||"127.0.0.1"==n.hostname||function(t,i){const s=t.length-i.length;return s>=0&&t.indexOf(i,s)==s}(n.hostname,".localhost")||/^\/\//.test(t),'%s %s must start with "https://" or "//" or be relative and served from either https or from localhost. Invalid value: %s',i,s,t),t}var V="amp-user-notification",O="userNotificationManager",U=class extends t.BaseElement{constructor(t){super(t),this.hvt=null,this.uvt=null;const i=new n;this.fvt=i.promise,this.dvt=i.resolve,this.vvt=null,this._vt=!1,this.Pvt=null,this.wvt=null,this.Avt=null,this.bvt=null,this.Tot="",this.Eot=null,this.yy=null}isAlwaysFixed(){return!0}buildCallback(){const t=this.getAmpDoc();this.yy=function(t,i){const s=b(A(t));return y(s,i)?g(s,i):null}(this.element,"url-replace"),this.Eot=P(this.element,"storage"),this.uvt=v(this.element.id,"amp-user-notification should have an id."),this.Tot="amp-user-notification:"+this.uvt,this.Pvt=this.element.getAttribute("data-show-if-geo"),this.wvt=this.element.getAttribute("data-show-if-not-geo"),this.bvt=this.element.getAttribute("data-show-if-href"),this.bvt&&C(this.bvt,this.element),v(!!this.bvt+!!this.Pvt+!!this.wvt<=1,'Only one "data-show-if-*" attribute allowed'),this.Pvt&&(this.Avt=this.gvt(this.Pvt,!0)),this.wvt&&(this.Avt=this.gvt(this.wvt,!1)),this.vvt=this.element.getAttribute("data-dismiss-href"),this.vvt&&C(this.vvt,this.element),this.element.getAttribute("role")||this.element.setAttribute("role","alert");const i=this.element.getAttribute("data-persist-dismissal");this._vt="false"!=i&&"no"!=i,this.registerDefaultAction((()=>this.dismiss(!1)),"dismiss"),this.registerAction("optoutOfCid",(()=>this.Ivt())),P(t,O).then((t=>{t.registerUserNotification(this.uvt,this)}))}gvt(t,i){return(s=this.element,function(t,i,s,n){const e=w(t,i);if(e)return e;const o=A(t);return o.whenExtensionsKnown().then((()=>{const t=o.getExtensionVersion(s);return t?_(o.win,"extensions").waitForExtension(s,t):null})).then((s=>s?w(t,i):null))}(s,"geo","amp-geo")).then((s=>{v(s,"requires <amp-geo> to use promptIfUnknownForGeoGroup");const n=t.split(/,\s*/).filter((t=>2==s.isInCountryGroup(t)));return!!(i?n.length:!n.length)}));var s}Evt(t){const i=this.bvt;return this.yy.expandUrlAsync(i).then((i=>function(t,i,s){if(!i)return t;const n=t.split("#",2),e=n[0].split("?",2);let o=e[0]+(e[1]?`?${e[1]}&${i}`:`?${i}`);return o+=n[1]?`#${n[1]}`:"",o}(i,function(t){const i=[];for(const r in t){let h=t[r];if(null!=h){h=e(o=h)?o:[o];for(let t=0;t<h.length;t++)i.push((s=r,n=h[t],`${encodeURIComponent(s)}=${encodeURIComponent(n)}`))}}var s,n,o;return i.join("&")}({"elementId":this.uvt,"ampUserId":t}))))}yvt(t){return this.hvt=t,this.Evt(t).then((t=>T(this.win).fetchJson(t,{credentials:"include"}).then((t=>t.json()))))}Rvt(){const t=this.element.getAttribute("enctype")||"application/json;charset=utf-8";return T(this.win).fetchJson(this.vvt,this.Tvt(t,this.uvt,this.hvt))}Tvt(t,i,s){return{method:"POST",credentials:"include",body:{"elementId":i,"ampUserId":s},headers:{"Content-Type":t}}}Mvt(t){return v("boolean"==typeof t.showNotification,'`showNotification` should be a boolean. Got "%s" which is of type %s.',t.showNotification,typeof t.showNotification),t.showNotification||this.dvt(),Promise.resolve(t.showNotification)}Ivt(){return this.Cvt().then((t=>t.optOut())).then((()=>this.dismiss(!1)),(t=>{m().error(V,"Failed to opt out of Cid",t),this.dismiss(!0)}))}Vvt(){return this.Cvt().then((t=>t.get({scope:V,createCookieIfNotPresent:!0},s(),this.fvt)))}Cvt(){return P(this.element,"cid")}shouldShow(){return this.isDismissed().then((t=>!t&&(this.bvt?this.Ovt():!this.Avt||this.Avt)))}Ovt(){return this.Vvt().then(this.yvt.bind(this)).then(this.Mvt.bind(this))}show(){var t,i;return t=this.element,void 0===(i=!0)&&(i=t.hasAttribute("hidden")),i?t.removeAttribute("hidden"):t.setAttribute("hidden",""),this.element.classList.add("amp-active"),this.getViewport().addToFixedLayer(this.element),this.fvt}isDismissed(){return this._vt?this.Eot.then((t=>t.get(this.Tot))).then((t=>!!t),(t=>(m().error(V,"Failed to read storage",t),!1))):Promise.resolve(!1)}dismiss(t){this.element.classList.remove("amp-active"),this.element.classList.add("amp-hidden"),this.dvt(),this.getViewport().removeFromFixedLayer(this.element),this._vt&&!t&&this.Eot.then((t=>{t.set(this.Tot,!0)})),this.vvt&&this.Rvt()}};t.registerServiceForDoc(O,class{constructor(t){this.ampdoc=t,this.Uvt=Object.create(null),this.jvt=Object.create(null),this.xvt=this.ampdoc.whenReady(),this.Nvt=Promise.all([this.ampdoc.whenFirstVisible(),this.xvt]),this.Svt=P(this.ampdoc,M)}get(t){return this.Nvt.then((()=>{this.ampdoc.getElementById(t)})),this.Gvt(t).promise}getNotification(t){return this.xvt.then((()=>this.Uvt[t]))}registerUserNotification(t,i){this.Uvt[t]=i;const s=this.Gvt(t);return this.Nvt.then((()=>i.shouldShow())).then((t=>{if(t)return this.Svt.then((t=>t.registerUI(i.show.bind(i))))})).then(s.resolve.bind(this,i)).catch(l.bind(null,"Notification service failed amp-user-notification",t))}Gvt(t){if(this.jvt[t])return this.jvt[t];const i=new n,{promise:s,resolve:e}=i;return this.jvt[t]={promise:s,resolve:e}}}),t.registerServiceForDoc(M,class{constructor(){this.dot=0,this.fot=s(),this.mot=()=>{},this._ot=()=>{}}onQueueEmpty(t){this.mot=t,0==this.dot&&t()}onQueueNotEmpty(t){this._ot=t,this.dot>0&&t()}registerUI(t){0==this.dot&&this._ot(),this.dot++;const i=this.fot.then((()=>t().then((()=>{this.dot--,0==this.dot&&this.mot()}))));return this.fot=i,i}}),t.registerElement(V,U,"amp-user-notification{position:fixed!important;bottom:0;left:0;overflow:hidden!important;visibility:hidden;background:hsla(0,0%,100%,.7);z-index:1000;width:100%}amp-user-notification.amp-active{visibility:visible}amp-user-notification.amp-hidden{visibility:hidden}\n/*# sourceURL=/extensions/amp-user-notification/0.1/amp-user-notification.css*/")})();
/*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */}});
//# sourceMappingURL=amp-user-notification-0.1.mjs.map