!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("openstack-uicore-foundation",[],t):"object"==typeof exports?exports["openstack-uicore-foundation"]=t():e["openstack-uicore-foundation"]=t()}(this,(()=>(()=>{"use strict";var e={8779:e=>{e.exports=require("@babel/runtime/helpers/defineProperty")},8213:e=>{e.exports=require("@babel/runtime/helpers/extends")},3838:e=>{e.exports=require("@babel/runtime/helpers/objectWithoutProperties")},8362:e=>{e.exports=require("moment-timezone")},6689:e=>{e.exports=require("react")}},t={};function r(o){var i=t[o];if(void 0!==i)return i.exports;var a=t[o]={exports:{}};return e[o](a,a.exports,r),a.exports}(()=>{r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t}})(),(()=>{r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})}})(),(()=>{r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}})();var o={};return(()=>{r.r(o),r.d(o,{default:()=>v});var e=r(8213),t=r.n(e),i=r(8779),a=r.n(i),n=r(3838),s=r.n(n),p=r(6689),l=r.n(p);const u=require("react-datetime");var d=r.n(u),c=r(8362),f=r.n(c);const h=["onChange","id","value","format","error","inputProps","disabled"];function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){a()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}class v extends l().Component{constructor(e){super(e),this.state={value:e.value},this.handleChange=this.handleChange.bind(this),this.isValidDate=this.isValidDate.bind(this)}componentDidUpdate(e,t,r){this.props.value!==e.value&&this.setState({value:this.props.value})}handleChange(e){let{timezone:t}=this.props;e&&f().isMoment(e)?e=f().tz(e.format("YYYY-MM-DD HH:mm:ss"),t):""===e&&(e=f()(0));let r={target:{id:this.props.id,value:e,type:"datetime"}};e&&f().isMoment(e)&&this.props.onChange(r)}isValidDate(e,t){let{timezone:r,validation:o}=this.props,{after:i,before:a}=o;if("<"==i)return e.isBefore(f().tz(1e3*a,r));if("<="==i)return e.isSameOrBefore(f().tz(1e3*a,r));if(">"==i)return e.isAfter(f().tz(1e3*a,r));if(">="==i)return e.isSameOrAfter(f().tz(1e3*a,r));{let t=f().tz(1e3*i,r).subtract(1,"day"),o=f().tz(1e3*a,r);return e.isAfter(t)&&e.isBefore(o)}}render(){let e=void 0!==this.props.validation,r=this.props,{onChange:o,id:i,value:a,format:n,error:p,inputProps:u,disabled:c}=r,f=s()(r,h),m=this.props.hasOwnProperty("error")&&""!=p,v="form-control "+(m?"error":""),y=!!this.props.hasOwnProperty("disabled")&&c;return l().createElement("div",null,e?l().createElement(d(),t()({isValidDate:this.isValidDate,onChange:this.handleChange,dateFormat:n.date,timeFormat:n.time,value:this.state.value,inputProps:b(b({},u),{},{id:i,className:v,disabled:y,autoComplete:"off"})},f)):l().createElement(d(),t()({onChange:this.handleChange,dateFormat:n.date,timeFormat:n.time,value:this.state.value,inputProps:b(b({},u),{},{id:i,className:v,disabled:y,autoComplete:"off"})},f)),m&&l().createElement("p",{className:"error-label"},p))}}})(),o})()));
//# sourceMappingURL=datetimepicker.js.map