PageSourceSearch

https://assets.coursehero.com/ssi/header-components-notification-bell.a45f4278ba8da3a90c4b.js

js coursehero.com collected 2026-09-24 08:30:08 UTC 15,518 bytes, 2 lines download raw bytes

1(self.globalSSILoad=self.globalSSILoad||[]).push([[543],{3350403667:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>a});var o=n(4579028391),i=n.n(o)()((function(t){return t[1]}));i.push([t.id,".gjJht\\+SO-lLCTi2Rkdqtvw\\=\\={-ms-overflow-style:none;scrollbar-width:none}.gjJht\\+SO-lLCTi2Rkdqtvw\\=\\=::-webkit-scrollbar{display:none}",""]),i.locals={notificationPopover:"gjJht+SO-lLCTi2Rkdqtvw=="};const a=i},553776903:(t,e,n)=>{var o=n(3350403667),i=n(1619006158),a="string"==typeof o?[[t.id,o,""]]:o;void 0!==a.default&&(a=a.default),(e=t.exports=a.locals||{})._getContent=function(){return a},e._getCss=function(){return""+a},e._insertCss=function(t){return i(a,t)}},1398713647:(t,e,n)=>{"use strict";n.r(e),n.d(e,{NotificationBell:()=>jt});var o=n(6950451566),i=n.n(o);function a(){return a=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},a.apply(this,arguments)}const r="SET_INFO",c=(t,e)=>{t({type:r,info:e})};function s(){return s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},s.apply(this,arguments)}const l="SET_NOTIFICATIONS",u=(t,e)=>{t({type:l,notifications:e})},f=t=>{const e=t.map((t=>t.notification_id));return t=>-1===e.indexOf(t.notification_id)};var w=n(6433816403),d=n(3898329665);function m(t,e,n,o,i,a,r){try{var c=t[a](r),s=c.value}catch(t){return void n(t)}c.done?e(s):Promise.resolve(s).then(o,i)}function p(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function r(t){m(a,o,i,r,c,"next",t)}function c(t){m(a,o,i,r,c,"throw",t)}r(void 0)}))}}function h(){return h=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},h.apply(this,arguments)}const g={notification_count:0,unseen_count:0,newest_notification:new Date(0)},v=p((function*(){try{const t=yield(0,d.handleStandardResponse)(yield fetch("/api/v1/users/notifications/info/"));if(204===t.status)return g;const e=yield t.json();return{notification_count:parseInt(e.notification_count),unseen_count:parseInt(e.unseen_count),newest_notification:new Date(e.newest_notification)}}catch(t){throw t}})),y=p((function*({before:t,since:e,id:n}){try{const o=yield(0,d.handleStandardResponse)(yield fetch(`/api/v1/users/notifications/${N({before:t?x(t):void 0,since:e?x(e):void 0,id:n})}`));if(204===o.status)return[];return(yield o.json()).map(O)}catch(t){throw t}})),b=p((function*(t){return yield(0,d.handleStandardResponse)(yield fetch(`/api/v1/users/notifications/seen/${N({before:t?x(t):void 0})}`,{method:"POST"}))})),_=p((function*(t){return yield(0,d.handleStandardResponse)(yield fetch(`/api/v1/users/notifications/${t.notification_id}/acknowledge/`,{method:"POST"}))})),E=p((function*(t){return yield(0,d.handleStandardResponse)(yield fetch(`/api/v1/users/notifications/${t.notification_id}/`,{method:"DELETE"}))})),x=t=>Math.floor(t.getTime()/1e3),N=t=>{const e=[];for(const[n,o]of Object.entries(t))null!=o&&e.push(`${n}=${encodeURIComponent(o)}`);return 0===e.length?"":`?${e.join("&")}`},O=t=>h({},t,{notification_date:new Date(t.notification_date),acknowledged:!!t.acknowledged}),S={info:g,notifications:[],open:!1},j=i().createContext({state:S,dispatch:()=>{}}),k=()=>i().useContext(j).state,T=()=>i().useContext(j).dispatch,M=j;function C(){return C=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},C.apply(this,arguments)}const P="MARK_ALL_SEEN",R=t=>{t({type:P})};function A(){return A=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},A.apply(this,arguments)}const I="REMOVE_NOTIFICATIONS",L=(t,e)=>{t({type:I,notificationsToRemove:e})};function $(){return $=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},$.apply(this,arguments)}const D="INCREASE_UNSEEN_COUNT",F=t=>{t({type:D})};function H(){return H=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},H.apply(this,arguments)}const J="SET_OPEN",W=(t,e)=>{t({type:J,open:e})},q=(t,e)=>{switch(e.type){case r:return((t,e)=>a({},t,{info:e.info}))(t,e);case P:return((t,e)=>C({},t,{info:C({},t.info,{unseen_count:0})}))(t);case l:return((t,e)=>
1{const n=t.info,o=[...t.notifications.filter(f(e.notifications)),...e.notifications].sort(((t,e)=>e.notification_date.getTime()-t.notification_date.getTime())),i=o.length>0?o[o.length-1].notification_date:null;let a=n.notification_count;return a<o.length&&(a=o.length),s({},t,{info:s({},n,{newest_notification:i||n.newest_notification,notification_count:a}),notifications:o})})(t,e);case J:return((t,e)=>H({},t,{open:e.open}))(t,e);case I:return((t,e)=>{const n=t.info,o=[...t.notifications.filter(f(e.notificationsToRemove))].sort(((t,e)=>e.notification_date.getTime()-t.notification_date.getTime()));return A({},t,{info:A({},n,{notification_count:n.notification_count-e.notificationsToRemove.length}),notifications:o})})(t,e);case D:return(t=>$({},t,{info:$({},t.info,{unseen_count:t.info.unseen_count+1})}))(t)}return t};var B=n(627207613),U=n.n(B),z=n(6204216226);const V=()=>{const{info:t,open:e}=k(),n=t.unseen_count;return i().createElement("span",{className:U()("tw-relative tw-p-1 tw-rounded-full tw-w-[38px] tw-flex",{"tw-bg-pink-10":e,"tw-justify-center":0===n})},i().createElement(z.A,{className:"tw-w-[26px] tw-text-gray-80"}),n>0&&i().createElement("span",{className:"tw-right-1 tw-bg-pink-30 -tw-top-2 tw-absolute tw-text-gray-10 tw-rounded-full tw-flex tw-items-center tw-justify-center tw-w-10 tw-h-10 tw-text-sm tw-justify-middle"},n))};var Y=n(5178190483),K=n(5793949263),X=n.n(K),G=n(5715343393),Q=n(2485027752);const Z=({})=>i().createElement("div",{className:"tw-p-20 tw-text-center tw-w-full tw-text-gray-50 tw-text-lg tw-font-medium tw-bg-white tw-rounded-lg tw-shadow-md"},i().createElement(Q.A,{id:"notification.empty",defaultMessage:"You have no notifications"}));var tt=n(3717649176),et=n(7125872910);const nt=t=>{if(("url"==t.action_type||"hash"==t.action_type)&&t.action_data&&t.action_data.url){var e=t.action_data.url;for(var n in t.action_params)t.action_params.hasOwnProperty(n)&&(e=e.replace(":"+n,t.action_params[n].toString()));if("hash"==t.action_type){var o="#/"+t.action_data.url;window.location.hash=o}else"url"==t.action_type&&(window.location.href=e)}},ot=(t,e)=>{(0,tt.trackCtaClicked)({actionType:tt.ActionType.SECONDARY,text:t,intent:e||t,xpath:et.rI})};var it=n(19703092),at=n(4596923113),rt=n(4697320113);const ct=({notification:t})=>{const[e,n]=i().useState(!1),o=T();return i().createElement(rt.A,{className:U()("tw-w-10 tw-text-gray-50",{"tw-opacity-80":e}),onClick:()=>{e||(ot("X","Remove Notification"),n(!0),L(o,[t]),E(t).then((()=>{})).catch((()=>{})).finally((()=>{n(!1)})))}})};var st=n(3915538307);function lt(t,e,n,o,i,a,r){try{var c=t[a](r),s=c.value}catch(t){return void n(t)}c.done?e(s):Promise.resolve(s).then(o,i)}function ut(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function r(t){lt(a,o,i,r,c,"next",t)}function c(t){lt(a,o,i,r,c,"throw",t)}r(void 0)}))}}function ft(){return ft=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},ft.apply(this,arguments)}const wt=({notification:t})=>{const[e,n]=i().useState(!1),o=((0,st.A)(),T()),a=t.acknowledged,r=i().useCallback(ut((function*(){if(!e)return n(!0),_(t).then((()=>{u(o,[ft({},t,{acknowledged:!0})])})).finally((()=>{n(!1)}))})),[e,t]);return i().createElement("li",{className:"tw-w-full tw-border-gray-30 tw-bg-white tw-rounded-md tw-shadow-md hover:tw-bg-blue-10 tw-mb-4 last:tw-mb-0"},i().createElement("div",{className:"tw-flex tw-py-8 tw-px-6"},i().createElement("div",{className:"tw-grow-0 tw-pl-4"},!a&&i().createElement("span",{className:"tw-w-6 tw-h-6 tw-bg-green-40 tw-rounded-full tw-inline-block"}),a&&i().createElement("span",{className:"tw-w-6 tw-h-6 tw-bg-gray-30 tw-rounded-full tw-inline-block"})),i().createElement("div",{className:"tw-grow tw-flex-1 tw-basis-64 tw-px-8 tw-text-md tw-cursor-pointer tw-leading-10 tw-overflow-hidden tw-text-ellipsis",onClick:()=>{ot(t.title,"View Notification"),a?nt(t):r().then((()=>{nt(t)}))}},i().createElement("span",{className:"tw-font-medium",dangerouslySetInnerHTML:{__html:t.title}}
1),i().createElement("div",{className:"tw-w-full tw-flex tw-justify-between tw-pt-8 tw-text-sm"},i().createElement("div",null,i().createElement("em",{className:"tw-not-italic tw-text-gray-60"},(0,at.A)(t.notification_date))),!a&&i().createElement(it.$,{className:U()("!tw-text-sm tw-underline",{"tw-opacity-75":e}),variant:"link-secondary",size:"sm",onClick:t=>{null==t||t.stopPropagation(),ot("Mark As Read"),r()}},i().createElement(Q.A,{id:"notification.markAsRead",defaultMessage:"Mark as read"})))),i().createElement("div",{className:"tw-grow-0 tw-pl-6 tw-flex tw-items-start"},i().createElement(ct,{notification:t}))))},dt=n.p+"20cdc6717fdc03e0b4b7.svg",mt=({})=>i().createElement("div",{className:"tw-w-full tw-px-6 tw-mt-6"},i().createElement("div",{className:"tw-p-6 tw-text-center tw-w-full tw-text-gray-50 tw-text-lg tw-font-medium tw-bg-white tw-rounded-lg tw-shadow-md tw-mb-6"},i().createElement("img",{src:dt,alt:"Loading...",className:"tw-animate-[pulse_500ms_ease-in-out_infinite] tw-w-full"})),i().createElement("div",{className:"tw-p-6 tw-text-center tw-w-full tw-text-gray-50 tw-text-lg tw-font-medium tw-bg-white tw-rounded-lg tw-shadow-md tw-mb-6"},i().createElement("img",{src:dt,alt:"Loading...",className:"tw-animate-[pulse_500ms_ease-in-out_infinite] tw-w-full"})),i().createElement("div",{className:"tw-p-6 tw-text-center tw-w-full tw-text-gray-50 tw-text-lg tw-font-medium tw-bg-white tw-rounded-lg tw-shadow-md"},i().createElement("img",{src:dt,alt:"Loading...",className:"tw-animate-[pulse_500ms_ease-in-out_infinite] tw-w-full"})));var pt=n(5193263406),ht=n(553776903),gt=n.n(ht);const vt=({hasMore:t,loadMore:e})=>{X()(gt());const{pageHeight:n,isMobile:a}=(0,w.mp)(),{notifications:r,info:c}=k(),s=T(),l=(0,st.A)();return(0,o.useEffect)((()=>(W(s,!0),ot("Notification Bell","Open Notifications Menu"),()=>{W(s,!1)})),[s]),(0,o.useEffect)((()=>{c.unseen_count>0&&(R(s),b().catch((t=>{}))),e(!0)}),[c.unseen_count]),i().createElement("div",{onClick:t=>{t.stopPropagation()},className:"tw-w-full tw-bg-gray-20",style:{overflow:"auto",display:"flex",flexDirection:"column"}},i().createElement("h4",{className:"tw-pl-8 tw-pt-12 tw-pb-4 tw-text-black tw-font-medium tw-flex tw-items-center tw-text-md tw-leading-3"},i().createElement("span",{className:"tw-min-w-[3rem] tw-px-1 tw-h-9 tw-mr-3 tw-bg-gray-40 tw-rounded-full tw-flex tw-justify-center tw-items-center"},c.notification_count)," ",(0,G.t)(c.notification_count,[l.formatMessage({id:"notification",defaultMessage:"Notification"}),l.formatMessage({id:"notifications",defaultMessage:"Notifications"})])),i().createElement(pt.J,{open}),i().createElement(Y.A,{dataLength:r.length,next:e,hasMore:t,loader:i().createElement(mt,null),height:a?n:300,className:gt().notificationPopover},i().createElement("ul",{className:"tw-w-f tw-px-4"},r.map((t=>i().createElement(wt,{key:t.notification_id,notification:t}))),0===r.length&&!t&&i().createElement(Z,null))))};var yt=n(1400628055),bt=n.n(yt),_t=n(818107561);const Et=t=>{const e=T(),{userState:n}=(0,w.mp)(),{userId:i}=n,a=`v1.notification_bell.${i}.owner`,r=(0,_t.useWebsocket)();(0,o.useEffect)((()=>{const e=setInterval((()=>{r&&r.connected&&void 0!==r.subscriptions[a]||t(!1)}),3e4);return()=>{clearInterval(e)}}),[a,t,r]);const c=(0,o.useCallback)((t=>{u(e,[O(t.data.notification)]),F(e)}),[e]);bt()(a,c)},xt=t=>{const{loadMore:e}=t;return Et(e),null};var Nt=n(4311282653),Ot=n(7073935324);const St=({buttonComponent:t,children:e,align:n="center",className:a="",fullScreenMobile:r=!1})=>{const{pageHeight:c,isMobile:s}=(0,w.mp)(),l=r&&s,u="center"===n&&!l,f="right"===n&&!l,d="left"===n&&!l;let m={};return l&&(m.height=`${c+20}px`),i().createElement(Nt.A,{className:U()({"tw-relative":!l})},i().createElement(i().Fragment,null,i().createElement(Nt.A.Button,{className:"tw-text-opacity-90 tw-text-base tw-font-medium hover:tw-text-opacity-100 tw-flex"},t),i().createElement(Ot.e,{as:o.Fragment,enter:"transition ease-out duration-200",enterFrom:"opacity-0 translate-y-1",enterTo:"opacity-100 translate-y-0",leave:"transition ease-in duration-150",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 translate-y-1"},i().createElement(Nt.A.Panel,{style:m,className:U()("tw-absolute tw-z-10 tw-mt-3 tw-w-screen tw-transform tw-px-4 sm:tw-px-0 tw-flex",{"tw-left-1/2 -tw-translate-x-1/2":u,"tw-right-0":f,"lg:tw-max-w-3xl":!l,"md:tw-max-w-3xl":!l,"tw-left-0 tw-h-full":l,"tw-left-0":d})},i().createElement("div",{className:U()(`tw-overflow-hidden tw-flex-1 tw-flex-row tw-flex ${a}`,{"tw-rounded-lg":!l,"tw-shadow-lg":!l})},e)))))},jt=()=>{const{isStudySpace:t}=(0,w.mp)(),[e,n]=(0,o.useReducer)(q,S),[a,r]=(0,o.useState)(!0),[s,l]=(0,o.useState)(!0),f=(0,o.useRef)(0),d=(0,o.useRef)(0),{notifications:m}=e;(0,o.useEffect)((()=>{v().then((t=>{c(n,t)})).catch((()=>{}))}),[]);const p=(0,o.useCallback)(((t=!1)=>{const e=m.length>0?m[m.length-1]:null;Date.now()<d.current||s&&y(e&&!t?{before:e.notification_date,id:e.notification_id}:{}).then((e=>{f.current=0,setTimeout((()=>{(0===e.length||t&&e.length<4)&&r(!1),u(n,e)}),750)})).catch((t=>{if([401,403].includes(t.code))return l(!1),void r(!1);f.current+=1,d.current=Date.now()+2500*Math.pow(2,f.current-1),f.current>=10&&(l(!1),r(!1))}))}),[m,s]),h=t?"left":"right";return i().createElement(M.Provider,{value:{state:e,dispatch:n}}
1,i().createElement(xt,{loadMore:p}),i().createElement(St,{align:h,buttonComponent:i().createElement(V,null),className:"tw-bg-gray-20 tw-mt-2",fullScreenMobile:!0},i().createElement(vt,{hasMore:a,loadMore:p})))}},1400628055:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t,e){for(var n in e)Object.defineProperty(t,n,{enumerable:!0,get:e[n]})}(e,{default:function(){return r},useWebsocketSubscription:function(){return a}});const o=n(6950451566),i=n(818107561),a=(t,e)=>{const n=(0,i.useWebsocket)();(0,o.useEffect)((()=>{if(""===t||void 0===n)return;const o=n.subscribe(t,e);return()=>{o()}}),[e,t,n])},r=a},818107561:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"useWebsocket",{enumerable:!0,get:function(){return r}});const o=n(6950451566),i=a(n(7018072389));function a(t){return t&&t.__esModule?t:{default:t}}const r=()=>{const[t,e]=(0,o.useState)(i.default),[n,a]=(0,o.useState)(1);return(0,o.useEffect)((()=>{if(void 0!==t)return;if(void 0!==window.connectionHandler&&void 0===t)return void e(window.connectionHandler);if(n>=10)return;const o=setTimeout((()=>{a(n+1),void 0!==window.connectionHandler&&e(window.connectionHandler)}),500*n);return()=>{clearTimeout(o)}}),[t,n]),t}}}]);
2//# sourceMappingURL=header-components-notification-bell.a45f4278ba8da3a90c4b.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.