 React = window?.React || require 'react'
-jsdiff = require 'diff'
-
-assert = require('chai').assert
 
 DEFAULT_TRANSLATIONS =
   '9': /\d/

          char

    @_cursorPos = @_firstNonMaskIdx
    value: @_buffer.join('')

  componentDidUpdate: ->
    @_setSelection(@_cursorPos) if @_cursorPos?

  componentDidMount: ->
    # TODO: any other lifecycle functions we need to modify when there's no mask?
    return unless @props.mask?

    if @props.onChange? && @props.value?
      # TODO: should @state.value already be ready to use here?
      value = @_maskedValue(@props.value)
      @props.onChange(target: {value}) if value isnt @props.value

  render: ->
    props = {}
    if @props.mask?
      props.onChange = @_handleChange
      # props.onKeyPress = @_handleKeyPress
      props.onKeyDown = @_handleKeyDown
      props.onFocus = @_handleFocus
      props.value =
        if @props.value? && @props.value isnt @state.value
          @_maskedValue(@props.value)
        else
          @state.value

    <input {...@props} {...props} />



    @_cursorPos = Math.max(begin, @_firstNonMaskIdx)

  _callOnComplete: (value) ->
    return unless @props.onComplete?
    for i in [0...@props.mask.length]
