import { c as createCommonjsModule, u as unwrapExports } from './_commonjsHelpers-0c4b6f40.js';
import React, { Component, useRef, useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import { _ as _slicedToArray } from './slicedToArray-67a08c9c.js';
import urlFor from './urlFor.js';
import { s as smoothscroll } from './smoothscroll-0cd4c7a6.js';

function _classCallCheck(instance, Constructor) {
  if (!(instance instanceof Constructor)) {
    throw new TypeError("Cannot call a class as a function");
  }
}

function _defineProperties(target, props) {
  for (var i = 0; i < props.length; i++) {
    var descriptor = props[i];
    descriptor.enumerable = descriptor.enumerable || false;
    descriptor.configurable = true;
    if ("value" in descriptor) descriptor.writable = true;
    Object.defineProperty(target, descriptor.key, descriptor);
  }
}

function _createClass(Constructor, protoProps, staticProps) {
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  if (staticProps) _defineProperties(Constructor, staticProps);
  return Constructor;
}

function _typeof(obj) {
  "@babel/helpers - typeof";

  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
    _typeof = function _typeof(obj) {
      return typeof obj;
    };
  } else {
    _typeof = function _typeof(obj) {
      return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
    };
  }

  return _typeof(obj);
}

function _assertThisInitialized(self) {
  if (self === void 0) {
    throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  }

  return self;
}

function _possibleConstructorReturn(self, call) {
  if (call && (_typeof(call) === "object" || typeof call === "function")) {
    return call;
  }

  return _assertThisInitialized(self);
}

function _getPrototypeOf(o) {
  _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
    return o.__proto__ || Object.getPrototypeOf(o);
  };
  return _getPrototypeOf(o);
}

function _setPrototypeOf(o, p) {
  _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
    o.__proto__ = p;
    return o;
  };

  return _setPrototypeOf(o, p);
}

function _inherits(subClass, superClass) {
  if (typeof superClass !== "function" && superClass !== null) {
    throw new TypeError("Super expression must either be null or a function");
  }

  subClass.prototype = Object.create(superClass && superClass.prototype, {
    constructor: {
      value: subClass,
      writable: true,
      configurable: true
    }
  });
  if (superClass) _setPrototypeOf(subClass, superClass);
}

function _defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }

  return obj;
}

var isRequiredIf_1 = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports,'__esModule',{value:!0});var VALIDATOR_ARG_ERROR_MESSAGE='The typeValidator argument must be a function with the signature function(props, propName, componentName).',MESSAGE_ARG_ERROR_MESSAGE='The error message is optional, but must be a string if provided.',propIsRequired=function propIsRequired(a,b,c,d){if('boolean'==typeof a)return a;return 'function'==typeof a?a(b,c,d):!(!0!==!!a)&&!!a},propExists=function propExists(a,b){return Object.hasOwnProperty.call(a,b)},missingPropError=function missingPropError(a,b,c,d){return d?new Error(d):new Error('Required '+a[b]+' `'+b+'`'+(' was not specified in `'+c+'`.'))},guardAgainstInvalidArgTypes=function guardAgainstInvalidArgTypes(a,b){if('function'!=typeof a)throw new TypeError(VALIDATOR_ARG_ERROR_MESSAGE);if(!!b&&'string'!=typeof b)throw new TypeError(MESSAGE_ARG_ERROR_MESSAGE)},isRequiredIf=function isRequiredIf(a,b,c){return guardAgainstInvalidArgTypes(a,c),function(d,e,f){for(var _len=arguments.length,g=Array(3<_len?_len-3:0),_key=3;_key<_len;_key++)g[_key-3]=arguments[_key];return propIsRequired(b,d,e,f)?propExists(d,e)?a.apply(void 0,[d,e,f].concat(g)):missingPropError(d,e,f,c):a.apply(void 0,[d,e,f].concat(g));// Is not required, so just run typeValidator.
}};exports.default=isRequiredIf;


});

var isRequiredIf = unwrapExports(isRequiredIf_1);

var exenv = createCommonjsModule(function (module) {
/*!
  Copyright (c) 2015 Jed Watson.
  Based on code that is Copyright 2013-2015, Facebook, Inc.
  All rights reserved.
*/
/* global define */

(function () {

	var canUseDOM = !!(
		typeof window !== 'undefined' &&
		window.document &&
		window.document.createElement
	);

	var ExecutionEnvironment = {

		canUseDOM: canUseDOM,

		canUseWorkers: typeof Worker !== 'undefined',

		canUseEventListeners:
			canUseDOM && !!(window.addEventListener || window.attachEvent),

		canUseViewport: canUseDOM && !!window.screen

	};

	if ( module.exports) {
		module.exports = ExecutionEnvironment;
	} else {
		window.ExecutionEnvironment = ExecutionEnvironment;
	}

}());
});

var twitterWidgetJs = 'https://platform.twitter.com/widgets.js';

