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