class t{static is(t){return"object"==typeof t&&"string"==typeof t.destination&&null!=t.content}static send(s,n,e){if(t.is(s)&&null==e){(e=n)||(e=window);const t=s.destination.split("#",2);e.postMessage(s={destination:t[1],content:s.content},t[0])}else"string"!=typeof e&&(e||(e=window),"string"==typeof s&&t.send({destination:s,content:n},e))}static listen(s,n,e){const i=s.split("#",2);let o="";2==i.length&&(s=i[0],o=i[1]),(e||window).addEventListener("message",(e=>{const i=e.data;!t.is(i)||"*"!=s&&e.origin!=s||""!=o&&i.destination!=o||n(i.destination,i.content)}))}}class s{static is(t){return"object"==typeof t&&"string"==typeof t.name}}export{t as M,s as T}