@whereby.com/browser-sdk 2.0.0-beta4 → 2.0.0

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.
@@ -1,5 +1,5 @@
1
- /*! (c) Andrea Giammarchi - ISC */
2
- var e={};try{e.WeakMap=WeakMap}catch(t){e.WeakMap=function(e,t){var n=t.defineProperty,r=t.hasOwnProperty,s=o.prototype;return s.delete=function(e){return this.has(e)&&delete e[this._]},s.get=function(e){return this.has(e)?e[this._]:void 0},s.has=function(e){return r.call(e,this._)},s.set=function(e,t){return n(e,this._,{configurable:!0,value:t}),this},o;function o(t){n(this,"_",{value:"_@ungap/weakmap"+e++}),t&&t.forEach(a,this)}function a(e){this.set(e[0],e[1])}}(Math.random(),Object)}var t=e.WeakMap,n={};try{n.Event=new Event(".").constructor}catch(e){try{n.Event=new CustomEvent(".").constructor}catch(e){n.Event=function(e,t){t||(t={});var n=document.createEvent("Event"),r=!!t.bubbles,s=!!t.cancelable;n.initEvent(e,r,s);try{n.bubbles=r,n.cancelable=s}catch(n){}return n}}}var r=n.Event,s={};
1
+ var whereby=function(){"use strict";
2
+ /*! (c) Andrea Giammarchi - ISC */var e={};try{e.WeakMap=WeakMap}catch(t){e.WeakMap=function(e,t){var n=t.defineProperty,r=t.hasOwnProperty,s=o.prototype;return s.delete=function(e){return this.has(e)&&delete e[this._]},s.get=function(e){return this.has(e)?e[this._]:void 0},s.has=function(e){return r.call(e,this._)},s.set=function(e,t){return n(e,this._,{configurable:!0,value:t}),this},o;function o(t){n(this,"_",{value:"_@ungap/weakmap"+e++}),t&&t.forEach(a,this)}function a(e){this.set(e[0],e[1])}}(Math.random(),Object)}var t=e.WeakMap,n={};try{n.Event=new Event(".").constructor}catch(e){try{n.Event=new CustomEvent(".").constructor}catch(e){n.Event=function(e,t){t||(t={});var n=document.createEvent("Event"),r=!!t.bubbles,s=!!t.cancelable;n.initEvent(e,r,s);try{n.bubbles=r,n.cancelable=s}catch(n){}return n}}}var r=n.Event,s={};
3
3
  /*! (c) Andrea Giammarchi - ISC */try{s.WeakSet=WeakSet}catch(e){!function(e){var t=new e,n=r.prototype;function r(n){t.set(this,new e),n&&n.forEach(this.add,this)}n.add=function(e){return t.get(this).set(e,1),this},n.delete=function(e){return t.get(this).delete(e)},n.has=function(e){return t.get(this).has(e)},s.WeakSet=r}(WeakMap)}var o,a,i,c=s.WeakSet,l="-"+Math.random().toFixed(6)+"%",u=!1;
4
4
  /*! (c) Andrea Giammarchi - ISC */try{o=document.createElement("template"),i="tabindex",(a="content")in o&&(o.innerHTML="<p "+i+'="'+l+'"></p>',o[a].childNodes[0].getAttribute(i)==l)||(l="_dt: "+l.slice(1,-1)+";",u=!0)}catch(e){}var h="\x3c!--"+l+"--\x3e",f=8,d=1,p=3,g=/^(?:plaintext|script|style|textarea|title|xmp)$/i,m=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
5
5
  /*! (c) Andrea Giammarchi - ISC */
@@ -7,10 +7,10 @@ function v(e){return e.join(h).replace(k,_).replace(x,A)}var b=" \\f\\n\\r\\t",y
7
7
  /*! (c) Andrea Giammarchi - ISC */
8
8
  var R=function(e){var t="fragment",n="template",r="content"in o(n)?function(e){var t=o(n);return t.innerHTML=e,t.content}:function(e){var r=o(t),a=o(n),i=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var c=RegExp.$1;a.innerHTML="<table>"+e+"</table>",i=a.querySelectorAll(c)}else a.innerHTML=e,i=a.childNodes;return s(r,i),r};return function(e,t){return("svg"===t?a:r)(e)};function s(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function o(n){return n===t?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",n)}function a(e){var n=o(t),r=o("div");return r.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+e+"</svg>",s(n,r.firstChild.childNodes),n}}(document),U=(e,t,n,r,s)=>{const o=n.length;let a=t.length,i=o,c=0,l=0,u=null;for(;c<a||l<i;)if(a===c){const t=i<o?l?r(n[l-1],-0).nextSibling:r(n[i-l],0):s;for(;l<i;)e.insertBefore(r(n[l++],1),t)}else if(i===l)for(;c<a;)u&&u.has(t[c])||e.removeChild(r(t[c],-1)),c++;else if(t[c]===n[l])c++,l++;else if(t[a-1]===n[i-1])a--,i--;else if(t[c]===n[i-1]&&n[l]===t[a-1]){const s=r(t[--a],-1).nextSibling;e.insertBefore(r(n[l++],1),r(t[c++],-1).nextSibling),e.insertBefore(r(n[--i],1),s),t[a]=n[i]}else{if(!u){u=new Map;let e=l;for(;e<i;)u.set(n[e],e++)}if(u.has(t[c])){const s=u.get(t[c]);if(l<s&&s<i){let o=c,h=1;for(;++o<a&&o<i&&u.get(t[o])===s+h;)h++;if(h>s-l){const o=r(t[c],0);for(;l<s;)e.insertBefore(r(n[l++],1),o)}else e.replaceChild(r(n[l++],1),r(t[c++],-1))}else c++}else e.removeChild(r(t[c++],-1))}return n},W=function(e,t,n,r,s){var o=s in e,a=e.createDocumentFragment();return a[t](e[r]("g")),a[t](e[r]("")),(o?e[s](a,!0):a[n](!0)).childNodes.length<2?function e(r,s){for(var o=r[n](),a=r.childNodes||[],i=a.length,c=0;s&&c<i;c++)o[t](e(a[c],s));return o}:o?e[s]:function(e,t){return e[n](!!t)}}(document,"appendChild","cloneNode","createTextNode","importNode"),P="".trim||function(){return String(this).replace(/^\s+|\s+/g,"")},Z=u?function(e,t){var n=t.join(" ");return t.slice.call(e,0).sort((function(e,t){return n.indexOf(e.name)<=n.indexOf(t.name)?-1:1}))}:function(e,t){return t.slice.call(e,0)};function B(e,t){for(var n=t.length,r=0;r<n;)e=e.childNodes[t[r++]];return e}function z(e,t,n,r){for(var s=e.childNodes,o=s.length,a=0;a<o;){var i=s[a];switch(i.nodeType){case d:var c=r.concat(a);D(i,t,n,c),z(i,t,n,c);break;case f:var u=i.textContent;if(u===l)n.shift(),t.push(g.test(e.nodeName)?H(e,r):V(i,r.concat(a)));else switch(u.slice(0,2)){case"/*":if("*/"!==u.slice(-2))break;case"👻":e.removeChild(i),a--,o--}break;case p:g.test(e.nodeName)&&P.call(i.textContent)===h&&(n.shift(),t.push(H(e,r)))}a++}}function D(e,t,n,r){for(var s=e.attributes,o=[],a=[],i=Z(s,n),c=i.length,f=0;f<c;){var d,p=i[f++],g=p.value===l;if(g||1<(d=p.value.split(h)).length){var m=p.name;if(o.indexOf(m)<0){o.push(m);var v=n.shift().replace(g?/^(?:|[\S\s]*?\s)(\S+?)\s*=\s*('|")?$/:new RegExp("^(?:|[\\S\\s]*?\\s)("+m+")\\s*=\\s*('|\")[\\S\\s]*","i"),"$1"),b=s[v]||s[v.toLowerCase()];if(g)t.push(F(b,r,v,null));else{for(var y=d.length-2;y--;)n.shift();t.push(F(b,r,v,d))}}a.push(p)}}f=0;for(var w=(0<(c=a.length)&&u&&!("ownerSVGElement"in e));f<c;){var E=a[f++];w&&(E.value=""),e.removeAttribute(E.name)}var C=e.nodeName;if(/^script$/i.test(C)){var x=document.createElement(C);for(c=s.length,f=0;f<c;)x.setAttributeNode(s[f++].cloneNode(!0));x.textContent=e.textContent,e.parentNode.replaceChild(x,e)}}function V(e,t){return{type:"any",node:e,path:t}}function F(e,t,n,r){return{type:"attr",node:e,path:t,name:n,sparse:r}}function H(e,t){return{type:"text",node:e,path:t}}var I=L(new t);function q(e,t){var n=(e.convert||v)(t),r=e.transform;r&&(n=r(n));var s=R(n,e.type);K(s);var o=[];return z(s,o,t.slice(0),[]),{content:s,updates:function(n){for(var r=[],s=o.length,a=0,i=0;a<s;){var c=o[a++],l=B(n,c.path);switch(c.type){case"any":r.push({fn:e.any(l,[]),sparse:!1});break;case"attr":var u=c.sparse,h=e.attribute(l,c.name,c.node);null===u?r.push({fn:h,sparse:!1}):(i+=u.length-2,r.push({fn:h,sparse:!0,values:u}));break;case"text":r.push({fn:e.text(l),sparse:!1}),l.textContent=""}}return s+=i,function(){var e=arguments.length;if(s!==e-1)throw new Error(e-1+" values instead of "+s+"\n"+t.join("${value}"));for(var o=1,a=1;o<e;){var i=r[o-a];if(i.sparse){var c=i.values,l=c[0],u=1,h=c.length;for(a+=h-2;u<h;)l+=arguments[o++]+c[u++];i.fn(l)}else i.fn(arguments[o++])}return n}}}}var G=[];function J(e){var t=G,n=K;return function(r){return t!==r&&(n=function(e,t){var n=I.get(t)||I.set(t,q(e,t));return n.updates(W.call(document,n.content,!0))}(e,t=r)),n.apply(null,arguments)}}function K(e){for(var t=e.childNodes,n=t.length;n--;){var r=t[n];1!==r.nodeType&&0===P.call(r.textContent).length&&e.removeChild(r)}}
