"use strict";(self.webpackChunkstreamlit_browser=self.webpackChunkstreamlit_browser||[]).push([[828],{2828:function(e,t,n){n.r(t),n.d(t,{default:function(){return w}});var r=n(15671),a=n(43144),i=n(60136),o=n(29388),s=n(47313),l=n(70816),u=n.n(l),p=n(83985),d=n(78138),m=n(66097),c=n(18550),f=n(46332),h=n(65167),g=n(73290),y=n(80213),v=n(64243),b=n(46417),C="YYYY/MM/DD";function x(e){return e.map((function(e){return new Date(e)}))}function k(e){return e.map((function(e){return u()(e).format(C)}))}var V=function(e){(0,i.Z)(n,e);var t=(0,o.Z)(n);function n(){var e;(0,r.Z)(this,n);for(var a=arguments.length,i=new Array(a),o=0;o<a;o++)i[o]=arguments[o];return(e=t.call.apply(t,[this].concat(i))).formClearHelper=new f.Kz,e.state={values:e.initialValue,isRange:e.props.element.isRange,isEmpty:!1},e.commitWidgetValue=function(t){e.props.widgetMgr.setStringArrayValue(e.props.element,k(e.state.values),t)},e.onFormCleared=function(){var t=x(e.props.element.default);e.setState({values:t},(function(){return e.commitWidgetValue({fromUi:!0})}))},e.handleChange=function(t){var n=t.date;if(null!==n&&void 0!==n){var r=[];Array.isArray(n)?n.forEach((function(e){e&&r.push(e)})):r.push(n),e.setState({values:r,isEmpty:!r},(function(){e.state.isEmpty||e.commitWidgetValue({fromUi:!0})}))}else e.setState({values:[],isEmpty:!0})},e.handleClose=function(){e.state.isEmpty&&e.setState((function(e,t){return{values:x(t.element.default),isEmpty:!x(t.element.default)}}),(function(){e.commitWidgetValue({fromUi:!0})}))},e.getMaxDate=function(){var t=e.props.element.max;return t&&t.length>0?u()(t,C).toDate():void 0},e}return(0,a.Z)(n,[{key:"initialValue",get:function(){var e=this.props.widgetMgr.getStringArrayValue(this.props.element);return x(void 0!==e?e:this.props.element.default)}},{key:"componentDidMount",value:function(){this.props.element.setValue?this.updateFromProtobuf():this.commitWidgetValue({fromUi:!1})}},{key:"componentDidUpdate",value:function(){this.maybeUpdateFromProtobuf()}},{key:"componentWillUnmount",value:function(){this.formClearHelper.disconnect()}},{key:"maybeUpdateFromProtobuf",value:function(){this.props.element.setValue&&this.updateFromProtobuf()}},{key:"updateFromProtobuf",value:function(){var e=this,t=this.props.element.value;this.props.element.setValue=!1,this.setState({values:t.map((function(e){return new Date(e)}))},(function(){e.commitWidgetValue({fromUi:!1})}))}},{key:"render",value:function(){var e,t=this.props,n=t.width,r=t.element,a=t.disabled,i=t.theme,o=t.widgetMgr,s=this.state,l=s.values,p=s.isRange,f=i.colors,x=i.fontSizes,k=i.lineHeights,V={width:n},w=u()(r.min,C).toDate(),D=this.getMaxDate();return this.formClearHelper.manageFormClearListener(o,r.formId,this.onFormCleared),(0,b.jsxs)("div",{className:"stDateInput",style:V,children:[(0,b.jsx)(h.ON,{label:r.label,disabled:a,labelVisibility:(0,v.iF)(null===(e=r.labelVisibility)||void 0===e?void 0:e.value),children:r.help&&(0,b.jsx)(h.dT,{children:(0,b.jsx)(g.ZP,{content:r.help,placement:y.ug.TOP_RIGHT})})}),(0,b.jsx)(d.Z,{density:m.pw.high,formatString:"yyyy/MM/dd",disabled:a,onChange:this.handleChange,onClose:this.handleClose,overrides:{Popover:{props:{placement:c.r4.bottomLeft,overrides:{Body:{style:{border:"1px solid ".concat(f.fadedText10)}}}}},CalendarContainer:{style:{fontSize:x.sm,paddingRight:i.spacing.sm,paddingLeft:i.spacing.sm,paddingBottom:i.spacing.sm,paddingTop:i.spacing.sm}},Week:{style:{fontSize:x.sm}},Day:{style:{fontSize:x.sm,lineHeight:k.base,"::after":{borderColor:f.transparent}}},PrevButton:{style:function(){return{display:"flex",alignItems:"center",justifyContent:"center",":active":{backgroundColor:f.transparent},":focus":{backgroundColor:f.transparent,outline:0}}}},NextButton:{style:{display:"flex",alignItems:"center",justifyContent:"center",":active":{backgroundColor:f.transparent},":focus":{backgroundColor:f.transparent,outline:0}}},Input:{props:{maskChar:null,overrides:{Root:{style:{borderLeftWidth:"1px",borderRightWidth:"1px",borderTopWidth:"1px",borderBottomWidth:"1px"}},Input:{style:{paddingRight:".5rem",paddingLeft:".5rem",paddingBottom:".5rem",paddingTop:".5rem"}}}}}},value:l,minDate:w,maxDate:D,range:p})]})}}]),n}(s.PureComponent),w=(0,p.b)(V)}}]);