@articles-media/articles-dev-box 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/Ad.cjs +1 -0
  2. package/dist/Ad.js +604 -0
  3. package/dist/AdConfirmExitModal-CKkMAvBK.js +72 -0
  4. package/dist/AdConfirmExitModal-CcSxmXKT.cjs +1 -0
  5. package/dist/AdDetailsModal-Bp5hZm9N.js +83 -0
  6. package/dist/AdDetailsModal-k840vrS2.cjs +1 -0
  7. package/dist/ArticlesAd.cjs +1 -0
  8. package/dist/ArticlesAd.js +16 -0
  9. package/dist/Button-0ZK0NKiK.cjs +1 -0
  10. package/dist/Button-_Quon8UV.js +54 -0
  11. package/dist/FriendsList.cjs +1 -0
  12. package/dist/FriendsList.js +135 -0
  13. package/dist/GameScoreboard.cjs +1 -0
  14. package/dist/GameScoreboard.js +190 -0
  15. package/dist/GlobalBody-BQ2qC81K.cjs +33 -0
  16. package/dist/GlobalBody-tmIC_GWn.js +123 -0
  17. package/dist/GlobalBody.cjs +1 -0
  18. package/dist/GlobalBody.js +7 -0
  19. package/dist/GlobalHead.cjs +1 -0
  20. package/dist/GlobalHead.js +13 -0
  21. package/dist/Modal-C9oYRgI1.js +2073 -0
  22. package/dist/Modal-Wmqy9fOm.cjs +2 -0
  23. package/dist/ReturnToLauncherButton.cjs +1 -0
  24. package/dist/ReturnToLauncherButton.js +55 -0
  25. package/dist/StatusModal-BlwaI-2B.cjs +1 -0
  26. package/dist/StatusModal-CAVxWCUq.js +71 -0
  27. package/dist/ViewUserModal.cjs +1 -0
  28. package/dist/ViewUserModal.js +3189 -0
  29. package/dist/articles-dev-box.css +1 -0
  30. package/dist/index-BlP2-uOi.cjs +1 -0
  31. package/dist/index-DLYx67wi.js +2394 -0
  32. package/dist/index-Ddv_TnxK.cjs +6 -0
  33. package/dist/index-YnD2EP-S.js +43 -0
  34. package/dist/index.cjs +1 -0
  35. package/dist/index.js +22 -0
  36. package/dist/jsx-runtime-nZSsnGb7.cjs +6 -0
  37. package/dist/jsx-runtime-tc70JA_2.js +264 -0
  38. package/dist/numberWithCommas-CRgrb58X.cjs +1 -0
  39. package/dist/numberWithCommas-DnAkiOFL.js +1256 -0
  40. package/dist/useUserDetails.cjs +1 -0
  41. package/dist/useUserDetails.js +33 -0
  42. package/dist/useUserToken.cjs +1 -0
  43. package/dist/useUserToken.js +22 -0
  44. package/package.json +1 -1
