solve-engine 2.32.0 → 2.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{EngineError-CqGtaT_v.d.cts → EngineError-Bm4OYmw8.d.cts} +6 -0
- package/dist/{EngineError-CqGtaT_v.d.ts → EngineError-Bm4OYmw8.d.ts} +6 -0
- package/dist/{Lexer-CqFjYoRA.d.ts → Lexer-DPn5dfCH.d.ts} +1 -13
- package/dist/{Lexer-sCI05tqO.d.cts → Lexer-DaWkCu84.d.cts} +1 -13
- package/dist/{PackageCompatibility-phvSFP4f.d.ts → PackageCompatibility-CkzZfoJ3.d.ts} +1 -1
- package/dist/{PackageCompatibility-Bn-T_xKW.d.cts → PackageCompatibility-E_5GtcQW.d.cts} +1 -1
- package/dist/{PackageRegistry-C78jVkI9.d.ts → PackageRegistry-DSqic8kz.d.ts} +132 -23
- package/dist/{PackageRegistry-B-C1duZw.d.cts → PackageRegistry-js47hr28.d.cts} +132 -23
- package/dist/{Parselet-Dgymjxzd.d.ts → Parselet-CQjcHOKw.d.ts} +13 -6
- package/dist/{Parselet-DF3864la.d.cts → Parselet-s1sRRn8H.d.cts} +13 -6
- package/dist/{TokenNormalizer-Pe3_390t.d.cts → TokenNormalizer-D382VSYh.d.cts} +4 -1
- package/dist/{TokenNormalizer-IF7nPRMp.d.ts → TokenNormalizer-DAzPp-j1.d.ts} +4 -1
- package/dist/{VMBuiltins-BkKzhj6C.d.cts → VMBuiltins-JCavlQUj.d.cts} +53 -18
- package/dist/{VMBuiltins-Du9y8sEo.d.ts → VMBuiltins-qgzA6qGi.d.ts} +53 -18
- package/dist/{VMCheckpoints-WdUQrdc9.d.cts → VMCheckpoints-BxPzmdu0.d.cts} +2 -2
- package/dist/{VMCheckpoints-gvy_yxYh.d.ts → VMCheckpoints-DjjE92mf.d.ts} +2 -2
- package/dist/{Value-BYHw-x7q.d.cts → Value-2TIKi-YL.d.cts} +19 -0
- package/dist/{Value-BYHw-x7q.d.ts → Value-2TIKi-YL.d.ts} +19 -0
- package/dist/{WorkerError-DTrl3Jag.d.ts → WorkerError-BaN8_eok.d.ts} +1 -1
- package/dist/{WorkerError-CRoM8Ju1.d.cts → WorkerError-CexHHmbb.d.cts} +1 -1
- package/dist/{chunk-AGCNMEP2.cjs → chunk-3MG7VIPL.cjs} +2 -2
- package/dist/{chunk-AGCNMEP2.cjs.map → chunk-3MG7VIPL.cjs.map} +1 -1
- package/dist/chunk-4ASM522I.js +2 -0
- package/dist/chunk-4ASM522I.js.map +1 -0
- package/dist/chunk-4M3FZRGL.cjs +5 -0
- package/dist/chunk-4M3FZRGL.cjs.map +1 -0
- package/dist/{chunk-KH4QXKLT.js → chunk-4MD5L23F.js} +2 -2
- package/dist/{chunk-KH4QXKLT.js.map → chunk-4MD5L23F.js.map} +1 -1
- package/dist/{chunk-IQVSCL2R.js → chunk-4XWZXP6I.js} +3 -3
- package/dist/{chunk-IQVSCL2R.js.map → chunk-4XWZXP6I.js.map} +1 -1
- package/dist/{chunk-AXTYQFIV.cjs → chunk-6DCSGINN.cjs} +3 -3
- package/dist/{chunk-AXTYQFIV.cjs.map → chunk-6DCSGINN.cjs.map} +1 -1
- package/dist/{chunk-RELMEWY6.js → chunk-6G2NES2I.js} +2 -2
- package/dist/chunk-6G2NES2I.js.map +1 -0
- package/dist/{chunk-CDE2ZUGG.js → chunk-6NL7RBAG.js} +2 -2
- package/dist/{chunk-CDE2ZUGG.js.map → chunk-6NL7RBAG.js.map} +1 -1
- package/dist/{chunk-SUAGBRQ7.cjs → chunk-6SYU4MH7.cjs} +2 -2
- package/dist/chunk-6SYU4MH7.cjs.map +1 -0
- package/dist/chunk-72J5V7SN.cjs +2 -0
- package/dist/chunk-72J5V7SN.cjs.map +1 -0
- package/dist/chunk-7CRVRPV7.cjs +3 -0
- package/dist/chunk-7CRVRPV7.cjs.map +1 -0
- package/dist/chunk-ADK7LGYN.js +5 -0
- package/dist/chunk-ADK7LGYN.js.map +1 -0
- package/dist/chunk-APYRNAU2.js +2 -0
- package/dist/chunk-APYRNAU2.js.map +1 -0
- package/dist/{chunk-IJE4AEDX.js → chunk-D55NMAGM.js} +3 -3
- package/dist/{chunk-IJE4AEDX.js.map → chunk-D55NMAGM.js.map} +1 -1
- package/dist/chunk-DB5ISONG.js +2 -0
- package/dist/chunk-DB5ISONG.js.map +1 -0
- package/dist/chunk-EOKHRS2T.js +2 -0
- package/dist/chunk-EOKHRS2T.js.map +1 -0
- package/dist/{chunk-NQFCXLEF.js → chunk-EOO6M65F.js} +2 -2
- package/dist/{chunk-NQFCXLEF.js.map → chunk-EOO6M65F.js.map} +1 -1
- package/dist/{chunk-A764BY7L.cjs → chunk-EQNKDTMX.cjs} +2 -2
- package/dist/{chunk-A764BY7L.cjs.map → chunk-EQNKDTMX.cjs.map} +1 -1
- package/dist/chunk-FESR6PZI.cjs +2 -0
- package/dist/chunk-FESR6PZI.cjs.map +1 -0
- package/dist/chunk-G5TZ6TDA.js +2 -0
- package/dist/chunk-G5TZ6TDA.js.map +1 -0
- package/dist/chunk-GDLYXRMA.cjs +2 -0
- package/dist/chunk-GDLYXRMA.cjs.map +1 -0
- package/dist/chunk-HOU7QTE7.js +3 -0
- package/dist/chunk-HOU7QTE7.js.map +1 -0
- package/dist/{chunk-CAJTDZ5B.cjs → chunk-HPV4CKCC.cjs} +2 -2
- package/dist/{chunk-CAJTDZ5B.cjs.map → chunk-HPV4CKCC.cjs.map} +1 -1
- package/dist/{chunk-7DJYS5PO.cjs → chunk-HSTGWWU2.cjs} +2 -2
- package/dist/{chunk-7DJYS5PO.cjs.map → chunk-HSTGWWU2.cjs.map} +1 -1
- package/dist/{chunk-OE2DBN4K.js → chunk-INMJ7ZXL.js} +2 -2
- package/dist/chunk-INMJ7ZXL.js.map +1 -0
- package/dist/{chunk-TSJ4RQLZ.js → chunk-J3YC3IQD.js} +2 -2
- package/dist/{chunk-TSJ4RQLZ.js.map → chunk-J3YC3IQD.js.map} +1 -1
- package/dist/{chunk-5AKT36UK.cjs → chunk-K3PZ66XR.cjs} +2 -2
- package/dist/{chunk-5AKT36UK.cjs.map → chunk-K3PZ66XR.cjs.map} +1 -1
- package/dist/chunk-LI6LYJDA.cjs +2 -0
- package/dist/chunk-LI6LYJDA.cjs.map +1 -0
- package/dist/{chunk-WQGHJAW2.cjs → chunk-M4UC2PB6.cjs} +2 -2
- package/dist/{chunk-WQGHJAW2.cjs.map → chunk-M4UC2PB6.cjs.map} +1 -1
- package/dist/chunk-O7HF345B.js +2 -0
- package/dist/chunk-O7HF345B.js.map +1 -0
- package/dist/{chunk-CM2WM5CM.cjs → chunk-OBZJKZ2F.cjs} +2 -2
- package/dist/{chunk-CM2WM5CM.cjs.map → chunk-OBZJKZ2F.cjs.map} +1 -1
- package/dist/{chunk-Q7TBBV62.cjs → chunk-P5YWBIIU.cjs} +2 -2
- package/dist/chunk-P5YWBIIU.cjs.map +1 -0
- package/dist/chunk-PICFFFJV.js +3 -0
- package/dist/chunk-PICFFFJV.js.map +1 -0
- package/dist/{chunk-P43SV4NJ.cjs → chunk-QOOTRUY7.cjs} +3 -3
- package/dist/{chunk-P43SV4NJ.cjs.map → chunk-QOOTRUY7.cjs.map} +1 -1
- package/dist/chunk-R3W53ZMP.cjs +2 -0
- package/dist/chunk-R3W53ZMP.cjs.map +1 -0
- package/dist/chunk-RMDCGYZM.js +2 -0
- package/dist/chunk-RMDCGYZM.js.map +1 -0
- package/dist/{chunk-CB3EXUM2.js → chunk-RU3KGJRA.js} +2 -2
- package/dist/chunk-RU3KGJRA.js.map +1 -0
- package/dist/chunk-S3SPDK6N.cjs +2 -0
- package/dist/chunk-S3SPDK6N.cjs.map +1 -0
- package/dist/chunk-SF5QVUEI.cjs +3 -0
- package/dist/chunk-SF5QVUEI.cjs.map +1 -0
- package/dist/{chunk-FXB5GCBT.js → chunk-TJKN466F.js} +2 -2
- package/dist/{chunk-FXB5GCBT.js.map → chunk-TJKN466F.js.map} +1 -1
- package/dist/{chunk-VLX7ZVK4.js → chunk-U5MESNRT.js} +2 -2
- package/dist/{chunk-VLX7ZVK4.js.map → chunk-U5MESNRT.js.map} +1 -1
- package/dist/{chunk-YWF6C2IO.cjs → chunk-WFT3XUSH.cjs} +2 -2
- package/dist/{chunk-YWF6C2IO.cjs.map → chunk-WFT3XUSH.cjs.map} +1 -1
- package/dist/{chunk-3ZGFAE3Q.js → chunk-X2GQAKL2.js} +2 -2
- package/dist/{chunk-3ZGFAE3Q.js.map → chunk-X2GQAKL2.js.map} +1 -1
- package/dist/{chunk-G3POUURF.js → chunk-YID47OPR.js} +2 -2
- package/dist/{chunk-G3POUURF.js.map → chunk-YID47OPR.js.map} +1 -1
- package/dist/chunk-YV4GDW5A.cjs +2 -0
- package/dist/chunk-YV4GDW5A.cjs.map +1 -0
- package/dist/chunk-ZSXQP7PD.cjs +2 -0
- package/dist/chunk-ZSXQP7PD.cjs.map +1 -0
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/engine.cjs +1 -1
- package/dist/engine.d.cts +10 -10
- package/dist/engine.d.ts +10 -10
- package/dist/engine.js +1 -1
- package/dist/engine.worker.cjs +1 -1
- package/dist/engine.worker.cjs.map +1 -1
- package/dist/engine.worker.js +1 -1
- package/dist/engine.worker.js.map +1 -1
- package/dist/errors.cjs +1 -1
- package/dist/errors.d.cts +3 -3
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +1 -1
- package/dist/format.cjs +1 -1
- package/dist/format.d.cts +1 -1
- package/dist/format.d.ts +1 -1
- package/dist/format.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/language.d.cts +9 -9
- package/dist/language.d.ts +9 -9
- package/dist/lexer.cjs +1 -1
- package/dist/lexer.d.cts +3 -3
- package/dist/lexer.d.ts +3 -3
- package/dist/lexer.js +1 -1
- package/dist/normalizer.cjs +1 -1
- package/dist/normalizer.d.cts +2 -2
- package/dist/normalizer.d.ts +2 -2
- package/dist/normalizer.js +1 -1
- package/dist/packages.cjs +1 -1
- package/dist/packages.d.cts +8 -8
- package/dist/packages.d.ts +8 -8
- package/dist/packages.js +1 -1
- package/dist/parser.cjs +1 -1
- package/dist/parser.d.cts +3 -3
- package/dist/parser.d.ts +3 -3
- package/dist/parser.js +1 -1
- package/dist/{pipeline-BYkKNpql.d.cts → pipeline-Bum6y1B9.d.cts} +1 -1
- package/dist/{pipeline-Cl7KW8CB.d.ts → pipeline-DOo3KHaq.d.ts} +1 -1
- package/dist/resolvers.cjs +1 -1
- package/dist/resolvers.d.cts +69 -3
- package/dist/resolvers.d.ts +69 -3
- package/dist/resolvers.js +1 -1
- package/dist/temporal.cjs +1 -1
- package/dist/temporal.js +1 -1
- package/dist/testing.cjs +2 -2
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +9 -9
- package/dist/testing.d.ts +9 -9
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/uom.cjs +1 -1
- package/dist/uom.d.cts +35 -2
- package/dist/uom.d.ts +35 -2
- package/dist/uom.js +1 -1
- package/dist/vm.cjs +1 -1
- package/dist/vm.d.cts +6 -6
- package/dist/vm.d.ts +6 -6
- package/dist/vm.js +1 -1
- package/dist/worker.cjs +2 -2
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +9 -9
- package/dist/worker.d.ts +9 -9
- package/dist/worker.js +1 -1
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-4DR5RBHQ.cjs +0 -2
- package/dist/chunk-4DR5RBHQ.cjs.map +0 -1
- package/dist/chunk-4IC5OARK.js +0 -3
- package/dist/chunk-4IC5OARK.js.map +0 -1
- package/dist/chunk-7ODHPWQC.js +0 -5
- package/dist/chunk-7ODHPWQC.js.map +0 -1
- package/dist/chunk-A755LVPT.cjs +0 -2
- package/dist/chunk-A755LVPT.cjs.map +0 -1
- package/dist/chunk-AF6NDOIE.js +0 -2
- package/dist/chunk-AF6NDOIE.js.map +0 -1
- package/dist/chunk-B2NL65FI.js +0 -2
- package/dist/chunk-B2NL65FI.js.map +0 -1
- package/dist/chunk-CB3EXUM2.js.map +0 -1
- package/dist/chunk-DUFEONVN.cjs +0 -3
- package/dist/chunk-DUFEONVN.cjs.map +0 -1
- package/dist/chunk-IJHL3LMH.js +0 -2
- package/dist/chunk-IJHL3LMH.js.map +0 -1
- package/dist/chunk-LCYQQFUH.cjs +0 -2
- package/dist/chunk-LCYQQFUH.cjs.map +0 -1
- package/dist/chunk-LP3JYC3A.js +0 -2
- package/dist/chunk-LP3JYC3A.js.map +0 -1
- package/dist/chunk-OE2DBN4K.js.map +0 -1
- package/dist/chunk-OKKGPINQ.cjs +0 -5
- package/dist/chunk-OKKGPINQ.cjs.map +0 -1
- package/dist/chunk-OM7NOHJF.cjs +0 -2
- package/dist/chunk-OM7NOHJF.cjs.map +0 -1
- package/dist/chunk-PTXUWGRR.js +0 -3
- package/dist/chunk-PTXUWGRR.js.map +0 -1
- package/dist/chunk-Q7TBBV62.cjs.map +0 -1
- package/dist/chunk-RELMEWY6.js.map +0 -1
- package/dist/chunk-SFM4XFGJ.js +0 -2
- package/dist/chunk-SFM4XFGJ.js.map +0 -1
- package/dist/chunk-SRAU3BLV.cjs +0 -3
- package/dist/chunk-SRAU3BLV.cjs.map +0 -1
- package/dist/chunk-SUAGBRQ7.cjs.map +0 -1
- package/dist/chunk-UNKZ5XRC.cjs +0 -2
- package/dist/chunk-UNKZ5XRC.cjs.map +0 -1
- package/dist/chunk-WU7SBKVU.cjs +0 -2
- package/dist/chunk-WU7SBKVU.cjs.map +0 -1
- package/dist/chunk-X5K72MBV.js +0 -2
- package/dist/chunk-X5K72MBV.js.map +0 -1
- package/dist/chunk-ZVPZQ66D.cjs +0 -2
- package/dist/chunk-ZVPZQ66D.cjs.map +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var chunkTLG7VZRX_cjs=require('./chunk-TLG7VZRX.cjs'),chunk6SYU4MH7_cjs=require('./chunk-6SYU4MH7.cjs');var A=new Set(["AED","AFN","ALL","AMD","ANG","AOA","ARS","AUD","AWG","AZN","BAM","BBD","BDT","BGN","BHD","BIF","BMD","BND","BOB","BOV","BRL","BSD","BTN","BWP","BYN","BZD","CAD","CDF","CHE","CHF","CHW","CLF","CLP","CNY","COP","COU","CRC","CUP","CVE","CZK","DJF","DKK","DOP","DZD","EGP","ERN","ETB","EUR","FJD","FKP","GBP","GEL","GHS","GIP","GMD","GNF","GTQ","GYD","HKD","HNL","HTG","HUF","IDR","ILS","INR","IQD","IRR","ISK","JMD","JOD","JPY","KES","KGS","KHR","KMF","KPW","KRW","KWD","KYD","KZT","LAK","LBP","LKR","LRD","LSL","LYD","MAD","MDL","MGA","MKD","MMK","MNT","MOP","MRU","MUR","MVR","MWK","MXN","MXV","MYR","MZN","NAD","NGN","NIO","NOK","NPR","NZD","OMR","PAB","PEN","PGK","PHP","PKR","PLN","PYG","QAR","RON","RSD","RUB","RWF","SAR","SBD","SCR","SDG","SEK","SGD","SHP","SLE","SOS","SRD","SSP","STN","SVC","SYP","SZL","THB","TJS","TMT","TND","TOP","TRY","TTD","TWD","TZS","UAH","UGX","USD","USN","UYI","UYU","UYW","UZS","VED","VES","VND","VUV","WST","XAF","XCD","XCG","XOF","XPF","YER","ZAR","ZMW","ZWG"]);function O(P){return A.has(P.toUpperCase())}var S={API_ERROR:"CURRENCY_API_ERROR",UNKNOWN_CODE:"UNKNOWN_CURRENCY_CODE",CRYPTO_API_ERROR:"CRYPTO_PRICE_API_ERROR"},o=class o{constructor(){this.baseTables=new Map;this.currencyAnswers=new Map;}isCryptoCode(t){return Object.prototype.hasOwnProperty.call(o.CRYPTO_IDS,t.toUpperCase())}async getRate(t,e,n){let r=t.toUpperCase(),s=e.toUpperCase();if(this.isCryptoCode(r)||this.isCryptoCode(s))return this.getCryptoRate(r,s,n);let{signal:u,cleanup:l}=chunkTLG7VZRX_cjs.a(n,o.FETCH_TIMEOUT_MS,"Currency API fetch");try{let R=new URLSearchParams({base:r}),i=await fetch(`https://api.frankfurter.dev/v2/rates?${R.toString()}`,{signal:u});if(!i.ok)throw chunk6SYU4MH7_cjs.c.external(S.API_ERROR,`Currency API returned ${i.status}`,{status:i.status});let c=await i.json(),C=Array.isArray(c)?Object.fromEntries(c.filter(a=>{if(typeof a!="object"||a===null)return !1;let d=a;return typeof d.quote=="string"&&typeof d.rate=="number"}).map(a=>[a.quote.toUpperCase(),a.rate])):c.rates??{};if(C[s]===void 0)throw chunk6SYU4MH7_cjs.c.validation(S.UNKNOWN_CODE,`Unknown currency: ${s}`,{code:s});return this.baseTables.set(r,{fetchedAt:Date.now(),rates:{...C,[r]:1}}),C[s]}finally{l();}}async getCryptoRate(t,e,n){let{signal:r,cleanup:s}=chunkTLG7VZRX_cjs.a(n,o.FETCH_TIMEOUT_MS,"Crypto price API fetch");try{let u=this.isCryptoCode(t),l=this.isCryptoCode(e),R;if(u&&l){let i=o.CRYPTO_IDS[t],c=o.CRYPTO_IDS[e],C=await this.fetchCoinGeckoPrices([i,c],"usd",r),a=C[i]?.usd,d=C[c]?.usd;if(typeof a!="number")throw chunk6SYU4MH7_cjs.c.validation(S.UNKNOWN_CODE,`Unknown currency: ${t}`,{code:t});if(typeof d!="number")throw chunk6SYU4MH7_cjs.c.validation(S.UNKNOWN_CODE,`Unknown currency: ${e}`,{code:e});R=a/d;}else if(u){let i=o.CRYPTO_IDS[t],c=e.toLowerCase(),a=(await this.fetchCoinGeckoPrices([i],c,r))[i]?.[c];if(typeof a!="number")throw chunk6SYU4MH7_cjs.c.validation(S.UNKNOWN_CODE,`Unknown currency: ${e}`,{code:e});R=a;}else {let i=o.CRYPTO_IDS[e],c=t.toLowerCase(),a=(await this.fetchCoinGeckoPrices([i],c,r))[i]?.[c];if(typeof a!="number")throw chunk6SYU4MH7_cjs.c.validation(S.UNKNOWN_CODE,`Unknown currency: ${t}`,{code:t});R=1/a;}return this.baseTables.set(t,{fetchedAt:Date.now(),rates:{[t]:1,[e]:R}}),R}finally{s();}}async fetchCoinGeckoPrices(t,e,n){let r=new URLSearchParams({ids:t.join(","),vs_currencies:e}),s=await fetch(`https://api.coingecko.com/api/v3/simple/price?${r.toString()}`,{signal:n});if(!s.ok)throw chunk6SYU4MH7_cjs.c.external(S.CRYPTO_API_ERROR,`Crypto price API returned ${s.status}`,{status:s.status});return s.json()}primeRates(t,e){let n=t.toUpperCase();this.baseTables.set(n,{fetchedAt:Date.now(),rates:{...e,[n]:1}});}clearRates(){this.baseTables.clear();}getRateSync(t,e){let n=t.toUpperCase(),r=e.toUpperCase();if(n===r)return 1;let s=Date.now();for(let u of this.baseTables.values()){if(s-u.fetchedAt>o.RATE_FRESHNESS_MS)continue;let l=u.rates[n],R=u.rates[r];if(l&&R)return R/l}return null}async convert(t,e,n){let r=await this.getRate(e,n);return t*r}getAllRates(){let t=Date.now(),e={},n=false;for(let[r,s]of this.baseTables)if(!(t-s.fetchedAt>o.RATE_FRESHNESS_MS))for(let[u,l]of Object.entries(s.rates))e[`${r}:${u}`]=l,n=true;return n?e:null}hasRates(){return this.getAllRates()!==null}convertSync(t,e,n){let r=this.getRateSync(e,n);return r===null?null:t*r}isCurrency(t){let e=t.length;if(e<3||e>4)return false;let n=this.currencyAnswers.get(t);if(n!==void 0)return n;let r=O(t)||this.isCryptoCode(t);return this.currencyAnswers.size>=o.MAX_REMEMBERED_CODES&&this.currencyAnswers.clear(),this.currencyAnswers.set(t,r),r}};o.RATE_FRESHNESS_MS=900*1e3,o.CRYPTO_IDS={BTC:"bitcoin",ETH:"ethereum",SOL:"solana",XRP:"ripple",ADA:"cardano",DOGE:"dogecoin",DOT:"polkadot"},o.MAX_REMEMBERED_CODES=4096,o.FETCH_TIMEOUT_MS=1e4;var E=o,p=new E,T=p;
|
|
2
|
+
exports.a=E;exports.b=p;exports.c=T;//# sourceMappingURL=chunk-SF5QVUEI.cjs.map
|
|
3
|
+
//# sourceMappingURL=chunk-SF5QVUEI.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/uom/Iso4217.ts","../src/uom/CurrencyExchange.ts"],"names":["ISO_4217_CODES","isIso4217","code","CurrencyErrorCodes","_CurrencyExchangeService","from","to","signal","fromUpper","toUpper","fetchSignal","cleanup","createTimeoutSignal","query","response","ErrorFactory","data","rates","entry","candidate","fromIsCrypto","toIsCrypto","rate","fromId","toId","fromUsd","toUsd","vs","value","priceOfToInFrom","ids","vsCurrency","base","baseUpper","now","table","fromRate","toRate","snapshot","any","length","remembered","answer","CurrencyExchangeService","currencyExchangeService","sharedCurrencyExchange"],"mappings":"qHAyBO,IAAMA,CAAAA,CAAsC,IAAI,GAAA,CAAI,CAC1D,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,MAC/D,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAC/D,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,MAAO,KAAA,CACnC,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAC/D,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CACrB,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CACrB,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CACrB,KAAA,CAAO,KAAA,CACP,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,MAAO,KAAA,CAAO,KAAA,CACjD,KAAA,CAAO,KAAA,CAAO,KAAA,CAAO,KAAA,CACrB,KAAA,CAAO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Content":["/**\n * Every active ISO 4217 currency code.\n *\n * This exists because `CurrencyExchange.isCurrency()` used to hold a\n * hand-written list of forty-six codes, and a code missing from it did not\n * error: `$100 in UAH` returned the original hundred dollars, unconverted, as\n * though the rate were 1. A wrong answer, not a missing feature.\n *\n * The list is the ISO 4217 active set, so \"is this a currency\" is answered by\n * the standard rather than by whichever codes happened to get added. Whether a\n * *rate* is available for one is a separate question, answered at resolution\n * time by whatever the exchange provider supports; conflating the two is what\n * produced the silent failure.\n *\n * Deliberately excluded:\n * - The historical/withdrawn codes (DEM, FRF, and the rest). They are not\n * active, no provider quotes them, and recognising them would only move the\n * failure later.\n * - The X-series non-currencies: XAU/XAG/XPT/XPD (metals), XDR (IMF special\n * drawing rights), XTS (reserved for testing) and XXX (explicitly \"no\n * currency\"). XXX in particular must never resolve.\n *\n * Cryptocurrencies are not here either. They are not ISO 4217 and are tracked\n * separately in `CurrencyExchangeService.CRYPTO_IDS`.\n */\nexport const ISO_4217_CODES: ReadonlySet<string> = new Set([\n\t\"AED\", \"AFN\", \"ALL\", \"AMD\", \"ANG\", \"AOA\", \"ARS\", \"AUD\", \"AWG\", \"AZN\",\n\t\"BAM\", \"BBD\", \"BDT\", \"BGN\", \"BHD\", \"BIF\", \"BMD\", \"BND\", \"BOB\", \"BOV\",\n\t\"BRL\", \"BSD\", \"BTN\", \"BWP\", \"BYN\", \"BZD\",\n\t\"CAD\", \"CDF\", \"CHE\", \"CHF\", \"CHW\", \"CLF\", \"CLP\", \"CNY\", \"COP\", \"COU\",\n\t\"CRC\", \"CUP\", \"CVE\", \"CZK\",\n\t\"DJF\", \"DKK\", \"DOP\", \"DZD\",\n\t\"EGP\", \"ERN\", \"ETB\", \"EUR\",\n\t\"FJD\", \"FKP\",\n\t\"GBP\", \"GEL\", \"GHS\", \"GIP\", \"GMD\", \"GNF\", \"GTQ\", \"GYD\",\n\t\"HKD\", \"HNL\", \"HTG\", \"HUF\",\n\t\"IDR\", \"ILS\", \"INR\", \"IQD\", \"IRR\", \"ISK\",\n\t\"JMD\", \"JOD\", \"JPY\",\n\t\"KES\", \"KGS\", \"KHR\", \"KMF\", \"KPW\", \"KRW\", \"KWD\", \"KYD\", \"KZT\",\n\t\"LAK\", \"LBP\", \"LKR\", \"LRD\", \"LSL\", \"LYD\",\n\t\"MAD\", \"MDL\", \"MGA\", \"MKD\", \"MMK\", \"MNT\", \"MOP\", \"MRU\", \"MUR\", \"MVR\",\n\t\"MWK\", \"MXN\", \"MXV\", \"MYR\", \"MZN\",\n\t\"NAD\", \"NGN\", \"NIO\", \"NOK\", \"NPR\", \"NZD\",\n\t\"OMR\",\n\t\"PAB\", \"PEN\", \"PGK\", \"PHP\", \"PKR\", \"PLN\", \"PYG\",\n\t\"QAR\",\n\t\"RON\", \"RSD\", \"RUB\", \"RWF\",\n\t\"SAR\", \"SBD\", \"SCR\", \"SDG\", \"SEK\", \"SGD\", \"SHP\", \"SLE\", \"SOS\", \"SRD\",\n\t\"SSP\", \"STN\", \"SVC\", \"SYP\", \"SZL\",\n\t\"THB\", \"TJS\", \"TMT\", \"TND\", \"TOP\", \"TRY\", \"TTD\", \"TWD\", \"TZS\",\n\t\"UAH\", \"UGX\", \"USD\", \"USN\", \"UYI\", \"UYU\", \"UYW\", \"UZS\",\n\t\"VED\", \"VES\", \"VND\", \"VUV\",\n\t\"WST\",\n\t\"XAF\", \"XCD\", \"XCG\", \"XOF\", \"XPF\",\n\t\"YER\",\n\t\"ZAR\", \"ZMW\", \"ZWG\",\n]);\n\n/**\n * Whether `code` is an active ISO 4217 currency code.\n *\n * @param code - A three-letter code, in any case.\n */\nexport function isIso4217(code: string): boolean {\n\treturn ISO_4217_CODES.has(code.toUpperCase());\n}\n","/**\n * Production-grade currency exchange service with scalable architecture\n * Integrates with DataQueryService for worker-based execution\n */\n\nimport { isIso4217 } from \"@solve-js/uom/Iso4217\";\nimport { createTimeoutSignal } from \"@solve-js/utilities/TimeoutSignal\";\nimport { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\n\n/**\n * Error codes for this service. Co-located rather than unioned into\n * `errors/ErrorCode.ts`'s core catalog (that catalog is scoped to the\n * parser/VM/engine/errors/config/lexer layers, not yet the ~17 domain\n * packages. See that file's module doc for the intended per-package\n * pattern this follows).\n */\nexport const CurrencyErrorCodes = {\n /** Frankfurter's rates endpoint returned a non-OK HTTP status. */\n API_ERROR: \"CURRENCY_API_ERROR\",\n /** A requested currency/crypto code isn't in the fetched rate table, an unrecognized code, not an API failure. */\n UNKNOWN_CODE: \"UNKNOWN_CURRENCY_CODE\",\n /** CoinGecko's simple-price endpoint returned a non-OK HTTP status. */\n CRYPTO_API_ERROR: \"CRYPTO_PRICE_API_ERROR\",\n} as const;\n\n// ============================================================================\n// CURRENCY EXCHANGE SERVICE\n// ============================================================================\n\n/**\n * Caches exchange rates fetched from an external source.\n *\n * Rates are global market data rather than per-engine configuration, which is\n * why one instance is shared. Two engines with private copies would fetch the\n * same endpoint twice and could disagree about one pair at one moment. See\n * `engine/EngineContext.ts`.\n */\nexport class CurrencyExchangeService {\n /**\n * Live rate tables cached from successful getRate() fetches, keyed by\n * uppercase base currency. Each table holds every rate the API returned\n * for that base (plus the base itself at 1), so any pair whose two codes\n * appear in one fresh table can be served synchronously, including\n * cross pairs via triangulation (EUR→GBP through a USD-base table).\n * Stale tables are ignored, not evicted; the next successful fetch for\n * the same base overwrites them.\n */\n private baseTables: Map<string, { fetchedAt: number; rates: Record<string, number> }> = new Map();\n\n /**\n * How long a fetched rate may be served synchronously by getRateSync().\n * Beyond this window callers fall through to the async path (expression\n * shows Pending until the fetch lands).\n */\n private static readonly RATE_FRESHNESS_MS = 15 * 60 * 1000;\n\n /**\n * Ticker → CoinGecko coin id, for the cryptocurrencies `isCurrency()`\n * recognizes. Frankfurter (the fiat rate source below) is ECB reference\n * rates only and has no concept of BTC/ETH/etc, routing a crypto code\n * through it as `base=BTC` fails outright, which is why crypto pairs\n * previously never resolved (see CurrencyAsyncResolver/VM.ts's ADD\n * handling for the two bugs that let that failure pass silently instead\n * of surfacing as a real fetch).\n */\n private static readonly CRYPTO_IDS: Record<string, string> = {\n BTC: \"bitcoin\", ETH: \"ethereum\", SOL: \"solana\", XRP: \"ripple\",\n ADA: \"cardano\", DOGE: \"dogecoin\", DOT: \"polkadot\",\n };\n\n private isCryptoCode(code: string): boolean {\n // An own-property check, not `in`: `in` also answers for everything on\n // Object.prototype, so a code spelt like an inherited name would pass.\n return Object.prototype.hasOwnProperty.call(CurrencyExchangeService.CRYPTO_IDS, code.toUpperCase());\n }\n\n /**\n * Remembered {@link isCurrency} answers, keyed by the spelling asked about.\n *\n * The VM asks this question on every unit-bearing instruction (a `UOM_CONVERT`\n * for `5 kg`, a `MUL` of money by a count, a `DIV` of two quantities), and each\n * ask used to upper-case the code twice and probe two tables. The answer never\n * changes for a given spelling: the ISO 4217 set and {@link CRYPTO_IDS} are\n * both fixed for the life of the process, so remembering it is safe and the\n * ask becomes one map read. Keyed by the raw spelling rather than its\n * upper-cased form so the hot path allocates nothing.\n */\n private readonly currencyAnswers = new Map<string, boolean>();\n\n /**\n * How many spellings the cache will hold before it is emptied.\n *\n * A document's unit vocabulary is small and closed, so an ordinary run never\n * comes near this. The bound exists for the public `./vm` surface, where a\n * host can hand `UOM_CONVERT` any string it likes; emptying rather than\n * evicting keeps the miss path free of bookkeeping.\n */\n private static readonly MAX_REMEMBERED_CODES = 4096;\n\n constructor() {}\n\n // ------------------------------------------------------------------------\n // RATE FETCHING\n // ------------------------------------------------------------------------\n\n /**\n * Timeout (ms) for currency exchange rate fetches.\n *\n * If the frankfurter API doesn't respond within this window, the fetch\n * is aborted, preventing indefinite \"Pending\" states in the playground\n * and Obsidian plugin when the exchange rate API is unreachable.\n */\n private static readonly FETCH_TIMEOUT_MS = 10_000;\n\n /**\n * Fetch the live exchange rate for converting 1 unit of `from` into `to`.\n *\n * Routes cryptocurrency codes (see {@link CRYPTO_IDS}) to CoinGecko and\n * everything else to Frankfurter (ECB reference rates, fiat-only). On\n * success, caches the whole returned rate table for `from` so subsequent\n * lookups, including cross-pairs via triangulation, can be served\n * synchronously by {@link getRateSync} within the freshness window.\n *\n * @throws If the currency code is unrecognized or the fetch fails/times out.\n */\n async getRate(from: string, to: string, signal?: AbortSignal): Promise<number> {\n const fromUpper = from.toUpperCase();\n const toUpper = to.toUpperCase();\n\n if (this.isCryptoCode(fromUpper) || this.isCryptoCode(toUpper)) {\n return this.getCryptoRate(fromUpper, toUpper, signal);\n }\n\n // Combine the caller's optional abort signal with a hard timeout so a\n // hanging currency API never blocks re-evaluation indefinitely.\n const { signal: fetchSignal, cleanup } = createTimeoutSignal(\n signal,\n CurrencyExchangeService.FETCH_TIMEOUT_MS,\n \"Currency API fetch\",\n );\n\n try {\n // Built with URLSearchParams rather than interpolated. The code is\n // ISO-4217 by the time it gets here, but the query should be safe on\n // its own terms rather than by relying on a check that lives elsewhere.\n const query = new URLSearchParams({ base: fromUpper });\n const response = await fetch(`https://api.frankfurter.dev/v2/rates?${query.toString()}`, { signal: fetchSignal });\n if (!response.ok) throw ErrorFactory.external(CurrencyErrorCodes.API_ERROR, `Currency API returned ${response.status}`, { status: response.status });\n const data = await response.json();\n // The v2 endpoint returns a flat array of { date, base, quote, rate }\n // entries (one per target currency) rather than the classic v1 shape\n // { base, date, rates: { CODE: rate } }. Reading data.rates against\n // the real response is always undefined, so every conversion used to\n // throw \"Unknown currency\" no matter which currencies were requested.\n // Accept both shapes so a future API revision back to the object form\n // doesn't silently break this again.\n const rates: Record<string, number> = Array.isArray(data)\n ? Object.fromEntries(\n data\n .filter((entry: unknown): entry is { quote: string; rate: number } => {\n if (typeof entry !== \"object\" || entry === null) return false;\n const candidate = entry as { quote?: unknown; rate?: unknown };\n return typeof candidate.quote === \"string\" && typeof candidate.rate === \"number\";\n })\n .map((entry: { quote: string; rate: number }) => [entry.quote.toUpperCase(), entry.rate])\n )\n : (data.rates ?? {});\n if (rates[toUpper] === undefined) throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${toUpper}`, { code: toUpper });\n\n // The API returns ALL rates for the base currency, cache the whole\n // table so subsequent conversions (including cross pairs via\n // triangulation) resolve synchronously within the freshness window\n // instead of going Pending again.\n this.baseTables.set(fromUpper, {\n fetchedAt: Date.now(),\n rates: { ...rates, [fromUpper]: 1 },\n });\n\n return rates[toUpper];\n } finally {\n cleanup();\n }\n }\n\n /**\n * Crypto rate fetch, routed through CoinGecko's no-auth simple-price\n * endpoint instead of Frankfurter (fiat-only, has no BTC/ETH concept).\n * Handles all three combinations, crypto→crypto, crypto→fiat\n * fiat→crypto, via prices denominated in USD (or the target fiat\n * directly, which CoinGecko's `vs_currencies` also accepts), then\n * caches the result as a same-shaped base table so getRateSync /\n * convertSync keep working unchanged for crypto pairs too.\n */\n private async getCryptoRate(fromUpper: string, toUpper: string, signal?: AbortSignal): Promise<number> {\n const { signal: fetchSignal, cleanup } = createTimeoutSignal(\n signal,\n CurrencyExchangeService.FETCH_TIMEOUT_MS,\n \"Crypto price API fetch\",\n );\n\n try {\n const fromIsCrypto = this.isCryptoCode(fromUpper);\n const toIsCrypto = this.isCryptoCode(toUpper);\n let rate: number;\n\n if (fromIsCrypto && toIsCrypto) {\n const fromId = CurrencyExchangeService.CRYPTO_IDS[fromUpper];\n const toId = CurrencyExchangeService.CRYPTO_IDS[toUpper];\n const data = await this.fetchCoinGeckoPrices([fromId, toId], \"usd\", fetchSignal);\n const fromUsd = data[fromId]?.usd;\n const toUsd = data[toId]?.usd;\n if (typeof fromUsd !== \"number\") throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${fromUpper}`, { code: fromUpper });\n if (typeof toUsd !== \"number\") throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${toUpper}`, { code: toUpper });\n rate = fromUsd / toUsd;\n } else if (fromIsCrypto) {\n const fromId = CurrencyExchangeService.CRYPTO_IDS[fromUpper];\n const vs = toUpper.toLowerCase();\n const data = await this.fetchCoinGeckoPrices([fromId], vs, fetchSignal);\n const value = data[fromId]?.[vs];\n if (typeof value !== \"number\") throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${toUpper}`, { code: toUpper });\n rate = value;\n } else {\n const toId = CurrencyExchangeService.CRYPTO_IDS[toUpper];\n const vs = fromUpper.toLowerCase();\n const data = await this.fetchCoinGeckoPrices([toId], vs, fetchSignal);\n const priceOfToInFrom = data[toId]?.[vs];\n if (typeof priceOfToInFrom !== \"number\") throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${fromUpper}`, { code: fromUpper });\n rate = 1 / priceOfToInFrom;\n }\n\n // Cache as a single-pair base table, same shape Frankfurter fetches\n // produce, so getRateSync/convertSync's triangulation logic doesn't\n // need to know or care which source a rate came from.\n this.baseTables.set(fromUpper, {\n fetchedAt: Date.now(),\n rates: { [fromUpper]: 1, [toUpper]: rate },\n });\n\n return rate;\n } finally {\n cleanup();\n }\n }\n\n private async fetchCoinGeckoPrices(ids: string[], vsCurrency: string, signal: AbortSignal): Promise<Record<string, Record<string, number>>> {\n const query = new URLSearchParams({ ids: ids.join(\",\"), vs_currencies: vsCurrency });\n const response = await fetch(`https://api.coingecko.com/api/v3/simple/price?${query.toString()}`, { signal });\n if (!response.ok) throw ErrorFactory.external(CurrencyErrorCodes.CRYPTO_API_ERROR, `Crypto price API returned ${response.status}`, { status: response.status });\n return response.json();\n }\n\n /**\n * Seed a base rate table without a network fetch.\n *\n * Intended for tests and for future user-provided offline rates\n * production live data always comes from {@link getRate}. Seeded rates\n * obey the same freshness window as fetched ones.\n *\n * @param base - Base currency code (e.g. \"USD\").\n * @param rates - Map of currency code → rate relative to the base.\n */\n primeRates(base: string, rates: Record<string, number>): void {\n const baseUpper = base.toUpperCase();\n this.baseTables.set(baseUpper, {\n fetchedAt: Date.now(),\n rates: { ...rates, [baseUpper]: 1 },\n });\n }\n\n /**\n * Drop every cached/primed rate table.\n *\n * Mainly for test isolation: {@link sharedCurrencyExchange} is a\n * module-level singleton, so a rate primed or fetched by one test can\n * silently leak into a later test in the same file. Also usable in\n * production if a caller ever wants to force a full re-fetch.\n */\n clearRates(): void {\n this.baseTables.clear();\n }\n\n /**\n * Synchronous rate lookup: `1` for same-currency pairs, a cached LIVE\n * rate if one was fetched within {@link RATE_FRESHNESS_MS}, otherwise\n * `null`, callers fall through to the async fetch path and the\n * expression shows Pending until real data arrives.\n *\n * There is deliberately no hardcoded fallback table: a stale made-up\n * rate presented as a real conversion is worse than a Pending state.\n */\n getRateSync(from: string, to: string): number | null {\n const fromUpper = from.toUpperCase();\n const toUpper = to.toUpperCase();\n if (fromUpper === toUpper) {\n return 1;\n }\n const now = Date.now();\n for (const table of this.baseTables.values()) {\n if (now - table.fetchedAt > CurrencyExchangeService.RATE_FRESHNESS_MS) continue;\n const fromRate = table.rates[fromUpper];\n const toRate = table.rates[toUpper];\n if (fromRate && toRate) {\n return toRate / fromRate;\n }\n }\n return null;\n }\n\n /** Convert `value` from `from` to `to` using a freshly-fetched live rate (see {@link getRate}). */\n async convert(value: number, from: string, to: string): Promise<number> {\n const rate = await this.getRate(from, to);\n return value * rate;\n }\n\n /**\n * Get all currently cached fresh rates, keyed \"FROM:TO\".\n * @returns Snapshot of fresh live rates, or null when none are cached.\n */\n getAllRates(): Record<string, number> | null {\n const now = Date.now();\n const snapshot: Record<string, number> = {};\n let any = false;\n for (const [base, table] of this.baseTables) {\n if (now - table.fetchedAt > CurrencyExchangeService.RATE_FRESHNESS_MS) continue;\n for (const [code, rate] of Object.entries(table.rates)) {\n snapshot[`${base}:${code}`] = rate;\n any = true;\n }\n }\n return any ? snapshot : null;\n }\n\n /**\n * Check whether any fresh live rates are currently cached.\n */\n hasRates(): boolean {\n return this.getAllRates() !== null;\n }\n\n /**\n * Synchronous conversion using cached rates only\n * Returns null if rate not in cache\n */\n convertSync(value: number, from: string, to: string): number | null {\n const rate = this.getRateSync(from, to);\n if (rate === null) return null;\n return value * rate;\n }\n\n // ------------------------------------------------------------------------\n // CURRENCY VALIDATION\n // ------------------------------------------------------------------------\n\n /**\n * Check whether `code` is a recognized currency code: any active ISO 4217\n * code, or one of the cryptocurrencies in {@link CRYPTO_IDS}.\n *\n * This used to be a hand-written list of forty-six codes, which meant\n * `$100 in UAH` returned an unconverted hundred dollars rather than saying\n * it could not convert. Answering from the standard rather than from\n * whichever codes happened to get added is what stops that class of bug.\n *\n * Recognising a code is not the same as having a rate for it. That is\n * answered later, by the exchange provider; conflating the two is what\n * produced the silent failure.\n *\n * Remembered per spelling (see {@link currencyAnswers}), because the VM asks\n * on every unit-bearing instruction and the answer for a spelling never\n * changes.\n */\n isCurrency(code: string): boolean {\n // Every recognised code is three or four letters (ISO 4217 is exactly\n // three, the crypto tickers three or four), so any other length is plainly\n // not money and is answered without touching either table or the cache.\n const length = code.length;\n if (length < 3 || length > 4) return false;\n const remembered = this.currencyAnswers.get(code);\n if (remembered !== undefined) return remembered;\n const answer = isIso4217(code) || this.isCryptoCode(code);\n if (this.currencyAnswers.size >= CurrencyExchangeService.MAX_REMEMBERED_CODES) this.currencyAnswers.clear();\n this.currencyAnswers.set(code, answer);\n return answer;\n }\n}\n\n// ============================================================================\n// SINGLETON INSTANCE\n// ============================================================================\n\n/** The shared rate cache. See {@link CurrencyExchangeService} for why it is shared. */\nexport const currencyExchangeService = new CurrencyExchangeService();\n\n// Export for backward compatibility\n/** Alias for {@link currencyExchangeService}, kept for older imports. */\nexport const sharedCurrencyExchange = currencyExchangeService;\n\n// Default export\nexport default currencyExchangeService;\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a,d}from'./chunk-VLX7ZVK4.js';import {b as b$1}from'./chunk-NQFCXLEF.js';import {f,b as b$2}from'./chunk-J4K72CQN.js';import {a as a$1}from'./chunk-LP3JYC3A.js';import {c}from'./chunk-FAO6DQ74.js';import {c as c$1}from'./chunk-RELMEWY6.js';var C=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN"),t.parseExpression(a.Lowest,e),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(67),e.emitIndex(1);}};var S=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN"),t.parseExpression(a.Lowest,e),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(68),e.emitIndex(1);}};function R(r,t){let o=r.peek();if(!o||o.type!=="IDENT"&&o.type!=="UNIT")throw c$1.parsing("SYMBOLIC_REQUIRES_VARIABLE_NAME",`${t} needs the name of an unknown here, as in ${t}(x^2, x).`,{found:o?.type??"end of input"});return r.consume(),o.value}function A(r,t){r.emitOpcode(13),r.emitString(t);}function _(r,t,o){let e=new d(t.pluginIndexMap);r.parseExpression(a.Lowest,e),r.setBuilder(t);let n=e.build();if(n.hasAsync)throw c$1.parsing("SYMBOLIC_ARGUMENT_MUST_BE_SYNCHRONOUS",`${o}'s expression must be synchronous (no weather/stocks/currency calls).`);return n}function g(r,t,o){let e=r.emitAnonymousBody([o],t);r.emitOpcode(159),r.emitIndex(e);}var k=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN");let n=_(t,e,"solve"),i=t.match("EQUALS")?_(t,e,"solve"):null;t.consume("COMMA");let a=t.peek();if(!a||a.type!=="IDENT"&&a.type!=="UNIT")throw c$1.parsing("SOLVE_REQUIRES_VARIABLE_NAME","solve's second argument must be the name of the unknown to solve for, as in solve(x^2-4=0, x).",{found:a?.type??"end of input"});t.consume(),g(e,n,a.value),i?g(e,i,a.value):(e.emitOpcode(10),e.emitNumber(0)),A(e,a.value),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(69),e.emitIndex(3);}};var b=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN");let n=_(t,e,"der");t.consume("COMMA");let i=R(t,"der");g(e,n,i),A(e,i),t.match("COMMA")?t.parseExpression(a.Lowest,e):(e.emitOpcode(10),e.emitNumber(1)),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(70),e.emitIndex(3);}};var F=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN");let n=_(t,e,"integral");t.consume("COMMA");let i=R(t,"integral");g(e,n,i),A(e,i),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(71),e.emitIndex(2);}};var w=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN");let n=_(t,e,"taylor");t.consume("COMMA");let i=R(t,"taylor");g(e,n,i),A(e,i),t.consume("EQUALS"),t.parseExpression(a.Lowest,e),t.consume("COMMA"),t.parseExpression(a.Lowest,e),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(72),e.emitIndex(4);}};var Y=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN");let n=0;do t.parseExpression(a.Lowest,e),n++;while(t.match("COMMA"));t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(73),e.emitIndex(n);}};var v=class{constructor(){this.category="Symbolic";}parse(t,o,e){e.emitOpcode(10),e.emitNumber(Number(o.value)),e.emitOpcode(51),e.emitIndex(74),e.emitIndex(1);}};var U=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN"),t.parseExpression(a.Lowest,e),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(75),e.emitIndex(1);}};var $=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN"),t.parseExpression(a.Lowest,e),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(76),e.emitIndex(1);}};var z=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN"),t.parseExpression(a.Lowest,e),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(77),e.emitIndex(1);}};var j=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN"),t.parseExpression(a.Lowest,e),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(78),e.emitIndex(1);}};var G=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN"),t.parseExpression(a.Lowest,e),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(79),e.emitIndex(1);}};function ne(r=75){return {name:"symbolic:imaginary-literal",priority:r,shape:[{types:["NUMBER"]},{types:["IDENT"],values:["i"]}],match(t,o){let e=t[o];if(!e||e.type!=="NUMBER")return null;let n=t[o+1];return !n||n.type!=="IDENT"||n.value!=="i"||n.offset!==e.offset+e.value.length||t[o+2]?.type==="LPAREN"?null:{consumed:2,replacement:[new a$1("IMAGINARY",c("IMAGINARY"),e.value,e.value,e.offset,0,e.line,e.col)],ruleName:"symbolic:imaginary-literal"}}}}var ie={expand:"EXPAND_FN",factor:"FACTOR_FN",solve:"SOLVE_FN",der:"DER_FN",derivative:"DER_FN",integral:"INTEGRAL_FN",taylor:"TAYLOR_FN",jacobian:"JACOBIAN_FN",conj:"CONJ_FN",re:"RE_FN",im:"IM_FN",cancel:"CANCEL_FN",apart:"APART_FN"};function ae(r=80){return {name:"symbolic:call",priority:r,shape:[{types:["IDENT"],values:Object.keys(ie)},{types:["LPAREN"]}],match(t,o){let e=t[o];if(!e||e.type!=="IDENT")return null;let n=ie[e.value.toLowerCase()];return !n||t[o+1]?.type!=="LPAREN"?null:{consumed:1,replacement:[new a$1(n,c(n),e.value,e.value,e.offset,0,e.line,e.col)],ruleName:"symbolic:call"}}}}var se=[{word:"expand",tokenType:"EXPAND_FN",builtinIndex:67,example:"expand((x+1)*(x+2))",expected:"x^2+3x+2",docPage:"expanding.md"},{word:"factor",tokenType:"FACTOR_FN",builtinIndex:68,example:"factor(x^2-4)",expected:"(x-2)*(x+2)",docPage:"factoring.md"},{word:"solve",tokenType:"SOLVE_FN",builtinIndex:69,example:"solve(x^2-4=0, x)",expected:"= [-2, 2]",docPage:"solving-equations.md"},{word:"der",tokenType:"DER_FN",builtinIndex:70,example:"der(x^3, x)",expected:"3x^2",docPage:"calculus.md"},{word:"integral",tokenType:"INTEGRAL_FN",builtinIndex:71,example:"integral(x^2, x)",expected:"1/3x^3",docPage:"calculus.md"},{word:"taylor",tokenType:"TAYLOR_FN",builtinIndex:72,example:"taylor(exp(x), x=0, 3)",expected:"1/6x^3+0.5x^2+x+1",docPage:"calculus.md"},{word:"jacobian",tokenType:"JACOBIAN_FN",builtinIndex:73,example:"jacobian(x*y, x+y)",expected:"= [y, x; 1, 1]",docPage:"calculus.md"},{word:"conj",tokenType:"CONJ_FN",builtinIndex:75,example:"conj(2+3i)",expected:"2-3i",docPage:"complex.md"},{word:"re",tokenType:"RE_FN",builtinIndex:76,example:"re(2+3i)",expected:"= 2",docPage:"complex.md"},{word:"im",tokenType:"IM_FN",builtinIndex:77,example:"im(2+3i)",expected:"= 3",docPage:"complex.md"},{word:"cancel",tokenType:"CANCEL_FN",builtinIndex:78,example:"cancel((x^2-1)/(x-1))",expected:"x+1",docPage:"cancelling-fractions.md"},{word:"apart",tokenType:"APART_FN",builtinIndex:79,example:"apart((3x+5)/(x^2-1))",expected:"4/(x-1)-1/(x+1)",docPage:"splitting-fractions.md"}],Ce={name:"solve-symbolic",normalizerRules:[ae(),ne()],prefixParselets:{EXPAND_FN:new C,FACTOR_FN:new S,SOLVE_FN:new k,DER_FN:new b,INTEGRAL_FN:new F,TAYLOR_FN:new w,JACOBIAN_FN:new Y,IMAGINARY:new v,CONJ_FN:new U,RE_FN:new $,IM_FN:new z,CANCEL_FN:new j,APART_FN:new G},tokenCategories:{EXPAND_FN:"keyword",FACTOR_FN:"keyword",SOLVE_FN:"keyword",DER_FN:"keyword",INTEGRAL_FN:"keyword",TAYLOR_FN:"keyword",JACOBIAN_FN:"keyword",IMAGINARY:"number",CONJ_FN:"keyword",RE_FN:"keyword",IM_FN:"keyword",CANCEL_FN:"keyword",APART_FN:"keyword"}},Se=new Set(se.map(r=>r.tokenType));function ke(r){return r.some(t=>Se.has(t.type))}var be=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;function me(r,t){let o=r.trim();if(o.length>=2&&o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),!be.test(o))return null;let e=t.parseIso8601(o);return Number.isNaN(e)?null:e}var Fe=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;function mr(r){let t=Fe.exec(r.trim());if(t===null||t[1]===void 0)return {grain:"date"};let o=t[2];if(o===void 0)return {grain:"datetime"};if(o==="Z")return {grain:"instant",zone:f(0)};let e=o[0]==="-"?-1:1,n=o.slice(1).replace(":",""),i=Number(n.slice(0,2))*60+Number(n.slice(2));return {grain:"instant",zone:f(e*i)}}function lr(r,t){let o=t.fields(r),e=N=>String(N).padStart(2,"0"),n=o.year,i=e(o.month0+1),a=e(o.day),m=e(o.hour),d=e(o.minute),f=e(o.second),l=t.utcOffsetMinutes(r),p=l>=0?"+":"-",y=Math.abs(l),u=e(Math.floor(y/60)),s=e(y%60);return `${n}-${i}-${a}T${m}:${d}:${f}${p}${u}:${s}`}var we=1e12;function dr(r){return Math.abs(r)>=we?r:r*1e3}var Ye=Date.UTC(2026,3,3),le,h,K=new Map;function ve(){return typeof Intl=="object"&&Intl!==null?Intl.DateTimeFormat:void 0}function de(){let r=ve();r!==le&&(le=r,h=void 0,K.clear());}function Ue(){if(de(),h!==void 0)return h;try{let r=new Intl.DateTimeFormat("ja-JP").resolvedOptions().locale;h=typeof r=="string"&&r.startsWith("ja");}catch{h=false;}return h}function ce(){if(typeof Intl!="object"||Intl===null||typeof Intl.DateTimeFormat!="function")return null;try{let r=new Intl.DateTimeFormat().resolvedOptions().locale;return typeof r=="string"&&r.length>0?r:null}catch{return null}}function ue(r){de();let t=K.get(r);if(t!==void 0)return t;let o=$e(r);return K.set(r,o),o}function $e(r){if(typeof Intl!="object"||Intl===null||typeof Intl.DateTimeFormat!="function"||!Ue())return null;try{if(typeof Intl.DateTimeFormat.supportedLocalesOf=="function"&&Intl.DateTimeFormat.supportedLocalesOf([r]).length===0)return null;let t=new Intl.DateTimeFormat(r,{calendar:"gregory",numberingSystem:"latn",timeZone:"UTC",year:"numeric",month:"numeric",day:"numeric"}).formatToParts(Ye);if(!Array.isArray(t))return null;let o=t.filter(e=>e.type==="year"||e.type==="month"||e.type==="day").map(e=>e.type[0].toUpperCase()).join("");return o==="DMY"||o==="MDY"||o==="YMD"?o:null}catch{return null}}var M={DATE_INPUT_LOCALE_INVALID:"DATE_INPUT_LOCALE_INVALID",DATE_ORDER_MISMATCH:"DATE_ORDER_MISMATCH",DATE_NOT_A_CALENDAR_DAY:"DATE_NOT_A_CALENDAR_DAY"};function ze(r){if(typeof Intl!="object"||Intl===null||typeof Intl.getCanonicalLocales!="function")return true;try{return Intl.getCanonicalLocales(r),!0}catch{return false}}function Nr(r){let t=r.inputLocale;if(t!==void 0&&!ze(t))throw c$1.config(M.DATE_INPUT_LOCALE_INVALID,`date.inputLocale "${t}" is not a BCP-47 locale tag. Use a tag Intl accepts, for example "en-US".`,{inputLocale:t});let o=r.onAmbiguous,e=r.inputOrder;if(e==="DMY"||e==="MDY"||e==="YMD")return Object.freeze({order:e,orderSource:"config",onAmbiguous:o});if(e==="locale"){let n=t??ce();if(n!=null){let i=ue(n);if(i!==null)return Object.freeze({order:i,orderSource:t!==void 0?"locale":"host-locale",locale:n,onAmbiguous:o})}return Object.freeze({order:"auto",orderSource:"fallback",onAmbiguous:o})}return Object.freeze({order:"auto",orderSource:"separator",onAmbiguous:o})}var fe=["January","February","March","April","May","June","July","August","September","October","November","December"],X=/^\d{1,2}$/,Z=/^\d{4}$/;function je(r,t,o,e){let n=X.test(r),i=X.test(t),a=X.test(o);return e==="hyphen"&&Z.test(r)&&i&&a?"iso":n&&i&&Z.test(o)?"year-last-4":e==="slash"&&Z.test(r)&&i&&a?"year-first-4":n&&i&&a?"short":"none"}function Ge(r){if(r.length===4)return Number(r);if(r.length===2){let t=Number(r);return t<=68?2e3+t:1900+t}return null}function O(r,t,o){return t<1||t>12||r<1?false:r<=b$2(o,t-1)}function ye(r,t,o){return t<1||t>12?`there is no month ${t}`:r<1?`there is no day ${r}`:`${fe[t-1]} ${o} has ${b$2(o,t-1)} days`}function P(r,t,o){return `${r} ${fe[t-1]} ${o}`}function Q(r,t,o){let e=n=>String(n).padStart(2,"0");return `${String(o).padStart(4,"0")}-${e(t)}-${e(r)}`}function V(r,t,o){return r==="DMY"?{day:Number(t),month:Number(o)}:{day:Number(o),month:Number(t)}}function D(r){return r==="DMY"?"day first":r==="MDY"?"month first":"year first"}function Ve(r){return r==="hyphen"?"MDY":"DMY"}function ee(r,t,o,e){let[n,i,a]=r.groups,m=je(n,i,a,r.separator),d=r.separator!=="dot",f=o==="refuse"||!d;if(m==="none")return {kind:"arithmetic"};if(m==="iso"){let T=Number(n),x=Number(i),I=Number(a);return O(I,x,T)?{kind:"date",day:I,month:x,year:T,order:"ISO",shortYear:false}:f?q(r.text,I,x,T):{kind:"arithmetic"}}if(m==="year-first-4"){if(t!=="YMD")return {kind:"arithmetic"};let T=Number(n),x=Number(i),I=Number(a);return O(I,x,T)?{kind:"date",day:I,month:x,year:T,order:"YMD",shortYear:false}:{kind:"arithmetic"}}let l=Ge(a);if(l===null)return {kind:"arithmetic"};let p=a.length===2;if(t==="YMD")return !f||m==="short"&&d?{kind:"arithmetic"}:He(r.text,n,i,l);let y=t==="auto"?Ve(r.separator):t,u=y==="DMY"?"MDY":"DMY",s=V(y,n,i),N=V(u,n,i);if(O(s.day,s.month,l)){let x=(N.day!==s.day||N.month!==s.month)&&O(N.day,N.month,l)?Q(N.day,N.month,l):void 0;return {kind:"date",day:s.day,month:s.month,year:l,order:y,shortYear:p,alternative:x}}return !f||m==="short"&&d?{kind:"arithmetic"}:O(N.day,N.month,l)?{kind:"refuse",code:M.DATE_ORDER_MISMATCH,message:`"${r.text}" is not a date read ${D(y)}: ${ye(s.day,s.month,l)}. Read ${D(u)} it is ${P(N.day,N.month,l)}. Set date.inputOrder to "${u}" to read numeric dates ${D(u)}.`}:q(r.text,s.day,s.month,l)}function q(r,t,o,e){return {kind:"refuse",code:M.DATE_NOT_A_CALENDAR_DAY,message:`"${r}" is not a real date: ${ye(t,o,e)}.`}}function He(r,t,o,e,n){let i=V("DMY",t,o),a=V("MDY",t,o),m=O(i.day,i.month,e),d=O(a.day,a.month,e);if(!m&&!d)return q(r,i.day,i.month,e);let f=`"${r}" is not a date read year first.`,l=i.day===a.day&&i.month===a.month;if(m&&d&&!l)return {kind:"refuse",code:M.DATE_ORDER_MISMATCH,message:`${f} Read day first it is ${P(i.day,i.month,e)} and month first ${P(a.day,a.month,e)}. Write it as ${Q(i.day,i.month,e)}, or set date.inputOrder to "DMY" or "MDY".`};let p=m?i:a,y=m?"DMY":"MDY";return {kind:"refuse",code:M.DATE_ORDER_MISMATCH,message:`${f} Read ${D(y)} it is ${P(p.day,p.month,e)}. Write it as ${Q(p.day,p.month,e)}, or set date.inputOrder to "${y}".`}}function Je(r,t){if(r.orderSource==="iso")return "ISO";if(r.orderSource==="spelled")return "with the month spelled out";let o=r.order===null||r.order==="ISO"||r.order==="spelled"?"as written":D(r.order);switch(r.orderSource){case "config":return `${o}, from date.inputOrder`;case "locale":return `${o}, from the locale ${r.locale}`;case "host-locale":return `${o}, from the host locale ${r.locale}`;case "fallback":return `${o}, the default for a ${t} date, because the host locale could not be read`;default:return `${o}, the default for a ${t} date`}}function pe(r){let[t,o,e]=r.split("-").map(Number);return P(e,o,t)}function We(r,t,o){if(r.iso===null)return o??`"${r.text}" is not a date this engine can read.`;let e=`${r.text} read as ${pe(r.iso)}, ${Je(r,t)}.`;if(r.alternative!==void 0&&r.order!==null&&r.order!=="ISO"&&r.order!=="spelled"){let n=r.order==="DMY"?"Month first":"Day first";e+=` ${n} would be ${pe(r.alternative)}.`;}return r.shortYear&&(e+=` The two-digit year ${r.text.slice(-2)} was read as ${r.iso.slice(0,4)}.`),e}function Ir(r,t,o){return {...r,note:We(r,t,o),needsNote:r.contested||r.shortYear||r.iso===null}}function xr(r){let t=/^(\d+)([/-])(\d+)\2(\d+)$/.exec(r);if(t!==null)return {text:r,groups:[t[1],t[3],t[4]],separator:t[2]==="-"?"hyphen":"slash"};let o=/^(\d{1,2})\.(\d{1,2})\.(\d{2}|\d{4})$/.exec(r);return o!==null?{text:r,groups:[o[1],o[2],o[3]],separator:"dot"}:null}var te="DATETIME_LITERAL",xe=c(te),Te="DATETIME_LITERAL_UNREADABLE",Ke=c(Te),H=/^\d+$/,Xe=/^\d{1,2}\.\d{1,2}$/,Ze=/^\.(\d{2}|\d{4})$/;function Qe(r){for(let t=0;t<r.length-1;t++){let o=r[t];if((o.sourceEnd??o.offset+o.text.length)!==r[t+1].offset)return false}return true}function Ne(r,t,o,e,n,i){if(t<1||t>12||r<1||r>31)return null;let a=i.localMidnight(o,t-1,r),m=i.fields(a);if(m.year!==o||m.month0!==t-1||m.day!==r)return null;let d=e[0],f=e.map(p=>p.value).join(""),l=new a$1(te,xe,String(a),f,d.offset,0,d.line,d.col);return {consumed:e.length,replacement:[l],ruleName:n}}function qe(r){let t="",o=-1;for(let e of r){let n=e.text??e.value;o>=0&&e.offset>o&&(t+=" "),t+=n,o=e.sourceEnd??e.offset+n.length;}return t}function Ie(r,t,o,e){let n=o[0],i=qe(o),a=new a$1(Te,Ke,i,i,n.offset,0,n.line,n.col);return a.fault={code:r,message:t},{consumed:o.length,replacement:[a],ruleName:e}}var et=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?/,tt=new Set(["NUMBER","MINUS","PLUS","COLON","IDENT"]),rt=16;function ot(r,t,o,e){let n=r[t];if(n.sourceEnd!==void 0)return null;let i=n.text,a=n.offset+n.text.length,m=[n];for(let u=t+1;u<r.length&&m.length<rt;u++){let s=r[u];if(s.sourceEnd!==void 0||s.offset!==a||!tt.has(s.type))break;i+=s.text,a=s.offset+s.text.length,m.push(s);}let d=et.exec(i);if(d===null)return null;let f=0,l=0;for(let u of m)if(l+=u.text.length,f++,l>=d[0].length)break;if(l!==d[0].length)return null;let p=me(d[0],e);if(p===null)return null;let y=new a$1(te,xe,String(p),d[0],n.offset,0,n.line,n.col,n.offset+d[0].length);return {consumed:f,replacement:[y],ruleName:o}}function Br(r=()=>"auto",t=()=>b$1,o=()=>"refuse"){return {name:"datetime:date-literal",priority:70,shape:[{types:["NUMBER"]}],match(e,n){let i=e[n];if(i.type!=="NUMBER")return null;let a=t();if(Xe.test(i.value)){let s=e[n+1];if(s&&s.type==="NUMBER"&&Ze.test(s.value)){let[N,T]=i.value.split("."),x={text:`${i.value}${s.value}`,groups:[N,T,s.value.slice(1)],separator:"dot"},I=ee(x,r(),o());if(I.kind==="date")return Ne(I.day,I.month,I.year,[i,s],"datetime:date-literal:dot",a);if(I.kind==="refuse")return Ie(I.code,I.message,[i,s],"datetime:date-literal:dot:unreadable")}return null}if(i.value.length===4&&H.test(i.value)){let s=ot(e,n,"datetime:date-literal:iso-timestamp",a);if(s)return s}if(!H.test(i.value))return null;let m=e[n+1];if(!m||m.type!=="SLASH"&&m.type!=="MINUS")return null;let d=e[n+2],f=e[n+3],l=e[n+4];if(!d||d.type!=="NUMBER"||!H.test(d.value)||!f||f.type!==m.type||!l||l.type!=="NUMBER"||!H.test(l.value))return null;let p=[i,m,d,f,l];if(!Qe(p))return null;let y={text:p.map(s=>s.value).join(""),groups:[i.value,d.value,l.value],separator:m.type==="MINUS"?"hyphen":"slash"},u=ee(y,r(),o());return u.kind==="arithmetic"?null:u.kind==="refuse"?Ie(u.code,u.message,p,"datetime:date-literal:unreadable"):Ne(u.day,u.month,u.year,p,`datetime:date-literal:${u.order.toLowerCase()}`,a)}}}export{Ce as a,ke as b,me as c,mr as d,lr as e,dr as f,M as g,Nr as h,je as i,ye as j,Q as k,ee as l,Ir as m,xr as n,te as o,Te as p,Ne as q,qe as r,Ie as s,Br as t};//# sourceMappingURL=chunk-FXB5GCBT.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {a,d}from'./chunk-U5MESNRT.js';import {b as b$1}from'./chunk-EOO6M65F.js';import {f,b as b$2}from'./chunk-J4K72CQN.js';import {a as a$1}from'./chunk-APYRNAU2.js';import {c}from'./chunk-FAO6DQ74.js';import {c as c$1}from'./chunk-6G2NES2I.js';var C=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN"),t.parseExpression(a.Lowest,e),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(67),e.emitIndex(1);}};var S=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN"),t.parseExpression(a.Lowest,e),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(68),e.emitIndex(1);}};function R(r,t){let o=r.peek();if(!o||o.type!=="IDENT"&&o.type!=="UNIT")throw c$1.parsing("SYMBOLIC_REQUIRES_VARIABLE_NAME",`${t} needs the name of an unknown here, as in ${t}(x^2, x).`,{found:o?.type??"end of input"});return r.consume(),o.value}function A(r,t){r.emitOpcode(13),r.emitString(t);}function _(r,t,o){let e=new d(t.pluginIndexMap);r.parseExpression(a.Lowest,e),r.setBuilder(t);let n=e.build();if(n.hasAsync)throw c$1.parsing("SYMBOLIC_ARGUMENT_MUST_BE_SYNCHRONOUS",`${o}'s expression must be synchronous (no weather/stocks/currency calls).`);return n}function g(r,t,o){let e=r.emitAnonymousBody([o],t);r.emitOpcode(159),r.emitIndex(e);}var k=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN");let n=_(t,e,"solve"),i=t.match("EQUALS")?_(t,e,"solve"):null;t.consume("COMMA");let a=t.peek();if(!a||a.type!=="IDENT"&&a.type!=="UNIT")throw c$1.parsing("SOLVE_REQUIRES_VARIABLE_NAME","solve's second argument must be the name of the unknown to solve for, as in solve(x^2-4=0, x).",{found:a?.type??"end of input"});t.consume(),g(e,n,a.value),i?g(e,i,a.value):(e.emitOpcode(10),e.emitNumber(0)),A(e,a.value),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(69),e.emitIndex(3);}};var b=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN");let n=_(t,e,"der");t.consume("COMMA");let i=R(t,"der");g(e,n,i),A(e,i),t.match("COMMA")?t.parseExpression(a.Lowest,e):(e.emitOpcode(10),e.emitNumber(1)),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(70),e.emitIndex(3);}};var F=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN");let n=_(t,e,"integral");t.consume("COMMA");let i=R(t,"integral");g(e,n,i),A(e,i),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(71),e.emitIndex(2);}};var w=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN");let n=_(t,e,"taylor");t.consume("COMMA");let i=R(t,"taylor");g(e,n,i),A(e,i),t.consume("EQUALS"),t.parseExpression(a.Lowest,e),t.consume("COMMA"),t.parseExpression(a.Lowest,e),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(72),e.emitIndex(4);}};var Y=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN");let n=0;do t.parseExpression(a.Lowest,e),n++;while(t.match("COMMA"));t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(73),e.emitIndex(n);}};var v=class{constructor(){this.category="Symbolic";}parse(t,o,e){e.emitOpcode(10),e.emitNumber(Number(o.value)),e.emitOpcode(51),e.emitIndex(74),e.emitIndex(1);}};var U=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN"),t.parseExpression(a.Lowest,e),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(75),e.emitIndex(1);}};var $=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN"),t.parseExpression(a.Lowest,e),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(76),e.emitIndex(1);}};var z=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN"),t.parseExpression(a.Lowest,e),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(77),e.emitIndex(1);}};var j=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN"),t.parseExpression(a.Lowest,e),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(78),e.emitIndex(1);}};var G=class{constructor(){this.category="Symbolic";}parse(t,o,e){t.consume("LPAREN"),t.parseExpression(a.Lowest,e),t.consume("RPAREN"),e.emitOpcode(51),e.emitIndex(79),e.emitIndex(1);}};function ne(r=75){return {name:"symbolic:imaginary-literal",priority:r,shape:[{types:["NUMBER"]},{types:["IDENT"],values:["i"]}],match(t,o){let e=t[o];if(!e||e.type!=="NUMBER")return null;let n=t[o+1];return !n||n.type!=="IDENT"||n.value!=="i"||n.offset!==e.offset+e.value.length||t[o+2]?.type==="LPAREN"?null:{consumed:2,replacement:[new a$1("IMAGINARY",c("IMAGINARY"),e.value,e.value,e.offset,0,e.line,e.col)],ruleName:"symbolic:imaginary-literal"}}}}var ie={expand:"EXPAND_FN",factor:"FACTOR_FN",solve:"SOLVE_FN",der:"DER_FN",derivative:"DER_FN",integral:"INTEGRAL_FN",taylor:"TAYLOR_FN",jacobian:"JACOBIAN_FN",conj:"CONJ_FN",re:"RE_FN",im:"IM_FN",cancel:"CANCEL_FN",apart:"APART_FN"};function ae(r=80){return {name:"symbolic:call",priority:r,shape:[{types:["IDENT"],values:Object.keys(ie)},{types:["LPAREN"]}],match(t,o){let e=t[o];if(!e||e.type!=="IDENT")return null;let n=ie[e.value.toLowerCase()];return !n||t[o+1]?.type!=="LPAREN"?null:{consumed:1,replacement:[new a$1(n,c(n),e.value,e.value,e.offset,0,e.line,e.col)],ruleName:"symbolic:call"}}}}var se=[{word:"expand",tokenType:"EXPAND_FN",builtinIndex:67,example:"expand((x+1)*(x+2))",expected:"x^2+3x+2",docPage:"expanding.md"},{word:"factor",tokenType:"FACTOR_FN",builtinIndex:68,example:"factor(x^2-4)",expected:"(x-2)*(x+2)",docPage:"factoring.md"},{word:"solve",tokenType:"SOLVE_FN",builtinIndex:69,example:"solve(x^2-4=0, x)",expected:"= [-2, 2]",docPage:"solving-equations.md"},{word:"der",tokenType:"DER_FN",builtinIndex:70,example:"der(x^3, x)",expected:"3x^2",docPage:"calculus.md"},{word:"integral",tokenType:"INTEGRAL_FN",builtinIndex:71,example:"integral(x^2, x)",expected:"1/3x^3",docPage:"calculus.md"},{word:"taylor",tokenType:"TAYLOR_FN",builtinIndex:72,example:"taylor(exp(x), x=0, 3)",expected:"1/6x^3+0.5x^2+x+1",docPage:"calculus.md"},{word:"jacobian",tokenType:"JACOBIAN_FN",builtinIndex:73,example:"jacobian(x*y, x+y)",expected:"= [y, x; 1, 1]",docPage:"calculus.md"},{word:"conj",tokenType:"CONJ_FN",builtinIndex:75,example:"conj(2+3i)",expected:"2-3i",docPage:"complex.md"},{word:"re",tokenType:"RE_FN",builtinIndex:76,example:"re(2+3i)",expected:"= 2",docPage:"complex.md"},{word:"im",tokenType:"IM_FN",builtinIndex:77,example:"im(2+3i)",expected:"= 3",docPage:"complex.md"},{word:"cancel",tokenType:"CANCEL_FN",builtinIndex:78,example:"cancel((x^2-1)/(x-1))",expected:"x+1",docPage:"cancelling-fractions.md"},{word:"apart",tokenType:"APART_FN",builtinIndex:79,example:"apart((3x+5)/(x^2-1))",expected:"4/(x-1)-1/(x+1)",docPage:"splitting-fractions.md"}],Ce={name:"solve-symbolic",normalizerRules:[ae(),ne()],prefixParselets:{EXPAND_FN:new C,FACTOR_FN:new S,SOLVE_FN:new k,DER_FN:new b,INTEGRAL_FN:new F,TAYLOR_FN:new w,JACOBIAN_FN:new Y,IMAGINARY:new v,CONJ_FN:new U,RE_FN:new $,IM_FN:new z,CANCEL_FN:new j,APART_FN:new G},tokenCategories:{EXPAND_FN:"keyword",FACTOR_FN:"keyword",SOLVE_FN:"keyword",DER_FN:"keyword",INTEGRAL_FN:"keyword",TAYLOR_FN:"keyword",JACOBIAN_FN:"keyword",IMAGINARY:"number",CONJ_FN:"keyword",RE_FN:"keyword",IM_FN:"keyword",CANCEL_FN:"keyword",APART_FN:"keyword"}},Se=new Set(se.map(r=>r.tokenType));function ke(r){return r.some(t=>Se.has(t.type))}var be=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;function me(r,t){let o=r.trim();if(o.length>=2&&o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1)),!be.test(o))return null;let e=t.parseIso8601(o);return Number.isNaN(e)?null:e}var Fe=/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;function mr(r){let t=Fe.exec(r.trim());if(t===null||t[1]===void 0)return {grain:"date"};let o=t[2];if(o===void 0)return {grain:"datetime"};if(o==="Z")return {grain:"instant",zone:f(0)};let e=o[0]==="-"?-1:1,n=o.slice(1).replace(":",""),i=Number(n.slice(0,2))*60+Number(n.slice(2));return {grain:"instant",zone:f(e*i)}}function lr(r,t){let o=t.fields(r),e=N=>String(N).padStart(2,"0"),n=o.year,i=e(o.month0+1),a=e(o.day),m=e(o.hour),d=e(o.minute),f=e(o.second),l=t.utcOffsetMinutes(r),p=l>=0?"+":"-",y=Math.abs(l),u=e(Math.floor(y/60)),s=e(y%60);return `${n}-${i}-${a}T${m}:${d}:${f}${p}${u}:${s}`}var we=1e12;function dr(r){return Math.abs(r)>=we?r:r*1e3}var Ye=Date.UTC(2026,3,3),le,h,K=new Map;function ve(){return typeof Intl=="object"&&Intl!==null?Intl.DateTimeFormat:void 0}function de(){let r=ve();r!==le&&(le=r,h=void 0,K.clear());}function Ue(){if(de(),h!==void 0)return h;try{let r=new Intl.DateTimeFormat("ja-JP").resolvedOptions().locale;h=typeof r=="string"&&r.startsWith("ja");}catch{h=false;}return h}function ce(){if(typeof Intl!="object"||Intl===null||typeof Intl.DateTimeFormat!="function")return null;try{let r=new Intl.DateTimeFormat().resolvedOptions().locale;return typeof r=="string"&&r.length>0?r:null}catch{return null}}function ue(r){de();let t=K.get(r);if(t!==void 0)return t;let o=$e(r);return K.set(r,o),o}function $e(r){if(typeof Intl!="object"||Intl===null||typeof Intl.DateTimeFormat!="function"||!Ue())return null;try{if(typeof Intl.DateTimeFormat.supportedLocalesOf=="function"&&Intl.DateTimeFormat.supportedLocalesOf([r]).length===0)return null;let t=new Intl.DateTimeFormat(r,{calendar:"gregory",numberingSystem:"latn",timeZone:"UTC",year:"numeric",month:"numeric",day:"numeric"}).formatToParts(Ye);if(!Array.isArray(t))return null;let o=t.filter(e=>e.type==="year"||e.type==="month"||e.type==="day").map(e=>e.type[0].toUpperCase()).join("");return o==="DMY"||o==="MDY"||o==="YMD"?o:null}catch{return null}}var M={DATE_INPUT_LOCALE_INVALID:"DATE_INPUT_LOCALE_INVALID",DATE_ORDER_MISMATCH:"DATE_ORDER_MISMATCH",DATE_NOT_A_CALENDAR_DAY:"DATE_NOT_A_CALENDAR_DAY"};function ze(r){if(typeof Intl!="object"||Intl===null||typeof Intl.getCanonicalLocales!="function")return true;try{return Intl.getCanonicalLocales(r),!0}catch{return false}}function Nr(r){let t=r.inputLocale;if(t!==void 0&&!ze(t))throw c$1.config(M.DATE_INPUT_LOCALE_INVALID,`date.inputLocale "${t}" is not a BCP-47 locale tag. Use a tag Intl accepts, for example "en-US".`,{inputLocale:t});let o=r.onAmbiguous,e=r.inputOrder;if(e==="DMY"||e==="MDY"||e==="YMD")return Object.freeze({order:e,orderSource:"config",onAmbiguous:o});if(e==="locale"){let n=t??ce();if(n!=null){let i=ue(n);if(i!==null)return Object.freeze({order:i,orderSource:t!==void 0?"locale":"host-locale",locale:n,onAmbiguous:o})}return Object.freeze({order:"auto",orderSource:"fallback",onAmbiguous:o})}return Object.freeze({order:"auto",orderSource:"separator",onAmbiguous:o})}var fe=["January","February","March","April","May","June","July","August","September","October","November","December"],X=/^\d{1,2}$/,Z=/^\d{4}$/;function je(r,t,o,e){let n=X.test(r),i=X.test(t),a=X.test(o);return e==="hyphen"&&Z.test(r)&&i&&a?"iso":n&&i&&Z.test(o)?"year-last-4":e==="slash"&&Z.test(r)&&i&&a?"year-first-4":n&&i&&a?"short":"none"}function Ge(r){if(r.length===4)return Number(r);if(r.length===2){let t=Number(r);return t<=68?2e3+t:1900+t}return null}function O(r,t,o){return t<1||t>12||r<1?false:r<=b$2(o,t-1)}function ye(r,t,o){return t<1||t>12?`there is no month ${t}`:r<1?`there is no day ${r}`:`${fe[t-1]} ${o} has ${b$2(o,t-1)} days`}function P(r,t,o){return `${r} ${fe[t-1]} ${o}`}function Q(r,t,o){let e=n=>String(n).padStart(2,"0");return `${String(o).padStart(4,"0")}-${e(t)}-${e(r)}`}function V(r,t,o){return r==="DMY"?{day:Number(t),month:Number(o)}:{day:Number(o),month:Number(t)}}function D(r){return r==="DMY"?"day first":r==="MDY"?"month first":"year first"}function Ve(r){return r==="hyphen"?"MDY":"DMY"}function ee(r,t,o,e){let[n,i,a]=r.groups,m=je(n,i,a,r.separator),d=r.separator!=="dot",f=o==="refuse"||!d;if(m==="none")return {kind:"arithmetic"};if(m==="iso"){let T=Number(n),x=Number(i),I=Number(a);return O(I,x,T)?{kind:"date",day:I,month:x,year:T,order:"ISO",shortYear:false}:f?q(r.text,I,x,T):{kind:"arithmetic"}}if(m==="year-first-4"){if(t!=="YMD")return {kind:"arithmetic"};let T=Number(n),x=Number(i),I=Number(a);return O(I,x,T)?{kind:"date",day:I,month:x,year:T,order:"YMD",shortYear:false}:{kind:"arithmetic"}}let l=Ge(a);if(l===null)return {kind:"arithmetic"};let p=a.length===2;if(t==="YMD")return !f||m==="short"&&d?{kind:"arithmetic"}:He(r.text,n,i,l);let y=t==="auto"?Ve(r.separator):t,u=y==="DMY"?"MDY":"DMY",s=V(y,n,i),N=V(u,n,i);if(O(s.day,s.month,l)){let x=(N.day!==s.day||N.month!==s.month)&&O(N.day,N.month,l)?Q(N.day,N.month,l):void 0;return {kind:"date",day:s.day,month:s.month,year:l,order:y,shortYear:p,alternative:x}}return !f||m==="short"&&d?{kind:"arithmetic"}:O(N.day,N.month,l)?{kind:"refuse",code:M.DATE_ORDER_MISMATCH,message:`"${r.text}" is not a date read ${D(y)}: ${ye(s.day,s.month,l)}. Read ${D(u)} it is ${P(N.day,N.month,l)}. Set date.inputOrder to "${u}" to read numeric dates ${D(u)}.`}:q(r.text,s.day,s.month,l)}function q(r,t,o,e){return {kind:"refuse",code:M.DATE_NOT_A_CALENDAR_DAY,message:`"${r}" is not a real date: ${ye(t,o,e)}.`}}function He(r,t,o,e,n){let i=V("DMY",t,o),a=V("MDY",t,o),m=O(i.day,i.month,e),d=O(a.day,a.month,e);if(!m&&!d)return q(r,i.day,i.month,e);let f=`"${r}" is not a date read year first.`,l=i.day===a.day&&i.month===a.month;if(m&&d&&!l)return {kind:"refuse",code:M.DATE_ORDER_MISMATCH,message:`${f} Read day first it is ${P(i.day,i.month,e)} and month first ${P(a.day,a.month,e)}. Write it as ${Q(i.day,i.month,e)}, or set date.inputOrder to "DMY" or "MDY".`};let p=m?i:a,y=m?"DMY":"MDY";return {kind:"refuse",code:M.DATE_ORDER_MISMATCH,message:`${f} Read ${D(y)} it is ${P(p.day,p.month,e)}. Write it as ${Q(p.day,p.month,e)}, or set date.inputOrder to "${y}".`}}function Je(r,t){if(r.orderSource==="iso")return "ISO";if(r.orderSource==="spelled")return "with the month spelled out";let o=r.order===null||r.order==="ISO"||r.order==="spelled"?"as written":D(r.order);switch(r.orderSource){case "config":return `${o}, from date.inputOrder`;case "locale":return `${o}, from the locale ${r.locale}`;case "host-locale":return `${o}, from the host locale ${r.locale}`;case "fallback":return `${o}, the default for a ${t} date, because the host locale could not be read`;default:return `${o}, the default for a ${t} date`}}function pe(r){let[t,o,e]=r.split("-").map(Number);return P(e,o,t)}function We(r,t,o){if(r.iso===null)return o??`"${r.text}" is not a date this engine can read.`;let e=`${r.text} read as ${pe(r.iso)}, ${Je(r,t)}.`;if(r.alternative!==void 0&&r.order!==null&&r.order!=="ISO"&&r.order!=="spelled"){let n=r.order==="DMY"?"Month first":"Day first";e+=` ${n} would be ${pe(r.alternative)}.`;}return r.shortYear&&(e+=` The two-digit year ${r.text.slice(-2)} was read as ${r.iso.slice(0,4)}.`),e}function Ir(r,t,o){return {...r,note:We(r,t,o),needsNote:r.contested||r.shortYear||r.iso===null}}function xr(r){let t=/^(\d+)([/-])(\d+)\2(\d+)$/.exec(r);if(t!==null)return {text:r,groups:[t[1],t[3],t[4]],separator:t[2]==="-"?"hyphen":"slash"};let o=/^(\d{1,2})\.(\d{1,2})\.(\d{2}|\d{4})$/.exec(r);return o!==null?{text:r,groups:[o[1],o[2],o[3]],separator:"dot"}:null}var te="DATETIME_LITERAL",xe=c(te),Te="DATETIME_LITERAL_UNREADABLE",Ke=c(Te),H=/^\d+$/,Xe=/^\d{1,2}\.\d{1,2}$/,Ze=/^\.(\d{2}|\d{4})$/;function Qe(r){for(let t=0;t<r.length-1;t++){let o=r[t];if((o.sourceEnd??o.offset+o.text.length)!==r[t+1].offset)return false}return true}function Ne(r,t,o,e,n,i){if(t<1||t>12||r<1||r>31)return null;let a=i.localMidnight(o,t-1,r),m=i.fields(a);if(m.year!==o||m.month0!==t-1||m.day!==r)return null;let d=e[0],f=e.map(p=>p.value).join(""),l=new a$1(te,xe,String(a),f,d.offset,0,d.line,d.col);return {consumed:e.length,replacement:[l],ruleName:n}}function qe(r){let t="",o=-1;for(let e of r){let n=e.text??e.value;o>=0&&e.offset>o&&(t+=" "),t+=n,o=e.sourceEnd??e.offset+n.length;}return t}function Ie(r,t,o,e){let n=o[0],i=qe(o),a=new a$1(Te,Ke,i,i,n.offset,0,n.line,n.col);return a.fault={code:r,message:t},{consumed:o.length,replacement:[a],ruleName:e}}var et=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?/,tt=new Set(["NUMBER","MINUS","PLUS","COLON","IDENT"]),rt=16;function ot(r,t,o,e){let n=r[t];if(n.sourceEnd!==void 0)return null;let i=n.text,a=n.offset+n.text.length,m=[n];for(let u=t+1;u<r.length&&m.length<rt;u++){let s=r[u];if(s.sourceEnd!==void 0||s.offset!==a||!tt.has(s.type))break;i+=s.text,a=s.offset+s.text.length,m.push(s);}let d=et.exec(i);if(d===null)return null;let f=0,l=0;for(let u of m)if(l+=u.text.length,f++,l>=d[0].length)break;if(l!==d[0].length)return null;let p=me(d[0],e);if(p===null)return null;let y=new a$1(te,xe,String(p),d[0],n.offset,0,n.line,n.col,n.offset+d[0].length);return {consumed:f,replacement:[y],ruleName:o}}function Br(r=()=>"auto",t=()=>b$1,o=()=>"refuse"){return {name:"datetime:date-literal",priority:70,shape:[{types:["NUMBER"]}],match(e,n){let i=e[n];if(i.type!=="NUMBER")return null;let a=t();if(Xe.test(i.value)){let s=e[n+1];if(s&&s.type==="NUMBER"&&Ze.test(s.value)){let[N,T]=i.value.split("."),x={text:`${i.value}${s.value}`,groups:[N,T,s.value.slice(1)],separator:"dot"},I=ee(x,r(),o());if(I.kind==="date")return Ne(I.day,I.month,I.year,[i,s],"datetime:date-literal:dot",a);if(I.kind==="refuse")return Ie(I.code,I.message,[i,s],"datetime:date-literal:dot:unreadable")}return null}if(i.value.length===4&&H.test(i.value)){let s=ot(e,n,"datetime:date-literal:iso-timestamp",a);if(s)return s}if(!H.test(i.value))return null;let m=e[n+1];if(!m||m.type!=="SLASH"&&m.type!=="MINUS")return null;let d=e[n+2],f=e[n+3],l=e[n+4];if(!d||d.type!=="NUMBER"||!H.test(d.value)||!f||f.type!==m.type||!l||l.type!=="NUMBER"||!H.test(l.value))return null;let p=[i,m,d,f,l];if(!Qe(p))return null;let y={text:p.map(s=>s.value).join(""),groups:[i.value,d.value,l.value],separator:m.type==="MINUS"?"hyphen":"slash"},u=ee(y,r(),o());return u.kind==="arithmetic"?null:u.kind==="refuse"?Ie(u.code,u.message,p,"datetime:date-literal:unreadable"):Ne(u.day,u.month,u.year,p,`datetime:date-literal:${u.order.toLowerCase()}`,a)}}}export{Ce as a,ke as b,me as c,mr as d,lr as e,dr as f,M as g,Nr as h,je as i,ye as j,Q as k,ee as l,Ir as m,xr as n,te as o,Te as p,Ne as q,qe as r,Ie as s,Br as t};//# sourceMappingURL=chunk-TJKN466F.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-TJKN466F.js.map
|