 fs = require 'fs'
 blur = require './StackBlur.js'
 youtubedl = require 'youtube-dl'
-gif = require './gif.js'
+gif_ = require './gif.js'
+GIF=gif_.GIF
 
 qr = (selector) -> document.querySelector selector
 style = (element) -> document.defaultView.getComputedStyle element

      if ytidregres?.length>0
        ytid=ytidregres[1]


  runVideo:(image)->
    gif = document.createElement 'div'
    gif.style.cssText="
    position:absolute;
    left:0;
    top:0;
    width:100%;
    height:100%;
    background:url(#{image});
    background-size:cover;
    "
    @elements.gif = gif
    @elements.main.insertBefore gif,@elements.textBackground

  convertToGif: (ytid) ->
    return
    videoPath = @elements.videoPath+ytid+'.webm'
    gifPath = @elements.videoPath+ytid+'.gif'
    console.log 'converting to gif',ytid
    if gifshot.isExistingVideoGIFSupported ['webm']
      gifshot.createGIF {
        'video': [videoPath],
        'progressCallback': (progress)->
          console.log 'progress',progress
        'completeCallback': ->
          console.log 'converting finished'
      },(obj) =>
        if !obj.error?
          console.log 'image',obj
          image = obj.image
          @runVideo.apply @,[image]
    else
      console.log 'cant make gif :('

  downloadYTVideo: (url)->
    if url != ''
      ytid = @getYTId url
      savePath = @elements.videoPath+ytid+'.webm'
      gifPath = @elements.videoPath+ytid+'.gif'
      alreadyExists = false

      try

    .replace(/>/g, "&gt;")
    .replace(/"/g, "&quot;")
    .replace(/'/g, "&#039;")

blobToBase64 = (blob, cb) ->
  reader = new FileReader()
  reader.onload = ->
    dataUrl = reader.result
    base64 = dataUrl.split(',')[1]
    cb(base64)
  reader.readAsDataURL(blob)




planeInitialCss =
  "position:absolute;