var TwitterTimelineEmbed =
/*#__PURE__*/
function (_Component) {
  _inherits(TwitterTimelineEmbed, _Component);

  function TwitterTimelineEmbed(props) {
    var _this;

    _classCallCheck(this, TwitterTimelineEmbed);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(TwitterTimelineEmbed).call(this, props));
    _this.state = {
      isLoading: true
    };
    return _this;
  }

  _createClass(TwitterTimelineEmbed, [{
    key: "buildChromeOptions",
    value: function buildChromeOptions(options) {
      options.chrome = '';

      if (this.props.noHeader) {
        options.chrome = options.chrome + ' noheader';
      }

      if (this.props.noFooter) {
        options.chrome = options.chrome + ' nofooter';
      }

      if (this.props.noBorders) {
        options.chrome = options.chrome + ' noborders';
      }

      if (this.props.noScrollbar) {
        options.chrome = options.chrome + ' noscrollbar';
      }

      if (this.props.transparent) {
        options.chrome = options.chrome + ' transparent';
      }

      return options;
    }
  }, {
    key: "buildOptions",
    value: function buildOptions() {
      var options = Object.assign({}, this.props.options);

      if (this.props.autoHeight) {
        options.height = this.refs.embedContainer.parentNode.offsetHeight;
      }

      options = Object.assign({}, options, {
        theme: this.props.theme,
        linkColor: this.props.linkColor,
        borderColor: this.props.borderColor,
        lang: this.props.lang
      });
      return options;
    }
  }, {
    key: "renderWidget",
    value: function renderWidget(options) {
      var _this2 = this;

      var onLoad = this.props.onLoad;

      if (!this.isMountCanceled) {
        window.twttr.widgets.createTimeline({
          sourceType: this.props.sourceType,
          screenName: this.props.screenName,
          userId: this.props.userId,
          ownerScreenName: this.props.ownerScreenName,
          slug: this.props.slug,
          id: this.props.id || this.props.widgetId,
          url: this.props.url
        }, this.refs.embedContainer, options).then(function (element) {
          _this2.setState({
            isLoading: false
          });

          if (onLoad) {
            onLoad(element);
          }
        });
      }
    }
  }, {
    key: "componentDidMount",
    value: function componentDidMount() {
      var _this3 = this;

      if (exenv.canUseDOM) {
        var script = require('scriptjs');

        script(twitterWidgetJs, 'twitter-embed', function () {
          if (!window.twttr) {
            console.error('Failure to load window.twttr in TwitterTimelineEmbed, aborting load.');
            return;
          }

          var options = _this3.buildOptions();
          /** Append chrome options */


          options = _this3.buildChromeOptions(options);

          _this3.renderWidget(options);
        });
      }
    }
  }, {
    key: "componentWillUnmount",
    value: function componentWillUnmount() {
      this.isMountCanceled = true;
    }
  }, {
    key: "render",
    value: function render() {
      var isLoading = this.state.isLoading;
      var placeholder = this.props.placeholder;
      return React.createElement(React.Fragment, null, isLoading && placeholder, React.createElement("div", {
        ref: "embedContainer"
      }));
    }
  }]);

  return TwitterTimelineEmbed;
}(Component);

_defineProperty(TwitterTimelineEmbed, "propTypes", {
  /**
       * This can be either of profile, likes, list, collection, URL, widget
       */
  sourceType: PropTypes.oneOf(['profile', 'likes', 'list', 'collection', 'url', 'widget']).isRequired,

  /**
       * username of twitter handle as String
       */
  screenName: isRequiredIf(PropTypes.string, function (props) {
    return !props.hasOwnProperty('userId') && (props.sourceType === 'profile' || props.sourceType === 'likes');
  }),

  /**
       * UserId of twitter handle as number
       */
  userId: isRequiredIf(PropTypes.number, function (props) {
    return !props.hasOwnProperty('screenName') && (props.sourceType === 'profile' || props.sourceType === 'likes');
  }),

  /**
       * To show list, used along with slug
       */
  ownerScreenName: isRequiredIf(PropTypes.string, function (props) {
    return props.sourceType === 'list' && !props.hasOwnProperty('id');
  }),

  /**
       * To show list, used along with ownerScreenName
       */
  slug: isRequiredIf(PropTypes.string, function (props) {
    return props.sourceType === 'list' && !props.hasOwnProperty('id');
  }),

  /**
       * To show list, unique list id
       * Also used with collections, in that case its valid collection id
       */
  id: isRequiredIf(PropTypes.oneOfType([PropTypes.number, PropTypes.string]), function (props) {
    return props.sourceType === 'list' && !props.hasOwnProperty('ownerScreenName') && !props.hasOwnProperty('slug') || props.sourceType === 'collection';
  }),

  /**
       * To show twitter content with url.
       * Supported content includes profiles, likes, lists, and collections.
       */
  url: isRequiredIf(PropTypes.string, function (props) {
    return props.sourceType === 'url';
  }),

  /**
       * To show custom widget
       */
  widgetId: isRequiredIf(PropTypes.string, function (props) {
    return props.sourceType === 'widget';
  }),

  /**
       * Additional options to pass to twitter widget plugin
       */
  options: PropTypes.object,

  /**
       * Automatically fit into parent container height
       */
  autoHeight: PropTypes.bool,

  /**
       * With dark or light theme
       */
  theme: PropTypes.oneOf(['dark', 'light']),

  /**
       * With custom link colors. Note: Only Hex colors are supported.
       */
  linkColor: PropTypes.string,

  /**
       * With custom border colors. Note: Only Hex colors are supported.
       */
  borderColor: PropTypes.string,

  /**
       * Hide the header from timeline
       */
  noHeader: PropTypes.bool,

  /**
       * Hide the footer from timeline
       */
  noFooter: PropTypes.bool,

  /**
       * Hide the border from timeline
       */
  noBorders: PropTypes.bool,

  /**
       * Hide the scrollbars
       */
  noScrollbar: PropTypes.bool,

  /**
       * Enable Transparancy
       */
  transparent: PropTypes.bool,

  /**
       * Custom language code. Supported codes here: https://developer.twitter.com/en/docs/twitter-for-websites/twitter-for-websites-supported-languages/overview.html
       */
  lang: PropTypes.string,

  /**
   * Placeholder while tweet is loading
   */
  placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),

  /**
   * Function to execute after load, return html element
   */
  onLoad: PropTypes.func
});

