import type { IObjectOf } from "@thi.ng/api" ; export interface ILifecycle { /**
     * Component init method. Called with the actual DOM element, hdom
     * user context and any other args when the component is first used,
     * but **after** `render()` has been called once already AND all of
     * the components children have been realized. Therefore, if any
     * children have their own `init` lifecycle method, these hooks will
     * be executed before that of the parent.
     */ init ? ( el , ctx , ... args ) : void ; /**
     * Returns the hdom tree of this component.
     * Note: Always will be called first (prior to `init`/`release`)
     * to obtain the actual component definition used for diffing.
     * Therefore might have to include checks if any local state
     * has already been initialized via `init`. This is the only
     * mandatory method which MUST be implemented.
     *
     * `render` is executed before `init` because `normalizeTree()`
     * must obtain the component's hdom tree first before it can
     * determine if an `init` is necessary. `init` itself will be
     * called from `diffTree`, `createDOM` or `hydrateDOM()` in a later
     * phase of processing.
     *
     * `render` should ALWAYS return an array or another function,
     * else the component's `init` or `release` fns will NOT be able
     * to be called later. E.g. If the return value of `render`
     * evaluates as a string or number, the return value should be
     * wrapped as `["span", "foo"]`. If no `init` or `release` are
     * used, this requirement is relaxed.
     */ render ( ctx , ... args ) : any ; /**
     * Called when the underlying DOM of this component is removed
     * (or replaced). Intended for cleanup tasks.
     */ release ? ( ctx , ... args ) : void ; } export interface HDOMBehaviorAttribs { /**
     * HDOM behavior control attribute. If true (default), the element
     * will be fully processed by `diffTree()`. If false, no diff will
     * be computed and the `replaceChild()` operation will be called in
     * the currently active hdom target implementation.
     */ __diff ? : boolean ; /**
     * HDOM behavior control attribute. If true, the element will not be
     * diffed and simply skipped. IMPORTANT: This attribute is only
     * intended for cases when a component / tree branch should not be
     * updated, but MUST NEVER be enabled when that component is first
     * included in the tree. Doing so will result in undefined future
     * behavior.
     *
     * Note, skipped elements and their children are being normalized,
     * but are ignored during diffing. Therefore, if this attribute is
     * enabled the element should either have no children OR the
     * children are the same (type) as when the attribute is disabled
     * (i.e. when `__skip` is falsy).
     */ __skip ? : boolean ; /**
     * HDOM behavior control attribute. If present, the element and all
     * of its children will be processed by the given
     * `HDOMImplementation` instead of the default implementation.
     */ __impl ? : HDOMImplementation < any > ; /**
     * HDOM behavior control attribute. If `false`, the current
     * element's children will not be normalized. Use this when you're
     * sure that all children are already in canonical format (incl.
     * `key` attributes). See `normalizeTree()` for details.
     */ __normalize ? : boolean ; /**
     * HDOM behavior control attribute. If `false`, hdom will not
     * attempt to call `release()` lifecycle methods on this element or
     * any of its children.
     */ __release ? : boolean ; /**
     * Currently only used by  {@link @thi.ng/hiccup# | @thi.ng/hiccup} . No relevance for hdom. If
     * `false`, the element and its children will be omitted from the
     * serialized result.
      __serialize ? : boolean ; } export interface ComponentAttribs extends HDOMBehaviorAttribs { class ? : string ; disabled ? : boolean ; href ? : string ; id ? : string ; key ? : string ; style ? : string | IObjectOf < string | number > ; [ _ ] : any ; } export interface HDOMOpts { defaultValue root ? : Element | string ; /**
     * Arbitrary user context object, passed to all component functions
     * embedded in the tree.
     */ ctx ? : any ; /**
     * Attempts to auto-expand/deref the given keys in the user supplied
     * context object (`ctx` option) prior to *each* tree normalization.
     * All of these values should implement the
     *  {@link @thi.ng/api#IDeref} interface (e.g. atoms, cursors, views,
     * rstreams etc.). This feature can be used to define dynamic
     * contexts linked to the main app state, e.g. using derived views
     * provided by  {@link @thi.ng/atom# | @thi.ng/atom} .
     *
     *  defaultValue autoDerefKeys : PropertyKey [ ] ; defaultValue keys ? : boolean ; defaultValue span ? : boolean ; defaultValue hydrate ? : boolean ; /**
     * Allow further custom opts.
     */ [ id ] : any ; } /**
 * This interface defines the underlying target update operations used
 * by `diffTree()` and `createDOM()`. It allows  {@link @thi.ng/hdom# | @thi.ng/hdom} to
 * be used as general purpose tree definition & differential update
 * mechanism, rather than being restricted to only work with an HTML
 * DOM. See  DEFAULT_IMPL for the default implementations dealing
 * with the latter. Note: Depending on use case and tree configuration,
 * not all of these methods are required.
 *
 * Custom element-local implementations can also be provided via the
 * special `__impl` hdom element/component attribute. In this case the
 * element itself and all of its children will be processed with those
 * custom operations.
  export interface HDOMImplementation < T > { param tree param opts normalizeTree ( opts , tree ) : any [ ] ; remarks param parent param tree param child param init - true, if  ILifecycle . init methods are called
      createTree ( opts , parent , tree , child ? , init ? ) : T | T [ ] ; param opts param parent param tree param child hydrateTree ( opts , parent , tree , child ? ) : void ; param opts param parent param prev param curr param child diffTree ( opts , parent , prev , curr , child ? ) : void ; param parent param tag param attribs param child createElement ( parent , tag , attribs ? , child ? ) : T ; param parent param content createTextElement ( parent , content ) : T ; param id getElementById ( id ) : T | null ; param parent param child param newTree replaceChild ( opts , parent , child , newTree , init ? ) : T | T [ ] ; param parent param i getChild ( parent , i ) : T ; param parent param i removeChild ( parent , i ) : void ; param element param id param value param attribs setAttrib ( element , id , value , attribs ? ) : void ; param element param attribs param prevAttribs removeAttribs ( element , attribs , prevAttribs ) : void ; param element param value setContent ( element , value ) : void ; }