Liferay.Loader.define("dynamic-data-mapping-form-field-type@6.0.145/Geolocation/Geolocation.es",["module","exports","require","dynamic-data-mapping-form-field-type$leaflet/dist/leaflet.css","@frontend-taglib-clay$clayui/icon","liferay!frontend-js-react-web$react","../FieldBase/ReactFieldBase.es","./useGeolocation.es"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0,a("dynamic-data-mapping-form-field-type$leaflet/dist/leaflet.css");var n=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(a("@frontend-taglib-clay$clayui/icon")),r=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var l=n?Object.getOwnPropertyDescriptor(e,r):null;l&&(l.get||l.set)?Object.defineProperty(a,r,l):a[r]=e[r]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react")),l=a("../FieldBase/ReactFieldBase.es"),o=a("./useGeolocation.es");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e}).apply(this,arguments)}function _objectWithoutProperties(e,t){if(null==e)return{};var a,n,r=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var a,n,r={},l=Object.keys(e);for(n=0;n<l.length;n++)a=l[n],t.indexOf(a)>=0||(r[a]=e[a]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)a=l[n],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}const e=Liferay.Language.get("geolocate"),d=Liferay.ThemeDisplay.getPathThemeImages();class NoRender extends r.default.Component{shouldComponentUpdate(){return!1}render(){return r.default.createElement("div",this.props)}}const Geolocation=t=>{let{disabled:a,googleMapsAPIKey:l,instanceId:i,mapProviderKey:c,name:u,onChange:s,value:f,viewMode:p}=t,m=_objectWithoutProperties(t,["disabled","googleMapsAPIKey","instanceId","mapProviderKey","name","onChange","value","viewMode"]);const[y,g]=(0,r.useState)(),v=(0,r.useCallback)((({newVal:{address:e,location:t}})=>{g(e),s(JSON.stringify(t))}),[s,g]);return(0,o.useGeolocation)({disabled:a,googleMapsAPIKey:l,instanceId:i,mapProviderKey:c,name:u,onChange:v,value:f,viewMode:p}),r.default.createElement("div",_extends({},m,{className:"ddm-geolocation field-labels-inline"}),!a||p?r.default.createElement("div",null,r.default.createElement("div",null,r.default.createElement(n.default,{symbol:"geolocation"}),y),r.default.createElement("dl",null,r.default.createElement("dt",{className:"text-capitalize"}),r.default.createElement("dd",null,r.default.createElement(NoRender,{className:"lfr-map",id:"map_".concat(i),style:{height:"280px"}}),r.default.createElement("input",{id:"input_value_".concat(i),name:u,type:"hidden"})))):r.default.createElement("img",{alt:Liferay.Language.get("geolocation"),className:"w-100",src:"".concat(d,"/common/geolocation.png"),style:{maxWidth:"150px"},title:e}))},Main=e=>{let{googleMapsAPIKey:t,instanceId:a,mapProviderKey:n=o.MAP_PROVIDER.openStreetMap,name:i,onChange:d,readOnly:c,value:u,viewMode:s}=e,f=_objectWithoutProperties(e,["googleMapsAPIKey","instanceId","mapProviderKey","name","onChange","readOnly","value","viewMode"]);return r.default.createElement(l.FieldBase,_extends({name:i,readOnly:c},f),r.default.createElement(Geolocation,{disabled:c,googleMapsAPIKey:t,instanceId:a,mapProviderKey:n,name:i,onChange:e=>d({},e),value:u,viewMode:s}))};Main.displayName="Geolocation";var i=Main;t.default=i}}));
//# sourceMappingURL=Geolocation.es.js.map