import e from"@arcgis/core/time/TimeExtent";import t from"@arcgis/core/time/TimeInterval";export function applyToEsriApiWidgetsObject(i,r){const s=r??{},n=i?.timeSlider?.properties;if(n){const{endTime:i,startTime:r,numberOfStops:m,thumbCount:u,timeStopInterval:o}=n;s.timeSlider={currentTimeExtent:new e({start:r,end:i}),numStops:m,numThumbs:u,stopInterval:new t({unit:o?.units?toEsriApiTimeInterval(o.units):void 0,value:o?.interval})}}return s}export function fromEsriApiWidgetsObject(e,t){const i=t??{},r=e?.timeSlider;if(r){i.timeSlider?.properties||(i.timeSlider={properties:{}});const e=i.timeSlider.properties,{stopInterval:t,numThumbs:s,numStops:n,currentTimeExtent:m}=r;e.thumbCount=s,e.numberOfStops=n,e.startTime=m?.start?.valueOf(),e.endTime=m?.end?.valueOf(),t&&(e.timeStopInterval||(e.timeStopInterval={}),e.timeStopInterval.units=t.unit?fromEsriApiTimeInterval(t.unit):void 0,e.timeStopInterval.interval=t.value)}return i}export function toEsriApiTimeInterval(e){switch(e){case"esriTimeUnitsCenturies":return"centuries";case"esriTimeUnitsDays":return"days";case"esriTimeUnitsDecades":return"decades";case"esriTimeUnitsHours":return"hours";case"esriTimeUnitsMilliseconds":return"milliseconds";case"esriTimeUnitsMinutes":return"minutes";case"esriTimeUnitsMonths":return"months";case"esriTimeUnitsSeconds":return"seconds";case"esriTimeUnitsWeeks":return"weeks";case"esriTimeUnitsYears":return"years";default:throw new Error("Unknown time interval unit")}}export function fromEsriApiTimeInterval(e){switch(e){case"centuries":return"esriTimeUnitsCenturies";case"days":return"esriTimeUnitsDays";case"decades":return"esriTimeUnitsDecades";case"hours":return"esriTimeUnitsHours";case"milliseconds":return"esriTimeUnitsMilliseconds";case"minutes":return"esriTimeUnitsMinutes";case"months":return"esriTimeUnitsMonths";case"seconds":return"esriTimeUnitsSeconds";case"weeks":return"esriTimeUnitsWeeks";case"years":return"esriTimeUnitsYears";default:throw new Error("Unknown time interval unit")}}