/**
 * Copyright 2020 The Pennsylvania State University
 * @license Apache-2.0, see License.md for full text.
 */
import{LitElement as t}from"../../../lit/index.js";import{localStorageSet as e,localStorageGet as r}from"../../utils/utils.js";class LrsBridge extends t{static get properties(){return{endpoint:{type:String}}}constructor(){super(),this.endpoint="",this.addEventListener("lrs-emitter",this._lrsEmitterHander.bind(this))}static get tag(){return"lrs-bridge"}_lrsEmitterHander(t){this._enableProperties&&this.recordStatement(t)}recordStatement(t){console.log("options:",t);const e={method:"POST",cors:"no-cors",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"\n          mutation($data: StatementCreateInput!) {\n            createStatement(data: $data) {\n              id\n            }\n          }\n        ",variables:{data:{data:Object.assign({},{actor:{name:this.getUserName()}},t)}}},"utf8")};try{fetch(this.endpoint,e).then((t=>t.json())).then((t=>{}))}catch(t){}}getUserName(){var t=r("lrs-name","");if(!t){const t=this.makeGUID();e("lrs-name",t)}return t}makeGUID(){const s4=()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1);return s4()+s4()+"-"+s4()+"-"+s4()+"-"+s4()+"-"+s4()+s4()+s4()}}customElements.define(LrsBridge.tag,LrsBridge);export{LrsBridge};