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