@adview/react 1.0.14 → 1.0.16

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 (75) hide show
  1. package/dist/AdViewUnit/AdViewUnit.cjs +288 -66
  2. package/dist/AdViewUnit/AdViewUnit.cjs.map +1 -1
  3. package/dist/AdViewUnit/AdViewUnit.client.cjs +249 -43
  4. package/dist/AdViewUnit/AdViewUnit.client.cjs.map +1 -1
  5. package/dist/AdViewUnit/AdViewUnit.client.d.cts +1 -1
  6. package/dist/AdViewUnit/AdViewUnit.client.d.ts +1 -1
  7. package/dist/AdViewUnit/AdViewUnit.client.js +228 -22
  8. package/dist/AdViewUnit/AdViewUnit.client.js.map +1 -1
  9. package/dist/AdViewUnit/AdViewUnit.d.cts +1 -1
  10. package/dist/AdViewUnit/AdViewUnit.d.ts +1 -1
  11. package/dist/AdViewUnit/AdViewUnit.js +263 -41
  12. package/dist/AdViewUnit/AdViewUnit.js.map +1 -1
  13. package/dist/AdViewUnit/AdViewUnit.server.cjs +246 -42
  14. package/dist/AdViewUnit/AdViewUnit.server.cjs.map +1 -1
  15. package/dist/AdViewUnit/AdViewUnit.server.d.cts +2 -2
  16. package/dist/AdViewUnit/AdViewUnit.server.d.ts +2 -2
  17. package/dist/AdViewUnit/AdViewUnit.server.js +233 -29
  18. package/dist/AdViewUnit/AdViewUnit.server.js.map +1 -1
  19. package/dist/AdViewUnit/AdViewUnitBannerTemplate.cjs +21 -2
  20. package/dist/AdViewUnit/AdViewUnitBannerTemplate.cjs.map +1 -1
  21. package/dist/AdViewUnit/AdViewUnitBannerTemplate.d.cts +7 -2
  22. package/dist/AdViewUnit/AdViewUnitBannerTemplate.d.ts +7 -2
  23. package/dist/AdViewUnit/AdViewUnitBannerTemplate.js +21 -2
  24. package/dist/AdViewUnit/AdViewUnitBannerTemplate.js.map +1 -1
  25. package/dist/AdViewUnit/AdViewUnitDefaultTemplate.cjs +21 -3
  26. package/dist/AdViewUnit/AdViewUnitDefaultTemplate.cjs.map +1 -1
  27. package/dist/AdViewUnit/AdViewUnitDefaultTemplate.d.cts +3 -4
  28. package/dist/AdViewUnit/AdViewUnitDefaultTemplate.d.ts +3 -4
  29. package/dist/AdViewUnit/AdViewUnitDefaultTemplate.js +21 -3
  30. package/dist/AdViewUnit/AdViewUnitDefaultTemplate.js.map +1 -1
  31. package/dist/AdViewUnit/AdViewUnitNativeTemplate.cjs +21 -2
  32. package/dist/AdViewUnit/AdViewUnitNativeTemplate.cjs.map +1 -1
  33. package/dist/AdViewUnit/AdViewUnitNativeTemplate.d.cts +7 -2
  34. package/dist/AdViewUnit/AdViewUnitNativeTemplate.d.ts +7 -2
  35. package/dist/AdViewUnit/AdViewUnitNativeTemplate.js +21 -2
  36. package/dist/AdViewUnit/AdViewUnitNativeTemplate.js.map +1 -1
  37. package/dist/AdViewUnit/AdViewUnitProxyTemplate.cjs +21 -2
  38. package/dist/AdViewUnit/AdViewUnitProxyTemplate.cjs.map +1 -1
  39. package/dist/AdViewUnit/AdViewUnitProxyTemplate.d.cts +7 -2
  40. package/dist/AdViewUnit/AdViewUnitProxyTemplate.d.ts +7 -2
  41. package/dist/AdViewUnit/AdViewUnitProxyTemplate.js +21 -2
  42. package/dist/AdViewUnit/AdViewUnitProxyTemplate.js.map +1 -1
  43. package/dist/AdViewUnit/AdViewUnitTemplate.cjs +24 -6
  44. package/dist/AdViewUnit/AdViewUnitTemplate.cjs.map +1 -1
  45. package/dist/AdViewUnit/AdViewUnitTemplate.d.cts +2 -2
  46. package/dist/AdViewUnit/AdViewUnitTemplate.d.ts +2 -2
  47. package/dist/AdViewUnit/AdViewUnitTemplate.js +24 -6
  48. package/dist/AdViewUnit/AdViewUnitTemplate.js.map +1 -1
  49. package/dist/AdViewUnit/useAdViewController.cjs +0 -2
  50. package/dist/AdViewUnit/useAdViewController.cjs.map +1 -1
  51. package/dist/AdViewUnit/useAdViewController.d.cts +1 -1
  52. package/dist/AdViewUnit/useAdViewController.d.ts +1 -1
  53. package/dist/AdViewUnit/useAdViewController.js +0 -2
  54. package/dist/AdViewUnit/useAdViewController.js.map +1 -1
  55. package/dist/AdViewUnit/utils.cjs +33 -0
  56. package/dist/AdViewUnit/utils.cjs.map +1 -0
  57. package/dist/AdViewUnit/utils.d.cts +7 -0
  58. package/dist/AdViewUnit/utils.d.ts +7 -0
  59. package/dist/AdViewUnit/utils.js +8 -0
  60. package/dist/AdViewUnit/utils.js.map +1 -0
  61. package/dist/index.cjs +278 -195
  62. package/dist/index.cjs.map +1 -1
  63. package/dist/index.d.cts +1 -1
  64. package/dist/index.d.ts +1 -1
  65. package/dist/index.js +257 -174
  66. package/dist/index.js.map +1 -1
  67. package/dist/server.cjs +277 -196
  68. package/dist/server.cjs.map +1 -1
  69. package/dist/server.d.cts +1 -1
  70. package/dist/server.d.ts +1 -1
  71. package/dist/server.js +264 -183
  72. package/dist/server.js.map +1 -1
  73. package/dist/{types-B65WDsgh.d.cts → types-E00UyX0q.d.cts} +15 -27
  74. package/dist/{types-B65WDsgh.d.ts → types-E00UyX0q.d.ts} +15 -27
  75. package/package.json +1 -1
@@ -35,40 +35,228 @@ __export(AdViewUnit_exports, {
35
35
  default: () => AdViewUnit_default
36
36
  });
37
37
  module.exports = __toCommonJS(AdViewUnit_exports);
38
- var import_react7 = __toESM(require("react"), 1);
38
+ var import_react10 = __toESM(require("react"), 1);
39
39
 
40
40
  // src/AdViewUnit/AdViewUnit.client.tsx
41
- var import_react5 = __toESM(require("react"), 1);
41
+ var import_react8 = __toESM(require("react"), 1);
42
42
 
43
- // src/AdViewUnit/AdViewUnitTemplate.tsx
43
+ // src/AdViewUnit/AdViewUnitBannerTemplate.tsx
44
+ var import_utils = require("@adview/core/utils");
44
45
  var import_react = __toESM(require("react"), 1);
