text: "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard");Object.defineProperty(exports,"__esModule",{value:true});exports.AmenitySource=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _assertThisInitialized2=_interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));var _inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits"));var _possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));var _getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _react=_interopRequireDefault(require("react"));var _maps=_interopRequireDefault(require("@react-native-mapbox-gl/maps"));var _instance=_interopRequireWildcard(require("./instance"));var _react2=_interopRequireDefault(require("fast-deep-equal/react"));var _jsxFileName="/home/matej/Documents/proximi/react-native-mapbox-library/src/amenity_source.tsx";function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=(0,_getPrototypeOf2.default)(Derived),result;if(hasNativeReflectConstruct){var NewTarget=(0,_getPrototypeOf2.default)(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return(0,_possibleConstructorReturn2.default)(this,result);};}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Date.prototype.toString.call(Reflect.construct(Date,[],function(){}));return true;}catch(e){return false;}}var AmenitySource=function(_React$Component){(0,_inherits2.default)(AmenitySource,_React$Component);var _super=_createSuper(AmenitySource);function AmenitySource(props){var _this;(0,_classCallCheck2.default)(this,AmenitySource);_this=_super.call(this,props);(0,_defineProperty2.default)((0,_assertThisInitialized2.default)(_this),"state",{syncKey:"proximiio-amenity-source-".concat(new Date().getTime()),images:{}});_this.onChange=_this.onChange.bind((0,_assertThisInitialized2.default)(_this));return _this;}(0,_createClass2.default)(AmenitySource,[{key:"onChange",value:function onChange(){var amenities,images;return _regenerator.default.async(function onChange$(_context){while(1){switch(_context.prev=_context.next){case 0:amenities=_instance.default.getAmenities();console.log('amenity source onChange, size: ',amenities.length);images={};amenities.filter(function(a){return a.icon&&a.icon.length>256;}).forEach(function(amenity){return images[amenity.id]={uri:amenity.icon,scale:1};});this.setState({images:images,syncKey:"proximiio-amenity-source-".concat(new Date().getTime())});case 5:case"end":return _context.stop();}}},null,this,null,Promise);}},{key:"componentDidMount",value:function componentDidMount(){this.onChange();_instance.default.subscribe(_instance.ProximiioMapboxEvents.AMENITIES_CHANGED,this.onChange);}},{key:"componentWillUnmount",value:function componentWillUnmount(){_instance.default.unsubscribe(_instance.ProximiioMapboxEvents.AMENITIES_CHANGED,this.onChange);}},{key:"shouldComponentUpdate",value:function shouldComponentUpdate(_nextProps,nextState){if((0,_react2.default)(nextState,this.state)){return false;}return true;}},{key:"render",value:function render(){return _react.default.createElement(_maps.default.Images,{key:this.state.syncKey,images:this.state.images,__self:this,__source:{fileName:_jsxFileName,lineNumber:66,columnNumber:7}});}}]);return AmenitySource;}(_react.default.Component);exports.AmenitySource=AmenitySource;
  //# sourceMappingURL=amenity_source.js.map