1"use strict";(self.webpackChunkfarm_portal=self.webpackChunkfarm_portal||[]).push([["projects_farm-portal_src_app_modules_livestock_livestock_module_ts"],{46695:(F,T,s)=>{s.r(T),s.d(T,{LivestockModule:()=>qt});var c=s(94666),r=s(2508),u=s(85511),h=s(76317),g=s(59295),C=s(19337),d=s(32313),t=s(22560),v=s(38504),p=s(10944);let S=(()=>{class n{constructor(e,i,a){this.api=e,this.userContextService=i,this.spinnerService=a,this.currentLivestock=new h.X(null),this.currentLivestock$=this.currentLivestock.asObservable(),this.livestock=null}fetchDetailsItem(e){this.spinnerService.display(),this.api.get(this.userContextService.currentOrganizationId,e).pipe((0,g.q)(1),(0,C.b)(i=>{this.currentLivestock.next(i),this.livestock=i}),(0,d.x)(()=>{this.spinnerService.hide()})).subscribe()}clearDetailsItem(){this.currentLivestock.next(null),this.livestock=null}}return n.\u0275fac=function(e){return new(e||n)(t.LFG(u.g0W),t.LFG(v.o),t.LFG(p.V))},n.\u0275prov=t.Yz7({token:n,factory:n.\u0275fac}),n})();var ct=s(86266),pt=s(79649),ut=s(13647),dt=s(80953),L=s(94908),ht=s(13935),mt=s(15333),Y=s(84348),f=s(83539),H=s(33345),gt=s(19278);class B{static mapToForm(o){return{title:o.title,description:o.description??null,registeredAt:o.registeredAt?H.s.isoStringDateToDatePicker(o.registeredAt):null,photos:(o.photos??[]).map(e=>({file:e})),relatedOrganizationId:o.relatedOrganizationId??""}}static mapToListItem(o){return{id:o.id,title:o.title,description:o.description??"",groundId:o.groundId??"",groundName:o.groundName??"",groundCrop:o.groundCrop??"",parcelId:o.parcelId??"",parcelName:o.parcelName??"",fieldCardId:o.fieldCardId??"",fieldCardCrop:o.fieldCardCrop??"",organizationId:o.organizationId??"",registeredAt:o.registeredAt,photos:(o.photos??[]).map(e=>({id:e.id??"",name:e.name,link:e.link??"",rootFileName:e.rootFileName??e.name,mimeType:e.mimeType??""})),locations:o.locations??[],weatherDataList:o.weatherDataList??[],recommendation:o.recommendation??"",sharingOrganizations:o.sharingOrganizations??[],recommendations:o.recommendations??[]}}static toFormData(o){const e=new FormData;return e.append("title",o.title),e.append("id",o.id??(0,gt.Z)()),o.description&&e.append("description",o.description),o.registeredAt&&e.append("registeredAt",o.registeredAt),(o.photos??[]).forEach(i=>{i.file?.file?e.append("photos",i.file.file,i.file.name):i.file?.id&&e.append("ExistingPhotoIds",i.file.id)}),o.relatedOrganizationId&&e.append("relatedOrganizationId",o.relatedOrganizationId),e}}var Q=s(23136),M=s(85173),w=s(80155),D=s(92689),K=s(49894),x=s(91711),vt=s(83486),R=s(85466),y=s(90538),I=s(64344);function ft(n,o){if(1&n&&(t.ynx(0),t.TgZ(1,"div",9),t._UZ(2,"lib-file-form-control",10),t.qZA(),t.BQk()),2&n){const e=o.index,i=t.oxw();t.xp6(1),t.Q6J("formGroupName",e),t.xp6(1),t.Q6J("label","SUPPLIER.NOTE.photosGroup")("accept",i.acceptedMimeTypes)("acceptExtensions",i.acceptedFileExtensions)}}let z=(()=>{class n{constructor(e,i,a,l,m){this.router=e,this.api=i,this.spinnerService=a,this.formBuilder=l,this.formMode="add",this.title="SUPPLIER.NOTE.create:header",this.subtitle="",this.isInEditMode=!1,this.acceptedFileExtensions=Q.ai,this.acceptedMimeTypes=Q.KL,this.imagesCount=5,this.noteId=m.snapshot.params.id,this.livestockId=m.snapshot.queryParamMap.get("livestock"),m.snapshot.params.action&&(this.formMode=m.snapshot.params.action),"edit"===this.formMode&&(this.title="SUPPLIER.NOTE.edit:header",this.isInEditMode=!0),"add"===this.formMode&&(this.isInEditMode=!0),"details"===this.formMode&&(this.title="SUPPLIER.NOTE.details:header"),this.addEditNoteForm=this.formBuilder.group({title:["",[r.kI.required,r.kI.minLength(3),r.kI.maxLength(160)]],description:["",r.kI.maxLength(1e3)],registeredAt:[(0,p.sm)((new Date).toISOString()),[M.r.toCurrentDate()]],photos:this.formBuilder.array([])});for(let k=0;k<this.imagesCount;k++)this.photos.push(this.initImagesFormGroup())}ngOnInit(){this.noteId&&this.loadData()}onSave(){"add"!==this.formMode?this.onEdit():this.onAdd()}onNavigateBack(){this.router.navigate(["livestock",this.livestockId,"notes"])}getFormControl(e){return this.addEditNoteForm.get(e)}get photos(){return this.addEditNoteForm.get("photos")}initImagesFormGroup(){return this.formBuilder.group({file:new r.p4(null)})}onAdd(){this.spinnerService.display();const e=B.toFormData(this.setFormSubmitData());this.api.create(this.livestockId,e).pipe((0,w.P)(),(0,d.x)(()=>this.spinnerService.hide())).subscribe(()=>this.onNavigateBack())}onEdit(){this.spinnerService.display();const e=this.setFormSubmitData();e.id=this.noteId;const i=B.toFormData(e);this.api.update(this.livestockId,this.noteId,i).pipe((0,w.P)(),(0,d.x)(()=>this.spinnerService.hide())).subscribe(()=>this.onNavigateBack())}loadData(){this.spinnerService.display(),this.api.get(this.livestockId,this.noteId).pipe((0,g.q)(1),(0,d.x)(()=>this.spinnerService.hide())).subscribe(e=>{this.addEditNoteForm.patchValue(B.mapToForm(e)),this.subtitle=`- ${e.title}`})}setFormSubmitData(){const e=this.addEditNoteForm.value;return e.registeredAt=e.registeredAt?H.s.dataPickerDateToISOString(e.registeredAt):null,e.relatedOrganizationId=this.livestockId,e}}return n.\u0275fac=function(e){return new(e||n)(t.Y36(f.F0),t.Y36(u.ZeK),t.Y36(p.V),t.Y36(r.QS),t.Y36(f.gz))},n.\u0275cmp=t.Xpm({type:n,selectors:[["app-livestock-note-add-edit-form"]],decls:14,vars:17,consts:[[3,"title","backBtnAction"],[3,"headerTranslationKey","formGroup","isEditMode","formSubmitted","navigateBack"],[1,"form-group--big"],[3,"inputControl","labelTranslateKey"],[3,"inputControl","labelTranslateKey","rows"],[1,"headline-underline"],["formArrayName","photos"],["form-group","",1,"d-flex","flex-wrap","gap-12"],[4,"ngFor","ngForOf"],[3,"formGroupName"],["formControlName","file",3,"label","accept","acceptExtensions"]],template:function(e,i){1&e&&(t.TgZ(0,"app-title-with-back-btn",0),t.NdJ("backBtnAction",function(){return i.onNavigateBack()}),t.ALo(1,"translate"),t.qZA(),t.TgZ(2,"lib-page-content")(3,"lib-form",1),t.NdJ("formSubmitted",function(){return i.onSave()})("navigateBack",function(){return i.onNavigateBack()}),t.TgZ(4,"div",2),t._UZ(5,"app-input-text",3)(6,"app-input-datepicker",3)(7,"app-input-textarea",4),t.qZA(),t.TgZ(8,"h5",5),t._uU(9),t.ALo(10,"translate"),t.qZA(),t.ynx(11,6),t.TgZ(12,"div",7),t.YNc(13,ft,3,4,"ng-container",8),t.qZA(),t.BQk(),t.qZA()()),2&e&&(t.Q6J("title",t.lcZ(1,13,i.title)+i.subtitle),t.xp6(3),t.Q6J("headerTranslationKey","SUPPLIER.NOTE.baseGroup")("formGroup",i.addEditNoteForm)("isEditMode",i.isInEditMode),t.xp6(2),t.Q6J("inputControl",i.getFormControl("title"))("labelTranslateKey","SUPPLIER.NOTE.title"),t.xp6(1),t.Q6J("inputControl",i.getFormControl("registeredAt"))("labelTranslateKey","SUPPLIER.NOTE.registeredAt"),t.xp6(1),t.Q6J("inputControl",i.getFormControl("description"))("labelTranslateKey","SUPPLIER.NOTE.description")("rows",9),t.xp6(2),t.Oqu(t.lcZ(10,15,"SUPPLIER.NOTE.photosGroup")),t.xp6(4),t.Q6J("ngForOf",i.photos.controls))},dependencies:[c.sg,r.JJ,r.JL,r.sg,r.u,r.x0,r.CE,D.s,K.m,x.Q,vt.g,R.U,L.u,y.Y,I.X$],encapsulation:2}),n})();const bt=/^[A-Z]{2}[0-9]{12}$/,kt=new Set(["AT","BE","BG","HR","CY","CZ","DK","EE","FI","FR","DE","GR","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","RO","SK","SI","ES","SE"]);function O(n){return null==n?null:n.trim().toUpperCase()}function W(){return n=>{const o=O(n.value);return o?14===o.length&&bt.test(o)&&kt.has(o.substring(0,2))?null:{pattern:!0}:null}}function U(n){return{livestockBaseInfoGroup:{id:n.id??"",species:n.species??null,breed:n.breed??null,earTagNumber:n.earTagNumber??null,entryReason:n.entryReason??null,arrivalDate:n.arrivalDate?(0,p.sm)(n.arrivalDate.toISOString()):null,birthDate:n.birthDate?(0,p.sm)(n.birthDate.toISOString()):null,name:n.name??null,weight:n.weight??null,passportNumber:n.passportNumber??null,motherEarTagNumber:n.motherEarTagNumber??null,bullEarTagNumber:n.bullEarTagNumber??null,notes:n.notes??null,utilityType:n.utilityType??null,lactationPhase:n.lactationPhase??null}}}const $=new Map([[u.Ni2.Cattle,["HO","RW","AB","AY","BG","DR","RE","GU","JE","MS","MM","NO","ZB","RP","ZR","RN","SW","SL","SH","SM","SR","TA","LM","CH","AR","AN","PI","BI","RG","LU","HH","WB","BD","BB","BS","MO","AL","LO","NR","LV","GR","MR","AU","CA","GA","GV","HI","BM","BO","WA","PT","SF","BR","BN","MA","MG","PZ","SG","SD","BF","WS","UK","SP","IN"]],[u.Ni2.Pigs,["Wielka Bia\u0142a Polska","Polska Bia\u0142a Zwis\u0142oucha","Z\u0142otnicka Bia\u0142a","Z\u0142otnicka Pstra","Pu\u0142awska","Duroc","Pietrain","Hampshire","Landrace (du\u0144ska)","Landrace (niemiecka)","Landrace (francuska)","Landrace (holenderska)","Large White (angielska)","Middle White","Small White","Berkshire","Tamworth","Gloucestershire Old Spots","British Saddleback","Oxford Sandy and Black","Mangalica (w\u0119gierska)","Bazna","Iberian (Iberyjska)","Gascon","Limousin","Normande","Nustrale","Cinta Senese","Casertana","Apulo-Calabrese","Nero Siciliano","Sarda","Mora Romagnola","Swabian-Hall","Buntes Bentheimer","Angler Sattelschwein","Schw\xe4bisch-H\xe4llisches Schwein","Turopolje","Black Slavonian","Kr\u0161kopolje","Lithuanian White","Lithuanian Indigenous Wattle","Latvian White","Estonian Bacon","Finnish Landrace","Norweg
1ian Landrace","Swedish Landrace","Danish Protest Pig"]],[u.Ni2.Sheep,["Polska Owca G\xf3rska","Polska Owca Nizinna","Polska Owca Pog\xf3rza","Polska Owca D\u0142ugowe\u0142nista","Merynos Polski","Merynos Stary Typ","Merynos Barwny","Wrzos\xf3wka","\u015awiniarka","Uhruska","Kamieniecka","Pomorska","Wielkopolska","Cakiel Podhala\u0144ski","Olkuska","Romanowska","Texel","Charollais","Ile-de-France","Berrichon du Cher","Suffolk","Hampshire Down","Southdown","Dorset","Dorset Horn","Poll Dorset","Wiltshire Horn","Ryeland","Lincoln","Leicester Longwool","Border Leicester","Bluefaced Leicester","Wensleydale","Teeswater","Cotswold","Clun Forest","Exmoor Horn","Devon Closewool","Hill Radnor","Kerry Hill","Beulah Speckled Face","Welsh Mountain","Black Welsh Mountain","Balwen Welsh Mountain","Lleyn","Manx Loaghtan","Jacob","Soay","North Ronaldsay","Hebridean","Scottish Blackface","Cheviot","Scottish Halfbred","Blackface (Highland type)","Rasa Aragonesa","Rasa Navarra","Churra","Castellana","Ojalada","Merino Espa\xf1ol","Segure\xf1a","Ojinegra de Teruel","Ripollesa","Xisqueta","Latxa","Carranzana","Mallorquina","Menorquina","Sarda","Comisana","Massese","Appenninica","Bergamasca","Sopravissana","Gentile di Puglia","Altamurana","Leccese","Biellese","Zwartbles","Drents Heideschaap","Veluws Heideschaap","Kempisch Heideschaap","Heideschaap (Dutch Heath)","Bentheimer Landschaf","Coburger Fuchsschaf","Rh\xf6nschaf","Merinolandschaf","Schwarzk\xf6pfiges Fleischschaf","Krainer Steinschaf","K\xe4rntner Brillenschaf","Tiroler Bergschaf","Waldschaf","Jura Sheep","Valais Blacknose","Engadine Sheep","B\xfcndner Oberl\xe4nder","Skudde","Gotland","Finnsheep","Norwegian White Sheep","Sp\xe6lsau","Dalap\xe4lsf\xe5r","Rya Sheep","Estonian Whitehead","Latvian Darkhead","Lithuanian Blackface","Romanian Turcana","Romanian Tsigai","Racka","Cig\xe1ja","Karagouniko","Chios","Serres","Sfakia","Karaman","Imroz","Sakiz","Awassi (European populations)"]],[u.Ni2.Goats,["Alpejska","Saanen","Toggenburska","Anglonubijska","Boer","Kameru\u0144ska","Karpacka","Murciano-Granadina","Malta\u0144ska","Damascus"]],[u.Ni2.Horses,["Andalusian (Pura Raza Espa\xf1ola)","Lusitano","Lipizzaner","Kladruber","Frederiksborg","Friesian","Gelderlander","Groningen","Dutch Warmblood (KWPN)","Belgian Warmblood (BWP)","Zangersheide","Hanoverian","Holsteiner","Oldenburg","Westphalian","Rhinelander","Trakehner","Mecklenburg Warmblood","Brandenburg Warmblood","Saxon Warmblood","Thuringian Warmblood","Bavarian Warmblood","W\xfcrttemberger","Hessian Warmblood","German Riding Pony","Black Forest Horse","Schleswiger","Jutland Horse","D\xf8le Gudbrandsdal","Nordlandshest/Lyngshest","Fjord Horse","Icelandic Horse","Swedish Warmblood","Gotland Pony","North Swedish Horse","Finnhorse","Estonian Native Horse","Latvian Horse","Lithuanian Heavy Draught","\u017demaitukas","Trakehner (Lithuanian line)","Polish Warmblood (Wielkopolski)","Ma\u0142opolski","\u015al\u0105ski","Polski ko\u0144 zimnokrwisty","Hucul","Konik Polski","Arabian (Polish Arabian)","Shagya Arabian","Anglo-Arabian","Orlov Trotter","Russian Trotter","Budyonny","Don Horse","Karabakh","Kabardin","Karachai","Nonius","Furioso-North Star","Gidran","Kisber Felver","Hucul (Carpathian)","Lipizzaner (Hungarian line)","Selle Fran\xe7ais","Anglo-Normand","Camargue","Ardennais","Boulonnais","Percheron","Comtois","Auxois","Trait du Nord","Breton","Norman Cob","Irish Draught","Irish Sport Horse","Connemara Pony","Kerry Bog Pony","Eriskay Pony","Highland Pony","Shetland Pony","Dales Pony","Fell Pony","Cleveland Bay","Exmoor Pony","Dartmoor Pony","New Forest Pony","Welsh Mountain Pony (Section A)","Welsh Pony (Section B)","Welsh Pony of Cob Type (Section C)","Welsh Cob (Section D)","Hackney Horse","Hackney Pony","Shire","Clydesdale","Suffolk Punch","Gypsy Vanner (Irish Cob)","Tinker Horse","Asturc\xf3n","Pottok","Galician Horse (Pura Raza Galega)","Losino","Mallorqu\xedn","Menorqu\xedn","Burguete","Jaca Navarra","Hispano-Bret\xf3n","Alter Real","Sorraia","M\xe9rens","Landais Pony","Auvergne Horse","Castillonnais","Barbe (European lines)"]]]);function X(n){return n&&$.has(n)?($.get(n)??[]).map(o=>({label:o,value:o})):[]}var E=s(50635),q=s(85261),V=s(47793);function At(n,o){if(1&n&&t._UZ(0,"app-input-ng-select",2),2&n){const e=t.oxw();t.Q6J("inputControl",e.getControl("livestockBaseInfoGroup.utilityType"))("labelTranslateKey","LIVESTOCK.FORM.utilityType")("options",e.utilityTypeOptions)}}function _t(n,o){if(1&n&&t._UZ(0,"app-input-ng-select",2),2&n){const e=t.oxw();t.Q6J("inputControl",e.getControl("livestockBaseInfoGroup.lactationPhase"))("labelTranslateKey","LIVESTOCK.FORM.lactationPhase")("options",e.lactationPhaseOptions)}}const Bt=[/[A-Za-z]/,/[A-Za-z]/,/\d/,/\d/,/\d/,/\d/,/\d/,/\d/,/\d/,/\d/,/\d/,/\d/,/\d/,/\d/];let j=(()=>{class n{constructor(e){this.fb=e,this.onAccept=new t.vpe,this.navigateBack=new t.vpe,this.editModeChanged=new t.vpe(null),this.isWeightEditable=!0,this.earTagMask=Bt,this.speciesOptions=(0,p.DQ)(u.Ni2,"LIVESTOCK_SPECIES",!1),this.entryReasonOptions=(0,p.DQ)(u.g7j,"LIVESTOCK_ENTRY_REASON",!1),this.utilityTypeOptions=(0,p.DQ)(u.WT7,"LIVESTOCK_UTILITY_TYPE",!1),this.lactationPhaseOptions=(0,p.DQ)(u.kxN,"LIVESTOCK_LACTATION_PHASE",!1),this.breedOptions=[],this.isCattleFieldsVisible=!1,this.initialData$=new h.X(null),this.initForm()}set data(e){this.initialData$.next(e??null)}ngOnInit(){this.onInitialDataChange()}ngOnDestroy(){this.onInitialDataChangeSub?.unsubscribe(),this.speciesSubscription?.unsubscribe(),this.earTagSubscription?.unsubscribe()}getControl(e){return this.formGroup.get(e)}onAcceptClick(){this.onAccept.emit(this.formGroup.getRawValue())}onNavigateBack(){this.navigateBack.emit()}handleOnEditModeChange(e){this.syncWeightControlState(e),this.editModeChanged.next(e)}initForm(){this.formGroup=this.fb.group({livestockBaseInfoGroup:this.fb.group({id:this.fb.nonNullable.control(""),species:this.fb.control(null,[r.kI.required]),breed:this.fb.control(null,[r.kI.required,r.kI.maxLength(250)]),earTagNumber:this.fb.control(null,[r.kI.required,W()]),entryReason:this.fb.control(null,[r.kI.required]),arrivalDate:this.fb.control(null,[r.kI.required]),birthDate:this.fb.control(null,[r.kI.required]),name:this.fb.control(null,[r.kI.maxLength(250)]),weight:this.fb.control(null,[r.kI.min(1),r.kI.max(4e3)]),passportNumber:this.fb.control(null,[r.kI.maxLength(50)]),motherEarTagNumber:this.fb.control(null,[r.kI.maxLength(30),W()]),bullEarTagNumber:this.fb.control(null,[r.kI.maxLength(30),W()]),notes:this.fb.control(null,[r.kI.maxLength(1e3)]),utilityType:this.fb.control(null),lactationPhase:this.fb.control(null)})}),this.speciesSubscription=this.getControl("livestockBaseInfoGroup.species").valueChanges.subscribe(i=>{const a=i;this.isCattleFieldsVisible=a===u.Ni2.Cattle,this.breedOptions=X(a);const l=this.getControl("livestockBaseInfoGroup.utilityType"),m=this.getControl("livestockBaseInfoGroup.lactationPhase");this.isCattleFieldsVisible?(l.setValidators(r.kI.required),m.setValidators(r.kI.required)):(l.setValue(null),m.setValue(null),l.clearValidators(),m.clearValidators()),l.updateValueAndValidity(),m.updateValueAndValidity(),this.getControl("livestockBaseInfoGroup.breed").setValue(null)});const e=this.getControl("livestockBaseInfoGroup.earTagNumber");this.earTagSubscription=e.valueChanges.subscribe(i=>{const a=O(i);a!==i&&e.setValue(a,{emitEvent:!1})}),this.syncWeightControlState(this.isEditMode)}onInitialDataChange(){this.onInitialDataChangeSub=this.initialData$.pipe((0,E.U)(e=>{if(e){this.formGroup.patchValue(e);const i=e.livestockBaseInfoGroup.species;this.isCattleFieldsVisible=i===u.Ni2.Cattle,this.breedOptions=X(i),this.syncWeightControlState(this.isEditMode)}})).subscribe()}syncWeightControlState(e){const i=this.getControl("livestockBaseInfoGroup.weight");this.isWeightEditable?e&&i.enable({emitEvent:!1}):i.disable({emitEvent:!1})}}return n.\u0275fac=function(e){return new(e||n)(t.Y36(r.qu))},n.\u0275cmp=t.Xpm({type:n,selectors:[["app-livestock-form"]],inputs:{data:"data",isEditMode:"isEditMode",isWeightEditable:"isWeightEditable"},outputs:{onAccept:"onAccept",navigateBack:"navigateBack",editModeChanged:"editModeChanged"},decls:16,vars:37,consts:[[3,"formGroup","isEditMode","formSubmitted","navigateBack","editModeChanged"],["formGroupName","livestockBaseInfoGroup",1,"row","form-group"],[1,"col-12","col-md-6",3,"inputControl","labelTranslateKey","options"],[1,"col-12","col-md-6",3,"inputControl","textMaskPattern","labelTranslateKey"],[1,"col-12","col-md-6",3,"inputControl","labelTranslateKey"],[1,"col-12",3,"rows","inputControl","labelTranslateKey"],["class","col-12 col-md-6",3,"inputControl","labelTranslateKey","options",4,"ngIf"]],template:function(e,i){1&e&&(t.TgZ(0,"lib-form",0),t.NdJ("formSubmitted",function(){return i.onAcceptClick()})("navigateBack",function(){return i.onNavigateBack()})("editModeChanged",function(l){return i.handleOnEditModeChange(l)}),t.TgZ(1,"div",1),t._UZ(2,"app-input-ng-select",2)(3,"app-input-ng-select",2)(4,"app-input-text",3)(5,"app-input-ng-select",2)(6,"app-input-datepicker",4)(7,"app-input-datepicker",4)(8,"app-input-text",4)(9,"app-input-number",4)(10,"app-input-text",4)(11,"app-input-text",3)(12,"app-input-text",3)(13,"a
1pp-input-textarea",5),t.YNc(14,At,1,3,"app-input-ng-select",6),t.YNc(15,_t,1,3,"app-input-ng-select",6),t.qZA()()),2&e&&(t.Akn("full"),t.Q6J("formGroup",i.formGroup)("isEditMode",i.isEditMode),t.xp6(2),t.Q6J("inputControl",i.getControl("livestockBaseInfoGroup.species"))("labelTranslateKey","LIVESTOCK.FORM.species")("options",i.speciesOptions),t.xp6(1),t.Q6J("inputControl",i.getControl("livestockBaseInfoGroup.breed"))("labelTranslateKey","LIVESTOCK.FORM.breed")("options",i.breedOptions),t.xp6(1),t.Q6J("inputControl",i.getControl("livestockBaseInfoGroup.earTagNumber"))("textMaskPattern",i.earTagMask)("labelTranslateKey","LIVESTOCK.FORM.earTagNumber"),t.xp6(1),t.Q6J("inputControl",i.getControl("livestockBaseInfoGroup.entryReason"))("labelTranslateKey","LIVESTOCK.FORM.entryReason")("options",i.entryReasonOptions),t.xp6(1),t.Q6J("inputControl",i.getControl("livestockBaseInfoGroup.arrivalDate"))("labelTranslateKey","LIVESTOCK.FORM.arrivalDate"),t.xp6(1),t.Q6J("inputControl",i.getControl("livestockBaseInfoGroup.birthDate"))("labelTranslateKey","LIVESTOCK.FORM.birthDate"),t.xp6(1),t.Q6J("inputControl",i.getControl("livestockBaseInfoGroup.name"))("labelTranslateKey","LIVESTOCK.FORM.name"),t.xp6(1),t.Q6J("inputControl",i.getControl("livestockBaseInfoGroup.weight"))("labelTranslateKey","LIVESTOCK.FORM.weightWithUnit"),t.xp6(1),t.Q6J("inputControl",i.getControl("livestockBaseInfoGroup.passportNumber"))("labelTranslateKey","LIVESTOCK.FORM.passportNumber"),t.xp6(1),t.Q6J("inputControl",i.getControl("livestockBaseInfoGroup.motherEarTagNumber"))("textMaskPattern",i.earTagMask)("labelTranslateKey","LIVESTOCK.FORM.motherEarTagNumber"),t.xp6(1),t.Q6J("inputControl",i.getControl("livestockBaseInfoGroup.bullEarTagNumber"))("textMaskPattern",i.earTagMask)("labelTranslateKey","LIVESTOCK.FORM.bullEarTagNumber"),t.xp6(1),t.Q6J("rows",6)("inputControl",i.getControl("livestockBaseInfoGroup.notes"))("labelTranslateKey","LIVESTOCK.FORM.notes"),t.xp6(1),t.Q6J("ngIf",i.isCattleFieldsVisible),t.xp6(1),t.Q6J("ngIf",i.isCattleFieldsVisible))},dependencies:[c.O5,r.JL,r.sg,r.x0,D.s,q.o,V.l,K.m,x.Q,R.U],encapsulation:2}),n})(),Dt=(()=>{class n{constructor(e,i,a,l){this.api=e,this.userContextService=i,this.router=a,this.spinnerService=l}ngOnInit(){this.initValue=U({})}add(e){this.spinnerService.display();const i=this.userContextService.currentOrganizationId,a=function Ct(n){const o=n.livestockBaseInfoGroup,e=(0,p.C2)(o.arrivalDate),i=(0,p.C2)(o.birthDate);return{species:o.species,breed:o.breed,earTagNumber:O(o.earTagNumber),entryReason:o.entryReason,arrivalDate:e?new Date(e):null,birthDate:i?new Date(i):null,name:o.name,weight:o.weight,passportNumber:o.passportNumber,motherEarTagNumber:o.motherEarTagNumber,bullEarTagNumber:o.bullEarTagNumber,notes:o.notes,utilityType:o.utilityType,lactationPhase:o.lactationPhase}}(e);this.api.create(i,a).pipe((0,d.x)(()=>{this.spinnerService.hide()})).subscribe(()=>this.navigateToList())}onAfterCancel(){this.navigateToList()}navigateToList(){this.router.navigate(["livestock"])}}return n.\u0275fac=function(e){return new(e||n)(t.Y36(u.g0W),t.Y36(v.o),t.Y36(f.F0),t.Y36(p.V))},n.\u0275cmp=t.Xpm({type:n,selectors:[["app-add-livestock"]],decls:3,vars:3,consts:[[3,"title","backBtnAction"],[3,"isEditMode","data","navigateBack","onAccept"]],template:function(e,i){1&e&&(t.TgZ(0,"app-title-with-back-btn",0),t.NdJ("backBtnAction",function(){return i.onAfterCancel()}),t.qZA(),t.TgZ(1,"lib-page-content")(2,"app-livestock-form",1),t.NdJ("navigateBack",function(){return i.onAfterCancel()})("onAccept",function(l){return i.add(l)}),t.qZA()()),2&e&&(t.Q6J("title","LIVESTOCK.add:header"),t.xp6(2),t.Q6J("isEditMode",!0)("data",i.initValue))},dependencies:[L.u,y.Y,j],encapsulation:2}),n})();var tt=s(60116),Ot=s(44874),N=s(18086),Nt=s(97329),Pt=s(57163);let Ft=(()=>{class n{constructor(e,i,a,l,m,k,A){this.route=e,this.router=i,this.confirmationModalService=a,this.contextService=l,this.api=m,this.userContextService=k,this.spinnerService=A,this.id=this.route.snapshot.paramMap.get("id"),this.tabPages=[{titleTranslationKey:"LIVESTOCK.TABS.information",routingPath:`${this.id}/info`},{titleTranslationKey:"LIVESTOCK.TABS.weightHistory",routingPath:`${this.id}/weights`},{titleTranslationKey:"LIVESTOCK.TABS.notes",routingPath:`${this.id}/notes`}]}
1ngOnInit(){this.contextService.fetchDetailsItem(this.id),this.livestockName$=this.contextService.currentLivestock$.pipe((0,tt.h)(e=>!!e),(0,E.U)(e=>e.earTagNumber),(0,C.b)(e=>{this.livestockName=e}),(0,Ot.O)(""))}ngOnDestroy(){this.contextService.clearDetailsItem()}onDelete(){this.confirmationModalService.open("LIVESTOCK.delete:confirmTitle","LIVESTOCK.delete:confirmText",[this.livestockName]).then(()=>{this.spinnerService.display(),this.api.delete(this.userContextService.currentOrganizationId,this.id).pipe((0,d.x)(()=>{this.spinnerService.hide()})).subscribe(()=>this.navigateBack())})}navigateBack(){this.router.navigate(["livestock"])}}return n.\u0275fac=function(e){return new(e||n)(t.Y36(f.gz),t.Y36(f.F0),t.Y36(N.k),t.Y36(S),t.Y36(u.g0W),t.Y36(v.o),t.Y36(p.V))},n.\u0275cmp=t.Xpm({type:n,selectors:[["app-livestock-details"]],decls:5,vars:8,consts:[[3,"title","subtitle","backBtnAction"],[3,"labelTranslationKey","onClick"],["routingBasePath","livestock",3,"pages"]],template:function(e,i){1&e&&(t.TgZ(0,"app-title-with-back-btn",0),t.NdJ("backBtnAction",function(){return i.navigateBack()}),t.ALo(1,"translate"),t.ALo(2,"async"),t.TgZ(3,"lib-danger-button",1),t.NdJ("onClick",function(){return i.onDelete()}),t.qZA()(),t._UZ(4,"lib-tabular-page",2)),2&e&&(t.Q6J("title",t.lcZ(1,4,"LIVESTOCK.details:header"))("subtitle",t.lcZ(2,6,i.livestockName$)),t.xp6(3),t.Q6J("labelTranslationKey","APPLICATION.FORM.delete"),t.xp6(1),t.Q6J("pages",i.tabPages))},dependencies:[L.u,Nt.d,Pt.o,c.Ov,I.X$],encapsulation:2,changeDetection:0}),n})();function Mt(n,o){if(1&n){const e=t.EpF();t.TgZ(0,"app-livestock-form",1),t.NdJ("navigateBack",function(){t.CHM(e);const a=t.oxw();return t.KtG(a.navigateBack())})("editModeChanged",function(a){t.CHM(e);const l=t.oxw();return t.KtG(l.onEditModeChanged(a))})("onAccept",function(a){t.CHM(e);const l=t.oxw();return t.KtG(l.onUpdate(a))}),t.qZA()}if(2&n){const e=t.oxw();t.Q6J("isEditMode",e.startFromIsEditing)("isWeightEditable",!1)("data",e.livestock)}}let et=(()=>{class n{constructor(e,i,a,l,m,k){this.route=e,this.router=i,this.api=a,this.contextService=l,this.userContextService=m,this.spinnerService=k}ngOnInit(){this.id=this.route.snapshot.parent.paramMap.get("id"),this.startFromIsEditing="edit"===this.route.snapshot.paramMap.get("action"),this.routeSubscription=this.contextService.currentLivestock$.pipe((0,tt.h)(e=>!!e)).subscribe(e=>{this.livestock=U(e)})}ngOnDestroy(){this.routeSubscription?.unsubscribe()}onUpdate(e){this.spinnerService.display();const i=function Tt(n){const o=n.livestockBaseInfoGroup,e=(0,p.C2)(o.arrivalDate),i=(0,p.C2)(o.birthDate);return{species:o.species,breed:o.breed,earTagNumber:O(o.earTagNumber),entryReason:o.entryReason,arrivalDate:e?new Date(e):null,birthDate:i?new Date(i):null,name:o.name,passportNumber:o.passportNumber,motherEarTagNumber:o.motherEarTagNumber,bullEarTagNumber:o.bullEarTagNumber,notes:o.notes,utilityType:o.utilityType,lactationPhase:o.lactationPhase}}(e);this.api.update(this.userContextService.currentOrganizationId,this.id,i).pipe((0,d.x)(()=>{this.spinnerService.hide()})).subscribe(()=>{this.contextService.fetchDetailsItem(this.id),this.navigateBack()})}navigateBack(){this.router.navigate(["livestock"])}onEditModeChanged(e){this.startFromIsEditing=e}}return n.\u0275fac=function(e){return new(e||n)(t.Y36(f.gz),t.Y36(f.F0),t.Y36(u.g0W),t.Y36(S),t.Y36(v.o),t.Y36(p.V))},n.\u0275cmp=t.Xpm({type:n,selectors:[["app-livestock-info"]],decls:1,vars:1,consts:[[3,"isEditMode","isWeightEditable","data","navigateBack","editModeChanged","onAccept",4,"ngIf"],[3,"isEditMode","isWeightEditable","data","navigateBack","editModeChanged","onAccept"]],template:function(e,i){1&e&&t.YNc(0,Mt,1,3,"app-livestock-form",0),2&e&&t.Q6J("ngIf",i.livestock)},dependencies:[c.O5,j],encapsulation:2}),n})();var it=s(18331),wt=s(17714),G=s(26562),P=s(32673),nt=s(72087),ot=s(65452),Kt=s(70698),xt=s(59091),Rt=s(11176);let Wt=(()=>{class n{constructor(e,i,a,l,m,k,A,Z,J){this.confirmationModalService=e,this.translateService=i,this.api=a,this.userContextService=l,this.spinnerService=m,this.ellipsisPipe=k,this.shortDatePipe=A,this.router=Z,this.formBuilder=J,this.speciesOptions=(0,p.DQ)(u.Ni2,"LIVESTOCK_SPECIES",!1),this.columns=[{key:"species",label:"LIVESTOCK.LIST.species",customContent:b=>this.translateService.instant("APPLICATION.DICTIONARIES.LIVESTOCK_SPECIES."+b.species.toLowerCase())},{key:"earTagNumber",label:"LIVESTOCK.LIST.earTagNumber"},{key:"name",label:"LIVESTOCK.LIST.name"},{key:"notes",label:"LIVESTOCK.LIST.description",formatter:this.ellipsisPipe,formatterOptions:60},{key:"weight",label:"LIVESTOCK.LIST.weight"},{key:"birthDate",label:"LIVESTOCK.LIST.birthDate",formatter:this.shortDatePipe}],this.onDeleteAction={action:b=>this.onDelete(b)},this.onEditAction={action:b=>this.onEdit(b)},this.onDetailsAction={action:b=>this.onDetails(b)},this.listRequestParameters$=new h.X({orderBy:[],page:1,pageSize:10,filter:[]}),this.refresh$=new h.X(null),this.formSubscriptions=new wt.w0,this.filterForm=this.formBuilder.group({species:new r.
1NI(null),earTagNumber:new r.NI(null),birthDateFrom:new r.NI(null,M.r.dayBeforeControlName("birthDateTo")),birthDateTo:new r.NI(null,M.r.dayAfterControlName("birthDateFrom")),weightFrom:new r.NI(null,(0,it.Y)("weightTo")),weightTo:new r.NI(null,(0,it.b)("weightFrom"))}),this.formSubscriptions.add(this.filterForm.controls.birthDateFrom.valueChanges.subscribe(()=>{this.filterForm.controls.birthDateTo.updateValueAndValidity({emitEvent:!1})})),this.formSubscriptions.add(this.filterForm.controls.birthDateTo.valueChanges.subscribe(()=>{this.filterForm.controls.birthDateFrom.updateValueAndValidity({emitEvent:!1})})),this.formSubscriptions.add(this.filterForm.controls.weightFrom.valueChanges.subscribe(()=>{this.filterForm.controls.weightTo.updateValueAndValidity({emitEvent:!1})})),this.formSubscriptions.add(this.filterForm.controls.weightTo.valueChanges.subscribe(()=>{this.filterForm.controls.weightFrom.updateValueAndValidity({emitEvent:!1})})),this.data$=(0,G.a)([this.listRequestParameters$,this.refresh$]).pipe((0,C.b)(()=>this.spinnerService.display()),(0,P.w)(([b])=>this.api.list(this.userContextService.currentOrganizationId,b).pipe((0,E.U)(_=>(this.dataPaginator=_.pager,_.items)),(0,d.x)(()=>{this.spinnerService.hide()}))))}getFormControl(e){return this.filterForm.controls[e]}onPaginationChange(e){this.listRequestParameters$.next({...this.listRequestParameters$.value,page:e.page,pageSize:e.pageSize})}onSortingChange(e){this.listRequestParameters$.next({...this.listRequestParameters$.value,orderBy:e.field?[e]:[]})}
1onFilter(){if(this.filterForm.invalid)return void this.filterForm.markAllAsTouched();const e=this.filterForm.getRawValue(),i=[];e.species&&i.push({field:"species",condition:"=",value:String(e.species)}),e.earTagNumber&&i.push({field:"earTagNumber",condition:"=*",value:e.earTagNumber}),e.birthDateFrom&&i.push({field:"birthDate",condition:">=",value:(0,p.C2)(e.birthDateFrom)}),e.birthDateTo&&i.push({field:"birthDate",condition:"<=",value:(0,p.C2)(e.birthDateTo,1)}),null!=e.weightFrom&&i.push({field:"weight",condition:">=",value:String(e.weightFrom)}),null!=e.weightTo&&i.push({field:"weight",condition:"<=",value:String(e.weightTo)}),this.listRequestParameters$.next({...this.listRequestParameters$.value,filter:i,page:1})}onAddClick(){return this.router.navigate(["livestock","add"])}ngOnDestroy(){this.formSubscriptions.unsubscribe()}onEdit(e){return this.router.navigate(["livestock",e.id,"info","edit"])}onDetails(e){return this.router.navigate(["livestock",e.id,"info"])}onDelete(e){this.confirmationModalService.open("LIVESTOCK.delete:confirmTitle","LIVESTOCK.delete:confirmText",[e.name??e.earTagNumber]).then(()=>{this.spinnerService.display(),this.api.delete(this.userContextService.currentOrganizationId,e.id).pipe((0,g.q)(1),(0,d.x)(()=>this.spinnerService.hide())).subscribe(()=>{this.refresh$.next(null)})})}}return n.\u0275fac=function(e){return new(e||n)(t.Y36(N.k),t.Y36(I.sK),t.Y36(u.g0W),t.Y36(v.o),t.Y36(p.V),t.Y36(nt.p),t.Y36(p.Mo),t.Y36(f.F0),t.Y36(r.qu))},n.\u0275cmp=t.Xpm({type:n,selectors:[["app-livestock-list"]],decls:12,vars:24,consts:[[3,"headerTranslationKey"],[3,"labelTranslationKey","onClick"],[3,"formGroup","search"],[1,"col-12","col-md-3",3,"inputControl","labelTranslateKey","options"],[1,"col-12","col-md-3",3,"inputControl","labelTranslateKey"],[3,"data","pager","columns","onDeleteAction","onEditAction","onDetailsAction","pagination","sorting"]],template:function(e,i){1&e&&(t.TgZ(0,"lib-title",0)(1,"lib-primary-button",1),t.NdJ("onClick",function(){return i.onAddClick()}),t.qZA()(),t.TgZ(2,"lib-page-content")(3,"lib-filters-container",2),t.NdJ("search",function(){return i.onFilter()}),t._UZ(4,"app-input-ng-select",3)(5,"app-input-text",4)(6,"app-input-datepicker",4)(7,"app-input-datepicker",4)(8,"app-input-number",4)(9,"app-input-number",4),t.qZA(),t.TgZ(10,"lib-generic-table",5),t.NdJ("pagination",function(l){return i.onPaginationChange(l)})("sorting",function(l){return i.onSortingChange(l)}),t.ALo(11,"async"),t.qZA()()),2&e&&(t.Q6J("headerTranslationKey","LIVESTOCK.list:header"),t.xp6(1),t.Q6J("labelTranslationKey","LIVESTOCK.add:button"),t.xp6(2),t.Q6J("formGroup",i.filterForm),t.xp6(1),t.Q6J("inputControl",i.getFormControl("species"))("labelTranslateKey","LIVESTOCK.FILTER.species")("options",i.speciesOptions),t.xp6(1),t.Q6J("inputControl",i.getFormControl("earTagNumber"))("labelTranslateKey","LIVESTOCK.FILTER.earTagNumber"),t.xp6(1),t.Q6J("inputControl",i.getFormControl("birthDateFrom"))("labelTranslateKey","LIVESTOCK.FILTER.birthDateFrom"),t.xp6(1),t.Q6J("inputControl",i.getFormControl("birthDateTo"))("labelTranslateKey","LIVESTOCK.FILTER.birthDateTo"),t.xp6(1),t.Q6J("inputControl",i.getFormControl("weightFrom"))("labelTranslateKey","LIVESTOCK.FILTER.weightFrom"),t.xp6(1),t.Q6J("inputControl",i.getFormControl("weightTo"))("labelTranslateKey","LIVESTOCK.FILTER.weightTo"),t.xp6(1),t.Q6J("data",t.lcZ(11,22,i.data$))("pager",i.dataPaginator)("columns",i.columns)("onDeleteAction",i.onDeleteAction)("onEditAction",i.onEditAction)("onDetailsAction",i.onDetailsAction))},dependencies:[r.JL,r.sg,D.s,q.o,V.l,K.m,ot.p,y.Y,Kt.E,xt.C,Rt.r,c.Ov],encapsulation:2}),n})();var at=s(36804),st=s(61064),Vt=s(47423),Gt=s(53466);let Zt=(()=>{class n{constructor(e,i,a,l,m){this.confirmationModalService=e,this.router=i,this.route=a,this.spinnerService=l,this.api=m,this.emptyStateDisplayModel={anyDataReturned:!1,filtersExists:!1,initialDataLoading:!0},this.listReload$=new h.X(!1),this.listRequestParameters$=new h.X({orderBy:[],page:1,pageSize:10,filter:[]}),this.livestockId=this.route.snapshot.parent.paramMap.get("id"),this.data$=this.getData()}onAdd(){this.router.navigate(["livestock","note","add"],{queryParams:{livestock:this.livestockId}})}onDelete(e){this.confirmationModalService.open("SUPPLIER.NOTE.delete:confirmTitle","SUPPLIER.NOTE.delete:confirmText",[e.title]).then(()=>{this.spinnerService.display(),this.api.delete(this.livestockId,e.id).pipe((0,w.P)(),(0,d.x)(()=>this.spinnerService.hide())).subscribe({complete:()=>{this.listReload$.next(!0)}})})}
1onDetails(e){this.router.navigate(["livestock","note",e.id,"details"],{queryParams:{livestock:this.livestockId}})}onEdit(e){this.router.navigate(["livestock","note",e.id,"edit"],{queryParams:{livestock:this.livestockId}})}onPageParameterChange(e){this.listRequestParameters$.next({...this.listRequestParameters$.value,...e.pageSize&&{pageSize:e.pageSize},...e.page&&{page:e.page}})}getData(){return(0,G.a)([this.listRequestParameters$,this.listReload$]).pipe((0,C.b)(()=>this.spinnerService.display()),(0,P.w)(([e])=>this.api.list(this.livestockId,e).pipe((0,C.b)(i=>{this.pager=i.pager,this.emptyStateDisplayModel={initialDataLoading:!1,filtersExists:0!==(e.filter?.length??0),anyDataReturned:i.items.length>0}}),(0,E.U)(i=>i.items.map(a=>B.mapToListItem(a))),(0,d.x)(()=>this.spinnerService.hide()))))}}return n.\u0275fac=function(e){return new(e||n)(t.Y36(N.k),t.Y36(f.F0),t.Y36(f.gz),t.Y36(p.V),t.Y36(u.ZeK))},n.\u0275cmp=t.Xpm({type:n,selectors:[["ng-component"]],decls:8,vars:14,consts:[["labelTranslationKey","SUPPLIER.NOTE.create:button",3,"onClick"],[1,"mt-3",3,"displayModel","title","subtitle","btnText","clicked"],[3,"pager","items","itemDetailClicked","itemDeletedClicked","itemEditedClicked","itemAddClicked","pageParameterChanged"]],template:function(e,i){1&e&&(t.TgZ(0,"lib-action-buttons-container")(1,"lib-action-button",0),t.NdJ("onClick",function(){return i.onAdd()}),t.qZA()(),t.TgZ(2,"app-empty-state",1),t.NdJ("clicked",function(){return i.onAdd()}),t.ALo(3,"translate"),t.ALo(4,"translate"),t.ALo(5,"translate"),t.TgZ(6,"lib-observation-list",2),t.NdJ("itemDetailClicked",function(l){return i.onDetails(l)})("itemDeletedClicked",function(l){return i.onDelete(l)})("itemEditedClicked",function(l){return i.onEdit(l)})("itemAddClicked",function(){return i.onAdd()})("pageParameterChanged",function(l){return i.onPageParameterChange(l)}),t.ALo(7,"async"),t.qZA()()),2&e&&(t.xp6(2),t.Q6J("displayModel",i.emptyStateDisplayModel)("title",t.lcZ(3,6,"SUPPLIER.NOTE.emptyStateTitle"))("subtitle",t.lcZ(4,8,"SUPPLIER.NOTE.emptyStateSubtitle"))("btnText",t.lcZ(5,10,"SUPPLIER.NOTE.create:button")),t.xp6(4),t.Q6J("pager",i.pager)("items",t.lcZ(7,12,i.data$)))},dependencies:[at.x,st._,Vt.s,Gt.Z,c.Ov,I.X$],encapsulation:2}),n})(),rt=(()=>{class n{constructor(e){this.formBuilder=e,this.isEditMode=!0,this.submitBtnTranslationKey="APPLICATION.FORM.save",this.onAccept=new t.vpe,this.navigateBack=new t.vpe,this.formGroup=this.formBuilder.group({measurementDate:new r.NI(null,r.kI.required),weight:new r.NI(null,[r.kI.required,r.kI.min(1),r.kI.max(4e3)]),notes:new r.NI(null,r.kI.maxLength(1e3))})}set data(e){e?this.formGroup.patchValue({measurementDate:(0,p.sm)(e.measurementDate.toISOString()),weight:e.weight,notes:e.notes??null}):this.formGroup.reset({measurementDate:null,weight:null,notes:null})}onSubmit(){this.onAccept.emit(this.formGroup.getRawValue())}onNavigateBack(){this.navigateBack.emit()}}return n.\u0275fac=function(e){return new(e||n)(t.Y36(r.qu))},n.\u0275cmp=t.Xpm({type:n,selectors:[["app-livestock-weight-form"]],inputs:{isEditMode:"isEditMode",submitBtnTranslationKey:"submitBtnTranslationKey",data:"data"},outputs:{onAccept:"onAccept",navigateBack:"navigateBack"},decls:5,vars:12,consts:[[3,"formGroup","isEditMode","submitBtnTranslationKey","formSubmitted","navigateBack"],[1,"row","form-group"],[1,"col-12","col-md-4",3,"inputControl","labelTranslateKey"],[1,"col-12",3,"rows","inputControl","labelTranslateKey"]],template:function(e,i){1&e&&(t.TgZ(0,"lib-form",0),t.NdJ("formSubmitted",function(){return i.onSubmit()})("navigateBack",function(){return i.onNavigateBack()}),t.TgZ(1,"div",1),t._UZ(2,"app-input-datepicker",2)(3,"app-input-number",2)(4,"app-input-textarea",3),t.qZA()()),2&e&&(t.Akn("full"),t.Q6J("formGroup",i.formGroup)("isEditMode",i.isEditMode)("submitBtnTranslationKey",i.submitBtnTranslationKey),t.xp6(2),t.Q6J("inputControl",i.formGroup.controls.measurementDate)("labelTranslateKey","LIVESTOCK.WEIGHT.measurementDate"),t.xp6(1),t.Q6J("inputControl",i.formGroup.controls.weight)("labelTranslateKey","LIVESTOCK.WEIGHT.weightWithUnit"),t.xp6(1),t.Q6J("rows",6)("inputControl",i.formGroup.controls.notes)("labelTranslateKey","LIVESTOCK.WEIGHT.notes"))},dependencies:[r.JL,r.sg,D.s,V.l,x.Q,R.U],encapsulation:2}),n})(),Jt=(()=>{class n{constructor(e,i,a,l,m,k){this.route=e,this.router=i,this.api=a,this.contextService=l,this.userContextService=m,this.spinnerService=k,this.livestockId=this.route.
1snapshot.paramMap.get("id")}onSubmit(e){this.spinnerService.display(),this.api.create(this.userContextService.currentOrganizationId,this.livestockId,{measurementDate:new Date((0,p.C2)(e.measurementDate)),weight:e.weight,notes:e.notes}).pipe((0,g.q)(1),(0,d.x)(()=>{this.spinnerService.hide()})).subscribe(()=>{this.contextService.fetchDetailsItem(this.livestockId),this.navigateBack()})}navigateBack(){this.router.navigate(["livestock",this.livestockId,"weights"])}}return n.\u0275fac=function(e){return new(e||n)(t.Y36(f.gz),t.Y36(f.F0),t.Y36(u.B8g),t.Y36(S),t.Y36(v.o),t.Y36(p.V))},n.\u0275cmp=t.Xpm({type:n,selectors:[["app-livestock-weight-add"]],decls:4,vars:5,consts:[[3,"title","backBtnAction"],[3,"isEditMode","submitBtnTranslationKey","onAccept","navigateBack"]],template:function(e,i){1&e&&(t.TgZ(0,"app-title-with-back-btn",0),t.NdJ("backBtnAction",function(){return i.navigateBack()}),t.ALo(1,"translate"),t.qZA(),t.TgZ(2,"lib-page-content")(3,"app-livestock-weight-form",1),t.NdJ("onAccept",function(l){return i.onSubmit(l)})("navigateBack",function(){return i.navigateBack()}),t.qZA()()),2&e&&(t.Q6J("title",t.lcZ(1,3,"LIVESTOCK.WEIGHT.add:header")),t.xp6(3),t.Q6J("isEditMode",!0)("submitBtnTranslationKey","LIVESTOCK.WEIGHT.add:button"))},dependencies:[L.u,y.Y,rt,I.X$],encapsulation:2}),n})(),Yt=(()=>{class n{constructor(e,i,a,l,m,k){this.route=e,this.router=i,this.api=a,this.contextService=l,this.userContextService=m,this.spinnerService=k,this.data=null}ngOnInit(){this.livestockId=this.route.snapshot.paramMap.get("id"),this.weightId=this.route.snapshot.paramMap.get("weightId"),this.spinnerService.display(),this.api.get(this.userContextService.currentOrganizationId,this.livestockId,this.weightId).pipe((0,g.q)(1),(0,d.x)(()=>{this.spinnerService.hide()})).subscribe(e=>{this.data=e})}onSubmit(e){this.spinnerService.display(),this.api.update(this.userContextService.currentOrganizationId,this.livestockId,this.weightId,{measurementDate:new Date((0,p.C2)(e.measurementDate)),weight:e.weight,notes:e.notes}).pipe((0,g.q)(1),(0,d.x)(()=>{this.spinnerService.hide()})).subscribe(()=>{this.contextService.fetchDetailsItem(this.livestockId),this.navigateBack()})}navigateBack(){this.router.navigate(["livestock",this.livestockId,"weights"])}}return n.\u0275fac=function(e){return new(e||n)(t.Y36(f.gz),t.Y36(f.F0),t.Y36(u.B8g),t.Y36(S),t.Y36(v.o),t.Y36(p.V))},n.\u0275cmp=t.Xpm({type:n,selectors:[["app-livestock-weight-edit"]],decls:4,vars:6,consts:[[3,"title","backBtnAction"],[3,"isEditMode","submitBtnTranslationKey","data","onAccept","navigateBack"]],template:function(e,i){1&e&&(t.TgZ(0,"app-title-with-back-btn",0),t.NdJ("backBtnAction",function(){return i.navigateBack()}),t.ALo(1,"translate"),t.qZA(),t.TgZ(2,"lib-page-content")(3,"app-livestock-weight-form",1),t.NdJ("onAccept",function(l){return i.onSubmit(l)})("navigateBack",function(){return i.navigateBack()}),t.qZA()()),2&e&&(t.Q6J("title",t.lcZ(1,4,"LIVESTOCK.WEIGHT.edit:header")),t.xp6(3),t.Q6J("isEditMode",!0)("submitBtnTranslationKey","APPLICATION.FORM.save")("data",i.data))},dependencies:[L.u,y.Y,rt,I.X$],encapsulation:2}),n})();var lt=s(89196),Ht=s(50253),Qt=s(68951);function zt(n,o){if(1&n&&(t.ynx(0),t._UZ(1,"div",1),t.BQk()),2&n){const e=t.oxw();
1t.xp6(1),t.Q6J("options",e.chartOption)}}let Ut=(()=>{class n{constructor(e,i,a){this.translateService=e,this.shortDatePipe=i,this.changeDetectorRef=a,this.data=[],this.chartOption=null,this.destroy$=new Ht.x}ngOnInit(){this.translateService.onLangChange.pipe((0,Qt.R)(this.destroy$)).subscribe(()=>{this.prepareChart(),this.changeDetectorRef.markForCheck()})}ngOnChanges(e){e.data&&this.prepareChart()}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}prepareChart(){const e=this.data??[];if(0===e.length)return void(this.chartOption=null);const i=this.translateService.instant("LIVESTOCK.WEIGHT.weightWithUnit");this.chartOption={color:["#37aa32"],tooltip:{trigger:"axis"},grid:{left:72,right:32,top:52,bottom:52,containLabel:!0},xAxis:{type:"category",boundaryGap:!1,axisLabel:{rotate:30,margin:12},data:e.map(a=>this.shortDatePipe.transform(a.measurementDate))},yAxis:{type:"value",name:i,nameGap:24,nameTextStyle:{padding:[0,0,12,0]}},series:[{name:i,type:"line",smooth:!0,symbolSize:8,data:e.map(a=>a.weight??0),areaStyle:{opacity:.12}}]}}}return n.\u0275fac=function(e){return new(e||n)(t.Y36(I.sK),t.Y36(p.Mo),t.Y36(t.sBO))},n.\u0275cmp=t.Xpm({type:n,selectors:[["app-livestock-weight-chart"]],inputs:{data:"data"},features:[t.TTD],decls:1,vars:1,consts:[[4,"ngIf"],["echarts","",1,"livestock-weight-chart",3,"options"]],template:function(e,i){1&e&&t.YNc(0,zt,2,1,"ng-container",0),2&e&&t.Q6J("ngIf",i.chartOption)},dependencies:[c.O5,Y._w],styles:[".livestock-weight-chart[_ngcontent-%COMP%]{height:400px;width:100%}"],changeDetection:0}),n})();const $t=[{path:"",component:(()=>{class n{}return n.\u0275fac=function(e){return new(e||n)},n.\u0275cmp=t.Xpm({type:n,selectors:[["app-livestock"]],decls:1,vars:0,template:function(e,i){1&e&&t._UZ(0,"router-outlet")},dependencies:[f.lC],encapsulation:2}),n})(),children:[{path:"",pathMatch:"full",redirectTo:"list"},{path:"list",component:Wt},{path:"add",component:Dt},{path:"note/add",component:z},{path:"note/:id/:action",component:z},{path:":id/weights/add",component:Jt},{path:":id/weights/:weightId/edit",component:Yt},{path:":id",component:Ft,children:[{path:"",pathMatch:"full",redirectTo:"info"},{path:"info",component:et},{path:"info/:action",component:et},{path:"weights",component:(()=>{class n{constructor(e,i,a,l,m,k,A,Z,J){this.route=e,this.router=i,this.api=a,this.contextService=l,this.userContextService=m,this.spinnerService=k,this.ellipsisPipe=A,this.shortDatePipe=Z,this.confirmationModalService=J,this.columns=[{key:"measurementDate",label:"LIVESTOCK.WEIGHT.measurementDate",formatter:this.shortDatePipe},{key:"weight",label:"LIVESTOCK.WEIGHT.weightWithUnit"},{key:"notes",label:"LIVESTOCK.WEIGHT.notes",formatter:this.ellipsisPipe,formatterOptions:60}],this.onEditAction={action:b=>this.onEdit(b)},this.onDeleteAction={action:b=>this.onDelete(b)},this.refresh$=new h.X(null),this.listRequestParameters$=new h.X({orderBy:[{field:"measurementDate",sortOrder:"desc"}],page:1,pageSize:10,filter:[]}),this.livestockId=this.route.snapshot.parent.paramMap.get("id"),this.chartData$=this.refresh$.pipe((0,P.w)(()=>this.api.chart(this.userContextService.currentOrganizationId,this.livestockId)),(0,lt.d)(1)),this.data$=(0,G.a)([this.listRequestParameters$,this.refresh$]).pipe((0,C.b)(()=>this.spinnerService.display()),(0,P.w)(([b])=>this.api.list(this.userContextService.currentOrganizationId,this.livestockId,b).pipe((0,E.U)(_=>(this.dataPaginator=_.pager,_.items)),(0,d.x)(()=>{this.spinnerService.hide()}))),(0,lt.d)(1))}onAddNew(){this.router.navigate(["livestock",this.livestockId,"weights","add"])}onPaginationChange(e){this.listRequestParameters$.next({...this.listRequestParameters$.value,page:e.page,pageSize:e.pageSize})}onSortingChange(e){this.listRequestParameters$.next({...this.listRequestParameters$.value,orderBy:e.field?[e]:[]})}onEdit(e){this.router.navigate(["livestock",this.livestockId,"weights",e.id,"edit"])}onDelete(e){this.confirmationModalService.open("LIVESTOCK.WEIGHT.delete:confirmTitle","LIVESTOCK.WEIGHT.delete:confirmText",[this.shortDatePipe.transform(e.measurementDate),String(e.weight)]).then(()=>{this.spinnerService.display(),this.api.delete(this.userContextService.currentOrganizationId,this.livestockId,e.id).pipe((0,g.q)(1),(0,d.x)(()=>{this.spinnerService.hide()})).subscribe(()=>{this.contextService.fetchDetailsItem(this.livestockId),this.refresh$.next(null)})})}}return n.\u0275fac=function(e){return new(e||n)(t.Y36(f.gz),t.Y36(f.F0),t.Y36(u.B8g),t.Y36(S),t.Y36(v.o),t.Y36(p.V),t.Y36(nt.p),t.Y36(p.Mo),t.Y36(N.k))},n.\u0275cmp=t.Xpm({type:n,selectors:[["app-livestock-weight-history"]],decls:6,vars:10,consts:[["labelTranslationKey","LIVESTOCK.WEIGHT.add:button",3,"onClick"],[1,"d-block","mb-4",3,"data"],[3,"columns","data","pager","onEditAction","onDeleteAction","sorting","pagination"]],template:function(e,i){1&e&&(t.TgZ(0,"lib-action-buttons-container")(1,"lib-action-button",0),t.NdJ("onClick",function(){return i.onAddNew()}),t.qZA()(),t._UZ(2,"app-livestock-weight-chart",1),t.ALo(3,"async"),t.TgZ(4,"lib-generic-table",2),t.NdJ("sorting",function(l){return i.onSortingChange(l)})("pagination",function(l){return i.onPaginationChange(l)}),t.ALo(5,"async"),t.qZA()),2&e&&(t.xp6(2),t.Q6J("data",t.lcZ(3,6,i.chartData$)),t.xp6(2),t.Q6J("columns",i.columns)("data",t.lcZ(5,8,i.data$))("pager",i.dataPaginator)("onEditAction",i.onEditAction)("onDeleteAction",i.onDeleteAction))},dependencies:[ot.p,at.x,st._,Ut,c.Ov],encapsulation:2}),n})()},{path:"notes",component:Zt}]}]}];let Xt=(()=>{class n{}return n.\u0275fac=function(e){return new(e||n)},n.\u0275mod=t.oAB({type:n}),n.\u0275inj=t.cJS({imports:[f.Bz.forChild($t),f.Bz]}),n})(),qt=(()=>{class n{}return n.\u0275fac=function(e){return new(e||n)},n.\u0275mod=t.oAB({type:n}),n.\u0275inj=t.cJS({providers:[S,p.Mo],imports:[c.ez,r.UX,p.qw,p.Fm,ct.T,Y.Ns.forRoot({echarts:{init:mt.S1}}
1),u.tnv,u.JCY,u.zZ0,Xt,L.m,pt.G,ut.x,ht.N,dt.P]}),n})()},59091:(F,T,s)=>{s.d(T,{C:()=>C});var c=s(22560),r=s(94666),u=s(64344);function h(d,t){if(1&d&&c._UZ(0,"i"),2&d){const v=c.oxw(2);c.Tol(v.icon)}}function g(d,t){if(1&d){const v=c.EpF();c.TgZ(0,"button",1),c.NdJ("click",function(){c.CHM(v);const S=c.oxw();return c.KtG(S.click())}),c._uU(1),c.ALo(2,"translate"),c.YNc(3,h,1,3,"i",2),c.qZA()}if(2&d){const v=c.oxw();c.xp6(1),c.hij(" ",c.lcZ(2,2,v.labelTranslationKey)," "),c.xp6(2),c.Q6J("ngIf",v.icon)}}let C=(()=>{class d{constructor(){this.icon="ph ph-plus",this.isVisible=!0,this.onClick=new c.vpe}click(){this.onClick.emit()}}return d.\u0275fac=function(v){return new(v||d)},d.\u0275cmp=c.Xpm({type:d,selectors:[["lib-primary-button"]],inputs:{labelTranslationKey:"labelTranslationKey",icon:"icon",isVisible:"isVisible"},outputs:{onClick:"onClick"},decls:1,vars:1,consts:[["class","btn btn-primary","type","button",3,"click",4,"ngIf"],["type","button",1,"btn","btn-primary",3,"click"],[3,"class",4,"ngIf"]],template:function(v,p){1&v&&c.YNc(0,g,4,4,"button",0),2&v&&c.Q6J("ngIf",p.isVisible)},dependencies:[r.O5,u.X$],encapsulation:2}),d})()},90538:(F,T,s)=>{s.d(T,{Y:()=>u});var c=s(22560);const r=["*"];let u=(()=>{class h{}return h.\u0275fac=function(C){return new(C||h)},h.\u0275cmp=c.Xpm({type:h,selectors:[["lib-page-content"]],ngContentSelectors:r,decls:4,vars:0,consts:[[1,"card"],[1,"card-content"],[1,"card-body"]],template:function(C,d){1&C&&(c.F$t(),c.TgZ(0,"div",0)(1,"div",1)(2,"div",2),c.Hsn(3),c.qZA()()())},encapsulation:2}),h})()},18331:(F,T,s)=>{function c(u){return h=>{if(!h.parent)return null;const g=h.parent.get(u);return g&&null!==h.value&&null!==g.value&&h.value<g.value?{hasToBeHigherOrEqualThan:{value:g.value}}:null}}function r(u){return h=>{if(!h.parent)return null;const g=h.parent.get(u);return g&&null!==h.value&&null!==g.value&&h.value>g.value?{hasToBeLessOrEqualThan:{value:g.value}}:null}}s.d(T,{Y:()=>r,b:()=>c})}}]); 2//# sourceMappingURL=projects_farm-portal_src_app_modules_livestock_livestock_module_ts.a375336890a3dfa9.js.map
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.