diff --git a/.editorconfig b/.editorconfig index cce17d713..6876d7a97 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,7 +12,7 @@ indent_style = space indent_size = 4 charset = utf-8 -[launchSettings.json] +[*.json] indent_size = 2 # C# files diff --git a/BTCPayServer.Tests/CheckoutUITests.cs b/BTCPayServer.Tests/CheckoutUITests.cs index 5c7630877..028875413 100644 --- a/BTCPayServer.Tests/CheckoutUITests.cs +++ b/BTCPayServer.Tests/CheckoutUITests.cs @@ -30,7 +30,7 @@ namespace BTCPayServer.Tests s.AddDerivationScheme(); s.GoToStore(StoreNavPages.CheckoutAppearance); s.Driver.FindElement(By.Id("RequiresRefundEmail")).Click(); - s.Driver.FindElement(By.Name("command")).Click(); + s.Driver.FindElement(By.Id("Save")).Click(); var emailAlreadyThereInvoiceId = s.CreateInvoice(100, "USD", "a@g.com"); s.GoToInvoiceCheckout(emailAlreadyThereInvoiceId); diff --git a/BTCPayServer.Tests/Checkoutv2Tests.cs b/BTCPayServer.Tests/Checkoutv2Tests.cs new file mode 100644 index 000000000..a5c540b4a --- /dev/null +++ b/BTCPayServer.Tests/Checkoutv2Tests.cs @@ -0,0 +1,200 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using BTCPayServer.Payments; +using BTCPayServer.Tests.Logging; +using BTCPayServer.Views.Stores; +using NBitcoin; +using OpenQA.Selenium; +using Xunit; +using Xunit.Abstractions; + +namespace BTCPayServer.Tests +{ + [Trait("Selenium", "Selenium")] + [Collection(nameof(NonParallelizableCollectionDefinition))] + public class CheckoutV2Tests : UnitTestBase + { + private const int TestTimeout = TestUtils.TestTimeout; + + public CheckoutV2Tests(ITestOutputHelper helper) : base(helper) + { + } + + [Fact(Timeout = TestTimeout)] + [Trait("Lightning", "Lightning")] + public async Task CanConfigureCheckout() + { + using var s = CreateSeleniumTester(); + s.Server.ActivateLightning(); + await s.StartAsync(); + s.GoToRegister(); + s.RegisterNewUser(true); + s.CreateNewStore(); + s.EnableCheckoutV2(); + s.AddLightningNode(); + s.AddDerivationScheme(); + + // Configure store url + var storeUrl = "https://satoshisteaks.com/"; + s.GoToStore(); + s.Driver.FindElement(By.Id("StoreWebsite")).SendKeys(storeUrl); + s.Driver.FindElement(By.Id("Save")).Click(); + Assert.Contains("Store successfully updated", s.FindAlertMessage().Text); + + // Default payment method + var invoiceId = s.CreateInvoice(defaultPaymentMethod: "BTC_LightningLike"); + s.GoToInvoiceCheckout(invoiceId); + + Assert.Equal(2, s.Driver.FindElements(By.CssSelector(".payment-method")).Count); + Assert.Contains("Lightning", s.Driver.FindElement(By.CssSelector(".payment-method.active")).Text); + Assert.DoesNotContain("LNURL", s.Driver.PageSource); + var payUrl = s.Driver.FindElement(By.CssSelector(".btn-primary")).GetAttribute("href"); + Assert.StartsWith("lightning:", payUrl); + + // Lightning amount in Sats + Assert.Contains("BTC", s.Driver.FindElement(By.Id("AmountDue")).Text); + s.GoToHome(); + s.GoToLightningSettings(); + s.Driver.SetCheckbox(By.Id("LightningAmountInSatoshi"), true); + s.Driver.FindElement(By.Id("save")).Click(); + Assert.Contains("BTC Lightning settings successfully updated", s.FindAlertMessage().Text); + s.GoToInvoiceCheckout(invoiceId); + Assert.Contains("Sats", s.Driver.FindElement(By.Id("AmountDue")).Text); + + // Expire + var expirySeconds = s.Driver.FindElement(By.Id("ExpirySeconds")); + expirySeconds.Clear(); + expirySeconds.SendKeys("3"); + s.Driver.FindElement(By.Id("Expire")).Click(); + + var paymentInfo = s.Driver.WaitForElement(By.Id("PaymentInfo")); + Assert.Contains("This invoice will expire in", paymentInfo.Text); + TestUtils.Eventually(() => + { + var expiredSection = s.Driver.FindElement(By.Id("expired")); + Assert.True(expiredSection.Displayed); + Assert.Contains("Invoice Expired", expiredSection.Text); + }); + Assert.True(s.Driver.ElementDoesNotExist(By.Id("ReceiptLink"))); + Assert.Equal(storeUrl, s.Driver.FindElement(By.Id("StoreLink")).GetAttribute("href")); + + // Test payment + s.GoToHome(); + invoiceId = s.CreateInvoice(); + s.GoToInvoiceCheckout(invoiceId); + + // Details + s.Driver.ToggleCollapse("PaymentDetails"); + var details = s.Driver.FindElement(By.CssSelector(".payment-details")); + Assert.Contains("Total Price", details.Text); + Assert.Contains("Total Fiat", details.Text); + Assert.Contains("Exchange Rate", details.Text); + Assert.Contains("Amount Due", details.Text); + Assert.Contains("Recommended Fee", details.Text); + + // Pay partial amount + await Task.Delay(200); + var address = s.Driver.FindElement(By.CssSelector(".qr-container")).GetAttribute("data-destination"); + var amountFraction = "0.00001"; + await s.Server.ExplorerNode.SendToAddressAsync(BitcoinAddress.Create(address, Network.RegTest), + Money.Parse(amountFraction)); + await s.Server.ExplorerNode.GenerateAsync(1); + + // Fake Pay + s.Driver.FindElement(By.Id("FakePayAmount")).FillIn(amountFraction); + s.Driver.FindElement(By.Id("FakePay")).Click(); + TestUtils.Eventually(() => + { + Assert.Contains("Created transaction", + s.Driver.WaitForElement(By.Id("CheatSuccessMessage")).Text); + s.Server.ExplorerNode.Generate(1); + Assert.Contains("The invoice hasn't been paid in full", + s.Driver.WaitForElement(By.Id("PaymentInfo")).Text); + }); + + // Mine + s.Driver.FindElement(By.Id("Mine")).Click(); + TestUtils.Eventually(() => + { + Assert.Contains("Mined 1 block", + s.Driver.WaitForElement(By.Id("CheatSuccessMessage")).Text); + }); + + // Pay full amount + var amountDue = s.Driver.FindElement(By.Id("AmountDue")).GetAttribute("data-amount-due"); + s.Driver.FindElement(By.Id("FakePayAmount")).FillIn(amountDue); + s.Driver.FindElement(By.Id("FakePay")).Click(); + TestUtils.Eventually(() => + { + s.Server.ExplorerNode.Generate(1); + var paidSection = s.Driver.WaitForElement(By.Id("paid")); + Assert.True(paidSection.Displayed); + Assert.Contains("Invoice Paid", paidSection.Text); + }); + s.Driver.FindElement(By.Id("ReceiptLink")); + Assert.Equal(storeUrl, s.Driver.FindElement(By.Id("StoreLink")).GetAttribute("href")); + + // BIP21 + s.GoToHome(); + s.GoToStore(StoreNavPages.CheckoutAppearance); + s.Driver.SetCheckbox(By.Id("OnChainWithLnInvoiceFallback"), true); + s.Driver.FindElement(By.Id("Save")).Click(); + Assert.Contains("Store successfully updated", s.FindAlertMessage().Text); + + invoiceId = s.CreateInvoice(); + s.GoToInvoiceCheckout(invoiceId); + Assert.Empty(s.Driver.FindElements(By.CssSelector(".payment-method"))); + payUrl = s.Driver.FindElement(By.CssSelector(".btn-primary")).GetAttribute("href"); + Assert.StartsWith("bitcoin:", payUrl); + Assert.Contains("&LIGHTNING=", payUrl); + + // BIP21 with topup invoice (which is only available with Bitcoin onchain) + s.GoToHome(); + invoiceId = s.CreateInvoice(amount: null); + s.GoToInvoiceCheckout(invoiceId); + Assert.Empty(s.Driver.FindElements(By.CssSelector(".payment-method"))); + payUrl = s.Driver.FindElement(By.CssSelector(".btn-primary")).GetAttribute("href"); + Assert.StartsWith("bitcoin:", payUrl); + Assert.DoesNotContain("&LIGHTNING=", payUrl); + } + + [Fact(Timeout = TestTimeout)] + public async Task CanUseCheckoutAsModal() + { + using var s = CreateSeleniumTester(); + await s.StartAsync(); + s.GoToRegister(); + s.RegisterNewUser(); + s.CreateNewStore(); + s.EnableCheckoutV2(); + s.GoToStore(); + s.AddDerivationScheme(); + var invoiceId = s.CreateInvoice(0.001m, "BTC", "a@x.com"); + var invoice = await s.Server.PayTester.InvoiceRepository.GetInvoice(invoiceId); + s.Driver.Navigate() + .GoToUrl(new Uri(s.ServerUri, $"tests/index.html?invoice={invoiceId}")); + TestUtils.Eventually(() => + { + Assert.True(s.Driver.FindElement(By.Name("btcpay")).Displayed); + }); + await s.Server.ExplorerNode.SendToAddressAsync(BitcoinAddress.Create(invoice + .GetPaymentMethod(new PaymentMethodId("BTC", PaymentTypes.BTCLike)) + .GetPaymentMethodDetails().GetPaymentDestination(), Network.RegTest), + new Money(0.001m, MoneyUnit.BTC)); + + IWebElement closebutton = null; + TestUtils.Eventually(() => + { + var frameElement = s.Driver.FindElement(By.Name("btcpay")); + var iframe = s.Driver.SwitchTo().Frame(frameElement); + closebutton = iframe.FindElement(By.Id("close")); + Assert.True(closebutton.Displayed); + }); + closebutton.Click(); + s.Driver.AssertElementNotFound(By.Name("btcpay")); + Assert.Equal(s.Driver.Url, + new Uri(s.ServerUri, $"tests/index.html?invoice={invoiceId}").ToString()); + } + } +} diff --git a/BTCPayServer.Tests/Extensions.cs b/BTCPayServer.Tests/Extensions.cs index 10c1beb85..8ad062e36 100644 --- a/BTCPayServer.Tests/Extensions.cs +++ b/BTCPayServer.Tests/Extensions.cs @@ -125,6 +125,12 @@ retry: return el; } + + public static void FillIn(this IWebElement el, string text) + { + el.Clear(); + el.SendKeys(text); + } public static void ScrollTo(this IWebDriver driver, IWebElement element) { diff --git a/BTCPayServer.Tests/SeleniumTester.cs b/BTCPayServer.Tests/SeleniumTester.cs index 79cf33dd6..77afabda4 100644 --- a/BTCPayServer.Tests/SeleniumTester.cs +++ b/BTCPayServer.Tests/SeleniumTester.cs @@ -185,6 +185,15 @@ namespace BTCPayServer.Tests return (name, storeId); } + public void EnableCheckoutV2(bool bip21 = false) + { + GoToStore(StoreNavPages.CheckoutAppearance); + Driver.SetCheckbox(By.Id("UseNewCheckout"), true); + Driver.WaitForElement(By.Id("OnChainWithLnInvoiceFallback")); + Driver.SetCheckbox(By.Id("OnChainWithLnInvoiceFallback"), bip21); + Driver.FindElement(By.Id("Save")).Click(); + } + public Mnemonic GenerateWallet(string cryptoCode = "BTC", string seed = "", bool? importkeys = null, bool isHotWallet = false, ScriptPubKeyType format = ScriptPubKeyType.Segwit) { var isImport = !string.IsNullOrEmpty(seed); diff --git a/BTCPayServer.Tests/ThirdPartyTests.cs b/BTCPayServer.Tests/ThirdPartyTests.cs index 3190df52d..6925a5d91 100644 --- a/BTCPayServer.Tests/ThirdPartyTests.cs +++ b/BTCPayServer.Tests/ThirdPartyTests.cs @@ -311,17 +311,39 @@ namespace BTCPayServer.Tests { // This test verify that no malicious js is added in the minified files. // We should extend the tests to other js files, but we can do as we go... - - using HttpClient client = new HttpClient(); - var actual = GetFileContent("BTCPayServer", "wwwroot", "vendor", "bootstrap", "bootstrap.bundle.min.js"); + using var client = new HttpClient(); + var actual = GetFileContent("BTCPayServer", "wwwroot", "vendor", "bootstrap", "bootstrap.bundle.min.js").Trim(); var version = Regex.Match(actual, "Bootstrap v([0-9]+.[0-9]+.[0-9]+)").Groups[1].Value; - var expected = await (await client.GetAsync($"https://cdn.jsdelivr.net/npm/bootstrap@{version}/dist/js/bootstrap.bundle.min.js")).Content.ReadAsStringAsync(); - Assert.Equal(expected, actual.Replace("\r\n", "\n", StringComparison.OrdinalIgnoreCase)); + var expected = (await (await client.GetAsync($"https://cdn.jsdelivr.net/npm/bootstrap@{version}/dist/js/bootstrap.bundle.min.js")).Content.ReadAsStringAsync()).Trim(); + Assert.Equal(expected, actual); actual = GetFileContent("BTCPayServer", "wwwroot", "vendor", "clipboard.js", "clipboard.js"); - expected = await (await client.GetAsync($"https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.8/clipboard.js")).Content.ReadAsStringAsync(); - Assert.Equal(expected, actual.Replace("\r\n", "\n", StringComparison.OrdinalIgnoreCase)); + expected = (await (await client.GetAsync("https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.8/clipboard.js")).Content.ReadAsStringAsync()).Trim(); + Assert.Equal(expected, actual); + + actual = GetFileContent("BTCPayServer", "wwwroot", "vendor", "vuejs", "vue.min.js").Trim(); + version = Regex.Match(actual, "Vue\\.js v([0-9]+.[0-9]+.[0-9]+)").Groups[1].Value; + expected = (await (await client.GetAsync($"https://cdnjs.cloudflare.com/ajax/libs/vue/{version}/vue.min.js")).Content.ReadAsStringAsync()).Trim(); + Assert.Equal(expected, actual); + + actual = GetFileContent("BTCPayServer", "wwwroot", "vendor", "i18next", "i18next.min.js").Trim(); + expected = (await (await client.GetAsync("https://cdnjs.cloudflare.com/ajax/libs/i18next/22.0.6/i18next.min.js")).Content.ReadAsStringAsync()).Trim(); + Assert.Equal(expected, actual); + + actual = GetFileContent("BTCPayServer", "wwwroot", "vendor", "i18next", "i18nextHttpBackend.min.js").Trim(); + expected = (await (await client.GetAsync("https://cdnjs.cloudflare.com/ajax/libs/i18next-http-backend/2.0.1/i18nextHttpBackend.min.js")).Content.ReadAsStringAsync()).Trim(); + Assert.Equal(expected, actual); + + actual = GetFileContent("BTCPayServer", "wwwroot", "vendor", "i18next", "vue-i18next.js").Trim(); + expected = (await (await client.GetAsync("https://unpkg.com/@panter/vue-i18next@0.15.2/dist/vue-i18next.js")).Content.ReadAsStringAsync()).Trim(); + Assert.Equal(expected, actual); + + actual = GetFileContent("BTCPayServer", "wwwroot", "vendor", "vue-qrcode", "vue-qrcode.min.js").Trim(); + version = Regex.Match(actual, "vue-qrcode v([0-9]+.[0-9]+.[0-9]+)").Groups[1].Value; + expected = (await (await client.GetAsync($"https://unpkg.com/@chenfengyuan/vue-qrcode@{version}/dist/vue-qrcode.min.js")).Content.ReadAsStringAsync()).Trim(); + Assert.Equal(expected, actual); } + string GetFileContent(params string[] path) { var l = path.ToList(); diff --git a/BTCPayServer/Controllers/UIInvoiceController.Testing.cs b/BTCPayServer/Controllers/UIInvoiceController.Testing.cs index bdd41d27f..8e47024ef 100644 --- a/BTCPayServer/Controllers/UIInvoiceController.Testing.cs +++ b/BTCPayServer/Controllers/UIInvoiceController.Testing.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading.Tasks; using BTCPayServer.Data; using BTCPayServer.Filters; +using BTCPayServer.Lightning; using BTCPayServer.Payments; using BTCPayServer.Services; using Microsoft.AspNetCore.Mvc; @@ -17,6 +18,7 @@ namespace BTCPayServer.Controllers { public Decimal Amount { get; set; } public string CryptoCode { get; set; } = "BTC"; + public string PaymentMethodId { get; set; } = "BTC"; } public class MineBlocksRequest @@ -31,31 +33,65 @@ namespace BTCPayServer.Controllers { var invoice = await _InvoiceRepository.GetInvoice(invoiceId); var store = await _StoreRepository.FindStore(invoice.StoreId); - - // TODO support altcoins, not just bitcoin - and make it work for LN-only invoices var isSats = request.CryptoCode.ToUpper(CultureInfo.InvariantCulture) == "SATS"; var cryptoCode = isSats ? "BTC" : request.CryptoCode; - var network = _NetworkProvider.GetNetwork(cryptoCode); - var paymentMethodId = new [] {store.GetDefaultPaymentId()}.Concat(store.GetEnabledPaymentIds(_NetworkProvider)) - .FirstOrDefault(p => p != null && p.CryptoCode == cryptoCode && p.PaymentType == PaymentTypes.BTCLike); - var bitcoinAddressString = invoice.GetPaymentMethod(paymentMethodId).GetPaymentMethodDetails().GetPaymentDestination(); - var bitcoinAddressObj = BitcoinAddress.Create(bitcoinAddressString, network.NBitcoinNetwork); var amount = new Money(request.Amount, isSats ? MoneyUnit.Satoshi : MoneyUnit.BTC); - + var network = _NetworkProvider.GetNetwork(cryptoCode).NBitcoinNetwork; + var paymentMethodId = new [] {store.GetDefaultPaymentId()} + .Concat(store.GetEnabledPaymentIds(_NetworkProvider)) + .FirstOrDefault(p => p?.ToString() == request.PaymentMethodId); + try { var paymentMethod = invoice.GetPaymentMethod(paymentMethodId); - var rate = paymentMethod.Rate; - var txid = (await cheater.CashCow.SendToAddressAsync(bitcoinAddressObj, amount)).ToString(); - - // TODO The value of totalDue is wrong. How can we get the real total due? invoice.Price is only correct if this is the 2nd payment, not for a 3rd or 4th payment. - var totalDue = invoice.Price; - return Ok(new + var destination = paymentMethod?.GetPaymentMethodDetails().GetPaymentDestination(); + + switch (paymentMethod?.GetId().PaymentType) { - Txid = txid, - AmountRemaining = (totalDue - (amount.ToUnit(MoneyUnit.BTC) * rate)) / rate, - SuccessMessage = "Created transaction " + txid - }); + case BitcoinPaymentType: + var address = BitcoinAddress.Create(destination, network); + var txid = (await cheater.CashCow.SendToAddressAsync(address, amount)).ToString(); + + return Ok(new + { + Txid = txid, + AmountRemaining = (paymentMethod.Calculate().Due - amount).ToUnit(MoneyUnit.BTC), + SuccessMessage = $"Created transaction {txid}" + }); + + case LightningPaymentType: + // requires the channels to be set up using the BTCPayServer.Tests/docker-lightning-channel-setup.sh script + LightningConnectionString.TryParse(Environment.GetEnvironmentVariable("BTCPAY_BTCEXTERNALLNDREST"), false, out var lnConnection); + var lnClient = LightningClientFactory.CreateClient(lnConnection, network); + var lnAmount = new LightMoney(amount.Satoshi, LightMoneyUnit.Satoshi); + var response = await lnClient.Pay(destination, new PayInvoiceParams { Amount = lnAmount }); + + if (response.Result == PayResult.Ok) + { + var bolt11 = BOLT11PaymentRequest.Parse(destination, network); + var paymentHash = bolt11.PaymentHash?.ToString(); + var paid = new Money(response.Details.TotalAmount.ToUnit(LightMoneyUnit.Satoshi), MoneyUnit.Satoshi); + return Ok(new + { + Txid = paymentHash, + AmountRemaining = (paymentMethod.Calculate().TotalDue - paid).ToUnit(MoneyUnit.BTC), + SuccessMessage = $"Sent payment {paymentHash}" + }); + } + return UnprocessableEntity(new + { + ErrorMessage = response.ErrorDetail, + AmountRemaining = invoice.Price + }); + + default: + return UnprocessableEntity(new + { + ErrorMessage = $"Payment method {paymentMethodId} is not supported", + AmountRemaining = invoice.Price + }); + } + } catch (Exception e) { @@ -71,40 +107,30 @@ namespace BTCPayServer.Controllers [CheatModeRoute] public IActionResult MineBlock(string invoiceId, MineBlocksRequest request, [FromServices] Cheater cheater) { - // TODO support altcoins, not just bitcoin var blockRewardBitcoinAddress = cheater.CashCow.GetNewAddress(); try { if (request.BlockCount > 0) { cheater.CashCow.GenerateToAddress(request.BlockCount, blockRewardBitcoinAddress); - return Ok(new - { - SuccessMessage = "Mined " + request.BlockCount + " blocks" - }); + return Ok(new { SuccessMessage = $"Mined {request.BlockCount} block{(request.BlockCount == 1 ? "" : "s")} " }); } - return BadRequest(new - { - ErrorMessage = "Number of blocks should be > 0" - }); + return BadRequest(new { ErrorMessage = "Number of blocks should be at least 1" }); } catch (Exception e) { - return BadRequest(new - { - ErrorMessage = e.Message - }); + return BadRequest(new { ErrorMessage = e.Message }); } } [HttpPost("i/{invoiceId}/expire")] [CheatModeRoute] - public async Task TestExpireNow(string invoiceId, [FromServices] Cheater cheater) + public async Task Expire(string invoiceId, int seconds, [FromServices] Cheater cheater) { try { - await cheater.UpdateInvoiceExpiry(invoiceId, DateTimeOffset.Now); - return Ok(new { SuccessMessage = "Invoice is now expired." }); + await cheater.UpdateInvoiceExpiry(invoiceId, TimeSpan.FromSeconds(seconds)); + return Ok(new { SuccessMessage = $"Invoice set to expire in {seconds} seconds." }); } catch (Exception e) { diff --git a/BTCPayServer/Controllers/UIInvoiceController.UI.cs b/BTCPayServer/Controllers/UIInvoiceController.UI.cs index 6d07bc49c..67a49bd21 100644 --- a/BTCPayServer/Controllers/UIInvoiceController.UI.cs +++ b/BTCPayServer/Controllers/UIInvoiceController.UI.cs @@ -928,14 +928,6 @@ namespace BTCPayServer.Controllers return Ok("{}"); } - [HttpPost("i/{invoiceId}/Form")] - [HttpPost("invoice/Form")] - public IActionResult UpdateForm(string invoiceId) - { - // TODO: Forms integration - return Ok(); - } - [HttpGet("/stores/{storeId}/invoices")] [HttpGet("invoices")] [Authorize(AuthenticationSchemes = AuthenticationSchemes.Cookie, Policy = Policies.CanViewInvoices)] diff --git a/BTCPayServer/Controllers/UIInvoiceController.cs b/BTCPayServer/Controllers/UIInvoiceController.cs index 046e58868..698d758bf 100644 --- a/BTCPayServer/Controllers/UIInvoiceController.cs +++ b/BTCPayServer/Controllers/UIInvoiceController.cs @@ -417,15 +417,10 @@ namespace BTCPayServer.Controllers var logPrefix = $"{supportedPaymentMethod.PaymentId.ToPrettyString()}:"; var storeBlob = store.GetStoreBlob(); - object? preparePayment; - if (storeBlob.LazyPaymentMethods) - { - preparePayment = null; - } - else - { - preparePayment = handler.PreparePayment(supportedPaymentMethod, store, network); - } + // Checkout v2 does not show a payment method switch for Bitcoin-only + BIP21, so exclude that case + var preparePayment = storeBlob.LazyPaymentMethods && !storeBlob.OnChainWithLnInvoiceFallback + ? null + : handler.PreparePayment(supportedPaymentMethod, store, network); var rate = await fetchingByCurrencyPair[new CurrencyPair(network.CryptoCode, entity.Currency)]; if (rate.BidAsk == null) { diff --git a/BTCPayServer/Controllers/UIStoresController.cs b/BTCPayServer/Controllers/UIStoresController.cs index d9a8e92e1..1e73909fd 100644 --- a/BTCPayServer/Controllers/UIStoresController.cs +++ b/BTCPayServer/Controllers/UIStoresController.cs @@ -383,7 +383,6 @@ namespace BTCPayServer.Controllers }).ToList(); vm.UseNewCheckout = storeBlob.CheckoutType == Client.Models.CheckoutType.V2; - vm.CheckoutFormId = storeBlob.CheckoutFormId; vm.OnChainWithLnInvoiceFallback = storeBlob.OnChainWithLnInvoiceFallback; vm.RequiresRefundEmail = storeBlob.RequiresRefundEmail; vm.LazyPaymentMethods = storeBlob.LazyPaymentMethods; @@ -504,7 +503,6 @@ namespace BTCPayServer.Controllers blob.CheckoutType = model.UseNewCheckout ? Client.Models.CheckoutType.V2 : Client.Models.CheckoutType.V1; if (blob.CheckoutType == Client.Models.CheckoutType.V2) { - blob.CheckoutFormId = model.CheckoutFormId; blob.OnChainWithLnInvoiceFallback = model.OnChainWithLnInvoiceFallback; } @@ -620,7 +618,7 @@ namespace BTCPayServer.Controllers } [HttpPost("{storeId}/settings")] - public async Task GeneralSettings(GeneralSettingsViewModel model, string? command = null) + public async Task GeneralSettings(GeneralSettingsViewModel model, [FromForm] bool RemoveLogoFile = false) { bool needUpdate = false; if (CurrentStore.StoreName != model.StoreName) @@ -649,14 +647,14 @@ namespace BTCPayServer.Controllers } blob.BrandColor = model.BrandColor; + var userId = GetUserId(); + if (userId is null) + return NotFound(); + if (model.LogoFile != null) { if (model.LogoFile.ContentType.StartsWith("image/", StringComparison.InvariantCulture)) { - var userId = GetUserId(); - if (userId is null) - return NotFound(); - // delete existing image if (!string.IsNullOrEmpty(blob.LogoFileId)) { @@ -679,6 +677,12 @@ namespace BTCPayServer.Controllers TempData[WellKnownTempData.ErrorMessage] = "The uploaded logo file needs to be an image"; } } + else if (RemoveLogoFile && !string.IsNullOrEmpty(blob.LogoFileId)) + { + await _fileService.RemoveFile(blob.LogoFileId, userId); + blob.LogoFileId = null; + needUpdate = true; + } if (CurrentStore.SetStoreBlob(blob)) { diff --git a/BTCPayServer/Models/StoreViewModels/CheckoutAppearanceViewModel.cs b/BTCPayServer/Models/StoreViewModels/CheckoutAppearanceViewModel.cs index de1b20448..8e01242f8 100644 --- a/BTCPayServer/Models/StoreViewModels/CheckoutAppearanceViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/CheckoutAppearanceViewModel.cs @@ -5,7 +5,6 @@ using System.Linq; using BTCPayServer.Services; using Microsoft.AspNetCore.Mvc.Rendering; using Newtonsoft.Json.Linq; -using YamlDotNet.Core.Tokens; namespace BTCPayServer.Models.StoreViewModels { @@ -24,10 +23,7 @@ namespace BTCPayServer.Models.StoreViewModels public SelectList Languages { get; set; } - [Display(Name = "Request customer data on checkout")] - public string CheckoutFormId { get; set; } - - [Display(Name = "Include Lightning invoice fallback to on-chain BIP21 payment URL")] + [Display(Name = "Unify on-chain and lightning payment URL/QR code")] public bool OnChainWithLnInvoiceFallback { get; set; } [Display(Name = "Default payment method on checkout")] diff --git a/BTCPayServer/Models/StoreViewModels/LightningSettingsViewModel.cs b/BTCPayServer/Models/StoreViewModels/LightningSettingsViewModel.cs index c04d8bb19..914310ab8 100644 --- a/BTCPayServer/Models/StoreViewModels/LightningSettingsViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/LightningSettingsViewModel.cs @@ -11,7 +11,7 @@ namespace BTCPayServer.Models.StoreViewModels [Display(Name = "Add hop hints for private channels to the Lightning invoice")] public bool LightningPrivateRouteHints { get; set; } - [Display(Name = "Include Lightning invoice fallback to on-chain BIP21 payment URL")] + [Display(Name = "Unify on-chain and lightning payment URL/QR code")] public bool OnChainWithLnInvoiceFallback { get; set; } [Display(Name = "Description template of the lightning invoice")] diff --git a/BTCPayServer/Services/Cheater.cs b/BTCPayServer/Services/Cheater.cs index 3f48ff2ea..0651c38d5 100644 --- a/BTCPayServer/Services/Cheater.cs +++ b/BTCPayServer/Services/Cheater.cs @@ -1,44 +1,33 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; -using BTCPayServer.Configuration; -using BTCPayServer.Data; +using BTCPayServer.Services.Invoices; using Microsoft.Extensions.Hosting; -using NBitcoin; using NBitcoin.RPC; namespace BTCPayServer.Services { public class Cheater : IHostedService { - private readonly ApplicationDbContextFactory _applicationDbContextFactory; + private readonly InvoiceRepository _invoiceRepository; + public RPCClient CashCow { get; set; } - public Cheater(BTCPayServerOptions opts, ExplorerClientProvider prov, ApplicationDbContextFactory applicationDbContextFactory) + public Cheater( + ExplorerClientProvider prov, + InvoiceRepository invoiceRepository) { CashCow = prov.GetExplorerClient("BTC")?.RPCClient; - _applicationDbContextFactory = applicationDbContextFactory; - } - public RPCClient CashCow - { - get; - set; + _invoiceRepository = invoiceRepository; } - public async Task UpdateInvoiceExpiry(string invoiceId, DateTimeOffset dateTimeOffset) + public async Task UpdateInvoiceExpiry(string invoiceId, TimeSpan seconds) { - using var ctx = _applicationDbContextFactory.CreateContext(); - var invoiceData = await ctx.Invoices.FindAsync(invoiceId).ConfigureAwait(false); - if (invoiceData == null) - return; - // TODO change the expiry time. But how? - await ctx.SaveChangesAsync().ConfigureAwait(false); + await _invoiceRepository.UpdateInvoiceExpiry(invoiceId, seconds); } Task IHostedService.StartAsync(CancellationToken cancellationToken) { - _ = CashCow?.ScanRPCCapabilitiesAsync(); + _ = CashCow?.ScanRPCCapabilitiesAsync(cancellationToken); return Task.CompletedTask; } diff --git a/BTCPayServer/Services/Invoices/InvoiceRepository.cs b/BTCPayServer/Services/Invoices/InvoiceRepository.cs index 5e6e643fe..0fd7c347f 100644 --- a/BTCPayServer/Services/Invoices/InvoiceRepository.cs +++ b/BTCPayServer/Services/Invoices/InvoiceRepository.cs @@ -139,6 +139,28 @@ namespace BTCPayServer.Services.Invoices await ctx.SaveChangesAsync().ConfigureAwait(false); } + public async Task UpdateInvoiceExpiry(string invoiceId, TimeSpan seconds) + { + await using var ctx = _applicationDbContextFactory.CreateContext(); + var invoiceData = await ctx.Invoices.FindAsync(invoiceId); + var invoice = invoiceData.GetBlob(_btcPayNetworkProvider); + var expiry = DateTimeOffset.Now + seconds; + invoice.ExpirationTime = expiry; + invoice.MonitoringExpiration = expiry.AddHours(1); + invoiceData.Blob = ToBytes(invoice, _btcPayNetworkProvider.DefaultNetwork); + + await ctx.SaveChangesAsync(); + + _eventAggregator.Publish(new InvoiceDataChangedEvent(invoice)); + _ = InvoiceNeedUpdateEventLater(invoiceId, seconds); + } + + async Task InvoiceNeedUpdateEventLater(string invoiceId, TimeSpan expirationIn) + { + await Task.Delay(expirationIn); + _eventAggregator.Publish(new InvoiceNeedUpdateEvent(invoiceId)); + } + public async Task ExtendInvoiceMonitor(string invoiceId) { using var ctx = _applicationDbContextFactory.CreateContext(); diff --git a/BTCPayServer/Views/Shared/Bitcoin/BitcoinLikeMethodCheckout-v2.cshtml b/BTCPayServer/Views/Shared/Bitcoin/BitcoinLikeMethodCheckout-v2.cshtml index 96cd4516a..44f7e5e32 100644 --- a/BTCPayServer/Views/Shared/Bitcoin/BitcoinLikeMethodCheckout-v2.cshtml +++ b/BTCPayServer/Views/Shared/Bitcoin/BitcoinLikeMethodCheckout-v2.cshtml @@ -3,26 +3,36 @@ diff --git a/BTCPayServer/Views/Shared/PayButton/PayButton.cshtml b/BTCPayServer/Views/Shared/PayButton/PayButton.cshtml index 34b434fdf..f3453fa5c 100644 --- a/BTCPayServer/Views/Shared/PayButton/PayButton.cshtml +++ b/BTCPayServer/Views/Shared/PayButton/PayButton.cshtml @@ -17,7 +17,7 @@ @section PageFootContent { - + diff --git a/BTCPayServer/Views/Shared/_Footer.cshtml b/BTCPayServer/Views/Shared/_Footer.cshtml index 47897d736..3525def7a 100644 --- a/BTCPayServer/Views/Shared/_Footer.cshtml +++ b/BTCPayServer/Views/Shared/_Footer.cshtml @@ -26,9 +26,9 @@ @if (!string.IsNullOrEmpty(_env.OnionUrl) && !Context.Request.IsOnion()) { - + - Copy Tor URL + Copy Tor URL } diff --git a/BTCPayServer/Views/UIInvoice/Checkout-Cheating.cshtml b/BTCPayServer/Views/UIInvoice/Checkout-Cheating.cshtml index 38d5e023f..80c03750b 100644 --- a/BTCPayServer/Views/UIInvoice/Checkout-Cheating.cshtml +++ b/BTCPayServer/Views/UIInvoice/Checkout-Cheating.cshtml @@ -1,82 +1,81 @@ @model PaymentModel -
-

