!function(t){var e={};function s(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,s),n.l=!0,n.exports}s.m=t,s.c=e,s.d=function(t,e,a){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(s.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)s.d(a,n,function(e){return t[e]}.bind(null,n));return a},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=0)}([function(t,e){const{createElement:s,render:a,useState:n,useEffect:i,Fragment:r}=wp.element,{select:l,dispatch:o}=wp.data,d=t=>{const e=window.student_dash_activity,[a,d]=n(!0),[c,u]=n({}),[m,g]=n(()=>t.settings.messages?e.translations.unread_messages:t.settings.activity?e.translations.recent_activity:t.settings.friends?e.translations.friends_online:void 0),[v,p]=n(()=>{let s=[];return t.settings.messages&&s.push(e.translations.unread_messages),t.settings.activity&&s.push(e.translations.recent_activity),t.settings.friends&&s.push(e.translations.friends_online),s});i(()=>{_()},[]);const _=()=>{let s=[];return t.settings.messages&&s.push("messages"),t.settings.activity&&s.push("activity"),t.settings.friends&&s.push("friends"),fetch(`${e.api}/activity${t.settings.user_id?"?force":""}`,{method:"post",body:JSON.stringify({user_id:t.settings.user_id,num:t.settings.number,token:l("vibebp").getToken(),type:s})}).then(t=>t.ok?t.json():{status:0,message:window.wplms_course_data.translations.error_loading_data}).then(e=>{if(e&&(console.log(e),Object.keys(e).length)){let t={};Object.keys(e).map((s,a)=>{console.log(s),e[s].status&&e[s].data&&e[s].data.length&&(t[s]=e[s].data)}),u(t)}d(!1),document.dispatchEvent(new CustomEvent("vibebp_widget_loaded",{detail:{props:t}}))}).catch(t=>{o("vibebp").addNotification({text:window.wplms_course_data.translations.error_loading_data})})};return s("div",{className:"activity_widget"},a?s("div",null,s("div",{className:"widget_loader"},s("div",null),s("div",null),s("div",null),s("div",null))):s(r,null,v&&v.length?s("div",{className:"tabs dash_tabs"},v.map((t,e)=>s("div",{className:t===m?"dash_tab active":"dash_tab",onClick:()=>{g(t)}},t))):"",s("div",{id:"",className:"tab_content"},t.settings.friends&&m==e.translations.friends_online?s("div",{id:"tab-friends",className:"tab-pane"},s("ul",{className:"dash-user-friends"},c.friends&&c.friends.length?c.friends.map((t,e)=>s("li",null,s("span",{dangerouslySetInnerHTML:{__html:t.avatar+" "+t.name}}),s("span",null,t.last_active))):s("div",{className:"message error"},e.translations.no_friends))):"",t.settings.messages&&m==e.translations.unread_messages?s("div",{id:"tab-messages",className:"tab-pane"},s("ul",{className:"dash-unread-messages"},c.messages&&c.messages.length?c.messages.map((t,e)=>s("li",null,s("span",{dangerouslySetInnerHTML:{__html:t.avatar}}),s("a",{href:t.link},t.subject,s("span",{dangerouslySetInnerHTML:{__html:t.subject_form}})))):s("div",{className:"message error"},e.translations.no_messages))):"",t.settings.activity&&m==e.translations.recent_activity?s("div",{id:"tab-activity",className:"tab-pane student_activity"},s("ul",{className:"dash-activities"},c.activity&&c.activity.length?c.activity.map((t,a)=>s("li",{class:t.component+" "+t.type},s("div",{class:"dash-activity"},s("span",{class:"dash-activity-time"},t.time+" "+e.translations.ago),s("strong",{dangerouslySetInnerHTML:{__html:t.action}}),s("p",{dangerouslySetInnerHTML:{__html:t.content}})))):s("div",{className:"message error"},e.translations.no_activity))):"")))};document.addEventListener("wplms_dash_activity",t=>{t.target.removeEventListener(t.type,arguments.callee),document.querySelectorAll(".wplms_dash_activity").forEach(e=>{a(s(d,{settings:t.detail.widget.options}),e)})})}]);