"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[8851],{65663:(e,t,o)=>{o.d(t,{U:()=>h,e:()=>N});var a=o(69307),s=o(83849),n=o.n(s),c=o(59838),r=o(76292),i=o.n(r),l=o(7862),m=o.n(l),d=o(86020),_=o(55609),u=o(92819);class p extends a.Component{render(){const{className:e,hasAction:t,hasDate:o,hasSubtitle:s,lines:c}=this.props,r=n()("woocommerce-activity-card is-loading",e);return(0,a.createElement)("div",{className:r,"aria-hidden":!0},(0,a.createElement)("span",{className:"woocommerce-activity-card__icon"},(0,a.createElement)("span",{className:"is-placeholder"})),(0,a.createElement)("div",{className:"woocommerce-activity-card__header"},(0,a.createElement)("div",{className:"woocommerce-activity-card__title is-placeholder"}),s&&(0,a.createElement)("div",{className:"woocommerce-activity-card__subtitle is-placeholder"}),o&&(0,a.createElement)("div",{className:"woocommerce-activity-card__date"},(0,a.createElement)("span",{className:"is-placeholder"}))),(0,a.createElement)("div",{className:"woocommerce-activity-card__body"},(0,u.range)(c).map((e=>(0,a.createElement)("span",{className:"is-placeholder",key:e})))),t&&(0,a.createElement)("div",{className:"woocommerce-activity-card__actions"},(0,a.createElement)("span",{className:"is-placeholder"})))}}p.propTypes={className:m().string,hasAction:m().bool,hasDate:m().bool,hasSubtitle:m().bool,lines:m().number},p.defaultProps={hasAction:!1,hasDate:!1,hasSubtitle:!1,lines:1};const N=p;class h extends a.Component{getCard(){const{actions:e,className:t,children:o,date:s,icon:c,subtitle:r,title:l,unread:m}=this.props,_=n()("woocommerce-activity-card",t),u=Array.isArray(e)?e:[e],p=/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(s)?i().utc(s).fromNow():s;return(0,a.createElement)("section",{className:_},m&&(0,a.createElement)("span",{className:"woocommerce-activity-card__unread"}),c&&(0,a.createElement)("span",{className:"woocommerce-activity-card__icon","aria-hidden":!0},c),l&&(0,a.createElement)("header",{className:"woocommerce-activity-card__header"},(0,a.createElement)(d.H,{className:"woocommerce-activity-card__title"},l),r&&(0,a.createElement)("div",{className:"woocommerce-activity-card__subtitle"},r),p&&(0,a.createElement)("span",{className:"woocommerce-activity-card__date"},p)),o&&(0,a.createElement)(d.Section,{className:"woocommerce-activity-card__body"},o),e&&(0,a.createElement)("footer",{className:"woocommerce-activity-card__actions"},u.map(((e,t)=>(0,a.cloneElement)(e,{key:t})))))}render(){const{onClick:e}=this.props;return e?(0,a.createElement)(_.Button,{className:"woocommerce-activity-card__button",onClick:e},this.getCard()):this.getCard()}}h.propTypes={actions:m().oneOfType([m().arrayOf(m().element),m().element]),onClick:m().func,className:m().string,children:m().node,date:m().string,icon:m().node,subtitle:m().node,title:m().oneOfType([m().string,m().node]),unread:m().bool},h.defaultProps={icon:(0,a.createElement)(c.Z,{size:48}),unread:!1}},72122:(e,t,o)=>{o.r(t),o.d(t,{InboxPanel:()=>c,default:()=>r});var a=o(69307),s=o(69338),n=o(30554);const c=e=>{let{hasAbbreviatedNotifications:t,thingsToDoNextCount:o}=e;return(0,a.createElement)("div",{className:"woocommerce-notification-panels"},t&&(0,a.createElement)(n.vn,{thingsToDoNextCount:o}),(0,a.createElement)(s.Z,{showHeader:!1}))},r=c},69338:(e,t,o)=>{o.d(t,{Z:()=>k});var a=o(69307),s=o(65736),n=o(86020),c=o(55609),r=o(67221),i=o(9818),l=o(14599),m=o(61586),d=o(28443),_=o(14812),u=o(76292),p=o.n(u),N=o(65663),h=o(23322),E=o(34374);const w=e=>{let{onClose:t}=e;const{createNotice:o}=(0,i.useDispatch)("core/notices"),{batchUpdateNotes:n,removeAllNotes:m}=(0,i.useDispatch)(r.NOTES_STORE_NAME);return(0,a.createElement)(a.Fragment,null,(0,a.createElement)(c.Modal,{title:(0,s.__)("Dismiss all messages","woocommerce"),className:"woocommerce-inbox-dismiss-all-modal",onRequestClose:t},(0,a.createElement)("div",{className:"woocommerce-inbox-dismiss-all-modal__wrapper"},(0,a.createElement)("div",{className:"woocommerce-usage-modal__message"},(0,s.__)("Are you sure? Inbox messages will be dismissed forever.","woocommerce")),(0,a.createElement)("div",{className:"woocommerce-usage-modal__actions"},(0,a.createElement)(c.Button,{onClick:t},(0,s.__)("Cancel","woocommerce")),(0,a.createElement)(c.Button,{isPrimary:!0,onClick:()=>{(async()=>{(0,l.recordEvent)("wcadmin_inbox_action_dismissall",{});try{const e=await m({status:"unactioned"});o("success",(0,s.__)("All messages dismissed","woocommerce"),{actions:[{label:(0,s.__)("Undo","woocommerce"),onClick:()=>{n(e.map((e=>e.id)),{is_deleted:0})}}]})}catch(e){o("error",(0,s.__)("Messages could not be dismissed","woocommerce")),t()}})(),t()}},(0,s.__)("Yes, dismiss all","woocommerce"))))))},g={page:1,per_page:5,status:"unactioned",type:r.QUERY_DEFAULTS.noteTypes,orderby:"date",order:"desc",_fields:["id","name","title","content","type","status","actions","date_created","date_created_gmt","layout","image","is_deleted","is_read","locale"]},b=["en_US","en_AU","en_CA","en_GB","en_ZA"],v=p()("2022-01-11","YYYY-MM-DD").valueOf(),y=(e,t)=>{(0,l.recordEvent)("inbox_action_click",{note_name:e.name,note_title:e.title,note_content_inner_link:t})};let C=!1;const k=e=>{let{showHeader:t=!0}=e;const[o,u]=(0,a.useState)(g.per_page),[k,x]=(0,a.useState)(!1),[S,A]=(0,a.useState)([]),[f,D]=(0,a.useState)({}),{createNotice:T}=(0,i.useDispatch)("core/notices"),{removeNote:M,updateNote:U,triggerNoteAction:B,invalidateResolutionForStoreSelector:R}=(0,i.useDispatch)(r.NOTES_STORE_NAME),O=(0,E.GG)(),Y=(0,a.useMemo)((()=>({...g,per_page:o})),[o]),{isError:H,notes:F,notesHaveResolved:P,isBatchUpdating:I,unreadNotesCount:Z}=(0,i.useSelect)((e=>{const{getNotes:t,getNotesError:o,isNotesRequesting:a,hasFinishedResolution:s}=e(r.NOTES_STORE_NAME);return{notes:t(Y),unreadNotesCount:t({...g,is_read:!1,per_page:-1}).length,isError:Boolean(o("getNotes",[Y])),isBatchUpdating:a("batchUpdateNotes"),notesHaveResolved:!a("batchUpdateNotes")&&s("getNotes",[Y])}}));(0,a.useEffect)((()=>{P&&F.length<o&&x(!0),P&&F.length&&A(F.map((e=>{const t=p()(e.date_created_gmt,"YYYY-MM-DD").valueOf();return b.includes(e.locale)&&t>=v?{...e,content:(0,h.r7)(e.content,320)}:e})))}),[F,P]);const[z,L]=(0,a.useState)(!1);if(H){const e=(0,s.__)("There was an error getting your inbox. Please try again.","woocommerce"),t=(0,s.__)("Reload","woocommerce"),o=()=>{window.location.reload()};return(0,a.createElement)(n.EmptyContent,{title:e,actionLabel:t,actionURL:null,actionCallback:o})}return P&&!S.length?null:(0,a.createElement)(a.Fragment,null,z&&(0,a.createElement)(w,{onClose:()=>{L(!1)}}),(0,a.createElement)("div",{className:"woocommerce-homepage-notes-wrapper"},!P&&!S.length&&(0,a.createElement)(n.Section,null,(0,a.createElement)(_.InboxNotePlaceholder,{className:"banner message-is-unread"})),(0,a.createElement)(n.Section,null,Boolean(S.length)&&(e=>{let{hasNotes:t,isBatchUpdating:o,notes:r,onDismiss:i,onNoteActionClick:u,onNoteVisible:p,setShowDismissAllModal:h,showHeader:E=!0,loadMoreNotes:w,allNotesFetched:b,notesHaveResolved:v,unreadNotesCount:k}=e;if(o)return;if(!t)return(0,a.createElement)(N.U,{className:"woocommerce-empty-activity-card",title:(0,s.__)("Your inbox is empty","woocommerce"),icon:!1},(0,s.__)("As things begin to happen in your store your inbox will start to fill up. You'll see things like achievements, new feature announcements, extension recommendations and more!","woocommerce"));C||((0,l.recordEvent)("inbox_panel_view",{total:r.length}),C=!0);const x=Object.keys(r).map((e=>r[e]));return(0,a.createElement)(c.Card,{size:"large"},E&&(0,a.createElement)(c.CardHeader,{size:"medium"},(0,a.createElement)("div",{className:"wooocommerce-inbox-card__header"},(0,a.createElement)(_.Text,{size:"20",lineHeight:"28px",variant:"title.small"},(0,s.__)("Inbox","woocommerce")),(0,a.createElement)(n.Badge,{count:k})),(0,a.createElement)(n.EllipsisMenu,{label:(0,s.__)("Inbox Notes Options","woocommerce"),renderContent:e=>{let{onToggle:t}=e;return(0,a.createElement)("div",{className:"woocommerce-inbox-card__section-controls"},(0,a.createElement)(c.Button,{onClick:()=>{h(!0),t()}},(0,s.__)("Dismiss all","woocommerce")))}})),(0,a.createElement)(m.Z,{role:"menu"},x.map((e=>{const{id:t,is_deleted:o}=e;return o?null:(0,a.createElement)(d.Z,{key:t,timeout:500,classNames:"woocommerce-inbox-message"},(0,a.createElement)(_.InboxNoteCard,{key:t,note:e,onDismiss:i,onNoteActionClick:u,onBodyLinkClick:y,onNoteVisible:p}))}))),b?null:v?(0,a.createElement)(c.CardFooter,{className:"wooocommerce-inbox-card__footer",size:"medium"},(0,a.createElement)(c.Button,{isPrimary:!0,onClick:()=>{w()}},x.length>g.per_page?(0,s.__)("Show more","woocommerce"):(0,s.__)("Show older","woocommerce"))):(0,a.createElement)(_.InboxNotePlaceholder,{className:"banner message-is-unread"}))})({loadMoreNotes:()=>{(0,l.recordEvent)("inbox_action_load_more",{quantity_shown:S.length}),u(o+10)},hasNotes:(0,h.kS)(S),isBatchUpdating:I,notes:S,onDismiss:async e=>{(0,l.recordEvent)("inbox_action_dismiss",{note_name:e.name,note_title:e.title,note_name_dismiss_all:!1,note_name_dismiss_confirmation:!0,screen:O});const t=e.id;try{await M(t),R("getNotes"),T("success",(0,s.__)("Message dismissed","woocommerce"),{actions:[{label:(0,s.__)("Undo","woocommerce"),onClick:async()=>{await U(t,{is_deleted:0}),R("getNotes")}}]})}catch(e){T("error",(0,s._n)("Message could not be dismissed","Messages could not be dismissed",1,"woocommerce"))}},onNoteActionClick:(e,t)=>{B(e.id,t.id)},onNoteVisible:e=>{f[e.id]||e.is_read||(D({...f,[e.id]:!0}),setTimeout((()=>{U(e.id,{is_read:!0})}),3e3)),(0,l.recordEvent)("inbox_note_view",{note_content:e.content,note_name:e.name,note_title:e.title,note_type:e.type,screen:O})},setShowDismissAllModal:L,showHeader:t,allNotesFetched:k,notesHaveResolved:P,unreadNotesCount:Z}))))}}}]);