import{a as K}from"./chunk-2E4P66QC.js";import{b as J}from"./chunk-SPNVV2KO.js";import{Ea as z,H as Y,I as q,Xa as G}from"./chunk-JIDGXFMJ.js";import{c as j,f as H,g as B,k as O,y as R}from"./chunk-MTR2L2TG.js";import{X as $}from"./chunk-KVTHJWZA.js";import{Ab as A,Bc as V,Hb as u,Nc as P,Ob as w,Sb as d,Tb as l,Ub as x,Xc as E,Yb as k,Yc as D,b as T,hb as p,ib as C,ic as _,jc as c,pa as m,qa as I,tb as N,uc as v,va as f,vc as F,wa as S}from"./chunk-FWZCAEAJ.js";function L(o,s){o&1&&(d(0,"small",6),F(1,"inkorrektes Datum"),l())}function Q(o,s){if(o&1){let r=k();d(0,"div")(1,"ngb-datepicker",7,8),_("ngModelChange",function(t){f(r);let n=c();return S(n.dateStruct=t)})("ngModelChange",function(t){f(r);let n=c();return S(n.onDateChange(t))}),l(),d(3,"div",9)(4,"ngb-timepicker",10,11),_("ngModelChange",function(t){f(r);let n=c();return S(n.onTimeChange(t))}),l()()()}if(o&2){let r=c();p(),u("ngModel",r.dateStruct),p(3),u("meridian",!1)("ngModel",r.timeStruct)("seconds",r.seconds)("hourStep",r.hourStep)("minuteStep",r.minuteStep)}}var ue=(()=>{let s=class s{constructor(e,t,n){this._ngbDateParser=e,this._ngbDateTimeAdapter=t,this.ngControl=n,this.placeholder="",this.hourStep=1,this.minuteStep=1,this.secondStep=30,this.seconds=!0,this.error=!1,this.disabled=!1,this.onTouched=T,this.onChange=T,this.displayedDateTime="",this.parse=i=>{let a=i.split(" "),h=this._ngbDateParser.parse(a[0]),g=a[1]?.split(":");if(!h||!g)return null;let b=parseInt(g[0],10),y=parseInt(g[1],10),M=this.seconds?parseInt(g[2],10):void 0;return isNaN(b)||isNaN(y)||this.seconds&&isNaN(M??NaN)?null:{year:h.year,month:h.month,day:h.day,hour:b,minute:y,second:M??0}},this.format=i=>i?`${this._ngbDateParser.format(i)} ${i.hour.toString().padStart(2,"0")}:${i.minute.toString().padStart(2,"0")}${this.seconds?`:${i.second.toString().padStart(2,"0")}`:""}`:"",this.ngControl.valueAccessor=this}formatDisplayedDateTime(){this.displayedDateTime=this.format(this.dateTimeStruct)}writeValue(e){let t=this._ngbDateTimeAdapter.fromModel(e);t&&(this.dateTimeStruct=t,this.dateStruct=t,this.timeStruct=t,this.formatDisplayedDateTime())}registerOnChange(e){this.onChange=e}registerOnTouched(e){this.onTouched=e}onInputChange(e){let t=this.parse(e);t?(this.error=!1,this.dateTimeStruct=t,this.dateStruct=t,this.timeStruct=t,this.propagateModelChange()):e.length>0?this.error=!0:(this.error=!1,this.onChange(null))}onDateChange(e){this.dateStruct=e,this.dateTimeStruct?(this.dateTimeStruct.year=e.year,this.dateTimeStruct.month=e.month,this.dateTimeStruct.day=e.day):this.dateTimeStruct={year:e.year,month:e.month,day:e.day,hour:0,minute:0,second:0},this.formatDisplayedDateTime(),this.propagateModelChange()}onTimeChange(e){if(this.timeStruct=e,this.dateTimeStruct)this.dateTimeStruct.hour=e.hour,this.dateTimeStruct.minute=e.minute,this.dateTimeStruct.second=e.second;else{let t=new Date;this.dateTimeStruct={year:t.getFullYear(),month:t.getMonth(),day:t.getDay(),hour:e.hour,minute:e.minute,second:e.second}}this.formatDisplayedDateTime(),this.propagateModelChange()}inputBlur(e){this.onTouched()}propagateModelChange(e=!0){e&&this.onTouched(),this.onChange(this._ngbDateTimeAdapter.toModel(this.dateTimeStruct??null))}setDisabledState(e){this.disabled=e}};s.\u0275fac=function(t){return new(t||s)(C(q),C(K),C(H,10))},s.\u0275cmp=I({type:s,selectors:[["app-datetime-input"]],inputs:{placeholder:"placeholder",hourStep:[m.HasDecoratorInputTransform,"hourStep","hourStep",D],minuteStep:[m.HasDecoratorInputTransform,"minuteStep","minuteStep",D],secondStep:[m.HasDecoratorInputTransform,"secondStep","secondStep",D],seconds:[m.HasDecoratorInputTransform,"seconds","seconds",E],id:"id"},standalone:!0,features:[N,V],decls:7,vars:10,consts:[[1,"input-group"],[1,"form-control",3,"id","placeholder","disabled","ngClass","ngModel","ngModelChange","blur"],["type","button",1,"input-group-text",3,"ngbPopover","autoClose","placement","disabled"],["name","calendar-date"],["class","text-warning"],["calendarContent",""],[1,"text-warning"],["name","datepicker",3,"ngModel","ngModelChange"],["dp",""],[1,"d-flex","justify-content-center","mt-2"],["name","timepicker",3,"meridian","ngModel","seconds","hourStep","minuteStep","ngModelChange"],["tp",""]],template:function(t,n){if(t&1&&(d(0,"div",0)(1,"input",1),_("ngModelChange",function(a){return n.onInputChange(a)})("blur",function(a){return n.inputBlur(a)}),l(),d(2,"button",2),x(3,"bi",3),l()(),A(4,L,2,0,"small",4)(5,Q,6,6,"ng-template",null,5,P)),t&2){let i=v(6),a;p(),u("id",n.id)("placeholder",n.placeholder)("disabled",n.disabled)("ngClass",n.ngControl.valid?"ng-valid":"ng-invalid")("ngModel",(a=n.displayedDateTime)!==null&&a!==void 0?a:""),p(),u("ngbPopover",i)("autoClose","outside")("placement","auto")("disabled",n.disabled),p(2),w(4,n.error?4:-1)}},dependencies:[J,G,$,z,Y,R,j,B,O],encapsulation:2,changeDetection:0});let o=s;return o})();export{ue as a};