9
9
  /*! (c) Andrea Giammarchi - ISC */var Q=function(){var e=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,t=/([^A-Z])([A-Z]+)/g;return function(e,t){return"ownerSVGElement"in e?function(e,t){var n;t?n=t.cloneNode(!0):(e.setAttribute("style","--hyper:style;"),n=e.getAttributeNode("style"));return n.value="",e.setAttributeNode(n),r(n,!0)}(e,t):r(e.style,!1)};function n(e,t,n){return t+"-"+n.toLowerCase()}function r(r,s){var o,a;return function(i){var c,l,u,h;switch(typeof i){case"object":if(i){if("object"===o){if(!s&&a!==i)for(l in a)l in i||(r[l]="")}else s?r.value="":r.cssText="";for(l in c=s?{}:r,i)u="number"!=typeof(h=i[l])||e.test(l)?h:h+"px",!s&&/^--/.test(l)?c.setProperty(l,u):c[l]=u;o="object",s?r.value=function(e){var r,s=[];for(r in e)s.push(r.replace(t,n),":",e[r],";");return s.join("")}(a=c):a=i;break}default:a!=i&&(o="string",a=i,s?r.value=i||"":r.cssText=i||"")}}}}();const X=(e,t)=>{let n,r=!0;const s=document.createAttributeNS(null,t);return t=>{n!==t&&(n=t,null==n?r||(e.removeAttributeNode(s),r=!0):(s.value=t,r&&(e.setAttributeNodeNS(s),r=!1)))}},Y=({dataset:e})=>t=>{for(const n in t){const r=t[n];null==r?delete e[n]:e[n]=r}},ee=(e,t)=>"dataset"===t?Y(e):n=>{e[t]=n},te=/^(?:form|list)$/i,ne=(e,t)=>e.ownerDocument.createTextNode(t);function re(e){return this.type=e,J(this)}function se(e){return e(this)}re.prototype={attribute(e,t,n){const r="svg"===this.type;switch(t){case"class":if(r)return X(e,t);t="className";case"props":return ee(e,t);case"aria":return(e=>t=>{for(const n in t){const r="role"===n?n:`aria-${n}`,s=t[n];null==s?e.removeAttribute(r):e.setAttribute(r,s)}})(e);case"style":return Q(e,n,r);case"ref":return(e=>t=>{"function"==typeof t?t(e):t.current=e})(e);case".dataset":return Y(e);default:return"."===t.slice(0,1)?ee(e,t.slice(1)):"?"===t.slice(0,1)?((e,t,n)=>r=>{n!==!!r&&((n=!!r)?e.setAttribute(t,""):e.removeAttribute(t))})(e,t.slice(1)):"on"===t.slice(0,2)?((e,t)=>{let n,r=t.slice(2);return!(t in e)&&t.toLowerCase()in e&&(r=r.toLowerCase()),t=>{const s=S(t)?t:[t,!1];n!==s[0]&&(n&&e.removeEventListener(r,n,s[1]),(n=s[0])&&e.addEventListener(r,n,s[1]))}})(e,t):!(t in e)||r||te.test(t)?X(e,t):((e,t)=>{let n;return r=>{n!==r&&(n=r,e[t]!==r&&(null==r?(e[t]="",e.removeAttribute(t)):e[t]=r))}})(e,t)}},any(e,t){const{type:n}=this;let r,s=!1;const o=a=>{switch(typeof a){case"string":case"number":case"boolean":s?r!==a&&(r=a,t[0].textContent=a):(s=!0,r=a,t=U(e.parentNode,t,[ne(e,a)],M,e));break;case"function":o(a(e));break;case"object":case"undefined":if(null==a){s=!1,t=U(e.parentNode,t,[],M,e);break}default:if(s=!1,r=a,S(a))if(0===a.length)t.length&&(t=U(e.parentNode,t,[],M,e));else switch(typeof a[0]){case"string":case"number":case"boolean":o(String(a));break;case"function":o(a.map(se,e));break;case"object":S(a[0])&&(a=a.concat.apply([],a));default:t=U(e.parentNode,t,a,M,e)}else"ELEMENT_NODE"in a?t=U(e.parentNode,t,11===a.nodeType?O.call(a.childNodes):[a],M,e):"text"in a?o(String(a.text)):"any"in a?o(a.any):"html"in a?t=U(e.parentNode,t,O.call(R([].concat(a.html).join(""),n).childNodes),M,e):"length"in a&&o(O.call(a))}};return o},text(e){let t;const n=r=>{if(t!==r){t=r;const s=typeof r;"object"===s&&r?"text"in r?n(String(r.text)):"any"in r?n(r.any):"html"in r?n([].concat(r.html).join("")):"length"in r&&n(O.call(r).join("")):"function"===s?n(r(e)):e.textContent=null==r?"":r}};return n}};const{create:oe,freeze:ae,keys:ie}=Object,ce=re.prototype,le=L(new t),ue=e=>({html:fe("html",e),svg:fe("svg",e),render(t,n){const r="function"==typeof n?n():n,s=le.get(t)||le.set(t,he()),o=r instanceof ge?de(e,s,r):r;return o!==s.wire&&(s.wire=o,t.textContent="",t.appendChild(o.valueOf())),t}}),he=()=>({stack:[],entry:null,wire:null}),fe=(e,n)=>{const r=L(new t);return s.for=(e,t)=>{const o=r.get(e)||r.set(e,oe(null));return o[t]||(o[t]=(e=>function(){return de(n,e,s.apply(null,arguments))})(he()))},s.node=function(){return de(n,he(),s.apply(null,arguments)).valueOf()},s;function s(){return new ge(e,ve.apply(null,arguments))}},de=(e,t,{type:n,template:r,values:s})=>{const{length:o}=s;pe(e,t,s,o);let{entry:a}=t;if(a&&a.template===r&&a.type===n)a.tag(r,...s);else{const o=new e(n);t.entry=a={type:n,template:r,tag:o,wire:T(o(r,...s))}}return a.wire},pe=(e,{stack:t},n,r)=>{for(let s=0;s<r;s++){const r=n[s];r instanceof me?n[s]=de(e,t[s]||(t[s]=he()),r):S(r)?pe(e,t[s]||(t[s]=he()),r,r.length):t[s]=null}r<t.length&&t.splice(r)};function ge(e,t){this.type=e,this.template=t.shift(),this.values=t}ae(ge);const me=ge;function ve(){let e=[],t=0,{length:n}=arguments;for(;t<n;)e.push(arguments[t++]);return e}ue(re);var be="function"==typeof cancelAnimationFrame,ye=be?cancelAnimationFrame:clearTimeout,we=be?requestAnimationFrame:setTimeout;function Ee(e){var t,n,r,s,o;return i(),function(e,i,l){return r=e,s=i,o=l,n||(n=we(a)),--t<0&&c(!0),c};function a(){i(),r.apply(s,o||[])}function i(){t=e||1/0,n=be?0:null}function c(e){var t=!!n;return t&&(ye(n),e&&a()),t}}
