require(["jquery","xwiki-meta"],function(a,d){a(function(){[{name:"first_name",purpose:"given-name"},{name:"last_name",purpose:"family-name"},{name:"company",purpose:"organization"},{name:"email",purpose:"email"},{name:"phone",purpose:"tel"},{name:"address",purpose:"street-address"},{name:"blog",purpose:"url"}].forEach(function(b){var c=a('[name$\x3d"'+b.name+'"]');1===c.length&&c.attr("autocomplete",b.purpose)});var f=function(b){var c=new XWiki.widgets.Notification("Saving...","inprogress"),e=(new XWiki.Document(XWiki.Model.resolve("XWiki.Notifications.Code.NotificationPreferenceService",
XWiki.EntityType.DOCUMENT))).getURL("get","outputSyntax\x3dplain");a.post(e,{action:b,csrf:d.form_token,user:XWiki.Model.serialize(d.documentReference),target:"user"}).then(()=>{c.hide();new XWiki.widgets.Notification("Done","done");"watchUser"==b?(a(".notificationWatchUserNotFollowing").addClass("hidden"),a(".notificationWatchUserFollowing").removeClass("hidden")):(a(".notificationWatchUserFollowing").addClass("hidden"),a(".notificationWatchUserNotFollowing").removeClass("hidden"))}).catch(()=>{c.hide();
new XWiki.widgets.Notification("Error saving the notification setting","error")})},g=function(b){var c=new XWiki.widgets.Notification("Saving...","inprogress"),e=(new XWiki.Document(XWiki.Model.resolve("XWiki.XWikiUserProfileSheet",XWiki.EntityType.DOCUMENT))).getURL("get","outputSyntax\x3dplain");a.post(e,{action:b,csrf:d.form_token,userId:XWiki.Model.serialize(d.documentReference)}).then(h=>{c.hide();h.success?(new XWiki.widgets.Notification("Done","done"),"disable"==b?(a("#disable").addClass("hidden"),
a("#enable").removeClass("hidden")):(a("#disable").removeClass("hidden"),a("#enable").addClass("hidden"))):new XWiki.widgets.Notification("Error saving the user status","error")}).catch(()=>{c.hide();new XWiki.widgets.Notification("Error saving the user status","error")})};a("#disable").on("click",function(b){g("disable")});a("#enable").on("click",function(b){g("enable")});a(".notificationWatchUserAdd").on("click",function(b){f("watchUser")});a(".notificationWatchUserRemove").on("click",function(b){f("unwatchUser")})})});