var TwitterShareButton =
/*#__PURE__*/
function (_Component) {
  _inherits(TwitterShareButton, _Component);

  function TwitterShareButton(props) {
    var _this;

    _classCallCheck(this, TwitterShareButton);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(TwitterShareButton).call(this, props));
    _this.state = {
      isLoading: true
    };
    return _this;
  }

  _createClass(TwitterShareButton, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var _this2 = this;

      var onLoad = this.props.onLoad;

      if (exenv.canUseDOM) {
        var script = require('scriptjs');

        script(twitterWidgetJs, 'twitter-embed', function () {
          if (!window.twttr) {
            console.error('Failure to load window.twttr in TwitterShareButton, aborting load.');
            return;
          }

          if (!_this2.isMountCanceled) {
            window.twttr.widgets.createShareButton(_this2.props.url, _this2.refs.embedContainer, _this2.props.options).then(function (element) {
              _this2.setState({
                isLoading: false
              });

              if (onLoad) {
                onLoad(element);
              }
            });
          }
        });
      }
    }
  }, {
    key: "componentWillUnmount",
    value: function componentWillUnmount() {
      this.isMountCanceled = true;
    }
  }, {
    key: "render",
    value: function render() {
      var isLoading = this.state.isLoading;
      var placeholder = this.props.placeholder;
      return React.createElement(React.Fragment, null, isLoading && placeholder, React.createElement("div", {
        ref: "embedContainer"
      }));
    }
  }]);

  return TwitterShareButton;
}(Component);

_defineProperty(TwitterShareButton, "propTypes", {
  /**
  * Url for sharing
  */
  url: PropTypes.string.isRequired,

  /**
  * Additional options for overriding config. Details at : https://dev.twitter.com/web/tweet-button/parameters
  */
  options: PropTypes.object,

  /**
   * Placeholder while tweet is loading
   */
  placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),

  /**
   * Function to execute after load, return html element
   */
  onLoad: PropTypes.func
});

var TwitterFollowButton =
/*#__PURE__*/
function (_Component) {
  _inherits(TwitterFollowButton, _Component);

  function TwitterFollowButton(props) {
    var _this;

    _classCallCheck(this, TwitterFollowButton);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(TwitterFollowButton).call(this, props));
    _this.state = {
      isLoading: true
    };
    return _this;
  }

  _createClass(TwitterFollowButton, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var _this2 = this;

      var onLoad = this.props.onLoad;

      if (exenv.canUseDOM) {
        var script = require('scriptjs');

        script(twitterWidgetJs, 'twitter-embed', function () {
          if (!window.twttr) {
            console.error('Failure to load window.twttr in TwitterFollowButton, aborting load.');
            return;
          }

          if (!_this2.isMountCanceled) {
            window.twttr.widgets.createFollowButton(_this2.props.screenName, _this2.refs.embedContainer, _this2.props.options).then(function (element) {
              _this2.setState({
                isLoading: false
              });

              if (onLoad) {
                onLoad(element);
              }
            });
          }
        });
      }
    }
  }, {
    key: "componentWillUnmount",
    value: function componentWillUnmount() {
      this.isMountCanceled = true;
    }
  }, {
    key: "render",
    value: function render() {
      var isLoading = this.state.isLoading;
      var placeholder = this.props.placeholder;
      return React.createElement(React.Fragment, null, isLoading && placeholder, React.createElement("div", {
        ref: "embedContainer"
      }));
    }
  }]);

  return TwitterFollowButton;
}(Component);

_defineProperty(TwitterFollowButton, "propTypes", {
  /**
       * Username of twitter user which will be followed on click
       */
  screenName: PropTypes.string.isRequired,

  /**
       * Additional options to be added to the button
       */
  options: PropTypes.object,

  /**
   * Placeholder while tweet is loading
   */
  placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),

  /**
   * Function to execute after load, return html element
   */
  onLoad: PropTypes.func
});

