1"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[6752],{6752:(Y,D,a)=>{a.r(D),a.d(D,{TourneeManageProductsPageModule:()=>b});var k=a(6895),U=a(9436),v=a(12),_=a(4006),E=a(5230),A=a(6512),R=a(5503),M=a(5861),P=a(4641),L=a.n(P),Z=a(8493),t=a(5698),n=a(8060),s=a(1334),d=a(8901),c=a(5798),e=a(4650),i=a(958),g=a(7020),f=a(9244),m=a(3224),l=a(39),S=a(5883);function y(u,O){if(1&u){const T=e.EpF();e.TgZ(0,"ion-icon",12),e.NdJ("click",function(){e.CHM(T);const r=e.oxw();return e.KtG(r.onSwitchFiltering(!0))}),e.qZA()}}function $(u,O){if(1&u){const T=e.EpF();e.TgZ(0,"ion-icon",13),e.NdJ("click",function(){e.CHM(T);const r=e.oxw();return e.KtG(r.onSwitchFiltering(!1))}),e.qZA()}}L().vfs=Z.I.vfs;const j=[{path:"",component:(()=>{var u;class O{constructor(o,r,p,h,C,B,K,w,x,z,Q,J){this.navCtrl=o,this.route=r,this.auth=p,this.dataService=h,this.alertCtrl=C,this.modalCtrl=B,this.externalService=K,this.toastCtrl=w,this.popoverCtrl=x,this.fileService=z,this.mathService=Q,this.productService=J,this.tournee={},this.debug="none",this.showOnlyOrdered=!1,this.products=[],this.productsDisplayed=[],this.canEdit=!1,this.canAdministrate=!1,this.preparationDisplayed=!1,this.sortingTypeExclusions=[],this.orders=[],this.ordersByStatus=[],this.zoom=2,this.canStartTourneeStatuses=["open","full","distributing","prepared"],this.notDeliveredOrderStatuses=["created","acknowledged","accepted","prepared"],this.orderCount=0,this.printing=!1,this.statusToColor={draft:"tertiary",open:"secondary",full:"primary",prepared:"primary",distributing:"primary",delivered:"primary",cancelled:"primary",closed:"primary",unpaid:"danger",paid:"success",cashedIn:"success",rejected:"medium",canceled:"medium"},this.route.data.subscribe(F=>{this.debug=r.snapshot.queryParams.debug,F.tournee.producer=F.producer,this.tournee=F.tournee,this.productCatalog=F.products,this.tournee.products||(this.tournee.products={references:{},freeText:""}),"custom"==this.tournee.details.productMode&&!this.tournee.products.references&&(this.tournee.products.references={}),this.dataService.getProducerTourneeProductsOrdered(F.producer.key,F.tournee.key).pipe((0,t.q)(1)).subscribe(W=>{if(W)for(const I of W)this.tournee.orders[I.key]?I.products&&(this.tournee.orders[I.key].products=I.products):console.log("missing order",I.key);this.computeValues(!0,!0,!0)}),this.canEdit=!0,console.log(this.tournee)})}ngOnInit(){}ionViewWillLeave(){this.modal&&this.modal.dismiss()}presentToast(o){var r=this;return(0,M.Z)(function*(){(yield r.toastCtrl.create({message:o,duration:15e3,buttons:[{side:"end",icon:"close-circle-outline",role:"cancel",handler:()=>{console.log("dismiss toast")}}],position:"bottom"})).present()})()}computeValues(o,r,p,h){if("free"!==this.tournee.details.productMode&&r&&(this.products=this.tournee.products?this.productService.transformProductsToArray(this.tournee,"included",this.sortingTypeExclusions):[],this.filterProducts()),"full"===this.tournee.status){const C={open:0,rejected:0,prepared:0,delivered:0};Object.keys(this.tournee.orders);for(const[K,w]of Object.entries(this.tournee.orders))C[w.status]+=1}}closeToast(){typeof this.toastCtrl<"u"&&this.toastCtrl.dismiss()}goHome(){this.navCtrl.navigateBack("/producer/"+this.tournee.producer.key)}updateStatusTotals(o,r){this.updateStatusTotal(o),this.updateStatusTotal(r)}updateStatusTotal(o){const r=this.ordersByStatus.findIndex(p=>p.name==o);this.ordersByStatus[r].finances=this.mathService.calculateTourneeRevenue2({orders:this.ordersByStatus[r].array,details:this.tournee.details},!0).finances}changeProductStatus(o,r,p){return(0,M.Z)(function*(){r.status=p})()}logError(o){console.error("Error: "+o)}onProductStatusChanged(o){this.dataService.updateTourneeProduct(this.tournee,o),this.tournee.products.references[o.key]=o}onProductClicked(o){this.navCtrl.navigateForward("/producer/"+this.tournee.producer.key+"/sale/"+this.tournee.key+"/product/"+o.key)}onProductPriceUpdated(o){this.dataService.updateTourneeProduct(this.tournee,o),this.tournee.products.references[o.key]=o}onProductIconUpdated(o){this.dataService.updateTourneeProduct(this.tournee,o),this.tournee.products.references[o.key]=o}onProductStockUpdated(o){console.log(this.tournee.products.references[o.key]),this.tournee.products.references[o.key]=o}onProductAddClicked(){var o=this;return(0,M.Z)(function*(){const r=o.productService.identifyIncludedProducts(o.productCatalog,o.tournee).filter(p=>"notIncluded"==p.status).sort(o.productService.sortProduct(o.sortingTypeExclusions));return console.log(r),o.modal=yield o.modalCtrl.create({component:n.o,cssClass:"modal",componentProps:{items:r,showButtons:!0,mode:"sale",onCancel:()=>{o.modal.dismiss()},onValidate:()=>{o.updateProducts(r),o.modal.dismiss()}}}),yield o.modal.present()})()}updateProducts(o){var r=this;console.log("updateProducts",o),o.filter(h=>
1"included"==h.status).forEach(function(){var h=(0,M.Z)(function*(C){r.tournee.products.references[C.key]=C,yield r.dataService.updateTourneeProduct(r.tournee,C)});return function(C){return h.apply(this,arguments)}}()),this.products=this.productService.transformProductsToArray(this.tournee,"included"),this.filterProducts()}onSwitchFiltering(o){var r=this;return(0,M.Z)(function*(){r.showOnlyOrdered=o,r.filterProducts(),yield r.dataService.setUserConfig(r.tournee.producer.key,"showOnlyOrdered",o)})()}filterProducts(){this.productsDisplayed=this.showOnlyOrdered?this.products.filter(o=>o.basket&&o.basket.quantity>0):[...this.products]}}return(u=O).\u0275fac=function(o){return new(o||u)(e.Y36(i.SH),e.Y36(U.gz),e.Y36(g.$),e.Y36(f.D),e.Y36(v.Br),e.Y36(v.IN),e.Y36(s.l),e.Y36(v.yF),e.Y36(v.Dh),e.Y36(m.I),e.Y36(d.n),e.Y36(c.M))},u.\u0275cmp=e.Xpm({type:u,selectors:[["app-tournee-manage-products"]],decls:18,vars:10,consts:[["helpLink","saleManage"],[1,"main"],[1,"inner"],[1,"center"],["mode","producer",3,"tournee"],[1,"section"],[1,"title"],[1,"icons"],["slot","start","name","folder-open-outline",2,"visibility","hidden"],["slot","end","name","funnel-outline","class","pointer",3,"click",4,"ngIf"],["slot","end","name","infinite-outline","class","pointer",3,"click",4,"ngIf"],["mode","prepare","showSizings","true",3,"items","canEdit","tournee","showAdd","clicked","addClicked","priceUpdated","stockUpdated","statusChanged","iconUpdated"],["slot","end","name","funnel-outline",1,"pointer",3,"click"],["slot","end","name","infinite-outline",1,"pointer",3,"click"]],template:function(o,r){1&o&&(e._UZ(0,"info-header",0),e.TgZ(1,"ion-content")(2,"div",1)(3,"div",2)(4,"div",3),e._UZ(5,"sale-header",4),e.TgZ(6,"div",5)(7,"div",6)(8,"div",7),e._UZ(9,"ion-icon",8)(10,"ion-icon",8),e.qZA(),e.TgZ(11,"h2"),e._uU(12),e.ALo(13,"translate"),e.qZA(),e.TgZ(14,"div",7),e.YNc(15,y,1,0,"ion-icon",9),e.YNc(16,$,1,0,"ion-icon",10),e.qZA()(),e.TgZ(17,"products-list",11),e.NdJ("clicked",function(h){return r.onProductClicked(h)})("addClicked",function(){return r.onProductAddClicked()})("priceUpdated",function(h){return r.onProductPriceUpdated(h)})("stockUpdated",function(h){return r.onProductStockUpdated(h)})("statusChanged",function(h){return r.onProductStatusChanged(h)})("iconUpdated",function(h){return r.onProductIconUpdated(h)}),e.qZA()()()()()()),2&o&&(e.xp6(5),e.Q6J("tournee",r.tournee),e.xp6(7),e.Oqu(e.l
1cZ(13,8,"tournee.YourProductsOnSale")),e.xp6(3),e.Q6J("ngIf",!r.showOnlyOrdered),e.xp6(1),e.Q6J("ngIf",r.showOnlyOrdered),e.xp6(1),e.Q6J("items",r.productsDisplayed)("canEdit","closed"!==r.tournee.status)("tournee",r.tournee)("showAdd",("open"==r.tournee.status||"draft"==r.tournee.status)&&r.productCatalog.length>r.products.length))},dependencies:[k.O5,v.W2,v.gu,l.O,n.o,S.q,E.X$],styles:["sale-header[_ngcontent-%COMP%]{width:100%}products-list[_ngcontent-%COMP%]{width:100%}.title[_ngcontent-%COMP%]{display:flex;width:100%;flex-direction:row;justify-content:space-between;align-items:center}.title[_ngcontent-%COMP%] h2[_ngcontent-%COMP%]{text-align:center}.icons[_ngcontent-%COMP%]{display:flex;flex-direction:row;gap:8px}"]}),O})()}];let b=(()=>{var u;class O{}return(u=O).\u0275fac=function(o){return new(o||u)},u.\u0275mod=e.oAB({type:u}),u.\u0275inj=e.cJS({providers:[k.H9],imports:[k.ez,_.u5,_.UX,E.aw.forChild(),v.Pc,R.D,A.K,U.Bz.forChild(j)]}),O})()},1334:(Y,D,a)=>{a.d(D,{l:()=>M});var k=a(5861),U=a(3905),v=a(4004),_=a(2340),E=a(4650),A=a(958),R=a(529);let M=(()=>{var P;class L{constructor(t,n){this.platform=t,this.http=n}init(){}getPlace(t,n){return encodeURI("https://www.google.com/maps/search/?api=1&query="+t+"+"+n)}calculateBestRoute(t){return(0,U.z)(this.http.post("https://api.routexl.com/",t).pipe((0,v.U)(d=>this.transformRouteXL(d))))}showRoute(t,n){let s="";return"ios"===this.platform.platforms[2]?(s="http://maps.apple.com/?",s+=null==n?"saddr="+n:"",s+="&daddr="+t+"&dirflg=d"):(s="https://www.google.com/maps/dir/?api=1",s+=null!=n?"&origin="+n:"",s+="&destination="+t+"&travelmode=driving"),encodeURI(s)}showAddress(t){let n="";return n="ios"===this.platform.platforms[2]?"http://maps.apple.com/?q="+t:"https://www.google.com/maps/search/?api=1&query="+t,encodeURI(n)}openExternalMap(t){var n,s,d,c,e,i;window.open(this.showAddress((null===(n=t.details)||void 0===n||null===(s=n.geocoding)||void 0===s?void 0:s.label)||(null===(d=t.geocoding)||void 0===d?void 0:d.label)||(null===(c=t.details)||void 0===c||null===(e=c.dates[0])||void 0===e||null===(i=e.geocoding)||void 0===i?void 0:i.label)),"_blank")}geocodeLocation(t,n,s,d,c,e,i){return"locationIQ"==i?this.geocodeLocationWithLocationIQ(t,n,s,d,c,e):this.geocodeLocationWithHere(t,n,s,d,c,e)}geocodeLocationWithLocationIQ(t,n,s,d,c,e){let i="https://eu1.locationiq.com/v1/search.php?key="+_.CA.apiKey;return i+=null!==t?"&q="+t:"",i+=null!==n?"&country="+n:"",i+=null!==s?"&city="+s:"",i+=null!==d?"&postalCode="+d:"",i+=null!==c?"&street="+c:"",i+="&format=json",console.log(i),(0,U.z)(this.http.get(i).pipe((0,v.U)(f=>this.transformLocationIQResponse(f))))}geocodeLocationWithHere(t,n,s,d,c,e){const i={};if(null!==t)i.q=t,n&&(i.in="countryCode:"+n);else{let l="";l+=null!=n?";country="+n:"",l+=null!=s?";city="+s:"",l+=null!=d?";postalCode="+d:"",l+=null!=c?";street="+c:"",l+=null!==e&&"0"!==e&&void 0!==e?";houseNumber="+e:"",l=l.slice(1),i.qq=l}const m=new H.service.Platform({apikey:_.dW.apiKey}).getSearchService();return new Promise((l,S)=>{m.geocode(i,y=>{y.items.length>0?l(y.items.map(this.transformHereResponse)):S({message:"no results found",code:204})},y=>{S(y)})})}autoCompleteWithHere(t){const n={};n.q=t;const d=new H.service.Platform({apikey:_.dW.apiKey});console.log(n);const c=d.getSearchService();return new Promise((e,i)=>{c.autocomplete(n,g=>{console.log(g),g.items.length>0?e(g.items.map(this.transformHereResponse)):i({message:"no results found",code:204})},g=>{i(g)})})}transformLocationIQResponse(t){return console.log(t[0]),t[0]}transformOpenStreetMapResponse(t){const n=t[0];return"https://map.openseamap.org/?zoom=18&lat="+parseFloat(n.lat).toFixed(5)+"&lon="+parseFloat(n.lon).toFixed(5)+"&layers=BFTFFFFFFTF0FFFFFFFFFF"}transformRouteXL(t){return console.log(t),t}transformHereResponse(t){return{label:t.address.label,source:"Here",relevance:t.scoring.queryScore||null,locationType:t.localityType||null,resultType:t.resultType,locationID:t.id,latitude:t.position.lat,longitude:t.position.lng,address:{name:"place"==t.resultType&&t.title?t.title:null,country:t.address.countryName||null,countryCode:t.address.countryCode||null,state:t.address.state||null,county:t.address.county||null,city:t.address.city||null,postalCode:t.address.postalCode||null,street:t.address.street||null,houseNumber:t.address.houseNumber||null}}}calculateRoute(t){var n=this;return(0,k.Z)(function*(){const s=[],d={name:t.producer.details.shortDetails.name,address:t.producer.details.geocoding.label,lat:t.producer.details.geocoding.latitude,lng:t.producer.details.geocoding.longitude};s.push(d);for(const[g,f]of Object.entries(t.orders))s.push({name:f.consumer.details.fullDetails.firstname+f.consumer.details.fullDetails.lastname,address:f.consumer.details.geocoding.label,lat:f.consumer.details.geocoding.latitude,lng:f.consumer.details.geocoding.longitude,servicetime:5});s.push(d);
1const c=yield n.calculateBestRoute(s);let e=[];for(const[g,f]of Object.entries(c))for(const[m,l]of Object.entries(t.orders))if(l.details.address.geocoding.label==f.name){let S={key:m,...l},y={order:S,step:g,arrival:f.arrival,distance:f.distance};f.order=S,e.push(y)}return console.log({totalDistanceKm:0,steps:e},e,c),t.route})()}}return(P=L).\u0275fac=function(t){return new(t||P)(E.LFG(A.t4),E.LFG(R.eN))},P.\u0275prov=E.Yz7({token:P,factory:P.\u0275fac,providedIn:"root"}),L})()}}]);
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.