1import"./chunk-s0wiiGIr.js";import"./chunk-B7GYYPiL.js";import{Cn as fh,Dt as Vr,E as Gh,F as Hh,G as Lu,Hn as ku,Kt as ZI,M as HT,Or as sl,Qr as zD,Qt as aT,S as GD,Zt as _g,at as QD,c as Bh,g as EE,gn as eT,kt as WD,m as Dh,nn as aw,qn as lw,ut as Ri,vt as UD,x as Fg}from"./chunk-hDFLhPjY.js";import"./chunk-FC6QOr9W.js";import"./chunk-CliYzLcJ.js";import"./chunk-CcZ3toaq.js";import"./chunk-rZVfv4j_.js";import"./chunk-zDu33c0T.js";import"./chunk-CvaPAsOr.js";import"./chunk-BVtY32wR.js";import"./chunk-CABSGZFi.js";import"./chunk-DD_7l2Gm.js";import{Bn as xD,Bt as b5,C as ED,Dt as Xy,F as JE,Lt as a5,_t as Uh,b as DE,m as CE,un as lI}from"./chunk-DvgwK5vQ.js";import{a as nt}from"./chunk-OfVixYYr.js";import"./chunk-CCKOTdxL.js";import{b as Ue,o as Bt}from"./main-N5A2UYE4.js";import"./chunk-CUE-5jAO.js";import{L as z,h as X,r as Be,v as Ze,z as H}from"./chunk-C5uwmGBb.js";import{r as X$1}from"./chunk-DANXAhNr.js";import"./chunk-ApEGa6EG.js";import"./chunk-CJbVWNpS.js";import"./chunk-Cf0m4eJf.js";import{n as w}from"./chunk-DwJ-SRIz2.js";function oe(c,k){if(c&1&&(Ri(0,`li`),HT(1),sl()),c&2){let o=k.$implicit;EE(),Bh(``,o.name,` â `,o.source)}}function ne(c,k){if(c&1&&(Ri(0,`div`,3),HT(1),sl()),c&2){let o=aT();EE(),Hh(o.i18n.texts.pages.import_from_sources.message_internet)}}var ke=(()=>{class c{constructor(o,i,e,r,t,l,f,S,p){this.i18n=o,this.network=i,this.trailService=e,this.fetchSourceService=r,this.progressService=t,this.modalController=l,this.authService=f,this.trackService=S,this.photoService=p,this.trailsSources=[]}ngOnInit(){this.trailService.getAll$().pipe(H()).subscribe(o=>{this.trailsSources=[];for(let i of this.trails){let e=o.find(r=>r.uuid===i.trailUuid);e&&this.trailsSources.push({name:e.name,source:this.fetchSourceService.getPluginByUrl(i.source).name})}})}doImport(){let o=this.progressService.create(this.i18n.texts.pages.import_from_sources.title,this.trails.length),i=this.authService.email;if(i)for(let e of this.trails){let r=this.trailService.getTrail(e.trailUuid,i);if(!r){o.addWorkDone(1);continue}this.fetchSourceService.fetchTrailInfo(e.source).then(t=>{if(!t)return!0;let l=Promise.resolve(!0),f=t.description&&t.description.trim().length>0&&r.description.trim().length===0,S=t.location&&t.location.trim().length>0&&r.location.trim().length===0;if((f||S)&&(l=l.then(()=>new Promise(p=>this.trailService.doUpdate(r,m=>{f&&(m.description=t.description.trim()),S&&(m.location=t.location.trim())},()=>p(!0))))),t.wayPoints&&t.wayPoints.length>0&&(l=l.then(()=>_g(Fg([this.trackService.getFullTrackReady$(r.originalTrackUuid,i),this.trackService.getFullTrackReady$(r.currentTrackUuid,i)]))).then(([p,m])=>{let v=w(p,t.wayPoints),re=m.uuid===p.uuid?!1:w(m,t.wayPoints);return v&&this.trackService.update(p),re&&this.trackService.update(m),!0})),t.photos&&t.photos.length>0){let p=100;for(let m of t.photos)l=l.then(()=>globalThis.fetch(m.url)).then(v=>v.arrayBuffer()).then(v=>_g(this.photoService.addPhoto(i,e.trailUuid,m.description??``,p++,v)))}return l}).catch(t=>!0).then(()=>o.addWorkDone(1))}}close(){this.modalController.dismiss(null,`cancel`)}static{this.ɵfac=function(i){return new(i||c)(Vr(Bt),Vr(nt),Vr(X),Vr(X$1),Vr(z),Vr(Uh),Vr(Ue),Vr(Be),Vr(Ze))}}static{this.ɵcmp=ZI({type:c,selectors:[[`app-fetch-source-popup`]],inputs:{trails:`trails`},decls:23,vars:9,consts:[[`color`,`primary`],[1,`ion-padding`],[1,`message`],[1,`internet`],[`color`,`footer`],[`slot`,`end`],[`color`,`success`,3,`click`,`disabled`],[3,`click`]],template:function(i,e){if(i&1){let r=eT();Gh(0),aw(1,`async`),Ri(2,`ion-header`)(3,`ion-toolbar`,0)(4,`ion-title`)(5,`ion-label`),HT(6),sl()()()(),Ri(7,`ion-content`,1)(8,`div`,2),HT(9),sl(),Ri(10,`ul`),zD(11,oe,2,2,`li`,null,GD),sl(),Ri(13,`div`,2),HT(14),sl(),UD(15,ne,2,1,`div`,3),sl(),Ri(16,`ion-footer`)(17,`ion-toolbar`,4)(18,`ion-buttons`,5)(19,`ion-button`,6),Dh(`click`,function(){return ku(r),e.doImport(),Lu(e.close())}),HT(20),sl(),Ri(21,`ion-button`,7),Dh(`click`,function(){return e.close()}),HT(22),sl()()()()}if(i&2){let r=lw(1,7,e.network.internet$);EE(6),Hh(e.i18n.texts.pages.import_from_sources.title),EE(3),Hh(e.i18n.texts.pages.import_from_sources.message1),EE(2),QD(e.trailsSources),EE(3),Hh(e.i18n.texts.pages.import_from_sources.message2),EE(),WD(r?-1:15),EE(4),fh(`disabled`,!r),EE(),Hh(e.i18n.texts.buttons.yes),EE(2),Hh(e.i18n.texts.buttons.no)}},dependencies:[ED,b5,JE,a5,lI,xD,DE,CE,Xy],encapsulation:2,changeDetection:1})}}return c})();export{ke as FetchSourcePopupComponent};
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.