var TwitterHashtagButton =
/*#__PURE__*/
function (_Component) {
  _inherits(TwitterHashtagButton, _Component);

  function TwitterHashtagButton(props) {
    var _this;

    _classCallCheck(this, TwitterHashtagButton);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(TwitterHashtagButton).call(this, props));
    _this.state = {
      isLoading: true
    };
    return _this;
  }

  _createClass(TwitterHashtagButton, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var _this2 = this;

      var onLoad = this.props.onLoad;

      if (exenv.canUseDOM) {
        var script = require('scriptjs');

        script(twitterWidgetJs, 'twitter-embed', function () {
          if (!window.twttr) {
            console.error('Failure to load window.twttr in TwitterHashtagButton, aborting load.');
            return;
          }

          if (!_this2.isMountCanceled) {
            window.twttr.widgets.createHashtagButton(_this2.props.tag, _this2.refs.embedContainer, _this2.props.options).then(function (element) {
              _this2.setState({
                isLoading: false
              });

              if (onLoad) {
                onLoad(element);
              }
            });
          }
        });
      }
    }
  }, {
    key: "componentWillUnmount",
    value: function componentWillUnmount() {
      this.isMountCanceled = true;
    }
  }, {
    key: "render",
    value: function render() {
      var isLoading = this.state.isLoading;
      var placeholder = this.props.placeholder;
      return React.createElement(React.Fragment, null, isLoading && placeholder, React.createElement("div", {
        ref: "embedContainer"
      }));
    }
  }]);

  return TwitterHashtagButton;
}(Component);

_defineProperty(TwitterHashtagButton, "propTypes", {
  /**
       * Tag name for hashtag button
       */
  tag: PropTypes.string.isRequired,

  /**
       * Additional options to be added to the button
       */
  options: PropTypes.object,

  /**
   * Placeholder while tweet is loading
   */
  placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),

  /**
   * Function to execute after load, return html element
   */
  onLoad: PropTypes.func
});

var TwitterMentionButton =
/*#__PURE__*/
function (_Component) {
  _inherits(TwitterMentionButton, _Component);

  function TwitterMentionButton(props) {
    var _this;

    _classCallCheck(this, TwitterMentionButton);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(TwitterMentionButton).call(this, props));
    _this.state = {
      isLoading: true
    };
    return _this;
  }

  _createClass(TwitterMentionButton, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var _this2 = this;

      var onLoad = this.props.onLoad;

      if (exenv.canUseDOM) {
        var script = require('scriptjs');

        script(twitterWidgetJs, 'twitter-embed', function () {
          if (!window.twttr) {
            console.error('Failure to load window.twttr in TwitterMentionButton, aborting load.');
            return;
          }

          if (!_this2.isMountCanceled) {
            window.twttr.widgets.createMentionButton(_this2.props.screenName, _this2.refs.embedContainer, _this2.props.options).then(function (element) {
              _this2.setState({
                isLoading: false
              });

              if (onLoad) {
                onLoad(element);
              }
            });
          }
        });
      }
    }
  }, {
    key: "componentWillUnmount",
    value: function componentWillUnmount() {
      this.isMountCanceled = true;
    }
  }, {
    key: "render",
    value: function render() {
      var isLoading = this.state.isLoading;
      var placeholder = this.props.placeholder;
      return React.createElement(React.Fragment, null, isLoading && placeholder, React.createElement("div", {
        ref: "embedContainer"
      }));
    }
  }]);

  return TwitterMentionButton;
}(Component);

_defineProperty(TwitterMentionButton, "propTypes", {
  /**
   * Username to which you will need to tweet
   */
  screenName: PropTypes.string.isRequired,

  /**
   * Additional options for overriding config.
   */
  options: PropTypes.object,

  /**
   * Placeholder while tweet is loading
   */
  placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),

  /**
   * Function to execute after load, return html element
   */
  onLoad: PropTypes.func
});

var TwitterTweetEmbed =
/*#__PURE__*/
function (_Component) {
  _inherits(TwitterTweetEmbed, _Component);

  function TwitterTweetEmbed(props) {
    var _this;

    _classCallCheck(this, TwitterTweetEmbed);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(TwitterTweetEmbed).call(this, props));
    _this.state = {
      isLoading: true
    };
    return _this;
  }

  _createClass(TwitterTweetEmbed, [{
    key: "renderWidget",
    value: function renderWidget() {
      var _this2 = this;

      var onLoad = this.props.onLoad;

      if (!window.twttr) {
        console.error('Failure to load window.twttr in TwitterTweetEmbed, aborting load.');
        return;
      }

      if (!this.isMountCanceled) {
        window.twttr.widgets.createTweet(this.props.tweetId, this.refs.embedContainer, this.props.options).then(function (element) {
          _this2.setState({
            isLoading: false
          });

          if (onLoad) {
            onLoad(element);
          }
        });
      }
    }
  }, {
    key: "componentDidMount",
    value: function componentDidMount() {
      var _this3 = this;

      if (exenv.canUseDOM) {
        var script = require('scriptjs');

        script(twitterWidgetJs, 'twitter-embed', function () {
          _this3.renderWidget();
        });
      }
    }
  }, {
    key: "componentWillUnmount",
    value: function componentWillUnmount() {
      this.isMountCanceled = true;
    }
  }, {
    key: "render",
    value: function render() {
      var isLoading = this.state.isLoading;
      var placeholder = this.props.placeholder;
      return React.createElement(React.Fragment, null, isLoading && placeholder, React.createElement("div", {
        ref: "embedContainer"
      }));
    }
  }]);

  return TwitterTweetEmbed;
}(Component);

