// src/hooks.ts
import { useHost, useMemo } from "atomico";
import { render } from "lit-html";
function useRender(callback, args) {
  const host = useHost();
  useMemo(() => {
    render(callback(), host.current);
  }, args);
}

// src/html.ts
import { html as h, render as render2 } from "lit-html";
function html(parts, ...args) {
  const result = h.call(null, parts, ...args);
  const { shadowDom } = html;
  html.shadowDom = false;
  result.render = (element) => {
    if (shadowDom && !element.shadowRoot) {
      element.attachShadow({ mode: "open" });
    }
    const root = shadowDom ? element.shadowRoot : element;
    render2(result, root);
  };
  return result;
}
html.shadowDom = false;

// src/ref.ts
import { nothing as nothing2 } from "lit-html";
import { directive, Directive } from "lit-html/directive.js";
var RefDirective = class extends Directive {
  prev;
  render(ref2) {
    return nothing2;
  }
  update(part, [ref2]) {
    if ("element" in part) {
      if (this.prev != ref2) {
        ref2.current = part.element;
        this.prev = ref2;
      }
    }
    return nothing2;
  }
};
var ref = directive(RefDirective);
export {
  html,
  ref,
  useRender
};
