import  theaterJS from  "theaterjs" ; 
interface  ITheaterOptions  { 
	autoplay? :  boolean; 
	minSpeed? :  { 
		type :  number; 
		erase :  number; 
	} ; 
	maxSpeed? :  { 
		type :  number; 
		erase :  number; 
	} ; 
} 
export  default  function  useTheater ( id :  string,  options :  ITheaterOptions,  addSceneOptions :  any[ ] )  { 
	
	const  theater =  theaterJS ( options) ; 
	
	theater. addActor ( id,  {  speed :  0.8 ,  accuracy :  0.6  } ) ; 
	
	addSceneOptions. forEach ( item  =>  { 
		theater. addScene ( item) ; 
	} ) ; 
	theater. addScene ( theater. replay . bind ( theater) ) ; 
	
	
	
	
	theater
		. on ( "type:start, erase:start" ,  function  ( )  { 
			theater. getCurrentActor ( ) . $element?. classList! . add ( "actor__content--typing" ) ; 
		} ) 
		. on ( "type:end, erase:end" ,  function  ( )  { 
			theater. getCurrentActor ( ) . $element?. classList! . remove ( "actor__content--typing" ) ; 
		} ) ; 
	
	
	
	
	
	
	
	return  {  theater } ; 
} 
  
< div class = "actor" > 
				< div class = "actor__prefix"  @click= "handleOnFocus" > Search for  your domain name... < / div> 
				< div v- show= "!isClick"  id= "vader"  type= "text"  class = "actor__content"  data- focus- visible= ""  @click= "handleOnFocus" > < / div> 
				< a- input
					v- show= "isClick" 
					id= "vader-input" 
					ref= "searchContentRef" 
					v- model= "searchContent" 
					class = "actor__input" 
					allow- clear
					@blur= "handleOnBlur" 
				/ > 
				< a- button type= "primary"  class = "w-98px"  @click= "handleSearch" > Search< / a- button> 
			< / div> 
  
const  addScenes =  [ 
	[ "vader:Start typing..." ,  800 ] , 
	[ 
		"vader:youridea.com" , 
		800 , 
		- 8 , 
		"circle.net" , 
		800 , 
		- 10 , 
		"version.org" , 
		800 , 
		- 11 , 
		"brandnew.site" , 
		800 , 
		- 13 , 
		"world.online" , 
		800 , 
		- 12 , 
		"business.ca" , 
		1000 
	] 
] ; 
const  isClick =  ref ( false ) ; 
const  searchContentRef =  ref ( ) ; 
const  searchContent =  ref ( "" ) ; 
const  handleOnFocus  =  ( )  =>  { 
	isClick. value =  true ; 
	nextTick ( ( )  =>  { 
		searchContentRef. value. focus ( ) ; 
	} ) ; 
} ; 
const  handleOnBlur  =  ( )  =>  { 
	if  ( searchContent. value ===  "" )  { 
		isClick. value =  false ; 
	} 
} ; 
const  handleSearch  =  ( )  =>  { 
	console. log ( "searchContent" ,  searchContent. value) ; 
} ; 
watch ( searchContent,  val  =>  { 
	if  ( val. length <=  0 )  { 
		isClick. value =  false ; 
		searchContent. value =  "" ; 
	}  else  { 
		isClick. value =  true ; 
	} 
} ) ; 
useTheater ( "vader" ,  {  autoplay :  true  } ,  addScenes) ; 
  
. actor { 
			@apply absolute left- 0  px- 5vw flex flex- col; 
			top :  40 % ; 
			& __prefix { 
				@apply text- [ #919091 ] ; 
			} 
			& __input { 
				@apply border- none bg- transparent h- 69px   pl- 0 ; 
				: deep ( . arco- input)  { 
					color :  #fff; 
					font- size:  3rem; 
					@apply font- 700 ; 
					& : focus { 
						outline :  none; 
					} 
				} 
			} 
			& __content { 
				font- size:  3rem; 
				@apply font- 700  bg- transparent  text- color- placeholder- 1 ; 
			} 
			. actor__content-- typing: : after { 
				
				content :  "|" ; 
				animation :  blink 500ms infinite; 
			} 
		}