@telia-ace/widget-site 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.umd.js +27 -0
  2. package/package.json +1 -1
package/index.umd.js ADDED
@@ -0,0 +1,27 @@
1
+ (function(m,$){typeof exports=="object"&&typeof module<"u"?$(exports):typeof define=="function"&&define.amd?define(["exports"],$):(m=typeof globalThis<"u"?globalThis:m||self,$(m["@telia-ace/widget-site"]={}))})(this,function(m){var ut;"use strict";/**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */const $=globalThis,B=$.ShadowRoot&&($.ShadyCSS===void 0||$.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,G=Symbol(),Q=new WeakMap;let $t=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==G)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(B&&t===void 0){const s=e!==void 0&&e.length===1;s&&(t=Q.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&Q.set(e,t))}return t}toString(){return this.cssText}};const _t=n=>new $t(typeof n=="string"?n:n+"",void 0,G),ft=(n,t)=>{if(B)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const s=document.createElement("style"),i=$.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=e.cssText,n.appendChild(s)}},Y=B?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return _t(e)})(n):n;/**
6
+ * @license
7
+ * Copyright 2017 Google LLC
8
+ * SPDX-License-Identifier: BSD-3-Clause
9
+ */const{is:gt,defineProperty:mt,getOwnPropertyDescriptor:yt,getOwnPropertyNames:At,getOwnPropertySymbols:wt,getPrototypeOf:vt}=Object,_=globalThis,X=_.trustedTypes,bt=X?X.emptyScript:"",V=_.reactiveElementPolyfillSupport,O=(n,t)=>n,k={toAttribute(n,t){switch(t){case Boolean:n=n?bt:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},q=(n,t)=>!gt(n,t),tt={attribute:!0,type:String,converter:k,reflect:!1,hasChanged:q};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),_.litPropertyMetadata??(_.litPropertyMetadata=new WeakMap);class S extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=tt){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&&mt(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:r}=yt(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get(){return i==null?void 0:i.call(this)},set(o){const a=i==null?void 0:i.call(this);r.call(this,o),this.requestUpdate(t,a,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??tt}static _$Ei(){if(this.hasOwnProperty(O("elementProperties")))return;const t=vt(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(O("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(O("properties"))){const e=this.properties,s=[...At(e),...wt(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(Y(i))}else t!==void 0&&e.push(Y(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(){var t;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$EO)==null||e.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 ft(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(e=>{var s;return(s=e.hostConnected)==null?void 0:s.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(e=>{var s;return(s=e.hostDisconnected)==null?void 0:s.call(e)})}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$EC(t,e){var r;const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const o=(((r=s.converter)==null?void 0:r.toAttribute)!==void 0?s.converter:k).toAttribute(e,s.type);this._$Em=t,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(t,e){var r;const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const o=s.getPropertyOptions(i),a=typeof o.converter=="function"?{fromAttribute:o.converter}:((r=o.converter)==null?void 0:r.fromAttribute)!==void 0?o.converter:k;this._$Em=i,this[i]=a.fromAttribute(e,o.type),this._$Em=null}}requestUpdate(t,e,s){if(t!==void 0){if(s??(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??(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(){var s;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[r,o]of i)o.wrapped!==!0||this._$AL.has(r)||this[r]===void 0||this.P(r,this[r],o)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(s=this._$EO)==null||s.forEach(i=>{var r;return(r=i.hostUpdate)==null?void 0:r.call(i)}),this.update(e)):this._$EU()}catch(i){throw t=!1,this._$EU(),i}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$EO)==null||e.forEach(s=>{var i;return(i=s.hostUpdated)==null?void 0:i.call(s)}),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=this._$Ej.forEach(e=>this._$EC(e,this[e]))),this._$EU()}updated(t){}firstUpdated(t){}}S.elementStyles=[],S.shadowRootOptions={mode:"open"},S[O("elementProperties")]=new Map,S[O("finalized")]=new Map,V==null||V({ReactiveElement:S}),(_.reactiveElementVersions??(_.reactiveElementVersions=[])).push("2.0.4");/**
10
+ * @license
11
+ * Copyright 2017 Google LLC
12
+ * SPDX-License-Identifier: BSD-3-Clause
13
+ */const x=globalThis,z=x.trustedTypes,et=z?z.createPolicy("lit-html",{createHTML:n=>n}):void 0,st="$lit$",f=`lit$${Math.random().toFixed(9).slice(2)}$`,it="?"+f,Et=`<${it}>`,y=document,T=()=>y.createComment(""),N=n=>n===null||typeof n!="object"&&typeof n!="function",J=Array.isArray,St=n=>J(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",K=`[
14
+ \f\r]`,H=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,nt=/-->/g,rt=/>/g,A=RegExp(`>|${K}(?:([^\\s"'>=/]+)(${K}*=${K}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),ot=/'/g,ht=/"/g,at=/^(?:script|style|textarea|title)$/i,U=Symbol.for("lit-noChange"),d=Symbol.for("lit-nothing"),ct=new WeakMap,w=y.createTreeWalker(y,129);function lt(n,t){if(!J(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return et!==void 0?et.createHTML(t):t}const Ut=(n,t)=>{const e=n.length-1,s=[];let i,r=t===2?"<svg>":t===3?"<math>":"",o=H;for(let a=0;a<e;a++){const h=n[a];let l,p,c=-1,u=0;for(;u<h.length&&(o.lastIndex=u,p=o.exec(h),p!==null);)u=o.lastIndex,o===H?p[1]==="!--"?o=nt:p[1]!==void 0?o=rt:p[2]!==void 0?(at.test(p[2])&&(i=RegExp("</"+p[2],"g")),o=A):p[3]!==void 0&&(o=A):o===A?p[0]===">"?(o=i??H,c=-1):p[1]===void 0?c=-2:(c=o.lastIndex-p[2].length,l=p[1],o=p[3]===void 0?A:p[3]==='"'?ht:ot):o===ht||o===ot?o=A:o===nt||o===rt?o=H:(o=A,i=void 0);const g=o===A&&n[a+1].startsWith("/>")?" ":"";r+=o===H?h+Et:c>=0?(s.push(l),h.slice(0,c)+st+h.slice(c)+f+g):h+f+(c===-2?a:g)}return[lt(n,r+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};class M{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let r=0,o=0;const a=t.length-1,h=this.parts,[l,p]=Ut(t,e);if(this.el=M.createElement(l,s),w.currentNode=this.el.content,e===2||e===3){const c=this.el.content.firstChild;c.replaceWith(...c.childNodes)}for(;(i=w.nextNode())!==null&&h.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const c of i.getAttributeNames())if(c.endsWith(st)){const u=p[o++],g=i.getAttribute(c).split(f),W=/([.?@])?(.*)/.exec(u);h.push({type:1,index:r,name:W[2],strings:g,ctor:W[1]==="."?Ct:W[1]==="?"?Ot:W[1]==="@"?xt:D}),i.removeAttribute(c)}else c.startsWith(f)&&(h.push({type:6,index:r}),i.removeAttribute(c));if(at.test(i.tagName)){const c=i.textContent.split(f),u=c.length-1;if(u>0){i.textContent=z?z.emptyScript:"";for(let g=0;g<u;g++)i.append(c[g],T()),w.nextNode(),h.push({type:2,index:++r});i.append(c[u],T())}}}else if(i.nodeType===8)if(i.data===it)h.push({type:2,index:r});else{let c=-1;for(;(c=i.data.indexOf(f,c+1))!==-1;)h.push({type:7,index:r}),c+=f.length-1}r++}}static createElement(t,e){const s=y.createElement("template");return s.innerHTML=t,s}}function P(n,t,e=n,s){var o,a;if(t===U)return t;let i=s!==void 0?(o=e.o)==null?void 0:o[s]:e.l;const r=N(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==r&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),r===void 0?i=void 0:(i=new r(n),i._$AT(n,e,s)),s!==void 0?(e.o??(e.o=[]))[s]=i:e.l=i),i!==void 0&&(t=P(n,i._$AS(n,t.values),i,s)),t}class Pt{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==null?void 0:t.creationScope)??y).importNode(e,!0);w.currentNode=i;let r=w.nextNode(),o=0,a=0,h=s[0];for(;h!==void 0;){if(o===h.index){let l;h.type===2?l=new R(r,r.nextSibling,this,t):h.type===1?l=new h.ctor(r,h.name,h.strings,this,t):h.type===6&&(l=new Tt(r,this,t)),this._$AV.push(l),h=s[++a]}o!==(h==null?void 0:h.index)&&(r=w.nextNode(),o++)}return w.currentNode=y,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 R{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this.v}constructor(t,e,s,i){this.type=2,this._$AH=d,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this.v=(i==null?void 0:i.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?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===d||t==null||t===""?(this._$AH!==d&&this._$AR(),this._$AH=d):t!==this._$AH&&t!==U&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):St(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!==d&&N(this._$AH)?this._$AA.nextSibling.data=t:this.T(y.createTextNode(t)),this._$AH=t}$(t){var r;const{values:e,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=M.createElement(lt(s.h,s.h[0]),this.options)),s);if(((r=this._$AH)==null?void 0:r._$AD)===i)this._$AH.p(e);else{const o=new Pt(i,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(t){let e=ct.get(t.strings);return e===void 0&&ct.set(t.strings,e=new M(t)),e}k(t){J(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const r of t)i===e.length?e.push(s=new R(this.O(T()),this.O(T()),this,this.options)):s=e[i],s._$AI(r),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,e);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this.v=t,(e=this._$AP)==null||e.call(this,t))}}class D{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,r){this.type=1,this._$AH=d,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=r,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=d}_$AI(t,e=this,s,i){const r=this.strings;let o=!1;if(r===void 0)t=P(this,t,e,0),o=!N(t)||t!==this._$AH&&t!==U,o&&(this._$AH=t);else{const a=t;let h,l;for(t=r[0],h=0;h<r.length-1;h++)l=P(this,a[s+h],e,h),l===U&&(l=this._$AH[h]),o||(o=!N(l)||l!==this._$AH[h]),l===d?t=d:t!==d&&(t+=(l??"")+r[h+1]),this._$AH[h]=l}o&&!i&&this.j(t)}j(t){t===d?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Ct extends D{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===d?void 0:t}}class Ot extends D{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==d)}}class xt extends D{constructor(t,e,s,i,r){super(t,e,s,i,r),this.type=5}_$AI(t,e=this){if((t=P(this,t,e,0)??d)===U)return;const s=this._$AH,i=t===d&&s!==d||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==d&&(s===d||i);i&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}}class Tt{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 Z=x.litHtmlPolyfillSupport;Z==null||Z(M,R),(x.litHtmlVersions??(x.litHtmlVersions=[])).push("3.2.0");const Nt=(n,t,e)=>{const s=(e==null?void 0:e.renderBefore)??t;let i=s._$litPart$;if(i===void 0){const r=(e==null?void 0:e.renderBefore)??null;s._$litPart$=i=new R(t.insertBefore(T(),r),r,void 0,e??{})}return i._$AI(n),i};/**
16
+ * @license
17
+ * Copyright 2017 Google LLC
18
+ * SPDX-License-Identifier: BSD-3-Clause
19
+ */class C extends S{constructor(){super(...arguments),this.renderOptions={host:this},this.o=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this.o=Nt(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this.o)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.o)==null||t.setConnected(!1)}render(){return U}}C._$litElement$=!0,C.finalized=!0,(ut=globalThis.litElementHydrateSupport)==null||ut.call(globalThis,{LitElement:C});const F=globalThis.litElementPolyfillSupport;F==null||F({LitElement:C}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.0");/**
20
+ * @license
21
+ * Copyright 2017 Google LLC
22
+ * SPDX-License-Identifier: BSD-3-Clause
23
+ */const Ht={attribute:!0,type:String,converter:k,reflect:!1,hasChanged:q},Mt=(n=Ht,t,e)=>{const{kind:s,metadata:i}=e;let r=globalThis.litPropertyMetadata.get(i);if(r===void 0&&globalThis.litPropertyMetadata.set(i,r=new Map),r.set(e.name,n),s==="accessor"){const{name:o}=e;return{set(a){const h=t.get.call(this);t.set.call(this,a),this.requestUpdate(o,h,n)},init(a){return a!==void 0&&this.P(o,void 0,n),a}}}if(s==="setter"){const{name:o}=e;return function(a){const h=this[o];t.call(this,a),this.requestUpdate(o,h,n)}}throw Error("Unsupported decorator location: "+s)};function v(n){return(t,e)=>typeof e=="object"?Mt(n,t,e):((s,i,r)=>{const o=i.hasOwnProperty(r);return i.constructor.createProperty(r,o?{...s,wrapped:!0}:s),o?Object.getOwnPropertyDescriptor(i,r):void 0})(n,t,e)}/**
24
+ * @license
25
+ * Copyright 2017 Google LLC
26
+ * SPDX-License-Identifier: BSD-3-Clause
27
+ */function L(n){return v({...n,state:!0,attribute:!1})}var Rt=Object.defineProperty,It=Object.getOwnPropertyDescriptor,I=(n,t,e,s)=>{for(var i=s>1?void 0:s?It(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&Rt(t,e,i),i};const dt="https://widgets.ace.teliacompany.net",pt="https://embed.webprovisions.io";class b extends C{constructor(){super(...arguments),this.apiUrl=dt,this.embedUrl=pt,this._site=null,this._widgets={}}async connectedCallback(){super.connectedCallback(),await this.loadSite()}async disconnectedCallback(){super.disconnectedCallback()}async loadSite(){var s;const e=await(await fetch(`${this.apiUrl}/api/site/${this.siteId}`)).json();this._site=e,(((s=this._site)==null?void 0:s.widgets)||[]).forEach(async i=>{this.addWidgetEl(i.widgetId)})}addWidgetEl(t){const e=`ace-widget_${t}`;let s=document.getElementById(e);s||(s=document.createElement("ace-widget-wrapper"),s.setAttribute("id",e),s.setAttribute("widgetId",t),this.apiUrl!==dt&&s.setAttribute("apiUrl",this.apiUrl),this.embedUrl!==pt&&s.setAttribute("embedUrl",this.embedUrl),document.body.appendChild(s)),this._widgets={...this._widgets,[t]:s},window.ace=window.ace||{_c:[],_w:[],widget:function(i,r){window.ace._w.push([i,r])},configure:function(i){window.ace._c.push(i)}}}async render(){if(!this._site)return d;const t=[];(this._site.triggers||[]).filter(e=>e.triggerType==="visit").forEach(e=>{const s=window.location.pathname,i=e.condition.outputs||[];e.condition.type==="url"&&i.forEach(r=>{var h;const o=r.action.type==="render_widget";if((r.value===s||r.value==="*")&&o){let l={widgetId:""};try{l=JSON.parse(r.action.data)}catch{l={widgetId:""}}const p=t.findIndex(u=>u.widgetId===l.widgetId)>-1,c=(((h=this._site)==null?void 0:h.widgets)||[]).find(u=>u.widgetId===l.widgetId);c&&!p&&t.push(c)}})});for await(const e of t){const s=this._widgets[e.widgetId];s&&s.activate()}return d}}I([v({attribute:!0})],b.prototype,"siteId",2),I([v()],b.prototype,"apiUrl",2),I([v()],b.prototype,"embedUrl",2),I([L()],b.prototype,"_site",2),I([L()],b.prototype,"_widgets",2),window.customElements.get("ace-site")||window.customElements.define("ace-site",b);var jt=Object.defineProperty,kt=Object.getOwnPropertyDescriptor,j=(n,t,e,s)=>{for(var i=s>1?void 0:s?kt(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&jt(t,e,i),i};const zt="https://widgets.ace.teliacompany.net",Dt="https://embed.webprovisions.io";class E extends C{constructor(){super(...arguments),this.apiUrl=zt,this.embedUrl=Dt,this.widget=null,this.scriptEl=null}async connectedCallback(){super.connectedCallback(),this.widget=await this._loadWidget(this.widgetId)}async _loadWidget(t){return await(await fetch(`${this.apiUrl}/api/widget/${t}`)).json()}_createEmbedScript(){var e;if(!((e=this.widget)!=null&&e.distributionName))return;let t=document.createElement("script");t.setAttribute("type","module"),t.setAttribute("async","true"),t.setAttribute("src",`${this.embedUrl}/d/${this.widget.organization}/${this.widget.distributionName}@latest/index.js`),this.scriptEl=t}async activate(){this.widget||(this.widget=await this._loadWidget(this.widgetId)),this._createEmbedScript()}render(){return this.scriptEl?this.scriptEl:d}}j([v({attribute:!0})],E.prototype,"widgetId",2),j([v()],E.prototype,"apiUrl",2),j([v()],E.prototype,"embedUrl",2),j([L()],E.prototype,"widget",2),j([L()],E.prototype,"scriptEl",2),customElements.get("ace-widget-wrapper")||customElements.define("ace-widget-wrapper",E),m.SiteComponent=b,m.WidgetComponent=E,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-site",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "dependencies": {
5
5
  "lit": "^3.0.2",
6
6
  "lit-html": "^3.0.2"