/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{makeHandle as e}from"../../core/handleUtils.js";import{widgetSymbol as t,widgetTestDataSymbol as r}from"./symbols.js";const o=[],n={},i=new Map;function d(e,t){let r=t.children;if(r?.length)for(let o=0;o<r.length;++o)r[o]=d(e,r[o]);else r=o;const i=t.vnodeSelector;if(f(i)){const o=t.properties||n,d=o.key||i,f={key:d,afterCreate:c,afterUpdate:s,afterRemoved:a,parentWidget:e,widgetConstructor:i,widgetProperties:{...o,key:d,children:r}};return{vnodeSelector:i.vnodeSelector,properties:f,children:void 0,text:void 0,domNode:null}}return t}function c(t,o,n,{parentWidget:d,widgetConstructor:c,widgetProperties:s}){const f=new c(s);f.container=t,i.set(t,f),f.afterCreate?.(f,t),d.addHandles(e(()=>a(t))),queueMicrotask(()=>{f[r].projector?.renderNow()})}function s(e,t,r,{widgetProperties:o}){const n=i.get(e);n&&(n.set(o),n.afterUpdate?.(n,e))}function a(e){const t=i.get(e);t&&(t.afterRemoved?.(t,e),t.destroy(),i.delete(e))}function f(e){return"function"==typeof e&&e[t]}export{f as isWidgetConstructor,d as processWidgets,i as widgetMap};
