function noop() { } function assign(tar, src) { for (const k in src) tar[k] = src[k]; return tar; } function is_promise(value) { return value && typeof value === "object" && typeof value.then === "function"; } function run(fn) { return fn(); } function blank_object() { return /* @__PURE__ */ Object.create(null); } function run_all(fns) { fns.forEach(run); } function is_function(thing) { return typeof thing === "function"; } function safe_not_equal(a, b) { return a != a ? b == b : a !== b || (a && typeof a === "object" || typeof a === "function"); } function is_empty(obj) { return Object.keys(obj).length === 0; } function null_to_empty(value) { return value == null ? "" : value; } let is_hydrating = false; function start_hydrating() { is_hydrating = true; } function end_hydrating() { is_hydrating = false; } function upper_bound(low, high, key, value) { while (low < high) { const mid = low + (high - low >> 1); if (key(mid) <= value) { low = mid + 1; } else { high = mid; } } return low; } function init_hydrate(target) { if (target.hydrate_init) return; target.hydrate_init = true; const children2 = target.childNodes; const m = new Int32Array(children2.length + 1); const p = new Int32Array(children2.length); m[0] = -1; let longest = 0; for (let i = 0; i < children2.length; i++) { const current = children2[i].claim_order; const seqLen = upper_bound(1, longest + 1, (idx) => children2[m[idx]].claim_order, current) - 1; p[i] = m[seqLen] + 1; const newLen = seqLen + 1; m[newLen] = i; longest = Math.max(newLen, longest); } const lis = []; const toMove = []; let last = children2.length - 1; for (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) { lis.push(children2[cur - 1]); for (; last >= cur; last--) { toMove.push(children2[last]); } last--; } for (; last >= 0; last--) { toMove.push(children2[last]); } lis.reverse(); toMove.sort((a, b) => a.claim_order - b.claim_order); for (let i = 0, j = 0; i < toMove.length; i++) { while (j < lis.length && toMove[i].claim_order >= lis[j].claim_order) { j++; } const anchor = j < lis.length ? lis[j] : null; target.insertBefore(toMove[i], anchor); } } function append(target, node) { if (is_hydrating) { init_hydrate(target); if (target.actual_end_child === void 0 || target.actual_end_child !== null && target.actual_end_child.parentElement !== target) { target.actual_end_child = target.firstChild; } if (node !== target.actual_end_child) { target.insertBefore(node, target.actual_end_child); } else { target.actual_end_child = node.nextSibling; } } else if (node.parentNode !== target) { target.appendChild(node); } } function insert(target, node, anchor) { if (is_hydrating && !anchor) { append(target, node); } else if (node.parentNode !== target || node.nextSibling != anchor) { target.insertBefore(node, anchor || null); } } function detach(node) { node.parentNode.removeChild(node); } function element(name) { return document.createElement(name); } function text(data) { return document.createTextNode(data); } function space() { return text(" "); } function empty() { return text(""); } function listen(node, event, handler, options) { node.addEventListener(event, handler, options); return () => node.removeEventListener(event, handler, options); } function attr(node, attribute, value) { if (value == null) node.removeAttribute(attribute); else if (node.getAttribute(attribute) !== value) node.setAttribute(attribute, value); } function children(element2) { return Array.from(element2.childNodes); } function set_data(text2, data) { data = "" + data; if (text2.wholeText !== data) text2.data = data; } function set_style(node, key, value, important) { node.style.setProperty(key, value, important ? "important" : ""); } let current_component; function set_current_component(component) { current_component = component; } function get_current_component() { if (!current_component) throw new Error("Function called outside component initialization"); return current_component; } function onMount(fn) { get_current_component().$$.on_mount.push(fn); } const dirty_components = []; const binding_callbacks = []; const render_callbacks = []; const flush_callbacks = []; const resolved_promise = Promise.resolve(); let update_scheduled = false; function schedule_update() { if (!update_scheduled) { update_scheduled = true; resolved_promise.then(flush); } } function add_render_callback(fn) { render_callbacks.push(fn); } let flushing = false; const seen_callbacks = /* @__PURE__ */ new Set(); function flush() { if (flushing) return; flushing = true; do { for (let i = 0; i < dirty_components.length; i += 1) { const component = dirty_components[i]; set_current_component(component); update(component.$$); } set_current_component(null); dirty_components.length = 0; while (binding_callbacks.length) binding_callbacks.pop()(); for (let i = 0; i < render_callbacks.length; i += 1) { const callback = render_callbacks[i]; if (!seen_callbacks.has(callback)) { seen_callbacks.add(callback); callback(); } } render_callbacks.length = 0; } while (dirty_components.length); while (flush_callbacks.length) { flush_callbacks.pop()(); } update_scheduled = false; flushing = false; seen_callbacks.clear(); } function update($$) { if ($$.fragment !== null) { $$.update(); run_all($$.before_update); const dirty = $$.dirty; $$.dirty = [-1]; $$.fragment && $$.fragment.p($$.ctx, dirty); $$.after_update.forEach(add_render_callback); } } const outroing = /* @__PURE__ */ new Set(); let outros; function group_outros() { outros = { r: 0, c: [], p: outros }; } function check_outros() { if (!outros.r) { run_all(outros.c); } outros = outros.p; } function transition_in(block, local) { if (block && block.i) { outroing.delete(block); block.i(local); } } function transition_out(block, local, detach2, callback) { if (block && block.o) { if (outroing.has(block)) return; outroing.add(block); outros.c.push(() => { outroing.delete(block); if (callback) { if (detach2) block.d(1); callback(); } }); block.o(local); } } function handle_promise(promise, info) { const token = info.token = {}; function update2(type, index, key, value) { if (info.token !== token) return; info.resolved = value; let child_ctx = info.ctx; if (key !== void 0) { child_ctx = child_ctx.slice(); child_ctx[key] = value; } const block = type && (info.current = type)(child_ctx); let needs_flush = false; if (info.block) { if (info.blocks) { info.blocks.forEach((block2, i) => { if (i !== index && block2) { group_outros(); transition_out(block2, 1, 1, () => { if (info.blocks[i] === block2) { info.blocks[i] = null; } }); check_outros(); } }); } else { info.block.d(1); } block.c(); transition_in(block, 1); block.m(info.mount(), info.anchor); needs_flush = true; } info.block = block; if (info.blocks) info.blocks[index] = block; if (needs_flush) { flush(); } } if (is_promise(promise)) { const current_component2 = get_current_component(); promise.then((value) => { set_current_component(current_component2); update2(info.then, 1, info.value, value); set_current_component(null); }, (error) => { set_current_component(current_component2); update2(info.catch, 2, info.error, error); set_current_component(null); if (!info.hasCatch) { throw error; } }); if (info.current !== info.pending) { update2(info.pending, 0); return true; } } else { if (info.current !== info.then) { update2(info.then, 1, info.value, promise); return true; } info.resolved = promise; } } function update_await_block_branch(info, ctx, dirty) { const child_ctx = ctx.slice(); const { resolved } = info; if (info.current === info.then) { child_ctx[info.value] = resolved; } if (info.current === info.catch) { child_ctx[info.error] = resolved; } info.block.p(child_ctx, dirty); } const globals = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : global; function get_spread_update(levels, updates) { const update2 = {}; const to_null_out = {}; const accounted_for = { $$scope: 1 }; let i = levels.length; while (i--) { const o = levels[i]; const n = updates[i]; if (n) { for (const key in o) { if (!(key in n)) to_null_out[key] = 1; } for (const key in n) { if (!accounted_for[key]) { update2[key] = n[key]; accounted_for[key] = 1; } } levels[i] = n; } else { for (const key in o) { accounted_for[key] = 1; } } } for (const key in to_null_out) { if (!(key in update2)) update2[key] = void 0; } return update2; } function get_spread_object(spread_props) { return typeof spread_props === "object" && spread_props !== null ? spread_props : {}; } function create_component(block) { block && block.c(); } function mount_component(component, target, anchor, customElement) { const { fragment, on_mount, on_destroy, after_update } = component.$$; fragment && fragment.m(target, anchor); if (!customElement) { add_render_callback(() => { const new_on_destroy = on_mount.map(run).filter(is_function); if (on_destroy) { on_destroy.push(...new_on_destroy); } else { run_all(new_on_destroy); } component.$$.on_mount = []; }); } after_update.forEach(add_render_callback); } function destroy_component(component, detaching) { const $$ = component.$$; if ($$.fragment !== null) { run_all($$.on_destroy); $$.fragment && $$.fragment.d(detaching); $$.on_destroy = $$.fragment = null; $$.ctx = []; } } function make_dirty(component, i) { if (component.$$.dirty[0] === -1) { dirty_components.push(component); schedule_update(); component.$$.dirty.fill(0); } component.$$.dirty[i / 31 | 0] |= 1 << i % 31; } function init(component, options, instance2, create_fragment2, not_equal, props, dirty = [-1]) { const parent_component = current_component; set_current_component(component); const $$ = component.$$ = { fragment: null, ctx: null, props, update: noop, not_equal, bound: blank_object(), on_mount: [], on_destroy: [], on_disconnect: [], before_update: [], after_update: [], context: new Map(parent_component ? parent_component.$$.context : options.context || []), callbacks: blank_object(), dirty, skip_bound: false }; let ready = false; $$.ctx = instance2 ? instance2(component, options.props || {}, (i, ret, ...rest) => { const value = rest.length ? rest[0] : ret; if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) { if (!$$.skip_bound && $$.bound[i]) $$.bound[i](value); if (ready) make_dirty(component, i); } return ret; }) : []; $$.update(); ready = true; run_all($$.before_update); $$.fragment = create_fragment2 ? create_fragment2($$.ctx) : false; if (options.target) { if (options.hydrate) { start_hydrating(); const nodes = children(options.target); $$.fragment && $$.fragment.l(nodes); nodes.forEach(detach); } else { $$.fragment && $$.fragment.c(); } if (options.intro) transition_in(component.$$.fragment); mount_component(component, options.target, options.anchor, options.customElement); end_hydrating(); flush(); } set_current_component(parent_component); } class SvelteComponent { $destroy() { destroy_component(this, 1); this.$destroy = noop; } $on(type, callback) { const callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []); callbacks.push(callback); return () => { const index = callbacks.indexOf(callback); if (index !== -1) callbacks.splice(index, 1); }; } $set($$props) { if (this.$$set && !is_empty($$props)) { this.$$.skip_bound = true; this.$$set($$props); this.$$.skip_bound = false; } } } function create_if_block_1(ctx) { let await_block_anchor; let current; let info = { ctx, current: null, token: null, hasCatch: false, pending: create_pending_block_1, then: create_then_block_1, catch: create_catch_block_1, value: 7, blocks: [, , ,] }; handle_promise(ctx[3].qrCodeWidget(), info); return { c() { await_block_anchor = empty(); info.block.c(); }, m(target, anchor) { insert(target, await_block_anchor, anchor); info.block.m(target, info.anchor = anchor); info.mount = () => await_block_anchor.parentNode; info.anchor = await_block_anchor; current = true; }, p(new_ctx, dirty) { ctx = new_ctx; update_await_block_branch(info, ctx, dirty); }, i(local) { if (current) return; transition_in(info.block); current = true; }, o(local) { for (let i = 0; i < 3; i += 1) { const block = info.blocks[i]; transition_out(block); } current = false; }, d(detaching) { if (detaching) detach(await_block_anchor); info.block.d(detaching); info.token = null; info = null; } }; } function create_catch_block_1(ctx) { return { c: noop, m: noop, p: noop, i: noop, o: noop, d: noop }; } function create_then_block_1(ctx) { let switch_instance; let switch_instance_anchor; let current; const switch_instance_spread_levels = [ ctx[2].qrCode, { appId: ctx[0] }, { environment: ctx[1] } ]; var switch_value = ctx[7].default; function switch_props(ctx2) { let switch_instance_props = {}; for (let i = 0; i < switch_instance_spread_levels.length; i += 1) { switch_instance_props = assign(switch_instance_props, switch_instance_spread_levels[i]); } return { props: switch_instance_props }; } if (switch_value) { switch_instance = new switch_value(switch_props()); } return { c() { if (switch_instance) create_component(switch_instance.$$.fragment); switch_instance_anchor = empty(); }, m(target, anchor) { if (switch_instance) { mount_component(switch_instance, target, anchor); } insert(target, switch_instance_anchor, anchor); current = true; }, p(ctx2, dirty) { const switch_instance_changes = dirty & 7 ? get_spread_update(switch_instance_spread_levels, [ dirty & 4 && get_spread_object(ctx2[2].qrCode), dirty & 1 && { appId: ctx2[0] }, dirty & 2 && { environment: ctx2[1] } ]) : {}; if (switch_value !== (switch_value = ctx2[7].default)) { if (switch_instance) { group_outros(); const old_component = switch_instance; transition_out(old_component.$$.fragment, 1, 0, () => { destroy_component(old_component, 1); }); check_outros(); } if (switch_value) { switch_instance = new switch_value(switch_props()); create_component(switch_instance.$$.fragment); transition_in(switch_instance.$$.fragment, 1); mount_component(switch_instance, switch_instance_anchor.parentNode, switch_instance_anchor); } else { switch_instance = null; } } else if (switch_value) { switch_instance.$set(switch_instance_changes); } }, i(local) { if (current) return; if (switch_instance) transition_in(switch_instance.$$.fragment, local); current = true; }, o(local) { if (switch_instance) transition_out(switch_instance.$$.fragment, local); current = false; }, d(detaching) { if (detaching) detach(switch_instance_anchor); if (switch_instance) destroy_component(switch_instance, detaching); } }; } function create_pending_block_1(ctx) { return { c: noop, m: noop, p: noop, i: noop, o: noop, d: noop }; } function create_if_block(ctx) { let await_block_anchor; let current; let info = { ctx, current: null, token: null, hasCatch: false, pending: create_pending_block, then: create_then_block, catch: create_catch_block, value: 6, blocks: [, , ,] }; handle_promise(ctx[3].mobileDownloadBannerWidget(), info); return { c() { await_block_anchor = empty(); info.block.c(); }, m(target, anchor) { insert(target, await_block_anchor, anchor); info.block.m(target, info.anchor = anchor); info.mount = () => await_block_anchor.parentNode; info.anchor = await_block_anchor; current = true; }, p(new_ctx, dirty) { ctx = new_ctx; update_await_block_branch(info, ctx, dirty); }, i(local) { if (current) return; transition_in(info.block); current = true; }, o(local) { for (let i = 0; i < 3; i += 1) { const block = info.blocks[i]; transition_out(block); } current = false; }, d(detaching) { if (detaching) detach(await_block_anchor); info.block.d(detaching); info.token = null; info = null; } }; } function create_catch_block(ctx) { return { c: noop, m: noop, p: noop, i: noop, o: noop, d: noop }; } function create_then_block(ctx) { let switch_instance; let switch_instance_anchor; let current; const switch_instance_spread_levels = [ ctx[2].mobileDownloadBanner, { appId: ctx[0] }, { environment: ctx[1] } ]; var switch_value = ctx[6].default; function switch_props(ctx2) { let switch_instance_props = {}; for (let i = 0; i < switch_instance_spread_levels.length; i += 1) { switch_instance_props = assign(switch_instance_props, switch_instance_spread_levels[i]); } return { props: switch_instance_props }; } if (switch_value) { switch_instance = new switch_value(switch_props()); } return { c() { if (switch_instance) create_component(switch_instance.$$.fragment); switch_instance_anchor = empty(); }, m(target, anchor) { if (switch_instance) { mount_component(switch_instance, target, anchor); } insert(target, switch_instance_anchor, anchor); current = true; }, p(ctx2, dirty) { const switch_instance_changes = dirty & 7 ? get_spread_update(switch_instance_spread_levels, [ dirty & 4 && get_spread_object(ctx2[2].mobileDownloadBanner), dirty & 1 && { appId: ctx2[0] }, dirty & 2 && { environment: ctx2[1] } ]) : {}; if (switch_value !== (switch_value = ctx2[6].default)) { if (switch_instance) { group_outros(); const old_component = switch_instance; transition_out(old_component.$$.fragment, 1, 0, () => { destroy_component(old_component, 1); }); check_outros(); } if (switch_value) { switch_instance = new switch_value(switch_props()); create_component(switch_instance.$$.fragment); transition_in(switch_instance.$$.fragment, 1); mount_component(switch_instance, switch_instance_anchor.parentNode, switch_instance_anchor); } else { switch_instance = null; } } else if (switch_value) { switch_instance.$set(switch_instance_changes); } }, i(local) { if (current) return; if (switch_instance) transition_in(switch_instance.$$.fragment, local); current = true; }, o(local) { if (switch_instance) transition_out(switch_instance.$$.fragment, local); current = false; }, d(detaching) { if (detaching) detach(switch_instance_anchor); if (switch_instance) destroy_component(switch_instance, detaching); } }; } function create_pending_block(ctx) { return { c: noop, m: noop, p: noop, i: noop, o: noop, d: noop }; } function create_fragment(ctx) { let t; let if_block1_anchor; let current; let if_block0 = ctx[2] && ctx[2].qrCode.enabled && create_if_block_1(ctx); let if_block1 = ctx[2] && ctx[2].mobileDownloadBanner.enabled && create_if_block(ctx); return { c() { if (if_block0) if_block0.c(); t = space(); if (if_block1) if_block1.c(); if_block1_anchor = empty(); }, m(target, anchor) { if (if_block0) if_block0.m(target, anchor); insert(target, t, anchor); if (if_block1) if_block1.m(target, anchor); insert(target, if_block1_anchor, anchor); current = true; }, p(ctx2, [dirty]) { if (ctx2[2] && ctx2[2].qrCode.enabled) { if (if_block0) { if_block0.p(ctx2, dirty); if (dirty & 4) { transition_in(if_block0, 1); } } else { if_block0 = create_if_block_1(ctx2); if_block0.c(); transition_in(if_block0, 1); if_block0.m(t.parentNode, t); } } else if (if_block0) { group_outros(); transition_out(if_block0, 1, 1, () => { if_block0 = null; }); check_outros(); } if (ctx2[2] && ctx2[2].mobileDownloadBanner.enabled) { if (if_block1) { if_block1.p(ctx2, dirty); if (dirty & 4) { transition_in(if_block1, 1); } } else { if_block1 = create_if_block(ctx2); if_block1.c(); transition_in(if_block1, 1); if_block1.m(if_block1_anchor.parentNode, if_block1_anchor); } } else if (if_block1) { group_outros(); transition_out(if_block1, 1, 1, () => { if_block1 = null; }); check_outros(); } }, i(local) { if (current) return; transition_in(if_block0); transition_in(if_block1); current = true; }, o(local) { transition_out(if_block0); transition_out(if_block1); current = false; }, d(detaching) { if (if_block0) if_block0.d(detaching); if (detaching) detach(t); if (if_block1) if_block1.d(detaching); if (detaching) detach(if_block1_anchor); } }; } function instance($$self, $$props, $$invalidate) { let { shopStore = "" } = $$props; let { appId = "" } = $$props; let { environment = "production" } = $$props; let settings; const widgetImports = { qrCodeWidget: () => import("./QRCodeWidget.js"), mobileDownloadBannerWidget: () => import("./MobileDownloadBanner.js") }; const getApiBaseUrl = (environment2) => { if (environment2 === "staging" || environment2 === "local") { return "https://api.tapc.fans"; } return "https://api.tapc.art"; }; onMount(async () => { const captureKitAPIBaseUrl = getApiBaseUrl(environment); const captureKitSettingsPath = `${captureKitAPIBaseUrl}/capture-kit/?shopStore=${shopStore}&appId=${appId}`; let response = await fetch(captureKitSettingsPath); if (response.ok) { const res = await response.json(); $$invalidate(2, settings = res); } }); $$self.$$set = ($$props2) => { if ("shopStore" in $$props2) $$invalidate(4, shopStore = $$props2.shopStore); if ("appId" in $$props2) $$invalidate(0, appId = $$props2.appId); if ("environment" in $$props2) $$invalidate(1, environment = $$props2.environment); }; return [appId, environment, settings, widgetImports, shopStore]; } class Fetch extends SvelteComponent { constructor(options) { super(); init(this, options, instance, create_fragment, safe_not_equal, { shopStore: 4, appId: 0, environment: 1 }); } } const params = window["tapcartParams"] || {}; new Fetch({ target: document.body, props: { shopStore: params.shopStore, appId: params.appId, environment: params.environment } }); export { SvelteComponent as S, append as a, add_render_callback as b, space as c, attr as d, element as e, set_style as f, insert as g, detach as h, init as i, set_data as j, empty as k, listen as l, globals as m, noop as n, onMount as o, binding_callbacks as p, null_to_empty as q, run_all as r, safe_not_equal as s, text as t };