@hellocoop/vue 2.1.2 → 2.1.4

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.
package/dist/index.mjs CHANGED
@@ -1,19 +1,19 @@
1
- import { provide as ae, inject as le, defineComponent as L, onMounted as Q, ref as X, openBlock as k, createElementBlock as U, normalizeClass as se, normalizeStyle as ue, createElementVNode as ce, createBlock as q, getCurrentInstance as fe, reactive as de, onUnmounted as he, watch as ve, isReadonly as ge, toRefs as pe, renderSlot as Z, createCommentVNode as ee } from "vue";
2
- const m = {
1
+ import { provide as oe, inject as le, defineComponent as C, onMounted as Q, ref as X, openBlock as E, createElementBlock as M, normalizeClass as se, unref as Y, normalizeStyle as ue, createElementVNode as ce, createBlock as j, getCurrentInstance as fe, reactive as de, onUnmounted as he, watch as ve, isReadonly as ge, toRefs as me, renderSlot as Z, createCommentVNode as ee } from "vue";
2
+ const w = {
3
3
  login: "/api/hellocoop?login=true",
4
4
  auth: "/api/hellocoop?auth=true",
5
5
  logout: "/api/hellocoop?logout=true"
6
- }, te = "HelloAuth", _e = () => le(te), Ke = {
6
+ }, te = "HelloAuth", ye = () => le(te), Be = {
7
7
  props: ["auth", "config"],
8
8
  setup(t) {
9
- var r, e, i;
10
- (r = t == null ? void 0 : t.config) != null && r.login && (m.login = t.config.login), (e = t == null ? void 0 : t.config) != null && e.auth && (m.auth = t.config.auth), (i = t == null ? void 0 : t.config) != null && i.logout && (m.logout = t.config.logout), ae(te, t.auth);
9
+ var n, e, i;
10
+ (n = t == null ? void 0 : t.config) != null && n.login && (w.login = t.config.login), (e = t == null ? void 0 : t.config) != null && e.auth && (w.auth = t.config.auth), (i = t == null ? void 0 : t.config) != null && i.logout && (w.logout = t.config.logout), oe(te, t.auth);
11
11
  },
12
12
  render() {
13
13
  return this.$slots.default();
14
14
  }
15
15
  };
16
- var P;
16
+ var A;
17
17
  ((t) => {
18
18
  t.STYLES_URL = "https://cdn.hello.coop/css/hello-btn.css", t.HOVER_MAPPING = {
19
19
  pop: "",
@@ -34,292 +34,260 @@ var P;
34
34
  "aware-static": "hello-btn-white-and-static"
35
35
  }
36
36
  };
37
- })(P || (P = {}));
38
- const ye = /* @__PURE__ */ L({
37
+ })(A || (A = {}));
38
+ const be = ["disabled"], pe = ["innerHTML"], U = /* @__PURE__ */ C({
39
39
  __name: "BaseButton",
40
40
  props: {
41
- label: { type: String, required: !1, default: "ō   Continue with Hellō" },
42
- style: { type: null, required: !1 },
43
- color: { type: String, required: !1, default: "black" },
44
- theme: { type: String, required: !1, default: "ignore-light" },
45
- hover: { type: String, required: !1, default: "pop" },
46
- scope: { type: Array, required: !1 },
47
- update: { type: Boolean, required: !1 },
48
- targetURI: { type: String, required: !1 },
49
- providerHint: { type: Array, required: !1 },
50
- showLoader: { type: Boolean, required: !1, default: !1 },
51
- disabled: { type: Boolean, required: !1, default: !1 },
52
- promptLogin: { type: Boolean, required: !1, default: !1 },
53
- promptConsent: { type: Boolean, required: !1, default: !1 },
54
- loginHint: { type: String, required: !1, default: "" },
55
- domainHint: { type: String, required: !1, default: "" }
41
+ label: { default: "ō   Continue with Hellō" },
42
+ style: {},
43
+ color: { default: "black" },
44
+ theme: { default: "ignore-light" },
45
+ hover: { default: "pop" },
46
+ scope: {},
47
+ update: { type: Boolean },
48
+ targetURI: {},
49
+ providerHint: {},
50
+ showLoader: { type: Boolean, default: !1 },
51
+ disabled: { type: Boolean, default: !1 },
52
+ promptLogin: { type: Boolean, default: !1 },
53
+ promptConsent: { type: Boolean, default: !1 },
54
+ loginHint: { default: "" },
55
+ domainHint: { default: "" }
56
56
  },
57
- setup(t, { expose: r }) {
58
- r();
59
- let e = !1;
57
+ setup(t) {
58
+ let n = !1;
60
59
  Q(() => {
61
- typeof window < "u" && !e && (Array.from(document.head.getElementsByTagName("link")).find(
62
- (a) => {
60
+ typeof window < "u" && !n && (Array.from(document.head.getElementsByTagName("link")).find(
61
+ (f) => {
63
62
  var s;
64
- return a.getAttribute("rel") === "stylesheet" && ((s = a.getAttribute("href")) == null ? void 0 : s.startsWith(P.STYLES_URL));
63
+ return f.getAttribute("rel") === "stylesheet" && ((s = f.getAttribute("href")) == null ? void 0 : s.startsWith(A.STYLES_URL));
65
64
  }
66
- ) || console.warn("Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."), e = !0);
65
+ ) || console.warn("Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."), n = !0);
67
66
  });
68
- const i = X(!1), o = t, n = new URL(m.login, window.location.origin);
69
- o.scope && n.searchParams.set("scope", o.scope.join(" ")), n.searchParams.set("target_uri", o.targetURI || window.location.pathname), o.update && n.searchParams.set("prompt", "consent"), o.promptLogin && o.promptConsent ? n.searchParams.set("prompt", "login consent") : o.promptLogin ? n.searchParams.set("prompt", "login") : o.promptConsent && n.searchParams.set("prompt", "consent"), o.loginHint && n.searchParams.set("login_hint", o.loginHint), o.domainHint && n.searchParams.set("login_hint", o.domainHint), o.providerHint && n.searchParams.set("provider_hint", o.providerHint.join(" "));
70
- const c = { get checkedForStylesheet() {
71
- return e;
72
- }, set checkedForStylesheet(f) {
73
- e = f;
74
- }, clicked: i, props: o, loginRoute: n, onClickHandler: () => {
75
- i.value = !0, window.location.href = n.href;
76
- }, get Button() {
77
- return P;
78
- } };
79
- return Object.defineProperty(c, "__isScriptSetup", { enumerable: !1, value: !0 }), c;
67
+ const e = X(!1), i = t, a = new URL(w.login, window.location.origin);
68
+ i.scope && a.searchParams.set("scope", i.scope.join(" ")), a.searchParams.set("target_uri", i.targetURI || window.location.pathname), i.update && a.searchParams.set("prompt", "consent"), i.promptLogin && i.promptConsent ? a.searchParams.set("prompt", "login consent") : i.promptLogin ? a.searchParams.set("prompt", "login") : i.promptConsent && a.searchParams.set("prompt", "consent"), i.loginHint && a.searchParams.set("login_hint", i.loginHint), i.domainHint && a.searchParams.set("login_hint", i.domainHint), i.providerHint && a.searchParams.set("provider_hint", i.providerHint.join(" "));
69
+ const r = () => {
70
+ e.value = !0, window.location.href = a.href;
71
+ };
72
+ return (l, f) => {
73
+ var s;
74
+ return E(), M("button", {
75
+ onClick: r,
76
+ class: se(["hello-btn", (s = Y(A).CLASS_MAPPING[i.color]) == null ? void 0 : s[i.theme], Y(A).HOVER_MAPPING[l.hover], (l.showLoader || e.value) && "hello-btn-loader"]),
77
+ disabled: i.disabled || e.value,
78
+ style: ue(l.style)
79
+ }, [
80
+ ce("span", { innerHTML: l.label }, null, 8, pe)
81
+ ], 14, be);
82
+ };
80
83
  }
81
- }), R = (t, r) => {
82
- const e = t.__vccOpts || t;
83
- for (const [i, o] of r)
84
- e[i] = o;
85
- return e;
86
- }, be = ["disabled"], me = ["innerHTML"];
87
- function we(t, r, e, i, o, n) {
88
- var l;
89
- return k(), U("button", {
90
- onClick: i.onClickHandler,
91
- class: se(["hello-btn", (l = i.Button.CLASS_MAPPING[i.props.color]) == null ? void 0 : l[i.props.theme], i.Button.HOVER_MAPPING[e.hover], (e.showLoader || i.clicked) && "hello-btn-loader"]),
92
- disabled: i.props.disabled || i.clicked,
93
- style: ue(e.style)
94
- }, [
95
- ce("span", { innerHTML: e.label }, null, 8, me)
96
- ], 14, be);
97
- }
98
- const M = /* @__PURE__ */ R(ye, [["render", we], ["__file", "/Users/dick/github/HelloCoop/packages-js/vue/lib/buttons/BaseButton.vue"]]), Se = /* @__PURE__ */ L({
84
+ }), De = /* @__PURE__ */ C({
99
85
  __name: "ContinueButton",
100
- setup(t, { expose: r }) {
101
- r();
102
- const e = { BaseButton: M };
103
- return Object.defineProperty(e, "__isScriptSetup", { enumerable: !1, value: !0 }), e;
86
+ setup(t) {
87
+ return (n, e) => (E(), j(U));
104
88
  }
105
- });
106
- function Ce(t, r, e, i, o, n) {
107
- return k(), q(i.BaseButton);
108
- }
109
- const We = /* @__PURE__ */ R(Se, [["render", Ce], ["__file", "/Users/dick/github/HelloCoop/packages-js/vue/lib/buttons/ContinueButton.vue"]]), Le = /* @__PURE__ */ L({
89
+ }), xe = /* @__PURE__ */ C({
110
90
  __name: "LoginButton",
111
- setup(t, { expose: r }) {
112
- r();
113
- const e = { BaseButton: M };
114
- return Object.defineProperty(e, "__isScriptSetup", { enumerable: !1, value: !0 }), e;
91
+ setup(t) {
92
+ return (n, e) => (E(), j(U, { label: "ō   Login with Hellō" }));
115
93
  }
116
- });
117
- function ke(t, r, e, i, o, n) {
118
- return k(), q(i.BaseButton, { label: "ō   Login with Hellō" });
119
- }
120
- const Ye = /* @__PURE__ */ R(Le, [["render", ke], ["__file", "/Users/dick/github/HelloCoop/packages-js/vue/lib/buttons/LoginButton.vue"]]), Re = /* @__PURE__ */ L({
94
+ }), $e = /* @__PURE__ */ C({
121
95
  __name: "UpdateProfileButton",
122
- setup(t, { expose: r }) {
123
- r();
124
- const e = { BaseButton: M };
125
- return Object.defineProperty(e, "__isScriptSetup", { enumerable: !1, value: !0 }), e;
96
+ setup(t) {
97
+ return (n, e) => (E(), j(U, {
98
+ label: "ō   Update Profile with Hellō",
99
+ update: !0
100
+ }));
126
101
  }
127
102
  });
128
- function Ae(t, r, e, i, o, n) {
129
- return k(), q(i.BaseButton, {
130
- label: "ō   Update Profile with Hellō",
131
- update: !0
132
- });
133
- }
134
- const Je = /* @__PURE__ */ R(Re, [["render", Ae], ["__file", "/Users/dick/github/HelloCoop/packages-js/vue/lib/buttons/UpdateProfileButton.vue"]]);
135
- var $ = /* @__PURE__ */ new WeakMap(), Y = 0;
136
- function Ie(t) {
103
+ var D = /* @__PURE__ */ new WeakMap(), q = 0;
104
+ function we(t) {
137
105
  if (!t.length)
138
106
  return "";
139
- for (var r = "arg", e = 0; e < t.length; ++e) {
107
+ for (var n = "arg", e = 0; e < t.length; ++e) {
140
108
  var i = void 0;
141
- t[e] === null || typeof t[e] != "object" && typeof t[e] != "function" ? typeof t[e] == "string" ? i = '"' + t[e] + '"' : i = String(t[e]) : $.has(t[e]) ? i = $.get(t[e]) : (i = Y, $.set(t[e], Y++)), r += "@" + i;
109
+ t[e] === null || typeof t[e] != "object" && typeof t[e] != "function" ? typeof t[e] == "string" ? i = '"' + t[e] + '"' : i = String(t[e]) : D.has(t[e]) ? i = D.get(t[e]) : (i = q, D.set(t[e], q++)), n += "@" + i;
142
110
  }
143
- return r;
111
+ return n;
144
112
  }
145
- function Be(t) {
113
+ function _e(t) {
146
114
  if (typeof t == "function")
147
115
  try {
148
116
  t = t();
149
117
  } catch {
150
118
  t = "";
151
119
  }
152
- return Array.isArray(t) ? t = Ie(t) : t = String(t || ""), t;
120
+ return Array.isArray(t) ? t = we(t) : t = String(t || ""), t;
153
121
  }
154
122
  var F = (
155
123
  /** @class */
156
124
  function() {
157
- function t(r) {
158
- r === void 0 && (r = 0), this.items = /* @__PURE__ */ new Map(), this.ttl = r;
125
+ function t(n) {
126
+ n === void 0 && (n = 0), this.items = /* @__PURE__ */ new Map(), this.ttl = n;
159
127
  }
160
- return t.prototype.serializeKey = function(r) {
161
- return Be(r);
162
- }, t.prototype.get = function(r) {
163
- var e = this.serializeKey(r);
128
+ return t.prototype.serializeKey = function(n) {
129
+ return _e(n);
130
+ }, t.prototype.get = function(n) {
131
+ var e = this.serializeKey(n);
164
132
  return this.items.get(e);
165
- }, t.prototype.set = function(r, e, i) {
166
- var o = this.serializeKey(r), n = i || this.ttl, l = Date.now(), c = {
133
+ }, t.prototype.set = function(n, e, i) {
134
+ var a = this.serializeKey(n), r = i || this.ttl, l = Date.now(), f = {
167
135
  data: e,
168
136
  createdAt: l,
169
- expiresAt: n ? l + n : 1 / 0
137
+ expiresAt: r ? l + r : 1 / 0
170
138
  };
171
- this.dispatchExpire(n, c, o), this.items.set(o, c);
172
- }, t.prototype.dispatchExpire = function(r, e, i) {
173
- var o = this;
174
- r && setTimeout(function() {
175
- var n = Date.now(), l = n >= e.expiresAt;
176
- l && o.delete(i);
177
- }, r);
178
- }, t.prototype.delete = function(r) {
179
- this.items.delete(r);
139
+ this.dispatchExpire(r, f, a), this.items.set(a, f);
140
+ }, t.prototype.dispatchExpire = function(n, e, i) {
141
+ var a = this;
142
+ n && setTimeout(function() {
143
+ var r = Date.now(), l = r >= e.expiresAt;
144
+ l && a.delete(i);
145
+ }, n);
146
+ }, t.prototype.delete = function(n) {
147
+ this.items.delete(n);
180
148
  }, t;
181
149
  }()
182
150
  );
183
- function He() {
151
+ function Re() {
184
152
  return typeof navigator.onLine < "u" ? navigator.onLine : !0;
185
153
  }
186
- function Pe() {
154
+ function Le() {
187
155
  return typeof document < "u" && typeof document.visibilityState < "u" ? document.visibilityState !== "hidden" : !0;
188
156
  }
189
- var Oe = function(t) {
190
- return fetch(t).then(function(r) {
191
- return r.json();
157
+ var Ce = function(t) {
158
+ return fetch(t).then(function(n) {
159
+ return n.json();
192
160
  });
193
161
  };
194
- const j = {
195
- isOnline: He,
196
- isDocumentVisible: Pe,
197
- fetcher: Oe
162
+ const x = {
163
+ isOnline: Re,
164
+ isDocumentVisible: Le,
165
+ fetcher: Ce
198
166
  };
199
- var _ = globalThis && globalThis.__assign || function() {
200
- return _ = Object.assign || function(t) {
201
- for (var r, e = 1, i = arguments.length; e < i; e++) {
202
- r = arguments[e];
203
- for (var o in r)
204
- Object.prototype.hasOwnProperty.call(r, o) && (t[o] = r[o]);
167
+ var y = globalThis && globalThis.__assign || function() {
168
+ return y = Object.assign || function(t) {
169
+ for (var n, e = 1, i = arguments.length; e < i; e++) {
170
+ n = arguments[e];
171
+ for (var a in n)
172
+ Object.prototype.hasOwnProperty.call(n, a) && (t[a] = n[a]);
205
173
  }
206
174
  return t;
207
- }, _.apply(this, arguments);
208
- }, S = globalThis && globalThis.__awaiter || function(t, r, e, i) {
209
- function o(n) {
210
- return n instanceof e ? n : new e(function(l) {
211
- l(n);
175
+ }, y.apply(this, arguments);
176
+ }, R = globalThis && globalThis.__awaiter || function(t, n, e, i) {
177
+ function a(r) {
178
+ return r instanceof e ? r : new e(function(l) {
179
+ l(r);
212
180
  });
213
181
  }
214
- return new (e || (e = Promise))(function(n, l) {
215
- function c(s) {
182
+ return new (e || (e = Promise))(function(r, l) {
183
+ function f(u) {
216
184
  try {
217
- a(i.next(s));
185
+ o(i.next(u));
218
186
  } catch (g) {
219
187
  l(g);
220
188
  }
221
189
  }
222
- function f(s) {
190
+ function s(u) {
223
191
  try {
224
- a(i.throw(s));
192
+ o(i.throw(u));
225
193
  } catch (g) {
226
194
  l(g);
227
195
  }
228
196
  }
229
- function a(s) {
230
- s.done ? n(s.value) : o(s.value).then(c, f);
197
+ function o(u) {
198
+ u.done ? r(u.value) : a(u.value).then(f, s);
231
199
  }
232
- a((i = i.apply(t, r || [])).next());
200
+ o((i = i.apply(t, n || [])).next());
233
201
  });
234
- }, C = globalThis && globalThis.__generator || function(t, r) {
202
+ }, L = globalThis && globalThis.__generator || function(t, n) {
235
203
  var e = { label: 0, sent: function() {
236
- if (n[0] & 1)
237
- throw n[1];
238
- return n[1];
239
- }, trys: [], ops: [] }, i, o, n, l;
240
- return l = { next: c(0), throw: c(1), return: c(2) }, typeof Symbol == "function" && (l[Symbol.iterator] = function() {
204
+ if (r[0] & 1)
205
+ throw r[1];
206
+ return r[1];
207
+ }, trys: [], ops: [] }, i, a, r, l;
208
+ return l = { next: f(0), throw: f(1), return: f(2) }, typeof Symbol == "function" && (l[Symbol.iterator] = function() {
241
209
  return this;
242
210
  }), l;
243
- function c(a) {
244
- return function(s) {
245
- return f([a, s]);
211
+ function f(o) {
212
+ return function(u) {
213
+ return s([o, u]);
246
214
  };
247
215
  }
248
- function f(a) {
216
+ function s(o) {
249
217
  if (i)
250
218
  throw new TypeError("Generator is already executing.");
251
219
  for (; e; )
252
220
  try {
253
- if (i = 1, o && (n = a[0] & 2 ? o.return : a[0] ? o.throw || ((n = o.return) && n.call(o), 0) : o.next) && !(n = n.call(o, a[1])).done)
254
- return n;
255
- switch (o = 0, n && (a = [a[0] & 2, n.value]), a[0]) {
221
+ if (i = 1, a && (r = o[0] & 2 ? a.return : o[0] ? a.throw || ((r = a.return) && r.call(a), 0) : a.next) && !(r = r.call(a, o[1])).done)
222
+ return r;
223
+ switch (a = 0, r && (o = [o[0] & 2, r.value]), o[0]) {
256
224
  case 0:
257
225
  case 1:
258
- n = a;
226
+ r = o;
259
227
  break;
260
228
  case 4:
261
- return e.label++, { value: a[1], done: !1 };
229
+ return e.label++, { value: o[1], done: !1 };
262
230
  case 5:
263
- e.label++, o = a[1], a = [0];
231
+ e.label++, a = o[1], o = [0];
264
232
  continue;
265
233
  case 7:
266
- a = e.ops.pop(), e.trys.pop();
234
+ o = e.ops.pop(), e.trys.pop();
267
235
  continue;
268
236
  default:
269
- if (n = e.trys, !(n = n.length > 0 && n[n.length - 1]) && (a[0] === 6 || a[0] === 2)) {
237
+ if (r = e.trys, !(r = r.length > 0 && r[r.length - 1]) && (o[0] === 6 || o[0] === 2)) {
270
238
  e = 0;
271
239
  continue;
272
240
  }
273
- if (a[0] === 3 && (!n || a[1] > n[0] && a[1] < n[3])) {
274
- e.label = a[1];
241
+ if (o[0] === 3 && (!r || o[1] > r[0] && o[1] < r[3])) {
242
+ e.label = o[1];
275
243
  break;
276
244
  }
277
- if (a[0] === 6 && e.label < n[1]) {
278
- e.label = n[1], n = a;
245
+ if (o[0] === 6 && e.label < r[1]) {
246
+ e.label = r[1], r = o;
279
247
  break;
280
248
  }
281
- if (n && e.label < n[2]) {
282
- e.label = n[2], e.ops.push(a);
249
+ if (r && e.label < r[2]) {
250
+ e.label = r[2], e.ops.push(o);
283
251
  break;
284
252
  }
285
- n[2] && e.ops.pop(), e.trys.pop();
253
+ r[2] && e.ops.pop(), e.trys.pop();
286
254
  continue;
287
255
  }
288
- a = r.call(t, e);
289
- } catch (s) {
290
- a = [6, s], o = 0;
256
+ o = n.call(t, e);
257
+ } catch (u) {
258
+ o = [6, u], a = 0;
291
259
  } finally {
292
- i = n = 0;
260
+ i = r = 0;
293
261
  }
294
- if (a[0] & 5)
295
- throw a[1];
296
- return { value: a[0] ? a[1] : void 0, done: !0 };
262
+ if (o[0] & 5)
263
+ throw o[1];
264
+ return { value: o[0] ? o[1] : void 0, done: !0 };
297
265
  }
298
- }, Ee = globalThis && globalThis.__read || function(t, r) {
266
+ }, Ee = globalThis && globalThis.__read || function(t, n) {
299
267
  var e = typeof Symbol == "function" && t[Symbol.iterator];
300
268
  if (!e)
301
269
  return t;
302
- var i = e.call(t), o, n = [], l;
270
+ var i = e.call(t), a, r = [], l;
303
271
  try {
304
- for (; (r === void 0 || r-- > 0) && !(o = i.next()).done; )
305
- n.push(o.value);
306
- } catch (c) {
307
- l = { error: c };
272
+ for (; (n === void 0 || n-- > 0) && !(a = i.next()).done; )
273
+ r.push(a.value);
274
+ } catch (f) {
275
+ l = { error: f };
308
276
  } finally {
309
277
  try {
310
- o && !o.done && (e = i.return) && e.call(i);
278
+ a && !a.done && (e = i.return) && e.call(i);
311
279
  } finally {
312
280
  if (l)
313
281
  throw l.error;
314
282
  }
315
283
  }
316
- return n;
317
- }, xe = globalThis && globalThis.__spreadArray || function(t, r, e) {
284
+ return r;
285
+ }, Ie = globalThis && globalThis.__spreadArray || function(t, n, e) {
318
286
  if (e || arguments.length === 2)
319
- for (var i = 0, o = r.length, n; i < o; i++)
320
- (n || !(i in r)) && (n || (n = Array.prototype.slice.call(r, 0, i)), n[i] = r[i]);
321
- return t.concat(n || Array.prototype.slice.call(r));
322
- }, ne = new F(), O = new F(), D = new F(), re = {
287
+ for (var i = 0, a = n.length, r; i < a; i++)
288
+ (r || !(i in n)) && (r || (r = Array.prototype.slice.call(n, 0, i)), r[i] = n[i]);
289
+ return t.concat(r || Array.prototype.slice.call(n));
290
+ }, ne = new F(), V = new F(), $ = new F(), re = {
323
291
  cache: ne,
324
292
  refreshInterval: 0,
325
293
  ttl: 0,
@@ -330,74 +298,74 @@ var _ = globalThis && globalThis.__assign || function() {
330
298
  shouldRetryOnError: !0,
331
299
  errorRetryInterval: 5e3,
332
300
  errorRetryCount: 5,
333
- fetcher: j.fetcher,
334
- isOnline: j.isOnline,
335
- isDocumentVisible: j.isDocumentVisible
301
+ fetcher: x.fetcher,
302
+ isOnline: x.isOnline,
303
+ isDocumentVisible: x.isDocumentVisible
336
304
  };
337
- function Te(t, r, e) {
338
- var i = O.get(t);
305
+ function Se(t, n, e) {
306
+ var i = V.get(t);
339
307
  if (i)
340
- i.data.push(r);
308
+ i.data.push(n);
341
309
  else {
342
- var o = 5e3;
343
- O.set(t, [r], e > 0 ? e + o : e);
310
+ var a = 5e3;
311
+ V.set(t, [n], e > 0 ? e + a : e);
344
312
  }
345
313
  }
346
- function Ve(t, r, e) {
347
- if (e.isDocumentVisible() && !(e.errorRetryCount !== void 0 && r > e.errorRetryCount)) {
348
- var i = Math.min(r || 0, e.errorRetryCount), o = i * e.errorRetryInterval;
314
+ function Ae(t, n, e) {
315
+ if (e.isDocumentVisible() && !(e.errorRetryCount !== void 0 && n > e.errorRetryCount)) {
316
+ var i = Math.min(n || 0, e.errorRetryCount), a = i * e.errorRetryInterval;
349
317
  setTimeout(function() {
350
318
  t(null, { errorRetryCount: i + 1, shouldRetryOnError: !0 });
351
- }, o);
319
+ }, a);
352
320
  }
353
321
  }
354
- var J = function(t, r, e, i) {
355
- return e === void 0 && (e = ne), i === void 0 && (i = re.ttl), S(void 0, void 0, void 0, function() {
356
- var o, n, l, c, f, a, s;
357
- return C(this, function(g) {
322
+ var J = function(t, n, e, i) {
323
+ return e === void 0 && (e = ne), i === void 0 && (i = re.ttl), R(void 0, void 0, void 0, function() {
324
+ var a, r, l, f, s, o, u;
325
+ return L(this, function(g) {
358
326
  switch (g.label) {
359
327
  case 0:
360
- if (!je(r))
328
+ if (!Pe(n))
361
329
  return [3, 5];
362
330
  g.label = 1;
363
331
  case 1:
364
- return g.trys.push([1, 3, , 4]), [4, r];
332
+ return g.trys.push([1, 3, , 4]), [4, n];
365
333
  case 2:
366
- return o = g.sent(), [3, 4];
334
+ return a = g.sent(), [3, 4];
367
335
  case 3:
368
- return c = g.sent(), n = c, [3, 4];
336
+ return f = g.sent(), r = f, [3, 4];
369
337
  case 4:
370
338
  return [3, 6];
371
339
  case 5:
372
- o = r, g.label = 6;
340
+ a = n, g.label = 6;
373
341
  case 6:
374
- if (l = !1, f = { data: o, error: n, isValidating: l }, typeof o < "u")
342
+ if (l = !1, s = { data: a, error: r, isValidating: l }, typeof a < "u")
375
343
  try {
376
- e.set(t, f, i);
344
+ e.set(t, s, i);
377
345
  } catch (v) {
378
346
  console.error("swrv(mutate): failed to set cache", v);
379
347
  }
380
- return a = O.get(t), a && a.data.length && (s = a.data.filter(function(v) {
348
+ return o = V.get(t), o && o.data.length && (u = o.data.filter(function(v) {
381
349
  return v.key === t;
382
- }), s.forEach(function(v, d) {
383
- typeof f.data < "u" && (v.data = f.data), v.error = f.error, v.isValidating = f.isValidating;
384
- var y = d === s.length - 1;
385
- y || delete s[d];
386
- }), s = s.filter(Boolean)), [2, f];
350
+ }), u.forEach(function(v, d) {
351
+ typeof s.data < "u" && (v.data = s.data), v.error = s.error, v.isValidating = s.isValidating;
352
+ var b = d === u.length - 1;
353
+ b || delete u[d];
354
+ }), u = u.filter(Boolean)), [2, s];
387
355
  }
388
356
  });
389
357
  });
390
358
  };
391
- function $e() {
392
- for (var t = this, r = [], e = 0; e < arguments.length; e++)
393
- r[e] = arguments[e];
394
- var i, o, n = _({}, re), l = !1, c = !1, f = fe(), a = (f == null ? void 0 : f.proxy) || f;
395
- if (!a)
359
+ function Te() {
360
+ for (var t = this, n = [], e = 0; e < arguments.length; e++)
361
+ n[e] = arguments[e];
362
+ var i, a, r = y({}, re), l = !1, f = !1, s = fe(), o = (s == null ? void 0 : s.proxy) || s;
363
+ if (!o)
396
364
  return console.error("Could not get current instance, check to make sure that `useSwrv` is declared in the top level of the setup function."), null;
397
- var s = (a == null ? void 0 : a.$isServer) || !1;
398
- r.length >= 1 && (i = r[0]), r.length >= 2 && (o = r[1]), r.length > 2 && (n = _(_({}, n), r[2]));
399
- var g = s ? n.serverTTL : n.ttl, v = typeof i == "function" ? i : X(i);
400
- typeof o > "u" && (o = n.fetcher);
365
+ var u = (o == null ? void 0 : o.$isServer) || !1;
366
+ n.length >= 1 && (i = n[0]), n.length >= 2 && (a = n[1]), n.length > 2 && (r = y(y({}, r), n[2]));
367
+ var g = u ? r.serverTTL : r.ttl, v = typeof i == "function" ? i : X(i);
368
+ typeof a > "u" && (a = r.fetcher);
401
369
  var d = null;
402
370
  d || (d = de({
403
371
  data: void 0,
@@ -405,47 +373,47 @@ function $e() {
405
373
  isValidating: !0,
406
374
  key: null
407
375
  }));
408
- var y = function(h, u) {
409
- return S(t, void 0, void 0, function() {
410
- var N, p, A, I, E, z, x, G = this;
411
- return C(this, function(T) {
412
- switch (T.label) {
376
+ var b = function(h, c) {
377
+ return R(t, void 0, void 0, function() {
378
+ var N, m, I, S, H, z, O, G = this;
379
+ return L(this, function(k) {
380
+ switch (k.label) {
413
381
  case 0:
414
- return N = d.data === void 0, p = v.value, p ? (A = n.cache.get(p), I = A && A.data, d.isValidating = !0, I && (d.data = I.data, d.error = I.error), E = h || o, !E || !n.isDocumentVisible() && !N || (u == null ? void 0 : u.forceRevalidate) !== void 0 && !(u != null && u.forceRevalidate) ? (d.isValidating = !1, [
382
+ return N = d.data === void 0, m = v.value, m ? (I = r.cache.get(m), S = I && I.data, d.isValidating = !0, S && (d.data = S.data, d.error = S.error), H = h || a, !H || !r.isDocumentVisible() && !N || (c == null ? void 0 : c.forceRevalidate) !== void 0 && !(c != null && c.forceRevalidate) ? (d.isValidating = !1, [
415
383
  2
416
384
  /*return*/
417
- ]) : A && (z = !!(Date.now() - A.createdAt >= n.dedupingInterval || u != null && u.forceRevalidate), !z) ? (d.isValidating = !1, [
385
+ ]) : I && (z = !!(Date.now() - I.createdAt >= r.dedupingInterval || c != null && c.forceRevalidate), !z) ? (d.isValidating = !1, [
418
386
  2
419
387
  /*return*/
420
- ]) : (x = function() {
421
- return S(G, void 0, void 0, function() {
422
- var b, K, V, W;
423
- return C(this, function(H) {
424
- switch (H.label) {
388
+ ]) : (O = function() {
389
+ return R(G, void 0, void 0, function() {
390
+ var p, K, B, W;
391
+ return L(this, function(P) {
392
+ switch (P.label) {
425
393
  case 0:
426
- return b = D.get(p), b ? [3, 2] : (K = Array.isArray(p) ? p : [p], V = E.apply(void 0, xe([], Ee(K), !1)), D.set(p, V, n.dedupingInterval), [4, J(p, V, n.cache, g)]);
394
+ return p = $.get(m), p ? [3, 2] : (K = Array.isArray(m) ? m : [m], B = H.apply(void 0, Ie([], Ee(K), !1)), $.set(m, B, r.dedupingInterval), [4, J(m, B, r.cache, g)]);
427
395
  case 1:
428
- return H.sent(), [3, 4];
396
+ return P.sent(), [3, 4];
429
397
  case 2:
430
- return [4, J(p, b.data, n.cache, g)];
398
+ return [4, J(m, p.data, r.cache, g)];
431
399
  case 3:
432
- H.sent(), H.label = 4;
400
+ P.sent(), P.label = 4;
433
401
  case 4:
434
- return d.isValidating = !1, D.delete(p), d.error !== void 0 && (W = !l && n.shouldRetryOnError && (u ? u.shouldRetryOnError : !0), W && Ve(y, u ? u.errorRetryCount : 1, n)), [
402
+ return d.isValidating = !1, $.delete(m), d.error !== void 0 && (W = !l && r.shouldRetryOnError && (c ? c.shouldRetryOnError : !0), W && Ae(b, c ? c.errorRetryCount : 1, r)), [
435
403
  2
436
404
  /*return*/
437
405
  ];
438
406
  }
439
407
  });
440
408
  });
441
- }, I && n.revalidateDebounce ? (setTimeout(function() {
442
- return S(G, void 0, void 0, function() {
443
- return C(this, function(b) {
444
- switch (b.label) {
409
+ }, S && r.revalidateDebounce ? (setTimeout(function() {
410
+ return R(G, void 0, void 0, function() {
411
+ return L(this, function(p) {
412
+ switch (p.label) {
445
413
  case 0:
446
- return l ? [3, 2] : [4, x()];
414
+ return l ? [3, 2] : [4, O()];
447
415
  case 1:
448
- b.sent(), b.label = 2;
416
+ p.sent(), p.label = 2;
449
417
  case 2:
450
418
  return [
451
419
  2
@@ -454,14 +422,14 @@ function $e() {
454
422
  }
455
423
  });
456
424
  });
457
- }, n.revalidateDebounce), [3, 3]) : [3, 1])) : [
425
+ }, r.revalidateDebounce), [3, 3]) : [3, 1])) : [
458
426
  2
459
427
  /*return*/
460
428
  ];
461
429
  case 1:
462
- return [4, x()];
430
+ return [4, O()];
463
431
  case 2:
464
- T.sent(), T.label = 3;
432
+ k.sent(), k.label = 3;
465
433
  case 3:
466
434
  return [
467
435
  2
@@ -470,26 +438,26 @@ function $e() {
470
438
  }
471
439
  });
472
440
  });
473
- }, B = function() {
474
- return S(t, void 0, void 0, function() {
475
- return C(this, function(h) {
476
- return [2, y(null, { shouldRetryOnError: !1 })];
441
+ }, T = function() {
442
+ return R(t, void 0, void 0, function() {
443
+ return L(this, function(h) {
444
+ return [2, b(null, { shouldRetryOnError: !1 })];
477
445
  });
478
446
  });
479
- }, w = null;
447
+ }, _ = null;
480
448
  Q(function() {
481
449
  var h = function() {
482
- return S(t, void 0, void 0, function() {
483
- return C(this, function(u) {
484
- switch (u.label) {
450
+ return R(t, void 0, void 0, function() {
451
+ return L(this, function(c) {
452
+ switch (c.label) {
485
453
  case 0:
486
- return !d.error && n.isOnline() ? [4, y()] : [3, 2];
454
+ return !d.error && r.isOnline() ? [4, b()] : [3, 2];
487
455
  case 1:
488
- return u.sent(), [3, 3];
456
+ return c.sent(), [3, 3];
489
457
  case 2:
490
- w && clearTimeout(w), u.label = 3;
458
+ _ && clearTimeout(_), c.label = 3;
491
459
  case 3:
492
- return n.refreshInterval && !l && (w = setTimeout(h, n.refreshInterval)), [
460
+ return r.refreshInterval && !l && (_ = setTimeout(h, r.refreshInterval)), [
493
461
  2
494
462
  /*return*/
495
463
  ];
@@ -497,92 +465,82 @@ function $e() {
497
465
  });
498
466
  });
499
467
  };
500
- n.refreshInterval && (w = setTimeout(h, n.refreshInterval)), n.revalidateOnFocus && (document.addEventListener("visibilitychange", B, !1), window.addEventListener("focus", B, !1));
468
+ r.refreshInterval && (_ = setTimeout(h, r.refreshInterval)), r.revalidateOnFocus && (document.addEventListener("visibilitychange", T, !1), window.addEventListener("focus", T, !1));
501
469
  }), he(function() {
502
- l = !0, w && clearTimeout(w), n.revalidateOnFocus && (document.removeEventListener("visibilitychange", B, !1), window.removeEventListener("focus", B, !1));
503
- var h = O.get(v.value);
504
- h && (h.data = h.data.filter(function(u) {
505
- return u !== d;
470
+ l = !0, _ && clearTimeout(_), r.revalidateOnFocus && (document.removeEventListener("visibilitychange", T, !1), window.removeEventListener("focus", T, !1));
471
+ var h = V.get(v.value);
472
+ h && (h.data = h.data.filter(function(c) {
473
+ return c !== d;
506
474
  }));
507
475
  });
508
476
  try {
509
477
  ve(v, function(h) {
510
- ge(v) || (v.value = h), d.key = h, d.isValidating = !!h, Te(v.value, d, g), !s && !c && v.value && y(), c = !1;
478
+ ge(v) || (v.value = h), d.key = h, d.isValidating = !!h, Se(v.value, d, g), !u && !f && v.value && b(), f = !1;
511
479
  }, {
512
480
  immediate: !0
513
481
  });
514
482
  } catch {
515
483
  }
516
- var oe = _(_({}, pe(d)), { mutate: function(h, u) {
517
- return y(h, _(_({}, u), { forceRevalidate: !0 }));
484
+ var ae = y(y({}, me(d)), { mutate: function(h, c) {
485
+ return b(h, y(y({}, c), { forceRevalidate: !0 }));
518
486
  } });
519
- return oe;
487
+ return ae;
520
488
  }
521
- function je(t) {
489
+ function Pe(t) {
522
490
  return t !== null && typeof t == "object" && typeof t.then == "function";
523
491
  }
524
- const De = async (t) => {
492
+ const Ve = async (t) => {
525
493
  try {
526
494
  return await (await fetch(t)).json();
527
- } catch (r) {
528
- console.error(r);
495
+ } catch (n) {
496
+ console.error(n);
529
497
  return;
530
498
  }
531
499
  }, ie = () => {
532
- const t = _e(), { data: r = t, isValidating: e } = $e(m.auth, De);
500
+ const t = ye(), { data: n = t, isValidating: e } = Te(w.auth, Ve);
533
501
  return {
534
- auth: r || {},
502
+ auth: n || {},
535
503
  // @ts-ignore //TBD
536
504
  isLoading: e,
537
505
  // @ts-ignore
538
- isLoggedIn: r == null ? void 0 : r.isLoggedIn
506
+ isLoggedIn: n == null ? void 0 : n.isLoggedIn
539
507
  };
540
- }, Ue = /* @__PURE__ */ L({
508
+ }, He = { key: 0 }, Me = /* @__PURE__ */ C({
541
509
  __name: "LoggedIn",
542
- setup(t, { expose: r }) {
543
- r();
544
- const i = { isLoggedIn: () => {
545
- var o;
546
- return ((o = ie()) == null ? void 0 : o.isLoggedIn) || !1;
547
- } };
548
- return Object.defineProperty(i, "__isScriptSetup", { enumerable: !1, value: !0 }), i;
510
+ setup(t) {
511
+ const n = () => {
512
+ var e;
513
+ return ((e = ie()) == null ? void 0 : e.isLoggedIn) || !1;
514
+ };
515
+ return (e, i) => n() ? (E(), M("div", He, [
516
+ Z(e.$slots, "default")
517
+ ])) : ee("", !0);
549
518
  }
550
- }), qe = { key: 0 };
551
- function Me(t, r, e, i, o, n) {
552
- return i.isLoggedIn() ? (k(), U("div", qe, [
553
- Z(t.$slots, "default")
554
- ])) : ee("v-if", !0);
555
- }
556
- const Qe = /* @__PURE__ */ R(Ue, [["render", Me], ["__file", "/Users/dick/github/HelloCoop/packages-js/vue/lib/login-status/LoggedIn.vue"]]), Fe = /* @__PURE__ */ L({
519
+ }), Oe = { key: 0 }, je = /* @__PURE__ */ C({
557
520
  __name: "LoggedOut",
558
- setup(t, { expose: r }) {
559
- r();
560
- const i = { isLoggedIn: () => {
561
- var o;
562
- return ((o = ie()) == null ? void 0 : o.isLoggedIn) || !1;
563
- } };
564
- return Object.defineProperty(i, "__isScriptSetup", { enumerable: !1, value: !0 }), i;
521
+ setup(t) {
522
+ const n = () => {
523
+ var e;
524
+ return ((e = ie()) == null ? void 0 : e.isLoggedIn) || !1;
525
+ };
526
+ return (e, i) => n() ? ee("", !0) : (E(), M("div", Oe, [
527
+ Z(e.$slots, "default")
528
+ ]));
565
529
  }
566
- }), Ne = { key: 0 };
567
- function ze(t, r, e, i, o, n) {
568
- return i.isLoggedIn() ? ee("v-if", !0) : (k(), U("div", Ne, [
569
- Z(t.$slots, "default")
570
- ]));
571
- }
572
- const Xe = /* @__PURE__ */ R(Fe, [["render", ze], ["__file", "/Users/dick/github/HelloCoop/packages-js/vue/lib/login-status/LoggedOut.vue"]]), Ze = () => m.logout;
573
- function et() {
574
- window.location.href = m.logout;
530
+ }), Ue = () => w.logout;
531
+ function Fe() {
532
+ window.location.href = w.logout;
575
533
  }
576
534
  export {
577
- We as ContinueButton,
578
- Ke as HelloProvider,
579
- Qe as LoggedIn,
580
- Xe as LoggedOut,
581
- Ye as LoginButton,
582
- Je as UpdateProfileButton,
583
- Ze as getLogOutRoute,
584
- et as logOut,
585
- m as routeConfig,
535
+ De as ContinueButton,
536
+ Be as HelloProvider,
537
+ Me as LoggedIn,
538
+ je as LoggedOut,
539
+ xe as LoginButton,
540
+ $e as UpdateProfileButton,
541
+ Ue as getLogOutRoute,
542
+ Fe as logOut,
543
+ w as routeConfig,
586
544
  ie as useAuth,
587
- _e as useHelloProviderContext
545
+ ye as useHelloProviderContext
588
546
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(g,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],l):(g=typeof globalThis<"u"?globalThis:g||self,l(g["@hellocoop/vue"]={},g.Vue))})(this,function(g,l){"use strict";const m={login:"/api/hellocoop?login=true",auth:"/api/hellocoop?auth=true",logout:"/api/hellocoop?logout=true"},F="HelloAuth",N=()=>l.inject(F),ee={props:["auth","config"],setup(t){var r,e,i;(r=t==null?void 0:t.config)!=null&&r.login&&(m.login=t.config.login),(e=t==null?void 0:t.config)!=null&&e.auth&&(m.auth=t.config.auth),(i=t==null?void 0:t.config)!=null&&i.logout&&(m.logout=t.config.logout),l.provide(F,t.auth)},render(){return this.$slots.default()}};var I;(t=>{t.STYLES_URL="https://cdn.hello.coop/css/hello-btn.css",t.HOVER_MAPPING={pop:"",glow:"hello-btn-hover-glow",flare:"hello-btn-hover-flare",none:"hello-btn-hover-none"},t.CLASS_MAPPING={black:{"ignore-light":"","ignore-dark":"hello-btn-black-on-dark","aware-invert":"hello-btn-black-and-invert","aware-static":"hello-btn-black-and-static"},white:{"ignore-light":"hello-btn-white-on-light","ignore-dark":"hello-btn-white-on-dark","aware-invert":"hello-btn-white-and-invert","aware-static":"hello-btn-white-and-static"}}})(I||(I={}));const te=l.defineComponent({__name:"BaseButton",props:{label:{type:String,required:!1,default:"ō&nbsp;&nbsp;&nbsp;Continue with Hellō"},style:{type:null,required:!1},color:{type:String,required:!1,default:"black"},theme:{type:String,required:!1,default:"ignore-light"},hover:{type:String,required:!1,default:"pop"},scope:{type:Array,required:!1},update:{type:Boolean,required:!1},targetURI:{type:String,required:!1},providerHint:{type:Array,required:!1},showLoader:{type:Boolean,required:!1,default:!1},disabled:{type:Boolean,required:!1,default:!1},promptLogin:{type:Boolean,required:!1,default:!1},promptConsent:{type:Boolean,required:!1,default:!1},loginHint:{type:String,required:!1,default:""},domainHint:{type:String,required:!1,default:""}},setup(t,{expose:r}){r();let e=!1;l.onMounted(()=>{typeof window<"u"&&!e&&(Array.from(document.head.getElementsByTagName("link")).find(a=>{var u;return a.getAttribute("rel")==="stylesheet"&&((u=a.getAttribute("href"))==null?void 0:u.startsWith(I.STYLES_URL))})||console.warn("Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."),e=!0)});const i=l.ref(!1),o=t,n=new URL(m.login,window.location.origin);o.scope&&n.searchParams.set("scope",o.scope.join(" ")),n.searchParams.set("target_uri",o.targetURI||window.location.pathname),o.update&&n.searchParams.set("prompt","consent"),o.promptLogin&&o.promptConsent?n.searchParams.set("prompt","login consent"):o.promptLogin?n.searchParams.set("prompt","login"):o.promptConsent&&n.searchParams.set("prompt","consent"),o.loginHint&&n.searchParams.set("login_hint",o.loginHint),o.domainHint&&n.searchParams.set("login_hint",o.domainHint),o.providerHint&&n.searchParams.set("provider_hint",o.providerHint.join(" "));const f={get checkedForStylesheet(){return e},set checkedForStylesheet(d){e=d},clicked:i,props:o,loginRoute:n,onClickHandler:()=>{i.value=!0,window.location.href=n.href},get Button(){return I}};return Object.defineProperty(f,"__isScriptSetup",{enumerable:!1,value:!0}),f}}),S=(t,r)=>{const e=t.__vccOpts||t;for(const[i,o]of r)e[i]=o;return e},ne=["disabled"],re=["innerHTML"];function ie(t,r,e,i,o,n){var s;return l.openBlock(),l.createElementBlock("button",{onClick:i.onClickHandler,class:l.normalizeClass(["hello-btn",(s=i.Button.CLASS_MAPPING[i.props.color])==null?void 0:s[i.props.theme],i.Button.HOVER_MAPPING[e.hover],(e.showLoader||i.clicked)&&"hello-btn-loader"]),disabled:i.props.disabled||i.clicked,style:l.normalizeStyle(e.style)},[l.createElementVNode("span",{innerHTML:e.label},null,8,re)],14,ne)}const E=S(te,[["render",ie],["__file","/Users/dick/github/HelloCoop/packages-js/vue/lib/buttons/BaseButton.vue"]]),oe=l.defineComponent({__name:"ContinueButton",setup(t,{expose:r}){r();const e={BaseButton:E};return Object.defineProperty(e,"__isScriptSetup",{enumerable:!1,value:!0}),e}});function ae(t,r,e,i,o,n){return l.openBlock(),l.createBlock(i.BaseButton)}const le=S(oe,[["render",ae],["__file","/Users/dick/github/HelloCoop/packages-js/vue/lib/buttons/ContinueButton.vue"]]),se=l.defineComponent({__name:"LoginButton",setup(t,{expose:r}){r();const e={BaseButton:E};return Object.defineProperty(e,"__isScriptSetup",{enumerable:!1,value:!0}),e}});function ue(t,r,e,i,o,n){return l.openBlock(),l.createBlock(i.BaseButton,{label:"ō   Login with Hellō"})}const ce=S(se,[["render",ue],["__file","/Users/dick/github/HelloCoop/packages-js/vue/lib/buttons/LoginButton.vue"]]),fe=l.defineComponent({__name:"UpdateProfileButton",setup(t,{expose:r}){r();const e={BaseButton:E};return Object.defineProperty(e,"__isScriptSetup",{enumerable:!1,value:!0}),e}});function de(t,r,e,i,o,n){return l.openBlock(),l.createBlock(i.BaseButton,{label:"ō   Update Profile with Hellō",update:!0})}const he=S(fe,[["render",de],["__file","/Users/dick/github/HelloCoop/packages-js/vue/lib/buttons/UpdateProfileButton.vue"]]);var T=new WeakMap,z=0;function ge(t){if(!t.length)return"";for(var r="arg",e=0;e<t.length;++e){var i=void 0;t[e]===null||typeof t[e]!="object"&&typeof t[e]!="function"?typeof t[e]=="string"?i='"'+t[e]+'"':i=String(t[e]):T.has(t[e])?i=T.get(t[e]):(i=z,T.set(t[e],z++)),r+="@"+i}return r}function ve(t){if(typeof t=="function")try{t=t()}catch{t=""}return Array.isArray(t)?t=ge(t):t=String(t||""),t}var V=function(){function t(r){r===void 0&&(r=0),this.items=new Map,this.ttl=r}return t.prototype.serializeKey=function(r){return ve(r)},t.prototype.get=function(r){var e=this.serializeKey(r);return this.items.get(e)},t.prototype.set=function(r,e,i){var o=this.serializeKey(r),n=i||this.ttl,s=Date.now(),f={data:e,createdAt:s,expiresAt:n?s+n:1/0};this.dispatchExpire(n,f,o),this.items.set(o,f)},t.prototype.dispatchExpire=function(r,e,i){var o=this;r&&setTimeout(function(){var n=Date.now(),s=n>=e.expiresAt;s&&o.delete(i)},r)},t.prototype.delete=function(r){this.items.delete(r)},t}();function pe(){return typeof navigator.onLine<"u"?navigator.onLine:!0}function _e(){return typeof document<"u"&&typeof document.visibilityState<"u"?document.visibilityState!=="hidden":!0}var ye=function(t){return fetch(t).then(function(r){return r.json()})};const $={isOnline:pe,isDocumentVisible:_e,fetcher:ye};var b=globalThis&&globalThis.__assign||function(){return b=Object.assign||function(t){for(var r,e=1,i=arguments.length;e<i;e++){r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},b.apply(this,arguments)},k=globalThis&&globalThis.__awaiter||function(t,r,e,i){function o(n){return n instanceof e?n:new e(function(s){s(n)})}return new(e||(e=Promise))(function(n,s){function f(u){try{a(i.next(u))}catch(_){s(_)}}function d(u){try{a(i.throw(u))}catch(_){s(_)}}function a(u){u.done?n(u.value):o(u.value).then(f,d)}a((i=i.apply(t,r||[])).next())})},L=globalThis&&globalThis.__generator||function(t,r){var e={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},i,o,n,s;return s={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function f(a){return function(u){return d([a,u])}}function d(a){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,o&&(n=a[0]&2?o.return:a[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,a[1])).done)return n;switch(o=0,n&&(a=[a[0]&2,n.value]),a[0]){case 0:case 1:n=a;break;case 4:return e.label++,{value:a[1],done:!1};case 5:e.label++,o=a[1],a=[0];continue;case 7:a=e.ops.pop(),e.trys.pop();continue;default:if(n=e.trys,!(n=n.length>0&&n[n.length-1])&&(a[0]===6||a[0]===2)){e=0;continue}if(a[0]===3&&(!n||a[1]>n[0]&&a[1]<n[3])){e.label=a[1];break}if(a[0]===6&&e.label<n[1]){e.label=n[1],n=a;break}if(n&&e.label<n[2]){e.label=n[2],e.ops.push(a);break}n[2]&&e.ops.pop(),e.trys.pop();continue}a=r.call(t,e)}catch(u){a=[6,u],o=0}finally{i=n=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}},be=globalThis&&globalThis.__read||function(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var i=e.call(t),o,n=[],s;try{for(;(r===void 0||r-- >0)&&!(o=i.next()).done;)n.push(o.value)}catch(f){s={error:f}}finally{try{o&&!o.done&&(e=i.return)&&e.call(i)}finally{if(s)throw s.error}}return n},me=globalThis&&globalThis.__spreadArray||function(t,r,e){if(e||arguments.length===2)for(var i=0,o=r.length,n;i<o;i++)(n||!(i in r))&&(n||(n=Array.prototype.slice.call(r,0,i)),n[i]=r[i]);return t.concat(n||Array.prototype.slice.call(r))},G=new V,O=new V,j=new V,K={cache:G,refreshInterval:0,ttl:0,serverTTL:1e3,dedupingInterval:2e3,revalidateOnFocus:!0,revalidateDebounce:0,shouldRetryOnError:!0,errorRetryInterval:5e3,errorRetryCount:5,fetcher:$.fetcher,isOnline:$.isOnline,isDocumentVisible:$.isDocumentVisible};function we(t,r,e){var i=O.get(t);if(i)i.data.push(r);else{var o=5e3;O.set(t,[r],e>0?e+o:e)}}function Ce(t,r,e){if(e.isDocumentVisible()&&!(e.errorRetryCount!==void 0&&r>e.errorRetryCount)){var i=Math.min(r||0,e.errorRetryCount),o=i*e.errorRetryInterval;setTimeout(function(){t(null,{errorRetryCount:i+1,shouldRetryOnError:!0})},o)}}var W=function(t,r,e,i){return e===void 0&&(e=G),i===void 0&&(i=K.ttl),k(void 0,void 0,void 0,function(){var o,n,s,f,d,a,u;return L(this,function(_){switch(_.label){case 0:if(!ke(r))return[3,5];_.label=1;case 1:return _.trys.push([1,3,,4]),[4,r];case 2:return o=_.sent(),[3,4];case 3:return f=_.sent(),n=f,[3,4];case 4:return[3,6];case 5:o=r,_.label=6;case 6:if(s=!1,d={data:o,error:n,isValidating:s},typeof o<"u")try{e.set(t,d,i)}catch(p){console.error("swrv(mutate): failed to set cache",p)}return a=O.get(t),a&&a.data.length&&(u=a.data.filter(function(p){return p.key===t}),u.forEach(function(p,h){typeof d.data<"u"&&(p.data=d.data),p.error=d.error,p.isValidating=d.isValidating;var w=h===u.length-1;w||delete u[h]}),u=u.filter(Boolean)),[2,d]}})})};function Se(){for(var t=this,r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var i,o,n=b({},K),s=!1,f=!1,d=l.getCurrentInstance(),a=(d==null?void 0:d.proxy)||d;if(!a)return console.error("Could not get current instance, check to make sure that `useSwrv` is declared in the top level of the setup function."),null;var u=(a==null?void 0:a.$isServer)||!1;r.length>=1&&(i=r[0]),r.length>=2&&(o=r[1]),r.length>2&&(n=b(b({},n),r[2]));var _=u?n.serverTTL:n.ttl,p=typeof i=="function"?i:l.ref(i);typeof o>"u"&&(o=n.fetcher);var h=null;h||(h=l.reactive({data:void 0,error:void 0,isValidating:!0,key:null}));var w=function(v,c){return k(t,void 0,void 0,function(){var Y,y,R,A,D,J,U,Q=this;return L(this,function(q){switch(q.label){case 0:return Y=h.data===void 0,y=p.value,y?(R=n.cache.get(y),A=R&&R.data,h.isValidating=!0,A&&(h.data=A.data,h.error=A.error),D=v||o,!D||!n.isDocumentVisible()&&!Y||(c==null?void 0:c.forceRevalidate)!==void 0&&!(c!=null&&c.forceRevalidate)?(h.isValidating=!1,[2]):R&&(J=!!(Date.now()-R.createdAt>=n.dedupingInterval||c!=null&&c.forceRevalidate),!J)?(h.isValidating=!1,[2]):(U=function(){return k(Q,void 0,void 0,function(){var C,X,M,Z;return L(this,function(H){switch(H.label){case 0:return C=j.get(y),C?[3,2]:(X=Array.isArray(y)?y:[y],M=D.apply(void 0,me([],be(X),!1)),j.set(y,M,n.dedupingInterval),[4,W(y,M,n.cache,_)]);case 1:return H.sent(),[3,4];case 2:return[4,W(y,C.data,n.cache,_)];case 3:H.sent(),H.label=4;case 4:return h.isValidating=!1,j.delete(y),h.error!==void 0&&(Z=!s&&n.shouldRetryOnError&&(c?c.shouldRetryOnError:!0),Z&&Ce(w,c?c.errorRetryCount:1,n)),[2]}})})},A&&n.revalidateDebounce?(setTimeout(function(){return k(Q,void 0,void 0,function(){return L(this,function(C){switch(C.label){case 0:return s?[3,2]:[4,U()];case 1:C.sent(),C.label=2;case 2:return[2]}})})},n.revalidateDebounce),[3,3]):[3,1])):[2];case 1:return[4,U()];case 2:q.sent(),q.label=3;case 3:return[2]}})})},P=function(){return k(t,void 0,void 0,function(){return L(this,function(v){return[2,w(null,{shouldRetryOnError:!1})]})})},B=null;l.onMounted(function(){var v=function(){return k(t,void 0,void 0,function(){return L(this,function(c){switch(c.label){case 0:return!h.error&&n.isOnline()?[4,w()]:[3,2];case 1:return c.sent(),[3,3];case 2:B&&clearTimeout(B),c.label=3;case 3:return n.refreshInterval&&!s&&(B=setTimeout(v,n.refreshInterval)),[2]}})})};n.refreshInterval&&(B=setTimeout(v,n.refreshInterval)),n.revalidateOnFocus&&(document.addEventListener("visibilitychange",P,!1),window.addEventListener("focus",P,!1))}),l.onUnmounted(function(){s=!0,B&&clearTimeout(B),n.revalidateOnFocus&&(document.removeEventListener("visibilitychange",P,!1),window.removeEventListener("focus",P,!1));var v=O.get(p.value);v&&(v.data=v.data.filter(function(c){return c!==h}))});try{l.watch(p,function(v){l.isReadonly(p)||(p.value=v),h.key=v,h.isValidating=!!v,we(p.value,h,_),!u&&!f&&p.value&&w(),f=!1},{immediate:!0})}catch{}var $e=b(b({},l.toRefs(h)),{mutate:function(v,c){return w(v,b(b({},c),{forceRevalidate:!0}))}});return $e}function ke(t){return t!==null&&typeof t=="object"&&typeof t.then=="function"}const Le=async t=>{try{return await(await fetch(t)).json()}catch(r){console.error(r);return}},x=()=>{const t=N(),{data:r=t,isValidating:e}=Se(m.auth,Le);return{auth:r||{},isLoading:e,isLoggedIn:r==null?void 0:r.isLoggedIn}},Be=l.defineComponent({__name:"LoggedIn",setup(t,{expose:r}){r();const i={isLoggedIn:()=>{var o;return((o=x())==null?void 0:o.isLoggedIn)||!1}};return Object.defineProperty(i,"__isScriptSetup",{enumerable:!1,value:!0}),i}}),Re={key:0};function Ae(t,r,e,i,o,n){return i.isLoggedIn()?(l.openBlock(),l.createElementBlock("div",Re,[l.renderSlot(t.$slots,"default")])):l.createCommentVNode("v-if",!0)}const Ie=S(Be,[["render",Ae],["__file","/Users/dick/github/HelloCoop/packages-js/vue/lib/login-status/LoggedIn.vue"]]),Oe=l.defineComponent({__name:"LoggedOut",setup(t,{expose:r}){r();const i={isLoggedIn:()=>{var o;return((o=x())==null?void 0:o.isLoggedIn)||!1}};return Object.defineProperty(i,"__isScriptSetup",{enumerable:!1,value:!0}),i}}),Pe={key:0};function He(t,r,e,i,o,n){return i.isLoggedIn()?l.createCommentVNode("v-if",!0):(l.openBlock(),l.createElementBlock("div",Pe,[l.renderSlot(t.$slots,"default")]))}const Ee=S(Oe,[["render",He],["__file","/Users/dick/github/HelloCoop/packages-js/vue/lib/login-status/LoggedOut.vue"]]),Te=()=>m.logout;function Ve(){window.location.href=m.logout}g.ContinueButton=le,g.HelloProvider=ee,g.LoggedIn=Ie,g.LoggedOut=Ee,g.LoginButton=ce,g.UpdateProfileButton=he,g.getLogOutRoute=Te,g.logOut=Ve,g.routeConfig=m,g.useAuth=x,g.useHelloProviderContext=N,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
1
+ (function(g,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(g=typeof globalThis<"u"?globalThis:g||self,a(g["@hellocoop/vue"]={},g.Vue))})(this,function(g,a){"use strict";const w={login:"/api/hellocoop?login=true",auth:"/api/hellocoop?auth=true",logout:"/api/hellocoop?logout=true"},N="HelloAuth",z=()=>a.inject(N),Z={props:["auth","config"],setup(t){var n,e,i;(n=t==null?void 0:t.config)!=null&&n.login&&(w.login=t.config.login),(e=t==null?void 0:t.config)!=null&&e.auth&&(w.auth=t.config.auth),(i=t==null?void 0:t.config)!=null&&i.logout&&(w.logout=t.config.logout),a.provide(N,t.auth)},render(){return this.$slots.default()}};var S;(t=>{t.STYLES_URL="https://cdn.hello.coop/css/hello-btn.css",t.HOVER_MAPPING={pop:"",glow:"hello-btn-hover-glow",flare:"hello-btn-hover-flare",none:"hello-btn-hover-none"},t.CLASS_MAPPING={black:{"ignore-light":"","ignore-dark":"hello-btn-black-on-dark","aware-invert":"hello-btn-black-and-invert","aware-static":"hello-btn-black-and-static"},white:{"ignore-light":"hello-btn-white-on-light","ignore-dark":"hello-btn-white-on-dark","aware-invert":"hello-btn-white-and-invert","aware-static":"hello-btn-white-and-static"}}})(S||(S={}));const ee=["disabled"],te=["innerHTML"],V=a.defineComponent({__name:"BaseButton",props:{label:{default:"ō&nbsp;&nbsp;&nbsp;Continue with Hellō"},style:{},color:{default:"black"},theme:{default:"ignore-light"},hover:{default:"pop"},scope:{},update:{type:Boolean},targetURI:{},providerHint:{},showLoader:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},promptLogin:{type:Boolean,default:!1},promptConsent:{type:Boolean,default:!1},loginHint:{default:""},domainHint:{default:""}},setup(t){let n=!1;a.onMounted(()=>{typeof window<"u"&&!n&&(Array.from(document.head.getElementsByTagName("link")).find(d=>{var u;return d.getAttribute("rel")==="stylesheet"&&((u=d.getAttribute("href"))==null?void 0:u.startsWith(S.STYLES_URL))})||console.warn("Could not find Hellō stylesheet. Please add to pages with Hellō buttons. See http://hello.dev/docs/buttons/#stylesheet for more info."),n=!0)});const e=a.ref(!1),i=t,o=new URL(w.login,window.location.origin);i.scope&&o.searchParams.set("scope",i.scope.join(" ")),o.searchParams.set("target_uri",i.targetURI||window.location.pathname),i.update&&o.searchParams.set("prompt","consent"),i.promptLogin&&i.promptConsent?o.searchParams.set("prompt","login consent"):i.promptLogin?o.searchParams.set("prompt","login"):i.promptConsent&&o.searchParams.set("prompt","consent"),i.loginHint&&o.searchParams.set("login_hint",i.loginHint),i.domainHint&&o.searchParams.set("login_hint",i.domainHint),i.providerHint&&o.searchParams.set("provider_hint",i.providerHint.join(" "));const r=()=>{e.value=!0,window.location.href=o.href};return(s,d)=>{var u;return a.openBlock(),a.createElementBlock("button",{onClick:r,class:a.normalizeClass(["hello-btn",(u=a.unref(S).CLASS_MAPPING[i.color])==null?void 0:u[i.theme],a.unref(S).HOVER_MAPPING[s.hover],(s.showLoader||e.value)&&"hello-btn-loader"]),disabled:i.disabled||e.value,style:a.normalizeStyle(s.style)},[a.createElementVNode("span",{innerHTML:s.label},null,8,te)],14,ee)}}}),ne=a.defineComponent({__name:"ContinueButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(V))}}),re=a.defineComponent({__name:"LoginButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(V,{label:"ō   Login with Hellō"}))}}),ie=a.defineComponent({__name:"UpdateProfileButton",setup(t){return(n,e)=>(a.openBlock(),a.createBlock(V,{label:"ō   Update Profile with Hellō",update:!0}))}});var B=new WeakMap,x=0;function oe(t){if(!t.length)return"";for(var n="arg",e=0;e<t.length;++e){var i=void 0;t[e]===null||typeof t[e]!="object"&&typeof t[e]!="function"?typeof t[e]=="string"?i='"'+t[e]+'"':i=String(t[e]):B.has(t[e])?i=B.get(t[e]):(i=x,B.set(t[e],x++)),n+="@"+i}return n}function ae(t){if(typeof t=="function")try{t=t()}catch{t=""}return Array.isArray(t)?t=oe(t):t=String(t||""),t}var O=function(){function t(n){n===void 0&&(n=0),this.items=new Map,this.ttl=n}return t.prototype.serializeKey=function(n){return ae(n)},t.prototype.get=function(n){var e=this.serializeKey(n);return this.items.get(e)},t.prototype.set=function(n,e,i){var o=this.serializeKey(n),r=i||this.ttl,s=Date.now(),d={data:e,createdAt:s,expiresAt:r?s+r:1/0};this.dispatchExpire(r,d,o),this.items.set(o,d)},t.prototype.dispatchExpire=function(n,e,i){var o=this;n&&setTimeout(function(){var r=Date.now(),s=r>=e.expiresAt;s&&o.delete(i)},n)},t.prototype.delete=function(n){this.items.delete(n)},t}();function le(){return typeof navigator.onLine<"u"?navigator.onLine:!0}function se(){return typeof document<"u"&&typeof document.visibilityState<"u"?document.visibilityState!=="hidden":!0}var ue=function(t){return fetch(t).then(function(n){return n.json()})};const H={isOnline:le,isDocumentVisible:se,fetcher:ue};var b=globalThis&&globalThis.__assign||function(){return b=Object.assign||function(t){for(var n,e=1,i=arguments.length;e<i;e++){n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},b.apply(this,arguments)},R=globalThis&&globalThis.__awaiter||function(t,n,e,i){function o(r){return r instanceof e?r:new e(function(s){s(r)})}return new(e||(e=Promise))(function(r,s){function d(c){try{l(i.next(c))}catch(y){s(y)}}function u(c){try{l(i.throw(c))}catch(y){s(y)}}function l(c){c.done?r(c.value):o(c.value).then(d,u)}l((i=i.apply(t,n||[])).next())})},L=globalThis&&globalThis.__generator||function(t,n){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,o,r,s;return s={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function d(l){return function(c){return u([l,c])}}function u(l){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,o&&(r=l[0]&2?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[l[0]&2,r.value]),l[0]){case 0:case 1:r=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,o=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!r||l[1]>r[0]&&l[1]<r[3])){e.label=l[1];break}if(l[0]===6&&e.label<r[1]){e.label=r[1],r=l;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(l);break}r[2]&&e.ops.pop(),e.trys.pop();continue}l=n.call(t,e)}catch(c){l=[6,c],o=0}finally{i=r=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},ce=globalThis&&globalThis.__read||function(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var i=e.call(t),o,r=[],s;try{for(;(n===void 0||n-- >0)&&!(o=i.next()).done;)r.push(o.value)}catch(d){s={error:d}}finally{try{o&&!o.done&&(e=i.return)&&e.call(i)}finally{if(s)throw s.error}}return r},fe=globalThis&&globalThis.__spreadArray||function(t,n,e){if(e||arguments.length===2)for(var i=0,o=n.length,r;i<o;i++)(r||!(i in n))&&(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return t.concat(r||Array.prototype.slice.call(n))},G=new O,T=new O,D=new O,K={cache:G,refreshInterval:0,ttl:0,serverTTL:1e3,dedupingInterval:2e3,revalidateOnFocus:!0,revalidateDebounce:0,shouldRetryOnError:!0,errorRetryInterval:5e3,errorRetryCount:5,fetcher:H.fetcher,isOnline:H.isOnline,isDocumentVisible:H.isDocumentVisible};function de(t,n,e){var i=T.get(t);if(i)i.data.push(n);else{var o=5e3;T.set(t,[n],e>0?e+o:e)}}function he(t,n,e){if(e.isDocumentVisible()&&!(e.errorRetryCount!==void 0&&n>e.errorRetryCount)){var i=Math.min(n||0,e.errorRetryCount),o=i*e.errorRetryInterval;setTimeout(function(){t(null,{errorRetryCount:i+1,shouldRetryOnError:!0})},o)}}var W=function(t,n,e,i){return e===void 0&&(e=G),i===void 0&&(i=K.ttl),R(void 0,void 0,void 0,function(){var o,r,s,d,u,l,c;return L(this,function(y){switch(y.label){case 0:if(!ve(n))return[3,5];y.label=1;case 1:return y.trys.push([1,3,,4]),[4,n];case 2:return o=y.sent(),[3,4];case 3:return d=y.sent(),r=d,[3,4];case 4:return[3,6];case 5:o=n,y.label=6;case 6:if(s=!1,u={data:o,error:r,isValidating:s},typeof o<"u")try{e.set(t,u,i)}catch(m){console.error("swrv(mutate): failed to set cache",m)}return l=T.get(t),l&&l.data.length&&(c=l.data.filter(function(m){return m.key===t}),c.forEach(function(m,h){typeof u.data<"u"&&(m.data=u.data),m.error=u.error,m.isValidating=u.isValidating;var _=h===c.length-1;_||delete c[h]}),c=c.filter(Boolean)),[2,u]}})})};function ge(){for(var t=this,n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var i,o,r=b({},K),s=!1,d=!1,u=a.getCurrentInstance(),l=(u==null?void 0:u.proxy)||u;if(!l)return console.error("Could not get current instance, check to make sure that `useSwrv` is declared in the top level of the setup function."),null;var c=(l==null?void 0:l.$isServer)||!1;n.length>=1&&(i=n[0]),n.length>=2&&(o=n[1]),n.length>2&&(r=b(b({},r),n[2]));var y=c?r.serverTTL:r.ttl,m=typeof i=="function"?i:a.ref(i);typeof o>"u"&&(o=r.fetcher);var h=null;h||(h=a.reactive({data:void 0,error:void 0,isValidating:!0,key:null}));var _=function(v,f){return R(t,void 0,void 0,function(){var Y,p,k,I,$,q,j,J=this;return L(this,function(U){switch(U.label){case 0:return Y=h.data===void 0,p=m.value,p?(k=r.cache.get(p),I=k&&k.data,h.isValidating=!0,I&&(h.data=I.data,h.error=I.error),$=v||o,!$||!r.isDocumentVisible()&&!Y||(f==null?void 0:f.forceRevalidate)!==void 0&&!(f!=null&&f.forceRevalidate)?(h.isValidating=!1,[2]):k&&(q=!!(Date.now()-k.createdAt>=r.dedupingInterval||f!=null&&f.forceRevalidate),!q)?(h.isValidating=!1,[2]):(j=function(){return R(J,void 0,void 0,function(){var C,Q,F,X;return L(this,function(P){switch(P.label){case 0:return C=D.get(p),C?[3,2]:(Q=Array.isArray(p)?p:[p],F=$.apply(void 0,fe([],ce(Q),!1)),D.set(p,F,r.dedupingInterval),[4,W(p,F,r.cache,y)]);case 1:return P.sent(),[3,4];case 2:return[4,W(p,C.data,r.cache,y)];case 3:P.sent(),P.label=4;case 4:return h.isValidating=!1,D.delete(p),h.error!==void 0&&(X=!s&&r.shouldRetryOnError&&(f?f.shouldRetryOnError:!0),X&&he(_,f?f.errorRetryCount:1,r)),[2]}})})},I&&r.revalidateDebounce?(setTimeout(function(){return R(J,void 0,void 0,function(){return L(this,function(C){switch(C.label){case 0:return s?[3,2]:[4,j()];case 1:C.sent(),C.label=2;case 2:return[2]}})})},r.revalidateDebounce),[3,3]):[3,1])):[2];case 1:return[4,j()];case 2:U.sent(),U.label=3;case 3:return[2]}})})},A=function(){return R(t,void 0,void 0,function(){return L(this,function(v){return[2,_(null,{shouldRetryOnError:!1})]})})},E=null;a.onMounted(function(){var v=function(){return R(t,void 0,void 0,function(){return L(this,function(f){switch(f.label){case 0:return!h.error&&r.isOnline()?[4,_()]:[3,2];case 1:return f.sent(),[3,3];case 2:E&&clearTimeout(E),f.label=3;case 3:return r.refreshInterval&&!s&&(E=setTimeout(v,r.refreshInterval)),[2]}})})};r.refreshInterval&&(E=setTimeout(v,r.refreshInterval)),r.revalidateOnFocus&&(document.addEventListener("visibilitychange",A,!1),window.addEventListener("focus",A,!1))}),a.onUnmounted(function(){s=!0,E&&clearTimeout(E),r.revalidateOnFocus&&(document.removeEventListener("visibilitychange",A,!1),window.removeEventListener("focus",A,!1));var v=T.get(m.value);v&&(v.data=v.data.filter(function(f){return f!==h}))});try{a.watch(m,function(v){a.isReadonly(m)||(m.value=v),h.key=v,h.isValidating=!!v,de(m.value,h,y),!c&&!d&&m.value&&_(),d=!1},{immediate:!0})}catch{}var Re=b(b({},a.toRefs(h)),{mutate:function(v,f){return _(v,b(b({},f),{forceRevalidate:!0}))}});return Re}function ve(t){return t!==null&&typeof t=="object"&&typeof t.then=="function"}const me=async t=>{try{return await(await fetch(t)).json()}catch(n){console.error(n);return}},M=()=>{const t=z(),{data:n=t,isValidating:e}=ge(w.auth,me);return{auth:n||{},isLoading:e,isLoggedIn:n==null?void 0:n.isLoggedIn}},ye={key:0},pe=a.defineComponent({__name:"LoggedIn",setup(t){const n=()=>{var e;return((e=M())==null?void 0:e.isLoggedIn)||!1};return(e,i)=>n()?(a.openBlock(),a.createElementBlock("div",ye,[a.renderSlot(e.$slots,"default")])):a.createCommentVNode("",!0)}}),be={key:0},we=a.defineComponent({__name:"LoggedOut",setup(t){const n=()=>{var e;return((e=M())==null?void 0:e.isLoggedIn)||!1};return(e,i)=>n()?a.createCommentVNode("",!0):(a.openBlock(),a.createElementBlock("div",be,[a.renderSlot(e.$slots,"default")]))}}),_e=()=>w.logout;function Ce(){window.location.href=w.logout}g.ContinueButton=ne,g.HelloProvider=Z,g.LoggedIn=pe,g.LoggedOut=we,g.LoginButton=re,g.UpdateProfileButton=ie,g.getLogOutRoute=_e,g.logOut=Ce,g.routeConfig=w,g.useAuth=M,g.useHelloProviderContext=z,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hellocoop/vue",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "description": "Svelte SDK for Hellō https://hello.dev",
5
5
  "repository": {
6
6
  "type": "git",
@@ -51,5 +51,5 @@
51
51
  "typescript": "^5.2.2",
52
52
  "vite-plugin-dts": "^3.6.3"
53
53
  },
54
- "gitHead": "2890e885168a5a0333b7ef610536fb8ad15703a5"
54
+ "gitHead": "f04a59ac821e23c4e65ae4ae5314eb058724be3e"
55
55
  }