import { M as MountResult } from './mount-Bo2qOx25.js';
import { ReadonlySignal } from '@preact/signals-core';
import './jsx-runtime.js';
import './bindings-CYwoJpQb.js';
/**
* `kerfjs/remount` — force a subtree to be REPLACED, not morphed, when a key changes.
*
* kerf morphs by default, which is almost always right. The exception is a
* library-owned subtree (a highlighted diff, a chart, an editor) that must be
* torn down and rebuilt on fresh DOM when its identity changes — so the library
* re-initializes instead of the morph patching stale internals underneath it.
* The folk pattern is a monotonic counter spent as `data-key={`gen-${n}`}` on a
* `data-morph-skip` div; `remountOn` names that pattern.
*
* import { remountOn } from 'kerfjs/remount';
*
* // Replace the diff pane whenever the file (or diff mode) changes:
* const stop = remountOn(paneEl, () => fileId.value, () => );
* // same key -> the subtree is left entirely alone
* // key change -> old subtree + its mounts disposed, a fresh one mounted
*
* `remountOn` owns `parent`'s children (like `mount()` / `bindList`). It returns
* a disposer that tears down the current subtree and stops watching the key.
* Pairs with `kerfjs/attach`: put the widget's setup/teardown on the fresh
* node, and `remountOn` drives its re-creation.
*/
/** The key that drives a {@link remountOn}: a signal, or a thunk that reads signals. */
type RemountKey = ReadonlySignal | (() => K);
/** Options for {@link remountOn}. */
interface RemountOptions {
/**
* Called after each (re)mount with `parent` — the live, freshly-rendered
* subtree. This is where you bind a widget to the new DOM (e.g.
* `attach(parent.querySelector('.host'), setup)` from `kerfjs/attach`),
* because `render` returns a string and has no live node yet. May return a
* cleanup `() => void` that runs before the NEXT remount and on dispose — return
* the disposer from `attach()` here for synchronous teardown.
*/
onMount?: (root: HTMLElement) => (() => void) | void;
}
/**
* Watch `key` and, whenever it changes (by `Object.is`), dispose the current
* subtree + its mounts and render a fresh one into `parent` via `mount(render)`.
* An unchanged key leaves the subtree untouched. `options.onMount(parent)` runs
* after each (re)mount to bind widgets to the fresh DOM. Returns a disposer that
* tears down the current subtree and stops watching.
*/
declare function remountOn(parent: HTMLElement, key: RemountKey, render: () => MountResult, options?: RemountOptions): () => void;
export { type RemountKey, type RemountOptions, remountOn };