<commit_before>(function (window, Cryptoloji, $, twemoji, undefined) {

  /*
    methods prefixed with _ are "private"
    to see exposed method goto bottom :)
  */

  //////////////////////////////////////////////////////////////////////////////
  // private var to store the emoji letter-set used to encyption animation
  var _emojiLetterSet = {'a': '🇦', 'b': '🇧', 'c': '🇨', 'd': '🇩', 'e': '🇪', 'f': '🇫', 'g': '🇬', 'h': '🇭', 'i': '🇮', 'j': '🇯', 'k': '🇰', 'l': '🇱', 'm': '🇲', 'n': '🇳', 'o': '🇴', 'p': '🇵', 'q': '🇶', 'r': '🇷', 's': '🇸', 't': '🇹', 'u': '🇺', 'v': '🇻', 'w': '🇼', 'x': '🇽', 'y': '🇾', 'z': '🇿',
                         '0': '0⃣', '1': '1⃣', '2': '2⃣', '3': '3⃣', '4': '4⃣', '5': '5⃣', '6': '6⃣', '7': '7⃣', '8': '8⃣', '9': '9⃣',
                         'symbol': '🔣'}
  //
  // public methods
  //

  function decryptText () {
    var text = $('#decryption_input').attr('text')
    Cryptoloji.current.input = text

    console.debug('Chosen text:', Cryptoloji.current.input)
    text = CryptoLib.decrypt(Cryptoloji.current.input, Cryptoloji.current.key)
    console.debug('Decrypted text:', text)
    Cryptoloji.current.output = text
    $('#decryption_output').removeClass('placeholdit').text(text)
    Cryptoloji.stateman.emit('decrypt:show-reply')
  }

  function encryptText () {
    if (Cryptoloji.current.key) {
      var text = $('#encryption_input').val()
      if (text !== '' && !/^\s+$/.test(text)) {
        CryptoLib.generateEmojiSubsetFrom(Cryptoloji.current.key)
        Cryptoloji.current.input = text
        Cryptoloji.stateman.emit('encrypt:hide-output-placeholder')
        console.debug('Chosen text:', text)
        text = CryptoLib.encrypt(Cryptoloji.current.input, Cryptoloji.current.key)
        console.debug('Encrypted text:', text)
        Cryptoloji.current.output = text
        encryptTextAnimation(Cryptoloji.current.input, text)
        // text = toTwemoji(text)
        // $('#encryption_output').html(text)
        // $('.share_message_item').html(text)
        // Cryptoloji.stateman.emit('encrypt:show-share')
      }
    }
  }

  function encryptTextAnimation (text, emojiText) {
    console.log(text, emojiText)

    function _mapToBlueBox (text) {
      text = text.toLowerCase()
      var letterEmoji = _.map(text, function (c) {
        // escape space or newline
        if (c === '\n' || c === ' ') return c

        // remap 'strange' characters
        var pointC = punycode.ucs2.decode(c)[0]
        // a <- à 0ca 224 á 1ca 225 â 2ca 226 ã 3ca 227 ä 4ca 228 å 5ca 229 æ 6ca 230
        if (pointC >= 224 && pointC <= 230) c = 'a'
        // c <- ç 7ca 231
        else if (pointC === 231) c = 'c'
        // d <- ð hda 240 þ vda 254
        else if (pointC === 240 || pointC === 254) c = 'd'
        // e <- è 8ca 232 é 9ca 233 ê bda 234 ë cda 235
        else if (pointC >= 232 && pointC <= 235) c = 'e'
        // i <- ì dda 236 í eda 237 î fda 238 ï gda 239
        else if (pointC >= 236 && pointC <= 239) c = 'i'
        // n <- ñ ida 241
        else if (pointC === 241) c = 'n'
        // o <- ò jda 242 ó kda 243 ô lda 244 õ mda 245 ö nda 246 ø pda 248
        else if (pointC >= 242 && pointC <= 246 || pointC === 248) c = 'o'
        // u <- ù qda 249 ú rda 250 û sda 251 ü tda 252
        else if (pointC >= 249 && pointC <= 252) c = 'u'
        // y <- ý uda 253 ÿ wda 255
        else if (pointC === 253 || pointC === 255) c = 'y'
        
        // custom class attached to containing span element
        var spanClass = null
        // is a symbol
        if (pointC < 48 || (pointC > 57 && pointC < 65) || (pointC > 90 && pointC < 97) || pointC > 122 ) {
          spanClass = 'bb_symbol'
        } else {
          spanClass = 'bb_' + c
        }

        // find the emoji letter corresponding to the current char
        var current = _emojiLetterSet[c]
        // return the image of emoji letter wrapped in span
        var openspan = '<span class="' + spanClass + '">'
        var closespan = '</span>'
        var currentTwemoji = current ? toTwemoji(current) : toTwemoji(_emojiLetterSet['symbol'])
        return openspan + currentTwemoji + closespan
        // return currentTwemoji
      })
      letterEmoji = letterEmoji.join('')
      return letterEmoji
    }

    function _generateEmojiHtml (blueBoxText, emojiText) {
      emojiText = toTwemoji(emojiText)
      $('.share_message_item').html(emojiText)

      emojiText = emojiText.replace(/>/g, '>,').split(',')
      var emojiOut = _.map(blueBoxText, function (bb, idx) {
        var openspan = '<span class="' + $(bb).attr('class') + '">'
        var closespan = '</span>'
        return openspan + emojiText[idx] + closespan
      })
      $('#encryption_output > .emojis_output').html(emojiOut)
    }

    function _blueBoxAnimation (blueElem, emojiElem) {

      blueElem.css('opacity', 0)
      emojiElem.css('opacity', 0)

      var fragtime = (blueElem.length<15) ? .02 : .01
      var totaltime = blueElem.length * fragtime

      blueElem.each(function(i, e){
        TweenLite.to(e, .3, {opacity:1, delay:fragtime*i, ease:Expo.easeInOut})
      })

      var _uniqueClasses = []
      blueElem.each(function(i, e){
        var _classname = $(e).attr('class')
        if(_uniqueClasses.indexOf(_classname) == -1) _uniqueClasses.push(_classname)
      })

      _.each(_uniqueClasses, function(d, i){
        $('#encryption_output > .bluebox_output .'+d).each(function(j, e){
          TweenLite.to(e, .5, {opacity:0, delay:totaltime + i*.25, ease:Expo.easeInOut})
        })
        $('#encryption_output > .emojis_output .'+d).each(function(j, e){
          TweenLite.to(e, .5, {opacity:1, delay:totaltime + i*.25, ease:Expo.easeInOut})
        })
      })

      setTimeout(function () {
        Cryptoloji.stateman.emit('encrypt:show-share')
      }, 2500)
    }

    var blueBoxOut = _mapToBlueBox(text)
    $('#encryption_output > .bluebox_output').html(blueBoxOut)

    var blueBoxElements = $('#encryption_output > .bluebox_output').children()
    var emojiOut = _generateEmojiHtml(blueBoxElements, emojiText)
    var emojiElements = $('#encryption_output > .emojis_output').children()
    _blueBoxAnimation(blueBoxElements, emojiElements)
  }

  function handleHeader () {
    Cryptoloji.stateman.on('header:show', function () {
      $("#header").show()
    })
    Cryptoloji.stateman.on('header:hide', function () {
      $("#header").hide()
    })
  }

  function handleFooter () {
    if (Cryptoloji.mq.matches) {
      Cryptoloji.stateman.on('footer:show', function () {
        $("#footer").show()
        var h = $("#footer").innerHeight()
        $("[footer-padding-bottom-correction]").css("padding-bottom", h)
      })
      Cryptoloji.stateman.on('footer:hide', function () {
        $("#footer").hide()
      })
    }
  }
  function selectKey (key) {
    Cryptoloji.current.key = key
    console.debug('Chosen key', key)
    $(".share_key_emoji-item").html(toTwemoji(key))
  }

  function showDecryptableText (text) {
    $('#decryption_input').html(toTwemoji(text))
                          .attr('text', text)
  }




  function handleSvgLoading () {
    function loadSvg (element, path) {
      $.get(path)
       .done(function (result) {
          // console.log(result)<commit_msg>anim emo big<commit_after>(function (window, Cryptoloji, $, twemoji, undefined) {

  /*
    methods prefixed with _ are "private"
    to see exposed method goto bottom :)
  */

  //////////////////////////////////////////////////////////////////////////////
  // private var to store the emoji letter-set used to encyption animation
  var _emojiLetterSet = {'a': '🇦', 'b': '🇧', 'c': '🇨', 'd': '🇩', 'e': '🇪', 'f': '🇫', 'g': '🇬', 'h': '🇭', 'i': '🇮', 'j': '🇯', 'k': '🇰', 'l': '🇱', 'm': '🇲', 'n': '🇳', 'o': '🇴', 'p': '🇵', 'q': '🇶', 'r': '🇷', 's': '🇸', 't': '🇹', 'u': '🇺', 'v': '🇻', 'w': '🇼', 'x': '🇽', 'y': '🇾', 'z': '🇿',
                         '0': '0⃣', '1': '1⃣', '2': '2⃣', '3': '3⃣', '4': '4⃣', '5': '5⃣', '6': '6⃣', '7': '7⃣', '8': '8⃣', '9': '9⃣',
                         'symbol': '🔣'}
  //
  // public methods
  //

  function decryptText () {
    var text = $('#decryption_input').attr('text')
    Cryptoloji.current.input = text

    console.debug('Chosen text:', Cryptoloji.current.input)
    text = CryptoLib.decrypt(Cryptoloji.current.input, Cryptoloji.current.key)
    console.debug('Decrypted text:', text)
    Cryptoloji.current.output = text
    $('#decryption_output').removeClass('placeholdit').text(text)
    Cryptoloji.stateman.emit('decrypt:show-reply')
  }

  function encryptText () {
    if (Cryptoloji.current.key) {
      var text = $('#encryption_input').val()
      if (text !== '' && !/^\s+$/.test(text)) {
        CryptoLib.generateEmojiSubsetFrom(Cryptoloji.current.key)
        Cryptoloji.current.input = text
        Cryptoloji.stateman.emit('encrypt:hide-output-placeholder')
        console.debug('Chosen text:', text)
        text = CryptoLib.encrypt(Cryptoloji.current.input, Cryptoloji.current.key)
        console.debug('Encrypted text:', text)
        Cryptoloji.current.output = text
        encryptTextAnimation(Cryptoloji.current.input, text)
        // text = toTwemoji(text)
        // $('#encryption_output').html(text)
        // $('.share_message_item').html(text)
        // Cryptoloji.stateman.emit('encrypt:show-share')
      }
    }
  }

  function encryptTextAnimation (text, emojiText) {
    console.log(text, emojiText)

    function _mapToBlueBox (text) {
      text = text.toLowerCase()
      var letterEmoji = _.map(text, function (c) {
        // escape space or newline
        if (c === '\n' || c === ' ') return c

        // remap 'strange' characters
        var pointC = punycode.ucs2.decode(c)[0]
        // a <- à 0ca 224 á 1ca 225 â 2ca 226 ã 3ca 227 ä 4ca 228 å 5ca 229 æ 6ca 230
        if (pointC >= 224 && pointC <= 230) c = 'a'
        // c <- ç 7ca 231
        else if (pointC === 231) c = 'c'
        // d <- ð hda 240 þ vda 254
        else if (pointC === 240 || pointC === 254) c = 'd'
        // e <- è 8ca 232 é 9ca 233 ê bda 234 ë cda 235
        else if (pointC >= 232 && pointC <= 235) c = 'e'
        // i <- ì dda 236 í eda 237 î fda 238 ï gda 239
        else if (pointC >= 236 && pointC <= 239) c = 'i'
        // n <- ñ ida 241
        else if (pointC === 241) c = 'n'
        // o <- ò jda 242 ó kda 243 ô lda 244 õ mda 245 ö nda 246 ø pda 248
        else if (pointC >= 242 && pointC <= 246 || pointC === 248) c = 'o'
        // u <- ù qda 249 ú rda 250 û sda 251 ü tda 252
        else if (pointC >= 249 && pointC <= 252) c = 'u'
        // y <- ý uda 253 ÿ wda 255
        else if (pointC === 253 || pointC === 255) c = 'y'
        
        // custom class attached to containing span element
        var spanClass = null
        // is a symbol
        if (pointC < 48 || (pointC > 57 && pointC < 65) || (pointC > 90 && pointC < 97) || pointC > 122 ) {
          spanClass = 'bb_symbol'
        } else {
          spanClass = 'bb_' + c
        }

        // find the emoji letter corresponding to the current char
        var current = _emojiLetterSet[c]
        // return the image of emoji letter wrapped in span
        var openspan = '<span class="' + spanClass + '">'
        var closespan = '</span>'
        var currentTwemoji = current ? toTwemoji(current) : toTwemoji(_emojiLetterSet['symbol'])
        return openspan + currentTwemoji + closespan
        // return currentTwemoji
      })
      letterEmoji = letterEmoji.join('')
      return letterEmoji
    }

    function _generateEmojiHtml (blueBoxText, emojiText) {
      emojiText = toTwemoji(emojiText)
      $('.share_message_item').html(emojiText)

      emojiText = emojiText.replace(/>/g, '>,').split(',')
      var emojiOut = _.map(blueBoxText, function (bb, idx) {
        var openspan = '<span class="' + $(bb).attr('class') + '">'
        var closespan = '</span>'
        return openspan + emojiText[idx] + closespan
      })
      $('#encryption_output > .emojis_output').html(emojiOut)
    }

    function _blueBoxAnimation (blueElem, emojiElem) {

      blueElem.css('opacity', 0)
      emojiElem.css('opacity', 0)

      var fragtime = (blueElem.length<15) ? .02 : .01
      var totaltime = blueElem.length * fragtime

      blueElem.each(function(i, e){
        TweenLite.to(e, .3, {opacity:1, delay:fragtime*i, ease:Expo.easeInOut})
      })

      var _uniqueClasses = []
      blueElem.each(function(i, e){
        var _classname = $(e).attr('class')
        if(_uniqueClasses.indexOf(_classname) == -1) _uniqueClasses.push(_classname)
      })

      _.each(_uniqueClasses, function(d, i){
        $('#encryption_output > .bluebox_output .'+d).each(function(j, e){
          TweenLite.to(e, .5, {opacity:0, delay:totaltime + i*.25, ease:Expo.easeInOut})
        })
        $('#encryption_output > .emojis_output .'+d).each(function(j, e){
          TweenLite.to(e, .5, {opacity:1, delay:totaltime + i*.25, ease:Expo.easeInOut})
        })
      })

      setTimeout(function () {
        Cryptoloji.stateman.emit('encrypt:show-share')
      }, 2500)
    }

    var blueBoxOut = _mapToBlueBox(text)
    $('#encryption_output > .bluebox_output').html(blueBoxOut)

    var blueBoxElements = $('#encryption_output > .bluebox_output').children()
    var emojiOut = _generateEmojiHtml(blueBoxElements, emojiText)
    var emojiElements = $('#encryption_output > .emojis_output').children()
    _blueBoxAnimation(blueBoxElements, emojiElements)
  }

  function handleHeader () {
    Cryptoloji.stateman.on('header:show', function () {
      $("#header").show()
    })
    Cryptoloji.stateman.on('header:hide', function () {
      $("#header").hide()
    })
  }

  function handleFooter () {
    if (Cryptoloji.mq.matches) {
      Cryptoloji.stateman.on('footer:show', function () {
        $("#footer").show()
        var h = $("#footer").innerHeight()
        $("[footer-padding-bottom-correction]").css("padding-bottom", h)
      })
      Cryptoloji.stateman.on('footer:hide', function () {
        $("#footer").hide()
      })
    }
  }
  function selectKey (key) {
    Cryptoloji.current.key = key
    console.debug('Chosen key', key)
    $(".share_key_emoji-item").html(toTwemoji(key))
    TweenLite.from($('#encryption_selected_key'), 1.25, {scale:1.25, ease:Expo.easeOut})
  }

  function showDecryptableText (text) {
    $('#decryption_input').html(toTwemoji(text))
                          .attr('text', text)
  }




  function handleSvgLoading () {
    function loadSvg (element, path) {
      $.get(path)
       .done(function (result) {
          // console.log(result)
{'fraction_non_alphanumeric': 0.18452380952380953, 'fraction_numerical': 0.029419813902572523, 'mean_word_length': 2.373413339487653, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5674890', 'n_tokens_mistral': 5565, 'n_tokens_neox': 5081, 'n_words': 1191}