(()=>{"use strict";const e=window.React,t=window.wp.element,l=window.jfb.components,{CurrentActionEditContext:r,ActionFieldsMapContext:o,CurrentPropertyMapContext:n}=JetFBComponents,i=function(){const{FieldSelect:i,property:s}=(0,t.useContext)(n),{setMapField:a,getMapField:d}=(0,t.useContext)(r),{name:u,index:m}=(0,t.useContext)(o);return"user_meta"===s?(0,e.createElement)("div",{className:"components-base-control jet-margin-bottom-wrapper"},i,(0,e.createElement)(l.StyledTextControl,{key:u+m+"_text",value:d({name:u}),onChange:e=>a({nameField:u,value:e})})):i},s=window.jfb.blocksToActions,a=window.jfb.actions,d=window.wp.components,u=window.wp.i18n,{ActionFieldsMap:m,WrapperRequiredControl:c,DynamicPropertySelect:p}=JetFBComponents,w=window.wp.primitives,f=(0,e.createElement)(w.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,e.createElement)(w.Path,{fillRule:"evenodd",d:"M7.25 16.437a6.5 6.5 0 1 1 9.5 0V16A2.75 2.75 0 0 0 14 13.25h-4A2.75 2.75 0 0 0 7.25 16v.437Zm1.5 1.193a6.47 6.47 0 0 0 3.25.87 6.47 6.47 0 0 0 3.25-.87V16c0-.69-.56-1.25-1.25-1.25h-4c-.69 0-1.25.56-1.25 1.25v1.63ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm10-2a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z",clipRule:"evenodd"})),_={type:"update_user",label:(0,u.__)("Update User","jet-form-builder"),edit:function(t){var r,o;const n=(0,a.convertListToFieldsMap)((0,s.useFields)({withInner:!1})),{settings:w,onChangeSetting:f,source:_,label:b}=t;(0,s.useSanitizeFieldsMap)();const{hasError:g}=(0,a.useActionValidatorProvider)({isSupported:e=>"field_id"===e?.property}),v=Object.values(null!==(r=w?.fields_map)&&void 0!==r?r:{}).includes("role"),h=(Array.isArray(w?.user_role)?w.user_role:w?.user_role?[w.user_role]:[]).filter(Boolean),y=null!==(o=_.globalSelfPromotableRoles)&&void 0!==o?o:[],E=h.some(e=>!y.includes(e));return(0,e.createElement)(d.Flex,{direction:"column"},(0,e.createElement)(m,{label:b("fields_map"),fields:n,customHelp:()=>g&&(0,e.createElement)(l.IconText,null,(0,u.__)("Please select a field for User ID","jet-form-builder"))},(0,e.createElement)(c,null,(0,e.createElement)(p,{dynamic:["user_meta"]},(0,e.createElement)(i,null)))),(v||E)&&(0,e.createElement)(d.Notice,{status:"warning",isDismissible:!1},v&&(0,u.__)('Role values from Fields Map, including User Meta with the key "role", only work for users who can promote users, or when the submitted role is already allowed for self-promotion.',"jet-form-builder"),v&&E&&" ",E&&(0,u.__)("Selected User Role values outside the global Self-Promotable Roles list may be skipped for users without the promote_users capability.","jet-form-builder")," ",(0,e.createElement)("a",{href:_.globalSettingsUrl,target:"_blank",rel:"noopener noreferrer"},(0,u.__)("Manage in JetFormBuilder Settings.","jet-form-builder"))),(0,e.createElement)(l.WideLine,null),(0,e.createElement)(l.RowControl,null,({id:t})=>(0,e.createElement)(e.Fragment,null,(0,e.createElement)(l.Label,{htmlFor:t},(0,u.__)("User role","jet-form-builder")),(0,e.createElement)(l.StyledSelectControl,{multiple:!0,id:t,value:w.user_role,options:_.userRoles,onChange:e=>f(e,"user_role"),help:(0,u.__)("Hold Ctrl (Windows) or Command (Mac) to select multiple roles.","jet-form-builder")}))),(0,e.createElement)(l.WideLine,null),(0,e.createElement)(a.ActionMessages,{...t}))},icon:f,docHref:"https://jetformbuilder.com/features/update-user/",category:"user",validators:[({settings:e})=>{var t;return!Object.values(null!==(t=e?.fields_map)&&void 0!==t?t:{}).some(e=>"ID"===e)&&{type:"empty",property:"field_id"}}]};(0,a.registerAction)(_)})();