!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("riot"),require("@riotjs/util/dom")):"function"==typeof define&&define.amd?define(["riot","@riotjs/util/dom"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).lazy=e(t.riot,t.dom)}(this,(function(t,e){"use strict";const n=new WeakMap;function o(t,e){return{name:"lazy",exports:o.export(t,e)}}return o.cache=n,o.export=function(o,i){const s=o&&i,u=s?i:o,r=n.get(u);return t.pure((i=>{let{slots:p,attributes:a,props:c}=i;return{mount(t,e){this.el=t,this.isMounted=!0;const i=()=>{this.mountLazyComponent(e),this.el.dispatchEvent(new Event("load"))};r?i():(s&&this.createManagedComponent(o,e),("function"==typeof u?u():Promise.resolve(u)).then((t=>{n.set(u,t.default||t),i()})))},createManagedComponent(e,n){this.component=t.component(e)(this.el,c,{attributes:a,slots:p,parentScope:n})},mountLazyComponent(t){this.isMounted&&(this.component&&(this.component.unmount(!0),this.el.children.length&&e.cleanNode(this.el)),this.createManagedComponent(n.get(u),t))},update(t){this.isMounted&&this.component&&this.component.update({},t)},unmount(){this.isMounted=!1,this.component&&this.component.unmount(...arguments)}}}))},o}));