Module 435738

1,587 characters · in no known chunk
Dependencies
Lazily required by (0)none
Lazily requires (0)none
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>v}),n(321073);var r=n(311907),i=n(73153),s=n(927813);let a=2592e6,o=3*s.A.Millis.DAY,l=2048,u=()=>({itemImpressions:[],hidden:!1}),c=u(),d=new Set,_=new Set,f=0,p=!1,h=!1,m=1e3;function E(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!e&&Date.now()<f)return;let t=0,n=Date.now()-a;for(let e=0;e<c.itemImpressions.length;e++){let[r,i]=c.itemImpressions[e];if(i<n)t=e+1;else break}t>0&&(c.itemImpressions=c.itemImpressions.slice(t)),c.itemImpressions.length>l&&(c.itemImpressions=c.itemImpressions.slice(-l));let r=h?m:o,i=new Set,s=new Set,u=Date.now()-r,E=null;for(let[e,t]of c.itemImpressions)t<u?i.add(e):null==E&&(E=t+r),s.add(e);d=i,_=s,f=E??1/0,p=!0}function g(e){let{itemIds:t}=e;p||E();let n=Date.now(),r=!1;for(let e of t)_.has(e)||(c.itemImpressions.push([e,n]),r=!0);return E(r),r}function A(){c.itemImpressions=[],E(!0)}function I(){return console.log("Item impressions:",c.itemImpressions),!1}function T(){h=!h}function S(){c.hidden=!c.hidden}class y extends r.Ay.PersistedStore{static displayName="ContentInventoryPersistedStore";static persistKey="ContentInventoryPersistedStore";initialize(e){c={...c,...e??{}}}getState(){return c}getImpressionCappedItemIds(){return E(),d}getDebugFastImpressionCappingEnabled(){return h}get hidden(){return c.hidden}reset(){c=u()}}let v=new y(i.h,{CONTENT_INVENTORY_TRACK_ITEM_IMPRESSIONS:g,CONTENT_INVENTORY_DEBUG_CLEAR_IMPRESSIONS:A,CONTENT_INVENTORY_DEBUG_LOG_IMPRESSIONS:I,CONTENT_INVENTORY_DEBUG_TOGGLE_FAST_IMPRESSION_CAPPING:T,CONTENT_INVENTORY_TOGGLE_FEED_HIDDEN:S})}