File: /volume1/@appstore/SynologyPhotos/ui/799.react_bundle.js
"use strict";(self.webpackChunkFotoReactLibrary=self.webpackChunkFotoReactLibrary||[]).push([["799"],{3589:function(e,t,n){n.r(t),n.d(t,{default:function(){return I}});var a=n(76150),r=n(7409),i=n(24460),o=n(28395),l=n(45697),u=n.n(l),c=n(67294),s=n(15593),f=n(73935),d=n(27412),m=n(33344),p=n(59435),h=n(96904),g=n(79905),v=n(64701),y=n(82260),C=function(e,t,n){var a=e<t?"width":"height";return(0,m._H)((0,m.YG)((0,d._)({unit:"%"},a,100),n,e,t),e,t)},T=function(e){var t=e.handleApply,n=e.handleCancel,r=e.imageDataUrl,l=e.altText,u=(0,i._)((0,c.useState)(),2),s=u[0],f=u[1],d=(0,i._)((0,c.useState)(),2),T=d[0],x=d[1],E=(0,c.useRef)(null),_=c.createElement(c.Fragment,null,c.createElement("div",{className:"synofoto-avatar-image-crop-desc"},(0,g.n6)("common","avatar_drag_drop")),c.createElement("div",{className:"synofoto-avatar-image-crop-container"},c.createElement(m.ZP,{className:"ReactCrop--no-animate",crop:s,aspect:1,keepSelection:!0,minHeight:100,minWidth:100,onChange:function(e,t){return f(t)},onComplete:function(e,t){x(t)}},c.createElement("img",{className:"synofoto-avatar-crop-image",ref:E,alt:l,src:r,onLoad:function(e){var t=e.currentTarget;f(C(t.width,t.height,1))}}))));return c.createElement(p.Z,{className:"synofoto-avatar-image-crop-dialog",isOpen:!0,showCancel:!0,content:_,handleCancel:function(){n()},handleConfirm:function(){return(0,a._)(function(){var e;return(0,o.Jh)(this,function(n){switch(n.label){case 0:return[4,(0,y.a)({image:E.current,crop:T,outputType:"image/png",maxSize:400})];case 1:return e=n.sent(),[4,(0,v.m)(e)];case 2:return t.apply(void 0,[n.sent()]),[2]}})})()},title:(0,g.n6)("common","avatar_crop_photo"),contentPadding:h.k3.ALL})};T.propTypes={handleApply:u().func.isRequired,handleCancel:u().func.isRequired,imageDataUrl:u().string.isRequired,altText:u().string},T.defaultProps={altText:""};var x=n(47524),E=n(94057),_=function(e){var t=document.body.appendChild(document.createElement("div"));return new Promise(function(n){var a=x.Z.getStore();f.render(c.createElement(s.zt,{store:a},c.createElement(T,{handleApply:function(e){n({type:h.uE.APPLY,dataUrl:e})},handleCancel:function(){n({type:h.uE.CANCEL})},imageDataUrl:e})),t)}).then(function(e){return e}).catch(function(e){throw e}).finally(function(){(0,E.P)(t)})};function b(e){var t=e.value,n=e.onChange;return c.createElement("div",{className:"synofoto-avatar-editor-container"},t?c.createElement("img",{className:"synofoto-avatar-editor-image",src:t,alt:"","aria-label":"avatar"}):c.createElement("div",{className:"synofoto-avatar-editor-empty","aria-label":"no avatar"}),c.createElement("div",{className:"synofoto-avatar-editor-icon","aria-label":"icon"}),c.createElement("input",{type:"file",accept:"image/jpeg, image/gif, image/png",className:"synofoto-avatar-editor-file-input",onChange:function(e){return(0,a._)(function(){var t,a,r;return(0,o.Jh)(this,function(i){switch(i.label){case 0:if(!(e.target.files&&e.target.files.length>0))return[3,3];return[4,(0,v.m)(e.target.files[0])];case 1:return[4,_(i.sent())];case 2:a=(t=i.sent()).type,r=t.dataUrl,a===h.uE.APPLY&&n(r),i.label=3;case 3:return[2]}})})()},title:"","aria-label":"upload"}),t&&c.createElement("div",{className:"synofoto-avatar-editor-delete",onClick:function(){n("")},"aria-label":"delete"}))}b.propTypes={value:u().string,onChange:u().func},b.defaultProps={value:"",onChange:function(){}};var N=n(37865),P=n(98848),R=n(11617);function k(e){var t=e.fieldText,n=e.type,a=e.onChange,o=e.inputTextCheckerList,l=e.inputTextValid,u=e.setInputTextValid,s=(0,P._)(e,["fieldText","type","onChange","inputTextCheckerList","inputTextValid","setInputTextValid"]),f=(0,i._)((0,c.useState)(""),2),d=f[0],m=f[1];return c.createElement(c.Fragment,null,c.createElement("div",{className:"synofoto-profile-dialog-label"},"".concat(t).concat((0,g.n6)("common","colon"))),"textarea"===n?c.createElement("textarea",(0,r._)({onChange:function(e){a(e.target.value)}},s)):c.createElement("input",(0,r._)({type:"text",className:l?"":"invalid",onChange:function(e){a(e.target.value)},onBlur:function(e){if(0!==o.length){var t=e.target.value;if(""===t){m(""),u(!0);return}var n=(0,R.mI)(t,o),a=n.errorMessage,r=n.isValid;m(a),u(r)}},"data-tooltip-id":h.ZP.GLOBAL_WARNING_TOOLTIP_ID,"data-tooltip-content":l?"":d,"data-tooltip-place":"top"},s)))}k.propTypes={fieldText:u().string,onChange:u().func.isRequired,value:u().string,type:u().oneOf(["text","textarea"]),inputTextCheckerList:u().arrayOf(u().shape({isValid:u().func,errorMessage:u().string})),inputTextValid:u().bool,setInputTextValid:u().func},k.defaultProps={fieldText:"",value:"",type:"text",inputTextCheckerList:[],inputTextValid:!0,setInputTextValid:function(){}};var L=n(39308);function O(e){var t=e.fieldText,n=e.options,a=e.defaultValue,i=(0,P._)(e,["fieldText","options","defaultValue"]),o=(0,c.useRef)(n.filter(function(e){return e.value===a}));return c.createElement(c.Fragment,null,c.createElement("div",{className:"synofoto-profile-dialog-label"},"".concat(t).concat((0,g.n6)("common","colon"))),c.createElement(L.Z,(0,r._)({options:n,defaultValue:o.current},i)))}O.propTypes={fieldText:u().string,onChange:u().func.isRequired,options:u().arrayOf(u().shape({value:u().string.isRequired,label:u().string.isRequired}).isRequired).isRequired,defaultValue:u().string},O.defaultProps={fieldText:"",defaultValue:void 0};var V=n(19297),w=function(e){var t=e.email,n=e.nickname,r=e.description,i=e.timezone;return(0,a._)(function(){return(0,o.Jh)(this,function(e){switch(e.label){case 0:return[4,(0,V.Z)({api:"SYNO.Personal.Profile",method:"set",version:1,keepParamsCase:!0,params:{email:t,nickName:n,title:r,timezone:i}})];case 1:return[2,e.sent()]}})})()},q=n(95635),S=n(63744),A=n(72181),z=function(e,t){return(0,r._)({},e,t)},Z=function(e){var t=e.handleApply,n=e.handleCancel,l=e.languageOptions,u=e.timezoneOptions,f=(0,S.j)((0,s.v9)(A.Z.getProfile)),d=(0,i._)((0,c.useState)(!1),2),m=d[0],v=d[1],y=(0,i._)((0,c.useState)(f.avatar),2),C=y[0],T=y[1],x=(0,i._)((0,c.useState)((0,q.Ks)()),2),E=x[0],_=x[1],P=(0,i._)((0,c.useState)(!0),2),L=P[0],Z=P[1],I=(0,i._)((0,c.useState)(!1),2),J=I[0],U=I[1],Y={nickname:f.nickName,description:f.description,email:f.email,timezone:f.timezoneUI},D=(0,i._)((0,c.useReducer)(z,Y),2),F=D[0],j=D[1];(0,c.useEffect)(function(){if(J){var e=setTimeout(function(){U(!1)},5e3);return function(){clearTimeout(e)}}return function(){}},[J]);var B=c.createElement("div",{className:"synofoto-profile-dialog-container"},c.createElement(b,{value:C,onChange:function(e){return T(e)}}),c.createElement("div",{className:"synofoto-profile-dialog-form"},c.createElement("div",{className:"synofoto-profile-dialog-username"},f.userName),c.createElement(k,{fieldText:(0,g.n6)("common","nickname"),value:F.nickname,onChange:function(e){return j({nickname:e})}}),c.createElement(k,{type:"textarea",className:"synofoto-profile-dialog-description",fieldText:(0,g.n6)("common","description"),value:F.description,onChange:function(e){return j({description:e})}}),c.createElement(k,{fieldText:(0,g.n6)("common","email"),value:F.email,onChange:function(e){return j({email:e})},inputTextCheckerList:[R.oP],inputTextValid:L,setInputTextValid:Z}),c.createElement(O,{fieldText:(0,g.n6)("common","language"),options:l,defaultValue:E,onChange:function(e){return _(e.value)}}),c.createElement(O,{fieldText:(0,g.n6)("common","timezone"),options:u,defaultValue:F.timezone,onChange:function(e){return j({timezone:e.value})}})));return c.createElement(p.Z,{className:"synofoto-profile-dialog",isOpen:!0,showCancel:!0,showLoadingBox:m,content:B,handleCancel:n,handleConfirm:function(){return(0,a._)(function(){var e;return(0,o.Jh)(this,function(n){var i;switch(n.label){case 0:if(!L)return U(!0),[2];return U(!1),v(!0),[4,(i=f.avatar,(0,a._)(function(){return(0,o.Jh)(this,function(e){switch(e.label){case 0:if(C===i)return[2];if(!C.startsWith("data:image/png"))return[3,2];return[4,(0,a._)(function(){var e;return(0,o.Jh)(this,function(t){switch(t.label){case 0:return[4,fetch(C)];case 1:return[4,t.sent().blob()];case 2:return e=t.sent(),[4,(0,V.Z)({api:"SYNO.Personal.Profile.Photo",method:"upload",version:1,formData:{photo:e}})];case 3:return[2,t.sent().photo]}})})()];case 1:return e.sent(),[3,4];case 2:if(""!==C)return[3,4];return[4,(0,a._)(function(){return(0,o.Jh)(this,function(e){switch(e.label){case 0:return[4,(0,V.Z)({api:"SYNO.Personal.Profile.Photo",method:"delete",version:1})];case 1:return e.sent(),[2]}})})()];case 3:e.sent(),e.label=4;case 4:return[2]}})})())];case 1:return n.sent(),[4,(0,a._)(function(){var e,t,n,a,i,l,u;return(0,o.Jh)(this,function(o){switch(o.label){case 0:e={},t=!0,n=!1,a=void 0;try{for(i=Object.keys(Y)[Symbol.iterator]();!(t=(l=i.next()).done);t=!0)F[u=l.value]!==Y[u]&&(e[u]=F[u])}catch(e){n=!0,a=e}finally{try{t||null==i.return||i.return()}finally{if(n)throw a}}if(0===Object.keys(e).length)return[2];return[4,w((0,r._)({},Y,e))];case 1:return o.sent(),[2]}})})()];case 2:return n.sent(),e=E!==(0,q.Ks)()&&((0,q.rs)(E),!0),v(!1),t({isLanguageChanged:e}),[2]}})})()},title:(0,g.n6)("action","profile"),contentPadding:h.k3.ALL,footerMessage:J?c.createElement(N.Z,{message:(0,g.n6)("error","email_invalid"),isError:!0,iconType:"none"}):null})};Z.propTypes={handleApply:u().func,handleCancel:u().func,languageOptions:u().arrayOf(u().shape({value:u().string.isRequired,label:u().string.isRequired}).isRequired).isRequired,timezoneOptions:u().arrayOf(u().shape({value:u().string.isRequired,label:u().string.isRequired}).isRequired).isRequired},Z.defaultProps={handleApply:function(){},handleCancel:function(){}};var I=Z}}]);