_defineProperty(TwitterTweetEmbed, "propTypes", {
  /**
       * Tweet id that needs to be shown
       */
  tweetId: PropTypes.string.isRequired,

  /**
       * Additional options to pass to twitter widget plugin
       */
  options: PropTypes.object,

  /**
   * Placeholder while tweet is loading
   */
  placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),

  /**
   * Function to execute after load, return html element
   */
  onLoad: PropTypes.func
});

var TwitterMomentShare =
/*#__PURE__*/
function (_Component) {
  _inherits(TwitterMomentShare, _Component);

  function TwitterMomentShare(props) {
    var _this;

    _classCallCheck(this, TwitterMomentShare);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(TwitterMomentShare).call(this, props));
    _this.state = {
      isLoading: true
    };
    return _this;
  }

  _createClass(TwitterMomentShare, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var _this2 = this;

      var onLoad = this.props.onLoad;

      if (exenv.canUseDOM) {
        var script = require('scriptjs');

        script(twitterWidgetJs, 'twitter-embed', function () {
          if (!window.twttr) {
            console.error('Failure to load window.twttr in TwitterMomentShare, aborting load.');
            return;
          }

          if (!_this2.isMountCanceled) {
            window.twttr.widgets.createMoment(_this2.props.momentId, _this2.refs.shareMoment, _this2.props.options).then(function (element) {
              _this2.setState({
                isLoading: false
              });

              if (onLoad) {
                onLoad(element);
              }
            });
          }
        });
      }
    }
  }, {
    key: "componentWillUnmount",
    value: function componentWillUnmount() {
      this.isMountCanceled = true;
    }
  }, {
    key: "render",
    value: function render() {
      var isLoading = this.state.isLoading;
      var placeholder = this.props.placeholder;
      return React.createElement(React.Fragment, null, isLoading && placeholder, React.createElement("div", {
        ref: "shareMoment"
      }));
    }
  }]);

  return TwitterMomentShare;
}(Component);

_defineProperty(TwitterMomentShare, "propTypes", {
  /**
   * id of Twitter moment to show
   */
  momentId: PropTypes.string.isRequired,

  /**
   * Additional options for overriding config.
   */
  options: PropTypes.object,

  /**
   * Placeholder while tweet is loading
   */
  placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),

  /**
   * Function to execute after load, return html element
   */
  onLoad: PropTypes.func
});

var TwitterDMButton =
/*#__PURE__*/
function (_Component) {
  _inherits(TwitterDMButton, _Component);

  function TwitterDMButton(props) {
    var _this;

    _classCallCheck(this, TwitterDMButton);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(TwitterDMButton).call(this, props));
    _this.state = {
      isLoading: true
    };
    return _this;
  }

  _createClass(TwitterDMButton, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var _this2 = this;

      var onLoad = this.props.onLoad;

      if (exenv.canUseDOM) {
        var script = require('scriptjs');

        script(twitterWidgetJs, 'twitter-embed', function () {
          if (!window.twttr) {
            console.error('Failure to load window.twttr in TwitterDMButton, aborting load.');
            return;
          }

          if (!_this2.isMountCanceled) {
            window.twttr.widgets.createDMButton(_this2.props.id, _this2.refs.embedContainer, _this2.props.options).then(function (element) {
              _this2.setState({
                isLoading: false
              });

              if (onLoad) {
                onLoad(element);
              }
            });
          }
        });
      }
    }
  }, {
    key: "componentWillUnmount",
    value: function componentWillUnmount() {
      this.isMountCanceled = true;
    }
  }, {
    key: "render",
    value: function render() {
      var isLoading = this.state.isLoading;
      var placeholder = this.props.placeholder;
      return React.createElement(React.Fragment, null, isLoading && placeholder, React.createElement("div", {
        ref: "embedContainer"
      }));
    }
  }]);

  return TwitterDMButton;
}(Component);

_defineProperty(TwitterDMButton, "propTypes", {
  /**
  * Twitter user id for DM button
  */
  id: PropTypes.number.isRequired,

  /**
  * Additional options to be added to the button
  */
  options: PropTypes.object,

  /**
   * Placeholder while tweet is loading
   */
  placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),

  /**
   * Function to execute after load, return html element
   */
  onLoad: PropTypes.func
});

var TwitterVideoEmbed =
/*#__PURE__*/
function (_Component) {
  _inherits(TwitterVideoEmbed, _Component);

  function TwitterVideoEmbed(props) {
    var _this;

    _classCallCheck(this, TwitterVideoEmbed);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(TwitterVideoEmbed).call(this, props));
    _this.state = {
      isLoading: true
    };
    return _this;
  }

  _createClass(TwitterVideoEmbed, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var _this2 = this;

      var onLoad = this.props.onLoad;

      if (exenv.canUseDOM) {
        var script = require('scriptjs');

        script(twitterWidgetJs, 'twitter-embed', function () {
          if (!window.twttr) {
            console.error('Failure to load window.twttr in TwitterVideoEmbed, aborting load.');
            return;
          }

          if (!_this2.isMountCanceled) {
            window.twttr.widgets.createVideo(_this2.props.id, _this2.refs.embedContainer).then(function (element) {
              _this2.setState({
                isLoading: false
              });

              if (onLoad) {
                onLoad(element);
              }
            });
          }
        });
      }
    }
  }, {
    key: "componentWillUnmount",
    value: function componentWillUnmount() {
      this.isMountCanceled = true;
    }
  }, {
    key: "render",
    value: function render() {
      var isLoading = this.state.isLoading;
      var placeholder = this.props.placeholder;
      return React.createElement(React.Fragment, null, isLoading && placeholder, React.createElement("div", {
        ref: "embedContainer"
      }));
    }
  }]);

  return TwitterVideoEmbed;
}(Component);

