"use strict";(self.webpackChunkbackend_ai_webui_react=self.webpackChunkbackend_ai_webui_react||[]).push([[898],{9898:function(e,n,r){r.r(n),r.d(n,{default:function(){return C},passwordPattern:function(){return j}});var t=r(9439),a=r(4036),s=r(4039),o=r(3842),i=r(3656),u=r(8818),d=r(2513),c=r(1502),l=r(9277),w=r(1748),m=r(7462),f=r(4519),h={icon:function(e,n){return{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M955.7 856l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zm-783.5-27.9L512 239.9l339.8 588.2H172.2z",fill:e}},{tag:"path",attrs:{d:"M172.2 828.1h679.6L512 239.9 172.2 828.1zM560 720a48.01 48.01 0 01-96 0 48.01 48.01 0 0196 0zm-16-304v184c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V416c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8z",fill:n}},{tag:"path",attrs:{d:"M464 720a48 48 0 1096 0 48 48 0 10-96 0zm16-304v184c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V416c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8z",fill:e}}]}},name:"warning",theme:"twotone"},p=r(9491),g=function(e,n){return f.createElement(p.Z,(0,m.Z)({},e,{ref:n,icon:h}))};var P=f.forwardRef(g),b=r(7112),v=r(7760),k=r(3255),Z=r(2556),j=/^(?=.*\d)(?=.*[a-zA-Z])(?=.*[_\W]).{8,}$/,C=function(){var e,n=(0,c.useWebComponentInfo)(),r=n.value,m=n.dispatchEvent;try{e=JSON.parse(r||"")}catch(L){e={open:!1,currentPassword:"",username:"",api_endpoint:""}}var h=e,p=h.open,g=h.currentPassword,C=h.username,_=h.api_endpoint,x=a.Z.useToken().token,M=s.Z.useForm(),y=(0,t.Z)(M,1)[0],z=(0,w.$G)().t;(0,f.useEffect)((function(){p&&y.resetFields()}),[p,y]);var S=(0,v.M)({api_endpoint:_}),E=(0,b.useMutation)({mutationFn:function(e){return(0,k.Lc)({method:"POST",url:"/server/update-password-no-auth",body:e,client:S})}}),F=function(){y.validateFields().then((function(e){E.mutate({username:C,current_password:g,new_password:e.newPassword},{onSuccess:function(e,n,r){m("ok",null)},onError:function(e,n,r){}})}))};return(0,Z.jsx)(o.Z,{open:p,centered:!0,mask:!1,onCancel:function(){m("cancel",null)},keyboard:!1,maskClosable:!1,footer:null,width:450,destroyOnClose:!0,forceRender:!0,children:(0,Z.jsxs)(l.Z,{direction:"column",justify:"start",align:"stretch",gap:"md",style:{alignSelf:"stretch",paddingTop:x.paddingMD,paddingBottom:x.paddingMD},children:[(0,Z.jsxs)(i.Z.Title,{level:3,style:{margin:0},children:[(0,Z.jsx)(P,{twoToneColor:x.colorWarning})," ",z("webui.menu.PleaseChangeYourPassword")]}),z("webui.menu.YouMushChangeYourPassword"),(0,Z.jsxs)(s.Z,{form:y,layout:"vertical",initialValues:{currentPassword:g},disabled:E.isLoading,children:[(0,Z.jsx)(s.Z.Item,{name:"newPassword",label:z("webui.menu.NewPassword"),rules:[{required:!0},{pattern:j,message:z("webui.menu.InvalidPasswordMessage").toString()},function(){return{validator:function(e,n){return g===n?Promise.reject(new Error(z("webui.menu.NewPasswordCannotBeSame").toString())):Promise.resolve()}}}],hasFeedback:!0,children:(0,Z.jsx)(u.Z.Password,{})}),(0,Z.jsx)(s.Z.Item,{name:"confirm",label:z("webui.menu.NewPasswordAgain"),dependencies:["newPassword"],hasFeedback:!0,rules:[{required:!0},function(e){var n=e.getFieldValue;return{validator:function(e,r){return r&&n("newPassword")!==r?Promise.reject(new Error(z("environment.PasswordsDoNotMatch").toString())):Promise.resolve()}}}],children:(0,Z.jsx)(u.Z.Password,{onPressEnter:F})})]}),(0,Z.jsx)(d.ZP,{type:"primary",onClick:F,loading:E.isLoading,children:z("webui.menu.Update")})]})})}}}]);
//# sourceMappingURL=898.55663304.chunk.js.map