From f92f73f8d288266c85862cd274fb09b0e9e5125c Mon Sep 17 00:00:00 2001 From: corbanbrook Date: Mon, 13 May 2024 15:43:23 +0000 Subject: [PATCH] Build: (3c76aa5) Linting examples (#46) --- ...owser-external_commonjs-proxy-DkHUugHh.js} | 2 +- assets/{ccip-B6W3FZRX.js => ccip-DN2Ajsz4.js} | 2 +- .../{index-DYhvDNQV.js => index-ChNvmUDN.js} | 22708 ++++++++-------- .../{index-C-TzBlls.js => index-CkPH4BBJ.js} | 4 +- .../{index-HXyKrRYH.js => index-D0xnVYlY.js} | 4 +- .../{index-CCfamuWQ.js => index-DRpgmzbP.js} | 6 +- ...ex.es-CYNju8ul.js => index.es-ODknoF3v.js} | 8 +- index.html | 2 +- 8 files changed, 11360 insertions(+), 11376 deletions(-) rename assets/{___vite-browser-external_commonjs-proxy-DAAlPToO.js => ___vite-browser-external_commonjs-proxy-DkHUugHh.js} (99%) rename assets/{ccip-B6W3FZRX.js => ccip-DN2Ajsz4.js} (99%) rename assets/{index-DYhvDNQV.js => index-ChNvmUDN.js} (99%) rename assets/{index-C-TzBlls.js => index-CkPH4BBJ.js} (99%) rename assets/{index-HXyKrRYH.js => index-D0xnVYlY.js} (99%) rename assets/{index-CCfamuWQ.js => index-DRpgmzbP.js} (99%) rename assets/{index.es-CYNju8ul.js => index.es-ODknoF3v.js} (99%) diff --git a/assets/___vite-browser-external_commonjs-proxy-DAAlPToO.js b/assets/___vite-browser-external_commonjs-proxy-DkHUugHh.js similarity index 99% rename from assets/___vite-browser-external_commonjs-proxy-DAAlPToO.js rename to assets/___vite-browser-external_commonjs-proxy-DkHUugHh.js index 0ba584f2..16d87b1a 100644 --- a/assets/___vite-browser-external_commonjs-proxy-DAAlPToO.js +++ b/assets/___vite-browser-external_commonjs-proxy-DkHUugHh.js @@ -1,4 +1,4 @@ -import { b as getDefaultExportFromCjs, a as getAugmentedNamespace } from "./index-DYhvDNQV.js"; +import { b as getDefaultExportFromCjs, a as getAugmentedNamespace } from "./index-ChNvmUDN.js"; var events = { exports: {} }; var R = typeof Reflect === "object" ? Reflect : null; var ReflectApply = R && typeof R.apply === "function" ? R.apply : function ReflectApply2(target, receiver, args) { diff --git a/assets/ccip-B6W3FZRX.js b/assets/ccip-DN2Ajsz4.js similarity index 99% rename from assets/ccip-B6W3FZRX.js rename to assets/ccip-DN2Ajsz4.js index 3c2fd549..8bd46979 100644 --- a/assets/ccip-B6W3FZRX.js +++ b/assets/ccip-DN2Ajsz4.js @@ -1,4 +1,4 @@ -import { h as BaseError, j as getUrl, s as stringify, k as isAddress, I as InvalidAddressError, l as decodeErrorResult, m as call, n as concat, o as encodeAbiParameters, H as HttpRequestError, q as isHex } from "./index-DYhvDNQV.js"; +import { h as BaseError, j as getUrl, s as stringify, k as isAddress, I as InvalidAddressError, l as decodeErrorResult, m as call, n as concat, o as encodeAbiParameters, H as HttpRequestError, q as isHex } from "./index-ChNvmUDN.js"; class OffchainLookupError extends BaseError { constructor({ callbackSelector, cause, data, extraData, sender, urls }) { var _a; diff --git a/assets/index-DYhvDNQV.js b/assets/index-ChNvmUDN.js similarity index 99% rename from assets/index-DYhvDNQV.js rename to assets/index-ChNvmUDN.js index 92e8d7b5..d3a8a9e3 100644 --- a/assets/index-DYhvDNQV.js +++ b/assets/index-ChNvmUDN.js @@ -1,4 +1,4 @@ -const __vite__fileDeps=["./index-C-TzBlls.js","./___vite-browser-external_commonjs-proxy-DAAlPToO.js","./index.es-CYNju8ul.js"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]); +const __vite__fileDeps=["./index-CkPH4BBJ.js","./___vite-browser-external_commonjs-proxy-DkHUugHh.js","./index.es-ODknoF3v.js"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]); var __defProp = Object.defineProperty; var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value; var __publicField = (obj, key2, value) => { @@ -71826,7 +71826,7 @@ async function call(client2, args) { return { data: response }; } catch (err) { const data2 = getRevertErrorData(err); - const { offchainLookup, offchainLookupSignature } = await __vitePreload(() => import("./ccip-B6W3FZRX.js"), true ? [] : void 0, import.meta.url); + const { offchainLookup, offchainLookupSignature } = await __vitePreload(() => import("./ccip-DN2Ajsz4.js"), true ? [] : void 0, import.meta.url); if (client2.ccipRead !== false && (data2 == null ? void 0 : data2.slice(0, 10)) === offchainLookupSignature && to) return { data: await offchainLookup(client2, { data: data2, to }) }; throw getCallError(err, { @@ -84818,8989 +84818,8561 @@ const KitProvider = (props) => { marginTop: "1" }, /* @__PURE__ */ React.createElement(SequenceLogo$1, null)))))))), children)))))); }; -var __defProp2 = Object.defineProperty; -var __getOwnPropSymbols = Object.getOwnPropertySymbols; -var __hasOwnProp = Object.prototype.hasOwnProperty; -var __propIsEnum = Object.prototype.propertyIsEnumerable; -var __defNormalProp2 = (obj, key2, value) => key2 in obj ? __defProp2(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value; -var __spreadValues = (a2, b2) => { - for (var prop in b2 || (b2 = {})) - if (__hasOwnProp.call(b2, prop)) - __defNormalProp2(a2, prop, b2[prop]); - if (__getOwnPropSymbols) - for (var prop of __getOwnPropSymbols(b2)) { - if (__propIsEnum.call(b2, prop)) - __defNormalProp2(a2, prop, b2[prop]); - } - return a2; -}; -var __objRest = (source, exclude) => { - var target = {}; - for (var prop in source) - if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) - target[prop] = source[prop]; - if (source != null && __getOwnPropSymbols) - for (var prop of __getOwnPropSymbols(source)) { - if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) - target[prop] = source[prop]; - } - return target; +const [useCheckoutModalContext, CheckoutModalContextProvider] = createGenericContext$1(); +const useCheckoutModal = () => { + const { + triggerCheckout, + closeCheckout, + settings + } = useCheckoutModalContext(); + return { + triggerCheckout, + closeCheckout, + settings + }; }; -/** - * @license QR Code generator library (TypeScript) - * Copyright (c) Project Nayuki. - * SPDX-License-Identifier: MIT - */ -var qrcodegen; -((qrcodegen2) => { - const _QrCode = class { - constructor(version2, errorCorrectionLevel, dataCodewords, msk) { - this.version = version2; - this.errorCorrectionLevel = errorCorrectionLevel; - this.modules = []; - this.isFunction = []; - if (version2 < _QrCode.MIN_VERSION || version2 > _QrCode.MAX_VERSION) - throw new RangeError("Version value out of range"); - if (msk < -1 || msk > 7) - throw new RangeError("Mask value out of range"); - this.size = version2 * 4 + 17; - let row = []; - for (let i2 = 0; i2 < this.size; i2++) - row.push(false); - for (let i2 = 0; i2 < this.size; i2++) { - this.modules.push(row.slice()); - this.isFunction.push(row.slice()); - } - this.drawFunctionPatterns(); - const allCodewords = this.addEccAndInterleave(dataCodewords); - this.drawCodewords(allCodewords); - if (msk == -1) { - let minPenalty = 1e9; - for (let i2 = 0; i2 < 8; i2++) { - this.applyMask(i2); - this.drawFormatBits(i2); - const penalty = this.getPenaltyScore(); - if (penalty < minPenalty) { - msk = i2; - minPenalty = penalty; - } - this.applyMask(i2); +const [useNavigationContext$1, NavigationContextProvider$1] = createGenericContext$1(); +function _extends$4() { + _extends$4 = Object.assign ? Object.assign.bind() : function(target) { + for (var i2 = 1; i2 < arguments.length; i2++) { + var source = arguments[i2]; + for (var key2 in source) { + if (Object.prototype.hasOwnProperty.call(source, key2)) { + target[key2] = source[key2]; } } - assert2(0 <= msk && msk <= 7); - this.mask = msk; - this.applyMask(msk); - this.drawFormatBits(msk); - this.isFunction = []; - } - static encodeText(text2, ecl) { - const segs = qrcodegen2.QrSegment.makeSegments(text2); - return _QrCode.encodeSegments(segs, ecl); } - static encodeBinary(data, ecl) { - const seg = qrcodegen2.QrSegment.makeBytes(data); - return _QrCode.encodeSegments([seg], ecl); + return target; + }; + return _extends$4.apply(this, arguments); +} +const HEADER_HEIGHT$1 = "54px"; +const NavigationHeader$1 = ({ + secondaryText, + primaryText, + disableBack: _disableBack = false +}) => { + const { + goBack, + history + } = useNavigation$1(); + const onClickBack = () => { + goBack(); + }; + return /* @__PURE__ */ React.createElement(Box, { + background: "backgroundPrimary", + zIndex: "20", + position: "fixed", + width: "full", + flexDirection: "row", + alignItems: "center", + justifyContent: "space-between", + style: { + height: HEADER_HEIGHT$1, + paddingTop: "6px", + backgroundColor: vars.colors.backgroundPrimary } - static encodeSegments(segs, ecl, minVersion = 1, maxVersion = 40, mask = -1, boostEcl = true) { - if (!(_QrCode.MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= _QrCode.MAX_VERSION) || mask < -1 || mask > 7) - throw new RangeError("Invalid value"); - let version2; - let dataUsedBits; - for (version2 = minVersion; ; version2++) { - const dataCapacityBits2 = _QrCode.getNumDataCodewords(version2, ecl) * 8; - const usedBits = QrSegment.getTotalBits(segs, version2); - if (usedBits <= dataCapacityBits2) { - dataUsedBits = usedBits; - break; - } - if (version2 >= maxVersion) - throw new RangeError("Data too long"); - } - for (const newEcl of [_QrCode.Ecc.MEDIUM, _QrCode.Ecc.QUARTILE, _QrCode.Ecc.HIGH]) { - if (boostEcl && dataUsedBits <= _QrCode.getNumDataCodewords(version2, newEcl) * 8) - ecl = newEcl; - } - let bb2 = []; - for (const seg of segs) { - appendBits(seg.mode.modeBits, 4, bb2); - appendBits(seg.numChars, seg.mode.numCharCountBits(version2), bb2); - for (const b2 of seg.getData()) - bb2.push(b2); - } - assert2(bb2.length == dataUsedBits); - const dataCapacityBits = _QrCode.getNumDataCodewords(version2, ecl) * 8; - assert2(bb2.length <= dataCapacityBits); - appendBits(0, Math.min(4, dataCapacityBits - bb2.length), bb2); - appendBits(0, (8 - bb2.length % 8) % 8, bb2); - assert2(bb2.length % 8 == 0); - for (let padByte = 236; bb2.length < dataCapacityBits; padByte ^= 236 ^ 17) - appendBits(padByte, 8, bb2); - let dataCodewords = []; - while (dataCodewords.length * 8 < bb2.length) - dataCodewords.push(0); - bb2.forEach((b2, i2) => dataCodewords[i2 >>> 3] |= b2 << 7 - (i2 & 7)); - return new _QrCode(version2, ecl, dataCodewords, mask); + }, history.length > 0 && !_disableBack ? /* @__PURE__ */ React.createElement(IconButton, { + onClick: onClickBack, + icon: SvgChevronLeftIcon, + size: "sm", + style: { + background: "rgba(0,0,0,0)", + width: "44px" } - getModule(x, y2) { - return 0 <= x && x < this.size && 0 <= y2 && y2 < this.size && this.modules[y2][x]; + }) : /* @__PURE__ */ React.createElement(Box, null), /* @__PURE__ */ React.createElement(Box, { + width: "full", + alignItems: "center", + justifyContent: "center", + style: { + marginLeft: "40px" } - getModules() { - return this.modules; + }, /* @__PURE__ */ React.createElement(Text, { + fontWeight: "medium", + variant: "small", + color: "text50" + }, secondaryText), /* @__PURE__ */ React.createElement(Text, { + fontWeight: "medium", + variant: "small", + color: "text100" + }, primaryText)), /* @__PURE__ */ React.createElement(Box, { + style: { + width: "44px" } - drawFunctionPatterns() { - for (let i2 = 0; i2 < this.size; i2++) { - this.setFunctionModule(6, i2, i2 % 2 == 0); - this.setFunctionModule(i2, 6, i2 % 2 == 0); - } - this.drawFinderPattern(3, 3); - this.drawFinderPattern(this.size - 4, 3); - this.drawFinderPattern(3, this.size - 4); - const alignPatPos = this.getAlignmentPatternPositions(); - const numAlign = alignPatPos.length; - for (let i2 = 0; i2 < numAlign; i2++) { - for (let j2 = 0; j2 < numAlign; j2++) { - if (!(i2 == 0 && j2 == 0 || i2 == 0 && j2 == numAlign - 1 || i2 == numAlign - 1 && j2 == 0)) - this.drawAlignmentPattern(alignPatPos[i2], alignPatPos[j2]); - } + })); +}; +const fetchSardineClientToken = async (order, isDev, projectAccessKey2, tokenMetadata) => { + const randomNumber = Math.floor(Math.random() * 1e6); + const timestamp = (/* @__PURE__ */ new Date()).getTime(); + const referenceId = `sequence-kit-${randomNumber}-${timestamp}-${order.recipientAddress}-${networks[order.chainId].name}-${order.contractAddress}-${order.contractAddress}-${order.recipientAddress}`; + const accessKey = isDev ? "17xhjK4yjRf1fr0am8kgKfICAAAAAAAAA" : projectAccessKey2; + const url = isDev ? "https://dev-api.sequence.app/rpc/API/GetSardineNFTCheckoutToken" : "https://api.sequence.app/rpc/API/GetSardineNFTCheckoutToken"; + const res = await fetch(url, { + method: "POST", + headers: { + "Content-Type": "application/json", + "X-Access-Key": `${accessKey || ""}` + }, + body: JSON.stringify({ + params: { + referenceId, + expiresIn: 3600, + paymentMethodTypeConfig: { + enabled: ["us_debit", "us_credit", "international_debit", "international_credit", "ach"], + default: order.defaultPaymentMethodType + }, + name: (tokenMetadata == null ? void 0 : tokenMetadata.name) || "Unknown", + imageUrl: (tokenMetadata == null ? void 0 : tokenMetadata.image) || "https://www.sequence.market/images/placeholder.png", + network: networks[order.chainId].name, + recipientAddress: order.recipientAddress, + platform: "horizon", + blockchainNftId: order.blockchainNftId, + contractAddress: order.contractAddress, + executionType: "smart_contract", + quantity: Number(order.quantity), + decimals: Number(order.decimals) } - this.drawFormatBits(0); - this.drawVersion(); + }) + }); + const { + resp: { + orderId, + token } - drawFormatBits(mask) { - const data = this.errorCorrectionLevel.formatBits << 3 | mask; - let rem = data; - for (let i2 = 0; i2 < 10; i2++) - rem = rem << 1 ^ (rem >>> 9) * 1335; - const bits = (data << 10 | rem) ^ 21522; - assert2(bits >>> 15 == 0); - for (let i2 = 0; i2 <= 5; i2++) - this.setFunctionModule(8, i2, getBit(bits, i2)); - this.setFunctionModule(8, 7, getBit(bits, 6)); - this.setFunctionModule(8, 8, getBit(bits, 7)); - this.setFunctionModule(7, 8, getBit(bits, 8)); - for (let i2 = 9; i2 < 15; i2++) - this.setFunctionModule(14 - i2, 8, getBit(bits, i2)); - for (let i2 = 0; i2 < 8; i2++) - this.setFunctionModule(this.size - 1 - i2, 8, getBit(bits, i2)); - for (let i2 = 8; i2 < 15; i2++) - this.setFunctionModule(8, this.size - 15 + i2, getBit(bits, i2)); - this.setFunctionModule(8, this.size - 8, true); + } = await res.json(); + return { + token, + orderId + }; +}; +const fetchSardineOrderStatus = async (orderId, isDev, projectAccessKey2) => { + const accessKey = isDev ? "17xhjK4yjRf1fr0am8kgKfICAAAAAAAAA" : projectAccessKey2; + const url = isDev ? "https://dev-api.sequence.app/rpc/API/GetSardineNFTCheckoutOrderStatus" : "https://api.sequence.app/rpc/API/GetSardineNFTCheckoutOrderStatus"; + const response = await fetch(url, { + method: "POST", + headers: { + "Content-Type": "application/json", + "X-Access-Key": `${accessKey}` + }, + body: JSON.stringify({ + orderId + }) + }); + const json = await response.json(); + console.log("json:", json); + return json; +}; +const POLLING_TIME = 10 * 1e3; +const PendingTransaction = () => { + var _settings$sardineChec; + const nav = useNavigation$1(); + const { + settings + } = useCheckoutModal(); + const { + params: { + authToken, + orderId } - drawVersion() { - if (this.version < 7) + } = nav.navigation; + const { + setNavigation + } = nav; + const projectAccessKey2 = useProjectAccessKey(); + const isDev = (settings == null || (_settings$sardineChec = settings.sardineCheckout) == null ? void 0 : _settings$sardineChec.isDev) || false; + const url = isDev ? `https://crypto.sandbox.sardine.ai/?client_token=${authToken}&show_features=true` : `https://crypto.sardine.ai/?client_token=${authToken}&show_features=true`; + const pollForOrderStatus = async () => { + try { + var _settings$sardineChec2, _pollResponse$resp; + console.log("Polling for transaction status"); + const isDev2 = (settings == null || (_settings$sardineChec2 = settings.sardineCheckout) == null ? void 0 : _settings$sardineChec2.isDev) || false; + const pollResponse = await fetchSardineOrderStatus(orderId, isDev2, projectAccessKey2); + const status = pollResponse.resp.status; + const transactionHash = (_pollResponse$resp = pollResponse.resp) == null ? void 0 : _pollResponse$resp.transactionHash; + console.log("transaction status poll response:", status); + if (status === "Draft") { return; - let rem = this.version; - for (let i2 = 0; i2 < 12; i2++) - rem = rem << 1 ^ (rem >>> 11) * 7973; - const bits = this.version << 12 | rem; - assert2(bits >>> 18 == 0); - for (let i2 = 0; i2 < 18; i2++) { - const color2 = getBit(bits, i2); - const a2 = this.size - 11 + i2 % 3; - const b2 = Math.floor(i2 / 3); - this.setFunctionModule(a2, b2, color2); - this.setFunctionModule(b2, a2, color2); } - } - drawFinderPattern(x, y2) { - for (let dy = -4; dy <= 4; dy++) { - for (let dx = -4; dx <= 4; dx++) { - const dist2 = Math.max(Math.abs(dx), Math.abs(dy)); - const xx = x + dx; - const yy = y2 + dy; - if (0 <= xx && xx < this.size && 0 <= yy && yy < this.size) - this.setFunctionModule(xx, yy, dist2 != 2 && dist2 != 4); - } + if (status === "Complete") { + setNavigation && setNavigation({ + location: "transaction-success", + params: { + transactionHash + } + }); + return; } - } - drawAlignmentPattern(x, y2) { - for (let dy = -2; dy <= 2; dy++) { - for (let dx = -2; dx <= 2; dx++) - this.setFunctionModule(x + dx, y2 + dy, Math.max(Math.abs(dx), Math.abs(dy)) != 1); + if (status === "Declined" || status === "Cancelled") { + setNavigation && setNavigation({ + location: "transaction-error", + params: { + error: new Error("Failed to transfer collectible") + } + }); + return; } + } catch (e2) { + console.error("An error occurred while fetching the transaction status"); + setNavigation && setNavigation({ + location: "transaction-error", + params: { + error: e2 + } + }); } - setFunctionModule(x, y2, isDark) { - this.modules[y2][x] = isDark; - this.isFunction[y2][x] = true; + }; + reactExports.useEffect(() => { + const interval = setInterval(() => { + pollForOrderStatus(); + }, POLLING_TIME); + return () => { + clearInterval(interval); + }; + }, []); + return /* @__PURE__ */ React.createElement(Box, { + alignItems: "center", + justifyContent: "center", + style: { + height: "620px" } - addEccAndInterleave(data) { - const ver = this.version; - const ecl = this.errorCorrectionLevel; - if (data.length != _QrCode.getNumDataCodewords(ver, ecl)) - throw new RangeError("Invalid argument"); - const numBlocks = _QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver]; - const blockEccLen = _QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver]; - const rawCodewords = Math.floor(_QrCode.getNumRawDataModules(ver) / 8); - const numShortBlocks = numBlocks - rawCodewords % numBlocks; - const shortBlockLen = Math.floor(rawCodewords / numBlocks); - let blocks = []; - const rsDiv = _QrCode.reedSolomonComputeDivisor(blockEccLen); - for (let i2 = 0, k2 = 0; i2 < numBlocks; i2++) { - let dat = data.slice(k2, k2 + shortBlockLen - blockEccLen + (i2 < numShortBlocks ? 0 : 1)); - k2 += dat.length; - const ecc = _QrCode.reedSolomonComputeRemainder(dat, rsDiv); - if (i2 < numShortBlocks) - dat.push(0); - blocks.push(dat.concat(ecc)); - } - let result = []; - for (let i2 = 0; i2 < blocks[0].length; i2++) { - blocks.forEach((block, j2) => { - if (i2 != shortBlockLen - blockEccLen || j2 >= numShortBlocks) - result.push(block[i2]); - }); - } - assert2(result.length == rawCodewords); - return result; + }, /* @__PURE__ */ React.createElement("iframe", { + src: url, + style: { + maxHeight: "500px", + height: "100%", + maxWidth: "380px", + width: "100%" } - drawCodewords(data) { - if (data.length != Math.floor(_QrCode.getNumRawDataModules(this.version) / 8)) - throw new RangeError("Invalid argument"); - let i2 = 0; - for (let right = this.size - 1; right >= 1; right -= 2) { - if (right == 6) - right = 5; - for (let vert = 0; vert < this.size; vert++) { - for (let j2 = 0; j2 < 2; j2++) { - const x = right - j2; - const upward = (right + 1 & 2) == 0; - const y2 = upward ? this.size - 1 - vert : vert; - if (!this.isFunction[y2][x] && i2 < data.length * 8) { - this.modules[y2][x] = getBit(data[i2 >>> 3], 7 - (i2 & 7)); - i2++; - } - } - } - } - assert2(i2 == data.length * 8); + })); +}; +const TransactionSuccess = () => { + var _settings$sardineChec, _network$blockExplore, _network$blockExplore2; + const { + settings + } = useCheckoutModal(); + const nav = useNavigation$1(); + const navigation = nav.navigation; + const chainId = (settings == null || (_settings$sardineChec = settings.sardineCheckout) == null ? void 0 : _settings$sardineChec.chainId) || 137; + const network2 = sequence$1.network.allNetworks.find((n2) => n2.chainId === chainId); + reactExports.useEffect(() => { + var _settings$sardineChec2, _settings$sardineChec3, _settings$sardineChec4, _settings$sardineChec5; + (settings == null || (_settings$sardineChec2 = settings.sardineCheckout) == null ? void 0 : _settings$sardineChec2.onSuccess) && (settings == null || (_settings$sardineChec3 = settings.sardineCheckout) == null ? void 0 : _settings$sardineChec3.onSuccess(navigation.params.transactionHash, settings == null ? void 0 : settings.sardineCheckout)); + (settings == null || (_settings$sardineChec4 = settings.sardineCheckout) == null ? void 0 : _settings$sardineChec4.onSuccess) && (settings == null || (_settings$sardineChec5 = settings.sardineCheckout) == null ? void 0 : _settings$sardineChec5.onSuccess(navigation.params.transactionHash, settings == null ? void 0 : settings.sardineCheckout)); + }, []); + return /* @__PURE__ */ React.createElement(Box, { + style: { + height: "500px" } - applyMask(mask) { - if (mask < 0 || mask > 7) - throw new RangeError("Mask value out of range"); - for (let y2 = 0; y2 < this.size; y2++) { - for (let x = 0; x < this.size; x++) { - let invert2; - switch (mask) { - case 0: - invert2 = (x + y2) % 2 == 0; - break; - case 1: - invert2 = y2 % 2 == 0; - break; - case 2: - invert2 = x % 3 == 0; - break; - case 3: - invert2 = (x + y2) % 3 == 0; - break; - case 4: - invert2 = (Math.floor(x / 3) + Math.floor(y2 / 2)) % 2 == 0; - break; - case 5: - invert2 = x * y2 % 2 + x * y2 % 3 == 0; - break; - case 6: - invert2 = (x * y2 % 2 + x * y2 % 3) % 2 == 0; - break; - case 7: - invert2 = ((x + y2) % 2 + x * y2 % 3) % 2 == 0; - break; - default: - throw new Error("Unreachable"); - } - if (!this.isFunction[y2][x] && invert2) - this.modules[y2][x] = !this.modules[y2][x]; - } - } + }, /* @__PURE__ */ React.createElement(Box, { + flexDirection: "column", + alignItems: "center", + position: "absolute", + style: { + top: "50%", + right: "50%", + transform: "translate(50%, -50%)" } - getPenaltyScore() { - let result = 0; - for (let y2 = 0; y2 < this.size; y2++) { - let runColor = false; - let runX = 0; - let runHistory = [0, 0, 0, 0, 0, 0, 0]; - for (let x = 0; x < this.size; x++) { - if (this.modules[y2][x] == runColor) { - runX++; - if (runX == 5) - result += _QrCode.PENALTY_N1; - else if (runX > 5) - result++; - } else { - this.finderPenaltyAddHistory(runX, runHistory); - if (!runColor) - result += this.finderPenaltyCountPatterns(runHistory) * _QrCode.PENALTY_N3; - runColor = this.modules[y2][x]; - runX = 1; - } - } - result += this.finderPenaltyTerminateAndCount(runColor, runX, runHistory) * _QrCode.PENALTY_N3; - } - for (let x = 0; x < this.size; x++) { - let runColor = false; - let runY = 0; - let runHistory = [0, 0, 0, 0, 0, 0, 0]; - for (let y2 = 0; y2 < this.size; y2++) { - if (this.modules[y2][x] == runColor) { - runY++; - if (runY == 5) - result += _QrCode.PENALTY_N1; - else if (runY > 5) - result++; - } else { - this.finderPenaltyAddHistory(runY, runHistory); - if (!runColor) - result += this.finderPenaltyCountPatterns(runHistory) * _QrCode.PENALTY_N3; - runColor = this.modules[y2][x]; - runY = 1; - } - } - result += this.finderPenaltyTerminateAndCount(runColor, runY, runHistory) * _QrCode.PENALTY_N3; - } - for (let y2 = 0; y2 < this.size - 1; y2++) { - for (let x = 0; x < this.size - 1; x++) { - const color2 = this.modules[y2][x]; - if (color2 == this.modules[y2][x + 1] && color2 == this.modules[y2 + 1][x] && color2 == this.modules[y2 + 1][x + 1]) - result += _QrCode.PENALTY_N2; - } - } - let dark2 = 0; - for (const row of this.modules) - dark2 = row.reduce((sum, color2) => sum + (color2 ? 1 : 0), dark2); - const total = this.size * this.size; - const k2 = Math.ceil(Math.abs(dark2 * 20 - total * 10) / total) - 1; - assert2(0 <= k2 && k2 <= 9); - result += k2 * _QrCode.PENALTY_N4; - assert2(0 <= result && result <= 2568888); - return result; - } - getAlignmentPatternPositions() { - if (this.version == 1) - return []; - else { - const numAlign = Math.floor(this.version / 7) + 2; - const step = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (numAlign * 2 - 2)) * 2; - let result = [6]; - for (let pos = this.size - 7; result.length < numAlign; pos -= step) - result.splice(1, 0, pos); - return result; - } - } - static getNumRawDataModules(ver) { - if (ver < _QrCode.MIN_VERSION || ver > _QrCode.MAX_VERSION) - throw new RangeError("Version number out of range"); - let result = (16 * ver + 128) * ver + 64; - if (ver >= 2) { - const numAlign = Math.floor(ver / 7) + 2; - result -= (25 * numAlign - 10) * numAlign - 55; - if (ver >= 7) - result -= 36; - } - assert2(208 <= result && result <= 29648); - return result; - } - static getNumDataCodewords(ver, ecl) { - return Math.floor(_QrCode.getNumRawDataModules(ver) / 8) - _QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] * _QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver]; - } - static reedSolomonComputeDivisor(degree) { - if (degree < 1 || degree > 255) - throw new RangeError("Degree out of range"); - let result = []; - for (let i2 = 0; i2 < degree - 1; i2++) - result.push(0); - result.push(1); - let root2 = 1; - for (let i2 = 0; i2 < degree; i2++) { - for (let j2 = 0; j2 < result.length; j2++) { - result[j2] = _QrCode.reedSolomonMultiply(result[j2], root2); - if (j2 + 1 < result.length) - result[j2] ^= result[j2 + 1]; - } - root2 = _QrCode.reedSolomonMultiply(root2, 2); - } - return result; - } - static reedSolomonComputeRemainder(data, divisor) { - let result = divisor.map((_) => 0); - for (const b2 of data) { - const factor = b2 ^ result.shift(); - result.push(0); - divisor.forEach((coef, i2) => result[i2] ^= _QrCode.reedSolomonMultiply(coef, factor)); - } - return result; - } - static reedSolomonMultiply(x, y2) { - if (x >>> 8 != 0 || y2 >>> 8 != 0) - throw new RangeError("Byte out of range"); - let z = 0; - for (let i2 = 7; i2 >= 0; i2--) { - z = z << 1 ^ (z >>> 7) * 285; - z ^= (y2 >>> i2 & 1) * x; - } - assert2(z >>> 8 == 0); - return z; - } - finderPenaltyCountPatterns(runHistory) { - const n2 = runHistory[1]; - assert2(n2 <= this.size * 3); - const core2 = n2 > 0 && runHistory[2] == n2 && runHistory[3] == n2 * 3 && runHistory[4] == n2 && runHistory[5] == n2; - return (core2 && runHistory[0] >= n2 * 4 && runHistory[6] >= n2 ? 1 : 0) + (core2 && runHistory[6] >= n2 * 4 && runHistory[0] >= n2 ? 1 : 0); - } - finderPenaltyTerminateAndCount(currentRunColor, currentRunLength, runHistory) { - if (currentRunColor) { - this.finderPenaltyAddHistory(currentRunLength, runHistory); - currentRunLength = 0; - } - currentRunLength += this.size; - this.finderPenaltyAddHistory(currentRunLength, runHistory); - return this.finderPenaltyCountPatterns(runHistory); + }, /* @__PURE__ */ React.createElement(NotificationSuccessIcon, null), /* @__PURE__ */ React.createElement(Text, { + fontSize: "xlarge" + }, "Success!"), /* @__PURE__ */ React.createElement(Text, { + textAlign: "center", + variant: "normal", + color: "text80" + }, "Purchase was successful, item was sent to your wallet."), navigation.params.transactionHash && /* @__PURE__ */ React.createElement(Text, { + as: "a", + variant: "small", + underline: true, + marginTop: "6", + color: "text100", + href: `${network2 == null || (_network$blockExplore = network2.blockExplorer) == null ? void 0 : _network$blockExplore.rootUrl}/tx/${navigation.params.transactionHash}`, + target: "_blank", + rel: "noreferrer" + }, "View on ", network2 == null || (_network$blockExplore2 = network2.blockExplorer) == null ? void 0 : _network$blockExplore2.name))); +}; +const NotificationSuccessIcon = () => /* @__PURE__ */ React.createElement(Box, { + color: "white", + background: "positive", + alignItems: "center", + justifyContent: "center", + width: "16", + height: "16", + borderRadius: "circle", + marginBottom: "2" +}, /* @__PURE__ */ React.createElement(SvgCheckmarkIcon, { + size: "xl" +})); +const TransactionError = () => { + const { + closeCheckout, + settings + } = useCheckoutModal(); + const nav = useNavigation$1(); + const navigation = nav.navigation; + reactExports.useEffect(() => { + setTimeout(() => { + var _settings$sardineChec, _settings$sardineChec2; + closeCheckout(); + (settings == null || (_settings$sardineChec = settings.sardineCheckout) == null ? void 0 : _settings$sardineChec.onError) && (settings == null || (_settings$sardineChec2 = settings.sardineCheckout) == null ? void 0 : _settings$sardineChec2.onError(navigation.params.error, settings == null ? void 0 : settings.sardineCheckout)); + }, 3e3); + }, []); + return /* @__PURE__ */ React.createElement(Box, { + style: { + height: "500px" } - finderPenaltyAddHistory(currentRunLength, runHistory) { - if (runHistory[0] == 0) - currentRunLength += this.size; - runHistory.pop(); - runHistory.unshift(currentRunLength); + }, /* @__PURE__ */ React.createElement(Box, { + flexDirection: "column", + alignItems: "center", + position: "absolute", + style: { + top: "50%", + right: "50%", + transform: "translate(50%, -50%)" } - }; - let QrCode = _QrCode; - QrCode.MIN_VERSION = 1; - QrCode.MAX_VERSION = 40; - QrCode.PENALTY_N1 = 3; - QrCode.PENALTY_N2 = 3; - QrCode.PENALTY_N3 = 40; - QrCode.PENALTY_N4 = 10; - QrCode.ECC_CODEWORDS_PER_BLOCK = [ - [-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], - [-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28], - [-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], - [-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30] - ]; - QrCode.NUM_ERROR_CORRECTION_BLOCKS = [ - [-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25], - [-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49], - [-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68], - [-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81] - ]; - qrcodegen2.QrCode = QrCode; - function appendBits(val, len, bb2) { - if (len < 0 || len > 31 || val >>> len != 0) - throw new RangeError("Value out of range"); - for (let i2 = len - 1; i2 >= 0; i2--) - bb2.push(val >>> i2 & 1); + }, /* @__PURE__ */ React.createElement(NotificationErrorIcon, null), /* @__PURE__ */ React.createElement(Text, { + fontSize: "xlarge" + }, "Error"), /* @__PURE__ */ React.createElement(Text, { + textAlign: "center", + variant: "normal", + color: "text80" + }, "An error occurred while processing the transaction."))); +}; +const NotificationErrorIcon = () => /* @__PURE__ */ React.createElement(Box, { + color: "white", + alignItems: "center", + justifyContent: "center", + width: "16", + height: "16", + borderRadius: "circle", + marginBottom: "2", + background: "negative" +}, /* @__PURE__ */ React.createElement(SvgCloseIcon, { + size: "xl" +})); +const compareAddress$1 = (a2, b2) => { + return a2.toLowerCase() === b2.toLowerCase(); +}; +var ValueType$1 = /* @__PURE__ */ function(ValueType2) { + ValueType2[ValueType2["VERY_LARGE"] = 0] = "VERY_LARGE"; + ValueType2[ValueType2["FRACTION"] = 1] = "FRACTION"; + ValueType2[ValueType2["VERY_TINY"] = 2] = "VERY_TINY"; + ValueType2[ValueType2["MIXED"] = 3] = "MIXED"; + return ValueType2; +}(ValueType$1 || {}); +const formatDisplay$1 = (_val) => { + if (isNaN(Number(_val))) { + console.error(`display format error ${_val} is not a number`); + return "NaN"; } - function getBit(x, i2) { - return (x >>> i2 & 1) != 0; + const val = Number(_val); + if (val === 0) { + return "0"; } - function assert2(cond) { - if (!cond) - throw new Error("Assertion error"); + let valMode; + if (val > 1e8) { + valMode = ValueType$1.VERY_LARGE; + } else if (val < 1e-10) { + valMode = ValueType$1.VERY_TINY; + } else if (val < 1) { + valMode = ValueType$1.FRACTION; + } else { + valMode = ValueType$1.MIXED; } - const _QrSegment = class { - constructor(mode, numChars, bitData) { - this.mode = mode; - this.numChars = numChars; - this.bitData = bitData; - if (numChars < 0) - throw new RangeError("Invalid argument"); - this.bitData = bitData.slice(); - } - static makeBytes(data) { - let bb2 = []; - for (const b2 of data) - appendBits(b2, 8, bb2); - return new _QrSegment(_QrSegment.Mode.BYTE, data.length, bb2); - } - static makeNumeric(digits) { - if (!_QrSegment.isNumeric(digits)) - throw new RangeError("String contains non-numeric characters"); - let bb2 = []; - for (let i2 = 0; i2 < digits.length; ) { - const n2 = Math.min(digits.length - i2, 3); - appendBits(parseInt(digits.substr(i2, n2), 10), n2 * 3 + 1, bb2); - i2 += n2; - } - return new _QrSegment(_QrSegment.Mode.NUMERIC, digits.length, bb2); - } - static makeAlphanumeric(text2) { - if (!_QrSegment.isAlphanumeric(text2)) - throw new RangeError("String contains unencodable characters in alphanumeric mode"); - let bb2 = []; - let i2; - for (i2 = 0; i2 + 2 <= text2.length; i2 += 2) { - let temp = _QrSegment.ALPHANUMERIC_CHARSET.indexOf(text2.charAt(i2)) * 45; - temp += _QrSegment.ALPHANUMERIC_CHARSET.indexOf(text2.charAt(i2 + 1)); - appendBits(temp, 11, bb2); - } - if (i2 < text2.length) - appendBits(_QrSegment.ALPHANUMERIC_CHARSET.indexOf(text2.charAt(i2)), 6, bb2); - return new _QrSegment(_QrSegment.Mode.ALPHANUMERIC, text2.length, bb2); + let notation = void 0; + let config2; + switch (valMode) { + case ValueType$1.VERY_LARGE: + notation = "compact"; + config2 = { + maximumFractionDigits: 4 + }; + break; + case ValueType$1.VERY_TINY: + notation = "scientific"; + config2 = { + maximumFractionDigits: 4 + }; + break; + case ValueType$1.FRACTION: + notation = "standard"; + config2 = { + maximumSignificantDigits: 4 + }; + break; + default: + notation = "standard"; + config2 = { + maximumFractionDigits: 2 + }; + } + return Intl.NumberFormat("en-US", _extends$4({ + notation + }, config2)).format(val); +}; +const OrderSummaryItem = ({ + contractAddress, + tokenId, + quantityRaw, + chainId +}) => { + var _tokenMetadata$; + const { + data: tokenMetadata, + isPending: isPendingTokenMetadata + } = useTokenMetadata(chainId, contractAddress, [tokenId]); + const { + data: contractInfo, + isPending: isPendingContractInfo + } = useContractInfo(chainId, contractAddress); + const isPending = isPendingTokenMetadata || isPendingContractInfo; + if (isPending) { + return /* @__PURE__ */ React.createElement(OrderSummarySkeleton, null); + } + const { + name: name2 = "unknown", + image, + decimals = 0 + } = (_tokenMetadata$ = tokenMetadata == null ? void 0 : tokenMetadata[0]) != null ? _tokenMetadata$ : {}; + const { + logoURI: collectionLogoURI, + name: collectionName = "Unknown Collection" + } = contractInfo || {}; + const balanceFormatted = formatUnits$1(quantityRaw, decimals); + return /* @__PURE__ */ React.createElement(Card, { + flexDirection: "row", + alignItems: "flex-start", + justifyContent: "space-between" + }, /* @__PURE__ */ React.createElement(Box, { + flexDirection: "row", + alignItems: "center", + justifyContent: "center", + gap: "2" + }, /* @__PURE__ */ React.createElement(Box, { + aspectRatio: "1/1", + height: "full", + justifyContent: "center", + alignItems: "center", + style: { + width: "80px" } - static makeSegments(text2) { - if (text2 == "") - return []; - else if (_QrSegment.isNumeric(text2)) - return [_QrSegment.makeNumeric(text2)]; - else if (_QrSegment.isAlphanumeric(text2)) - return [_QrSegment.makeAlphanumeric(text2)]; - else - return [_QrSegment.makeBytes(_QrSegment.toUtf8ByteArray(text2))]; + }, /* @__PURE__ */ React.createElement(Image$1, { + src: image, + borderRadius: "md", + style: { + maxWidth: "80px", + height: "80px", + objectFit: "cover" } - static makeEci(assignVal) { - let bb2 = []; - if (assignVal < 0) - throw new RangeError("ECI assignment value out of range"); - else if (assignVal < 1 << 7) - appendBits(assignVal, 8, bb2); - else if (assignVal < 1 << 14) { - appendBits(2, 2, bb2); - appendBits(assignVal, 14, bb2); - } else if (assignVal < 1e6) { - appendBits(6, 3, bb2); - appendBits(assignVal, 21, bb2); - } else - throw new RangeError("ECI assignment value out of range"); - return new _QrSegment(_QrSegment.Mode.ECI, 0, bb2); + })), /* @__PURE__ */ React.createElement(Box, { + flexDirection: "column", + alignItems: "flex-start", + justifyContent: "center", + gap: "2" + }, /* @__PURE__ */ React.createElement(Box, { + gap: "1", + alignItems: "center" + }, /* @__PURE__ */ React.createElement(TokenImage, { + src: collectionLogoURI, + size: "xs" + }), /* @__PURE__ */ React.createElement(Text, { + marginLeft: "1", + fontSize: "small", + color: "text80", + fontWeight: "bold" + }, collectionName), /* @__PURE__ */ React.createElement(NetworkImage, { + chainId, + size: "xs" + })), /* @__PURE__ */ React.createElement(Box, { + flexDirection: "column", + alignItems: "flex-start", + justifyContent: "center", + style: { + width: "180px" } - static isNumeric(text2) { - return _QrSegment.NUMERIC_REGEX.test(text2); + }, /* @__PURE__ */ React.createElement(Text, { + color: "text100", + fontSize: "normal", + fontWeight: "normal" + }, name2), /* @__PURE__ */ React.createElement(Text, { + color: "text50", + fontSize: "normal", + fontWeight: "normal" + }, `#${tokenId}`)))), /* @__PURE__ */ React.createElement(Box, { + height: "full", + fontSize: "small", + color: "text50", + fontWeight: "bold" + }, `x${formatDisplay$1(balanceFormatted)}`)); +}; +const OrderSummarySkeleton = () => { + return /* @__PURE__ */ React.createElement(Card, { + flexDirection: "row", + alignItems: "flex-start", + justifyContent: "space-between" + }, /* @__PURE__ */ React.createElement(Box, { + flexDirection: "row", + alignItems: "center", + justifyContent: "center", + gap: "2" + }, /* @__PURE__ */ React.createElement(Skeleton, { + style: { + width: "80px", + height: "80px" } - static isAlphanumeric(text2) { - return _QrSegment.ALPHANUMERIC_REGEX.test(text2); + }), /* @__PURE__ */ React.createElement(Box, { + flexDirection: "column", + alignItems: "flex-start", + justifyContent: "center", + gap: "2" + }, /* @__PURE__ */ React.createElement(Skeleton, { + style: { + width: "100px", + height: "14px" } - getData() { - return this.bitData.slice(); + }), /* @__PURE__ */ React.createElement(Skeleton, { + style: { + width: "180px", + height: "34px" } - static getTotalBits(segs, version2) { - let result = 0; - for (const seg of segs) { - const ccbits = seg.mode.numCharCountBits(version2); - if (seg.numChars >= 1 << ccbits) - return Infinity; - result += 4 + ccbits + seg.bitData.length; - } - return result; + }))), /* @__PURE__ */ React.createElement(Skeleton, { + style: { + width: "14px", + height: "14px" } - static toUtf8ByteArray(str) { - str = encodeURI(str); - let result = []; - for (let i2 = 0; i2 < str.length; i2++) { - if (str.charAt(i2) != "%") - result.push(str.charCodeAt(i2)); - else { - result.push(parseInt(str.substr(i2 + 1, 2), 16)); - i2 += 2; - } - } - return result; - } - }; - let QrSegment = _QrSegment; - QrSegment.NUMERIC_REGEX = /^[0-9]*$/; - QrSegment.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/; - QrSegment.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; - qrcodegen2.QrSegment = QrSegment; -})(qrcodegen || (qrcodegen = {})); -((qrcodegen2) => { - ((QrCode2) => { - const _Ecc = class { - constructor(ordinal, formatBits) { - this.ordinal = ordinal; - this.formatBits = formatBits; - } - }; - let Ecc = _Ecc; - Ecc.LOW = new _Ecc(0, 1); - Ecc.MEDIUM = new _Ecc(1, 0); - Ecc.QUARTILE = new _Ecc(2, 3); - Ecc.HIGH = new _Ecc(3, 2); - QrCode2.Ecc = Ecc; - })(qrcodegen2.QrCode || (qrcodegen2.QrCode = {})); -})(qrcodegen || (qrcodegen = {})); -((qrcodegen2) => { - ((QrSegment2) => { - const _Mode = class { - constructor(modeBits, numBitsCharCount) { - this.modeBits = modeBits; - this.numBitsCharCount = numBitsCharCount; - } - numCharCountBits(ver) { - return this.numBitsCharCount[Math.floor((ver + 7) / 17)]; - } - }; - let Mode = _Mode; - Mode.NUMERIC = new _Mode(1, [10, 12, 14]); - Mode.ALPHANUMERIC = new _Mode(2, [9, 11, 13]); - Mode.BYTE = new _Mode(4, [8, 16, 16]); - Mode.KANJI = new _Mode(8, [8, 10, 12]); - Mode.ECI = new _Mode(7, [0, 0, 0]); - QrSegment2.Mode = Mode; - })(qrcodegen2.QrSegment || (qrcodegen2.QrSegment = {})); -})(qrcodegen || (qrcodegen = {})); -var qrcodegen_default = qrcodegen; -/** - * @license qrcode.react - * Copyright (c) Paul O'Shannessy - * SPDX-License-Identifier: ISC - */ -var ERROR_LEVEL_MAP = { - L: qrcodegen_default.QrCode.Ecc.LOW, - M: qrcodegen_default.QrCode.Ecc.MEDIUM, - Q: qrcodegen_default.QrCode.Ecc.QUARTILE, - H: qrcodegen_default.QrCode.Ecc.HIGH + })); }; -var DEFAULT_SIZE = 128; -var DEFAULT_LEVEL = "L"; -var DEFAULT_BGCOLOR = "#FFFFFF"; -var DEFAULT_FGCOLOR = "#000000"; -var DEFAULT_INCLUDEMARGIN = false; -var MARGIN_SIZE = 4; -var DEFAULT_IMG_SCALE = 0.1; -function generatePath(modules, margin = 0) { - const ops = []; - modules.forEach(function(row, y2) { - let start = null; - row.forEach(function(cell, x) { - if (!cell && start !== null) { - ops.push(`M${start + margin} ${y2 + margin}h${x - start}v1H${start + margin}z`); - start = null; - return; - } - if (x === row.length - 1) { - if (!cell) { - return; - } - if (start === null) { - ops.push(`M${x + margin},${y2 + margin} h1v1H${x + margin}z`); - } else { - ops.push(`M${start + margin},${y2 + margin} h${x + 1 - start}v1H${start + margin}z`); - } - return; - } - if (cell && start === null) { - start = x; - } - }); +const CheckoutSelection = () => { + var _cryptoCheckoutSettin, _cryptoCheckoutSettin2, _cryptoCheckoutSettin4, _settings$cryptoCheck, _settings$sardineChec; + const { + chains: chains2 + } = useConfig(); + const { + setNavigation + } = useNavigation$1(); + const { + closeCheckout, + settings + } = useCheckoutModal(); + const { + address: accountAddress + } = useAccount(); + const projectAccessKey2 = useProjectAccessKey(); + const cryptoCheckoutSettings = settings == null ? void 0 : settings.cryptoCheckout; + const creditCardCheckoutSettings = settings == null ? void 0 : settings.sardineCheckout; + const displayCreditCardCheckout = !!creditCardCheckoutSettings; + const displayCryptoCheckout = !!cryptoCheckoutSettings; + const { + data: contractInfoData, + isLoading: isPendingContractInfo + } = useContractInfo((cryptoCheckoutSettings == null ? void 0 : cryptoCheckoutSettings.chainId) || 1, (cryptoCheckoutSettings == null || (_cryptoCheckoutSettin = cryptoCheckoutSettings.coinQuantity) == null ? void 0 : _cryptoCheckoutSettin.contractAddress) || ""); + const { + data: balancesData, + isPending: isPendingBalances + } = useBalances({ + chainIds: [(cryptoCheckoutSettings == null ? void 0 : cryptoCheckoutSettings.chainId) || 1], + accountAddress: accountAddress || "" }); - return ops.join(""); -} -function excavateModules(modules, excavation) { - return modules.slice().map((row, y2) => { - if (y2 < excavation.y || y2 >= excavation.y + excavation.h) { - return row; - } - return row.map((cell, x) => { - if (x < excavation.x || x >= excavation.x + excavation.w) { - return cell; - } - return false; - }); + const isPending = (isPendingContractInfo || isPendingBalances) && cryptoCheckoutSettings; + const isNativeToken = compareAddress$1((cryptoCheckoutSettings == null || (_cryptoCheckoutSettin2 = cryptoCheckoutSettings.coinQuantity) == null ? void 0 : _cryptoCheckoutSettin2.contractAddress) || "", AddressZero); + const nativeTokenInfo = getNativeTokenInfoByChainId((cryptoCheckoutSettings == null ? void 0 : cryptoCheckoutSettings.chainId) || 1, chains2); + const coinDecimals = isNativeToken ? nativeTokenInfo.decimals : (contractInfoData == null ? void 0 : contractInfoData.decimals) || 0; + const coinSymbol = isNativeToken ? nativeTokenInfo.symbol : (contractInfoData == null ? void 0 : contractInfoData.symbol) || "COIN"; + const coinImageUrl = isNativeToken ? nativeTokenInfo.logoURI : (contractInfoData == null ? void 0 : contractInfoData.logoURI) || ""; + const coinBalance = balancesData == null ? void 0 : balancesData.find((balance) => { + var _cryptoCheckoutSettin3; + return compareAddress$1(balance.contractAddress, (cryptoCheckoutSettings == null || (_cryptoCheckoutSettin3 = cryptoCheckoutSettings.coinQuantity) == null ? void 0 : _cryptoCheckoutSettin3.contractAddress) || ""); }); -} -function getImageSettings(cells, size2, includeMargin, imageSettings) { - if (imageSettings == null) { - return null; - } - const margin = includeMargin ? MARGIN_SIZE : 0; - const numCells = cells.length + margin * 2; - const defaultSize = Math.floor(size2 * DEFAULT_IMG_SCALE); - const scale2 = numCells / size2; - const w2 = (imageSettings.width || defaultSize) * scale2; - const h2 = (imageSettings.height || defaultSize) * scale2; - const x = imageSettings.x == null ? cells.length / 2 - w2 / 2 : imageSettings.x * scale2; - const y2 = imageSettings.y == null ? cells.length / 2 - h2 / 2 : imageSettings.y * scale2; - let excavation = null; - if (imageSettings.excavate) { - let floorX = Math.floor(x); - let floorY = Math.floor(y2); - let ceilW = Math.ceil(w2 + x - floorX); - let ceilH = Math.ceil(h2 + y2 - floorY); - excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH }; - } - return { x, y: y2, h: h2, w: w2, excavation }; -} -var SUPPORTS_PATH2D = function() { - try { - new Path2D().addPath(new Path2D()); - } catch (e2) { - return false; - } - return true; -}(); -function QRCodeCanvas(props) { - const _a2 = props, { - value, - size: size2 = DEFAULT_SIZE, - level = DEFAULT_LEVEL, - bgColor = DEFAULT_BGCOLOR, - fgColor = DEFAULT_FGCOLOR, - includeMargin = DEFAULT_INCLUDEMARGIN, - style, - imageSettings - } = _a2, otherProps = __objRest(_a2, [ - "value", - "size", - "level", - "bgColor", - "fgColor", - "includeMargin", - "style", - "imageSettings" - ]); - const imgSrc = imageSettings == null ? void 0 : imageSettings.src; - const _canvas = reactExports.useRef(null); - const _image = reactExports.useRef(null); - const [isImgLoaded, setIsImageLoaded] = reactExports.useState(false); - reactExports.useEffect(() => { - if (_canvas.current != null) { - const canvas = _canvas.current; - const ctx = canvas.getContext("2d"); - if (!ctx) { - return; - } - let cells = qrcodegen_default.QrCode.encodeText(value, ERROR_LEVEL_MAP[level]).getModules(); - const margin = includeMargin ? MARGIN_SIZE : 0; - const numCells = cells.length + margin * 2; - const calculatedImageSettings = getImageSettings(cells, size2, includeMargin, imageSettings); - const image = _image.current; - const haveImageToRender = calculatedImageSettings != null && image !== null && image.complete && image.naturalHeight !== 0 && image.naturalWidth !== 0; - if (haveImageToRender) { - if (calculatedImageSettings.excavation != null) { - cells = excavateModules(cells, calculatedImageSettings.excavation); + const userBalanceRaw = coinBalance ? coinBalance.balance : "0"; + const requestedAmountRaw = (cryptoCheckoutSettings == null || (_cryptoCheckoutSettin4 = cryptoCheckoutSettings.coinQuantity) == null ? void 0 : _cryptoCheckoutSettin4.amountRequiredRaw) || "0"; + const userBalance = formatUnits$1(userBalanceRaw, coinDecimals); + const requestAmount = formatUnits$1(requestedAmountRaw, coinDecimals); + const isInsufficientBalance = BigNumber.from(userBalanceRaw).lt(BigNumber.from(requestedAmountRaw)); + const orderSummaryItems = (settings == null ? void 0 : settings.orderSummaryItems) || []; + const chainId = (settings == null || (_settings$cryptoCheck = settings.cryptoCheckout) == null ? void 0 : _settings$cryptoCheck.chainId) || (settings == null || (_settings$sardineChec = settings.sardineCheckout) == null ? void 0 : _settings$sardineChec.chainId) || 1; + const { + data: tokensMetadata + } = useTokenMetadata(chainId, orderSummaryItems[0].contractAddress, [orderSummaryItems[0].tokenId]); + const tokenMetadata = tokensMetadata ? tokensMetadata[0] : void 0; + const triggerSardineTransaction = async () => { + console.log("trigger sardine transaction"); + if (settings != null && settings.sardineCheckout) { + var _settings$sardineChec2; + const isDev = (settings == null || (_settings$sardineChec2 = settings.sardineCheckout) == null ? void 0 : _settings$sardineChec2.isDev) || false; + const { + token, + orderId + } = await fetchSardineClientToken(settings.sardineCheckout, isDev, projectAccessKey2, tokenMetadata); + setNavigation({ + location: "transaction-pending", + params: { + orderId, + authToken: token } - } - const pixelRatio = window.devicePixelRatio || 1; - canvas.height = canvas.width = size2 * pixelRatio; - const scale2 = size2 / numCells * pixelRatio; - ctx.scale(scale2, scale2); - ctx.fillStyle = bgColor; - ctx.fillRect(0, 0, numCells, numCells); - ctx.fillStyle = fgColor; - if (SUPPORTS_PATH2D) { - ctx.fill(new Path2D(generatePath(cells, margin))); - } else { - cells.forEach(function(row, rdx) { - row.forEach(function(cell, cdx) { - if (cell) { - ctx.fillRect(cdx + margin, rdx + margin, 1, 1); - } - }); - }); - } - if (haveImageToRender) { - ctx.drawImage(image, calculatedImageSettings.x + margin, calculatedImageSettings.y + margin, calculatedImageSettings.w, calculatedImageSettings.h); - } - } - }); - reactExports.useEffect(() => { - setIsImageLoaded(false); - }, [imgSrc]); - const canvasStyle = __spreadValues({ height: size2, width: size2 }, style); - let img2 = null; - if (imgSrc != null) { - img2 = /* @__PURE__ */ React.createElement("img", { - src: imgSrc, - key: imgSrc, - style: { display: "none" }, - onLoad: () => { - setIsImageLoaded(true); - }, - ref: _image - }); - } - return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("canvas", __spreadValues({ - style: canvasStyle, - height: size2, - width: size2, - ref: _canvas - }, otherProps)), img2); -} -function QRCodeSVG(props) { - const _a2 = props, { - value, - size: size2 = DEFAULT_SIZE, - level = DEFAULT_LEVEL, - bgColor = DEFAULT_BGCOLOR, - fgColor = DEFAULT_FGCOLOR, - includeMargin = DEFAULT_INCLUDEMARGIN, - imageSettings - } = _a2, otherProps = __objRest(_a2, [ - "value", - "size", - "level", - "bgColor", - "fgColor", - "includeMargin", - "imageSettings" - ]); - let cells = qrcodegen_default.QrCode.encodeText(value, ERROR_LEVEL_MAP[level]).getModules(); - const margin = includeMargin ? MARGIN_SIZE : 0; - const numCells = cells.length + margin * 2; - const calculatedImageSettings = getImageSettings(cells, size2, includeMargin, imageSettings); - let image = null; - if (imageSettings != null && calculatedImageSettings != null) { - if (calculatedImageSettings.excavation != null) { - cells = excavateModules(cells, calculatedImageSettings.excavation); - } - image = /* @__PURE__ */ React.createElement("image", { - xlinkHref: imageSettings.src, - height: calculatedImageSettings.h, - width: calculatedImageSettings.w, - x: calculatedImageSettings.x + margin, - y: calculatedImageSettings.y + margin, - preserveAspectRatio: "none" - }); - } - const fgPath = generatePath(cells, margin); - return /* @__PURE__ */ React.createElement("svg", __spreadValues({ - height: size2, - width: size2, - viewBox: `0 0 ${numCells} ${numCells}` - }, otherProps), /* @__PURE__ */ React.createElement("path", { - fill: bgColor, - d: `M0,0 h${numCells}v${numCells}H0z`, - shapeRendering: "crispEdges" - }), /* @__PURE__ */ React.createElement("path", { - fill: fgColor, - d: fgPath, - shapeRendering: "crispEdges" - }), image); -} -var QRCode = (props) => { - const _a2 = props, { renderAs } = _a2, otherProps = __objRest(_a2, ["renderAs"]); - if (renderAs === "svg") { - return /* @__PURE__ */ React.createElement(QRCodeSVG, __spreadValues({}, otherProps)); - } - return /* @__PURE__ */ React.createElement(QRCodeCanvas, __spreadValues({}, otherProps)); -}; -var Component = {}; -var toggleSelection = function() { - var selection = document.getSelection(); - if (!selection.rangeCount) { - return function() { - }; - } - var active = document.activeElement; - var ranges = []; - for (var i2 = 0; i2 < selection.rangeCount; i2++) { - ranges.push(selection.getRangeAt(i2)); - } - switch (active.tagName.toUpperCase()) { - case "INPUT": - case "TEXTAREA": - active.blur(); - break; - default: - active = null; - break; - } - selection.removeAllRanges(); - return function() { - selection.type === "Caret" && selection.removeAllRanges(); - if (!selection.rangeCount) { - ranges.forEach(function(range2) { - selection.addRange(range2); }); } - active && active.focus(); }; -}; -var deselectCurrent = toggleSelection; -var clipboardToIE11Formatting = { - "text/plain": "Text", - "text/html": "Url", - "default": "Text" -}; -var defaultMessage = "Copy to clipboard: #{key}, Enter"; -function format$1(message) { - var copyKey = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C"; - return message.replace(/#{\s*key\s*}/g, copyKey); -} -function copy(text2, options) { - var debug2, message, reselectPrevious, range2, selection, mark, success = false; - if (!options) { - options = {}; - } - debug2 = options.debug || false; - try { - reselectPrevious = deselectCurrent(); - range2 = document.createRange(); - selection = document.getSelection(); - mark = document.createElement("span"); - mark.textContent = text2; - mark.ariaHidden = "true"; - mark.style.all = "unset"; - mark.style.position = "fixed"; - mark.style.top = 0; - mark.style.clip = "rect(0, 0, 0, 0)"; - mark.style.whiteSpace = "pre"; - mark.style.webkitUserSelect = "text"; - mark.style.MozUserSelect = "text"; - mark.style.msUserSelect = "text"; - mark.style.userSelect = "text"; - mark.addEventListener("copy", function(e2) { - e2.stopPropagation(); - if (options.format) { - e2.preventDefault(); - if (typeof e2.clipboardData === "undefined") { - debug2 && console.warn("unable to use e.clipboardData"); - debug2 && console.warn("trying IE specific stuff"); - window.clipboardData.clearData(); - var format2 = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting["default"]; - window.clipboardData.setData(format2, text2); - } else { - e2.clipboardData.clearData(); - e2.clipboardData.setData(options.format, text2); - } - } - if (options.onCopy) { - e2.preventDefault(); - options.onCopy(e2.clipboardData); - } - }); - document.body.appendChild(mark); - range2.selectNodeContents(mark); - selection.addRange(range2); - var successful = document.execCommand("copy"); - if (!successful) { - throw new Error("copy command was unsuccessful"); + const onClickPayWithCard = () => { + if (settings != null && settings.sardineCheckout) { + triggerSardineTransaction(); + } else { + setNavigation({ + location: "transaction-form" + }); } - success = true; - } catch (err) { - debug2 && console.error("unable to copy using execCommand: ", err); - debug2 && console.warn("trying IE specific stuff"); - try { - window.clipboardData.setData(options.format || "text", text2); - options.onCopy && options.onCopy(window.clipboardData); - success = true; - } catch (err2) { - debug2 && console.error("unable to copy using clipboardData: ", err2); - debug2 && console.error("falling back to prompt"); - message = format$1("message" in options ? options.message : defaultMessage); - window.prompt(message, text2); + }; + const onClickPayWithCrypto = () => { + var _settings$cryptoCheck2; + console.log("trigger transaction"); + const transaction2 = settings == null || (_settings$cryptoCheck2 = settings.cryptoCheckout) == null ? void 0 : _settings$cryptoCheck2.triggerTransaction; + transaction2 && transaction2(); + closeCheckout(); + }; + return /* @__PURE__ */ React.createElement(Box, { + paddingX: "5", + paddingBottom: "5", + style: { + marginTop: HEADER_HEIGHT$1 + }, + flexDirection: "column", + gap: "3" + }, orderSummaryItems.length > 0 && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Box, { + flexDirection: "row", + gap: "2", + alignItems: "center" + }, /* @__PURE__ */ React.createElement(Text, { + fontWeight: "normal", + fontSize: "normal", + color: "text50" + }, "Order summary"), /* @__PURE__ */ React.createElement(Tooltip, { + vOffset: -2, + side: "bottom", + message: /* @__PURE__ */ React.createElement(React.Fragment, null, "Please note that NFTs are digital assets", /* @__PURE__ */ React.createElement("br", null), " ,and as such, cannot be delivered physically.") + }, /* @__PURE__ */ React.createElement(Box, { + width: "5", + height: "5" + }, /* @__PURE__ */ React.createElement(SvgHelpIcon, { + color: "text80" + })))), /* @__PURE__ */ React.createElement(Box, { + flexDirection: "column", + gap: "2" + }, orderSummaryItems.map((orderSummaryItem, index2) => { + return /* @__PURE__ */ React.createElement(OrderSummaryItem, _extends$4({ + key: index2 + }, orderSummaryItem, { + chainId + })); + })), /* @__PURE__ */ React.createElement(Box, { + marginTop: "2" + }, /* @__PURE__ */ React.createElement(Divider, { + color: "backgroundSecondary", + style: { + margin: "0px" } - } finally { - if (selection) { - if (typeof selection.removeRange == "function") { - selection.removeRange(range2); - } else { - selection.removeAllRanges(); - } + }))), displayCryptoCheckout && /* @__PURE__ */ React.createElement(Box, { + justifyContent: "space-between", + alignItems: "center" + }, /* @__PURE__ */ React.createElement(Text, { + fontWeight: "normal", + fontSize: "normal", + color: "text50" + }, "Total"), isPending ? /* @__PURE__ */ React.createElement(Skeleton, { + style: { + width: "100px", + height: "17px" } - if (mark) { - document.body.removeChild(mark); + }) : /* @__PURE__ */ React.createElement(Box, { + flexDirection: "row", + gap: "1", + alignItems: "center" + }, /* @__PURE__ */ React.createElement(TokenImage, { + src: coinImageUrl, + size: "xs" + }), /* @__PURE__ */ React.createElement(Text, { + fontWeight: "normal", + fontSize: "normal", + color: "text100" + }, `${formatDisplay$1(requestAmount)} ${coinSymbol}`))), /* @__PURE__ */ React.createElement(Box, { + flexDirection: "column", + alignItems: "center", + justifyContent: "center", + gap: "2" + }, displayCreditCardCheckout && /* @__PURE__ */ React.createElement(Button, { + style: { + borderRadius: vars.radii.md, + height: "56px" + }, + width: "full", + borderRadius: "md", + leftIcon: SvgPaymentsIcon, + variant: "primary", + label: "Pay with credit card", + rightIcon: SvgChevronRightIcon, + onClick: onClickPayWithCard + }), displayCryptoCheckout && !isInsufficientBalance && !isPending && /* @__PURE__ */ React.createElement(Button, { + style: { + borderRadius: vars.radii.md, + height: "56px" + }, + width: "full", + leftIcon: () => /* @__PURE__ */ React.createElement(TokenImage, { + src: coinImageUrl, + size: "sm" + }), + variant: "primary", + label: `Pay with ${coinSymbol}`, + rightIcon: SvgChevronRightIcon, + onClick: onClickPayWithCrypto + }), displayCryptoCheckout && (isInsufficientBalance || isPending) && /* @__PURE__ */ React.createElement(Button, { + shape: "square", + width: "full", + variant: "glass", + label: /* @__PURE__ */ React.createElement(Box, { + placeItems: "center", + gap: "2" + }, /* @__PURE__ */ React.createElement(TokenImage, { + src: coinImageUrl, + size: "sm" + }), /* @__PURE__ */ React.createElement(Text, null, "Insufficient $", coinSymbol)), + onClick: onClickPayWithCrypto, + disabled: true + })), displayCryptoCheckout && /* @__PURE__ */ React.createElement(Box, { + width: "full", + justifyContent: "flex-end" + }, isPending ? /* @__PURE__ */ React.createElement(Skeleton, { + style: { + width: "102px", + height: "14px" } - reselectPrevious(); - } - return success; -} -var copyToClipboard = copy; -function _typeof(obj) { - "@babel/helpers - typeof"; - return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) { - return typeof obj2; - } : function(obj2) { - return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; - }, _typeof(obj); -} -Object.defineProperty(Component, "__esModule", { - value: true -}); -Component.CopyToClipboard = void 0; -var _react = _interopRequireDefault(reactExports); -var _copyToClipboard = _interopRequireDefault(copyToClipboard); -var _excluded$4 = ["text", "onCopy", "options", "children"]; -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : { "default": obj }; -} -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - enumerableOnly && (symbols = symbols.filter(function(sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - })), keys.push.apply(keys, symbols); - } - return keys; -} -function _objectSpread(target) { - for (var i2 = 1; i2 < arguments.length; i2++) { - var source = null != arguments[i2] ? arguments[i2] : {}; - i2 % 2 ? ownKeys(Object(source), true).forEach(function(key2) { - _defineProperty(target, key2, source[key2]); - }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key2) { - Object.defineProperty(target, key2, Object.getOwnPropertyDescriptor(source, key2)); - }); - } - return target; -} -function _objectWithoutProperties(source, excluded) { - if (source == null) - return {}; - var target = _objectWithoutPropertiesLoose$2(source, excluded); - var key2, i2; - if (Object.getOwnPropertySymbols) { - var sourceSymbolKeys = Object.getOwnPropertySymbols(source); - for (i2 = 0; i2 < sourceSymbolKeys.length; i2++) { - key2 = sourceSymbolKeys[i2]; - if (excluded.indexOf(key2) >= 0) - continue; - if (!Object.prototype.propertyIsEnumerable.call(source, key2)) - continue; - target[key2] = source[key2]; + }) : /* @__PURE__ */ React.createElement(Text, { + fontWeight: "bold", + fontSize: "small", + color: "text50" + }, "Balance: ", `${formatDisplay$1(userBalance)} ${coinSymbol}`))); +}; +const DEFAULT_LOCATION$1 = { + location: "select-method-checkout" +}; +const KitCheckoutProvider = (props) => { + const queryClient2 = new QueryClient(); + return /* @__PURE__ */ React.createElement(QueryClientProvider, { + client: queryClient2 + }, /* @__PURE__ */ React.createElement(KitCheckoutContent, props)); +}; +const KitCheckoutContent = ({ + children +}) => { + const { + theme, + position + } = useTheme(); + const [openCheckoutModal, setOpenCheckoutModal] = reactExports.useState(false); + const [settings, setSettings] = reactExports.useState(); + const [history, setHistory] = reactExports.useState([]); + const navigation = history.length > 0 ? history[history.length - 1] : DEFAULT_LOCATION$1; + const triggerCheckout = (settings2) => { + setSettings(settings2); + setOpenCheckoutModal(true); + }; + const closeCheckout = () => { + setOpenCheckoutModal(false); + }; + const getContent2 = () => { + const { + location: location2 + } = navigation; + switch (location2) { + case "select-method-checkout": + return /* @__PURE__ */ React.createElement(CheckoutSelection, null); + case "transaction-pending": + return /* @__PURE__ */ React.createElement(PendingTransaction, null); + case "transaction-success": + return /* @__PURE__ */ React.createElement(TransactionSuccess, null); + case "transaction-error": + return /* @__PURE__ */ React.createElement(TransactionError, null); + case "transaction-form": + default: + return /* @__PURE__ */ React.createElement(CheckoutSelection, null); } - } - return target; -} -function _objectWithoutPropertiesLoose$2(source, excluded) { - if (source == null) - return {}; - var target = {}; - var sourceKeys = Object.keys(source); - var key2, i2; - for (i2 = 0; i2 < sourceKeys.length; i2++) { - key2 = sourceKeys[i2]; - if (excluded.indexOf(key2) >= 0) - continue; - target[key2] = source[key2]; - } - return target; -} -function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } -} -function _defineProperties(target, props) { - for (var i2 = 0; i2 < props.length; i2++) { - var descriptor = props[i2]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) - descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } -} -function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) - _defineProperties(Constructor.prototype, protoProps); - Object.defineProperty(Constructor, "prototype", { writable: false }); - return Constructor; -} -function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function"); - } - subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); - Object.defineProperty(subClass, "prototype", { writable: false }); - if (superClass) - _setPrototypeOf(subClass, superClass); -} -function _setPrototypeOf(o2, p2) { - _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o3, p3) { - o3.__proto__ = p3; - return o3; }; - return _setPrototypeOf(o2, p2); -} -function _createSuper(Derived) { - var hasNativeReflectConstruct = _isNativeReflectConstruct(); - return function _createSuperInternal() { - var Super = _getPrototypeOf(Derived), result; - if (hasNativeReflectConstruct) { - var NewTarget = _getPrototypeOf(this).constructor; - result = Reflect.construct(Super, arguments, NewTarget); - } else { - result = Super.apply(this, arguments); + const getHeader2 = () => { + const { + location: location2 + } = navigation; + switch (location2) { + case "select-method-checkout": + return /* @__PURE__ */ React.createElement(NavigationHeader$1, { + primaryText: "Checkout" + }); + case "transaction-success": + case "transaction-error": + case "transaction-pending": + return /* @__PURE__ */ React.createElement(NavigationHeader$1, { + disableBack: true, + primaryText: "Pay with credit or debit card" + }); + case "transaction-form": + default: + return /* @__PURE__ */ React.createElement(NavigationHeader$1, { + primaryText: "Pay with credit or debit card" + }); } - return _possibleConstructorReturn(this, result); }; -} -function _possibleConstructorReturn(self2, call2) { - if (call2 && (_typeof(call2) === "object" || typeof call2 === "function")) { - return call2; - } else if (call2 !== void 0) { - throw new TypeError("Derived constructors may only return object or undefined"); - } - return _assertThisInitialized(self2); -} -function _assertThisInitialized(self2) { - if (self2 === void 0) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - return self2; -} -function _isNativeReflectConstruct() { - if (typeof Reflect === "undefined" || !Reflect.construct) - return false; - if (Reflect.construct.sham) - return false; - if (typeof Proxy === "function") - return true; - try { - Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() { - })); - return true; - } catch (e2) { - return false; - } -} -function _getPrototypeOf(o2) { - _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o3) { - return o3.__proto__ || Object.getPrototypeOf(o3); + reactExports.useEffect(() => { + if (openCheckoutModal) { + setHistory([]); + } + }, [openCheckoutModal]); + return /* @__PURE__ */ React.createElement(CheckoutModalContextProvider, { + value: { + triggerCheckout, + closeCheckout, + settings, + theme + } + }, /* @__PURE__ */ React.createElement(NavigationContextProvider$1, { + value: { + history, + setHistory + } + }, /* @__PURE__ */ React.createElement("div", { + id: "kit-checkout" + }, /* @__PURE__ */ React.createElement(ThemeProvider, { + root: "#kit-checkout", + scope: "kit", + theme + }, /* @__PURE__ */ React.createElement(AnimatePresence, null, openCheckoutModal && /* @__PURE__ */ React.createElement(Modal, { + contentProps: { + style: _extends$4({ + maxWidth: "400px", + height: "auto" + }, getModalPositionCss(position)) + }, + scroll: false, + backdropColor: "backgroundBackdrop", + onClose: () => setOpenCheckoutModal(false) + }, /* @__PURE__ */ React.createElement(Box, { + id: "sequence-kit-checkout-content" + }, getHeader2(), getContent2()))))), children)); +}; +const useNavigation$1 = () => { + const { + setHistory, + history + } = useNavigationContext$1(); + const setNavigation = (navigation2) => { + const childElement = document.getElementById("sequence-kit-wallet-content"); + const parentElement = childElement == null ? void 0 : childElement.parentElement; + parentElement == null || parentElement.scrollTo(0, 0); + const newHistory = [...history, navigation2]; + setHistory(newHistory); }; - return _getPrototypeOf(o2); -} -function _defineProperty(obj, key2, value) { - if (key2 in obj) { - Object.defineProperty(obj, key2, { value, enumerable: true, configurable: true, writable: true }); - } else { - obj[key2] = value; - } - return obj; -} -var CopyToClipboard$1 = /* @__PURE__ */ function(_React$PureComponent) { - _inherits(CopyToClipboard2, _React$PureComponent); - var _super = _createSuper(CopyToClipboard2); - function CopyToClipboard2() { - var _this; - _classCallCheck(this, CopyToClipboard2); - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + const goBack = () => { + const newHistory = [...history]; + newHistory.pop(); + setHistory(newHistory); + }; + const navigation = history.length > 0 ? history[history.length - 1] : DEFAULT_LOCATION$1; + return { + setNavigation, + history, + setHistory, + goBack, + navigation + }; +}; +var __defProp2 = Object.defineProperty; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp2 = (obj, key2, value) => key2 in obj ? __defProp2(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value; +var __spreadValues = (a2, b2) => { + for (var prop in b2 || (b2 = {})) + if (__hasOwnProp.call(b2, prop)) + __defNormalProp2(a2, prop, b2[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b2)) { + if (__propIsEnum.call(b2, prop)) + __defNormalProp2(a2, prop, b2[prop]); } - _this = _super.call.apply(_super, [this].concat(args)); - _defineProperty(_assertThisInitialized(_this), "onClick", function(event) { - var _this$props = _this.props, text2 = _this$props.text, onCopy = _this$props.onCopy, children = _this$props.children, options = _this$props.options; - var elem = _react["default"].Children.only(children); - var result = (0, _copyToClipboard["default"])(text2, options); - if (onCopy) { - onCopy(text2, result); + return a2; +}; +var __objRest = (source, exclude) => { + var target = {}; + for (var prop in source) + if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) + target[prop] = source[prop]; + if (source != null && __getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(source)) { + if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) + target[prop] = source[prop]; + } + return target; +}; +/** + * @license QR Code generator library (TypeScript) + * Copyright (c) Project Nayuki. + * SPDX-License-Identifier: MIT + */ +var qrcodegen; +((qrcodegen2) => { + const _QrCode = class { + constructor(version2, errorCorrectionLevel, dataCodewords, msk) { + this.version = version2; + this.errorCorrectionLevel = errorCorrectionLevel; + this.modules = []; + this.isFunction = []; + if (version2 < _QrCode.MIN_VERSION || version2 > _QrCode.MAX_VERSION) + throw new RangeError("Version value out of range"); + if (msk < -1 || msk > 7) + throw new RangeError("Mask value out of range"); + this.size = version2 * 4 + 17; + let row = []; + for (let i2 = 0; i2 < this.size; i2++) + row.push(false); + for (let i2 = 0; i2 < this.size; i2++) { + this.modules.push(row.slice()); + this.isFunction.push(row.slice()); } - if (elem && elem.props && typeof elem.props.onClick === "function") { - elem.props.onClick(event); + this.drawFunctionPatterns(); + const allCodewords = this.addEccAndInterleave(dataCodewords); + this.drawCodewords(allCodewords); + if (msk == -1) { + let minPenalty = 1e9; + for (let i2 = 0; i2 < 8; i2++) { + this.applyMask(i2); + this.drawFormatBits(i2); + const penalty = this.getPenaltyScore(); + if (penalty < minPenalty) { + msk = i2; + minPenalty = penalty; + } + this.applyMask(i2); + } } - }); - return _this; - } - _createClass(CopyToClipboard2, [{ - key: "render", - value: function render() { - var _this$props2 = this.props; - _this$props2.text; - _this$props2.onCopy; - _this$props2.options; - var children = _this$props2.children, props = _objectWithoutProperties(_this$props2, _excluded$4); - var elem = _react["default"].Children.only(children); - return /* @__PURE__ */ _react["default"].cloneElement(elem, _objectSpread(_objectSpread({}, props), {}, { - onClick: this.onClick - })); + assert2(0 <= msk && msk <= 7); + this.mask = msk; + this.applyMask(msk); + this.drawFormatBits(msk); + this.isFunction = []; } - }]); - return CopyToClipboard2; -}(_react["default"].PureComponent); -Component.CopyToClipboard = CopyToClipboard$1; -_defineProperty(CopyToClipboard$1, "defaultProps", { - onCopy: void 0, - options: void 0 -}); -var _require = Component, CopyToClipboard = _require.CopyToClipboard; -CopyToClipboard.CopyToClipboard = CopyToClipboard; -var lib = CopyToClipboard; -var dayjs_min = { exports: {} }; -(function(module2, exports) { - !function(t2, e2) { - module2.exports = e2(); - }(commonjsGlobal, function() { - var t2 = 1e3, e2 = 6e4, n2 = 36e5, r2 = "millisecond", i2 = "second", s2 = "minute", u2 = "hour", a2 = "day", o2 = "week", c2 = "month", f2 = "quarter", h2 = "year", d2 = "date", l2 = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y2 = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M2 = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t3) { - var e3 = ["th", "st", "nd", "rd"], n3 = t3 % 100; - return "[" + t3 + (e3[(n3 - 20) % 10] || e3[n3] || e3[0]) + "]"; - } }, m2 = function(t3, e3, n3) { - var r3 = String(t3); - return !r3 || r3.length >= e3 ? t3 : "" + Array(e3 + 1 - r3.length).join(n3) + t3; - }, v3 = { s: m2, z: function(t3) { - var e3 = -t3.utcOffset(), n3 = Math.abs(e3), r3 = Math.floor(n3 / 60), i3 = n3 % 60; - return (e3 <= 0 ? "+" : "-") + m2(r3, 2, "0") + ":" + m2(i3, 2, "0"); - }, m: function t3(e3, n3) { - if (e3.date() < n3.date()) - return -t3(n3, e3); - var r3 = 12 * (n3.year() - e3.year()) + (n3.month() - e3.month()), i3 = e3.clone().add(r3, c2), s3 = n3 - i3 < 0, u3 = e3.clone().add(r3 + (s3 ? -1 : 1), c2); - return +(-(r3 + (n3 - i3) / (s3 ? i3 - u3 : u3 - i3)) || 0); - }, a: function(t3) { - return t3 < 0 ? Math.ceil(t3) || 0 : Math.floor(t3); - }, p: function(t3) { - return { M: c2, y: h2, w: o2, d: a2, D: d2, h: u2, m: s2, s: i2, ms: r2, Q: f2 }[t3] || String(t3 || "").toLowerCase().replace(/s$/, ""); - }, u: function(t3) { - return void 0 === t3; - } }, g2 = "en", D2 = {}; - D2[g2] = M2; - var p2 = "$isDayjsObject", S2 = function(t3) { - return t3 instanceof _ || !(!t3 || !t3[p2]); - }, w2 = function t3(e3, n3, r3) { - var i3; - if (!e3) - return g2; - if ("string" == typeof e3) { - var s3 = e3.toLowerCase(); - D2[s3] && (i3 = s3), n3 && (D2[s3] = n3, i3 = s3); - var u3 = e3.split("-"); - if (!i3 && u3.length > 1) - return t3(u3[0]); - } else { - var a3 = e3.name; - D2[a3] = e3, i3 = a3; - } - return !r3 && i3 && (g2 = i3), i3 || !r3 && g2; - }, O2 = function(t3, e3) { - if (S2(t3)) - return t3.clone(); - var n3 = "object" == typeof e3 ? e3 : {}; - return n3.date = t3, n3.args = arguments, new _(n3); - }, b2 = v3; - b2.l = w2, b2.i = S2, b2.w = function(t3, e3) { - return O2(t3, { locale: e3.$L, utc: e3.$u, x: e3.$x, $offset: e3.$offset }); - }; - var _ = function() { - function M3(t3) { - this.$L = w2(t3.locale, null, true), this.parse(t3), this.$x = this.$x || t3.x || {}, this[p2] = true; - } - var m3 = M3.prototype; - return m3.parse = function(t3) { - this.$d = function(t4) { - var e3 = t4.date, n3 = t4.utc; - if (null === e3) - return /* @__PURE__ */ new Date(NaN); - if (b2.u(e3)) - return /* @__PURE__ */ new Date(); - if (e3 instanceof Date) - return new Date(e3); - if ("string" == typeof e3 && !/Z$/i.test(e3)) { - var r3 = e3.match($); - if (r3) { - var i3 = r3[2] - 1 || 0, s3 = (r3[7] || "0").substring(0, 3); - return n3 ? new Date(Date.UTC(r3[1], i3, r3[3] || 1, r3[4] || 0, r3[5] || 0, r3[6] || 0, s3)) : new Date(r3[1], i3, r3[3] || 1, r3[4] || 0, r3[5] || 0, r3[6] || 0, s3); - } - } - return new Date(e3); - }(t3), this.init(); - }, m3.init = function() { - var t3 = this.$d; - this.$y = t3.getFullYear(), this.$M = t3.getMonth(), this.$D = t3.getDate(), this.$W = t3.getDay(), this.$H = t3.getHours(), this.$m = t3.getMinutes(), this.$s = t3.getSeconds(), this.$ms = t3.getMilliseconds(); - }, m3.$utils = function() { - return b2; - }, m3.isValid = function() { - return !(this.$d.toString() === l2); - }, m3.isSame = function(t3, e3) { - var n3 = O2(t3); - return this.startOf(e3) <= n3 && n3 <= this.endOf(e3); - }, m3.isAfter = function(t3, e3) { - return O2(t3) < this.startOf(e3); - }, m3.isBefore = function(t3, e3) { - return this.endOf(e3) < O2(t3); - }, m3.$g = function(t3, e3, n3) { - return b2.u(t3) ? this[e3] : this.set(n3, t3); - }, m3.unix = function() { - return Math.floor(this.valueOf() / 1e3); - }, m3.valueOf = function() { - return this.$d.getTime(); - }, m3.startOf = function(t3, e3) { - var n3 = this, r3 = !!b2.u(e3) || e3, f3 = b2.p(t3), l3 = function(t4, e4) { - var i3 = b2.w(n3.$u ? Date.UTC(n3.$y, e4, t4) : new Date(n3.$y, e4, t4), n3); - return r3 ? i3 : i3.endOf(a2); - }, $2 = function(t4, e4) { - return b2.w(n3.toDate()[t4].apply(n3.toDate("s"), (r3 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e4)), n3); - }, y3 = this.$W, M4 = this.$M, m4 = this.$D, v5 = "set" + (this.$u ? "UTC" : ""); - switch (f3) { - case h2: - return r3 ? l3(1, 0) : l3(31, 11); - case c2: - return r3 ? l3(1, M4) : l3(0, M4 + 1); - case o2: - var g3 = this.$locale().weekStart || 0, D3 = (y3 < g3 ? y3 + 7 : y3) - g3; - return l3(r3 ? m4 - D3 : m4 + (6 - D3), M4); - case a2: - case d2: - return $2(v5 + "Hours", 0); - case u2: - return $2(v5 + "Minutes", 1); - case s2: - return $2(v5 + "Seconds", 2); - case i2: - return $2(v5 + "Milliseconds", 3); - default: - return this.clone(); - } - }, m3.endOf = function(t3) { - return this.startOf(t3, false); - }, m3.$set = function(t3, e3) { - var n3, o3 = b2.p(t3), f3 = "set" + (this.$u ? "UTC" : ""), l3 = (n3 = {}, n3[a2] = f3 + "Date", n3[d2] = f3 + "Date", n3[c2] = f3 + "Month", n3[h2] = f3 + "FullYear", n3[u2] = f3 + "Hours", n3[s2] = f3 + "Minutes", n3[i2] = f3 + "Seconds", n3[r2] = f3 + "Milliseconds", n3)[o3], $2 = o3 === a2 ? this.$D + (e3 - this.$W) : e3; - if (o3 === c2 || o3 === h2) { - var y3 = this.clone().set(d2, 1); - y3.$d[l3]($2), y3.init(), this.$d = y3.set(d2, Math.min(this.$D, y3.daysInMonth())).$d; - } else - l3 && this.$d[l3]($2); - return this.init(), this; - }, m3.set = function(t3, e3) { - return this.clone().$set(t3, e3); - }, m3.get = function(t3) { - return this[b2.p(t3)](); - }, m3.add = function(r3, f3) { - var d3, l3 = this; - r3 = Number(r3); - var $2 = b2.p(f3), y3 = function(t3) { - var e3 = O2(l3); - return b2.w(e3.date(e3.date() + Math.round(t3 * r3)), l3); - }; - if ($2 === c2) - return this.set(c2, this.$M + r3); - if ($2 === h2) - return this.set(h2, this.$y + r3); - if ($2 === a2) - return y3(1); - if ($2 === o2) - return y3(7); - var M4 = (d3 = {}, d3[s2] = e2, d3[u2] = n2, d3[i2] = t2, d3)[$2] || 1, m4 = this.$d.getTime() + r3 * M4; - return b2.w(m4, this); - }, m3.subtract = function(t3, e3) { - return this.add(-1 * t3, e3); - }, m3.format = function(t3) { - var e3 = this, n3 = this.$locale(); - if (!this.isValid()) - return n3.invalidDate || l2; - var r3 = t3 || "YYYY-MM-DDTHH:mm:ssZ", i3 = b2.z(this), s3 = this.$H, u3 = this.$m, a3 = this.$M, o3 = n3.weekdays, c3 = n3.months, f3 = n3.meridiem, h3 = function(t4, n4, i4, s4) { - return t4 && (t4[n4] || t4(e3, r3)) || i4[n4].slice(0, s4); - }, d3 = function(t4) { - return b2.s(s3 % 12 || 12, t4, "0"); - }, $2 = f3 || function(t4, e4, n4) { - var r4 = t4 < 12 ? "AM" : "PM"; - return n4 ? r4.toLowerCase() : r4; - }; - return r3.replace(y2, function(t4, r4) { - return r4 || function(t5) { - switch (t5) { - case "YY": - return String(e3.$y).slice(-2); - case "YYYY": - return b2.s(e3.$y, 4, "0"); - case "M": - return a3 + 1; - case "MM": - return b2.s(a3 + 1, 2, "0"); - case "MMM": - return h3(n3.monthsShort, a3, c3, 3); - case "MMMM": - return h3(c3, a3); - case "D": - return e3.$D; - case "DD": - return b2.s(e3.$D, 2, "0"); - case "d": - return String(e3.$W); - case "dd": - return h3(n3.weekdaysMin, e3.$W, o3, 2); - case "ddd": - return h3(n3.weekdaysShort, e3.$W, o3, 3); - case "dddd": - return o3[e3.$W]; - case "H": - return String(s3); - case "HH": - return b2.s(s3, 2, "0"); - case "h": - return d3(1); - case "hh": - return d3(2); - case "a": - return $2(s3, u3, true); - case "A": - return $2(s3, u3, false); - case "m": - return String(u3); - case "mm": - return b2.s(u3, 2, "0"); - case "s": - return String(e3.$s); - case "ss": - return b2.s(e3.$s, 2, "0"); - case "SSS": - return b2.s(e3.$ms, 3, "0"); - case "Z": - return i3; - } - return null; - }(t4) || i3.replace(":", ""); - }); - }, m3.utcOffset = function() { - return 15 * -Math.round(this.$d.getTimezoneOffset() / 15); - }, m3.diff = function(r3, d3, l3) { - var $2, y3 = this, M4 = b2.p(d3), m4 = O2(r3), v5 = (m4.utcOffset() - this.utcOffset()) * e2, g3 = this - m4, D3 = function() { - return b2.m(y3, m4); - }; - switch (M4) { - case h2: - $2 = D3() / 12; - break; - case c2: - $2 = D3(); - break; - case f2: - $2 = D3() / 3; - break; - case o2: - $2 = (g3 - v5) / 6048e5; - break; - case a2: - $2 = (g3 - v5) / 864e5; - break; - case u2: - $2 = g3 / n2; - break; - case s2: - $2 = g3 / e2; - break; - case i2: - $2 = g3 / t2; - break; - default: - $2 = g3; + static encodeText(text2, ecl) { + const segs = qrcodegen2.QrSegment.makeSegments(text2); + return _QrCode.encodeSegments(segs, ecl); + } + static encodeBinary(data, ecl) { + const seg = qrcodegen2.QrSegment.makeBytes(data); + return _QrCode.encodeSegments([seg], ecl); + } + static encodeSegments(segs, ecl, minVersion = 1, maxVersion = 40, mask = -1, boostEcl = true) { + if (!(_QrCode.MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= _QrCode.MAX_VERSION) || mask < -1 || mask > 7) + throw new RangeError("Invalid value"); + let version2; + let dataUsedBits; + for (version2 = minVersion; ; version2++) { + const dataCapacityBits2 = _QrCode.getNumDataCodewords(version2, ecl) * 8; + const usedBits = QrSegment.getTotalBits(segs, version2); + if (usedBits <= dataCapacityBits2) { + dataUsedBits = usedBits; + break; } - return l3 ? $2 : b2.a($2); - }, m3.daysInMonth = function() { - return this.endOf(c2).$D; - }, m3.$locale = function() { - return D2[this.$L]; - }, m3.locale = function(t3, e3) { - if (!t3) - return this.$L; - var n3 = this.clone(), r3 = w2(t3, e3, true); - return r3 && (n3.$L = r3), n3; - }, m3.clone = function() { - return b2.w(this.$d, this); - }, m3.toDate = function() { - return new Date(this.valueOf()); - }, m3.toJSON = function() { - return this.isValid() ? this.toISOString() : null; - }, m3.toISOString = function() { - return this.$d.toISOString(); - }, m3.toString = function() { - return this.$d.toUTCString(); - }, M3; - }(), k2 = _.prototype; - return O2.prototype = k2, [["$ms", r2], ["$s", i2], ["$m", s2], ["$H", u2], ["$W", a2], ["$M", c2], ["$y", h2], ["$D", d2]].forEach(function(t3) { - k2[t3[1]] = function(e3) { - return this.$g(e3, t3[0], t3[1]); - }; - }), O2.extend = function(t3, e3) { - return t3.$i || (t3(e3, _, O2), t3.$i = true), O2; - }, O2.locale = w2, O2.isDayjs = S2, O2.unix = function(t3) { - return O2(1e3 * t3); - }, O2.en = D2[g2], O2.Ls = D2, O2.p = {}, O2; - }); -})(dayjs_min); -var dayjs_minExports = dayjs_min.exports; -const dayjs = /* @__PURE__ */ getDefaultExportFromCjs$1(dayjs_minExports); -function isArray(value) { - return !Array.isArray ? getTag(value) === "[object Array]" : Array.isArray(value); -} -const INFINITY = 1 / 0; -function baseToString(value) { - if (typeof value == "string") { - return value; - } - let result = value + ""; - return result == "0" && 1 / value == -INFINITY ? "-0" : result; -} -function toString(value) { - return value == null ? "" : baseToString(value); -} -function isString(value) { - return typeof value === "string"; -} -function isNumber(value) { - return typeof value === "number"; -} -function isBoolean(value) { - return value === true || value === false || isObjectLike(value) && getTag(value) == "[object Boolean]"; -} -function isObject(value) { - return typeof value === "object"; -} -function isObjectLike(value) { - return isObject(value) && value !== null; -} -function isDefined(value) { - return value !== void 0 && value !== null; -} -function isBlank(value) { - return !value.trim().length; -} -function getTag(value) { - return value == null ? value === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(value); -} -const EXTENDED_SEARCH_UNAVAILABLE = "Extended search is not available"; -const INCORRECT_INDEX_TYPE = "Incorrect 'index' type"; -const LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key2) => `Invalid value for key ${key2}`; -const PATTERN_LENGTH_TOO_LARGE = (max2) => `Pattern length exceeds max of ${max2}.`; -const MISSING_KEY_PROPERTY = (name2) => `Missing ${name2} property in key`; -const INVALID_KEY_WEIGHT_VALUE = (key2) => `Property 'weight' in key '${key2}' must be a positive integer`; -const hasOwn = Object.prototype.hasOwnProperty; -class KeyStore { - constructor(keys) { - this._keys = []; - this._keyMap = {}; - let totalWeight = 0; - keys.forEach((key2) => { - let obj = createKey(key2); - totalWeight += obj.weight; - this._keys.push(obj); - this._keyMap[obj.id] = obj; - totalWeight += obj.weight; - }); - this._keys.forEach((key2) => { - key2.weight /= totalWeight; - }); - } - get(keyId) { - return this._keyMap[keyId]; - } - keys() { - return this._keys; - } - toJSON() { - return JSON.stringify(this._keys); - } -} -function createKey(key2) { - let path = null; - let id2 = null; - let src = null; - let weight = 1; - let getFn = null; - if (isString(key2) || isArray(key2)) { - src = key2; - path = createKeyPath(key2); - id2 = createKeyId(key2); - } else { - if (!hasOwn.call(key2, "name")) { - throw new Error(MISSING_KEY_PROPERTY("name")); + if (version2 >= maxVersion) + throw new RangeError("Data too long"); + } + for (const newEcl of [_QrCode.Ecc.MEDIUM, _QrCode.Ecc.QUARTILE, _QrCode.Ecc.HIGH]) { + if (boostEcl && dataUsedBits <= _QrCode.getNumDataCodewords(version2, newEcl) * 8) + ecl = newEcl; + } + let bb2 = []; + for (const seg of segs) { + appendBits(seg.mode.modeBits, 4, bb2); + appendBits(seg.numChars, seg.mode.numCharCountBits(version2), bb2); + for (const b2 of seg.getData()) + bb2.push(b2); + } + assert2(bb2.length == dataUsedBits); + const dataCapacityBits = _QrCode.getNumDataCodewords(version2, ecl) * 8; + assert2(bb2.length <= dataCapacityBits); + appendBits(0, Math.min(4, dataCapacityBits - bb2.length), bb2); + appendBits(0, (8 - bb2.length % 8) % 8, bb2); + assert2(bb2.length % 8 == 0); + for (let padByte = 236; bb2.length < dataCapacityBits; padByte ^= 236 ^ 17) + appendBits(padByte, 8, bb2); + let dataCodewords = []; + while (dataCodewords.length * 8 < bb2.length) + dataCodewords.push(0); + bb2.forEach((b2, i2) => dataCodewords[i2 >>> 3] |= b2 << 7 - (i2 & 7)); + return new _QrCode(version2, ecl, dataCodewords, mask); } - const name2 = key2.name; - src = name2; - if (hasOwn.call(key2, "weight")) { - weight = key2.weight; - if (weight <= 0) { - throw new Error(INVALID_KEY_WEIGHT_VALUE(name2)); + getModule(x, y2) { + return 0 <= x && x < this.size && 0 <= y2 && y2 < this.size && this.modules[y2][x]; + } + getModules() { + return this.modules; + } + drawFunctionPatterns() { + for (let i2 = 0; i2 < this.size; i2++) { + this.setFunctionModule(6, i2, i2 % 2 == 0); + this.setFunctionModule(i2, 6, i2 % 2 == 0); + } + this.drawFinderPattern(3, 3); + this.drawFinderPattern(this.size - 4, 3); + this.drawFinderPattern(3, this.size - 4); + const alignPatPos = this.getAlignmentPatternPositions(); + const numAlign = alignPatPos.length; + for (let i2 = 0; i2 < numAlign; i2++) { + for (let j2 = 0; j2 < numAlign; j2++) { + if (!(i2 == 0 && j2 == 0 || i2 == 0 && j2 == numAlign - 1 || i2 == numAlign - 1 && j2 == 0)) + this.drawAlignmentPattern(alignPatPos[i2], alignPatPos[j2]); + } } + this.drawFormatBits(0); + this.drawVersion(); } - path = createKeyPath(name2); - id2 = createKeyId(name2); - getFn = key2.getFn; - } - return { path, id: id2, weight, src, getFn }; -} -function createKeyPath(key2) { - return isArray(key2) ? key2 : key2.split("."); -} -function createKeyId(key2) { - return isArray(key2) ? key2.join(".") : key2; -} -function get(obj, path) { - let list2 = []; - let arr = false; - const deepGet = (obj2, path2, index2) => { - if (!isDefined(obj2)) { - return; + drawFormatBits(mask) { + const data = this.errorCorrectionLevel.formatBits << 3 | mask; + let rem = data; + for (let i2 = 0; i2 < 10; i2++) + rem = rem << 1 ^ (rem >>> 9) * 1335; + const bits = (data << 10 | rem) ^ 21522; + assert2(bits >>> 15 == 0); + for (let i2 = 0; i2 <= 5; i2++) + this.setFunctionModule(8, i2, getBit(bits, i2)); + this.setFunctionModule(8, 7, getBit(bits, 6)); + this.setFunctionModule(8, 8, getBit(bits, 7)); + this.setFunctionModule(7, 8, getBit(bits, 8)); + for (let i2 = 9; i2 < 15; i2++) + this.setFunctionModule(14 - i2, 8, getBit(bits, i2)); + for (let i2 = 0; i2 < 8; i2++) + this.setFunctionModule(this.size - 1 - i2, 8, getBit(bits, i2)); + for (let i2 = 8; i2 < 15; i2++) + this.setFunctionModule(8, this.size - 15 + i2, getBit(bits, i2)); + this.setFunctionModule(8, this.size - 8, true); } - if (!path2[index2]) { - list2.push(obj2); - } else { - let key2 = path2[index2]; - const value = obj2[key2]; - if (!isDefined(value)) { + drawVersion() { + if (this.version < 7) return; + let rem = this.version; + for (let i2 = 0; i2 < 12; i2++) + rem = rem << 1 ^ (rem >>> 11) * 7973; + const bits = this.version << 12 | rem; + assert2(bits >>> 18 == 0); + for (let i2 = 0; i2 < 18; i2++) { + const color2 = getBit(bits, i2); + const a2 = this.size - 11 + i2 % 3; + const b2 = Math.floor(i2 / 3); + this.setFunctionModule(a2, b2, color2); + this.setFunctionModule(b2, a2, color2); } - if (index2 === path2.length - 1 && (isString(value) || isNumber(value) || isBoolean(value))) { - list2.push(toString(value)); - } else if (isArray(value)) { - arr = true; - for (let i2 = 0, len = value.length; i2 < len; i2 += 1) { - deepGet(value[i2], path2, index2 + 1); + } + drawFinderPattern(x, y2) { + for (let dy = -4; dy <= 4; dy++) { + for (let dx = -4; dx <= 4; dx++) { + const dist2 = Math.max(Math.abs(dx), Math.abs(dy)); + const xx = x + dx; + const yy = y2 + dy; + if (0 <= xx && xx < this.size && 0 <= yy && yy < this.size) + this.setFunctionModule(xx, yy, dist2 != 2 && dist2 != 4); } - } else if (path2.length) { - deepGet(value, path2, index2 + 1); } } - }; - deepGet(obj, isString(path) ? path.split(".") : path, 0); - return arr ? list2 : list2[0]; -} -const MatchOptions = { - // Whether the matches should be included in the result set. When `true`, each record in the result - // set will include the indices of the matched characters. - // These can consequently be used for highlighting purposes. - includeMatches: false, - // When `true`, the matching function will continue to the end of a search pattern even if - // a perfect match has already been located in the string. - findAllMatches: false, - // Minimum number of characters that must be matched before a result is considered a match - minMatchCharLength: 1 -}; -const BasicOptions = { - // When `true`, the algorithm continues searching to the end of the input even if a perfect - // match is found before the end of the same input. - isCaseSensitive: false, - // When true, the matching function will continue to the end of a search pattern even if - includeScore: false, - // List of properties that will be searched. This also supports nested properties. - keys: [], - // Whether to sort the result list, by score - shouldSort: true, - // Default sort function: sort by ascending score, ascending index - sortFn: (a2, b2) => a2.score === b2.score ? a2.idx < b2.idx ? -1 : 1 : a2.score < b2.score ? -1 : 1 -}; -const FuzzyOptions = { - // Approximately where in the text is the pattern expected to be found? - location: 0, - // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match - // (of both letters and location), a threshold of '1.0' would match anything. - threshold: 0.6, - // Determines how close the match must be to the fuzzy location (specified above). - // An exact letter match which is 'distance' characters away from the fuzzy location - // would score as a complete mismatch. A distance of '0' requires the match be at - // the exact location specified, a threshold of '1000' would require a perfect match - // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold. - distance: 100 -}; -const AdvancedOptions = { - // When `true`, it enables the use of unix-like search commands - useExtendedSearch: false, - // The get function to use when fetching an object's properties. - // The default will search nested paths *ie foo.bar.baz* - getFn: get, - // When `true`, search will ignore `location` and `distance`, so it won't matter - // where in the string the pattern appears. - // More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score - ignoreLocation: false, - // When `true`, the calculation for the relevance score (used for sorting) will - // ignore the field-length norm. - // More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm - ignoreFieldNorm: false, - // The weight to determine how much field length norm effects scoring. - fieldNormWeight: 1 -}; -var Config = { - ...BasicOptions, - ...MatchOptions, - ...FuzzyOptions, - ...AdvancedOptions -}; -const SPACE$1 = /[^ ]+/g; -function norm(weight = 1, mantissa = 3) { - const cache = /* @__PURE__ */ new Map(); - const m2 = Math.pow(10, mantissa); - return { - get(value) { - const numTokens = value.match(SPACE$1).length; - if (cache.has(numTokens)) { - return cache.get(numTokens); + drawAlignmentPattern(x, y2) { + for (let dy = -2; dy <= 2; dy++) { + for (let dx = -2; dx <= 2; dx++) + this.setFunctionModule(x + dx, y2 + dy, Math.max(Math.abs(dx), Math.abs(dy)) != 1); } - const norm2 = 1 / Math.pow(numTokens, 0.5 * weight); - const n2 = parseFloat(Math.round(norm2 * m2) / m2); - cache.set(numTokens, n2); - return n2; - }, - clear() { - cache.clear(); - } - }; -} -class FuseIndex { - constructor({ - getFn = Config.getFn, - fieldNormWeight = Config.fieldNormWeight - } = {}) { - this.norm = norm(fieldNormWeight, 3); - this.getFn = getFn; - this.isCreated = false; - this.setIndexRecords(); - } - setSources(docs = []) { - this.docs = docs; - } - setIndexRecords(records = []) { - this.records = records; - } - setKeys(keys = []) { - this.keys = keys; - this._keysMap = {}; - keys.forEach((key2, idx) => { - this._keysMap[key2.id] = idx; - }); - } - create() { - if (this.isCreated || !this.docs.length) { - return; } - this.isCreated = true; - if (isString(this.docs[0])) { - this.docs.forEach((doc, docIndex) => { - this._addString(doc, docIndex); - }); - } else { - this.docs.forEach((doc, docIndex) => { - this._addObject(doc, docIndex); - }); + setFunctionModule(x, y2, isDark) { + this.modules[y2][x] = isDark; + this.isFunction[y2][x] = true; } - this.norm.clear(); - } - // Adds a doc to the end of the index - add(doc) { - const idx = this.size(); - if (isString(doc)) { - this._addString(doc, idx); - } else { - this._addObject(doc, idx); + addEccAndInterleave(data) { + const ver = this.version; + const ecl = this.errorCorrectionLevel; + if (data.length != _QrCode.getNumDataCodewords(ver, ecl)) + throw new RangeError("Invalid argument"); + const numBlocks = _QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver]; + const blockEccLen = _QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver]; + const rawCodewords = Math.floor(_QrCode.getNumRawDataModules(ver) / 8); + const numShortBlocks = numBlocks - rawCodewords % numBlocks; + const shortBlockLen = Math.floor(rawCodewords / numBlocks); + let blocks = []; + const rsDiv = _QrCode.reedSolomonComputeDivisor(blockEccLen); + for (let i2 = 0, k2 = 0; i2 < numBlocks; i2++) { + let dat = data.slice(k2, k2 + shortBlockLen - blockEccLen + (i2 < numShortBlocks ? 0 : 1)); + k2 += dat.length; + const ecc = _QrCode.reedSolomonComputeRemainder(dat, rsDiv); + if (i2 < numShortBlocks) + dat.push(0); + blocks.push(dat.concat(ecc)); + } + let result = []; + for (let i2 = 0; i2 < blocks[0].length; i2++) { + blocks.forEach((block, j2) => { + if (i2 != shortBlockLen - blockEccLen || j2 >= numShortBlocks) + result.push(block[i2]); + }); + } + assert2(result.length == rawCodewords); + return result; } - } - // Removes the doc at the specified index of the index - removeAt(idx) { - this.records.splice(idx, 1); - for (let i2 = idx, len = this.size(); i2 < len; i2 += 1) { - this.records[i2].i -= 1; + drawCodewords(data) { + if (data.length != Math.floor(_QrCode.getNumRawDataModules(this.version) / 8)) + throw new RangeError("Invalid argument"); + let i2 = 0; + for (let right = this.size - 1; right >= 1; right -= 2) { + if (right == 6) + right = 5; + for (let vert = 0; vert < this.size; vert++) { + for (let j2 = 0; j2 < 2; j2++) { + const x = right - j2; + const upward = (right + 1 & 2) == 0; + const y2 = upward ? this.size - 1 - vert : vert; + if (!this.isFunction[y2][x] && i2 < data.length * 8) { + this.modules[y2][x] = getBit(data[i2 >>> 3], 7 - (i2 & 7)); + i2++; + } + } + } + } + assert2(i2 == data.length * 8); } - } - getValueForItemAtKeyId(item2, keyId) { - return item2[this._keysMap[keyId]]; - } - size() { - return this.records.length; - } - _addString(doc, docIndex) { - if (!isDefined(doc) || isBlank(doc)) { - return; + applyMask(mask) { + if (mask < 0 || mask > 7) + throw new RangeError("Mask value out of range"); + for (let y2 = 0; y2 < this.size; y2++) { + for (let x = 0; x < this.size; x++) { + let invert2; + switch (mask) { + case 0: + invert2 = (x + y2) % 2 == 0; + break; + case 1: + invert2 = y2 % 2 == 0; + break; + case 2: + invert2 = x % 3 == 0; + break; + case 3: + invert2 = (x + y2) % 3 == 0; + break; + case 4: + invert2 = (Math.floor(x / 3) + Math.floor(y2 / 2)) % 2 == 0; + break; + case 5: + invert2 = x * y2 % 2 + x * y2 % 3 == 0; + break; + case 6: + invert2 = (x * y2 % 2 + x * y2 % 3) % 2 == 0; + break; + case 7: + invert2 = ((x + y2) % 2 + x * y2 % 3) % 2 == 0; + break; + default: + throw new Error("Unreachable"); + } + if (!this.isFunction[y2][x] && invert2) + this.modules[y2][x] = !this.modules[y2][x]; + } + } } - let record = { - v: doc, - i: docIndex, - n: this.norm.get(doc) - }; - this.records.push(record); - } - _addObject(doc, docIndex) { - let record = { i: docIndex, $: {} }; - this.keys.forEach((key2, keyIndex) => { - let value = key2.getFn ? key2.getFn(doc) : this.getFn(doc, key2.path); - if (!isDefined(value)) { - return; + getPenaltyScore() { + let result = 0; + for (let y2 = 0; y2 < this.size; y2++) { + let runColor = false; + let runX = 0; + let runHistory = [0, 0, 0, 0, 0, 0, 0]; + for (let x = 0; x < this.size; x++) { + if (this.modules[y2][x] == runColor) { + runX++; + if (runX == 5) + result += _QrCode.PENALTY_N1; + else if (runX > 5) + result++; + } else { + this.finderPenaltyAddHistory(runX, runHistory); + if (!runColor) + result += this.finderPenaltyCountPatterns(runHistory) * _QrCode.PENALTY_N3; + runColor = this.modules[y2][x]; + runX = 1; + } + } + result += this.finderPenaltyTerminateAndCount(runColor, runX, runHistory) * _QrCode.PENALTY_N3; } - if (isArray(value)) { - let subRecords = []; - const stack = [{ nestedArrIndex: -1, value }]; - while (stack.length) { - const { nestedArrIndex, value: value2 } = stack.pop(); - if (!isDefined(value2)) { - continue; + for (let x = 0; x < this.size; x++) { + let runColor = false; + let runY = 0; + let runHistory = [0, 0, 0, 0, 0, 0, 0]; + for (let y2 = 0; y2 < this.size; y2++) { + if (this.modules[y2][x] == runColor) { + runY++; + if (runY == 5) + result += _QrCode.PENALTY_N1; + else if (runY > 5) + result++; + } else { + this.finderPenaltyAddHistory(runY, runHistory); + if (!runColor) + result += this.finderPenaltyCountPatterns(runHistory) * _QrCode.PENALTY_N3; + runColor = this.modules[y2][x]; + runY = 1; } - if (isString(value2) && !isBlank(value2)) { - let subRecord = { - v: value2, - i: nestedArrIndex, - n: this.norm.get(value2) - }; - subRecords.push(subRecord); - } else if (isArray(value2)) { - value2.forEach((item2, k2) => { - stack.push({ - nestedArrIndex: k2, - value: item2 - }); - }); - } else - ; } - record.$[keyIndex] = subRecords; - } else if (isString(value) && !isBlank(value)) { - let subRecord = { - v: value, - n: this.norm.get(value) - }; - record.$[keyIndex] = subRecord; + result += this.finderPenaltyTerminateAndCount(runColor, runY, runHistory) * _QrCode.PENALTY_N3; } - }); - this.records.push(record); - } - toJSON() { - return { - keys: this.keys, - records: this.records - }; - } -} -function createIndex(keys, docs, { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}) { - const myIndex = new FuseIndex({ getFn, fieldNormWeight }); - myIndex.setKeys(keys.map(createKey)); - myIndex.setSources(docs); - myIndex.create(); - return myIndex; -} -function parseIndex(data, { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}) { - const { keys, records } = data; - const myIndex = new FuseIndex({ getFn, fieldNormWeight }); - myIndex.setKeys(keys); - myIndex.setIndexRecords(records); - return myIndex; -} -function computeScore$1(pattern, { - errors: errors2 = 0, - currentLocation = 0, - expectedLocation = 0, - distance: distance2 = Config.distance, - ignoreLocation = Config.ignoreLocation -} = {}) { - const accuracy = errors2 / pattern.length; - if (ignoreLocation) { - return accuracy; - } - const proximity = Math.abs(expectedLocation - currentLocation); - if (!distance2) { - return proximity ? 1 : accuracy; - } - return accuracy + proximity / distance2; -} -function convertMaskToIndices(matchmask = [], minMatchCharLength = Config.minMatchCharLength) { - let indices = []; - let start = -1; - let end = -1; - let i2 = 0; - for (let len = matchmask.length; i2 < len; i2 += 1) { - let match = matchmask[i2]; - if (match && start === -1) { - start = i2; - } else if (!match && start !== -1) { - end = i2 - 1; - if (end - start + 1 >= minMatchCharLength) { - indices.push([start, end]); + for (let y2 = 0; y2 < this.size - 1; y2++) { + for (let x = 0; x < this.size - 1; x++) { + const color2 = this.modules[y2][x]; + if (color2 == this.modules[y2][x + 1] && color2 == this.modules[y2 + 1][x] && color2 == this.modules[y2 + 1][x + 1]) + result += _QrCode.PENALTY_N2; + } } - start = -1; + let dark2 = 0; + for (const row of this.modules) + dark2 = row.reduce((sum, color2) => sum + (color2 ? 1 : 0), dark2); + const total = this.size * this.size; + const k2 = Math.ceil(Math.abs(dark2 * 20 - total * 10) / total) - 1; + assert2(0 <= k2 && k2 <= 9); + result += k2 * _QrCode.PENALTY_N4; + assert2(0 <= result && result <= 2568888); + return result; } - } - if (matchmask[i2 - 1] && i2 - start >= minMatchCharLength) { - indices.push([start, i2 - 1]); - } - return indices; -} -const MAX_BITS = 32; -function search(text2, pattern, patternAlphabet, { - location: location2 = Config.location, - distance: distance2 = Config.distance, - threshold = Config.threshold, - findAllMatches = Config.findAllMatches, - minMatchCharLength = Config.minMatchCharLength, - includeMatches = Config.includeMatches, - ignoreLocation = Config.ignoreLocation -} = {}) { - if (pattern.length > MAX_BITS) { - throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS)); - } - const patternLen = pattern.length; - const textLen = text2.length; - const expectedLocation = Math.max(0, Math.min(location2, textLen)); - let currentThreshold = threshold; - let bestLocation = expectedLocation; - const computeMatches = minMatchCharLength > 1 || includeMatches; - const matchMask = computeMatches ? Array(textLen) : []; - let index2; - while ((index2 = text2.indexOf(pattern, bestLocation)) > -1) { - let score = computeScore$1(pattern, { - currentLocation: index2, - expectedLocation, - distance: distance2, - ignoreLocation - }); - currentThreshold = Math.min(score, currentThreshold); - bestLocation = index2 + patternLen; - if (computeMatches) { - let i2 = 0; - while (i2 < patternLen) { - matchMask[index2 + i2] = 1; - i2 += 1; + getAlignmentPatternPositions() { + if (this.version == 1) + return []; + else { + const numAlign = Math.floor(this.version / 7) + 2; + const step = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (numAlign * 2 - 2)) * 2; + let result = [6]; + for (let pos = this.size - 7; result.length < numAlign; pos -= step) + result.splice(1, 0, pos); + return result; } } - } - bestLocation = -1; - let lastBitArr = []; - let finalScore = 1; - let binMax = patternLen + textLen; - const mask = 1 << patternLen - 1; - for (let i2 = 0; i2 < patternLen; i2 += 1) { - let binMin = 0; - let binMid = binMax; - while (binMin < binMid) { - const score2 = computeScore$1(pattern, { - errors: i2, - currentLocation: expectedLocation + binMid, - expectedLocation, - distance: distance2, - ignoreLocation - }); - if (score2 <= currentThreshold) { - binMin = binMid; - } else { - binMax = binMid; + static getNumRawDataModules(ver) { + if (ver < _QrCode.MIN_VERSION || ver > _QrCode.MAX_VERSION) + throw new RangeError("Version number out of range"); + let result = (16 * ver + 128) * ver + 64; + if (ver >= 2) { + const numAlign = Math.floor(ver / 7) + 2; + result -= (25 * numAlign - 10) * numAlign - 55; + if (ver >= 7) + result -= 36; } - binMid = Math.floor((binMax - binMin) / 2 + binMin); + assert2(208 <= result && result <= 29648); + return result; } - binMax = binMid; - let start = Math.max(1, expectedLocation - binMid + 1); - let finish = findAllMatches ? textLen : Math.min(expectedLocation + binMid, textLen) + patternLen; - let bitArr = Array(finish + 2); - bitArr[finish + 1] = (1 << i2) - 1; - for (let j2 = finish; j2 >= start; j2 -= 1) { - let currentLocation = j2 - 1; - let charMatch = patternAlphabet[text2.charAt(currentLocation)]; - if (computeMatches) { - matchMask[currentLocation] = +!!charMatch; - } - bitArr[j2] = (bitArr[j2 + 1] << 1 | 1) & charMatch; - if (i2) { - bitArr[j2] |= (lastBitArr[j2 + 1] | lastBitArr[j2]) << 1 | 1 | lastBitArr[j2 + 1]; - } - if (bitArr[j2] & mask) { - finalScore = computeScore$1(pattern, { - errors: i2, - currentLocation, - expectedLocation, - distance: distance2, - ignoreLocation - }); - if (finalScore <= currentThreshold) { - currentThreshold = finalScore; - bestLocation = currentLocation; - if (bestLocation <= expectedLocation) { - break; - } - start = Math.max(1, 2 * expectedLocation - bestLocation); + static getNumDataCodewords(ver, ecl) { + return Math.floor(_QrCode.getNumRawDataModules(ver) / 8) - _QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] * _QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver]; + } + static reedSolomonComputeDivisor(degree) { + if (degree < 1 || degree > 255) + throw new RangeError("Degree out of range"); + let result = []; + for (let i2 = 0; i2 < degree - 1; i2++) + result.push(0); + result.push(1); + let root2 = 1; + for (let i2 = 0; i2 < degree; i2++) { + for (let j2 = 0; j2 < result.length; j2++) { + result[j2] = _QrCode.reedSolomonMultiply(result[j2], root2); + if (j2 + 1 < result.length) + result[j2] ^= result[j2 + 1]; } + root2 = _QrCode.reedSolomonMultiply(root2, 2); } + return result; } - const score = computeScore$1(pattern, { - errors: i2 + 1, - currentLocation: expectedLocation, - expectedLocation, - distance: distance2, - ignoreLocation - }); - if (score > currentThreshold) { - break; + static reedSolomonComputeRemainder(data, divisor) { + let result = divisor.map((_) => 0); + for (const b2 of data) { + const factor = b2 ^ result.shift(); + result.push(0); + divisor.forEach((coef, i2) => result[i2] ^= _QrCode.reedSolomonMultiply(coef, factor)); + } + return result; } - lastBitArr = bitArr; - } - const result = { - isMatch: bestLocation >= 0, - // Count exact matches (those with a score of 0) to be "almost" exact - score: Math.max(1e-3, finalScore) - }; - if (computeMatches) { - const indices = convertMaskToIndices(matchMask, minMatchCharLength); - if (!indices.length) { - result.isMatch = false; - } else if (includeMatches) { - result.indices = indices; + static reedSolomonMultiply(x, y2) { + if (x >>> 8 != 0 || y2 >>> 8 != 0) + throw new RangeError("Byte out of range"); + let z = 0; + for (let i2 = 7; i2 >= 0; i2--) { + z = z << 1 ^ (z >>> 7) * 285; + z ^= (y2 >>> i2 & 1) * x; + } + assert2(z >>> 8 == 0); + return z; + } + finderPenaltyCountPatterns(runHistory) { + const n2 = runHistory[1]; + assert2(n2 <= this.size * 3); + const core2 = n2 > 0 && runHistory[2] == n2 && runHistory[3] == n2 * 3 && runHistory[4] == n2 && runHistory[5] == n2; + return (core2 && runHistory[0] >= n2 * 4 && runHistory[6] >= n2 ? 1 : 0) + (core2 && runHistory[6] >= n2 * 4 && runHistory[0] >= n2 ? 1 : 0); + } + finderPenaltyTerminateAndCount(currentRunColor, currentRunLength, runHistory) { + if (currentRunColor) { + this.finderPenaltyAddHistory(currentRunLength, runHistory); + currentRunLength = 0; + } + currentRunLength += this.size; + this.finderPenaltyAddHistory(currentRunLength, runHistory); + return this.finderPenaltyCountPatterns(runHistory); } + finderPenaltyAddHistory(currentRunLength, runHistory) { + if (runHistory[0] == 0) + currentRunLength += this.size; + runHistory.pop(); + runHistory.unshift(currentRunLength); + } + }; + let QrCode = _QrCode; + QrCode.MIN_VERSION = 1; + QrCode.MAX_VERSION = 40; + QrCode.PENALTY_N1 = 3; + QrCode.PENALTY_N2 = 3; + QrCode.PENALTY_N3 = 40; + QrCode.PENALTY_N4 = 10; + QrCode.ECC_CODEWORDS_PER_BLOCK = [ + [-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], + [-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28], + [-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], + [-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30] + ]; + QrCode.NUM_ERROR_CORRECTION_BLOCKS = [ + [-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25], + [-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49], + [-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68], + [-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81] + ]; + qrcodegen2.QrCode = QrCode; + function appendBits(val, len, bb2) { + if (len < 0 || len > 31 || val >>> len != 0) + throw new RangeError("Value out of range"); + for (let i2 = len - 1; i2 >= 0; i2--) + bb2.push(val >>> i2 & 1); } - return result; -} -function createPatternAlphabet(pattern) { - let mask = {}; - for (let i2 = 0, len = pattern.length; i2 < len; i2 += 1) { - const char = pattern.charAt(i2); - mask[char] = (mask[char] || 0) | 1 << len - i2 - 1; + function getBit(x, i2) { + return (x >>> i2 & 1) != 0; } - return mask; -} -class BitapSearch { - constructor(pattern, { - location: location2 = Config.location, - threshold = Config.threshold, - distance: distance2 = Config.distance, - includeMatches = Config.includeMatches, - findAllMatches = Config.findAllMatches, - minMatchCharLength = Config.minMatchCharLength, - isCaseSensitive = Config.isCaseSensitive, - ignoreLocation = Config.ignoreLocation - } = {}) { - this.options = { - location: location2, - threshold, - distance: distance2, - includeMatches, - findAllMatches, - minMatchCharLength, - isCaseSensitive, - ignoreLocation - }; - this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase(); - this.chunks = []; - if (!this.pattern.length) { - return; + function assert2(cond) { + if (!cond) + throw new Error("Assertion error"); + } + const _QrSegment = class { + constructor(mode, numChars, bitData) { + this.mode = mode; + this.numChars = numChars; + this.bitData = bitData; + if (numChars < 0) + throw new RangeError("Invalid argument"); + this.bitData = bitData.slice(); } - const addChunk = (pattern2, startIndex) => { - this.chunks.push({ - pattern: pattern2, - alphabet: createPatternAlphabet(pattern2), - startIndex - }); - }; - const len = this.pattern.length; - if (len > MAX_BITS) { - let i2 = 0; - const remainder = len % MAX_BITS; - const end = len - remainder; - while (i2 < end) { - addChunk(this.pattern.substr(i2, MAX_BITS), i2); - i2 += MAX_BITS; + static makeBytes(data) { + let bb2 = []; + for (const b2 of data) + appendBits(b2, 8, bb2); + return new _QrSegment(_QrSegment.Mode.BYTE, data.length, bb2); + } + static makeNumeric(digits) { + if (!_QrSegment.isNumeric(digits)) + throw new RangeError("String contains non-numeric characters"); + let bb2 = []; + for (let i2 = 0; i2 < digits.length; ) { + const n2 = Math.min(digits.length - i2, 3); + appendBits(parseInt(digits.substr(i2, n2), 10), n2 * 3 + 1, bb2); + i2 += n2; } - if (remainder) { - const startIndex = len - MAX_BITS; - addChunk(this.pattern.substr(startIndex), startIndex); + return new _QrSegment(_QrSegment.Mode.NUMERIC, digits.length, bb2); + } + static makeAlphanumeric(text2) { + if (!_QrSegment.isAlphanumeric(text2)) + throw new RangeError("String contains unencodable characters in alphanumeric mode"); + let bb2 = []; + let i2; + for (i2 = 0; i2 + 2 <= text2.length; i2 += 2) { + let temp = _QrSegment.ALPHANUMERIC_CHARSET.indexOf(text2.charAt(i2)) * 45; + temp += _QrSegment.ALPHANUMERIC_CHARSET.indexOf(text2.charAt(i2 + 1)); + appendBits(temp, 11, bb2); } - } else { - addChunk(this.pattern, 0); + if (i2 < text2.length) + appendBits(_QrSegment.ALPHANUMERIC_CHARSET.indexOf(text2.charAt(i2)), 6, bb2); + return new _QrSegment(_QrSegment.Mode.ALPHANUMERIC, text2.length, bb2); } - } - searchIn(text2) { - const { isCaseSensitive, includeMatches } = this.options; - if (!isCaseSensitive) { - text2 = text2.toLowerCase(); + static makeSegments(text2) { + if (text2 == "") + return []; + else if (_QrSegment.isNumeric(text2)) + return [_QrSegment.makeNumeric(text2)]; + else if (_QrSegment.isAlphanumeric(text2)) + return [_QrSegment.makeAlphanumeric(text2)]; + else + return [_QrSegment.makeBytes(_QrSegment.toUtf8ByteArray(text2))]; } - if (this.pattern === text2) { - let result2 = { - isMatch: true, - score: 0 - }; - if (includeMatches) { - result2.indices = [[0, text2.length - 1]]; + static makeEci(assignVal) { + let bb2 = []; + if (assignVal < 0) + throw new RangeError("ECI assignment value out of range"); + else if (assignVal < 1 << 7) + appendBits(assignVal, 8, bb2); + else if (assignVal < 1 << 14) { + appendBits(2, 2, bb2); + appendBits(assignVal, 14, bb2); + } else if (assignVal < 1e6) { + appendBits(6, 3, bb2); + appendBits(assignVal, 21, bb2); + } else + throw new RangeError("ECI assignment value out of range"); + return new _QrSegment(_QrSegment.Mode.ECI, 0, bb2); + } + static isNumeric(text2) { + return _QrSegment.NUMERIC_REGEX.test(text2); + } + static isAlphanumeric(text2) { + return _QrSegment.ALPHANUMERIC_REGEX.test(text2); + } + getData() { + return this.bitData.slice(); + } + static getTotalBits(segs, version2) { + let result = 0; + for (const seg of segs) { + const ccbits = seg.mode.numCharCountBits(version2); + if (seg.numChars >= 1 << ccbits) + return Infinity; + result += 4 + ccbits + seg.bitData.length; } - return result2; + return result; } - const { - location: location2, - distance: distance2, - threshold, - findAllMatches, - minMatchCharLength, - ignoreLocation - } = this.options; - let allIndices = []; - let totalScore = 0; - let hasMatches = false; - this.chunks.forEach(({ pattern, alphabet, startIndex }) => { - const { isMatch, score, indices } = search(text2, pattern, alphabet, { - location: location2 + startIndex, - distance: distance2, - threshold, - findAllMatches, - minMatchCharLength, - includeMatches, - ignoreLocation - }); - if (isMatch) { - hasMatches = true; + static toUtf8ByteArray(str) { + str = encodeURI(str); + let result = []; + for (let i2 = 0; i2 < str.length; i2++) { + if (str.charAt(i2) != "%") + result.push(str.charCodeAt(i2)); + else { + result.push(parseInt(str.substr(i2 + 1, 2), 16)); + i2 += 2; + } } - totalScore += score; - if (isMatch && indices) { - allIndices = [...allIndices, ...indices]; + return result; + } + }; + let QrSegment = _QrSegment; + QrSegment.NUMERIC_REGEX = /^[0-9]*$/; + QrSegment.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/; + QrSegment.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; + qrcodegen2.QrSegment = QrSegment; +})(qrcodegen || (qrcodegen = {})); +((qrcodegen2) => { + ((QrCode2) => { + const _Ecc = class { + constructor(ordinal, formatBits) { + this.ordinal = ordinal; + this.formatBits = formatBits; } - }); - let result = { - isMatch: hasMatches, - score: hasMatches ? totalScore / this.chunks.length : 1 }; - if (hasMatches && includeMatches) { - result.indices = allIndices; + let Ecc = _Ecc; + Ecc.LOW = new _Ecc(0, 1); + Ecc.MEDIUM = new _Ecc(1, 0); + Ecc.QUARTILE = new _Ecc(2, 3); + Ecc.HIGH = new _Ecc(3, 2); + QrCode2.Ecc = Ecc; + })(qrcodegen2.QrCode || (qrcodegen2.QrCode = {})); +})(qrcodegen || (qrcodegen = {})); +((qrcodegen2) => { + ((QrSegment2) => { + const _Mode = class { + constructor(modeBits, numBitsCharCount) { + this.modeBits = modeBits; + this.numBitsCharCount = numBitsCharCount; + } + numCharCountBits(ver) { + return this.numBitsCharCount[Math.floor((ver + 7) / 17)]; + } + }; + let Mode = _Mode; + Mode.NUMERIC = new _Mode(1, [10, 12, 14]); + Mode.ALPHANUMERIC = new _Mode(2, [9, 11, 13]); + Mode.BYTE = new _Mode(4, [8, 16, 16]); + Mode.KANJI = new _Mode(8, [8, 10, 12]); + Mode.ECI = new _Mode(7, [0, 0, 0]); + QrSegment2.Mode = Mode; + })(qrcodegen2.QrSegment || (qrcodegen2.QrSegment = {})); +})(qrcodegen || (qrcodegen = {})); +var qrcodegen_default = qrcodegen; +/** + * @license qrcode.react + * Copyright (c) Paul O'Shannessy + * SPDX-License-Identifier: ISC + */ +var ERROR_LEVEL_MAP = { + L: qrcodegen_default.QrCode.Ecc.LOW, + M: qrcodegen_default.QrCode.Ecc.MEDIUM, + Q: qrcodegen_default.QrCode.Ecc.QUARTILE, + H: qrcodegen_default.QrCode.Ecc.HIGH +}; +var DEFAULT_SIZE = 128; +var DEFAULT_LEVEL = "L"; +var DEFAULT_BGCOLOR = "#FFFFFF"; +var DEFAULT_FGCOLOR = "#000000"; +var DEFAULT_INCLUDEMARGIN = false; +var MARGIN_SIZE = 4; +var DEFAULT_IMG_SCALE = 0.1; +function generatePath(modules, margin = 0) { + const ops = []; + modules.forEach(function(row, y2) { + let start = null; + row.forEach(function(cell, x) { + if (!cell && start !== null) { + ops.push(`M${start + margin} ${y2 + margin}h${x - start}v1H${start + margin}z`); + start = null; + return; + } + if (x === row.length - 1) { + if (!cell) { + return; + } + if (start === null) { + ops.push(`M${x + margin},${y2 + margin} h1v1H${x + margin}z`); + } else { + ops.push(`M${start + margin},${y2 + margin} h${x + 1 - start}v1H${start + margin}z`); + } + return; + } + if (cell && start === null) { + start = x; + } + }); + }); + return ops.join(""); +} +function excavateModules(modules, excavation) { + return modules.slice().map((row, y2) => { + if (y2 < excavation.y || y2 >= excavation.y + excavation.h) { + return row; } - return result; - } + return row.map((cell, x) => { + if (x < excavation.x || x >= excavation.x + excavation.w) { + return cell; + } + return false; + }); + }); } -class BaseMatch { - constructor(pattern) { - this.pattern = pattern; - } - static isMultiMatch(pattern) { - return getMatch(pattern, this.multiRegex); - } - static isSingleMatch(pattern) { - return getMatch(pattern, this.singleRegex); +function getImageSettings(cells, size2, includeMargin, imageSettings) { + if (imageSettings == null) { + return null; } - search() { + const margin = includeMargin ? MARGIN_SIZE : 0; + const numCells = cells.length + margin * 2; + const defaultSize = Math.floor(size2 * DEFAULT_IMG_SCALE); + const scale2 = numCells / size2; + const w2 = (imageSettings.width || defaultSize) * scale2; + const h2 = (imageSettings.height || defaultSize) * scale2; + const x = imageSettings.x == null ? cells.length / 2 - w2 / 2 : imageSettings.x * scale2; + const y2 = imageSettings.y == null ? cells.length / 2 - h2 / 2 : imageSettings.y * scale2; + let excavation = null; + if (imageSettings.excavate) { + let floorX = Math.floor(x); + let floorY = Math.floor(y2); + let ceilW = Math.ceil(w2 + x - floorX); + let ceilH = Math.ceil(h2 + y2 - floorY); + excavation = { x: floorX, y: floorY, w: ceilW, h: ceilH }; } + return { x, y: y2, h: h2, w: w2, excavation }; } -function getMatch(pattern, exp) { - const matches = pattern.match(exp); - return matches ? matches[1] : null; -} -class ExactMatch extends BaseMatch { - constructor(pattern) { - super(pattern); - } - static get type() { - return "exact"; - } - static get multiRegex() { - return /^="(.*)"$/; - } - static get singleRegex() { - return /^=(.*)$/; +var SUPPORTS_PATH2D = function() { + try { + new Path2D().addPath(new Path2D()); + } catch (e2) { + return false; } - search(text2) { - const isMatch = text2 === this.pattern; - return { - isMatch, - score: isMatch ? 0 : 1, - indices: [0, this.pattern.length - 1] - }; + return true; +}(); +function QRCodeCanvas(props) { + const _a2 = props, { + value, + size: size2 = DEFAULT_SIZE, + level = DEFAULT_LEVEL, + bgColor = DEFAULT_BGCOLOR, + fgColor = DEFAULT_FGCOLOR, + includeMargin = DEFAULT_INCLUDEMARGIN, + style, + imageSettings + } = _a2, otherProps = __objRest(_a2, [ + "value", + "size", + "level", + "bgColor", + "fgColor", + "includeMargin", + "style", + "imageSettings" + ]); + const imgSrc = imageSettings == null ? void 0 : imageSettings.src; + const _canvas = reactExports.useRef(null); + const _image = reactExports.useRef(null); + const [isImgLoaded, setIsImageLoaded] = reactExports.useState(false); + reactExports.useEffect(() => { + if (_canvas.current != null) { + const canvas = _canvas.current; + const ctx = canvas.getContext("2d"); + if (!ctx) { + return; + } + let cells = qrcodegen_default.QrCode.encodeText(value, ERROR_LEVEL_MAP[level]).getModules(); + const margin = includeMargin ? MARGIN_SIZE : 0; + const numCells = cells.length + margin * 2; + const calculatedImageSettings = getImageSettings(cells, size2, includeMargin, imageSettings); + const image = _image.current; + const haveImageToRender = calculatedImageSettings != null && image !== null && image.complete && image.naturalHeight !== 0 && image.naturalWidth !== 0; + if (haveImageToRender) { + if (calculatedImageSettings.excavation != null) { + cells = excavateModules(cells, calculatedImageSettings.excavation); + } + } + const pixelRatio = window.devicePixelRatio || 1; + canvas.height = canvas.width = size2 * pixelRatio; + const scale2 = size2 / numCells * pixelRatio; + ctx.scale(scale2, scale2); + ctx.fillStyle = bgColor; + ctx.fillRect(0, 0, numCells, numCells); + ctx.fillStyle = fgColor; + if (SUPPORTS_PATH2D) { + ctx.fill(new Path2D(generatePath(cells, margin))); + } else { + cells.forEach(function(row, rdx) { + row.forEach(function(cell, cdx) { + if (cell) { + ctx.fillRect(cdx + margin, rdx + margin, 1, 1); + } + }); + }); + } + if (haveImageToRender) { + ctx.drawImage(image, calculatedImageSettings.x + margin, calculatedImageSettings.y + margin, calculatedImageSettings.w, calculatedImageSettings.h); + } + } + }); + reactExports.useEffect(() => { + setIsImageLoaded(false); + }, [imgSrc]); + const canvasStyle = __spreadValues({ height: size2, width: size2 }, style); + let img2 = null; + if (imgSrc != null) { + img2 = /* @__PURE__ */ React.createElement("img", { + src: imgSrc, + key: imgSrc, + style: { display: "none" }, + onLoad: () => { + setIsImageLoaded(true); + }, + ref: _image + }); } + return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("canvas", __spreadValues({ + style: canvasStyle, + height: size2, + width: size2, + ref: _canvas + }, otherProps)), img2); } -class InverseExactMatch extends BaseMatch { - constructor(pattern) { - super(pattern); - } - static get type() { - return "inverse-exact"; - } - static get multiRegex() { - return /^!"(.*)"$/; - } - static get singleRegex() { - return /^!(.*)$/; - } - search(text2) { - const index2 = text2.indexOf(this.pattern); - const isMatch = index2 === -1; - return { - isMatch, - score: isMatch ? 0 : 1, - indices: [0, text2.length - 1] - }; +function QRCodeSVG(props) { + const _a2 = props, { + value, + size: size2 = DEFAULT_SIZE, + level = DEFAULT_LEVEL, + bgColor = DEFAULT_BGCOLOR, + fgColor = DEFAULT_FGCOLOR, + includeMargin = DEFAULT_INCLUDEMARGIN, + imageSettings + } = _a2, otherProps = __objRest(_a2, [ + "value", + "size", + "level", + "bgColor", + "fgColor", + "includeMargin", + "imageSettings" + ]); + let cells = qrcodegen_default.QrCode.encodeText(value, ERROR_LEVEL_MAP[level]).getModules(); + const margin = includeMargin ? MARGIN_SIZE : 0; + const numCells = cells.length + margin * 2; + const calculatedImageSettings = getImageSettings(cells, size2, includeMargin, imageSettings); + let image = null; + if (imageSettings != null && calculatedImageSettings != null) { + if (calculatedImageSettings.excavation != null) { + cells = excavateModules(cells, calculatedImageSettings.excavation); + } + image = /* @__PURE__ */ React.createElement("image", { + xlinkHref: imageSettings.src, + height: calculatedImageSettings.h, + width: calculatedImageSettings.w, + x: calculatedImageSettings.x + margin, + y: calculatedImageSettings.y + margin, + preserveAspectRatio: "none" + }); } + const fgPath = generatePath(cells, margin); + return /* @__PURE__ */ React.createElement("svg", __spreadValues({ + height: size2, + width: size2, + viewBox: `0 0 ${numCells} ${numCells}` + }, otherProps), /* @__PURE__ */ React.createElement("path", { + fill: bgColor, + d: `M0,0 h${numCells}v${numCells}H0z`, + shapeRendering: "crispEdges" + }), /* @__PURE__ */ React.createElement("path", { + fill: fgColor, + d: fgPath, + shapeRendering: "crispEdges" + }), image); } -class PrefixExactMatch extends BaseMatch { - constructor(pattern) { - super(pattern); - } - static get type() { - return "prefix-exact"; - } - static get multiRegex() { - return /^\^"(.*)"$/; - } - static get singleRegex() { - return /^\^(.*)$/; +var QRCode = (props) => { + const _a2 = props, { renderAs } = _a2, otherProps = __objRest(_a2, ["renderAs"]); + if (renderAs === "svg") { + return /* @__PURE__ */ React.createElement(QRCodeSVG, __spreadValues({}, otherProps)); } - search(text2) { - const isMatch = text2.startsWith(this.pattern); - return { - isMatch, - score: isMatch ? 0 : 1, - indices: [0, this.pattern.length - 1] + return /* @__PURE__ */ React.createElement(QRCodeCanvas, __spreadValues({}, otherProps)); +}; +var Component = {}; +var toggleSelection = function() { + var selection = document.getSelection(); + if (!selection.rangeCount) { + return function() { }; } -} -class InversePrefixExactMatch extends BaseMatch { - constructor(pattern) { - super(pattern); - } - static get type() { - return "inverse-prefix-exact"; - } - static get multiRegex() { - return /^!\^"(.*)"$/; - } - static get singleRegex() { - return /^!\^(.*)$/; + var active = document.activeElement; + var ranges = []; + for (var i2 = 0; i2 < selection.rangeCount; i2++) { + ranges.push(selection.getRangeAt(i2)); } - search(text2) { - const isMatch = !text2.startsWith(this.pattern); - return { - isMatch, - score: isMatch ? 0 : 1, - indices: [0, text2.length - 1] - }; + switch (active.tagName.toUpperCase()) { + case "INPUT": + case "TEXTAREA": + active.blur(); + break; + default: + active = null; + break; } + selection.removeAllRanges(); + return function() { + selection.type === "Caret" && selection.removeAllRanges(); + if (!selection.rangeCount) { + ranges.forEach(function(range2) { + selection.addRange(range2); + }); + } + active && active.focus(); + }; +}; +var deselectCurrent = toggleSelection; +var clipboardToIE11Formatting = { + "text/plain": "Text", + "text/html": "Url", + "default": "Text" +}; +var defaultMessage = "Copy to clipboard: #{key}, Enter"; +function format$1(message) { + var copyKey = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C"; + return message.replace(/#{\s*key\s*}/g, copyKey); } -class SuffixExactMatch extends BaseMatch { - constructor(pattern) { - super(pattern); - } - static get type() { - return "suffix-exact"; - } - static get multiRegex() { - return /^"(.*)"\$$/; - } - static get singleRegex() { - return /^(.*)\$$/; +function copy(text2, options) { + var debug2, message, reselectPrevious, range2, selection, mark, success = false; + if (!options) { + options = {}; } - search(text2) { - const isMatch = text2.endsWith(this.pattern); - return { - isMatch, - score: isMatch ? 0 : 1, - indices: [text2.length - this.pattern.length, text2.length - 1] - }; + debug2 = options.debug || false; + try { + reselectPrevious = deselectCurrent(); + range2 = document.createRange(); + selection = document.getSelection(); + mark = document.createElement("span"); + mark.textContent = text2; + mark.ariaHidden = "true"; + mark.style.all = "unset"; + mark.style.position = "fixed"; + mark.style.top = 0; + mark.style.clip = "rect(0, 0, 0, 0)"; + mark.style.whiteSpace = "pre"; + mark.style.webkitUserSelect = "text"; + mark.style.MozUserSelect = "text"; + mark.style.msUserSelect = "text"; + mark.style.userSelect = "text"; + mark.addEventListener("copy", function(e2) { + e2.stopPropagation(); + if (options.format) { + e2.preventDefault(); + if (typeof e2.clipboardData === "undefined") { + debug2 && console.warn("unable to use e.clipboardData"); + debug2 && console.warn("trying IE specific stuff"); + window.clipboardData.clearData(); + var format2 = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting["default"]; + window.clipboardData.setData(format2, text2); + } else { + e2.clipboardData.clearData(); + e2.clipboardData.setData(options.format, text2); + } + } + if (options.onCopy) { + e2.preventDefault(); + options.onCopy(e2.clipboardData); + } + }); + document.body.appendChild(mark); + range2.selectNodeContents(mark); + selection.addRange(range2); + var successful = document.execCommand("copy"); + if (!successful) { + throw new Error("copy command was unsuccessful"); + } + success = true; + } catch (err) { + debug2 && console.error("unable to copy using execCommand: ", err); + debug2 && console.warn("trying IE specific stuff"); + try { + window.clipboardData.setData(options.format || "text", text2); + options.onCopy && options.onCopy(window.clipboardData); + success = true; + } catch (err2) { + debug2 && console.error("unable to copy using clipboardData: ", err2); + debug2 && console.error("falling back to prompt"); + message = format$1("message" in options ? options.message : defaultMessage); + window.prompt(message, text2); + } + } finally { + if (selection) { + if (typeof selection.removeRange == "function") { + selection.removeRange(range2); + } else { + selection.removeAllRanges(); + } + } + if (mark) { + document.body.removeChild(mark); + } + reselectPrevious(); } + return success; } -class InverseSuffixExactMatch extends BaseMatch { - constructor(pattern) { - super(pattern); - } - static get type() { - return "inverse-suffix-exact"; - } - static get multiRegex() { - return /^!"(.*)"\$$/; - } - static get singleRegex() { - return /^!(.*)\$$/; - } - search(text2) { - const isMatch = !text2.endsWith(this.pattern); - return { - isMatch, - score: isMatch ? 0 : 1, - indices: [0, text2.length - 1] - }; +var copyToClipboard = copy; +function _typeof(obj) { + "@babel/helpers - typeof"; + return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) { + return typeof obj2; + } : function(obj2) { + return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; + }, _typeof(obj); +} +Object.defineProperty(Component, "__esModule", { + value: true +}); +Component.CopyToClipboard = void 0; +var _react = _interopRequireDefault(reactExports); +var _copyToClipboard = _interopRequireDefault(copyToClipboard); +var _excluded$4 = ["text", "onCopy", "options", "children"]; +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { "default": obj }; +} +function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + enumerableOnly && (symbols = symbols.filter(function(sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + })), keys.push.apply(keys, symbols); } + return keys; } -class FuzzyMatch extends BaseMatch { - constructor(pattern, { - location: location2 = Config.location, - threshold = Config.threshold, - distance: distance2 = Config.distance, - includeMatches = Config.includeMatches, - findAllMatches = Config.findAllMatches, - minMatchCharLength = Config.minMatchCharLength, - isCaseSensitive = Config.isCaseSensitive, - ignoreLocation = Config.ignoreLocation - } = {}) { - super(pattern); - this._bitapSearch = new BitapSearch(pattern, { - location: location2, - threshold, - distance: distance2, - includeMatches, - findAllMatches, - minMatchCharLength, - isCaseSensitive, - ignoreLocation +function _objectSpread(target) { + for (var i2 = 1; i2 < arguments.length; i2++) { + var source = null != arguments[i2] ? arguments[i2] : {}; + i2 % 2 ? ownKeys(Object(source), true).forEach(function(key2) { + _defineProperty(target, key2, source[key2]); + }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key2) { + Object.defineProperty(target, key2, Object.getOwnPropertyDescriptor(source, key2)); }); } - static get type() { - return "fuzzy"; + return target; +} +function _objectWithoutProperties(source, excluded) { + if (source == null) + return {}; + var target = _objectWithoutPropertiesLoose$2(source, excluded); + var key2, i2; + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + for (i2 = 0; i2 < sourceSymbolKeys.length; i2++) { + key2 = sourceSymbolKeys[i2]; + if (excluded.indexOf(key2) >= 0) + continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key2)) + continue; + target[key2] = source[key2]; + } } - static get multiRegex() { - return /^"(.*)"$/; + return target; +} +function _objectWithoutPropertiesLoose$2(source, excluded) { + if (source == null) + return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key2, i2; + for (i2 = 0; i2 < sourceKeys.length; i2++) { + key2 = sourceKeys[i2]; + if (excluded.indexOf(key2) >= 0) + continue; + target[key2] = source[key2]; } - static get singleRegex() { - return /^(.*)$/; + return target; +} +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); } - search(text2) { - return this._bitapSearch.searchIn(text2); +} +function _defineProperties(target, props) { + for (var i2 = 0; i2 < props.length; i2++) { + var descriptor = props[i2]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) + descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); } } -class IncludeMatch extends BaseMatch { - constructor(pattern) { - super(pattern); +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) + _defineProperties(Constructor.prototype, protoProps); + Object.defineProperty(Constructor, "prototype", { writable: false }); + return Constructor; +} +function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function"); } - static get type() { - return "include"; + subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); + Object.defineProperty(subClass, "prototype", { writable: false }); + if (superClass) + _setPrototypeOf(subClass, superClass); +} +function _setPrototypeOf(o2, p2) { + _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o3, p3) { + o3.__proto__ = p3; + return o3; + }; + return _setPrototypeOf(o2, p2); +} +function _createSuper(Derived) { + var hasNativeReflectConstruct = _isNativeReflectConstruct(); + return function _createSuperInternal() { + var Super = _getPrototypeOf(Derived), result; + if (hasNativeReflectConstruct) { + var NewTarget = _getPrototypeOf(this).constructor; + result = Reflect.construct(Super, arguments, NewTarget); + } else { + result = Super.apply(this, arguments); + } + return _possibleConstructorReturn(this, result); + }; +} +function _possibleConstructorReturn(self2, call2) { + if (call2 && (_typeof(call2) === "object" || typeof call2 === "function")) { + return call2; + } else if (call2 !== void 0) { + throw new TypeError("Derived constructors may only return object or undefined"); } - static get multiRegex() { - return /^'"(.*)"$/; + return _assertThisInitialized(self2); +} +function _assertThisInitialized(self2) { + if (self2 === void 0) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } - static get singleRegex() { - return /^'(.*)$/; + return self2; +} +function _isNativeReflectConstruct() { + if (typeof Reflect === "undefined" || !Reflect.construct) + return false; + if (Reflect.construct.sham) + return false; + if (typeof Proxy === "function") + return true; + try { + Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() { + })); + return true; + } catch (e2) { + return false; } - search(text2) { - let location2 = 0; - let index2; - const indices = []; - const patternLen = this.pattern.length; - while ((index2 = text2.indexOf(this.pattern, location2)) > -1) { - location2 = index2 + patternLen; - indices.push([index2, location2 - 1]); - } - const isMatch = !!indices.length; - return { - isMatch, - score: isMatch ? 0 : 1, - indices - }; +} +function _getPrototypeOf(o2) { + _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o3) { + return o3.__proto__ || Object.getPrototypeOf(o3); + }; + return _getPrototypeOf(o2); +} +function _defineProperty(obj, key2, value) { + if (key2 in obj) { + Object.defineProperty(obj, key2, { value, enumerable: true, configurable: true, writable: true }); + } else { + obj[key2] = value; } + return obj; } -const searchers = [ - ExactMatch, - IncludeMatch, - PrefixExactMatch, - InversePrefixExactMatch, - InverseSuffixExactMatch, - SuffixExactMatch, - InverseExactMatch, - FuzzyMatch -]; -const searchersLen = searchers.length; -const SPACE_RE = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/; -const OR_TOKEN = "|"; -function parseQuery(pattern, options = {}) { - return pattern.split(OR_TOKEN).map((item2) => { - let query = item2.trim().split(SPACE_RE).filter((item3) => item3 && !!item3.trim()); - let results2 = []; - for (let i2 = 0, len = query.length; i2 < len; i2 += 1) { - const queryItem = query[i2]; - let found = false; - let idx = -1; - while (!found && ++idx < searchersLen) { - const searcher = searchers[idx]; - let token = searcher.isMultiMatch(queryItem); - if (token) { - results2.push(new searcher(token, options)); - found = true; - } +var CopyToClipboard$1 = /* @__PURE__ */ function(_React$PureComponent) { + _inherits(CopyToClipboard2, _React$PureComponent); + var _super = _createSuper(CopyToClipboard2); + function CopyToClipboard2() { + var _this; + _classCallCheck(this, CopyToClipboard2); + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + _this = _super.call.apply(_super, [this].concat(args)); + _defineProperty(_assertThisInitialized(_this), "onClick", function(event) { + var _this$props = _this.props, text2 = _this$props.text, onCopy = _this$props.onCopy, children = _this$props.children, options = _this$props.options; + var elem = _react["default"].Children.only(children); + var result = (0, _copyToClipboard["default"])(text2, options); + if (onCopy) { + onCopy(text2, result); } - if (found) { - continue; + if (elem && elem.props && typeof elem.props.onClick === "function") { + elem.props.onClick(event); } - idx = -1; - while (++idx < searchersLen) { - const searcher = searchers[idx]; - let token = searcher.isSingleMatch(queryItem); - if (token) { - results2.push(new searcher(token, options)); - break; - } - } - } - return results2; - }); -} -const MultiMatchSet = /* @__PURE__ */ new Set([FuzzyMatch.type, IncludeMatch.type]); -class ExtendedSearch { - constructor(pattern, { - isCaseSensitive = Config.isCaseSensitive, - includeMatches = Config.includeMatches, - minMatchCharLength = Config.minMatchCharLength, - ignoreLocation = Config.ignoreLocation, - findAllMatches = Config.findAllMatches, - location: location2 = Config.location, - threshold = Config.threshold, - distance: distance2 = Config.distance - } = {}) { - this.query = null; - this.options = { - isCaseSensitive, - includeMatches, - minMatchCharLength, - findAllMatches, - ignoreLocation, - location: location2, - threshold, - distance: distance2 - }; - this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase(); - this.query = parseQuery(this.pattern, this.options); - } - static condition(_, options) { - return options.useExtendedSearch; + }); + return _this; } - searchIn(text2) { - const query = this.query; - if (!query) { - return { - isMatch: false, - score: 1 - }; + _createClass(CopyToClipboard2, [{ + key: "render", + value: function render() { + var _this$props2 = this.props; + _this$props2.text; + _this$props2.onCopy; + _this$props2.options; + var children = _this$props2.children, props = _objectWithoutProperties(_this$props2, _excluded$4); + var elem = _react["default"].Children.only(children); + return /* @__PURE__ */ _react["default"].cloneElement(elem, _objectSpread(_objectSpread({}, props), {}, { + onClick: this.onClick + })); } - const { includeMatches, isCaseSensitive } = this.options; - text2 = isCaseSensitive ? text2 : text2.toLowerCase(); - let numMatches = 0; - let allIndices = []; - let totalScore = 0; - for (let i2 = 0, qLen = query.length; i2 < qLen; i2 += 1) { - const searchers2 = query[i2]; - allIndices.length = 0; - numMatches = 0; - for (let j2 = 0, pLen = searchers2.length; j2 < pLen; j2 += 1) { - const searcher = searchers2[j2]; - const { isMatch, indices, score } = searcher.search(text2); - if (isMatch) { - numMatches += 1; - totalScore += score; - if (includeMatches) { - const type = searcher.constructor.type; - if (MultiMatchSet.has(type)) { - allIndices = [...allIndices, ...indices]; - } else { - allIndices.push(indices); + }]); + return CopyToClipboard2; +}(_react["default"].PureComponent); +Component.CopyToClipboard = CopyToClipboard$1; +_defineProperty(CopyToClipboard$1, "defaultProps", { + onCopy: void 0, + options: void 0 +}); +var _require = Component, CopyToClipboard = _require.CopyToClipboard; +CopyToClipboard.CopyToClipboard = CopyToClipboard; +var lib = CopyToClipboard; +var dayjs_min = { exports: {} }; +(function(module2, exports) { + !function(t2, e2) { + module2.exports = e2(); + }(commonjsGlobal, function() { + var t2 = 1e3, e2 = 6e4, n2 = 36e5, r2 = "millisecond", i2 = "second", s2 = "minute", u2 = "hour", a2 = "day", o2 = "week", c2 = "month", f2 = "quarter", h2 = "year", d2 = "date", l2 = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y2 = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M2 = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t3) { + var e3 = ["th", "st", "nd", "rd"], n3 = t3 % 100; + return "[" + t3 + (e3[(n3 - 20) % 10] || e3[n3] || e3[0]) + "]"; + } }, m2 = function(t3, e3, n3) { + var r3 = String(t3); + return !r3 || r3.length >= e3 ? t3 : "" + Array(e3 + 1 - r3.length).join(n3) + t3; + }, v3 = { s: m2, z: function(t3) { + var e3 = -t3.utcOffset(), n3 = Math.abs(e3), r3 = Math.floor(n3 / 60), i3 = n3 % 60; + return (e3 <= 0 ? "+" : "-") + m2(r3, 2, "0") + ":" + m2(i3, 2, "0"); + }, m: function t3(e3, n3) { + if (e3.date() < n3.date()) + return -t3(n3, e3); + var r3 = 12 * (n3.year() - e3.year()) + (n3.month() - e3.month()), i3 = e3.clone().add(r3, c2), s3 = n3 - i3 < 0, u3 = e3.clone().add(r3 + (s3 ? -1 : 1), c2); + return +(-(r3 + (n3 - i3) / (s3 ? i3 - u3 : u3 - i3)) || 0); + }, a: function(t3) { + return t3 < 0 ? Math.ceil(t3) || 0 : Math.floor(t3); + }, p: function(t3) { + return { M: c2, y: h2, w: o2, d: a2, D: d2, h: u2, m: s2, s: i2, ms: r2, Q: f2 }[t3] || String(t3 || "").toLowerCase().replace(/s$/, ""); + }, u: function(t3) { + return void 0 === t3; + } }, g2 = "en", D2 = {}; + D2[g2] = M2; + var p2 = "$isDayjsObject", S2 = function(t3) { + return t3 instanceof _ || !(!t3 || !t3[p2]); + }, w2 = function t3(e3, n3, r3) { + var i3; + if (!e3) + return g2; + if ("string" == typeof e3) { + var s3 = e3.toLowerCase(); + D2[s3] && (i3 = s3), n3 && (D2[s3] = n3, i3 = s3); + var u3 = e3.split("-"); + if (!i3 && u3.length > 1) + return t3(u3[0]); + } else { + var a3 = e3.name; + D2[a3] = e3, i3 = a3; + } + return !r3 && i3 && (g2 = i3), i3 || !r3 && g2; + }, O2 = function(t3, e3) { + if (S2(t3)) + return t3.clone(); + var n3 = "object" == typeof e3 ? e3 : {}; + return n3.date = t3, n3.args = arguments, new _(n3); + }, b2 = v3; + b2.l = w2, b2.i = S2, b2.w = function(t3, e3) { + return O2(t3, { locale: e3.$L, utc: e3.$u, x: e3.$x, $offset: e3.$offset }); + }; + var _ = function() { + function M3(t3) { + this.$L = w2(t3.locale, null, true), this.parse(t3), this.$x = this.$x || t3.x || {}, this[p2] = true; + } + var m3 = M3.prototype; + return m3.parse = function(t3) { + this.$d = function(t4) { + var e3 = t4.date, n3 = t4.utc; + if (null === e3) + return /* @__PURE__ */ new Date(NaN); + if (b2.u(e3)) + return /* @__PURE__ */ new Date(); + if (e3 instanceof Date) + return new Date(e3); + if ("string" == typeof e3 && !/Z$/i.test(e3)) { + var r3 = e3.match($); + if (r3) { + var i3 = r3[2] - 1 || 0, s3 = (r3[7] || "0").substring(0, 3); + return n3 ? new Date(Date.UTC(r3[1], i3, r3[3] || 1, r3[4] || 0, r3[5] || 0, r3[6] || 0, s3)) : new Date(r3[1], i3, r3[3] || 1, r3[4] || 0, r3[5] || 0, r3[6] || 0, s3); } } - } else { - totalScore = 0; - numMatches = 0; - allIndices.length = 0; - break; + return new Date(e3); + }(t3), this.init(); + }, m3.init = function() { + var t3 = this.$d; + this.$y = t3.getFullYear(), this.$M = t3.getMonth(), this.$D = t3.getDate(), this.$W = t3.getDay(), this.$H = t3.getHours(), this.$m = t3.getMinutes(), this.$s = t3.getSeconds(), this.$ms = t3.getMilliseconds(); + }, m3.$utils = function() { + return b2; + }, m3.isValid = function() { + return !(this.$d.toString() === l2); + }, m3.isSame = function(t3, e3) { + var n3 = O2(t3); + return this.startOf(e3) <= n3 && n3 <= this.endOf(e3); + }, m3.isAfter = function(t3, e3) { + return O2(t3) < this.startOf(e3); + }, m3.isBefore = function(t3, e3) { + return this.endOf(e3) < O2(t3); + }, m3.$g = function(t3, e3, n3) { + return b2.u(t3) ? this[e3] : this.set(n3, t3); + }, m3.unix = function() { + return Math.floor(this.valueOf() / 1e3); + }, m3.valueOf = function() { + return this.$d.getTime(); + }, m3.startOf = function(t3, e3) { + var n3 = this, r3 = !!b2.u(e3) || e3, f3 = b2.p(t3), l3 = function(t4, e4) { + var i3 = b2.w(n3.$u ? Date.UTC(n3.$y, e4, t4) : new Date(n3.$y, e4, t4), n3); + return r3 ? i3 : i3.endOf(a2); + }, $2 = function(t4, e4) { + return b2.w(n3.toDate()[t4].apply(n3.toDate("s"), (r3 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e4)), n3); + }, y3 = this.$W, M4 = this.$M, m4 = this.$D, v5 = "set" + (this.$u ? "UTC" : ""); + switch (f3) { + case h2: + return r3 ? l3(1, 0) : l3(31, 11); + case c2: + return r3 ? l3(1, M4) : l3(0, M4 + 1); + case o2: + var g3 = this.$locale().weekStart || 0, D3 = (y3 < g3 ? y3 + 7 : y3) - g3; + return l3(r3 ? m4 - D3 : m4 + (6 - D3), M4); + case a2: + case d2: + return $2(v5 + "Hours", 0); + case u2: + return $2(v5 + "Minutes", 1); + case s2: + return $2(v5 + "Seconds", 2); + case i2: + return $2(v5 + "Milliseconds", 3); + default: + return this.clone(); } - } - if (numMatches) { - let result = { - isMatch: true, - score: totalScore / numMatches + }, m3.endOf = function(t3) { + return this.startOf(t3, false); + }, m3.$set = function(t3, e3) { + var n3, o3 = b2.p(t3), f3 = "set" + (this.$u ? "UTC" : ""), l3 = (n3 = {}, n3[a2] = f3 + "Date", n3[d2] = f3 + "Date", n3[c2] = f3 + "Month", n3[h2] = f3 + "FullYear", n3[u2] = f3 + "Hours", n3[s2] = f3 + "Minutes", n3[i2] = f3 + "Seconds", n3[r2] = f3 + "Milliseconds", n3)[o3], $2 = o3 === a2 ? this.$D + (e3 - this.$W) : e3; + if (o3 === c2 || o3 === h2) { + var y3 = this.clone().set(d2, 1); + y3.$d[l3]($2), y3.init(), this.$d = y3.set(d2, Math.min(this.$D, y3.daysInMonth())).$d; + } else + l3 && this.$d[l3]($2); + return this.init(), this; + }, m3.set = function(t3, e3) { + return this.clone().$set(t3, e3); + }, m3.get = function(t3) { + return this[b2.p(t3)](); + }, m3.add = function(r3, f3) { + var d3, l3 = this; + r3 = Number(r3); + var $2 = b2.p(f3), y3 = function(t3) { + var e3 = O2(l3); + return b2.w(e3.date(e3.date() + Math.round(t3 * r3)), l3); }; - if (includeMatches) { - result.indices = allIndices; + if ($2 === c2) + return this.set(c2, this.$M + r3); + if ($2 === h2) + return this.set(h2, this.$y + r3); + if ($2 === a2) + return y3(1); + if ($2 === o2) + return y3(7); + var M4 = (d3 = {}, d3[s2] = e2, d3[u2] = n2, d3[i2] = t2, d3)[$2] || 1, m4 = this.$d.getTime() + r3 * M4; + return b2.w(m4, this); + }, m3.subtract = function(t3, e3) { + return this.add(-1 * t3, e3); + }, m3.format = function(t3) { + var e3 = this, n3 = this.$locale(); + if (!this.isValid()) + return n3.invalidDate || l2; + var r3 = t3 || "YYYY-MM-DDTHH:mm:ssZ", i3 = b2.z(this), s3 = this.$H, u3 = this.$m, a3 = this.$M, o3 = n3.weekdays, c3 = n3.months, f3 = n3.meridiem, h3 = function(t4, n4, i4, s4) { + return t4 && (t4[n4] || t4(e3, r3)) || i4[n4].slice(0, s4); + }, d3 = function(t4) { + return b2.s(s3 % 12 || 12, t4, "0"); + }, $2 = f3 || function(t4, e4, n4) { + var r4 = t4 < 12 ? "AM" : "PM"; + return n4 ? r4.toLowerCase() : r4; + }; + return r3.replace(y2, function(t4, r4) { + return r4 || function(t5) { + switch (t5) { + case "YY": + return String(e3.$y).slice(-2); + case "YYYY": + return b2.s(e3.$y, 4, "0"); + case "M": + return a3 + 1; + case "MM": + return b2.s(a3 + 1, 2, "0"); + case "MMM": + return h3(n3.monthsShort, a3, c3, 3); + case "MMMM": + return h3(c3, a3); + case "D": + return e3.$D; + case "DD": + return b2.s(e3.$D, 2, "0"); + case "d": + return String(e3.$W); + case "dd": + return h3(n3.weekdaysMin, e3.$W, o3, 2); + case "ddd": + return h3(n3.weekdaysShort, e3.$W, o3, 3); + case "dddd": + return o3[e3.$W]; + case "H": + return String(s3); + case "HH": + return b2.s(s3, 2, "0"); + case "h": + return d3(1); + case "hh": + return d3(2); + case "a": + return $2(s3, u3, true); + case "A": + return $2(s3, u3, false); + case "m": + return String(u3); + case "mm": + return b2.s(u3, 2, "0"); + case "s": + return String(e3.$s); + case "ss": + return b2.s(e3.$s, 2, "0"); + case "SSS": + return b2.s(e3.$ms, 3, "0"); + case "Z": + return i3; + } + return null; + }(t4) || i3.replace(":", ""); + }); + }, m3.utcOffset = function() { + return 15 * -Math.round(this.$d.getTimezoneOffset() / 15); + }, m3.diff = function(r3, d3, l3) { + var $2, y3 = this, M4 = b2.p(d3), m4 = O2(r3), v5 = (m4.utcOffset() - this.utcOffset()) * e2, g3 = this - m4, D3 = function() { + return b2.m(y3, m4); + }; + switch (M4) { + case h2: + $2 = D3() / 12; + break; + case c2: + $2 = D3(); + break; + case f2: + $2 = D3() / 3; + break; + case o2: + $2 = (g3 - v5) / 6048e5; + break; + case a2: + $2 = (g3 - v5) / 864e5; + break; + case u2: + $2 = g3 / n2; + break; + case s2: + $2 = g3 / e2; + break; + case i2: + $2 = g3 / t2; + break; + default: + $2 = g3; } - return result; - } - } - return { - isMatch: false, - score: 1 - }; - } -} -const registeredSearchers = []; -function register(...args) { - registeredSearchers.push(...args); -} -function createSearcher(pattern, options) { - for (let i2 = 0, len = registeredSearchers.length; i2 < len; i2 += 1) { - let searcherClass = registeredSearchers[i2]; - if (searcherClass.condition(pattern, options)) { - return new searcherClass(pattern, options); - } - } - return new BitapSearch(pattern, options); -} -const LogicalOperator = { - AND: "$and", - OR: "$or" -}; -const KeyType = { - PATH: "$path", - PATTERN: "$val" -}; -const isExpression = (query) => !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]); -const isPath = (query) => !!query[KeyType.PATH]; -const isLeaf = (query) => !isArray(query) && isObject(query) && !isExpression(query); -const convertToExplicit = (query) => ({ - [LogicalOperator.AND]: Object.keys(query).map((key2) => ({ - [key2]: query[key2] - })) -}); -function parse$1(query, options, { auto: auto2 = true } = {}) { - const next = (query2) => { - let keys = Object.keys(query2); - const isQueryPath = isPath(query2); - if (!isQueryPath && keys.length > 1 && !isExpression(query2)) { - return next(convertToExplicit(query2)); - } - if (isLeaf(query2)) { - const key2 = isQueryPath ? query2[KeyType.PATH] : keys[0]; - const pattern = isQueryPath ? query2[KeyType.PATTERN] : query2[key2]; - if (!isString(pattern)) { - throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key2)); - } - const obj = { - keyId: createKeyId(key2), - pattern + return l3 ? $2 : b2.a($2); + }, m3.daysInMonth = function() { + return this.endOf(c2).$D; + }, m3.$locale = function() { + return D2[this.$L]; + }, m3.locale = function(t3, e3) { + if (!t3) + return this.$L; + var n3 = this.clone(), r3 = w2(t3, e3, true); + return r3 && (n3.$L = r3), n3; + }, m3.clone = function() { + return b2.w(this.$d, this); + }, m3.toDate = function() { + return new Date(this.valueOf()); + }, m3.toJSON = function() { + return this.isValid() ? this.toISOString() : null; + }, m3.toISOString = function() { + return this.$d.toISOString(); + }, m3.toString = function() { + return this.$d.toUTCString(); + }, M3; + }(), k2 = _.prototype; + return O2.prototype = k2, [["$ms", r2], ["$s", i2], ["$m", s2], ["$H", u2], ["$W", a2], ["$M", c2], ["$y", h2], ["$D", d2]].forEach(function(t3) { + k2[t3[1]] = function(e3) { + return this.$g(e3, t3[0], t3[1]); }; - if (auto2) { - obj.searcher = createSearcher(pattern, options); - } - return obj; - } - let node = { - children: [], - operator: keys[0] - }; - keys.forEach((key2) => { - const value = query2[key2]; - if (isArray(value)) { - value.forEach((item2) => { - node.children.push(next(item2)); - }); - } - }); - return node; - }; - if (!isExpression(query)) { - query = convertToExplicit(query); - } - return next(query); -} -function computeScore(results2, { ignoreFieldNorm = Config.ignoreFieldNorm }) { - results2.forEach((result) => { - let totalScore = 1; - result.matches.forEach(({ key: key2, norm: norm2, score }) => { - const weight = key2 ? key2.weight : null; - totalScore *= Math.pow( - score === 0 && weight ? Number.EPSILON : score, - (weight || 1) * (ignoreFieldNorm ? 1 : norm2) - ); - }); - result.score = totalScore; + }), O2.extend = function(t3, e3) { + return t3.$i || (t3(e3, _, O2), t3.$i = true), O2; + }, O2.locale = w2, O2.isDayjs = S2, O2.unix = function(t3) { + return O2(1e3 * t3); + }, O2.en = D2[g2], O2.Ls = D2, O2.p = {}, O2; }); +})(dayjs_min); +var dayjs_minExports = dayjs_min.exports; +const dayjs = /* @__PURE__ */ getDefaultExportFromCjs$1(dayjs_minExports); +function isArray(value) { + return !Array.isArray ? getTag(value) === "[object Array]" : Array.isArray(value); } -function transformMatches(result, data) { - const matches = result.matches; - data.matches = []; - if (!isDefined(matches)) { - return; +const INFINITY = 1 / 0; +function baseToString(value) { + if (typeof value == "string") { + return value; } - matches.forEach((match) => { - if (!isDefined(match.indices) || !match.indices.length) { - return; - } - const { indices, value } = match; - let obj = { - indices, - value - }; - if (match.key) { - obj.key = match.key.src; - } - if (match.idx > -1) { - obj.refIndex = match.idx; - } - data.matches.push(obj); - }); + let result = value + ""; + return result == "0" && 1 / value == -INFINITY ? "-0" : result; } -function transformScore(result, data) { - data.score = result.score; +function toString(value) { + return value == null ? "" : baseToString(value); } -function format(results2, docs, { - includeMatches = Config.includeMatches, - includeScore = Config.includeScore -} = {}) { - const transformers = []; - if (includeMatches) - transformers.push(transformMatches); - if (includeScore) - transformers.push(transformScore); - return results2.map((result) => { - const { idx } = result; - const data = { - item: docs[idx], - refIndex: idx - }; - if (transformers.length) { - transformers.forEach((transformer) => { - transformer(result, data); - }); - } - return data; - }); +function isString(value) { + return typeof value === "string"; } -class Fuse { - constructor(docs, options = {}, index2) { - this.options = { ...Config, ...options }; - if (this.options.useExtendedSearch && false) { - throw new Error(EXTENDED_SEARCH_UNAVAILABLE); +function isNumber(value) { + return typeof value === "number"; +} +function isBoolean(value) { + return value === true || value === false || isObjectLike(value) && getTag(value) == "[object Boolean]"; +} +function isObject(value) { + return typeof value === "object"; +} +function isObjectLike(value) { + return isObject(value) && value !== null; +} +function isDefined(value) { + return value !== void 0 && value !== null; +} +function isBlank(value) { + return !value.trim().length; +} +function getTag(value) { + return value == null ? value === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(value); +} +const EXTENDED_SEARCH_UNAVAILABLE = "Extended search is not available"; +const INCORRECT_INDEX_TYPE = "Incorrect 'index' type"; +const LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key2) => `Invalid value for key ${key2}`; +const PATTERN_LENGTH_TOO_LARGE = (max2) => `Pattern length exceeds max of ${max2}.`; +const MISSING_KEY_PROPERTY = (name2) => `Missing ${name2} property in key`; +const INVALID_KEY_WEIGHT_VALUE = (key2) => `Property 'weight' in key '${key2}' must be a positive integer`; +const hasOwn = Object.prototype.hasOwnProperty; +class KeyStore { + constructor(keys) { + this._keys = []; + this._keyMap = {}; + let totalWeight = 0; + keys.forEach((key2) => { + let obj = createKey(key2); + totalWeight += obj.weight; + this._keys.push(obj); + this._keyMap[obj.id] = obj; + totalWeight += obj.weight; + }); + this._keys.forEach((key2) => { + key2.weight /= totalWeight; + }); + } + get(keyId) { + return this._keyMap[keyId]; + } + keys() { + return this._keys; + } + toJSON() { + return JSON.stringify(this._keys); + } +} +function createKey(key2) { + let path = null; + let id2 = null; + let src = null; + let weight = 1; + let getFn = null; + if (isString(key2) || isArray(key2)) { + src = key2; + path = createKeyPath(key2); + id2 = createKeyId(key2); + } else { + if (!hasOwn.call(key2, "name")) { + throw new Error(MISSING_KEY_PROPERTY("name")); } - this._keyStore = new KeyStore(this.options.keys); - this.setCollection(docs, index2); + const name2 = key2.name; + src = name2; + if (hasOwn.call(key2, "weight")) { + weight = key2.weight; + if (weight <= 0) { + throw new Error(INVALID_KEY_WEIGHT_VALUE(name2)); + } + } + path = createKeyPath(name2); + id2 = createKeyId(name2); + getFn = key2.getFn; } - setCollection(docs, index2) { - this._docs = docs; - if (index2 && !(index2 instanceof FuseIndex)) { - throw new Error(INCORRECT_INDEX_TYPE); + return { path, id: id2, weight, src, getFn }; +} +function createKeyPath(key2) { + return isArray(key2) ? key2 : key2.split("."); +} +function createKeyId(key2) { + return isArray(key2) ? key2.join(".") : key2; +} +function get(obj, path) { + let list2 = []; + let arr = false; + const deepGet = (obj2, path2, index2) => { + if (!isDefined(obj2)) { + return; } - this._myIndex = index2 || createIndex(this.options.keys, this._docs, { - getFn: this.options.getFn, - fieldNormWeight: this.options.fieldNormWeight + if (!path2[index2]) { + list2.push(obj2); + } else { + let key2 = path2[index2]; + const value = obj2[key2]; + if (!isDefined(value)) { + return; + } + if (index2 === path2.length - 1 && (isString(value) || isNumber(value) || isBoolean(value))) { + list2.push(toString(value)); + } else if (isArray(value)) { + arr = true; + for (let i2 = 0, len = value.length; i2 < len; i2 += 1) { + deepGet(value[i2], path2, index2 + 1); + } + } else if (path2.length) { + deepGet(value, path2, index2 + 1); + } + } + }; + deepGet(obj, isString(path) ? path.split(".") : path, 0); + return arr ? list2 : list2[0]; +} +const MatchOptions = { + // Whether the matches should be included in the result set. When `true`, each record in the result + // set will include the indices of the matched characters. + // These can consequently be used for highlighting purposes. + includeMatches: false, + // When `true`, the matching function will continue to the end of a search pattern even if + // a perfect match has already been located in the string. + findAllMatches: false, + // Minimum number of characters that must be matched before a result is considered a match + minMatchCharLength: 1 +}; +const BasicOptions = { + // When `true`, the algorithm continues searching to the end of the input even if a perfect + // match is found before the end of the same input. + isCaseSensitive: false, + // When true, the matching function will continue to the end of a search pattern even if + includeScore: false, + // List of properties that will be searched. This also supports nested properties. + keys: [], + // Whether to sort the result list, by score + shouldSort: true, + // Default sort function: sort by ascending score, ascending index + sortFn: (a2, b2) => a2.score === b2.score ? a2.idx < b2.idx ? -1 : 1 : a2.score < b2.score ? -1 : 1 +}; +const FuzzyOptions = { + // Approximately where in the text is the pattern expected to be found? + location: 0, + // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match + // (of both letters and location), a threshold of '1.0' would match anything. + threshold: 0.6, + // Determines how close the match must be to the fuzzy location (specified above). + // An exact letter match which is 'distance' characters away from the fuzzy location + // would score as a complete mismatch. A distance of '0' requires the match be at + // the exact location specified, a threshold of '1000' would require a perfect match + // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold. + distance: 100 +}; +const AdvancedOptions = { + // When `true`, it enables the use of unix-like search commands + useExtendedSearch: false, + // The get function to use when fetching an object's properties. + // The default will search nested paths *ie foo.bar.baz* + getFn: get, + // When `true`, search will ignore `location` and `distance`, so it won't matter + // where in the string the pattern appears. + // More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score + ignoreLocation: false, + // When `true`, the calculation for the relevance score (used for sorting) will + // ignore the field-length norm. + // More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm + ignoreFieldNorm: false, + // The weight to determine how much field length norm effects scoring. + fieldNormWeight: 1 +}; +var Config = { + ...BasicOptions, + ...MatchOptions, + ...FuzzyOptions, + ...AdvancedOptions +}; +const SPACE$1 = /[^ ]+/g; +function norm(weight = 1, mantissa = 3) { + const cache = /* @__PURE__ */ new Map(); + const m2 = Math.pow(10, mantissa); + return { + get(value) { + const numTokens = value.match(SPACE$1).length; + if (cache.has(numTokens)) { + return cache.get(numTokens); + } + const norm2 = 1 / Math.pow(numTokens, 0.5 * weight); + const n2 = parseFloat(Math.round(norm2 * m2) / m2); + cache.set(numTokens, n2); + return n2; + }, + clear() { + cache.clear(); + } + }; +} +class FuseIndex { + constructor({ + getFn = Config.getFn, + fieldNormWeight = Config.fieldNormWeight + } = {}) { + this.norm = norm(fieldNormWeight, 3); + this.getFn = getFn; + this.isCreated = false; + this.setIndexRecords(); + } + setSources(docs = []) { + this.docs = docs; + } + setIndexRecords(records = []) { + this.records = records; + } + setKeys(keys = []) { + this.keys = keys; + this._keysMap = {}; + keys.forEach((key2, idx) => { + this._keysMap[key2.id] = idx; }); } - add(doc) { - if (!isDefined(doc)) { + create() { + if (this.isCreated || !this.docs.length) { return; } - this._docs.push(doc); - this._myIndex.add(doc); + this.isCreated = true; + if (isString(this.docs[0])) { + this.docs.forEach((doc, docIndex) => { + this._addString(doc, docIndex); + }); + } else { + this.docs.forEach((doc, docIndex) => { + this._addObject(doc, docIndex); + }); + } + this.norm.clear(); } - remove(predicate = () => false) { - const results2 = []; - for (let i2 = 0, len = this._docs.length; i2 < len; i2 += 1) { - const doc = this._docs[i2]; - if (predicate(doc, i2)) { - this.removeAt(i2); - i2 -= 1; - len -= 1; - results2.push(doc); - } + // Adds a doc to the end of the index + add(doc) { + const idx = this.size(); + if (isString(doc)) { + this._addString(doc, idx); + } else { + this._addObject(doc, idx); } - return results2; } + // Removes the doc at the specified index of the index removeAt(idx) { - this._docs.splice(idx, 1); - this._myIndex.removeAt(idx); + this.records.splice(idx, 1); + for (let i2 = idx, len = this.size(); i2 < len; i2 += 1) { + this.records[i2].i -= 1; + } } - getIndex() { - return this._myIndex; + getValueForItemAtKeyId(item2, keyId) { + return item2[this._keysMap[keyId]]; } - search(query, { limit = -1 } = {}) { - const { - includeMatches, - includeScore, - shouldSort, - sortFn, - ignoreFieldNorm - } = this.options; - let results2 = isString(query) ? isString(this._docs[0]) ? this._searchStringList(query) : this._searchObjectList(query) : this._searchLogical(query); - computeScore(results2, { ignoreFieldNorm }); - if (shouldSort) { - results2.sort(sortFn); - } - if (isNumber(limit) && limit > -1) { - results2 = results2.slice(0, limit); + size() { + return this.records.length; + } + _addString(doc, docIndex) { + if (!isDefined(doc) || isBlank(doc)) { + return; } - return format(results2, this._docs, { - includeMatches, - includeScore - }); + let record = { + v: doc, + i: docIndex, + n: this.norm.get(doc) + }; + this.records.push(record); } - _searchStringList(query) { - const searcher = createSearcher(query, this.options); - const { records } = this._myIndex; - const results2 = []; - records.forEach(({ v: text2, i: idx, n: norm2 }) => { - if (!isDefined(text2)) { + _addObject(doc, docIndex) { + let record = { i: docIndex, $: {} }; + this.keys.forEach((key2, keyIndex) => { + let value = key2.getFn ? key2.getFn(doc) : this.getFn(doc, key2.path); + if (!isDefined(value)) { return; } - const { isMatch, score, indices } = searcher.searchIn(text2); - if (isMatch) { - results2.push({ - item: text2, - idx, - matches: [{ score, value: text2, norm: norm2, indices }] - }); - } - }); - return results2; - } - _searchLogical(query) { - const expression = parse$1(query, this.options); - const evaluate2 = (node, item2, idx) => { - if (!node.children) { - const { keyId, searcher } = node; - const matches = this._findMatches({ - key: this._keyStore.get(keyId), - value: this._myIndex.getValueForItemAtKeyId(item2, keyId), - searcher - }); - if (matches && matches.length) { - return [ - { - idx, - item: item2, - matches - } - ]; - } - return []; - } - const res = []; - for (let i2 = 0, len = node.children.length; i2 < len; i2 += 1) { - const child = node.children[i2]; - const result = evaluate2(child, item2, idx); - if (result.length) { - res.push(...result); - } else if (node.operator === LogicalOperator.AND) { - return []; - } - } - return res; - }; - const records = this._myIndex.records; - const resultMap = {}; - const results2 = []; - records.forEach(({ $: item2, i: idx }) => { - if (isDefined(item2)) { - let expResults = evaluate2(expression, item2, idx); - if (expResults.length) { - if (!resultMap[idx]) { - resultMap[idx] = { idx, item: item2, matches: [] }; - results2.push(resultMap[idx]); + if (isArray(value)) { + let subRecords = []; + const stack = [{ nestedArrIndex: -1, value }]; + while (stack.length) { + const { nestedArrIndex, value: value2 } = stack.pop(); + if (!isDefined(value2)) { + continue; } - expResults.forEach(({ matches }) => { - resultMap[idx].matches.push(...matches); - }); + if (isString(value2) && !isBlank(value2)) { + let subRecord = { + v: value2, + i: nestedArrIndex, + n: this.norm.get(value2) + }; + subRecords.push(subRecord); + } else if (isArray(value2)) { + value2.forEach((item2, k2) => { + stack.push({ + nestedArrIndex: k2, + value: item2 + }); + }); + } else + ; } + record.$[keyIndex] = subRecords; + } else if (isString(value) && !isBlank(value)) { + let subRecord = { + v: value, + n: this.norm.get(value) + }; + record.$[keyIndex] = subRecord; } }); - return results2; - } - _searchObjectList(query) { - const searcher = createSearcher(query, this.options); - const { keys, records } = this._myIndex; - const results2 = []; - records.forEach(({ $: item2, i: idx }) => { - if (!isDefined(item2)) { - return; - } - let matches = []; - keys.forEach((key2, keyIndex) => { - matches.push( - ...this._findMatches({ - key: key2, - value: item2[keyIndex], - searcher - }) - ); - }); - if (matches.length) { - results2.push({ - idx, - item: item2, - matches - }); - } - }); - return results2; + this.records.push(record); } - _findMatches({ key: key2, value, searcher }) { - if (!isDefined(value)) { - return []; - } - let matches = []; - if (isArray(value)) { - value.forEach(({ v: text2, i: idx, n: norm2 }) => { - if (!isDefined(text2)) { - return; - } - const { isMatch, score, indices } = searcher.searchIn(text2); - if (isMatch) { - matches.push({ - score, - key: key2, - value: text2, - idx, - norm: norm2, - indices - }); - } - }); - } else { - const { v: text2, n: norm2 } = value; - const { isMatch, score, indices } = searcher.searchIn(text2); - if (isMatch) { - matches.push({ score, key: key2, value: text2, norm: norm2, indices }); - } - } - return matches; + toJSON() { + return { + keys: this.keys, + records: this.records + }; } } -Fuse.version = "6.6.2"; -Fuse.createIndex = createIndex; -Fuse.parseIndex = parseIndex; -Fuse.config = Config; -{ - Fuse.parseQuery = parse$1; -} -{ - register(ExtendedSearch); +function createIndex(keys, docs, { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}) { + const myIndex = new FuseIndex({ getFn, fieldNormWeight }); + myIndex.setKeys(keys.map(createKey)); + myIndex.setSources(docs); + myIndex.create(); + return myIndex; } -function r$1(e2) { - var t2, f2, n2 = ""; - if ("string" == typeof e2 || "number" == typeof e2) - n2 += e2; - else if ("object" == typeof e2) - if (Array.isArray(e2)) { - var o2 = e2.length; - for (t2 = 0; t2 < o2; t2++) - e2[t2] && (f2 = r$1(e2[t2])) && (n2 && (n2 += " "), n2 += f2); - } else - for (f2 in e2) - e2[f2] && (n2 && (n2 += " "), n2 += f2); - return n2; +function parseIndex(data, { getFn = Config.getFn, fieldNormWeight = Config.fieldNormWeight } = {}) { + const { keys, records } = data; + const myIndex = new FuseIndex({ getFn, fieldNormWeight }); + myIndex.setKeys(keys); + myIndex.setIndexRecords(records); + return myIndex; } -function clsx() { - for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) - (e2 = arguments[f2]) && (t2 = r$1(e2)) && (n2 && (n2 += " "), n2 += t2); - return n2; +function computeScore$1(pattern, { + errors: errors2 = 0, + currentLocation = 0, + expectedLocation = 0, + distance: distance2 = Config.distance, + ignoreLocation = Config.ignoreLocation +} = {}) { + const accuracy = errors2 / pattern.length; + if (ignoreLocation) { + return accuracy; + } + const proximity = Math.abs(expectedLocation - currentLocation); + if (!distance2) { + return proximity ? 1 : accuracy; + } + return accuracy + proximity / distance2; } -function _extends$4() { - _extends$4 = Object.assign ? Object.assign.bind() : function(target) { - for (var i2 = 1; i2 < arguments.length; i2++) { - var source = arguments[i2]; - for (var key2 in source) { - if (Object.prototype.hasOwnProperty.call(source, key2)) { - target[key2] = source[key2]; - } +function convertMaskToIndices(matchmask = [], minMatchCharLength = Config.minMatchCharLength) { + let indices = []; + let start = -1; + let end = -1; + let i2 = 0; + for (let len = matchmask.length; i2 < len; i2 += 1) { + let match = matchmask[i2]; + if (match && start === -1) { + start = i2; + } else if (!match && start !== -1) { + end = i2 - 1; + if (end - start + 1 >= minMatchCharLength) { + indices.push([start, end]); } + start = -1; } - return target; - }; - return _extends$4.apply(this, arguments); + } + if (matchmask[i2 - 1] && i2 - start >= minMatchCharLength) { + indices.push([start, i2 - 1]); + } + return indices; } -function $e42e1063c40fb3ef$export$b9ecd428b558ff10(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) { - return function handleEvent(event) { - originalEventHandler === null || originalEventHandler === void 0 || originalEventHandler(event); - if (checkForDefaultPrevented === false || !event.defaultPrevented) - return ourEventHandler === null || ourEventHandler === void 0 ? void 0 : ourEventHandler(event); +const MAX_BITS = 32; +function search(text2, pattern, patternAlphabet, { + location: location2 = Config.location, + distance: distance2 = Config.distance, + threshold = Config.threshold, + findAllMatches = Config.findAllMatches, + minMatchCharLength = Config.minMatchCharLength, + includeMatches = Config.includeMatches, + ignoreLocation = Config.ignoreLocation +} = {}) { + if (pattern.length > MAX_BITS) { + throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS)); + } + const patternLen = pattern.length; + const textLen = text2.length; + const expectedLocation = Math.max(0, Math.min(location2, textLen)); + let currentThreshold = threshold; + let bestLocation = expectedLocation; + const computeMatches = minMatchCharLength > 1 || includeMatches; + const matchMask = computeMatches ? Array(textLen) : []; + let index2; + while ((index2 = text2.indexOf(pattern, bestLocation)) > -1) { + let score = computeScore$1(pattern, { + currentLocation: index2, + expectedLocation, + distance: distance2, + ignoreLocation + }); + currentThreshold = Math.min(score, currentThreshold); + bestLocation = index2 + patternLen; + if (computeMatches) { + let i2 = 0; + while (i2 < patternLen) { + matchMask[index2 + i2] = 1; + i2 += 1; + } + } + } + bestLocation = -1; + let lastBitArr = []; + let finalScore = 1; + let binMax = patternLen + textLen; + const mask = 1 << patternLen - 1; + for (let i2 = 0; i2 < patternLen; i2 += 1) { + let binMin = 0; + let binMid = binMax; + while (binMin < binMid) { + const score2 = computeScore$1(pattern, { + errors: i2, + currentLocation: expectedLocation + binMid, + expectedLocation, + distance: distance2, + ignoreLocation + }); + if (score2 <= currentThreshold) { + binMin = binMid; + } else { + binMax = binMid; + } + binMid = Math.floor((binMax - binMin) / 2 + binMin); + } + binMax = binMid; + let start = Math.max(1, expectedLocation - binMid + 1); + let finish = findAllMatches ? textLen : Math.min(expectedLocation + binMid, textLen) + patternLen; + let bitArr = Array(finish + 2); + bitArr[finish + 1] = (1 << i2) - 1; + for (let j2 = finish; j2 >= start; j2 -= 1) { + let currentLocation = j2 - 1; + let charMatch = patternAlphabet[text2.charAt(currentLocation)]; + if (computeMatches) { + matchMask[currentLocation] = +!!charMatch; + } + bitArr[j2] = (bitArr[j2 + 1] << 1 | 1) & charMatch; + if (i2) { + bitArr[j2] |= (lastBitArr[j2 + 1] | lastBitArr[j2]) << 1 | 1 | lastBitArr[j2 + 1]; + } + if (bitArr[j2] & mask) { + finalScore = computeScore$1(pattern, { + errors: i2, + currentLocation, + expectedLocation, + distance: distance2, + ignoreLocation + }); + if (finalScore <= currentThreshold) { + currentThreshold = finalScore; + bestLocation = currentLocation; + if (bestLocation <= expectedLocation) { + break; + } + start = Math.max(1, 2 * expectedLocation - bestLocation); + } + } + } + const score = computeScore$1(pattern, { + errors: i2 + 1, + currentLocation: expectedLocation, + expectedLocation, + distance: distance2, + ignoreLocation + }); + if (score > currentThreshold) { + break; + } + lastBitArr = bitArr; + } + const result = { + isMatch: bestLocation >= 0, + // Count exact matches (those with a score of 0) to be "almost" exact + score: Math.max(1e-3, finalScore) }; + if (computeMatches) { + const indices = convertMaskToIndices(matchMask, minMatchCharLength); + if (!indices.length) { + result.isMatch = false; + } else if (includeMatches) { + result.indices = indices; + } + } + return result; } -function $6ed0406888f73fc4$var$setRef(ref, value) { - if (typeof ref === "function") - ref(value); - else if (ref !== null && ref !== void 0) - ref.current = value; -} -function $6ed0406888f73fc4$export$43e446d32b3d21af(...refs) { - return (node) => refs.forEach( - (ref) => $6ed0406888f73fc4$var$setRef(ref, node) - ); -} -function $6ed0406888f73fc4$export$c7b2cbe3552a0d05(...refs) { - return reactExports.useCallback($6ed0406888f73fc4$export$43e446d32b3d21af(...refs), refs); +function createPatternAlphabet(pattern) { + let mask = {}; + for (let i2 = 0, len = pattern.length; i2 < len; i2 += 1) { + const char = pattern.charAt(i2); + mask[char] = (mask[char] || 0) | 1 << len - i2 - 1; + } + return mask; } -function $c512c27ab02ef895$export$50c7b4e9d9f19c1(scopeName, createContextScopeDeps = []) { - let defaultContexts2 = []; - function $c512c27ab02ef895$export$fd42f52fd3ae1109(rootComponentName, defaultContext) { - const BaseContext = /* @__PURE__ */ reactExports.createContext(defaultContext); - const index2 = defaultContexts2.length; - defaultContexts2 = [ - ...defaultContexts2, - defaultContext - ]; - function Provider2(props) { - const { scope, children, ...context2 } = props; - const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index2]) || BaseContext; - const value = reactExports.useMemo( - () => context2, - Object.values(context2) - ); - return /* @__PURE__ */ reactExports.createElement(Context.Provider, { - value - }, children); +class BitapSearch { + constructor(pattern, { + location: location2 = Config.location, + threshold = Config.threshold, + distance: distance2 = Config.distance, + includeMatches = Config.includeMatches, + findAllMatches = Config.findAllMatches, + minMatchCharLength = Config.minMatchCharLength, + isCaseSensitive = Config.isCaseSensitive, + ignoreLocation = Config.ignoreLocation + } = {}) { + this.options = { + location: location2, + threshold, + distance: distance2, + includeMatches, + findAllMatches, + minMatchCharLength, + isCaseSensitive, + ignoreLocation + }; + this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase(); + this.chunks = []; + if (!this.pattern.length) { + return; } - function useContext(consumerName, scope) { - const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index2]) || BaseContext; - const context2 = reactExports.useContext(Context); - if (context2) - return context2; - if (defaultContext !== void 0) - return defaultContext; - throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``); + const addChunk = (pattern2, startIndex) => { + this.chunks.push({ + pattern: pattern2, + alphabet: createPatternAlphabet(pattern2), + startIndex + }); + }; + const len = this.pattern.length; + if (len > MAX_BITS) { + let i2 = 0; + const remainder = len % MAX_BITS; + const end = len - remainder; + while (i2 < end) { + addChunk(this.pattern.substr(i2, MAX_BITS), i2); + i2 += MAX_BITS; + } + if (remainder) { + const startIndex = len - MAX_BITS; + addChunk(this.pattern.substr(startIndex), startIndex); + } + } else { + addChunk(this.pattern, 0); } - Provider2.displayName = rootComponentName + "Provider"; - return [ - Provider2, - useContext - ]; } - const createScope2 = () => { - const scopeContexts = defaultContexts2.map((defaultContext) => { - return /* @__PURE__ */ reactExports.createContext(defaultContext); + searchIn(text2) { + const { isCaseSensitive, includeMatches } = this.options; + if (!isCaseSensitive) { + text2 = text2.toLowerCase(); + } + if (this.pattern === text2) { + let result2 = { + isMatch: true, + score: 0 + }; + if (includeMatches) { + result2.indices = [[0, text2.length - 1]]; + } + return result2; + } + const { + location: location2, + distance: distance2, + threshold, + findAllMatches, + minMatchCharLength, + ignoreLocation + } = this.options; + let allIndices = []; + let totalScore = 0; + let hasMatches = false; + this.chunks.forEach(({ pattern, alphabet, startIndex }) => { + const { isMatch, score, indices } = search(text2, pattern, alphabet, { + location: location2 + startIndex, + distance: distance2, + threshold, + findAllMatches, + minMatchCharLength, + includeMatches, + ignoreLocation + }); + if (isMatch) { + hasMatches = true; + } + totalScore += score; + if (isMatch && indices) { + allIndices = [...allIndices, ...indices]; + } }); - return function useScope(scope) { - const contexts = (scope === null || scope === void 0 ? void 0 : scope[scopeName]) || scopeContexts; - return reactExports.useMemo( - () => ({ - [`__scope${scopeName}`]: { - ...scope, - [scopeName]: contexts - } - }), - [ - scope, - contexts - ] - ); - }; - }; - createScope2.scopeName = scopeName; - return [ - $c512c27ab02ef895$export$fd42f52fd3ae1109, - $c512c27ab02ef895$var$composeContextScopes(createScope2, ...createContextScopeDeps) - ]; -} -function $c512c27ab02ef895$var$composeContextScopes(...scopes) { - const baseScope = scopes[0]; - if (scopes.length === 1) - return baseScope; - const createScope1 = () => { - const scopeHooks = scopes.map( - (createScope2) => ({ - useScope: createScope2(), - scopeName: createScope2.scopeName - }) - ); - return function useComposedScopes(overrideScopes) { - const nextScopes1 = scopeHooks.reduce((nextScopes, { useScope, scopeName }) => { - const scopeProps = useScope(overrideScopes); - const currentScope = scopeProps[`__scope${scopeName}`]; - return { - ...nextScopes, - ...currentScope - }; - }, {}); - return reactExports.useMemo( - () => ({ - [`__scope${baseScope.scopeName}`]: nextScopes1 - }), - [ - nextScopes1 - ] - ); + let result = { + isMatch: hasMatches, + score: hasMatches ? totalScore / this.chunks.length : 1 }; - }; - createScope1.scopeName = baseScope.scopeName; - return createScope1; + if (hasMatches && includeMatches) { + result.indices = allIndices; + } + return result; + } } -const $5e63c961fc1ce211$export$8c6ed5c666ac1360 = /* @__PURE__ */ reactExports.forwardRef((props, forwardedRef) => { - const { children, ...slotProps } = props; - const childrenArray = reactExports.Children.toArray(children); - const slottable = childrenArray.find($5e63c961fc1ce211$var$isSlottable); - if (slottable) { - const newElement = slottable.props.children; - const newChildren = childrenArray.map((child) => { - if (child === slottable) { - if (reactExports.Children.count(newElement) > 1) - return reactExports.Children.only(null); - return /* @__PURE__ */ reactExports.isValidElement(newElement) ? newElement.props.children : null; - } else - return child; - }); - return /* @__PURE__ */ reactExports.createElement($5e63c961fc1ce211$var$SlotClone, _extends$4({}, slotProps, { - ref: forwardedRef - }), /* @__PURE__ */ reactExports.isValidElement(newElement) ? /* @__PURE__ */ reactExports.cloneElement(newElement, void 0, newChildren) : null); +class BaseMatch { + constructor(pattern) { + this.pattern = pattern; + } + static isMultiMatch(pattern) { + return getMatch(pattern, this.multiRegex); + } + static isSingleMatch(pattern) { + return getMatch(pattern, this.singleRegex); + } + search() { } - return /* @__PURE__ */ reactExports.createElement($5e63c961fc1ce211$var$SlotClone, _extends$4({}, slotProps, { - ref: forwardedRef - }), children); -}); -$5e63c961fc1ce211$export$8c6ed5c666ac1360.displayName = "Slot"; -const $5e63c961fc1ce211$var$SlotClone = /* @__PURE__ */ reactExports.forwardRef((props, forwardedRef) => { - const { children, ...slotProps } = props; - if (/* @__PURE__ */ reactExports.isValidElement(children)) - return /* @__PURE__ */ reactExports.cloneElement(children, { - ...$5e63c961fc1ce211$var$mergeProps(slotProps, children.props), - ref: forwardedRef ? $6ed0406888f73fc4$export$43e446d32b3d21af(forwardedRef, children.ref) : children.ref - }); - return reactExports.Children.count(children) > 1 ? reactExports.Children.only(null) : null; -}); -$5e63c961fc1ce211$var$SlotClone.displayName = "SlotClone"; -const $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 = ({ children }) => { - return /* @__PURE__ */ reactExports.createElement(reactExports.Fragment, null, children); -}; -function $5e63c961fc1ce211$var$isSlottable(child) { - return /* @__PURE__ */ reactExports.isValidElement(child) && child.type === $5e63c961fc1ce211$export$d9f1ccf0bdb05d45; } -function $5e63c961fc1ce211$var$mergeProps(slotProps, childProps) { - const overrideProps = { - ...childProps - }; - for (const propName in childProps) { - const slotPropValue = slotProps[propName]; - const childPropValue = childProps[propName]; - const isHandler = /^on[A-Z]/.test(propName); - if (isHandler) { - if (slotPropValue && childPropValue) - overrideProps[propName] = (...args) => { - childPropValue(...args); - slotPropValue(...args); - }; - else if (slotPropValue) - overrideProps[propName] = slotPropValue; - } else if (propName === "style") - overrideProps[propName] = { - ...slotPropValue, - ...childPropValue - }; - else if (propName === "className") - overrideProps[propName] = [ - slotPropValue, - childPropValue - ].filter(Boolean).join(" "); +function getMatch(pattern, exp) { + const matches = pattern.match(exp); + return matches ? matches[1] : null; +} +class ExactMatch extends BaseMatch { + constructor(pattern) { + super(pattern); + } + static get type() { + return "exact"; + } + static get multiRegex() { + return /^="(.*)"$/; + } + static get singleRegex() { + return /^=(.*)$/; + } + search(text2) { + const isMatch = text2 === this.pattern; + return { + isMatch, + score: isMatch ? 0 : 1, + indices: [0, this.pattern.length - 1] + }; } - return { - ...slotProps, - ...overrideProps - }; } -const $8927f6f2acc4f386$var$NODES = [ - "a", - "button", - "div", - "form", - "h2", - "h3", - "img", - "input", - "label", - "li", - "nav", - "ol", - "p", - "span", - "svg", - "ul" -]; -const $8927f6f2acc4f386$export$250ffa63cdc0d034 = $8927f6f2acc4f386$var$NODES.reduce((primitive, node) => { - const Node2 = /* @__PURE__ */ reactExports.forwardRef((props, forwardedRef) => { - const { asChild, ...primitiveProps } = props; - const Comp = asChild ? $5e63c961fc1ce211$export$8c6ed5c666ac1360 : node; - reactExports.useEffect(() => { - window[Symbol.for("radix-ui")] = true; - }, []); - return /* @__PURE__ */ reactExports.createElement(Comp, _extends$4({}, primitiveProps, { - ref: forwardedRef - })); - }); - Node2.displayName = `Primitive.${node}`; - return { - ...primitive, - [node]: Node2 - }; -}, {}); -function $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event) { - if (target) - reactDomExports.flushSync( - () => target.dispatchEvent(event) - ); -} -function $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(callback) { - const callbackRef = reactExports.useRef(callback); - reactExports.useEffect(() => { - callbackRef.current = callback; - }); - return reactExports.useMemo( - () => (...args) => { - var _callbackRef$current; - return (_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call(callbackRef, ...args); - }, - [] - ); -} -function $addc16e1bbe58fd0$export$3a72a57244d6e765(onEscapeKeyDownProp, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) { - const onEscapeKeyDown = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onEscapeKeyDownProp); - reactExports.useEffect(() => { - const handleKeyDown = (event) => { - if (event.key === "Escape") - onEscapeKeyDown(event); +class InverseExactMatch extends BaseMatch { + constructor(pattern) { + super(pattern); + } + static get type() { + return "inverse-exact"; + } + static get multiRegex() { + return /^!"(.*)"$/; + } + static get singleRegex() { + return /^!(.*)$/; + } + search(text2) { + const index2 = text2.indexOf(this.pattern); + const isMatch = index2 === -1; + return { + isMatch, + score: isMatch ? 0 : 1, + indices: [0, text2.length - 1] }; - ownerDocument.addEventListener("keydown", handleKeyDown); - return () => ownerDocument.removeEventListener("keydown", handleKeyDown); - }, [ - onEscapeKeyDown, - ownerDocument - ]); + } } -const $5cb92bef7577960e$var$CONTEXT_UPDATE = "dismissableLayer.update"; -const $5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside"; -const $5cb92bef7577960e$var$FOCUS_OUTSIDE = "dismissableLayer.focusOutside"; -let $5cb92bef7577960e$var$originalBodyPointerEvents; -const $5cb92bef7577960e$var$DismissableLayerContext = /* @__PURE__ */ reactExports.createContext({ - layers: /* @__PURE__ */ new Set(), - layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(), - branches: /* @__PURE__ */ new Set() -}); -const $5cb92bef7577960e$export$177fb62ff3ec1f22 = /* @__PURE__ */ reactExports.forwardRef((props, forwardedRef) => { - var _node$ownerDocument; - const { disableOutsidePointerEvents = false, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, onDismiss, ...layerProps } = props; - const context2 = reactExports.useContext($5cb92bef7577960e$var$DismissableLayerContext); - const [node1, setNode] = reactExports.useState(null); - const ownerDocument = (_node$ownerDocument = node1 === null || node1 === void 0 ? void 0 : node1.ownerDocument) !== null && _node$ownerDocument !== void 0 ? _node$ownerDocument : globalThis === null || globalThis === void 0 ? void 0 : globalThis.document; - const [, force] = reactExports.useState({}); - const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05( - forwardedRef, - (node) => setNode(node) - ); - const layers = Array.from(context2.layers); - const [highestLayerWithOutsidePointerEventsDisabled] = [ - ...context2.layersWithOutsidePointerEventsDisabled - ].slice(-1); - const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled); - const index2 = node1 ? layers.indexOf(node1) : -1; - const isBodyPointerEventsDisabled = context2.layersWithOutsidePointerEventsDisabled.size > 0; - const isPointerEventsEnabled = index2 >= highestLayerWithOutsidePointerEventsDisabledIndex; - const pointerDownOutside = $5cb92bef7577960e$var$usePointerDownOutside((event) => { - const target = event.target; - const isPointerDownOnBranch = [ - ...context2.branches - ].some( - (branch) => branch.contains(target) - ); - if (!isPointerEventsEnabled || isPointerDownOnBranch) - return; - onPointerDownOutside === null || onPointerDownOutside === void 0 || onPointerDownOutside(event); - onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event); - if (!event.defaultPrevented) - onDismiss === null || onDismiss === void 0 || onDismiss(); - }, ownerDocument); - const focusOutside = $5cb92bef7577960e$var$useFocusOutside((event) => { - const target = event.target; - const isFocusInBranch = [ - ...context2.branches - ].some( - (branch) => branch.contains(target) - ); - if (isFocusInBranch) - return; - onFocusOutside === null || onFocusOutside === void 0 || onFocusOutside(event); - onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event); - if (!event.defaultPrevented) - onDismiss === null || onDismiss === void 0 || onDismiss(); - }, ownerDocument); - $addc16e1bbe58fd0$export$3a72a57244d6e765((event) => { - const isHighestLayer = index2 === context2.layers.size - 1; - if (!isHighestLayer) - return; - onEscapeKeyDown === null || onEscapeKeyDown === void 0 || onEscapeKeyDown(event); - if (!event.defaultPrevented && onDismiss) { - event.preventDefault(); - onDismiss(); - } - }, ownerDocument); - reactExports.useEffect(() => { - if (!node1) - return; - if (disableOutsidePointerEvents) { - if (context2.layersWithOutsidePointerEventsDisabled.size === 0) { - $5cb92bef7577960e$var$originalBodyPointerEvents = ownerDocument.body.style.pointerEvents; - ownerDocument.body.style.pointerEvents = "none"; - } - context2.layersWithOutsidePointerEventsDisabled.add(node1); - } - context2.layers.add(node1); - $5cb92bef7577960e$var$dispatchUpdate(); - return () => { - if (disableOutsidePointerEvents && context2.layersWithOutsidePointerEventsDisabled.size === 1) - ownerDocument.body.style.pointerEvents = $5cb92bef7577960e$var$originalBodyPointerEvents; - }; - }, [ - node1, - ownerDocument, - disableOutsidePointerEvents, - context2 - ]); - reactExports.useEffect(() => { - return () => { - if (!node1) - return; - context2.layers.delete(node1); - context2.layersWithOutsidePointerEventsDisabled.delete(node1); - $5cb92bef7577960e$var$dispatchUpdate(); - }; - }, [ - node1, - context2 - ]); - reactExports.useEffect(() => { - const handleUpdate = () => force({}); - document.addEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate); - return () => document.removeEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate); - }, []); - return /* @__PURE__ */ reactExports.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends$4({}, layerProps, { - ref: composedRefs, - style: { - pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0, - ...props.style - }, - onFocusCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocusCapture, focusOutside.onFocusCapture), - onBlurCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onBlurCapture, focusOutside.onBlurCapture), - onPointerDownCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerDownCapture, pointerDownOutside.onPointerDownCapture) - })); -}); -function $5cb92bef7577960e$var$usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) { - const handlePointerDownOutside = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onPointerDownOutside); - const isPointerInsideReactTreeRef = reactExports.useRef(false); - const handleClickRef = reactExports.useRef(() => { - }); - reactExports.useEffect(() => { - const handlePointerDown = (event) => { - if (event.target && !isPointerInsideReactTreeRef.current) { - let handleAndDispatchPointerDownOutsideEvent = function() { - $5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE, handlePointerDownOutside, eventDetail, { - discrete: true - }); - }; - const eventDetail = { - originalEvent: event - }; - if (event.pointerType === "touch") { - ownerDocument.removeEventListener("click", handleClickRef.current); - handleClickRef.current = handleAndDispatchPointerDownOutsideEvent; - ownerDocument.addEventListener("click", handleClickRef.current, { - once: true - }); - } else - handleAndDispatchPointerDownOutsideEvent(); - } else - ownerDocument.removeEventListener("click", handleClickRef.current); - isPointerInsideReactTreeRef.current = false; +class PrefixExactMatch extends BaseMatch { + constructor(pattern) { + super(pattern); + } + static get type() { + return "prefix-exact"; + } + static get multiRegex() { + return /^\^"(.*)"$/; + } + static get singleRegex() { + return /^\^(.*)$/; + } + search(text2) { + const isMatch = text2.startsWith(this.pattern); + return { + isMatch, + score: isMatch ? 0 : 1, + indices: [0, this.pattern.length - 1] }; - const timerId = window.setTimeout(() => { - ownerDocument.addEventListener("pointerdown", handlePointerDown); - }, 0); - return () => { - window.clearTimeout(timerId); - ownerDocument.removeEventListener("pointerdown", handlePointerDown); - ownerDocument.removeEventListener("click", handleClickRef.current); + } +} +class InversePrefixExactMatch extends BaseMatch { + constructor(pattern) { + super(pattern); + } + static get type() { + return "inverse-prefix-exact"; + } + static get multiRegex() { + return /^!\^"(.*)"$/; + } + static get singleRegex() { + return /^!\^(.*)$/; + } + search(text2) { + const isMatch = !text2.startsWith(this.pattern); + return { + isMatch, + score: isMatch ? 0 : 1, + indices: [0, text2.length - 1] }; - }, [ - ownerDocument, - handlePointerDownOutside - ]); - return { - // ensures we check React component tree (not just DOM tree) - onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true - }; + } } -function $5cb92bef7577960e$var$useFocusOutside(onFocusOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) { - const handleFocusOutside = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onFocusOutside); - const isFocusInsideReactTreeRef = reactExports.useRef(false); - reactExports.useEffect(() => { - const handleFocus = (event) => { - if (event.target && !isFocusInsideReactTreeRef.current) { - const eventDetail = { - originalEvent: event - }; - $5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$FOCUS_OUTSIDE, handleFocusOutside, eventDetail, { - discrete: false - }); - } +class SuffixExactMatch extends BaseMatch { + constructor(pattern) { + super(pattern); + } + static get type() { + return "suffix-exact"; + } + static get multiRegex() { + return /^"(.*)"\$$/; + } + static get singleRegex() { + return /^(.*)\$$/; + } + search(text2) { + const isMatch = text2.endsWith(this.pattern); + return { + isMatch, + score: isMatch ? 0 : 1, + indices: [text2.length - this.pattern.length, text2.length - 1] }; - ownerDocument.addEventListener("focusin", handleFocus); - return () => ownerDocument.removeEventListener("focusin", handleFocus); - }, [ - ownerDocument, - handleFocusOutside - ]); - return { - onFocusCapture: () => isFocusInsideReactTreeRef.current = true, - onBlurCapture: () => isFocusInsideReactTreeRef.current = false - }; + } } -function $5cb92bef7577960e$var$dispatchUpdate() { - const event = new CustomEvent($5cb92bef7577960e$var$CONTEXT_UPDATE); - document.dispatchEvent(event); +class InverseSuffixExactMatch extends BaseMatch { + constructor(pattern) { + super(pattern); + } + static get type() { + return "inverse-suffix-exact"; + } + static get multiRegex() { + return /^!"(.*)"\$$/; + } + static get singleRegex() { + return /^!(.*)\$$/; + } + search(text2) { + const isMatch = !text2.endsWith(this.pattern); + return { + isMatch, + score: isMatch ? 0 : 1, + indices: [0, text2.length - 1] + }; + } } -function $5cb92bef7577960e$var$handleAndDispatchCustomEvent(name2, handler, detail, { discrete }) { - const target = detail.originalEvent.target; - const event = new CustomEvent(name2, { - bubbles: false, - cancelable: true, - detail - }); - if (handler) - target.addEventListener(name2, handler, { - once: true +class FuzzyMatch extends BaseMatch { + constructor(pattern, { + location: location2 = Config.location, + threshold = Config.threshold, + distance: distance2 = Config.distance, + includeMatches = Config.includeMatches, + findAllMatches = Config.findAllMatches, + minMatchCharLength = Config.minMatchCharLength, + isCaseSensitive = Config.isCaseSensitive, + ignoreLocation = Config.ignoreLocation + } = {}) { + super(pattern); + this._bitapSearch = new BitapSearch(pattern, { + location: location2, + threshold, + distance: distance2, + includeMatches, + findAllMatches, + minMatchCharLength, + isCaseSensitive, + ignoreLocation }); - if (discrete) - $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event); - else - target.dispatchEvent(event); + } + static get type() { + return "fuzzy"; + } + static get multiRegex() { + return /^"(.*)"$/; + } + static get singleRegex() { + return /^(.*)$/; + } + search(text2) { + return this._bitapSearch.searchIn(text2); + } } -let $3db38b7d1fb3fe6a$var$count = 0; -function $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c() { - reactExports.useEffect(() => { - var _edgeGuards$, _edgeGuards$2; - const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]"); - document.body.insertAdjacentElement("afterbegin", (_edgeGuards$ = edgeGuards[0]) !== null && _edgeGuards$ !== void 0 ? _edgeGuards$ : $3db38b7d1fb3fe6a$var$createFocusGuard()); - document.body.insertAdjacentElement("beforeend", (_edgeGuards$2 = edgeGuards[1]) !== null && _edgeGuards$2 !== void 0 ? _edgeGuards$2 : $3db38b7d1fb3fe6a$var$createFocusGuard()); - $3db38b7d1fb3fe6a$var$count++; - return () => { - if ($3db38b7d1fb3fe6a$var$count === 1) - document.querySelectorAll("[data-radix-focus-guard]").forEach( - (node) => node.remove() - ); - $3db38b7d1fb3fe6a$var$count--; +class IncludeMatch extends BaseMatch { + constructor(pattern) { + super(pattern); + } + static get type() { + return "include"; + } + static get multiRegex() { + return /^'"(.*)"$/; + } + static get singleRegex() { + return /^'(.*)$/; + } + search(text2) { + let location2 = 0; + let index2; + const indices = []; + const patternLen = this.pattern.length; + while ((index2 = text2.indexOf(this.pattern, location2)) > -1) { + location2 = index2 + patternLen; + indices.push([index2, location2 - 1]); + } + const isMatch = !!indices.length; + return { + isMatch, + score: isMatch ? 0 : 1, + indices }; - }, []); -} -function $3db38b7d1fb3fe6a$var$createFocusGuard() { - const element = document.createElement("span"); - element.setAttribute("data-radix-focus-guard", ""); - element.tabIndex = 0; - element.style.cssText = "outline: none; opacity: 0; position: fixed; pointer-events: none"; - return element; + } } -const $d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount"; -const $d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount"; -const $d3863c46a17e8a28$var$EVENT_OPTIONS = { - bubbles: false, - cancelable: true -}; -const $d3863c46a17e8a28$export$20e40289641fbbb6 = /* @__PURE__ */ reactExports.forwardRef((props, forwardedRef) => { - const { loop = false, trapped = false, onMountAutoFocus: onMountAutoFocusProp, onUnmountAutoFocus: onUnmountAutoFocusProp, ...scopeProps } = props; - const [container1, setContainer] = reactExports.useState(null); - const onMountAutoFocus = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onMountAutoFocusProp); - const onUnmountAutoFocus = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onUnmountAutoFocusProp); - const lastFocusedElementRef = reactExports.useRef(null); - const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05( - forwardedRef, - (node) => setContainer(node) - ); - const focusScope = reactExports.useRef({ - paused: false, - pause() { - this.paused = true; - }, - resume() { - this.paused = false; +const searchers = [ + ExactMatch, + IncludeMatch, + PrefixExactMatch, + InversePrefixExactMatch, + InverseSuffixExactMatch, + SuffixExactMatch, + InverseExactMatch, + FuzzyMatch +]; +const searchersLen = searchers.length; +const SPACE_RE = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/; +const OR_TOKEN = "|"; +function parseQuery(pattern, options = {}) { + return pattern.split(OR_TOKEN).map((item2) => { + let query = item2.trim().split(SPACE_RE).filter((item3) => item3 && !!item3.trim()); + let results2 = []; + for (let i2 = 0, len = query.length; i2 < len; i2 += 1) { + const queryItem = query[i2]; + let found = false; + let idx = -1; + while (!found && ++idx < searchersLen) { + const searcher = searchers[idx]; + let token = searcher.isMultiMatch(queryItem); + if (token) { + results2.push(new searcher(token, options)); + found = true; + } + } + if (found) { + continue; + } + idx = -1; + while (++idx < searchersLen) { + const searcher = searchers[idx]; + let token = searcher.isSingleMatch(queryItem); + if (token) { + results2.push(new searcher(token, options)); + break; + } + } } - }).current; - reactExports.useEffect(() => { - if (trapped) { - let handleFocusIn = function(event) { - if (focusScope.paused || !container1) - return; - const target = event.target; - if (container1.contains(target)) - lastFocusedElementRef.current = target; - else - $d3863c46a17e8a28$var$focus(lastFocusedElementRef.current, { - select: true - }); - }, handleFocusOut = function(event) { - if (focusScope.paused || !container1) - return; - const relatedTarget = event.relatedTarget; - if (relatedTarget === null) - return; - if (!container1.contains(relatedTarget)) - $d3863c46a17e8a28$var$focus(lastFocusedElementRef.current, { - select: true - }); - }, handleMutations = function(mutations) { - const focusedElement = document.activeElement; - if (focusedElement !== document.body) - return; - for (const mutation of mutations) - if (mutation.removedNodes.length > 0) - $d3863c46a17e8a28$var$focus(container1); - }; - document.addEventListener("focusin", handleFocusIn); - document.addEventListener("focusout", handleFocusOut); - const mutationObserver = new MutationObserver(handleMutations); - if (container1) - mutationObserver.observe(container1, { - childList: true, - subtree: true - }); - return () => { - document.removeEventListener("focusin", handleFocusIn); - document.removeEventListener("focusout", handleFocusOut); - mutationObserver.disconnect(); + return results2; + }); +} +const MultiMatchSet = /* @__PURE__ */ new Set([FuzzyMatch.type, IncludeMatch.type]); +class ExtendedSearch { + constructor(pattern, { + isCaseSensitive = Config.isCaseSensitive, + includeMatches = Config.includeMatches, + minMatchCharLength = Config.minMatchCharLength, + ignoreLocation = Config.ignoreLocation, + findAllMatches = Config.findAllMatches, + location: location2 = Config.location, + threshold = Config.threshold, + distance: distance2 = Config.distance + } = {}) { + this.query = null; + this.options = { + isCaseSensitive, + includeMatches, + minMatchCharLength, + findAllMatches, + ignoreLocation, + location: location2, + threshold, + distance: distance2 + }; + this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase(); + this.query = parseQuery(this.pattern, this.options); + } + static condition(_, options) { + return options.useExtendedSearch; + } + searchIn(text2) { + const query = this.query; + if (!query) { + return { + isMatch: false, + score: 1 }; } - }, [ - trapped, - container1, - focusScope.paused - ]); - reactExports.useEffect(() => { - if (container1) { - $d3863c46a17e8a28$var$focusScopesStack.add(focusScope); - const previouslyFocusedElement = document.activeElement; - const hasFocusedCandidate = container1.contains(previouslyFocusedElement); - if (!hasFocusedCandidate) { - const mountEvent = new CustomEvent($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, $d3863c46a17e8a28$var$EVENT_OPTIONS); - container1.addEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, onMountAutoFocus); - container1.dispatchEvent(mountEvent); - if (!mountEvent.defaultPrevented) { - $d3863c46a17e8a28$var$focusFirst($d3863c46a17e8a28$var$removeLinks($d3863c46a17e8a28$var$getTabbableCandidates(container1)), { - select: true - }); - if (document.activeElement === previouslyFocusedElement) - $d3863c46a17e8a28$var$focus(container1); + const { includeMatches, isCaseSensitive } = this.options; + text2 = isCaseSensitive ? text2 : text2.toLowerCase(); + let numMatches = 0; + let allIndices = []; + let totalScore = 0; + for (let i2 = 0, qLen = query.length; i2 < qLen; i2 += 1) { + const searchers2 = query[i2]; + allIndices.length = 0; + numMatches = 0; + for (let j2 = 0, pLen = searchers2.length; j2 < pLen; j2 += 1) { + const searcher = searchers2[j2]; + const { isMatch, indices, score } = searcher.search(text2); + if (isMatch) { + numMatches += 1; + totalScore += score; + if (includeMatches) { + const type = searcher.constructor.type; + if (MultiMatchSet.has(type)) { + allIndices = [...allIndices, ...indices]; + } else { + allIndices.push(indices); + } + } + } else { + totalScore = 0; + numMatches = 0; + allIndices.length = 0; + break; } } - return () => { - container1.removeEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, onMountAutoFocus); - setTimeout(() => { - const unmountEvent = new CustomEvent($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, $d3863c46a17e8a28$var$EVENT_OPTIONS); - container1.addEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus); - container1.dispatchEvent(unmountEvent); - if (!unmountEvent.defaultPrevented) - $d3863c46a17e8a28$var$focus(previouslyFocusedElement !== null && previouslyFocusedElement !== void 0 ? previouslyFocusedElement : document.body, { - select: true - }); - container1.removeEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus); - $d3863c46a17e8a28$var$focusScopesStack.remove(focusScope); - }, 0); - }; - } - }, [ - container1, - onMountAutoFocus, - onUnmountAutoFocus, - focusScope - ]); - const handleKeyDown = reactExports.useCallback((event) => { - if (!loop && !trapped) - return; - if (focusScope.paused) - return; - const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey; - const focusedElement = document.activeElement; - if (isTabKey && focusedElement) { - const container = event.currentTarget; - const [first, last] = $d3863c46a17e8a28$var$getTabbableEdges(container); - const hasTabbableElementsInside = first && last; - if (!hasTabbableElementsInside) { - if (focusedElement === container) - event.preventDefault(); - } else { - if (!event.shiftKey && focusedElement === last) { - event.preventDefault(); - if (loop) - $d3863c46a17e8a28$var$focus(first, { - select: true - }); - } else if (event.shiftKey && focusedElement === first) { - event.preventDefault(); - if (loop) - $d3863c46a17e8a28$var$focus(last, { - select: true - }); + if (numMatches) { + let result = { + isMatch: true, + score: totalScore / numMatches + }; + if (includeMatches) { + result.indices = allIndices; } + return result; } } - }, [ - loop, - trapped, - focusScope.paused - ]); - return /* @__PURE__ */ reactExports.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends$4({ - tabIndex: -1 - }, scopeProps, { - ref: composedRefs, - onKeyDown: handleKeyDown - })); -}); -function $d3863c46a17e8a28$var$focusFirst(candidates, { select = false } = {}) { - const previouslyFocusedElement = document.activeElement; - for (const candidate of candidates) { - $d3863c46a17e8a28$var$focus(candidate, { - select - }); - if (document.activeElement !== previouslyFocusedElement) - return; + return { + isMatch: false, + score: 1 + }; } } -function $d3863c46a17e8a28$var$getTabbableEdges(container) { - const candidates = $d3863c46a17e8a28$var$getTabbableCandidates(container); - const first = $d3863c46a17e8a28$var$findVisible(candidates, container); - const last = $d3863c46a17e8a28$var$findVisible(candidates.reverse(), container); - return [ - first, - last - ]; +const registeredSearchers = []; +function register(...args) { + registeredSearchers.push(...args); } -function $d3863c46a17e8a28$var$getTabbableCandidates(container) { - const nodes = []; - const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, { - acceptNode: (node) => { - const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden"; - if (node.disabled || node.hidden || isHiddenInput) - return NodeFilter.FILTER_SKIP; - return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP; +function createSearcher(pattern, options) { + for (let i2 = 0, len = registeredSearchers.length; i2 < len; i2 += 1) { + let searcherClass = registeredSearchers[i2]; + if (searcherClass.condition(pattern, options)) { + return new searcherClass(pattern, options); } - }); - while (walker.nextNode()) - nodes.push(walker.currentNode); - return nodes; -} -function $d3863c46a17e8a28$var$findVisible(elements, container) { - for (const element of elements) { - if (!$d3863c46a17e8a28$var$isHidden(element, { - upTo: container - })) - return element; - } -} -function $d3863c46a17e8a28$var$isHidden(node, { upTo }) { - if (getComputedStyle(node).visibility === "hidden") - return true; - while (node) { - if (upTo !== void 0 && node === upTo) - return false; - if (getComputedStyle(node).display === "none") - return true; - node = node.parentElement; - } - return false; -} -function $d3863c46a17e8a28$var$isSelectableInput(element) { - return element instanceof HTMLInputElement && "select" in element; -} -function $d3863c46a17e8a28$var$focus(element, { select = false } = {}) { - if (element && element.focus) { - const previouslyFocusedElement = document.activeElement; - element.focus({ - preventScroll: true - }); - if (element !== previouslyFocusedElement && $d3863c46a17e8a28$var$isSelectableInput(element) && select) - element.select(); } + return new BitapSearch(pattern, options); } -const $d3863c46a17e8a28$var$focusScopesStack = $d3863c46a17e8a28$var$createFocusScopesStack(); -function $d3863c46a17e8a28$var$createFocusScopesStack() { - let stack = []; - return { - add(focusScope) { - const activeFocusScope = stack[0]; - if (focusScope !== activeFocusScope) - activeFocusScope === null || activeFocusScope === void 0 || activeFocusScope.pause(); - stack = $d3863c46a17e8a28$var$arrayRemove(stack, focusScope); - stack.unshift(focusScope); - }, - remove(focusScope) { - var _stack$; - stack = $d3863c46a17e8a28$var$arrayRemove(stack, focusScope); - (_stack$ = stack[0]) === null || _stack$ === void 0 || _stack$.resume(); +const LogicalOperator = { + AND: "$and", + OR: "$or" +}; +const KeyType = { + PATH: "$path", + PATTERN: "$val" +}; +const isExpression = (query) => !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]); +const isPath = (query) => !!query[KeyType.PATH]; +const isLeaf = (query) => !isArray(query) && isObject(query) && !isExpression(query); +const convertToExplicit = (query) => ({ + [LogicalOperator.AND]: Object.keys(query).map((key2) => ({ + [key2]: query[key2] + })) +}); +function parse$1(query, options, { auto: auto2 = true } = {}) { + const next = (query2) => { + let keys = Object.keys(query2); + const isQueryPath = isPath(query2); + if (!isQueryPath && keys.length > 1 && !isExpression(query2)) { + return next(convertToExplicit(query2)); + } + if (isLeaf(query2)) { + const key2 = isQueryPath ? query2[KeyType.PATH] : keys[0]; + const pattern = isQueryPath ? query2[KeyType.PATTERN] : query2[key2]; + if (!isString(pattern)) { + throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key2)); + } + const obj = { + keyId: createKeyId(key2), + pattern + }; + if (auto2) { + obj.searcher = createSearcher(pattern, options); + } + return obj; } + let node = { + children: [], + operator: keys[0] + }; + keys.forEach((key2) => { + const value = query2[key2]; + if (isArray(value)) { + value.forEach((item2) => { + node.children.push(next(item2)); + }); + } + }); + return node; }; + if (!isExpression(query)) { + query = convertToExplicit(query); + } + return next(query); } -function $d3863c46a17e8a28$var$arrayRemove(array, item2) { - const updatedArray = [ - ...array - ]; - const index2 = updatedArray.indexOf(item2); - if (index2 !== -1) - updatedArray.splice(index2, 1); - return updatedArray; -} -function $d3863c46a17e8a28$var$removeLinks(items) { - return items.filter( - (item2) => item2.tagName !== "A" - ); -} -const $9f79659886946c16$export$e5c5a5f917a5871c = Boolean(globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) ? reactExports.useLayoutEffect : () => { -}; -const $1746a345f3d73bb7$var$useReactId = $2AODx$react["useId".toString()] || (() => void 0); -let $1746a345f3d73bb7$var$count = 0; -function $1746a345f3d73bb7$export$f680877a34711e37(deterministicId) { - const [id2, setId] = reactExports.useState($1746a345f3d73bb7$var$useReactId()); - $9f79659886946c16$export$e5c5a5f917a5871c(() => { - if (!deterministicId) - setId( - (reactId) => reactId !== null && reactId !== void 0 ? reactId : String($1746a345f3d73bb7$var$count++) +function computeScore(results2, { ignoreFieldNorm = Config.ignoreFieldNorm }) { + results2.forEach((result) => { + let totalScore = 1; + result.matches.forEach(({ key: key2, norm: norm2, score }) => { + const weight = key2 ? key2.weight : null; + totalScore *= Math.pow( + score === 0 && weight ? Number.EPSILON : score, + (weight || 1) * (ignoreFieldNorm ? 1 : norm2) ); - }, [ - deterministicId - ]); - return deterministicId || (id2 ? `radix-${id2}` : ""); -} -const sides = ["top", "right", "bottom", "left"]; -const min = Math.min; -const max = Math.max; -const round = Math.round; -const floor = Math.floor; -const createCoords = (v3) => ({ - x: v3, - y: v3 -}); -const oppositeSideMap = { - left: "right", - right: "left", - bottom: "top", - top: "bottom" -}; -const oppositeAlignmentMap = { - start: "end", - end: "start" -}; -function clamp(start, value, end) { - return max(start, min(value, end)); -} -function evaluate(value, param) { - return typeof value === "function" ? value(param) : value; -} -function getSide(placement) { - return placement.split("-")[0]; -} -function getAlignment(placement) { - return placement.split("-")[1]; -} -function getOppositeAxis(axis) { - return axis === "x" ? "y" : "x"; -} -function getAxisLength(axis) { - return axis === "y" ? "height" : "width"; -} -function getSideAxis(placement) { - return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x"; -} -function getAlignmentAxis(placement) { - return getOppositeAxis(getSideAxis(placement)); + }); + result.score = totalScore; + }); } -function getAlignmentSides(placement, rects, rtl) { - if (rtl === void 0) { - rtl = false; - } - const alignment = getAlignment(placement); - const alignmentAxis = getAlignmentAxis(placement); - const length = getAxisLength(alignmentAxis); - let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top"; - if (rects.reference[length] > rects.floating[length]) { - mainAlignmentSide = getOppositePlacement(mainAlignmentSide); +function transformMatches(result, data) { + const matches = result.matches; + data.matches = []; + if (!isDefined(matches)) { + return; } - return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)]; + matches.forEach((match) => { + if (!isDefined(match.indices) || !match.indices.length) { + return; + } + const { indices, value } = match; + let obj = { + indices, + value + }; + if (match.key) { + obj.key = match.key.src; + } + if (match.idx > -1) { + obj.refIndex = match.idx; + } + data.matches.push(obj); + }); } -function getExpandedPlacements(placement) { - const oppositePlacement = getOppositePlacement(placement); - return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)]; +function transformScore(result, data) { + data.score = result.score; } -function getOppositeAlignmentPlacement(placement) { - return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]); +function format(results2, docs, { + includeMatches = Config.includeMatches, + includeScore = Config.includeScore +} = {}) { + const transformers = []; + if (includeMatches) + transformers.push(transformMatches); + if (includeScore) + transformers.push(transformScore); + return results2.map((result) => { + const { idx } = result; + const data = { + item: docs[idx], + refIndex: idx + }; + if (transformers.length) { + transformers.forEach((transformer) => { + transformer(result, data); + }); + } + return data; + }); } -function getSideList(side, isStart, rtl) { - const lr = ["left", "right"]; - const rl2 = ["right", "left"]; - const tb2 = ["top", "bottom"]; - const bt = ["bottom", "top"]; - switch (side) { - case "top": - case "bottom": - if (rtl) - return isStart ? rl2 : lr; - return isStart ? lr : rl2; - case "left": - case "right": - return isStart ? tb2 : bt; - default: - return []; +class Fuse { + constructor(docs, options = {}, index2) { + this.options = { ...Config, ...options }; + if (this.options.useExtendedSearch && false) { + throw new Error(EXTENDED_SEARCH_UNAVAILABLE); + } + this._keyStore = new KeyStore(this.options.keys); + this.setCollection(docs, index2); } -} -function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) { - const alignment = getAlignment(placement); - let list2 = getSideList(getSide(placement), direction === "start", rtl); - if (alignment) { - list2 = list2.map((side) => side + "-" + alignment); - if (flipAlignment) { - list2 = list2.concat(list2.map(getOppositeAlignmentPlacement)); + setCollection(docs, index2) { + this._docs = docs; + if (index2 && !(index2 instanceof FuseIndex)) { + throw new Error(INCORRECT_INDEX_TYPE); } + this._myIndex = index2 || createIndex(this.options.keys, this._docs, { + getFn: this.options.getFn, + fieldNormWeight: this.options.fieldNormWeight + }); } - return list2; -} -function getOppositePlacement(placement) { - return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]); -} -function expandPaddingObject(padding2) { - return { - top: 0, - right: 0, - bottom: 0, - left: 0, - ...padding2 - }; -} -function getPaddingObject(padding2) { - return typeof padding2 !== "number" ? expandPaddingObject(padding2) : { - top: padding2, - right: padding2, - bottom: padding2, - left: padding2 - }; -} -function rectToClientRect(rect) { - const { - x, - y: y2, - width, - height - } = rect; - return { - width, - height, - top: y2, - left: x, - right: x + width, - bottom: y2 + height, - x, - y: y2 - }; -} -function computeCoordsFromPlacement(_ref, placement, rtl) { - let { - reference, - floating - } = _ref; - const sideAxis = getSideAxis(placement); - const alignmentAxis = getAlignmentAxis(placement); - const alignLength = getAxisLength(alignmentAxis); - const side = getSide(placement); - const isVertical = sideAxis === "y"; - const commonX = reference.x + reference.width / 2 - floating.width / 2; - const commonY = reference.y + reference.height / 2 - floating.height / 2; - const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; - let coords; - switch (side) { - case "top": - coords = { - x: commonX, - y: reference.y - floating.height - }; - break; - case "bottom": - coords = { - x: commonX, - y: reference.y + reference.height - }; - break; - case "right": - coords = { - x: reference.x + reference.width, - y: commonY - }; - break; - case "left": - coords = { - x: reference.x - floating.width, - y: commonY - }; - break; - default: - coords = { - x: reference.x, - y: reference.y - }; - } - switch (getAlignment(placement)) { - case "start": - coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); - break; - case "end": - coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); - break; + add(doc) { + if (!isDefined(doc)) { + return; + } + this._docs.push(doc); + this._myIndex.add(doc); } - return coords; -} -const computePosition$1 = async (reference, floating, config2) => { - const { - placement = "bottom", - strategy = "absolute", - middleware = [], - platform: platform2 - } = config2; - const validMiddleware = middleware.filter(Boolean); - const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating)); - let rects = await platform2.getElementRects({ - reference, - floating, - strategy - }); - let { - x, - y: y2 - } = computeCoordsFromPlacement(rects, placement, rtl); - let statefulPlacement = placement; - let middlewareData = {}; - let resetCount = 0; - for (let i2 = 0; i2 < validMiddleware.length; i2++) { - const { - name: name2, - fn - } = validMiddleware[i2]; - const { - x: nextX, - y: nextY, - data, - reset - } = await fn({ - x, - y: y2, - initialPlacement: placement, - placement: statefulPlacement, - strategy, - middlewareData, - rects, - platform: platform2, - elements: { - reference, - floating - } - }); - x = nextX != null ? nextX : x; - y2 = nextY != null ? nextY : y2; - middlewareData = { - ...middlewareData, - [name2]: { - ...middlewareData[name2], - ...data - } - }; - if (reset && resetCount <= 50) { - resetCount++; - if (typeof reset === "object") { - if (reset.placement) { - statefulPlacement = reset.placement; - } - if (reset.rects) { - rects = reset.rects === true ? await platform2.getElementRects({ - reference, - floating, - strategy - }) : reset.rects; - } - ({ - x, - y: y2 - } = computeCoordsFromPlacement(rects, statefulPlacement, rtl)); + remove(predicate = () => false) { + const results2 = []; + for (let i2 = 0, len = this._docs.length; i2 < len; i2 += 1) { + const doc = this._docs[i2]; + if (predicate(doc, i2)) { + this.removeAt(i2); + i2 -= 1; + len -= 1; + results2.push(doc); } - i2 = -1; } + return results2; } - return { - x, - y: y2, - placement: statefulPlacement, - strategy, - middlewareData - }; -}; -async function detectOverflow(state, options) { - var _await$platform$isEle; - if (options === void 0) { - options = {}; + removeAt(idx) { + this._docs.splice(idx, 1); + this._myIndex.removeAt(idx); } - const { - x, - y: y2, - platform: platform2, - rects, - elements, - strategy - } = state; - const { - boundary = "clippingAncestors", - rootBoundary = "viewport", - elementContext = "floating", - altBoundary = false, - padding: padding2 = 0 - } = evaluate(options, state); - const paddingObject = getPaddingObject(padding2); - const altContext = elementContext === "floating" ? "reference" : "floating"; - const element = elements[altBoundary ? altContext : elementContext]; - const clippingClientRect = rectToClientRect(await platform2.getClippingRect({ - element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)), - boundary, - rootBoundary, - strategy - })); - const rect = elementContext === "floating" ? { - x, - y: y2, - width: rects.floating.width, - height: rects.floating.height - } : rects.reference; - const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating)); - const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || { - x: 1, - y: 1 - } : { - x: 1, - y: 1 - }; - const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({ - elements, - rect, - offsetParent, - strategy - }) : rect); - return { - top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y, - bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y, - left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x, - right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x - }; -} -const arrow$2 = (options) => ({ - name: "arrow", - options, - async fn(state) { - const { - x, - y: y2, - placement, - rects, - platform: platform2, - elements, - middlewareData - } = state; + getIndex() { + return this._myIndex; + } + search(query, { limit = -1 } = {}) { const { - element, - padding: padding2 = 0 - } = evaluate(options, state) || {}; - if (element == null) { - return {}; + includeMatches, + includeScore, + shouldSort, + sortFn, + ignoreFieldNorm + } = this.options; + let results2 = isString(query) ? isString(this._docs[0]) ? this._searchStringList(query) : this._searchObjectList(query) : this._searchLogical(query); + computeScore(results2, { ignoreFieldNorm }); + if (shouldSort) { + results2.sort(sortFn); } - const paddingObject = getPaddingObject(padding2); - const coords = { - x, - y: y2 - }; - const axis = getAlignmentAxis(placement); - const length = getAxisLength(axis); - const arrowDimensions = await platform2.getDimensions(element); - const isYAxis = axis === "y"; - const minProp = isYAxis ? "top" : "left"; - const maxProp = isYAxis ? "bottom" : "right"; - const clientProp = isYAxis ? "clientHeight" : "clientWidth"; - const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length]; - const startDiff = coords[axis] - rects.reference[axis]; - const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element)); - let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0; - if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) { - clientSize = elements.floating[clientProp] || rects.floating[length]; + if (isNumber(limit) && limit > -1) { + results2 = results2.slice(0, limit); } - const centerToReference = endDiff / 2 - startDiff / 2; - const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1; - const minPadding = min(paddingObject[minProp], largestPossiblePadding); - const maxPadding = min(paddingObject[maxProp], largestPossiblePadding); - const min$12 = minPadding; - const max2 = clientSize - arrowDimensions[length] - maxPadding; - const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference; - const offset2 = clamp(min$12, center, max2); - const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset2 && rects.reference[length] / 2 - (center < min$12 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0; - const alignmentOffset = shouldAddOffset ? center < min$12 ? center - min$12 : center - max2 : 0; - return { - [axis]: coords[axis] + alignmentOffset, - data: { - [axis]: offset2, - centerOffset: center - offset2 - alignmentOffset, - ...shouldAddOffset && { - alignmentOffset - } - }, - reset: shouldAddOffset - }; - } -}); -const flip$1 = function(options) { - if (options === void 0) { - options = {}; + return format(results2, this._docs, { + includeMatches, + includeScore + }); } - return { - name: "flip", - options, - async fn(state) { - var _middlewareData$arrow, _middlewareData$flip; - const { - placement, - middlewareData, - rects, - initialPlacement, - platform: platform2, - elements - } = state; - const { - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = true, - fallbackPlacements: specifiedFallbackPlacements, - fallbackStrategy = "bestFit", - fallbackAxisSideDirection = "none", - flipAlignment = true, - ...detectOverflowOptions - } = evaluate(options, state); - if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { - return {}; - } - const side = getSide(placement); - const isBasePlacement = getSide(initialPlacement) === initialPlacement; - const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)); - const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement)); - if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== "none") { - fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)); - } - const placements = [initialPlacement, ...fallbackPlacements]; - const overflow = await detectOverflow(state, detectOverflowOptions); - const overflows = []; - let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; - if (checkMainAxis) { - overflows.push(overflow[side]); + _searchStringList(query) { + const searcher = createSearcher(query, this.options); + const { records } = this._myIndex; + const results2 = []; + records.forEach(({ v: text2, i: idx, n: norm2 }) => { + if (!isDefined(text2)) { + return; } - if (checkCrossAxis) { - const sides2 = getAlignmentSides(placement, rects, rtl); - overflows.push(overflow[sides2[0]], overflow[sides2[1]]); + const { isMatch, score, indices } = searcher.searchIn(text2); + if (isMatch) { + results2.push({ + item: text2, + idx, + matches: [{ score, value: text2, norm: norm2, indices }] + }); } - overflowsData = [...overflowsData, { - placement, - overflows - }]; - if (!overflows.every((side2) => side2 <= 0)) { - var _middlewareData$flip2, _overflowsData$filter; - const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1; - const nextPlacement = placements[nextIndex]; - if (nextPlacement) { - return { - data: { - index: nextIndex, - overflows: overflowsData - }, - reset: { - placement: nextPlacement - } - }; - } - let resetPlacement = (_overflowsData$filter = overflowsData.filter((d2) => d2.overflows[0] <= 0).sort((a2, b2) => a2.overflows[1] - b2.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement; - if (!resetPlacement) { - switch (fallbackStrategy) { - case "bestFit": { - var _overflowsData$map$so; - const placement2 = (_overflowsData$map$so = overflowsData.map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b2) => a2[1] - b2[1])[0]) == null ? void 0 : _overflowsData$map$so[0]; - if (placement2) { - resetPlacement = placement2; - } - break; + }); + return results2; + } + _searchLogical(query) { + const expression = parse$1(query, this.options); + const evaluate2 = (node, item2, idx) => { + if (!node.children) { + const { keyId, searcher } = node; + const matches = this._findMatches({ + key: this._keyStore.get(keyId), + value: this._myIndex.getValueForItemAtKeyId(item2, keyId), + searcher + }); + if (matches && matches.length) { + return [ + { + idx, + item: item2, + matches } - case "initialPlacement": - resetPlacement = initialPlacement; - break; - } + ]; } - if (placement !== resetPlacement) { - return { - reset: { - placement: resetPlacement - } - }; + return []; + } + const res = []; + for (let i2 = 0, len = node.children.length; i2 < len; i2 += 1) { + const child = node.children[i2]; + const result = evaluate2(child, item2, idx); + if (result.length) { + res.push(...result); + } else if (node.operator === LogicalOperator.AND) { + return []; } } - return {}; - } - }; -}; -function getSideOffsets(overflow, rect) { - return { - top: overflow.top - rect.height, - right: overflow.right - rect.width, - bottom: overflow.bottom - rect.height, - left: overflow.left - rect.width - }; -} -function isAnySideFullyClipped(overflow) { - return sides.some((side) => overflow[side] >= 0); -} -const hide$1 = function(options) { - if (options === void 0) { - options = {}; - } - return { - name: "hide", - options, - async fn(state) { - const { - rects - } = state; - const { - strategy = "referenceHidden", - ...detectOverflowOptions - } = evaluate(options, state); - switch (strategy) { - case "referenceHidden": { - const overflow = await detectOverflow(state, { - ...detectOverflowOptions, - elementContext: "reference" + return res; + }; + const records = this._myIndex.records; + const resultMap = {}; + const results2 = []; + records.forEach(({ $: item2, i: idx }) => { + if (isDefined(item2)) { + let expResults = evaluate2(expression, item2, idx); + if (expResults.length) { + if (!resultMap[idx]) { + resultMap[idx] = { idx, item: item2, matches: [] }; + results2.push(resultMap[idx]); + } + expResults.forEach(({ matches }) => { + resultMap[idx].matches.push(...matches); }); - const offsets = getSideOffsets(overflow, rects.reference); - return { - data: { - referenceHiddenOffsets: offsets, - referenceHidden: isAnySideFullyClipped(offsets) - } - }; } - case "escaped": { - const overflow = await detectOverflow(state, { - ...detectOverflowOptions, - altBoundary: true - }); - const offsets = getSideOffsets(overflow, rects.floating); - return { - data: { - escapedOffsets: offsets, - escaped: isAnySideFullyClipped(offsets) - } - }; - } - default: { - return {}; - } - } - } - }; -}; -async function convertValueToCoords(state, options) { - const { - placement, - platform: platform2, - elements - } = state; - const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)); - const side = getSide(placement); - const alignment = getAlignment(placement); - const isVertical = getSideAxis(placement) === "y"; - const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1; - const crossAxisMulti = rtl && isVertical ? -1 : 1; - const rawValue = evaluate(options, state); - let { - mainAxis, - crossAxis, - alignmentAxis - } = typeof rawValue === "number" ? { - mainAxis: rawValue, - crossAxis: 0, - alignmentAxis: null - } : { - mainAxis: 0, - crossAxis: 0, - alignmentAxis: null, - ...rawValue - }; - if (alignment && typeof alignmentAxis === "number") { - crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis; - } - return isVertical ? { - x: crossAxis * crossAxisMulti, - y: mainAxis * mainAxisMulti - } : { - x: mainAxis * mainAxisMulti, - y: crossAxis * crossAxisMulti - }; -} -const offset$1 = function(options) { - if (options === void 0) { - options = 0; - } - return { - name: "offset", - options, - async fn(state) { - var _middlewareData$offse, _middlewareData$arrow; - const { - x, - y: y2, - placement, - middlewareData - } = state; - const diffCoords = await convertValueToCoords(state, options); - if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) { - return {}; } - return { - x: x + diffCoords.x, - y: y2 + diffCoords.y, - data: { - ...diffCoords, - placement - } - }; - } - }; -}; -const shift$1 = function(options) { - if (options === void 0) { - options = {}; + }); + return results2; } - return { - name: "shift", - options, - async fn(state) { - const { - x, - y: y2, - placement - } = state; - const { - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = false, - limiter = { - fn: (_ref) => { - let { - x: x2, - y: y3 - } = _ref; - return { - x: x2, - y: y3 - }; - } - }, - ...detectOverflowOptions - } = evaluate(options, state); - const coords = { - x, - y: y2 - }; - const overflow = await detectOverflow(state, detectOverflowOptions); - const crossAxis = getSideAxis(getSide(placement)); - const mainAxis = getOppositeAxis(crossAxis); - let mainAxisCoord = coords[mainAxis]; - let crossAxisCoord = coords[crossAxis]; - if (checkMainAxis) { - const minSide = mainAxis === "y" ? "top" : "left"; - const maxSide = mainAxis === "y" ? "bottom" : "right"; - const min2 = mainAxisCoord + overflow[minSide]; - const max2 = mainAxisCoord - overflow[maxSide]; - mainAxisCoord = clamp(min2, mainAxisCoord, max2); - } - if (checkCrossAxis) { - const minSide = crossAxis === "y" ? "top" : "left"; - const maxSide = crossAxis === "y" ? "bottom" : "right"; - const min2 = crossAxisCoord + overflow[minSide]; - const max2 = crossAxisCoord - overflow[maxSide]; - crossAxisCoord = clamp(min2, crossAxisCoord, max2); + _searchObjectList(query) { + const searcher = createSearcher(query, this.options); + const { keys, records } = this._myIndex; + const results2 = []; + records.forEach(({ $: item2, i: idx }) => { + if (!isDefined(item2)) { + return; } - const limitedCoords = limiter.fn({ - ...state, - [mainAxis]: mainAxisCoord, - [crossAxis]: crossAxisCoord + let matches = []; + keys.forEach((key2, keyIndex) => { + matches.push( + ...this._findMatches({ + key: key2, + value: item2[keyIndex], + searcher + }) + ); }); - return { - ...limitedCoords, - data: { - x: limitedCoords.x - x, - y: limitedCoords.y - y2 - } - }; - } - }; -}; -const limitShift$1 = function(options) { - if (options === void 0) { - options = {}; - } - return { - options, - fn(state) { - const { - x, - y: y2, - placement, - rects, - middlewareData - } = state; - const { - offset: offset2 = 0, - mainAxis: checkMainAxis = true, - crossAxis: checkCrossAxis = true - } = evaluate(options, state); - const coords = { - x, - y: y2 - }; - const crossAxis = getSideAxis(placement); - const mainAxis = getOppositeAxis(crossAxis); - let mainAxisCoord = coords[mainAxis]; - let crossAxisCoord = coords[crossAxis]; - const rawOffset = evaluate(offset2, state); - const computedOffset = typeof rawOffset === "number" ? { - mainAxis: rawOffset, - crossAxis: 0 - } : { - mainAxis: 0, - crossAxis: 0, - ...rawOffset - }; - if (checkMainAxis) { - const len = mainAxis === "y" ? "height" : "width"; - const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis; - const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis; - if (mainAxisCoord < limitMin) { - mainAxisCoord = limitMin; - } else if (mainAxisCoord > limitMax) { - mainAxisCoord = limitMax; - } - } - if (checkCrossAxis) { - var _middlewareData$offse, _middlewareData$offse2; - const len = mainAxis === "y" ? "width" : "height"; - const isOriginSide = ["top", "left"].includes(getSide(placement)); - const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis); - const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0); - if (crossAxisCoord < limitMin) { - crossAxisCoord = limitMin; - } else if (crossAxisCoord > limitMax) { - crossAxisCoord = limitMax; - } + if (matches.length) { + results2.push({ + idx, + item: item2, + matches + }); } - return { - [mainAxis]: mainAxisCoord, - [crossAxis]: crossAxisCoord - }; - } - }; -}; -const size$1 = function(options) { - if (options === void 0) { - options = {}; + }); + return results2; } - return { - name: "size", - options, - async fn(state) { - const { - placement, - rects, - platform: platform2, - elements - } = state; - const { - apply = () => { - }, - ...detectOverflowOptions - } = evaluate(options, state); - const overflow = await detectOverflow(state, detectOverflowOptions); - const side = getSide(placement); - const alignment = getAlignment(placement); - const isYAxis = getSideAxis(placement) === "y"; - const { - width, - height - } = rects.floating; - let heightSide; - let widthSide; - if (side === "top" || side === "bottom") { - heightSide = side; - widthSide = alignment === (await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right"; - } else { - widthSide = side; - heightSide = alignment === "end" ? "top" : "bottom"; - } - const overflowAvailableHeight = height - overflow[heightSide]; - const overflowAvailableWidth = width - overflow[widthSide]; - const noShift = !state.middlewareData.shift; - let availableHeight = overflowAvailableHeight; - let availableWidth = overflowAvailableWidth; - if (isYAxis) { - const maximumClippingWidth = width - overflow.left - overflow.right; - availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth; - } else { - const maximumClippingHeight = height - overflow.top - overflow.bottom; - availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight; - } - if (noShift && !alignment) { - const xMin = max(overflow.left, 0); - const xMax = max(overflow.right, 0); - const yMin = max(overflow.top, 0); - const yMax = max(overflow.bottom, 0); - if (isYAxis) { - availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)); - } else { - availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)); + _findMatches({ key: key2, value, searcher }) { + if (!isDefined(value)) { + return []; + } + let matches = []; + if (isArray(value)) { + value.forEach(({ v: text2, i: idx, n: norm2 }) => { + if (!isDefined(text2)) { + return; + } + const { isMatch, score, indices } = searcher.searchIn(text2); + if (isMatch) { + matches.push({ + score, + key: key2, + value: text2, + idx, + norm: norm2, + indices + }); } - } - await apply({ - ...state, - availableWidth, - availableHeight }); - const nextDimensions = await platform2.getDimensions(elements.floating); - if (width !== nextDimensions.width || height !== nextDimensions.height) { - return { - reset: { - rects: true - } - }; + } else { + const { v: text2, n: norm2 } = value; + const { isMatch, score, indices } = searcher.searchIn(text2); + if (isMatch) { + matches.push({ score, key: key2, value: text2, norm: norm2, indices }); } - return {}; } - }; -}; -function getNodeName(node) { - if (isNode(node)) { - return (node.nodeName || "").toLowerCase(); + return matches; } - return "#document"; } -function getWindow(node) { - var _node$ownerDocument; - return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window; +Fuse.version = "6.6.2"; +Fuse.createIndex = createIndex; +Fuse.parseIndex = parseIndex; +Fuse.config = Config; +{ + Fuse.parseQuery = parse$1; } -function getDocumentElement(node) { - var _ref; - return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement; +{ + register(ExtendedSearch); } -function isNode(value) { - return value instanceof Node || value instanceof getWindow(value).Node; +function r$1(e2) { + var t2, f2, n2 = ""; + if ("string" == typeof e2 || "number" == typeof e2) + n2 += e2; + else if ("object" == typeof e2) + if (Array.isArray(e2)) { + var o2 = e2.length; + for (t2 = 0; t2 < o2; t2++) + e2[t2] && (f2 = r$1(e2[t2])) && (n2 && (n2 += " "), n2 += f2); + } else + for (f2 in e2) + e2[f2] && (n2 && (n2 += " "), n2 += f2); + return n2; } -function isElement(value) { - return value instanceof Element || value instanceof getWindow(value).Element; +function clsx() { + for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) + (e2 = arguments[f2]) && (t2 = r$1(e2)) && (n2 && (n2 += " "), n2 += t2); + return n2; } -function isHTMLElement(value) { - return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement; +function _extends$3() { + _extends$3 = Object.assign ? Object.assign.bind() : function(target) { + for (var i2 = 1; i2 < arguments.length; i2++) { + var source = arguments[i2]; + for (var key2 in source) { + if (Object.prototype.hasOwnProperty.call(source, key2)) { + target[key2] = source[key2]; + } + } + } + return target; + }; + return _extends$3.apply(this, arguments); } -function isShadowRoot(value) { - if (typeof ShadowRoot === "undefined") { - return false; - } - return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot; +function $e42e1063c40fb3ef$export$b9ecd428b558ff10(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) { + return function handleEvent(event) { + originalEventHandler === null || originalEventHandler === void 0 || originalEventHandler(event); + if (checkForDefaultPrevented === false || !event.defaultPrevented) + return ourEventHandler === null || ourEventHandler === void 0 ? void 0 : ourEventHandler(event); + }; } -function isOverflowElement(element) { - const { - overflow, - overflowX, - overflowY, - display - } = getComputedStyle$1(element); - return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display); +function $6ed0406888f73fc4$var$setRef(ref, value) { + if (typeof ref === "function") + ref(value); + else if (ref !== null && ref !== void 0) + ref.current = value; } -function isTableElement(element) { - return ["table", "td", "th"].includes(getNodeName(element)); +function $6ed0406888f73fc4$export$43e446d32b3d21af(...refs) { + return (node) => refs.forEach( + (ref) => $6ed0406888f73fc4$var$setRef(ref, node) + ); } -function isContainingBlock(element) { - const webkit = isWebKit(); - const css = getComputedStyle$1(element); - return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value)); +function $6ed0406888f73fc4$export$c7b2cbe3552a0d05(...refs) { + return reactExports.useCallback($6ed0406888f73fc4$export$43e446d32b3d21af(...refs), refs); } -function getContainingBlock(element) { - let currentNode = getParentNode(element); - while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) { - if (isContainingBlock(currentNode)) { - return currentNode; +function $c512c27ab02ef895$export$50c7b4e9d9f19c1(scopeName, createContextScopeDeps = []) { + let defaultContexts2 = []; + function $c512c27ab02ef895$export$fd42f52fd3ae1109(rootComponentName, defaultContext) { + const BaseContext = /* @__PURE__ */ reactExports.createContext(defaultContext); + const index2 = defaultContexts2.length; + defaultContexts2 = [ + ...defaultContexts2, + defaultContext + ]; + function Provider2(props) { + const { scope, children, ...context2 } = props; + const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index2]) || BaseContext; + const value = reactExports.useMemo( + () => context2, + Object.values(context2) + ); + return /* @__PURE__ */ reactExports.createElement(Context.Provider, { + value + }, children); } - currentNode = getParentNode(currentNode); + function useContext(consumerName, scope) { + const Context = (scope === null || scope === void 0 ? void 0 : scope[scopeName][index2]) || BaseContext; + const context2 = reactExports.useContext(Context); + if (context2) + return context2; + if (defaultContext !== void 0) + return defaultContext; + throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``); + } + Provider2.displayName = rootComponentName + "Provider"; + return [ + Provider2, + useContext + ]; } - return null; -} -function isWebKit() { - if (typeof CSS === "undefined" || !CSS.supports) - return false; - return CSS.supports("-webkit-backdrop-filter", "none"); -} -function isLastTraversableNode(node) { - return ["html", "body", "#document"].includes(getNodeName(node)); -} -function getComputedStyle$1(element) { - return getWindow(element).getComputedStyle(element); -} -function getNodeScroll(element) { - if (isElement(element)) { - return { - scrollLeft: element.scrollLeft, - scrollTop: element.scrollTop + const createScope2 = () => { + const scopeContexts = defaultContexts2.map((defaultContext) => { + return /* @__PURE__ */ reactExports.createContext(defaultContext); + }); + return function useScope(scope) { + const contexts = (scope === null || scope === void 0 ? void 0 : scope[scopeName]) || scopeContexts; + return reactExports.useMemo( + () => ({ + [`__scope${scopeName}`]: { + ...scope, + [scopeName]: contexts + } + }), + [ + scope, + contexts + ] + ); }; - } - return { - scrollLeft: element.pageXOffset, - scrollTop: element.pageYOffset }; + createScope2.scopeName = scopeName; + return [ + $c512c27ab02ef895$export$fd42f52fd3ae1109, + $c512c27ab02ef895$var$composeContextScopes(createScope2, ...createContextScopeDeps) + ]; } -function getParentNode(node) { - if (getNodeName(node) === "html") { - return node; - } - const result = ( - // Step into the shadow DOM of the parent of a slotted node. - node.assignedSlot || // DOM Element detected. - node.parentNode || // ShadowRoot detected. - isShadowRoot(node) && node.host || // Fallback. - getDocumentElement(node) - ); - return isShadowRoot(result) ? result.host : result; -} -function getNearestOverflowAncestor(node) { - const parentNode = getParentNode(node); - if (isLastTraversableNode(parentNode)) { - return node.ownerDocument ? node.ownerDocument.body : node.body; - } - if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) { - return parentNode; - } - return getNearestOverflowAncestor(parentNode); +function $c512c27ab02ef895$var$composeContextScopes(...scopes) { + const baseScope = scopes[0]; + if (scopes.length === 1) + return baseScope; + const createScope1 = () => { + const scopeHooks = scopes.map( + (createScope2) => ({ + useScope: createScope2(), + scopeName: createScope2.scopeName + }) + ); + return function useComposedScopes(overrideScopes) { + const nextScopes1 = scopeHooks.reduce((nextScopes, { useScope, scopeName }) => { + const scopeProps = useScope(overrideScopes); + const currentScope = scopeProps[`__scope${scopeName}`]; + return { + ...nextScopes, + ...currentScope + }; + }, {}); + return reactExports.useMemo( + () => ({ + [`__scope${baseScope.scopeName}`]: nextScopes1 + }), + [ + nextScopes1 + ] + ); + }; + }; + createScope1.scopeName = baseScope.scopeName; + return createScope1; } -function getOverflowAncestors(node, list2, traverseIframes) { - var _node$ownerDocument2; - if (list2 === void 0) { - list2 = []; - } - if (traverseIframes === void 0) { - traverseIframes = true; - } - const scrollableAncestor = getNearestOverflowAncestor(node); - const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body); - const win = getWindow(scrollableAncestor); - if (isBody) { - return list2.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []); +const $5e63c961fc1ce211$export$8c6ed5c666ac1360 = /* @__PURE__ */ reactExports.forwardRef((props, forwardedRef) => { + const { children, ...slotProps } = props; + const childrenArray = reactExports.Children.toArray(children); + const slottable = childrenArray.find($5e63c961fc1ce211$var$isSlottable); + if (slottable) { + const newElement = slottable.props.children; + const newChildren = childrenArray.map((child) => { + if (child === slottable) { + if (reactExports.Children.count(newElement) > 1) + return reactExports.Children.only(null); + return /* @__PURE__ */ reactExports.isValidElement(newElement) ? newElement.props.children : null; + } else + return child; + }); + return /* @__PURE__ */ reactExports.createElement($5e63c961fc1ce211$var$SlotClone, _extends$3({}, slotProps, { + ref: forwardedRef + }), /* @__PURE__ */ reactExports.isValidElement(newElement) ? /* @__PURE__ */ reactExports.cloneElement(newElement, void 0, newChildren) : null); } - return list2.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes)); + return /* @__PURE__ */ reactExports.createElement($5e63c961fc1ce211$var$SlotClone, _extends$3({}, slotProps, { + ref: forwardedRef + }), children); +}); +$5e63c961fc1ce211$export$8c6ed5c666ac1360.displayName = "Slot"; +const $5e63c961fc1ce211$var$SlotClone = /* @__PURE__ */ reactExports.forwardRef((props, forwardedRef) => { + const { children, ...slotProps } = props; + if (/* @__PURE__ */ reactExports.isValidElement(children)) + return /* @__PURE__ */ reactExports.cloneElement(children, { + ...$5e63c961fc1ce211$var$mergeProps(slotProps, children.props), + ref: forwardedRef ? $6ed0406888f73fc4$export$43e446d32b3d21af(forwardedRef, children.ref) : children.ref + }); + return reactExports.Children.count(children) > 1 ? reactExports.Children.only(null) : null; +}); +$5e63c961fc1ce211$var$SlotClone.displayName = "SlotClone"; +const $5e63c961fc1ce211$export$d9f1ccf0bdb05d45 = ({ children }) => { + return /* @__PURE__ */ reactExports.createElement(reactExports.Fragment, null, children); +}; +function $5e63c961fc1ce211$var$isSlottable(child) { + return /* @__PURE__ */ reactExports.isValidElement(child) && child.type === $5e63c961fc1ce211$export$d9f1ccf0bdb05d45; } -function getCssDimensions(element) { - const css = getComputedStyle$1(element); - let width = parseFloat(css.width) || 0; - let height = parseFloat(css.height) || 0; - const hasOffset = isHTMLElement(element); - const offsetWidth = hasOffset ? element.offsetWidth : width; - const offsetHeight = hasOffset ? element.offsetHeight : height; - const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight; - if (shouldFallback) { - width = offsetWidth; - height = offsetHeight; - } - return { - width, - height, - $: shouldFallback +function $5e63c961fc1ce211$var$mergeProps(slotProps, childProps) { + const overrideProps = { + ...childProps }; -} -function unwrapElement(element) { - return !isElement(element) ? element.contextElement : element; -} -function getScale(element) { - const domElement = unwrapElement(element); - if (!isHTMLElement(domElement)) { - return createCoords(1); - } - const rect = domElement.getBoundingClientRect(); - const { - width, - height, - $ - } = getCssDimensions(domElement); - let x = ($ ? round(rect.width) : rect.width) / width; - let y2 = ($ ? round(rect.height) : rect.height) / height; - if (!x || !Number.isFinite(x)) { - x = 1; - } - if (!y2 || !Number.isFinite(y2)) { - y2 = 1; + for (const propName in childProps) { + const slotPropValue = slotProps[propName]; + const childPropValue = childProps[propName]; + const isHandler = /^on[A-Z]/.test(propName); + if (isHandler) { + if (slotPropValue && childPropValue) + overrideProps[propName] = (...args) => { + childPropValue(...args); + slotPropValue(...args); + }; + else if (slotPropValue) + overrideProps[propName] = slotPropValue; + } else if (propName === "style") + overrideProps[propName] = { + ...slotPropValue, + ...childPropValue + }; + else if (propName === "className") + overrideProps[propName] = [ + slotPropValue, + childPropValue + ].filter(Boolean).join(" "); } return { - x, - y: y2 + ...slotProps, + ...overrideProps }; } -const noOffsets = /* @__PURE__ */ createCoords(0); -function getVisualOffsets(element) { - const win = getWindow(element); - if (!isWebKit() || !win.visualViewport) { - return noOffsets; - } +const $8927f6f2acc4f386$var$NODES = [ + "a", + "button", + "div", + "form", + "h2", + "h3", + "img", + "input", + "label", + "li", + "nav", + "ol", + "p", + "span", + "svg", + "ul" +]; +const $8927f6f2acc4f386$export$250ffa63cdc0d034 = $8927f6f2acc4f386$var$NODES.reduce((primitive, node) => { + const Node2 = /* @__PURE__ */ reactExports.forwardRef((props, forwardedRef) => { + const { asChild, ...primitiveProps } = props; + const Comp = asChild ? $5e63c961fc1ce211$export$8c6ed5c666ac1360 : node; + reactExports.useEffect(() => { + window[Symbol.for("radix-ui")] = true; + }, []); + return /* @__PURE__ */ reactExports.createElement(Comp, _extends$3({}, primitiveProps, { + ref: forwardedRef + })); + }); + Node2.displayName = `Primitive.${node}`; return { - x: win.visualViewport.offsetLeft, - y: win.visualViewport.offsetTop + ...primitive, + [node]: Node2 }; +}, {}); +function $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event) { + if (target) + reactDomExports.flushSync( + () => target.dispatchEvent(event) + ); } -function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) { - if (isFixed === void 0) { - isFixed = false; - } - if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) { - return false; - } - return isFixed; -} -function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) { - if (includeScale === void 0) { - includeScale = false; - } - if (isFixedStrategy === void 0) { - isFixedStrategy = false; - } - const clientRect = element.getBoundingClientRect(); - const domElement = unwrapElement(element); - let scale2 = createCoords(1); - if (includeScale) { - if (offsetParent) { - if (isElement(offsetParent)) { - scale2 = getScale(offsetParent); - } - } else { - scale2 = getScale(element); - } - } - const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0); - let x = (clientRect.left + visualOffsets.x) / scale2.x; - let y2 = (clientRect.top + visualOffsets.y) / scale2.y; - let width = clientRect.width / scale2.x; - let height = clientRect.height / scale2.y; - if (domElement) { - const win = getWindow(domElement); - const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent; - let currentWin = win; - let currentIFrame = currentWin.frameElement; - while (currentIFrame && offsetParent && offsetWin !== currentWin) { - const iframeScale = getScale(currentIFrame); - const iframeRect = currentIFrame.getBoundingClientRect(); - const css = getComputedStyle$1(currentIFrame); - const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x; - const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y; - x *= iframeScale.x; - y2 *= iframeScale.y; - width *= iframeScale.x; - height *= iframeScale.y; - x += left; - y2 += top; - currentWin = getWindow(currentIFrame); - currentIFrame = currentWin.frameElement; - } - } - return rectToClientRect({ - width, - height, - x, - y: y2 +function $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(callback) { + const callbackRef = reactExports.useRef(callback); + reactExports.useEffect(() => { + callbackRef.current = callback; }); + return reactExports.useMemo( + () => (...args) => { + var _callbackRef$current; + return (_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call(callbackRef, ...args); + }, + [] + ); } -const topLayerSelectors = [":popover-open", ":modal"]; -function isTopLayer(element) { - return topLayerSelectors.some((selector2) => { - try { - return element.matches(selector2); - } catch (e2) { - return false; - } - }); +function $addc16e1bbe58fd0$export$3a72a57244d6e765(onEscapeKeyDownProp, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) { + const onEscapeKeyDown = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onEscapeKeyDownProp); + reactExports.useEffect(() => { + const handleKeyDown = (event) => { + if (event.key === "Escape") + onEscapeKeyDown(event); + }; + ownerDocument.addEventListener("keydown", handleKeyDown); + return () => ownerDocument.removeEventListener("keydown", handleKeyDown); + }, [ + onEscapeKeyDown, + ownerDocument + ]); } -function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) { - let { - elements, - rect, - offsetParent, - strategy - } = _ref; - const isFixed = strategy === "fixed"; - const documentElement = getDocumentElement(offsetParent); - const topLayer = elements ? isTopLayer(elements.floating) : false; - if (offsetParent === documentElement || topLayer && isFixed) { - return rect; - } - let scroll2 = { - scrollLeft: 0, - scrollTop: 0 - }; - let scale2 = createCoords(1); - const offsets = createCoords(0); - const isOffsetParentAnElement = isHTMLElement(offsetParent); - if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { - if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { - scroll2 = getNodeScroll(offsetParent); +const $5cb92bef7577960e$var$CONTEXT_UPDATE = "dismissableLayer.update"; +const $5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside"; +const $5cb92bef7577960e$var$FOCUS_OUTSIDE = "dismissableLayer.focusOutside"; +let $5cb92bef7577960e$var$originalBodyPointerEvents; +const $5cb92bef7577960e$var$DismissableLayerContext = /* @__PURE__ */ reactExports.createContext({ + layers: /* @__PURE__ */ new Set(), + layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(), + branches: /* @__PURE__ */ new Set() +}); +const $5cb92bef7577960e$export$177fb62ff3ec1f22 = /* @__PURE__ */ reactExports.forwardRef((props, forwardedRef) => { + var _node$ownerDocument; + const { disableOutsidePointerEvents = false, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, onDismiss, ...layerProps } = props; + const context2 = reactExports.useContext($5cb92bef7577960e$var$DismissableLayerContext); + const [node1, setNode] = reactExports.useState(null); + const ownerDocument = (_node$ownerDocument = node1 === null || node1 === void 0 ? void 0 : node1.ownerDocument) !== null && _node$ownerDocument !== void 0 ? _node$ownerDocument : globalThis === null || globalThis === void 0 ? void 0 : globalThis.document; + const [, force] = reactExports.useState({}); + const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05( + forwardedRef, + (node) => setNode(node) + ); + const layers = Array.from(context2.layers); + const [highestLayerWithOutsidePointerEventsDisabled] = [ + ...context2.layersWithOutsidePointerEventsDisabled + ].slice(-1); + const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled); + const index2 = node1 ? layers.indexOf(node1) : -1; + const isBodyPointerEventsDisabled = context2.layersWithOutsidePointerEventsDisabled.size > 0; + const isPointerEventsEnabled = index2 >= highestLayerWithOutsidePointerEventsDisabledIndex; + const pointerDownOutside = $5cb92bef7577960e$var$usePointerDownOutside((event) => { + const target = event.target; + const isPointerDownOnBranch = [ + ...context2.branches + ].some( + (branch) => branch.contains(target) + ); + if (!isPointerEventsEnabled || isPointerDownOnBranch) + return; + onPointerDownOutside === null || onPointerDownOutside === void 0 || onPointerDownOutside(event); + onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event); + if (!event.defaultPrevented) + onDismiss === null || onDismiss === void 0 || onDismiss(); + }, ownerDocument); + const focusOutside = $5cb92bef7577960e$var$useFocusOutside((event) => { + const target = event.target; + const isFocusInBranch = [ + ...context2.branches + ].some( + (branch) => branch.contains(target) + ); + if (isFocusInBranch) + return; + onFocusOutside === null || onFocusOutside === void 0 || onFocusOutside(event); + onInteractOutside === null || onInteractOutside === void 0 || onInteractOutside(event); + if (!event.defaultPrevented) + onDismiss === null || onDismiss === void 0 || onDismiss(); + }, ownerDocument); + $addc16e1bbe58fd0$export$3a72a57244d6e765((event) => { + const isHighestLayer = index2 === context2.layers.size - 1; + if (!isHighestLayer) + return; + onEscapeKeyDown === null || onEscapeKeyDown === void 0 || onEscapeKeyDown(event); + if (!event.defaultPrevented && onDismiss) { + event.preventDefault(); + onDismiss(); } - if (isHTMLElement(offsetParent)) { - const offsetRect = getBoundingClientRect(offsetParent); - scale2 = getScale(offsetParent); - offsets.x = offsetRect.x + offsetParent.clientLeft; - offsets.y = offsetRect.y + offsetParent.clientTop; + }, ownerDocument); + reactExports.useEffect(() => { + if (!node1) + return; + if (disableOutsidePointerEvents) { + if (context2.layersWithOutsidePointerEventsDisabled.size === 0) { + $5cb92bef7577960e$var$originalBodyPointerEvents = ownerDocument.body.style.pointerEvents; + ownerDocument.body.style.pointerEvents = "none"; + } + context2.layersWithOutsidePointerEventsDisabled.add(node1); } - } + context2.layers.add(node1); + $5cb92bef7577960e$var$dispatchUpdate(); + return () => { + if (disableOutsidePointerEvents && context2.layersWithOutsidePointerEventsDisabled.size === 1) + ownerDocument.body.style.pointerEvents = $5cb92bef7577960e$var$originalBodyPointerEvents; + }; + }, [ + node1, + ownerDocument, + disableOutsidePointerEvents, + context2 + ]); + reactExports.useEffect(() => { + return () => { + if (!node1) + return; + context2.layers.delete(node1); + context2.layersWithOutsidePointerEventsDisabled.delete(node1); + $5cb92bef7577960e$var$dispatchUpdate(); + }; + }, [ + node1, + context2 + ]); + reactExports.useEffect(() => { + const handleUpdate = () => force({}); + document.addEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate); + return () => document.removeEventListener($5cb92bef7577960e$var$CONTEXT_UPDATE, handleUpdate); + }, []); + return /* @__PURE__ */ reactExports.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends$3({}, layerProps, { + ref: composedRefs, + style: { + pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0, + ...props.style + }, + onFocusCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onFocusCapture, focusOutside.onFocusCapture), + onBlurCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onBlurCapture, focusOutside.onBlurCapture), + onPointerDownCapture: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onPointerDownCapture, pointerDownOutside.onPointerDownCapture) + })); +}); +function $5cb92bef7577960e$var$usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) { + const handlePointerDownOutside = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onPointerDownOutside); + const isPointerInsideReactTreeRef = reactExports.useRef(false); + const handleClickRef = reactExports.useRef(() => { + }); + reactExports.useEffect(() => { + const handlePointerDown = (event) => { + if (event.target && !isPointerInsideReactTreeRef.current) { + let handleAndDispatchPointerDownOutsideEvent = function() { + $5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$POINTER_DOWN_OUTSIDE, handlePointerDownOutside, eventDetail, { + discrete: true + }); + }; + const eventDetail = { + originalEvent: event + }; + if (event.pointerType === "touch") { + ownerDocument.removeEventListener("click", handleClickRef.current); + handleClickRef.current = handleAndDispatchPointerDownOutsideEvent; + ownerDocument.addEventListener("click", handleClickRef.current, { + once: true + }); + } else + handleAndDispatchPointerDownOutsideEvent(); + } else + ownerDocument.removeEventListener("click", handleClickRef.current); + isPointerInsideReactTreeRef.current = false; + }; + const timerId = window.setTimeout(() => { + ownerDocument.addEventListener("pointerdown", handlePointerDown); + }, 0); + return () => { + window.clearTimeout(timerId); + ownerDocument.removeEventListener("pointerdown", handlePointerDown); + ownerDocument.removeEventListener("click", handleClickRef.current); + }; + }, [ + ownerDocument, + handlePointerDownOutside + ]); return { - width: rect.width * scale2.x, - height: rect.height * scale2.y, - x: rect.x * scale2.x - scroll2.scrollLeft * scale2.x + offsets.x, - y: rect.y * scale2.y - scroll2.scrollTop * scale2.y + offsets.y + // ensures we check React component tree (not just DOM tree) + onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true }; } -function getClientRects(element) { - return Array.from(element.getClientRects()); -} -function getWindowScrollBarX(element) { - return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft; -} -function getDocumentRect(element) { - const html = getDocumentElement(element); - const scroll2 = getNodeScroll(element); - const body = element.ownerDocument.body; - const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth); - const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight); - let x = -scroll2.scrollLeft + getWindowScrollBarX(element); - const y2 = -scroll2.scrollTop; - if (getComputedStyle$1(body).direction === "rtl") { - x += max(html.clientWidth, body.clientWidth) - width; - } - return { - width, - height, - x, - y: y2 - }; -} -function getViewportRect(element, strategy) { - const win = getWindow(element); - const html = getDocumentElement(element); - const visualViewport = win.visualViewport; - let width = html.clientWidth; - let height = html.clientHeight; - let x = 0; - let y2 = 0; - if (visualViewport) { - width = visualViewport.width; - height = visualViewport.height; - const visualViewportBased = isWebKit(); - if (!visualViewportBased || visualViewportBased && strategy === "fixed") { - x = visualViewport.offsetLeft; - y2 = visualViewport.offsetTop; - } - } +function $5cb92bef7577960e$var$useFocusOutside(onFocusOutside, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) { + const handleFocusOutside = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onFocusOutside); + const isFocusInsideReactTreeRef = reactExports.useRef(false); + reactExports.useEffect(() => { + const handleFocus = (event) => { + if (event.target && !isFocusInsideReactTreeRef.current) { + const eventDetail = { + originalEvent: event + }; + $5cb92bef7577960e$var$handleAndDispatchCustomEvent($5cb92bef7577960e$var$FOCUS_OUTSIDE, handleFocusOutside, eventDetail, { + discrete: false + }); + } + }; + ownerDocument.addEventListener("focusin", handleFocus); + return () => ownerDocument.removeEventListener("focusin", handleFocus); + }, [ + ownerDocument, + handleFocusOutside + ]); return { - width, - height, - x, - y: y2 + onFocusCapture: () => isFocusInsideReactTreeRef.current = true, + onBlurCapture: () => isFocusInsideReactTreeRef.current = false }; } -function getInnerBoundingClientRect(element, strategy) { - const clientRect = getBoundingClientRect(element, true, strategy === "fixed"); - const top = clientRect.top + element.clientTop; - const left = clientRect.left + element.clientLeft; - const scale2 = isHTMLElement(element) ? getScale(element) : createCoords(1); - const width = element.clientWidth * scale2.x; - const height = element.clientHeight * scale2.y; - const x = left * scale2.x; - const y2 = top * scale2.y; - return { - width, - height, - x, - y: y2 - }; +function $5cb92bef7577960e$var$dispatchUpdate() { + const event = new CustomEvent($5cb92bef7577960e$var$CONTEXT_UPDATE); + document.dispatchEvent(event); } -function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) { - let rect; - if (clippingAncestor === "viewport") { - rect = getViewportRect(element, strategy); - } else if (clippingAncestor === "document") { - rect = getDocumentRect(getDocumentElement(element)); - } else if (isElement(clippingAncestor)) { - rect = getInnerBoundingClientRect(clippingAncestor, strategy); - } else { - const visualOffsets = getVisualOffsets(element); - rect = { - ...clippingAncestor, - x: clippingAncestor.x - visualOffsets.x, - y: clippingAncestor.y - visualOffsets.y +function $5cb92bef7577960e$var$handleAndDispatchCustomEvent(name2, handler, detail, { discrete }) { + const target = detail.originalEvent.target; + const event = new CustomEvent(name2, { + bubbles: false, + cancelable: true, + detail + }); + if (handler) + target.addEventListener(name2, handler, { + once: true + }); + if (discrete) + $8927f6f2acc4f386$export$6d1a0317bde7de7f(target, event); + else + target.dispatchEvent(event); +} +let $3db38b7d1fb3fe6a$var$count = 0; +function $3db38b7d1fb3fe6a$export$b7ece24a22aeda8c() { + reactExports.useEffect(() => { + var _edgeGuards$, _edgeGuards$2; + const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]"); + document.body.insertAdjacentElement("afterbegin", (_edgeGuards$ = edgeGuards[0]) !== null && _edgeGuards$ !== void 0 ? _edgeGuards$ : $3db38b7d1fb3fe6a$var$createFocusGuard()); + document.body.insertAdjacentElement("beforeend", (_edgeGuards$2 = edgeGuards[1]) !== null && _edgeGuards$2 !== void 0 ? _edgeGuards$2 : $3db38b7d1fb3fe6a$var$createFocusGuard()); + $3db38b7d1fb3fe6a$var$count++; + return () => { + if ($3db38b7d1fb3fe6a$var$count === 1) + document.querySelectorAll("[data-radix-focus-guard]").forEach( + (node) => node.remove() + ); + $3db38b7d1fb3fe6a$var$count--; }; - } - return rectToClientRect(rect); + }, []); } -function hasFixedPositionAncestor(element, stopNode) { - const parentNode = getParentNode(element); - if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) { - return false; - } - return getComputedStyle$1(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode); +function $3db38b7d1fb3fe6a$var$createFocusGuard() { + const element = document.createElement("span"); + element.setAttribute("data-radix-focus-guard", ""); + element.tabIndex = 0; + element.style.cssText = "outline: none; opacity: 0; position: fixed; pointer-events: none"; + return element; } -function getClippingElementAncestors(element, cache) { - const cachedResult = cache.get(element); - if (cachedResult) { - return cachedResult; - } - let result = getOverflowAncestors(element, [], false).filter((el2) => isElement(el2) && getNodeName(el2) !== "body"); - let currentContainingBlockComputedStyle = null; - const elementIsFixed = getComputedStyle$1(element).position === "fixed"; - let currentNode = elementIsFixed ? getParentNode(element) : element; - while (isElement(currentNode) && !isLastTraversableNode(currentNode)) { - const computedStyle = getComputedStyle$1(currentNode); - const currentNodeIsContaining = isContainingBlock(currentNode); - if (!currentNodeIsContaining && computedStyle.position === "fixed") { - currentContainingBlockComputedStyle = null; +const $d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount"; +const $d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount"; +const $d3863c46a17e8a28$var$EVENT_OPTIONS = { + bubbles: false, + cancelable: true +}; +const $d3863c46a17e8a28$export$20e40289641fbbb6 = /* @__PURE__ */ reactExports.forwardRef((props, forwardedRef) => { + const { loop = false, trapped = false, onMountAutoFocus: onMountAutoFocusProp, onUnmountAutoFocus: onUnmountAutoFocusProp, ...scopeProps } = props; + const [container1, setContainer] = reactExports.useState(null); + const onMountAutoFocus = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onMountAutoFocusProp); + const onUnmountAutoFocus = $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onUnmountAutoFocusProp); + const lastFocusedElementRef = reactExports.useRef(null); + const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05( + forwardedRef, + (node) => setContainer(node) + ); + const focusScope = reactExports.useRef({ + paused: false, + pause() { + this.paused = true; + }, + resume() { + this.paused = false; } - const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode); - if (shouldDropCurrentNode) { - result = result.filter((ancestor) => ancestor !== currentNode); - } else { - currentContainingBlockComputedStyle = computedStyle; + }).current; + reactExports.useEffect(() => { + if (trapped) { + let handleFocusIn = function(event) { + if (focusScope.paused || !container1) + return; + const target = event.target; + if (container1.contains(target)) + lastFocusedElementRef.current = target; + else + $d3863c46a17e8a28$var$focus(lastFocusedElementRef.current, { + select: true + }); + }, handleFocusOut = function(event) { + if (focusScope.paused || !container1) + return; + const relatedTarget = event.relatedTarget; + if (relatedTarget === null) + return; + if (!container1.contains(relatedTarget)) + $d3863c46a17e8a28$var$focus(lastFocusedElementRef.current, { + select: true + }); + }, handleMutations = function(mutations) { + const focusedElement = document.activeElement; + if (focusedElement !== document.body) + return; + for (const mutation of mutations) + if (mutation.removedNodes.length > 0) + $d3863c46a17e8a28$var$focus(container1); + }; + document.addEventListener("focusin", handleFocusIn); + document.addEventListener("focusout", handleFocusOut); + const mutationObserver = new MutationObserver(handleMutations); + if (container1) + mutationObserver.observe(container1, { + childList: true, + subtree: true + }); + return () => { + document.removeEventListener("focusin", handleFocusIn); + document.removeEventListener("focusout", handleFocusOut); + mutationObserver.disconnect(); + }; } - currentNode = getParentNode(currentNode); - } - cache.set(element, result); - return result; -} -function getClippingRect(_ref) { - let { - element, - boundary, - rootBoundary, - strategy - } = _ref; - const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary); - const clippingAncestors = [...elementClippingAncestors, rootBoundary]; - const firstClippingAncestor = clippingAncestors[0]; - const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => { - const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy); - accRect.top = max(rect.top, accRect.top); - accRect.right = min(rect.right, accRect.right); - accRect.bottom = min(rect.bottom, accRect.bottom); - accRect.left = max(rect.left, accRect.left); - return accRect; - }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy)); - return { - width: clippingRect.right - clippingRect.left, - height: clippingRect.bottom - clippingRect.top, - x: clippingRect.left, - y: clippingRect.top - }; -} -function getDimensions(element) { - const { - width, - height - } = getCssDimensions(element); - return { - width, - height - }; -} -function getRectRelativeToOffsetParent(element, offsetParent, strategy) { - const isOffsetParentAnElement = isHTMLElement(offsetParent); - const documentElement = getDocumentElement(offsetParent); - const isFixed = strategy === "fixed"; - const rect = getBoundingClientRect(element, true, isFixed, offsetParent); - let scroll2 = { - scrollLeft: 0, - scrollTop: 0 - }; - const offsets = createCoords(0); - if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { - if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) { - scroll2 = getNodeScroll(offsetParent); + }, [ + trapped, + container1, + focusScope.paused + ]); + reactExports.useEffect(() => { + if (container1) { + $d3863c46a17e8a28$var$focusScopesStack.add(focusScope); + const previouslyFocusedElement = document.activeElement; + const hasFocusedCandidate = container1.contains(previouslyFocusedElement); + if (!hasFocusedCandidate) { + const mountEvent = new CustomEvent($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, $d3863c46a17e8a28$var$EVENT_OPTIONS); + container1.addEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, onMountAutoFocus); + container1.dispatchEvent(mountEvent); + if (!mountEvent.defaultPrevented) { + $d3863c46a17e8a28$var$focusFirst($d3863c46a17e8a28$var$removeLinks($d3863c46a17e8a28$var$getTabbableCandidates(container1)), { + select: true + }); + if (document.activeElement === previouslyFocusedElement) + $d3863c46a17e8a28$var$focus(container1); + } + } + return () => { + container1.removeEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_MOUNT, onMountAutoFocus); + setTimeout(() => { + const unmountEvent = new CustomEvent($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, $d3863c46a17e8a28$var$EVENT_OPTIONS); + container1.addEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus); + container1.dispatchEvent(unmountEvent); + if (!unmountEvent.defaultPrevented) + $d3863c46a17e8a28$var$focus(previouslyFocusedElement !== null && previouslyFocusedElement !== void 0 ? previouslyFocusedElement : document.body, { + select: true + }); + container1.removeEventListener($d3863c46a17e8a28$var$AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus); + $d3863c46a17e8a28$var$focusScopesStack.remove(focusScope); + }, 0); + }; } - if (isOffsetParentAnElement) { - const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent); - offsets.x = offsetRect.x + offsetParent.clientLeft; - offsets.y = offsetRect.y + offsetParent.clientTop; - } else if (documentElement) { - offsets.x = getWindowScrollBarX(documentElement); + }, [ + container1, + onMountAutoFocus, + onUnmountAutoFocus, + focusScope + ]); + const handleKeyDown = reactExports.useCallback((event) => { + if (!loop && !trapped) + return; + if (focusScope.paused) + return; + const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey; + const focusedElement = document.activeElement; + if (isTabKey && focusedElement) { + const container = event.currentTarget; + const [first, last] = $d3863c46a17e8a28$var$getTabbableEdges(container); + const hasTabbableElementsInside = first && last; + if (!hasTabbableElementsInside) { + if (focusedElement === container) + event.preventDefault(); + } else { + if (!event.shiftKey && focusedElement === last) { + event.preventDefault(); + if (loop) + $d3863c46a17e8a28$var$focus(first, { + select: true + }); + } else if (event.shiftKey && focusedElement === first) { + event.preventDefault(); + if (loop) + $d3863c46a17e8a28$var$focus(last, { + select: true + }); + } + } } + }, [ + loop, + trapped, + focusScope.paused + ]); + return /* @__PURE__ */ reactExports.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends$3({ + tabIndex: -1 + }, scopeProps, { + ref: composedRefs, + onKeyDown: handleKeyDown + })); +}); +function $d3863c46a17e8a28$var$focusFirst(candidates, { select = false } = {}) { + const previouslyFocusedElement = document.activeElement; + for (const candidate of candidates) { + $d3863c46a17e8a28$var$focus(candidate, { + select + }); + if (document.activeElement !== previouslyFocusedElement) + return; } - const x = rect.left + scroll2.scrollLeft - offsets.x; - const y2 = rect.top + scroll2.scrollTop - offsets.y; - return { - x, - y: y2, - width: rect.width, - height: rect.height - }; -} -function isStaticPositioned(element) { - return getComputedStyle$1(element).position === "static"; } -function getTrueOffsetParent(element, polyfill2) { - if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") { - return null; - } - if (polyfill2) { - return polyfill2(element); - } - return element.offsetParent; +function $d3863c46a17e8a28$var$getTabbableEdges(container) { + const candidates = $d3863c46a17e8a28$var$getTabbableCandidates(container); + const first = $d3863c46a17e8a28$var$findVisible(candidates, container); + const last = $d3863c46a17e8a28$var$findVisible(candidates.reverse(), container); + return [ + first, + last + ]; } -function getOffsetParent(element, polyfill2) { - const win = getWindow(element); - if (isTopLayer(element)) { - return win; - } - if (!isHTMLElement(element)) { - let svgOffsetParent = getParentNode(element); - while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) { - if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) { - return svgOffsetParent; - } - svgOffsetParent = getParentNode(svgOffsetParent); +function $d3863c46a17e8a28$var$getTabbableCandidates(container) { + const nodes = []; + const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, { + acceptNode: (node) => { + const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden"; + if (node.disabled || node.hidden || isHiddenInput) + return NodeFilter.FILTER_SKIP; + return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP; } - return win; + }); + while (walker.nextNode()) + nodes.push(walker.currentNode); + return nodes; +} +function $d3863c46a17e8a28$var$findVisible(elements, container) { + for (const element of elements) { + if (!$d3863c46a17e8a28$var$isHidden(element, { + upTo: container + })) + return element; } - let offsetParent = getTrueOffsetParent(element, polyfill2); - while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) { - offsetParent = getTrueOffsetParent(offsetParent, polyfill2); +} +function $d3863c46a17e8a28$var$isHidden(node, { upTo }) { + if (getComputedStyle(node).visibility === "hidden") + return true; + while (node) { + if (upTo !== void 0 && node === upTo) + return false; + if (getComputedStyle(node).display === "none") + return true; + node = node.parentElement; } - if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) { - return win; + return false; +} +function $d3863c46a17e8a28$var$isSelectableInput(element) { + return element instanceof HTMLInputElement && "select" in element; +} +function $d3863c46a17e8a28$var$focus(element, { select = false } = {}) { + if (element && element.focus) { + const previouslyFocusedElement = document.activeElement; + element.focus({ + preventScroll: true + }); + if (element !== previouslyFocusedElement && $d3863c46a17e8a28$var$isSelectableInput(element) && select) + element.select(); } - return offsetParent || getContainingBlock(element) || win; } -const getElementRects = async function(data) { - const getOffsetParentFn = this.getOffsetParent || getOffsetParent; - const getDimensionsFn = this.getDimensions; - const floatingDimensions = await getDimensionsFn(data.floating); +const $d3863c46a17e8a28$var$focusScopesStack = $d3863c46a17e8a28$var$createFocusScopesStack(); +function $d3863c46a17e8a28$var$createFocusScopesStack() { + let stack = []; return { - reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy), - floating: { - x: 0, - y: 0, - width: floatingDimensions.width, - height: floatingDimensions.height + add(focusScope) { + const activeFocusScope = stack[0]; + if (focusScope !== activeFocusScope) + activeFocusScope === null || activeFocusScope === void 0 || activeFocusScope.pause(); + stack = $d3863c46a17e8a28$var$arrayRemove(stack, focusScope); + stack.unshift(focusScope); + }, + remove(focusScope) { + var _stack$; + stack = $d3863c46a17e8a28$var$arrayRemove(stack, focusScope); + (_stack$ = stack[0]) === null || _stack$ === void 0 || _stack$.resume(); } }; -}; -function isRTL(element) { - return getComputedStyle$1(element).direction === "rtl"; } -const platform = { - convertOffsetParentRelativeRectToViewportRelativeRect, - getDocumentElement, - getClippingRect, - getOffsetParent, - getElementRects, - getClientRects, - getDimensions, - getScale, - isElement, - isRTL +function $d3863c46a17e8a28$var$arrayRemove(array, item2) { + const updatedArray = [ + ...array + ]; + const index2 = updatedArray.indexOf(item2); + if (index2 !== -1) + updatedArray.splice(index2, 1); + return updatedArray; +} +function $d3863c46a17e8a28$var$removeLinks(items) { + return items.filter( + (item2) => item2.tagName !== "A" + ); +} +const $9f79659886946c16$export$e5c5a5f917a5871c = Boolean(globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) ? reactExports.useLayoutEffect : () => { }; -function observeMove(element, onMove) { - let io = null; - let timeoutId; - const root2 = getDocumentElement(element); - function cleanup() { - var _io; - clearTimeout(timeoutId); - (_io = io) == null || _io.disconnect(); - io = null; - } - function refresh(skip, threshold) { - if (skip === void 0) { - skip = false; - } - if (threshold === void 0) { - threshold = 1; - } - cleanup(); - const { - left, - top, - width, - height - } = element.getBoundingClientRect(); - if (!skip) { - onMove(); - } - if (!width || !height) { - return; - } - const insetTop = floor(top); - const insetRight = floor(root2.clientWidth - (left + width)); - const insetBottom = floor(root2.clientHeight - (top + height)); - const insetLeft = floor(left); - const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px"; - const options = { - rootMargin, - threshold: max(0, min(1, threshold)) || 1 - }; - let isFirstUpdate = true; - function handleObserve(entries) { - const ratio = entries[0].intersectionRatio; - if (ratio !== threshold) { - if (!isFirstUpdate) { - return refresh(); - } - if (!ratio) { - timeoutId = setTimeout(() => { - refresh(false, 1e-7); - }, 1e3); - } else { - refresh(false, ratio); - } - } - isFirstUpdate = false; - } - try { - io = new IntersectionObserver(handleObserve, { - ...options, - // Handle