{{ successMessage }}

-

{{ errorMessage }}

-
- - -
-
- -
@Model.CryptoCode
+
+
+

+

+ + + + +
+
+ +
@Model.CryptoCode
+
+
- -
- {{$t("This is the same as running bitcoin-cli.sh sendtoaddress xxx")}} - -
- - -
-
- -
{{$t("Blocks")}}
-
- -
-
-
- -
-
+ +
+ +
+
+ +
blocks
+
+ +
+
+
+ +
+
+ +
seconds
+
+ +
+
+ + - - + + @@ -149,7 +149,7 @@ var fallbackLanguage = "en"; startingLanguage = computeStartingLanguage(); i18next - .use(window.i18nextXHRBackend) + .use(window.i18nextHttpBackend) .init({ backend: { loadPath: @Safe.Json($"{Model.RootPath}locales/{{{{lng}}}}.json") diff --git a/BTCPayServer/Views/UIInvoice/CheckoutV2.cshtml b/BTCPayServer/Views/UIInvoice/CheckoutV2.cshtml index 38f5bd8de..7e7bf35e9 100644 --- a/BTCPayServer/Views/UIInvoice/CheckoutV2.cshtml +++ b/BTCPayServer/Views/UIInvoice/CheckoutV2.cshtml @@ -1,18 +1,17 @@ @inject LanguageService LangService @inject BTCPayServerEnvironment Env @inject IFileService FileService -@inject ThemeSettings Theme +@inject IEnumerable UiExtensions @inject PaymentMethodHandlerDictionary PaymentMethodHandlerDictionary @using BTCPayServer.Services @using BTCPayServer.Abstractions.Contracts -@using BTCPayServer.Abstractions.TagHelpers -@using BTCPayServer.Components.ThemeSwitch @using Microsoft.AspNetCore.Mvc.TagHelpers @model PaymentModel @{ Layout = null; ViewData["Title"] = Model.HtmlTitle; + var hasPaymentPlugins = UiExtensions.Any(extension => extension.Location == "checkout-payment-method"); var paymentMethodCount = Model.AvailableCryptos.Count; var logoUrl = !string.IsNullOrEmpty(Model.LogoFileId) ? await FileService.GetFileUrl(Context.Request.GetAbsoluteRootUri(), Model.LogoFileId) @@ -25,24 +24,18 @@ ? $"{pm.PaymentMethodName} {pm.CryptoCode}" : pm.PaymentMethodName.Replace("Bitcoin (", "").Replace(")", "").Replace("Lightning ", ""); } -} + private string ToJsValue(object value) + { + return Safe.Json(value).ToString()?.Replace("\"", "'"); + } +} - + - @if (!string.IsNullOrEmpty(Model.CustomCSSLink)) - { - - } - @if (Model.IsModal) - { - - } @if (!string.IsNullOrEmpty(Model.BrandColor)) { } - -
+ +
@if (!string.IsNullOrEmpty(logoUrl)) { } -

@Model.StoreName

+

@Model.StoreName

-
-
+
+
+
+
{{srvModel.orderAmount}} {{ srvModel.cryptoCode }}
+
+
+
+
{{srvModel.orderAmountFiat}}
+
+
+
+
+ + +
+
+
+
+
+ + {{ srvModel.networkFee }} {{ srvModel.cryptoCode }} +
+
+
+
+
{{srvModel.btcPaid }} {{ srvModel.cryptoCode }}
+
+
+
+
{{srvModel.btcDue}} {{ srvModel.cryptoCode }}
+
+
+
+
+
+
+ - - + + @@ -297,242 +255,6 @@ { } - @foreach (var paymentMethodHandler in PaymentMethodHandlerDictionary .Select(handler => handler.GetCheckoutUISettings()) .Where(settings => settings != null) @@ -540,6 +262,6 @@ { } - @await Component.InvokeAsync("UiExtensionPoint", new { location = "checkout-end", model = Model }) + @await Component.InvokeAsync("UiExtensionPoint", new { location = "checkout-payment", model = Model }) diff --git a/BTCPayServer/Views/UIServer/Theme.cshtml b/BTCPayServer/Views/UIServer/Theme.cshtml index 558b75769..8b7e221ee 100644 --- a/BTCPayServer/Views/UIServer/Theme.cshtml +++ b/BTCPayServer/Views/UIServer/Theme.cshtml @@ -35,15 +35,22 @@

Branding

- +
+ + @if (!string.IsNullOrEmpty(Model.LogoFileId)) + { + + } +
@if (canUpload) { -
+
@if (!string.IsNullOrEmpty(Model.LogoFileId)) { Logo - }
diff --git a/BTCPayServer/Views/UIStores/CheckoutAppearance.cshtml b/BTCPayServer/Views/UIStores/CheckoutAppearance.cshtml index ec38d1232..a951aeb18 100644 --- a/BTCPayServer/Views/UIStores/CheckoutAppearance.cshtml +++ b/BTCPayServer/Views/UIStores/CheckoutAppearance.cshtml @@ -1,7 +1,5 @@ @using BTCPayServer.Payments -@using BTCPayServer.Services.Invoices @using Microsoft.AspNetCore.Mvc.TagHelpers -@using BTCPayServer.Abstractions.TagHelpers @using BTCPayServer.Services.Stores @model CheckoutAppearanceViewModel @{ @@ -9,7 +7,6 @@ ViewData.SetActivePage(StoreNavPages.CheckoutAppearance, "Checkout experience", Context.GetStoreData().Id); var store = ViewContext.HttpContext.GetStoreData(); - var checkoutFormOptions = CheckoutFormSelectList.ForStore(store, Model.CheckoutFormId, false); } @section PageFootContent { @@ -64,10 +61,79 @@
} -
- - +

Checkout

+
+ +
+ + +
+ Since v1.7.0 a new version of the checkout is available. Note: For now, the new version is English-only.
+ We are still collecting feedback and offer this as an opt-in feature. +
+
+ +
+
+ + + + + +
+
+ +
+
+ + +
+
+
+ + +

Detects the language of the customer's browser with 99.9% accuracy.

+
+
+
+ + +
+
+ + + + + + +
+
+ + + + + + +

+ Bundled Themes: + Default | + Dark | + Legacy +

+ @await Component.InvokeAsync("UiExtensionPoint", new { location = "invoice-checkout-theme-options", model = Model }) +
+
+ +
+ + + +
+
@@ -77,34 +143,6 @@
-

- New checkout - Experimental -

-
- -
- - -
- Since v1.7.0 a new version of the checkout is available.
- We are still collecting feedback and offer this as an opt-in feature. -
-
-
- -
-
- - - -
-
- - -
-
-

Public receipt

@@ -114,54 +152,12 @@
-
+
- -

Language

-
-
- - -

Detects the language of the customer's browser with 99.9% accuracy.

-
-
-
- - -
- -

Appearance

-
- - - -
-
- - - - - - -
-
- - - - - - -

- Bundled Themes: - Default | - Dark | - Legacy -

- @await Component.InvokeAsync("UiExtensionPoint", new { location = "invoice-checkout-theme-options", model = Model }) -
- + +
diff --git a/BTCPayServer/Views/UIStores/GeneralSettings.cshtml b/BTCPayServer/Views/UIStores/GeneralSettings.cshtml index db07c179f..771ae4b62 100644 --- a/BTCPayServer/Views/UIStores/GeneralSettings.cshtml +++ b/BTCPayServer/Views/UIStores/GeneralSettings.cshtml @@ -35,17 +35,29 @@

Branding

- +
+ + @if (!string.IsNullOrEmpty(Model.LogoFileId)) + { + + } +
@if (canUpload) { -
+
@if (!string.IsNullOrEmpty(Model.LogoFileId)) { - @Model.StoreName + @Model.StoreName }
-

Please upload an image with square dimension, as it will be displayed in 1:1 format and circular.

+ +

+ Please upload an image with square dimension, as it will be displayed in 1:1 format and circular. + Size should be around 100✕100px. +

} else { @@ -120,7 +132,7 @@
- + @if (Model.CanDelete) { diff --git a/BTCPayServer/Views/UIStores/LightningSettings.cshtml b/BTCPayServer/Views/UIStores/LightningSettings.cshtml index 48f2a2f08..041dd9763 100644 --- a/BTCPayServer/Views/UIStores/LightningSettings.cshtml +++ b/BTCPayServer/Views/UIStores/LightningSettings.cshtml @@ -67,6 +67,9 @@
diff --git a/BTCPayServer/wwwroot/checkout-v2/checkout.css b/BTCPayServer/wwwroot/checkout-v2/checkout.css index 557269f06..34dab5811 100644 --- a/BTCPayServer/wwwroot/checkout-v2/checkout.css +++ b/BTCPayServer/wwwroot/checkout-v2/checkout.css @@ -2,22 +2,31 @@ --logo-size: 3rem; --navbutton-size: .8rem; --qr-size: 256px; - --section-padding: var(--btcpay-space-l); + --section-padding: 1.5rem; + --border-radius: var(--btcpay-border-radius-l); + --wrap-max-width: 400px; } -body { +.wrap { + display: flex; + flex-direction: column; + min-height: 100vh; + margin: 0 auto; padding: var(--btcpay-space-m); + max-width: var(--wrap-max-width); } header, footer { display: flex; flex-direction: column; align-items: center; - padding: var(--btcpay-space-l) var(--btcpay-space-s); - gap: var(--btcpay-space-m); + padding: var(--section-padding); +} +header { + gap: var(--btcpay-space-s); } main { position: relative; - border-radius: var(--btcpay-border-radius-l); + border-radius: var(--border-radius); background-color: var(--btcpay-bg-tile); } nav { @@ -36,9 +45,6 @@ nav button { nav button:hover { color: var(--btcpay-body-text-hover); } -nav button#back { - left: 0; -} nav button#close { right: 0; } @@ -68,12 +74,10 @@ section .buttons { flex-direction: column; gap: var(--btcpay-space-m); } -section dl { - margin-bottom: 1.5rem; -} section dl > div { display: flex; justify-content: space-between; + gap: var(--btcpay-space-m); } section dl > div dt, section dl > div dd { @@ -83,9 +87,13 @@ section dl > div dd { } section dl > div dt { text-align: left; + white-space: nowrap; + color: var(--btcpay-body-text-muted); } section dl > div dd { text-align: right; + word-wrap: break-word; + word-break: break-word; } .logo { height: var(--logo-size); @@ -94,18 +102,38 @@ section dl > div dd { width: var(--logo-size); border-radius: 50%; } -.wrap { - max-width: 400px; - margin: 0 auto; +.info { + color: var(--btcpay-neutral-700); + background-color: var(--btcpay-body-bg); + border-radius: var(--border-radius); } -.timer { +.info .expiryTime { + color: var(--btcpay-body-text); +} +.info > div { + padding: var(--btcpay-space-m) var(--btcpay-space-m); +} +.info > div > div { display: flex; align-items: center; justify-content: center; - margin: var(--btcpay-space-m) calc(var(--section-padding) * -1) var(--btcpay-space-s); - padding: var(--btcpay-space-s) var(--section-padding); - background-color: var(--btcpay-body-bg-medium); text-align: center; + gap: var(--btcpay-space-xs); +} +.info > div > div + div { + margin-top: var(--btcpay-space-s); +} +.info .spinner-border { + width: var(--btcpay-font-size-s); + height: var(--btcpay-font-size-s); + color: var(--btcpay-body-text-muted); + margin-right: var(--btcpay-space-xs); + animation-duration: 1s; +} +.info .icon { + width: 1.25rem; + height: 1.25rem; + color: var(--btcpay-info); } .payment-box { max-width: 300px; @@ -120,12 +148,44 @@ section dl > div dd { .payment-box .qr-container { min-height: var(--qr-size); } +.payment-box .qr-container svg { + border-radius: var(--btcpay-border-radius); +} .payment-box svg { width: 100%; } -.payment-box [data-clipboard] { +.payment-details dl { + margin: 0; +} +.payment-details-button { + margin: 0 auto; + padding: var(--btcpay-space-s); +} +.payment-details-button .icon { + margin-left: -1rem; /* Adjust for visual center */ +} +[data-clipboard] { cursor: copy; } +.payment-details [data-clipboard] { + position: relative; +} + +.payment-details [data-clipboard]::before { + content: ''; + position: absolute; + top: .5rem; + left: -1.5rem; + width: 1rem; + height: 1rem; + background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgPGcgY2xpcC1wYXRoPSJ1cmwoI2EpIiBzdHJva2U9IiM4Rjk3OUUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+CiAgICA8cGF0aCBkPSJNMTMuMzMgNmgtNkM2LjYgNiA2IDYuNiA2IDcuMzN2NmMwIC43NC42IDEuMzQgMS4zMyAxLjM0aDZjLjc0IDAgMS4zNC0uNiAxLjM0LTEuMzR2LTZjMC0uNzMtLjYtMS4zMy0xLjM0LTEuMzNaIi8+CiAgICA8cGF0aCBkPSJNMy4zMyAxMGgtLjY2YTEuMzMgMS4zMyAwIDAgMS0xLjM0LTEuMzN2LTZhMS4zMyAxLjMzIDAgMCAxIDEuMzQtMS4zNGg2QTEuMzMgMS4zMyAwIDAgMSAxMCAyLjY3di42NiIvPgogIDwvZz4KICA8ZGVmcz4KICAgIDxjbGlwUGF0aCBpZD0iYSI+CiAgICAgIDxwYXRoIGZpbGw9IiNmZmYiIGQ9Ik0wIDBoMTZ2MTZIMHoiLz4KICAgIDwvY2xpcFBhdGg+CiAgPC9kZWZzPgo8L3N2Zz4K"); + pointer-events: none; + opacity: 0; + transition: opacity var(--btcpay-transition-duration-fast); +} +.payment-details [data-clipboard]:hover::before { + opacity: 1; +} #payment .btcpay-pills .btcpay-pill { padding: var(--btcpay-space-xs) var(--btcpay-space-m); } @@ -134,19 +194,79 @@ section dl > div dd { display: flex; flex-direction: column; } -#result .top .icon { + +#result .top .icn .icon { display: block; width: 3rem; height: 3rem; margin: .5rem auto 1.5rem; } -#PaymentDetails dl { - margin: 0; + +#result #paid .top .icn .icon { + color: var(--btcpay-primary); } -#PaymentDetailsButton { - margin: 0 auto; - padding: var(--btcpay-space-s); +#result #expired .top .icn .icon { + color: var(--btcpay-body-text-muted); } -#PaymentDetailsButton .icon { - margin-left: -1rem; /* Adjust for visual center */ +footer { + margin-top: auto; + padding-top: 2.5rem; + gap: var(--btcpay-space-m); +} +footer, +footer a, +#DefaultLang { + color: var(--btcpay-body-text-muted); +} +footer a { + transition-duration: unset; +} +footer a svg { + height: 2rem; + width: 4rem; +} +#DefaultLang { + background-color: transparent; + box-shadow: none; + border: none; + text-align: right; + cursor: pointer; + margin-left: -4.5rem; /* Adjust for visual center */ +} +footer a:hover, +#DefaultLang:hover { + color: var(--btcpay-body-text-hover); +} +footer a:hover .logo-brand-light { + color: var(--btcpay-brand-secondary); +} +footer a:hover .logo-brand-medium { + color: var(--btcpay-brand-primary); +} +footer a:hover .logo-brand-dark { + color: var(--btcpay-brand-tertiary); +} + +@media (max-width: 400px) { + .wrap { + padding: 0; + } + main { + border-radius: 0; + } +} + +/* Modal adjustments */ +.checkout-modal body { + background: rgba(var(--btcpay-black-rgb), 0.85); +} +.checkout-modal h1, +.checkout-modal footer a:hover, +.checkout-modal #DefaultLang:hover { + color: var(--btcpay-white); +} + +/* Plugins */ +.payment-box .plugins > .payment { + margin-top: var(--btcpay-space-l); } diff --git a/BTCPayServer/wwwroot/checkout-v2/checkout.js b/BTCPayServer/wwwroot/checkout-v2/checkout.js index e9c46f530..60c13e919 100644 --- a/BTCPayServer/wwwroot/checkout-v2/checkout.js +++ b/BTCPayServer/wwwroot/checkout-v2/checkout.js @@ -1,29 +1,7 @@ -const urlParams = {}; -(window.onpopstate = function () { - let match, - pl = /\+/g, // Regex for replacing addition symbol with a space - search = /([^&=]+)=?([^&]*)/g, - decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); }, - query = window.location.search.substring(1); - - while (match = search.exec(query)) { - urlParams[decode(match[1])] = decode(match[2]); - } -})(); - -document.addEventListener('DOMContentLoaded', () => { - // Theme Switch - delegate('click', '.btcpay-theme-switch', e => { - e.preventDefault() - const current = document.documentElement.getAttribute(THEME_ATTR) || COLOR_MODES[0] - const mode = current === COLOR_MODES[0] ? COLOR_MODES[1] : COLOR_MODES[0] - setColorMode(mode) - e.target.closest('.btcpay-theme-switch').blur() - }) -}); - Vue.directive('collapsible', { - bind: function (el) { + bind: function (el, binding) { + el.classList.add('collapse'); + el.classList[binding.value ? 'add' : 'remove']('show'); el.transitionDuration = 350; }, update: function (el, binding) { @@ -35,26 +13,273 @@ Vue.directive('collapsible', { el.classList.add('collapsing'); el.offsetHeight; el.style.height = height; - setTimeout(() => { + setTimeout(function () { el.classList.remove('collapsing'); el.classList.add('collapse'); el.style.height = null; el.classList.add('show'); }, el.transitionDuration) }, 0); - } - else { + } else { el.style.height = window.getComputedStyle(el).height; el.classList.remove('collapse'); el.classList.remove('show'); el.offsetHeight; el.style.height = null; el.classList.add('collapsing'); - setTimeout(() => { + setTimeout(function () { el.classList.add('collapse'); - el.classList.remove("collapsing"); + el.classList.remove('collapsing'); }, el.transitionDuration) } } } }); + +const fallbackLanguage = 'en'; +const startingLanguage = computeStartingLanguage(); +const STATUS_PAID = ['complete', 'confirmed', 'paid']; +const STATUS_UNPAYABLE = ['expired', 'invalid']; + +function computeStartingLanguage() { + const { defaultLang } = initialSrvModel; + return isLanguageAvailable(defaultLang) ? defaultLang : fallbackLanguage; +} + +function isLanguageAvailable(languageCode) { + return availableLanguages.indexOf(languageCode) >= 0; +} + +Vue.use(VueI18next); + +const i18n = new VueI18next(i18next); +const eventBus = new Vue(); + +const PaymentDetails = Vue.component('payment-details', { + el: '#payment-details', + props: { + srvModel: Object, + isActive: Boolean + }, + computed: { + orderAmount () { + return parseFloat(this.srvModel.orderAmount); + }, + btcDue () { + return parseFloat(this.srvModel.btcDue); + }, + btcPaid () { + return parseFloat(this.srvModel.btcPaid); + }, + showRecommendedFee () { + return this.isActive && this.srvModel.showRecommendedFee && this.srvModel.feeRate; + }, + } +}); + +function initApp() { + return new Vue({ + i18n, + el: '#Checkout', + components: { + PaymentDetails + }, + data () { + const srvModel = initialSrvModel; + return { + srvModel, + displayPaymentDetails: false, + remainingSeconds: srvModel.expirationSeconds, + expirationPercentage: 0, + emailAddressInput: "", + emailAddressInputDirty: false, + emailAddressInputInvalid: false, + paymentMethodId: null, + endData: null, + isModal: srvModel.isModal + } + }, + computed: { + isUnpayable () { + return STATUS_UNPAYABLE.includes(this.srvModel.status); + }, + isPaid () { + return STATUS_PAID.includes(this.srvModel.status); + }, + isActive () { + return !this.isUnpayable && !this.isPaid; + }, + showInfo () { + return this.showTimer || this.showPaymentDueInfo; + }, + showTimer () { + return this.isActive && (this.expirationPercentage >= 75 || this.minutesLeft < 5); + }, + showPaymentDueInfo () { + return this.btcPaid > 0 && this.btcDue > 0; + }, + showRecommendedFee () { + return this.isActive() && this.srvModel.showRecommendedFee && this.srvModel.feeRate; + }, + orderAmount () { + return parseFloat(this.srvModel.orderAmount); + }, + btcDue () { + return parseFloat(this.srvModel.btcDue); + }, + btcPaid () { + return parseFloat(this.srvModel.btcPaid); + }, + pmId () { + return this.paymentMethodId || this.srvModel.paymentMethodId; + }, + minutesLeft () { + return Math.floor(this.remainingSeconds / 60); + }, + secondsLeft () { + return Math.floor(this.remainingSeconds % 60); + }, + timeText () { + return this.remainingSeconds > 0 + ? `${this.padTime(this.minutesLeft)}:${this.padTime(this.secondsLeft)}` + : '00:00'; + }, + storeLink () { + return this.srvModel.merchantRefLink && this.srvModel.merchantRefLink !== this.srvModel.receiptLink + ? this.srvModel.merchantRefLink + : null; + }, + paymentMethodIds () { + return this.srvModel.availableCryptos.map(function (c) { return c.paymentMethodId }); + }, + paymentMethodComponent () { + return this.isPluginPaymentMethod + ? `${this.pmId}Checkout` + : this.srvModel.activated && this.srvModel.uiSettings.checkoutBodyVueComponentName; + }, + isPluginPaymentMethod () { + return !this.paymentMethodIds.includes(this.pmId); + } + }, + mounted () { + this.updateData(this.srvModel); + this.updateTimer(); + if (this.isActive) { + this.listenIn(); + } + window.parent.postMessage('loaded', '*'); + }, + methods: { + changePaymentMethod (id) { // payment method or plugin id + if (this.pmId !== id) { + this.paymentMethodId = id; + this.fetchData(); + } + }, + changeLanguage (e) { + const lang = e.target.value; + if (isLanguageAvailable(lang)) { + i18next.changeLanguage(lang); + } + }, + padTime (val) { + return val.toString().padStart(2, '0'); + }, + close () { + window.parent.postMessage('close', '*'); + }, + updateTimer () { + this.remainingSeconds = Math.floor((this.endDate.getTime() - new Date().getTime())/1000); + this.expirationPercentage = 100 - Math.floor((this.remainingSeconds / this.srvModel.maxTimeSeconds) * 100); + if (this.isActive) { + setTimeout(this.updateTimer, 500); + } + }, + listenIn () { + let socket = null; + const updateFn = this.fetchData; + const supportsWebSockets = 'WebSocket' in window && window.WebSocket.CLOSING === 2; + if (supportsWebSockets) { + const protocol = window.location.protocol.replace('http', 'ws'); + const wsUri = `${protocol}//${window.location.host}${statusWsUrl}`; + try { + socket = new WebSocket(wsUri); + socket.onmessage = async function (e) { + if (e.data !== 'ping') await updateFn(); + }; + socket.onerror = function (e) { + console.error('Error while connecting to websocket for invoice notifications (callback):', e); + }; + } + catch (e) { + console.error('Error while connecting to websocket for invoice notifications', e); + } + } + // fallback in case there is no websocket support + (function watcher() { + setTimeout(async function () { + if (socket === null || socket.readyState !== 1) { + await updateFn(); + } + watcher(); + }, 2000); + })(); + }, + async fetchData () { + if (this.isPluginPaymentMethod) return; + + const url = `${statusUrl}&paymentMethodId=${this.pmId}`; + const response = await fetch(url); + if (response.ok) { + const data = await response.json(); + this.updateData(data); + } + }, + updateData (data) { + if (this.srvModel.status !== data.status) { + const { invoiceId } = this.srvModel; + const { status } = data; + window.parent.postMessage({ invoiceId, status }, '*'); + } + + // displaying satoshis for lightning payments + data.cryptoCodeSrv = data.cryptoCode; + + const newEnd = new Date(); + newEnd.setSeconds(newEnd.getSeconds() + data.expirationSeconds); + this.endDate = newEnd; + + // updating ui + this.srvModel = data; + eventBus.$emit('data-fetched', this.srvModel); + + const self = this; + if (this.isPaid && data.redirectAutomatically && data.merchantRefLink) { + setTimeout(function () { + if (self.isModal && window.top.location === data.merchantRefLink){ + self.close(); + } else { + window.top.location = data.merchantRefLink; + } + }, 2000); + } + }, + replaceNewlines (value) { + return value ? value.replace(/\n/ig, '
') : ''; + } + } + }); +} + +i18next + .use(window.i18nextHttpBackend) + .init({ + backend: { + loadPath: i18nUrl + }, + lng: startingLanguage, + fallbackLng: fallbackLanguage, + nsSeparator: false, + keySeparator: false, + load: 'currentOnly' + }, initApp); diff --git a/BTCPayServer/wwwroot/img/icon-sprite.svg b/BTCPayServer/wwwroot/img/icon-sprite.svg index e758119ca..5a1a1fc75 100644 --- a/BTCPayServer/wwwroot/img/icon-sprite.svg +++ b/BTCPayServer/wwwroot/img/icon-sprite.svg @@ -4,7 +4,7 @@ - + diff --git a/BTCPayServer/wwwroot/js/copy-to-clipboard.js b/BTCPayServer/wwwroot/js/copy-to-clipboard.js index c4f7a9328..1a1e39b5e 100644 --- a/BTCPayServer/wwwroot/js/copy-to-clipboard.js +++ b/BTCPayServer/wwwroot/js/copy-to-clipboard.js @@ -1,5 +1,9 @@ -const confirmCopy = (el, message) => { - el.innerText = message; +function confirmCopy(el, message) { + if (!el.dataset.clipboardInitial) { + el.dataset.clipboardInitial = el.innerHTML; + el.style.minWidth = el.getBoundingClientRect().width + 'px'; + } + el.innerHTML = `${message}`; setTimeout(function () { el.innerHTML = el.dataset.clipboardInitial; }, 2500); @@ -11,11 +15,7 @@ window.copyToClipboard = function (e, data) { const confirm = item.dataset.clipboardConfirmElement ? document.getElementById(item.dataset.clipboardConfirmElement) || item : item.querySelector('[data-clipboard-confirm]') || item; - const message = confirm.getAttribute('data-clipboard-confirm') || 'Copied ✔'; - if (!confirm.dataset.clipboardInitial) { - confirm.dataset.clipboardInitial = confirm.innerHTML; - confirm.style.minWidth = confirm.getBoundingClientRect().width + 'px'; - } + const message = confirm.getAttribute('data-clipboard-confirm') || 'Copied'; if (navigator.clipboard) { navigator.clipboard.writeText(data).then(function () { confirmCopy(confirm, message); @@ -38,12 +38,12 @@ window.copyUrlToClipboard = function (e) { window.copyToClipboard(e, window.location) } -document.addEventListener("DOMContentLoaded", () => { - delegate('click', '[data-clipboard]', e => { +document.addEventListener("DOMContentLoaded", function () { + delegate('click', '[data-clipboard]', function (e) { const data = e.target.closest('[data-clipboard]').getAttribute('data-clipboard') window.copyToClipboard(e, data) }) - delegate('click', '[data-clipboard-target]', e => { + delegate('click', '[data-clipboard-target]', function (e) { const selector = e.target.closest('[data-clipboard-target]').getAttribute('data-clipboard-target') const target = document.querySelector(selector) const data = target.innerText diff --git a/BTCPayServer/wwwroot/locales/checkout/en.json b/BTCPayServer/wwwroot/locales/checkout/en.json new file mode 100644 index 000000000..5006e1b39 --- /dev/null +++ b/BTCPayServer/wwwroot/locales/checkout/en.json @@ -0,0 +1,30 @@ +{ + "any_amount": "Any amount", + "expiry_info": "This invoice will expire in", + "partial_payment_info": "The invoice hasn't been paid in full.", + "still_due": "Please send {{amount}}\nto the address below.", + "view_details": "View Details", + "pay_with": "Pay with", + "pay_in_wallet": "Pay in wallet", + "invoice_id": "Invoice ID", + "order_id": "Order ID", + "total_price": "Total Price", + "total_fiat": "Total Fiat", + "exchange_rate": "Exchange Rate", + "amount_paid": "Amount Paid", + "amount_due": "Amount Due", + "recommended_fee": "Recommended Fee", + "fee_rate": "{{feeRate}} sat/byte", + "network_cost": "Network Cost", + "tx_count": "{{count}} transactions", + "qr_text": "Scan the QR code, or tap to copy the address.", + "invoice_paid": "Invoice Paid", + "invoice_expired": "Invoice Expired", + "invoice_expired_body": "An invoice is only valid for {{minutes}} minutes.\n\nReturn to {{storeName}} if you like to resubmit a payment.", + "view_receipt": "View Receipt", + "return_to_store": "Return to {{storeName}}", + "copy_confirm": "Copied", + "powered_by": "Powered by", + "conversion_body": "You can pay {{btcDue}} {{cryptoCode}} using altcoins other than the ones merchant directly supports.\n\nThis service is provided by 3rd party. Please keep in mind that we have no control over how providers will forward your funds. Invoice will only be marked paid once funds are received on {{cryptoCode}} Blockchain." + +} diff --git a/BTCPayServer/wwwroot/main/site.css b/BTCPayServer/wwwroot/main/site.css index fa80a8ff7..4051eea99 100644 --- a/BTCPayServer/wwwroot/main/site.css +++ b/BTCPayServer/wwwroot/main/site.css @@ -176,8 +176,8 @@ h2 small .fa-question-circle-o { background-color: lightgray; } -[v-cloak] { display:none } -[v-cloak-loading] > * { display:none } +[v-cloak] { display: none !important; } +[v-cloak-loading] > * { display: none !important; } [v-cloak-loading]::before { content: "loading…" } .list-group-item a:not(.btn) { diff --git a/BTCPayServer/wwwroot/main/themes/default-dark.css b/BTCPayServer/wwwroot/main/themes/default-dark.css index b77361cab..4aa9fac46 100644 --- a/BTCPayServer/wwwroot/main/themes/default-dark.css +++ b/BTCPayServer/wwwroot/main/themes/default-dark.css @@ -1,89 +1,47 @@ :root { - --btcpay-neutral-100: var(--btcpay-neutral-dark-100); - --btcpay-neutral-200: var(--btcpay-neutral-dark-200); - --btcpay-neutral-300: var(--btcpay-neutral-dark-300); - --btcpay-neutral-400: var(--btcpay-neutral-dark-400); + --btcpay-neutral-50: #0D1117; + --btcpay-neutral-100: var(--btcpay-neutral-dark-900); + --btcpay-neutral-200: var(--btcpay-neutral-dark-800); + --btcpay-neutral-300: var(--btcpay-neutral-dark-700); + --btcpay-neutral-400: var(--btcpay-neutral-dark-600); --btcpay-neutral-500: var(--btcpay-neutral-dark-500); - --btcpay-neutral-600: var(--btcpay-neutral-dark-600); - --btcpay-neutral-700: var(--btcpay-neutral-dark-700); - --btcpay-neutral-800: var(--btcpay-neutral-dark-800); - --btcpay-neutral-900: var(--btcpay-neutral-dark-900); - --btcpay-neutral-950: #0D1117; - --btcpay-bg-dark: var(--btcpay-neutral-950); + --btcpay-neutral-600: var(--btcpay-neutral-dark-400); + --btcpay-neutral-700: var(--btcpay-neutral-dark-300); + --btcpay-neutral-800: var(--btcpay-neutral-dark-200); + --btcpay-neutral-900: var(--btcpay-neutral-dark-100); + --btcpay-bg-dark: var(--btcpay-neutral-50); --btcpay-bg-tile: var(--btcpay-bg-dark); - --btcpay-body-bg: var(--btcpay-neutral-900); - --btcpay-body-bg-light: var(--btcpay-neutral-950); - --btcpay-body-bg-medium: var(--btcpay-neutral-800); - --btcpay-body-bg-striped: var(--btcpay-neutral-800); - --btcpay-body-bg-hover: var(--btcpay-neutral-950); + --btcpay-body-bg-light: var(--btcpay-neutral-50); + --btcpay-body-bg-hover: var(--btcpay-neutral-50); --btcpay-body-bg-rgb: 41, 41, 41; - --btcpay-body-border-light: var(--btcpay-neutral-800); - --btcpay-body-border-medium: var(--btcpay-neutral-700); --btcpay-body-text: var(--btcpay-white); + --btcpay-body-text-muted: var(--btcpay-neutral-600); --btcpay-body-text-rgb: 255, 255, 255; --btcpay-body-link-accent: var(--btcpay-primary-300); - --btcpay-form-bg: var(--btcpay-neutral-950); - --btcpay-form-bg-addon: var(--btcpay-neutral-700); - --btcpay-form-bg-disabled: var(--btcpay-neutral-800); - --btcpay-form-text: var(--btcpay-neutral-200); - --btcpay-form-text-label: var(--btcpay-neutral-100); - --btcpay-form-text-addon: var(--btcpay-neutral-300); - --btcpay-form-border: var(--btcpay-neutral-800); - --btcpay-form-border-check: var(--btcpay-neutral-600); + --btcpay-form-bg: var(--btcpay-bg-dark); + --btcpay-form-text: var(--btcpay-neutral-800); + --btcpay-form-text-label: var(--btcpay-neutral-900); + --btcpay-form-border: var(--btcpay-neutral-200); --btcpay-header-bg: var(--btcpay-bg-dark); --btcpay-nav-link: var(--btcpay-neutral-500); - --btcpay-nav-link-accent: var(--btcpay-neutral-300); --btcpay-nav-link-active: var(--btcpay-white); - --btcpay-footer-text: var(--btcpay-neutral-400); - --btcpay-footer-link: var(--btcpay-neutral-400); - --btcpay-footer-link-accent: var(--btcpay-neutral-200); + --btcpay-footer-link-accent: var(--btcpay-neutral-800); --btcpay-pre-bg: var(--btcpay-bg-dark); --btcpay-secondary: transparent; --btcpay-secondary-text-active: var(--btcpay-primary); - --btcpay-secondary-border: var(--btcpay-neutral-700); --btcpay-secondary-rgb: 22, 27, 34; - --btcpay-light: var(--btcpay-neutral-800); + --btcpay-warning-text: var(--btcpay-neutral-100); + --btcpay-warning-text-hover: var(--btcpay-neutral-100); + --btcpay-warning-text-active: var(--btcpay-neutral-100); --btcpay-light-accent: var(--btcpay-black); - --btcpay-light-text: var(--btcpay-neutral-200); - --btcpay-light-text-hover: var(--btcpay-neutral-200); - --btcpay-light-text-active: var(--btcpay-neutral-200); - --btcpay-light-bg-hover: var(--btcpay-light-accent); - --btcpay-light-bg-active: var(--btcpay-light-accent); - --btcpay-light-border: var(--btcpay-light); - --btcpay-light-border-hover: var(--btcpay-light-bg-hover); - --btcpay-light-border-active: var(--btcpay-light-bg-active); - --btcpay-light-dim-bg: var(--btcpay-neutral-950); - --btcpay-light-dim-bg-striped: var(--btcpay-neutral-900); - --btcpay-light-dim-bg-hover: var(--btcpay-neutral-800); - --btcpay-light-dim-bg-active: var(--btcpay-neutral-700); - --btcpay-light-dim-border: var(--btcpay-light-dim-bg); - --btcpay-light-dim-border-active: var(--btcpay-light-dim-bg-active); - --btcpay-light-dim-text: var(--btcpay-neutral-200); - --btcpay-light-dim-text-striped: var(--btcpay-light-dim-text); - --btcpay-light-dim-text-hover: var(--btcpay-light-dim-text); - --btcpay-light-dim-text-active: var(--btcpay-neutral-100); + --btcpay-light-dim-bg: var(--btcpay-neutral-50); --btcpay-light-shadow: rgba(66, 70, 73, 0.33); --btcpay-light-rgb: 33, 38, 45; - --btcpay-dark: var(--btcpay-neutral-200); --btcpay-dark-accent: var(--btcpay-neutral-400); - --btcpay-dark-text: var(--btcpay-neutral-800); - --btcpay-dark-text-hover: var(--btcpay-neutral-800); - --btcpay-dark-text-active: var(--btcpay-neutral-800); - --btcpay-dark-bg-hover: var(--btcpay-dark-accent); - --btcpay-dark-bg-active: var(--btcpay-dark-accent); - --btcpay-dark-border: var(--btcpay-dark); - --btcpay-dark-border-hover: var(--btcpay-dark-bg-hover); - --btcpay-dark-border-active: var(--btcpay-dark-bg-active); --btcpay-dark-dim-bg: var(--btcpay-white); --btcpay-dark-dim-bg-striped: var(--btcpay-neutral-200); --btcpay-dark-dim-bg-hover: var(--btcpay-neutral-200); --btcpay-dark-dim-bg-active: var(--btcpay-neutral-300); - --btcpay-dark-dim-border: var(--btcpay-dark-dim-bg); - --btcpay-dark-dim-border-active: var(--btcpay-dark-dim-bg-active); - --btcpay-dark-dim-text: var(--btcpay-neutral-800); - --btcpay-dark-dim-text-striped: var(--btcpay-dark-dim-text); - --btcpay-dark-dim-text-hover: var(--btcpay-dark-dim-text); - --btcpay-dark-dim-text-active: var(--btcpay-neutral-900); --btcpay-dark-shadow: rgba(211, 212, 213, 0.33); --btcpay-dark-rgb: 201, 209, 217; } diff --git a/BTCPayServer/wwwroot/main/themes/default.css b/BTCPayServer/wwwroot/main/themes/default.css index c9915b042..ba455d14b 100644 --- a/BTCPayServer/wwwroot/main/themes/default.css +++ b/BTCPayServer/wwwroot/main/themes/default.css @@ -209,8 +209,8 @@ --btcpay-toggle-bg-active: var(--btcpay-primary); --btcpay-toggle-bg-active-hover: var(--btcpay-primary-600); --btcpay-footer-bg: var(--btcpay-body-bg); - --btcpay-footer-text: var(--btcpay-neutral-500); - --btcpay-footer-link: var(--btcpay-neutral-500); + --btcpay-footer-text: var(--btcpay-body-text-muted); + --btcpay-footer-link: var(--btcpay-body-text-muted); --btcpay-footer-link-accent: var(--btcpay-neutral-600); --btcpay-code-text: var(--btcpay-body-text); --btcpay-code-bg: transparent; diff --git a/BTCPayServer/wwwroot/swagger/v1/swagger.template.stores.json b/BTCPayServer/wwwroot/swagger/v1/swagger.template.stores.json index 6cf6662a7..683ce63da 100644 --- a/BTCPayServer/wwwroot/swagger/v1/swagger.template.stores.json +++ b/BTCPayServer/wwwroot/swagger/v1/swagger.template.stores.json @@ -367,7 +367,7 @@ "onChainWithLnInvoiceFallback": { "type": "boolean", "default": false, - "description": "Include lightning invoice fallback to on-chain BIP21 payment url." + "description": "Unify on-chain and lightning payment URL." }, "redirectAutomatically": { "type": "boolean", diff --git a/BTCPayServer/wwwroot/vendor/bootstrap-vue/bootstrap-vue.js b/BTCPayServer/wwwroot/vendor/bootstrap-vue/bootstrap-vue.js index 0e689414c..96f13e457 100644 --- a/BTCPayServer/wwwroot/vendor/bootstrap-vue/bootstrap-vue.js +++ b/BTCPayServer/wwwroot/vendor/bootstrap-vue/bootstrap-vue.js @@ -16699,4 +16699,3 @@ return VuePlugin$F; }))); -//# sourceMappingURL=bootstrap-vue.js.map diff --git a/BTCPayServer/wwwroot/vendor/i18next/i18next.min.js b/BTCPayServer/wwwroot/vendor/i18next/i18next.min.js new file mode 100644 index 000000000..cccde2c91 --- /dev/null +++ b/BTCPayServer/wwwroot/vendor/i18next/i18next.min.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).i18next=t()}(this,function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};t(this,e),this.init(n,r)}return r(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||p,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n1?t-1:0),r=1;r-1?e.replace(/###/g,"."):e}function o(){return!e||"string"==typeof e}for(var i="string"!=typeof t?[].concat(t):t.split(".");i.length>1;){if(o())return{};var a=r(i.shift());!e[a]&&n&&(e[a]=new n),e=Object.prototype.hasOwnProperty.call(e,a)?e[a]:{}}return o()?{}:{obj:e,k:r(i.shift())}}function m(e,t,n){var r=y(e,t,Object);r.obj[r.k]=n}function b(e,t){var n=y(e,t),r=n.obj,o=n.k;if(r)return r[o]}function O(e,t,n){var r=b(e,n);return void 0!==r?r:b(t,n)}function k(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var w={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function x(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,function(e){return w[e]}):e}var S="undefined"!=typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,j=[" ",",","?","!",";"];function P(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function L(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return t(this,i),r=n.call(this),S&&h.call(o(r)),r.data=e||{},r.options=a,void 0===r.options.keySeparator&&(r.options.keySeparator="."),void 0===r.options.ignoreJSONStructure&&(r.options.ignoreJSONStructure=!0),r}return r(i,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,i=void 0!==r.ignoreJSONStructure?r.ignoreJSONStructure:this.options.ignoreJSONStructure,a=[e,t];n&&"string"!=typeof n&&(a=a.concat(n)),n&&"string"==typeof n&&(a=a.concat(o?n.split(o):n)),e.indexOf(".")>-1&&(a=e.split("."));var s=b(this.data,a);return s||!i||"string"!=typeof n?s:function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(t){if(t[n])return t[n];for(var o=n.split(r),i=t,a=0;aa+s;)s++,c=i[u=o.slice(a,a+s).join(r)];if(void 0===c)return;if(null===c)return null;if(n.endsWith(u)){if("string"==typeof c)return c;if(u&&"string"==typeof c[u])return c[u]}var l=o.slice(a+s).join(r);return l?e(c,l,r):void 0}i=i[o[a]]}return i}}(this.data&&this.data[e]&&this.data[e][t],n,o)}},{key:"addResource",value:function(e,t,n,r){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},i=this.options.keySeparator;void 0===i&&(i=".");var a=[e,t];n&&(a=a.concat(i?n.split(i):n)),e.indexOf(".")>-1&&(r=t,t=(a=e.split("."))[1]),this.addNamespaces(t),m(this.data,a,r),o.silent||this.emit("added",e,t,n,r)}},{key:"addResources",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var o in n)"string"!=typeof n[o]&&"[object Array]"!==Object.prototype.toString.apply(n[o])||this.addResource(e,t,o,n[o],{silent:!0});r.silent||this.emit("added",e,t,n)}},{key:"addResourceBundle",value:function(e,t,n,r,o){var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},a=[e,t];e.indexOf(".")>-1&&(r=n,n=t,t=(a=e.split("."))[1]),this.addNamespaces(t);var s=b(this.data,a)||{};r?function e(t,n,r){for(var o in n)"__proto__"!==o&&"constructor"!==o&&(o in t?"string"==typeof t[o]||t[o]instanceof String||"string"==typeof n[o]||n[o]instanceof String?r&&(t[o]=n[o]):e(t[o],n[o],r):t[o]=n[o]);return t}(s,n,o):s=L(L({},s),n),m(this.data,a,s),i.silent||this.emit("added",e,t,n)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?L(L({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(function(e){return t[e]&&Object.keys(t[e]).length>0})}},{key:"toJSON",value:function(){return this.data}}]),i}(),C={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,r,o){var i=this;return e.forEach(function(e){i.processors[e]&&(t=i.processors[e].process(t,n,r,o))}),t}};function E(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function D(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{};return t(this,s),n=i.call(this),S&&h.call(o(n)),r=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],a=e,u=o(n),r.forEach(function(e){a[e]&&(u[e]=a[e])}),n.options=c,void 0===n.options.keySeparator&&(n.options.keySeparator="."),n.logger=g.create("translator"),n}return r(s,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var n=this.resolve(e,t);return n&&void 0!==n.res}},{key:"extractFromKey",value:function(e,t){var n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");var r=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,o=t.ns||this.options.defaultNS||[],i=n&&e.indexOf(n)>-1,a=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||function(e,t,n){t=t||"",n=n||"";var r=j.filter(function(e){return t.indexOf(e)<0&&n.indexOf(e)<0});if(0===r.length)return!0;var o=new RegExp("(".concat(r.map(function(e){return"?"===e?"\\?":e}).join("|"),")")),i=!o.test(e);if(!i){var a=e.indexOf(n);a>0&&!o.test(e.substring(0,a))&&(i=!0)}return i}(e,n,r));if(i&&!a){var s=e.match(this.interpolator.nestingRegexp);if(s&&s.length>0)return{key:e,namespaces:o};var u=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(u[0])>-1)&&(o=u.shift()),e=u.join(r)}return"string"==typeof o&&(o=[o]),{key:e,namespaces:o}}},{key:"translate",value:function(t,n,r){var o=this;if("object"!==e(n)&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),n||(n={}),null==t)return"";Array.isArray(t)||(t=[String(t)]);var i=void 0!==n.returnDetails?n.returnDetails:this.options.returnDetails,a=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,u=this.extractFromKey(t[t.length-1],n),c=u.key,l=u.namespaces,f=l[l.length-1],p=n.lng||this.language,g=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p&&"cimode"===p.toLowerCase()){if(g){var h=n.nsSeparator||this.options.nsSeparator;return i?(d.res="".concat(f).concat(h).concat(c),d):"".concat(f).concat(h).concat(c)}return i?(d.res=c,d):c}var d=this.resolve(t,n),v=d&&d.res,y=d&&d.usedKey||c,m=d&&d.exactUsedKey||c,b=Object.prototype.toString.apply(v),O=void 0!==n.joinArrays?n.joinArrays:this.options.joinArrays,k=!this.i18nFormat||this.i18nFormat.handleAsObject;if(k&&v&&("string"!=typeof v&&"boolean"!=typeof v&&"number"!=typeof v)&&["[object Number]","[object Function]","[object RegExp]"].indexOf(b)<0&&("string"!=typeof O||"[object Array]"!==b)){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var w=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,v,D(D({},n),{},{ns:l})):"key '".concat(c," (").concat(this.language,")' returned an object instead of string.");return i?(d.res=w,d):w}if(a){var x="[object Array]"===b,S=x?[]:{},j=x?m:y;for(var P in v)if(Object.prototype.hasOwnProperty.call(v,P)){var L="".concat(j).concat(a).concat(P);S[P]=this.translate(L,D(D({},n),{joinArrays:!1,ns:l})),S[P]===L&&(S[P]=v[P])}v=S}}else if(k&&"string"==typeof O&&"[object Array]"===b)(v=v.join(O))&&(v=this.extendTranslation(v,t,n,r));else{var R=!1,N=!1,C=void 0!==n.count&&"string"!=typeof n.count,E=s.hasDefaultValue(n),F=C?this.pluralResolver.getSuffix(p,n.count,n):"",I=n["defaultValue".concat(F)]||n.defaultValue;!this.isValidLookup(v)&&E&&(R=!0,v=I),this.isValidLookup(v)||(N=!0,v=c);var A=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&N?void 0:v,T=E&&I!==v&&this.options.updateMissing;if(N||R||T){if(this.logger.log(T?"updateKey":"missingKey",p,f,c,T?I:v),a){var V=this.resolve(c,D(D({},n),{},{keySeparator:!1}));V&&V.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var U=[],K=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if("fallback"===this.options.saveMissingTo&&K&&K[0])for(var B=0;B1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach(function(e){if(!a.isValidLookup(t)){var u=a.extractFromKey(e,s),c=u.key;n=c;var l=u.namespaces;a.options.fallbackNS&&(l=l.concat(a.options.fallbackNS));var f=void 0!==s.count&&"string"!=typeof s.count,p=f&&!s.ordinal&&0===s.count&&a.pluralResolver.shouldUseIntlApi(),g=void 0!==s.context&&("string"==typeof s.context||"number"==typeof s.context)&&""!==s.context,h=s.lngs?s.lngs:a.languageUtils.toResolveHierarchy(s.lng||a.language,s.fallbackLng);l.forEach(function(e){a.isValidLookup(t)||(i=e,!I["".concat(h[0],"-").concat(e)]&&a.utils&&a.utils.hasLoadedNamespace&&!a.utils.hasLoadedNamespace(i)&&(I["".concat(h[0],"-").concat(e)]=!0,a.logger.warn('key "'.concat(n,'" for languages "').concat(h.join(", "),'" won\'t get resolved as namespace "').concat(i,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),h.forEach(function(n){if(!a.isValidLookup(t)){o=n;var i,u=[c];if(a.i18nFormat&&a.i18nFormat.addLookupKeys)a.i18nFormat.addLookupKeys(u,c,n,e,s);else{var l;f&&(l=a.pluralResolver.getSuffix(n,s.count,s));var h="".concat(a.options.pluralSeparator,"zero");if(f&&(u.push(c+l),p&&u.push(c+h)),g){var d="".concat(c).concat(a.options.contextSeparator).concat(s.context);u.push(d),f&&(u.push(d+l),p&&u.push(d+h))}}for(;i=u.pop();)a.isValidLookup(t)||(r=i,t=a.getResource(n,e,i,s))}}))})}}),{res:t,usedKey:n,exactUsedKey:r,usedLng:o,usedNS:i}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}}],[{key:"hasDefaultValue",value:function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&"defaultValue"===t.substring(0,"defaultValue".length)&&void 0!==e[t])return!0;return!1}}]),s}();function T(e){return e.charAt(0).toUpperCase()+e.slice(1)}var V=function(){function e(n){t(this,e),this.options=n,this.supportedLngs=this.options.supportedLngs||!1,this.logger=g.create("languageUtils")}return r(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],n=e.split("-");return this.options.lowerCaseLng?n=n.map(function(e){return e.toLowerCase()}):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=T(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),"sgn"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=T(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=T(n[2].toLowerCase()))),n.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,n=this;return e?(e.forEach(function(e){if(!t){var r=n.formatLanguageCode(e);n.options.supportedLngs&&!n.isSupportedCode(r)||(t=r)}}),!t&&this.options.supportedLngs&&e.forEach(function(e){if(!t){var r=n.getLanguagePartFromCode(e);if(n.isSupportedCode(r))return t=r;t=n.options.supportedLngs.find(function(e){if(0===e.indexOf(r))return e})}}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}},{key:"toResolveHierarchy",value:function(e,t){var n=this,r=this.getFallbackCodes(t||this.options.fallbackLng||[],e),o=[],i=function(e){e&&(n.isSupportedCode(e)?o.push(e):n.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&i(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&i(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&i(this.getLanguagePartFromCode(e))):"string"==typeof e&&i(this.formatLanguageCode(e)),r.forEach(function(e){o.indexOf(e)<0&&i(n.formatLanguageCode(e))}),o}}]),e}(),U=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],K={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1&&e%100!=11?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},B=["v1","v2","v3"],M={zero:0,one:1,two:2,few:3,many:4,other:5};var H=function(){function e(n){var r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t(this,e),this.languageUtils=n,this.options=o,this.logger=g.create("pluralResolver"),this.options.compatibilityJSON&&"v4"!==this.options.compatibilityJSON||"undefined"!=typeof Intl&&Intl.PluralRules||(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=(r={},U.forEach(function(e){e.lngs.forEach(function(t){r[t]={numbers:e.nr,plurals:K[e.fc]}})}),r)}return r(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,t);return this.shouldUseIntlApi()?n&&n.resolvedOptions().pluralCategories.length>1:n&&n.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,n).map(function(e){return"".concat(t).concat(e)})}},{key:"getSuffixes",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.getRule(e,n);return r?this.shouldUseIntlApi()?r.resolvedOptions().pluralCategories.sort(function(e,t){return M[e]-M[t]}).map(function(e){return"".concat(t.options.prepend).concat(e)}):r.numbers.map(function(r){return t.getSuffix(e,r,n)}):[]}},{key:"getSuffix",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this.getRule(e,n);return r?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(r.select(t)):this.getSuffixRetroCompatible(r,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var n=this,r=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),o=e.numbers[r];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===o?o="plural":1===o&&(o=""));var i=function(){return n.options.prepend&&o.toString()?n.options.prepend+o.toString():o.toString()};return"v1"===this.options.compatibilityJSON?1===o?"":"number"==typeof o?"_plural_".concat(o.toString()):i():"v2"===this.options.compatibilityJSON?i():this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?i():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}},{key:"shouldUseIntlApi",value:function(){return!B.includes(this.options.compatibilityJSON)}}]),e}();function z(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function J(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{};t(this,e),this.logger=g.create("interpolator"),this.options=n,this.format=n.interpolation&&n.interpolation.format||function(e){return e},this.init(n)}return r(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:x,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?k(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?k(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?k(t.nestingPrefix):t.nestingPrefixEscaped||k("$t("),this.nestingSuffix=t.nestingSuffix?k(t.nestingSuffix):t.nestingSuffixEscaped||k(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(t,"g");var n="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(n,"g")}},{key:"interpolate",value:function(e,t,n,r){var o,i,a,s=this,u=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function c(e){return e.replace(/\$/g,"$$$$")}var l=function(e){if(e.indexOf(s.formatSeparator)<0){var o=O(t,u,e);return s.alwaysFormat?s.format(o,void 0,n,J(J(J({},r),t),{},{interpolationkey:e})):o}var i=e.split(s.formatSeparator),a=i.shift().trim(),c=i.join(s.formatSeparator).trim();return s.format(O(t,u,a),c,n,J(J(J({},r),t),{},{interpolationkey:a}))};this.resetRegExp();var f=r&&r.missingInterpolationHandler||this.options.missingInterpolationHandler,p=r&&r.interpolation&&void 0!==r.interpolation.skipOnVariables?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return c(e)}},{regex:this.regexp,safeValue:function(e){return s.escapeValue?c(s.escape(e)):c(e)}}].forEach(function(t){for(a=0;o=t.regex.exec(e);){var n=o[1].trim();if(void 0===(i=l(n)))if("function"==typeof f){var u=f(e,o,r);i="string"==typeof u?u:""}else if(r&&r.hasOwnProperty(n))i="";else{if(p){i=o[0];continue}s.logger.warn("missed to pass in variable ".concat(n," for interpolating ").concat(e)),i=""}else"string"==typeof i||s.useRawValueToEscape||(i=v(i));var c=t.safeValue(i);if(e=e.replace(o[0],c),p?(t.regex.lastIndex+=i.length,t.regex.lastIndex-=o[0].length):t.regex.lastIndex=0,++a>=s.maxReplaces)break}}),e}},{key:"nest",value:function(e,t){var n,r,o=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=J({},i);function s(e,t){var n=this.nestingOptionsSeparator;if(e.indexOf(n)<0)return e;var r=e.split(new RegExp("".concat(n,"[ ]*{"))),o="{".concat(r[1]);e=r[0];var i=(o=this.interpolate(o,a)).match(/'/g),s=o.match(/"/g);(i&&i.length%2==0&&!s||s.length%2!=0)&&(o=o.replace(/'/g,'"'));try{a=JSON.parse(o),t&&(a=J(J({},t),a))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(n).concat(o)}return delete a.defaultValue,e}for(a.applyPostProcessor=!1,delete a.defaultValue;n=this.nestingRegexp.exec(e);){var u=[],c=!1;if(-1!==n[0].indexOf(this.formatSeparator)&&!/{.*}/.test(n[1])){var l=n[1].split(this.formatSeparator).map(function(e){return e.trim()});n[1]=l.shift(),u=l,c=!0}if((r=t(s.call(this,n[1].trim(),a),a))&&n[0]===e&&"string"!=typeof r)return r;"string"!=typeof r&&(r=v(r)),r||(this.logger.warn("missed to resolve ".concat(n[1]," for nesting ").concat(e)),r=""),c&&(r=u.reduce(function(e,t){return o.format(e,t,i.lng,J(J({},i),{},{interpolationkey:n[1].trim()}))},r.trim())),e=e.replace(n[0],r),this.regexp.lastIndex=0}return e}}]),e}();function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:{};t(this,e),this.logger=g.create("formatter"),this.options=n,this.formats={number:G(function(e,t){var n=new Intl.NumberFormat(e,t);return function(e){return n.format(e)}}),currency:G(function(e,t){var n=new Intl.NumberFormat(e,Y(Y({},t),{},{style:"currency"}));return function(e){return n.format(e)}}),datetime:G(function(e,t){var n=new Intl.DateTimeFormat(e,Y({},t));return function(e){return n.format(e)}}),relativetime:G(function(e,t){var n=new Intl.RelativeTimeFormat(e,Y({},t));return function(e){return n.format(e,t.range||"day")}}),list:G(function(e,t){var n=new Intl.ListFormat(e,Y({},t));return function(e){return n.format(e)}})},this.init(n)}return r(e,[{key:"init",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=G(t)}},{key:"format",value:function(e,t,n,r){var o=this;return t.split(this.formatSeparator).reduce(function(e,t){var i=function(e){var t=e.toLowerCase().trim(),n={};if(e.indexOf("(")>-1){var r=e.split("(");t=r[0].toLowerCase().trim();var o=r[1].substring(0,r[1].length-1);"currency"===t&&o.indexOf(":")<0?n.currency||(n.currency=o.trim()):"relativetime"===t&&o.indexOf(":")<0?n.range||(n.range=o.trim()):o.split(";").forEach(function(e){if(e){var t=$(e.split(":")),r=t[0],o=t.slice(1).join(":").trim().replace(/^'+|'+$/g,"");n[r.trim()]||(n[r.trim()]=o),"false"===o&&(n[r.trim()]=!1),"true"===o&&(n[r.trim()]=!0),isNaN(o)||(n[r.trim()]=parseInt(o,10))}})}return{formatName:t,formatOptions:n}}(t),a=i.formatName,s=i.formatOptions;if(o.formats[a]){var u=e;try{var c=r&&r.formatParams&&r.formatParams[r.interpolationkey]||{},l=c.locale||c.lng||r.locale||r.lng||n;u=o.formats[a](e,l,Y(Y(Y({},s),r),c))}catch(e){o.logger.warn(e)}return u}return o.logger.warn("there was no format function for ".concat(a)),e},e)}}]),e}();function X(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t3&&void 0!==arguments[3]?arguments[3]:{};return t(this,i),s=n.call(this),S&&h.call(o(s)),s.backend=e,s.store=r,s.services=a,s.languageUtils=a.languageUtils,s.options=u,s.logger=g.create("backendConnector"),s.waitingReads=[],s.maxParallelReads=u.maxParallelReads||10,s.readingCalls=0,s.maxRetries=u.maxRetries>=0?u.maxRetries:5,s.retryTimeout=u.retryTimeout>=1?u.retryTimeout:350,s.state={},s.queue=[],s.backend&&s.backend.init&&s.backend.init(a,u.backend,u),s}return r(i,[{key:"queueLoad",value:function(e,t,n,r){var o=this,i={},a={},s={},u={};return e.forEach(function(e){var r=!0;t.forEach(function(t){var s="".concat(e,"|").concat(t);!n.reload&&o.store.hasResourceBundle(e,t)?o.state[s]=2:o.state[s]<0||(1===o.state[s]?void 0===a[s]&&(a[s]=!0):(o.state[s]=1,r=!1,void 0===a[s]&&(a[s]=!0),void 0===i[s]&&(i[s]=!0),void 0===u[t]&&(u[t]=!0)))}),r||(s[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(s),toLoadNamespaces:Object.keys(u)}}},{key:"loaded",value:function(e,t,n){var r=e.split("|"),o=r[0],i=r[1];t&&this.emit("failedLoading",o,i,t),n&&this.store.addResourceBundle(o,i,n),this.state[e]=t?-1:2;var a={};this.queue.forEach(function(n){var r,s,u,c,l,f;r=n.loaded,s=i,c=y(r,[o],Object),l=c.obj,f=c.k,l[f]=l[f]||[],u&&(l[f]=l[f].concat(s)),u||l[f].push(s),function(e,t){void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)}(n,e),t&&n.errors.push(t),0!==n.pendingCount||n.done||(Object.keys(n.loaded).forEach(function(e){a[e]||(a[e]={});var t=n.loaded[e];t.length&&t.forEach(function(t){void 0===a[e][t]&&(a[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(function(e){return!e.done})}},{key:"read",value:function(e,t,n){var r=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;return e.length?this.readingCalls>=this.maxParallelReads?void this.waitingReads.push({lng:e,ns:t,fcName:n,tried:o,wait:i,callback:a}):(this.readingCalls++,this.backend[n](e,t,function(s,u){if(r.readingCalls--,r.waitingReads.length>0){var c=r.waitingReads.shift();r.read(c.lng,c.ns,c.fcName,c.tried,c.wait,c.callback)}s&&u&&o2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var i=this.queueLoad(e,t,r,o);if(!i.toLoad.length)return i.pending.length||o(),null;i.toLoad.forEach(function(e){n.loadOne(e)})}},{key:"load",value:function(e,t,n){this.prepareLoading(e,t,{},n)}},{key:"reload",value:function(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}},{key:"loadOne",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=e.split("|"),o=r[0],i=r[1];this.read(o,i,"read",void 0,void 0,function(r,a){r&&t.logger.warn("".concat(n,"loading namespace ").concat(i," for language ").concat(o," failed"),r),!r&&a&&t.logger.log("".concat(n,"loaded namespace ").concat(i," for language ").concat(o),a),t.loaded(e,r,a)})}},{key:"saveMissing",value:function(e,t,n,r,o){var i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t)?this.logger.warn('did not save key "'.concat(n,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"):null!=n&&""!==n&&(this.backend&&this.backend.create&&this.backend.create(e,t,n,r,null,Z(Z({},i),{},{isUpdate:o})),e&&e[0]&&this.store.addResource(e[0],t,n,r))}}]),i}();function ne(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function re(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function oe(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{},a=arguments.length>1?arguments[1]:void 0;if(t(this,u),e=i.call(this),S&&h.call(o(e)),e.options=ne(r),e.services={},e.logger=g,e.modules={external:[]},n=o(e),Object.getOwnPropertyNames(Object.getPrototypeOf(n)).forEach(function(e){"function"==typeof n[e]&&(n[e]=n[e].bind(n))}),a&&!e.isInitialized&&!r.isClone){if(!e.options.initImmediate)return e.init(r,a),s(e,o(e));setTimeout(function(){e.init(r,a)},0)}return e}return r(u,[{key:"init",value:function(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;"function"==typeof n&&(r=n,n={}),!n.defaultNS&&!1!==n.defaultNS&&n.ns&&("string"==typeof n.ns?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));var o={debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(t){var n={};if("object"===e(t[1])&&(n=t[1]),"string"==typeof t[1]&&(n.defaultValue=t[1]),"string"==typeof t[2]&&(n.tDescription=t[2]),"object"===e(t[2])||"object"===e(t[3])){var r=t[3]||t[2];Object.keys(r).forEach(function(e){n[e]=r[e]})}return n},interpolation:{escapeValue:!0,format:function(e,t,n,r){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}};function i(e){return e?"function"==typeof e?new e:e:null}if(this.options=oe(oe(oe({},o),this.options),ne(n)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=oe(oe({},o.interpolation),this.options.interpolation)),void 0!==n.keySeparator&&(this.options.userDefinedKeySeparator=n.keySeparator),void 0!==n.nsSeparator&&(this.options.userDefinedNsSeparator=n.nsSeparator),!this.options.isClone){var a;this.modules.logger?g.init(i(this.modules.logger),this.options):g.init(null,this.options),this.modules.formatter?a=this.modules.formatter:"undefined"!=typeof Intl&&(a=Q);var s=new V(this.options);this.store=new N(this.options.resources,this.options);var u=this.services;u.logger=g,u.resourceStore=this.store,u.languageUtils=s,u.pluralResolver=new H(s,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!a||this.options.interpolation.format&&this.options.interpolation.format!==o.interpolation.format||(u.formatter=i(a),u.formatter.init(u,this.options),this.options.interpolation.format=u.formatter.format.bind(u.formatter)),u.interpolator=new _(this.options),u.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},u.backendConnector=new te(i(this.modules.backend),u.resourceStore,u,this.options),u.backendConnector.on("*",function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o1?n-1:0),o=1;o0&&"dev"!==c[0]&&(this.options.lng=c[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(function(e){t[e]=function(){var n;return(n=t.store)[e].apply(n,arguments)}});["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(function(e){t[e]=function(){var n;return(n=t.store)[e].apply(n,arguments),t}});var l=d(),f=function(){var e=function(e,n){t.isInitialized&&!t.initializedStoreOnce&&t.logger.warn("init: i18next is already initialized. You should call init just once!"),t.isInitialized=!0,t.options.isClone||t.logger.log("initialized",t.options),t.emit("initialized",t.options),l.resolve(n),r(e,n)};if(t.languages&&"v1"!==t.options.compatibilityAPI&&!t.isInitialized)return e(null,t.t.bind(t));t.changeLanguage(t.options.lng,e)};return this.options.resources||!this.options.initImmediate?f():setTimeout(f,0),l}},{key:"loadResources",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ae,r="string"==typeof e?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(r&&"cimode"===r.toLowerCase())return n();var o=[],i=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach(function(e){o.indexOf(e)<0&&o.push(e)})};if(r)i(r);else this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(function(e){return i(e)});this.options.preload&&this.options.preload.forEach(function(e){return i(e)}),this.services.backendConnector.load(o,this.options.ns,function(e){e||t.resolvedLanguage||!t.language||t.setResolvedLanguage(t.language),n(e)})}else n(null)}},{key:"reloadResources",value:function(e,t,n){var r=d();return e||(e=this.languages),t||(t=this.options.ns),n||(n=ae),this.services.backendConnector.reload(e,t,function(e){r.resolve(),n(e)}),r}},{key:"use",value:function(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&C.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}}},{key:"changeLanguage",value:function(e,t){var n=this;this.isLanguageChangingTo=e;var r=d();this.emit("languageChanging",e);var o=function(e){n.language=e,n.languages=n.services.languageUtils.toResolveHierarchy(e),n.resolvedLanguage=void 0,n.setResolvedLanguage(e)},i=function(i){e||i||!n.services.languageDetector||(i=[]);var a="string"==typeof i?i:n.services.languageUtils.getBestMatchFromCodes(i);a&&(n.language||o(a),n.translator.language||n.translator.changeLanguage(a),n.services.languageDetector&&n.services.languageDetector.cacheUserLanguage(a)),n.loadResources(a,function(e){!function(e,i){i?(o(i),n.translator.changeLanguage(i),n.isLanguageChangingTo=void 0,n.emit("languageChanged",i),n.logger.log("languageChanged",i)):n.isLanguageChangingTo=void 0,r.resolve(function(){return n.t.apply(n,arguments)}),t&&t(e,function(){return n.t.apply(n,arguments)})}(e,a)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(i):i(e):i(this.services.languageDetector.detect()),r}},{key:"getFixedT",value:function(t,n,r){var o=this,i=function t(n,i){var a;if("object"!==e(i)){for(var s=arguments.length,u=new Array(s>2?s-2:0),c=2;c1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var r=this.resolvedLanguage||this.languages[0],o=!!this.options&&this.options.fallbackLng,i=this.languages[this.languages.length-1];if("cimode"===r.toLowerCase())return!0;var a=function(e,n){var r=t.services.backendConnector.state["".concat(e,"|").concat(n)];return-1===r||2===r};if(n.precheck){var s=n.precheck(this,a);if(void 0!==s)return s}return!!this.hasResourceBundle(r,e)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!a(r,e)||o&&!a(i,e)))}},{key:"loadNamespaces",value:function(e,t){var n=this,r=d();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach(function(e){n.options.ns.indexOf(e)<0&&n.options.ns.push(e)}),this.loadResources(function(e){r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var n=d();"string"==typeof e&&(e=[e]);var r=this.options.preload||[],o=e.filter(function(e){return r.indexOf(e)<0});return o.length?(this.options.preload=r.concat(o),this.loadResources(function(e){n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){if(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!e)return"rtl";return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(this.services.languageUtils.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}},{key:"cloneInstance",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ae,r=oe(oe(oe({},this.options),t),{isClone:!0}),o=new u(r);void 0===t.debug&&void 0===t.prefix||(o.logger=o.logger.clone(t));return["store","services","language"].forEach(function(t){o[t]=e[t]}),o.services=oe({},this.services),o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o.translator=new A(o.services,o.options),o.translator.on("*",function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return new se(e,t)});var ue=se.createInstance();return ue.createInstance=se.createInstance,ue}); diff --git a/BTCPayServer/wwwroot/vendor/i18next/i18nextHttpBackend.min.js b/BTCPayServer/wwwroot/vendor/i18next/i18nextHttpBackend.min.js new file mode 100644 index 000000000..74f45f68a --- /dev/null +++ b/BTCPayServer/wwwroot/vendor/i18next/i18nextHttpBackend.min.js @@ -0,0 +1 @@ +!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).i18nextHttpBackend=e()}(function(){return function o(i,r,a){function s(t,e){if(!r[t]){if(!i[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(u)return u(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}n=r[t]={exports:{}},i[t][0].call(n.exports,function(e){return s(i[t][1][e]||e)},n,n.exports,o,i,r,a)}return r[t].exports}for(var u="function"==typeof require&&require,e=0;e 3 && callback && callback(x.responseText, x); - }; - x.send(data); - } catch (e) { - console && console.log(e); - } -} - -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function getDefaults() { - return { - loadPath: '/locales/{{lng}}/{{ns}}.json', - addPath: '/locales/add/{{lng}}/{{ns}}', - allowMultiLoading: false, - parse: JSON.parse, - crossDomain: false, - ajax: ajax - }; -} - -var Backend = function () { - function Backend(services) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - _classCallCheck(this, Backend); - - this.init(services, options); - - this.type = 'backend'; - } - - _createClass(Backend, [{ - key: 'init', - value: function init(services) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - this.services = services; - this.options = defaults(options, this.options || {}, getDefaults()); - } - }, { - key: 'readMulti', - value: function readMulti(languages, namespaces, callback) { - var loadPath = this.options.loadPath; - if (typeof this.options.loadPath === 'function') { - loadPath = this.options.loadPath(languages, namespaces); - } - - var url = this.services.interpolator.interpolate(loadPath, { lng: languages.join('+'), ns: namespaces.join('+') }); - - this.loadUrl(url, callback); - } - }, { - key: 'read', - value: function read(language, namespace, callback) { - var loadPath = this.options.loadPath; - if (typeof this.options.loadPath === 'function') { - loadPath = this.options.loadPath([language], [namespace]); - } - - var url = this.services.interpolator.interpolate(loadPath, { lng: language, ns: namespace }); - - this.loadUrl(url, callback); - } - }, { - key: 'loadUrl', - value: function loadUrl(url, callback) { - var _this = this; - - this.options.ajax(url, this.options, function (data, xhr) { - if (xhr.status >= 500 && xhr.status < 600) return callback('failed loading ' + url, true /* retry */); - if (xhr.status >= 400 && xhr.status < 500) return callback('failed loading ' + url, false /* no retry */); - - var ret = void 0, - err = void 0; - try { - ret = _this.options.parse(data, url); - } catch (e) { - err = 'failed parsing ' + url + ' to json'; - } - if (err) return callback(err, false); - callback(null, ret); - }); - } - }, { - key: 'create', - value: function create(languages, namespace, key, fallbackValue) { - var _this2 = this; - - if (typeof languages === 'string') languages = [languages]; - - var payload = {}; - payload[key] = fallbackValue || ''; - - languages.forEach(function (lng) { - var url = _this2.services.interpolator.interpolate(_this2.options.addPath, { lng: lng, ns: namespace }); - - _this2.options.ajax(url, _this2.options, function (data, xhr) { - //const statusCode = xhr.status.toString(); - // TODO: if statusCode === 4xx do log - }, payload); - }); - } - }]); - - return Backend; -}(); - -Backend.type = 'backend'; - -return Backend; - -}))); diff --git a/BTCPayServer/wwwroot/vendor/i18next/vue-i18next.js b/BTCPayServer/wwwroot/vendor/i18next/vue-i18next.js index ecaff4ba0..a73c6115e 100644 --- a/BTCPayServer/wwwroot/vendor/i18next/vue-i18next.js +++ b/BTCPayServer/wwwroot/vendor/i18next/vue-i18next.js @@ -1 +1,537 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("VueI18next",[],t):"object"==typeof exports?exports.VueI18next=t():e.VueI18next=t()}(this,function(){return function(e){function t(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/dist/",t(t.s=2)}([function(e,t,n){"use strict";function i(e){i.installed||(i.installed=!0,t.Vue=u=e,u.mixin({computed:{$t:function(){var e=this;return function(t,n){return e.$i18n.t(t,n,e.$i18n.i18nLoadedAt)}}},beforeCreate:function(){var e=this.$options;e.i18n?this.$i18n=e.i18n:e.parent&&e.parent.$i18n&&(this.$i18n=e.parent.$i18n)}}),u.component(r.default.name,r.default))}Object.defineProperty(t,"__esModule",{value:!0}),t.Vue=void 0,t.install=i;var o=n(1),r=function(e){return e&&e.__esModule?e:{default:e}}(o),u=t.Vue=void 0},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"i18next",functional:!0,props:{tag:{type:String,default:"span"},path:{type:String,required:!0}},render:function(e,t){var n=t.props,i=t.data,o=t.children,r=t.parent,u=r.$i18n;if(!u)return o;var a=n.path,s=u.i18next.services.interpolator.regexp,f=u.t(a,{interpolation:{prefix:"#$?",suffix:"?$#"}}),d=[],c={};return o.forEach(function(e){e.data&&e.data.attrs&&e.data.attrs.tkey&&(c[e.data.attrs.tkey]=e)}),f.split(s).reduce(function(e,t,n){var i=void 0;if(n%2==0){if(0===t.length)return e;i=t}else i=o[parseInt(t,10)];return e.push(i),e},d),e(n.tag,i,d)}},e.exports=t.default},function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};i(this,e);var o=n.bindI18n,r=void 0===o?"languageChanged loaded":o,u=n.bindStore,a=void 0===u?"added removed":u;this._vm=null,this.i18next=t,this.onI18nChanged=this.onI18nChanged.bind(this),r&&this.i18next.on(r,this.onI18nChanged),a&&this.i18next.store&&this.i18next.store.on(a,this.onI18nChanged),this.resetVM({i18nLoadedAt:new Date})}return r(e,[{key:"resetVM",value:function(e){var t=this._vm,n=u.Vue.config.silent;u.Vue.config.silent=!0,this._vm=new u.Vue({data:e}),u.Vue.config.silent=n,t&&u.Vue.nextTick(function(){return t.$destroy()})}},{key:"t",value:function(e,t){return this.i18next.t(e,t)}},{key:"onI18nChanged",value:function(){this.i18nLoadedAt=new Date}},{key:"i18nLoadedAt",get:function(){return this._vm.$data.i18nLoadedAt},set:function(e){this._vm.$set(this._vm,"i18nLoadedAt",e)}}]),e}();t.default=a,a.install=u.install,a.version="0.4.0",("undefined"==typeof window?"undefined":o(window))&&window.Vue&&window.Vue.use(a),e.exports=t.default}])}); +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global.VueI18next = factory()); +}(this, (function () { 'use strict'; + + var isMergeableObject = function isMergeableObject(value) { + return isNonNullObject(value) + && !isSpecial(value) + }; + + function isNonNullObject(value) { + return !!value && typeof value === 'object' + } + + function isSpecial(value) { + var stringValue = Object.prototype.toString.call(value); + + return stringValue === '[object RegExp]' + || stringValue === '[object Date]' + || isReactElement(value) + } + + // see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25 + var canUseSymbol = typeof Symbol === 'function' && Symbol.for; + var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7; + + function isReactElement(value) { + return value.$$typeof === REACT_ELEMENT_TYPE + } + + function emptyTarget(val) { + return Array.isArray(val) ? [] : {} + } + + function cloneUnlessOtherwiseSpecified(value, options) { + return (options.clone !== false && options.isMergeableObject(value)) + ? deepmerge(emptyTarget(value), value, options) + : value + } + + function defaultArrayMerge(target, source, options) { + return target.concat(source).map(function(element) { + return cloneUnlessOtherwiseSpecified(element, options) + }) + } + + function mergeObject(target, source, options) { + var destination = {}; + if (options.isMergeableObject(target)) { + Object.keys(target).forEach(function(key) { + destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); + }); + } + Object.keys(source).forEach(function(key) { + if (!options.isMergeableObject(source[key]) || !target[key]) { + destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); + } else { + destination[key] = deepmerge(target[key], source[key], options); + } + }); + return destination + } + + function deepmerge(target, source, options) { + options = options || {}; + options.arrayMerge = options.arrayMerge || defaultArrayMerge; + options.isMergeableObject = options.isMergeableObject || isMergeableObject; + + var sourceIsArray = Array.isArray(source); + var targetIsArray = Array.isArray(target); + var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; + + if (!sourceAndTargetTypesMatch) { + return cloneUnlessOtherwiseSpecified(source, options) + } else if (sourceIsArray) { + return options.arrayMerge(target, source, options) + } else { + return mergeObject(target, source, options) + } + } + + deepmerge.all = function deepmergeAll(array, options) { + if (!Array.isArray(array)) { + throw new Error('first argument should be an array') + } + + return array.reduce(function(prev, next) { + return deepmerge(prev, next, options) + }, {}) + }; + + var deepmerge_1 = deepmerge; + + var component = { + name: 'i18next', + functional: true, + props: { + tag: { + type: String, + default: 'span' + }, + path: { + type: String, + required: true + }, + options: { + type: Object + } + }, + render: function render(h, ref) { + var props = ref.props; + var data = ref.data; + var children = ref.children; + var parent = ref.parent; + + var i18next = parent.$i18n; + var $t = parent.$t.bind(parent); + if (!i18next || !$t) { + return h(props.tag, data, children); + } + + var path = props.path; + var options = props.options || {}; + + var REGEXP = i18next.i18next.services.interpolator.regexp; + var i18nextOptions = Object.assign({}, options, + {interpolation: { prefix: '#$?', suffix: '?$#' }}); + var format = $t(path, i18nextOptions); + var tchildren = []; + + format.split(REGEXP).reduce(function (memo, match, index) { + var child; + if (index % 2 === 0) { + if (match.length === 0) { return memo; } + + child = match; + } else { + var place = match.trim(); + // eslint-disable-next-line no-restricted-globals + if (isNaN(parseFloat(place)) || !isFinite(place)) { + children.forEach(function (e) { + if ( + !child && + e.data.attrs && + e.data.attrs.place && + e.data.attrs.place === place + ) { + child = e; + } + }); + } else { + child = children[parseInt(match, 10)]; + } + } + + memo.push(child); + return memo; + }, tchildren); + + return h(props.tag, data, tchildren); + } + }; + + /* eslint-disable import/prefer-default-export */ + + function log(message) { + if (typeof console !== 'undefined') { + console.warn(message); // eslint-disable-line no-console + } + } + + function warn(message) { + log(("[vue-i18next warn]: " + message)); + } + + function deprecate(message) { + log(("[vue-i18next deprecated]: " + message)); + } + + /* eslint-disable no-param-reassign, no-unused-vars */ + + function equalLanguage(el, vnode) { + var vm = vnode.context; + return el._i18nLanguage === vm.$i18n.i18next.language; + } + + function equalValue(value, oldValue) { + if (value === oldValue) { + return true; + } + if (value && oldValue) { + return ( + value.path === oldValue.path && + value.language === oldValue.language && + value.args === oldValue.args + ); + } + } + + function assert(vnode) { + var vm = vnode.context; + + if (!vm.$i18n) { + warn('No VueI18Next instance found in the Vue instance'); + return false; + } + + return true; + } + + function parseValue(value) { + var assign; + + var path; + var language; + var args; + + if (typeof value === 'string') { + path = value; + } else if (toString.call(value) === '[object Object]') { + ((assign = value, path = assign.path, language = assign.language, args = assign.args)); + } + + return { path: path, language: language, args: args }; + } + + function t(el, binding, vnode) { + var value = binding.value; + + var ref = parseValue(value); + var path = ref.path; + var language = ref.language; + var args = ref.args; + if (!path && !language && !args) { + warn('v-t: invalid value'); + return; + } + + if (!path) { + warn('v-t: "path" is required'); + return; + } + + if (language) { + deprecate("v-t: \"language\" is deprecated.Use the \"lng\" property in args.\n https://www.i18next.com/overview/configuration-options#configuration-options"); + } + + var vm = vnode.context; + el.textContent = vm.$i18n.i18next.t(path, Object.assign({}, (language ? { lng: language } : {}), + args)); + + el._i18nLanguage = vm.$i18n.i18next.language; + } + + function bind(el, binding, vnode) { + if (!assert(vnode)) { + return; + } + + t(el, binding, vnode); + } + + function update(el, binding, vnode, oldVNode) { + if (equalLanguage(el, vnode) && equalValue(binding.value, binding.oldValue)) { + return; + } + + t(el, binding, vnode); + } + + var directive = { + bind: bind, + update: update + }; + + /* eslint-disable no-param-reassign, no-unused-vars */ + + function assert$1(vnode) { + var vm = vnode.context; + + if (!vm.$i18n) { + warn('No VueI18Next instance found in the Vue instance'); + return false; + } + + return true; + } + + function waitForIt(el, vnode) { + if (vnode.context.$i18n.i18next.isInitialized) { + el.hidden = false; + } else { + el.hidden = true; + var initialized = function () { + vnode.context.$forceUpdate(); + // due to emitter removing issue in i18next we need to delay remove + setTimeout(function () { + if (vnode.context && vnode.context.$i18n) { + vnode.context.$i18n.i18next.off('initialized', initialized); + } + }, 1000); + }; + vnode.context.$i18n.i18next.on('initialized', initialized); + } + } + + function bind$1(el, binding, vnode) { + if (!assert$1(vnode)) { + return; + } + + waitForIt(el, vnode); + } + + function update$1(el, binding, vnode, oldVNode) { + if (vnode.context.$i18n.i18next.isInitialized) { + el.hidden = false; + } + } + + var waitDirective = { + bind: bind$1, + update: update$1 + }; + + /* eslint-disable import/no-mutable-exports */ + + var Vue; + + function install(_Vue) { + if (install.installed) { + return; + } + install.installed = true; + + Vue = _Vue; + + var getByKey = function (i18nOptions, i18nextOptions) { return function (key) { + if ( + i18nOptions && + i18nOptions.keyPrefix && + !key.includes(i18nextOptions.nsSeparator) + ) { + return ((i18nOptions.keyPrefix) + "." + key); + } + return key; + }; }; + + var getComponentNamespace = function (vm) { + var namespace = vm.$options.name || vm.$options._componentTag; + if (namespace) { + return { + namespace: namespace, + loadNamespace: true + }; + } + + return { + namespace: ("" + (Math.random())) + }; + }; + + Vue.mixin({ + beforeCreate: function beforeCreate() { + var this$1 = this; + + var options = this.$options; + if (options.i18n) { + this._i18n = options.i18n; + } else if (options.parent && options.parent.$i18n) { + this._i18n = options.parent.$i18n; + } + var inlineTranslations = {}; + + if (this._i18n) { + var getNamespace = + this._i18n.options.getComponentNamespace || getComponentNamespace; + var ref = getNamespace(this); + var namespace = ref.namespace; + var loadNamespace = ref.loadNamespace; + + if (options.__i18n) { + options.__i18n.forEach(function (resource) { + inlineTranslations = deepmerge_1( + inlineTranslations, + JSON.parse(resource) + ); + }); + } + + if (options.i18nOptions) { + var ref$1 = this.$options.i18nOptions; + var lng = ref$1.lng; if ( lng === void 0 ) lng = null; + var keyPrefix = ref$1.keyPrefix; if ( keyPrefix === void 0 ) keyPrefix = null; + var messages = ref$1.messages; + var ref$2 = this.$options.i18nOptions; + var namespaces = ref$2.namespaces; + namespaces = namespaces || this._i18n.i18next.options.defaultNS; + + if (typeof namespaces === 'string') { namespaces = [namespaces]; } + var namespacesToLoad = namespaces.concat([namespace]); + + if (messages) { + inlineTranslations = deepmerge_1(inlineTranslations, messages); + } + + this._i18nOptions = { lng: lng, namespaces: namespacesToLoad, keyPrefix: keyPrefix }; + this._i18n.i18next.loadNamespaces(namespaces); + } else if (options.parent && options.parent._i18nOptions) { + this._i18nOptions = Object.assign({}, options.parent._i18nOptions); + this._i18nOptions.namespaces = [ + namespace ].concat( this._i18nOptions.namespaces + ); + } else if (options.__i18n) { + this._i18nOptions = { namespaces: [namespace] }; + } + + if (loadNamespace && this._i18n.options.loadComponentNamespace) { + this._i18n.i18next.loadNamespaces([namespace]); + } + + var languages = Object.keys(inlineTranslations); + languages.forEach(function (lang) { + this$1._i18n.i18next.addResourceBundle( + lang, + namespace, + Object.assign({}, inlineTranslations[lang]), + true, + false + ); + }); + } + + var getKey = getByKey( + this._i18nOptions, + this._i18n ? this._i18n.i18next.options : {} + ); + + if (this._i18nOptions && this._i18nOptions.namespaces) { + var ref$3 = this._i18nOptions; + var lng$1 = ref$3.lng; + var namespaces$1 = ref$3.namespaces; + + var fixedT = this._i18n.i18next.getFixedT(lng$1, namespaces$1); + this._getI18nKey = function (key, i18nextOptions) { return fixedT(getKey(key), i18nextOptions, this$1._i18n.i18nLoadedAt); }; + } else { + this._getI18nKey = function (key, i18nextOptions) { return this$1._i18n.t(getKey(key), i18nextOptions, this$1._i18n.i18nLoadedAt); }; + } + } + }); + + // extend Vue.js + if (!Object.prototype.hasOwnProperty.call(Vue.prototype, '$i18n')) { + Object.defineProperty(Vue.prototype, '$i18n', { + get: function get() { + return this._i18n; + } + }); + } + + Vue.prototype.$t = function t(key, options) { + return this._getI18nKey(key, options); + }; + + Vue.component(component.name, component); + Vue.directive('t', directive); + Vue.directive('waitForT', waitDirective); + } + + var VueI18n = function VueI18n(i18next, opts) { + if ( opts === void 0 ) opts = {}; + + var options = Object.assign({}, {bindI18n: 'languageChanged loaded', + bindStore: 'added removed', + loadComponentNamespace: false}, + opts); + + this._vm = null; + this.i18next = i18next; + this.options = options; + + this.onI18nChanged = this.onI18nChanged.bind(this); + + if (options.bindI18n) { + this.i18next.on(options.bindI18n, this.onI18nChanged); + } + if (options.bindStore && this.i18next.store) { + this.i18next.store.on(options.bindStore, this.onI18nChanged); + } + + this.resetVM({ i18nLoadedAt: new Date() }); + }; + + var prototypeAccessors = { i18nLoadedAt: { configurable: true } }; + + VueI18n.prototype.resetVM = function resetVM (data) { + var oldVM = this._vm; + var ref = Vue.config; + var silent = ref.silent; + Vue.config.silent = true; + this._vm = new Vue({ data: data }); + Vue.config.silent = silent; + if (oldVM) { + Vue.nextTick(function () { return oldVM.$destroy(); }); + } + }; + + prototypeAccessors.i18nLoadedAt.get = function () { + return this._vm.$data.i18nLoadedAt; + }; + + prototypeAccessors.i18nLoadedAt.set = function (date) { + this._vm.$set(this._vm, 'i18nLoadedAt', date); + }; + + VueI18n.prototype.t = function t (key, options) { + return this.i18next.t(key, options); + }; + + VueI18n.prototype.onI18nChanged = function onI18nChanged () { + this.i18nLoadedAt = new Date(); + }; + + Object.defineProperties( VueI18n.prototype, prototypeAccessors ); + + VueI18n.install = install; + VueI18n.version = "0.15.2"; + + /* istanbul ignore if */ + if (typeof window !== 'undefined' && window.Vue) { + window.Vue.use(VueI18n); + } + + return VueI18n; + +}))); diff --git a/BTCPayServer/wwwroot/vendor/signalr/signalr.js b/BTCPayServer/wwwroot/vendor/signalr/signalr.js index e53c2b019..a8c75a3b7 100644 --- a/BTCPayServer/wwwroot/vendor/signalr/signalr.js +++ b/BTCPayServer/wwwroot/vendor/signalr/signalr.js @@ -1357,7 +1357,6 @@ return Promise$2; -//# sourceMappingURL=es6-promise.auto.map /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(2))) @@ -4085,4 +4084,3 @@ var JsonHubProtocol = /** @class */ (function () { /***/ }) /******/ ]); }); -//# sourceMappingURL=signalr.js.map \ No newline at end of file diff --git a/BTCPayServer/wwwroot/vendor/vuejs/vue.js b/BTCPayServer/wwwroot/vendor/vuejs/vue.js deleted file mode 100644 index be061434c..000000000 --- a/BTCPayServer/wwwroot/vendor/vuejs/vue.js +++ /dev/null @@ -1,11965 +0,0 @@ -/*! - * Vue.js v2.6.12 - * (c) 2014-2020 Evan You - * Released under the MIT License. - */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global = global || self, global.Vue = factory()); -}(this, function () { 'use strict'; - - /* */ - - var emptyObject = Object.freeze({}); - - // These helpers produce better VM code in JS engines due to their - // explicitness and function inlining. - function isUndef (v) { - return v === undefined || v === null - } - - function isDef (v) { - return v !== undefined && v !== null - } - - function isTrue (v) { - return v === true - } - - function isFalse (v) { - return v === false - } - - /** - * Check if value is primitive. - */ - function isPrimitive (value) { - return ( - typeof value === 'string' || - typeof value === 'number' || - // $flow-disable-line - typeof value === 'symbol' || - typeof value === 'boolean' - ) - } - - /** - * Quick object check - this is primarily used to tell - * Objects from primitive values when we know the value - * is a JSON-compliant type. - */ - function isObject (obj) { - return obj !== null && typeof obj === 'object' - } - - /** - * Get the raw type string of a value, e.g., [object Object]. - */ - var _toString = Object.prototype.toString; - - function toRawType (value) { - return _toString.call(value).slice(8, -1) - } - - /** - * Strict object type check. Only returns true - * for plain JavaScript objects. - */ - function isPlainObject (obj) { - return _toString.call(obj) === '[object Object]' - } - - function isRegExp (v) { - return _toString.call(v) === '[object RegExp]' - } - - /** - * Check if val is a valid array index. - */ - function isValidArrayIndex (val) { - var n = parseFloat(String(val)); - return n >= 0 && Math.floor(n) === n && isFinite(val) - } - - function isPromise (val) { - return ( - isDef(val) && - typeof val.then === 'function' && - typeof val.catch === 'function' - ) - } - - /** - * Convert a value to a string that is actually rendered. - */ - function toString (val) { - return val == null - ? '' - : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString) - ? JSON.stringify(val, null, 2) - : String(val) - } - - /** - * Convert an input value to a number for persistence. - * If the conversion fails, return original string. - */ - function toNumber (val) { - var n = parseFloat(val); - return isNaN(n) ? val : n - } - - /** - * Make a map and return a function for checking if a key - * is in that map. - */ - function makeMap ( - str, - expectsLowerCase - ) { - var map = Object.create(null); - var list = str.split(','); - for (var i = 0; i < list.length; i++) { - map[list[i]] = true; - } - return expectsLowerCase - ? function (val) { return map[val.toLowerCase()]; } - : function (val) { return map[val]; } - } - - /** - * Check if a tag is a built-in tag. - */ - var isBuiltInTag = makeMap('slot,component', true); - - /** - * Check if an attribute is a reserved attribute. - */ - var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is'); - - /** - * Remove an item from an array. - */ - function remove (arr, item) { - if (arr.length) { - var index = arr.indexOf(item); - if (index > -1) { - return arr.splice(index, 1) - } - } - } - - /** - * Check whether an object has the property. - */ - var hasOwnProperty = Object.prototype.hasOwnProperty; - function hasOwn (obj, key) { - return hasOwnProperty.call(obj, key) - } - - /** - * Create a cached version of a pure function. - */ - function cached (fn) { - var cache = Object.create(null); - return (function cachedFn (str) { - var hit = cache[str]; - return hit || (cache[str] = fn(str)) - }) - } - - /** - * Camelize a hyphen-delimited string. - */ - var camelizeRE = /-(\w)/g; - var camelize = cached(function (str) { - return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; }) - }); - - /** - * Capitalize a string. - */ - var capitalize = cached(function (str) { - return str.charAt(0).toUpperCase() + str.slice(1) - }); - - /** - * Hyphenate a camelCase string. - */ - var hyphenateRE = /\B([A-Z])/g; - var hyphenate = cached(function (str) { - return str.replace(hyphenateRE, '-$1').toLowerCase() - }); - - /** - * Simple bind polyfill for environments that do not support it, - * e.g., PhantomJS 1.x. Technically, we don't need this anymore - * since native bind is now performant enough in most browsers. - * But removing it would mean breaking code that was able to run in - * PhantomJS 1.x, so this must be kept for backward compatibility. - */ - - /* istanbul ignore next */ - function polyfillBind (fn, ctx) { - function boundFn (a) { - var l = arguments.length; - return l - ? l > 1 - ? fn.apply(ctx, arguments) - : fn.call(ctx, a) - : fn.call(ctx) - } - - boundFn._length = fn.length; - return boundFn - } - - function nativeBind (fn, ctx) { - return fn.bind(ctx) - } - - var bind = Function.prototype.bind - ? nativeBind - : polyfillBind; - - /** - * Convert an Array-like object to a real Array. - */ - function toArray (list, start) { - start = start || 0; - var i = list.length - start; - var ret = new Array(i); - while (i--) { - ret[i] = list[i + start]; - } - return ret - } - - /** - * Mix properties into target object. - */ - function extend (to, _from) { - for (var key in _from) { - to[key] = _from[key]; - } - return to - } - - /** - * Merge an Array of Objects into a single Object. - */ - function toObject (arr) { - var res = {}; - for (var i = 0; i < arr.length; i++) { - if (arr[i]) { - extend(res, arr[i]); - } - } - return res - } - - /* eslint-disable no-unused-vars */ - - /** - * Perform no operation. - * Stubbing args to make Flow happy without leaving useless transpiled code - * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/). - */ - function noop (a, b, c) {} - - /** - * Always return false. - */ - var no = function (a, b, c) { return false; }; - - /* eslint-enable no-unused-vars */ - - /** - * Return the same value. - */ - var identity = function (_) { return _; }; - - /** - * Generate a string containing static keys from compiler modules. - */ - function genStaticKeys (modules) { - return modules.reduce(function (keys, m) { - return keys.concat(m.staticKeys || []) - }, []).join(',') - } - - /** - * Check if two values are loosely equal - that is, - * if they are plain objects, do they have the same shape? - */ - function looseEqual (a, b) { - if (a === b) { return true } - var isObjectA = isObject(a); - var isObjectB = isObject(b); - if (isObjectA && isObjectB) { - try { - var isArrayA = Array.isArray(a); - var isArrayB = Array.isArray(b); - if (isArrayA && isArrayB) { - return a.length === b.length && a.every(function (e, i) { - return looseEqual(e, b[i]) - }) - } else if (a instanceof Date && b instanceof Date) { - return a.getTime() === b.getTime() - } else if (!isArrayA && !isArrayB) { - var keysA = Object.keys(a); - var keysB = Object.keys(b); - return keysA.length === keysB.length && keysA.every(function (key) { - return looseEqual(a[key], b[key]) - }) - } else { - /* istanbul ignore next */ - return false - } - } catch (e) { - /* istanbul ignore next */ - return false - } - } else if (!isObjectA && !isObjectB) { - return String(a) === String(b) - } else { - return false - } - } - - /** - * Return the first index at which a loosely equal value can be - * found in the array (if value is a plain object, the array must - * contain an object of the same shape), or -1 if it is not present. - */ - function looseIndexOf (arr, val) { - for (var i = 0; i < arr.length; i++) { - if (looseEqual(arr[i], val)) { return i } - } - return -1 - } - - /** - * Ensure a function is called only once. - */ - function once (fn) { - var called = false; - return function () { - if (!called) { - called = true; - fn.apply(this, arguments); - } - } - } - - var SSR_ATTR = 'data-server-rendered'; - - var ASSET_TYPES = [ - 'component', - 'directive', - 'filter' - ]; - - var LIFECYCLE_HOOKS = [ - 'beforeCreate', - 'created', - 'beforeMount', - 'mounted', - 'beforeUpdate', - 'updated', - 'beforeDestroy', - 'destroyed', - 'activated', - 'deactivated', - 'errorCaptured', - 'serverPrefetch' - ]; - - /* */ - - - - var config = ({ - /** - * Option merge strategies (used in core/util/options) - */ - // $flow-disable-line - optionMergeStrategies: Object.create(null), - - /** - * Whether to suppress warnings. - */ - silent: false, - - /** - * Show production mode tip message on boot? - */ - productionTip: "development" !== 'production', - - /** - * Whether to enable devtools - */ - devtools: "development" !== 'production', - - /** - * Whether to record perf - */ - performance: false, - - /** - * Error handler for watcher errors - */ - errorHandler: null, - - /** - * Warn handler for watcher warns - */ - warnHandler: null, - - /** - * Ignore certain custom elements - */ - ignoredElements: [], - - /** - * Custom user key aliases for v-on - */ - // $flow-disable-line - keyCodes: Object.create(null), - - /** - * Check if a tag is reserved so that it cannot be registered as a - * component. This is platform-dependent and may be overwritten. - */ - isReservedTag: no, - - /** - * Check if an attribute is reserved so that it cannot be used as a component - * prop. This is platform-dependent and may be overwritten. - */ - isReservedAttr: no, - - /** - * Check if a tag is an unknown element. - * Platform-dependent. - */ - isUnknownElement: no, - - /** - * Get the namespace of an element - */ - getTagNamespace: noop, - - /** - * Parse the real tag name for the specific platform. - */ - parsePlatformTagName: identity, - - /** - * Check if an attribute must be bound using property, e.g. value - * Platform-dependent. - */ - mustUseProp: no, - - /** - * Perform updates asynchronously. Intended to be used by Vue Test Utils - * This will significantly reduce performance if set to false. - */ - async: true, - - /** - * Exposed for legacy reasons - */ - _lifecycleHooks: LIFECYCLE_HOOKS - }); - - /* */ - - /** - * unicode letters used for parsing html tags, component names and property paths. - * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname - * skipping \u10000-\uEFFFF due to it freezing up PhantomJS - */ - var unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/; - - /** - * Check if a string starts with $ or _ - */ - function isReserved (str) { - var c = (str + '').charCodeAt(0); - return c === 0x24 || c === 0x5F - } - - /** - * Define a property. - */ - function def (obj, key, val, enumerable) { - Object.defineProperty(obj, key, { - value: val, - enumerable: !!enumerable, - writable: true, - configurable: true - }); - } - - /** - * Parse simple path. - */ - var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]")); - function parsePath (path) { - if (bailRE.test(path)) { - return - } - var segments = path.split('.'); - return function (obj) { - for (var i = 0; i < segments.length; i++) { - if (!obj) { return } - obj = obj[segments[i]]; - } - return obj - } - } - - /* */ - - // can we use __proto__? - var hasProto = '__proto__' in {}; - - // Browser environment sniffing - var inBrowser = typeof window !== 'undefined'; - var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform; - var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase(); - var UA = inBrowser && window.navigator.userAgent.toLowerCase(); - var isIE = UA && /msie|trident/.test(UA); - var isIE9 = UA && UA.indexOf('msie 9.0') > 0; - var isEdge = UA && UA.indexOf('edge/') > 0; - var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android'); - var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios'); - var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge; - var isPhantomJS = UA && /phantomjs/.test(UA); - var isFF = UA && UA.match(/firefox\/(\d+)/); - - // Firefox has a "watch" function on Object.prototype... - var nativeWatch = ({}).watch; - - var supportsPassive = false; - if (inBrowser) { - try { - var opts = {}; - Object.defineProperty(opts, 'passive', ({ - get: function get () { - /* istanbul ignore next */ - supportsPassive = true; - } - })); // https://github.com/facebook/flow/issues/285 - window.addEventListener('test-passive', null, opts); - } catch (e) {} - } - - // this needs to be lazy-evaled because vue may be required before - // vue-server-renderer can set VUE_ENV - var _isServer; - var isServerRendering = function () { - if (_isServer === undefined) { - /* istanbul ignore if */ - if (!inBrowser && !inWeex && typeof global !== 'undefined') { - // detect presence of vue-server-renderer and avoid - // Webpack shimming the process - _isServer = global['process'] && global['process'].env.VUE_ENV === 'server'; - } else { - _isServer = false; - } - } - return _isServer - }; - - // detect devtools - var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__; - - /* istanbul ignore next */ - function isNative (Ctor) { - return typeof Ctor === 'function' && /native code/.test(Ctor.toString()) - } - - var hasSymbol = - typeof Symbol !== 'undefined' && isNative(Symbol) && - typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys); - - var _Set; - /* istanbul ignore if */ // $flow-disable-line - if (typeof Set !== 'undefined' && isNative(Set)) { - // use native Set when available. - _Set = Set; - } else { - // a non-standard Set polyfill that only works with primitive keys. - _Set = /*@__PURE__*/(function () { - function Set () { - this.set = Object.create(null); - } - Set.prototype.has = function has (key) { - return this.set[key] === true - }; - Set.prototype.add = function add (key) { - this.set[key] = true; - }; - Set.prototype.clear = function clear () { - this.set = Object.create(null); - }; - - return Set; - }()); - } - - /* */ - - var warn = noop; - var tip = noop; - var generateComponentTrace = (noop); // work around flow check - var formatComponentName = (noop); - - { - var hasConsole = typeof console !== 'undefined'; - var classifyRE = /(?:^|[-_])(\w)/g; - var classify = function (str) { return str - .replace(classifyRE, function (c) { return c.toUpperCase(); }) - .replace(/[-_]/g, ''); }; - - warn = function (msg, vm) { - var trace = vm ? generateComponentTrace(vm) : ''; - - if (config.warnHandler) { - config.warnHandler.call(null, msg, vm, trace); - } else if (hasConsole && (!config.silent)) { - console.error(("[Vue warn]: " + msg + trace)); - } - }; - - tip = function (msg, vm) { - if (hasConsole && (!config.silent)) { - console.warn("[Vue tip]: " + msg + ( - vm ? generateComponentTrace(vm) : '' - )); - } - }; - - formatComponentName = function (vm, includeFile) { - if (vm.$root === vm) { - return '' - } - var options = typeof vm === 'function' && vm.cid != null - ? vm.options - : vm._isVue - ? vm.$options || vm.constructor.options - : vm; - var name = options.name || options._componentTag; - var file = options.__file; - if (!name && file) { - var match = file.match(/([^/\\]+)\.vue$/); - name = match && match[1]; - } - - return ( - (name ? ("<" + (classify(name)) + ">") : "") + - (file && includeFile !== false ? (" at " + file) : '') - ) - }; - - var repeat = function (str, n) { - var res = ''; - while (n) { - if (n % 2 === 1) { res += str; } - if (n > 1) { str += str; } - n >>= 1; - } - return res - }; - - generateComponentTrace = function (vm) { - if (vm._isVue && vm.$parent) { - var tree = []; - var currentRecursiveSequence = 0; - while (vm) { - if (tree.length > 0) { - var last = tree[tree.length - 1]; - if (last.constructor === vm.constructor) { - currentRecursiveSequence++; - vm = vm.$parent; - continue - } else if (currentRecursiveSequence > 0) { - tree[tree.length - 1] = [last, currentRecursiveSequence]; - currentRecursiveSequence = 0; - } - } - tree.push(vm); - vm = vm.$parent; - } - return '\n\nfound in\n\n' + tree - .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm) - ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)") - : formatComponentName(vm))); }) - .join('\n') - } else { - return ("\n\n(found in " + (formatComponentName(vm)) + ")") - } - }; - } - - /* */ - - var uid = 0; - - /** - * A dep is an observable that can have multiple - * directives subscribing to it. - */ - var Dep = function Dep () { - this.id = uid++; - this.subs = []; - }; - - Dep.prototype.addSub = function addSub (sub) { - this.subs.push(sub); - }; - - Dep.prototype.removeSub = function removeSub (sub) { - remove(this.subs, sub); - }; - - Dep.prototype.depend = function depend () { - if (Dep.target) { - Dep.target.addDep(this); - } - }; - - Dep.prototype.notify = function notify () { - // stabilize the subscriber list first - var subs = this.subs.slice(); - if (!config.async) { - // subs aren't sorted in scheduler if not running async - // we need to sort them now to make sure they fire in correct - // order - subs.sort(function (a, b) { return a.id - b.id; }); - } - for (var i = 0, l = subs.length; i < l; i++) { - subs[i].update(); - } - }; - - // The current target watcher being evaluated. - // This is globally unique because only one watcher - // can be evaluated at a time. - Dep.target = null; - var targetStack = []; - - function pushTarget (target) { - targetStack.push(target); - Dep.target = target; - } - - function popTarget () { - targetStack.pop(); - Dep.target = targetStack[targetStack.length - 1]; - } - - /* */ - - var VNode = function VNode ( - tag, - data, - children, - text, - elm, - context, - componentOptions, - asyncFactory - ) { - this.tag = tag; - this.data = data; - this.children = children; - this.text = text; - this.elm = elm; - this.ns = undefined; - this.context = context; - this.fnContext = undefined; - this.fnOptions = undefined; - this.fnScopeId = undefined; - this.key = data && data.key; - this.componentOptions = componentOptions; - this.componentInstance = undefined; - this.parent = undefined; - this.raw = false; - this.isStatic = false; - this.isRootInsert = true; - this.isComment = false; - this.isCloned = false; - this.isOnce = false; - this.asyncFactory = asyncFactory; - this.asyncMeta = undefined; - this.isAsyncPlaceholder = false; - }; - - var prototypeAccessors = { child: { configurable: true } }; - - // DEPRECATED: alias for componentInstance for backwards compat. - /* istanbul ignore next */ - prototypeAccessors.child.get = function () { - return this.componentInstance - }; - - Object.defineProperties( VNode.prototype, prototypeAccessors ); - - var createEmptyVNode = function (text) { - if ( text === void 0 ) text = ''; - - var node = new VNode(); - node.text = text; - node.isComment = true; - return node - }; - - function createTextVNode (val) { - return new VNode(undefined, undefined, undefined, String(val)) - } - - // optimized shallow clone - // used for static nodes and slot nodes because they may be reused across - // multiple renders, cloning them avoids errors when DOM manipulations rely - // on their elm reference. - function cloneVNode (vnode) { - var cloned = new VNode( - vnode.tag, - vnode.data, - // #7975 - // clone children array to avoid mutating original in case of cloning - // a child. - vnode.children && vnode.children.slice(), - vnode.text, - vnode.elm, - vnode.context, - vnode.componentOptions, - vnode.asyncFactory - ); - cloned.ns = vnode.ns; - cloned.isStatic = vnode.isStatic; - cloned.key = vnode.key; - cloned.isComment = vnode.isComment; - cloned.fnContext = vnode.fnContext; - cloned.fnOptions = vnode.fnOptions; - cloned.fnScopeId = vnode.fnScopeId; - cloned.asyncMeta = vnode.asyncMeta; - cloned.isCloned = true; - return cloned - } - - /* - * not type checking this file because flow doesn't play well with - * dynamically accessing methods on Array prototype - */ - - var arrayProto = Array.prototype; - var arrayMethods = Object.create(arrayProto); - - var methodsToPatch = [ - 'push', - 'pop', - 'shift', - 'unshift', - 'splice', - 'sort', - 'reverse' - ]; - - /** - * Intercept mutating methods and emit events - */ - methodsToPatch.forEach(function (method) { - // cache original method - var original = arrayProto[method]; - def(arrayMethods, method, function mutator () { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - var result = original.apply(this, args); - var ob = this.__ob__; - var inserted; - switch (method) { - case 'push': - case 'unshift': - inserted = args; - break - case 'splice': - inserted = args.slice(2); - break - } - if (inserted) { ob.observeArray(inserted); } - // notify change - ob.dep.notify(); - return result - }); - }); - - /* */ - - var arrayKeys = Object.getOwnPropertyNames(arrayMethods); - - /** - * In some cases we may want to disable observation inside a component's - * update computation. - */ - var shouldObserve = true; - - function toggleObserving (value) { - shouldObserve = value; - } - - /** - * Observer class that is attached to each observed - * object. Once attached, the observer converts the target - * object's property keys into getter/setters that - * collect dependencies and dispatch updates. - */ - var Observer = function Observer (value) { - this.value = value; - this.dep = new Dep(); - this.vmCount = 0; - def(value, '__ob__', this); - if (Array.isArray(value)) { - if (hasProto) { - protoAugment(value, arrayMethods); - } else { - copyAugment(value, arrayMethods, arrayKeys); - } - this.observeArray(value); - } else { - this.walk(value); - } - }; - - /** - * Walk through all properties and convert them into - * getter/setters. This method should only be called when - * value type is Object. - */ - Observer.prototype.walk = function walk (obj) { - var keys = Object.keys(obj); - for (var i = 0; i < keys.length; i++) { - defineReactive$$1(obj, keys[i]); - } - }; - - /** - * Observe a list of Array items. - */ - Observer.prototype.observeArray = function observeArray (items) { - for (var i = 0, l = items.length; i < l; i++) { - observe(items[i]); - } - }; - - // helpers - - /** - * Augment a target Object or Array by intercepting - * the prototype chain using __proto__ - */ - function protoAugment (target, src) { - /* eslint-disable no-proto */ - target.__proto__ = src; - /* eslint-enable no-proto */ - } - - /** - * Augment a target Object or Array by defining - * hidden properties. - */ - /* istanbul ignore next */ - function copyAugment (target, src, keys) { - for (var i = 0, l = keys.length; i < l; i++) { - var key = keys[i]; - def(target, key, src[key]); - } - } - - /** - * Attempt to create an observer instance for a value, - * returns the new observer if successfully observed, - * or the existing observer if the value already has one. - */ - function observe (value, asRootData) { - if (!isObject(value) || value instanceof VNode) { - return - } - var ob; - if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) { - ob = value.__ob__; - } else if ( - shouldObserve && - !isServerRendering() && - (Array.isArray(value) || isPlainObject(value)) && - Object.isExtensible(value) && - !value._isVue - ) { - ob = new Observer(value); - } - if (asRootData && ob) { - ob.vmCount++; - } - return ob - } - - /** - * Define a reactive property on an Object. - */ - function defineReactive$$1 ( - obj, - key, - val, - customSetter, - shallow - ) { - var dep = new Dep(); - - var property = Object.getOwnPropertyDescriptor(obj, key); - if (property && property.configurable === false) { - return - } - - // cater for pre-defined getter/setters - var getter = property && property.get; - var setter = property && property.set; - if ((!getter || setter) && arguments.length === 2) { - val = obj[key]; - } - - var childOb = !shallow && observe(val); - Object.defineProperty(obj, key, { - enumerable: true, - configurable: true, - get: function reactiveGetter () { - var value = getter ? getter.call(obj) : val; - if (Dep.target) { - dep.depend(); - if (childOb) { - childOb.dep.depend(); - if (Array.isArray(value)) { - dependArray(value); - } - } - } - return value - }, - set: function reactiveSetter (newVal) { - var value = getter ? getter.call(obj) : val; - /* eslint-disable no-self-compare */ - if (newVal === value || (newVal !== newVal && value !== value)) { - return - } - /* eslint-enable no-self-compare */ - if (customSetter) { - customSetter(); - } - // #7981: for accessor properties without setter - if (getter && !setter) { return } - if (setter) { - setter.call(obj, newVal); - } else { - val = newVal; - } - childOb = !shallow && observe(newVal); - dep.notify(); - } - }); - } - - /** - * Set a property on an object. Adds the new property and - * triggers change notification if the property doesn't - * already exist. - */ - function set (target, key, val) { - if (isUndef(target) || isPrimitive(target) - ) { - warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target)))); - } - if (Array.isArray(target) && isValidArrayIndex(key)) { - target.length = Math.max(target.length, key); - target.splice(key, 1, val); - return val - } - if (key in target && !(key in Object.prototype)) { - target[key] = val; - return val - } - var ob = (target).__ob__; - if (target._isVue || (ob && ob.vmCount)) { - warn( - 'Avoid adding reactive properties to a Vue instance or its root $data ' + - 'at runtime - declare it upfront in the data option.' - ); - return val - } - if (!ob) { - target[key] = val; - return val - } - defineReactive$$1(ob.value, key, val); - ob.dep.notify(); - return val - } - - /** - * Delete a property and trigger change if necessary. - */ - function del (target, key) { - if (isUndef(target) || isPrimitive(target) - ) { - warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target)))); - } - if (Array.isArray(target) && isValidArrayIndex(key)) { - target.splice(key, 1); - return - } - var ob = (target).__ob__; - if (target._isVue || (ob && ob.vmCount)) { - warn( - 'Avoid deleting properties on a Vue instance or its root $data ' + - '- just set it to null.' - ); - return - } - if (!hasOwn(target, key)) { - return - } - delete target[key]; - if (!ob) { - return - } - ob.dep.notify(); - } - - /** - * Collect dependencies on array elements when the array is touched, since - * we cannot intercept array element access like property getters. - */ - function dependArray (value) { - for (var e = (void 0), i = 0, l = value.length; i < l; i++) { - e = value[i]; - e && e.__ob__ && e.__ob__.dep.depend(); - if (Array.isArray(e)) { - dependArray(e); - } - } - } - - /* */ - - /** - * Option overwriting strategies are functions that handle - * how to merge a parent option value and a child option - * value into the final value. - */ - var strats = config.optionMergeStrategies; - - /** - * Options with restrictions - */ - { - strats.el = strats.propsData = function (parent, child, vm, key) { - if (!vm) { - warn( - "option \"" + key + "\" can only be used during instance " + - 'creation with the `new` keyword.' - ); - } - return defaultStrat(parent, child) - }; - } - - /** - * Helper that recursively merges two data objects together. - */ - function mergeData (to, from) { - if (!from) { return to } - var key, toVal, fromVal; - - var keys = hasSymbol - ? Reflect.ownKeys(from) - : Object.keys(from); - - for (var i = 0; i < keys.length; i++) { - key = keys[i]; - // in case the object is already observed... - if (key === '__ob__') { continue } - toVal = to[key]; - fromVal = from[key]; - if (!hasOwn(to, key)) { - set(to, key, fromVal); - } else if ( - toVal !== fromVal && - isPlainObject(toVal) && - isPlainObject(fromVal) - ) { - mergeData(toVal, fromVal); - } - } - return to - } - - /** - * Data - */ - function mergeDataOrFn ( - parentVal, - childVal, - vm - ) { - if (!vm) { - // in a Vue.extend merge, both should be functions - if (!childVal) { - return parentVal - } - if (!parentVal) { - return childVal - } - // when parentVal & childVal are both present, - // we need to return a function that returns the - // merged result of both functions... no need to - // check if parentVal is a function here because - // it has to be a function to pass previous merges. - return function mergedDataFn () { - return mergeData( - typeof childVal === 'function' ? childVal.call(this, this) : childVal, - typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal - ) - } - } else { - return function mergedInstanceDataFn () { - // instance merge - var instanceData = typeof childVal === 'function' - ? childVal.call(vm, vm) - : childVal; - var defaultData = typeof parentVal === 'function' - ? parentVal.call(vm, vm) - : parentVal; - if (instanceData) { - return mergeData(instanceData, defaultData) - } else { - return defaultData - } - } - } - } - - strats.data = function ( - parentVal, - childVal, - vm - ) { - if (!vm) { - if (childVal && typeof childVal !== 'function') { - warn( - 'The "data" option should be a function ' + - 'that returns a per-instance value in component ' + - 'definitions.', - vm - ); - - return parentVal - } - return mergeDataOrFn(parentVal, childVal) - } - - return mergeDataOrFn(parentVal, childVal, vm) - }; - - /** - * Hooks and props are merged as arrays. - */ - function mergeHook ( - parentVal, - childVal - ) { - var res = childVal - ? parentVal - ? parentVal.concat(childVal) - : Array.isArray(childVal) - ? childVal - : [childVal] - : parentVal; - return res - ? dedupeHooks(res) - : res - } - - function dedupeHooks (hooks) { - var res = []; - for (var i = 0; i < hooks.length; i++) { - if (res.indexOf(hooks[i]) === -1) { - res.push(hooks[i]); - } - } - return res - } - - LIFECYCLE_HOOKS.forEach(function (hook) { - strats[hook] = mergeHook; - }); - - /** - * Assets - * - * When a vm is present (instance creation), we need to do - * a three-way merge between constructor options, instance - * options and parent options. - */ - function mergeAssets ( - parentVal, - childVal, - vm, - key - ) { - var res = Object.create(parentVal || null); - if (childVal) { - assertObjectType(key, childVal, vm); - return extend(res, childVal) - } else { - return res - } - } - - ASSET_TYPES.forEach(function (type) { - strats[type + 's'] = mergeAssets; - }); - - /** - * Watchers. - * - * Watchers hashes should not overwrite one - * another, so we merge them as arrays. - */ - strats.watch = function ( - parentVal, - childVal, - vm, - key - ) { - // work around Firefox's Object.prototype.watch... - if (parentVal === nativeWatch) { parentVal = undefined; } - if (childVal === nativeWatch) { childVal = undefined; } - /* istanbul ignore if */ - if (!childVal) { return Object.create(parentVal || null) } - { - assertObjectType(key, childVal, vm); - } - if (!parentVal) { return childVal } - var ret = {}; - extend(ret, parentVal); - for (var key$1 in childVal) { - var parent = ret[key$1]; - var child = childVal[key$1]; - if (parent && !Array.isArray(parent)) { - parent = [parent]; - } - ret[key$1] = parent - ? parent.concat(child) - : Array.isArray(child) ? child : [child]; - } - return ret - }; - - /** - * Other object hashes. - */ - strats.props = - strats.methods = - strats.inject = - strats.computed = function ( - parentVal, - childVal, - vm, - key - ) { - if (childVal && "development" !== 'production') { - assertObjectType(key, childVal, vm); - } - if (!parentVal) { return childVal } - var ret = Object.create(null); - extend(ret, parentVal); - if (childVal) { extend(ret, childVal); } - return ret - }; - strats.provide = mergeDataOrFn; - - /** - * Default strategy. - */ - var defaultStrat = function (parentVal, childVal) { - return childVal === undefined - ? parentVal - : childVal - }; - - /** - * Validate component names - */ - function checkComponents (options) { - for (var key in options.components) { - validateComponentName(key); - } - } - - function validateComponentName (name) { - if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) { - warn( - 'Invalid component name: "' + name + '". Component names ' + - 'should conform to valid custom element name in html5 specification.' - ); - } - if (isBuiltInTag(name) || config.isReservedTag(name)) { - warn( - 'Do not use built-in or reserved HTML elements as component ' + - 'id: ' + name - ); - } - } - - /** - * Ensure all props option syntax are normalized into the - * Object-based format. - */ - function normalizeProps (options, vm) { - var props = options.props; - if (!props) { return } - var res = {}; - var i, val, name; - if (Array.isArray(props)) { - i = props.length; - while (i--) { - val = props[i]; - if (typeof val === 'string') { - name = camelize(val); - res[name] = { type: null }; - } else { - warn('props must be strings when using array syntax.'); - } - } - } else if (isPlainObject(props)) { - for (var key in props) { - val = props[key]; - name = camelize(key); - res[name] = isPlainObject(val) - ? val - : { type: val }; - } - } else { - warn( - "Invalid value for option \"props\": expected an Array or an Object, " + - "but got " + (toRawType(props)) + ".", - vm - ); - } - options.props = res; - } - - /** - * Normalize all injections into Object-based format - */ - function normalizeInject (options, vm) { - var inject = options.inject; - if (!inject) { return } - var normalized = options.inject = {}; - if (Array.isArray(inject)) { - for (var i = 0; i < inject.length; i++) { - normalized[inject[i]] = { from: inject[i] }; - } - } else if (isPlainObject(inject)) { - for (var key in inject) { - var val = inject[key]; - normalized[key] = isPlainObject(val) - ? extend({ from: key }, val) - : { from: val }; - } - } else { - warn( - "Invalid value for option \"inject\": expected an Array or an Object, " + - "but got " + (toRawType(inject)) + ".", - vm - ); - } - } - - /** - * Normalize raw function directives into object format. - */ - function normalizeDirectives (options) { - var dirs = options.directives; - if (dirs) { - for (var key in dirs) { - var def$$1 = dirs[key]; - if (typeof def$$1 === 'function') { - dirs[key] = { bind: def$$1, update: def$$1 }; - } - } - } - } - - function assertObjectType (name, value, vm) { - if (!isPlainObject(value)) { - warn( - "Invalid value for option \"" + name + "\": expected an Object, " + - "but got " + (toRawType(value)) + ".", - vm - ); - } - } - - /** - * Merge two option objects into a new one. - * Core utility used in both instantiation and inheritance. - */ - function mergeOptions ( - parent, - child, - vm - ) { - { - checkComponents(child); - } - - if (typeof child === 'function') { - child = child.options; - } - - normalizeProps(child, vm); - normalizeInject(child, vm); - normalizeDirectives(child); - - // Apply extends and mixins on the child options, - // but only if it is a raw options object that isn't - // the result of another mergeOptions call. - // Only merged options has the _base property. - if (!child._base) { - if (child.extends) { - parent = mergeOptions(parent, child.extends, vm); - } - if (child.mixins) { - for (var i = 0, l = child.mixins.length; i < l; i++) { - parent = mergeOptions(parent, child.mixins[i], vm); - } - } - } - - var options = {}; - var key; - for (key in parent) { - mergeField(key); - } - for (key in child) { - if (!hasOwn(parent, key)) { - mergeField(key); - } - } - function mergeField (key) { - var strat = strats[key] || defaultStrat; - options[key] = strat(parent[key], child[key], vm, key); - } - return options - } - - /** - * Resolve an asset. - * This function is used because child instances need access - * to assets defined in its ancestor chain. - */ - function resolveAsset ( - options, - type, - id, - warnMissing - ) { - /* istanbul ignore if */ - if (typeof id !== 'string') { - return - } - var assets = options[type]; - // check local registration variations first - if (hasOwn(assets, id)) { return assets[id] } - var camelizedId = camelize(id); - if (hasOwn(assets, camelizedId)) { return assets[camelizedId] } - var PascalCaseId = capitalize(camelizedId); - if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] } - // fallback to prototype chain - var res = assets[id] || assets[camelizedId] || assets[PascalCaseId]; - if (warnMissing && !res) { - warn( - 'Failed to resolve ' + type.slice(0, -1) + ': ' + id, - options - ); - } - return res - } - - /* */ - - - - function validateProp ( - key, - propOptions, - propsData, - vm - ) { - var prop = propOptions[key]; - var absent = !hasOwn(propsData, key); - var value = propsData[key]; - // boolean casting - var booleanIndex = getTypeIndex(Boolean, prop.type); - if (booleanIndex > -1) { - if (absent && !hasOwn(prop, 'default')) { - value = false; - } else if (value === '' || value === hyphenate(key)) { - // only cast empty string / same name to boolean if - // boolean has higher priority - var stringIndex = getTypeIndex(String, prop.type); - if (stringIndex < 0 || booleanIndex < stringIndex) { - value = true; - } - } - } - // check default value - if (value === undefined) { - value = getPropDefaultValue(vm, prop, key); - // since the default value is a fresh copy, - // make sure to observe it. - var prevShouldObserve = shouldObserve; - toggleObserving(true); - observe(value); - toggleObserving(prevShouldObserve); - } - { - assertProp(prop, key, value, vm, absent); - } - return value - } - - /** - * Get the default value of a prop. - */ - function getPropDefaultValue (vm, prop, key) { - // no default, return undefined - if (!hasOwn(prop, 'default')) { - return undefined - } - var def = prop.default; - // warn against non-factory defaults for Object & Array - if (isObject(def)) { - warn( - 'Invalid default value for prop "' + key + '": ' + - 'Props with type Object/Array must use a factory function ' + - 'to return the default value.', - vm - ); - } - // the raw prop value was also undefined from previous render, - // return previous default value to avoid unnecessary watcher trigger - if (vm && vm.$options.propsData && - vm.$options.propsData[key] === undefined && - vm._props[key] !== undefined - ) { - return vm._props[key] - } - // call factory function for non-Function types - // a value is Function if its prototype is function even across different execution context - return typeof def === 'function' && getType(prop.type) !== 'Function' - ? def.call(vm) - : def - } - - /** - * Assert whether a prop is valid. - */ - function assertProp ( - prop, - name, - value, - vm, - absent - ) { - if (prop.required && absent) { - warn( - 'Missing required prop: "' + name + '"', - vm - ); - return - } - if (value == null && !prop.required) { - return - } - var type = prop.type; - var valid = !type || type === true; - var expectedTypes = []; - if (type) { - if (!Array.isArray(type)) { - type = [type]; - } - for (var i = 0; i < type.length && !valid; i++) { - var assertedType = assertType(value, type[i]); - expectedTypes.push(assertedType.expectedType || ''); - valid = assertedType.valid; - } - } - - if (!valid) { - warn( - getInvalidTypeMessage(name, value, expectedTypes), - vm - ); - return - } - var validator = prop.validator; - if (validator) { - if (!validator(value)) { - warn( - 'Invalid prop: custom validator check failed for prop "' + name + '".', - vm - ); - } - } - } - - var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/; - - function assertType (value, type) { - var valid; - var expectedType = getType(type); - if (simpleCheckRE.test(expectedType)) { - var t = typeof value; - valid = t === expectedType.toLowerCase(); - // for primitive wrapper objects - if (!valid && t === 'object') { - valid = value instanceof type; - } - } else if (expectedType === 'Object') { - valid = isPlainObject(value); - } else if (expectedType === 'Array') { - valid = Array.isArray(value); - } else { - valid = value instanceof type; - } - return { - valid: valid, - expectedType: expectedType - } - } - - /** - * Use function string name to check built-in types, - * because a simple equality check will fail when running - * across different vms / iframes. - */ - function getType (fn) { - var match = fn && fn.toString().match(/^\s*function (\w+)/); - return match ? match[1] : '' - } - - function isSameType (a, b) { - return getType(a) === getType(b) - } - - function getTypeIndex (type, expectedTypes) { - if (!Array.isArray(expectedTypes)) { - return isSameType(expectedTypes, type) ? 0 : -1 - } - for (var i = 0, len = expectedTypes.length; i < len; i++) { - if (isSameType(expectedTypes[i], type)) { - return i - } - } - return -1 - } - - function getInvalidTypeMessage (name, value, expectedTypes) { - var message = "Invalid prop: type check failed for prop \"" + name + "\"." + - " Expected " + (expectedTypes.map(capitalize).join(', ')); - var expectedType = expectedTypes[0]; - var receivedType = toRawType(value); - var expectedValue = styleValue(value, expectedType); - var receivedValue = styleValue(value, receivedType); - // check if we need to specify expected value - if (expectedTypes.length === 1 && - isExplicable(expectedType) && - !isBoolean(expectedType, receivedType)) { - message += " with value " + expectedValue; - } - message += ", got " + receivedType + " "; - // check if we need to specify received value - if (isExplicable(receivedType)) { - message += "with value " + receivedValue + "."; - } - return message - } - - function styleValue (value, type) { - if (type === 'String') { - return ("\"" + value + "\"") - } else if (type === 'Number') { - return ("" + (Number(value))) - } else { - return ("" + value) - } - } - - function isExplicable (value) { - var explicitTypes = ['string', 'number', 'boolean']; - return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; }) - } - - function isBoolean () { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; }) - } - - /* */ - - function handleError (err, vm, info) { - // Deactivate deps tracking while processing error handler to avoid possible infinite rendering. - // See: https://github.com/vuejs/vuex/issues/1505 - pushTarget(); - try { - if (vm) { - var cur = vm; - while ((cur = cur.$parent)) { - var hooks = cur.$options.errorCaptured; - if (hooks) { - for (var i = 0; i < hooks.length; i++) { - try { - var capture = hooks[i].call(cur, err, vm, info) === false; - if (capture) { return } - } catch (e) { - globalHandleError(e, cur, 'errorCaptured hook'); - } - } - } - } - } - globalHandleError(err, vm, info); - } finally { - popTarget(); - } - } - - function invokeWithErrorHandling ( - handler, - context, - args, - vm, - info - ) { - var res; - try { - res = args ? handler.apply(context, args) : handler.call(context); - if (res && !res._isVue && isPromise(res) && !res._handled) { - res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); }); - // issue #9511 - // avoid catch triggering multiple times when nested calls - res._handled = true; - } - } catch (e) { - handleError(e, vm, info); - } - return res - } - - function globalHandleError (err, vm, info) { - if (config.errorHandler) { - try { - return config.errorHandler.call(null, err, vm, info) - } catch (e) { - // if the user intentionally throws the original error in the handler, - // do not log it twice - if (e !== err) { - logError(e, null, 'config.errorHandler'); - } - } - } - logError(err, vm, info); - } - - function logError (err, vm, info) { - { - warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm); - } - /* istanbul ignore else */ - if ((inBrowser || inWeex) && typeof console !== 'undefined') { - console.error(err); - } else { - throw err - } - } - - /* */ - - var isUsingMicroTask = false; - - var callbacks = []; - var pending = false; - - function flushCallbacks () { - pending = false; - var copies = callbacks.slice(0); - callbacks.length = 0; - for (var i = 0; i < copies.length; i++) { - copies[i](); - } - } - - // Here we have async deferring wrappers using microtasks. - // In 2.5 we used (macro) tasks (in combination with microtasks). - // However, it has subtle problems when state is changed right before repaint - // (e.g. #6813, out-in transitions). - // Also, using (macro) tasks in event handler would cause some weird behaviors - // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109). - // So we now use microtasks everywhere, again. - // A major drawback of this tradeoff is that there are some scenarios - // where microtasks have too high a priority and fire in between supposedly - // sequential events (e.g. #4521, #6690, which have workarounds) - // or even between bubbling of the same event (#6566). - var timerFunc; - - // The nextTick behavior leverages the microtask queue, which can be accessed - // via either native Promise.then or MutationObserver. - // MutationObserver has wider support, however it is seriously bugged in - // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It - // completely stops working after triggering a few times... so, if native - // Promise is available, we will use it: - /* istanbul ignore next, $flow-disable-line */ - if (typeof Promise !== 'undefined' && isNative(Promise)) { - var p = Promise.resolve(); - timerFunc = function () { - p.then(flushCallbacks); - // In problematic UIWebViews, Promise.then doesn't completely break, but - // it can get stuck in a weird state where callbacks are pushed into the - // microtask queue but the queue isn't being flushed, until the browser - // needs to do some other work, e.g. handle a timer. Therefore we can - // "force" the microtask queue to be flushed by adding an empty timer. - if (isIOS) { setTimeout(noop); } - }; - isUsingMicroTask = true; - } else if (!isIE && typeof MutationObserver !== 'undefined' && ( - isNative(MutationObserver) || - // PhantomJS and iOS 7.x - MutationObserver.toString() === '[object MutationObserverConstructor]' - )) { - // Use MutationObserver where native Promise is not available, - // e.g. PhantomJS, iOS7, Android 4.4 - // (#6466 MutationObserver is unreliable in IE11) - var counter = 1; - var observer = new MutationObserver(flushCallbacks); - var textNode = document.createTextNode(String(counter)); - observer.observe(textNode, { - characterData: true - }); - timerFunc = function () { - counter = (counter + 1) % 2; - textNode.data = String(counter); - }; - isUsingMicroTask = true; - } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) { - // Fallback to setImmediate. - // Technically it leverages the (macro) task queue, - // but it is still a better choice than setTimeout. - timerFunc = function () { - setImmediate(flushCallbacks); - }; - } else { - // Fallback to setTimeout. - timerFunc = function () { - setTimeout(flushCallbacks, 0); - }; - } - - function nextTick (cb, ctx) { - var _resolve; - callbacks.push(function () { - if (cb) { - try { - cb.call(ctx); - } catch (e) { - handleError(e, ctx, 'nextTick'); - } - } else if (_resolve) { - _resolve(ctx); - } - }); - if (!pending) { - pending = true; - timerFunc(); - } - // $flow-disable-line - if (!cb && typeof Promise !== 'undefined') { - return new Promise(function (resolve) { - _resolve = resolve; - }) - } - } - - /* */ - - var mark; - var measure; - - { - var perf = inBrowser && window.performance; - /* istanbul ignore if */ - if ( - perf && - perf.mark && - perf.measure && - perf.clearMarks && - perf.clearMeasures - ) { - mark = function (tag) { return perf.mark(tag); }; - measure = function (name, startTag, endTag) { - perf.measure(name, startTag, endTag); - perf.clearMarks(startTag); - perf.clearMarks(endTag); - // perf.clearMeasures(name) - }; - } - } - - /* not type checking this file because flow doesn't play well with Proxy */ - - var initProxy; - - { - var allowedGlobals = makeMap( - 'Infinity,undefined,NaN,isFinite,isNaN,' + - 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + - 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + - 'require' // for Webpack/Browserify - ); - - var warnNonPresent = function (target, key) { - warn( - "Property or method \"" + key + "\" is not defined on the instance but " + - 'referenced during render. Make sure that this property is reactive, ' + - 'either in the data option, or for class-based components, by ' + - 'initializing the property. ' + - 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', - target - ); - }; - - var warnReservedPrefix = function (target, key) { - warn( - "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " + - 'properties starting with "$" or "_" are not proxied in the Vue instance to ' + - 'prevent conflicts with Vue internals. ' + - 'See: https://vuejs.org/v2/api/#data', - target - ); - }; - - var hasProxy = - typeof Proxy !== 'undefined' && isNative(Proxy); - - if (hasProxy) { - var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact'); - config.keyCodes = new Proxy(config.keyCodes, { - set: function set (target, key, value) { - if (isBuiltInModifier(key)) { - warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key)); - return false - } else { - target[key] = value; - return true - } - } - }); - } - - var hasHandler = { - has: function has (target, key) { - var has = key in target; - var isAllowed = allowedGlobals(key) || - (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data)); - if (!has && !isAllowed) { - if (key in target.$data) { warnReservedPrefix(target, key); } - else { warnNonPresent(target, key); } - } - return has || !isAllowed - } - }; - - var getHandler = { - get: function get (target, key) { - if (typeof key === 'string' && !(key in target)) { - if (key in target.$data) { warnReservedPrefix(target, key); } - else { warnNonPresent(target, key); } - } - return target[key] - } - }; - - initProxy = function initProxy (vm) { - if (hasProxy) { - // determine which proxy handler to use - var options = vm.$options; - var handlers = options.render && options.render._withStripped - ? getHandler - : hasHandler; - vm._renderProxy = new Proxy(vm, handlers); - } else { - vm._renderProxy = vm; - } - }; - } - - /* */ - - var seenObjects = new _Set(); - - /** - * Recursively traverse an object to evoke all converted - * getters, so that every nested property inside the object - * is collected as a "deep" dependency. - */ - function traverse (val) { - _traverse(val, seenObjects); - seenObjects.clear(); - } - - function _traverse (val, seen) { - var i, keys; - var isA = Array.isArray(val); - if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) { - return - } - if (val.__ob__) { - var depId = val.__ob__.dep.id; - if (seen.has(depId)) { - return - } - seen.add(depId); - } - if (isA) { - i = val.length; - while (i--) { _traverse(val[i], seen); } - } else { - keys = Object.keys(val); - i = keys.length; - while (i--) { _traverse(val[keys[i]], seen); } - } - } - - /* */ - - var normalizeEvent = cached(function (name) { - var passive = name.charAt(0) === '&'; - name = passive ? name.slice(1) : name; - var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first - name = once$$1 ? name.slice(1) : name; - var capture = name.charAt(0) === '!'; - name = capture ? name.slice(1) : name; - return { - name: name, - once: once$$1, - capture: capture, - passive: passive - } - }); - - function createFnInvoker (fns, vm) { - function invoker () { - var arguments$1 = arguments; - - var fns = invoker.fns; - if (Array.isArray(fns)) { - var cloned = fns.slice(); - for (var i = 0; i < cloned.length; i++) { - invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler"); - } - } else { - // return handler return value for single handlers - return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler") - } - } - invoker.fns = fns; - return invoker - } - - function updateListeners ( - on, - oldOn, - add, - remove$$1, - createOnceHandler, - vm - ) { - var name, def$$1, cur, old, event; - for (name in on) { - def$$1 = cur = on[name]; - old = oldOn[name]; - event = normalizeEvent(name); - if (isUndef(cur)) { - warn( - "Invalid handler for event \"" + (event.name) + "\": got " + String(cur), - vm - ); - } else if (isUndef(old)) { - if (isUndef(cur.fns)) { - cur = on[name] = createFnInvoker(cur, vm); - } - if (isTrue(event.once)) { - cur = on[name] = createOnceHandler(event.name, cur, event.capture); - } - add(event.name, cur, event.capture, event.passive, event.params); - } else if (cur !== old) { - old.fns = cur; - on[name] = old; - } - } - for (name in oldOn) { - if (isUndef(on[name])) { - event = normalizeEvent(name); - remove$$1(event.name, oldOn[name], event.capture); - } - } - } - - /* */ - - function mergeVNodeHook (def, hookKey, hook) { - if (def instanceof VNode) { - def = def.data.hook || (def.data.hook = {}); - } - var invoker; - var oldHook = def[hookKey]; - - function wrappedHook () { - hook.apply(this, arguments); - // important: remove merged hook to ensure it's called only once - // and prevent memory leak - remove(invoker.fns, wrappedHook); - } - - if (isUndef(oldHook)) { - // no existing hook - invoker = createFnInvoker([wrappedHook]); - } else { - /* istanbul ignore if */ - if (isDef(oldHook.fns) && isTrue(oldHook.merged)) { - // already a merged invoker - invoker = oldHook; - invoker.fns.push(wrappedHook); - } else { - // existing plain hook - invoker = createFnInvoker([oldHook, wrappedHook]); - } - } - - invoker.merged = true; - def[hookKey] = invoker; - } - - /* */ - - function extractPropsFromVNodeData ( - data, - Ctor, - tag - ) { - // we are only extracting raw values here. - // validation and default values are handled in the child - // component itself. - var propOptions = Ctor.options.props; - if (isUndef(propOptions)) { - return - } - var res = {}; - var attrs = data.attrs; - var props = data.props; - if (isDef(attrs) || isDef(props)) { - for (var key in propOptions) { - var altKey = hyphenate(key); - { - var keyInLowerCase = key.toLowerCase(); - if ( - key !== keyInLowerCase && - attrs && hasOwn(attrs, keyInLowerCase) - ) { - tip( - "Prop \"" + keyInLowerCase + "\" is passed to component " + - (formatComponentName(tag || Ctor)) + ", but the declared prop name is" + - " \"" + key + "\". " + - "Note that HTML attributes are case-insensitive and camelCased " + - "props need to use their kebab-case equivalents when using in-DOM " + - "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"." - ); - } - } - checkProp(res, props, key, altKey, true) || - checkProp(res, attrs, key, altKey, false); - } - } - return res - } - - function checkProp ( - res, - hash, - key, - altKey, - preserve - ) { - if (isDef(hash)) { - if (hasOwn(hash, key)) { - res[key] = hash[key]; - if (!preserve) { - delete hash[key]; - } - return true - } else if (hasOwn(hash, altKey)) { - res[key] = hash[altKey]; - if (!preserve) { - delete hash[altKey]; - } - return true - } - } - return false - } - - /* */ - - // The template compiler attempts to minimize the need for normalization by - // statically analyzing the template at compile time. - // - // For plain HTML markup, normalization can be completely skipped because the - // generated render function is guaranteed to return Array. There are - // two cases where extra normalization is needed: - - // 1. When the children contains components - because a functional component - // may return an Array instead of a single root. In this case, just a simple - // normalization is needed - if any child is an Array, we flatten the whole - // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep - // because functional components already normalize their own children. - function simpleNormalizeChildren (children) { - for (var i = 0; i < children.length; i++) { - if (Array.isArray(children[i])) { - return Array.prototype.concat.apply([], children) - } - } - return children - } - - // 2. When the children contains constructs that always generated nested Arrays, - // e.g.