import{a as n,g as o}from"./p-e97fde0a.js";var r=new Map,a=function(e,a){var n=e.fields,t=e.updater;n.forEach((function(e){t(e,a[e])}))},i={create:function(e,t){var o=n(e),c=new Map,l={wormholes:c,state:t};r.set(e,l);var i=e.connectedCallback;e.connectedCallback=function(){r.set(e,l),i&&i.call(e)};var d=e.disconnectedCallback;e.disconnectedCallback=function(){r.delete(e),d&&d.call(e)},o.addEventListener("openWormhole",(function(e){e.stopPropagation();var n=e.detail,t=n.consumer,o=n.onOpen;if(!c.has(t)){if("symbol"!=typeof t){var r=t.connectedCallback,i=t.disconnectedCallback;t.connectedCallback=function(){c.set(t,e.detail),r&&r.call(t)},t.disconnectedCallback=function(){c.delete(t),i&&i.call(t)}}c.set(t,e.detail),a(e.detail,l.state),null==o||o.resolve((function(){c.delete(t)}))}})),o.addEventListener("closeWormhole",(function(e){var a=e.detail;c.delete(a)}))},Provider:function(e,n){var t=e.state,c=o();if(r.has(c)){var l=r.get(c);l.state=t,l.wormholes.forEach((function(e){a(e,t)}))}return n}};export{i as U};