package/dist/Ad.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";const e=require("./jsx-runtime-nZSsnGb7.cjs"),c=require("react"),v=require("./numberWithCommas-CRgrb58X.cjs"),R=require("./index-Ddv_TnxK.cjs"),Z=require("./Button-0ZK0NKiK.cjs"),ee=require("./index-BlP2-uOi.cjs");function se(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const i in s)if(i!=="default"){const r=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:()=>s[i]})}}return t.default=s,Object.freeze(t)}const A=se(c);var C=new Map,M=new WeakMap,W=0,te;function ne(s){return s?(M.has(s)||(W+=1,M.set(s,W.toString())),M.get(s)):"0"}function re(s){return Object.keys(s).sort().filter(t=>s[t]!==void 0).map(t=>`${t}_${t==="root"?ne(s.root):s[t]}`).toString()}function ie(s){const t=re(s);let i=C.get(t);if(!i){const r=new Map;let l;const u=new IntersectionObserver(x=>{x.forEach(o=>{var p;const N=o.isIntersecting&&l.some(j=>o.intersectionRatio>=j);s.trackVisibility&&typeof o.isVisible>"u"&&(o.isVisible=N),(p=r.get(o.target))==null||p.forEach(j=>{j(N,o)})})},s);l=u.thresholds||(Array.isArray(s.threshold)?s.threshold:[s.threshold||0]),i={id:t,observer:u,elements:r},C.set(t,i)}return i}function oe(s,t,i={},r=te){if(typeof window.IntersectionObserver>"u"&&r!==void 0){const p=s.getBoundingClientRect();return t(r,{isIntersecting:r,target:s,intersectionRatio:typeof i.threshold=="number"?i.threshold:0,time:0,boundingClientRect:p,intersectionRect:p,rootBounds:p}),()=>{}}const{id:l,observer:u,elements:x}=ie(i),o=x.get(s)||[];return x.has(s)||x.set(s,o),o.push(t),u.observe(s),function(){o.splice(o.indexOf(t),1),o.length===0&&(x.delete(s),u.unobserve(s)),x.size===0&&(u.disconnect(),C.delete(l))}}function ae({threshold:s,delay:t,trackVisibility:i,rootMargin:r,root:l,triggerOnce:u,skip:x,initialInView:o,fallbackInView:p,onChange:N}={}){var j;const[_,b]=A.useState(null),n=A.useRef(N),a=A.useRef(o),[k,D]=A.useState({inView:!!o,entry:void 0});n.current=N,A.useEffect(()=>{if(a.current===void 0&&(a.current=o),x||!_)return;let g;return g=oe(_,(f,E)=>{const P=a.current;a.current=f,!(P===void 0&&!f)&&(D({inView:f,entry:E}),n.current&&n.current(f,E),E.isIntersecting&&u&&g&&(g(),g=void 0))},{root:l,rootMargin:r,threshold:s,trackVisibility:i,delay:t},p),()=>{g&&g()}},[Array.isArray(s)?s.toString():s,_,l,r,u,x,i,p,t]);const y=(j=k.entry)==null?void 0:j.target,S=A.useRef(void 0);!_&&y&&!u&&!x&&S.current!==y&&(S.current=y,D({inView:!!o,entry:void 0}),a.current=o);const m=[b,k.inView,k.entry];return m.ref=m[0],m.inView=m[1],m.entry=m[2],m}const ce=async s=>{if(process.env.NODE_ENV==="development")try{return(await R.axios.get(`http://localhost:3001/api/ads/${s.ad_id}`,{params:{ad_id:s.ad_id,user_ad_token:s.user_ad_token}})).data.result}catch{}return R.axios.get(s.url,{params:{ad_id:s.ad_id}}).then(t=>t.data.result)},le=60,de={dedupingInterval:1e3*60*le},ue=(s,t)=>{const{data:i,error:r,isLoading:l,mutate:u}=R.useSWR(s?{url:`https://articles.media/api/ads/${s}`,ad_id:s,user_ad_token:t}:null,ce,de);return{data:i,error:r,isLoading:l,mutate:u}};function xe(s){return t=>{const r=(s?Math[s]:Math.trunc)(t);return r===0?0:r}}function me(s,t){return+v.toDate(s)-+v.toDate(t)}function z(s,t,i){const r=me(s,t)/v.millisecondsInMinute;return xe(i?.roundingMethod)(r)}function U(s){return Math.trunc(s*v.millisecondsInMinute)}const pe=async s=>{if(process.env.NODE_ENV==="development")try{return(await R.axios.get("http://localhost:3001/api/ads",{params:{}})).data}catch{}return R.axios.get(s.url,{params:{}}).then(t=>t.data)},X=60,je={dedupingInterval:U(X),focusThrottleInterval:U(X)},fe=s=>{const{data:t,error:i,isLoading:r,mutate:l}=R.useSWR(s?.loading||s?.disabled?null:{url:"https://articles.media/api/ads"},pe,je);return{data:t,error:i,isLoading:r,mutate:l}},he=c.lazy(()=>Promise.resolve().then(()=>require("./AdDetailsModal-k840vrS2.cjs"))),ve=c.lazy(()=>Promise.resolve().then(()=>require("./AdConfirmExitModal-CcSxmXKT.cjs")));function ge(s,t){return Math.floor(Math.random()*(t-s+1))+s}function Ee(s){let{previewMode:t,darkMode:i,user_ad_token:r,userDetails:l,userDetailsLoading:u,prepend:x,append:o}=s;const p=!1,N=[],[j,_]=c.useState(null),{data:b}=fe({loading:u,disabled:l?.articles_membership?.status=="Active"}),{data:n}=ue(j,r);let a=s.previewData||{};const[k,D]=c.useState(null),[y,S]=c.useState(null),[m,g]=c.useState(null),[f,E]=c.useState(0),[P,K]=c.useState(!1),[$,L]=c.useState(!1),[F,O]=c.useState(!1),[Ne,be]=c.useState(new Date),[V,G]=c.useState([]);c.useEffect(()=>{b&&b?.length>0&&!j&&(console.log("Ad Mounted or reduxAds changed"),_(s.ad_id||b[ge(0,b?.length-1)]?._id))},[b]),c.useEffect(()=>{},[n]),c.useEffect(()=>{n?.populated_promos&&f>=0&&g(n?.populated_promos[f])},[f,n]);function H(){L(!$)}const{ref:J,inView:w}=ae({threshold:0,triggerOnce:!0});function T(d){if(t&&console.log("Preventing this event from being logged as this ad is being shown in preview mode."),V.find(h=>h==d)){console.log("Already logged this event");return}R.axios.get("/api/ads/event",{params:{ad_id:n?._id,event:d}}).then(function(h){G([...V,d]),console.log(h.data)}).catch(function(h){console.log(h)})}c.useEffect(()=>{if(!t&&(console.log("inView",w),w&&j)){let d=[{ad_id:j,date:new Date().toString()},...N.filter(h=>{if(console.log(z(new Date,new Date(h.date))),z(new Date,new Date(h.date))>5){console.log("adsViewed - Remove Old Ad View Object");return}else return console.log("adsViewed - Keep Ad View Object"),h})];console.log("unexpiredRecentViews",d)}},[w,j]);const[q,Q]=c.useState(null),[Y,I]=c.useState(!1);function B(){I(!0),console.log("logAdAvoided called",r),R.axios.get(process.env.NODE_ENV==="development"?"http://localhost:3001/api/user/advertising/avoided":"https://articles.media/api/user/advertising/avoided",{params:{user_id:l?._id},headers:{"x-articles-api-key":r}}).then(function(d){I(!1),Q(d.data.avoided_count),console.log(d.data)}).catch(function(d){console.log(d),I(!1)})}return c.useEffect(()=>{t||(console.log("inView",w),l?.articles_membership?.status=="Active"&&w&&B())},[w,l]),u?null:e.jsxRuntimeExports.jsxs("div",{ref:J,className:ee.classNames("ad-wrap",{"active-member":l?.articles_membership?.status=="Active"}),style:{"--articles-ad-background-color":a.background_color||n?.background_color,"--articles-ad-font-color":a.font_color||n?.font_color,"--articles-ad-border-color":a.border_color||n?.border_color},children:[$&&e.jsxRuntimeExports.jsx(he,{setModalShow:L,ad:n,previewData:a}),F&&e.jsxRuntimeExports.jsx(ve,{setModalShow:O,ad:n,previewData:a}),x&&e.jsxRuntimeExports.jsx("div",{className:"prepend-container",children:x}),e.jsxRuntimeExports.jsxs("div",{className:"ad",children:[l?.articles_membership?.status!=="Active"&&e.jsxRuntimeExports.jsxs("div",{className:"main-panel",children:[e.jsxRuntimeExports.jsx("div",{className:"ad-warning flex-header",children:e.jsxRuntimeExports.jsxs("div",{className:"",children:[n?.city&&"Local"," Advertisement"]})}),e.jsxRuntimeExports.jsxs("div",{className:"content-wrap",children:[e.jsxRuntimeExports.jsxs("div",{className:"photo-banner",children:[e.jsxRuntimeExports.jsx("div",{className:"logo",children:(a.logo?.location||n?.logo?.location)&&e.jsxRuntimeExports.jsx("img",{src:a?.logo?.key?`${process.env.NEXT_PUBLIC_CDN}${a?.logo?.key}`:`${process.env.NEXT_PUBLIC_CDN}${n?.logo?.key}`,alt:""})}),e.jsxRuntimeExports.jsx("div",{className:"icon d-none",children:e.jsxRuntimeExports.jsx("i",{className:"fas fa-mug-hot"})}),e.jsxRuntimeExports.jsx("img",{className:"photo",src:a?.background?.key?`${process.env.NEXT_PUBLIC_CDN}${a.background?.key}`:`${process.env.NEXT_PUBLIC_CDN}${n?.background?.key}`,alt:""})]}),e.jsxRuntimeExports.jsxs("div",{className:"details-wrap",children:[e.jsxRuntimeExports.jsxs("div",{className:"detail-title",children:[e.jsxRuntimeExports.jsx("div",{className:"detail",children:e.jsxRuntimeExports.jsx("span",{className:"h4",children:a?.business||n?.business})}),e.jsxRuntimeExports.jsxs("div",{className:"flex flex-column d-none",children:[e.jsxRuntimeExports.jsxs("div",{className:"detail",children:[e.jsxRuntimeExports.jsx("span",{className:"icon",children:e.jsxRuntimeExports.jsx("i",{className:"fas fa-search-location"})}),e.jsxRuntimeExports.jsxs("span",{children:[n?.city,", ",n?.state]})]}),e.jsxRuntimeExports.jsxs("div",{className:"detail",children:[e.jsxRuntimeExports.jsx("span",{className:"icon",children:e.jsxRuntimeExports.jsx("i",{className:"fas fa-clock me-2"})}),e.jsxRuntimeExports.jsx("span",{children:"6:30AM–8PM"})]})]})]}),n?.city&&e.jsxRuntimeExports.jsx("div",{className:"details mb-3 d-none"}),e.jsxRuntimeExports.jsx("div",{className:"short-description",children:a?.description||n?.description})]})]}),p?.roles?.isDev&&n?.populated_promos?.length>0&&e.jsxRuntimeExports.jsxs("div",{children:[m&&e.jsxRuntimeExports.jsx("div",{className:"promos-wrap",children:m&&e.jsxRuntimeExports.jsxs("div",{className:"promo-wrap d-flex justify-content-between align-items-center mx-2 p-1 px-2 border border-2 border-light mb-0",children:[e.jsxRuntimeExports.jsxs("div",{className:"",children:[e.jsxRuntimeExports.jsx("div",{children:m.title}),e.jsxRuntimeExports.jsx("div",{className:"small",children:e.jsxRuntimeExports.jsx("div",{className:"small",children:m.details})})]}),e.jsxRuntimeExports.jsx(Z.ArticlesButton,{className:"px-3",small:!0,onClick:()=>{console.log("Load Save Modal"),K(!0)},children:"Save"})]},m._id)}),e.jsxRuntimeExports.jsxs("div",{className:"d-flex justify-content-between",children:[e.jsxRuntimeExports.jsxs("div",{className:"px-2",children:[n?.populated_promos?.length," Promos Active"]}),e.jsxRuntimeExports.jsxs("div",{className:"controls",children:[e.jsxRuntimeExports.jsx("i",{className:"fad fa-arrow-circle-left",type:"button",onClick:()=>{f==0?E(n?.populated_promos?.length-1):E(d=>d-1)}}),n?.populated_promos?.map((d,h)=>e.jsxRuntimeExports.jsx("i",{className:`fa-square ${h==f?"fad":"fas"}`},d._id)),e.jsxRuntimeExports.jsx("i",{className:"fad fa-arrow-circle-right",type:"button",onClick:()=>{f==n?.populated_promos?.length-1?E(0):E(d=>d+1)}})]})]})]}),e.jsxRuntimeExports.jsx("hr",{style:{borderColor:"white"},className:"mt-auto mb-0"}),e.jsxRuntimeExports.jsxs("div",{className:"action-wrap d-flex justify-content-lg-between px-3 py-2",children:[e.jsxRuntimeExports.jsx("div",{onClick:()=>{H(),T("Details")},className:"action flex-grow-1 flex-shrink-0",children:"Details"}),e.jsxRuntimeExports.jsx("span",{className:"px-4"}),e.jsxRuntimeExports.jsx("a",{className:"action flex-grow-1 flex-shrink-0",href:n?.website,target:"_blank",rel:"noreferrer",onClick:d=>{d.preventDefault(),O(!0),T("Confirm Exit Modal Opened")},children:e.jsxRuntimeExports.jsx("div",{children:"Website"})})]})]}),l?.articles_membership?.status=="Active"&&e.jsxRuntimeExports.jsx("div",{className:"main-panel",children:e.jsxRuntimeExports.jsxs("div",{className:"content-wrap",children:[e.jsxRuntimeExports.jsxs("div",{className:"photo-banner",children:[e.jsxRuntimeExports.jsx("div",{className:"logo"}),e.jsxRuntimeExports.jsxs("div",{className:"splash",children:[e.jsxRuntimeExports.jsx("i",{className:"fas fa-broadcast-tower"}),e.jsxRuntimeExports.jsxs("div",{className:"text",children:[e.jsxRuntimeExports.jsx("div",{className:"count",children:Y?e.jsxRuntimeExports.jsx("i",{className:"fas fa-spinner fa-spin me-0"}):q?v.numberWithCommas(q):0}),e.jsxRuntimeExports.jsx("div",{className:"label",children:"ads avoided."})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"member-since",children:["Member since: ",e.jsxRuntimeExports.jsx(v.ArticlesDate,{format:"PP",date:l?.articles_membership?.membership_started})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"details-wrap",children:[e.jsxRuntimeExports.jsx("div",{className:"detail-title",children:e.jsxRuntimeExports.jsx("div",{className:"detail",children:e.jsxRuntimeExports.jsx("span",{className:"h4",children:"Thanks for the support!"})})}),e.jsxRuntimeExports.jsxs("div",{className:"short-description",children:[e.jsxRuntimeExports.jsx("div",{className:"mb-2",children:"Without support from users like you, we wouldn't be here."}),e.jsxRuntimeExports.jsxs("div",{className:"links-list",children:[e.jsxRuntimeExports.jsxs(v.Link,{newPage:!0,className:"link-item",href:"https://articles.media/messages",children:[e.jsxRuntimeExports.jsx("i",{className:"fas fa-comments-alt"}),"0 unread messages."]}),e.jsxRuntimeExports.jsxs(v.Link,{newPage:!0,className:"link-item",href:"https://articles.media/settings/notifications",onClick:()=>{B()},children:[e.jsxRuntimeExports.jsx("i",{className:"fas fa-bell"}),"0 notifications."]}),e.jsxRuntimeExports.jsxs(v.Link,{newPage:!0,className:"link-item",href:"https://articles.media/settings/account",children:[e.jsxRuntimeExports.jsx("i",{className:"fas fa-cog"}),"Manage account settings."]})]})]})]})]})})]}),o&&e.jsxRuntimeExports.jsx("div",{className:"append-container",children:o}),!t&&e.jsxRuntimeExports.jsx("div",{className:"advertise-with-us p-1",style:{backgroundColor:a.background_color||n?.background_color,color:a.font_color||n?.font_color,borderColor:a.border_color||n?.border_color},children:e.jsxRuntimeExports.jsxs(v.Link,{className:"small d-block w-100 text-center",href:"https://articles.media/advertising",newPage:!0,children:[e.jsxRuntimeExports.jsx("i",{className:"fas fa-share me-1"}),"Advertise with Articles Media!"]})})]})}const Re=c.memo(Ee);module.exports=Re;
package/dist/Ad.js ADDED
@@ -0,0 +1,604 @@
1
+ import { j as e } from "./jsx-runtime-tc70JA_2.js";
2
+ import * as A from "react";
3
+ import { lazy as G, memo as re, useState as p, useEffect as y } from "react";
4
+ import { t as X, m as H, n as ne, A as ie, L as E } from "./numberWithCommas-DnAkiOFL.js";
5
+ import { u as J, a as k } from "./index-DLYx67wi.js";
6
+ import { A as oe } from "./Button-_Quon8UV.js";
7
+ import { c as le } from "./index-YnD2EP-S.js";
8
+ var S = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new WeakMap(), z = 0, de;
9
+ function ce(s) {
10
+ return s ? (I.has(s) || (z += 1, I.set(s, z.toString())), I.get(s)) : "0";
11
+ }
12
+ function ue(s) {
13
+ return Object.keys(s).sort().filter(
14
+ (t) => s[t] !== void 0
15
+ ).map((t) => `${t}_${t === "root" ? ce(s.root) : s[t]}`).toString();
16
+ }
17
+ function me(s) {
18
+ const t = ue(s);
19
+ let l = S.get(t);
20
+ if (!l) {
21
+ const r = /* @__PURE__ */ new Map();
22
+ let o;
23
+ const c = new IntersectionObserver((u) => {
24
+ u.forEach((n) => {
25
+ var h;
26
+ const N = n.isIntersecting && o.some((f) => n.intersectionRatio >= f);
27
+ s.trackVisibility && typeof n.isVisible > "u" && (n.isVisible = N), (h = r.get(n.target)) == null || h.forEach((f) => {
28
+ f(N, n);
29
+ });
30
+ });
31
+ }, s);
32
+ o = c.thresholds || (Array.isArray(s.threshold) ? s.threshold : [s.threshold || 0]), l = {
33
+ id: t,
34
+ observer: c,
35
+ elements: r
36
+ }, S.set(t, l);
37
+ }
38
+ return l;
39
+ }
40
+ function he(s, t, l = {}, r = de) {
41
+ if (typeof window.IntersectionObserver > "u" && r !== void 0) {
42
+ const h = s.getBoundingClientRect();
43
+ return t(r, {
44
+ isIntersecting: r,
45
+ target: s,
46
+ intersectionRatio: typeof l.threshold == "number" ? l.threshold : 0,
47
+ time: 0,
48
+ boundingClientRect: h,
49
+ intersectionRect: h,
50
+ rootBounds: h
51
+ }), () => {
52
+ };
53
+ }
54
+ const { id: o, observer: c, elements: u } = me(l), n = u.get(s) || [];
55
+ return u.has(s) || u.set(s, n), n.push(t), c.observe(s), function() {
56
+ n.splice(n.indexOf(t), 1), n.length === 0 && (u.delete(s), c.unobserve(s)), u.size === 0 && (c.disconnect(), S.delete(o));
57
+ };
58
+ }
59
+ function fe({
60
+ threshold: s,
61
+ delay: t,
62
+ trackVisibility: l,
63
+ rootMargin: r,
64
+ root: o,
65
+ triggerOnce: c,
66
+ skip: u,
67
+ initialInView: n,
68
+ fallbackInView: h,
69
+ onChange: N
70
+ } = {}) {
71
+ var f;
72
+ const [_, b] = A.useState(null), a = A.useRef(N), i = A.useRef(n), [M, C] = A.useState({
73
+ inView: !!n,
74
+ entry: void 0
75
+ });
76
+ a.current = N, A.useEffect(
77
+ () => {
78
+ if (i.current === void 0 && (i.current = n), u || !_) return;
79
+ let x;
80
+ return x = he(
81
+ _,
82
+ (v, j) => {
83
+ const $ = i.current;
84
+ i.current = v, !($ === void 0 && !v) && (C({
85
+ inView: v,
86
+ entry: j
87
+ }), a.current && a.current(v, j), j.isIntersecting && c && x && (x(), x = void 0));
88
+ },
89
+ {
90
+ root: o,
91
+ rootMargin: r,
92
+ threshold: s,
93
+ // @ts-expect-error
94
+ trackVisibility: l,
95
+ delay: t
96
+ },
97
+ h
98
+ ), () => {
99
+ x && x();
100
+ };
101
+ },
102
+ // We break the rule here, because we aren't including the actual `threshold` variable
103
+ // eslint-disable-next-line react-hooks/exhaustive-deps
104
+ [
105
+ // If the threshold is an array, convert it to a string, so it won't change between renders.
106
+ Array.isArray(s) ? s.toString() : s,
107
+ _,
108
+ o,
109
+ r,
110
+ c,
111
+ u,
112
+ l,
113
+ h,
114
+ t
115
+ ]
116
+ );
117
+ const D = (f = M.entry) == null ? void 0 : f.target, R = A.useRef(void 0);
118
+ !_ && D && !c && !u && R.current !== D && (R.current = D, C({
119
+ inView: !!n,
120
+ entry: void 0
121
+ }), i.current = n);
122
+ const m = [b, M.inView, M.entry];
123
+ return m.ref = m[0], m.inView = m[1], m.entry = m[2], m;
124
+ }
125
+ const pe = async (s) => {
126
+ if (process.env.NODE_ENV === "development")
127
+ try {
128
+ return (await k.get(`http://localhost:3001/api/ads/${s.ad_id}`, {
129
+ params: {
130
+ ad_id: s.ad_id,
131
+ user_ad_token: s.user_ad_token
132
+ }
133
+ })).data.result;
134
+ } catch {
135
+ }
136
+ return k.get(s.url, {
137
+ params: {
138
+ ad_id: s.ad_id
139
+ }
140
+ }).then((t) => t.data.result);
141
+ }, ve = 60, ge = {
142
+ dedupingInterval: 1e3 * 60 * ve
143
+ // keepPreviousData: true,
144
+ // fallbackData: []
145
+ }, xe = (s, t) => {
146
+ const { data: l, error: r, isLoading: o, mutate: c } = J(
147
+ s ? {
148
+ url: `https://articles.media/api/ads/${s}`,
149
+ ad_id: s,
150
+ user_ad_token: t
151
+ } : null,
152
+ pe,
153
+ ge
154
+ );
155
+ return {
156
+ data: l,
157
+ error: r,
158
+ isLoading: o,
159
+ mutate: c
160
+ };
161
+ };
162
+ function je(s) {
163
+ return (t) => {
164
+ const r = (s ? Math[s] : Math.trunc)(t);
165
+ return r === 0 ? 0 : r;
166
+ };
167
+ }
168
+ function Ne(s, t) {
169
+ return +X(s) - +X(t);
170
+ }
171
+ function q(s, t, l) {
172
+ const r = Ne(s, t) / H;
173
+ return je(l?.roundingMethod)(r);
174
+ }
175
+ function K(s) {
176
+ return Math.trunc(s * H);
177
+ }
178
+ const be = async (s) => {
179
+ if (process.env.NODE_ENV === "development")
180
+ try {
181
+ return (await k.get("http://localhost:3001/api/ads", {
182
+ params: {
183
+ // ad_id: data.ad_id
184
+ }
185
+ })).data;
186
+ } catch {
187
+ }
188
+ return k.get(s.url, {
189
+ params: {
190
+ // ad_id: data.ad_id
191
+ }
192
+ }).then((t) => t.data);
193
+ }, F = 60, _e = {
194
+ dedupingInterval: K(F),
195
+ focusThrottleInterval: K(F)
196
+ // keepPreviousData: true,
197
+ // fallbackData: []
198
+ }, we = (s) => {
199
+ const { data: t, error: l, isLoading: r, mutate: o } = J(
200
+ s?.loading || s?.disabled ? null : {
201
+ url: "https://articles.media/api/ads"
202
+ // ad_id
203
+ },
204
+ be,
205
+ _e
206
+ );
207
+ return {
208
+ data: t,
209
+ error: l,
210
+ isLoading: r,
211
+ mutate: o
212
+ };
213
+ }, Ae = G(() => import("./AdDetailsModal-Bp5hZm9N.js")), ke = G(() => import("./AdConfirmExitModal-CKkMAvBK.js"));
214
+ function ye(s, t) {
215
+ return Math.floor(Math.random() * (t - s + 1)) + s;
216
+ }
217
+ function Me(s) {
218
+ let {
219
+ previewMode: t,
220
+ darkMode: l,
221
+ user_ad_token: r,
222
+ userDetails: o,
223
+ userDetailsLoading: c,
224
+ prepend: u,
225
+ append: n
226
+ } = s;
227
+ const h = !1, N = [], [f, _] = p(null), {
228
+ data: b
229
+ } = we(
230
+ {
231
+ loading: c,
232
+ disabled: o?.articles_membership?.status == "Active"
233
+ }
234
+ ), { data: a } = xe(f, r);
235
+ let i = s.previewData || {};
236
+ const [M, C] = p(null), [D, R] = p(null), [m, x] = p(null), [v, j] = p(0), [$, Q] = p(!1), [L, V] = p(!1), [Y, O] = p(!1), [De, Ee] = p(/* @__PURE__ */ new Date()), [T, Z] = p([]);
237
+ y(() => {
238
+ b && b?.length > 0 && !f && (console.log("Ad Mounted or reduxAds changed"), _(s.ad_id || b[ye(0, b?.length - 1)]?._id));
239
+ }, [b]), y(() => {
240
+ }, [a]), y(() => {
241
+ a?.populated_promos && v >= 0 && x(a?.populated_promos[v]);
242
+ }, [v, a]);
243
+ function ee() {
244
+ V(!L);
245
+ }
246
+ const { ref: se, inView: w } = fe({
247
+ /* Optional options */
248
+ threshold: 0,
249
+ triggerOnce: !0
250
+ });
251
+ function B(d) {
252
+ if (t && console.log("Preventing this event from being logged as this ad is being shown in preview mode."), T.find((g) => g == d)) {
253
+ console.log("Already logged this event");
254
+ return;
255
+ }
256
+ k.get("/api/ads/event", {
257
+ params: {
258
+ ad_id: a?._id,
259
+ event: d
260
+ }
261
+ }).then(function(g) {
262
+ Z([...T, d]), console.log(g.data);
263
+ }).catch(function(g) {
264
+ console.log(g);
265
+ });
266
+ }
267
+ y(() => {
268
+ if (!t && (console.log("inView", w), w && f)) {
269
+ let d = [
270
+ {
271
+ ad_id: f,
272
+ date: (/* @__PURE__ */ new Date()).toString()
273
+ },
274
+ ...N.filter((g) => {
275
+ if (console.log(
276
+ q(/* @__PURE__ */ new Date(), new Date(g.date))
277
+ ), q(/* @__PURE__ */ new Date(), new Date(g.date)) > 5) {
278
+ console.log("adsViewed - Remove Old Ad View Object");
279
+ return;
280
+ } else
281
+ return console.log("adsViewed - Keep Ad View Object"), g;
282
+ })
283
+ ];
284
+ console.log("unexpiredRecentViews", d);
285
+ }
286
+ }, [w, f]);
287
+ const [W, te] = p(null), [ae, P] = p(!1);
288
+ function U() {
289
+ P(!0), console.log("logAdAvoided called", r), k.get(
290
+ process.env.NODE_ENV === "development" ? "http://localhost:3001/api/user/advertising/avoided" : "https://articles.media/api/user/advertising/avoided",
291
+ {
292
+ params: {
293
+ user_id: o?._id
294
+ },
295
+ headers: {
296
+ "x-articles-api-key": r
297
+ }
298
+ }
299
+ ).then(function(d) {
300
+ P(!1), te(d.data.avoided_count), console.log(d.data);
301
+ }).catch(function(d) {
302
+ console.log(d), P(!1);
303
+ });
304
+ }
305
+ return y(() => {
306
+ t || (console.log("inView", w), o?.articles_membership?.status == "Active" && w && U());
307
+ }, [w, o]), c ? null : /* @__PURE__ */ e.jsxs(
308
+ "div",
309
+ {
310
+ ref: se,
311
+ className: le(
312
+ "ad-wrap",
313
+ {
314
+ "active-member": o?.articles_membership?.status == "Active"
315
+ }
316
+ ),
317
+ style: {
318
+ "--articles-ad-background-color": i.background_color || a?.background_color,
319
+ "--articles-ad-font-color": i.font_color || a?.font_color,
320
+ "--articles-ad-border-color": i.border_color || a?.border_color
321
+ },
322
+ children: [
323
+ L && /* @__PURE__ */ e.jsx(
324
+ Ae,
325
+ {
326
+ setModalShow: V,
327
+ ad: a,
328
+ previewData: i
329
+ }
330
+ ),
331
+ Y && /* @__PURE__ */ e.jsx(
332
+ ke,
333
+ {
334
+ setModalShow: O,
335
+ ad: a,
336
+ previewData: i
337
+ }
338
+ ),
339
+ u && /* @__PURE__ */ e.jsx("div", { className: "prepend-container", children: u }),
340
+ /* @__PURE__ */ e.jsxs(
341
+ "div",
342
+ {
343
+ className: "ad",
344
+ children: [
345
+ o?.articles_membership?.status !== "Active" && /* @__PURE__ */ e.jsxs(
346
+ "div",
347
+ {
348
+ className: "main-panel",
349
+ children: [
350
+ /* @__PURE__ */ e.jsx("div", { className: "ad-warning flex-header", children: /* @__PURE__ */ e.jsxs("div", { className: "", children: [
351
+ a?.city && "Local",
352
+ " Advertisement"
353
+ ] }) }),
354
+ /* @__PURE__ */ e.jsxs("div", { className: "content-wrap", children: [
355
+ /* @__PURE__ */ e.jsxs("div", { className: "photo-banner", children: [
356
+ /* @__PURE__ */ e.jsx("div", { className: "logo", children: (i.logo?.location || a?.logo?.location) && /* @__PURE__ */ e.jsx(
357
+ "img",
358
+ {
359
+ src: i?.logo?.key ? `${process.env.NEXT_PUBLIC_CDN}${i?.logo?.key}` : `${process.env.NEXT_PUBLIC_CDN}${a?.logo?.key}`,
360
+ alt: ""
361
+ }
362
+ ) }),
363
+ /* @__PURE__ */ e.jsx("div", { className: "icon d-none", children: /* @__PURE__ */ e.jsx("i", { className: "fas fa-mug-hot" }) }),
364
+ /* @__PURE__ */ e.jsx(
365
+ "img",
366
+ {
367
+ className: "photo",
368
+ src: i?.background?.key ? `${process.env.NEXT_PUBLIC_CDN}${i.background?.key}` : `${process.env.NEXT_PUBLIC_CDN}${a?.background?.key}`,
369
+ alt: ""
370
+ }
371
+ )
372
+ ] }),
373
+ /* @__PURE__ */ e.jsxs("div", { className: "details-wrap", children: [
374
+ /* @__PURE__ */ e.jsxs("div", { className: "detail-title", children: [
375
+ /* @__PURE__ */ e.jsx("div", { className: "detail", children: /* @__PURE__ */ e.jsx("span", { className: "h4", children: i?.business || a?.business }) }),
376
+ /* @__PURE__ */ e.jsxs("div", { className: "flex flex-column d-none", children: [
377
+ /* @__PURE__ */ e.jsxs("div", { className: "detail", children: [
378
+ /* @__PURE__ */ e.jsx("span", { className: "icon", children: /* @__PURE__ */ e.jsx("i", { className: "fas fa-search-location" }) }),
379
+ /* @__PURE__ */ e.jsxs("span", { children: [
380
+ a?.city,
381
+ ", ",
382
+ a?.state
383
+ ] })
384
+ ] }),
385
+ /* @__PURE__ */ e.jsxs("div", { className: "detail", children: [
386
+ /* @__PURE__ */ e.jsx("span", { className: "icon", children: /* @__PURE__ */ e.jsx("i", { className: "fas fa-clock me-2" }) }),
387
+ /* @__PURE__ */ e.jsx("span", { children: "6:30AM–8PM" })
388
+ ] })
389
+ ] })
390
+ ] }),
391
+ a?.city && /* @__PURE__ */ e.jsx("div", { className: "details mb-3 d-none" }),
392
+ /* @__PURE__ */ e.jsx("div", { className: "short-description", children: i?.description || a?.description })
393
+ ] })
394
+ ] }),
395
+ h?.roles?.isDev && a?.populated_promos?.length > 0 && /* @__PURE__ */ e.jsxs("div", { children: [
396
+ m && /* @__PURE__ */ e.jsx("div", { className: "promos-wrap", children: m && /* @__PURE__ */ e.jsxs(
397
+ "div",
398
+ {
399
+ className: "promo-wrap d-flex justify-content-between align-items-center mx-2 p-1 px-2 border border-2 border-light mb-0",
400
+ children: [
401
+ /* @__PURE__ */ e.jsxs("div", { className: "", children: [
402
+ /* @__PURE__ */ e.jsx("div", { children: m.title }),
403
+ /* @__PURE__ */ e.jsx("div", { className: "small", children: /* @__PURE__ */ e.jsx("div", { className: "small", children: m.details }) })
404
+ ] }),
405
+ /* @__PURE__ */ e.jsx(
406
+ oe,
407
+ {
408
+ className: "px-3",
409
+ small: !0,
410
+ onClick: () => {
411
+ console.log("Load Save Modal"), Q(!0);
412
+ },
413
+ children: "Save"
414
+ }
415
+ )
416
+ ]
417
+ },
418
+ m._id
419
+ ) }),
420
+ /* @__PURE__ */ e.jsxs("div", { className: "d-flex justify-content-between", children: [
421
+ /* @__PURE__ */ e.jsxs("div", { className: "px-2", children: [
422
+ a?.populated_promos?.length,
423
+ " Promos Active"
424
+ ] }),
425
+ /* @__PURE__ */ e.jsxs("div", { className: "controls", children: [
426
+ /* @__PURE__ */ e.jsx(
427
+ "i",
428
+ {
429
+ className: "fad fa-arrow-circle-left",
430
+ type: "button",
431
+ onClick: () => {
432
+ v == 0 ? j(a?.populated_promos?.length - 1) : j((d) => d - 1);
433
+ }
434
+ }
435
+ ),
436
+ a?.populated_promos?.map(
437
+ (d, g) => /* @__PURE__ */ e.jsx(
438
+ "i",
439
+ {
440
+ className: `fa-square ${g == v ? "fad" : "fas"}`
441
+ },
442
+ d._id
443
+ )
444
+ ),
445
+ /* @__PURE__ */ e.jsx(
446
+ "i",
447
+ {
448
+ className: "fad fa-arrow-circle-right",
449
+ type: "button",
450
+ onClick: () => {
451
+ v == a?.populated_promos?.length - 1 ? j(0) : j((d) => d + 1);
452
+ }
453
+ }
454
+ )
455
+ ] })
456
+ ] })
457
+ ] }),
458
+ /* @__PURE__ */ e.jsx("hr", { style: { borderColor: "white" }, className: "mt-auto mb-0" }),
459
+ /* @__PURE__ */ e.jsxs("div", { className: "action-wrap d-flex justify-content-lg-between px-3 py-2", children: [
460
+ /* @__PURE__ */ e.jsx(
461
+ "div",
462
+ {
463
+ onClick: () => {
464
+ ee(), B("Details");
465
+ },
466
+ className: "action flex-grow-1 flex-shrink-0",
467
+ children: "Details"
468
+ }
469
+ ),
470
+ /* @__PURE__ */ e.jsx("span", { className: "px-4" }),
471
+ /* @__PURE__ */ e.jsx(
472
+ "a",
473
+ {
474
+ className: "action flex-grow-1 flex-shrink-0",
475
+ href: a?.website,
476
+ target: "_blank",
477
+ rel: "noreferrer",
478
+ onClick: (d) => {
479
+ d.preventDefault(), O(!0), B("Confirm Exit Modal Opened");
480
+ },
481
+ children: /* @__PURE__ */ e.jsx("div", { children: "Website" })
482
+ }
483
+ )
484
+ ] })
485
+ ]
486
+ }
487
+ ),
488
+ o?.articles_membership?.status == "Active" && /* @__PURE__ */ e.jsx(
489
+ "div",
490
+ {
491
+ className: "main-panel",
492
+ children: /* @__PURE__ */ e.jsxs("div", { className: "content-wrap", children: [
493
+ /* @__PURE__ */ e.jsxs("div", { className: "photo-banner", children: [
494
+ /* @__PURE__ */ e.jsx("div", { className: "logo" }),
495
+ /* @__PURE__ */ e.jsxs("div", { className: "splash", children: [
496
+ /* @__PURE__ */ e.jsx("i", { className: "fas fa-broadcast-tower" }),
497
+ /* @__PURE__ */ e.jsxs("div", { className: "text", children: [
498
+ /* @__PURE__ */ e.jsx(
499
+ "div",
500
+ {
501
+ className: "count",
502
+ children: ae ? /* @__PURE__ */ e.jsx("i", { className: "fas fa-spinner fa-spin me-0" }) : W ? ne(W) : 0
503
+ }
504
+ ),
505
+ /* @__PURE__ */ e.jsx("div", { className: "label", children: "ads avoided." })
506
+ ] })
507
+ ] }),
508
+ /* @__PURE__ */ e.jsxs(
509
+ "div",
510
+ {
511
+ className: "member-since",
512
+ children: [
513
+ "Member since: ",
514
+ /* @__PURE__ */ e.jsx(ie, { format: "PP", date: o?.articles_membership?.membership_started })
515
+ ]
516
+ }
517
+ )
518
+ ] }),
519
+ /* @__PURE__ */ e.jsxs("div", { className: "details-wrap", children: [
520
+ /* @__PURE__ */ e.jsx("div", { className: "detail-title", children: /* @__PURE__ */ e.jsx("div", { className: "detail", children: /* @__PURE__ */ e.jsx("span", { className: "h4", children: "Thanks for the support!" }) }) }),
521
+ /* @__PURE__ */ e.jsxs("div", { className: "short-description", children: [
522
+ /* @__PURE__ */ e.jsx("div", { className: "mb-2", children: "Without support from users like you, we wouldn't be here." }),
523
+ /* @__PURE__ */ e.jsxs("div", { className: "links-list", children: [
524
+ /* @__PURE__ */ e.jsxs(
525
+ E,
526
+ {
527
+ newPage: !0,
528
+ className: "link-item",
529
+ href: "https://articles.media/messages",
530
+ children: [
531
+ /* @__PURE__ */ e.jsx("i", { className: "fas fa-comments-alt" }),
532
+ "0 unread messages."
533
+ ]
534
+ }
535
+ ),
536
+ /* @__PURE__ */ e.jsxs(
537
+ E,
538
+ {
539
+ newPage: !0,
540
+ className: "link-item",
541
+ href: "https://articles.media/settings/notifications",
542
+ onClick: () => {
543
+ U();
544
+ },
545
+ children: [
546
+ /* @__PURE__ */ e.jsx("i", { className: "fas fa-bell" }),
547
+ "0 notifications."
548
+ ]
549
+ }
550
+ ),
551
+ /* @__PURE__ */ e.jsxs(
552
+ E,
553
+ {
554
+ newPage: !0,
555
+ className: "link-item",
556
+ href: "https://articles.media/settings/account",
557
+ children: [
558
+ /* @__PURE__ */ e.jsx("i", { className: "fas fa-cog" }),
559
+ "Manage account settings."
560
+ ]
561
+ }
562
+ )
563
+ ] })
564
+ ] })
565
+ ] })
566
+ ] })
567
+ }
568
+ )
569
+ ]
570
+ }
571
+ ),
572
+ n && /* @__PURE__ */ e.jsx("div", { className: "append-container", children: n }),
573
+ !t && /* @__PURE__ */ e.jsx(
574
+ "div",
575
+ {
576
+ className: "advertise-with-us p-1",
577
+ style: {
578
+ // ...(props.previewData ? props.previewData.background_color : ad?.background_color),
579
+ backgroundColor: i.background_color || a?.background_color,
580
+ color: i.font_color || a?.font_color,
581
+ borderColor: i.border_color || a?.border_color
582
+ },
583
+ children: /* @__PURE__ */ e.jsxs(
584
+ E,
585
+ {
586
+ className: "small d-block w-100 text-center",
587
+ href: "https://articles.media/advertising",
588
+ newPage: !0,
589
+ children: [
590
+ /* @__PURE__ */ e.jsx("i", { className: "fas fa-share me-1" }),
591
+ "Advertise with Articles Media!"
592
+ ]
593
+ }
594
+ )
595
+ }
596
+ )
597
+ ]
598
+ }
599
+ );
600
+ }
601
+ const Le = re(Me);
602
+ export {
603
+ Le as default
604
+ };