@gigscom/embeds-js
Version:
prebuilt embeddable UI components on top of the Gigs API for the Web
1,518 lines (1,517 loc) • 61.9 kB
JavaScript
function jt(e) {
return { all: e = e || /* @__PURE__ */ new Map(), on: function(t, i) {
var r = e.get(t);
r ? r.push(i) : e.set(t, [i]);
}, off: function(t, i) {
var r = e.get(t);
r && (i ? r.splice(r.indexOf(i) >>> 0, 1) : e.set(t, []));
}, emit: function(t, i) {
var r = e.get(t);
r && r.slice().map(function(n) {
n(i);
}), (r = e.get("*")) && r.slice().map(function(n) {
n(t, i);
});
} };
}
var he, k, ct, ft, B, Be, _t, xe, Ue, we, Ae, dt, ie = {}, vt = [], zt = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, He = Array.isArray;
function z(e, t) {
for (var i in t) e[i] = t[i];
return e;
}
function pt(e) {
var t = e.parentNode;
t && t.removeChild(e);
}
function Vt(e, t, i) {
var r, n, o, u = {};
for (o in t) o == "key" ? r = t[o] : o == "ref" ? n = t[o] : u[o] = t[o];
if (arguments.length > 2 && (u.children = arguments.length > 3 ? he.call(arguments, 2) : i), typeof e == "function" && e.defaultProps != null) for (o in e.defaultProps) u[o] === void 0 && (u[o] = e.defaultProps[o]);
return ae(e, u, r, n, null);
}
function ae(e, t, i, r, n) {
var o = { type: e, props: t, key: i, ref: r, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: n ?? ++ct, __i: -1, __u: 0 };
return n == null && k.vnode != null && k.vnode(o), o;
}
function Z(e) {
return e.children;
}
function ee(e, t) {
this.props = e, this.context = t;
}
function Y(e, t) {
if (t == null) return e.__ ? Y(e.__, e.__i + 1) : null;
for (var i; t < e.__k.length; t++) if ((i = e.__k[t]) != null && i.__e != null) return i.__e;
return typeof e.type == "function" ? Y(e) : null;
}
function ht(e) {
var t, i;
if ((e = e.__) != null && e.__c != null) {
for (e.__e = e.__c.base = null, t = 0; t < e.__k.length; t++) if ((i = e.__k[t]) != null && i.__e != null) {
e.__e = e.__c.base = i.__e;
break;
}
return ht(e);
}
}
function Fe(e) {
(!e.__d && (e.__d = !0) && B.push(e) && !_e.__r++ || Be !== k.debounceRendering) && ((Be = k.debounceRendering) || _t)(_e);
}
function _e() {
var e, t, i, r, n, o, u, a;
for (B.sort(xe); e = B.shift(); ) e.__d && (t = B.length, r = void 0, o = (n = (i = e).__v).__e, u = [], a = [], i.__P && ((r = z({}, n)).__v = n.__v + 1, k.vnode && k.vnode(r), Ge(i.__P, r, n, i.__n, i.__P.namespaceURI, 32 & n.__u ? [o] : null, u, o ?? Y(n), !!(32 & n.__u), a), r.__v = n.__v, r.__.__k[r.__i] = r, bt(u, r, a), r.__e != o && ht(r)), B.length > t && B.sort(xe));
_e.__r = 0;
}
function mt(e, t, i, r, n, o, u, a, f, l, c) {
var s, h, d, p, y, v = r && r.__k || vt, m = t.length;
for (i.__d = f, Mt(i, t, v), f = i.__d, s = 0; s < m; s++) (d = i.__k[s]) != null && typeof d != "boolean" && typeof d != "function" && (h = d.__i === -1 ? ie : v[d.__i] || ie, d.__i = s, Ge(e, d, h, n, o, u, a, f, l, c), p = d.__e, d.ref && h.ref != d.ref && (h.ref && Le(h.ref, null, d), c.push(d.ref, d.__c || p, d)), y == null && p != null && (y = p), 65536 & d.__u || h.__k === d.__k ? (f && !f.isConnected && (f = Y(h)), f = yt(d, f, e)) : typeof d.type == "function" && d.__d !== void 0 ? f = d.__d : p && (f = p.nextSibling), d.__d = void 0, d.__u &= -196609);
i.__d = f, i.__e = y;
}
function Mt(e, t, i) {
var r, n, o, u, a, f = t.length, l = i.length, c = l, s = 0;
for (e.__k = [], r = 0; r < f; r++) u = r + s, (n = e.__k[r] = (n = t[r]) == null || typeof n == "boolean" || typeof n == "function" ? null : typeof n == "string" || typeof n == "number" || typeof n == "bigint" || n.constructor == String ? ae(null, n, null, null, null) : He(n) ? ae(Z, { children: n }, null, null, null) : n.constructor === void 0 && n.__b > 0 ? ae(n.type, n.props, n.key, n.ref ? n.ref : null, n.__v) : n) != null ? (n.__ = e, n.__b = e.__b + 1, a = Rt(n, i, u, c), n.__i = a, o = null, a !== -1 && (c--, (o = i[a]) && (o.__u |= 131072)), o == null || o.__v === null ? (a == -1 && s--, typeof n.type != "function" && (n.__u |= 65536)) : a !== u && (a === u + 1 ? s++ : a > u ? c > f - u ? s += a - u : s-- : a < u ? a == u - 1 && (s = a - u) : s = 0, a !== r + s && (n.__u |= 65536))) : (o = i[u]) && o.key == null && o.__e && !(131072 & o.__u) && (o.__e == e.__d && (e.__d = Y(o)), Ce(o, o, !1), i[u] = null, c--);
if (c) for (r = 0; r < l; r++) (o = i[r]) != null && !(131072 & o.__u) && (o.__e == e.__d && (e.__d = Y(o)), Ce(o, o));
}
function yt(e, t, i) {
var r, n;
if (typeof e.type == "function") {
for (r = e.__k, n = 0; r && n < r.length; n++) r[n] && (r[n].__ = e, t = yt(r[n], t, i));
return t;
}
e.__e != t && (i.insertBefore(e.__e, t || null), t = e.__e);
do
t = t && t.nextSibling;
while (t != null && t.nodeType === 8);
return t;
}
function Rt(e, t, i, r) {
var n = e.key, o = e.type, u = i - 1, a = i + 1, f = t[i];
if (f === null || f && n == f.key && o === f.type && !(131072 & f.__u)) return i;
if (r > (f != null && !(131072 & f.__u) ? 1 : 0)) for (; u >= 0 || a < t.length; ) {
if (u >= 0) {
if ((f = t[u]) && !(131072 & f.__u) && n == f.key && o === f.type) return u;
u--;
}
if (a < t.length) {
if ((f = t[a]) && !(131072 & f.__u) && n == f.key && o === f.type) return a;
a++;
}
}
return -1;
}
function Je(e, t, i) {
t[0] === "-" ? e.setProperty(t, i ?? "") : e[t] = i == null ? "" : typeof i != "number" || zt.test(t) ? i : i + "px";
}
function ue(e, t, i, r, n) {
var o;
e: if (t === "style") if (typeof i == "string") e.style.cssText = i;
else {
if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) i && t in i || Je(e.style, t, "");
if (i) for (t in i) r && i[t] === r[t] || Je(e.style, t, i[t]);
}
else if (t[0] === "o" && t[1] === "n") o = t !== (t = t.replace(/(PointerCapture)$|Capture$/i, "$1")), t = t.toLowerCase() in e || t === "onFocusOut" || t === "onFocusIn" ? t.toLowerCase().slice(2) : t.slice(2), e.l || (e.l = {}), e.l[t + o] = i, i ? r ? i.u = r.u : (i.u = Ue, e.addEventListener(t, o ? Ae : we, o)) : e.removeEventListener(t, o ? Ae : we, o);
else {
if (n == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
else if (t != "width" && t != "height" && t != "href" && t != "list" && t != "form" && t != "tabIndex" && t != "download" && t != "rowSpan" && t != "colSpan" && t != "role" && t in e) try {
e[t] = i ?? "";
break e;
} catch {
}
typeof i == "function" || (i == null || i === !1 && t[4] !== "-" ? e.removeAttribute(t) : e.setAttribute(t, i));
}
}
function Ye(e) {
return function(t) {
if (this.l) {
var i = this.l[t.type + e];
if (t.t == null) t.t = Ue++;
else if (t.t < i.u) return;
return i(k.event ? k.event(t) : t);
}
};
}
function Ge(e, t, i, r, n, o, u, a, f, l) {
var c, s, h, d, p, y, v, m, S, q, O, N, j, T, Se, w = t.type;
if (t.constructor !== void 0) return null;
128 & i.__u && (f = !!(32 & i.__u), o = [a = t.__e = i.__e]), (c = k.__b) && c(t);
e: if (typeof w == "function") try {
if (m = t.props, S = (c = w.contextType) && r[c.__c], q = c ? S ? S.props.value : c.__ : r, i.__c ? v = (s = t.__c = i.__c).__ = s.__E : ("prototype" in w && w.prototype.render ? t.__c = s = new w(m, q) : (t.__c = s = new ee(m, q), s.constructor = w, s.render = Bt), S && S.sub(s), s.props = m, s.state || (s.state = {}), s.context = q, s.__n = r, h = s.__d = !0, s.__h = [], s._sb = []), s.__s == null && (s.__s = s.state), w.getDerivedStateFromProps != null && (s.__s == s.state && (s.__s = z({}, s.__s)), z(s.__s, w.getDerivedStateFromProps(m, s.__s))), d = s.props, p = s.state, s.__v = t, h) w.getDerivedStateFromProps == null && s.componentWillMount != null && s.componentWillMount(), s.componentDidMount != null && s.__h.push(s.componentDidMount);
else {
if (w.getDerivedStateFromProps == null && m !== d && s.componentWillReceiveProps != null && s.componentWillReceiveProps(m, q), !s.__e && (s.shouldComponentUpdate != null && s.shouldComponentUpdate(m, s.__s, q) === !1 || t.__v === i.__v)) {
for (t.__v !== i.__v && (s.props = m, s.state = s.__s, s.__d = !1), t.__e = i.__e, t.__k = i.__k, t.__k.forEach(function(se) {
se && (se.__ = t);
}), O = 0; O < s._sb.length; O++) s.__h.push(s._sb[O]);
s._sb = [], s.__h.length && u.push(s);
break e;
}
s.componentWillUpdate != null && s.componentWillUpdate(m, s.__s, q), s.componentDidUpdate != null && s.__h.push(function() {
s.componentDidUpdate(d, p, y);
});
}
if (s.context = q, s.props = m, s.__P = e, s.__e = !1, N = k.__r, j = 0, "prototype" in w && w.prototype.render) {
for (s.state = s.__s, s.__d = !1, N && N(t), c = s.render(s.props, s.state, s.context), T = 0; T < s._sb.length; T++) s.__h.push(s._sb[T]);
s._sb = [];
} else do
s.__d = !1, N && N(t), c = s.render(s.props, s.state, s.context), s.state = s.__s;
while (s.__d && ++j < 25);
s.state = s.__s, s.getChildContext != null && (r = z(z({}, r), s.getChildContext())), h || s.getSnapshotBeforeUpdate == null || (y = s.getSnapshotBeforeUpdate(d, p)), mt(e, He(Se = c != null && c.type === Z && c.key == null ? c.props.children : c) ? Se : [Se], t, i, r, n, o, u, a, f, l), s.base = t.__e, t.__u &= -161, s.__h.length && u.push(s), v && (s.__E = s.__ = null);
} catch (se) {
t.__v = null, f || o != null ? (t.__e = a, t.__u |= f ? 160 : 32, o[o.indexOf(a)] = null) : (t.__e = i.__e, t.__k = i.__k), k.__e(se, t, i);
}
else o == null && t.__v === i.__v ? (t.__k = i.__k, t.__e = i.__e) : t.__e = Wt(i.__e, t, i, r, n, o, u, f, l);
(c = k.diffed) && c(t);
}
function bt(e, t, i) {
t.__d = void 0;
for (var r = 0; r < i.length; r++) Le(i[r], i[++r], i[++r]);
k.__c && k.__c(t, e), e.some(function(n) {
try {
e = n.__h, n.__h = [], e.some(function(o) {
o.call(n);
});
} catch (o) {
k.__e(o, n.__v);
}
});
}
function Wt(e, t, i, r, n, o, u, a, f) {
var l, c, s, h, d, p, y, v = i.props, m = t.props, S = t.type;
if (S === "svg" ? n = "http://www.w3.org/2000/svg" : S === "math" ? n = "http://www.w3.org/1998/Math/MathML" : n || (n = "http://www.w3.org/1999/xhtml"), o != null) {
for (l = 0; l < o.length; l++) if ((d = o[l]) && "setAttribute" in d == !!S && (S ? d.localName === S : d.nodeType === 3)) {
e = d, o[l] = null;
break;
}
}
if (e == null) {
if (S === null) return document.createTextNode(m);
e = document.createElementNS(n, S, m.is && m), o = null, a = !1;
}
if (S === null) v === m || a && e.data === m || (e.data = m);
else {
if (o = o && he.call(e.childNodes), v = i.props || ie, !a && o != null) for (v = {}, l = 0; l < e.attributes.length; l++) v[(d = e.attributes[l]).name] = d.value;
for (l in v) if (d = v[l], l != "children") {
if (l == "dangerouslySetInnerHTML") s = d;
else if (l !== "key" && !(l in m)) {
if (l == "value" && "defaultValue" in m || l == "checked" && "defaultChecked" in m) continue;
ue(e, l, null, d, n);
}
}
for (l in m) d = m[l], l == "children" ? h = d : l == "dangerouslySetInnerHTML" ? c = d : l == "value" ? p = d : l == "checked" ? y = d : l === "key" || a && typeof d != "function" || v[l] === d || ue(e, l, d, v[l], n);
if (c) a || s && (c.__html === s.__html || c.__html === e.innerHTML) || (e.innerHTML = c.__html), t.__k = [];
else if (s && (e.innerHTML = ""), mt(e, He(h) ? h : [h], t, i, r, S === "foreignObject" ? "http://www.w3.org/1999/xhtml" : n, o, u, o ? o[0] : i.__k && Y(i, 0), a, f), o != null) for (l = o.length; l--; ) o[l] != null && pt(o[l]);
a || (l = "value", p !== void 0 && (p !== e[l] || S === "progress" && !p || S === "option" && p !== v[l]) && ue(e, l, p, v[l], n), l = "checked", y !== void 0 && y !== e[l] && ue(e, l, y, v[l], n));
}
return e;
}
function Le(e, t, i) {
try {
typeof e == "function" ? e(t) : e.current = t;
} catch (r) {
k.__e(r, i);
}
}
function Ce(e, t, i) {
var r, n;
if (k.unmount && k.unmount(e), (r = e.ref) && (r.current && r.current !== e.__e || Le(r, null, t)), (r = e.__c) != null) {
if (r.componentWillUnmount) try {
r.componentWillUnmount();
} catch (o) {
k.__e(o, t);
}
r.base = r.__P = null;
}
if (r = e.__k) for (n = 0; n < r.length; n++) r[n] && Ce(r[n], t, i || typeof e.type != "function");
i || e.__e == null || pt(e.__e), e.__c = e.__ = e.__e = e.__d = void 0;
}
function Bt(e, t, i) {
return this.constructor(e, i);
}
function Ze(e, t, i) {
var r, n, o, u;
k.__ && k.__(e, t), n = (r = typeof i == "function") ? null : i && i.__k || t.__k, o = [], u = [], Ge(t, e = (!r && i || t).__k = Vt(Z, null, [e]), n || ie, ie, t.namespaceURI, !r && i ? [i] : n ? null : t.firstChild ? he.call(t.childNodes) : null, o, !r && i ? i : n ? n.__e : t.firstChild, r, u), bt(o, e, u);
}
function Jt(e, t) {
var i = { __c: t = "__cC" + dt++, __: e, Consumer: function(r, n) {
return r.children(n);
}, Provider: function(r) {
var n, o;
return this.getChildContext || (n = [], (o = {})[t] = this, this.getChildContext = function() {
return o;
}, this.shouldComponentUpdate = function(u) {
this.props.value !== u.value && n.some(function(a) {
a.__e = !0, Fe(a);
});
}, this.sub = function(u) {
n.push(u);
var a = u.componentWillUnmount;
u.componentWillUnmount = function() {
n.splice(n.indexOf(u), 1), a && a.call(u);
};
}), r.children;
} };
return i.Provider.__ = i.Consumer.contextType = i;
}
he = vt.slice, k = { __e: function(e, t, i, r) {
for (var n, o, u; t = t.__; ) if ((n = t.__c) && !n.__) try {
if ((o = n.constructor) && o.getDerivedStateFromError != null && (n.setState(o.getDerivedStateFromError(e)), u = n.__d), n.componentDidCatch != null && (n.componentDidCatch(e, r || {}), u = n.__d), u) return n.__E = n;
} catch (a) {
e = a;
}
throw e;
} }, ct = 0, ft = function(e) {
return e != null && e.constructor == null;
}, ee.prototype.setState = function(e, t) {
var i;
i = this.__s != null && this.__s !== this.state ? this.__s : this.__s = z({}, this.state), typeof e == "function" && (e = e(z({}, i), this.props)), e && z(i, e), e != null && this.__v && (t && this._sb.push(t), Fe(this));
}, ee.prototype.forceUpdate = function(e) {
this.__v && (this.__e = !0, e && this.__h.push(e), Fe(this));
}, ee.prototype.render = Z, B = [], _t = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, xe = function(e, t) {
return e.__v.__b - t.__v.__b;
}, _e.__r = 0, Ue = 0, we = Ye(!1), Ae = Ye(!0), dt = 0;
function P(e, t, i) {
if (!e)
throw new Error(t, {
cause: i
});
}
async function Yt(e, t, i) {
const r = await fetch(`https://api.gigs.com/projects/${i.project}/portings/${e}`, {
method: "PATCH",
headers: {
authorization: `Bearer ${i.token}`,
"content-type": "application/json",
accept: "application/json"
},
body: JSON.stringify(t)
}), n = await r.json().catch(() => r.text());
return P(r.status !== 404, "PRT_NOT_FOUND: Porting could not be found."), P(r.ok, `FETCH_FAILED: ${(n == null ? void 0 : n.message) || (n == null ? void 0 : n.toString())}`), n;
}
async function Zt(e, t) {
const i = await fetch(`https://api.gigs.com/projects/${t.project}/subscriptions/${e}`, {
headers: {
authorization: `Bearer ${t.token}`
}
}), r = await i.json().catch(() => i.text());
return P(i.status !== 404, "SUB_NOT_FOUND: Subscription could not be fetched."), P(i.ok, `FETCH_FAILED: ${(r == null ? void 0 : r.message) || (r == null ? void 0 : r.toString())}`), r;
}
async function Kt(e, t) {
var u;
const {
connectSession: i,
token: r
} = Qt(e, t), n = await fetch("https://connect.gigs.com/api/embeds/auth", {
method: "POST",
headers: {
"content-type": "application/json"
},
body: JSON.stringify({
secret: r
})
}), o = await n.json().catch(async () => ({
error: await n.text()
}));
return P(n.status !== 422, "INVALID_SESSION: Session is expired."), P(n.ok, `FETCH_FAILED: ${o.error}`), P((u = o.token) == null ? void 0 : u.access_token, "Expected user token to be returned in response of token exchange, but was not found."), {
connectSession: i,
token: o.token.access_token
};
}
function Qt(e, t) {
P(e && typeof e == "object" && "object" in e && "intent" in e && "url" in e && e.object === "connectSession", "INVALID_SESSION: The object you passed in is not a ConnectSession resoure. Make sure to pass in the complete resource.");
const i = e;
P(i.intent.type === t, `INVALID_SESSION: PortingEmbed must be initialized with the "${t}" intent, but got "${i.intent.type}" instead.`), P(i.url, "INVALID_SESSION: Session has no URL. Did you pass in the created session?");
const n = new URL(i.url).searchParams.get("token");
return P(n, "INVALID_SESSION: Session has no token. Is it an authenticated session?"), {
connectSession: i,
token: n
};
}
var re, x, Ee, Ke, De = 0, gt = [], le = [], E = k, Qe = E.__b, Xe = E.__r, et = E.diffed, tt = E.__c, it = E.unmount, rt = E.__;
function je(e, t) {
E.__h && E.__h(x, e, De || t), De = 0;
var i = x.__H || (x.__H = { __: [], __h: [] });
return e >= i.__.length && i.__.push({ __V: le }), i.__[e];
}
function qe(e, t) {
var i = je(re++, 3);
!E.__s && Nt(i.__H, t) && (i.__ = e, i.i = t, x.__H.__h.push(i));
}
function kt(e) {
return De = 5, I(function() {
return { current: e };
}, []);
}
function I(e, t) {
var i = je(re++, 7);
return Nt(i.__H, t) ? (i.__V = e(), i.i = t, i.__h = e, i.__V) : i.__;
}
function Xt(e) {
var t = x.context[e.__c], i = je(re++, 9);
return i.c = e, t ? (i.__ == null && (i.__ = !0, t.sub(x)), t.props.value) : e.__;
}
function ei() {
for (var e; e = gt.shift(); ) if (e.__P && e.__H) try {
e.__H.__h.forEach(ce), e.__H.__h.forEach(Ie), e.__H.__h = [];
} catch (t) {
e.__H.__h = [], E.__e(t, e.__v);
}
}
E.__b = function(e) {
x = null, Qe && Qe(e);
}, E.__ = function(e, t) {
e && t.__k && t.__k.__m && (e.__m = t.__k.__m), rt && rt(e, t);
}, E.__r = function(e) {
Xe && Xe(e), re = 0;
var t = (x = e.__c).__H;
t && (Ee === x ? (t.__h = [], x.__h = [], t.__.forEach(function(i) {
i.__N && (i.__ = i.__N), i.__V = le, i.__N = i.i = void 0;
})) : (t.__h.forEach(ce), t.__h.forEach(Ie), t.__h = [], re = 0)), Ee = x;
}, E.diffed = function(e) {
et && et(e);
var t = e.__c;
t && t.__H && (t.__H.__h.length && (gt.push(t) !== 1 && Ke === E.requestAnimationFrame || ((Ke = E.requestAnimationFrame) || ti)(ei)), t.__H.__.forEach(function(i) {
i.i && (i.__H = i.i), i.__V !== le && (i.__ = i.__V), i.i = void 0, i.__V = le;
})), Ee = x = null;
}, E.__c = function(e, t) {
t.some(function(i) {
try {
i.__h.forEach(ce), i.__h = i.__h.filter(function(r) {
return !r.__ || Ie(r);
});
} catch (r) {
t.some(function(n) {
n.__h && (n.__h = []);
}), t = [], E.__e(r, i.__v);
}
}), tt && tt(e, t);
}, E.unmount = function(e) {
it && it(e);
var t, i = e.__c;
i && i.__H && (i.__H.__.forEach(function(r) {
try {
ce(r);
} catch (n) {
t = n;
}
}), i.__H = void 0, t && E.__e(t, i.__v));
};
var nt = typeof requestAnimationFrame == "function";
function ti(e) {
var t, i = function() {
clearTimeout(r), nt && cancelAnimationFrame(t), setTimeout(e);
}, r = setTimeout(i, 100);
nt && (t = requestAnimationFrame(i));
}
function ce(e) {
var t = x, i = e.__c;
typeof i == "function" && (e.__c = void 0, i()), x = t;
}
function Ie(e) {
var t = x;
e.__c = e.__(), x = t;
}
function Nt(e, t) {
return !e || e.length !== t.length || t.some(function(i, r) {
return i !== e[r];
});
}
const me = "gigsPortingEmbedForm", ii = {
"field.accountNumber.label": "Account Number",
"field.accountNumber.error.required": "The account number is required",
"field.accountPin.label": "Account PIN",
"field.accountPin.error.required": "The account pin is required",
"field.accountPin.error.cleared": "The new account pin is empty. If you do not want to change the account pin, clear the input.",
"field.firstName.label": "First Name",
"field.firstName.error.required": "Your first name is required",
"field.lastName.label": "Last Name",
"field.lastName.error.required": "Your last name is required",
"field.birthday.label": "Birthday",
"field.birthday.error.required": "Your birthday is required",
"field.line1.label": "Line 1",
"field.line1.error.required": "Line 1 is required",
"field.line2.label": "Line 2",
"field.city.label": "City",
"field.city.error.required": "City is required",
"field.postalCode.label": "Postal Code",
"field.postalCode.error.required": "Postal Code is required",
"field.state.label": "State (ISO code)",
"field.state.error.format": "Must be an ISO state code",
"field.country.label": "Country (2 letter code)",
"field.country.error.required": "Country is required",
"field.country.error.format": "Must be an ISO country code",
"field.donorProviderApproval.label": "I have notified my current provider of the number porting and got the approval that the number can be ported",
"field.donorProviderApproval.error.required": "You must get the approval of your current provider"
}, St = Jt({});
function W() {
const e = Xt(St);
return {
...e,
text: {
...ii,
...e.text
}
};
}
var ri = Symbol.for("preact-signals");
function ye() {
if (V > 1)
V--;
else {
for (var e, t = !1; te !== void 0; ) {
var i = te;
for (te = void 0, Oe++; i !== void 0; ) {
var r = i.o;
if (i.o = void 0, i.f &= -3, !(8 & i.f) && Pt(i)) try {
i.c();
} catch (n) {
t || (e = n, t = !0);
}
i = r;
}
}
if (Oe = 0, V--, t) throw e;
}
}
function L(e) {
if (V > 0) return e();
V++;
try {
return e();
} finally {
ye();
}
}
var g = void 0, te = void 0, V = 0, Oe = 0, de = 0;
function Et(e) {
if (g !== void 0) {
var t = e.n;
if (t === void 0 || t.t !== g)
return t = { i: 0, S: e, p: g.s, n: void 0, t: g, e: void 0, x: void 0, r: t }, g.s !== void 0 && (g.s.n = t), g.s = t, e.n = t, 32 & g.f && e.S(t), t;
if (t.i === -1)
return t.i = 0, t.n !== void 0 && (t.n.p = t.p, t.p !== void 0 && (t.p.n = t.n), t.p = g.s, t.n = void 0, g.s.n = t, g.s = t), t;
}
}
function $(e) {
this.v = e, this.i = 0, this.n = void 0, this.t = void 0;
}
$.prototype.brand = ri;
$.prototype.h = function() {
return !0;
};
$.prototype.S = function(e) {
this.t !== e && e.e === void 0 && (e.x = this.t, this.t !== void 0 && (this.t.e = e), this.t = e);
};
$.prototype.U = function(e) {
if (this.t !== void 0) {
var t = e.e, i = e.x;
t !== void 0 && (t.x = i, e.e = void 0), i !== void 0 && (i.e = t, e.x = void 0), e === this.t && (this.t = i);
}
};
$.prototype.subscribe = function(e) {
var t = this;
return oe(function() {
var i = t.value, r = g;
g = void 0;
try {
e(i);
} finally {
g = r;
}
});
};
$.prototype.valueOf = function() {
return this.value;
};
$.prototype.toString = function() {
return this.value + "";
};
$.prototype.toJSON = function() {
return this.value;
};
$.prototype.peek = function() {
var e = g;
g = void 0;
try {
return this.value;
} finally {
g = e;
}
};
Object.defineProperty($.prototype, "value", { get: function() {
var e = Et(this);
return e !== void 0 && (e.i = this.i), this.v;
}, set: function(e) {
if (e !== this.v) {
if (Oe > 100) throw new Error("Cycle detected");
this.v = e, this.i++, de++, V++;
try {
for (var t = this.t; t !== void 0; t = t.x) t.t.N();
} finally {
ye();
}
}
} });
function b(e) {
return new $(e);
}
function Pt(e) {
for (var t = e.s; t !== void 0; t = t.n) if (t.S.i !== t.i || !t.S.h() || t.S.i !== t.i) return !0;
return !1;
}
function $t(e) {
for (var t = e.s; t !== void 0; t = t.n) {
var i = t.S.n;
if (i !== void 0 && (t.r = i), t.S.n = t, t.i = -1, t.n === void 0) {
e.s = t;
break;
}
}
}
function xt(e) {
for (var t = e.s, i = void 0; t !== void 0; ) {
var r = t.p;
t.i === -1 ? (t.S.U(t), r !== void 0 && (r.n = t.n), t.n !== void 0 && (t.n.p = r)) : i = t, t.S.n = t.r, t.r !== void 0 && (t.r = void 0), t = r;
}
e.s = i;
}
function K(e) {
$.call(this, void 0), this.x = e, this.s = void 0, this.g = de - 1, this.f = 4;
}
(K.prototype = new $()).h = function() {
if (this.f &= -3, 1 & this.f) return !1;
if ((36 & this.f) == 32 || (this.f &= -5, this.g === de)) return !0;
if (this.g = de, this.f |= 1, this.i > 0 && !Pt(this))
return this.f &= -2, !0;
var e = g;
try {
$t(this), g = this;
var t = this.x();
(16 & this.f || this.v !== t || this.i === 0) && (this.v = t, this.f &= -17, this.i++);
} catch (i) {
this.v = i, this.f |= 16, this.i++;
}
return g = e, xt(this), this.f &= -2, !0;
};
K.prototype.S = function(e) {
if (this.t === void 0) {
this.f |= 36;
for (var t = this.s; t !== void 0; t = t.n) t.S.S(t);
}
$.prototype.S.call(this, e);
};
K.prototype.U = function(e) {
if (this.t !== void 0 && ($.prototype.U.call(this, e), this.t === void 0)) {
this.f &= -33;
for (var t = this.s; t !== void 0; t = t.n) t.S.U(t);
}
};
K.prototype.N = function() {
if (!(2 & this.f)) {
this.f |= 6;
for (var e = this.t; e !== void 0; e = e.x) e.t.N();
}
};
Object.defineProperty(K.prototype, "value", { get: function() {
if (1 & this.f) throw new Error("Cycle detected");
var e = Et(this);
if (this.h(), e !== void 0 && (e.i = this.i), 16 & this.f) throw this.v;
return this.v;
} });
function wt(e) {
return new K(e);
}
function At(e) {
var t = e.u;
if (e.u = void 0, typeof t == "function") {
V++;
var i = g;
g = void 0;
try {
t();
} catch (r) {
throw e.f &= -2, e.f |= 8, ze(e), r;
} finally {
g = i, ye();
}
}
}
function ze(e) {
for (var t = e.s; t !== void 0; t = t.n) t.S.U(t);
e.x = void 0, e.s = void 0, At(e);
}
function ni(e) {
if (g !== this) throw new Error("Out-of-order effect");
xt(this), g = e, this.f &= -2, 8 & this.f && ze(this), ye();
}
function ne(e) {
this.x = e, this.u = void 0, this.s = void 0, this.o = void 0, this.f = 32;
}
ne.prototype.c = function() {
var e = this.S();
try {
if (8 & this.f || this.x === void 0) return;
var t = this.x();
typeof t == "function" && (this.u = t);
} finally {
e();
}
};
ne.prototype.S = function() {
if (1 & this.f) throw new Error("Cycle detected");
this.f |= 1, this.f &= -9, At(this), $t(this), V++;
var e = g;
return g = this, ni.bind(this, e);
};
ne.prototype.N = function() {
2 & this.f || (this.f |= 2, this.o = te, te = this);
};
ne.prototype.d = function() {
this.f |= 8, 1 & this.f || ze(this);
};
function oe(e) {
var t = new ne(e);
try {
t.c();
} catch (i) {
throw t.d(), i;
}
return t.d.bind(t);
}
var be, Pe;
function Q(e, t) {
k[e] = t.bind(null, k[e] || function() {
});
}
function ve(e) {
Pe && Pe(), Pe = e && e.S();
}
function Ft(e) {
var t = this, i = e.data, r = Ct(i);
r.value = i;
var n = I(function() {
for (var o = t.__v; o = o.__; ) if (o.__c) {
o.__c.__$f |= 4;
break;
}
return t.__$u.c = function() {
var u;
!ft(n.peek()) && ((u = t.base) == null ? void 0 : u.nodeType) === 3 ? t.base.data = n.peek() : (t.__$f |= 1, t.setState({}));
}, wt(function() {
var u = r.value.value;
return u === 0 ? 0 : u === !0 ? "" : u || "";
});
}, []);
return n.value;
}
Ft.displayName = "_st";
Object.defineProperties($.prototype, { constructor: { configurable: !0, value: void 0 }, type: { configurable: !0, value: Ft }, props: { configurable: !0, get: function() {
return { data: this };
} }, __b: { configurable: !0, value: 1 } });
Q("__b", function(e, t) {
if (typeof t.type == "string") {
var i, r = t.props;
for (var n in r) if (n !== "children") {
var o = r[n];
o instanceof $ && (i || (t.__np = i = {}), i[n] = o, r[n] = o.peek());
}
}
e(t);
});
Q("__r", function(e, t) {
ve();
var i, r = t.__c;
r && (r.__$f &= -2, (i = r.__$u) === void 0 && (r.__$u = i = function(n) {
var o;
return oe(function() {
o = this;
}), o.c = function() {
r.__$f |= 1, r.setState({});
}, o;
}())), be = r, ve(i), e(t);
});
Q("__e", function(e, t, i, r) {
ve(), be = void 0, e(t, i, r);
});
Q("diffed", function(e, t) {
ve(), be = void 0;
var i;
if (typeof t.type == "string" && (i = t.__e)) {
var r = t.__np, n = t.props;
if (r) {
var o = i.U;
if (o) for (var u in o) {
var a = o[u];
a !== void 0 && !(u in r) && (a.d(), o[u] = void 0);
}
else i.U = o = {};
for (var f in r) {
var l = o[f], c = r[f];
l === void 0 ? (l = oi(i, f, c, n), o[f] = l) : l.o(c, n);
}
}
}
e(t);
});
function oi(e, t, i, r) {
var n = t in e && e.ownerSVGElement === void 0, o = b(i);
return { o: function(u, a) {
o.value = u, r = a;
}, d: oe(function() {
var u = o.value.value;
r[t] !== u && (r[t] = u, n ? e[t] = u : u ? e.setAttribute(t, u) : e.removeAttribute(t));
}) };
}
Q("unmount", function(e, t) {
if (typeof t.type == "string") {
var i = t.__e;
if (i) {
var r = i.U;
if (r) {
i.U = void 0;
for (var n in r) {
var o = r[n];
o && o.d();
}
}
}
} else {
var u = t.__c;
if (u) {
var a = u.__$u;
a && (u.__$u = void 0, a.d());
}
}
e(t);
});
Q("__h", function(e, t, i, r) {
(r < 3 || r === 9) && (t.__$f |= 2), e(t, i, r);
});
ee.prototype.shouldComponentUpdate = function(e, t) {
var i = this.__$u;
if (!(i && i.s !== void 0 || 4 & this.__$f) || 3 & this.__$f) return !0;
for (var r in t) return !0;
for (var n in e) if (n !== "__source" && e[n] !== this.props[n]) return !0;
for (var o in this.props) if (!(o in e)) return !0;
return !1;
};
function Ct(e) {
return I(function() {
return b(e);
}, []);
}
function si(e) {
var t = kt(e);
return t.current = e, be.__$f |= 4, I(function() {
return wt(function() {
return t.current();
});
}, []);
}
function ge(e) {
var t = kt(e);
t.current = e, qe(function() {
return oe(function() {
return t.current();
});
}, []);
}
var ui = 0;
function _(e, t, i, r, n, o) {
t || (t = {});
var u, a, f = t;
if ("ref" in f) for (a in f = {}, t) a == "ref" ? u = t[a] : f[a] = t[a];
var l = { type: e, props: f, key: i, ref: u, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: --ui, __i: -1, __u: 0, __source: n, __self: o };
if (typeof e == "function" && (u = e.defaultProps)) for (a in u) f[a] === void 0 && (f[a] = u[a]);
return k.vnode && k.vnode(l), l;
}
var ai = Object.defineProperty, li = (e, t, i) => t in e ? ai(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i, ot = (e, t, i) => (li(e, typeof t != "symbol" ? t + "" : t, i), i);
function ci({
initialValues: e = {},
validateOn: t = "submit",
revalidateOn: i = "input",
validate: r
} = {}) {
return I(
() => ({
internal: {
// Props
initialValues: e,
validate: r,
validateOn: t,
revalidateOn: i,
// Signals
fieldNames: b([]),
fieldArrayNames: b([]),
// Stores
fields: {},
fieldArrays: {},
// Other
validators: /* @__PURE__ */ new Set()
},
// Signals
element: b(null),
submitCount: b(0),
submitting: b(!1),
submitted: b(!1),
validating: b(!1),
touched: b(!1),
dirty: b(!1),
invalid: b(!1),
response: b({})
}),
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
}
function ke(e) {
const t = ci(e);
return I(() => [t, {
Form: (i) => Pi({
...i,
of: t
}),
Field: (i) => Si({
...i,
of: t
}),
FieldArray: (i) => Ei({
...i,
of: t
})
}], [t]);
}
function st(e, t, i) {
const {
checked: r,
files: n,
options: o,
value: u,
valueAsDate: a,
valueAsNumber: f
} = e;
return !i || i === "string" ? u : i === "string[]" ? o ? [...o].filter((l) => l.selected && !l.disabled).map((l) => l.value) : r ? [...t.value.peek() || [], u] : (t.value.peek() || []).filter((l) => l !== u) : i === "number" ? f : i === "boolean" ? r : i === "File" && n ? n[0] : i === "File[]" && n ? [...n] : i === "Date" && a ? a : t.value.peek();
}
function Ve(e) {
return [...Object.values(e.internal.fields), ...Object.values(e.internal.fieldArrays)];
}
function M(e, t) {
return e.internal.fieldArrays[t];
}
function fi(e, t) {
return +t.replace(`${e}.`, "").split(".")[0];
}
function Dt(e, t) {
qt(e, !1).forEach((i) => {
const r = M(e, i).items.peek().length - 1;
t.filter((n) => n.startsWith(`${i}.`) && fi(i, n) > r).forEach((n) => {
t.splice(t.indexOf(n), 1);
});
});
}
function qt(e, t = !0) {
const i = [...e.internal.fieldArrayNames.peek()];
return t && Dt(e, i), i;
}
function _i(e, t = !0) {
const i = [...e.internal.fieldNames.peek()];
return t && Dt(e, i), i;
}
function R(e, t) {
return e.internal.fields[t];
}
function Me(e, t, i) {
const r = _i(e, i), n = qt(e, i);
return typeof t == "string" || Array.isArray(t) ? (typeof t == "string" ? [t] : t).reduce((o, u) => {
const [a, f] = o;
return n.includes(u) ? (n.forEach((l) => {
l.startsWith(u) && f.add(l);
}), r.forEach((l) => {
l.startsWith(u) && a.add(l);
})) : a.add(u), o;
}, [/* @__PURE__ */ new Set(), /* @__PURE__ */ new Set()]).map((o) => [...o]) : [r, n];
}
function Re(e, t) {
return (typeof e != "string" && !Array.isArray(e) ? e : t) || {};
}
function pe(e, t) {
return e.split(".").reduce((i, r) => i == null ? void 0 : i[r], t);
}
let di = 0;
function Ne() {
return di++;
}
function vi(e, t) {
const i = (r) => r instanceof Blob ? r.size : r;
return Array.isArray(e) && Array.isArray(t) ? e.map(i).join() !== t.map(i).join() : e instanceof Date && t instanceof Date ? e.getTime() !== t.getTime() : Number.isNaN(e) && Number.isNaN(t) ? !1 : e !== t;
}
function pi(e, t) {
e.dirty.value = t || Ve(e).some((i) => i.active.peek() && i.dirty.peek());
}
function hi(e, t) {
const i = vi(t.startValue.peek(), t.value.peek());
i !== t.dirty.peek() && L(() => {
t.dirty.value = i, pi(e, i);
});
}
function mi(e, t, i, {
on: r,
shouldFocus: n = !1
}) {
r.includes((e.internal.validateOn === "submit" ? e.submitted.peek() : t.error.peek()) ? e.internal.revalidateOn : e.internal.validateOn) && Ht(e, i, {
shouldFocus: n
});
}
function $e(e, t, i, r, n, o) {
L(() => {
t.value.value = t.transform.reduce((u, a) => a(u, r), o ?? t.value.value), t.touched.value = !0, e.touched.value = !0, hi(e, t), mi(e, t, i, {
on: n
});
});
}
function yi(e, t) {
var i;
if (!M(e, t)) {
const r = ((i = pe(t, e.internal.initialValues)) == null ? void 0 : i.map(() => Ne())) || [];
e.internal.fieldArrays[t] = {
// Signals
initialItems: b(r),
startItems: b(r),
items: b(r),
error: b(""),
active: b(!1),
touched: b(!1),
dirty: b(!1),
// Other
validate: [],
consumers: /* @__PURE__ */ new Set()
}, e.internal.fieldArrayNames.value = [...e.internal.fieldArrayNames.peek(), t];
}
return M(e, t);
}
function bi(e, t) {
if (!R(e, t)) {
const i = pe(t, e.internal.initialValues);
e.internal.fields[t] = {
// Signals
elements: b([]),
initialValue: b(i),
startValue: b(i),
value: b(i),
error: b(""),
active: b(!1),
touched: b(!1),
dirty: b(!1),
// Other
validate: [],
transform: [],
consumers: /* @__PURE__ */ new Set()
}, e.internal.fieldNames.value = [...e.internal.fieldNames.peek(), t];
}
return R(e, t);
}
function X(e, t) {
return t ? e.peek() : e.value;
}
function gi(e, t, {
shouldActive: i = !0
}) {
const r = Object.entries(t).reduce((n, [o, u]) => ([R(e, o), M(e, o)].every((a) => !a || i && !a.active.peek()) && n.push(u), n), []).join(" ");
r && (e.response.value = {
status: "error",
message: r
});
}
function It(e, t) {
e.invalid.value = t || Ve(e).some((i) => i.active.peek() && i.error.peek());
}
function Te(e) {
let t = !1, i = !1, r = !1;
for (const n of Ve(e))
if (n.active.peek() && (n.touched.peek() && (t = !0), n.dirty.peek() && (i = !0), n.error.peek() && (r = !0)), t && i && r)
break;
L(() => {
e.touched.value = t, e.dirty.value = i, e.invalid.value = r;
});
}
function Ot(e, t) {
var i, r;
(r = (i = R(e, t)) == null ? void 0 : i.elements.peek()[0]) == null || r.focus();
}
function Tt(e, t, i, {
shouldActive: r = !0,
shouldTouched: n = !1,
shouldDirty: o = !1,
shouldFocus: u = !!i
} = {}) {
L(() => {
for (const a of [R(e, t), M(e, t)])
a && (!r || a.active.peek()) && (!n || a.touched.peek()) && (!o || a.dirty.peek()) && (a.error.value = i, i && "value" in a && u && Ot(e, t));
It(e, !!i);
});
}
function Ut(e, t, i) {
const [r, n] = Me(e, t), {
shouldActive: o = !0,
shouldTouched: u = !1,
shouldDirty: a = !1,
shouldValid: f = !1,
peek: l = !1
} = Re(t, i);
return l || (typeof t != "string" && !Array.isArray(t) ? e.internal.fieldNames.value : n.forEach((c) => M(e, c).items.value)), r.reduce((c, s) => {
const h = R(e, s);
return (!o || X(h.active, l)) && (!u || X(h.touched, l)) && (!a || X(h.dirty, l)) && (!f || !X(h.error, l)) && (typeof t == "string" ? s.replace(`${t}.`, "") : s).split(".").reduce((d, p, y, v) => d[p] = y === v.length - 1 ? (
// If it is last key, add value
X(h.value, l)
) : (
// Otherwise return object or array
typeof d[p] == "object" && d[p] || (isNaN(+v[y + 1]) ? {} : [])
), c), c;
}, typeof t == "string" ? [] : {});
}
function ki(e, t, i) {
const [r, n] = Me(e, t, !1), o = typeof t == "string" && r.length === 1, u = !o && !Array.isArray(t), a = Re(t, i), {
initialValue: f,
initialValues: l,
keepResponse: c = !1,
keepSubmitCount: s = !1,
keepSubmitted: h = !1,
keepValues: d = !1,
keepDirtyValues: p = !1,
keepItems: y = !1,
keepDirtyItems: v = !1,
keepErrors: m = !1,
keepTouched: S = !1,
keepDirty: q = !1
} = a;
L(() => {
r.forEach((O) => {
const N = R(e, O);
(o ? "initialValue" in a : l) && (N.initialValue.value = o ? f : pe(O, l));
const j = p && N.dirty.peek();
!d && !j && (N.startValue.value = N.initialValue.peek(), N.value.value = N.initialValue.peek(), N.elements.peek().forEach((T) => {
T.type === "file" && (T.value = "");
})), S || (N.touched.value = !1), !q && !d && !j && (N.dirty.value = !1), m || (N.error.value = "");
}), n.forEach((O) => {
var T;
const N = M(e, O), j = v && N.dirty.peek();
!y && !j && (l && (N.initialItems.value = ((T = pe(O, l)) == null ? void 0 : T.map(() => Ne())) || []), N.startItems.value = [...N.initialItems.peek()], N.items.value = [...N.initialItems.peek()]), S || (N.touched.value = !1), !q && !y && !j && (N.dirty.value = !1), m || (N.error.value = "");
}), u && (c || (e.response.value = {}), s || (e.submitCount.value = 0), h || (e.submitted.value = !1)), Te(e);
});
}
function Ni(e, t, {
duration: i
} = {}) {
e.response.value = t, i && setTimeout(() => {
e.response.peek() === t && (e.response.value = {});
}, i);
}
async function Ht(e, t, i) {
const [r, n] = Me(e, t), {
shouldActive: o = !0,
shouldFocus: u = !0
} = Re(t, i), a = Ne();
e.internal.validators.add(a), e.validating.value = !0;
const f = e.internal.validate ? await e.internal.validate(Ut(e, {
shouldActive: o,
peek: !0
})) : {};
let l = typeof t != "string" && !Array.isArray(t) ? !Object.keys(f).length : !0;
const [c] = await Promise.all([
// Validate each field in list
Promise.all(r.map(async (s) => {
const h = R(e, s);
if (!o || h.active.peek()) {
let d;
for (const y of h.validate)
if (d = await y(h.value.peek()), d)
break;
const p = d || f[s] || "";
return p && (l = !1), h.error.value = p, p ? s : null;
}
})),
// Validate each field array in list
Promise.all(n.map(async (s) => {
const h = M(e, s);
if (!o || h.active.peek()) {
let d = "";
for (const y of h.validate)
if (d = await y(h.items.peek()), d)
break;
const p = d || f[s] || "";
p && (l = !1), h.error.value = p;
}
}))
]);
return L(() => {
if (gi(e, f, {
shouldActive: o
}), u) {
const s = c.find((h) => h);
s && Ot(e, s);
}
It(e, !l), e.internal.validators.delete(a), e.internal.validators.size || (e.validating.value = !1);
}), l;
}
function Gt({
of: e,
name: t,
store: i,
validate: r,
transform: n,
keepActive: o = !1,
keepState: u = !0
}) {
qe(() => {
i.validate = r ? Array.isArray(r) ? r : [r] : [], "transform" in i && (i.transform = n ? Array.isArray(n) ? n : [n] : []);
}, [i, n, r]), qe(() => {
const a = Ne();
return i.consumers.add(a), i.active.peek() || L(() => {
i.active.value = !0, Te(e);
}), () => {
setTimeout(() => {
i.consumers.delete(a), L(() => {
!o && !i.consumers.size && (i.active.value = !1, u ? Te(e) : ki(e, t));
}), "elements" in i && (i.elements.value = i.elements.peek().filter((f) => f.isConnected));
});
};
}, [e, t, i, o, u]);
}
function H(e) {
const t = Ct(e);
return t.peek() !== e && (t.value = e), si(() => t.value.value);
}
function Si({
children: e,
type: t,
...i
}) {
const {
of: r,
name: n
} = i, o = I(() => bi(r, n), [r, n]);
Gt({
...i,
store: o
});
const u = H(o.value), a = H(o.error), f = H(o.active), l = H(o.touched), c = H(o.dirty);
return _(Z, {
children: e(I(
() => ({
name: n,
value: u,
error: a,
active: f,
touched: l,
dirty: c
}),
// eslint-disable-next-line react-hooks/exhaustive-deps
[n]
), I(() => ({
name: n,
ref(s) {
s && (o.elements.value = [...o.elements.value, s], oe(() => {
if (s.type !== "radio" && o.startValue.value === void 0 && o.value.peek() === void 0) {
const h = st(s, o, t);
o.startValue.value = h, o.value.value = h;
}
}));
},
onInput(s) {
$e(r, o, n, s, ["touched", "input"], st(s.currentTarget, o, t));
},
onChange(s) {
$e(r, o, n, s, ["change"]);
},
onBlur(s) {
$e(r, o, n, s, ["touched", "blur"]);
}
}), [o, r, n, t]))
});
}
function Ei({
children: e,
...t
}) {
const {
of: i,
name: r
} = t, n = I(() => yi(i, r), [i, r]);
Gt({
...t,
store: n
});
const o = H(n.items), u = H(n.error), a = H(n.active), f = H(n.touched), l = H(n.dirty);
return _(Z, {
children: e(I(
() => ({
name: r,
items: o,
error: u,
active: a,
touched: f,
dirty: l
}),
// eslint-disable-next-line react-hooks/exhaustive-deps
[r]
))
});
}
class ut extends Error {
constructor(t, i) {
super(typeof t == "string" ? t : ""), ot(this, "name", "FormError"), ot(this, "errors"), this.errors = typeof t == "string" ? i || {} : t;
}
}
function Pi({
of: e,
onSubmit: t,
responseDuration: i,
keepResponse: r,
shouldActive: n,
shouldTouched: o,
shouldDirty: u,
shouldFocus: a,
...f
}) {
return _("form", {
noValidate: !0,
...f,
ref: (l) => e.element.value = l,
onSubmit: async (l) => {
l.preventDefault(), L(() => {
r || (e.response.value = {}), e.submitCount.value++, e.submitted.value = !0, e.submitting.value = !0;
});
const c = {
duration: i,
shouldActive: n,
shouldTouched: o,
shouldDirty: u,
shouldFocus: a
};
try {
await Ht(e, c) && await t(Ut(e, c), l);
} catch (s) {
L(() => {
s instanceof ut && Object.entries(s.errors).forEach(([h, d]) => {
d && Tt(e, h, d, {
...c,
shouldFocus: !1
});
}), (!(s instanceof ut) || s.message) && Ni(e, {
status: "error",
message: (s == null ? void 0 : s.message) || "An unknown error has occurred."
}, c);
});
} finally {
e.submitting.value = !1;
}
}
});
}
function Lt(e, {
on: t
}) {
return (i, r) => r.type === t ? e(i, r) : i;
}
function U(e) {
return Lt((t) => t && t.trim(), e);
}
function at(e) {
return Lt((t) => t && t.toUpperCase(), e);
}
function lt(e, t) {
return (i) => i && !e.test(i) ? t : "";
}
function G(e) {
return (t) => !t && t !== 0 || Array.isArray(t) && !t.length ? e : "";
}
function A({
children: e,
of: t
}) {
var n, o;
const r = ((o = (n = W().className) == null ? void 0 : n.field) == null ? void 0 : o.call(n, {
name: t.name,
touched: t.touched.value,
dirty: t.dirty.value,
valid: !t.error.value
})) || "";
return _("div", {
className: `GigsEmbeds GigsPortingEmbed GigsEmbeds-field ${r}`,
children: e
});
}
function F({
of: e
}) {
var n, o;
const i = ((o = (n = W().className) == null ? void 0 : n.error) == null ? void 0 : o.call(n, {
name: e.name,
touched: e.touched.value,
dirty: e.dirty.value
})) || "", r = e.error.value;
return r ? _("div", {
className: `GigsEmbeds GigsPortingEmbed GigsEmbeds-error ${i}`,
children: r
}) : null;
}
function C({
of: e,
...t
}) {
var o, u;
const r = ((u = (o = W().className) == null ? void 0 : o.input) == null ? void 0 : u.call(o, {
name: e.name,
touched: e.touched.value,
dirty: e.dirty.value,
valid: !e.error.value
})) || "", n = `__ge_${e.name}`;
return _("input", {
className: `GigsEmbeds GigsPortingEmbed GigsEmbeds-input ${r}`,
id: n,
...t
});
}
function D({
of: e,
...t
}) {
var o, u;
const r = ((u = (o = W().className) == null ? void 0 : o.label) == null ? void 0 : u.call(o, {
name: e.name,
touched: e.touched.value,
dirty: e.dirty.value,
valid: !e.error.value
})) || "", n = `__ge_${e.name}`;
return _("label", {
htmlFor: n,
className: `GigsEmbeds GigsPortingEmbed GigsEmbeds-label ${r}`,
...t
});
}
function $i({
porting: e,
onValidationChange: t,
onSubmit: i
}) {
var f, l, c, s, h, d, p, y;
const r = W(), [n, {
Form: o,
Field: u
}] = ke({
initialValues: {
line1: ((f = e.address) == null ? void 0 : f.line1) ?? "",
line2: ((l = e.address) == null ? void 0 : l.line2) ?? null,
city: ((c = e.address) == null ? void 0 : c.city) ?? "",
postalCode: ((s = e.address) == null ? void 0 : s.postalCode) ?? "",
state: (h = e.address) == null ? void 0 : h.state,
country: ((d = e.address) == null ? void 0 : d.country) ?? ""
},
validateOn: "blur"
}), a = ((y = (p = r.className) == null ? void 0 : p.form) == null ? void 0 : y.call(p, {
name: "address",
dirty: n.dirty.value,
valid: !n.invalid.value,
submitting: n.submitting.value,
touched: n.touched.value
})) || "";
return ge(() => {
const v = !n.invalid.value;
t == null || t({
isValid: v
});
}), _(o, {
id: r.formId || me,
role: "form",
className: `GigsEmbeds GigsPortingEmbed GigsEmbeds-form ${a}`,
onSubmit: (v) => {
const m = {
...v,
line2: v.line2 || null,
state: v.state || null
};
return i(m);
},
children: [_(u, {
name: "line1",
validate: [G(r.text["field.line1.error.required"])],
transform: U({
on: "input"
}),
children: (v, m) => _(A, {
of: v,
children: [_(D, {
of: v,
children: r.text["field.line1.label"]
}), _(C, {
...m,
of: v,
type: "text",
value: v.value,
required: !0
}), _(F, {
of: v
})]
})
}), _(u, {
name: "line2",
transform: U({
on: "input"
}),
children: (v, m) => _(A, {
of: v,
children: [_(D, {
of: v,
children: r.text["field.line2.label"]
}), _(C, {
...m,
of: v,
type: "text",
value: v.value.value || ""
}), _(F, {
of: v
})]
})
}), _(u, {
name: "city",
validate: [G(r.text["field.city.error.required"])],
transform: U({
on: "input"
}),
children: (v, m) => _(A, {
of: v,
children: [_(D, {
of: v,
children: r.text["field.city.label"]
}), _(C, {
...m,
of: v,
type: "text",
value: v.value,
required: !0
}), _(F, {
of: v
})]
})
}), _(u, {
name: "postalCode",
validate: [G(r.text["field.postalCode.error.required"])],
transform: U({
on: "input"
}),
children: (v, m) => _(A, {
of: v,
children: [_(D, {
of: v,
children: r.text["field.postalCode.label"]
}), _(C, {
...m,
of: v,
type: "text",
value: v.value,
required: !0
}), _(F, {
of: v
})]
})
}), _(u, {
name: "state",
validate: lt(/^[A-Z]{1,3}(-[A-Z0-9]{1,3})?$/, r.text["field.state.error.format"]),