, s = (0,
u.useState)(!1)
, l = (0,
g.Z)(s, 2)
, c = l[0]
, d = l[1];
function f(e) {
sessionStorage.setItem(sx, JSON.stringify(e)),
i(e)
function p() {
return (p = v(h().mark((function e(t) {
var n, r, o, a, s, l, u;
return h().wrap((function(e) {
for (; ; )
switch (e.prev = e.next) {
case 0:
if (t.storeUrl,
t.storeName,
!(n = t.shortname)) {
e.next = 24;
break
if (d(!0),
r = Ex(),
o = r.getCachedData(),
!r.hasCache({
cachedData: o,
selectedCompanyShortname: n
})) {
e.next = 8;
break
return d(!1),
e.abrupt("return", i(o));
case 8:
return e.prev = 8,
l = Cx(),
e.next = 12,
l.getCachedCompanyDiscountsData(n);
case 12:
if (u = e.sent,
!l.notHaveCache(u)) {
e.next = 16;
break
return d(!1),
e.abrupt("return", l.getDiscountsData({
shortname: n,
responseCallback: f
}));
case 16:
sessionStorage.setItem(sx, JSON.stringify(null === (a = u.data) || void
0 === a ? void 0 : a.data)),
i(null === (s = u.data) || void 0 === s ? void 0 : s.data),
e.next = 24;
break;
case 20:
return e.prev = 20,
e.t0 = e.catch(8),
console.error(JSON.stringify(e.t0)),
e.abrupt("return", d(!1));
case 24:
d(!1);
case 25:
case "end":
return e.stop()
), e, null, [[8, 20]])
)))).apply(this, arguments)
var m = (0,
u.useCallback)((function() {
return !(null === o || void 0 === o || !o.discount_coupons.length)
), [null === o || void 0 === o ? void 0 : o.discount_coupons.length])
, y = (0,
u.useCallback)((function() {
return !(null === o || void 0 === o || !o.discount_offers.length)
), [null === o || void 0 === o ? void 0 : o.discount_offers.length])
, b = (0,
u.useMemo)((function() {
var e;
return null !== (e = null === o || void 0 === o ? void 0 :
o.discount_coupons.length) && void 0 !== e ? e : 0
), [o])
, x = (0,
u.useMemo)((function() {
var e;
return null !== (e = null === o || void 0 === o ? void 0 :
o.discount_offers.length) && void 0 !== e ? e : 0
), [o]);
return (0,
u.useEffect)((function() {
var e = sessionStorage.getItem(sx);
if (e) {
var t = JSON.parse(e);
return sessionStorage.setItem(lx, "true"),
i(t)
), []),
(0,
a.jsx)($l.Provider, {
value: {
loading: c,
selectedCompanyDiscounts: o,
couponsQuantity: b,
offersQuantity: x,
couponsAndOffersQuantity: b + x,
hasOffers: y,
hasCoupons: m,
getCompanyDiscounts: function(e) {
return p.apply(this, arguments)
},
clearSelectedCompanyDiscounts: function() {
sessionStorage.removeItem(sx),
i(void 0)
},
children: t
})
};
function Px(e) {
var t = e.children;
return (0,
a.jsx)(mx, {
components: [Lr, qr, xx, _x, Xl, Ae, Ax, wx],
children: t
})
var Tx = function() {
return (0,
a.jsx)(f.ZP.section, {
children: (0,
a.jsx)(l, {
children: (0,
a.jsx)(Px, {
children: (0,
a.jsx)(hx, {})
})
})
})
, Rx = document.createElement("reclameaqui-extension-pin");
document.body.appendChild(Rx);
var Ox = document.getElementById("extension-root")
, jx = (0,
d.s)(Rx);
!Ox && jx.render((0,
a.jsx)(u.StrictMode, {
children: (0,
a.jsx)(Tx, {})
}))
}()
}();
//# sourceMappingURL=pinComponent.js.map