!function(){"use strict";var e={d:function(t,r){for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{AvatarImg:function(){return y},AvatarLoader:function(){return g},clearCache:function(){return b},default:function(){return j}});var r={};e.r(r),e.d(r,{receiveAvatar:function(){return c}});var n={};e.r(n),e.d(n,{getAvatar:function(){return l}});var a={};e.r(a),e.d(a,{getAvatar:function(){return u}});var i=window.wp.dataControls,s=window.wp.data,o=(0,window.nisje.data.onSubKey)("context")(((e={},t)=>"RECEIVE_AVATAR"===t.type?{...e,[t.id]:t.sources}:e));function c(e,t,r="members"){return{type:"RECEIVE_AVATAR",id:e,context:r,sources:t}}function*l(e,t="members"){const r=yield(0,i.apiFetch)({path:`/buddypress/v1/${t}/${e}/avatar?_fields=full`});Array.isArray(r)&&0!==r.length?yield c(e,r[0].full,t):yield c(e,"fallback",t)}var d=window.lodash;function u(e,t,r="members"){return(0,d.get)(e[r],t,!1)}function m(){return m=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},m.apply(this,arguments)}(0,s.registerStore)("nisje/avatar",{reducer:o,controls:i.controls,actions:r,selectors:a,resolvers:n});var f=window.wp.element,v=window.wp.i18n,h=function({size:e,name:t}){return(0,f.createElement)("svg",{"aria-hidden":!0,focusable:!1,height:e,role:"img",viewBox:"0 0 150 150",width:e},(0,f.createElement)("rect",{className:"nisje-avatar__fill",height:"100%",width:"100%"}),(0,f.createElement)("text",{className:"nisje-avatar__text",dominantBaseline:"middle",fontSize:"50px",fontWeight:"600",textAnchor:"middle",x:"50%",y:"79"},t.replace(/[^a-zA-Z]+/g,"").substring(0,2).toUpperCase()))},w=function({size:e}){return(0,f.createElement)("svg",{"aria-hidden":!0,focusable:!1,height:e,role:"img",viewBox:"0 0 150 150",width:e,xmlns:"http://www.w3.org/2000/svg"},(0,f.createElement)("path",{d:"M0 0h150v150H0z",fill:"#d9edfb"}),(0,f.createElement)("circle",{cx:"75",cy:"58",fill:"#006db5",r:"33"}),(0,f.createElement)("path",{d:"M145.8 150c-2.6-35.6-33.3-50-70.8-50S6.8 114.4 4.2 150h141.6z",fill:"#006db5"}))},p=window.nisje.format,g=function({className:e,size:t=150}){const r=(0,p.classnames)("nisje-avatar nisje-avatar__loader",e),n={height:`${t}px`,width:`${t}px`};return(0,f.createElement)("div",{className:r,style:n})},y=function({className:e,context:t="members",id:r,name:n="",size:a=150,src:i}){const s=(0,p.classnames)("nisje-avatar",e),o={height:`${a}px`,width:`${a}px`};if("fallback"!==i)return(0,f.createElement)("img",{alt:(0,v.__)("Avatar","nisje"),className:s,height:`${a}px`,loading:"lazy",src:i,style:o,width:`${a}px`});const c=String(r),l=c.charAt(c.length-1),d="groups"===t?h:w;return(0,f.createElement)("div",{className:`${s} nisje-avatar__color--${l}`,style:o},(0,f.createElement)(d,{name:n,size:a}))};function b(){caches.delete("nisje-avatars")}var j=function(e){const{className:t,context:r,id:n,size:a}=e,i=(0,s.useSelect)((e=>{const{getAvatar:t}=e("nisje/avatar");return t(n,r)}),[n]);return i?(0,f.createElement)(y,m({},e,{src:i})):(0,f.createElement)(g,{className:t,size:a})};(window.nisje=window.nisje||{}).avatar=t}();