_defineProperty(TwitterVideoEmbed, "propTypes", {
  /**
       * Id of video tweet.
       */
  id: PropTypes.string.isRequired,

  /**
   * Placeholder while tweet is loading
   */
  placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),

  /**
   * Function to execute after load, return html element
   */
  onLoad: PropTypes.func
});

var TwitterOnAirButton =
/*#__PURE__*/
function (_Component) {
  _inherits(TwitterOnAirButton, _Component);

  function TwitterOnAirButton(props) {
    var _this;

    _classCallCheck(this, TwitterOnAirButton);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(TwitterOnAirButton).call(this, props));
    _this.state = {
      isLoading: true
    };
    return _this;
  }

  _createClass(TwitterOnAirButton, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var _this2 = this;

      var onLoad = this.props.onLoad;

      if (exenv.canUseDOM) {
        var script = require('scriptjs');

        script(twitterWidgetJs, 'twitter-embed', function () {
          if (!window.twttr) {
            console.error('Failure to load window.twttr in TwitterOnAirButton, aborting load.');
            return;
          }

          if (!_this2.isMountCanceled) {
            window.twttr.widgets.createPeriscopeOnAirButton(_this2.props.username, _this2.refs.embedContainer, _this2.props.options).then(function (element) {
              _this2.setState({
                isLoading: false
              });

              if (onLoad) {
                onLoad(element);
              }
            });
          }
        });
      }
    }
  }, {
    key: "componentWillUnmount",
    value: function componentWillUnmount() {
      this.isMountCanceled = true;
    }
  }, {
    key: "render",
    value: function render() {
      var isLoading = this.state.isLoading;
      var placeholder = this.props.placeholder;
      return React.createElement(React.Fragment, null, isLoading && placeholder, React.createElement("div", {
        ref: "embedContainer"
      }));
    }
  }]);

  return TwitterOnAirButton;
}(Component);

_defineProperty(TwitterOnAirButton, "propTypes", {
  /**
   * Username for which you require periscope on air button
   */
  username: PropTypes.string.isRequired,

  /**
   * Additional options for overriding config.
   */
  options: PropTypes.object,

  /**
   * Placeholder while tweet is loading
   */
  placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),

  /**
   * Function to execute after load, return html element
   */
  onLoad: PropTypes.func
});

