@topsort/banners
Advanced tools
| <svg xmlns="http://www.w3.org/2000/svg" width="400" height="300" viewBox="0 0 400 300"> | ||
| <defs> | ||
| <pattern id="grid" width="20" height="20" patternUnits="userSpaceOnUse"> | ||
| <path d="M 20 0 L 0 0 0 20" fill="none" stroke="#e2e2e2" stroke-width="0.5"/> | ||
| </pattern> | ||
| </defs> | ||
| <rect width="400" height="300" fill="#f5f5f5"/> | ||
| <rect width="400" height="300" fill="url(#grid)"/> | ||
| <rect x="1" y="1" width="398" height="298" fill="none" stroke="#ccc" stroke-width="2" stroke-dasharray="8 4" rx="8"/> | ||
| <text x="200" y="125" text-anchor="middle" font-family="system-ui, sans-serif" font-size="22" font-weight="600" fill="#888">Fallback · Rank 1</text> | ||
| <text x="200" y="160" text-anchor="middle" font-family="system-ui, sans-serif" font-size="14" fill="#aaa">No auction winner for this slot.</text> | ||
| <text x="200" y="185" text-anchor="middle" font-family="system-ui, sans-serif" font-size="12" fill="#bbb">Your default content stays visible.</text> | ||
| </svg> |
| <svg xmlns="http://www.w3.org/2000/svg" width="400" height="300" viewBox="0 0 400 300"> | ||
| <defs> | ||
| <pattern id="grid" width="20" height="20" patternUnits="userSpaceOnUse"> | ||
| <path d="M 20 0 L 0 0 0 20" fill="none" stroke="#e2e2e2" stroke-width="0.5"/> | ||
| </pattern> | ||
| </defs> | ||
| <rect width="400" height="300" fill="#f5f5f5"/> | ||
| <rect width="400" height="300" fill="url(#grid)"/> | ||
| <rect x="1" y="1" width="398" height="298" fill="none" stroke="#ccc" stroke-width="2" stroke-dasharray="8 4" rx="8"/> | ||
| <text x="200" y="125" text-anchor="middle" font-family="system-ui, sans-serif" font-size="22" font-weight="600" fill="#888">Fallback · Rank 2</text> | ||
| <text x="200" y="160" text-anchor="middle" font-family="system-ui, sans-serif" font-size="14" fill="#aaa">No auction winner for this slot.</text> | ||
| <text x="200" y="185" text-anchor="middle" font-family="system-ui, sans-serif" font-size="12" fill="#bbb">Your default content stays visible.</text> | ||
| </svg> |
| <svg xmlns="http://www.w3.org/2000/svg" width="800" height="400" viewBox="0 0 800 400"> | ||
| <defs> | ||
| <pattern id="grid" width="20" height="20" patternUnits="userSpaceOnUse"> | ||
| <path d="M 20 0 L 0 0 0 20" fill="none" stroke="#e2e2e2" stroke-width="0.5"/> | ||
| </pattern> | ||
| </defs> | ||
| <rect width="800" height="400" fill="#f5f5f5"/> | ||
| <rect width="800" height="400" fill="url(#grid)"/> | ||
| <rect x="1" y="1" width="798" height="398" fill="none" stroke="#ccc" stroke-width="2" stroke-dasharray="8 4" rx="8"/> | ||
| <text x="400" y="170" text-anchor="middle" font-family="system-ui, sans-serif" font-size="28" font-weight="600" fill="#888">Fallback Placeholder</text> | ||
| <text x="400" y="210" text-anchor="middle" font-family="system-ui, sans-serif" font-size="16" fill="#aaa">No auction winner — your default content stays visible.</text> | ||
| <text x="400" y="240" text-anchor="middle" font-family="system-ui, sans-serif" font-size="14" fill="#bbb">Replace this src with your own fallback image.</text> | ||
| </svg> |
+6
-0
@@ -0,1 +1,7 @@ | ||
| ### 0.8.2 | ||
| - Emit `statechange` event from `<topsort-banner-slot>` in context mode (previously only non-context banners emitted the event) | ||
| - Add `location` field to the interactive playground for geo-targeting support | ||
| - Document `statechange` event usage for context mode and predefined link customization in README | ||
| ### 0.8.1 | ||
@@ -2,0 +8,0 @@ |
@@ -89,2 +89,3 @@ import { LitElement } from 'lit'; | ||
| updated(changedProperties: Map<string | number | symbol, unknown>): void; | ||
| private _emitStateChange; | ||
| protected createRenderRoot(): this; | ||
@@ -91,0 +92,0 @@ } |
@@ -1,4 +0,4 @@ | ||
| var banners=(function(u){"use strict";let it=class extends Event{constructor(t,e,s,i){super("context-request",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e,this.callback=s,this.subscribe=i??!1}};function He(r){return r}let rt=class{constructor(t,e,s,i){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(n,o)=>{this.unsubscribe&&(this.unsubscribe!==o&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=n,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(n,o)),this.unsubscribe=o},this.host=t,e.context!==void 0){const n=e;this.context=n.context,this.callback=n.callback,this.subscribe=n.subscribe??!1}else this.context=e,this.callback=s,this.subscribe=i??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new it(this.context,this.host,this.t,this.subscribe))}};let Nt=class{get value(){return this.o}set value(t){this.setValue(t)}setValue(t,e=!1){const s=e||!Object.is(t,this.o);this.o=t,s&&this.updateObservers()}constructor(t){this.subscriptions=new Map,this.updateObservers=()=>{for(const[e,{disposer:s}]of this.subscriptions)e(this.o,s)},t!==void 0&&(this.value=t)}addCallback(t,e,s){if(!s)return void t(this.value);this.subscriptions.has(t)||this.subscriptions.set(t,{disposer:()=>{this.subscriptions.delete(t)},consumerHost:e});const{disposer:i}=this.subscriptions.get(t);t(this.value,i)}clearCallbacks(){this.subscriptions.clear()}};let Mt=class extends Event{constructor(t,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e}},nt=class extends Nt{constructor(t,e,s){super(e.context!==void 0?e.initialValue:s),this.onContextRequest=i=>{if(i.context!==this.context)return;const n=i.contextTarget??i.composedPath()[0];n!==this.host&&(i.stopPropagation(),this.addCallback(i.callback,n,i.subscribe))},this.onProviderRequest=i=>{if(i.context!==this.context||(i.contextTarget??i.composedPath()[0])===this.host)return;const n=new Set;for(const[o,{consumerHost:a}]of this.subscriptions)n.has(o)||(n.add(o),a.dispatchEvent(new it(this.context,a,o,!0)));i.stopPropagation()},this.host=t,e.context!==void 0?this.context=e.context:this.context=e,this.attachListeners(),this.host.addController?.(this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new Mt(this.context,this.host))}};function Bt({context:r}){return(t,e)=>{const s=new WeakMap;if(typeof e=="object")return{get(){return t.get.call(this)},set(i){return s.get(this).setValue(i),t.set.call(this,i)},init(i){return s.set(this,new nt(this,{context:r,initialValue:i})),i}};{t.constructor.addInitializer((o=>{s.set(o,new nt(o,{context:r}))}));const i=Object.getOwnPropertyDescriptor(t,e);let n;if(i===void 0){const o=new WeakMap;n={get(){return o.get(this)},set(a){s.get(this).setValue(a),o.set(this,a)},configurable:!0,enumerable:!0}}else{const o=i.set;n={...i,set(a){s.get(this).setValue(a),o?.call(this,a)}}}return void Object.defineProperty(t,e,n)}}}function It({context:r,subscribe:t}){return(e,s)=>{typeof s=="object"?s.addInitializer((function(){new rt(this,{context:r,callback:i=>{e.set.call(this,i)},subscribe:t})})):e.constructor.addInitializer((i=>{new rt(i,{context:r,callback:n=>{i[s]=n},subscribe:t})}))}}const j=globalThis,J=j.ShadowRoot&&(j.ShadyCSS===void 0||j.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ot=Symbol(),at=new WeakMap;let Ht=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==ot)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(J&&t===void 0){const s=e!==void 0&&e.length===1;s&&(t=at.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&at.set(e,t))}return t}toString(){return this.cssText}};const jt=r=>new Ht(typeof r=="string"?r:r+"",void 0,ot),Lt=(r,t)=>{if(J)r.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const e of t){const s=document.createElement("style"),i=j.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=e.cssText,r.appendChild(s)}},ht=J?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return jt(e)})(r):r;const{is:qt,defineProperty:Dt,getOwnPropertyDescriptor:zt,getOwnPropertyNames:Wt,getOwnPropertySymbols:Vt,getPrototypeOf:Ft}=Object,L=globalThis,ct=L.trustedTypes,Jt=ct?ct.emptyScript:"",Kt=L.reactiveElementPolyfillSupport,U=(r,t)=>r,K={toAttribute(r,t){switch(t){case Boolean:r=r?Jt:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,t){let e=r;switch(t){case Boolean:e=r!==null;break;case Number:e=r===null?null:Number(r);break;case Object:case Array:try{e=JSON.parse(r)}catch{e=null}}return e}},Q=(r,t)=>!qt(r,t),lt={attribute:!0,type:String,converter:K,reflect:!1,hasChanged:Q};Symbol.metadata??=Symbol("metadata"),L.litPropertyMetadata??=new WeakMap;let O=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=lt){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);i!==void 0&&Dt(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=zt(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get(){return i?.call(this)},set(o){const a=i?.call(this);n.call(this,o),this.requestUpdate(t,a,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??lt}static _$Ei(){if(this.hasOwnProperty(U("elementProperties")))return;const t=Ft(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(U("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(U("properties"))){const e=this.properties,s=[...Wt(e),...Vt(e)];for(const i of s)this.createProperty(i,e[i])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[s,i]of e)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[e,s]of this.elementProperties){const i=this._$Eu(e,s);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)e.unshift(ht(i))}else t!==void 0&&e.push(ht(t));return e}static _$Eu(t,e){const s=e.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Lt(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$EC(t,e){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const n=(s.converter?.toAttribute!==void 0?s.converter:K).toAttribute(e,s.type);this._$Em=t,n==null?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const n=s.getPropertyOptions(i),o=typeof n.converter=="function"?{fromAttribute:n.converter}:n.converter?.fromAttribute!==void 0?n.converter:K;this._$Em=i,this[i]=o.fromAttribute(e,n.type),this._$Em=null}}requestUpdate(t,e,s){if(t!==void 0){if(s??=this.constructor.getPropertyOptions(t),!(s.hasChanged??Q)(this[t],e))return;this.P(t,e,s)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,s){this._$AL.has(t)||this._$AL.set(t,e),s.reflect===!0&&this._$Em!==t&&(this._$Ej??=new Set).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[i,n]of this._$Ep)this[i]=n;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[i,n]of s)n.wrapped!==!0||this._$AL.has(i)||this[i]===void 0||this.P(i,this[i],n)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach((s=>s.hostUpdate?.())),this.update(e)):this._$EU()}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&=this._$Ej.forEach((e=>this._$EC(e,this[e]))),this._$EU()}updated(t){}firstUpdated(t){}};O.elementStyles=[],O.shadowRootOptions={mode:"open"},O[U("elementProperties")]=new Map,O[U("finalized")]=new Map,Kt?.({ReactiveElement:O}),(L.reactiveElementVersions??=[]).push("2.0.4");const v={INITIAL:0,COMPLETE:2,ERROR:3},Qt=Symbol();let Zt=class{get taskComplete(){return this.t||(this.i===1?this.t=new Promise(((t,e)=>{this.o=t,this.h=e})):this.i===3?this.t=Promise.reject(this.l):this.t=Promise.resolve(this.u)),this.t}constructor(t,e,s){this.p=0,this.i=0,(this._=t).addController(this);const i=typeof e=="object"?e:{task:e,args:s};this.v=i.task,this.j=i.args,this.m=i.argsEqual??Xt,this.k=i.onComplete,this.A=i.onError,this.autoRun=i.autoRun??!0,"initialValue"in i&&(this.u=i.initialValue,this.i=2,this.O=this.T?.())}hostUpdate(){this.autoRun===!0&&this.S()}hostUpdated(){this.autoRun==="afterUpdate"&&this.S()}T(){if(this.j===void 0)return;const t=this.j();if(!Array.isArray(t))throw Error("The args function must return an array");return t}async S(){const t=this.T(),e=this.O;this.O=t,t===e||t===void 0||e!==void 0&&this.m(e,t)||await this.run(t)}async run(t){let e,s;t??=this.T(),this.O=t,this.i===1?this.q?.abort():(this.t=void 0,this.o=void 0,this.h=void 0),this.i=1,this.autoRun==="afterUpdate"?queueMicrotask((()=>this._.requestUpdate())):this._.requestUpdate();const i=++this.p;this.q=new AbortController;let n=!1;try{e=await this.v(t,{signal:this.q.signal})}catch(o){n=!0,s=o}if(this.p===i){if(e===Qt)this.i=0;else{if(n===!1){try{this.k?.(e)}catch{}this.i=2,this.o?.(e)}else{try{this.A?.(s)}catch{}this.i=3,this.h?.(s)}this.u=e,this.l=s}this._.requestUpdate()}}abort(t){this.i===1&&this.q?.abort(t)}get value(){return this.u}get error(){return this.l}get status(){return this.i}render(t){switch(this.i){case 0:return t.initial?.();case 1:return t.pending?.();case 2:return t.complete?.(this.value);case 3:return t.error?.(this.error);default:throw Error("Unexpected status: "+this.i)}}};const Xt=(r,t)=>r===t||r.length===t.length&&r.every(((e,s)=>!Q(e,t[s])));const q=globalThis,Z=q.ShadowRoot&&(q.ShadyCSS===void 0||q.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,dt=Symbol(),ut=new WeakMap;let Gt=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==dt)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(Z&&t===void 0){const s=e!==void 0&&e.length===1;s&&(t=ut.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&ut.set(e,t))}return t}toString(){return this.cssText}};const Yt=r=>new Gt(typeof r=="string"?r:r+"",void 0,dt),te=(r,t)=>{if(Z)r.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const e of t){const s=document.createElement("style"),i=q.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=e.cssText,r.appendChild(s)}},pt=Z?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return Yt(e)})(r):r;const{is:ee,defineProperty:se,getOwnPropertyDescriptor:ie,getOwnPropertyNames:re,getOwnPropertySymbols:ne,getPrototypeOf:oe}=Object,D=globalThis,ft=D.trustedTypes,ae=ft?ft.emptyScript:"",he=D.reactiveElementPolyfillSupport,R=(r,t)=>r,z={toAttribute(r,t){switch(t){case Boolean:r=r?ae:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,t){let e=r;switch(t){case Boolean:e=r!==null;break;case Number:e=r===null?null:Number(r);break;case Object:case Array:try{e=JSON.parse(r)}catch{e=null}}return e}},X=(r,t)=>!ee(r,t),$t={attribute:!0,type:String,converter:z,reflect:!1,useDefault:!1,hasChanged:X};Symbol.metadata??=Symbol("metadata"),D.litPropertyMetadata??=new WeakMap;let C=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=$t){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);i!==void 0&&se(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=ie(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get:i,set(o){const a=i?.call(this);n?.call(this,o),this.requestUpdate(t,a,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??$t}static _$Ei(){if(this.hasOwnProperty(R("elementProperties")))return;const t=oe(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(R("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(R("properties"))){const e=this.properties,s=[...re(e),...ne(e)];for(const i of s)this.createProperty(i,e[i])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[s,i]of e)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[e,s]of this.elementProperties){const i=this._$Eu(e,s);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)e.unshift(pt(i))}else t!==void 0&&e.push(pt(t));return e}static _$Eu(t,e){const s=e.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return te(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const n=(s.converter?.toAttribute!==void 0?s.converter:z).toAttribute(e,s.type);this._$Em=t,n==null?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const n=s.getPropertyOptions(i),o=typeof n.converter=="function"?{fromAttribute:n.converter}:n.converter?.fromAttribute!==void 0?n.converter:z;this._$Em=i;const a=o.fromAttribute(e,n.type);this[i]=a??this._$Ej?.get(i)??a,this._$Em=null}}requestUpdate(t,e,s){if(t!==void 0){const i=this.constructor,n=this[t];if(s??=i.getPropertyOptions(t),!((s.hasChanged??X)(n,e)||s.useDefault&&s.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(i._$Eu(t,s))))return;this.C(t,e,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),n!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),i===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[i,n]of this._$Ep)this[i]=n;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[i,n]of s){const{wrapped:o}=n,a=this[i];o!==!0||this._$AL.has(i)||a===void 0||this.C(i,void 0,n,a)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach((s=>s.hostUpdate?.())),this.update(e)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach((e=>this._$ET(e,this[e]))),this._$EM()}updated(t){}firstUpdated(t){}};C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[R("elementProperties")]=new Map,C[R("finalized")]=new Map,he?.({ReactiveElement:C}),(D.reactiveElementVersions??=[]).push("2.1.1");const G=globalThis,W=G.trustedTypes,gt=W?W.createPolicy("lit-html",{createHTML:r=>r}):void 0,yt="$lit$",m=`lit$${Math.random().toFixed(9).slice(2)}$`,bt="?"+m,ce=`<${bt}>`,w=document,k=()=>w.createComment(""),N=r=>r===null||typeof r!="object"&&typeof r!="function",Y=Array.isArray,le=r=>Y(r)||typeof r?.[Symbol.iterator]=="function",tt=`[ | ||
| var banners=(function(u){"use strict";let it=class extends Event{constructor(t,e,s,i){super("context-request",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e,this.callback=s,this.subscribe=i??!1}};function He(r){return r}let rt=class{constructor(t,e,s,i){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(n,o)=>{this.unsubscribe&&(this.unsubscribe!==o&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=n,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(n,o)),this.unsubscribe=o},this.host=t,e.context!==void 0){const n=e;this.context=n.context,this.callback=n.callback,this.subscribe=n.subscribe??!1}else this.context=e,this.callback=s,this.subscribe=i??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new it(this.context,this.host,this.t,this.subscribe))}};let Nt=class{get value(){return this.o}set value(t){this.setValue(t)}setValue(t,e=!1){const s=e||!Object.is(t,this.o);this.o=t,s&&this.updateObservers()}constructor(t){this.subscriptions=new Map,this.updateObservers=()=>{for(const[e,{disposer:s}]of this.subscriptions)e(this.o,s)},t!==void 0&&(this.value=t)}addCallback(t,e,s){if(!s)return void t(this.value);this.subscriptions.has(t)||this.subscriptions.set(t,{disposer:()=>{this.subscriptions.delete(t)},consumerHost:e});const{disposer:i}=this.subscriptions.get(t);t(this.value,i)}clearCallbacks(){this.subscriptions.clear()}};let Mt=class extends Event{constructor(t,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e}},nt=class extends Nt{constructor(t,e,s){super(e.context!==void 0?e.initialValue:s),this.onContextRequest=i=>{if(i.context!==this.context)return;const n=i.contextTarget??i.composedPath()[0];n!==this.host&&(i.stopPropagation(),this.addCallback(i.callback,n,i.subscribe))},this.onProviderRequest=i=>{if(i.context!==this.context||(i.contextTarget??i.composedPath()[0])===this.host)return;const n=new Set;for(const[o,{consumerHost:a}]of this.subscriptions)n.has(o)||(n.add(o),a.dispatchEvent(new it(this.context,a,o,!0)));i.stopPropagation()},this.host=t,e.context!==void 0?this.context=e.context:this.context=e,this.attachListeners(),this.host.addController?.(this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new Mt(this.context,this.host))}};function Bt({context:r}){return(t,e)=>{const s=new WeakMap;if(typeof e=="object")return{get(){return t.get.call(this)},set(i){return s.get(this).setValue(i),t.set.call(this,i)},init(i){return s.set(this,new nt(this,{context:r,initialValue:i})),i}};{t.constructor.addInitializer((o=>{s.set(o,new nt(o,{context:r}))}));const i=Object.getOwnPropertyDescriptor(t,e);let n;if(i===void 0){const o=new WeakMap;n={get(){return o.get(this)},set(a){s.get(this).setValue(a),o.set(this,a)},configurable:!0,enumerable:!0}}else{const o=i.set;n={...i,set(a){s.get(this).setValue(a),o?.call(this,a)}}}return void Object.defineProperty(t,e,n)}}}function It({context:r,subscribe:t}){return(e,s)=>{typeof s=="object"?s.addInitializer((function(){new rt(this,{context:r,callback:i=>{e.set.call(this,i)},subscribe:t})})):e.constructor.addInitializer((i=>{new rt(i,{context:r,callback:n=>{i[s]=n},subscribe:t})}))}}const j=globalThis,J=j.ShadowRoot&&(j.ShadyCSS===void 0||j.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ot=Symbol(),at=new WeakMap;let Ht=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==ot)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(J&&t===void 0){const s=e!==void 0&&e.length===1;s&&(t=at.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&at.set(e,t))}return t}toString(){return this.cssText}};const jt=r=>new Ht(typeof r=="string"?r:r+"",void 0,ot),Lt=(r,t)=>{if(J)r.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const e of t){const s=document.createElement("style"),i=j.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=e.cssText,r.appendChild(s)}},ht=J?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return jt(e)})(r):r;const{is:qt,defineProperty:Dt,getOwnPropertyDescriptor:zt,getOwnPropertyNames:Wt,getOwnPropertySymbols:Vt,getPrototypeOf:Ft}=Object,L=globalThis,ct=L.trustedTypes,Jt=ct?ct.emptyScript:"",Kt=L.reactiveElementPolyfillSupport,U=(r,t)=>r,K={toAttribute(r,t){switch(t){case Boolean:r=r?Jt:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,t){let e=r;switch(t){case Boolean:e=r!==null;break;case Number:e=r===null?null:Number(r);break;case Object:case Array:try{e=JSON.parse(r)}catch{e=null}}return e}},Q=(r,t)=>!qt(r,t),lt={attribute:!0,type:String,converter:K,reflect:!1,hasChanged:Q};Symbol.metadata??=Symbol("metadata"),L.litPropertyMetadata??=new WeakMap;let O=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=lt){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);i!==void 0&&Dt(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=zt(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get(){return i?.call(this)},set(o){const a=i?.call(this);n.call(this,o),this.requestUpdate(t,a,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??lt}static _$Ei(){if(this.hasOwnProperty(U("elementProperties")))return;const t=Ft(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(U("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(U("properties"))){const e=this.properties,s=[...Wt(e),...Vt(e)];for(const i of s)this.createProperty(i,e[i])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[s,i]of e)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[e,s]of this.elementProperties){const i=this._$Eu(e,s);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)e.unshift(ht(i))}else t!==void 0&&e.push(ht(t));return e}static _$Eu(t,e){const s=e.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Lt(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$EC(t,e){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const n=(s.converter?.toAttribute!==void 0?s.converter:K).toAttribute(e,s.type);this._$Em=t,n==null?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const n=s.getPropertyOptions(i),o=typeof n.converter=="function"?{fromAttribute:n.converter}:n.converter?.fromAttribute!==void 0?n.converter:K;this._$Em=i,this[i]=o.fromAttribute(e,n.type),this._$Em=null}}requestUpdate(t,e,s){if(t!==void 0){if(s??=this.constructor.getPropertyOptions(t),!(s.hasChanged??Q)(this[t],e))return;this.P(t,e,s)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,s){this._$AL.has(t)||this._$AL.set(t,e),s.reflect===!0&&this._$Em!==t&&(this._$Ej??=new Set).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[i,n]of this._$Ep)this[i]=n;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[i,n]of s)n.wrapped!==!0||this._$AL.has(i)||this[i]===void 0||this.P(i,this[i],n)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach((s=>s.hostUpdate?.())),this.update(e)):this._$EU()}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&=this._$Ej.forEach((e=>this._$EC(e,this[e]))),this._$EU()}updated(t){}firstUpdated(t){}};O.elementStyles=[],O.shadowRootOptions={mode:"open"},O[U("elementProperties")]=new Map,O[U("finalized")]=new Map,Kt?.({ReactiveElement:O}),(L.reactiveElementVersions??=[]).push("2.0.4");const v={INITIAL:0,COMPLETE:2,ERROR:3},Qt=Symbol();let Zt=class{get taskComplete(){return this.t||(this.i===1?this.t=new Promise(((t,e)=>{this.o=t,this.h=e})):this.i===3?this.t=Promise.reject(this.l):this.t=Promise.resolve(this.u)),this.t}constructor(t,e,s){this.p=0,this.i=0,(this._=t).addController(this);const i=typeof e=="object"?e:{task:e,args:s};this.v=i.task,this.j=i.args,this.m=i.argsEqual??Xt,this.k=i.onComplete,this.A=i.onError,this.autoRun=i.autoRun??!0,"initialValue"in i&&(this.u=i.initialValue,this.i=2,this.O=this.T?.())}hostUpdate(){this.autoRun===!0&&this.S()}hostUpdated(){this.autoRun==="afterUpdate"&&this.S()}T(){if(this.j===void 0)return;const t=this.j();if(!Array.isArray(t))throw Error("The args function must return an array");return t}async S(){const t=this.T(),e=this.O;this.O=t,t===e||t===void 0||e!==void 0&&this.m(e,t)||await this.run(t)}async run(t){let e,s;t??=this.T(),this.O=t,this.i===1?this.q?.abort():(this.t=void 0,this.o=void 0,this.h=void 0),this.i=1,this.autoRun==="afterUpdate"?queueMicrotask((()=>this._.requestUpdate())):this._.requestUpdate();const i=++this.p;this.q=new AbortController;let n=!1;try{e=await this.v(t,{signal:this.q.signal})}catch(o){n=!0,s=o}if(this.p===i){if(e===Qt)this.i=0;else{if(n===!1){try{this.k?.(e)}catch{}this.i=2,this.o?.(e)}else{try{this.A?.(s)}catch{}this.i=3,this.h?.(s)}this.u=e,this.l=s}this._.requestUpdate()}}abort(t){this.i===1&&this.q?.abort(t)}get value(){return this.u}get error(){return this.l}get status(){return this.i}render(t){switch(this.i){case 0:return t.initial?.();case 1:return t.pending?.();case 2:return t.complete?.(this.value);case 3:return t.error?.(this.error);default:throw Error("Unexpected status: "+this.i)}}};const Xt=(r,t)=>r===t||r.length===t.length&&r.every(((e,s)=>!Q(e,t[s])));const q=globalThis,Z=q.ShadowRoot&&(q.ShadyCSS===void 0||q.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,dt=Symbol(),ut=new WeakMap;let Gt=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==dt)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(Z&&t===void 0){const s=e!==void 0&&e.length===1;s&&(t=ut.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&ut.set(e,t))}return t}toString(){return this.cssText}};const Yt=r=>new Gt(typeof r=="string"?r:r+"",void 0,dt),te=(r,t)=>{if(Z)r.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const e of t){const s=document.createElement("style"),i=q.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=e.cssText,r.appendChild(s)}},pt=Z?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return Yt(e)})(r):r;const{is:ee,defineProperty:se,getOwnPropertyDescriptor:ie,getOwnPropertyNames:re,getOwnPropertySymbols:ne,getPrototypeOf:oe}=Object,D=globalThis,ft=D.trustedTypes,ae=ft?ft.emptyScript:"",he=D.reactiveElementPolyfillSupport,R=(r,t)=>r,z={toAttribute(r,t){switch(t){case Boolean:r=r?ae:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,t){let e=r;switch(t){case Boolean:e=r!==null;break;case Number:e=r===null?null:Number(r);break;case Object:case Array:try{e=JSON.parse(r)}catch{e=null}}return e}},X=(r,t)=>!ee(r,t),$t={attribute:!0,type:String,converter:z,reflect:!1,useDefault:!1,hasChanged:X};Symbol.metadata??=Symbol("metadata"),D.litPropertyMetadata??=new WeakMap;let x=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=$t){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);i!==void 0&&se(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=ie(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get:i,set(o){const a=i?.call(this);n?.call(this,o),this.requestUpdate(t,a,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??$t}static _$Ei(){if(this.hasOwnProperty(R("elementProperties")))return;const t=oe(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(R("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(R("properties"))){const e=this.properties,s=[...re(e),...ne(e)];for(const i of s)this.createProperty(i,e[i])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[s,i]of e)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[e,s]of this.elementProperties){const i=this._$Eu(e,s);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)e.unshift(pt(i))}else t!==void 0&&e.push(pt(t));return e}static _$Eu(t,e){const s=e.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return te(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const n=(s.converter?.toAttribute!==void 0?s.converter:z).toAttribute(e,s.type);this._$Em=t,n==null?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const n=s.getPropertyOptions(i),o=typeof n.converter=="function"?{fromAttribute:n.converter}:n.converter?.fromAttribute!==void 0?n.converter:z;this._$Em=i;const a=o.fromAttribute(e,n.type);this[i]=a??this._$Ej?.get(i)??a,this._$Em=null}}requestUpdate(t,e,s){if(t!==void 0){const i=this.constructor,n=this[t];if(s??=i.getPropertyOptions(t),!((s.hasChanged??X)(n,e)||s.useDefault&&s.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(i._$Eu(t,s))))return;this.C(t,e,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),n!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),i===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[i,n]of this._$Ep)this[i]=n;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[i,n]of s){const{wrapped:o}=n,a=this[i];o!==!0||this._$AL.has(i)||a===void 0||this.C(i,void 0,n,a)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach((s=>s.hostUpdate?.())),this.update(e)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach((e=>this._$ET(e,this[e]))),this._$EM()}updated(t){}firstUpdated(t){}};x.elementStyles=[],x.shadowRootOptions={mode:"open"},x[R("elementProperties")]=new Map,x[R("finalized")]=new Map,he?.({ReactiveElement:x}),(D.reactiveElementVersions??=[]).push("2.1.1");const G=globalThis,W=G.trustedTypes,gt=W?W.createPolicy("lit-html",{createHTML:r=>r}):void 0,bt="$lit$",m=`lit$${Math.random().toFixed(9).slice(2)}$`,yt="?"+m,ce=`<${yt}>`,w=document,k=()=>w.createComment(""),N=r=>r===null||typeof r!="object"&&typeof r!="function",Y=Array.isArray,le=r=>Y(r)||typeof r?.[Symbol.iterator]=="function",tt=`[ | ||
| \f\r]`,M=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,mt=/-->/g,_t=/>/g,E=RegExp(`>|${tt}(?:([^\\s"'>=/]+)(${tt}*=${tt}*(?:[^ | ||
| \f\r"'\`<>=]|("|')|))|$)`,"g"),vt=/'/g,wt=/"/g,Et=/^(?:script|style|textarea|title)$/i,de=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),$=de(1),T=Symbol.for("lit-noChange"),p=Symbol.for("lit-nothing"),St=new WeakMap,S=w.createTreeWalker(w,129);function At(r,t){if(!Y(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return gt!==void 0?gt.createHTML(t):t}const ue=(r,t)=>{const e=r.length-1,s=[];let i,n=t===2?"<svg>":t===3?"<math>":"",o=M;for(let a=0;a<e;a++){const h=r[a];let l,d,c=-1,g=0;for(;g<h.length&&(o.lastIndex=g,d=o.exec(h),d!==null);)g=o.lastIndex,o===M?d[1]==="!--"?o=mt:d[1]!==void 0?o=_t:d[2]!==void 0?(Et.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=E):d[3]!==void 0&&(o=E):o===E?d[0]===">"?(o=i??M,c=-1):d[1]===void 0?c=-2:(c=o.lastIndex-d[2].length,l=d[1],o=d[3]===void 0?E:d[3]==='"'?wt:vt):o===wt||o===vt?o=E:o===mt||o===_t?o=M:(o=E,i=void 0);const _=o===E&&r[a+1].startsWith("/>")?" ":"";n+=o===M?h+ce:c>=0?(s.push(l),h.slice(0,c)+yt+h.slice(c)+m+_):h+m+(c===-2?a:_)}return[At(r,n+(r[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};class B{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,o=0;const a=t.length-1,h=this.parts,[l,d]=ue(t,e);if(this.el=B.createElement(l,s),S.currentNode=this.el.content,e===2||e===3){const c=this.el.content.firstChild;c.replaceWith(...c.childNodes)}for(;(i=S.nextNode())!==null&&h.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const c of i.getAttributeNames())if(c.endsWith(yt)){const g=d[o++],_=i.getAttribute(c).split(m),F=/([.?@])?(.*)/.exec(g);h.push({type:1,index:n,name:F[2],strings:_,ctor:F[1]==="."?fe:F[1]==="?"?$e:F[1]==="@"?ge:V}),i.removeAttribute(c)}else c.startsWith(m)&&(h.push({type:6,index:n}),i.removeAttribute(c));if(Et.test(i.tagName)){const c=i.textContent.split(m),g=c.length-1;if(g>0){i.textContent=W?W.emptyScript:"";for(let _=0;_<g;_++)i.append(c[_],k()),S.nextNode(),h.push({type:2,index:++n});i.append(c[g],k())}}}else if(i.nodeType===8)if(i.data===bt)h.push({type:2,index:n});else{let c=-1;for(;(c=i.data.indexOf(m,c+1))!==-1;)h.push({type:7,index:n}),c+=m.length-1}n++}}static createElement(t,e){const s=w.createElement("template");return s.innerHTML=t,s}}function P(r,t,e=r,s){if(t===T)return t;let i=s!==void 0?e._$Co?.[s]:e._$Cl;const n=N(t)?void 0:t._$litDirective$;return i?.constructor!==n&&(i?._$AO?.(!1),n===void 0?i=void 0:(i=new n(r),i._$AT(r,e,s)),s!==void 0?(e._$Co??=[])[s]=i:e._$Cl=i),i!==void 0&&(t=P(r,i._$AS(r,t.values),i,s)),t}class pe{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=(t?.creationScope??w).importNode(e,!0);S.currentNode=i;let n=S.nextNode(),o=0,a=0,h=s[0];for(;h!==void 0;){if(o===h.index){let l;h.type===2?l=new I(n,n.nextSibling,this,t):h.type===1?l=new h.ctor(n,h.name,h.strings,this,t):h.type===6&&(l=new ye(n,this,t)),this._$AV.push(l),h=s[++a]}o!==h?.index&&(n=S.nextNode(),o++)}return S.currentNode=w,i}p(t){let e=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class I{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=p,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=P(this,t,e),N(t)?t===p||t==null||t===""?(this._$AH!==p&&this._$AR(),this._$AH=p):t!==this._$AH&&t!==T&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):le(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==p&&N(this._$AH)?this._$AA.nextSibling.data=t:this.T(w.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=B.createElement(At(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{const n=new pe(i,this),o=n.u(this.options);n.p(e),this.T(o),this._$AH=n}}_$AC(t){let e=St.get(t.strings);return e===void 0&&St.set(t.strings,e=new B(t)),e}k(t){Y(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new I(this.O(k()),this.O(k()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}}class V{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=p,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=p}_$AI(t,e=this,s,i){const n=this.strings;let o=!1;if(n===void 0)t=P(this,t,e,0),o=!N(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else{const a=t;let h,l;for(t=n[0],h=0;h<n.length-1;h++)l=P(this,a[s+h],e,h),l===T&&(l=this._$AH[h]),o||=!N(l)||l!==this._$AH[h],l===p?t=p:t!==p&&(t+=(l??"")+n[h+1]),this._$AH[h]=l}o&&!i&&this.j(t)}j(t){t===p?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class fe extends V{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===p?void 0:t}}class $e extends V{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==p)}}class ge extends V{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=P(this,t,e,0)??p)===T)return;const s=this._$AH,i=t===p&&s!==p||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==p&&(s===p||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class ye{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){P(this,t)}}const be=G.litHtmlPolyfillSupport;be?.(B,I),(G.litHtmlVersions??=[]).push("3.3.1");const me=(r,t,e)=>{const s=e?.renderBefore??t;let i=s._$litPart$;if(i===void 0){const n=e?.renderBefore??null;s._$litPart$=i=new I(t.insertBefore(k(),n),n,void 0,e??{})}return i._$AI(r),i};const et=globalThis;class A extends C{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=me(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return T}}A._$litElement$=!0,A.finalized=!0,et.litElementHydrateSupport?.({LitElement:A});const _e=et.litElementPolyfillSupport;_e?.({LitElement:A}),(et.litElementVersions??=[]).push("4.2.1");const st=r=>(t,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(r,t)})):customElements.define(r,t)};const ve={attribute:!0,type:String,converter:z,reflect:!1,hasChanged:X},we=(r=ve,t,e)=>{const{kind:s,metadata:i}=e;let n=globalThis.litPropertyMetadata.get(i);if(n===void 0&&globalThis.litPropertyMetadata.set(i,n=new Map),s==="setter"&&((r=Object.create(r)).wrapped=!0),n.set(e.name,r),s==="accessor"){const{name:o}=e;return{set(a){const h=t.get.call(this);t.set.call(this,a),this.requestUpdate(o,h,r)},init(a){return a!==void 0&&this.C(o,void 0,r,a),a}}}if(s==="setter"){const{name:o}=e;return function(a){const h=this[o];t.call(this,a),this.requestUpdate(o,h,r)}}throw Error("Unsupported decorator location: "+s)};function f(r){return(t,e)=>typeof e=="object"?we(r,t,e):((s,i,n)=>{const o=i.hasOwnProperty(n);return i.constructor.createProperty(n,s),o?Object.getOwnPropertyDescriptor(i,n):void 0})(r,t,e)}const Ee=r=>r??p;class xt extends Error{constructor(t,e){super(t),this.name="TopsortRequestError",this.status=e}static isTopsortRequestError(t){return t.name==="TopsortRequestError"}}class Se extends Error{constructor(t,e){let s="Missing ";!e&&!t?s+="API Key and Slot ID":e?t||(s+="API Key"):s+="Slot ID",super(s),this.name="TopsortConfigurationError"}static isTopsortConfigurationError(t){return t.name==="TopsortConfigurationError"}}function Ae(){if(window.TS?.getUserId&&typeof window.TS.getUserId=="function")return window.TS.getUserId()}const xe=()=>{const r=navigator.userAgent;return/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(r)||/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(r)?"mobile":"desktop"};async function Ce(r,{signal:t,logError:e}){const{device:s}=r,i=window.TS.token,n=window.TS.url||"https://api.topsort.com",o=Ae();o&&(r.opaqueUserId=o);const a=await fetch(new URL(`${n}/v2/auctions`),{method:"POST",mode:"cors",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-UA":`topsort/banners-0.8.1 (${s})`},body:JSON.stringify({auctions:[r]}),signal:t});if(!a.ok){const d=await a.json().catch(()=>({}));throw new xt(d.message??`HTTP ${a.status}`,a.status)}const l=(await a.json()).results[0];if(!l)throw new xt("No auction results",a.status);if(l.error)throw e(l.error),new Error(l.error);return l.winners}var Te=Object.defineProperty,b=(r,t,e,s)=>{for(var i=void 0,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(t,e,i)||i);return i&&Te(t,e,i),i};const Pe=r=>{class t extends r{constructor(){super(...arguments),this.width=0,this.height=0,this.slotId="",this.newTab=!1}buildAuction(s){const i=xe(),n={type:"banners",slots:s,device:i,slotId:this.slotId};return this.categoryId?n.category={id:this.categoryId}:this.categoryIds?n.category={ids:this.categoryIds.split(",").map(o=>o.trim())}:this.categoryDisjunctions?n.category={disjunctions:[this.categoryDisjunctions.split(",").map(o=>o.trim())]}:this.searchQuery&&(n.searchQuery=this.searchQuery),this.location&&(n.geoTargeting={location:this.location}),n}emitEvent(s){const i=new CustomEvent("statechange",{detail:{slotId:this.slotId,status:s},bubbles:!0,composed:!0});this.dispatchEvent(i)}}return b([f({type:Number})],t.prototype,"width"),b([f({type:Number})],t.prototype,"height"),b([f({attribute:"id",type:String})],t.prototype,"slotId"),b([f({attribute:"category-id",type:String})],t.prototype,"categoryId"),b([f({attribute:"category-ids",type:String})],t.prototype,"categoryIds"),b([f({attribute:"category-disjunctions",type:String})],t.prototype,"categoryDisjunctions"),b([f({attribute:"search-query",type:String})],t.prototype,"searchQuery"),b([f({attribute:"location",type:String})],t.prototype,"location"),b([f({attribute:"new-tab",type:Boolean})],t.prototype,"newTab"),t};let Ct=!1;function Ue(r){const t=[];for(const e of r.split(",")){const s=e.trim();if(!s)continue;const i=s.indexOf(":");i===-1?t.push({key:s,target:null}):t.push({key:s.slice(0,i),target:s.slice(i+1)})}return t}function Tt(r,t){if(t)return t;const e=r.tagName.toLowerCase();return e==="a"?"href":e==="img"||e==="video"||e==="source"?"src":"textContent"}function Oe(r,t,e){return e==="textContent"?(r.textContent=t,!0):r.hasAttribute(e)?(r.setAttribute(e,t),!0):!1}function Pt(r,t){const e=t.asset?.[0]?.content;if(e){const i=r.querySelectorAll("[data-ts-field]");for(const n of i){const o=n.dataset.tsField;if(!o)continue;const a=Ue(o),h=a.some(l=>l.target!==null);for(const{key:l,target:d}of a){if(!(l in e))continue;let c;if(!h&&d===null){const g=n.dataset.tsAttr;Ct||(Ct=!0,console.warn('[banners.js] Implicit data-ts-field binding is deprecated. Use explicit "key:target" syntax instead (e.g. data-ts-field="image:src").')),c=Tt(n,g??null)}else c=Tt(n,d);if(!Oe(n,e[l],c)){const g=n.tagName.toLowerCase();console.warn(`[banners.js] Binding "${l}" → "${c}" skipped: <${g}> has no "${c}" attribute. Add a fallback value (e.g. ${c}="...") to your template.`)}}}}const s=r.querySelector("[data-ts-clickable]")||r.firstElementChild;s&&(s.setAttribute("data-ts-clickable",""),t.isFallback||s.setAttribute("data-ts-resolved-bid",t.resolvedBidId))}var Re=Object.defineProperty,ke=Object.getOwnPropertyDescriptor,y=(r,t,e,s)=>{for(var i=s>1?void 0:s?ke(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&Re(t,e,i),i};window.TS_BANNERS=window.TS_BANNERS||{};function Ne(r){}function Me(r){return window.TS_BANNERS.getLink?window.TS_BANNERS.getLink(r):r.type==="url"?r.id:`${r.type}/${r.id}`}function Ut(){if(window.TS_BANNERS.getLoadingElement){const r=window.TS_BANNERS.getLoadingElement();return $`${r}`}return $``}function H(r){if(window.TS_BANNERS.getErrorElement){const t=window.TS_BANNERS.getErrorElement(r);return $`${t}`}return $``}function Ot(){if(window.TS_BANNERS.getNoWinnersElement){const r=window.TS_BANNERS.getNoWinnersElement();return $`${r}`}return $``}function Rt(r,t,e,s){if(window.TS_BANNERS.getBannerElement){const l=window.TS_BANNERS.getBannerElement(r);return $`${l}`}if(!r.asset?.[0]?.url)return $``;const i=r.asset[0].url,o=(()=>{try{const d=new URL(i).pathname.split("/"),c=d.indexOf("manifest");return c>=0?d[c+1]?.startsWith("video")??!1:!1}catch{return!1}})()?$` | ||
| \f\r"'\`<>=]|("|')|))|$)`,"g"),vt=/'/g,wt=/"/g,Et=/^(?:script|style|textarea|title)$/i,de=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),$=de(1),T=Symbol.for("lit-noChange"),p=Symbol.for("lit-nothing"),St=new WeakMap,S=w.createTreeWalker(w,129);function At(r,t){if(!Y(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return gt!==void 0?gt.createHTML(t):t}const ue=(r,t)=>{const e=r.length-1,s=[];let i,n=t===2?"<svg>":t===3?"<math>":"",o=M;for(let a=0;a<e;a++){const h=r[a];let l,d,c=-1,g=0;for(;g<h.length&&(o.lastIndex=g,d=o.exec(h),d!==null);)g=o.lastIndex,o===M?d[1]==="!--"?o=mt:d[1]!==void 0?o=_t:d[2]!==void 0?(Et.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=E):d[3]!==void 0&&(o=E):o===E?d[0]===">"?(o=i??M,c=-1):d[1]===void 0?c=-2:(c=o.lastIndex-d[2].length,l=d[1],o=d[3]===void 0?E:d[3]==='"'?wt:vt):o===wt||o===vt?o=E:o===mt||o===_t?o=M:(o=E,i=void 0);const _=o===E&&r[a+1].startsWith("/>")?" ":"";n+=o===M?h+ce:c>=0?(s.push(l),h.slice(0,c)+bt+h.slice(c)+m+_):h+m+(c===-2?a:_)}return[At(r,n+(r[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};class B{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,o=0;const a=t.length-1,h=this.parts,[l,d]=ue(t,e);if(this.el=B.createElement(l,s),S.currentNode=this.el.content,e===2||e===3){const c=this.el.content.firstChild;c.replaceWith(...c.childNodes)}for(;(i=S.nextNode())!==null&&h.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const c of i.getAttributeNames())if(c.endsWith(bt)){const g=d[o++],_=i.getAttribute(c).split(m),F=/([.?@])?(.*)/.exec(g);h.push({type:1,index:n,name:F[2],strings:_,ctor:F[1]==="."?fe:F[1]==="?"?$e:F[1]==="@"?ge:V}),i.removeAttribute(c)}else c.startsWith(m)&&(h.push({type:6,index:n}),i.removeAttribute(c));if(Et.test(i.tagName)){const c=i.textContent.split(m),g=c.length-1;if(g>0){i.textContent=W?W.emptyScript:"";for(let _=0;_<g;_++)i.append(c[_],k()),S.nextNode(),h.push({type:2,index:++n});i.append(c[g],k())}}}else if(i.nodeType===8)if(i.data===yt)h.push({type:2,index:n});else{let c=-1;for(;(c=i.data.indexOf(m,c+1))!==-1;)h.push({type:7,index:n}),c+=m.length-1}n++}}static createElement(t,e){const s=w.createElement("template");return s.innerHTML=t,s}}function P(r,t,e=r,s){if(t===T)return t;let i=s!==void 0?e._$Co?.[s]:e._$Cl;const n=N(t)?void 0:t._$litDirective$;return i?.constructor!==n&&(i?._$AO?.(!1),n===void 0?i=void 0:(i=new n(r),i._$AT(r,e,s)),s!==void 0?(e._$Co??=[])[s]=i:e._$Cl=i),i!==void 0&&(t=P(r,i._$AS(r,t.values),i,s)),t}class pe{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=(t?.creationScope??w).importNode(e,!0);S.currentNode=i;let n=S.nextNode(),o=0,a=0,h=s[0];for(;h!==void 0;){if(o===h.index){let l;h.type===2?l=new I(n,n.nextSibling,this,t):h.type===1?l=new h.ctor(n,h.name,h.strings,this,t):h.type===6&&(l=new be(n,this,t)),this._$AV.push(l),h=s[++a]}o!==h?.index&&(n=S.nextNode(),o++)}return S.currentNode=w,i}p(t){let e=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class I{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=p,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=P(this,t,e),N(t)?t===p||t==null||t===""?(this._$AH!==p&&this._$AR(),this._$AH=p):t!==this._$AH&&t!==T&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):le(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==p&&N(this._$AH)?this._$AA.nextSibling.data=t:this.T(w.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=B.createElement(At(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{const n=new pe(i,this),o=n.u(this.options);n.p(e),this.T(o),this._$AH=n}}_$AC(t){let e=St.get(t.strings);return e===void 0&&St.set(t.strings,e=new B(t)),e}k(t){Y(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new I(this.O(k()),this.O(k()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}}class V{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=p,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=p}_$AI(t,e=this,s,i){const n=this.strings;let o=!1;if(n===void 0)t=P(this,t,e,0),o=!N(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else{const a=t;let h,l;for(t=n[0],h=0;h<n.length-1;h++)l=P(this,a[s+h],e,h),l===T&&(l=this._$AH[h]),o||=!N(l)||l!==this._$AH[h],l===p?t=p:t!==p&&(t+=(l??"")+n[h+1]),this._$AH[h]=l}o&&!i&&this.j(t)}j(t){t===p?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class fe extends V{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===p?void 0:t}}class $e extends V{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==p)}}class ge extends V{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=P(this,t,e,0)??p)===T)return;const s=this._$AH,i=t===p&&s!==p||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==p&&(s===p||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class be{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){P(this,t)}}const ye=G.litHtmlPolyfillSupport;ye?.(B,I),(G.litHtmlVersions??=[]).push("3.3.1");const me=(r,t,e)=>{const s=e?.renderBefore??t;let i=s._$litPart$;if(i===void 0){const n=e?.renderBefore??null;s._$litPart$=i=new I(t.insertBefore(k(),n),n,void 0,e??{})}return i._$AI(r),i};const et=globalThis;class A extends x{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=me(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return T}}A._$litElement$=!0,A.finalized=!0,et.litElementHydrateSupport?.({LitElement:A});const _e=et.litElementPolyfillSupport;_e?.({LitElement:A}),(et.litElementVersions??=[]).push("4.2.1");const st=r=>(t,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(r,t)})):customElements.define(r,t)};const ve={attribute:!0,type:String,converter:z,reflect:!1,hasChanged:X},we=(r=ve,t,e)=>{const{kind:s,metadata:i}=e;let n=globalThis.litPropertyMetadata.get(i);if(n===void 0&&globalThis.litPropertyMetadata.set(i,n=new Map),s==="setter"&&((r=Object.create(r)).wrapped=!0),n.set(e.name,r),s==="accessor"){const{name:o}=e;return{set(a){const h=t.get.call(this);t.set.call(this,a),this.requestUpdate(o,h,r)},init(a){return a!==void 0&&this.C(o,void 0,r,a),a}}}if(s==="setter"){const{name:o}=e;return function(a){const h=this[o];t.call(this,a),this.requestUpdate(o,h,r)}}throw Error("Unsupported decorator location: "+s)};function f(r){return(t,e)=>typeof e=="object"?we(r,t,e):((s,i,n)=>{const o=i.hasOwnProperty(n);return i.constructor.createProperty(n,s),o?Object.getOwnPropertyDescriptor(i,n):void 0})(r,t,e)}const Ee=r=>r??p;class Ct extends Error{constructor(t,e){super(t),this.name="TopsortRequestError",this.status=e}static isTopsortRequestError(t){return t.name==="TopsortRequestError"}}class Se extends Error{constructor(t,e){let s="Missing ";!e&&!t?s+="API Key and Slot ID":e?t||(s+="API Key"):s+="Slot ID",super(s),this.name="TopsortConfigurationError"}static isTopsortConfigurationError(t){return t.name==="TopsortConfigurationError"}}function Ae(){if(window.TS?.getUserId&&typeof window.TS.getUserId=="function")return window.TS.getUserId()}const Ce=()=>{const r=navigator.userAgent;return/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(r)||/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(r)?"mobile":"desktop"};async function xe(r,{signal:t,logError:e}){const{device:s}=r,i=window.TS.token,n=window.TS.url||"https://api.topsort.com",o=Ae();o&&(r.opaqueUserId=o);const a=await fetch(new URL(`${n}/v2/auctions`),{method:"POST",mode:"cors",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json","X-UA":`topsort/banners-0.8.2 (${s})`},body:JSON.stringify({auctions:[r]}),signal:t});if(!a.ok){const d=await a.json().catch(()=>({}));throw new Ct(d.message??`HTTP ${a.status}`,a.status)}const l=(await a.json()).results[0];if(!l)throw new Ct("No auction results",a.status);if(l.error)throw e(l.error),new Error(l.error);return l.winners}var Te=Object.defineProperty,y=(r,t,e,s)=>{for(var i=void 0,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(t,e,i)||i);return i&&Te(t,e,i),i};const Pe=r=>{class t extends r{constructor(){super(...arguments),this.width=0,this.height=0,this.slotId="",this.newTab=!1}buildAuction(s){const i=Ce(),n={type:"banners",slots:s,device:i,slotId:this.slotId};return this.categoryId?n.category={id:this.categoryId}:this.categoryIds?n.category={ids:this.categoryIds.split(",").map(o=>o.trim())}:this.categoryDisjunctions&&(n.category={disjunctions:[this.categoryDisjunctions.split(",").map(o=>o.trim())]}),this.searchQuery&&(n.searchQuery=this.searchQuery),this.location&&(n.geoTargeting={location:this.location}),n}emitEvent(s){const i=new CustomEvent("statechange",{detail:{slotId:this.slotId,status:s},bubbles:!0,composed:!0});this.dispatchEvent(i)}}return y([f({type:Number})],t.prototype,"width"),y([f({type:Number})],t.prototype,"height"),y([f({attribute:"id",type:String})],t.prototype,"slotId"),y([f({attribute:"category-id",type:String})],t.prototype,"categoryId"),y([f({attribute:"category-ids",type:String})],t.prototype,"categoryIds"),y([f({attribute:"category-disjunctions",type:String})],t.prototype,"categoryDisjunctions"),y([f({attribute:"search-query",type:String})],t.prototype,"searchQuery"),y([f({attribute:"location",type:String})],t.prototype,"location"),y([f({attribute:"new-tab",type:Boolean})],t.prototype,"newTab"),t};let xt=!1;function Ue(r){const t=[];for(const e of r.split(",")){const s=e.trim();if(!s)continue;const i=s.indexOf(":");i===-1?t.push({key:s,target:null}):t.push({key:s.slice(0,i),target:s.slice(i+1)})}return t}function Tt(r,t){if(t)return t;const e=r.tagName.toLowerCase();return e==="a"?"href":e==="img"||e==="video"||e==="source"?"src":"textContent"}function Oe(r,t,e){return e==="textContent"?(r.textContent=t,!0):r.hasAttribute(e)?(r.setAttribute(e,t),!0):!1}function Pt(r,t){const e=t.asset?.[0]?.content;if(e){const i=r.querySelectorAll("[data-ts-field]");for(const n of i){const o=n.dataset.tsField;if(!o)continue;const a=Ue(o),h=a.some(l=>l.target!==null);for(const{key:l,target:d}of a){if(!(l in e))continue;let c;if(!h&&d===null){const g=n.dataset.tsAttr;xt||(xt=!0,console.warn('[banners.js] Implicit data-ts-field binding is deprecated. Use explicit "key:target" syntax instead (e.g. data-ts-field="image:src").')),c=Tt(n,g??null)}else c=Tt(n,d);if(!Oe(n,e[l],c)){const g=n.tagName.toLowerCase();console.warn(`[banners.js] Binding "${l}" → "${c}" skipped: <${g}> has no "${c}" attribute. Add a fallback value (e.g. ${c}="...") to your template.`)}}}}const s=r.querySelector("[data-ts-clickable]")||r.firstElementChild;s&&(s.setAttribute("data-ts-clickable",""),t.isFallback||s.setAttribute("data-ts-resolved-bid",t.resolvedBidId))}var Re=Object.defineProperty,ke=Object.getOwnPropertyDescriptor,b=(r,t,e,s)=>{for(var i=s>1?void 0:s?ke(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&Re(t,e,i),i};window.TS_BANNERS=window.TS_BANNERS||{};function Ne(r){}function Me(r){return window.TS_BANNERS.getLink?window.TS_BANNERS.getLink(r):r.type==="url"?r.id:`${r.type}/${r.id}`}function Ut(){if(window.TS_BANNERS.getLoadingElement){const r=window.TS_BANNERS.getLoadingElement();return $`${r}`}return $``}function H(r){if(window.TS_BANNERS.getErrorElement){const t=window.TS_BANNERS.getErrorElement(r);return $`${t}`}return $``}function Ot(){if(window.TS_BANNERS.getNoWinnersElement){const r=window.TS_BANNERS.getNoWinnersElement();return $`${r}`}return $``}function Rt(r,t,e,s){if(window.TS_BANNERS.getBannerElement){const l=window.TS_BANNERS.getBannerElement(r);return $`${l}`}if(!r.asset?.[0]?.url)return $``;const i=r.asset[0].url,o=(()=>{try{const d=new URL(i).pathname.split("/"),c=d.indexOf("manifest");return c>=0?d[c+1]?.startsWith("video")??!1:!1}catch{return!1}})()?$` | ||
| <hls-video | ||
@@ -23,3 +23,3 @@ src="${i}" | ||
| </div> | ||
| `}const kt=Symbol("banner-context"),Be=(r,t)=>!t&&r?!0:r==null||t==null?!1:r.width!==t.width||r.height!==t.height||r.newTab!==t.newTab||!!r.error!=!!t.error||r.banners?.length!==t.banners?.length;u.TopsortBanner=class extends Pe(A){constructor(){super(...arguments),this.task=new Zt(this,{task:([t],e)=>Ce(this.buildAuction(t),{...e,logError:Ne}).then(s=>(e.signal.throwIfAborted(),this.isContext&&(this.context={...this.context,banners:s}),s)).catch(s=>{throw e.signal.throwIfAborted(),this.isContext&&(this.context={...this.context,error:s}),s}),args:()=>[this.slots?.length||1]}),this.context={width:this.width,height:this.height,newTab:this.newTab},this.isContext=!1,this.predefined=!1,this._prevTaskStatus=v.INITIAL}render(){return!window.TS.token||!this.slotId?H(new Se(window.TS.token,this.slotId)):this.isContext?$``:this.predefined?p:this.task.render({pending:()=>Ut(),complete:t=>{if(!t.length)return Ot();if(t[0].asset?.[0]?.content){const e=new Error("Banner has predefined content but component is not in predefined mode");return H(e)}return Rt(t[0],this.width,this.height,this.newTab)},error:t=>H(t)})}updated(t){super.updated(t);const e=this._prevTaskStatus,s=this.task.status;this._prevTaskStatus=s;const i=this.task.value??[];if(this.predefined&&e!==v.COMPLETE&&s===v.COMPLETE)if(i.length&&i[0].asset?.[0]?.content)try{Pt(this,i[0])}catch{}else i.length&&console.warn(`[topsort-banner] Predefined mode is set but the auction response for slot "${this.slotId}" contains no content map. Template was not mutated.`);this.isContext||(e!==v.COMPLETE&&s===v.COMPLETE?this.emitEvent(i.length?"ready":"nowinners"):e!==v.ERROR&&s===v.ERROR&&this.emitEvent("error")),this.isContext&&!t.has("slots")&&Promise.resolve().then(()=>{this.slots=this.renderRoot.querySelectorAll("topsort-banner-slot")}),t.has("width")&&this.style.setProperty("--ts-banner-width",`${this.width}px`),t.has("height")&&this.style.setProperty("--ts-banner-height",`${this.height}px`),(t.has("width")||t.has("height")||t.has("newTab"))&&Promise.resolve().then(()=>{this.context={...this.context,width:this.width,height:this.height,newTab:this.newTab}})}createRenderRoot(){return this}},y([Bt({context:kt}),f({attribute:!1,hasChanged:Be})],u.TopsortBanner.prototype,"context",2),y([f({type:Boolean,attribute:"context"})],u.TopsortBanner.prototype,"isContext",2),y([f({type:Boolean})],u.TopsortBanner.prototype,"predefined",2),y([f({attribute:!1,state:!0})],u.TopsortBanner.prototype,"slots",2),u.TopsortBanner=y([st("topsort-banner")],u.TopsortBanner),u.TopsortBannerSlot=class extends A{constructor(){super(...arguments),this.rank=1,this.predefined=!1}_bannerForRank(){if(!(!this.context?.banners?.length||this.rank<1||this.context.banners.length<this.rank))return this.context.banners[this.rank-1]}render(){if(this.predefined)return p;if(!this.context)return $``;if(!this.context.banners)return Ut();if(this.context.error)return H(this.context.error);if(!this.context.banners.length||this.context.banners.length<this.rank)return Ot();const t=this.context.banners[this.rank-1];if(t.asset?.[0]?.content){const e=new Error("Banner has predefined content but component is not in predefined mode");return H(e)}return Rt(t,this.context.width,this.context.height,this.context.newTab)}updated(t){if(super.updated(t),this.predefined&&t.has("context")&&!t.get("context")?.banners&&!!this.context?.banners){const i=this._bannerForRank();if(i?.asset?.[0]?.content)try{Pt(this,i)}catch{}else i&&console.warn(`[topsort-banner-slot] Predefined mode is set but the auction response for rank ${this.rank} contains no content map. Template was not mutated.`)}}createRenderRoot(){return this}},y([It({context:kt,subscribe:!0}),f({attribute:!1})],u.TopsortBannerSlot.prototype,"context",2),y([f({attribute:"rank",type:Number})],u.TopsortBannerSlot.prototype,"rank",2),y([f({type:Boolean})],u.TopsortBannerSlot.prototype,"predefined",2),u.TopsortBannerSlot=y([st("topsort-banner-slot")],u.TopsortBannerSlot),u.HlsVideo=class extends A{constructor(){super(...arguments),this.src="",this.width="800px",this.height="400px"}get videoId(){try{return new URL(this.src).pathname.split("/")[1]}catch{return"hls-video"}}render(){return $` | ||
| `}const kt=Symbol("banner-context"),Be=(r,t)=>!t&&r?!0:r==null||t==null?!1:r.width!==t.width||r.height!==t.height||r.newTab!==t.newTab||!!r.error!=!!t.error||r.banners?.length!==t.banners?.length;u.TopsortBanner=class extends Pe(A){constructor(){super(...arguments),this.task=new Zt(this,{task:([t],e)=>xe(this.buildAuction(t),{...e,logError:Ne}).then(s=>(e.signal.throwIfAborted(),this.isContext&&(this.context={...this.context,banners:s}),s)).catch(s=>{throw e.signal.throwIfAborted(),this.isContext&&(this.context={...this.context,error:s}),s}),args:()=>[this.slots?.length||1]}),this.context={width:this.width,height:this.height,newTab:this.newTab},this.isContext=!1,this.predefined=!1,this._prevTaskStatus=v.INITIAL}render(){return!window.TS.token||!this.slotId?H(new Se(window.TS.token,this.slotId)):this.isContext?$``:this.predefined?p:this.task.render({pending:()=>Ut(),complete:t=>{if(!t.length)return Ot();if(t[0].asset?.[0]?.content){const e=new Error("Banner has predefined content but component is not in predefined mode");return H(e)}return Rt(t[0],this.width,this.height,this.newTab)},error:t=>H(t)})}updated(t){super.updated(t);const e=this._prevTaskStatus,s=this.task.status;this._prevTaskStatus=s;const i=this.task.value??[];if(this.predefined&&e!==v.COMPLETE&&s===v.COMPLETE)if(i.length&&i[0].asset?.[0]?.content)try{Pt(this,i[0])}catch{}else i.length&&console.warn(`[topsort-banner] Predefined mode is set but the auction response for slot "${this.slotId}" contains no content map. Template was not mutated.`);this.isContext||(e!==v.COMPLETE&&s===v.COMPLETE?this.emitEvent(i.length?"ready":"nowinners"):e!==v.ERROR&&s===v.ERROR&&this.emitEvent("error")),this.isContext&&!t.has("slots")&&Promise.resolve().then(()=>{this.slots=this.renderRoot.querySelectorAll("topsort-banner-slot")}),t.has("width")&&this.style.setProperty("--ts-banner-width",`${this.width}px`),t.has("height")&&this.style.setProperty("--ts-banner-height",`${this.height}px`),(t.has("width")||t.has("height")||t.has("newTab"))&&Promise.resolve().then(()=>{this.context={...this.context,width:this.width,height:this.height,newTab:this.newTab}})}createRenderRoot(){return this}},b([Bt({context:kt}),f({attribute:!1,hasChanged:Be})],u.TopsortBanner.prototype,"context",2),b([f({type:Boolean,attribute:"context"})],u.TopsortBanner.prototype,"isContext",2),b([f({type:Boolean})],u.TopsortBanner.prototype,"predefined",2),b([f({attribute:!1,state:!0})],u.TopsortBanner.prototype,"slots",2),u.TopsortBanner=b([st("topsort-banner")],u.TopsortBanner),u.TopsortBannerSlot=class extends A{constructor(){super(...arguments),this.rank=1,this.predefined=!1}_bannerForRank(){if(!(!this.context?.banners?.length||this.rank<1||this.context.banners.length<this.rank))return this.context.banners[this.rank-1]}render(){if(this.predefined)return p;if(!this.context)return $``;if(!this.context.banners)return Ut();if(this.context.error)return H(this.context.error);if(!this.context.banners.length||this.context.banners.length<this.rank)return Ot();const t=this.context.banners[this.rank-1];if(t.asset?.[0]?.content){const e=new Error("Banner has predefined content but component is not in predefined mode");return H(e)}return Rt(t,this.context.width,this.context.height,this.context.newTab)}updated(t){if(super.updated(t),t.has("context")){const e=t.get("context");if(!e?.banners&&!!this.context?.banners){if(this.predefined){const n=this._bannerForRank();if(n?.asset?.[0]?.content)try{Pt(this,n)}catch{}else n&&console.warn(`[topsort-banner-slot] Predefined mode is set but the auction response for rank ${this.rank} contains no content map. Template was not mutated.`)}const i=this._bannerForRank();this._emitStateChange(i?"ready":"nowinners")}!e?.error&&this.context?.error&&this._emitStateChange("error")}}_emitStateChange(t){this.dispatchEvent(new CustomEvent("statechange",{detail:{rank:this.rank,status:t},bubbles:!0,composed:!0}))}createRenderRoot(){return this}},b([It({context:kt,subscribe:!0}),f({attribute:!1})],u.TopsortBannerSlot.prototype,"context",2),b([f({attribute:"rank",type:Number})],u.TopsortBannerSlot.prototype,"rank",2),b([f({type:Boolean})],u.TopsortBannerSlot.prototype,"predefined",2),u.TopsortBannerSlot=b([st("topsort-banner-slot")],u.TopsortBannerSlot),u.HlsVideo=class extends A{constructor(){super(...arguments),this.src="",this.width="800px",this.height="400px"}get videoId(){try{return new URL(this.src).pathname.split("/")[1]}catch{return"hls-video"}}render(){return $` | ||
| <video | ||
@@ -33,3 +33,3 @@ id="${this.videoId}" | ||
| ></video> | ||
| `}async firstUpdated(){const t=this.shadowRoot?.getElementById(this.videoId);if(!t)return;let e;try{e=await Ie()}catch(i){console.error("Failed to load HLS.js:",i);return}if(!e){console.error("HLS.js not available after load");return}const s=new e;s.loadSource(this.src),s.attachMedia(t),s.on(e.Events.MANIFEST_PARSED,()=>{t.play().catch(i=>console.warn("Autoplay failed:",i))})}},y([f({type:String})],u.HlsVideo.prototype,"src",2),y([f({type:String})],u.HlsVideo.prototype,"width",2),y([f({type:String})],u.HlsVideo.prototype,"height",2),u.HlsVideo=y([st("hls-video")],u.HlsVideo);let x=null;function Ie(){return x||(window.Hls?(x=Promise.resolve(window.Hls),x):(x=new Promise((r,t)=>{const e=document.createElement("script");e.src="https://cdn.jsdelivr.net/npm/hls.js@1.6.13/dist/hls.min.js",e.onload=()=>window.Hls?r(window.Hls):t(new Error("HLS.js loaded but not available")),e.onerror=()=>t(new Error("Failed to load HLS.js")),document.head.appendChild(e)}).catch(r=>{throw x=null,r}),x))}return Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),u})({}); | ||
| `}async firstUpdated(){const t=this.shadowRoot?.getElementById(this.videoId);if(!t)return;let e;try{e=await Ie()}catch(i){console.error("Failed to load HLS.js:",i);return}if(!e){console.error("HLS.js not available after load");return}const s=new e;s.loadSource(this.src),s.attachMedia(t),s.on(e.Events.MANIFEST_PARSED,()=>{t.play().catch(i=>console.warn("Autoplay failed:",i))})}},b([f({type:String})],u.HlsVideo.prototype,"src",2),b([f({type:String})],u.HlsVideo.prototype,"width",2),b([f({type:String})],u.HlsVideo.prototype,"height",2),u.HlsVideo=b([st("hls-video")],u.HlsVideo);let C=null;function Ie(){return C||(window.Hls?(C=Promise.resolve(window.Hls),C):(C=new Promise((r,t)=>{const e=document.createElement("script");e.src="https://cdn.jsdelivr.net/npm/hls.js@1.6.13/dist/hls.min.js",e.onload=()=>window.Hls?r(window.Hls):t(new Error("HLS.js loaded but not available")),e.onerror=()=>t(new Error("Failed to load HLS.js")),document.head.appendChild(e)}).catch(r=>{throw C=null,r}),C))}return Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),u})({}); | ||
| //# sourceMappingURL=banners.iife.js.map |
+29
-12
@@ -1013,3 +1013,3 @@ let St = class extends Event { | ||
| "Content-Type": "application/json", | ||
| "X-UA": `topsort/banners-0.8.1 (${s})` | ||
| "X-UA": `topsort/banners-0.8.2 (${s})` | ||
| }, | ||
@@ -1052,5 +1052,5 @@ body: JSON.stringify({ | ||
| ids: this.categoryIds.split(",").map((o) => o.trim()) | ||
| } : this.categoryDisjunctions ? n.category = { | ||
| } : this.categoryDisjunctions && (n.category = { | ||
| disjunctions: [this.categoryDisjunctions.split(",").map((o) => o.trim())] | ||
| } : this.searchQuery && (n.searchQuery = this.searchQuery), this.location && (n.geoTargeting = { | ||
| }), this.searchQuery && (n.searchQuery = this.searchQuery), this.location && (n.geoTargeting = { | ||
| location: this.location | ||
@@ -1312,14 +1312,31 @@ }), n; | ||
| updated(r) { | ||
| if (super.updated(r), this.predefined && r.has("context") && !r.get("context")?.banners && !!this.context?.banners) { | ||
| const s = this._bannerForRank(); | ||
| if (s?.asset?.[0]?.content) | ||
| try { | ||
| Ot(this, s); | ||
| } catch { | ||
| if (super.updated(r), r.has("context")) { | ||
| const t = r.get("context"); | ||
| if (!t?.banners && !!this.context?.banners) { | ||
| if (this.predefined) { | ||
| const i = this._bannerForRank(); | ||
| if (i?.asset?.[0]?.content) | ||
| try { | ||
| Ot(this, i); | ||
| } catch { | ||
| } | ||
| else i && console.warn( | ||
| `[topsort-banner-slot] Predefined mode is set but the auction response for rank ${this.rank} contains no content map. Template was not mutated.` | ||
| ); | ||
| } | ||
| else s && console.warn( | ||
| `[topsort-banner-slot] Predefined mode is set but the auction response for rank ${this.rank} contains no content map. Template was not mutated.` | ||
| ); | ||
| const s = this._bannerForRank(); | ||
| this._emitStateChange(s ? "ready" : "nowinners"); | ||
| } | ||
| !t?.error && this.context?.error && this._emitStateChange("error"); | ||
| } | ||
| } | ||
| _emitStateChange(r) { | ||
| this.dispatchEvent( | ||
| new CustomEvent("statechange", { | ||
| detail: { rank: this.rank, status: r }, | ||
| bubbles: !0, | ||
| composed: !0 | ||
| }) | ||
| ); | ||
| } | ||
| // avoid shadow dom since we cannot attach to events via analytics.js | ||
@@ -1326,0 +1343,0 @@ createRenderRoot() { |
+3
-3
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "name": "@topsort/banners", | ||
| "version": "0.8.1", | ||
| "version": "0.8.2", | ||
| "description": "A web component for displaying Topsort banner ads.", | ||
@@ -57,6 +57,6 @@ "type": "module", | ||
| "devDependencies": { | ||
| "@biomejs/biome": "2.4.4", | ||
| "@biomejs/biome": "2.4.9", | ||
| "@playwright/test": "^1.58.2", | ||
| "@size-limit/file": "^12.0.0", | ||
| "@types/node": "24.11.0", | ||
| "@types/node": "24.12.0", | ||
| "@vitest/coverage-v8": "^4.0.18", | ||
@@ -63,0 +63,0 @@ "jsdom": "^28.1.0", |
+30
-3
@@ -278,12 +278,39 @@ [](https://github.com/Topsort/banners.js/actions/workflows/test.yml) | ||
| # Listening to events | ||
| The banner component emits an event when the state changes. You can listen to this event to write custom logic. | ||
| The various states are `loading`, `ready`, `error`, and `nowinners`. | ||
| The banner component emits a `statechange` event when the auction resolves. You can listen to this event to write custom logic. | ||
| The possible statuses are `ready`, `error`, and `nowinners`. | ||
| ### Single and predefined mode | ||
| ```javascript | ||
| document.querySelector('#my-slot-id').addEventListener('statechange', (event) => { | ||
| console.log(event.detail); // { status: 'ready', banner: { ... } } | ||
| console.log(event.detail); // { slotId: 'my-slot-id', status: 'ready' } | ||
| }); | ||
| ``` | ||
| ### Context mode | ||
| In context mode, each `<topsort-banner-slot>` emits its own `statechange` event with the slot's `rank` in the detail: | ||
| ```javascript | ||
| document.addEventListener('statechange', (event) => { | ||
| console.log(event.detail); // { rank: 1, status: 'ready' } | ||
| }, true); | ||
| ``` | ||
| ### Customizing links in predefined mode | ||
| In predefined mode, `data-ts-field="target:href"` sets the link directly from the auction response. If you need to transform the URL (similar to `window.TS_BANNERS.getLink` in standard mode), use the `statechange` event to post-process the link after the template has been applied: | ||
| ```javascript | ||
| document.addEventListener('statechange', (event) => { | ||
| if (event.detail.status !== 'ready') return; | ||
| const banner = event.target; | ||
| const link = banner.querySelector('a'); | ||
| if (link) { | ||
| const original = link.getAttribute('href'); | ||
| link.href = `https://example.com/${original}`; | ||
| } | ||
| }, true); | ||
| ``` | ||
| # Playground | ||
@@ -290,0 +317,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
332051
2.06%12
33.33%1692
1.2%333
8.82%