import"./immer.js";import{defineSmartComponentCore as t}from"../smart-manager.js";import{META as n}from"./smart-symbols.js";import{produce as e}from"immer/dist/immer.esm.js";function o(o){t({selector:o.selector,params:o.params,onConnect(t,e){null==e[n]&&(e[n]=new Map),e[n].set(o,{})},onContextUpdate(t,a,s){if(Object.entries(o.params).filter((([,t])=>!0!==t.optional)).map((([t])=>t)).some((t=>null==s[t])))return;const c=a[n].get(o);c.abortController?.abort(),c.abortController=new AbortController;const l=c.abortController.signal;const i=new EventTarget;i.addEventListener("update-component",(t=>{const n=t;!function(t,n,o){const r=t;"function"==typeof o?null!=r[n]&&(r[n]=e(r[n],o)):r[n]=o}(a,n.property,n.callbackOrObject)}),{signal:l}),o.onContextUpdate({container:t,component:a,context:s,onEvent:function(t,n){a.addEventListener(t,(t=>{n(t.detail)}),{signal:l})},updateComponent:function(t,n){const e=new r(t,n);i.dispatchEvent(e)},signal:l})},onDisconnect(t,e){e[n].get(o).abortController?.abort(),e[n].delete(o)}})}class r extends Event{constructor(t,n){super("update-component"),this.property=t,this.callbackOrObject=n}}export{o as defineSmartComponent};
//# sourceMappingURL=define-smart-component.js.map