10
- /*! (c) Andrea Giammarchi - ISC */let Ce=null;const xe=L(new WeakMap),ke=(e,t,n)=>{e.apply(t,n)},Ne={async:!1,always:!1},Ae=(e,t)=>"function"==typeof t?t(e):t,$e=(e,t,n,r)=>{const s=Ce.i++,{hook:o,args:a,stack:i,length:c}=Ce;s===c&&(Ce.length=i.push({}));const l=i[s];if(l.args=a,s===c){const s="function"==typeof n,{async:a,always:i}=(s?r:n)||r||Ne;l.$=s?n(t):Ae(void 0,t),l._=a?xe.get(o)||xe.set(o,Ee()):ke,l.f=t=>{const n=e(l.$,t);(i||l.$!==n)&&(l.$=n,l._(o,null,l.args))}}return[l.$,l.f]},_e=new WeakMap;function Se({hook:e}){return e===this.hook}const je=new WeakMap,Oe=L(je),Le=()=>{},Me=e=>(t,n)=>{const r=Ce.i++,{hook:s,after:o,stack:a,length:i}=Ce;if(r<i){const s=a[r],{update:i,values:c,stop:l}=s;if(!n||n.some(Pe,c)){s.values=n,e&&l(e);const{clean:r}=s;r&&(s.clean=null,r());const a=()=>{s.clean=t()};e?i(a):o.push(a)}}else{const r=e?Ee():Le,i={clean:null,update:r,values:n,stop:Le};Ce.length=a.push(i),(Oe.get(s)||Oe.set(s,[])).push(i);const c=()=>{i.clean=t()};e?i.stop=r(c):o.push(c)}},Te=e=>{(je.get(e)||[]).forEach((e=>{const{clean:t,stop:n}=e;n(),t&&(e.clean=null,t())}))};je.has.bind(je);const Re=Me(!0),Ue=Me(!1),We=(e,t)=>{const n=Ce.i++,{stack:r,length:s}=Ce;return n===s?Ce.length=r.push({$:e(),_:t}):t&&!t.some(Pe,r[n]._)||(r[n]={$:e(),_:t}),r[n].$};function Pe(e,t){return e!==this[t]}let Ze=null;try{Ze=new{o(){}}.o}catch(Bt){}let Be=e=>class extends e{};if(Ze){const{getPrototypeOf:e,setPrototypeOf:t}=Object,{construct:n}="object"==typeof Reflect?Reflect:{construct(e,n,r){const s=[null];for(let e=0;e<n.length;e++)s.push(n[e]);const o=e.bind.apply(e,s);return t(new o,r.prototype)}};Be=function(r,s){function o(){return n(s?e(r):r,arguments,o)}return t(o.prototype,r.prototype),t(o,r)}}const ze={map:{},re:null},De=e=>new RegExp(`<(/)?(${e.join("|")})([^A-Za-z0-9:._-])`,"g");let Ve=null;const Fe=(e,t)=>{const{map:n,re:r}=Ve||t;return e.replace(r,((e,t,r,s)=>{const{tagName:o,is:a,element:i}=n[r];return i?t?`</${a}>`:`<${a}${s}`:t?`</${o}>`:`<${o} is="${a}"${s}`}))},He=({tagName:e,is:t,element:n})=>n?t:`${e}[is="${t}"]`,Ie=()=>Ve,qe=e=>{Ve=e},Ge={useCallback:(e,t)=>We((()=>e),t),useContext:e=>{const{hook:t,args:n}=Ce,r=_e.get(e),s={hook:t,args:n};return r.some(Se,s)||r.push(s),e.value},useEffect:Re,useLayoutEffect:Ue,useMemo:We,useReducer:$e,useRef:e=>{const t=Ce.i++,{stack:n,length:r}=Ce;return t===r&&(Ce.length=n.push({current:e})),n[t]},useState:(e,t)=>$e(Ae,e,void 0,t)},{render:Je,html:Ke,svg:Qe}=(e=>{const t=oe(ce);return ie(e).forEach((n=>{t[n]=e[n](t[n]||("convert"===n?v:String))})),n.prototype=t,ue(n);function n(){return re.apply(this,arguments)}})({transform:()=>e=>Fe(e,ze)}),Xe="_🔥",{defineProperties:Ye}=Object,et=new t,tt=new t,nt=new t,rt=new c,st=!0,ot="attributeChangedCallback",at="connectedCallback",it=`dis${at}`,ct=(e,t,n)=>{if(n in e){const r=e[n];t[n]={configurable:st,value(){return wt.call(this),r.apply(this,arguments)}}}else t[n]={configurable:st,value:wt}},lt=e=>{const{prototype:n}=e,r=[],s={html:{configurable:st,get:vt},svg:{configurable:st,get:bt}};if(s[Xe]={value:{events:r,info:null}},"handleEvent"in n||(s.handleEvent={configurable:st,value:yt}),"render"in n&&n.render.length){const{oninit:e}=n;Ye(n,{oninit:{configurable:st,value(){const t=(e=>{const t=[];return function n(){const r=Ce,s=[];Ce={hook:n,args:arguments,stack:t,i:0,length:t.length,after:s};try{return e.apply(null,arguments)}finally{Ce=r;for(let e=0,{length:t}=s;e<t;e++)s[e]()}}})(this.render.bind(this,Ge));Ye(this,{render:{configurable:st,value:t}}),this.addEventListener("disconnected",Te.bind(null,t),!1),e&&e.apply(this,arguments)}}})}"oninit"in n&&(r.push("init"),ct(n,s,"render")),ct(n,s,ot),ct(n,s,at),ct(n,s,it),[[ot,"onattributechanged",Et],[at,"onconnected",Ct],[it,"ondisconnected",kt],[at,"render",xt]].forEach((([e,t,o])=>{if(!(e in n)&&t in n)if("render"!==t&&r.push(t.slice(2)),e in s){const t=s[e].value;s[e]={configurable:st,value(){return t.apply(this,arguments),o.apply(this,arguments)}}}else s[e]={configurable:st,value:o}}));const o=e.booleanAttributes||[];o.forEach((e=>{e in n||(s[e]={configurable:st,get(){return this.hasAttribute(e)},set(t){t&&"false"!==t?this.setAttribute(e,t):this.removeAttribute(e)}})}));const a=e.observedAttributes||[];a.forEach((e=>{e in n||(s[e]={configurable:st,get(){return this.getAttribute(e)},set(t){null==t?this.removeAttribute(e):this.setAttribute(e,t)}})}));(e.mappedAttributes||[]).forEach((e=>{const o=new t,a="on"+e in n;a&&r.push(e),s[e]={configurable:st,get(){return o.get(this)},set(t){if(o.set(this,t),a){const n=ut(e);if(n.detail=t,rt.has(this))this.dispatchEvent(n);else{const e=nt.get(this);e?e.push(n):nt.set(this,[n])}}}}})),Ye(n,s);const i=o.concat(a);return i.length?Ye(e,{observedAttributes:{configurable:st,get:()=>i}}):e},ut=e=>new r(e),ht=(...e)=>new me("html",e);ht.for=Ke.for;const ft=(...e)=>new me("svg",e);ft.for=Qe.for;const dt=(e,n,r)=>{const s=pt(e,n,new t);return r.set(e,s),s},pt=(e,t,n)=>(r,...s)=>{const o=n.get(r)||((e,t,{info:n})=>{const r=n?Fe(t.join(Xe),n).split(Xe):t;return e.set(t,r),r})(n,r,e[Xe]);return Je(e,(()=>t(o,...s)))};function gt(e){this.addEventListener(e,this)}function mt(e){this.dispatchEvent(e)}function vt(){return et.get(this)||dt(this,ht,et)}function bt(){return tt.get(this)||dt(this,ft,tt)}function yt(e){this[`on${e.type}`](e)}function wt(){if(!rt.has(this)){rt.add(this),this[Xe].events.forEach(gt,this),this.dispatchEvent(ut("init"));const e=nt.get(this);e&&(nt.delete(this),e.forEach(mt,this))}}function Et(e,t,n){const r=ut("attributechanged");r.attributeName=e,r.oldValue=t,r.newValue=n,this.dispatchEvent(r)}function Ct(){this.dispatchEvent(ut("connected"))}function xt(){this.render()}function kt(){this.dispatchEvent(ut("disconnected"))}const{create:Nt,defineProperty:At,defineProperties:$t,getOwnPropertyNames:_t,getOwnPropertySymbols:St,getOwnPropertyDescriptor:jt,keys:Ot}=Object,Lt={element:HTMLElement},Mt=new t;new t;const Tt=new t;new t;const Rt=e=>{const t=Nt(null),n=Nt(null),r={prototype:n,statics:t};return _t(e).concat(St(e)).forEach((r=>{const s=jt(e,r);switch(s.enumerable=!1,r){case"extends":r="tagName";case"contains":case"includes":case"name":case"booleanAttributes":case"mappedAttributes":case"observedAttributes":case"style":case"tagName":t[r]=s;break;default:n[r]=s}})),r},Ut=(e,t,n)=>{if(!/^([A-Z][A-Za-z0-9_]*)(<([A-Za-z0-9:._-]+)>|:([A-Za-z0-9:._-]+))?$/.test(e))throw"Invalid name";const{$1:r,$3:s,$4:o}=RegExp;let a=s||o||t.tagName||t.extends||"element";const i="fragment"===a;if(i)a="element";else if(!/^[A-Za-z0-9:._-]+$/.test(a))throw"Invalid tag";let c="",l="";a.indexOf("-")<0?(c=r.replace(/(([A-Z0-9])([A-Z0-9][a-z]))|(([a-z])([A-Z]))/g,"$2$5-$3$6").toLowerCase()+n,c.indexOf("-")<0&&(l="-heresy")):(c=a+n,a="element");const u=c+l;if(customElements.get(u))throw`Duplicated ${u} definition`;const h=Be("object"==typeof t?Tt.get(t)||((e,t)=>{const{statics:n,prototype:r}=Rt(e),s=Be(Lt[t]||(Lt[t]=document.createElement(t).constructor),!1);return $t(s.prototype,r),$t(s,n),Tt.set(e,lt(s)),s})(t,a):Mt.get(t)||(e=>{const t=Be(e,!1);return Mt.set(e,lt(t)),t})(t),!0),f="element"===a;if(At(h,"new",{value:f?()=>document.createElement(u):()=>document.createElement(a,{is:u})}),At(h.prototype,"is",{value:u}),""===n){const e=(e=>{const{length:t}=e;let n=0,r=0;for(;r<t;)n=(n<<5)-n+e.charCodeAt(r++),n&=n;return n.toString(36)})(c.toUpperCase());ze.map[r]=Wt(h,a,u,{id:e,i:0}),ze.re=De(Ot(ze.map))}if(i){const{render:e}=h.prototype;At(h.prototype,"render",{configurable:!0,value(){if(e&&e.apply(this,arguments),this.parentNode){const{firstChild:e}=this;let t=null;if(e){const n=document.createRange();n.setStartBefore(e),n.setEndAfter(this.lastChild),t=n.extractContents(),this.parentNode.replaceChild(t,this)}}}})}const d=[u,h];return f||d.push({extends:a}),customElements.define(...d),{Class:h,is:u,name:r,tagName:a}},Wt=(e,t,n,r)=>{const{prototype:s}=e,o=((e,t)=>({tagName:e,is:t,element:"element"===e}))(t,n),a=[He(o)],i=e.includes||e.contains;if(i){const e={};Ot(i).forEach((t=>{const n=`-${r.id}-${r.i++}`,{Class:s,is:o,name:c,tagName:l}=Ut(t,i[t],n);a.push(He(e[c]=Wt(s,l,o,r)))}));const t=De(Ot(e)),{events:n}=s[Xe],o={events:n,info:{map:e,re:t}};if(At(s,Xe,{value:o}),"render"in s){const{render:e}=s,{info:t}=o;At(s,"render",{configurable:!0,value(){const n=Ie();qe(t);const r=e.apply(this,arguments);return qe(n),r}})}}return"style"in e&&(e=>{if((e||"").length){const t=document.createElement("style");t.type="text/css",t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e));const n=document.head||document.querySelector("head");n.insertBefore(t,n.lastChild)}})(e.style(...a)),o};const Pt="2.0.0-beta4",Zt=["audio","background","cameraAccess","chat","people","embed","emptyRoomInvitation","help","leaveButton","precallReview","screenshare","video","floatSelf","recording","logo","locking","participantCount","settingsButton","pipButton","moreButton","personality","subgridLabels","lowData","breakout"];var Bt,zt;Bt="WherebyEmbed",zt={oninit(){this.iframe=((e,t)=>e?e[t]||(e[t]={current:null}):{current:null})()},onconnected(){window.addEventListener("message",this.onmessage.bind(this))},ondisconnected(){window.removeEventListener("message",this.onmessage.bind(this))},observedAttributes:["displayName","minimal","room","subdomain","lang","metadata","groups","virtualBackgroundUrl","avatarUrl","externalId","title",...Zt].map((e=>e.toLowerCase())),onattributechanged({attributeName:e,oldValue:t}){["room","subdomain"].includes(e)&&null==t||this.render()},style:e=>`\n ${e} {\n display: block;\n }\n ${e} iframe {\n border: none;\n height: 100%;\n width: 100%;\n }\n `,_postCommand(e,t=[]){this.iframe.current&&this.iframe.current.contentWindow.postMessage({command:e,args:t},this.roomUrl.origin)},startRecording(){this._postCommand("start_recording")},stopRecording(){this._postCommand("stop_recording")},startStreaming(){this._postCommand("start_streaming")},stopStreaming(){this._postCommand("stop_streaming")},toggleCamera(e){this._postCommand("toggle_camera",[e])},toggleMicrophone(e){this._postCommand("toggle_microphone",[e])},toggleScreenshare(e){this._postCommand("toggle_screenshare",[e])},toggleChat(e){this._postCommand("toggle_chat",[e])},onmessage({origin:e,data:t}){if(!this.roomUrl||e!==this.roomUrl.origin)return;const{type:n,payload:r}=t;this.dispatchEvent(new CustomEvent(n,{detail:r}))},render(){const{avatarurl:e,displayname:t,lang:n,metadata:r,externalid:s,minimal:o,room:a,groups:i,virtualbackgroundurl:c,title:l}=this;let u,h;try{({roomUrl:u,subdomain:h}=function(e,t){if(!e)throw new Error("Missing room attribute");const n=/https:\/\/([^.]+)(\.whereby\.com|-ip-\d+-\d+-\d+-\d+.hereby.dev:4443)\/.+/.exec(e),r=n&&n[1]||t;if(!r)throw new Error("Missing subdomain attribute");if(!n)throw new Error("Could not parse room URL");return{subdomain:r,roomUrl:new URL(e)}}(a,this.subdomain))}catch(e){return this.html`Whereby: ${e instanceof Error?e.message:"unknown error"}`}this.roomUrl=u,Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({jsApi:!0,we:Pt,iframeSource:h},t&&{displayName:t}),n&&{lang:n}),r&&{metadata:r}),s&&{externalId:s}),i&&{groups:i}),c&&{virtualBackgroundUrl:c}),e&&{avatarUrl:e}),null!=o&&{embed:o}),Zt.reduce(((e,t)=>null!=this[t.toLowerCase()]?Object.assign(Object.assign({},e),{[t]:this[t.toLowerCase()]}):e),{}))).forEach((([e,t])=>{this.roomUrl.searchParams.has(e)||this.roomUrl.searchParams.set(e,t)})),this.html`
10
+ /*! (c) Andrea Giammarchi - ISC */let Ce=null;const xe=L(new WeakMap),ke=(e,t,n)=>{e.apply(t,n)},Ne={async:!1,always:!1},Ae=(e,t)=>"function"==typeof t?t(e):t,$e=(e,t,n,r)=>{const s=Ce.i++,{hook:o,args:a,stack:i,length:c}=Ce;s===c&&(Ce.length=i.push({}));const l=i[s];if(l.args=a,s===c){const s="function"==typeof n,{async:a,always:i}=(s?r:n)||r||Ne;l.$=s?n(t):Ae(void 0,t),l._=a?xe.get(o)||xe.set(o,Ee()):ke,l.f=t=>{const n=e(l.$,t);(i||l.$!==n)&&(l.$=n,l._(o,null,l.args))}}return[l.$,l.f]},_e=new WeakMap;function Se({hook:e}){return e===this.hook}const je=new WeakMap,Oe=L(je),Le=()=>{},Me=e=>(t,n)=>{const r=Ce.i++,{hook:s,after:o,stack:a,length:i}=Ce;if(r<i){const s=a[r],{update:i,values:c,stop:l}=s;if(!n||n.some(Pe,c)){s.values=n,e&&l(e);const{clean:r}=s;r&&(s.clean=null,r());const a=()=>{s.clean=t()};e?i(a):o.push(a)}}else{const r=e?Ee():Le,i={clean:null,update:r,values:n,stop:Le};Ce.length=a.push(i),(Oe.get(s)||Oe.set(s,[])).push(i);const c=()=>{i.clean=t()};e?i.stop=r(c):o.push(c)}},Te=e=>{(je.get(e)||[]).forEach((e=>{const{clean:t,stop:n}=e;n(),t&&(e.clean=null,t())}))};je.has.bind(je);const Re=Me(!0),Ue=Me(!1),We=(e,t)=>{const n=Ce.i++,{stack:r,length:s}=Ce;return n===s?Ce.length=r.push({$:e(),_:t}):t&&!t.some(Pe,r[n]._)||(r[n]={$:e(),_:t}),r[n].$};function Pe(e,t){return e!==this[t]}let Ze=null;try{Ze=new{o(){}}.o}catch(Bt){}let Be=e=>class extends e{};if(Ze){const{getPrototypeOf:e,setPrototypeOf:t}=Object,{construct:n}="object"==typeof Reflect?Reflect:{construct(e,n,r){const s=[null];for(let e=0;e<n.length;e++)s.push(n[e]);const o=e.bind.apply(e,s);return t(new o,r.prototype)}};Be=function(r,s){function o(){return n(s?e(r):r,arguments,o)}return t(o.prototype,r.prototype),t(o,r)}}const ze={map:{},re:null},De=e=>new RegExp(`<(/)?(${e.join("|")})([^A-Za-z0-9:._-])`,"g");let Ve=null;const Fe=(e,t)=>{const{map:n,re:r}=Ve||t;return e.replace(r,((e,t,r,s)=>{const{tagName:o,is:a,element:i}=n[r];return i?t?`</${a}>`:`<${a}${s}`:t?`</${o}>`:`<${o} is="${a}"${s}`}))},He=({tagName:e,is:t,element:n})=>n?t:`${e}[is="${t}"]`,Ie=()=>Ve,qe=e=>{Ve=e},Ge={useCallback:(e,t)=>We((()=>e),t),useContext:e=>{const{hook:t,args:n}=Ce,r=_e.get(e),s={hook:t,args:n};return r.some(Se,s)||r.push(s),e.value},useEffect:Re,useLayoutEffect:Ue,useMemo:We,useReducer:$e,useRef:e=>{const t=Ce.i++,{stack:n,length:r}=Ce;return t===r&&(Ce.length=n.push({current:e})),n[t]},useState:(e,t)=>$e(Ae,e,void 0,t)},{render:Je,html:Ke,svg:Qe}=(e=>{const t=oe(ce);return ie(e).forEach((n=>{t[n]=e[n](t[n]||("convert"===n?v:String))})),n.prototype=t,ue(n);function n(){return re.apply(this,arguments)}})({transform:()=>e=>Fe(e,ze)}),Xe="_🔥",{defineProperties:Ye}=Object,et=new t,tt=new t,nt=new t,rt=new c,st=!0,ot="attributeChangedCallback",at="connectedCallback",it=`dis${at}`,ct=(e,t,n)=>{if(n in e){const r=e[n];t[n]={configurable:st,value(){return wt.call(this),r.apply(this,arguments)}}}else t[n]={configurable:st,value:wt}},lt=e=>{const{prototype:n}=e,r=[],s={html:{configurable:st,get:vt},svg:{configurable:st,get:bt}};if(s[Xe]={value:{events:r,info:null}},"handleEvent"in n||(s.handleEvent={configurable:st,value:yt}),"render"in n&&n.render.length){const{oninit:e}=n;Ye(n,{oninit:{configurable:st,value(){const t=(e=>{const t=[];return function n(){const r=Ce,s=[];Ce={hook:n,args:arguments,stack:t,i:0,length:t.length,after:s};try{return e.apply(null,arguments)}finally{Ce=r;for(let e=0,{length:t}=s;e<t;e++)s[e]()}}})(this.render.bind(this,Ge));Ye(this,{render:{configurable:st,value:t}}),this.addEventListener("disconnected",Te.bind(null,t),!1),e&&e.apply(this,arguments)}}})}"oninit"in n&&(r.push("init"),ct(n,s,"render")),ct(n,s,ot),ct(n,s,at),ct(n,s,it),[[ot,"onattributechanged",Et],[at,"onconnected",Ct],[it,"ondisconnected",kt],[at,"render",xt]].forEach((([e,t,o])=>{if(!(e in n)&&t in n)if("render"!==t&&r.push(t.slice(2)),e in s){const t=s[e].value;s[e]={configurable:st,value(){return t.apply(this,arguments),o.apply(this,arguments)}}}else s[e]={configurable:st,value:o}}));const o=e.booleanAttributes||[];o.forEach((e=>{e in n||(s[e]={configurable:st,get(){return this.hasAttribute(e)},set(t){t&&"false"!==t?this.setAttribute(e,t):this.removeAttribute(e)}})}));const a=e.observedAttributes||[];a.forEach((e=>{e in n||(s[e]={configurable:st,get(){return this.getAttribute(e)},set(t){null==t?this.removeAttribute(e):this.setAttribute(e,t)}})}));(e.mappedAttributes||[]).forEach((e=>{const o=new t,a="on"+e in n;a&&r.push(e),s[e]={configurable:st,get(){return o.get(this)},set(t){if(o.set(this,t),a){const n=ut(e);if(n.detail=t,rt.has(this))this.dispatchEvent(n);else{const e=nt.get(this);e?e.push(n):nt.set(this,[n])}}}}})),Ye(n,s);const i=o.concat(a);return i.length?Ye(e,{observedAttributes:{configurable:st,get:()=>i}}):e},ut=e=>new r(e),ht=(...e)=>new me("html",e);ht.for=Ke.for;const ft=(...e)=>new me("svg",e);ft.for=Qe.for;const dt=(e,n,r)=>{const s=pt(e,n,new t);return r.set(e,s),s},pt=(e,t,n)=>(r,...s)=>{const o=n.get(r)||((e,t,{info:n})=>{const r=n?Fe(t.join(Xe),n).split(Xe):t;return e.set(t,r),r})(n,r,e[Xe]);return Je(e,(()=>t(o,...s)))};function gt(e){this.addEventListener(e,this)}function mt(e){this.dispatchEvent(e)}function vt(){return et.get(this)||dt(this,ht,et)}function bt(){return tt.get(this)||dt(this,ft,tt)}function yt(e){this[`on${e.type}`](e)}function wt(){if(!rt.has(this)){rt.add(this),this[Xe].events.forEach(gt,this),this.dispatchEvent(ut("init"));const e=nt.get(this);e&&(nt.delete(this),e.forEach(mt,this))}}function Et(e,t,n){const r=ut("attributechanged");r.attributeName=e,r.oldValue=t,r.newValue=n,this.dispatchEvent(r)}function Ct(){this.dispatchEvent(ut("connected"))}function xt(){this.render()}function kt(){this.dispatchEvent(ut("disconnected"))}const{create:Nt,defineProperty:At,defineProperties:$t,getOwnPropertyNames:_t,getOwnPropertySymbols:St,getOwnPropertyDescriptor:jt,keys:Ot}=Object,Lt={element:HTMLElement},Mt=new t;new t;const Tt=new t;new t;const Rt=e=>{const t=Nt(null),n=Nt(null),r={prototype:n,statics:t};return _t(e).concat(St(e)).forEach((r=>{const s=jt(e,r);switch(s.enumerable=!1,r){case"extends":r="tagName";case"contains":case"includes":case"name":case"booleanAttributes":case"mappedAttributes":case"observedAttributes":case"style":case"tagName":t[r]=s;break;default:n[r]=s}})),r},Ut=(e,t,n)=>{if(!/^([A-Z][A-Za-z0-9_]*)(<([A-Za-z0-9:._-]+)>|:([A-Za-z0-9:._-]+))?$/.test(e))throw"Invalid name";const{$1:r,$3:s,$4:o}=RegExp;let a=s||o||t.tagName||t.extends||"element";const i="fragment"===a;if(i)a="element";else if(!/^[A-Za-z0-9:._-]+$/.test(a))throw"Invalid tag";let c="",l="";a.indexOf("-")<0?(c=r.replace(/(([A-Z0-9])([A-Z0-9][a-z]))|(([a-z])([A-Z]))/g,"$2$5-$3$6").toLowerCase()+n,c.indexOf("-")<0&&(l="-heresy")):(c=a+n,a="element");const u=c+l;if(customElements.get(u))throw`Duplicated ${u} definition`;const h=Be("object"==typeof t?Tt.get(t)||((e,t)=>{const{statics:n,prototype:r}=Rt(e),s=Be(Lt[t]||(Lt[t]=document.createElement(t).constructor),!1);return $t(s.prototype,r),$t(s,n),Tt.set(e,lt(s)),s})(t,a):Mt.get(t)||(e=>{const t=Be(e,!1);return Mt.set(e,lt(t)),t})(t),!0),f="element"===a;if(At(h,"new",{value:f?()=>document.createElement(u):()=>document.createElement(a,{is:u})}),At(h.prototype,"is",{value:u}),""===n){const e=(e=>{const{length:t}=e;let n=0,r=0;for(;r<t;)n=(n<<5)-n+e.charCodeAt(r++),n&=n;return n.toString(36)})(c.toUpperCase());ze.map[r]=Wt(h,a,u,{id:e,i:0}),ze.re=De(Ot(ze.map))}if(i){const{render:e}=h.prototype;At(h.prototype,"render",{configurable:!0,value(){if(e&&e.apply(this,arguments),this.parentNode){const{firstChild:e}=this;let t=null;if(e){const n=document.createRange();n.setStartBefore(e),n.setEndAfter(this.lastChild),t=n.extractContents(),this.parentNode.replaceChild(t,this)}}}})}const d=[u,h];return f||d.push({extends:a}),customElements.define(...d),{Class:h,is:u,name:r,tagName:a}},Wt=(e,t,n,r)=>{const{prototype:s}=e,o=((e,t)=>({tagName:e,is:t,element:"element"===e}))(t,n),a=[He(o)],i=e.includes||e.contains;if(i){const e={};Ot(i).forEach((t=>{const n=`-${r.id}-${r.i++}`,{Class:s,is:o,name:c,tagName:l}=Ut(t,i[t],n);a.push(He(e[c]=Wt(s,l,o,r)))}));const t=De(Ot(e)),{events:n}=s[Xe],o={events:n,info:{map:e,re:t}};if(At(s,Xe,{value:o}),"render"in s){const{render:e}=s,{info:t}=o;At(s,"render",{configurable:!0,value(){const n=Ie();qe(t);const r=e.apply(this,arguments);return qe(n),r}})}}return"style"in e&&(e=>{if((e||"").length){const t=document.createElement("style");t.type="text/css",t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e));const n=document.head||document.querySelector("head");n.insertBefore(t,n.lastChild)}})(e.style(...a)),o};const Pt="2.0.0",Zt=["audio","background","cameraAccess","chat","people","embed","emptyRoomInvitation","help","leaveButton","precallReview","screenshare","video","floatSelf","recording","logo","locking","participantCount","settingsButton","pipButton","moreButton","personality","subgridLabels","lowData","breakout"];var Bt,zt;return Bt="WherebyEmbed",zt={oninit(){this.iframe=((e,t)=>e?e[t]||(e[t]={current:null}):{current:null})()},onconnected(){window.addEventListener("message",this.onmessage.bind(this))},ondisconnected(){window.removeEventListener("message",this.onmessage.bind(this))},observedAttributes:["displayName","minimal","room","subdomain","lang","metadata","groups","virtualBackgroundUrl","avatarUrl","externalId","title",...Zt].map((e=>e.toLowerCase())),onattributechanged({attributeName:e,oldValue:t}){["room","subdomain"].includes(e)&&null==t||this.render()},style:e=>`\n ${e} {\n display: block;\n }\n ${e} iframe {\n border: none;\n height: 100%;\n width: 100%;\n }\n `,_postCommand(e,t=[]){this.iframe.current&&this.iframe.current.contentWindow.postMessage({command:e,args:t},this.roomUrl.origin)},startRecording(){this._postCommand("start_recording")},stopRecording(){this._postCommand("stop_recording")},startStreaming(){this._postCommand("start_streaming")},stopStreaming(){this._postCommand("stop_streaming")},toggleCamera(e){this._postCommand("toggle_camera",[e])},toggleMicrophone(e){this._postCommand("toggle_microphone",[e])},toggleScreenshare(e){this._postCommand("toggle_screenshare",[e])},toggleChat(e){this._postCommand("toggle_chat",[e])},onmessage({origin:e,data:t}){if(!this.roomUrl||e!==this.roomUrl.origin)return;const{type:n,payload:r}=t;this.dispatchEvent(new CustomEvent(n,{detail:r}))},render(){const{avatarurl:e,displayname:t,lang:n,metadata:r,externalid:s,minimal:o,room:a,groups:i,virtualbackgroundurl:c,title:l}=this;let u,h;try{({roomUrl:u,subdomain:h}=function(e,t){if(!e)throw new Error("Missing room attribute");const n=/https:\/\/([^.]+)(\.whereby\.com|-ip-\d+-\d+-\d+-\d+.hereby.dev:4443)\/.+/.exec(e),r=n&&n[1]||t;if(!r)throw new Error("Missing subdomain attribute");if(!n)throw new Error("Could not parse room URL");return{subdomain:r,roomUrl:new URL(e)}}(a,this.subdomain))}catch(e){return this.html`Whereby: ${e instanceof Error?e.message:"unknown error"}`}this.roomUrl=u,Object.entries(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({jsApi:!0,we:Pt,iframeSource:h},t&&{displayName:t}),n&&{lang:n}),r&&{metadata:r}),s&&{externalId:s}),i&&{groups:i}),c&&{virtualBackgroundUrl:c}),e&&{avatarUrl:e}),null!=o&&{embed:o}),Zt.reduce(((e,t)=>null!=this[t.toLowerCase()]?Object.assign(Object.assign({},e),{[t]:this[t.toLowerCase()]}):e),{}))).forEach((([e,t])=>{this.roomUrl.searchParams.has(e)||this.roomUrl.searchParams.set(e,t)})),this.html`
11
11
  <iframe