var ImageSlider = function ImageSlider(props) {
  var innerSlider = useRef(null);
  var tile = useRef(null);
  var viewableWindow = useRef(null);

  var _useState = useState(0),
      _useState2 = _slicedToArray(_useState, 2),
      tileSize = _useState2[0],
      setTileSize = _useState2[1];

  var _useState3 = useState(false),
      _useState4 = _slicedToArray(_useState3, 2),
      showScroller = _useState4[0],
      setShowScroller = _useState4[1];

  var _useState5 = useState(0),
      _useState6 = _slicedToArray(_useState5, 2),
      scrollPosition = _useState6[0],
      setScrollPosition = _useState6[1];

  var client = props.client;


  function scrollSlider(e, direction) {
    var slide = e.target.parentElement;
    var scrollOffset = scrollPosition;
    var viewableWidth = slide.clientWidth;
    //calculate viewable size / slide
    var numberOfSlidesToScroll = Math.floor(tile.current.clientWidth + 25); //width of the tile plus margin
    var scrollDirection = void 0;
    if (direction === 'next') {
      scrollDirection = scrollOffset + numberOfSlidesToScroll;
      if (scrollOffset + viewableWidth + 25 >= innerSlider.current.offsetWidth) {
        scrollDirection = 0;
      }
    }
    if (direction === 'prev') {
      scrollDirection = scrollOffset - numberOfSlidesToScroll;
      if (scrollOffset === 0) {
        if (window.innerWidth > 1399) {
          scrollDirection = innerSlider.current.offsetWidth - tileSize * 3 - 70;
        }
        if (window.innerWidth < 1399 && window.innerWidth > 592) {
          scrollDirection = innerSlider.current.offsetWidth - tileSize * 2 - 40;
        }
        if (window.innerWidth < 592) {
          scrollDirection = innerSlider.current.offsetWidth - tileSize * 1 - 24;
        }
      }
    }
    slide.scrollTo({
      left: scrollDirection,
      behavior: 'smooth'
    });
    setScrollPosition(scrollDirection);
  }
  var setThumbSize = function setThumbSize() {
    var thumbSize = void 0;
    var scrollerVisible = false;
    if (window.innerWidth > 1399) {
      if (props.data.slides && props.data.slides.length < 3) {
        thumbSize = Math.floor(viewableWindow.current.clientWidth / 2 - 40);
      } else {
        thumbSize = Math.floor(viewableWindow.current.clientWidth / 3 - 40);
      }
      if (props.data.slides.length > 3) {
        scrollerVisible = true;
      }
    }
    if (window.innerWidth < 1399 && window.innerWidth > 592) {
      thumbSize = Math.floor(viewableWindow.current.clientWidth / 2 - 48);
      if (props.data.slides.length > 2) {
        scrollerVisible = true;
      }
    }
    if (window.innerWidth < 592) {
      thumbSize = Math.floor(viewableWindow.current.clientWidth / 1 - 64);
      if (props.data.slides.length > 1) {
        scrollerVisible = true;
      }
    }
    if (thumbSize !== tileSize) {
      setTileSize(thumbSize);
      setScrollPosition(0);
      setShowScroller(scrollerVisible);
      var videoRows = document.querySelectorAll('#vid-slider .row');
      for (var i = 0; i < videoRows.length; i++) {
        videoRows[i].scrollTo({
          left: 0,
          behavior: 'smooth'
        });
      }
    }
  };
  useEffect(function () {
    //IE11 Polyfill
    smoothscroll.polyfill();
    setThumbSize();

    window.addEventListener('resize', setThumbSize);

    return function () {
      return window.removeEventListener('resize', setThumbSize);
    };
  }, []);

  var variant = 'black';
  return React.createElement(
    React.Fragment,
    null,
    React.createElement(
      'div',
      { ref: viewableWindow, id: 'vid-slider', className: 'col' },
      React.createElement(
        'div',
        { className: 'row' },
        showScroller && React.createElement(
          'div',
          { onClick: function onClick(e) {
              return scrollSlider(e, 'prev');
            }, className: 'tile__slider-prev', style: { color: variant } },
          React.createElement('i', { style: { border: 'solid ' + variant, borderWidth: '0 4px 4px 0' }, className: 'arrow left' })
        ),
        showScroller && React.createElement(
          'div',
          { onClick: function onClick(e) {
              return scrollSlider(e, 'next');
            }, className: 'tile__slider-next', style: { color: variant } },
          React.createElement('i', { style: { border: 'solid ' + variant, borderWidth: '0 4px 4px 0' }, className: 'arrow right' })
        ),
        React.createElement(
          'div',
          { ref: innerSlider, className: 'row__inner' },
          props.data.slides.map(function (img, index) {
            var thumbnail = urlFor({ client: client, source: img.slideshowImage, imageWidth: 250 });
            if (!img.slideshowImage.link) {
              return React.createElement(
                'div',
                { ref: tile, key: index, className: 'tile', style: { width: tileSize + 'px' } },
                React.createElement(
                  'div',
                  { className: 'tile__media' },
                  React.createElement('img', { className: 'tile__img', src: thumbnail, alt: img.slideshowImage.alt ? img.slideshowImage.alt : '', style: { width: tileSize + 'px', maxHeight: '160px' } })
                ),
                React.createElement('div', { style: { color: variant }, className: 'tile__info' })
              );
            } else {
              return React.createElement(
                'a',
                { ref: tile, key: index, href: img.slideshowImage.link, target: img.slideshowImage.blank ? '_target' : '_self', className: 'tile', style: { width: tileSize + 'px' } },
                React.createElement(
                  'div',
                  { className: 'tile__media' },
                  React.createElement('img', { className: 'tile__img', src: thumbnail, alt: img.slideshowImage.alt ? img.slideshowImage.alt : '', style: { width: tileSize + 'px', maxHeight: '160px' } })
                ),
                React.createElement('div', { style: { color: variant }, className: 'tile__info' })
              );
            }
          })
        )
      ),
      React.createElement(
        'style',
        { jsx: 'true' },
        '\n          #vid-slider * {\n            box-sizing: border-box;\n            -ms-overflow-style: none;\n          }\n          #vid-slider::-webkit-scrollbar-thumb {\n            display: none;\n          }\n          #vid-slider::-webkit-scrollbar {\n            display: none;\n          }\n          #vid-slider .row::-webkit-scrollbar {\n            display: none;\n          }\n          #vid-slider .row::-webkit-scrollbar-thumb {\n            display: none;\n          }\n          #vid-slider {\n            position: relative;\n            -ms-overflow-style: none;\n            padding: 0 1.5rem;\n            margin-bottom: 0 !important;\n          }\n          #vid-slider .now-playing {\n            position: absolute;\n            top: 0.5rem;\n            left: 1rem;\n            color: white;\n            background: rgba(0, 0, 0, 0.75);\n          }\n          #vid-slider h1,\n          #vid-slider p {\n            text-align: center;\n            width: 100%;\n            max-width: 500px;\n            margin: auto;\n          }\n          #vid-slider,\n          #vidHolder {\n            max-width: 775px;\n            margin: 0 auto;\n          }\n          #vid-slider a:link,\n          #vid-slider a:hover,\n          #vid-slider a:active,\n          #vid-slider a:visited {\n            transition: color 150ms;\n            color: #95a5a6;\n            text-decoration: none;\n          }\n          #vid-slider a:hover {\n            color: #7f8c8d;\n            text-decoration: underline;\n          }\n          #vid-slider .contain {\n            width: 100%;\n          }\n          #vid-slider .row {\n            overflow-x: scroll;\n            width: 100%;\n            -ms-overflow-style: none;\n            overflow-y: hidden !important;\n          }\n          #vid-slider .tile__info {\n            white-space: normal !important;\n            position: absolute;\n            text-align: center;\n            color: ' + (props.dark ? 'white' : '#383838') + ';\n            opacity: 1;\n            font-size: 0.9rem;\n            font-weight: bold;\n            transition: opacity 0.25s;\n          }\n          #vid-slider .row__inner {\n            transition: 450ms -webkit-transform;\n            transition: 450ms transform;\n            transition: 450ms transform, 450ms -webkit-transform;\n            font-size: 0;\n            white-space: nowrap;\n            margin: 25px 0 70px !important;\n            padding-bottom: 10px;\n            padding-left: 0;\n          }\n          #vid-slider .tile {\n            position: relative;\n            display: inline-block;\n            margin: 0 12px;\n            font-size: 20px;\n            transition: 450ms all;\n            -webkit-transform-origin: center left;\n            transform-origin: center left;\n          }\n  \n          #vid-slider .tile:first-child {\n            margin-left: 15px;\n          }\n          #vid-slider .tile__img {\n            height: auto;\n            -o-object-fit: contain;\n            object-fit: contain;\n            object-position: center;\n          }\n          #vid-slider .tile__details {\n            position: absolute;\n            bottom: 0;\n            left: 0;\n            right: 0;\n            top: 0;\n            font-size: 10px;\n            opacity: 0;\n            background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 100%);\n            transition: 450ms opacity;\n          }\n          #vid-slider .tile__details:after,\n          #vid-slider .tile__details:before {\n            content: \'\';\n  \n            position: absolute;\n            top: 50%;\n            left: 50%;\n            display: #000;\n          }\n          #vid-slider .tile__details:after {\n            margin-top: -25px;\n            margin-left: -25px;\n            width: 50px;\n            height: 50px;\n            border: 3px solid #ecf0f1;\n            line-height: 50px;\n            text-align: center;\n            border-radius: 100%;\n            background: rgba(0, 0, 0, 0.5);\n            z-index: 1;\n          }\n          #vid-slider .tile__details:before {\n            content: \'\';\n            background: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 64 64\' width=\'64\' height=\'64\' fill=\'white\'><path d=\'M26 46 L46 32 L26 18 Z\'/></svg>")\n              no-repeat center center;\n            left: 0;\n            width: 100%;\n            height: 3rem;\n            font-size: 30px;\n            margin-right: 12px;\n            margin-top: -24px;\n            text-align: center;\n            z-index: 2;\n            color: white;\n          }\n  \n          #vid-slider .tile__title {\n            position: absolute;\n            bottom: 0;\n            padding: 10px;\n            max-width: 250px;\n          }\n          #vid-slider .tile__title_text {\n            position: relative;\n            left: 0;\n            white-space: normal;\n          }\n  \n          #vid-slider .tile__slider-prev,\n          #vid-slider .tile__slider-next {\n            width: 30px;\n            background: transparent;\n            border: none;\n            position: absolute;\n            top: 50%;\n            transform: translateY(-50%);\n            z-index: 99;\n            cursor: pointer;\n            color: ' + (props.dark ? 'white' : 'black') + ';\n            display: flex;\n            justify-content: center;\n            align-items: center;\n            font-size: 2rem;\n          }\n          #vid-slider .tile__slider-prev {\n            left: -0.5rem;\n            padding: .5rem;\n          }\n          #vid-slider .tile__slider-next {\n            right: -0.5rem;\n            padding: .5rem;\n          }\n          #vid-slider,\n          #vid-slider .row {\n            margin: 0;\n          }\n  \n          #vid-slider .row::-webkit-scrollbar-thumb {\n            background-color: transparent !important;\n          }\n          #vid-slider i {\n            border: solid ' + (props.dark ? 'white' : 'black') + ';\n            border-width: 0 4px 4px 0;\n            display: inline-block;\n            padding: 4px;\n            pointer-events: none;\n          }\n          #vid-slider .right {\n            transform: rotate(-45deg);\n            -webkit-transform: rotate(-45deg);\n          }\n          #vid-slider .left {\n            transform: rotate(135deg);\n            -webkit-transform: rotate(135deg);\n          }\n          @media screen and (min-width: 1399px) {\n            .block-content #vid-slider .tile__img {\n              height: auto;\n            }\n            .block-content #vid-slider .tile {\n              height: auto;\n            }\n          }\n  \n          @media screen and (max-width: 1399px) {\n            #vid-slider,\n            #vidHolder {\n              max-width: 620px;\n            }\n          }\n          @media screen and (max-width: 1200px) {\n            #vid-slider,\n            #vidHolder {\n              max-width: 580px;\n            }\n          }\n          @media screen and (max-width: 967px) {\n            #vid-slider {\n              max-width: 100%;\n            }\n  \n            #vid-slider .row__inner {\n              margin: 60px 0 50px !important;\n            }\n          }\n  \n          @media screen and (max-width: 768px) {\n            #vidHolder {\n              position: unset;\n              width: 100%;\n            }\n          }\n          @media screen and (max-width: 568px) {\n            #vidHolder {\n              position: unset;\n              width: 100%;\n            }\n  \n            #vid-slider .row__inner {\n              margin: 30px 0 70px;\n            }\n          }\n        '
      )
    )
  );
};

export { ImageSlider as I, TwitterTimelineEmbed as T };
