1import{O as z,aB as Q,ai as k,aj as w,j as b,P as oo,aC as to,k as ro,aD as no,p as L,e as ao,r as e,o as eo,ag as io,aE as so,aF as lo,z as co,h as po,q as go}from"./index.RuhrnD1v.js";import{h as I}from"./moment.C7qA8nIE.js";import{W as uo}from"./WidgetLabel.CgwydhVR.js";import{W as fo}from"./WidgetLabelHelpIcon.BKLcvqEy.js";import{u as mo,D as bo,a as Co}from"./useIntlLocale.CzCxC4VC.js";import{u as To}from"./useBasicWidgetState.CI9LlGGe.js";import{c as yo,S as Do}from"./styled-components.COQN5YTT.js";import{E as So}from"./ErrorOutline.esm.DR1BbBot.js";import{C as vo}from"./select.C3diGM4n.js";import"./styled-components.CXqQ-NdV.js";import"./timepicker.CC8Doctl.js";import"./input.edoqeH9S.js";import"./base-input.DmvIDeb9.js";import"./constants.BZvTtNRL.js";import"./FormClearHelper.DFo50Lfo.js";import"./styled-components.BjCveN31.js";const xo=yo(Do),zo=({theme:o,isInSidebar:t,step:r,minTime:p,maxTime:f,disabled:g,clearable:m,error:i,scrollbarGutterSize:C,windowHeight:W})=>{const D=Math.ceil(86400/r),n=z(o.sizes.dropdownItemHeight),T=Math.min(z(o.sizes.maxDropdownHeight),W*.7),M=D*n>T;return{Popover:{props:{ignoreBoundary:t,placement:Q.bottomLeft,popoverMargin:z(o.spacing.twoXS),overrides:{Body:{style:{...k(o),...L(o)&&{borderWidth:o.spacing.none}}}}}},CalendarContainer:{style:{fontSize:o.fontSizes.sm,paddingRight:o.spacing.sm,paddingLeft:o.spacing.sm,paddingBottom:o.spacing.none,paddingTop:o.spacing.sm,borderWidth:o.spacing.none}},Week:{style:{fontSize:o.fontSizes.sm}},Day:{style:({$pseudoHighlighted:u,$pseudoSelected:a,$selected:y,$isHovered:S})=>({fontSize:o.fontSizes.sm,lineHeight:o.lineHeights.base,"::before":{backgroundColor:y||a||u||S?`${o.colors.darkenedBgMix15} !important`:o.colors.transparent},"::after":{borderColor:o.colors.transparent},...L(o)&&S&&a&&!y?{color:o.colors.secondaryBg}:{}})},PrevButton:{style:()=>({display:"flex",alignItems:"center",justifyContent:"center",":active":{backgroundColor:o.colors.transparent},":focus":{backgroundColor:o.colors.transparent,outline:0}})},NextButton:{style:()=>({display:"flex",alignItems:"center",justifyContent:"center",":active":{backgroundColor:o.colors.transparent},":focus":{backgroundColor:o.colors.transparent,outline:0}})},Input:{props:{maskChar:null,endEnhancer:i&&b(no,{content:b(ro,{source:i,allowHTML:!1}),placement:oo.TOP_RIGHT,error:!0,children:b(to,{content:So,size:"lg"})}),overrides:{EndEnhancer:{style:{color:i?o.colors.redTextColor:o.colors.grayTextColor,backgroundColor:o.colors.transparent}},Root:{style:({$isFocused:u})=>{const a=w(o.colors,u);return{borderLeftWidth:o.sizes.borderWidth,borderRightWidth:o.sizes.borderWidth,borderTopWidth:o.sizes.borderWidth,borderBottomWidth:o.sizes.borderWidth,paddingRight:o.spacing.twoXS,borderTopColor:a,borderRightColor:a,borderBottomColor:a,borderLeftColor:a,...i&&{backgroundColor:o.colors.redBackgroundColor}}}},ClearIcon:{props:{overrides:{Svg:{style:{color:o.colors.grayTextColor,padding:o.spacing.threeXS,height:o.sizes.clearIconSize,width:o.sizes.clearIconSize,":hover":{fill:o.colors.bodyText}}}}}},InputContainer:{style:{backgroundColor:"transparent"}},Input:{style:{fontWeight:o.fontWeights.normal,paddingRight:o.spacing.sm,paddingLeft:`calc(${o.spacing.sm} + ${o.sizes.tagMarginInsideBorder})`,paddingBottom:o.spacing.sm,paddingTop:o.spacing.sm,lineHeight:o.lineHeights.inputWidget,"::placeholder":{color:o.colors.fadedText60},...i&&{color:o.colors.redTextColor}},props:{"data-testid":"stDateTimeInputField"}}}}},TimeSelectContainer:{style:{paddingTop:o.spacing.none,paddingBottom:o.spacing.none}},TimeSelectFormControl:{style:{marginBottom:o.spacing.none},props:{overrides:{Label:{component:()=>null}}}},TimeSelect:{props:{step:r,format:"24",disabled:g,nullable:m,minTime:p,maxTime:f,overrides:{Select:{props:{disabled:g,overrides:{ControlContainer:{style:({$isFocused:u})=>{const a=w(o.colors,u);return{height:o.sizes.minElementHeight,borderLeftWidth:o.sizes.borderWidth,borderRightWidth:o.sizes.borderWidth,borderTopWidth:o.sizes.borderWidth,borderBottomWidth:o.sizes.borderWidth,borderTopColor:a,borderRightColor:a,borderBottomColor:a,borderLeftColor:a}}},IconsContainer:{style:()=>({paddingRight:o.spacing.sm})},ValueContainer:{style:()=>
1({lineHeight:o.lineHeights.inputWidget,paddingRight:o.spacing.sm,paddingLeft:`calc(${o.spacing.sm} + ${o.sizes.tagMarginInsideBorder})`,paddingBottom:o.spacing.sm,paddingTop:o.spacing.sm})},SingleValue:{style:{fontWeight:o.fontWeights.normal,marginLeft:o.spacing.none},props:{"data-testid":"stDateTimeInputTimeDisplay"}},Dropdown:{style:()=>({paddingTop:o.spacing.none,paddingBottom:o.spacing.none,paddingLeft:o.spacing.none,paddingRight:o.spacing.none,boxShadow:"none",maxHeight:`min(${o.sizes.maxDropdownHeight}, 70vh)`,"--scrollbar-gutter-size":M?`${C}px`:"0px"})},DropdownContainer:{style:()=>({...k(o),overflow:"hidden"})},DropdownListItem:{component:xo},Popover:{props:{ignoreBoundary:t,popoverMargin:z(o.spacing.twoXS),overrides:{Body:{style:()=>({overflow:"hidden"})}}}},Placeholder:{style:()=>({color:o.colors.fadedText60,position:"absolute"})},Input:{style:{position:"relative",zIndex:o.zIndices.priority}},SelectArrow:{component:vo,props:{overrides:{Svg:{style:()=>({width:o.iconSizes.xl,height:o.iconSizes.xl})}}}}}}}}}}}},V="YYYY-MM-DDTHH:mm",E=(o,t)=>{const r=o.getStringArrayValue(t);if(r!==void 0)return r.length>0?r[0]:null},B=o=>o.default?.length?o.default[0]:null,A=o=>o.value?.length?o.value[0]:null,F=o=>{let t;if(Array.isArray(o)?t=o.find(p=>p instanceof Date):t=o,!t||Number.isNaN(t.getTime()))return null;const r=new Date(t.getTime());return r.setSeconds(0,0),r},Io="YYYY/MM/DD, HH:mm",Wo=[V,Io],c=o=>{if(ao(o)||o==="")return null;const t=I(o,Wo,!0);return t.isValid()?F(t.toDate()):null},P=(o,t)=>o.getFullYear()===t.getFullYear()&&o.getMonth()===t.getMonth()&&o.getDate()===t.getDate(),R=(o,t)=>{const r=new Date(o.getTime());return r.setHours(t.getHours(),t.getMinutes(),0,0),r},Mo=(o,t,r,p)=>{const f=c(o.min),g=c(o.max),m=i=>{t.setStringArrayValue(o,i?[i]:[],{fromUi:r.fromUi},p)};if(r.value){const i=c(r.value);if(i){f&&i<f||g&&i>g||m(r.value);return}}m(r.value)};function ho({disabled:o,element:t,widgetMgr:r,fragmentId:p}){const f=eo(),g=e.useContext(io),m=so(),{innerHeight:i}=lo(),C=e.useRef(null),W=t.queryParamKey?{paramKey:t.queryParamKey,valueType:"string_array_value",clearable:t.default.length===0}:void 0,D=()=>{const d=E(r,t)??(t.setValue?A(t):B(t));return c(d)},[n,T]=e.useState(D),[M,u]=e.useState(D),[a,y]=To({getStateFromWidgetMgr:E,getDefaultStateFromProto:B,getCurrStateFromProto:A,updateWidgetMgrState:Mo,element:t,widgetMgr:r,fragmentId:p,queryParamBinding:W,formClearBehavior:"resetValueAndRunCallback",onFormCleared:e.useCallback(()=>{T(c(B(t)))},[t])}),{locale:S}=e.useContext(co),O=mo(S),Y=t.step?Number(t.step):900,s=e.useMemo(()=>c(t.min),[t.min]),l=e.useMemo(()=>c(t.max),[t.max]),h=e.useMemo(()=>c(a),[a]);h!==M&&(T(h),u(h));const _=s??void 0,N=l??void 0,$=e.useMemo(()=>{if(!(!n||!s))return P(n,s)?R(n,s):void 0},[n,s]),j=e.useMemo(()=>{if(!(!n||!l))return P(n,l)?R(n,l):void 0},[n,l]),q=t.format.replaceAll(/[a-zA-Z]/g,"9"),v=`${t.format.replaceAll("Y","y").replaceAll("D","d")}, HH:mm`,G=`${q}, 99:99`,U=`${t.format}, HH:MM`,H=(t.default&&t.default.length>0?t.default[0]:"").length===0&&!o,X=e.useMemo(()=>{if(!n)return null;if(s&&n<s||l&&n>l){const d=I(s).format(v),x=I(l).format(v);return`**Error**: Date and time set outside allowed range. Please select a date and time between ${d} and ${x}.`}return null},[n,s,l,v]),K=e.useCallback(({date:d})=>{const x=F(d);T(x),C.current?.open?.()},[]),Z=e.useCallback(()=>{const d=n?I(n).format(V):null;d!==a&&y({value:d,fromUi:!0})},[n,a,y]),J=zo({theme:f,isInSidebar:g,step:Y,minTime:$,maxTime:j,disabled:o,clearable:H,error:X,scrollbarGutterSize:m,windowHeight:i});return po("div",{className:"stDateTimeInput","data-testid":"stDateTimeInput",children:[b(uo,{label:t.label,disabled:o,labelVisibility:go(t.labelVisibility?.value),children:t.help&&b(fo,{content:t.help,label:t.label})}),b(Co,{ref:C,locale:O,density:bo.high,value:n,onChange:K,onClose:Z,minDate:_,maxDate:N,disabled:o,timeSelectStart:!0,formatString:v,mask:G,placeholder:U,clearable:H,overrides:J,"aria-label":t.label})]})}const Go=e.memo(ho);export{Go as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.