(()=>{"use strict";var t={642:function(t,e){var i=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function o(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(t){this.host=t}getById(t){return i(this,void 0,void 0,(function*(){return yield fetch(`${this.host}/manifests/v1/${t}.json`).then((t=>t.json()))}))}getByIds(t){return i(this,void 0,void 0,(function*(){const e=t.map((t=>Promise.resolve(this.getById(t))));return Promise.all(e)}))}}},398:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(t){this.document=t}createStyles(){const t=this.document.createElement("style");return t.setAttribute("type","text/css"),t.innerText="etrusted-widget {display: block;}",t}createScript(t){const e=this.document.createElement("script");return e.async=!0,e.defer=!0,e.type="text/javascript",e.src=t,e}createWidgetPropertyScript(t){const e=this.document.createElement("script");return e.type="text/props",e.textContent=JSON.stringify({manifest:t}),e}}},119:function(t,e,i){var n=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function o(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const s=r(i(398)),o=r(i(642)),a=r(i(556)),c=r(i(83)),u=r(i(241));class d extends HTMLElement{constructor(){super(),this.loaded=!1,this.domService=new s.default(document);const t=new o.default("https://integrations.etrusted.com");this.useCase=new a.default(t)}static get observedAttributes(){return["data-locale"]}get widgetId(){return this.getAttribute("data-etrusted-widget-id")}attributeChangedCallback(t,e,i){var n;null===(n=this.application)||void 0===n||n.setAttribute(t,i)}connectedCallback(){return n(this,void 0,void 0,(function*(){if(!this.widgetId)throw new Error("The widget is missing the widget-id attribute.");if(!this.loaded){this.loaded=!0;const t=new u.default(this.widgetId),e=new c.default,i=yield this.useCase.execute(t,e);this.addApplication(i.applicationHtmlTag,i.manifest)}}))}addApplication(t,e){this.application=document.createElement(t),[...this.attributes].filter((t=>t.name.match(/data-.+/))).filter((t=>!d.EXCLUDED_ATTRIBUTES.includes(t.name))).forEach((t=>{this.application.setAttribute(t.name,t.value)})),this.application.appendChild(this.domService.createWidgetPropertyScript(e)),this.application.appendChild(this.domService.createStyles()),this.attachShadow({mode:"closed"}).appendChild(this.application);const i=e.application.url;[...document.head.querySelectorAll("script")].find((t=>t.src===i))||document.head.appendChild(this.domService.createScript(i))}}e.default=d,d.EXCLUDED_ATTRIBUTES=[]},241:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(t){this.widgetId=t}getRequest(){return{widgetId:this.widgetId}}}},629:function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(i(119));customElements.get("etrusted-widget")||customElements.define("etrusted-widget",r.default)},556:function(t,e){var i=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function o(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(t){this.manifestRepository=t}execute(t,e){return i(this,void 0,void 0,(function*(){const{widgetId:i}=t.getRequest(),n=yield this.manifestRepository.getById(i);return e.setResult(n)}))}}},83:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{setResult(t){return{manifest:t,applicationHtmlTag:`etrusted-${t.application.type.replace(/_/g,"-")}-widget`}}setError(t){throw t}}}},e={};!function i(n){var r=e[n];if(void 0!==r)return r.exports;var s=e[n]={exports:{}};return t[n].call(s.exports,s,s.exports,i),s.exports}(629)})();