File: /var/www/vhost/disk-apps/pwa.sports-crowd.com/www/5132.cdc7547dda5f8d98.js
"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[5132],{65132:(O,A,l)=>{l.r(A),l.d(A,{UserProfilePageModule:()=>g});var h=l(56610),f=l(77897),E=l(22882),v=l(37222),_=l(36075),b=l(73308),e=l(2978),L=l(29885),I=l(57291),S=l(7125),C=l(54171),R=l(41808),u=l(47855);function t(a,y){1&a&&e.nrm(0,"img",13)}function s(a,y){if(1&a&&e.nrm(0,"img",14),2&a){const o=e.XpG(2);e.FCK("src","",o.cityProvider._urlGallery,"avatars/",o.userProvider._infoUser.user_info.photo,"",e.B4B)}}function i(a,y){if(1&a&&e.nrm(0,"img",14),2&a){const o=e.XpG(2);e.FS9("src",o.userProvider._infoUser.user_info.photo_social,e.B4B)}}function r(a,y){if(1&a){const o=e.RV6();e.j41(0,"ion-content",4)(1,"div",5)(2,"div",6),e.bIt("click",function(){e.eBV(o);const P=e.sdS(4),x=e.XpG();return e.Njj(x.actionSheetImage(P))}),e.nrm(3,"input",7,8),e.DNE(5,t,1,0,"img",9),e.DNE(6,s,1,2,"img",10),e.DNE(7,i,1,1,"img",10),e.j41(8,"span"),e.nrm(9,"ion-icon",11),e.k0s()()(),e.nrm(10,"app-edit-profile",12),e.k0s()}if(2&a){const o=e.XpG();e.R7$(5),e.Y8G("ngIf",!o.userProvider._infoUser.user_info.photo&&!o.userProvider._infoUser.user_info.photo_social),e.R7$(1),e.Y8G("ngIf",o.userProvider._infoUser.user_info.photo),e.R7$(1),e.Y8G("ngIf",o.userProvider._infoUser.user_info.photo_social),e.R7$(3),e.Y8G("accountUser",o.accountUser)}}const c=[{path:"",component:(()=>{class a{constructor(o,m,P,x,U,F,X,w,D){this.userProvider=o,this.storage=m,this.translateService=P,this.toastCtrl=x,this.loadingCtrl=U,this.actionSheetCtrl=F,this.cityProvider=X,this.utilsService=w,this.photoService=D,this.lastImage=null,this.translateService.get(["PROFILE_UPDATED","TITLE_ACTION_SHEET","TEXT1_ACTION_SHEET","TEXT2_ACTION_SHEET","TEXT_CANCEL_SELECT","TEXT1_UPDATE_IMAGE_PROFILE","TEXT2_UPDATE_IMAGE_PROFILE","TEXT3_UPDATE_IMAGE_PROFILE","TEXT4_UPDATE_IMAGE_PROFILE"]).subscribe(T=>{this.messageText={updateSuccess:T.PROFILE_UPDATED,titleAction:T.TITLE_ACTION_SHEET,photo:T.TEXT1_ACTION_SHEET,gallery:T.TEXT2_ACTION_SHEET,cancel:T.TEXT_CANCEL_SELECT,text1UpdateImage:T.TEXT1_UPDATE_IMAGE_PROFILE,text2UpdateImage:T.TEXT2_UPDATE_IMAGE_PROFILE,text3UpdateImage:T.TEXT3_UPDATE_IMAGE_PROFILE,text4UpdateImage:T.TEXT4_UPDATE_IMAGE_PROFILE}})}ionViewWillLeave(){this.userProvider.getInfoUser()}ngOnInit(){this.accountUser=this.userProvider._infoUser,this.storage.get("token").then(o=>{this.token=o})}actionSheetImage(o){var m=this;return(0,b.A)(function*(){m.photoService.actionSheetImage(o).then(P=>{m.uploadImage(P)})})()}presentToast(o){this.utilsService.presentToast(3e3,"","top",o)}uploadImage(o){const m=new FormData;m.append("file",o),this.accountUser.user_info.photo=null,this.accountUser.user_info.photo_social=null,this.utilsService.presentLoading(this.translateService.instant("all.loading")),this.userProvider.uploadProfilePhoto(m,this.token.access_token).then(P=>{this.utilsService.dismissLoading(),P.status?(this.storage.get("infoUser").then(x=>{let U=x;U.user_info.photo=P.filename,U.user_info.photo_social=null,this.storage.set("infoUser",U),this.accountUser=U,setTimeout(()=>{this.userProvider.getInfoUser()},500)}),this.presentToast(this.messageText.text3UpdateImage)):this.presentToast(this.messageText.text4UpdateImage),this.utilsService.closeAllAlerts()}).catch(P=>{this.utilsService.dismissLoading(),console.log("error uploadProfilePhoto: ",P),this.presentToast(this.messageText.text4UpdateImage)})}static#e=this.\u0275fac=function(m){return new(m||a)(e.rXU(L.D),e.rXU(I.n),e.rXU(E.c$),e.rXU(f.K_),e.rXU(f.Xi),e.rXU(f.GD),e.rXU(S.h),e.rXU(C.T),e.rXU(R.I))};static#t=this.\u0275cmp=e.VBU({type:a,selectors:[["page-user-profile"]],decls:7,vars:4,consts:[[1,"ion-no-border"],["defaultHref","/app/tabs/settings","slot","start"],[1,"ion-text-center"],["padding","",4,"ngIf"],["padding",""],[2,"text-align","center"],[1,"item",3,"click"],["type","file","accept","image/*",2,"display","none"],["fileInput",""],["src","../../assets/img/default_profile.png","class","imageUserProfile",4,"ngIf"],["class","imageUserProfile",3,"src",4,"ngIf"],["name","camera",1,"ion-no-margin","notify-badge"],[3,"accountUser"],["src","../../assets/img/default_profile.png",1,"imageUserProfile"],[1,"imageUserProfile",3,"src"]],template:function(m,P){1&m&&(e.j41(0,"ion-header",0)(1,"ion-toolbar"),e.nrm(2,"ion-back-button",1),e.j41(3,"ion-title",2),e.EFF(4),e.nI1(5,"translate"),e.k0s()()(),e.DNE(6,r,11,4,"ion-content",3)),2&m&&(e.R7$(4),e.JRh(e.bMT(5,2,"USER_PROFILE_TITLE")),e.R7$(2),e.Y8G("ngIf",P.accountUser))},dependencies:[h.bT,f.el,f.W9,f.eU,f.iq,f.BC,f.ai,f.tY,u.r,E.D9],styles:[".imageUserProfile[_ngcontent-%COMP%]{display:block!important;margin:10px auto!important;border-radius:50%;width:90px;height:90px;max-width:90px;max-height:90px;border:1px solid lightgray}.textImageUserProfile[_ngcontent-%COMP%]{font-weight:700}.notEdit[_ngcontent-%COMP%]{pointer-events:none;opacity:.6}.item[_ngcontent-%COMP%]{position:relative;padding-top:20px;display:inline-block}.notify-badge[_ngcontent-%COMP%]{position:absolute;right:-7px;top:90px;text-align:center;border-radius:30px;padding:4px;font-size:20px;background:lightgray}"]})}return a})()}];let d=(()=>{class a{static#e=this.\u0275fac=function(m){return new(m||a)};static#t=this.\u0275mod=e.$C({type:a});static#i=this.\u0275inj=e.G2t({imports:[_.iI.forChild(c),_.iI]})}return a})();var p=l(55553);let g=(()=>{class a{static#e=this.\u0275fac=function(m){return new(m||a)};static#t=this.\u0275mod=e.$C({type:a});static#i=this.\u0275inj=e.G2t({imports:[h.MD,f.bv,v.YN,d,E.h.forChild(),p.h]})}return a})()},41808:(O,A,l)=>{l.d(A,{I:()=>R});var h=l(73308),f=l(22126),E=function(u){return u.Prompt="PROMPT",u.Camera="CAMERA",u.Photos="PHOTOS",u}(E||{}),v=function(u){return u.Rear="REAR",u.Front="FRONT",u}(v||{}),_=function(u){return u.Uri="uri",u.Base64="base64",u.DataUrl="dataUrl",u}(_||{});class b extends f.E_{getPhoto(t){var s=this;return(0,h.A)(function*(){return new Promise(function(){var i=(0,h.A)(function*(r,n){if(t.webUseInput||t.source===E.Photos)s.fileInputExperience(t,r,n);else if(t.source===E.Prompt){let c=document.querySelector("pwa-action-sheet");c||(c=document.createElement("pwa-action-sheet"),document.body.appendChild(c)),c.header=t.promptLabelHeader||"Photo",c.cancelable=!1,c.options=[{title:t.promptLabelPhoto||"From Photos"},{title:t.promptLabelPicture||"Take Picture"}],c.addEventListener("onSelection",function(){var d=(0,h.A)(function*(p){0===p.detail?s.fileInputExperience(t,r,n):s.cameraExperience(t,r,n)});return function(p){return d.apply(this,arguments)}}())}else s.cameraExperience(t,r,n)});return function(r,n){return i.apply(this,arguments)}}())})()}pickImages(t){var s=this;return(0,h.A)(function*(){return new Promise(function(){var i=(0,h.A)(function*(r,n){s.multipleFileInputExperience(r,n)});return function(r,n){return i.apply(this,arguments)}}())})()}cameraExperience(t,s,i){var r=this;return(0,h.A)(function*(){if(customElements.get("pwa-camera-modal")){const n=document.createElement("pwa-camera-modal");n.facingMode=t.direction===v.Front?"user":"environment",document.body.appendChild(n);try{yield n.componentOnReady(),n.addEventListener("onPhoto",function(){var c=(0,h.A)(function*(d){const p=d.detail;null===p?i(new f.I9("User cancelled photos app")):p instanceof Error?i(p):s(yield r._getCameraPhoto(p,t)),n.dismiss(),document.body.removeChild(n)});return function(d){return c.apply(this,arguments)}}()),n.present()}catch{r.fileInputExperience(t,s,i)}}else console.error("Unable to load PWA Element 'pwa-camera-modal'. See the docs: https://capacitorjs.com/docs/web/pwa-elements."),r.fileInputExperience(t,s,i)})()}fileInputExperience(t,s,i){let r=document.querySelector("#_capacitor-camera-input");const n=()=>{var c;null===(c=r.parentNode)||void 0===c||c.removeChild(r)};r||(r=document.createElement("input"),r.id="_capacitor-camera-input",r.type="file",r.hidden=!0,document.body.appendChild(r),r.addEventListener("change",c=>{const d=r.files[0];let p="jpeg";if("image/png"===d.type?p="png":"image/gif"===d.type&&(p="gif"),"dataUrl"===t.resultType||"base64"===t.resultType){const g=new FileReader;g.addEventListener("load",()=>{if("dataUrl"===t.resultType)s({dataUrl:g.result,format:p});else if("base64"===t.resultType){const a=g.result.split(",")[1];s({base64String:a,format:p})}n()}),g.readAsDataURL(d)}else s({webPath:URL.createObjectURL(d),format:p}),n()}),r.addEventListener("cancel",c=>{i(new f.I9("User cancelled photos app")),n()})),r.accept="image/*",r.capture=!0,t.source===E.Photos||t.source===E.Prompt?r.removeAttribute("capture"):t.direction===v.Front?r.capture="user":t.direction===v.Rear&&(r.capture="environment"),r.click()}multipleFileInputExperience(t,s){let i=document.querySelector("#_capacitor-camera-input-multiple");const r=()=>{var n;null===(n=i.parentNode)||void 0===n||n.removeChild(i)};i||(i=document.createElement("input"),i.id="_capacitor-camera-input-multiple",i.type="file",i.hidden=!0,i.multiple=!0,document.body.appendChild(i),i.addEventListener("change",n=>{const c=[];for(let d=0;d<i.files.length;d++){const p=i.files[d];let g="jpeg";"image/png"===p.type?g="png":"image/gif"===p.type&&(g="gif"),c.push({webPath:URL.createObjectURL(p),format:g})}t({photos:c}),r()}),i.addEventListener("cancel",n=>{s(new f.I9("User cancelled photos app")),r()})),i.accept="image/*",i.click()}_getCameraPhoto(t,s){return new Promise((i,r)=>{const n=new FileReader,c=t.type.split("/")[1];"uri"===s.resultType?i({webPath:URL.createObjectURL(t),format:c,saved:!1}):(n.readAsDataURL(t),n.onloadend=()=>{const d=n.result;i("dataUrl"===s.resultType?{dataUrl:d,format:c,saved:!1}:{base64String:d.split(",")[1],format:c,saved:!1})},n.onerror=d=>{r(d)})})}checkPermissions(){var t=this;return(0,h.A)(function*(){if(typeof navigator>"u"||!navigator.permissions)throw t.unavailable("Permissions API not available in this browser");try{return{camera:(yield window.navigator.permissions.query({name:"camera"})).state,photos:"granted"}}catch{throw t.unavailable("Camera permissions are not available in this browser")}})()}requestPermissions(){var t=this;return(0,h.A)(function*(){throw t.unimplemented("Not implemented on web.")})()}pickLimitedLibraryPhotos(){var t=this;return(0,h.A)(function*(){throw t.unavailable("Not implemented on web.")})()}getLimitedLibraryPhotos(){var t=this;return(0,h.A)(function*(){throw t.unavailable("Not implemented on web.")})()}}new b;const L=(0,f.F3)("Camera",{web:()=>new b});var I=l(2978),S=l(77897),C=l(22882);let R=(()=>{class u{constructor(s,i){this.actionSheetCtrl=s,this.translateService=i}actionSheetImage(s){var i=this;return(0,h.A)(function*(){return new Promise(function(){var r=(0,h.A)(function*(n,c){if(f.Ii.isNativePlatform()){const g=yield L.requestPermissions();if("denied"===g.photos||"denied"===g.camera)return;var d={quality:90,targetWidth:600,targetHeight:600,saveToPhotoAlbum:!1,correctOrientation:!0,cameraDirection:1,resultType:_.Base64,promptLabelHeader:i.translateService.instant("TITLE_ACTION_SHEET"),promptLabelPhoto:i.translateService.instant("TEXT2_ACTION_SHEET"),promptLabelPicture:i.translateService.instant("TEXT1_ACTION_SHEET")},p=yield L.getPhoto(d);n("data:image/"+p.format+";base64,"+p.base64String)}else s.click(),s.addEventListener("change",function(g){const a=g.target;if(a.files&&a.files.length>0){const y=a.files[0],o=new FileReader;o.onload=()=>{n(o.result)},o.readAsDataURL(y)}})});return function(n,c){return r.apply(this,arguments)}}())})()}static#e=this.\u0275fac=function(i){return new(i||u)(I.KVO(S.GD),I.KVO(C.c$))};static#t=this.\u0275prov=I.jDH({token:u,factory:u.\u0275fac,providedIn:"root"})}return u})()}}]);