import Vue , { CreateElement } from 'vue' ; export function define ( tagName , clazz ) { const isClient = typeof window !== 'undefined' ; if ( isClient && ! customElements . get ( tagName ) ) customElements . define ( tagName , clazz ) ; } export function method ( name ) { return function proxy ( this , ... args ) { return this . $refs . ref [ name ] ( ... args ) ; } ; } export function render ( tagName , events ) { return function proxy ( this , createElement ) { const self = this ; const listeners = events . reduce ( ( prevListeners , event ) => ( { ... prevListeners , [ event ] : ( $event ) => { let emittedValue = $event . detail ; if ( $event . detail ?. value ) emittedValue = $event . detail . value ; self . $emit ( event , emittedValue ) ; } , } ) , self . $listeners ) ; return createElement ( tagName , { ref : 'ref' , domProps : { ... self . $props } , on : listeners , } , [ self . $slots . default ] ) ; } ; }