46
+
47
+ // src/AdViewUnit/utils.ts
48
+ var matchExpectedState = (expectState, state) => {
49
+ return !expectState || (expectState.isInitial === void 0 || expectState.isInitial === state?.isInitial) && (expectState.isLoading === void 0 || expectState.isLoading === state?.isLoading) && (expectState.isError === void 0 || expectState.isError === state?.isError) && (expectState.isComplete === void 0 || expectState.isComplete === state?.isComplete);
50
+ };
51
+
52
+ // src/AdViewUnit/AdViewUnitBannerTemplate.tsx
53
+ function AdViewUnitBannerTemplate({ className = "banner", style, data, state, ...props }) {
54
+ const expectState = props?.isInitial || props?.isLoading || props?.isError || props?.isComplete ? {
55
+ isInitial: props?.isInitial,
56
+ isLoading: props?.isLoading,
57
+ isError: props?.isError,
58
+ isComplete: props?.isComplete
59
+ } : { isComplete: true };
60
+ if (!data || !data.assets || !data.assets.length) {
61
+ return null;
62
+ }
63
+ if (!matchExpectedState(expectState, state)) {
64
+ return null;
65
+ }
66
+ const asset = (0, import_utils.getAssetByName)("main", data.assets);
67
+ return /* @__PURE__ */ import_react.default.createElement(
68
+ "a",
69
+ {
70
+ target: "_blank",
71
+ rel: "noopener noreferrer",
72
+ href: (0, import_utils.getPrepareURL)(data.url),
73
+ className,
74
+ style: { fontSize: 0, ...style }
75
+ },
76
+ asset && /* @__PURE__ */ import_react.default.createElement(
77
+ "img",
78
+ {
79
+ alt: "main",
80
+ src: asset.path,
81
+ srcSet: asset.thumbs ? (0, import_utils.getSrcSetCSSThumbs)(asset.thumbs) : ""
82
+ }
83
+ )
84
+ );
85
+ }
86
+ AdViewUnitBannerTemplate.defaults = {
87
+ type: "banner"
88
+ };
89
+ var AdViewUnitBannerTemplate_default = AdViewUnitBannerTemplate;
90
+
91
+ // src/AdViewUnit/AdViewUnitNativeTemplate.tsx
92
+ var import_utils3 = require("@adview/core/utils");
93
+ var import_react2 = __toESM(require("react"), 1);
94
+ function AdViewUnitNativeTemplate({ classNames, data, state, ...props }) {
95
+ if (!data || !data.assets || !data.assets.length) {
96
+ return null;
97
+ }
98
+ const expectState = props?.isInitial || props?.isLoading || props?.isError || props?.isComplete ? {
99
+ isInitial: props?.isInitial,
100
+ isLoading: props?.isLoading,
101
+ isError: props?.isError,
102
+ isComplete: props?.isComplete
103
+ } : { isComplete: true };
104
+ if (!matchExpectedState(expectState, state)) {
105
+ return null;
106
+ }
107
+ const { assets, url, fields } = data;
108
+ const asset = (0, import_utils3.getAssetByName)("main", assets);
109
+ if (!url) {
110
+ return null;
111
+ }
112
+ return /* @__PURE__ */ import_react2.default.createElement("div", { className: classNames?.container }, /* @__PURE__ */ import_react2.default.createElement(
113
+ "a",
114
+ {
115
+ target: "_blank",
116
+ rel: "noopener noreferrer",
117
+ href: (0, import_utils3.getPrepareURL)(url),
118
+ className: classNames?.imageLink
119
+ },
120
+ asset && /* @__PURE__ */ import_react2.default.createElement(
121
+ "img",
122
+ {
123
+ alt: fields?.title,
124
+ title: fields?.title,
125
+ src: asset.path,
126
+ srcSet: asset.thumbs ? (0, import_utils3.getSrcSetCSSThumbs)(asset.thumbs) : void 0,
127
+ className: classNames?.image,
128
+ style: { objectFit: "cover", width: "100%", height: "100%" }
129
+ }
130
+ )
131
+ ), /* @__PURE__ */ import_react2.default.createElement("div", { className: classNames?.label }, fields?.title && /* @__PURE__ */ import_react2.default.createElement(
132
+ "a",
133
+ {
134
+ target: "_blank",
135
+ rel: "noopener noreferrer",
136
+ href: (0, import_utils3.getPrepareURL)(url),
137
+ "data-class": "titleLink",
138
+ className: classNames?.titleLink
139
+ },
140
+ fields.title
141
+ ), fields?.description && /* @__PURE__ */ import_react2.default.createElement(
142
+ "a",
143
+ {
144
+ target: "_blank",
145
+ rel: "noopener noreferrer",
146
+ href: (0, import_utils3.getPrepareURL)(url),
147
+ "data-class": "descriptionLink",
148
+ className: classNames?.descriptionLink
149
+ },
150
+ fields.description
151
+ ), fields?.brandname && /* @__PURE__ */ import_react2.default.createElement(
152
+ "a",
153
+ {
154
+ target: "_blank",
155
+ rel: "noopener noreferrer",
156
+ href: (0, import_utils3.getPrepareURL)(url),
157
+ "data-class": "brandNameLink",
158
+ className: classNames?.brandNameLink
159
+ },
160
+ fields.brandname
161
+ ), fields?.phone && /* @__PURE__ */ import_react2.default.createElement(
162
+ "a",
163
+ {
164
+ target: "_blank",
165
+ rel: "noopener noreferrer",
166
+ href: (0, import_utils3.getPrepareURL)(url),
167
+ "data-class": "phoneLink",
168
+ className: classNames?.phoneLink
169
+ },
170
+ fields.phone
171
+ ), fields?.url && /* @__PURE__ */ import_react2.default.createElement(
172
+ "a",
173
+ {
174
+ target: "_blank",
175
+ rel: "noopener noreferrer",
176
+ href: (0, import_utils3.getPrepareURL)(url),
177
+ "data-class": "urlLink",
178
+ className: classNames?.urlLink
179
+ },
180
+ fields?.url
181
+ )));
182
+ }
183
+ AdViewUnitNativeTemplate.defaults = {
184
+ type: "native"
185
+ };
186
+ var AdViewUnitNativeTemplate_default = AdViewUnitNativeTemplate;
187
+
188
+ // src/AdViewUnit/AdViewUnitProxyTemplate.tsx
189
+ var import_react3 = __toESM(require("react"), 1);
190
+ function AdViewUnitProxyTemplate({ className, style, data, state, ...props }) {
191
+ if (!data) {
192
+ return null;
193
+ }
194
+ const expectState = props?.isInitial || props?.isLoading || props?.isError || props?.isComplete ? {
195
+ isInitial: props?.isInitial,
196
+ isLoading: props?.isLoading,
197
+ isError: props?.isError,
198
+ isComplete: props?.isComplete
199
+ } : { isComplete: true };
200
+ if (!matchExpectedState(expectState, state)) {
201
+ return null;
202
+ }
203
+ const { url, fields } = data;
204
+ const iframeSrc = fields?.url || url;
205
+ if (!iframeSrc) {
206
+ return null;
207
+ }
208
+ return /* @__PURE__ */ import_react3.default.createElement(
209
+ "iframe",
210
+ {
211
+ className,
212
+ width: "100%",
213
+ height: "100%",
214
+ frameBorder: "0",
215
+ marginWidth: 0,
216
+ marginHeight: 0,
217
+ allowTransparency: true,
218
+ scrolling: "no",
219
+ allowFullScreen: true,
220
+ style: { width: "100%", height: "100%", border: "none", ...style },
221
+ src: iframeSrc
222
+ }
223
+ );
224
+ }
225
+ AdViewUnitProxyTemplate.defaults = {
226
+ type: "proxy"
227
+ };
228
+ var AdViewUnitProxyTemplate_default = AdViewUnitProxyTemplate;
229
+
230
+ // src/AdViewUnit/AdViewUnitTemplate.tsx
231
+ var import_react4 = __toESM(require("react"), 1);
45
232
  var templateFromListRender = (tmpls, data, wrap) => {
46
233
  let renderedRemplates = tmpls.map((tmpl, index) => {
47
234
  let tmp = renderTemplate(tmpl, data);
48
- return !!tmp && import_react.default.isValidElement(tmp) ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, { key: index }, !!wrap ? wrap(tmp) : tmp) : null;
235
+ return !!tmp && import_react4.default.isValidElement(tmp) ? /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, { key: index }, !!wrap ? wrap(tmp) : tmp) : null;
49
236
  }).filter((it) => !!it);
50
237
  if (!renderedRemplates.length) {
51
238
  renderedRemplates = tmpls.map((tmpl, index) => {
52
239
  let tmp = renderTemplate(tmpl, { ...data, type: "default" });
53
- return !!tmp && import_react.default.isValidElement(tmp) ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, { key: index }, !!wrap ? wrap(tmp) : tmp) : null;
240
+ return !!tmp && import_react4.default.isValidElement(tmp) ? /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, { key: index }, !!wrap ? wrap(tmp) : tmp) : null;
54
241
  }).filter((it) => !!it);
55
242
  }
56
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, renderedRemplates);
243
+ return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, renderedRemplates);
57
244
  };
