-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path78.4c4d4fb498fef230.js
1 lines (1 loc) · 15.2 KB
/
78.4c4d4fb498fef230.js
1
"use strict";(self.webpackChunk_04_country_app=self.webpackChunk_04_country_app||[]).push([[78],{78:(te,v,a)=>{a.r(v),a.d(v,{CountriesModule:()=>W});var c=a(895),h=a(551),e=a(256),C=a(262),Z=a(646),T=a(4),l=a(505),A=a(529);let g=(()=>{var n;class i{constructor(t){this.http=t,this.apiUrl="https://restcountries.com/v3.1",this.cacheStore={byCapital:{term:"",countries:[]},byCountries:{term:"",countries:[]},byRegion:{region:"",countries:[]}},this.loadFromLocalStorage()}saveToLocalStorage(){localStorage.setItem("cacheStore",JSON.stringify(this.cacheStore))}loadFromLocalStorage(){localStorage.getItem("cacheStore")&&(this.cacheStore=JSON.parse(localStorage.getItem("cacheStore")))}getCountriespRequest(t){return this.http.get(t).pipe((0,C.K)(()=>(0,Z.of)([])))}searchCountryByAlphaCode(t){return this.http.get(`${this.apiUrl}/alpha/${t}`).pipe((0,T.U)(s=>s.length>0?s[0]:null),(0,C.K)(()=>(0,Z.of)(null)))}searchCapital(t){return this.getCountriespRequest(`${this.apiUrl}/capital/${t}`).pipe((0,l.b)(s=>this.cacheStore.byCapital={term:t,countries:s}),(0,l.b)(()=>this.saveToLocalStorage()))}searchCountry(t){return this.getCountriespRequest(`${this.apiUrl}/name/${t}`).pipe((0,l.b)(s=>this.cacheStore.byCountries={term:t,countries:s}),(0,l.b)(()=>this.saveToLocalStorage()))}searchRegion(t){return this.getCountriespRequest(`${this.apiUrl}/region/${t}`).pipe((0,l.b)(s=>this.cacheStore.byRegion={region:t,countries:s}),(0,l.b)(()=>this.saveToLocalStorage()))}}return(n=i).\u0275fac=function(t){return new(t||n)(e.LFG(A.eN))},n.\u0275prov=e.Yz7({token:n,factory:n.\u0275fac,providedIn:"root"}),i})(),S=(()=>{var n;class i{constructor(){}ngOnInit(){}}return(n=i).\u0275fac=function(t){return new(t||n)},n.\u0275cmp=e.Xpm({type:n,selectors:[["shared-loading-spinner"]],decls:15,vars:0,consts:[[1,"spinner-container","bg-dark"],["width","30","height","30","viewBox","0 0 45 45","xmlns","http://www.w3.org/2000/svg","stroke","#fff"],["fill","none","fill-rule","evenodd","transform","translate(1 1)","stroke-width","2"],["cx","22","cy","22","r","6","stroke-opacity","0"],["attributeName","r","begin","1.5s","dur","3s","values","6;22","calcMode","linear","repeatCount","indefinite"],["attributeName","stroke-opacity","begin","1.5s","dur","3s","values","1;0","calcMode","linear","repeatCount","indefinite"],["attributeName","stroke-width","begin","1.5s","dur","3s","values","2;0","calcMode","linear","repeatCount","indefinite"],["attributeName","r","begin","3s","dur","3s","values","6;22","calcMode","linear","repeatCount","indefinite"],["attributeName","stroke-opacity","begin","3s","dur","3s","values","1;0","calcMode","linear","repeatCount","indefinite"],["attributeName","stroke-width","begin","3s","dur","3s","values","2;0","calcMode","linear","repeatCount","indefinite"],["cx","22","cy","22","r","8"],["attributeName","r","begin","0s","dur","1.5s","values","6;1;2;3;4;5;6","calcMode","linear","repeatCount","indefinite"]],template:function(t,r){1&t&&(e.TgZ(0,"div",0)(1,"span"),e._uU(2,"Buscando"),e.qZA(),e.O4$(),e.TgZ(3,"svg",1)(4,"g",2)(5,"circle",3),e._UZ(6,"animate",4)(7,"animate",5)(8,"animate",6),e.qZA(),e.TgZ(9,"circle",3),e._UZ(10,"animate",7)(11,"animate",8)(12,"animate",9),e.qZA(),e.TgZ(13,"circle",10),e._UZ(14,"animate",11),e.qZA()()()())},styles:[".spinner-container[_ngcontent-%COMP%]{position:fixed;bottom:15px;right:15px;background-color:#000;color:#fff;padding:5px 10px;border-radius:20px;display:flex;align-items:center;box-shadow:0 0 5px #00000080}span[_ngcontent-%COMP%]{margin-left:5px}"]}),i})();var q=a(579),U=a(727);class w extends U.w0{constructor(i,o){super()}schedule(i,o=0){return this}}const m={setInterval(n,i,...o){const{delegate:t}=m;return t?.setInterval?t.setInterval(n,i,...o):setInterval(n,i,...o)},clearInterval(n){const{delegate:i}=m;return(i?.clearInterval||clearInterval)(n)},delegate:void 0};var B=a(737);const b={now:()=>(b.delegate||Date).now(),delegate:void 0};class d{constructor(i,o=d.now){this.schedulerActionCtor=i,this.now=o}schedule(i,o=0,t){return new this.schedulerActionCtor(this,i).schedule(t,o)}}d.now=b.now;const P=new class O extends d{constructor(i,o=d.now){super(i,o),this.actions=[],this._active=!1}flush(i){const{actions:o}=this;if(this._active)return void o.push(i);let t;this._active=!0;do{if(t=i.execute(i.state,i.delay))break}while(i=o.shift());if(this._active=!1,t){for(;i=o.shift();)i.unsubscribe();throw t}}}(class I extends w{constructor(i,o){super(i,o),this.scheduler=i,this.work=o,this.pending=!1}schedule(i,o=0){var t;if(this.closed)return this;this.state=i;const r=this.id,s=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(s,r,o)),this.pending=!0,this.delay=o,this.id=null!==(t=this.id)&&void 0!==t?t:this.requestAsyncId(s,this.id,o),this}requestAsyncId(i,o,t=0){return m.setInterval(i.flush.bind(i,this),t)}recycleAsyncId(i,o,t=0){if(null!=t&&this.delay===t&&!1===this.pending)return o;null!=o&&m.clearInterval(o)}execute(i,o){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;const t=this._execute(i,o);if(t)return t;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))}_execute(i,o){let r,t=!1;try{this.work(i)}catch(s){t=!0,r=s||new Error("Scheduled action threw falsy error")}if(t)return this.unsubscribe(),r}unsubscribe(){if(!this.closed){const{id:i,scheduler:o}=this,{actions:t}=o;this.work=this.state=this.scheduler=null,this.pending=!1,(0,B.P)(t,this),null!=i&&(this.id=this.recycleAsyncId(o,i,null)),this.delay=null,super.unsubscribe()}}});var R=a(482),F=a(403);let _=(()=>{var n;class i{constructor(){this.debouncer=new q.x,this.placeholder="",this.initialValue="",this.onValue=new e.vpe,this.onDebounce=new e.vpe}ngOnInit(){this.debouncerSupscription=this.debouncer.pipe(function J(n,i=P){return(0,R.e)((o,t)=>{let r=null,s=null,u=null;const y=()=>{if(r){r.unsubscribe(),r=null;const p=s;s=null,t.next(p)}};function ee(){const p=u+n,x=i.now();if(x<p)return r=this.schedule(void 0,p-x),void t.add(r);y()}o.subscribe((0,F.x)(t,p=>{s=p,u=i.now(),r||(r=i.schedule(ee,n),t.add(r))},()=>{y(),t.complete()},void 0,()=>{s=r=null}))})}(300)).subscribe(t=>{this.onDebounce.emit(t)})}ngOnDestroy(){this.debouncerSupscription?.unsubscribe()}emitValue(t){this.onValue.emit(t)}onKeyPress(t){this.debouncer.next(t)}}return(n=i).\u0275fac=function(t){return new(t||n)},n.\u0275cmp=e.Xpm({type:n,selectors:[["shared-search-box"]],inputs:{placeholder:"placeholder",initialValue:"initialValue"},outputs:{onValue:"onValue",onDebounce:"onDebounce"},decls:2,vars:2,consts:[["type","text",1,"form-control",3,"placeholder","value","keyup"],["txtInput",""]],template:function(t,r){if(1&t){const s=e.EpF();e.TgZ(0,"input",0,1),e.NdJ("keyup",function(){e.CHM(s);const y=e.MAs(1);return e.KtG(r.onKeyPress(y.value))}),e.qZA()}2&t&&e.Q6J("placeholder",r.placeholder)("value",r.initialValue)},encapsulation:2}),i})();function M(n,i){1&n&&(e.TgZ(0,"div",2),e._uU(1," No hay paises que mostrar\n"),e.qZA())}const N=function(n){return["/countries/by",n]};function V(n,i){if(1&n&&(e.TgZ(0,"tr")(1,"td"),e._uU(2),e.qZA(),e.TgZ(3,"td"),e._uU(4),e.qZA(),e.TgZ(5,"td"),e._UZ(6,"img",5),e.qZA(),e.TgZ(7,"td"),e._uU(8),e.qZA(),e.TgZ(9,"td"),e._uU(10),e.qZA(),e.TgZ(11,"td"),e._uU(12),e.ALo(13,"number"),e.qZA(),e.TgZ(14,"td")(15,"a",6),e._uU(16,"Info"),e.qZA()()()),2&n){const o=i.$implicit,t=i.index;e.xp6(2),e.Oqu(t+1),e.xp6(2),e.Oqu(o.flag),e.xp6(2),e.Q6J("src",o.flags.svg,e.LSH)("alt",o.name.common),e.xp6(2),e.Oqu(o.name.common),e.xp6(2),e.Oqu(o.capital),e.xp6(2),e.Oqu(e.lcZ(13,8,o.population)),e.xp6(3),e.Q6J("routerLink",e.VKq(10,N,o.cca3))}}function L(n,i){if(1&n&&(e.TgZ(0,"table",3)(1,"thead")(2,"tr")(3,"th"),e._uU(4,"#"),e.qZA(),e.TgZ(5,"th"),e._uU(6,"Icono"),e.qZA(),e.TgZ(7,"th"),e._uU(8,"Bandera"),e.qZA(),e.TgZ(9,"th"),e._uU(10,"Nombre"),e.qZA(),e.TgZ(11,"th"),e._uU(12,"Capital"),e.qZA(),e.TgZ(13,"th"),e._uU(14,"Poblaci\xf3n"),e.qZA(),e._UZ(15,"th"),e.qZA()(),e.TgZ(16,"tbody"),e.YNc(17,V,17,12,"tr",4),e.qZA()()),2&n){const o=e.oxw();e.xp6(17),e.Q6J("ngForOf",o.countries)}}let f=(()=>{var n;class i{constructor(){this.countries=[]}ngOnInit(){}}return(n=i).\u0275fac=function(t){return new(t||n)},n.\u0275cmp=e.Xpm({type:n,selectors:[["countries-table"]],inputs:{countries:"countries"},decls:3,vars:2,consts:[["class","alert alert-warning text-center",4,"ngIf","ngIfElse"],["table",""],[1,"alert","alert-warning","text-center"],[1,"table","table-hover"],[4,"ngFor","ngForOf"],[3,"src","alt"],[3,"routerLink"]],template:function(t,r){if(1&t&&(e.YNc(0,M,2,0,"div",0),e.YNc(1,L,18,1,"ng-template",null,1,e.W1O)),2&t){const s=e.MAs(2);e.Q6J("ngIf",0===r.countries.length)("ngIfElse",s)}},dependencies:[c.sg,c.O5,h.rH,c.JJ],styles:["img[_ngcontent-%COMP%]{width:25px}"]}),i})();function Q(n,i){1&n&&e._UZ(0,"shared-loading-spinner")}let k=(()=>{var n;class i{constructor(t){this.countriesService=t,this.countries=[],this.isLoading=!1,this.initialValue=""}ngOnInit(){this.countries=this.countriesService.cacheStore.byCapital.countries,this.initialValue=this.countriesService.cacheStore.byCapital.term}searchByCapital(t){this.isLoading=!0,this.countriesService.searchCapital(t).subscribe(r=>{this.countries=r,this.isLoading=!1}),console.log({term:t})}}return(n=i).\u0275fac=function(t){return new(t||n)(e.Y36(g))},n.\u0275cmp=e.Xpm({type:n,selectors:[["app-by-capital-page"]],decls:11,vars:3,consts:[[1,"row"],[1,"col"],["placeholder","Buscar por capital",3,"initialValue","onDebounce"],[4,"ngIf"],[3,"countries"]],template:function(t,r){1&t&&(e.TgZ(0,"h2"),e._uU(1,"Por Capital"),e.qZA(),e._UZ(2,"hr"),e.TgZ(3,"div",0)(4,"div",1)(5,"shared-search-box",2),e.NdJ("onDebounce",function(u){return r.searchByCapital(u)}),e.qZA()()(),e.TgZ(6,"div",0)(7,"div",1),e._UZ(8,"hr"),e.YNc(9,Q,1,0,"shared-loading-spinner",3),e._UZ(10,"countries-table",4),e.qZA()()),2&t&&(e.xp6(5),e.Q6J("initialValue",r.initialValue),e.xp6(4),e.Q6J("ngIf",r.isLoading),e.xp6(1),e.Q6J("countries",r.countries))},dependencies:[c.O5,S,_,f],encapsulation:2}),i})(),Y=(()=>{var n;class i{constructor(t){this.countriesService=t,this.countries=[],this.initialValue=""}ngOnInit(){this.countries=this.countriesService.cacheStore.byCountries.countries,this.initialValue=this.countriesService.cacheStore.byCountries.term}searchByCountry(t){this.countriesService.searchCountry(t).subscribe(r=>{this.countries=r}),console.log({term:t})}}return(n=i).\u0275fac=function(t){return new(t||n)(e.Y36(g))},n.\u0275cmp=e.Xpm({type:n,selectors:[["app-by-country-page"]],decls:10,vars:2,consts:[[1,"row"],[1,"col"],["placeholder","Buscar por pais",3,"initialValue","onDebounce"],[3,"countries"]],template:function(t,r){1&t&&(e.TgZ(0,"h2"),e._uU(1,"Por Pais"),e.qZA(),e._UZ(2,"hr"),e.TgZ(3,"div",0)(4,"div",1)(5,"shared-search-box",2),e.NdJ("onDebounce",function(u){return r.searchByCountry(u)}),e.qZA()()(),e.TgZ(6,"div",0)(7,"div",1),e._UZ(8,"hr")(9,"countries-table",3),e.qZA()()),2&t&&(e.xp6(5),e.Q6J("initialValue",r.initialValue),e.xp6(4),e.Q6J("countries",r.countries))},dependencies:[_,f],encapsulation:2}),i})();const D=function(n){return{"btn-outline-primary":n}};function $(n,i){if(1&n){const o=e.EpF();e.TgZ(0,"button",5),e.NdJ("click",function(){const s=e.CHM(o).$implicit,u=e.oxw();return e.KtG(u.searchByRegion(s))}),e._uU(1),e.qZA()}if(2&n){const o=i.$implicit,t=e.oxw();e.Q6J("ngClass",e.VKq(2,D,t.selectedRegion===o)),e.xp6(1),e.hij(" ",o," ")}}let E=(()=>{var n;class i{constructor(t){this.countriesService=t,this.countries=[],this.regions=["Africa","America","Asia","Europe","Oceania"]}ngOnInit(){this.countries=this.countriesService.cacheStore.byRegion.countries,this.selectedRegion=this.countriesService.cacheStore.byRegion.region}searchByRegion(t){this.selectedRegion=t,this.countriesService.searchRegion(t).subscribe(r=>{this.countries=r})}}return(n=i).\u0275fac=function(t){return new(t||n)(e.Y36(g))},n.\u0275cmp=e.Xpm({type:n,selectors:[["app-by-region-page"]],decls:10,vars:2,consts:[[1,"row"],[1,"col","text-center"],["class","btn mx-2",3,"ngClass","click",4,"ngFor","ngForOf"],[1,"col"],[3,"countries"],[1,"btn","mx-2",3,"ngClass","click"]],template:function(t,r){1&t&&(e.TgZ(0,"h2"),e._uU(1,"Por Regi\xf3n"),e.qZA(),e._UZ(2,"hr"),e.TgZ(3,"div",0)(4,"div",1),e.YNc(5,$,2,4,"button",2),e.qZA()(),e.TgZ(6,"div",0)(7,"div",3),e._UZ(8,"hr")(9,"countries-table",4),e.qZA()()),2&t&&(e.xp6(5),e.Q6J("ngForOf",r.regions),e.xp6(4),e.Q6J("countries",r.countries))},dependencies:[c.mk,c.sg,f],encapsulation:2}),i})();var K=a(900);function X(n,i){1&n&&(e.TgZ(0,"div",2),e._uU(1," Espere por favor "),e.qZA())}function j(n,i){if(1&n&&(e.TgZ(0,"div")(1,"div",3)(2,"div",4)(3,"h2"),e._uU(4,"Pais: "),e.TgZ(5,"strong"),e._uU(6),e.qZA()(),e._UZ(7,"hr"),e.qZA()(),e.TgZ(8,"div",3)(9,"div",5)(10,"h3"),e._uU(11,"Bandera"),e.qZA(),e._UZ(12,"img",6),e.qZA(),e.TgZ(13,"div",7)(14,"h3"),e._uU(15,"Informaci\xf3n"),e.qZA(),e.TgZ(16,"ul",8)(17,"li",9)(18,"strong"),e._uU(19,"Poblaci\xf3n:"),e.qZA(),e._uU(20),e.ALo(21,"number"),e.qZA(),e.TgZ(22,"li",9)(23,"strong"),e._uU(24,"C\xf3digo:"),e.qZA(),e._uU(25),e.qZA()()()(),e.TgZ(26,"div",10)(27,"div",7)(28,"h3"),e._uU(29,"Traducciones"),e.qZA(),e.TgZ(30,"div",11)(31,"span",12),e._uU(32),e.qZA(),e.TgZ(33,"span",12),e._uU(34),e.qZA(),e.TgZ(35,"span",12),e._uU(36),e.qZA(),e.TgZ(37,"span",12),e._uU(38),e.qZA(),e.TgZ(39,"span",12),e._uU(40),e.qZA(),e.TgZ(41,"span",12),e._uU(42),e.qZA(),e.TgZ(43,"span",12),e._uU(44),e.qZA(),e.TgZ(45,"span",12),e._uU(46),e.qZA(),e.TgZ(47,"span",12),e._uU(48),e.qZA()()()()()),2&n){const o=e.oxw();e.xp6(6),e.Oqu(o.country.name.common),e.xp6(6),e.Q6J("src",o.country.flags.svg,e.LSH)("alt",o.country.name.common),e.xp6(8),e.hij(" ",e.lcZ(21,14,o.country.population)," "),e.xp6(5),e.hij(" ",o.country.cca3," "),e.xp6(7),e.Oqu(o.country.translations.ara.common),e.xp6(2),e.Oqu(o.country.translations.bre.common),e.xp6(2),e.Oqu(o.country.translations.ces.common),e.xp6(2),e.Oqu(o.country.translations.cym.common),e.xp6(2),e.Oqu(o.country.translations.deu.common),e.xp6(2),e.Oqu(o.country.translations.fin.common),e.xp6(2),e.Oqu(o.country.translations.ita.common),e.xp6(2),e.Oqu(o.country.translations.kor.common),e.xp6(2),e.Oqu(o.country.translations.per.common)}}const z=[{path:"by-capital",component:k},{path:"by-country",component:Y},{path:"by-region",component:E},{path:"by/:id",component:(()=>{var n;class i{constructor(t,r,s){this.activatedRoute=t,this.countriesService=r,this.router=s}ngOnInit(){this.activatedRoute.params.pipe((0,K.w)(({id:t})=>this.countriesService.searchCountryByAlphaCode(t))).subscribe(t=>t?this.country=t:this.router.navigateByUrl(""))}}return(n=i).\u0275fac=function(t){return new(t||n)(e.Y36(h.gz),e.Y36(g),e.Y36(h.F0))},n.\u0275cmp=e.Xpm({type:n,selectors:[["app-country-page"]],decls:3,vars:2,consts:[["loading",""],[4,"ngIf","ngIfElse"],[1,"alert","alert-info","text-center"],[1,"row"],[1,"col-12"],[1,"col-4"],[1,"img-thumbnail",3,"src","alt"],[1,"col"],[1,"list-group"],[1,"list-group-item"],[1,"row","mt-2"],[1,"d-flex","flex-wrap"],[1,"badge","bg-primary","m-1"]],template:function(t,r){if(1&t&&(e.YNc(0,X,2,0,"ng-template",null,0,e.W1O),e.YNc(2,j,49,16,"div",1)),2&t){const s=e.MAs(1);e.xp6(2),e.Q6J("ngIf",r.country)("ngIfElse",s)}},dependencies:[c.O5,c.JJ],encapsulation:2}),i})()},{path:"**",redirectTo:"by-capital"}];let H=(()=>{var n;class i{}return(n=i).\u0275fac=function(t){return new(t||n)},n.\u0275mod=e.oAB({type:n}),n.\u0275inj=e.cJS({imports:[h.Bz.forChild(z),h.Bz]}),i})();var G=a(466);let W=(()=>{var n;class i{}return(n=i).\u0275fac=function(t){return new(t||n)},n.\u0275mod=e.oAB({type:n}),n.\u0275inj=e.cJS({imports:[c.ez,H,G.m]}),i})()}}]);