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