import { api } from './index.js' ; import type { GenericEventAttrs , HTMLAttrs , SVGAttrs , HTMLElements , SVGElements } from '../jsx' ; type El = Element | Node | DocumentFragment ; type Tag = El | Component | [ ] | string ; type Component = ( ... args : unknown [ ] ) => El | undefined ; function h ( tag , props ? , ... children ) ; function h ( tag , ... args ) { if ( typeof tag === 'function' ) { return tag ( ... args ) ; } let el , arg ; if ( typeof tag === 'string' ) { el = api . ns ? document . createElementNS ( api . ns , tag ) : document . createElement ( tag ) ; } else if ( Array . isArray ( tag ) ) { el = document . createDocumentFragment ( ) ; args . unshift ( ... tag ) ; } else { el = tag ; } while ( args . length ) { arg = args . shift ( ) ; if ( arg == null ) { } else if ( typeof arg === 'string' || arg instanceof Node ) { api . add ( el , arg ) ; } else if ( Array . isArray ( arg ) ) { args . unshift ( ... arg ) ; } else if ( typeof arg === 'object' ) { api . property ( el , arg , null , ! ! api . ns ) ; } else if ( api . patch ( arg ) ) { api . insert ( el , arg , api . add ( el , '' ) as Text ) ; } else { api . add ( el , '' + arg ) ; } } return el ; } export { h } ; export type { Component , El , Tag } ; declare namespace h { export namespace JSX { type Element = HTMLElement | SVGElement | DocumentFragment ; interface ElementAttributesProperty { props : unknown ; } interface ElementChildrenAttribute { children : unknown ; } interface IntrinsicAttributes { children ? : never ; } type DOMAttributes < Target extends EventTarget > = GenericEventAttrs < Target > & { children ? : unknown ; } ; type HTMLAttributes < Target extends EventTarget > = HTMLAttrs & DOMAttributes < Target > ; type SVGAttributes < Target extends EventTarget > = SVGAttrs & HTMLAttributes < Target > ; type IntrinsicElements = { [ El in keyof HTMLElements ] : HTMLAttributes < HTMLElements [ El ] > ; } & { [ El in keyof SVGElements ] : SVGAttributes < SVGElements [ El ] > ; } ; } }