12
12
  title=${l||"Video calling component"}
13
13
  ref=${this.iframe}
14
14
  src=${this.roomUrl}
15
15
  allow="autoplay; camera; microphone; fullscreen; speaker; display-capture" />
16
- `}},("string"==typeof Bt?Ut(Bt,zt,""):Ut(Bt.name,Bt,"")).Class;var Dt={sdkVersion:Pt};export{Dt as default};
16
+ `}},("string"==typeof Bt?Ut(Bt,zt,""):Ut(Bt.name,Bt,"")).Class,{sdkVersion:Pt}}();
@@ -20,7 +20,7 @@ function parseRoomUrlAndSubdomain(roomAttribute, subdomainAttribute) {
20
20
  };
21
21
  }
22
22
 
23
- const sdkVersion = "2.0.0-beta4";
23
+ const sdkVersion = "2.0.0";
24
24
 
25
25
  const boolAttrs = [
26
26
  "audio",
@@ -584,6 +584,10 @@ type ConnectionStatus$1 = "initializing" | "connecting" | "connected" | "reconne
584
584
  * Reducer
585
585
  */
586
586
  interface RoomConnectionState$1 {
587
+ session: {
588
+ createdAt: string;
589
+ id: string;
590
+ } | null;
587
591
  status: ConnectionStatus$1;
588
592
  error: unknown;
589
593
  }
@@ -218,6 +218,7 @@ const signalEvents = {
218
218
  newClient: createSignalEventAction("newClient"),
219
219
  roomJoined: createSignalEventAction("roomJoined"),
220
220
  roomKnocked: createSignalEventAction("roomKnocked"),
221
+ roomSessionEnded: createSignalEventAction("roomSessionEnded"),
221
222
  screenshareStarted: createSignalEventAction("screenshareStarted"),
222
223
  screenshareStopped: createSignalEventAction("screenshareStopped"),
223
224
  streamingStopped: createSignalEventAction("streamingStopped"),
@@ -413,6 +414,7 @@ function forwardSocketEvents(socket, dispatch) {
413
414
  socket.on("chat_message", (payload) => dispatch(signalEvents.chatMessage(payload)));
414
415
  socket.on("disconnect", () => dispatch(signalEvents.disconnect()));
415
416
  socket.on("room_knocked", (payload) => dispatch(signalEvents.roomKnocked(payload)));
417
+ socket.on("room_session_ended", (payload) => dispatch(signalEvents.roomSessionEnded(payload)));
416
418
  socket.on("knocker_left", (payload) => dispatch(signalEvents.knockerLeft(payload)));
417
419
  socket.on("knock_handled", (payload) => dispatch(signalEvents.knockHandled(payload)));
418
420
  socket.on("screenshare_started", (payload) => dispatch(signalEvents.screenshareStarted(payload)));
@@ -2038,6 +2040,7 @@ const selectScreenshares = createSelector(selectLocalScreenshareStream, selectRe
2038
2040
  });
2039
2041
 
2040
2042
  const initialState$6 = {
2043
+ session: null,
2041
2044
  status: "initializing",
2042
2045
  error: null,
2043
2046
  };
@@ -2051,12 +2054,24 @@ const roomConnectionSlice = createSlice({
2051
2054
  },
2052
2055
  extraReducers: (builder) => {
2053
2056
  builder.addCase(signalEvents.roomJoined, (state, action) => {
2057
+ var _a, _b;
2054
2058
  //TODO: Handle error
2055
2059
  const { error, isLocked } = action.payload;
2056
2060
  if (error === "room_locked" && isLocked) {
2057
2061
  return Object.assign(Object.assign({}, state), { status: "room_locked" });
2058
2062
  }
2059
- return Object.assign(Object.assign({}, state), { status: "connected" });
2063
+ return Object.assign(Object.assign({}, state), { status: "connected", session: (_b = (_a = action.payload.room) === null || _a === void 0 ? void 0 : _a.session) !== null && _b !== void 0 ? _b : null });
2064
+ });
2065
+ builder.addCase(signalEvents.newClient, (state, action) => {
2066
+ var _a, _b;
2067
+ return Object.assign(Object.assign({}, state), { session: (_b = (_a = action.payload.room) === null || _a === void 0 ? void 0 : _a.session) !== null && _b !== void 0 ? _b : null });
2068
+ });
2069
+ builder.addCase(signalEvents.roomSessionEnded, (state, action) => {
2070
+ var _a;
2071
+ if (((_a = state.session) === null || _a === void 0 ? void 0 : _a.id) !== action.payload.roomSessionId) {
2072
+ return state;
2073
+ }
2074
+ return Object.assign(Object.assign({}, state), { session: null });
2060
2075
  });
2061
2076
  builder.addCase(socketReconnecting, (state) => {
2062
2077
  return Object.assign(Object.assign({}, state), { status: "reconnect" });
@@ -2128,6 +2143,7 @@ const doConnectRoom = createAppThunk(() => (dispatch, getState) => {
2128
2143
  });
2129
2144
  dispatch(connectionStatusChanged("connecting"));
2130
2145
  });
2146
+ const selectRoomConnectionSessionId = (state) => { var _a; return (_a = state.roomConnection.session) === null || _a === void 0 ? void 0 : _a.id; };
2131
2147
  const selectRoomConnectionStatus = (state) => state.roomConnection.status;
2132
2148
  /**
2133
2149
  * Reactors
@@ -7384,6 +7400,12 @@ const rtcAnalyticsCustomEvents = {
7384
7400
  getValue: (state) => selectSignalStatus(state),
7385
7401
  getOutput: (value) => ({ status: value }),
7386
7402
  },
7403
+ roomSessionId: {
7404
+ action: null,
7405
+ rtcEventName: "roomSessionId",
7406
+ getValue: (state) => selectRoomConnectionSessionId(state),
7407
+ getOutput: (value) => ({ roomSessionId: value }),
7408
+ },
7387
7409
  rtcConnectionStatus: {
7388
7410
  action: null,
7389
7411
  rtcEventName: "rtcConnectionStatus",
@@ -7422,6 +7444,16 @@ const doRtcAnalyticsCustomEventsInitialize = createAppThunk(() => (dispatch, get
7422
7444
  const rtcManager = selectRtcConnectionRaw(state).rtcManager;
7423
7445
  if (!rtcManager)
7424
7446
  return;
7447
+ // RTC stats require a `insightsStats` event to be sent to set the timestamp.
7448
+ // This is a temporary workaround, we just send one dummy event on initialization.
7449
+ rtcManager.sendStatsCustomEvent("insightsStats", {
7450
+ _time: Date.now(),
7451
+ ls: 0,
7452
+ lr: 0,
7453
+ bs: 0,
7454
+ br: 0,
7455
+ cpu: 0,
7456
+ });
7425
7457
  Object.values(rtcAnalyticsCustomEvents).forEach(({ rtcEventName, getValue, getOutput }) => {
7426
7458
  var _a;
7427
7459
  const value = getValue(state);
@@ -8651,7 +8683,7 @@ const selectRoomConnectionState = createSelector(selectChatMessages, selectCloud
8651
8683
  return state;
8652
8684
  });
8653
8685
 
8654
- const sdkVersion = "2.0.0-beta4";
8686
+ const sdkVersion = "2.0.0";
8655
8687
 
8656
8688
  const initialState$1 = {
8657
8689
  chatMessages: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whereby.com/browser-sdk",
3
- "version": "2.0.0-beta4",
3
+ "version": "2.0.0",
4
4
  "description": "Modules for integration Whereby video in web apps",
5
5
  "author": "Whereby AS",
6
6
  "license": "MIT",