58
245
  var renderTemplate = (tmpl, data) => {
59
246
  const isFunction = typeof tmpl === "function";
60
- const isReactElement = import_react.default.isValidElement(tmpl);
247
+ const isReactElement = import_react4.default.isValidElement(tmpl);
61
248
  if (isReactElement) {
62
- const { type, children } = tmpl.props;
63
- console.log("=====>\nrenderTemplate: React element detected, type:", type, "data:", data.type, data.type !== type);
64
- if (data.type !== type) {
249
+ let { type, children } = tmpl.props;
250
+ if (!type && typeof tmpl.type !== "string") {
251
+ type = tmpl.type?.defaults?.type;
252
+ }
253
+ if (!!type && type !== "*" && data.type !== type) {
65
254
  return null;
66
255
  }
67
256
  if (typeof children === "function") {
68
257
  return children(data);
69
258
  }
70
- console.log("CLONE ELEMENT", tmpl);
71
- return import_react.default.cloneElement(tmpl, {
259
+ return import_react4.default.cloneElement(tmpl, {
72
260
  ...data,
73
261
  children
74
262
  });
@@ -91,15 +279,15 @@ var renderAnyTemplates = (tmpls, data, listRender) => {
91
279
  if (typeof tmpls === "function") {
92
280
  return tmpls(data);
93
281
  }
94
- if (import_react.default.isValidElement(tmpls)) {
282
+ if (import_react4.default.isValidElement(tmpls)) {
95
283
  return templateFromListRender([tmpls], data);
96
284
  }
97
285
  return null;
98
286
  };
99
287
 
100
288
  // src/AdViewUnit/AdViewUnitTracking.tsx
101
- var import_utils = require("@adview/core/utils");
102
- var import_react2 = __toESM(require("react"), 1);
289
+ var import_utils7 = require("@adview/core/utils");
290
+ var import_react5 = __toESM(require("react"), 1);
103
291
  function AdViewUnitTracking({
104
292
  impressions,
105
293
  views,
@@ -107,30 +295,30 @@ function AdViewUnitTracking({
107
295
  children
108
296
  }) {
109
297
  const isServer = typeof window === "undefined";
110
- const wrapperRef = (0, import_react2.useRef)(null);
111
- const executeImpressionsTrackingHandler = (0, import_react2.useCallback)(
112
- () => (0, import_utils.executeImpressionsTracking)(impressions),
298
+ const wrapperRef = (0, import_react5.useRef)(null);
299
+ const executeImpressionsTrackingHandler = (0, import_react5.useCallback)(
300
+ () => (0, import_utils7.executeImpressionsTracking)(impressions),
113
301
  [impressions]
114
302
  );
115
- const trackingObserverInstanceHandler = (0, import_react2.useCallback)(
303
+ const trackingObserverInstanceHandler = (0, import_react5.useCallback)(
116
304
  (entries) => {
117
305
  entries.forEach((entry) => {
118
306
  if (entry.isIntersecting) {
119
- (0, import_utils.executeImpressionsTracking)(views);
307
+ (0, import_utils7.executeImpressionsTracking)(views);
120
308
  trackingObserverInstance?.unobserve(wrapperRef.current);
121
309
  }
122
310
  });
123
311
  },
124
312
  [views]
125
313
  );
126
- const trackingObserverInstance = (0, import_react2.useMemo)(() => {
314
+ const trackingObserverInstance = (0, import_react5.useMemo)(() => {
127
315
  return !isServer ? new IntersectionObserver(trackingObserverInstanceHandler) : null;
128
316
  }, [isServer, trackingObserverInstanceHandler]);
129
- const clickTrackerHandler = (0, import_react2.useCallback)(() => {
130
- (0, import_utils.executeImpressionsTracking)(clicks);
317
+ const clickTrackerHandler = (0, import_react5.useCallback)(() => {
318
+ (0, import_utils7.executeImpressionsTracking)(clicks);
131
319
  wrapperRef.current?.removeEventListener("click", clickTrackerHandler);
132
320
  }, [clicks]);
133
- (0, import_react2.useEffect)(() => {
321
+ (0, import_react5.useEffect)(() => {
134
322
  if (wrapperRef.current && trackingObserverInstance) {
135
323
  executeImpressionsTrackingHandler();
136
324
  wrapperRef.current?.addEventListener("click", clickTrackerHandler);
@@ -148,28 +336,28 @@ function AdViewUnitTracking({
148
336
  executeImpressionsTrackingHandler,
149
337
  clickTrackerHandler
150
338
  ]);
151
- return /* @__PURE__ */ import_react2.default.createElement("div", { ref: wrapperRef }, children);
339
+ return /* @__PURE__ */ import_react5.default.createElement("div", { ref: wrapperRef }, children);
152
340
  }
153
341
  var AdViewUnitTracking_default = AdViewUnitTracking;
154
342
 
155
343
  // src/AdViewUnit/useAdViewController.ts
156
- var import_utils2 = require("@adview/core/utils");
157
- var import_react4 = require("react");
344
+ var import_utils8 = require("@adview/core/utils");
345
+ var import_react7 = require("react");
158
346
 
159
347
  // src/AdViewUnit/AdViewProvider.tsx
160
- var import_react3 = __toESM(require("react"), 1);
161
- var AdViewProviderContext = (0, import_react3.createContext)(
348
+ var import_react6 = __toESM(require("react"), 1);
349
+ var AdViewProviderContext = (0, import_react6.createContext)(
162
350
  {}
163
351
  );
164
352
 
165
353
  // src/AdViewUnit/useAdViewController.ts
166
354
  function useAdViewController(adUnitConfig, unitId, format) {
167
- const [adLoadState, setAdLoadState] = (0, import_react4.useState)("initial");
168
- const [adData, setAdData] = (0, import_react4.useState)(null);
169
- const [errorMessage, setErrorMessage] = (0, import_react4.useState)(null);
170
- const globalConfig = (0, import_react4.useContext)(AdViewProviderContext);
171
- const baseConfig = (0, import_utils2.getResolveConfig)({ ...adUnitConfig, ...globalConfig });
172
- const requestUrl = (0, import_utils2.getAdRequestUrl)(
355
+ const [adLoadState, setAdLoadState] = (0, import_react7.useState)("initial");
356
+ const [adData, setAdData] = (0, import_react7.useState)(null);
357
+ const [errorMessage, setErrorMessage] = (0, import_react7.useState)(null);
358
+ const globalConfig = (0, import_react7.useContext)(AdViewProviderContext);
359
+ const baseConfig = (0, import_utils8.getResolveConfig)({ ...adUnitConfig, ...globalConfig });
360
+ const requestUrl = (0, import_utils8.getAdRequestUrl)(
173
361
  baseConfig,
174
362
  unitId,
175
363
  typeof format === "string" ? format : format?.join(",") || ""
@@ -177,9 +365,7 @@ function useAdViewController(adUnitConfig, unitId, format) {
177
365
  const loadAd = async () => {
178
366
  setAdLoadState("loading");
179
367
  try {
180
- console.log("Requesting ad data from:", import_utils2.adViewFetcher, "with URL:", requestUrl);
181
- const response = await (0, import_utils2.adViewFetcher)(requestUrl, baseConfig.defaultAdData);
182
- console.log("AdViewController response:", response);
368
+ const response = await (0, import_utils8.adViewFetcher)(requestUrl, baseConfig.defaultAdData);
183
369
  if (response instanceof Error) {
184
370
  setAdLoadState("error");
185
371
  setErrorMessage(response);
@@ -199,7 +385,7 @@ function useAdViewController(adUnitConfig, unitId, format) {
199
385
  isComplete: adLoadState === "complete",
200
386
  isError: adLoadState === "error"
201
387
  };
202
- (0, import_react4.useEffect)(() => {
388
+ (0, import_react7.useEffect)(() => {
203
389
  loadAd();
204
390
  }, []);
205
391
  return [adData, errorMessage, loadState];
@@ -213,56 +399,92 @@ function AdViewUnitClient({
213
399
  children,
214
400
  ...config
215
401
  }) {
402
+ const checkFormat = (f) => {
403
+ if (!format) {
404
+ return true;
405
+ }
406
+ return Array.isArray(format) ? format.includes(f) : f === format;
407
+ };
216
408
  const [response, error, loadState] = useAdViewController_default(
217
409
  config,
218
410
  unitId,
219
411
  format
220
412
  );
221
- const responseGroup = error ? null : response?.groups?.[0];
222
- const customTracker = responseGroup?.custom_tracker ?? {};
223
- const groupItems = responseGroup?.items;
413
+ const { responseGroup: _, customTracker, groupItems } = error ? { responseGroup: null, customTracker: {}, groupItems: [] } : (() => {
414
+ for (let responseGroup of response?.groups || []) {
415
+ const customTracker2 = responseGroup?.custom_tracker ?? {};
416
+ const groupItems2 = (responseGroup?.items || []).map((it) => checkFormat(it.type) ? it : null).filter(Boolean);
417
+ if (groupItems2 && groupItems2.length > 0) {
418
+ return { responseGroup, customTracker: customTracker2, groupItems: groupItems2 };
419
+ }
420
+ }
421
+ return { responseGroup: null, customTracker: {}, groupItems: [] };
422
+ })();
423
+ if (!children) {
424
+ children = [
425
+ /* @__PURE__ */ import_react8.default.createElement(AdViewUnitBannerTemplate_default, null),
426
+ /* @__PURE__ */ import_react8.default.createElement(AdViewUnitNativeTemplate_default, null),
427
+ /* @__PURE__ */ import_react8.default.createElement(AdViewUnitProxyTemplate_default, null)
428
+ ];
429
+ }
224
430
  if (groupItems && groupItems?.length > 0) {
225
431
  return groupItems.map(({ tracker, ...data }) => {
226
- return /* @__PURE__ */ import_react5.default.createElement(AdViewUnitTracking_default, { key: data.id, ...tracker }, renderAnyTemplates(children, { data, type: data.type || "default", error, state: loadState }));
432
+ return /* @__PURE__ */ import_react8.default.createElement(AdViewUnitTracking_default, { key: data.id, ...tracker }, renderAnyTemplates(children, { data, type: data.type || "default", error, state: loadState }));
227
433
  });
228
434
  }
229
- return /* @__PURE__ */ import_react5.default.createElement(AdViewUnitTracking_default, { ...customTracker }, renderAnyTemplates(children, { data: null, type: "default", error, state: loadState }));
435
+ return /* @__PURE__ */ import_react8.default.createElement(AdViewUnitTracking_default, { ...customTracker }, renderAnyTemplates(children, { data: null, type: "default", error, state: loadState }));
230
436
  }
231
437
  var AdViewUnit_client_default = AdViewUnitClient;
232
438
 
233
439
  // src/AdViewUnit/AdViewUnit.server.tsx
234
- var import_react6 = __toESM(require("react"), 1);
235
- var import_utils3 = require("@adview/core/utils");
440
+ var import_react9 = __toESM(require("react"), 1);
441
+ var import_utils9 = require("@adview/core/utils");
236
442
  async function AdViewUnitServer({
237
443
  unitId,
238
444
  format,
239
445
  children,
240
446
  ...config
241
447
  }) {
242
- const baseConfig = (0, import_utils3.getResolveConfig)(config);
243
- const requestUrl = (0, import_utils3.getAdRequestUrl)(baseConfig, unitId, format);
244
- const response = await (0, import_utils3.adViewFetcher)(requestUrl);
448
+ const checkFormat = (f) => {
449
+ if (!format) {
450
+ return true;
451
+ }
452
+ return Array.isArray(format) ? format.includes(f) : f === format;
453
+ };
454
+ const baseConfig = (0, import_utils9.getResolveConfig)(config);
455
+ const requestUrl = (0, import_utils9.getAdRequestUrl)(baseConfig, unitId, format);
456
+ const response = await (0, import_utils9.adViewFetcher)(requestUrl);
245
457
  const isLoadingError = response instanceof Error;
246
458
  const error = isLoadingError ? response : void 0;
247
- const responseGroup = response instanceof Error ? null : response?.groups?.[0];
248
- const customTracker = responseGroup?.custom_tracker ?? {};
249
- const groupItems = responseGroup?.items;
250
- if (groupItems && groupItems.length) {
251
- return groupItems.map(({ tracker, ...data }) => {
252
- return /* @__PURE__ */ import_react6.default.createElement(AdViewUnitTracking_default, { key: data.id, ...tracker }, renderAnyTemplates(children, { data, type: data.type || "default", error, state: {
253
- isLoading: true,
254
- isComplete: true,
255
- isInitial: false,
256
- isError: isLoadingError
257
- } }));
258
- });
259
- }
260
- return /* @__PURE__ */ import_react6.default.createElement(AdViewUnitTracking_default, { ...customTracker }, renderAnyTemplates(children, { data: null, type: "default", error, state: {
459
+ const state = {
261
460
  isLoading: true,
262
461
  isComplete: true,
263
462
  isInitial: false,
264
463
  isError: isLoadingError
265
- } }));
464
+ };
465
+ const { responseGroup: _, customTracker, groupItems } = error ? { responseGroup: null, customTracker: {}, groupItems: [] } : (() => {
466
+ for (let responseGroup of response?.groups || []) {
467
+ const customTracker2 = responseGroup?.custom_tracker ?? {};
468
+ const groupItems2 = (responseGroup?.items || []).map((it) => checkFormat(it.type) ? it : null).filter(Boolean);
469
+ if (groupItems2 && groupItems2.length > 0) {
470
+ return { responseGroup, customTracker: customTracker2, groupItems: groupItems2 };
471
+ }
472
+ }
473
+ return { responseGroup: null, customTracker: {}, groupItems: [] };
474
+ })();
475
+ if (!children) {
476
+ children = [
477
+ /* @__PURE__ */ import_react9.default.createElement(AdViewUnitBannerTemplate_default, null),
478
+ /* @__PURE__ */ import_react9.default.createElement(AdViewUnitNativeTemplate_default, null),
479
+ /* @__PURE__ */ import_react9.default.createElement(AdViewUnitProxyTemplate_default, null)
480
+ ];
481
+ }
482
+ if (groupItems && groupItems.length) {
483
+ return groupItems.map(({ tracker, ...data }) => {
484
+ return /* @__PURE__ */ import_react9.default.createElement(AdViewUnitTracking_default, { key: data.id, ...tracker }, renderAnyTemplates(children, { data, type: data.type || "default", error, state }));
485
+ });
486
+ }
487
+ return /* @__PURE__ */ import_react9.default.createElement(AdViewUnitTracking_default, { ...customTracker }, renderAnyTemplates(children, { data: null, type: "default", error, state }));
266
488
  }
267
489
  var AdViewUnit_server_default = AdViewUnitServer;
268
490
 
@@ -270,9 +492,9 @@ var AdViewUnit_server_default = AdViewUnitServer;
270
492
  function AdViewUnit(props) {
271
493
  const isServer = typeof window === "undefined";
272
494
  if (isServer) {
273
- return /* @__PURE__ */ import_react7.default.createElement(AdViewUnit_server_default, { ...props });
495
+ return /* @__PURE__ */ import_react10.default.createElement(AdViewUnit_server_default, { ...props });
274
496
  }
275
- return /* @__PURE__ */ import_react7.default.createElement(AdViewUnit_client_default, { ...props });
497
+ return /* @__PURE__ */ import_react10.default.createElement(AdViewUnit_client_default, { ...props });
276
498
  }
277
499
  var AdViewUnit_default = AdViewUnit;
278
500
  //# sourceMappingURL=AdViewUnit.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/AdViewUnit/AdViewUnit.tsx","../../src/AdViewUnit/AdViewUnit.client.tsx","../../src/AdViewUnit/AdViewUnitTemplate.tsx","../../src/AdViewUnit/AdViewUnitTracking.tsx","../../src/AdViewUnit/useAdViewController.ts","../../src/AdViewUnit/AdViewProvider.tsx","../../src/AdViewUnit/AdViewUnit.server.tsx"],"sourcesContent":["import React from 'react';\nimport AdViewUnitClient, { AdViewUnitClientProps } from './AdViewUnit.client';\nimport AdViewUnitServer, { AdViewUnitServerProps } from './AdViewUnit.server';\n\nexport type AdViewUnitProps = typeof window extends undefined\n ? AdViewUnitServerProps\n : AdViewUnitClientProps;\n\nfunction AdViewUnit(props: AdViewUnitProps) {\n const isServer = typeof window === 'undefined';\n\n if (isServer) {\n return <AdViewUnitServer {...(props as AdViewUnitServerProps)} />;\n }\n\n return <AdViewUnitClient {...(props as AdViewUnitClientProps)} />;\n}\n\nexport default AdViewUnit;\n","'use client';\n\nimport React from 'react';\nimport { AdViewUnitClientChildren, AdViewUnitPropsBase } from '../types';\nimport { renderAnyTemplates } from './AdViewUnitTemplate';\nimport AdViewUnitTracking from './AdViewUnitTracking';\nimport useAdViewController from './useAdViewController';\n\nexport type AdViewUnitClientProps = AdViewUnitPropsBase & {\n children?: AdViewUnitClientChildren;\n};\n\n// AdViewUnitClient is a client-side component that fetches ad data and renders it\n// using the provided children function. It handles loading, error states, and\n// tracks ad interactions.\n//\n// Example usage:\n// <AdView.Unit unitId=\"my-unit\" format=\"banner\" srcURL=\"https://api.example.com/ads/{<id>}\">\n// {({ data, state, error }) => (\n// <div>\n// {state.isLoading && <span>Loading...</span>}\n// {error && <span>Error: {error.message}</span>}\n// {data && <img src={data.imageUrl} alt={data.title} />\n// </div>\n// )}\n// </AdView.Unit>\n//\n// Note: This component is designed to be used in a client-side environment where\n// ad data can be fetched dynamically. It is not suitable for server-side rendering.\n// It uses the AdViewUnitTracking component to handle ad tracking and interactions.\nfunction AdViewUnitClient({\n unitId,\n format,\n children,\n ...config\n}: AdViewUnitClientProps) {\n const [response, error, loadState] = useAdViewController(\n config,\n unitId,\n format,\n );\n const responseGroup = error ? null : response?.groups?.[0];\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = responseGroup?.items;\n\n if (groupItems && groupItems?.length > 0) {\n return groupItems.map(({ tracker, ...data }) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n {renderAnyTemplates(children, {data, type: data.type || 'default', error, state: loadState})}\n </AdViewUnitTracking>\n );\n });\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n {renderAnyTemplates(children, {data: null, type: 'default', error, state: loadState})}\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitClient;\n","//\n// Example\n// <AdView.Unit>\n// <AdView.Template type=\"banner\">\n// <...>\n// </AdView.Template>\n// </AdView.Unit>\n//\n\nimport React, { JSX } from 'react';\nimport { AdViewUnitClientChildrenProps, AdViewUnitTemplateProps, AdViewUnitTemplateTypeProps } from '../types';\n\n// TemplateListRender is a function that takes a list of TemplateType and returns a React element\nexport type TemplateListRender = (tmpls: TemplateElement[]) => React.ReactElement | JSX.Element;\n\n// TemplateType is a React component that can be used to render ad templates\nexport type TemplateType = React.Component<AdViewUnitTemplateProps>;\nexport type TemplateElement = React.ReactElement<AdViewUnitTemplateProps>;\n\n// TemplateTypeFunction is a function that takes AdViewUnitTemplateTypeProps and returns a React node or element\nexport type TemplateTypeFunction = (props: AdViewUnitTemplateTypeProps) => React.ReactNode | React.ReactElement;\n\n// templateFromListRender is a function that takes a list of TemplateType and returns a React element\nexport const templateFromListRender = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, wrap?: (children: React.ReactNode) => React.ReactNode): JSX.Element | React.ReactElement => {\n let renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, data);\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n\n if (!renderedRemplates.length) {\n renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, {...data, type: 'default'});\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n }\n\n return (<>{renderedRemplates}</>);\n};\n\n// renderTemplate is a function that takes a TemplateType or a function and returns a React node\nexport const renderTemplate = (tmpl: TemplateElement | TemplateTypeFunction, data: AdViewUnitTemplateTypeProps): React.ReactNode => {\n const isFunction = typeof tmpl === 'function';\n const isReactElement = React.isValidElement(tmpl);\n\n if (isReactElement) {\n // Extract type and children from the React element\n const { type, children } = (tmpl as TemplateElement).props;\n console.log('=====>\\nrenderTemplate: React element detected, type:', type, 'data:', data.type, data.type !== type);\n // If the type does not match, return null\n if (data.type !== type) {\n return null;\n }\n // If children is a function, call it with the data\n if (typeof children === 'function') {\n return children(data as AdViewUnitClientChildrenProps);\n }\n console.log('CLONE ELEMENT', tmpl);\n // If children is a React element, clone it with the new props\n return React.cloneElement((tmpl as TemplateElement), {\n ...data,\n children: children,\n });\n }\n\n if (isFunction) {\n return tmpl(data);\n }\n\n return null;\n}\n\n// renderTemplates is a function that takes a list of TemplateType and returns a React element\nexport const renderTemplates = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element => {\n return listRender ? listRender(tmpls) : templateFromListRender(tmpls, data);\n};\n\nexport const renderAnyTemplates = (tmpls: any, data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element | null => {\n if (!tmpls) {\n return null;\n }\n\n if (Array.isArray(tmpls)) {\n return renderTemplates(tmpls as TemplateElement[], data, listRender);\n }\n\n if (typeof tmpls === 'function') {\n return tmpls(data);\n }\n\n if (React.isValidElement(tmpls)) {\n return templateFromListRender([tmpls as TemplateElement], data);\n }\n\n return null;\n}\n\n// Template is a React component that renders a template based on the type and data provided\n// Example usage:\n// <AdView.Unit>\n// <AdView.Template type=\"banner\" data={{...}}>\n// </AdView.Unit>\nconst AdViewUnitTemplate = ({ type, children, ...data }: AdViewUnitTemplateProps) => {\n const tmplProps: AdViewUnitTemplateTypeProps = {\n type,\n ...data,\n };\n\n // If children is a function, call it with the data\n if (typeof children === 'function') {\n return children(tmplProps as AdViewUnitClientChildrenProps) as React.ReactElement;\n }\n\n // If children is a React element, clone it with the new props\n if (React.isValidElement(children)) {\n return React.cloneElement(children, tmplProps);\n }\n\n // If no children are provided, return an empty fragment\n return <></>;\n}\n\nexport default AdViewUnitTemplate;\n","'use client';\n\nimport { executeImpressionsTracking } from '@adview/core/utils';\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\n\ntype AdViewUnitTrackingProps = {\n impressions?: string[];\n views?: string[];\n clicks?: string[];\n children: React.ReactNode;\n};\n\nfunction AdViewUnitTracking({\n impressions,\n views,\n clicks,\n children,\n}: AdViewUnitTrackingProps) {\n const isServer = typeof window === 'undefined';\n const wrapperRef = useRef<HTMLDivElement>(null);\n const executeImpressionsTrackingHandler = useCallback(\n () => executeImpressionsTracking(impressions),\n [impressions],\n );\n const trackingObserverInstanceHandler = useCallback(\n (entries: IntersectionObserverEntry[]) => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n executeImpressionsTracking(views);\n trackingObserverInstance?.unobserve(wrapperRef.current!);\n }\n });\n },\n [views],\n );\n const trackingObserverInstance = useMemo<IntersectionObserver | null>(() => {\n return !isServer\n ? new IntersectionObserver(trackingObserverInstanceHandler)\n : null;\n }, [isServer, trackingObserverInstanceHandler]);\n const clickTrackerHandler = useCallback(() => {\n executeImpressionsTracking(clicks);\n\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n }, [clicks]);\n\n useEffect(() => {\n if (wrapperRef.current && trackingObserverInstance) {\n executeImpressionsTrackingHandler();\n wrapperRef.current?.addEventListener('click', clickTrackerHandler);\n trackingObserverInstance?.observe(wrapperRef.current);\n\n return () => {\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n if (wrapperRef.current)\n trackingObserverInstance?.unobserve(wrapperRef.current);\n };\n }\n\n return () => {};\n }, [\n trackingObserverInstance,\n executeImpressionsTrackingHandler,\n clickTrackerHandler,\n ]);\n\n return <div ref={wrapperRef}>{children}</div>;\n}\n\nexport default AdViewUnitTracking;\n","'use client';\n\nimport { AdViewData } from '@adview/core/typings';\nimport { adViewFetcher, getAdRequestUrl, getResolveConfig } from '@adview/core/utils';\nimport { useContext, useEffect, useState } from 'react';\nimport { AdLoadState, AdViewConfig } from '../types';\nimport { AdViewProviderContext } from './AdViewProvider';\n\ntype UseAdViewControllerProps = [AdViewData | null, Error | null, AdLoadState];\n\nfunction useAdViewController(\n adUnitConfig: AdViewConfig,\n unitId: string,\n format?: string | string[],\n): UseAdViewControllerProps {\n const [adLoadState, setAdLoadState] = useState<string>('initial');\n const [adData, setAdData] = useState<AdViewData | null>(null);\n const [errorMessage, setErrorMessage] = useState<Error | null>(null);\n const globalConfig = useContext(AdViewProviderContext);\n const baseConfig = getResolveConfig({ ...adUnitConfig, ...globalConfig });\n const requestUrl = getAdRequestUrl(baseConfig, unitId,\n typeof format === 'string' ? format : format?.join(',') || '');\n\n const loadAd = async () => {\n setAdLoadState('loading');\n\n try {\n console.log('Requesting ad data from:', adViewFetcher, 'with URL:', requestUrl);\n const response = await adViewFetcher(requestUrl, baseConfig.defaultAdData);\n console.log('AdViewController response:', response);\n\n if (response instanceof Error) {\n setAdLoadState('error');\n setErrorMessage(response);\n } else {\n setAdData(response);\n }\n setAdLoadState('complete');\n } catch (error) {\n setAdLoadState('error');\n setAdLoadState('complete');\n setErrorMessage(error as Error);\n }\n };\n\n const loadState = {\n isInitial: adLoadState === 'initial',\n isLoading: adLoadState === 'loading',\n isComplete: adLoadState === 'complete',\n isError: adLoadState === 'error',\n };\n\n useEffect(() => {loadAd()}, []);\n\n return [adData, errorMessage, loadState];\n}\n\nexport default useAdViewController;\n","'use client';\n\nimport React, { createContext } from 'react';\nimport { type AdViewConfig } from '../types';\n\ntype AdViewProviderContextProps = AdViewConfig;\n\nexport const AdViewProviderContext = createContext<AdViewProviderContextProps>(\n {} as AdViewProviderContextProps,\n);\n\ntype AdViewProviderProps = {\n children: React.ReactNode;\n} & AdViewProviderContextProps;\n\nconst AdViewProvider = ({ children, ...props }: AdViewProviderProps) => {\n return (\n <AdViewProviderContext.Provider value={props}>\n {children}\n </AdViewProviderContext.Provider>\n );\n};\n\nexport default AdViewProvider;\n","import React from 'react';\n\nimport { AdViewGroupItem } from '@adview/core/typings';\nimport { adViewFetcher, getAdRequestUrl, getResolveConfig } from '@adview/core/utils';\nimport { AdViewUnitPropsBase, AdViewUnitServerChildren } from '../types';\nimport { renderAnyTemplates } from './AdViewUnitTemplate';\nimport AdViewUnitTracking from './AdViewUnitTracking';\n\nexport type AdViewUnitServerProps = AdViewUnitPropsBase & {\n children?: AdViewUnitServerChildren;\n};\n\nasync function AdViewUnitServer({\n unitId,\n format,\n children,\n ...config\n}: AdViewUnitServerProps) {\n const baseConfig = getResolveConfig(config);\n const requestUrl = getAdRequestUrl(baseConfig, unitId, format);\n const response = await adViewFetcher(requestUrl);\n const isLoadingError = response instanceof Error;\n const error = isLoadingError ? response : undefined;\n const responseGroup =\n response instanceof Error ? null : response?.groups?.[0];\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = responseGroup?.items;\n\n if (groupItems && groupItems.length) {\n return groupItems.map(({ tracker, ...data }: AdViewGroupItem) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n {renderAnyTemplates(children, {data, type: data.type || 'default', error, state: {\n isLoading: true,\n isComplete: true,\n isInitial: false,\n isError: isLoadingError,\n }})}\n </AdViewUnitTracking>\n );\n });\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n {renderAnyTemplates(children, {data: null, type: 'default', error, state: {\n isLoading: true,\n isComplete: true,\n isInitial: false,\n isError: isLoadingError,\n }})}\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitServer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;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OAAwB;AAC1C,QAAM,WAAW,OAAO,WAAW;AAEnC,MAAI,UAAU;AACZ,WAAO,8BAAAC,QAAA,cAAC,6BAAkB,GAAI,OAAiC;AAAA,EACjE;AAEA,SAAO,8BAAAA,QAAA,cAAC,6BAAkB,GAAI,OAAiC;AACjE;AAEA,IAAO,qBAAQ;","names":["import_react","import_react","React","import_react","React","import_utils","import_react","import_react","React","import_react","import_utils","React","React"]}
1
+ {"version":3,"sources":["../../src/AdViewUnit/AdViewUnit.tsx","../../src/AdViewUnit/AdViewUnit.client.tsx","../../src/AdViewUnit/AdViewUnitBannerTemplate.tsx","../../src/AdViewUnit/utils.ts","../../src/AdViewUnit/AdViewUnitNativeTemplate.tsx","../../src/AdViewUnit/AdViewUnitProxyTemplate.tsx","../../src/AdViewUnit/AdViewUnitTemplate.tsx","../../src/AdViewUnit/AdViewUnitTracking.tsx","../../src/AdViewUnit/useAdViewController.ts","../../src/AdViewUnit/AdViewProvider.tsx","../../src/AdViewUnit/AdViewUnit.server.tsx"],"sourcesContent":["import React from 'react';\nimport AdViewUnitClient, { AdViewUnitClientProps } from './AdViewUnit.client';\nimport AdViewUnitServer, { AdViewUnitServerProps } from './AdViewUnit.server';\n\nexport type AdViewUnitProps = typeof window extends undefined\n ? AdViewUnitServerProps\n : AdViewUnitClientProps;\n\nfunction AdViewUnit(props: AdViewUnitProps) {\n const isServer = typeof window === 'undefined';\n\n if (isServer) {\n return <AdViewUnitServer {...(props as AdViewUnitServerProps)} />;\n }\n\n return <AdViewUnitClient {...(props as AdViewUnitClientProps)} />;\n}\n\nexport default AdViewUnit;\n","'use client';\n\nimport { AdViewGroupItem } from '@adview/core';\nimport React from 'react';\nimport { AdViewUnitClientChildren, AdViewUnitPropsBase } from '../types';\nimport AdViewUnitBannerTemplate from './AdViewUnitBannerTemplate';\nimport AdViewUnitNativeTemplate from './AdViewUnitNativeTemplate';\nimport AdViewUnitProxyTemplate from './AdViewUnitProxyTemplate';\nimport { renderAnyTemplates } from './AdViewUnitTemplate';\nimport AdViewUnitTracking from './AdViewUnitTracking';\nimport useAdViewController from './useAdViewController';\n\nexport type AdViewUnitClientProps = AdViewUnitPropsBase & {\n children?: AdViewUnitClientChildren;\n};\n\n// AdViewUnitClient is a client-side component that fetches ad data and renders it\n// using the provided children function. It handles loading, error states, and\n// tracks ad interactions.\n//\n// Example usage:\n// <AdView.Unit unitId=\"my-unit\" format=\"banner\" srcURL=\"https://api.example.com/ads/{<id>}\">\n// {({ data, state, error }) => (\n// <div>\n// {state.isLoading && <span>Loading...</span>}\n// {error && <span>Error: {error.message}</span>}\n// {data && <img src={data.imageUrl} alt={data.title} />\n// </div>\n// )}\n// </AdView.Unit>\n//\n// Note: This component is designed to be used in a client-side environment where\n// ad data can be fetched dynamically. It is not suitable for server-side rendering.\n// It uses the AdViewUnitTracking component to handle ad tracking and interactions.\nfunction AdViewUnitClient({\n unitId,\n format,\n children,\n ...config\n}: AdViewUnitClientProps) {\n const checkFormat = (f: string) => {\n if (!format) { return true; }\n return Array.isArray(format) ? format.includes(f) : f === format;\n };\n\n const [response, error, loadState] = useAdViewController(\n config,\n unitId,\n format,\n );\n\n const { responseGroup: _, customTracker, groupItems } = error ? {responseGroup: null, customTracker: {}, groupItems: []} : (() => {\n for (let responseGroup of response?.groups || []) {\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = (responseGroup?.items || []).map(it => checkFormat(it.type) ? it : null).filter(Boolean);\n if (groupItems && groupItems.length > 0) {\n return {responseGroup, customTracker, groupItems};\n }\n }\n return {responseGroup: null, customTracker: {}, groupItems: []};\n })();\n\n if (!children) {\n children = [\n <AdViewUnitBannerTemplate />,\n <AdViewUnitNativeTemplate />,\n <AdViewUnitProxyTemplate />\n ];\n }\n\n if (groupItems && groupItems?.length > 0) {\n return (groupItems as AdViewGroupItem[]).map(({ tracker, ...data }) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n {renderAnyTemplates(children, {data, type: data.type || 'default', error, state: loadState})}\n </AdViewUnitTracking>\n );\n });\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n {renderAnyTemplates(children, {data: null, type: 'default', error, state: loadState})}\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitClient;\n","import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdLoadState, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitBannerTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'banner';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitBannerTemplate({className=\"banner\", style, data, state, ...props}: AdViewUnitBannerTemplateProps) {\n const expectState: AdLoadState =\n (props?.isInitial || props?.isLoading || props?.isError || props?.isComplete) ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete\n } : {isComplete: true};\n\n if (!data || !data.assets || !data.assets.length) {\n return null;\n }\n \n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\n\n const asset = getAssetByName('main', data.assets);\n\n return (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(data.url)}\n className={className}\n style={{ fontSize: 0, ...style }}\n >\n {asset && (\n <img\n alt=\"main\"\n src={asset.path}\n srcSet={asset.thumbs ? getSrcSetCSSThumbs(asset.thumbs) : ''}\n />\n )}\n </a>\n );\n}\n\nAdViewUnitBannerTemplate.defaults = {\n type: 'banner',\n};\n\nexport default AdViewUnitBannerTemplate;\n","import { AdLoadState } from \"../types\";\n\nexport const matchExpectedState = (expectState?: AdLoadState, state?: AdLoadState) => {\n return !expectState || (\n (expectState.isInitial === undefined || expectState.isInitial === state?.isInitial) &&\n (expectState.isLoading === undefined || expectState.isLoading === state?.isLoading) &&\n (expectState.isError === undefined || expectState.isError === state?.isError) &&\n (expectState.isComplete === undefined || expectState.isComplete === state?.isComplete)\n );\n};\n","import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdLoadState, AdViewStyleTokensNative, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitNativeTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'native';\n classNames?: AdViewStyleTokensNative;\n};\n\nfunction AdViewUnitNativeTemplate({classNames, data, state, ...props}: AdViewUnitNativeTemplateProps) {\n if (!data || !data.assets || !data.assets.length) {\n return null;\n }\n\n const expectState: AdLoadState =\n (props?.isInitial || props?.isLoading || props?.isError || props?.isComplete) ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete\n } : {isComplete: true};\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\n\n const { assets, url, fields } = data;\n const asset = getAssetByName('main', assets);\n\n if (!url) {\n return null;\n }\n\n return (\n <div className={classNames?.container}>\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n className={classNames?.imageLink}\n >\n {asset && (\n <img\n alt={fields?.title}\n title={fields?.title}\n src={asset.path}\n srcSet={asset.thumbs ? getSrcSetCSSThumbs(asset.thumbs) : undefined}\n className={classNames?.image}\n style={{ objectFit: 'cover', width: '100%', height: '100%' }}\n />\n )}\n </a>\n <div className={classNames?.label}>\n {fields?.title && (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n data-class=\"titleLink\"\n className={classNames?.titleLink}\n >\n {fields.title}\n </a>\n )}\n {fields?.description && (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n data-class=\"descriptionLink\"\n className={classNames?.descriptionLink}\n >\n {fields.description}\n </a>\n )}\n {fields?.brandname && (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n data-class=\"brandNameLink\"\n className={classNames?.brandNameLink}\n >\n {fields.brandname}\n </a>\n )}\n {fields?.phone && (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n data-class=\"phoneLink\"\n className={classNames?.phoneLink}\n >\n {fields.phone}\n </a>\n )}\n {fields?.url && (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n data-class=\"urlLink\"\n className={classNames?.urlLink}\n >\n {fields?.url}\n </a>\n )}\n </div>\n </div>\n );\n}\n\nAdViewUnitNativeTemplate.defaults = {\n type: 'native',\n};\n\nexport default AdViewUnitNativeTemplate;\n","import React from 'react';\nimport { AdLoadState, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitProxyTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'proxy';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitProxyTemplate({className, style, data, state, ...props}: AdViewUnitProxyTemplateProps) {\n if (!data) {\n return null;\n }\n\n const expectState: AdLoadState =\n (props?.isInitial || props?.isLoading || props?.isError || props?.isComplete) ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete\n } : {isComplete: true};\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\n\n const { url, fields } = data;\n const iframeSrc = fields?.url || url;\n\n if (!iframeSrc) {\n return null;\n }\n\n return (\n <iframe\n className={className}\n width=\"100%\"\n height=\"100%\"\n frameBorder=\"0\"\n marginWidth={0}\n marginHeight={0}\n allowTransparency={true}\n scrolling=\"no\"\n allowFullScreen={true}\n style={{ width: '100%', height: '100%', border: 'none', ...style }}\n src={iframeSrc}\n ></iframe>\n );\n}\n\nAdViewUnitProxyTemplate.defaults = {\n type: 'proxy',\n};\n\nexport default AdViewUnitProxyTemplate;\n","//\n// Example\n// <AdView.Unit>\n// <AdView.Template type=\"banner\">\n// <...>\n// </AdView.Template>\n// </AdView.Unit>\n//\n\nimport React, { JSX } from 'react';\nimport { AdLoadState, AdViewUnitClientChildrenProps, AdViewUnitTemplateProps, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\n// TemplateListRender is a function that takes a list of TemplateType and returns a React element\nexport type TemplateListRender = (tmpls: TemplateElement[]) => React.ReactElement | JSX.Element;\n\n// TemplateType is a React component that can be used to render ad templates\nexport type TemplateType = React.Component<AdViewUnitTemplateProps>;\nexport type TemplateElement = React.ReactElement<AdViewUnitTemplateProps>;\n\n// TemplateTypeFunction is a function that takes AdViewUnitTemplateTypeProps and returns a React node or element\nexport type TemplateTypeFunction = (props: AdViewUnitTemplateTypeProps) => React.ReactNode | React.ReactElement;\n\n// templateFromListRender is a function that takes a list of TemplateType and returns a React element\nexport const templateFromListRender = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, wrap?: (children: React.ReactNode) => React.ReactNode): JSX.Element | React.ReactElement => {\n let renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, data);\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n\n if (!renderedRemplates.length) {\n renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, {...data, type: 'default'});\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n }\n\n return (<>{renderedRemplates}</>);\n};\n\n// renderTemplate is a function that takes a TemplateType or a function and returns a React node\nexport const renderTemplate = (tmpl: TemplateElement | TemplateTypeFunction, data: AdViewUnitTemplateTypeProps): React.ReactNode => {\n const isFunction = typeof tmpl === 'function';\n const isReactElement = React.isValidElement(tmpl);\n\n if (isReactElement) {\n // Extract type and children from the React element\n let { type, children } = tmpl.props;\n if (!type && typeof tmpl.type !== 'string') {\n type = (tmpl.type as any)?.defaults?.type;\n }\n // If the type does not match, return null\n if (!!type && type !== '*' && data.type !== type) {\n return null;\n }\n // If children is a function, call it with the data\n if (typeof children === 'function') {\n return children(data as AdViewUnitClientChildrenProps);\n }\n // If children is a React element, clone it with the new props\n return React.cloneElement((tmpl as TemplateElement), {\n ...data,\n children: children,\n });\n }\n\n if (isFunction) {\n return tmpl(data);\n }\n\n return null;\n}\n\n// renderTemplates is a function that takes a list of TemplateType and returns a React element\nexport const renderTemplates = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element => {\n return listRender ? listRender(tmpls) : templateFromListRender(tmpls, data);\n};\n\nexport const renderAnyTemplates = (tmpls: any, data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element | null => {\n if (!tmpls) {\n return null;\n }\n\n if (Array.isArray(tmpls)) {\n return renderTemplates(tmpls as TemplateElement[], data, listRender);\n }\n\n if (typeof tmpls === 'function') {\n return tmpls(data);\n }\n\n if (React.isValidElement(tmpls)) {\n return templateFromListRender([tmpls as TemplateElement], data);\n }\n\n return null;\n}\n\n// Template is a React component that renders a template based on the type and data provided\n// Example usage:\n// <AdView.Unit>\n// <AdView.Template type=\"banner\" data={{...}}>\n// </AdView.Unit>\nconst AdViewUnitTemplate = ({ type, state, children, ...props }: AdViewUnitTemplateProps) => {\n const tmplProps: AdViewUnitTemplateTypeProps = {\n type,\n state,\n ...props,\n };\n \n const expectState: AdLoadState =\n (props?.isInitial || props?.isLoading || props?.isError || props?.isComplete) ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete\n } : {isComplete: true};\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\n\n // If children is a function, call it with the data\n if (typeof children === 'function') {\n return children(tmplProps as AdViewUnitClientChildrenProps) as React.ReactElement;\n }\n\n // If children is a React element, clone it with the new props\n if (React.isValidElement(children)) {\n return React.cloneElement(children, tmplProps);\n }\n\n // If no children are provided, return an empty fragment\n return <></>;\n}\n\nexport default AdViewUnitTemplate;\n","'use client';\n\nimport { executeImpressionsTracking } from '@adview/core/utils';\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\n\ntype AdViewUnitTrackingProps = {\n impressions?: string[];\n views?: string[];\n clicks?: string[];\n children: React.ReactNode;\n};\n\nfunction AdViewUnitTracking({\n impressions,\n views,\n clicks,\n children,\n}: AdViewUnitTrackingProps) {\n const isServer = typeof window === 'undefined';\n const wrapperRef = useRef<HTMLDivElement>(null);\n const executeImpressionsTrackingHandler = useCallback(\n () => executeImpressionsTracking(impressions),\n [impressions],\n );\n const trackingObserverInstanceHandler = useCallback(\n (entries: IntersectionObserverEntry[]) => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n executeImpressionsTracking(views);\n trackingObserverInstance?.unobserve(wrapperRef.current!);\n }\n });\n },\n [views],\n );\n const trackingObserverInstance = useMemo<IntersectionObserver | null>(() => {\n return !isServer\n ? new IntersectionObserver(trackingObserverInstanceHandler)\n : null;\n }, [isServer, trackingObserverInstanceHandler]);\n const clickTrackerHandler = useCallback(() => {\n executeImpressionsTracking(clicks);\n\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n }, [clicks]);\n\n useEffect(() => {\n if (wrapperRef.current && trackingObserverInstance) {\n executeImpressionsTrackingHandler();\n wrapperRef.current?.addEventListener('click', clickTrackerHandler);\n trackingObserverInstance?.observe(wrapperRef.current);\n\n return () => {\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n if (wrapperRef.current)\n trackingObserverInstance?.unobserve(wrapperRef.current);\n };\n }\n\n return () => {};\n }, [\n trackingObserverInstance,\n executeImpressionsTrackingHandler,\n clickTrackerHandler,\n ]);\n\n return <div ref={wrapperRef}>{children}</div>;\n}\n\nexport default AdViewUnitTracking;\n","'use client';\n\nimport { AdViewData } from '@adview/core/typings';\nimport { adViewFetcher, getAdRequestUrl, getResolveConfig } from '@adview/core/utils';\nimport { useContext, useEffect, useState } from 'react';\nimport { AdLoadState, AdViewConfig } from '../types';\nimport { AdViewProviderContext } from './AdViewProvider';\n\ntype UseAdViewControllerProps = [AdViewData | null, Error | null, AdLoadState];\n\nfunction useAdViewController(\n adUnitConfig: AdViewConfig,\n unitId: string,\n format?: string | string[],\n): UseAdViewControllerProps {\n const [adLoadState, setAdLoadState] = useState<string>('initial');\n const [adData, setAdData] = useState<AdViewData | null>(null);\n const [errorMessage, setErrorMessage] = useState<Error | null>(null);\n const globalConfig = useContext(AdViewProviderContext);\n const baseConfig = getResolveConfig({ ...adUnitConfig, ...globalConfig });\n const requestUrl = getAdRequestUrl(baseConfig, unitId,\n typeof format === 'string' ? format : format?.join(',') || '');\n\n const loadAd = async () => {\n setAdLoadState('loading');\n\n try {\n const response = await adViewFetcher(requestUrl, baseConfig.defaultAdData);\n\n if (response instanceof Error) {\n setAdLoadState('error');\n setErrorMessage(response);\n } else {\n setAdData(response);\n }\n setAdLoadState('complete');\n } catch (error) {\n setAdLoadState('error');\n setAdLoadState('complete');\n setErrorMessage(error as Error);\n }\n };\n\n const loadState = {\n isInitial: adLoadState === 'initial',\n isLoading: adLoadState === 'loading',\n isComplete: adLoadState === 'complete',\n isError: adLoadState === 'error',\n };\n\n useEffect(() => {loadAd()}, []);\n\n return [adData, errorMessage, loadState];\n}\n\nexport default useAdViewController;\n","'use client';\n\nimport React, { createContext } from 'react';\nimport { type AdViewConfig } from '../types';\n\ntype AdViewProviderContextProps = AdViewConfig;\n\nexport const AdViewProviderContext = createContext<AdViewProviderContextProps>(\n {} as AdViewProviderContextProps,\n);\n\ntype AdViewProviderProps = {\n children: React.ReactNode;\n} & AdViewProviderContextProps;\n\nconst AdViewProvider = ({ children, ...props }: AdViewProviderProps) => {\n return (\n <AdViewProviderContext.Provider value={props}>\n {children}\n </AdViewProviderContext.Provider>\n );\n};\n\nexport default AdViewProvider;\n","import React from 'react';\n\nimport { AdViewData } from '@adview/core';\nimport { AdViewGroupItem } from '@adview/core/typings';\nimport { adViewFetcher, getAdRequestUrl, getResolveConfig } from '@adview/core/utils';\nimport { AdViewUnitClientChildren, AdViewUnitPropsBase } from '../types';\nimport AdViewUnitBannerTemplate from './AdViewUnitBannerTemplate';\nimport AdViewUnitNativeTemplate from './AdViewUnitNativeTemplate';\nimport AdViewUnitProxyTemplate from './AdViewUnitProxyTemplate';\nimport { renderAnyTemplates } from './AdViewUnitTemplate';\nimport AdViewUnitTracking from './AdViewUnitTracking';\n\nexport type AdViewUnitServerProps = AdViewUnitPropsBase & {\n children?: AdViewUnitClientChildren;\n};\n\nasync function AdViewUnitServer({\n unitId,\n format,\n children,\n ...config\n}: AdViewUnitServerProps) {\n const checkFormat = (f: string) => {\n if (!format) { return true; }\n return Array.isArray(format) ? format.includes(f) : f === format;\n };\n\n const baseConfig = getResolveConfig(config);\n const requestUrl = getAdRequestUrl(baseConfig, unitId, format);\n const response = await adViewFetcher(requestUrl);\n const isLoadingError = response instanceof Error;\n const error = isLoadingError ? response : undefined;\n const state = {\n isLoading: true,\n isComplete: true,\n isInitial: false,\n isError: isLoadingError,\n };\n\n const { responseGroup: _, customTracker, groupItems } = error ? {responseGroup: null, customTracker: {}, groupItems: []} : (() => {\n for (let responseGroup of (response as AdViewData)?.groups || []) {\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = (responseGroup?.items || []).map(it => checkFormat(it.type) ? it : null).\n filter(Boolean) as AdViewGroupItem[];\n if (groupItems && groupItems.length > 0) {\n return {responseGroup, customTracker, groupItems};\n }\n }\n return {responseGroup: null, customTracker: {}, groupItems: []};\n })();\n \n if (!children) {\n children = [\n <AdViewUnitBannerTemplate />,\n <AdViewUnitNativeTemplate />,\n <AdViewUnitProxyTemplate />\n ];\n }\n\n if (groupItems && groupItems.length) {\n return groupItems.map(({ tracker, ...data }: AdViewGroupItem) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n {renderAnyTemplates(children, {data, type: data.type || 'default', error, state: state})}\n </AdViewUnitTracking>\n );\n });\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n {renderAnyTemplates(children, {data: null, type: 'default', error, state: state})}\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitServer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,iBAAkB;;;ACGlB,IAAAC,gBAAkB;;;ACHlB,mBAAkE;AAClE,mBAAkB;;;ACCX,IAAM,qBAAqB,CAAC,aAA2B,UAAwB;AACpF,SAAO,CAAC,gBACL,YAAY,cAAc,UAAa,YAAY,cAAc,OAAO,eACxE,YAAY,cAAc,UAAa,YAAY,cAAc,OAAO,eACxE,YAAY,YAAY,UAAa,YAAY,YAAY,OAAO,aACpE,YAAY,eAAe,UAAa,YAAY,eAAe,OAAO;AAE/E;;;ADEA,SAAS,yBAAyB,EAAC,YAAU,UAAU,OAAO,MAAM,OAAO,GAAG,MAAK,GAAkC;AACnH,QAAM,cACH,OAAO,aAAa,OAAO,aAAa,OAAO,WAAW,OAAO,aAAc;AAAA,IAC9E,WAAW,OAAO;AAAA,IAClB,WAAW,OAAO;AAAA,IAClB,SAAS,OAAO;AAAA,IAChB,YAAY,OAAO;AAAA,EACrB,IAAI,EAAC,YAAY,KAAI;AAEvB,MAAI,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC,KAAK,OAAO,QAAQ;AAChD,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,mBAAmB,aAAa,KAAK,GAAG;AAC3C,WAAO;AAAA,EACT;AAEA,QAAM,YAAQ,6BAAe,QAAQ,KAAK,MAAM;AAEhD,SACE,6BAAAC,QAAA;AAAA,IAAC;AAAA;AAAA,MACC,QAAO;AAAA,MACP,KAAI;AAAA,MACJ,UAAM,4BAAc,KAAK,GAAG;AAAA,MAC5B;AAAA,MACA,OAAO,EAAE,UAAU,GAAG,GAA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AkB,CAAC;AACxD,YAAMC,eAAc,eAAe,SAAS,CAAC,GAAG,IAAI,QAAM,YAAY,GAAG,IAAI,IAAI,KAAK,IAAI,EACxF,OAAO,OAAO;AAChB,UAAIA,eAAcA,YAAW,SAAS,GAAG;AACvC,eAAO,EAAC,eAAe,eAAAD,gBAAe,YAAAC,YAAU;AAAA,MAClD;AAAA,IACF;AACA,WAAO,EAAC,eAAe,MAAM,eAAe,CAAC,GAAG,YAAY,CAAC,EAAC;AAAA,EAChE,GAAG;AAEH,MAAI,CAAC,UAAU;AACb,eAAW;AAAA,MACT,8BAAAC,QAAA,cAAC,sCAAyB;AAAA,MAC1B,8BAAAA,QAAA,cAAC,sCAAyB;AAAA,MAC1B,8BAAAA,QAAA,cAAC,qCAAwB;AAAA,IAC3B;AAAA,EACF;AAEA,MAAI,cAAc,WAAW,QAAQ;AACnC,WAAO,WAAW,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,MAAuB;AAC/D,aACE,8BAAAA,QAAA,cAAC,8BAAmB,KAAK,KAAK,IAAK,GAAG,WACnC,mBAAmB,UAAU,EAAC,MAAM,MAAM,KAAK,QAAQ,WAAW,OAAO,MAAY,CAAC,CACzF;AAAA,IAEJ,CAAC;AAAA,EACH;AAEA,SACE,8BAAAA,QAAA,cAAC,8BAAoB,GAAG,iBACrB,mBAAmB,UAAU,EAAC,MAAM,MAAM,MAAM,WAAW,OAAO,MAAY,CAAC,CAClF;AAEJ;AAEA,IAAO,4BAAQ;;;AVpEf,SAAS,WAAW,OAAwB;AAC1C,QAAM,WAAW,OAAO,WAAW;AAEnC,MAAI,UAAU;AACZ,WAAO,+BAAAC,QAAA,cAAC,6BAAkB,GAAI,OAAiC;AAAA,EACjE;AAEA,SAAO,+BAAAA,QAAA,cAAC,6BAAkB,GAAI,OAAiC;AACjE;AAEA,IAAO,qBAAQ;","names":["import_react","import_react","React","import_utils","import_react","React","import_react","React","import_react","React","import_utils","import_react","React","import_utils","import_react","import_react","customTracker","groupItems","React","import_react","import_utils","customTracker","groupItems","React","React"]}