tweb/public/19.6ab6cfac6a40d6befd98.chunk.js
Eduard Kuzmenko e793a329d0 Build
2021-07-17 19:40:58 +03:00

2 lines
14 KiB
JavaScript

(this.webpackJsonp=this.webpackJsonp||[]).push([[19],{22:function(e,t,n){"use strict";n.r(t);var i=n(31),s=n(36),o=n(35),a=n(99),r=n(14),c=n(12),l=n(27),d=n(28),h=n(79),p=n(60),u=n(5),m=n(33);let v=null;const f=new p.a("page-signUp",!0,()=>Promise.all([n.e(4),n.e(6)]).then(n.bind(null,69)).then(e=>{const t=new h.a({className:"page-signUp",withInputWrapper:!0,titleLangKey:"YourName",subtitleLangKey:"Login.Register.Subtitle"});t.imageDiv.classList.add("avatar-edit"),t.title.classList.add("fullName");const r=document.createElement("canvas");r.id="canvas-avatar",r.className="avatar-edit-canvas";const p=document.createElement("span");p.className="tgico tgico-cameraadd",t.imageDiv.append(r,p);const f=e.default;let b;t.imageDiv.addEventListener("click",()=>{(new a.a).open(r,e=>{b=e})});const g=e=>{const n=w.value||"",i=L.value||"",s=n||i?(n+" "+i).trim():"";s?Object(m.a)(t.title,d.b.wrapEmojiText(s)):Object(m.a)(t.title,Object(c.i18n)("YourName"))};const w=new s.b({label:"FirstName",maxLength:70}),L=new s.b({label:"LastName",maxLength:64}),y=Object(i.a)("btn-primary btn-color-primary"),E=new c.default.IntlElement({key:"StartMessaging"});return y.append(E.element),t.inputWrapper.append(w.container,L.container,y),w.input.addEventListener("input",g),L.input.addEventListener("input",g),y.addEventListener("click",(function(e){if(w.input.classList.contains("error")||L.input.classList.contains("error"))return!1;if(!w.value.length)return w.input.classList.add("error"),!1;this.disabled=!0;const t=w.value.trim(),i=L.value.trim(),s={phone_number:v.phone_number,phone_code_hash:v.phone_code_hash,first_name:t,last_name:i};E.update({key:"PleaseWait"});const a=Object(o.f)(this);l.a.invokeApi("auth.signUp",s).then(e=>{switch(e._){case"auth.authorization":l.a.setUserAuth(e.user.id),new Promise((e,t)=>{if(!b)return e();b().then(n=>{f.uploadProfilePhoto(n).then(e,t)},t)}).finally(()=>{n.e(5).then(n.bind(null,17)).then(e=>{e.default.mount()})});break;default:E.update({key:e._}),this.removeAttribute("disabled"),a.remove()}}).catch(e=>{this.removeAttribute("disabled"),a.remove(),e.type,E.update({key:e.type})})})),Object(u.a)(),new Promise(e=>{window.requestAnimationFrame(e)})}),e=>{v=e,r.default.pushToState("authState",{_:"authStateSignUp",authCode:e})});t.default=f},49:function(e,t,n){"use strict";var i=n(13),s=n(27),o=n(43),a=n(84),r=n(80),c=n(26);const l=new class{constructor(){this.cacheStorage=new r.a("cachedFiles"),this.downloads={},this.progress={},this.progressCallbacks={},this.uploadId=0,this.thumbsCache={photo:{},document:{}},i.default.addEventListener("download_progress",e=>{const t=e;this.progress[t.fileName]=t;const n=this.progressCallbacks[t.fileName];n&&n.forEach(e=>e(t));const i=this.downloads[t.fileName];i&&i.notifyAll(t)})}getNewDeferred(e){const t=Object(o.a)();return t.cancel=()=>{const n=new Error("Download canceled");n.name="AbortError",s.a.cancelDownload(e),t.reject(n),t.cancel=()=>{}},t.finally(()=>{delete this.progress[e],delete this.progressCallbacks[e]}),t.catch(()=>{this.clearDownload(e)}),this.downloads[e]=t}clearDownload(e){delete this.downloads[e]}fakeDownload(e,t){const n=this.getNewDeferred(e);return"string"==typeof t?fetch(t).then(e=>e.blob()).then(e=>n.resolve(e)):n.resolve(t),n}download(e){const t=Object(a.a)(e.location,{fileName:e.fileName});if(this.downloads.hasOwnProperty(t))return this.downloads[t];const n=this.getNewDeferred(t),i=e=>{n.reject(e)};return(()=>{if(!s.a.worker||e.onlyCache){const o=this.cacheStorage.getFile(t).then(t=>{if(t.size<e.size)throw"wrong size";n.resolve(t)});return e.onlyCache?o.catch(i):o.catch(()=>s.a.downloadFile(e).then(n.resolve,i))}s.a.downloadFile(e).then(n.resolve,i)})(),n}upload(e,t){if(!t){const n=null==e?void 0:e.type;if(n){const e=this.uploadId+++"."+n.split("/")[1];t=["image/jpeg","image/png","image/bmp"].indexOf(n)>=0?"photo"+e:0===n.indexOf("audio/")||["video/ogg"].indexOf(n)>=0?"audio"+e:0===n.indexOf("video/")?"video"+e:"document"+e}else t="upload-"+this.uploadId++}const n=this.getNewDeferred(t);return s.a.uploadFile({file:e,fileName:t}).then(n.resolve,n.reject),n.finally(()=>{this.clearDownload(t)}),n}getDownload(e){return this.downloads[e]}addProgressCallback(e,t){var n;const i=this.progress[e];(null!==(n=this.progressCallbacks[e])&&void 0!==n?n:this.progressCallbacks[e]=[]).push(t),i&&t(i)}createDownloadAnchor(e,t,n){const i=document.createElement("a");i.href=e,i.download=t,i.target="_blank",i.style.position="absolute",i.style.top="1px",i.style.left="1px",document.body.append(i);try{var s=document.createEvent("MouseEvents");s.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),i.dispatchEvent(s)}catch(t){console.error("Download click error",t);try{i.click()}catch(t){window.open(e,"_blank")}}setTimeout(()=>{i.remove(),n&&n()},100)}downloadToDisc(e,t){const n=this.download(e);return n.then(e=>{const n=URL.createObjectURL(e);this.createDownloadAnchor(n,t,()=>{URL.revokeObjectURL(n)})}),n}getCacheContext(e,t="full"){var n,i;const s=null!==(n=this.thumbsCache[e._][e.id])&&void 0!==n?n:this.thumbsCache[e._][e.id]={};return null!==(i=s[t])&&void 0!==i?i:s[t]={downloaded:0,url:""}}};c.a&&(c.a.appDownloadManager=l),t.a=l},50:function(e,t,n){"use strict";n.d(t,"b",(function(){return d})),n.d(t,"a",(function(){return h}));var i=n(13),s=n(16),o=n(62),a=n(65),r=n(12),c=n(3),l=n(5);class d{constructor(e,t,n={}){if(this.element=document.createElement("div"),this.container=document.createElement("div"),this.header=document.createElement("div"),this.title=document.createElement("div"),this.onEscape=()=>!0,this.hide=()=>{a.a.back("popup")},this.destroy=()=>{this.onClose&&this.onClose(),this.element.classList.add("hiding"),this.element.classList.remove("active"),this.btnClose&&this.btnClose.removeEventListener("click",this.hide),i.default.overlayIsActive=!1,a.a.removeItem(this.navigationItem),this.navigationItem=void 0,setTimeout(()=>{this.element.remove(),this.onCloseAfterTimeout&&this.onCloseAfterTimeout(),o.a.checkAnimations(!1)},150)},this.element.classList.add("popup"),this.element.className="popup"+(e?" "+e:""),this.container.classList.add("popup-container","z-depth-1"),this.header.classList.add("popup-header"),this.title.classList.add("popup-title"),this.header.append(this.title),n.closable&&(this.btnClose=document.createElement("span"),this.btnClose.classList.add("btn-icon","popup-close","tgico-close"),this.header.prepend(this.btnClose),this.btnClose.addEventListener("click",this.hide,{once:!0})),n.overlayClosable){const e=t=>{Object(c.a)(t.target,"popup-container")||(this.hide(),this.element.removeEventListener("click",e))};this.element.addEventListener("click",e)}if(n.withConfirm&&(this.btnConfirm=document.createElement("button"),this.btnConfirm.classList.add("btn-primary","btn-color-primary"),!0!==n.withConfirm&&this.btnConfirm.append(Object(r.i18n)(n.withConfirm)),this.header.append(this.btnConfirm),Object(s.ripple)(this.btnConfirm)),this.container.append(this.header),n.body&&(this.body=document.createElement("div"),this.body.classList.add("popup-body"),this.container.append(this.body)),t&&t.length){const e=document.createElement("div");e.classList.add("popup-buttons"),2===t.length&&e.classList.add("popup-buttons-row");const n=t.map(e=>{const t=document.createElement("button");return t.className="btn"+(e.isDanger?" danger":" primary"),Object(s.ripple)(t),e.text?t.innerHTML=e.text:t.append(Object(r.i18n)(e.langKey,e.langArgs)),e.callback?t.addEventListener("click",()=>{e.callback(),this.destroy()},{once:!0}):e.isCancel&&t.addEventListener("click",()=>{this.destroy()},{once:!0}),t});e.append(...n),this.container.append(e)}this.element.append(this.container)}show(){this.navigationItem={type:"popup",onPop:this.destroy,onEscape:this.onEscape},a.a.pushItem(this.navigationItem),Object(l.a)(),document.body.append(this.element),this.element.offsetWidth,this.element.classList.add("active"),i.default.overlayIsActive=!0,o.a.checkAnimations(!0)}}const h=e=>(e.find(e=>e.isCancel)||e.push({langKey:"Cancel",isCancel:!0}),e)},79:function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var i=n(12);class s{constructor(e){this.element=document.body.querySelector("."+e.className),this.container=document.createElement("div"),this.container.className="container center-align",this.imageDiv=document.createElement("div"),this.imageDiv.className="auth-image",this.title=document.createElement("h4"),e.titleLangKey&&this.title.append(Object(i.i18n)(e.titleLangKey)),this.subtitle=document.createElement("p"),this.subtitle.className="subtitle",e.subtitleLangKey&&this.subtitle.append(Object(i.i18n)(e.subtitleLangKey)),this.container.append(this.imageDiv,this.title,this.subtitle),e.withInputWrapper&&(this.inputWrapper=document.createElement("div"),this.inputWrapper.className="input-wrapper",this.container.append(this.inputWrapper)),this.element.append(this.container)}}},84:function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return s}));function i(e,t){const n=""["".length-1]||"";let i;switch(e._){case"inputPhotoFileLocation":i=["photo",""[0],e.id,e.thumb_size].filter(Boolean).join("_");break;case"inputDocumentFileLocation":i=["document",""[0],e.id,e.thumb_size].filter(Boolean).join("_");break;case"inputPeerPhotoFileLocation":i=["peerPhoto",e.photo_id,e.pFlags.big?"big":"small"].join("_");break;case"inputStickerSetThumb":i=["stickerSetThumb",e.stickerset.id||e.stickerset.short_name||e.stickerset.emoticon||e.stickerset._,e.thumb_version].join("_");break;case"inputFileLocation":i=e.volume_id+"_"+e.local_id;break;default:console.error("Unrecognized location:",e),i=""}return i+(n?"."+n:n)}function s(e,t){return"/"+e+"/"+encodeURIComponent(JSON.stringify(t))}},99:function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var i=n(49);var s=function(e,t){let n,i,s,o={},a=0,r=0,c=0,l=0,d=0;function h(){e.classList.add("crop-blur"),e.draggable=!1,s=new Image,s.src=e.src,s.draggable=!1,s.classList.add("crop-overlay-image"),t||(t=document.createElement("canvas")),n=document.createElement("div"),n.classList.add("crop-component"),i=document.createElement("div"),i.classList.add("crop-overlay");const o=document.createElement("div");o.classList.add("crop-overlay-color"),n.appendChild(i);e.parentNode.appendChild(n),n.appendChild(s),n.appendChild(e),n.appendChild(o),i.appendChild(s),s.style.maxWidth=e.width+"px",d=e.naturalWidth/e.offsetWidth;const a=e.offsetWidth/2-100,r=e.offsetHeight/2-100;p(200,200),u(a,r),m(a,r),i.addEventListener("mousedown",g,!1),i.addEventListener("touchstart",g,!1),i.addEventListener("wheel",b,!1),document.addEventListener("keypress",f,!1)}function p(e,t){c=e*d,l=t*d,i.style.width=e+"px",i.style.height=t+"px"}function u(e,t){r=t*d,a=e*d,s.style.top=-t+"px",s.style.left=-e+"px"}function m(e,t){i.style.top=t+"px",i.style.left=e+"px"}function v(e){e=e*Math.PI*2;let t,n,o,a,r=Math.floor(i.clientWidth+e),c=Math.floor(i.clientHeight+e),l=s.clientWidth,d=s.clientHeight;r<50||r>l||(t=i.offsetLeft-e/2,n=i.offsetTop-e/2,o=t+r,a=n+c,t<0&&(t=0),n<0&&(n=0),o>l||a>d||(p(r,r),u(t,n),m(t,n)))}function f(e){switch(e.preventDefault(),String.fromCharCode(e.charCode)){case"+":v(4);break;case"-":v(-4)}}function b(e){e.preventDefault(),v(e.deltaY>0?1:-1)}function g(e){e.preventDefault(),e.stopPropagation(),function(e){o.container_width=i.offsetWidth,o.container_height=i.offsetHeight,o.container_left=i.offsetLeft,o.container_top=i.offsetTop,o.mouse_x=(e.clientX||e.pageX||e.touches&&e.touches[0].clientX)+window.scrollX,o.mouse_y=(e.clientY||e.pageY||e.touches&&e.touches[0].clientY)+window.scrollY}(e),document.addEventListener("mousemove",L),document.addEventListener("touchmove",L),document.addEventListener("mouseup",w),document.addEventListener("touchend",w)}function w(e){e.preventDefault(),document.removeEventListener("mouseup",w),document.removeEventListener("touchend",w),document.removeEventListener("mousemove",L),document.removeEventListener("touchmove",L)}function L(e){let t,n,a,r,c={x:0,y:0};e.preventDefault(),e.stopPropagation(),c.x=e.pageX||e.touches&&e.touches[0].pageX,c.y=e.pageY||e.touches&&e.touches[0].pageY,t=c.x-(o.mouse_x-o.container_left),n=c.y-(o.mouse_y-o.container_top),a=i.offsetWidth,r=i.offsetHeight,t<0?t=0:t>s.offsetWidth-a&&(t=s.offsetWidth-a),n<0?n=0:n>s.offsetHeight-r&&(n=s.offsetHeight-r),u(t,n),m(t,n)}return e.complete?h():e.onload=h,{crop:function(){t.width=c,t.height=l,t.getContext("2d").drawImage(e,a,r,c,l,0,0,c,l)},removeHandlers:function(){i.removeEventListener("mousedown",g),i.removeEventListener("touchstart",g),i.removeEventListener("wheel",b),document.removeEventListener("mouseup",w),document.removeEventListener("touchend",w),document.removeEventListener("mousemove",L),document.removeEventListener("touchmove",L),document.removeEventListener("keypress",f),n.remove(),i.remove(),s.remove()}}},o=n(50),a=n(16),r=n(12),c=n(64);class l extends o.b{constructor(){super("popup-avatar",null,{closable:!0}),this.image=new Image,this.cropper={crop:()=>{},removeHandlers:()=>{}},this.h6=document.createElement("h6"),Object(r._i18n)(this.h6,"Popup.Avatar.Title"),this.btnClose.classList.remove("btn-icon"),this.header.append(this.h6),this.cropContainer=document.createElement("div"),this.cropContainer.classList.add("crop"),this.cropContainer.append(this.image),this.input=document.createElement("input"),this.input.type="file",this.input.style.display="none",this.input.addEventListener("change",e=>{const t=e.target.files[0];t&&Object(c.b)(t).then(e=>{this.image=new Image,this.cropContainer.append(this.image),this.image.src=e,this.image.onload=()=>{this.show(),this.cropper=s(this.image,this.canvas),this.input.value=""}})},!1),this.btnSubmit=document.createElement("button"),this.btnSubmit.className="btn-primary btn-color-primary btn-circle btn-crop btn-icon tgico-check z-depth-1",Object(a.ripple)(this.btnSubmit),this.btnSubmit.addEventListener("click",()=>{this.cropper.crop(),this.btnClose.click(),this.canvas.toBlob(e=>{this.blob=e,this.darkenCanvas(),this.resolve()},"image/jpeg",1)}),this.container.append(this.cropContainer,this.btnSubmit,this.input),this.onCloseAfterTimeout=()=>{this.cropper.removeHandlers(),this.image&&this.image.remove()}}resolve(){this.onCrop(()=>i.a.upload(this.blob))}open(e,t){this.canvas=e,this.onCrop=t,this.input.click()}darkenCanvas(){let e=this.canvas.getContext("2d");e.fillStyle="rgba(0, 0, 0, 0.3)",e.fillRect(0,0,this.canvas.width,this.canvas.height)}}}}]);
//# sourceMappingURL=19.6ab6cfac6a40d6befd98.chunk.js.map