Liferay.Loader.define("dynamic-data-mapping-form-field-type@6.0.152/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 o=n?Object.getOwnPropertyDescriptor(e,r):null;o&&(o.get||o.set)?Object.defineProperty(a,r,o):a[r]=e[r]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react")),o=a("../FieldBase/ReactFieldBase.es"),l=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={},o=Object.keys(e);for(n=0;n<o.length;n++)a=o[n],t.indexOf(a)>=0||(r[a]=e[a]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)a=o[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:o,instanceId:i,mapProviderKey:c,name:s,onChange:u,value:f,viewMode:p}=t,y=_objectWithoutProperties(t,["disabled","googleMapsAPIKey","instanceId","mapProviderKey","name","onChange","value","viewMode"]);const[m,g]=(0,r.useState)(),v=(0,r.useCallback)((({newVal:{address:e,location:t}})=>{g(e),u({location:JSON.stringify(t)})}),[u,g]);return(0,l.useGeolocation)({disabled:a,googleMapsAPIKey:o,instanceId:i,mapProviderKey:c,name:s,onChange:v,value:f,viewMode:p}),r.default.createElement("div",_extends({},y,{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"}),m),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:s,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=l.MAP_PROVIDER.openStreetMap,name:i,onChange:d,readOnly:c,value:s,viewMode:u}=e,f=_objectWithoutProperties(e,["googleMapsAPIKey","instanceId","mapProviderKey","name","onChange","readOnly","value","viewMode"]);const[p,y]=(0,r.useState)("");return r.default.createElement(o.FieldBase,_extends({name:i,readOnly:c},f),r.default.createElement(Geolocation,{disabled:c,googleMapsAPIKey:t,instanceId:a,mapProviderKey:n,name:i,onChange:({location:e})=>{y(JSON.stringify(e)),p&&d({},e)},value:s,viewMode:u}))};Main.displayName="Geolocation";var i=Main;t.default=i}}));
//# sourceMappingURL=Geolocation.es.js.map