(()=>{"use strict";var e,r={823:()=>{const e=window.wp.element,r=window.wp.compose;class t{constructor(e,r){this.url=e;for(let e in r){let t=r[e];"boolean"==typeof t&&(t=t?"true":"false"),t&&this.url.searchParams.append(e,t)}this.applyLoginToken()}toString(){return this.url.toString()}applyLoginToken(){const e="loginToken",r=new URLSearchParams(window.location.search);var t;r.has(e)&&this.url.searchParams.append(e,null!==(t=r.get(e))&&void 0!==t?t:"")}}function o(o){const{focusable:n,iframeUrl:i,instanceId:a,defaultHomeserver:s,roomId:l,enableServiceWorker:c}=o,u=n?(0,r.useFocusableIframe)():void 0,d=new t(i,{instanceId:a,defaultHomeserver:s,roomId:l,enableServiceWorker:c});return(0,e.createElement)("div",{className:"chatrix-component-chat"},(0,e.createElement)("iframe",{ref:u,src:d.toString()}))}function n(r){const{focusable:t,iframeUrl:n}=r,{instanceId:i,defaultHomeserver:a,roomId:s,enableServiceWorker:l,height:c,borderWidth:u,borderRadius:d,borderStyle:h,borderColor:v}=r.attributes,m={height:c?c.toString():"",borderWidth:u?u.toString():0,borderRadius:d?d.toString():"",borderStyle:null!=h?h:"",borderColor:null!=v?v:""},f={focusable:t,iframeUrl:n,instanceId:i,defaultHomeserver:a,roomId:s,enableServiceWorker:l};return(0,e.createElement)("div",{className:"chatrix-component-block",style:m},(0,e.createElement)(o,f))}let i;!function(e){e.px="px",e["%"]="%",e.vh="vh",e.vw="vw",e.vmax="vmax",e.vmin="vmin",e.em="em",e.rem="rem"}(i||(i={}));class a{constructor(e,r){this.value="string"==typeof e?+e:e,this.unit="string"==typeof r?i[r]:r}toString(){return this.value&&this.unit?`${this.value}${this.unit}`:""}}function s(e){const{instanceId:r,defaultHomeserver:t,roomId:o,enableServiceWorker:n,height:i,borderWidth:a,borderRadius:s,borderStyle:d,borderColor:h}=e;return{instanceId:r,defaultHomeserver:null!=t?t:"",roomId:null!=o?o:"",enableServiceWorker:null==n||n,height:i?new l(i.value,i.unit):void 0,borderWidth:a?new c(a.value,a.unit):void 0,borderRadius:s?new u(s.value,s.unit):void 0,borderStyle:d,borderColor:h}}class l extends a{constructor(e,r){super(e,r)}}class c extends a{constructor(e,r){super(e,r)}toString(){return this.value&&this.unit?`${this.value}${this.unit}`:"0"}}class u extends a{constructor(e,r){super(e,r)}}function d(r,t){const o={...t,iframeUrl:h()},i=(0,e.createElement)(n,o);(0,e.render)(i,r)}function h(){var e;let r=window.origin;const t=null!==(e=window.ChatrixConfig)&&void 0!==e?e:null;return t&&t.rootUrl&&(r=t.rootUrl),new URL("iframe.html",r)}function v(e){var r,t;const o=decodeURIComponent(null!==(r=null===(t=e.dataset)||void 0===t?void 0:t.chatrixBlockConfig)&&void 0!==r?r:"");if(""===o)throw"Data attribute for chatrix block was not found, or is empty";return JSON.parse(o)}window.addEventListener("DOMContentLoaded",(()=>{(async function(){await async function(e){return new Promise((e=>setTimeout(e,1)))}();const e=document.getElementsByClassName("wp-block-automattic-chatrix");for(const r of e){const e=s(v(r).attributes),t={attributes:e};e.instanceId||console.warn("Chatrix block is missing the instanceId attribute. Re-save the page to fix this."),d(r,t)}})().catch((e=>{console.error(e)}))}))}},t={};function o(e){var n=t[e];if(void 0!==n)return n.exports;var i=t[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.m=r,e=[],o.O=(r,t,n,i)=>{if(!t){var a=1/0;for(u=0;u<e.length;u++){for(var[t,n,i]=e[u],s=!0,l=0;l<t.length;l++)(!1&i||a>=i)&&Object.keys(o.O).every((e=>o.O[e](t[l])))?t.splice(l--,1):(s=!1,i<a&&(a=i));if(s){e.splice(u--,1);var c=n();void 0!==c&&(r=c)}}return r}i=i||0;for(var u=e.length;u>0&&e[u-1][2]>i;u--)e[u]=e[u-1];e[u]=[t,n,i]},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{var e={692:0,431:0};o.O.j=r=>0===e[r];var r=(r,t)=>{var n,i,[a,s,l]=t,c=0;if(a.some((r=>0!==e[r]))){for(n in s)o.o(s,n)&&(o.m[n]=s[n]);if(l)var u=l(o)}for(r&&r(t);c<a.length;c++)i=a[c],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return o.O(u)},t=globalThis.webpackChunkchatrix=globalThis.webpackChunkchatrix||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})();var n=o.O(void 0,[431],(()=>o(823)));n=o.O(n)})();