(function(n,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(n=typeof globalThis<"u"?globalThis:n||self,t(n.trame_iframe={},n.Vue))})(this,function(n,t){"use strict";const f={IFrame:{setup(m,{emit:a,expose:u}){const i=t.ref(null);function s(o){i.value&&i.value.contentWindow.postMessage(o,"*")}function e(o){var r,d;(r=o==null?void 0:o.data)!=null&&r.emit&&a(o.data.emit,(d=o.data)==null?void 0:d.value)}return t.onMounted(()=>{i.value.contentWindow.addEventListener("message",e)}),t.onBeforeUnmount(()=>{i.value.contentWindow.removeEventListener("message",e)}),u({triggerEmit:e,postMessage:s}),{triggerEmit:e,postMessage:s,elem:i}},template:'<iframe ref="elem" v-bind="$attrs"></iframe>'},Communicator:{setup(m,{emit:a}){const u=t.inject("trame");function i(e){window.postMessage(e,"*")}function s(e){var o,r,d;(o=e==null?void 0:e.data)!=null&&o.emit&&a(e.data.emit,(r=e.data)==null?void 0:r.value),(d=e==null?void 0:e.data)!=null&&d.state&&u.state.update(e.data.state)}return t.onMounted(()=>{window.addEventListener("message",s)}),t.onBeforeUnmount(()=>{window.removeEventListener("message",s)}),{postMessage:i,triggerEmit:s}}}};function c(m){Object.keys(f).forEach(a=>{m.component(a,f[a])})}n.install=c,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
