diff --git a/.gitignore b/.gitignore index c0c6bfb..d4cc958 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,8 @@ resources/NibblePoker/js/*.min.js # Compiled Stuff *.min.php +tools/items/formula-wizard/*.js +tools/items/formula-wizard/src/*.js # Others *.pdn diff --git a/commons/strings.json b/commons/strings.json index 09edb4d..c380992 100644 --- a/commons/strings.json +++ b/commons/strings.json @@ -1 +1 @@ -{"_compile_date":"2023-08-13T19:19:46.118319Z","en":{"about.head.title":"About - NibblePoker","about.head.description":"TODO: description","about.og.title":"NibblePoker - About","about.og.description":"TODO: description","about.header.title":"About","about.part.year.single":"year","about.part.year.multiple":"years","about.part.since":"since","about.education.title":"Education","about.skills.title":"Skills","about.work.title":"Work Experience","about.work.ctie.title":"Government IT Centre (CTIE)","about.work.ctie.role.1":"IoT Developer Internship","about.work.ctie.location":"Luxembourg","about.work.computrade.title":"CompuTrade Luxembourg Ltd","about.work.computrade.role.1":"Full & Half-time student job","about.work.computrade.location":"Steinfort, Luxembourg","about.work.lih.title":"Luxembourg Institute of Health (LIH)","about.work.lih.role.1":"IT Support Internship","about.work.lih.location":"Luxembourg","about.work.crlux.title":"Luxembourg Red Cross","about.work.crlux.role.1":"Volunteer Excel VBA programmer.","about.work.crlux.location":"Luxembourg","about.work.buttek.title":"Luxembourg Red Cross - Buttek","about.work.buttek.role.1":"Volunteer ???","about.work.buttek.role.2":"Student cashier ???","about.work.buttek.location":"Luxembourg","about.work.current.title":"Current employer kept private","about.work.current.role.1":"???","about.work.current.location":"Belgium","contact.head.title":"Contact - NibblePoker","contact.head.description":"TODO: description","contact.og.title":"NibblePoker - Contact","contact.og.description":"TODO: description","contact.header.title":"Contact","contact.email.title":"Email","contact.email.compose":"Send an email to herwin.bozet@gmail.com","contact.twitter.title":"Twitter","contact.twitter.compose":"Compose DM to @NibblePoker on Twitter","content.search.head.title":"Content search - NibblePoker","content.search.head.description":"TODO: description","content.search.og.title":"NibblePoker - Content search","content.search.og.description":"TODO: description","content.search.heading.main.single":"Search result","content.search.heading.main.multiple":"Search results","content.search.count.single":"result","content.search.count.multiple":"results","content.header.base":"Projects","content.search.header":"Search","content.error.header":"Error","content.error.head.title":"Content error - NibblePoker","content.error.og.title":"NibblePoker - Content error","content.error.heading.main.search":"Search error","content.error.heading.main.content":"Content error","content.error.heading.main.fallback":"Unknown error","content.error.message.none":"No explicit error was encountered.","content.error.message.tags.length":"The \"tags\" URL parameter is too long.","content.error.message.tags.alphanumeric":"One of the tags given in the \"tags\" URL parameter is not a valid alphanumeric string.","content.error.message.detect.empty":"No content could be found for the given tags.","content.error.message.id.alphanumeric":"The requested resource's ID isn't a valid alphanumeric string.","content.error.message.data.not.exist":"The requested content doesn't have an internal item file associated to it.","content.error.message.cannot.load":"The requested content couldn't be loaded on our end !","content.error.message.data.no.tags":"No tags found !","content.error.message.data.no.title":"No title found !","content.item.head.title.prefix":"","content.item.head.title.suffix":" - NibblePoker","content.item.og.title.prefix":"","content.item.og.title.suffix":" - NibblePoker","content.commons.version.current":"Current version","content.commons.version.previous.single":"Previous version","content.commons.version.previous.multiple":"Previous versions","content.commons.version.old.single":"Old version","content.commons.version.old.multiple":"Old versions","content.commons.version.source":"Source code","content.commons.cpu":"CPU Architecture","content.commons.cpu.responsive":"CPU Architecture","content.commons.cpu.any":"Any architecture","content.commons.cpu.x64":"x64","content.commons.cpu.x86":"x86","content.commons.cpu.arm":"arm","content.commons.cpu.arm64":"arm64","content.commons.na.italic":"N/A","content.commons.na":"N/A","content.commons.lang":"Language","content.commons.download.single":"Download","content.commons.download.multiple":"Downloads","content.commons.version":"Version","content.commons.github":"GitHub Repository","content.commons.gitea":"Self-hosted Gitea Repository","content.commons.nuget":"Nuget Package","content.commons.license.mit.single":"MIT License","content.commons.lang.english":"English","content.commons.lang.french":"French","content.commons.lang.luxembourgish":"Luxembourgish","content.commons.lang.english.639-3":"English (eng)","content.commons.lang.french.639-3":"French (fra)","content.commons.lang.luxembourgish.639-3":"Luxembourgish (ltz)","error.403.head.title":"403 - NibblePoker","error.403.head.description":"Access to the requested resource isn't unauthorized.","error.403.og.title":"NibblePoker - 403 Error","error.403.og.description":"Access to the requested resource isn't unauthorized.","error.403.header.title":"Error\u2771403 Error","error.404.head.title":"404 - NibblePoker","error.404.head.description":"The server couldn't find the requested resource.","error.404.og.title":"NibblePoker - 404 Error","error.404.og.description":"The server couldn't find the requested resource.","error.404.header.title":"Error\u2771404 Error","error.500.head.title":"500 - NibblePoker","error.500.head.description":"The server has encountered a situation it doesn't know how to handle.","error.500.og.title":"NibblePoker - 500 Error","error.500.og.description":"The server has encountered a situation it doesn't know how to handle.","error.500.header.title":"Error\u2771500 Error","error.skit.pc.dead":"Drawing of an old PC with a face with crossed eyes.","footer.text.privacy":"Privacy policy","footer.alt.sidebar.button":"Open and close the navigation sidebar.","footer.alt.logo":"Website's logo","home.head.title":"NibblePoker","home.head.description":"TODO: description","home.og.title":"NibblePoker","home.og.description":"TODO: description","home.header.title":"Homepage","home.showcase.title":"Showcase","home.updates.title":"Updates","home.updates.text.privacy":"\u25cf  Updated our privacy policy.","home.updates.2.date":"August 15 2023","home.updates.2.text.1":"\u25cf  The website is back online.","home.updates.2.text.2":"\u25cf  New and much lighter design.","home.updates.2.text.3":"\u25cf  Changed our host to HostBrr.","home.updates.2.text.4":"\u25cf  Added a section for web-based tools.","home.updates.1.date":"September 9 2022","home.updates.1.text.1":"\u25cf  Changed our host to v6Node.","lang.menu.title":"Language","lang.current":"English","lang.automatic":"Automatic","lang.english":"English","lang.french":"French","lang.german":"German","lang.luxembourgish":"Luxembourgish","links.head.title":"Links - NibblePoker","links.head.description":"TODO: description","links.og.title":"NibblePoker - Links","links.og.description":"TODO: description","links.header.title":"Links","privacy.head.title":"Privacy policy - NibblePoker","privacy.head.description":"Our privacy policy in a clear and easy to understand format.","privacy.og.title":"NibblePoker - Privacy Policy","privacy.og.description":"Our privacy policy in a clear and easy to understand format.","privacy.header.title":"Privacy policy","privacy.introduction.title":"Introduction","privacy.introduction.text.1":"This privacy policy is written in accordance with the 12th and 13th articles of the GDPR.","privacy.introduction.text.2":"If you wish to consult it, you can do so on the following websites:","privacy.contact.title":"How to contact us ?","privacy.contact.text.1":"If you wish to contact us for more information regarding our privacy policy, please contact us via the form included on the contact page, or at the following email address:","privacy.complaint.title":"How to contact the appropriate authorities ?","privacy.complaint.text.1":"Should you wish to report a complaint or if you feel that our privacy policy has not addressed your concern in a satisfactory manner, you may contact your national Data Protection Authority (DPA).","privacy.complaint.text.2":"More information on this procedure can be found on the following websites:","privacy.v2.data.title":"Data collection","privacy.v2.data.intro.1":"This websites only collects data through generic access logs in order to detect and block bad actors from accessing this website.","privacy.v2.data.intro.2":"None of the data collected is used for any other purpose, it is never shared with any other third-party and is never use in any sort of analytics.","privacy.v2.data.private.1":"Here is the list of private data being collected:","privacy.v2.data.private_list.1":"IP address","privacy.v2.data.private_list.2":"Browser's User-Agent","privacy.v2.data.non_private.1":"And here is the list of non-private data being collected:","privacy.v2.data.non_private_list.1":"Requested resource' URI","privacy.v2.data.non_private_list.2":"Date and time","privacy.v2.data.end.1":"Once the data has been logged in the access logs, it is automatically retrieved and processed by a locally-hosted application every 30 seconds and then deleted from said logs.","privacy.v2.data.end.2":"This application compares this information against a list of known threat sources, targets and behaviours and if a match is found, the private information is anonymized and stored for 7 days pending a manual review.","privacy.v2.data.end.3":"Once that 7 day period has elapsed, or once the report has been reviewed, all the relevant data is automatically deleted.","privacy.v2.data.end.4":"If your request wasn't flagged as potentially malicious, every data collected from it is thrown out instantly.","privacy.v2.data.end.5":"This process should normally never be triggered for regular traffic since most of the triggering actions are ones that should not be possible to accomplish through normal browsing.","privacy.v2.data.end.6":"However, this process isn't infallible and there is always an off chance that false positives may happen.","privacy.v2.update.title":"Changes to our privacy policy","privacy.v2.update.intro.1":"The content of this privacy policy was originally written on the 4th of December 2021 and was last updated on the 18th of March 2022.","privacy.v2.update.history.1.date":"2021/12/04","privacy.v2.update.history.1.desc.1":"Original version","privacy.v2.update.history.2.date":"2022/03/18","privacy.v2.update.history.2.desc.1":"Changed section on data collection to reflect new policy.","privacy.v2.update.history.2.desc.2":"Added mention about CloudFlare and linked to their privacy policy.","privacy.v2.update.history.2.desc.3":"Improved the \"Changes to our privacy policy\" section.","privacy.v2.update.history.3.date":"2022/09/09","privacy.v2.update.history.3.desc.1":"Changed references to external services to reflect the migration to v6Node.","privacy.v2.update.history.3.desc.1.1":"Added mention about v6Node and linked to their privacy policy.","privacy.v2.update.history.3.desc.1.2":"Removed mentions of CloudFlare.","privacy.v2.update.history.3.desc.2":"Changed the \"Cookies\" section to indicate that none should be used on public domains.","privacy.v2.update.end.2":"In the event of a change to our privacy policy, you will be informed explicitly, and a copy of previous versions of the policy will be available through this page.","privacy.v2.third.title":"Third Parties","privacy.v2.third.intro.1":"Our websites uses some services provided by v6Node in order to prevent bad actors from accessing this website and in order to put in place a reverse-proxy system.","privacy.v2.third.intro.2":"The goal of this system is to improve your browsing experience with the help of a private caching service and custom traffic filtering rules.","privacy.v2.third.intro.3":"None of the data that may be gathered by v6Node or the system described above is ever used or stored.","privacy.v2.third.intro.4":"If you'd wish to consult their privacy policy and their partners', you can do so by using the following URLs:","privacy.v2.cookies.title":"Cookies","privacy.v2.cookies.intro.1":"Our websites doesn't use nor store any cookies in your browser.","privacy.v2.personal.title":"Personal Measures & Convictions","privacy.v2.personal.disabled.intro":"While not required by any laws, we decided to improve your online privacy by disabling some features:","privacy.v2.personal.disabled.list.1":"Disabling hidden HTTP Referer system.","privacy.v2.personal.disabled.list.2":"Disabling Google's predatory Topics API and defunct Cohort ad-serving systems.","privacy.v2.personal.disabled.list.3":"Preventing any external third-party code from being injected into the page.","privacy.v2.personal.tracking.text.1":"It is our belief that the web and modern technology in general should never be used to track and spy on people in any way shape or form.","privacy.v2.personal.tracking.text.2":"We believe that any service that is in any way trying to force you to disable any ad-blocking or privacy-enhancing extensions should be avoided at all cost and shunned for their practices.","privacy.v2.personal.tracking.text.3":"Modern website should never break with those type of extensions unless they are purposefully built to track you to near-illegal extents, this excuse is only used to force you to accept these predatory practices.","privacy.v2.personal.recommendations":"We also strongly recommend you to read the ENISA's Privacy considerations of online behavioural tracking report in order to improve your online privacy.","sidebar.alt.logo":"Website's logo","sidebar.text.home":"Home","sidebar.text.projects":"Projects","sidebar.text.applications":"Applications","sidebar.text.libraries":"Libraries","sidebar.text.electronics":"Electronics","sidebar.text.tools":"Tools","sidebar.text.links":"Links","sidebar.text.downloads":"Downloads","sidebar.text.gitea":"Git Repos.","sidebar.text.wiki":"Wiki","sidebar.text.about":"About","sidebar.text.contact":"Contact","tools.head.title":"Tools - NibblePoker","tools.head.description":"TODO: description","tools.og.title":"NibblePoker - Tools","tools.og.description":"TODO: description","tools.header.title":"Tools"},"fr":{"about.head.title":"\u00c0-propos - NibblePoker","about.head.description":"TODO: description","about.og.title":"NibblePoker - \u00c0-propos","about.og.description":"TODO: description","about.header.title":"\u00c0-propos","contact.head.title":"Contact - NibblePoker","contact.head.description":"TODO: description","contact.og.title":"NibblePoker - Contact","contact.og.description":"TODO: description","contact.header.title":"Contact","contact.email.title":"Courriel","contact.email.compose":"Envoyer un courriel \u00e0 herwin.bozet@gmail.com","contact.twitter.title":"Twitter","contact.twitter.compose":"Composer un message priv\u00e9 pour @NibblePoker sur Twitter","content.search.head.title":"Recherche de contenu - NibblePoker","content.search.head.description":"TODO: description","content.search.og.title":"NibblePoker - Recherche de contenu","content.search.og.description":"TODO: description","content.search.heading.main.single":"R\u00e9sultat de recherche","content.search.heading.main.multiple":"R\u00e9sultats de recherche","content.search.count.single":"r\u00e9sultat","content.search.count.multiple":"r\u00e9sultats","content.header.base":"Projets","content.search.header":"Recherche","content.error.header":"Erreur","content.error.head.title":"Erreur de contenu - NibblePoker","content.error.og.title":"NibblePoker - Erreur de contenu","content.error.heading.main.search":"Erreur de recherche","content.error.heading.main.content":"Erreur de contenu","content.error.heading.main.fallback":"Erreur inconnue","content.error.message.none":"Aucune erreur n'a \u00e9t\u00e9 d\u00e9tect\u00e9e.","content.error.message.tags.length":"Le param\u00e8tre d'URL \"tags\" est trop long.","content.error.message.tags.alphanumeric":"Un des tags donn\u00e9 dans le param\u00e8tre d'URL \"tags\" n'est pas une cha\u00eene de texte alphanum\u00e9rique valide.","content.error.message.detect.empty":"Aucun contenu en rapport avec les tags choisi n'as \u00e9t\u00e9 trouv\u00e9.","content.error.message.id.alphanumeric":"L'ID de la ressource demand\u00e9e n'est pas une cha\u00eene de texte alphanum\u00e9rique valide.","content.error.message.data.not.exist":"Le contenu demand\u00e9e n'a pas de fichier de rendu interne associ\u00e9.","content.error.message.cannot.load":"Le contenu demand\u00e9 n'a pas pu \u00eatre charg\u00e9 de notre c\u00f4t\u00e9 !","content.error.message.data.no.tags":"Aucun tag trouv\u00e9 !","content.error.message.data.no.title":"Aucun titre trouv\u00e9 !","content.item.head.title.prefix":"","content.item.head.title.suffix":" - NibblePoker","content.item.og.title.prefix":"","content.item.og.title.suffix":" - NibblePoker","content.commons.version.current":"Version actuelle","content.commons.version.previous.single":"Version pr\u00e9c\u00e9dente","content.commons.version.previous.multiple":"Versions pr\u00e9c\u00e9dentes","content.commons.version.old.single":"Ancienne version","content.commons.version.old.multiple":"Anciennes versions","content.commons.version.source":"Code source","content.commons.cpu":"Architecture de CPU","content.commons.cpu.any":"Ind\u00e9pendante","content.commons.cpu.x64":"x64","content.commons.cpu.x86":"x86","content.commons.cpu.arm":"arm","content.commons.cpu.arm64":"arm64","content.commons.na.italic":"N/A","content.commons.na":"N/A","content.commons.lang":"Langue","content.commons.download.single":"T\u00e9l\u00e9chargement","content.commons.download.multiple":"T\u00e9l\u00e9chargements","content.commons.version":"Version","content.commons.github":"D\u00e9p\u00f4t GitHub","content.commons.gitea":"D\u00e9p\u00f4t Gitea auto-h\u00e9berg\u00e9","content.commons.nuget":"Packet Nuget","content.commons.license.mit.single":"License MIT","content.commons.lang.english":"Anglais","content.commons.lang.french":"Fran\u00e7ais","content.commons.lang.luxembourgish":"Luxembourgeois","content.commons.lang.english.639-3":"Anglais (eng)","content.commons.lang.french.639-3":"Fran\u00e7ais (fra)","content.commons.lang.luxembourgish.639-3":"Luxembourgeois (ltz)","footer.text.privacy":"Politique de confidentialit\u00e9","footer.alt.sidebar.button":"Ouvrir et fermer le menu lat\u00e9ral de navigation.","footer.alt.logo":"Logo du site web","home.head.title":"NibblePoker","home.head.description":"TODO: description","home.og.title":"NibblePoker","home.og.description":"TODO: description","home.header.title":"Page d'accueil","home.showcase.title":"Vitrine","home.updates.title":"Updates","home.updates.text.privacy":"\u25cf  Mise-\u00e0-jour de notre politique de confidentialit\u00e9.","home.updates.2.date":"15 Ao\u00fbt 2023","home.updates.2.text.1":"\u25cf  Le site internet est \u00e0 nouveau disponible.","home.updates.2.text.2":"\u25cf  Mise en place d'un nouveau design plus l\u00e9ger.","home.updates.2.text.3":"\u25cf  Changement d'h\u00e9bergeur vers HostBrr.","home.updates.2.text.4":"\u25cf  Ajout d'une nouvelle section pour les outils.","home.updates.1.date":" 9 Septembre 2022","home.updates.1.text.1":"\u25cf  Changement d'h\u00e9bergeur vers v6Node.","lang.menu.title":"Langue","lang.current":"Fran\u00e7ais","lang.automatic":"Automatique","lang.english":"Anglais","lang.french":"Fran\u00e7ais","lang.german":"Allemand","lang.luxembourgish":"Luxembourgeois","links.head.title":"Liens - NibblePoker","links.head.description":"TODO: description","links.og.title":"NibblePoker - Liens","links.og.description":"TODO: description","links.header.title":"Liens","privacy.head.title":"Politique de confidentialit\u00e9 - NibblePoker","privacy.head.description":"Notre politique de confidentialit\u00e9 dans un format clair et compr\u00e9hensible.","privacy.og.title":"NibblePoker - Politique de confidentialit\u00e9","privacy.og.description":"Notre politique de confidentialit\u00e9 dans un format clair et compr\u00e9hensible.","privacy.header.title":"Politique de confidentialit\u00e9","privacy.introduction.title":"Introduction","privacy.introduction.text.1":"La politique de confidentialit\u00e9 ci-pr\u00e9sente a \u00e9t\u00e9 \u00e9crite en accord avec les articles 12 et 13 de la RGPD.","privacy.introduction.text.2":"Si vous souhaitez consulter le texte officiel en question, vous pouvez le faire sur les sites internet suivants :","privacy.contact.title":"Comment nous contacter ?","privacy.contact.text.1":"Si vous souhaitez nous contacter afin d'obtenir plus d'informations concernant notre politique de confidentialit\u00e9, nous vous recommandons d'utiliser le formulaire pr\u00e9sent sur la page de contact, ou par courriel \u00e0 l'adresse suivante:","privacy.complaint.title":"Comment contacter les autorit\u00e9s comp\u00e9tentes ?","privacy.complaint.text.1":"Dans l'\u00e9ventualit\u00e9 o\u00f9 vous souhaiteriez d\u00e9poser une plainte pour une quelconque raison en rapport avec notre politique de confidentialit\u00e9, veuillez vous adresser \u00e0 l'autorit\u00e9 nationale de protection des donn\u00e9es (DPA).","privacy.complaint.text.2":"Les informations concernant cette proc\u00e9dure peuvent \u00eatre trouv\u00e9es sur les sites internet suivants:","privacy.v2.data.title":"Collecte de donn\u00e9es","privacy.v2.data.intro.1":"Ce site web collecte des donn\u00e9es au travers des journaux d'\u00e9v\u00e8nements afin de d\u00e9tecter et bloquer de potentiels acteurs malveillants.","privacy.v2.data.intro.2":"Les donn\u00e9es collect\u00e9es ne sont en aucun cas utilis\u00e9es pour une quelconque autre raison.","privacy.v2.data.private.1":"Voici la liste des donn\u00e9es personelles collect\u00e9es:","privacy.v2.data.private_list.1":"L'addresse IP source","privacy.v2.data.private_list.2":"Le \"User-Agent\" de votre navigateur internet","privacy.v2.data.non_private.1":"Et voici la liste des donn\u00e9es non-personelles collect\u00e9es:","privacy.v2.data.non_private_list.1":"L'URI de la ressource demand\u00e9e","privacy.v2.data.non_private_list.2":"La date et l'heure","privacy.v2.data.end.1":"Les donn\u00e9es pr\u00e9sentes dans les journaux d'\u00e9v\u00e8nements sont extraites et retir\u00e9es pour \u00eatre trait\u00e9es par une application qui tourne en local toute les 30 secondes.","privacy.v2.data.end.2":"L'application en question utilise et compare ces informations avec une liste d'acteurs malveillants et comportement suspects connus.
Si une correspondance est d\u00e9tect\u00e9e, les informations priv\u00e9es sont anonymis\u00e9es et sont stock\u00e9es pendant 7 jours en attendant qu'un examen manuel soit effectu\u00e9.","privacy.v2.data.end.3":"Apr\u00e8s cette p\u00e9riode de 7 jours, ou apr\u00e8s qu'un examen ait \u00e9t\u00e9 effectu\u00e9, les donn\u00e9es sont automatiquement supprim\u00e9es.","privacy.v2.data.end.4":"Toute information concernant une requ\u00eate non suspecte est automatiquement supprim\u00e9e.","privacy.v2.data.end.5":"Ce processus n'est normalement jamais utilis\u00e9 sur des requ\u00eates provenant d'un trafic l\u00e9gitime d\u00fb au fait qu'il isole principalement les actions et requ\u00eates qui ne devraient pas \u00eatre possible sur ce site.","privacy.v2.data.end.6":"Cependant, ce processus n'est pas infaillible et il est toujours possible qu'une requ\u00eate soit isol\u00e9e par erreur.","privacy.v2.update.title":"Changements \u00e0 notre politique de confidentialit\u00e9","privacy.v2.update.intro.1":"Le contenu de notre politique de confidentialit\u00e9 a \u00e9t\u00e9 originalement \u00e9crit et le 4 d\u00e9cembre 2021 modifi\u00e9 pour la derni\u00e8re fois le 18 mars 2022.","privacy.v2.update.history.1.date":"2021/12/04","privacy.v2.update.history.1.desc.1":"Version originale","privacy.v2.update.history.2.date":"2022/03/18","privacy.v2.update.history.2.desc.1":"Mise-\u00e0-jour de la section sur la collection des donn\u00e9es.","privacy.v2.update.history.2.desc.2":"Ajout d'une mention de CloudFlare et ajout de liens vers leur politique de confidentialit\u00e9.","privacy.v2.update.history.2.desc.3":"Am\u00e9lioration de la section \"Changements \u00e0 notre politique de confidentialit\u00e9\".","privacy.v2.update.history.3.date":"2022/09/09","privacy.v2.update.history.3.desc.1":"Changement des r\u00e9f\u00e9rences aux services externes pour indiquer l'utilisation de v6Node.","privacy.v2.update.history.3.desc.1.1":"Ajout de mentions de v6Node et liens vers leur politique de vie confidentialit\u00e9.","privacy.v2.update.history.3.desc.1.2":"Suppression de mentions de CloudFlare.","privacy.v2.update.history.3.desc.2":"Changement de la section \"Cookies\" afin d'indiquer qu'ils ne seront plus utilis\u00e9s sur les domaines publics.","privacy.v2.update.end.2":"En cas de changement, vous serez clairement inform\u00e9 et une copie des anciennes versions de notre politique sera disponible au travers de cette page.","privacy.v2.third.title":"Organismes tiers","privacy.v2.third.intro.1":"Ce site web utilise les services propos\u00e9s par v6Node afin d'emp\u00eacher des acteurs malveillants d'y acc\u00e9der et dans le but de mettre en place un syst\u00e8me de reverse-proxy.","privacy.v2.third.intro.2":"Ceci a pour but d'am\u00e9liorer l'exp\u00e9rience des personnes le visitant gr\u00e2ce \u00e0 un syst\u00e8me de filtrage et caching priv\u00e9.","privacy.v2.third.intro.3":"Aucune des donn\u00e9es collect\u00e9es et stock\u00e9es par v6Node et le syst\u00e8me d\u00e9cris ci-dessus n'est utilis\u00e9 ou stock\u00e9.","privacy.v2.third.intro.4":"Si vous souhaitez consulter leur politique de confidentialit\u00e9 ainsi que celle de leur partenaires, vous pouvez le faire en suivant les liens ci-dessous:","privacy.v2.cookies.title":"Cookies de navigation","privacy.v2.cookies.intro.1":"Ce site web n'utilise pas, et ne stocke aucun cookies dans votre navigateur internet.","sidebar.alt.logo":"Logo du site web","sidebar.text.home":"Accueil","sidebar.text.projects":"Projets","sidebar.text.applications":"Applications","sidebar.text.libraries":"Librairies","sidebar.text.electronics":"\u00c9lectronique","sidebar.text.tools":"Outils","sidebar.text.links":"Liens","sidebar.text.downloads":"T\u00e9l\u00e9chargements","sidebar.text.gitea":"D\u00e9p\u00f4ts Git","sidebar.text.wiki":"Wiki","sidebar.text.about":"\u00c0-propos","sidebar.text.contact":"Contact","tools.head.title":"Outils - NibblePoker","tools.head.description":"TODO: description","tools.og.title":"NibblePoker - Outils","tools.og.description":"TODO: description","tools.header.title":"Outils"}} \ No newline at end of file +{"_compile_date":"2023-08-16T09:13:20.823019Z","en":{"about.head.title":"About - NibblePoker","about.head.description":"TODO: description","about.og.title":"NibblePoker - About","about.og.description":"TODO: description","about.header.title":"About","about.part.year.single":"year","about.part.year.multiple":"years","about.part.since":"since","about.education.title":"Education","about.skills.title":"Skills","about.work.title":"Work Experience","about.work.ctie.title":"Government IT Centre (CTIE)","about.work.ctie.role.1":"IoT Developer Internship","about.work.ctie.location":"Luxembourg","about.work.computrade.title":"CompuTrade Luxembourg Ltd","about.work.computrade.role.1":"Full & Half-time student job","about.work.computrade.location":"Steinfort, Luxembourg","about.work.lih.title":"Luxembourg Institute of Health (LIH)","about.work.lih.role.1":"IT Support Internship","about.work.lih.location":"Luxembourg","about.work.crlux.title":"Luxembourg Red Cross","about.work.crlux.role.1":"Volunteer Excel VBA programmer.","about.work.crlux.location":"Luxembourg","about.work.buttek.title":"Luxembourg Red Cross - Buttek","about.work.buttek.role.1":"Volunteer ???","about.work.buttek.role.2":"Student cashier ???","about.work.buttek.location":"Luxembourg","about.work.current.title":"Current employer kept private","about.work.current.role.1":"???","about.work.current.location":"Belgium","contact.head.title":"Contact - NibblePoker","contact.head.description":"TODO: description","contact.og.title":"NibblePoker - Contact","contact.og.description":"TODO: description","contact.header.title":"Contact","contact.email.title":"Email","contact.email.compose":"Send an email to herwin.bozet@gmail.com","contact.twitter.title":"Twitter","contact.twitter.compose":"Compose DM to @NibblePoker on Twitter","content.search.head.title":"Content search - NibblePoker","content.search.head.description":"TODO: description","content.search.og.title":"NibblePoker - Content search","content.search.og.description":"TODO: description","content.search.heading.main.single":"Search result","content.search.heading.main.multiple":"Search results","content.search.count.single":"result","content.search.count.multiple":"results","content.header.base":"Projects","content.search.header":"Search","content.error.header":"Error","content.error.head.title":"Content error - NibblePoker","content.error.og.title":"NibblePoker - Content error","content.error.heading.main.search":"Search error","content.error.heading.main.content":"Content error","content.error.heading.main.fallback":"Unknown error","content.error.message.none":"No explicit error was encountered.","content.error.message.tags.length":"The \"tags\" URL parameter is too long.","content.error.message.tags.alphanumeric":"One of the tags given in the \"tags\" URL parameter is not a valid alphanumeric string.","content.error.message.detect.empty":"No content could be found for the given tags.","content.error.message.id.alphanumeric":"The requested resource's ID isn't a valid alphanumeric string.","content.error.message.data.not.exist":"The requested content doesn't have an internal item file associated to it.","content.error.message.cannot.load":"The requested content couldn't be loaded on our end !","content.error.message.data.no.tags":"No tags found !","content.error.message.data.no.title":"No title found !","content.item.head.title.prefix":"","content.item.head.title.suffix":" - NibblePoker","content.item.og.title.prefix":"","content.item.og.title.suffix":" - NibblePoker","content.commons.version.current":"Current version","content.commons.version.previous.single":"Previous version","content.commons.version.previous.multiple":"Previous versions","content.commons.version.old.single":"Old version","content.commons.version.old.multiple":"Old versions","content.commons.version.source":"Source code","content.commons.cpu":"CPU Architecture","content.commons.cpu.responsive":"CPU Architecture","content.commons.cpu.any":"Any architecture","content.commons.cpu.x64":"x64","content.commons.cpu.x86":"x86","content.commons.cpu.arm":"arm","content.commons.cpu.arm64":"arm64","content.commons.na.italic":"N/A","content.commons.na":"N/A","content.commons.lang":"Language","content.commons.download.single":"Download","content.commons.download.multiple":"Downloads","content.commons.version":"Version","content.commons.github":"GitHub Repository","content.commons.gitea":"Self-hosted Gitea Repository","content.commons.nuget":"Nuget Package","content.commons.license.mit.single":"MIT License","content.commons.lang.english":"English","content.commons.lang.french":"French","content.commons.lang.luxembourgish":"Luxembourgish","content.commons.lang.english.639-3":"English (eng)","content.commons.lang.french.639-3":"French (fra)","content.commons.lang.luxembourgish.639-3":"Luxembourgish (ltz)","error.403.head.title":"403 - NibblePoker","error.403.head.description":"Access to the requested resource isn't unauthorized.","error.403.og.title":"NibblePoker - 403 Error","error.403.og.description":"Access to the requested resource isn't unauthorized.","error.403.header.title":"Error\u2771403 Error","error.404.head.title":"404 - NibblePoker","error.404.head.description":"The server couldn't find the requested resource.","error.404.og.title":"NibblePoker - 404 Error","error.404.og.description":"The server couldn't find the requested resource.","error.404.header.title":"Error\u2771404 Error","error.500.head.title":"500 - NibblePoker","error.500.head.description":"The server has encountered a situation it doesn't know how to handle.","error.500.og.title":"NibblePoker - 500 Error","error.500.og.description":"The server has encountered a situation it doesn't know how to handle.","error.500.header.title":"Error\u2771500 Error","error.skit.pc.dead":"Drawing of an old PC with a face with crossed eyes.","footer.text.privacy":"Privacy policy","footer.alt.sidebar.button":"Open and close the navigation sidebar.","footer.alt.logo":"Website's logo","home.head.title":"NibblePoker","home.head.description":"TODO: description","home.og.title":"NibblePoker","home.og.description":"TODO: description","home.header.title":"Homepage","home.showcase.title":"Showcase","home.updates.title":"Updates","home.updates.text.privacy":"\u25cf  Updated our privacy policy.","home.updates.2.date":"August 15 2023","home.updates.2.text.1":"\u25cf  The website is back online.","home.updates.2.text.2":"\u25cf  New and much lighter design.","home.updates.2.text.3":"\u25cf  Changed our host to HostBrr.","home.updates.2.text.4":"\u25cf  Added a section for web-based tools.","home.updates.1.date":"September 9 2022","home.updates.1.text.1":"\u25cf  Changed our host to v6Node.","lang.menu.title":"Language","lang.current":"English","lang.automatic":"Automatic","lang.english":"English","lang.french":"French","lang.german":"German","lang.luxembourgish":"Luxembourgish","links.head.title":"Links - NibblePoker","links.head.description":"TODO: description","links.og.title":"NibblePoker - Links","links.og.description":"TODO: description","links.header.title":"Links","privacy.head.title":"Privacy policy - NibblePoker","privacy.head.description":"Our privacy policy in a clear and easy to understand format.","privacy.og.title":"NibblePoker - Privacy Policy","privacy.og.description":"Our privacy policy in a clear and easy to understand format.","privacy.header.title":"Privacy policy","privacy.introduction.title":"Introduction","privacy.introduction.text.1":"This privacy policy is written in accordance with the 12th and 13th articles of the GDPR.","privacy.introduction.text.2":"If you wish to consult it, you can do so on the following websites:","privacy.contact.title":"How to contact us ?","privacy.contact.text.1":"If you wish to contact us for more information regarding our privacy policy, please contact us via the form included on the contact page, or at the following email address:","privacy.complaint.title":"How to contact the appropriate authorities ?","privacy.complaint.text.1":"Should you wish to report a complaint or if you feel that our privacy policy has not addressed your concern in a satisfactory manner, you may contact your national Data Protection Authority (DPA).","privacy.complaint.text.2":"More information on this procedure can be found on the following websites:","privacy.v2.data.title":"Data collection","privacy.v2.data.intro.1":"This websites only collects data through generic access logs in order to detect and block bad actors from accessing this website.","privacy.v2.data.intro.2":"None of the data collected is used for any other purpose, it is never shared with any other third-party and is never use in any sort of analytics.","privacy.v2.data.private.1":"Here is the list of private data being collected:","privacy.v2.data.private_list.1":"IP address","privacy.v2.data.private_list.2":"Browser's User-Agent","privacy.v2.data.non_private.1":"And here is the list of non-private data being collected:","privacy.v2.data.non_private_list.1":"Requested resource' URI","privacy.v2.data.non_private_list.2":"Date and time","privacy.v2.data.end.1":"Once the data has been logged in the access logs, it is automatically retrieved and processed by a locally-hosted application every 30 seconds and then deleted from said logs.","privacy.v2.data.end.2":"This application compares this information against a list of known threat sources, targets and behaviours and if a match is found, the private information is anonymized and stored for 7 days pending a manual review.","privacy.v2.data.end.3":"Once that 7 day period has elapsed, or once the report has been reviewed, all the relevant data is automatically deleted.","privacy.v2.data.end.4":"If your request wasn't flagged as potentially malicious, every data collected from it is thrown out instantly.","privacy.v2.data.end.5":"This process should normally never be triggered for regular traffic since most of the triggering actions are ones that should not be possible to accomplish through normal browsing.","privacy.v2.data.end.6":"However, this process isn't infallible and there is always an off chance that false positives may happen.","privacy.v2.update.title":"Changes to our privacy policy","privacy.v2.update.intro.1":"The content of this privacy policy was originally written on the 4th of December 2021 and was last updated on the 18th of March 2022.","privacy.v2.update.history.1.date":"2021/12/04","privacy.v2.update.history.1.desc.1":"Original version","privacy.v2.update.history.2.date":"2022/03/18","privacy.v2.update.history.2.desc.1":"Changed section on data collection to reflect new policy.","privacy.v2.update.history.2.desc.2":"Added mention about CloudFlare and linked to their privacy policy.","privacy.v2.update.history.2.desc.3":"Improved the \"Changes to our privacy policy\" section.","privacy.v2.update.history.3.date":"2022/09/09","privacy.v2.update.history.3.desc.1":"Changed references to external services to reflect the migration to v6Node.","privacy.v2.update.history.3.desc.1.1":"Added mention about v6Node and linked to their privacy policy.","privacy.v2.update.history.3.desc.1.2":"Removed mentions of CloudFlare.","privacy.v2.update.history.3.desc.2":"Changed the \"Cookies\" section to indicate that none should be used on public domains.","privacy.v2.update.end.2":"In the event of a change to our privacy policy, you will be informed explicitly, and a copy of previous versions of the policy will be available through this page.","privacy.v2.third.title":"Third Parties","privacy.v2.third.intro.1":"Our websites uses some services provided by v6Node in order to prevent bad actors from accessing this website and in order to put in place a reverse-proxy system.","privacy.v2.third.intro.2":"The goal of this system is to improve your browsing experience with the help of a private caching service and custom traffic filtering rules.","privacy.v2.third.intro.3":"None of the data that may be gathered by v6Node or the system described above is ever used or stored.","privacy.v2.third.intro.4":"If you'd wish to consult their privacy policy and their partners', you can do so by using the following URLs:","privacy.v2.cookies.title":"Cookies","privacy.v2.cookies.intro.1":"Our websites doesn't use nor store any cookies in your browser.","privacy.v2.personal.title":"Personal Measures & Convictions","privacy.v2.personal.disabled.intro":"While not required by any laws, we decided to improve your online privacy by disabling some features:","privacy.v2.personal.disabled.list.1":"Disabling hidden HTTP Referer system.","privacy.v2.personal.disabled.list.2":"Disabling Google's predatory Topics API and defunct Cohort ad-serving systems.","privacy.v2.personal.disabled.list.3":"Preventing any external third-party code from being injected into the page.","privacy.v2.personal.tracking.text.1":"It is our belief that the web and modern technology in general should never be used to track and spy on people in any way shape or form.","privacy.v2.personal.tracking.text.2":"We believe that any service that is in any way trying to force you to disable any ad-blocking or privacy-enhancing extensions should be avoided at all cost and shunned for their practices.","privacy.v2.personal.tracking.text.3":"Modern website should never break with those type of extensions unless they are purposefully built to track you to near-illegal extents, this excuse is only used to force you to accept these predatory practices.","privacy.v2.personal.recommendations":"We also strongly recommend you to read the ENISA's Privacy considerations of online behavioural tracking report in order to improve your online privacy.","sidebar.alt.logo":"Website's logo","sidebar.text.home":"Home","sidebar.text.projects":"Projects","sidebar.text.applications":"Applications","sidebar.text.libraries":"Libraries","sidebar.text.electronics":"Electronics","sidebar.text.tools":"Tools","sidebar.text.links":"Links","sidebar.text.downloads":"Downloads","sidebar.text.gitea":"Git Repos.","sidebar.text.wiki":"Wiki","sidebar.text.about":"About","sidebar.text.contact":"Contact","tools.head.title":"Tools - NibblePoker","tools.head.description":"TODO: description","tools.og.title":"NibblePoker - Tools","tools.og.description":"TODO: description","tools.header.title":"Tools"},"fr":{"about.head.title":"\u00c0-propos - NibblePoker","about.head.description":"TODO: description","about.og.title":"NibblePoker - \u00c0-propos","about.og.description":"TODO: description","about.header.title":"\u00c0-propos","contact.head.title":"Contact - NibblePoker","contact.head.description":"TODO: description","contact.og.title":"NibblePoker - Contact","contact.og.description":"TODO: description","contact.header.title":"Contact","contact.email.title":"Courriel","contact.email.compose":"Envoyer un courriel \u00e0 herwin.bozet@gmail.com","contact.twitter.title":"Twitter","contact.twitter.compose":"Composer un message priv\u00e9 pour @NibblePoker sur Twitter","content.search.head.title":"Recherche de contenu - NibblePoker","content.search.head.description":"TODO: description","content.search.og.title":"NibblePoker - Recherche de contenu","content.search.og.description":"TODO: description","content.search.heading.main.single":"R\u00e9sultat de recherche","content.search.heading.main.multiple":"R\u00e9sultats de recherche","content.search.count.single":"r\u00e9sultat","content.search.count.multiple":"r\u00e9sultats","content.header.base":"Projets","content.search.header":"Recherche","content.error.header":"Erreur","content.error.head.title":"Erreur de contenu - NibblePoker","content.error.og.title":"NibblePoker - Erreur de contenu","content.error.heading.main.search":"Erreur de recherche","content.error.heading.main.content":"Erreur de contenu","content.error.heading.main.fallback":"Erreur inconnue","content.error.message.none":"Aucune erreur n'a \u00e9t\u00e9 d\u00e9tect\u00e9e.","content.error.message.tags.length":"Le param\u00e8tre d'URL \"tags\" est trop long.","content.error.message.tags.alphanumeric":"Un des tags donn\u00e9 dans le param\u00e8tre d'URL \"tags\" n'est pas une cha\u00eene de texte alphanum\u00e9rique valide.","content.error.message.detect.empty":"Aucun contenu en rapport avec les tags choisi n'as \u00e9t\u00e9 trouv\u00e9.","content.error.message.id.alphanumeric":"L'ID de la ressource demand\u00e9e n'est pas une cha\u00eene de texte alphanum\u00e9rique valide.","content.error.message.data.not.exist":"Le contenu demand\u00e9e n'a pas de fichier de rendu interne associ\u00e9.","content.error.message.cannot.load":"Le contenu demand\u00e9 n'a pas pu \u00eatre charg\u00e9 de notre c\u00f4t\u00e9 !","content.error.message.data.no.tags":"Aucun tag trouv\u00e9 !","content.error.message.data.no.title":"Aucun titre trouv\u00e9 !","content.item.head.title.prefix":"","content.item.head.title.suffix":" - NibblePoker","content.item.og.title.prefix":"","content.item.og.title.suffix":" - NibblePoker","content.commons.version.current":"Version actuelle","content.commons.version.previous.single":"Version pr\u00e9c\u00e9dente","content.commons.version.previous.multiple":"Versions pr\u00e9c\u00e9dentes","content.commons.version.old.single":"Ancienne version","content.commons.version.old.multiple":"Anciennes versions","content.commons.version.source":"Code source","content.commons.cpu":"Architecture de CPU","content.commons.cpu.any":"Ind\u00e9pendante","content.commons.cpu.x64":"x64","content.commons.cpu.x86":"x86","content.commons.cpu.arm":"arm","content.commons.cpu.arm64":"arm64","content.commons.na.italic":"N/A","content.commons.na":"N/A","content.commons.lang":"Langue","content.commons.download.single":"T\u00e9l\u00e9chargement","content.commons.download.multiple":"T\u00e9l\u00e9chargements","content.commons.version":"Version","content.commons.github":"D\u00e9p\u00f4t GitHub","content.commons.gitea":"D\u00e9p\u00f4t Gitea auto-h\u00e9berg\u00e9","content.commons.nuget":"Packet Nuget","content.commons.license.mit.single":"License MIT","content.commons.lang.english":"Anglais","content.commons.lang.french":"Fran\u00e7ais","content.commons.lang.luxembourgish":"Luxembourgeois","content.commons.lang.english.639-3":"Anglais (eng)","content.commons.lang.french.639-3":"Fran\u00e7ais (fra)","content.commons.lang.luxembourgish.639-3":"Luxembourgeois (ltz)","footer.text.privacy":"Politique de confidentialit\u00e9","footer.alt.sidebar.button":"Ouvrir et fermer le menu lat\u00e9ral de navigation.","footer.alt.logo":"Logo du site web","home.head.title":"NibblePoker","home.head.description":"TODO: description","home.og.title":"NibblePoker","home.og.description":"TODO: description","home.header.title":"Page d'accueil","home.showcase.title":"Vitrine","home.updates.title":"Updates","home.updates.text.privacy":"\u25cf  Mise-\u00e0-jour de notre politique de confidentialit\u00e9.","home.updates.2.date":"15 Ao\u00fbt 2023","home.updates.2.text.1":"\u25cf  Le site internet est \u00e0 nouveau disponible.","home.updates.2.text.2":"\u25cf  Mise en place d'un nouveau design plus l\u00e9ger.","home.updates.2.text.3":"\u25cf  Changement d'h\u00e9bergeur vers HostBrr.","home.updates.2.text.4":"\u25cf  Ajout d'une nouvelle section pour les outils.","home.updates.1.date":" 9 Septembre 2022","home.updates.1.text.1":"\u25cf  Changement d'h\u00e9bergeur vers v6Node.","lang.menu.title":"Langue","lang.current":"Fran\u00e7ais","lang.automatic":"Automatique","lang.english":"Anglais","lang.french":"Fran\u00e7ais","lang.german":"Allemand","lang.luxembourgish":"Luxembourgeois","links.head.title":"Liens - NibblePoker","links.head.description":"TODO: description","links.og.title":"NibblePoker - Liens","links.og.description":"TODO: description","links.header.title":"Liens","privacy.head.title":"Politique de confidentialit\u00e9 - NibblePoker","privacy.head.description":"Notre politique de confidentialit\u00e9 dans un format clair et compr\u00e9hensible.","privacy.og.title":"NibblePoker - Politique de confidentialit\u00e9","privacy.og.description":"Notre politique de confidentialit\u00e9 dans un format clair et compr\u00e9hensible.","privacy.header.title":"Politique de confidentialit\u00e9","privacy.introduction.title":"Introduction","privacy.introduction.text.1":"La politique de confidentialit\u00e9 ci-pr\u00e9sente a \u00e9t\u00e9 \u00e9crite en accord avec les articles 12 et 13 de la RGPD.","privacy.introduction.text.2":"Si vous souhaitez consulter le texte officiel en question, vous pouvez le faire sur les sites internet suivants :","privacy.contact.title":"Comment nous contacter ?","privacy.contact.text.1":"Si vous souhaitez nous contacter afin d'obtenir plus d'informations concernant notre politique de confidentialit\u00e9, nous vous recommandons d'utiliser le formulaire pr\u00e9sent sur la page de contact, ou par courriel \u00e0 l'adresse suivante:","privacy.complaint.title":"Comment contacter les autorit\u00e9s comp\u00e9tentes ?","privacy.complaint.text.1":"Dans l'\u00e9ventualit\u00e9 o\u00f9 vous souhaiteriez d\u00e9poser une plainte pour une quelconque raison en rapport avec notre politique de confidentialit\u00e9, veuillez vous adresser \u00e0 l'autorit\u00e9 nationale de protection des donn\u00e9es (DPA).","privacy.complaint.text.2":"Les informations concernant cette proc\u00e9dure peuvent \u00eatre trouv\u00e9es sur les sites internet suivants:","privacy.v2.data.title":"Collecte de donn\u00e9es","privacy.v2.data.intro.1":"Ce site web collecte des donn\u00e9es au travers des journaux d'\u00e9v\u00e8nements afin de d\u00e9tecter et bloquer de potentiels acteurs malveillants.","privacy.v2.data.intro.2":"Les donn\u00e9es collect\u00e9es ne sont en aucun cas utilis\u00e9es pour une quelconque autre raison.","privacy.v2.data.private.1":"Voici la liste des donn\u00e9es personelles collect\u00e9es:","privacy.v2.data.private_list.1":"L'addresse IP source","privacy.v2.data.private_list.2":"Le \"User-Agent\" de votre navigateur internet","privacy.v2.data.non_private.1":"Et voici la liste des donn\u00e9es non-personelles collect\u00e9es:","privacy.v2.data.non_private_list.1":"L'URI de la ressource demand\u00e9e","privacy.v2.data.non_private_list.2":"La date et l'heure","privacy.v2.data.end.1":"Les donn\u00e9es pr\u00e9sentes dans les journaux d'\u00e9v\u00e8nements sont extraites et retir\u00e9es pour \u00eatre trait\u00e9es par une application qui tourne en local toute les 30 secondes.","privacy.v2.data.end.2":"L'application en question utilise et compare ces informations avec une liste d'acteurs malveillants et comportement suspects connus.
Si une correspondance est d\u00e9tect\u00e9e, les informations priv\u00e9es sont anonymis\u00e9es et sont stock\u00e9es pendant 7 jours en attendant qu'un examen manuel soit effectu\u00e9.","privacy.v2.data.end.3":"Apr\u00e8s cette p\u00e9riode de 7 jours, ou apr\u00e8s qu'un examen ait \u00e9t\u00e9 effectu\u00e9, les donn\u00e9es sont automatiquement supprim\u00e9es.","privacy.v2.data.end.4":"Toute information concernant une requ\u00eate non suspecte est automatiquement supprim\u00e9e.","privacy.v2.data.end.5":"Ce processus n'est normalement jamais utilis\u00e9 sur des requ\u00eates provenant d'un trafic l\u00e9gitime d\u00fb au fait qu'il isole principalement les actions et requ\u00eates qui ne devraient pas \u00eatre possible sur ce site.","privacy.v2.data.end.6":"Cependant, ce processus n'est pas infaillible et il est toujours possible qu'une requ\u00eate soit isol\u00e9e par erreur.","privacy.v2.update.title":"Changements \u00e0 notre politique de confidentialit\u00e9","privacy.v2.update.intro.1":"Le contenu de notre politique de confidentialit\u00e9 a \u00e9t\u00e9 originalement \u00e9crit et le 4 d\u00e9cembre 2021 modifi\u00e9 pour la derni\u00e8re fois le 18 mars 2022.","privacy.v2.update.history.1.date":"2021/12/04","privacy.v2.update.history.1.desc.1":"Version originale","privacy.v2.update.history.2.date":"2022/03/18","privacy.v2.update.history.2.desc.1":"Mise-\u00e0-jour de la section sur la collection des donn\u00e9es.","privacy.v2.update.history.2.desc.2":"Ajout d'une mention de CloudFlare et ajout de liens vers leur politique de confidentialit\u00e9.","privacy.v2.update.history.2.desc.3":"Am\u00e9lioration de la section \"Changements \u00e0 notre politique de confidentialit\u00e9\".","privacy.v2.update.history.3.date":"2022/09/09","privacy.v2.update.history.3.desc.1":"Changement des r\u00e9f\u00e9rences aux services externes pour indiquer l'utilisation de v6Node.","privacy.v2.update.history.3.desc.1.1":"Ajout de mentions de v6Node et liens vers leur politique de vie confidentialit\u00e9.","privacy.v2.update.history.3.desc.1.2":"Suppression de mentions de CloudFlare.","privacy.v2.update.history.3.desc.2":"Changement de la section \"Cookies\" afin d'indiquer qu'ils ne seront plus utilis\u00e9s sur les domaines publics.","privacy.v2.update.end.2":"En cas de changement, vous serez clairement inform\u00e9 et une copie des anciennes versions de notre politique sera disponible au travers de cette page.","privacy.v2.third.title":"Organismes tiers","privacy.v2.third.intro.1":"Ce site web utilise les services propos\u00e9s par v6Node afin d'emp\u00eacher des acteurs malveillants d'y acc\u00e9der et dans le but de mettre en place un syst\u00e8me de reverse-proxy.","privacy.v2.third.intro.2":"Ceci a pour but d'am\u00e9liorer l'exp\u00e9rience des personnes le visitant gr\u00e2ce \u00e0 un syst\u00e8me de filtrage et caching priv\u00e9.","privacy.v2.third.intro.3":"Aucune des donn\u00e9es collect\u00e9es et stock\u00e9es par v6Node et le syst\u00e8me d\u00e9cris ci-dessus n'est utilis\u00e9 ou stock\u00e9.","privacy.v2.third.intro.4":"Si vous souhaitez consulter leur politique de confidentialit\u00e9 ainsi que celle de leur partenaires, vous pouvez le faire en suivant les liens ci-dessous:","privacy.v2.cookies.title":"Cookies de navigation","privacy.v2.cookies.intro.1":"Ce site web n'utilise pas, et ne stocke aucun cookies dans votre navigateur internet.","sidebar.alt.logo":"Logo du site web","sidebar.text.home":"Accueil","sidebar.text.projects":"Projets","sidebar.text.applications":"Applications","sidebar.text.libraries":"Librairies","sidebar.text.electronics":"\u00c9lectronique","sidebar.text.tools":"Outils","sidebar.text.links":"Liens","sidebar.text.downloads":"T\u00e9l\u00e9chargements","sidebar.text.gitea":"D\u00e9p\u00f4ts Git","sidebar.text.wiki":"Wiki","sidebar.text.about":"\u00c0-propos","sidebar.text.contact":"Contact","tools.head.title":"Outils - NibblePoker","tools.head.description":"TODO: description","tools.og.title":"NibblePoker - Outils","tools.og.description":"TODO: description","tools.header.title":"Outils"}} \ No newline at end of file diff --git a/compile.bat b/compile.bat index e1b6f76..e20ddd3 100644 --- a/compile.bat +++ b/compile.bat @@ -57,7 +57,7 @@ popd :libs-end -:: THE FW min files don't poitn to the proper JS file !!!! +:: THE Formula-wizard minified files don't point to the proper minified JS file !!!! :formula-wizard @@ -65,6 +65,14 @@ echo. echo Handling the 'Formula Wizard' echo ----------------------------- +:formula-wizard-clean +echo Cleaning... +pushd %CD% +cd %~dp0\tools\items\formula-wizard\src\ +del *.js +del *.map +popd + :formula-wizard-compile echo Compiling TypeScript... pushd %CD% @@ -76,13 +84,14 @@ popd echo Fixing imports... pushd %CD% cd %~dp0\tools\items\formula-wizard\src\ -call node "%~dp0fix-import-path.js" "formulas.js;lang.js;main.js;units.js;ui_catalog.js;mvc_context.js;sets.js" "decimal" "decimal.min.mjs" -call node "%~dp0fix-import-path.js" "formulas.js;lang.js;main.js;units.js;ui_catalog.js;mvc_context.js;sets.js" "lang" "lang.js" -call node "%~dp0fix-import-path.js" "formulas.js;lang.js;main.js;units.js;ui_catalog.js;mvc_context.js;sets.js" "formulas" "formulas.js" -call node "%~dp0fix-import-path.js" "formulas.js;lang.js;main.js;units.js;ui_catalog.js;mvc_context.js;sets.js" "units" "units.js" -call node "%~dp0fix-import-path.js" "formulas.js;lang.js;main.js;units.js;ui_catalog.js;mvc_context.js;sets.js" "ui_catalog" "ui_catalog.js" -call node "%~dp0fix-import-path.js" "formulas.js;lang.js;main.js;units.js;ui_catalog.js;mvc_context.js;sets.js" "mvc_context" "mvc_context.js" -call node "%~dp0fix-import-path.js" "formulas.js;lang.js;main.js;units.js;ui_catalog.js;mvc_context.js;sets.js" "sets" "sets.js" +call node "%~dp0fix-import-path.js" "formulas.js;lang.js;main.js;units.js;ui_catalog.js;mvc_context.js;sets.js;mvc_formula.js" "decimal" "decimal.min.mjs" +call node "%~dp0fix-import-path.js" "formulas.js;lang.js;main.js;units.js;ui_catalog.js;mvc_context.js;sets.js;mvc_formula.js" "lang" "lang.js" +call node "%~dp0fix-import-path.js" "formulas.js;lang.js;main.js;units.js;ui_catalog.js;mvc_context.js;sets.js;mvc_formula.js" "formulas" "formulas.js" +call node "%~dp0fix-import-path.js" "formulas.js;lang.js;main.js;units.js;ui_catalog.js;mvc_context.js;sets.js;mvc_formula.js" "units" "units.js" +call node "%~dp0fix-import-path.js" "formulas.js;lang.js;main.js;units.js;ui_catalog.js;mvc_context.js;sets.js;mvc_formula.js" "ui_catalog" "ui_catalog.js" +call node "%~dp0fix-import-path.js" "formulas.js;lang.js;main.js;units.js;ui_catalog.js;mvc_context.js;sets.js;mvc_formula.js" "mvc_context" "mvc_context.js" +call node "%~dp0fix-import-path.js" "formulas.js;lang.js;main.js;units.js;ui_catalog.js;mvc_context.js;sets.js;mvc_formula.js" "sets" "sets.js" +call node "%~dp0fix-import-path.js" "formulas.js;lang.js;main.js;units.js;ui_catalog.js;mvc_context.js;sets.js;mvc_formula.js" "mvc_formula" "mvc_formula.js" popd :formula-wizard-bundle @@ -100,6 +109,10 @@ call "%~dp0node_modules\.bin\terser" main.js -c -m --toplevel -o main.min.js call "%~dp0node_modules\.bin\terser" lang.js -c -m --toplevel -o lang.min.js call "%~dp0node_modules\.bin\terser" formulas.js -c -m --toplevel -o formulas.min.js call "%~dp0node_modules\.bin\terser" units.js -c -m --toplevel -o units.min.js +call "%~dp0node_modules\.bin\terser" ui_catalog.js -c -m --toplevel -o ui_catalog.min.js +call "%~dp0node_modules\.bin\terser" mvc_context.js -c -m --toplevel -o mvc_context.min.js +call "%~dp0node_modules\.bin\terser" sets.js -c -m --toplevel -o sets.min.js +call "%~dp0node_modules\.bin\terser" mvc_formula.js -c -m --toplevel -o mvc_formula.min.js call "%~dp0node_modules\.bin\terser" formula-wizard.js -c -m --toplevel -o formula-wizard.min.js popd diff --git a/tools/items/formula-wizard.json b/tools/items/formula-wizard.json index 0c63d67..35429fd 100644 --- a/tools/items/formula-wizard.json +++ b/tools/items/formula-wizard.json @@ -1,5 +1,5 @@ { - "dom": "formula-wizard/page.min.php", + "dom": "formula-wizard/page.php", "lang": "formula-wizard/lang.json", "code": [], "module": [ diff --git a/tools/items/formula-wizard/code.js b/tools/items/formula-wizard/code.js deleted file mode 100644 index 0f255b5..0000000 --- a/tools/items/formula-wizard/code.js +++ /dev/null @@ -1,855 +0,0 @@ -import { Decimal } from "../../../resources/DecimalJs/10.4.3/decimal.min.mjs"; -const version = [0, 0, 1]; -console.log("Initializing 'Formula Wizard v" + version.join(".") + "'..."); -const startTime = new Date().getMilliseconds(); -Decimal.set({ precision: 25, rounding: 8 }); -function isStringValidNumber(text) { - return isNaN(parseFloat(text)); -} -console.debug("Preparing langs..."); -const langKey = document.documentElement.lang.match("(en|fr)") ? document.documentElement.lang : "en"; -const langData = { - en: { - "unit.any.name": "Not Important", - "unit.watt.name": "Watt", - "unit.ampere.name": "Ampere", - "unit.ohm.name": "Ohm", - "unit.ohm.desc": "Electrical Resistance", - "unit.volt.name": "Volt", - "unit.farad.name": "Farad", - "error.formulaValue.noParent": "Attempting to get a formula's value whose parent formula isn't set !", - "error.formulaValue.noSource": "Attempting to get a formula's value whose value source is null !", - "error.formulaContext.tooSmall": "The current calculation context is too small !", - "ui.formulaCount": "formulas", - "formula.ohm_law.name": "Ohm's Law", - "dataset.resistor-e3.name": "E3 IEC Resistors", - "dataset.resistor-e3.desc": "???", - "dataset.resistor-e6.name": "E6 IEC Resistors", - "dataset.resistor-e6.desc": "???", - "dataset.resistor-e12.name": "E12 IEC Resistors", - "dataset.resistor-e12.desc": "???", - "dataset.resistor-e24.name": "E24 IEC Resistors", - "dataset.resistor-e24.desc": "???", - "dataset.resistor-e48.name": "E48 IEC Resistors", - "dataset.resistor-e48.desc": "???", - "dataset.capacitor-iec.name": "IEC E24 Capacitors", - "dataset.capacitor-iec.desc": "???", - "context.type.disabled.name": "Disabled", - "context.type.constant.name": "Constant", - "context.type.continuous.name": "Continuous", - "context.type.valueRange.name": "Value Range", - "context.type.dataSetRange.name": "Set-based Range", - "context.type.disabled.desc": "???", - "context.type.constant.desc": "???", - "context.type.continuous.desc": "???", - "context.type.valueRange.desc": "???", - "context.type.dataSetRange.desc": "???", - }, - fr: { - "unit.ampere.name": "Ampère", - "unit.ohm.desc": "Résistance électrique", - "_error.formulaValue.noParent": "", - "_error.formulaValue.noSource": "", - "ui.formulaCount": "formules", - "formula.ohm_law.name": "Loi d'Ohm", - "context.type.disabled.name": "Désactivé", - "context.type.constant.name": "Constante", - "context.type.continuous.name": "Continue", - "context.type.valueRange.name": "Valeurs distinctes", - "context.type.dataSetRange.name": "Set de valeurs", - } -}; -function localize(stringKey) { - let _langData = langKey in langData ? langData[langKey] : langData.en; - return stringKey in _langData ? _langData[stringKey] : (stringKey in langData["en"] ? langData["en"][stringKey] : stringKey); -} -console.debug("Preparing scales..."); -const scales = { - SI: new class { - constructor() { - this.formatName = (unit) => { - return unit.symbol; - }; - this.formatSymbol = (unit) => { - return unit.symbol; - }; - this.scaleFactors = []; - } - }, - IMPERIAL_DISTANCE: new class { - constructor() { - this.formatName = (unit) => { - return unit.symbol; - }; - this.formatSymbol = (unit) => { - return unit.symbol; - }; - this.scaleFactors = []; - } - }, - IMPERIAL_WEIGHT: new class { - constructor() { - this.formatName = (unit) => { - return unit.symbol; - }; - this.formatSymbol = (unit) => { - return unit.symbol; - }; - this.scaleFactors = []; - } - }, - TIME_SECONDS: new class { - constructor() { - this.formatName = (unit) => { - return unit.symbol; - }; - this.formatSymbol = (unit) => { - return unit.symbol; - }; - this.scaleFactors = []; - } - }, - NONE: new class { - constructor() { - this.formatName = (unit) => { - return unit.name; - }; - this.formatSymbol = (unit) => { - return unit.symbol; - }; - this.scaleFactors = []; - } - }, -}; -const scaleFactors = { - SI_GIGA: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1e9'); - this.prefix = "giga"; - this.suffix = ""; - this.symbol = "G"; - } - }, - SI_MEGA: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1e6'); - this.prefix = "mega"; - this.suffix = ""; - this.symbol = "M"; - } - }, - SI_KILO: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1e3'); - this.prefix = "kilo"; - this.suffix = ""; - this.symbol = "k"; - } - }, - SI_BASE: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1'); - this.prefix = ""; - this.suffix = ""; - this.symbol = ""; - } - }, - SI_CENTI: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1e-2'); - this.prefix = "centi"; - this.suffix = ""; - this.symbol = "c"; - } - }, - SI_MILLI: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1e-3'); - this.prefix = "milli"; - this.suffix = ""; - this.symbol = "m"; - } - }, - TIME_MILLI: new class { - constructor() { - this.scale = scales.TIME_SECONDS; - this.multiplier = new Decimal('1e-3'); - this.prefix = "milli"; - this.suffix = ""; - this.symbol = "m"; - } - }, - TIME_BASE: new class { - constructor() { - this.scale = scales.TIME_SECONDS; - this.multiplier = new Decimal('1'); - this.prefix = ""; - this.suffix = ""; - this.symbol = ""; - } - }, - TIME_MINUTE: new class { - constructor() { - this.scale = scales.TIME_SECONDS; - this.multiplier = new Decimal('60'); - this.prefix = ""; - this.suffix = ""; - this.symbol = ""; - } - }, - TIME_HOUR: new class { - constructor() { - this.scale = scales.TIME_SECONDS; - this.multiplier = new Decimal('3600'); - this.prefix = ""; - this.suffix = ""; - this.symbol = ""; - } - }, - TIME_DAY: new class { - constructor() { - this.scale = scales.TIME_SECONDS; - this.multiplier = new Decimal('86400'); - this.prefix = ""; - this.suffix = ""; - this.symbol = ""; - } - }, -}; -Object.keys(scaleFactors).forEach(scaleFactorKey => { - const scaleFactor = scaleFactors[scaleFactorKey]; - scaleFactor.scale.scaleFactors.push(scaleFactor); -}); -function scaleToBase(value, scaleFactor) { - return value.times(scaleFactor.multiplier); -} -function scaleFromBase(value, scaleFactor) { - return value.dividedBy(scaleFactor.multiplier); -} -function getScaleKeyFromValue(scaleFactor) { - return Object.keys(scaleFactors).find(scaleFactorKey => (scaleFactors[scaleFactorKey]) === scaleFactor); -} -function populateScaleSelectForUnit(unit, eSelect, selectedScaleFactor) { - unit.scale.scaleFactors.forEach(scaleFactor => { - const eNewScaleOption = document.createElement("option"); - eNewScaleOption.setAttribute("value", getScaleKeyFromValue(scaleFactor)); - eNewScaleOption.innerText = scaleFactor.prefix + " - " + eNewScaleOption.getAttribute("value"); - eNewScaleOption.selected = (scaleFactor === selectedScaleFactor); - eSelect.appendChild(eNewScaleOption); - }); -} -console.debug("Preparing units..."); -class Unit { - constructor(unitKey, symbol, scale) { - this.name = localize("unit." + unitKey + ".name"); - this.symbol = symbol; - this.scale = scale; - this.description = localize("unit." + unitKey + ".desc"); - } -} -const units = { - ANY: new Unit("any", "", scales.NONE), - WATT: new Unit("watt", "W", scales.SI), - VOLT: new Unit("volt", "V", scales.SI), - AMPERE: new Unit("ampere", "A", scales.SI), - OHM: new Unit("ohm", "Ω", scales.SI), - FARAD: new Unit("farad", "F", scales.SI), - METER: new Unit("meter", "m", scales.SI), - INCH: new Unit("inch", "in", scales.IMPERIAL_DISTANCE), - POUND: new Unit("pound", "p", scales.IMPERIAL_WEIGHT), -}; -console.debug("Preparing formulas..."); -class FormulaContextHandler { - constructor(contextValueIndex) { - this.contextValueIndex = contextValueIndex; - } - getContextValue(context) { - if (context.length <= this.contextValueIndex) { - alert(localize("error.formulaContext.tooSmall")); - throw new Error(localize("error.formulaContext.tooSmall")); - } - return context[this.contextValueIndex]; - } -} -class FormulaValue { - constructor(unit, scaleFactor) { - this.unit = unit; - this.scaleFactor = scaleFactor; - this.parentFormula = null; - this.valueSource = null; - } - getFormulaValue(context) { - if (this.parentFormula === null) { - alert(localize("error.formulaValue.noParent")); - throw new Error(localize("error.formulaValue.noParent")); - } - if (this.valueSource === null) { - alert(localize("error.formulaValue.noSource")); - throw new Error(localize("error.formulaValue.noSource")); - } - if (this.valueSource instanceof FormulaContextHandler) { - return this.valueSource.getContextValue(context); - } - return scaleFromBase(scaleToBase(this.valueSource.getVariantValue(this.parentFormula, context), this.valueSource.getOutputValueDefinition().scaleFactor), this.scaleFactor); - } -} -class Formula { - constructor(values, variants, formulaKey, categories, wikiLink) { - this.values = values; - this.variants = variants; - this.formulaKey = formulaKey; - this.name = localize("formula." + formulaKey + ".name"); - this.description = localize("formula." + formulaKey + ".desc"); - this.categories = categories; - this.wikiLink = wikiLink; - this.values.forEach(value => { - value.parentFormula = this; - }); - } - getClone() { - const clonedFormulaValues = []; - this.values.forEach(originalValue => { - clonedFormulaValues.push(new FormulaValue(originalValue.unit, originalValue.scaleFactor)); - }); - return new Formula(clonedFormulaValues, this.variants, this.formulaKey, this.categories, this.wikiLink); - } -} -const formulas = { - OHM_LAW: new Formula([ - new FormulaValue(units.OHM, scaleFactors.SI_BASE), - new FormulaValue(units.AMPERE, scaleFactors.SI_BASE), - new FormulaValue(units.VOLT, scaleFactors.SI_BASE), - ], [ - new class { - constructor() { - this.description = "V=I*R"; - this.getVariantValue = (formula, context) => { - return formula.values[0].getFormulaValue(context).times(formula.values[1].getFormulaValue(context)); - }; - this.getInputValuesDefinition = () => { - return [this.parentFormula.values[0], this.parentFormula.values[1]]; - }; - this.getOutputValueDefinition = () => { - return this.parentFormula.values[2]; - }; - this.getMathMl = (formula) => { - return "" + - formula.values[2].unit.symbol + - "=" + - formula.values[0].unit.symbol + - "*" + - formula.values[1].unit.symbol + - ""; - }; - this.parentFormula = null; - } - }, - new class { - constructor() { - this.description = "I=V/R"; - this.getVariantValue = (formula, context) => { - return formula.values[2].getFormulaValue(context).dividedBy(formula.values[0].getFormulaValue(context)); - }; - this.getInputValuesDefinition = () => { - return [this.parentFormula.values[0], this.parentFormula.values[2]]; - }; - this.getOutputValueDefinition = () => { - return this.parentFormula.values[1]; - }; - this.getMathMl = (formula) => { - return "" + - formula.values[1].unit.symbol + - "=" + - formula.values[2].unit.symbol + - "" + - formula.values[0].unit.symbol + - ""; - }; - this.parentFormula = null; - } - }, - new class { - constructor() { - this.description = "R=V/I"; - this.getVariantValue = (formula, context) => { - return formula.values[2].getFormulaValue(context).dividedBy(formula.values[1].getFormulaValue(context)); - }; - this.getInputValuesDefinition = () => { - return [this.parentFormula.values[2], this.parentFormula.values[1]]; - }; - this.getOutputValueDefinition = () => { - return this.parentFormula.values[0]; - }; - this.getMathMl = (formula) => { - return "" + - formula.values[0].unit.symbol + - "=" + - formula.values[2].unit.symbol + - "" + - formula.values[1].unit.symbol + - ""; - }; - this.parentFormula = null; - } - }, - ], "ohm_law", ["electricity"], new URL("https://wikipedia.org/wiki/Ohm's_law")), -}; -Object.keys(formulas).forEach(formulaKey => { - formulas[formulaKey].variants.forEach(formulaVariant => { - formulaVariant.parentFormula = formulas[formulaKey]; - }); -}); -class ContextType { - constructor(name, description) { - this.name = name; - this.description = description; - } -} -const contextTypes = { - DISABLED: new ContextType(localize("context.type.disabled.name"), localize("context.type.disabled.desc")), - CONSTANT: new ContextType(localize("context.type.constant.name"), localize("context.type.constant.desc")), - CONTINUOUS: new ContextType(localize("context.type.continuous.name"), localize("context.type.continuous.desc")), - VALUE_RANGE: new ContextType(localize("context.type.valueRange.name"), localize("context.type.valueRange.desc")), - DATASET_RANG: new ContextType(localize("context.type.dataSetRange.name"), localize("context.type.dataSetRange.desc")), -}; -console.debug("Preparing sets..."); -class DataSet { - constructor(name, description, values, unit, scaleFactor) { - this.name = name; - this.description = description; - this.values = values; - this.unit = unit; - this.scaleFactor = scaleFactor; - if (unit.scale != scaleFactor.scale) { - alert(""); - throw Error(""); - } - } - getDataSet() { - return this.values; - } -} -const e3Range = [1, 2.2, 4.7]; -const e6Range = [1, 1.5, 2.2, 3.3, 4.7, 6.8]; -const e12Range = [1, 1.2, 1.5, 1.8, 2.2, 2.7, 3.3, 3.9, 4.7, 5.6, 6.8, 8.2]; -const e24Range = [ - 1, 1.1, 1.2, 1.3, 1.5, 1.6, 1.8, 2, 2.2, 2.4, 2.7, 3, 3.3, 3.6, 3.9, 4.3, 4.7, 5.1, 5.6, 6.2, 6.8, 7.5, 8.2, 9.1 -]; -const e48Range = [ - 1, 1.05, 1.1, 1.15, 1.21, 1.27, 1.33, 1.4, 1.47, 1.54, 1.62, 1.69, 1.78, 1.87, 1.96, 2.05, 2.15, 2.26, 2.37, 2.49, - 2.61, 2.74, 2.87, 3.01, 3.16, 3.32, 3.48, 3.65, 3.83, 4.02, 4.22, 4.42, 4.64, 4.87, 5.11, 5.36, 5.62, 5.9, 6.19, - 6.49, 6.81, 7.15, 7.5, 7.87, 8.25, 8.66, 9.09, 9.53 -]; -const resistorsScales = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]; -const capacitorScales = [10e-12, 10e-11, 10e-10, 10e-9, 10e-8, 10e-7, 10e-6, 10e-5, 10e-4, 10e-3, 10e-2]; -const sets = { - RESISTOR_E3: new DataSet(localize("dataset.resistor-e3.name"), localize("dataset.resistor-e3.desc"), resistorsScales.flatMap((e3Scale) => e3Range.map((e3Multiplier) => new Decimal(e3Scale).times(e3Multiplier))), units.OHM, scaleFactors.SI_BASE), - RESISTOR_E6: new DataSet(localize("dataset.resistor-e6.name"), localize("dataset.resistor-e6.desc"), resistorsScales.flatMap((e6Scale) => e6Range.map((e6Multiplier) => new Decimal(e6Scale).times(e6Multiplier))), units.OHM, scaleFactors.SI_BASE), - RESISTOR_E12: new DataSet(localize("dataset.resistor-e12.name"), localize("dataset.resistor-e12.desc"), resistorsScales.flatMap((e12Scale) => e12Range.map((e12Multiplier) => new Decimal(e12Scale).times(e12Multiplier))), units.OHM, scaleFactors.SI_BASE), - RESISTOR_E24: new DataSet(localize("dataset.resistor-e24.name"), localize("dataset.resistor-e24.desc"), resistorsScales.flatMap((e24Scale) => e24Range.map((e24Multiplier) => new Decimal(e24Scale).times(e24Multiplier))), units.OHM, scaleFactors.SI_BASE), - RESISTOR_E48: new DataSet(localize("dataset.resistor-e48.name"), localize("dataset.resistor-e48.desc"), resistorsScales.flatMap((e48Scale) => e48Range.map((e48Multiplier) => new Decimal(e48Scale).times(e48Multiplier))), units.OHM, scaleFactors.SI_BASE), - CAPACITOR_IEC: new DataSet(localize("dataset.capacitor-iec.name"), localize("dataset.capacitor-iec.desc"), capacitorScales.flatMap((cScale) => e24Range.map((eMultiplier) => new Decimal(cScale).times(eMultiplier))), units.FARAD, scaleFactors.SI_BASE), -}; -console.debug("Preparing UI..."); -const idWorkbenchFormulaPrefix = "fw-workbench-formula-"; -const idWorkbenchFormulaSpawnPoint = idWorkbenchFormulaPrefix + "spawn"; -const idTemplateFormula = "template-workbench-formula"; -const idFormulaName = idWorkbenchFormulaPrefix + "name"; -const idFormulaInputs = idWorkbenchFormulaPrefix + "inputs"; -const idFormulaOutputs = idWorkbenchFormulaPrefix + "outputs"; -const classTemplateFormulaValue = "formula-value-input-form"; -const idTemplateFormulaValue = idTemplateFormula + "-value"; -const idFormulaValuePrefix = idWorkbenchFormulaPrefix + "value-"; -const idFormulaValueId = idFormulaValuePrefix + "id"; -const idFormulaValueName = idFormulaValuePrefix + "name"; -const idFormulaValueLink = idFormulaValuePrefix + "link"; -const idFormulaValueTestValue = idFormulaValuePrefix + "test-value"; -const idFormulaValueTestScale = idFormulaValuePrefix + "test-scale"; -const idFormulaValueTestValueSet = idFormulaValuePrefix + "test-value-set"; -let eTemplateWorkbenchFormula = document.getElementById(idTemplateFormula); -let eTemplateWorkbenchFormulaValue = document.getElementById(idTemplateFormulaValue); -if (eTemplateWorkbenchFormula === null || eTemplateWorkbenchFormulaValue === null) { - alert("error.ui.workbench.noTemplate"); - throw Error("error.ui.workbench.noTemplate"); -} -eTemplateWorkbenchFormula = eTemplateWorkbenchFormula.cloneNode(true).content; -eTemplateWorkbenchFormulaValue = eTemplateWorkbenchFormulaValue.cloneNode(true).content; -const eWorkbenchFormulaSpawnPoint = document.querySelector(`a#${idWorkbenchFormulaSpawnPoint}`); -if (eWorkbenchFormulaSpawnPoint === null) { - alert("error.ui.workbench.noAnchor"); - throw Error("error.ui.workbench.noAnchor"); -} -let uiWorkbenchFormulas = []; -var WorkbenchFormulaValueTypes; -(function (WorkbenchFormulaValueTypes) { - WorkbenchFormulaValueTypes[WorkbenchFormulaValueTypes["INPUT"] = 0] = "INPUT"; - WorkbenchFormulaValueTypes[WorkbenchFormulaValueTypes["OUTPUT"] = 1] = "OUTPUT"; -})(WorkbenchFormulaValueTypes || (WorkbenchFormulaValueTypes = {})); -class WorkbenchFormulaValueUiElement { - constructor(rootElement, formulaValue, parentFormulaElement, valueType) { - this.rootElement = rootElement; - this.idSuffix = Date.now().toString() + Math.floor(Math.random() * 99); - this.valueType = valueType; - this.formulaValue = formulaValue; - this.parentFormulaElement = parentFormulaElement; - this.eFormulaValueId = rootElement.querySelector(`input#${idFormulaValueId}`); - this.eFormulaValueName = rootElement.querySelector(`p#${idFormulaValueName}`); - this.eFormulaValueLink = rootElement.querySelector(`select#${idFormulaValueLink}`); - this.eFormulaValueTestValue = rootElement.querySelector(`input#${idFormulaValueTestValue}`); - this.eFormulaValueTestScale = rootElement.querySelector(`select#${idFormulaValueTestScale}`); - this.eFormulaValueTestValueSet = rootElement.querySelector(`select#${idFormulaValueTestValueSet}`); - if ([this.eFormulaValueId, this.eFormulaValueName, this.eFormulaValueLink, this.eFormulaValueTestValue, - this.eFormulaValueTestScale, this.eFormulaValueTestValueSet].some((item) => item === null)) { - alert("error.ui.formula.value.missingElement"); - throw Error("error.ui.formula.value.missingElement"); - } - this.toggleField(this.eFormulaValueTestValueSet, true); - this.rootElement.querySelectorAll(`input, select, p, div`).forEach(eFormInput => { - if (eFormInput.hasAttribute("id")) { - eFormInput.setAttribute("id", eFormInput.getAttribute("id") + this.idSuffix); - } - }); - this.rootElement.querySelectorAll(`label`).forEach(eFormLabel => { - if (eFormLabel.hasAttribute("for")) { - eFormLabel.setAttribute("for", eFormLabel.getAttribute("for") + this.idSuffix); - } - }); - this.eFormulaValueName.innerText = `${this.formulaValue.unit.name} (${this.formulaValue.unit.symbol})`; - this.eFormulaValueId.value = this.idSuffix; - populateScaleSelectForUnit(this.formulaValue.unit, this.eFormulaValueTestScale, this.formulaValue.scaleFactor); - if (this.valueType === WorkbenchFormulaValueTypes.INPUT) { - this.setupInput(); - } - else { - this.setupOutput(); - } - } - onTestFieldChange(event) { - this.parentFormulaElement.calculateTestValues(); - } - getTestValue() { - return new Decimal(isStringValidNumber(this.eFormulaValueTestValue.value) ? this.eFormulaValueTestValue.value : 0); - } - setTestValue(newValue) { - this.eFormulaValueTestValue.value = newValue.toString(); - } - toggleTestMode(hidden) { - this.eFormulaValueTestScale.parentNode.parentNode.hidden = hidden; - this.eFormulaValueTestScale.parentNode.parentNode.hidden = hidden; - } - toggleField(eFormField, hidden) { - eFormField.parentNode.parentNode.hidden = hidden; - } - setupInput() { - this.toggleField(this.eFormulaValueId, true); - this.eFormulaValueTestValue.value = "0"; - this.eFormulaValueTestValue.onchange = this.onTestFieldChange.bind(this); - this.eFormulaValueTestScale.onchange = this.onTestFieldChange.bind(this); - } - setupOutput() { - this.toggleField(this.eFormulaValueLink, true); - this.eFormulaValueTestValue.readOnly = true; - this.eFormulaValueTestScale.onchange = this.onTestFieldChange.bind(this); - } - static getNew(formulaValue, parentFormulaElement, valueType) { - const eNewWorkbenchFormulaValue = eTemplateWorkbenchFormulaValue.cloneNode(true).firstElementChild; - if (eNewWorkbenchFormulaValue === null) { - alert("error.ui.workbench.formula.value.cannotGetElement"); - throw Error("error.ui.workbench.formula.value.cannotGetElement"); - } - return new WorkbenchFormulaValueUiElement(eNewWorkbenchFormulaValue, formulaValue, parentFormulaElement, valueType); - } -} -class WorkbenchFormulaUiElement { - constructor(rootElement, formulaVariant) { - this.rootElement = rootElement; - this.idSuffix = Date.now().toString(); - this.formulaVariant = formulaVariant; - this.eFormulaName = rootElement.querySelector(`p#${idFormulaName}`); - this.eFormulaInputs = rootElement.querySelector(`div#${idFormulaInputs}`); - this.eFormulaOutputs = rootElement.querySelector(`div#${idFormulaOutputs}`); - if ([this.eFormulaName, this.eFormulaInputs, this.eFormulaOutputs].some((item) => item === null)) { - alert("error.ui.formula.missingElement"); - throw Error("error.ui.formula.missingElement"); - } - this.eFormulaName.innerText = this.formulaVariant.parentFormula.name; - this.inputValueElements = []; - this.formulaVariant.getInputValuesDefinition().forEach(variantValue => { - const newInputValueElement = WorkbenchFormulaValueUiElement.getNew(variantValue, this, WorkbenchFormulaValueTypes.INPUT); - this.inputValueElements.push(newInputValueElement); - this.eFormulaInputs.appendChild(newInputValueElement.rootElement); - }); - this.outputValueElements = []; - [this.formulaVariant.getOutputValueDefinition()].forEach(variantValue => { - const newOutputValueElement = WorkbenchFormulaValueUiElement.getNew(variantValue, this, WorkbenchFormulaValueTypes.OUTPUT); - this.outputValueElements.push(newOutputValueElement); - this.eFormulaOutputs.appendChild(newOutputValueElement.rootElement); - }); - } - toggleTestMode(hidden) { - } - calculateTestValues() { - console.log("Handling change..."); - } - static createNew(formulaVariant) { - const eNewWorkbenchFormula = eTemplateWorkbenchFormula.cloneNode(true).firstElementChild; - if (eNewWorkbenchFormula === null) { - alert("error.ui.workbench.formula.cannotGetElement"); - throw Error("error.ui.workbench.formula.cannotGetElement"); - } - const newWorkbenchUiElement = new WorkbenchFormulaUiElement(eNewWorkbenchFormula, formulaVariant); - uiWorkbenchFormulas.push(newWorkbenchUiElement); - eWorkbenchFormulaSpawnPoint.parentNode.insertBefore(newWorkbenchUiElement.rootElement, eWorkbenchFormulaSpawnPoint); - return newWorkbenchUiElement; - } -} -const idCatalogPrefix = "fw-catalog-"; -const idCatalogCategoryPrefix = idCatalogPrefix + "category-"; -const idCatalogCategoryCount = idCatalogPrefix + "formula-count"; -const eCategoryContainers = {}; -document.querySelectorAll('[id]').forEach((element) => { - if (element.id.startsWith(idCatalogCategoryPrefix)) { - eCategoryContainers[element.id.replace(idCatalogCategoryPrefix, "")] = element; - } -}); -const eFormulaCount = document.getElementById(idCatalogCategoryCount); -if (eFormulaCount !== null) { - eFormulaCount.innerText = Object.keys(formulas).length.toString(); -} -let eTemplateFormula = document.getElementById("template-formula-available"); -let eTemplateFormulaVariant = document.getElementById("template-formula-available-variant"); -if (eTemplateFormula === null || eTemplateFormulaVariant === null) { - alert("error.ui.catalog.noTemplate"); - throw Error("error.ui.catalog.noTemplate"); -} -Object.keys(formulas).forEach(formulaKey => { - const hasValidCategory = formulas[formulaKey].categories.every(function (categoryId) { - return Object.keys(eCategoryContainers).indexOf(categoryId) !== -1; - }); - if (hasValidCategory) { - let eNewFormula = eTemplateFormula.content.cloneNode(true); - let eNewFormulaTitle = eNewFormula.querySelector("p"); - if (eNewFormulaTitle !== null) { - eNewFormulaTitle.innerText = formulas[formulaKey].name; - } - let eNewFormulaVariants = eNewFormula.querySelector("div.fw-variants"); - if (eNewFormulaVariants === null) { - alert(""); - throw Error(""); - } - eNewFormulaVariants.innerHTML = ""; - formulas[formulaKey].variants.forEach(variant => { - let eNewFormulaVariant = eTemplateFormulaVariant.content.cloneNode(true); - let eNewFormulaVariantButton = eNewFormulaVariant.querySelector("button"); - if (eNewFormulaVariantButton === null) { - alert(""); - throw Error(""); - } - eNewFormulaVariantButton.innerHTML = variant.getMathMl(formulas[formulaKey]); - eNewFormulaVariantButton.title = variant.description; - eNewFormulaVariantButton.onclick = function () { - WorkbenchFormulaUiElement.createNew(variant); - }; - eNewFormulaVariants.appendChild(eNewFormulaVariant); - }); - formulas[formulaKey].categories.forEach(categoryKey => { - if (Object.keys(eCategoryContainers).includes(categoryKey)) { - eCategoryContainers[categoryKey].appendChild(eNewFormula); - } - }); - } -}); -const idContextComponentPrefix = "fw-context-component-"; -const idContextComponentId = idContextComponentPrefix + "id"; -const idContextComponentDelete = idContextComponentPrefix + "delete"; -const idContextComponentTypes = idContextComponentPrefix + "type"; -const idContextComponentManualValue = idContextComponentPrefix + "manual-value"; -const idContextComponentManualValues = idContextComponentManualValue + "s"; -const idContextComponentRangeFrom = idContextComponentPrefix + "range-from"; -const idContextComponentRangeTo = idContextComponentPrefix + "range-to"; -const idContextComponentRangeStep = idContextComponentPrefix + "range-step"; -const idContextComponentSets = idContextComponentPrefix + "set"; -const idContextComponentUnit = idContextComponentPrefix + "unit"; -const idContextComponentScale = idContextComponentPrefix + "scale"; -let uiContextComponents = []; -let eTemplateContextComponent = document.getElementById("template-context-component"); -if (eTemplateContextComponent === null) { - alert("error.ui.context.noTemplate"); - throw Error("error.ui.context.noTemplate"); -} -eTemplateContextComponent = eTemplateContextComponent.cloneNode(true).content; -const eContextTypes = eTemplateContextComponent.getElementById(idContextComponentTypes); -const eContextSets = eTemplateContextComponent.getElementById(idContextComponentSets); -const eContextUnits = eTemplateContextComponent.getElementById(idContextComponentUnit); -const eContextScales = eTemplateContextComponent.getElementById(idContextComponentScale); -if ([eContextTypes, eContextSets, eContextUnits, eContextScales].some((item) => item === null)) { - alert("error.ui.context.noSets"); - throw Error("error.ui.context.noSets"); -} -Object.keys(contextTypes).forEach(value => { - const eNewContextTypesOption = document.createElement("option"); - eNewContextTypesOption.setAttribute("value", value); - eNewContextTypesOption.innerText = contextTypes[value].name; - eContextTypes.appendChild(eNewContextTypesOption); -}); -Object.keys(sets).forEach(value => { - const eNewContextSetsOption = document.createElement("option"); - eNewContextSetsOption.setAttribute("value", value); - eNewContextSetsOption.innerText = sets[value].name; - eContextSets.appendChild(eNewContextSetsOption); -}); -Object.keys(units).forEach(unitKey => { - const eNewContextUnitsOption = document.createElement("option"); - eNewContextUnitsOption.setAttribute("value", unitKey); - eNewContextUnitsOption.innerText = units[unitKey].name; - eContextUnits.appendChild(eNewContextUnitsOption); -}); -Object.keys(scaleFactors).forEach(scaleKey => { - const eNewContextScalesOption = document.createElement("option"); - eNewContextScalesOption.setAttribute("value", scaleKey); - eNewContextScalesOption.innerText = scaleFactors[scaleKey].prefix; - eContextScales.appendChild(eNewContextScalesOption); -}); -let eContextStatusMessage = document.getElementById("fw-text-context-middle"); -if (eContextStatusMessage === null) { - alert("error.ui.context.noStatus"); - throw Error("error.ui.context.noStatus"); -} -let eContextAddButton = document.querySelector("button#fw-button-add-context"); -if (eContextAddButton === null) { - alert("error.ui.context.missingButton"); - throw Error("error.ui.context.missingButton"); -} -class ContextComponentUiElement { - constructor(rootElement) { - this.rootElement = rootElement; - this.idSuffix = Date.now().toString(); - this.eIdLabel = rootElement.querySelector(`label[for="${idContextComponentId}"]`); - this.eIdInput = rootElement.querySelector(`input#${idContextComponentId}`); - this.eDeleteButton = rootElement.querySelector(`button#${idContextComponentDelete}`); - this.eTypeLabel = rootElement.querySelector(`label[for="${idContextComponentTypes}"]`); - this.eTypeSelect = rootElement.querySelector(`select#${idContextComponentTypes}`); - this.eManualValueLabel = rootElement.querySelector(`label[for="${idContextComponentManualValue}"]`); - this.eManualValueInput = rootElement.querySelector(`input#${idContextComponentManualValue}`); - this.eManualValuesLabel = rootElement.querySelector(`label[for="${idContextComponentManualValues}"]`); - this.eManualValuesInput = rootElement.querySelector(`input#${idContextComponentManualValues}`); - this.eRangeFromLabel = rootElement.querySelector(`label[for="${idContextComponentRangeFrom}"]`); - this.eRangeFromInput = rootElement.querySelector(`input#${idContextComponentRangeFrom}`); - this.eRangeToLabel = rootElement.querySelector(`label[for="${idContextComponentRangeTo}"]`); - this.eRangeToInput = rootElement.querySelector(`input#${idContextComponentRangeTo}`); - this.eRangeStepLabel = rootElement.querySelector(`label[for="${idContextComponentRangeStep}"]`); - this.eRangeStepInput = rootElement.querySelector(`input#${idContextComponentRangeStep}`); - this.eDataSetLabel = rootElement.querySelector(`label[for="${idContextComponentSets}"]`); - this.eDataSetSelect = rootElement.querySelector(`select#${idContextComponentSets}`); - this.eUnitLabel = rootElement.querySelector(`label[for="${idContextComponentUnit}"]`); - this.eUnitSelect = rootElement.querySelector(`select#${idContextComponentUnit}`); - this.eScaleLabel = rootElement.querySelector(`label[for="${idContextComponentScale}"]`); - this.eScaleSelect = rootElement.querySelector(`select#${idContextComponentScale}`); - this.allElements = [ - this.eIdLabel, this.eIdInput, this.eDeleteButton, this.eTypeLabel, this.eTypeSelect, - this.eManualValuesLabel, this.eManualValuesInput, this.eRangeFromLabel, this.eRangeFromInput, - this.eRangeToLabel, this.eRangeToInput, this.eRangeStepLabel, this.eRangeStepInput, this.eDataSetLabel, - this.eDataSetSelect, this.eUnitLabel, this.eUnitSelect, this.eScaleLabel, this.eScaleSelect, - this.eManualValueLabel, this.eManualValueInput - ]; - if (this.allElements.some((item) => item === null)) { - alert("error.ui.context.component.missingElement"); - throw Error("error.ui.context.component.missingElement"); - } - rootElement.querySelectorAll(`input, select`).forEach(eFormInput => { - if (eFormInput.hasAttribute("id")) { - eFormInput.setAttribute("id", eFormInput.getAttribute("id") + this.idSuffix); - } - }); - rootElement.querySelectorAll(`label`).forEach(eFormLabel => { - if (eFormLabel.hasAttribute("for")) { - eFormLabel.setAttribute("for", eFormLabel.getAttribute("for") + this.idSuffix); - } - }); - this.eDeleteButton.removeAttribute('id'); - this.eIdInput.value = this.idSuffix; - this.eTypeSelect.onchange = this.onTypeChange.bind(this); - this.eDeleteButton.onclick = this.onDeleteClick.bind(this); - this.onTypeChange(null); - } - onTypeChange(event) { - this.allElements.forEach(eFormElement => { - this.toggleField(eFormElement, true); - }); - this.toggleField(this.eIdLabel, false); - this.toggleField(this.eTypeLabel, false); - if (this.getContextType() !== contextTypes.DISABLED) { - this.toggleField(this.eUnitLabel, false); - this.toggleField(this.eScaleLabel, false); - } - switch (this.getContextType()) { - case contextTypes.CONSTANT: - this.toggleField(this.eManualValueInput, false); - break; - case contextTypes.CONTINUOUS: - this.toggleField(this.eRangeFromLabel, false); - this.toggleField(this.eRangeToLabel, false); - this.toggleField(this.eRangeStepLabel, false); - break; - case contextTypes.VALUE_RANGE: - this.toggleField(this.eManualValuesInput, false); - break; - case contextTypes.DATASET_RANG: - this.toggleField(this.eDataSetLabel, false); - break; - } - } - onDeleteClick(event) { - this.rootElement.remove(); - uiContextComponents = uiContextComponents.filter(item => item !== this); - if (uiContextComponents.length < 1) { - eContextStatusMessage.hidden = false; - } - } - toggleField(eFormField, hidden) { - eFormField.parentNode.parentNode.hidden = hidden; - } - getContextType() { - return contextTypes[this.eTypeSelect.value]; - } -} -eContextAddButton.onclick = function () { - const eNewContextComponent = eTemplateContextComponent.cloneNode(true).firstElementChild; - if (eNewContextComponent === null) { - alert("error.ui.context.component.cannotGetElement"); - throw Error("error.ui.context.component.cannotGetElement"); - } - const newContextComponent = new ContextComponentUiElement(eNewContextComponent); - uiContextComponents.push(newContextComponent); - eContextStatusMessage.parentNode.insertBefore(newContextComponent.rootElement, eContextStatusMessage); - eContextStatusMessage.hidden = true; -}; -function getRee() { -} -class NumberProlapsingMachine { - static createNewFromUi(formulaVariant) { - return null; - } -} -if (new URLSearchParams(window.location.search).has("debug")) { - console.debug("Preparing debugging tools..."); - let eDebugContainer = document.querySelector("div#fw-debug-root"); - let eDebugLinkAndIdsButton = document.querySelector("button#fw-button-debug-linkAndIds"); - if (eDebugContainer === null || eDebugLinkAndIdsButton === null) { - alert("error.ui.context.missingButton"); - throw Error("error.ui.context.missingButton"); - } - eDebugContainer.hidden = false; - eDebugLinkAndIdsButton.onclick = function () { - alert(JSON.stringify({ 'a': 1, 'b': 3 }, null, 4)); - }; -} -const endTime = new Date().getMilliseconds(); -console.log("Done, took " + (endTime - startTime) + "ms !"); -//# sourceMappingURL=code.js.map \ No newline at end of file diff --git a/tools/items/formula-wizard/src/formula-wizard.js b/tools/items/formula-wizard/src/formula-wizard.js deleted file mode 100644 index 8785faa..0000000 --- a/tools/items/formula-wizard/src/formula-wizard.js +++ /dev/null @@ -1,628 +0,0 @@ -'use strict'; - -/*! - * decimal.js v10.4.3 - * An arbitrary-precision Decimal type for JavaScript. - * https://github.com/MikeMcl/decimal.js - * Copyright (c) 2022 Michael Mclaughlin - * MIT Licence - */ -var n,e,i=9e15,r=1e9,t="0123456789abcdef",s="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",o="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",u={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-i,maxE:i,crypto:!1},c=!0,f="[DecimalError] ",a=f+"Invalid argument: ",h=f+"Precision limit exceeded",l=f+"crypto unavailable",d="[object Decimal]",g=Math.floor,p=Math.pow,m=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,w=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,v=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,N=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,b=1e7,E=7,x=s.length-1,y=o.length-1,M={toStringTag:d};function q(n){var e,i,r,t=n.length-1,s="",o=n[0];if(t>0){for(s+=o,e=1;ei)throw Error(a+n)}function D(n,e,i,r){var t,s,o,u;for(s=n[0];s>=10;s/=10)--e;return --e<0?(e+=E,t=0):(t=Math.ceil((e+1)/E),e%=E),s=p(10,E-e),u=n[t]%s|0,null==r?e<3?(0==e?u=u/100|0:1==e&&(u=u/10|0),o=i<4&&99999==u||i>3&&49999==u||5e4==u||0==u):o=(i<4&&u+1==s||i>3&&u+1==s/2)&&(n[t+1]/s/100|0)==p(10,e-2)-1||(u==s/2||0==u)&&0==(n[t+1]/s/100|0):e<4?(0==e?u=u/1e3|0:1==e?u=u/100|0:2==e&&(u=u/10|0),o=(r||i<4)&&9999==u||!r&&i>3&&4999==u):o=((r||i<4)&&u+1==s||!r&&i>3&&u+1==s/2)&&(n[t+1]/s/1e3|0)==p(10,e-3)-1,o}function F(n,e,i){for(var r,s,o=[0],u=0,c=n.length;ui-1&&(void 0===o[r+1]&&(o[r+1]=0),o[r+1]+=o[r]/i|0,o[r]%=i);}return o.reverse()}M.absoluteValue=M.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),Z(n)},M.ceil=function(){return Z(new this.constructor(this),this.e+1,2)},M.clampedTo=M.clamp=function(n,e){var i=this,r=i.constructor;if(n=new r(n),e=new r(e),!n.s||!e.s)return new r(NaN);if(n.gt(e))throw Error(a+e);return i.cmp(n)<0?n:i.cmp(e)>0?e:new r(i)},M.comparedTo=M.cmp=function(n){var e,i,r,t,s=this,o=s.d,u=(n=new s.constructor(n)).d,c=s.s,f=n.s;if(!o||!u)return c&&f?c!==f?c:o===u?0:!o^c<0?1:-1:NaN;if(!o[0]||!u[0])return o[0]?c:u[0]?-f:0;if(c!==f)return c;if(s.e!==n.e)return s.e>n.e^c<0?1:-1;for(e=0,i=(r=o.length)<(t=u.length)?r:t;eu[e]^c<0?1:-1;return r===t?0:r>t^c<0?1:-1},M.cosine=M.cos=function(){var n,i,r=this,t=r.constructor;return r.d?r.d[0]?(n=t.precision,i=t.rounding,t.precision=n+Math.max(r.e,r.sd())+E,t.rounding=1,r=function(n,e){var i,r,t;if(e.isZero())return e;r=e.d.length,r<32?t=(1/W(4,i=Math.ceil(r/3))).toString():(i=16,t="2.3283064365386962890625e-10");n.precision+=i,e=j(n,1,e.times(t),new n(1));for(var s=i;s--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1);}return n.precision-=i,e}(t,J(t,r)),t.precision=n,t.rounding=i,Z(2==e||3==e?r.neg():r,n,i,!0)):new t(1):new t(NaN)},M.cubeRoot=M.cbrt=function(){var n,e,i,r,t,s,o,u,f,a,h=this,l=h.constructor;if(!h.isFinite()||h.isZero())return new l(h);for(c=!1,(s=h.s*p(h.s*h,1/3))&&Math.abs(s)!=1/0?r=new l(s.toString()):(i=q(h.d),(s=((n=h.e)-i.length+1)%3)&&(i+=1==s||-2==s?"0":"00"),s=p(i,1/3),n=g((n+1)/3)-(n%3==(n<0?-1:2)),(r=new l(i=s==1/0?"5e"+n:(i=s.toExponential()).slice(0,i.indexOf("e")+1)+n)).s=h.s),o=(n=l.precision)+3;;)if(a=(f=(u=r).times(u).times(u)).plus(h),r=A(a.plus(h).times(u),a.plus(f),o+2,1),q(u.d).slice(0,o)===(i=q(r.d)).slice(0,o)){if("9999"!=(i=i.slice(o-3,o+1))&&(t||"4999"!=i)){+i&&(+i.slice(1)||"5"!=i.charAt(0))||(Z(r,n+1,1),e=!r.times(r).times(r).eq(h));break}if(!t&&(Z(u,n+1,0),u.times(u).times(u).eq(h))){r=u;break}o+=4,t=1;}return c=!0,Z(r,n,l.rounding,e)},M.decimalPlaces=M.dp=function(){var n,e=this.d,i=NaN;if(e){if(i=((n=e.length-1)-g(this.e/E))*E,n=e[n])for(;n%10==0;n/=10)i--;i<0&&(i=0);}return i},M.dividedBy=M.div=function(n){return A(this,new this.constructor(n))},M.dividedToIntegerBy=M.divToInt=function(n){var e=this.constructor;return Z(A(this,new e(n),0,1,1),e.precision,e.rounding)},M.equals=M.eq=function(n){return 0===this.cmp(n)},M.floor=function(){return Z(new this.constructor(this),this.e+1,3)},M.greaterThan=M.gt=function(n){return this.cmp(n)>0},M.greaterThanOrEqualTo=M.gte=function(n){var e=this.cmp(n);return 1==e||0===e},M.hyperbolicCosine=M.cosh=function(){var n,e,i,r,t,s=this,o=s.constructor,u=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return u;i=o.precision,r=o.rounding,o.precision=i+Math.max(s.e,s.sd())+4,o.rounding=1,(t=s.d.length)<32?e=(1/W(4,n=Math.ceil(t/3))).toString():(n=16,e="2.3283064365386962890625e-10"),s=j(o,1,s.times(e),new o(1),!0);for(var c,f=n,a=new o(8);f--;)c=s.times(s),s=u.minus(c.times(a.minus(c.times(a))));return Z(s,o.precision=i,o.rounding=r,!0)},M.hyperbolicSine=M.sinh=function(){var n,e,i,r,t=this,s=t.constructor;if(!t.isFinite()||t.isZero())return new s(t);if(e=s.precision,i=s.rounding,s.precision=e+Math.max(t.e,t.sd())+4,s.rounding=1,(r=t.d.length)<3)t=j(s,2,t,t,!0);else {n=(n=1.4*Math.sqrt(r))>16?16:0|n,t=j(s,2,t=t.times(1/W(5,n)),t,!0);for(var o,u=new s(5),c=new s(16),f=new s(20);n--;)o=t.times(t),t=t.times(u.plus(o.times(c.times(o).plus(f))));}return s.precision=e,s.rounding=i,Z(t,e,i,!0)},M.hyperbolicTangent=M.tanh=function(){var n,e,i=this,r=i.constructor;return i.isFinite()?i.isZero()?new r(i):(n=r.precision,e=r.rounding,r.precision=n+7,r.rounding=1,A(i.sinh(),i.cosh(),r.precision=n,r.rounding=e)):new r(i.s)},M.inverseCosine=M.acos=function(){var n,e=this,i=e.constructor,r=e.abs().cmp(1),t=i.precision,s=i.rounding;return -1!==r?0===r?e.isNeg()?T(i,t,s):new i(0):new i(NaN):e.isZero()?T(i,t+4,s).times(.5):(i.precision=t+6,i.rounding=1,e=e.asin(),n=T(i,t+4,s).times(.5),i.precision=t,i.rounding=s,n.minus(e))},M.inverseHyperbolicCosine=M.acosh=function(){var n,e,i=this,r=i.constructor;return i.lte(1)?new r(i.eq(1)?0:NaN):i.isFinite()?(n=r.precision,e=r.rounding,r.precision=n+Math.max(Math.abs(i.e),i.sd())+4,r.rounding=1,c=!1,i=i.times(i).minus(1).sqrt().plus(i),c=!0,r.precision=n,r.rounding=e,i.ln()):new r(i)},M.inverseHyperbolicSine=M.asinh=function(){var n,e,i=this,r=i.constructor;return !i.isFinite()||i.isZero()?new r(i):(n=r.precision,e=r.rounding,r.precision=n+2*Math.max(Math.abs(i.e),i.sd())+6,r.rounding=1,c=!1,i=i.times(i).plus(1).sqrt().plus(i),c=!0,r.precision=n,r.rounding=e,i.ln())},M.inverseHyperbolicTangent=M.atanh=function(){var n,e,i,r,t=this,s=t.constructor;return t.isFinite()?t.e>=0?new s(t.abs().eq(1)?t.s/0:t.isZero()?t:NaN):(n=s.precision,e=s.rounding,r=t.sd(),Math.max(r,n)<2*-t.e-1?Z(new s(t),n,e,!0):(s.precision=i=r-t.e,t=A(t.plus(1),new s(1).minus(t),i+n,1),s.precision=n+4,s.rounding=1,t=t.ln(),s.precision=n,s.rounding=e,t.times(.5))):new s(NaN)},M.inverseSine=M.asin=function(){var n,e,i,r,t=this,s=t.constructor;return t.isZero()?new s(t):(e=t.abs().cmp(1),i=s.precision,r=s.rounding,-1!==e?0===e?((n=T(s,i+4,r).times(.5)).s=t.s,n):new s(NaN):(s.precision=i+6,s.rounding=1,t=t.div(new s(1).minus(t.times(t)).sqrt().plus(1)).atan(),s.precision=i,s.rounding=r,t.times(2)))},M.inverseTangent=M.atan=function(){var n,e,i,r,t,s,o,u,f,a=this,h=a.constructor,l=h.precision,d=h.rounding;if(a.isFinite()){if(a.isZero())return new h(a);if(a.abs().eq(1)&&l+4<=y)return (o=T(h,l+4,d).times(.25)).s=a.s,o}else {if(!a.s)return new h(NaN);if(l+4<=y)return (o=T(h,l+4,d).times(.5)).s=a.s,o}for(h.precision=u=l+10,h.rounding=1,n=i=Math.min(28,u/E+2|0);n;--n)a=a.div(a.times(a).plus(1).sqrt().plus(1));for(c=!1,e=Math.ceil(u/E),r=1,f=a.times(a),o=new h(a),t=a;-1!==n;)if(t=t.times(f),s=o.minus(t.div(r+=2)),t=t.times(f),void 0!==(o=s.plus(t.div(r+=2))).d[e])for(n=e;o.d[n]===s.d[n]&&n--;);return i&&(o=o.times(2<this.d.length-2},M.isNaN=function(){return !this.s},M.isNegative=M.isNeg=function(){return this.s<0},M.isPositive=M.isPos=function(){return this.s>0},M.isZero=function(){return !!this.d&&0===this.d[0]},M.lessThan=M.lt=function(n){return this.cmp(n)<0},M.lessThanOrEqualTo=M.lte=function(n){return this.cmp(n)<1},M.logarithm=M.log=function(n){var e,i,r,t,s,o,u,f,a=this,h=a.constructor,l=h.precision,d=h.rounding;if(null==n)n=new h(10),e=!0;else {if(i=(n=new h(n)).d,n.s<0||!i||!i[0]||n.eq(1))return new h(NaN);e=n.eq(10);}if(i=a.d,a.s<0||!i||!i[0]||a.eq(1))return new h(i&&!i[0]?-1/0:1!=a.s?NaN:i?0:1/0);if(e)if(i.length>1)s=!0;else {for(t=i[0];t%10==0;)t/=10;s=1!==t;}if(c=!1,o=H(a,u=l+5),r=e?R(h,u+10):H(n,u),D((f=A(o,r,u,1)).d,t=l,d))do{if(o=H(a,u+=10),r=e?R(h,u+10):H(n,u),f=A(o,r,u,1),!s){+q(f.d).slice(t+1,t+15)+1==1e14&&(f=Z(f,l+1,0));break}}while(D(f.d,t+=10,d));return c=!0,Z(f,l,d)},M.minus=M.sub=function(n){var e,i,r,t,s,o,u,f,a,h,l,d,p=this,m=p.constructor;if(n=new m(n),!p.d||!n.d)return p.s&&n.s?p.d?n.s=-n.s:n=new m(n.d||p.s!==n.s?p:NaN):n=new m(NaN),n;if(p.s!=n.s)return n.s=-n.s,p.plus(n);if(a=p.d,d=n.d,u=m.precision,f=m.rounding,!a[0]||!d[0]){if(d[0])n.s=-n.s;else {if(!a[0])return new m(3===f?-0:0);n=new m(p);}return c?Z(n,u,f):n}if(i=g(n.e/E),h=g(p.e/E),a=a.slice(),s=h-i){for((l=s<0)?(e=a,s=-s,o=d.length):(e=d,i=h,o=a.length),s>(r=Math.max(Math.ceil(u/E),o)+2)&&(s=r,e.length=1),e.reverse(),r=s;r--;)e.push(0);e.reverse();}else {for((l=(r=a.length)<(o=d.length))&&(o=r),r=0;r0;--r)a[o++]=0;for(r=d.length;r>s;){if(a[--r](o=(s=Math.ceil(u/E))>o?s+1:o+1)&&(t=o,i.length=1),i.reverse();t--;)i.push(0);i.reverse();}for((o=a.length)-(t=h.length)<0&&(t=o,i=h,h=a,a=i),e=0;t;)e=(a[--t]=a[t]+h[t]+e)/b|0,a[t]%=b;for(e&&(a.unshift(e),++r),o=a.length;0==a[--o];)a.pop();return n.d=a,n.e=P(a,r),c?Z(n,u,f):n},M.precision=M.sd=function(n){var e,i=this;if(void 0!==n&&n!==!!n&&1!==n&&0!==n)throw Error(a+n);return i.d?(e=_(i.d),n&&i.e+1>e&&(e=i.e+1)):e=NaN,e},M.round=function(){var n=this,e=n.constructor;return Z(new e(n),n.e+1,e.rounding)},M.sine=M.sin=function(){var n,i,r=this,t=r.constructor;return r.isFinite()?r.isZero()?new t(r):(n=t.precision,i=t.rounding,t.precision=n+Math.max(r.e,r.sd())+E,t.rounding=1,r=function(n,e){var i,r=e.d.length;if(r<3)return e.isZero()?e:j(n,2,e,e);i=(i=1.4*Math.sqrt(r))>16?16:0|i,e=e.times(1/W(5,i)),e=j(n,2,e,e);for(var t,s=new n(5),o=new n(16),u=new n(20);i--;)t=e.times(e),e=e.times(s.plus(t.times(o.times(t).minus(u))));return e}(t,J(t,r)),t.precision=n,t.rounding=i,Z(e>2?r.neg():r,n,i,!0)):new t(NaN)},M.squareRoot=M.sqrt=function(){var n,e,i,r,t,s,o=this,u=o.d,f=o.e,a=o.s,h=o.constructor;if(1!==a||!u||!u[0])return new h(!a||a<0&&(!u||u[0])?NaN:u?o:1/0);for(c=!1,0==(a=Math.sqrt(+o))||a==1/0?(((e=q(u)).length+f)%2==0&&(e+="0"),a=Math.sqrt(e),f=g((f+1)/2)-(f<0||f%2),r=new h(e=a==1/0?"5e"+f:(e=a.toExponential()).slice(0,e.indexOf("e")+1)+f)):r=new h(a.toString()),i=(f=h.precision)+3;;)if(r=(s=r).plus(A(o,s,i+2,1)).times(.5),q(s.d).slice(0,i)===(e=q(r.d)).slice(0,i)){if("9999"!=(e=e.slice(i-3,i+1))&&(t||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(Z(r,f+1,1),n=!r.times(r).eq(o));break}if(!t&&(Z(s,f+1,0),s.times(s).eq(o))){r=s;break}i+=4,t=1;}return c=!0,Z(r,f,h.rounding,n)},M.tangent=M.tan=function(){var n,i,r=this,t=r.constructor;return r.isFinite()?r.isZero()?new t(r):(n=t.precision,i=t.rounding,t.precision=n+10,t.rounding=1,(r=r.sin()).s=1,r=A(r,new t(1).minus(r.times(r)).sqrt(),n+10,0),t.precision=n,t.rounding=i,Z(2==e||4==e?r.neg():r,n,i,!0)):new t(NaN)},M.times=M.mul=function(n){var e,i,r,t,s,o,u,f,a,h=this,l=h.constructor,d=h.d,p=(n=new l(n)).d;if(n.s*=h.s,!(d&&d[0]&&p&&p[0]))return new l(!n.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:d&&p?0*n.s:n.s/0);for(i=g(h.e/E)+g(n.e/E),(f=d.length)<(a=p.length)&&(s=d,d=p,p=s,o=f,f=a,a=o),s=[],r=o=f+a;r--;)s.push(0);for(r=a;--r>=0;){for(e=0,t=f+r;t>r;)u=s[t]+p[r]*d[t-r-1]+e,s[t--]=u%b|0,e=u/b|0;s[t]=(s[t]+e)%b|0;}for(;!s[--o];)s.pop();return e?++i:s.shift(),n.d=s,n.e=P(s,i),c?Z(n,l.precision,l.rounding):n},M.toBinary=function(n,e){return z(this,2,n,e)},M.toDecimalPlaces=M.toDP=function(n,e){var i=this,t=i.constructor;return i=new t(i),void 0===n?i:(O(n,0,r),void 0===e?e=t.rounding:O(e,0,8),Z(i,n+i.e+1,e))},M.toExponential=function(n,e){var i,t=this,s=t.constructor;return void 0===n?i=S(t,!0):(O(n,0,r),void 0===e?e=s.rounding:O(e,0,8),i=S(t=Z(new s(t),n+1,e),!0,n+1)),t.isNeg()&&!t.isZero()?"-"+i:i},M.toFixed=function(n,e){var i,t,s=this,o=s.constructor;return void 0===n?i=S(s):(O(n,0,r),void 0===e?e=o.rounding:O(e,0,8),i=S(t=Z(new o(s),n+s.e+1,e),!1,n+t.e+1)),s.isNeg()&&!s.isZero()?"-"+i:i},M.toFraction=function(n){var e,i,r,t,s,o,u,f,h,l,d,g,m=this,w=m.d,v=m.constructor;if(!w)return new v(m);if(h=i=new v(1),r=f=new v(0),o=(s=(e=new v(r)).e=_(w)-m.e-1)%E,e.d[0]=p(10,o<0?E+o:o),null==n)n=s>0?e:h;else {if(!(u=new v(n)).isInt()||u.lt(h))throw Error(a+u);n=u.gt(e)?s>0?e:h:u;}for(c=!1,u=new v(q(w)),l=v.precision,v.precision=s=w.length*E*2;d=A(u,e,0,1,1),1!=(t=i.plus(d.times(r))).cmp(n);)i=r,r=t,t=h,h=f.plus(d.times(t)),f=t,t=e,e=u.minus(d.times(t)),u=t;return t=A(n.minus(i),r,0,1,1),f=f.plus(t.times(h)),i=i.plus(t.times(r)),f.s=h.s=m.s,g=A(h,r,s,1).minus(m).abs().cmp(A(f,i,s,1).minus(m).abs())<1?[h,r]:[f,i],v.precision=l,c=!0,g},M.toHexadecimal=M.toHex=function(n,e){return z(this,16,n,e)},M.toNearest=function(n,e){var i=this,r=i.constructor;if(i=new r(i),null==n){if(!i.d)return i;n=new r(1),e=r.rounding;}else {if(n=new r(n),void 0===e?e=r.rounding:O(e,0,8),!i.d)return n.s?i:n;if(!n.d)return n.s&&(n.s=i.s),n}return n.d[0]?(c=!1,i=A(i,n,0,e,1).times(n),c=!0,Z(i)):(n.s=i.s,i=n),i},M.toNumber=function(){return +this},M.toOctal=function(n,e){return z(this,8,n,e)},M.toPower=M.pow=function(n){var e,i,r,t,s,o,u=this,f=u.constructor,a=+(n=new f(n));if(!(u.d&&n.d&&u.d[0]&&n.d[0]))return new f(p(+u,a));if((u=new f(u)).eq(1))return u;if(r=f.precision,s=f.rounding,n.eq(1))return Z(u,r,s);if((e=g(n.e/E))>=n.d.length-1&&(i=a<0?-a:a)<=9007199254740991)return t=U(f,u,i,r),n.s<0?new f(1).div(t):Z(t,r,s);if((o=u.s)<0){if(ef.maxE+1||e0?o/0:0):(c=!1,f.rounding=u.s=1,i=Math.min(12,(e+"").length),(t=C(n.times(H(u,r+i)),r)).d&&D((t=Z(t,r+5,1)).d,r,s)&&(e=r+10,+q((t=Z(C(n.times(H(u,e+i)),e),e+5,1)).d).slice(r+1,r+15)+1==1e14&&(t=Z(t,r+1,0))),t.s=o,c=!0,f.rounding=s,Z(t,r,s))},M.toPrecision=function(n,e){var i,t=this,s=t.constructor;return void 0===n?i=S(t,t.e<=s.toExpNeg||t.e>=s.toExpPos):(O(n,1,r),void 0===e?e=s.rounding:O(e,0,8),i=S(t=Z(new s(t),n,e),n<=t.e||t.e<=s.toExpNeg,n)),t.isNeg()&&!t.isZero()?"-"+i:i},M.toSignificantDigits=M.toSD=function(n,e){var i=this.constructor;return void 0===n?(n=i.precision,e=i.rounding):(O(n,1,r),void 0===e?e=i.rounding:O(e,0,8)),Z(new i(this),n,e)},M.toString=function(){var n=this,e=n.constructor,i=S(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+i:i},M.truncated=M.trunc=function(){return Z(new this.constructor(this),this.e+1,1)},M.valueOf=M.toJSON=function(){var n=this,e=n.constructor,i=S(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+i:i};var A=function(){function e(n,e,i){var r,t=0,s=n.length;for(n=n.slice();s--;)r=n[s]*e+t,n[s]=r%i|0,t=r/i|0;return t&&n.unshift(t),n}function i(n,e,i,r){var t,s;if(i!=r)s=i>r?1:-1;else for(t=s=0;te[t]?1:-1;break}return s}function r(n,e,i,r){for(var t=0;i--;)n[i]-=t,t=n[i]1;)n.shift();}return function(t,s,o,u,c,f){var a,h,l,d,p,m,w,v,N,x,y,M,q,O,D,F,A,S,P,R,T=t.constructor,_=t.s==s.s?1:-1,L=t.d,U=s.d;if(!(L&&L[0]&&U&&U[0]))return new T(t.s&&s.s&&(L?!U||L[0]!=U[0]:U)?L&&0==L[0]||!U?0*_:_/0:NaN);for(f?(p=1,h=t.e-s.e):(f=b,p=E,h=g(t.e/p)-g(s.e/p)),P=U.length,A=L.length,x=(N=new T(_)).d=[],l=0;U[l]==(L[l]||0);l++);if(U[l]>(L[l]||0)&&h--,null==o?(O=o=T.precision,u=T.rounding):O=c?o+(t.e-s.e)+1:o,O<0)x.push(1),m=!0;else {if(O=O/p+2|0,l=0,1==P){for(d=0,U=U[0],O++;(l1&&(U=e(U,d,f),L=e(L,d,f),P=U.length,A=L.length),F=P,M=(y=L.slice(0,P)).length;M=f/2&&++S;do{d=0,(a=i(U,y,P,M))<0?(q=y[0],P!=M&&(q=q*f+(y[1]||0)),(d=q/S|0)>1?(d>=f&&(d=f-1),1==(a=i(w=e(U,d,f),y,v=w.length,M=y.length))&&(d--,r(w,P=10;d/=10)l++;N.e=l+h*p-1,Z(N,c?o+N.e+1:o,u,m);}return N}}();function Z(n,e,i,r){var t,s,o,u,f,a,h,l,d,g=n.constructor;n:if(null!=e){if(!(l=n.d))return n;for(t=1,u=l[0];u>=10;u/=10)t++;if((s=e-t)<0)s+=E,o=e,f=(h=l[d=0])/p(10,t-o-1)%10|0;else if((d=Math.ceil((s+1)/E))>=(u=l.length)){if(!r)break n;for(;u++<=d;)l.push(0);h=f=0,t=1,o=(s%=E)-E+1;}else {for(h=u=l[d],t=1;u>=10;u/=10)t++;f=(o=(s%=E)-E+t)<0?0:h/p(10,t-o-1)%10|0;}if(r=r||e<0||void 0!==l[d+1]||(o<0?h:h%p(10,t-o-1)),a=i<4?(f||r)&&(0==i||i==(n.s<0?3:2)):f>5||5==f&&(4==i||r||6==i&&(s>0?o>0?h/p(10,t-o):0:l[d-1])%10&1||i==(n.s<0?8:7)),e<1||!l[0])return l.length=0,a?(e-=n.e+1,l[0]=p(10,(E-e%E)%E),n.e=-e||0):l[0]=n.e=0,n;if(0==s?(l.length=d,u=1,d--):(l.length=d+1,u=p(10,E-s),l[d]=o>0?(h/p(10,t-o)%p(10,o)|0)*u:0),a)for(;;){if(0==d){for(s=1,o=l[0];o>=10;o/=10)s++;for(o=l[0]+=u,u=1;o>=10;o/=10)u++;s!=u&&(n.e++,l[0]==b&&(l[0]=1));break}if(l[d]+=u,l[d]!=b)break;l[d--]=0,u=1;}for(s=l.length;0===l[--s];)l.pop();}return c&&(n.e>g.maxE?(n.d=null,n.e=NaN):n.e0?s=s.charAt(0)+"."+s.slice(1)+L(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(n.e<0?"e":"e+")+n.e):t<0?(s="0."+L(-t-1)+s,i&&(r=i-o)>0&&(s+=L(r))):t>=o?(s+=L(t+1-o),i&&(r=i-t-1)>0&&(s=s+"."+L(r))):((r=t+1)0&&(t+1===o&&(s+="."),s+=L(r))),s}function P(n,e){var i=n[0];for(e*=E;i>=10;i/=10)e++;return e}function R(n,e,i){if(e>x)throw c=!0,i&&(n.precision=i),Error(h);return Z(new n(s),e,1,!0)}function T(n,e,i){if(e>y)throw Error(h);return Z(new n(o),e,i,!0)}function _(n){var e=n.length-1,i=e*E+1;if(e=n[e]){for(;e%10==0;e/=10)i--;for(e=n[0];e>=10;e/=10)i++;}return i}function L(n){for(var e="";n--;)e+="0";return e}function U(n,e,i,r){var t,s=new n(1),o=Math.ceil(r/E+4);for(c=!1;;){if(i%2&&G((s=s.times(e)).d,o)&&(t=!0),0===(i=g(i/2))){i=s.d.length-1,t&&0===s.d[i]&&++s.d[i];break}G((e=e.times(e)).d,o);}return c=!0,s}function k(n){return 1&n.d[n.d.length-1]}function I(n,e,i){for(var r,t=new n(e[0]),s=0;++s17)return new d(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:NaN);for(null==e?(c=!1,f=m):f=e,u=new d(.03125);n.e>-2;)n=n.times(u),l+=5;for(f+=r=Math.log(p(2,l))/Math.LN10*2+5|0,i=s=o=new d(1),d.precision=f;;){if(s=Z(s.times(n),f,1),i=i.times(++h),q((u=o.plus(A(s,i,f,1))).d).slice(0,f)===q(o.d).slice(0,f)){for(t=l;t--;)o=Z(o.times(o),f,1);if(null!=e)return d.precision=m,o;if(!(a<3&&D(o.d,f-r,g,a)))return Z(o,d.precision=m,g,c=!0);d.precision=f+=10,i=s=u=new d(1),h=0,a++;}o=u;}}function H(n,e){var i,r,t,s,o,u,f,a,h,l,d,g=1,p=n,m=p.d,w=p.constructor,v=w.rounding,N=w.precision;if(p.s<0||!m||!m[0]||!p.e&&1==m[0]&&1==m.length)return new w(m&&!m[0]?-1/0:1!=p.s?NaN:m?0:p);if(null==e?(c=!1,h=N):h=e,w.precision=h+=10,r=(i=q(m)).charAt(0),!(Math.abs(s=p.e)<15e14))return a=R(w,h+2,N).times(s+""),p=H(new w(r+"."+i.slice(1)),h-10).plus(a),w.precision=N,null==e?Z(p,N,v,c=!0):p;for(;r<7&&1!=r||1==r&&i.charAt(1)>3;)r=(i=q((p=p.times(n)).d)).charAt(0),g++;for(s=p.e,r>1?(p=new w("0."+i),s++):p=new w(r+"."+i.slice(1)),l=p,f=o=p=A(p.minus(1),p.plus(1),h,1),d=Z(p.times(p),h,1),t=3;;){if(o=Z(o.times(d),h,1),q((a=f.plus(A(o,new w(t),h,1))).d).slice(0,h)===q(f.d).slice(0,h)){if(f=f.times(2),0!==s&&(f=f.plus(R(w,h+2,N).times(s+""))),f=A(f,new w(g),h,1),null!=e)return w.precision=N,f;if(!D(f.d,h-10,v,u))return Z(f,w.precision=N,v,c=!0);w.precision=h+=10,a=o=p=A(l.minus(1),l.plus(1),h,1),d=Z(p.times(p),h,1),t=u=1;}f=a,t+=2;}}function B(n){return String(n.s*n.s/0)}function V(n,e){var i,r,t;for((i=e.indexOf("."))>-1&&(e=e.replace(".","")),(r=e.search(/e/i))>0?(i<0&&(i=r),i+=+e.slice(r+1),e=e.substring(0,r)):i<0&&(i=e.length),r=0;48===e.charCodeAt(r);r++);for(t=e.length;48===e.charCodeAt(t-1);--t);if(e=e.slice(r,t)){if(t-=r,n.e=i=i-r-1,n.d=[],r=(i+1)%E,i<0&&(r+=E),rn.constructor.maxE?(n.d=null,n.e=NaN):n.e-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),N.test(e))return V(n,e)}else if("Infinity"===e||"NaN"===e)return +e||(n.s=NaN),n.e=NaN,n.d=null,n;if(w.test(e))i=16,e=e.toLowerCase();else if(m.test(e))i=2;else {if(!v.test(e))throw Error(a+e);i=8;}for((s=e.search(/p/i))>0?(f=+e.slice(s+1),e=e.substring(2,s)):e=e.slice(2),o=(s=e.indexOf("."))>=0,r=n.constructor,o&&(s=(u=(e=e.replace(".","")).length)-s,t=U(r,new r(i),s,2*s)),s=l=(h=F(e,i,b)).length-1;0===h[s];--s)h.pop();return s<0?new r(0*n.s):(n.e=P(h,l),n.d=h,c=!1,o&&(n=A(n,t,4*u)),f&&(n=n.times(Math.abs(f)<54?p(2,f):Decimal.pow(2,f))),c=!0,n)}function j(n,e,i,r,t){var s,o,u,f,a=n.precision,h=Math.ceil(a/E);for(c=!1,f=i.times(i),u=new n(r);;){if(o=A(u.times(f),new n(e++*e++),a,1),u=t?r.plus(o):r.minus(o),r=A(o.times(f),new n(e++*e++),a,1),void 0!==(o=u.plus(r)).d[h]){for(s=h;o.d[s]===u.d[s]&&s--;);if(-1==s)break}s=u,u=r,r=o,o=s;}return c=!0,o.d.length=h+1,o}function W(n,e){for(var i=n;--e;)i*=n;return i}function J(n,i){var r,t=i.s<0,s=T(n,n.precision,1),o=s.times(.5);if((i=i.abs()).lte(o))return e=t?4:1,i;if((r=i.divToInt(s)).isZero())e=t?3:2;else {if((i=i.minus(r.times(s))).lte(o))return e=k(r)?t?2:3:t?4:1,i;e=k(r)?t?1:4:t?3:2;}return i.minus(s).abs()}function z(e,i,s,o){var u,c,f,a,h,l,d,g,p,m=e.constructor,w=void 0!==s;if(w?(O(s,1,r),void 0===o?o=m.rounding:O(o,0,8)):(s=m.precision,o=m.rounding),e.isFinite()){for(w?(u=2,16==i?s=4*s-3:8==i&&(s=3*s-2)):u=i,(f=(d=S(e)).indexOf("."))>=0&&(d=d.replace(".",""),(p=new m(1)).e=d.length-f,p.d=F(S(p),10,u),p.e=p.d.length),c=h=(g=F(d,10,u)).length;0==g[--h];)g.pop();if(g[0]){if(f<0?c--:((e=new m(e)).d=g,e.e=c,g=(e=A(e,p,s,o,0,u)).d,c=e.e,l=n),f=g[s],a=u/2,l=l||void 0!==g[s+1],l=o<4?(void 0!==f||l)&&(0===o||o===(e.s<0?3:2)):f>a||f===a&&(4===o||l||6===o&&1&g[s-1]||o===(e.s<0?8:7)),g.length=s,l)for(;++g[--s]>u-1;)g[s]=0,s||(++c,g.unshift(1));for(h=g.length;!g[h-1];--h);for(f=0,d="";f1)if(16==i||8==i){for(f=16==i?4:3,--h;h%f;h++)d+="0";for(h=(g=F(d,u,i)).length;!g[h-1];--h);for(f=1,d="1.";fh)for(c-=h;c--;)d+="0";else ce)return n.length=e,!0}function K(n){return new this(n).abs()}function Q(n){return new this(n).acos()}function X(n){return new this(n).acosh()}function Y(n,e){return new this(n).plus(e)}function nn(n){return new this(n).asin()}function en(n){return new this(n).asinh()}function rn(n){return new this(n).atan()}function tn(n){return new this(n).atanh()}function sn(n,e){n=new this(n),e=new this(e);var i,r=this.precision,t=this.rounding,s=r+4;return n.s&&e.s?n.d||e.d?!e.d||n.isZero()?(i=e.s<0?T(this,r,t):new this(0)).s=n.s:!n.d||e.isZero()?(i=T(this,s,1).times(.5)).s=n.s:e.s<0?(this.precision=s,this.rounding=1,i=this.atan(A(n,e,s,1)),e=T(this,s,1),this.precision=r,this.rounding=t,i=n.s<0?i.minus(e):i.plus(e)):i=this.atan(A(n,e,s,1)):(i=T(this,s,1).times(e.s>0?.25:.75)).s=n.s:i=new this(NaN),i}function on(n){return new this(n).cbrt()}function un(n){return Z(n=new this(n),n.e+1,2)}function cn(n,e,i){return new this(n).clamp(e,i)}function fn(n){if(!n||"object"!=typeof n)throw Error(f+"Object expected");var e,t,s,o=!0===n.defaults,c=["precision",1,r,"rounding",0,8,"toExpNeg",-i,0,"toExpPos",0,i,"maxE",0,i,"minE",-i,0,"modulo",0,9];for(e=0;e=c[e+1]&&s<=c[e+2]))throw Error(a+t+": "+s);this[t]=s;}if(t="crypto",o&&(this[t]=u[t]),void 0!==(s=n[t])){if(!0!==s&&!1!==s&&0!==s&&1!==s)throw Error(a+t+": "+s);if(s){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(l);this[t]=!0;}else this[t]=!1;}return this}function an(n){return new this(n).cos()}function hn(n){return new this(n).cosh()}function ln(n,e){return new this(n).div(e)}function dn(n){return new this(n).exp()}function gn(n){return Z(n=new this(n),n.e+1,3)}function pn(){var n,e,i=new this(0);for(c=!1,n=0;n=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:c[o++]=s%1e7;else {if(!crypto.randomBytes)throw Error(l);for(e=crypto.randomBytes(t*=4);o=214e7?crypto.randomBytes(4).copy(e,o):(c.push(s%1e7),o+=4);o=t/4;}else for(;o=10;s/=10)t++;ts.maxE?(t.e=NaN,t.d=null):n.e=10;i/=10)e++;return void(c?e>s.maxE?(t.e=NaN,t.d=null):e { - return unit.symbol; - }; - this.formatSymbol = (unit) => { - return unit.symbol; - }; - this.scaleFactors = []; - } - }, - IMPERIAL_DISTANCE: new class { - constructor() { - this.formatName = (unit) => { - return unit.symbol; - }; - this.formatSymbol = (unit) => { - return unit.symbol; - }; - this.scaleFactors = []; - } - }, - IMPERIAL_WEIGHT: new class { - constructor() { - this.formatName = (unit) => { - return unit.symbol; - }; - this.formatSymbol = (unit) => { - return unit.symbol; - }; - this.scaleFactors = []; - } - }, - TIME_SECONDS: new class { - constructor() { - this.formatName = (unit) => { - return unit.symbol; - }; - this.formatSymbol = (unit) => { - return unit.symbol; - }; - this.scaleFactors = []; - } - }, - NONE: new class { - constructor() { - this.formatName = (unit) => { - return unit.name; - }; - this.formatSymbol = (unit) => { - return unit.symbol; - }; - this.scaleFactors = []; - } - }, -}; -const scaleFactors = { - SI_GIGA: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1e9'); - this.prefix = "giga"; - this.suffix = ""; - this.symbol = "G"; - } - }, - SI_MEGA: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1e6'); - this.prefix = "mega"; - this.suffix = ""; - this.symbol = "M"; - } - }, - SI_KILO: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1e3'); - this.prefix = "kilo"; - this.suffix = ""; - this.symbol = "k"; - } - }, - SI_BASE: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1'); - this.prefix = ""; - this.suffix = ""; - this.symbol = ""; - } - }, - SI_CENTI: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1e-2'); - this.prefix = "centi"; - this.suffix = ""; - this.symbol = "c"; - } - }, - SI_MILLI: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1e-3'); - this.prefix = "milli"; - this.suffix = ""; - this.symbol = "m"; - } - }, - TIME_MILLI: new class { - constructor() { - this.scale = scales.TIME_SECONDS; - this.multiplier = new Decimal('1e-3'); - this.prefix = "milli"; - this.suffix = ""; - this.symbol = "m"; - } - }, - TIME_BASE: new class { - constructor() { - this.scale = scales.TIME_SECONDS; - this.multiplier = new Decimal('1'); - this.prefix = ""; - this.suffix = ""; - this.symbol = ""; - } - }, - TIME_MINUTE: new class { - constructor() { - this.scale = scales.TIME_SECONDS; - this.multiplier = new Decimal('60'); - this.prefix = ""; - this.suffix = ""; - this.symbol = ""; - } - }, - TIME_HOUR: new class { - constructor() { - this.scale = scales.TIME_SECONDS; - this.multiplier = new Decimal('3600'); - this.prefix = ""; - this.suffix = ""; - this.symbol = ""; - } - }, - TIME_DAY: new class { - constructor() { - this.scale = scales.TIME_SECONDS; - this.multiplier = new Decimal('86400'); - this.prefix = ""; - this.suffix = ""; - this.symbol = ""; - } - }, -}; -const units = { - ANY: new Unit("any", "", scales.NONE), - WATT: new Unit("watt", "W", scales.SI), - VOLT: new Unit("volt", "V", scales.SI), - AMPERE: new Unit("ampere", "A", scales.SI), - OHM: new Unit("ohm", "Ω", scales.SI), - FARAD: new Unit("farad", "F", scales.SI), - METER: new Unit("meter", "m", scales.SI), - INCH: new Unit("inch", "in", scales.IMPERIAL_DISTANCE), - POUND: new Unit("pound", "p", scales.IMPERIAL_WEIGHT), -}; -function scaleToBase(value, scaleFactor) { - return value.times(scaleFactor.multiplier); -} -function scaleFromBase(value, scaleFactor) { - return value.dividedBy(scaleFactor.multiplier); -} -let areUnitsInitialized = false; -function initUnits() { - if (!areUnitsInitialized) { - console.debug("Initializing scales & units..."); - Object.keys(scaleFactors).forEach(scaleFactorKey => { - const scaleFactor = scaleFactors[scaleFactorKey]; - scaleFactor.scale.scaleFactors.push(scaleFactor); - }); - areUnitsInitialized = true; - } -} - -class FormulaContextHandler { - constructor(contextValueIndex) { - this.contextValueIndex = contextValueIndex; - } - getContextValue(context) { - if (context.length <= this.contextValueIndex) { - alert(localize("error.formulaContext.tooSmall")); - throw new Error(localize("error.formulaContext.tooSmall")); - } - return context[this.contextValueIndex]; - } -} -class FormulaValue { - constructor(unit, scaleFactor) { - this.unit = unit; - this.scaleFactor = scaleFactor; - this.parentFormula = null; - this.valueSource = null; - } - getFormulaValue(context) { - if (this.parentFormula === null) { - alert(localize("error.formulaValue.noParent")); - throw new Error(localize("error.formulaValue.noParent")); - } - if (this.valueSource === null) { - alert(localize("error.formulaValue.noSource")); - throw new Error(localize("error.formulaValue.noSource")); - } - if (this.valueSource instanceof FormulaContextHandler) { - return this.valueSource.getContextValue(context); - } - return scaleFromBase(scaleToBase(this.valueSource.getVariantValue(this.parentFormula, context), this.valueSource.getOutputValueDefinition().scaleFactor), this.scaleFactor); - } -} -class Formula { - constructor(values, variants, formulaKey, categories, wikiLink) { - this.values = values; - this.variants = variants; - this.formulaKey = formulaKey; - this.name = localize("formula." + formulaKey + ".name"); - this.description = localize("formula." + formulaKey + ".desc"); - this.categories = categories; - this.wikiLink = wikiLink; - this.values.forEach(value => { - value.parentFormula = this; - }); - } - getClone() { - const clonedFormulaValues = []; - this.values.forEach(originalValue => { - clonedFormulaValues.push(new FormulaValue(originalValue.unit, originalValue.scaleFactor)); - }); - return new Formula(clonedFormulaValues, this.variants, this.formulaKey, this.categories, this.wikiLink); - } -} -const formulas = { - OHM_LAW: new Formula([ - new FormulaValue(units.OHM, scaleFactors.SI_BASE), - new FormulaValue(units.AMPERE, scaleFactors.SI_BASE), - new FormulaValue(units.VOLT, scaleFactors.SI_BASE), - ], [ - new class { - constructor() { - this.description = "V=I*R"; - this.getVariantValue = (formula, context) => { - return formula.values[0].getFormulaValue(context).times(formula.values[1].getFormulaValue(context)); - }; - this.getInputValuesDefinition = () => { - return [this.parentFormula.values[0], this.parentFormula.values[1]]; - }; - this.getOutputValueDefinition = () => { - return this.parentFormula.values[2]; - }; - this.getMathMl = (formula) => { - return "" + - formula.values[2].unit.symbol + - "=" + - formula.values[0].unit.symbol + - "*" + - formula.values[1].unit.symbol + - ""; - }; - this.parentFormula = null; - } - }, - new class { - constructor() { - this.description = "I=V/R"; - this.getVariantValue = (formula, context) => { - return formula.values[2].getFormulaValue(context).dividedBy(formula.values[0].getFormulaValue(context)); - }; - this.getInputValuesDefinition = () => { - return [this.parentFormula.values[0], this.parentFormula.values[2]]; - }; - this.getOutputValueDefinition = () => { - return this.parentFormula.values[1]; - }; - this.getMathMl = (formula) => { - return "" + - formula.values[1].unit.symbol + - "=" + - formula.values[2].unit.symbol + - "" + - formula.values[0].unit.symbol + - ""; - }; - this.parentFormula = null; - } - }, - new class { - constructor() { - this.description = "R=V/I"; - this.getVariantValue = (formula, context) => { - return formula.values[2].getFormulaValue(context).dividedBy(formula.values[1].getFormulaValue(context)); - }; - this.getInputValuesDefinition = () => { - return [this.parentFormula.values[2], this.parentFormula.values[1]]; - }; - this.getOutputValueDefinition = () => { - return this.parentFormula.values[0]; - }; - this.getMathMl = (formula) => { - return "" + - formula.values[0].unit.symbol + - "=" + - formula.values[2].unit.symbol + - "" + - formula.values[1].unit.symbol + - ""; - }; - this.parentFormula = null; - } - }, - ], "ohm_law", ["electricity"], new URL("https://wikipedia.org/wiki/Ohm's_law")), -}; -let areFormulasInitialized = false; -function initFormulas() { - if (!areFormulasInitialized) { - console.debug("Initializing formulas..."); - Object.keys(formulas).forEach(formulaKey => { - formulas[formulaKey].variants.forEach(formulaVariant => { - formulaVariant.parentFormula = formulas[formulaKey]; - }); - }); - areFormulasInitialized = true; - } -} - -/*! - * Formula Wizard v0.0.2 - * [Short desc here] - * https://github.com/aziascreations/Web-NibblePoker - * Copyright (c) 2023 Herwin Bozet - * Unlicense Licence - */ -const idCatalogPrefix = "fw-catalog-"; -const idCatalogCategoryPrefix = idCatalogPrefix + "category-"; -const idCatalogCategoryCount = idCatalogPrefix + "formula-count"; -const eCategoryContainers = {}; -let IsCatalogInitialized = false; -function initCatalog() { - if (!IsCatalogInitialized) { - console.debug("Populating formula catalog..."); - document.querySelectorAll('[id]').forEach((element) => { - if (element.id.startsWith(idCatalogCategoryPrefix)) { - eCategoryContainers[element.id.replace(idCatalogCategoryPrefix, "")] = element; - } - }); - const eFormulaCount = document.getElementById(idCatalogCategoryCount); - if (eFormulaCount !== null) { - eFormulaCount.innerText = Object.keys(formulas).length.toString(); - } - let eTemplateFormula = document.getElementById("template-formula-available"); - let eTemplateFormulaVariant = document.getElementById("template-formula-available-variant"); - if (eTemplateFormula === null || eTemplateFormulaVariant === null) { - alert("error.ui.catalog.noTemplate"); - throw Error("error.ui.catalog.noTemplate"); - } - Object.keys(formulas).forEach(formulaKey => { - const hasValidCategory = formulas[formulaKey].categories.every(function (categoryId) { - return Object.keys(eCategoryContainers).indexOf(categoryId) !== -1; - }); - if (hasValidCategory) { - let eNewFormula = eTemplateFormula.content.cloneNode(true); - let eNewFormulaTitle = eNewFormula.querySelector("p"); - if (eNewFormulaTitle !== null) { - eNewFormulaTitle.innerText = formulas[formulaKey].name; - } - let eNewFormulaVariants = eNewFormula.querySelector("div.fw-variants"); - if (eNewFormulaVariants === null) { - alert(""); - throw Error(""); - } - eNewFormulaVariants.innerHTML = ""; - formulas[formulaKey].variants.forEach(variant => { - let eNewFormulaVariant = eTemplateFormulaVariant.content.cloneNode(true); - let eNewFormulaVariantButton = eNewFormulaVariant.querySelector("button"); - if (eNewFormulaVariantButton === null) { - alert(""); - throw Error(""); - } - eNewFormulaVariantButton.innerHTML = variant.getMathMl(formulas[formulaKey]); - eNewFormulaVariantButton.title = variant.description; - eNewFormulaVariants.appendChild(eNewFormulaVariant); - }); - formulas[formulaKey].categories.forEach(categoryKey => { - if (Object.keys(eCategoryContainers).includes(categoryKey)) { - eCategoryContainers[categoryKey].appendChild(eNewFormula); - } - }); - } - }); - IsCatalogInitialized = true; - } -} - -class DataSet { - constructor(name, description, values, unit, scaleFactor) { - this.name = name; - this.description = description; - this.values = values; - this.unit = unit; - this.scaleFactor = scaleFactor; - if (unit.scale != scaleFactor.scale) { - alert(""); - throw Error(""); - } - } - getDataSet() { - return this.values; - } -} -const e3Range = [1, 2.2, 4.7]; -const e6Range = [1, 1.5, 2.2, 3.3, 4.7, 6.8]; -const e12Range = [1, 1.2, 1.5, 1.8, 2.2, 2.7, 3.3, 3.9, 4.7, 5.6, 6.8, 8.2]; -const e24Range = [ - 1, 1.1, 1.2, 1.3, 1.5, 1.6, 1.8, 2, 2.2, 2.4, 2.7, 3, 3.3, 3.6, 3.9, 4.3, 4.7, 5.1, 5.6, 6.2, 6.8, 7.5, 8.2, 9.1 -]; -const e48Range = [ - 1, 1.05, 1.1, 1.15, 1.21, 1.27, 1.33, 1.4, 1.47, 1.54, 1.62, 1.69, 1.78, 1.87, 1.96, 2.05, 2.15, 2.26, 2.37, 2.49, - 2.61, 2.74, 2.87, 3.01, 3.16, 3.32, 3.48, 3.65, 3.83, 4.02, 4.22, 4.42, 4.64, 4.87, 5.11, 5.36, 5.62, 5.9, 6.19, - 6.49, 6.81, 7.15, 7.5, 7.87, 8.25, 8.66, 9.09, 9.53 -]; -const resistorsScales = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]; -const capacitorScales = [10e-12, 10e-11, 10e-10, 10e-9, 10e-8, 10e-7, 10e-6, 10e-5, 10e-4, 10e-3, 10e-2]; -const sets = { - RESISTOR_E3: new DataSet(localize("dataset.resistor-e3.name"), localize("dataset.resistor-e3.desc"), resistorsScales.flatMap((e3Scale) => e3Range.map((e3Multiplier) => new Decimal(e3Scale).times(e3Multiplier))), units.OHM, scaleFactors.SI_BASE), - RESISTOR_E6: new DataSet(localize("dataset.resistor-e6.name"), localize("dataset.resistor-e6.desc"), resistorsScales.flatMap((e6Scale) => e6Range.map((e6Multiplier) => new Decimal(e6Scale).times(e6Multiplier))), units.OHM, scaleFactors.SI_BASE), - RESISTOR_E12: new DataSet(localize("dataset.resistor-e12.name"), localize("dataset.resistor-e12.desc"), resistorsScales.flatMap((e12Scale) => e12Range.map((e12Multiplier) => new Decimal(e12Scale).times(e12Multiplier))), units.OHM, scaleFactors.SI_BASE), - RESISTOR_E24: new DataSet(localize("dataset.resistor-e24.name"), localize("dataset.resistor-e24.desc"), resistorsScales.flatMap((e24Scale) => e24Range.map((e24Multiplier) => new Decimal(e24Scale).times(e24Multiplier))), units.OHM, scaleFactors.SI_BASE), - RESISTOR_E48: new DataSet(localize("dataset.resistor-e48.name"), localize("dataset.resistor-e48.desc"), resistorsScales.flatMap((e48Scale) => e48Range.map((e48Multiplier) => new Decimal(e48Scale).times(e48Multiplier))), units.OHM, scaleFactors.SI_BASE), - CAPACITOR_IEC: new DataSet(localize("dataset.capacitor-iec.name"), localize("dataset.capacitor-iec.desc"), capacitorScales.flatMap((cScale) => e24Range.map((eMultiplier) => new Decimal(cScale).times(eMultiplier))), units.FARAD, scaleFactors.SI_BASE), -}; - -/*! - * Formula Wizard v0.0.2 - * [Short desc here] - * https://github.com/aziascreations/Web-NibblePoker - * Copyright (c) 2023 Herwin Bozet - * Unlicense Licence - */ -class ContextType { - constructor(name, description) { - this.name = name; - this.description = description; - } -} -const contextTypes = { - DISABLED: new ContextType(localize("context.type.disabled.name"), localize("context.type.disabled.desc")), - CONSTANT: new ContextType(localize("context.type.constant.name"), localize("context.type.constant.desc")), - CONTINUOUS: new ContextType(localize("context.type.continuous.name"), localize("context.type.continuous.desc")), - VALUE_RANGE: new ContextType(localize("context.type.valueRange.name"), localize("context.type.valueRange.desc")), - DATASET_RANG: new ContextType(localize("context.type.dataSetRange.name"), localize("context.type.dataSetRange.desc")), -}; -const idContextComponentPrefix = "fw-context-component-"; -const idContextComponentTypes = idContextComponentPrefix + "type"; -const idContextComponentSets = idContextComponentPrefix + "set"; -const idContextComponentUnit = idContextComponentPrefix + "unit"; -const idContextComponentScale = idContextComponentPrefix + "scale"; -let eTemplateContextComponent = null; -let eContextStatusMessage = null; -let eContextAddButton = null; -let isWorkbenchContextSetup = false; -function setupWorkbenchContext() { - if (!isWorkbenchContextSetup) { - console.debug("Preparing UI for workbench context components..."); - eTemplateContextComponent = document.getElementById("template-context-component"); - if (eTemplateContextComponent === null) { - alert(localize("error.ui.context.noTemplate")); - throw Error(localize("error.ui.context.noTemplate")); - } - eTemplateContextComponent = eTemplateContextComponent.cloneNode(true).content; - document.getElementById("template-context-component").remove(); - const eContextTypes = eTemplateContextComponent.getElementById(idContextComponentTypes); - const eContextSets = eTemplateContextComponent.getElementById(idContextComponentSets); - const eContextUnits = eTemplateContextComponent.getElementById(idContextComponentUnit); - const eContextScales = eTemplateContextComponent.getElementById(idContextComponentScale); - if ([eContextTypes, eContextSets, eContextUnits, eContextScales].some((item) => item === null)) { - alert(localize("error.ui.context.noSets")); - throw Error(localize("error.ui.context.noSets")); - } - Object.keys(contextTypes).forEach(value => { - const eNewContextTypesOption = document.createElement("option"); - eNewContextTypesOption.setAttribute("value", value); - eNewContextTypesOption.innerText = contextTypes[value].name; - eContextTypes.appendChild(eNewContextTypesOption); - }); - Object.keys(sets).forEach(value => { - const eNewContextSetsOption = document.createElement("option"); - eNewContextSetsOption.setAttribute("value", value); - eNewContextSetsOption.innerText = sets[value].name; - eContextSets.appendChild(eNewContextSetsOption); - }); - Object.keys(units).forEach(unitKey => { - const eNewContextUnitsOption = document.createElement("option"); - eNewContextUnitsOption.setAttribute("value", unitKey); - eNewContextUnitsOption.innerText = units[unitKey].name; - eContextUnits.appendChild(eNewContextUnitsOption); - }); - Object.keys(scaleFactors).forEach(scaleKey => { - const eNewContextScalesOption = document.createElement("option"); - eNewContextScalesOption.setAttribute("value", scaleKey); - eNewContextScalesOption.innerText = scaleFactors[scaleKey].prefix; - eContextScales.appendChild(eNewContextScalesOption); - }); - eContextStatusMessage = document.getElementById("fw-text-context-middle"); - if (eContextStatusMessage === null) { - alert(localize("error.ui.context.noStatus")); - throw Error(localize("error.ui.context.noStatus")); - } - eContextAddButton = document.querySelector("button#fw-button-add-context"); - if (eContextAddButton === null) { - alert(localize("error.ui.context.missingButton")); - throw Error(localize("error.ui.context.missingButton")); - } - eContextAddButton.onclick = function () { - const eNewContextComponent = eTemplateContextComponent.cloneNode(true).firstElementChild; - if (eNewContextComponent === null) { - alert(localize("error.ui.context.component.cannotGetElement")); - throw Error(localize("error.ui.context.component.cannotGetElement")); - } - }; - isWorkbenchContextSetup = true; - } -} - -/*! - * Formula Wizard v0.0.2 - * [Short desc here] - * https://github.com/aziascreations/Web-NibblePoker - * Copyright (c) 2023 Herwin Bozet - * Unlicense Licence - */ -const version = [0, 0, 2]; -console.log("Initializing 'Formula Wizard v" + version.join(".") + "'..."); -new Date().getMilliseconds(); -Decimal.set({ precision: 25, rounding: 8 }); -initUnits(); -initFormulas(); -initCatalog(); -setupWorkbenchContext(); -console.log(localize("joe.mama")); -console.log(units); -console.log(formulas); -//# sourceMappingURL=formula-wizard.js.map diff --git a/tools/items/formula-wizard/src/formula-wizard.min.js b/tools/items/formula-wizard/src/formula-wizard.min.js deleted file mode 100644 index 7428737..0000000 --- a/tools/items/formula-wizard/src/formula-wizard.min.js +++ /dev/null @@ -1,31 +0,0 @@ -"use strict"; -/*! - * decimal.js v10.4.3 - * An arbitrary-precision Decimal type for JavaScript. - * https://github.com/MikeMcl/decimal.js - * Copyright (c) 2022 Michael Mclaughlin - * MIT Licence - */var e,t,n=9e15,i=1e9,r="0123456789abcdef",s="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",o="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",u={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-n,maxE:n,crypto:!1},a=!0,c="[DecimalError] ",l=c+"Invalid argument: ",h=c+"Precision limit exceeded",f=c+"crypto unavailable",m="[object Decimal]",d=Math.floor,p=Math.pow,g=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,w=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,v=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,E=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,N=1e7,y=7,x=s.length-1,b=o.length-1,S={toStringTag:m};function I(e){var t,n,i,r=e.length-1,s="",o=e[0];if(r>0){for(s+=o,t=1;tn)throw Error(l+e)}function O(e,t,n,i){var r,s,o,u;for(s=e[0];s>=10;s/=10)--t;return--t<0?(t+=y,r=0):(r=Math.ceil((t+1)/y),t%=y),s=p(10,y-t),u=e[r]%s|0,null==i?t<3?(0==t?u=u/100|0:1==t&&(u=u/10|0),o=n<4&&99999==u||n>3&&49999==u||5e4==u||0==u):o=(n<4&&u+1==s||n>3&&u+1==s/2)&&(e[r+1]/s/100|0)==p(10,t-2)-1||(u==s/2||0==u)&&0==(e[r+1]/s/100|0):t<4?(0==t?u=u/1e3|0:1==t?u=u/100|0:2==t&&(u=u/10|0),o=(i||n<4)&&9999==u||!i&&n>3&&4999==u):o=((i||n<4)&&u+1==s||!i&&n>3&&u+1==s/2)&&(e[r+1]/s/1e3|0)==p(10,t-3)-1,o}function A(e,t,n){for(var i,s,o=[0],u=0,a=e.length;un-1&&(void 0===o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/n|0,o[i]%=n)}return o.reverse()}S.absoluteValue=S.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),R(e)},S.ceil=function(){return R(new this.constructor(this),this.e+1,2)},S.clampedTo=S.clamp=function(e,t){var n=this,i=n.constructor;if(e=new i(e),t=new i(t),!e.s||!t.s)return new i(NaN);if(e.gt(t))throw Error(l+t);return n.cmp(e)<0?e:n.cmp(t)>0?t:new i(n)},S.comparedTo=S.cmp=function(e){var t,n,i,r,s=this,o=s.d,u=(e=new s.constructor(e)).d,a=s.s,c=e.s;if(!o||!u)return a&&c?a!==c?a:o===u?0:!o^a<0?1:-1:NaN;if(!o[0]||!u[0])return o[0]?a:u[0]?-c:0;if(a!==c)return a;if(s.e!==e.e)return s.e>e.e^a<0?1:-1;for(t=0,n=(i=o.length)<(r=u.length)?i:r;tu[t]^a<0?1:-1;return i===r?0:i>r^a<0?1:-1},S.cosine=S.cos=function(){var e,n,i=this,r=i.constructor;return i.d?i.d[0]?(e=r.precision,n=r.rounding,r.precision=e+Math.max(i.e,i.sd())+y,r.rounding=1,i=function(e,t){var n,i,r;if(t.isZero())return t;(i=t.d.length)<32?r=(1/G(4,n=Math.ceil(i/3))).toString():(n=16,r="2.3283064365386962890625e-10"),e.precision+=n,t=j(e,1,t.times(r),new e(1));for(var s=n;s--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=n,t}(r,W(r,i)),r.precision=e,r.rounding=n,R(2==t||3==t?i.neg():i,e,n,!0)):new r(1):new r(NaN)},S.cubeRoot=S.cbrt=function(){var e,t,n,i,r,s,o,u,c,l,h=this,f=h.constructor;if(!h.isFinite()||h.isZero())return new f(h);for(a=!1,(s=h.s*p(h.s*h,1/3))&&Math.abs(s)!=1/0?i=new f(s.toString()):(n=I(h.d),(s=((e=h.e)-n.length+1)%3)&&(n+=1==s||-2==s?"0":"00"),s=p(n,1/3),e=d((e+1)/3)-(e%3==(e<0?-1:2)),(i=new f(n=s==1/0?"5e"+e:(n=s.toExponential()).slice(0,n.indexOf("e")+1)+e)).s=h.s),o=(e=f.precision)+3;;)if(l=(c=(u=i).times(u).times(u)).plus(h),i=F(l.plus(h).times(u),l.plus(c),o+2,1),I(u.d).slice(0,o)===(n=I(i.d)).slice(0,o)){if("9999"!=(n=n.slice(o-3,o+1))&&(r||"4999"!=n)){+n&&(+n.slice(1)||"5"!=n.charAt(0))||(R(i,e+1,1),t=!i.times(i).times(i).eq(h));break}if(!r&&(R(u,e+1,0),u.times(u).times(u).eq(h))){i=u;break}o+=4,r=1}return a=!0,R(i,e,f.rounding,t)},S.decimalPlaces=S.dp=function(){var e,t=this.d,n=NaN;if(t){if(n=((e=t.length-1)-d(this.e/y))*y,e=t[e])for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},S.dividedBy=S.div=function(e){return F(this,new this.constructor(e))},S.dividedToIntegerBy=S.divToInt=function(e){var t=this.constructor;return R(F(this,new t(e),0,1,1),t.precision,t.rounding)},S.equals=S.eq=function(e){return 0===this.cmp(e)},S.floor=function(){return R(new this.constructor(this),this.e+1,3)},S.greaterThan=S.gt=function(e){return this.cmp(e)>0},S.greaterThanOrEqualTo=S.gte=function(e){var t=this.cmp(e);return 1==t||0===t},S.hyperbolicCosine=S.cosh=function(){var e,t,n,i,r,s=this,o=s.constructor,u=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return u;n=o.precision,i=o.rounding,o.precision=n+Math.max(s.e,s.sd())+4,o.rounding=1,(r=s.d.length)<32?t=(1/G(4,e=Math.ceil(r/3))).toString():(e=16,t="2.3283064365386962890625e-10"),s=j(o,1,s.times(t),new o(1),!0);for(var a,c=e,l=new o(8);c--;)a=s.times(s),s=u.minus(a.times(l.minus(a.times(l))));return R(s,o.precision=n,o.rounding=i,!0)},S.hyperbolicSine=S.sinh=function(){var e,t,n,i,r=this,s=r.constructor;if(!r.isFinite()||r.isZero())return new s(r);if(t=s.precision,n=s.rounding,s.precision=t+Math.max(r.e,r.sd())+4,s.rounding=1,(i=r.d.length)<3)r=j(s,2,r,r,!0);else{e=(e=1.4*Math.sqrt(i))>16?16:0|e,r=j(s,2,r=r.times(1/G(5,e)),r,!0);for(var o,u=new s(5),a=new s(16),c=new s(20);e--;)o=r.times(r),r=r.times(u.plus(o.times(a.times(o).plus(c))))}return s.precision=t,s.rounding=n,R(r,t,n,!0)},S.hyperbolicTangent=S.tanh=function(){var e,t,n=this,i=n.constructor;return n.isFinite()?n.isZero()?new i(n):(e=i.precision,t=i.rounding,i.precision=e+7,i.rounding=1,F(n.sinh(),n.cosh(),i.precision=e,i.rounding=t)):new i(n.s)},S.inverseCosine=S.acos=function(){var e,t=this,n=t.constructor,i=t.abs().cmp(1),r=n.precision,s=n.rounding;return-1!==i?0===i?t.isNeg()?V(n,r,s):new n(0):new n(NaN):t.isZero()?V(n,r+4,s).times(.5):(n.precision=r+6,n.rounding=1,t=t.asin(),e=V(n,r+4,s).times(.5),n.precision=r,n.rounding=s,e.minus(t))},S.inverseHyperbolicCosine=S.acosh=function(){var e,t,n=this,i=n.constructor;return n.lte(1)?new i(n.eq(1)?0:NaN):n.isFinite()?(e=i.precision,t=i.rounding,i.precision=e+Math.max(Math.abs(n.e),n.sd())+4,i.rounding=1,a=!1,n=n.times(n).minus(1).sqrt().plus(n),a=!0,i.precision=e,i.rounding=t,n.ln()):new i(n)},S.inverseHyperbolicSine=S.asinh=function(){var e,t,n=this,i=n.constructor;return!n.isFinite()||n.isZero()?new i(n):(e=i.precision,t=i.rounding,i.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,i.rounding=1,a=!1,n=n.times(n).plus(1).sqrt().plus(n),a=!0,i.precision=e,i.rounding=t,n.ln())},S.inverseHyperbolicTangent=S.atanh=function(){var e,t,n,i,r=this,s=r.constructor;return r.isFinite()?r.e>=0?new s(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(e=s.precision,t=s.rounding,i=r.sd(),Math.max(i,e)<2*-r.e-1?R(new s(r),e,t,!0):(s.precision=n=i-r.e,r=F(r.plus(1),new s(1).minus(r),n+e,1),s.precision=e+4,s.rounding=1,r=r.ln(),s.precision=e,s.rounding=t,r.times(.5))):new s(NaN)},S.inverseSine=S.asin=function(){var e,t,n,i,r=this,s=r.constructor;return r.isZero()?new s(r):(t=r.abs().cmp(1),n=s.precision,i=s.rounding,-1!==t?0===t?((e=V(s,n+4,i).times(.5)).s=r.s,e):new s(NaN):(s.precision=n+6,s.rounding=1,r=r.div(new s(1).minus(r.times(r)).sqrt().plus(1)).atan(),s.precision=n,s.rounding=i,r.times(2)))},S.inverseTangent=S.atan=function(){var e,t,n,i,r,s,o,u,c,l=this,h=l.constructor,f=h.precision,m=h.rounding;if(l.isFinite()){if(l.isZero())return new h(l);if(l.abs().eq(1)&&f+4<=b)return(o=V(h,f+4,m).times(.25)).s=l.s,o}else{if(!l.s)return new h(NaN);if(f+4<=b)return(o=V(h,f+4,m).times(.5)).s=l.s,o}for(h.precision=u=f+10,h.rounding=1,e=n=Math.min(28,u/y+2|0);e;--e)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(a=!1,t=Math.ceil(u/y),i=1,c=l.times(l),o=new h(l),r=l;-1!==e;)if(r=r.times(c),s=o.minus(r.div(i+=2)),r=r.times(c),void 0!==(o=s.plus(r.div(i+=2))).d[t])for(e=t;o.d[e]===s.d[e]&&e--;);return n&&(o=o.times(2<this.d.length-2},S.isNaN=function(){return!this.s},S.isNegative=S.isNeg=function(){return this.s<0},S.isPositive=S.isPos=function(){return this.s>0},S.isZero=function(){return!!this.d&&0===this.d[0]},S.lessThan=S.lt=function(e){return this.cmp(e)<0},S.lessThanOrEqualTo=S.lte=function(e){return this.cmp(e)<1},S.logarithm=S.log=function(e){var t,n,i,r,s,o,u,c,l=this,h=l.constructor,f=h.precision,m=h.rounding;if(null==e)e=new h(10),t=!0;else{if(n=(e=new h(e)).d,e.s<0||!n||!n[0]||e.eq(1))return new h(NaN);t=e.eq(10)}if(n=l.d,l.s<0||!n||!n[0]||l.eq(1))return new h(n&&!n[0]?-1/0:1!=l.s?NaN:n?0:1/0);if(t)if(n.length>1)s=!0;else{for(r=n[0];r%10==0;)r/=10;s=1!==r}if(a=!1,o=H(l,u=f+5),i=t?C(h,u+10):H(e,u),O((c=F(o,i,u,1)).d,r=f,m))do{if(o=H(l,u+=10),i=t?C(h,u+10):H(e,u),c=F(o,i,u,1),!s){+I(c.d).slice(r+1,r+15)+1==1e14&&(c=R(c,f+1,0));break}}while(O(c.d,r+=10,m));return a=!0,R(c,f,m)},S.minus=S.sub=function(e){var t,n,i,r,s,o,u,c,l,h,f,m,p=this,g=p.constructor;if(e=new g(e),!p.d||!e.d)return p.s&&e.s?p.d?e.s=-e.s:e=new g(e.d||p.s!==e.s?p:NaN):e=new g(NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(l=p.d,m=e.d,u=g.precision,c=g.rounding,!l[0]||!m[0]){if(m[0])e.s=-e.s;else{if(!l[0])return new g(3===c?-0:0);e=new g(p)}return a?R(e,u,c):e}if(n=d(e.e/y),h=d(p.e/y),l=l.slice(),s=h-n){for((f=s<0)?(t=l,s=-s,o=m.length):(t=m,n=h,o=l.length),s>(i=Math.max(Math.ceil(u/y),o)+2)&&(s=i,t.length=1),t.reverse(),i=s;i--;)t.push(0);t.reverse()}else{for((f=(i=l.length)<(o=m.length))&&(o=i),i=0;i0;--i)l[o++]=0;for(i=m.length;i>s;){if(l[--i](o=(s=Math.ceil(u/y))>o?s+1:o+1)&&(r=o,n.length=1),n.reverse();r--;)n.push(0);n.reverse()}for((o=l.length)-(r=h.length)<0&&(r=o,n=h,h=l,l=n),t=0;r;)t=(l[--r]=l[r]+h[r]+t)/N|0,l[r]%=N;for(t&&(l.unshift(t),++i),o=l.length;0==l[--o];)l.pop();return e.d=l,e.e=_(l,i),a?R(e,u,c):e},S.precision=S.sd=function(e){var t,n=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(l+e);return n.d?(t=D(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},S.round=function(){var e=this,t=e.constructor;return R(new t(e),e.e+1,t.rounding)},S.sine=S.sin=function(){var e,n,i=this,r=i.constructor;return i.isFinite()?i.isZero()?new r(i):(e=r.precision,n=r.rounding,r.precision=e+Math.max(i.e,i.sd())+y,r.rounding=1,i=function(e,t){var n,i=t.d.length;if(i<3)return t.isZero()?t:j(e,2,t,t);n=(n=1.4*Math.sqrt(i))>16?16:0|n,t=j(e,2,t=t.times(1/G(5,n)),t);for(var r,s=new e(5),o=new e(16),u=new e(20);n--;)r=t.times(t),t=t.times(s.plus(r.times(o.times(r).minus(u))));return t}(r,W(r,i)),r.precision=e,r.rounding=n,R(t>2?i.neg():i,e,n,!0)):new r(NaN)},S.squareRoot=S.sqrt=function(){var e,t,n,i,r,s,o=this,u=o.d,c=o.e,l=o.s,h=o.constructor;if(1!==l||!u||!u[0])return new h(!l||l<0&&(!u||u[0])?NaN:u?o:1/0);for(a=!1,0==(l=Math.sqrt(+o))||l==1/0?(((t=I(u)).length+c)%2==0&&(t+="0"),l=Math.sqrt(t),c=d((c+1)/2)-(c<0||c%2),i=new h(t=l==1/0?"5e"+c:(t=l.toExponential()).slice(0,t.indexOf("e")+1)+c)):i=new h(l.toString()),n=(c=h.precision)+3;;)if(i=(s=i).plus(F(o,s,n+2,1)).times(.5),I(s.d).slice(0,n)===(t=I(i.d)).slice(0,n)){if("9999"!=(t=t.slice(n-3,n+1))&&(r||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(R(i,c+1,1),e=!i.times(i).eq(o));break}if(!r&&(R(s,c+1,0),s.times(s).eq(o))){i=s;break}n+=4,r=1}return a=!0,R(i,c,h.rounding,e)},S.tangent=S.tan=function(){var e,n,i=this,r=i.constructor;return i.isFinite()?i.isZero()?new r(i):(e=r.precision,n=r.rounding,r.precision=e+10,r.rounding=1,(i=i.sin()).s=1,i=F(i,new r(1).minus(i.times(i)).sqrt(),e+10,0),r.precision=e,r.rounding=n,R(2==t||4==t?i.neg():i,e,n,!0)):new r(NaN)},S.times=S.mul=function(e){var t,n,i,r,s,o,u,c,l,h=this,f=h.constructor,m=h.d,p=(e=new f(e)).d;if(e.s*=h.s,!(m&&m[0]&&p&&p[0]))return new f(!e.s||m&&!m[0]&&!p||p&&!p[0]&&!m?NaN:m&&p?0*e.s:e.s/0);for(n=d(h.e/y)+d(e.e/y),(c=m.length)<(l=p.length)&&(s=m,m=p,p=s,o=c,c=l,l=o),s=[],i=o=c+l;i--;)s.push(0);for(i=l;--i>=0;){for(t=0,r=c+i;r>i;)u=s[r]+p[i]*m[r-i-1]+t,s[r--]=u%N|0,t=u/N|0;s[r]=(s[r]+t)%N|0}for(;!s[--o];)s.pop();return t?++n:s.shift(),e.d=s,e.e=_(s,n),a?R(e,f.precision,f.rounding):e},S.toBinary=function(e,t){return $(this,2,e,t)},S.toDecimalPlaces=S.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),void 0===e?n:(M(e,0,i),void 0===t?t=r.rounding:M(t,0,8),R(n,e+n.e+1,t))},S.toExponential=function(e,t){var n,r=this,s=r.constructor;return void 0===e?n=T(r,!0):(M(e,0,i),void 0===t?t=s.rounding:M(t,0,8),n=T(r=R(new s(r),e+1,t),!0,e+1)),r.isNeg()&&!r.isZero()?"-"+n:n},S.toFixed=function(e,t){var n,r,s=this,o=s.constructor;return void 0===e?n=T(s):(M(e,0,i),void 0===t?t=o.rounding:M(t,0,8),n=T(r=R(new o(s),e+s.e+1,t),!1,e+r.e+1)),s.isNeg()&&!s.isZero()?"-"+n:n},S.toFraction=function(e){var t,n,i,r,s,o,u,c,h,f,m,d,g=this,w=g.d,v=g.constructor;if(!w)return new v(g);if(h=n=new v(1),i=c=new v(0),o=(s=(t=new v(i)).e=D(w)-g.e-1)%y,t.d[0]=p(10,o<0?y+o:o),null==e)e=s>0?t:h;else{if(!(u=new v(e)).isInt()||u.lt(h))throw Error(l+u);e=u.gt(t)?s>0?t:h:u}for(a=!1,u=new v(I(w)),f=v.precision,v.precision=s=w.length*y*2;m=F(u,t,0,1,1),1!=(r=n.plus(m.times(i))).cmp(e);)n=i,i=r,r=h,h=c.plus(m.times(r)),c=r,r=t,t=u.minus(m.times(r)),u=r;return r=F(e.minus(n),i,0,1,1),c=c.plus(r.times(h)),n=n.plus(r.times(i)),c.s=h.s=g.s,d=F(h,i,s,1).minus(g).abs().cmp(F(c,n,s,1).minus(g).abs())<1?[h,i]:[c,n],v.precision=f,a=!0,d},S.toHexadecimal=S.toHex=function(e,t){return $(this,16,e,t)},S.toNearest=function(e,t){var n=this,i=n.constructor;if(n=new i(n),null==e){if(!n.d)return n;e=new i(1),t=i.rounding}else{if(e=new i(e),void 0===t?t=i.rounding:M(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(a=!1,n=F(n,e,0,t,1).times(e),a=!0,R(n)):(e.s=n.s,n=e),n},S.toNumber=function(){return+this},S.toOctal=function(e,t){return $(this,8,e,t)},S.toPower=S.pow=function(e){var t,n,i,r,s,o,u=this,c=u.constructor,l=+(e=new c(e));if(!(u.d&&e.d&&u.d[0]&&e.d[0]))return new c(p(+u,l));if((u=new c(u)).eq(1))return u;if(i=c.precision,s=c.rounding,e.eq(1))return R(u,i,s);if((t=d(e.e/y))>=e.d.length-1&&(n=l<0?-l:l)<=9007199254740991)return r=L(c,u,n,i),e.s<0?new c(1).div(r):R(r,i,s);if((o=u.s)<0){if(tc.maxE+1||t0?o/0:0):(a=!1,c.rounding=u.s=1,n=Math.min(12,(t+"").length),(r=P(e.times(H(u,i+n)),i)).d&&O((r=R(r,i+5,1)).d,i,s)&&(t=i+10,+I((r=R(P(e.times(H(u,t+n)),t),t+5,1)).d).slice(i+1,i+15)+1==1e14&&(r=R(r,i+1,0))),r.s=o,a=!0,c.rounding=s,R(r,i,s))},S.toPrecision=function(e,t){var n,r=this,s=r.constructor;return void 0===e?n=T(r,r.e<=s.toExpNeg||r.e>=s.toExpPos):(M(e,1,i),void 0===t?t=s.rounding:M(t,0,8),n=T(r=R(new s(r),e,t),e<=r.e||r.e<=s.toExpNeg,e)),r.isNeg()&&!r.isZero()?"-"+n:n},S.toSignificantDigits=S.toSD=function(e,t){var n=this.constructor;return void 0===e?(e=n.precision,t=n.rounding):(M(e,1,i),void 0===t?t=n.rounding:M(t,0,8)),R(new n(this),e,t)},S.toString=function(){var e=this,t=e.constructor,n=T(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n},S.truncated=S.trunc=function(){return R(new this.constructor(this),this.e+1,1)},S.valueOf=S.toJSON=function(){var e=this,t=e.constructor,n=T(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};var F=function(){function t(e,t,n){var i,r=0,s=e.length;for(e=e.slice();s--;)i=e[s]*t+r,e[s]=i%n|0,r=i/n|0;return r&&e.unshift(r),e}function n(e,t,n,i){var r,s;if(n!=i)s=n>i?1:-1;else for(r=s=0;rt[r]?1:-1;break}return s}function i(e,t,n,i){for(var r=0;n--;)e[n]-=r,r=e[n]1;)e.shift()}return function(r,s,o,u,a,c){var l,h,f,m,p,g,w,v,E,x,b,S,I,M,O,A,F,T,_,C,V=r.constructor,D=r.s==s.s?1:-1,q=r.d,L=s.d;if(!(q&&q[0]&&L&&L[0]))return new V(r.s&&s.s&&(q?!L||q[0]!=L[0]:L)?q&&0==q[0]||!L?0*D:D/0:NaN);for(c?(p=1,h=r.e-s.e):(c=N,p=y,h=d(r.e/p)-d(s.e/p)),_=L.length,F=q.length,x=(E=new V(D)).d=[],f=0;L[f]==(q[f]||0);f++);if(L[f]>(q[f]||0)&&h--,null==o?(M=o=V.precision,u=V.rounding):M=a?o+(r.e-s.e)+1:o,M<0)x.push(1),g=!0;else{if(M=M/p+2|0,f=0,1==_){for(m=0,L=L[0],M++;(f1&&(L=t(L,m,c),q=t(q,m,c),_=L.length,F=q.length),A=_,S=(b=q.slice(0,_)).length;S<_;)b[S++]=0;(C=L.slice()).unshift(0),T=L[0],L[1]>=c/2&&++T;do{m=0,(l=n(L,b,_,S))<0?(I=b[0],_!=S&&(I=I*c+(b[1]||0)),(m=I/T|0)>1?(m>=c&&(m=c-1),1==(l=n(w=t(L,m,c),b,v=w.length,S=b.length))&&(m--,i(w,_=10;m/=10)f++;E.e=f+h*p-1,R(E,a?o+E.e+1:o,u,g)}return E}}();function R(e,t,n,i){var r,s,o,u,c,l,h,f,m,d=e.constructor;e:if(null!=t){if(!(f=e.d))return e;for(r=1,u=f[0];u>=10;u/=10)r++;if((s=t-r)<0)s+=y,o=t,c=(h=f[m=0])/p(10,r-o-1)%10|0;else if((m=Math.ceil((s+1)/y))>=(u=f.length)){if(!i)break e;for(;u++<=m;)f.push(0);h=c=0,r=1,o=(s%=y)-y+1}else{for(h=u=f[m],r=1;u>=10;u/=10)r++;c=(o=(s%=y)-y+r)<0?0:h/p(10,r-o-1)%10|0}if(i=i||t<0||void 0!==f[m+1]||(o<0?h:h%p(10,r-o-1)),l=n<4?(c||i)&&(0==n||n==(e.s<0?3:2)):c>5||5==c&&(4==n||i||6==n&&(s>0?o>0?h/p(10,r-o):0:f[m-1])%10&1||n==(e.s<0?8:7)),t<1||!f[0])return f.length=0,l?(t-=e.e+1,f[0]=p(10,(y-t%y)%y),e.e=-t||0):f[0]=e.e=0,e;if(0==s?(f.length=m,u=1,m--):(f.length=m+1,u=p(10,y-s),f[m]=o>0?(h/p(10,r-o)%p(10,o)|0)*u:0),l)for(;;){if(0==m){for(s=1,o=f[0];o>=10;o/=10)s++;for(o=f[0]+=u,u=1;o>=10;o/=10)u++;s!=u&&(e.e++,f[0]==N&&(f[0]=1));break}if(f[m]+=u,f[m]!=N)break;f[m--]=0,u=1}for(s=f.length;0===f[--s];)f.pop()}return a&&(e.e>d.maxE?(e.d=null,e.e=NaN):e.e0?s=s.charAt(0)+"."+s.slice(1)+q(i):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):r<0?(s="0."+q(-r-1)+s,n&&(i=n-o)>0&&(s+=q(i))):r>=o?(s+=q(r+1-o),n&&(i=n-r-1)>0&&(s=s+"."+q(i))):((i=r+1)0&&(r+1===o&&(s+="."),s+=q(i))),s}function _(e,t){var n=e[0];for(t*=y;n>=10;n/=10)t++;return t}function C(e,t,n){if(t>x)throw a=!0,n&&(e.precision=n),Error(h);return R(new e(s),t,1,!0)}function V(e,t,n){if(t>b)throw Error(h);return R(new e(o),t,n,!0)}function D(e){var t=e.length-1,n=t*y+1;if(t=e[t]){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function q(e){for(var t="";e--;)t+="0";return t}function L(e,t,n,i){var r,s=new e(1),o=Math.ceil(i/y+4);for(a=!1;;){if(n%2&&z((s=s.times(t)).d,o)&&(r=!0),0===(n=d(n/2))){n=s.d.length-1,r&&0===s.d[n]&&++s.d[n];break}z((t=t.times(t)).d,o)}return a=!0,s}function B(e){return 1&e.d[e.d.length-1]}function k(e,t,n){for(var i,r=new e(t[0]),s=0;++s17)return new m(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(null==t?(a=!1,c=g):c=t,u=new m(.03125);e.e>-2;)e=e.times(u),f+=5;for(c+=i=Math.log(p(2,f))/Math.LN10*2+5|0,n=s=o=new m(1),m.precision=c;;){if(s=R(s.times(e),c,1),n=n.times(++h),I((u=o.plus(F(s,n,c,1))).d).slice(0,c)===I(o.d).slice(0,c)){for(r=f;r--;)o=R(o.times(o),c,1);if(null!=t)return m.precision=g,o;if(!(l<3&&O(o.d,c-i,d,l)))return R(o,m.precision=g,d,a=!0);m.precision=c+=10,n=s=u=new m(1),h=0,l++}o=u}}function H(e,t){var n,i,r,s,o,u,c,l,h,f,m,d=1,p=e,g=p.d,w=p.constructor,v=w.rounding,E=w.precision;if(p.s<0||!g||!g[0]||!p.e&&1==g[0]&&1==g.length)return new w(g&&!g[0]?-1/0:1!=p.s?NaN:g?0:p);if(null==t?(a=!1,h=E):h=t,w.precision=h+=10,i=(n=I(g)).charAt(0),!(Math.abs(s=p.e)<15e14))return l=C(w,h+2,E).times(s+""),p=H(new w(i+"."+n.slice(1)),h-10).plus(l),w.precision=E,null==t?R(p,E,v,a=!0):p;for(;i<7&&1!=i||1==i&&n.charAt(1)>3;)i=(n=I((p=p.times(e)).d)).charAt(0),d++;for(s=p.e,i>1?(p=new w("0."+n),s++):p=new w(i+"."+n.slice(1)),f=p,c=o=p=F(p.minus(1),p.plus(1),h,1),m=R(p.times(p),h,1),r=3;;){if(o=R(o.times(m),h,1),I((l=c.plus(F(o,new w(r),h,1))).d).slice(0,h)===I(c.d).slice(0,h)){if(c=c.times(2),0!==s&&(c=c.plus(C(w,h+2,E).times(s+""))),c=F(c,new w(d),h,1),null!=t)return w.precision=E,c;if(!O(c.d,h-10,v,u))return R(c,w.precision=E,v,a=!0);w.precision=h+=10,l=o=p=F(f.minus(1),f.plus(1),h,1),m=R(p.times(p),h,1),r=u=1}c=l,r+=2}}function U(e){return String(e.s*e.s/0)}function Z(e,t){var n,i,r;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(i=t.search(/e/i))>0?(n<0&&(n=i),n+=+t.slice(i+1),t=t.substring(0,i)):n<0&&(n=t.length),i=0;48===t.charCodeAt(i);i++);for(r=t.length;48===t.charCodeAt(r-1);--r);if(t=t.slice(i,r)){if(r-=i,e.e=n=n-i-1,e.d=[],i=(n+1)%y,n<0&&(i+=y),ie.constructor.maxE?(e.d=null,e.e=NaN):e.e=0&&(m=m.replace(".",""),(p=new g(1)).e=m.length-c,p.d=A(T(p),10,u),p.e=p.d.length),a=h=(d=A(m,10,u)).length;0==d[--h];)d.pop();if(d[0]){if(c<0?a--:((t=new g(t)).d=d,t.e=a,d=(t=F(t,p,s,o,0,u)).d,a=t.e,f=e),c=d[s],l=u/2,f=f||void 0!==d[s+1],f=o<4?(void 0!==c||f)&&(0===o||o===(t.s<0?3:2)):c>l||c===l&&(4===o||f||6===o&&1&d[s-1]||o===(t.s<0?8:7)),d.length=s,f)for(;++d[--s]>u-1;)d[s]=0,s||(++a,d.unshift(1));for(h=d.length;!d[h-1];--h);for(c=0,m="";c1)if(16==n||8==n){for(c=16==n?4:3,--h;h%c;h++)m+="0";for(h=(d=A(m,u,n)).length;!d[h-1];--h);for(c=1,m="1.";ch)for(a-=h;a--;)m+="0";else at)return e.length=t,!0}function K(e){return new this(e).abs()}function Y(e){return new this(e).acos()}function J(e){return new this(e).acosh()}function Q(e,t){return new this(e).plus(t)}function X(e){return new this(e).asin()}function ee(e){return new this(e).asinh()}function te(e){return new this(e).atan()}function ne(e){return new this(e).atanh()}function ie(e,t){e=new this(e),t=new this(t);var n,i=this.precision,r=this.rounding,s=i+4;return e.s&&t.s?e.d||t.d?!t.d||e.isZero()?(n=t.s<0?V(this,i,r):new this(0)).s=e.s:!e.d||t.isZero()?(n=V(this,s,1).times(.5)).s=e.s:t.s<0?(this.precision=s,this.rounding=1,n=this.atan(F(e,t,s,1)),t=V(this,s,1),this.precision=i,this.rounding=r,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(F(e,t,s,1)):(n=V(this,s,1).times(t.s>0?.25:.75)).s=e.s:n=new this(NaN),n}function re(e){return new this(e).cbrt()}function se(e){return R(e=new this(e),e.e+1,2)}function oe(e,t,n){return new this(e).clamp(t,n)}function ue(e){if(!e||"object"!=typeof e)throw Error(c+"Object expected");var t,r,s,o=!0===e.defaults,a=["precision",1,i,"rounding",0,8,"toExpNeg",-n,0,"toExpPos",0,n,"maxE",0,n,"minE",-n,0,"modulo",0,9];for(t=0;t=a[t+1]&&s<=a[t+2]))throw Error(l+r+": "+s);this[r]=s}if(r="crypto",o&&(this[r]=u[r]),void 0!==(s=e[r])){if(!0!==s&&!1!==s&&0!==s&&1!==s)throw Error(l+r+": "+s);if(s){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(f);this[r]=!0}else this[r]=!1}return this}function ae(e){return new this(e).cos()}function ce(e){return new this(e).cosh()}function le(e,t){return new this(e).div(t)}function he(e){return new this(e).exp()}function fe(e){return R(e=new this(e),e.e+1,3)}function me(){var e,t,n=new this(0);for(a=!1,e=0;e=429e7?t[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=s%1e7;else{if(!crypto.randomBytes)throw Error(f);for(t=crypto.randomBytes(r*=4);o=214e7?crypto.randomBytes(4).copy(t,o):(a.push(s%1e7),o+=4);o=r/4}else for(;o=10;s/=10)r++;rs.maxE?(r.e=NaN,r.d=null):e.e=10;n/=10)t++;return void(a?t>s.maxE?(r.e=NaN,r.d=null):t-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),E.test(t))return Z(e,t)}else if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(w.test(t))n=16,t=t.toLowerCase();else if(g.test(t))n=2;else{if(!v.test(t))throw Error(l+t);n=8}for((s=t.search(/p/i))>0?(c=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),o=(s=t.indexOf("."))>=0,i=e.constructor,o&&(s=(u=(t=t.replace(".","")).length)-s,r=L(i,new i(n),s,2*s)),s=f=(h=A(t,n,N)).length-1;0===h[s];--s)h.pop();return s<0?new i(0*e.s):(e.e=_(h,f),e.d=h,a=!1,o&&(e=F(e,r,4*u)),c&&(e=e.times(Math.abs(c)<54?p(2,c):De.pow(2,c))),a=!0,e)}(r,e)}if(s.prototype=S,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=ue,s.clone=e,s.isDecimal=de,s.abs=K,s.acos=Y,s.acosh=J,s.add=Q,s.asin=X,s.asinh=ee,s.atan=te,s.atanh=ne,s.atan2=ie,s.cbrt=re,s.ceil=se,s.clamp=oe,s.cos=ae,s.cosh=ce,s.div=le,s.exp=he,s.floor=fe,s.hypot=me,s.ln=pe,s.log=ge,s.log10=ve,s.log2=we,s.max=Ee,s.min=Ne,s.mod=ye,s.mul=xe,s.pow=be,s.random=Se,s.round=Ie,s.sign=Me,s.sin=Oe,s.sinh=Ae,s.sqrt=Fe,s.sub=Re,s.sum=Te,s.tan=_e,s.tanh=Ce,s.trunc=Ve,void 0===t&&(t={}),t&&!0!==t.defaults)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],n=0;ne.symbol,this.formatSymbol=e=>e.symbol,this.scaleFactors=[]}},IMPERIAL_DISTANCE:new class{constructor(){this.formatName=e=>e.symbol,this.formatSymbol=e=>e.symbol,this.scaleFactors=[]}},IMPERIAL_WEIGHT:new class{constructor(){this.formatName=e=>e.symbol,this.formatSymbol=e=>e.symbol,this.scaleFactors=[]}},TIME_SECONDS:new class{constructor(){this.formatName=e=>e.symbol,this.formatSymbol=e=>e.symbol,this.scaleFactors=[]}},NONE:new class{constructor(){this.formatName=e=>e.name,this.formatSymbol=e=>e.symbol,this.scaleFactors=[]}}},He={SI_GIGA:new class{constructor(){this.scale=Pe.SI,this.multiplier=new De("1e9"),this.prefix="giga",this.suffix="",this.symbol="G"}},SI_MEGA:new class{constructor(){this.scale=Pe.SI,this.multiplier=new De("1e6"),this.prefix="mega",this.suffix="",this.symbol="M"}},SI_KILO:new class{constructor(){this.scale=Pe.SI,this.multiplier=new De("1e3"),this.prefix="kilo",this.suffix="",this.symbol="k"}},SI_BASE:new class{constructor(){this.scale=Pe.SI,this.multiplier=new De("1"),this.prefix="",this.suffix="",this.symbol=""}},SI_CENTI:new class{constructor(){this.scale=Pe.SI,this.multiplier=new De("1e-2"),this.prefix="centi",this.suffix="",this.symbol="c"}},SI_MILLI:new class{constructor(){this.scale=Pe.SI,this.multiplier=new De("1e-3"),this.prefix="milli",this.suffix="",this.symbol="m"}},TIME_MILLI:new class{constructor(){this.scale=Pe.TIME_SECONDS,this.multiplier=new De("1e-3"),this.prefix="milli",this.suffix="",this.symbol="m"}},TIME_BASE:new class{constructor(){this.scale=Pe.TIME_SECONDS,this.multiplier=new De("1"),this.prefix="",this.suffix="",this.symbol=""}},TIME_MINUTE:new class{constructor(){this.scale=Pe.TIME_SECONDS,this.multiplier=new De("60"),this.prefix="",this.suffix="",this.symbol=""}},TIME_HOUR:new class{constructor(){this.scale=Pe.TIME_SECONDS,this.multiplier=new De("3600"),this.prefix="",this.suffix="",this.symbol=""}},TIME_DAY:new class{constructor(){this.scale=Pe.TIME_SECONDS,this.multiplier=new De("86400"),this.prefix="",this.suffix="",this.symbol=""}}},Ue={ANY:new ke("any","",Pe.NONE),WATT:new ke("watt","W",Pe.SI),VOLT:new ke("volt","V",Pe.SI),AMPERE:new ke("ampere","A",Pe.SI),OHM:new ke("ohm","Ω",Pe.SI),FARAD:new ke("farad","F",Pe.SI),METER:new ke("meter","m",Pe.SI),INCH:new ke("inch","in",Pe.IMPERIAL_DISTANCE),POUND:new ke("pound","p",Pe.IMPERIAL_WEIGHT)};let Ze=!1;class je{constructor(e){this.contextValueIndex=e}getContextValue(e){if(e.length<=this.contextValueIndex)throw alert(Be("error.formulaContext.tooSmall")),new Error(Be("error.formulaContext.tooSmall"));return e[this.contextValueIndex]}}class Ge{constructor(e,t){this.unit=e,this.scaleFactor=t,this.parentFormula=null,this.valueSource=null}getFormulaValue(e){if(null===this.parentFormula)throw alert(Be("error.formulaValue.noParent")),new Error(Be("error.formulaValue.noParent"));if(null===this.valueSource)throw alert(Be("error.formulaValue.noSource")),new Error(Be("error.formulaValue.noSource"));return this.valueSource instanceof je?this.valueSource.getContextValue(e):function(e,t){return e.dividedBy(t.multiplier)}((t=this.valueSource.getVariantValue(this.parentFormula,e),n=this.valueSource.getOutputValueDefinition().scaleFactor,t.times(n.multiplier)),this.scaleFactor);var t,n}}class We{constructor(e,t,n,i,r){this.values=e,this.variants=t,this.formulaKey=n,this.name=Be("formula."+n+".name"),this.description=Be("formula."+n+".desc"),this.categories=i,this.wikiLink=r,this.values.forEach((e=>{e.parentFormula=this}))}getClone(){const e=[];return this.values.forEach((t=>{e.push(new Ge(t.unit,t.scaleFactor))})),new We(e,this.variants,this.formulaKey,this.categories,this.wikiLink)}}const $e={OHM_LAW:new We([new Ge(Ue.OHM,He.SI_BASE),new Ge(Ue.AMPERE,He.SI_BASE),new Ge(Ue.VOLT,He.SI_BASE)],[new class{constructor(){this.description="V=I*R",this.getVariantValue=(e,t)=>e.values[0].getFormulaValue(t).times(e.values[1].getFormulaValue(t)),this.getInputValuesDefinition=()=>[this.parentFormula.values[0],this.parentFormula.values[1]],this.getOutputValueDefinition=()=>this.parentFormula.values[2],this.getMathMl=e=>""+e.values[2].unit.symbol+"="+e.values[0].unit.symbol+"*"+e.values[1].unit.symbol+"",this.parentFormula=null}},new class{constructor(){this.description="I=V/R",this.getVariantValue=(e,t)=>e.values[2].getFormulaValue(t).dividedBy(e.values[0].getFormulaValue(t)),this.getInputValuesDefinition=()=>[this.parentFormula.values[0],this.parentFormula.values[2]],this.getOutputValueDefinition=()=>this.parentFormula.values[1],this.getMathMl=e=>""+e.values[1].unit.symbol+"="+e.values[2].unit.symbol+""+e.values[0].unit.symbol+"",this.parentFormula=null}},new class{constructor(){this.description="R=V/I",this.getVariantValue=(e,t)=>e.values[2].getFormulaValue(t).dividedBy(e.values[1].getFormulaValue(t)),this.getInputValuesDefinition=()=>[this.parentFormula.values[2],this.parentFormula.values[1]],this.getOutputValueDefinition=()=>this.parentFormula.values[0],this.getMathMl=e=>""+e.values[0].unit.symbol+"="+e.values[2].unit.symbol+""+e.values[1].unit.symbol+"",this.parentFormula=null}}],"ohm_law",["electricity"],new URL("https://wikipedia.org/wiki/Ohm's_law"))};let ze=!1; -/*! - * Formula Wizard v0.0.2 - * [Short desc here] - * https://github.com/aziascreations/Web-NibblePoker - * Copyright (c) 2023 Herwin Bozet - * Unlicense Licence - */ -const Ke="fw-catalog-",Ye=Ke+"category-",Je=Ke+"formula-count",Qe={};let Xe=!1;class et{constructor(e,t,n,i,r){if(this.name=e,this.description=t,this.values=n,this.unit=i,this.scaleFactor=r,i.scale!=r.scale)throw alert(""),Error("")}getDataSet(){return this.values}}const tt=[1,2.2,4.7],nt=[1,1.5,2.2,3.3,4.7,6.8],it=[1,1.2,1.5,1.8,2.2,2.7,3.3,3.9,4.7,5.6,6.8,8.2],rt=[1,1.1,1.2,1.3,1.5,1.6,1.8,2,2.2,2.4,2.7,3,3.3,3.6,3.9,4.3,4.7,5.1,5.6,6.2,6.8,7.5,8.2,9.1],st=[1,1.05,1.1,1.15,1.21,1.27,1.33,1.4,1.47,1.54,1.62,1.69,1.78,1.87,1.96,2.05,2.15,2.26,2.37,2.49,2.61,2.74,2.87,3.01,3.16,3.32,3.48,3.65,3.83,4.02,4.22,4.42,4.64,4.87,5.11,5.36,5.62,5.9,6.19,6.49,6.81,7.15,7.5,7.87,8.25,8.66,9.09,9.53],ot=[1,10,100,1e3,1e4,1e5,1e6,1e7],ut={RESISTOR_E3:new et(Be("dataset.resistor-e3.name"),Be("dataset.resistor-e3.desc"),ot.flatMap((e=>tt.map((t=>new De(e).times(t))))),Ue.OHM,He.SI_BASE),RESISTOR_E6:new et(Be("dataset.resistor-e6.name"),Be("dataset.resistor-e6.desc"),ot.flatMap((e=>nt.map((t=>new De(e).times(t))))),Ue.OHM,He.SI_BASE),RESISTOR_E12:new et(Be("dataset.resistor-e12.name"),Be("dataset.resistor-e12.desc"),ot.flatMap((e=>it.map((t=>new De(e).times(t))))),Ue.OHM,He.SI_BASE),RESISTOR_E24:new et(Be("dataset.resistor-e24.name"),Be("dataset.resistor-e24.desc"),ot.flatMap((e=>rt.map((t=>new De(e).times(t))))),Ue.OHM,He.SI_BASE),RESISTOR_E48:new et(Be("dataset.resistor-e48.name"),Be("dataset.resistor-e48.desc"),ot.flatMap((e=>st.map((t=>new De(e).times(t))))),Ue.OHM,He.SI_BASE),CAPACITOR_IEC:new et(Be("dataset.capacitor-iec.name"),Be("dataset.capacitor-iec.desc"),[1e-11,1e-10,1e-9,1e-8,1e-7,1e-6,1e-5,1e-4,.001,.01,.1].flatMap((e=>rt.map((t=>new De(e).times(t))))),Ue.FARAD,He.SI_BASE)}; -/*! - * Formula Wizard v0.0.2 - * [Short desc here] - * https://github.com/aziascreations/Web-NibblePoker - * Copyright (c) 2023 Herwin Bozet - * Unlicense Licence - */ -class at{constructor(e,t){this.name=e,this.description=t}}const ct={DISABLED:new at(Be("context.type.disabled.name"),Be("context.type.disabled.desc")),CONSTANT:new at(Be("context.type.constant.name"),Be("context.type.constant.desc")),CONTINUOUS:new at(Be("context.type.continuous.name"),Be("context.type.continuous.desc")),VALUE_RANGE:new at(Be("context.type.valueRange.name"),Be("context.type.valueRange.desc")),DATASET_RANG:new at(Be("context.type.dataSetRange.name"),Be("context.type.dataSetRange.desc"))},lt="fw-context-component-",ht=lt+"type",ft=lt+"set",mt=lt+"unit",dt=lt+"scale";let pt=null,gt=null,wt=null,vt=!1;console.log("Initializing 'Formula Wizard v"+[0,0,2].join(".")+"'..."),(new Date).getMilliseconds(),De.set({precision:25,rounding:8}),Ze||(console.debug("Initializing scales & units..."),Object.keys(He).forEach((e=>{const t=He[e];t.scale.scaleFactors.push(t)})),Ze=!0),ze||(console.debug("Initializing formulas..."),Object.keys($e).forEach((e=>{$e[e].variants.forEach((t=>{t.parentFormula=$e[e]}))})),ze=!0),function(){if(!Xe){console.debug("Populating formula catalog..."),document.querySelectorAll("[id]").forEach((e=>{e.id.startsWith(Ye)&&(Qe[e.id.replace(Ye,"")]=e)}));const e=document.getElementById(Je);null!==e&&(e.innerText=Object.keys($e).length.toString());let t=document.getElementById("template-formula-available"),n=document.getElementById("template-formula-available-variant");if(null===t||null===n)throw alert("error.ui.catalog.noTemplate"),Error("error.ui.catalog.noTemplate");Object.keys($e).forEach((e=>{if($e[e].categories.every((function(e){return-1!==Object.keys(Qe).indexOf(e)}))){let i=t.content.cloneNode(!0),r=i.querySelector("p");null!==r&&(r.innerText=$e[e].name);let s=i.querySelector("div.fw-variants");if(null===s)throw alert(""),Error("");s.innerHTML="",$e[e].variants.forEach((t=>{let i=n.content.cloneNode(!0),r=i.querySelector("button");if(null===r)throw alert(""),Error("");r.innerHTML=t.getMathMl($e[e]),r.title=t.description,s.appendChild(i)})),$e[e].categories.forEach((e=>{Object.keys(Qe).includes(e)&&Qe[e].appendChild(i)}))}})),Xe=!0}}(),function(){if(!vt){if(console.debug("Preparing UI for workbench context components..."),pt=document.getElementById("template-context-component"),null===pt)throw alert(Be("error.ui.context.noTemplate")),Error(Be("error.ui.context.noTemplate"));pt=pt.cloneNode(!0).content,document.getElementById("template-context-component").remove();const e=pt.getElementById(ht),t=pt.getElementById(ft),n=pt.getElementById(mt),i=pt.getElementById(dt);if([e,t,n,i].some((e=>null===e)))throw alert(Be("error.ui.context.noSets")),Error(Be("error.ui.context.noSets"));if(Object.keys(ct).forEach((t=>{const n=document.createElement("option");n.setAttribute("value",t),n.innerText=ct[t].name,e.appendChild(n)})),Object.keys(ut).forEach((e=>{const n=document.createElement("option");n.setAttribute("value",e),n.innerText=ut[e].name,t.appendChild(n)})),Object.keys(Ue).forEach((e=>{const t=document.createElement("option");t.setAttribute("value",e),t.innerText=Ue[e].name,n.appendChild(t)})),Object.keys(He).forEach((e=>{const t=document.createElement("option");t.setAttribute("value",e),t.innerText=He[e].prefix,i.appendChild(t)})),gt=document.getElementById("fw-text-context-middle"),null===gt)throw alert(Be("error.ui.context.noStatus")),Error(Be("error.ui.context.noStatus"));if(wt=document.querySelector("button#fw-button-add-context"),null===wt)throw alert(Be("error.ui.context.missingButton")),Error(Be("error.ui.context.missingButton"));wt.onclick=function(){if(null===pt.cloneNode(!0).firstElementChild)throw alert(Be("error.ui.context.component.cannotGetElement")),Error(Be("error.ui.context.component.cannotGetElement"))},vt=!0}} -/*! - * Formula Wizard v0.0.2 - * [Short desc here] - * https://github.com/aziascreations/Web-NibblePoker - * Copyright (c) 2023 Herwin Bozet - * Unlicense Licence - */(),console.log(Be("joe.mama")),console.log(Ue),console.log($e); \ No newline at end of file diff --git a/tools/items/formula-wizard/src/formulas.js b/tools/items/formula-wizard/src/formulas.js deleted file mode 100644 index 35d499a..0000000 --- a/tools/items/formula-wizard/src/formulas.js +++ /dev/null @@ -1,150 +0,0 @@ -import { localize } from "./lang.js"; -import { scaleFactors, units, scaleToBase, scaleFromBase } from "./units.js"; -class FormulaContextHandler { - constructor(contextValueIndex) { - this.contextValueIndex = contextValueIndex; - } - getContextValue(context) { - if (context.length <= this.contextValueIndex) { - alert(localize("error.formulaContext.tooSmall")); - throw new Error(localize("error.formulaContext.tooSmall")); - } - return context[this.contextValueIndex]; - } -} -export class FormulaValue { - constructor(unit, scaleFactor) { - this.unit = unit; - this.scaleFactor = scaleFactor; - this.parentFormula = null; - this.valueSource = null; - } - getFormulaValue(context) { - if (this.parentFormula === null) { - alert(localize("error.formulaValue.noParent")); - throw new Error(localize("error.formulaValue.noParent")); - } - if (this.valueSource === null) { - alert(localize("error.formulaValue.noSource")); - throw new Error(localize("error.formulaValue.noSource")); - } - if (this.valueSource instanceof FormulaContextHandler) { - return this.valueSource.getContextValue(context); - } - return scaleFromBase(scaleToBase(this.valueSource.getVariantValue(this.parentFormula, context), this.valueSource.getOutputValueDefinition().scaleFactor), this.scaleFactor); - } -} -export class Formula { - constructor(values, variants, formulaKey, categories, wikiLink) { - this.values = values; - this.variants = variants; - this.formulaKey = formulaKey; - this.name = localize("formula." + formulaKey + ".name"); - this.description = localize("formula." + formulaKey + ".desc"); - this.categories = categories; - this.wikiLink = wikiLink; - this.values.forEach(value => { - value.parentFormula = this; - }); - } - getClone() { - const clonedFormulaValues = []; - this.values.forEach(originalValue => { - clonedFormulaValues.push(new FormulaValue(originalValue.unit, originalValue.scaleFactor)); - }); - return new Formula(clonedFormulaValues, this.variants, this.formulaKey, this.categories, this.wikiLink); - } -} -export const formulas = { - OHM_LAW: new Formula([ - new FormulaValue(units.OHM, scaleFactors.SI_BASE), - new FormulaValue(units.AMPERE, scaleFactors.SI_BASE), - new FormulaValue(units.VOLT, scaleFactors.SI_BASE), - ], [ - new class { - constructor() { - this.description = "V=I*R"; - this.getVariantValue = (formula, context) => { - return formula.values[0].getFormulaValue(context).times(formula.values[1].getFormulaValue(context)); - }; - this.getInputValuesDefinition = () => { - return [this.parentFormula.values[0], this.parentFormula.values[1]]; - }; - this.getOutputValueDefinition = () => { - return this.parentFormula.values[2]; - }; - this.getMathMl = (formula) => { - return "" + - formula.values[2].unit.symbol + - "=" + - formula.values[0].unit.symbol + - "*" + - formula.values[1].unit.symbol + - ""; - }; - this.parentFormula = null; - } - }, - new class { - constructor() { - this.description = "I=V/R"; - this.getVariantValue = (formula, context) => { - return formula.values[2].getFormulaValue(context).dividedBy(formula.values[0].getFormulaValue(context)); - }; - this.getInputValuesDefinition = () => { - return [this.parentFormula.values[0], this.parentFormula.values[2]]; - }; - this.getOutputValueDefinition = () => { - return this.parentFormula.values[1]; - }; - this.getMathMl = (formula) => { - return "" + - formula.values[1].unit.symbol + - "=" + - formula.values[2].unit.symbol + - "" + - formula.values[0].unit.symbol + - ""; - }; - this.parentFormula = null; - } - }, - new class { - constructor() { - this.description = "R=V/I"; - this.getVariantValue = (formula, context) => { - return formula.values[2].getFormulaValue(context).dividedBy(formula.values[1].getFormulaValue(context)); - }; - this.getInputValuesDefinition = () => { - return [this.parentFormula.values[2], this.parentFormula.values[1]]; - }; - this.getOutputValueDefinition = () => { - return this.parentFormula.values[0]; - }; - this.getMathMl = (formula) => { - return "" + - formula.values[0].unit.symbol + - "=" + - formula.values[2].unit.symbol + - "" + - formula.values[1].unit.symbol + - ""; - }; - this.parentFormula = null; - } - }, - ], "ohm_law", ["electricity"], new URL("https://wikipedia.org/wiki/Ohm's_law")), -}; -let areFormulasInitialized = false; -export function initFormulas() { - if (!areFormulasInitialized) { - console.debug("Initializing formulas..."); - Object.keys(formulas).forEach(formulaKey => { - formulas[formulaKey].variants.forEach(formulaVariant => { - formulaVariant.parentFormula = formulas[formulaKey]; - }); - }); - areFormulasInitialized = true; - } -} -//# sourceMappingURL=formulas.js.map \ No newline at end of file diff --git a/tools/items/formula-wizard/src/formulas.min.js b/tools/items/formula-wizard/src/formulas.min.js deleted file mode 100644 index 1837a3b..0000000 --- a/tools/items/formula-wizard/src/formulas.min.js +++ /dev/null @@ -1 +0,0 @@ -import{localize as t}from"./lang.js";import{scaleFactors as e,units as a,scaleToBase as l,scaleFromBase as u}from"./units.js";class r{constructor(t){this.contextValueIndex=t}getContextValue(e){if(e.length<=this.contextValueIndex)throw alert(t("error.formulaContext.tooSmall")),new Error(t("error.formulaContext.tooSmall"));return e[this.contextValueIndex]}}export class FormulaValue{constructor(t,e){this.unit=t,this.scaleFactor=e,this.parentFormula=null,this.valueSource=null}getFormulaValue(e){if(null===this.parentFormula)throw alert(t("error.formulaValue.noParent")),new Error(t("error.formulaValue.noParent"));if(null===this.valueSource)throw alert(t("error.formulaValue.noSource")),new Error(t("error.formulaValue.noSource"));return this.valueSource instanceof r?this.valueSource.getContextValue(e):u(l(this.valueSource.getVariantValue(this.parentFormula,e),this.valueSource.getOutputValueDefinition().scaleFactor),this.scaleFactor)}}export class Formula{constructor(e,a,l,u,r){this.values=e,this.variants=a,this.formulaKey=l,this.name=t("formula."+l+".name"),this.description=t("formula."+l+".desc"),this.categories=u,this.wikiLink=r,this.values.forEach((t=>{t.parentFormula=this}))}getClone(){const t=[];return this.values.forEach((e=>{t.push(new FormulaValue(e.unit,e.scaleFactor))})),new Formula(t,this.variants,this.formulaKey,this.categories,this.wikiLink)}}export const formulas={OHM_LAW:new Formula([new FormulaValue(a.OHM,e.SI_BASE),new FormulaValue(a.AMPERE,e.SI_BASE),new FormulaValue(a.VOLT,e.SI_BASE)],[new class{constructor(){this.description="V=I*R",this.getVariantValue=(t,e)=>t.values[0].getFormulaValue(e).times(t.values[1].getFormulaValue(e)),this.getInputValuesDefinition=()=>[this.parentFormula.values[0],this.parentFormula.values[1]],this.getOutputValueDefinition=()=>this.parentFormula.values[2],this.getMathMl=t=>""+t.values[2].unit.symbol+"="+t.values[0].unit.symbol+"*"+t.values[1].unit.symbol+"",this.parentFormula=null}},new class{constructor(){this.description="I=V/R",this.getVariantValue=(t,e)=>t.values[2].getFormulaValue(e).dividedBy(t.values[0].getFormulaValue(e)),this.getInputValuesDefinition=()=>[this.parentFormula.values[0],this.parentFormula.values[2]],this.getOutputValueDefinition=()=>this.parentFormula.values[1],this.getMathMl=t=>""+t.values[1].unit.symbol+"="+t.values[2].unit.symbol+""+t.values[0].unit.symbol+"",this.parentFormula=null}},new class{constructor(){this.description="R=V/I",this.getVariantValue=(t,e)=>t.values[2].getFormulaValue(e).dividedBy(t.values[1].getFormulaValue(e)),this.getInputValuesDefinition=()=>[this.parentFormula.values[2],this.parentFormula.values[1]],this.getOutputValueDefinition=()=>this.parentFormula.values[0],this.getMathMl=t=>""+t.values[0].unit.symbol+"="+t.values[2].unit.symbol+""+t.values[1].unit.symbol+"",this.parentFormula=null}}],"ohm_law",["electricity"],new URL("https://wikipedia.org/wiki/Ohm's_law"))};let i=!1;export function initFormulas(){i||(console.debug("Initializing formulas..."),Object.keys(formulas).forEach((t=>{formulas[t].variants.forEach((e=>{e.parentFormula=formulas[t]}))})),i=!0)} \ No newline at end of file diff --git a/tools/items/formula-wizard/src/lang.js b/tools/items/formula-wizard/src/lang.js deleted file mode 100644 index 628ec2b..0000000 --- a/tools/items/formula-wizard/src/lang.js +++ /dev/null @@ -1,57 +0,0 @@ -export const langKey = document.documentElement.lang.match("(en|fr)") ? document.documentElement.lang : "en"; -const langData = { - en: { - "unit.any.name": "Not Important", - "unit.watt.name": "Watt", - "unit.ampere.name": "Ampere", - "unit.ohm.name": "Ohm", - "unit.ohm.desc": "Electrical Resistance", - "unit.volt.name": "Volt", - "unit.farad.name": "Farad", - "error.formulaValue.noParent": "Attempting to get a formula's value whose parent formula isn't set !", - "error.formulaValue.noSource": "Attempting to get a formula's value whose value source is null !", - "error.formulaContext.tooSmall": "The current calculation context is too small !", - "ui.formulaCount": "formulas", - "formula.ohm_law.name": "Ohm's Law", - "dataset.resistor-e3.name": "E3 IEC Resistors", - "dataset.resistor-e3.desc": "???", - "dataset.resistor-e6.name": "E6 IEC Resistors", - "dataset.resistor-e6.desc": "???", - "dataset.resistor-e12.name": "E12 IEC Resistors", - "dataset.resistor-e12.desc": "???", - "dataset.resistor-e24.name": "E24 IEC Resistors", - "dataset.resistor-e24.desc": "???", - "dataset.resistor-e48.name": "E48 IEC Resistors", - "dataset.resistor-e48.desc": "???", - "dataset.capacitor-iec.name": "IEC E24 Capacitors", - "dataset.capacitor-iec.desc": "???", - "context.type.disabled.name": "Disabled", - "context.type.constant.name": "Constant", - "context.type.continuous.name": "Continuous", - "context.type.valueRange.name": "Value Range", - "context.type.dataSetRange.name": "Set-based Range", - "context.type.disabled.desc": "???", - "context.type.constant.desc": "???", - "context.type.continuous.desc": "???", - "context.type.valueRange.desc": "???", - "context.type.dataSetRange.desc": "???", - }, - fr: { - "unit.ampere.name": "Ampère", - "unit.ohm.desc": "Résistance électrique", - "_error.formulaValue.noParent": "", - "_error.formulaValue.noSource": "", - "ui.formulaCount": "formules", - "formula.ohm_law.name": "Loi d'Ohm", - "context.type.disabled.name": "Désactivé", - "context.type.constant.name": "Constante", - "context.type.continuous.name": "Continue", - "context.type.valueRange.name": "Valeurs distinctes", - "context.type.dataSetRange.name": "Set de valeurs", - } -}; -export function localize(stringKey) { - let _langData = langKey in langData ? langData[langKey] : langData.en; - return stringKey in _langData ? _langData[stringKey] : (stringKey in langData["en"] ? langData["en"][stringKey] : stringKey); -} -//# sourceMappingURL=lang.js.map \ No newline at end of file diff --git a/tools/items/formula-wizard/src/lang.min.js b/tools/items/formula-wizard/src/lang.min.js deleted file mode 100644 index 07dda17..0000000 --- a/tools/items/formula-wizard/src/lang.min.js +++ /dev/null @@ -1 +0,0 @@ -export const langKey=document.documentElement.lang.match("(en|fr)")?document.documentElement.lang:"en";const e={en:{"unit.any.name":"Not Important","unit.watt.name":"Watt","unit.ampere.name":"Ampere","unit.ohm.name":"Ohm","unit.ohm.desc":"Electrical Resistance","unit.volt.name":"Volt","unit.farad.name":"Farad","error.formulaValue.noParent":"Attempting to get a formula's value whose parent formula isn't set !","error.formulaValue.noSource":"Attempting to get a formula's value whose value source is null !","error.formulaContext.tooSmall":"The current calculation context is too small !","ui.formulaCount":"formulas","formula.ohm_law.name":"Ohm's Law","dataset.resistor-e3.name":"E3 IEC Resistors","dataset.resistor-e3.desc":"???","dataset.resistor-e6.name":"E6 IEC Resistors","dataset.resistor-e6.desc":"???","dataset.resistor-e12.name":"E12 IEC Resistors","dataset.resistor-e12.desc":"???","dataset.resistor-e24.name":"E24 IEC Resistors","dataset.resistor-e24.desc":"???","dataset.resistor-e48.name":"E48 IEC Resistors","dataset.resistor-e48.desc":"???","dataset.capacitor-iec.name":"IEC E24 Capacitors","dataset.capacitor-iec.desc":"???","context.type.disabled.name":"Disabled","context.type.constant.name":"Constant","context.type.continuous.name":"Continuous","context.type.valueRange.name":"Value Range","context.type.dataSetRange.name":"Set-based Range","context.type.disabled.desc":"???","context.type.constant.desc":"???","context.type.continuous.desc":"???","context.type.valueRange.desc":"???","context.type.dataSetRange.desc":"???"},fr:{"unit.ampere.name":"Ampère","unit.ohm.desc":"Résistance électrique","_error.formulaValue.noParent":"","_error.formulaValue.noSource":"","ui.formulaCount":"formules","formula.ohm_law.name":"Loi d'Ohm","context.type.disabled.name":"Désactivé","context.type.constant.name":"Constante","context.type.continuous.name":"Continue","context.type.valueRange.name":"Valeurs distinctes","context.type.dataSetRange.name":"Set de valeurs"}};export function localize(t){let a=langKey in e?e[langKey]:e.en;return t in a?a[t]:t in e.en?e.en[t]:t} \ No newline at end of file diff --git a/tools/items/formula-wizard/src/main.js b/tools/items/formula-wizard/src/main.js deleted file mode 100644 index bac2173..0000000 --- a/tools/items/formula-wizard/src/main.js +++ /dev/null @@ -1,25 +0,0 @@ -/*! - * Formula Wizard v0.0.2 - * [Short desc here] - * https://github.com/aziascreations/Web-NibblePoker - * Copyright (c) 2023 Herwin Bozet - * Unlicense Licence - */ -const version = [0, 0, 2]; -console.log("Initializing 'Formula Wizard v" + version.join(".") + "'..."); -const startTime = new Date().getMilliseconds(); -import { Decimal } from "../../../../resources/DecimalJs/10.4.3/decimal.min.mjs"; -import { localize } from "./lang.js"; -import { units, initUnits } from "./units.js"; -import { formulas, initFormulas } from "./formulas.js"; -import { initCatalog } from "./ui_catalog.js"; -import { setupWorkbenchContext } from "./mvc_context.js"; -Decimal.set({ precision: 25, rounding: 8 }); -initUnits(); -initFormulas(); -initCatalog(); -setupWorkbenchContext(); -console.log(localize("joe.mama")); -console.log(units); -console.log(formulas); -//# sourceMappingURL=main.js.map \ No newline at end of file diff --git a/tools/items/formula-wizard/src/main.min.js b/tools/items/formula-wizard/src/main.min.js deleted file mode 100644 index faf4b91..0000000 --- a/tools/items/formula-wizard/src/main.min.js +++ /dev/null @@ -1,8 +0,0 @@ -/*! - * Formula Wizard v0.0.2 - * [Short desc here] - * https://github.com/aziascreations/Web-NibblePoker - * Copyright (c) 2023 Herwin Bozet - * Unlicense Licence - */ -console.log("Initializing 'Formula Wizard v"+[0,0,2].join(".")+"'...");(new Date).getMilliseconds();import{Decimal as o}from"../../../../resources/DecimalJs/10.4.3/decimal.min.mjs";import{localize as i}from"./lang.js";import{units as m,initUnits as r}from"./units.js";import{formulas as s,initFormulas as l}from"./formulas.js";import{initCatalog as e}from"./ui_catalog.js";import{setupWorkbenchContext as n}from"./mvc_context.js";o.set({precision:25,rounding:8}),r(),l(),e(),n(),console.log(i("joe.mama")),console.log(m),console.log(s); \ No newline at end of file diff --git a/tools/items/formula-wizard/src/main.ts b/tools/items/formula-wizard/src/main.ts index 8a1305c..003a19e 100644 --- a/tools/items/formula-wizard/src/main.ts +++ b/tools/items/formula-wizard/src/main.ts @@ -1,5 +1,5 @@ /*! - * Formula Wizard v0.0.2 + * Formula Wizard v0.0.3 * [Short desc here] * https://github.com/aziascreations/Web-NibblePoker * Copyright (c) 2023 Herwin Bozet @@ -17,17 +17,22 @@ import {localize} from "./lang"; import {units, initUnits} from "./units"; import {formulas, initFormulas} from "./formulas"; import {initCatalog} from "./ui_catalog"; -import {setupWorkbenchContext} from "./mvc_context" +import {setupWorkbenchContext} from "./mvc_context"; +import {setupWorkbenchFormula} from "./mvc_formula"; // Configuring the Decimal.JS library to use its maximum potential precision. Decimal.set({ precision: 25, rounding: 8 }); -// Setting up non-primary things +// Setting up common collections initUnits(); initFormulas(); +// Preparing the UI initCatalog(); setupWorkbenchContext(); +setupWorkbenchFormula(); + +// ??? // Tests console.log(localize("joe.mama")); diff --git a/tools/items/formula-wizard/src/mvc_context.js b/tools/items/formula-wizard/src/mvc_context.js deleted file mode 100644 index 34de15c..0000000 --- a/tools/items/formula-wizard/src/mvc_context.js +++ /dev/null @@ -1,124 +0,0 @@ -/*! - * Formula Wizard v0.0.2 - * [Short desc here] - * https://github.com/aziascreations/Web-NibblePoker - * Copyright (c) 2023 Herwin Bozet - * Unlicense Licence - */ -import { localize } from "./lang.js"; -import { units, scaleFactors } from "./units.js"; -import { sets } from "./sets.js"; -class ContextType { - constructor(name, description) { - this.name = name; - this.description = description; - } -} -export const contextTypes = { - DISABLED: new ContextType(localize("context.type.disabled.name"), localize("context.type.disabled.desc")), - CONSTANT: new ContextType(localize("context.type.constant.name"), localize("context.type.constant.desc")), - CONTINUOUS: new ContextType(localize("context.type.continuous.name"), localize("context.type.continuous.desc")), - VALUE_RANGE: new ContextType(localize("context.type.valueRange.name"), localize("context.type.valueRange.desc")), - DATASET_RANG: new ContextType(localize("context.type.dataSetRange.name"), localize("context.type.dataSetRange.desc")), -}; -const idContextComponentPrefix = "fw-context-component-"; -const idContextComponentId = idContextComponentPrefix + "id"; -const idContextComponentDelete = idContextComponentPrefix + "delete"; -const idContextComponentTypes = idContextComponentPrefix + "type"; -const idContextComponentManualValue = idContextComponentPrefix + "manual-value"; -const idContextComponentManualValues = idContextComponentManualValue + "s"; -const idContextComponentRangeFrom = idContextComponentPrefix + "range-from"; -const idContextComponentRangeTo = idContextComponentPrefix + "range-to"; -const idContextComponentRangeStep = idContextComponentPrefix + "range-step"; -const idContextComponentSets = idContextComponentPrefix + "set"; -const idContextComponentUnit = idContextComponentPrefix + "unit"; -const idContextComponentScale = idContextComponentPrefix + "scale"; -class WorkbenchContextComponentData { -} -class WorkbenchContextComponentInterface { -} -export class WorkbenchContextComponent { - constructor(uiElement, data) { - this.uiElement = uiElement; - this.data = data; - } - static createNew(eRootElement) { - return null; - } - toJson() { - return JSON.stringify(this.data); - } - fromJson() { - return false; - } -} -export let workbenchContextComponents = []; -let eTemplateContextComponent = null; -let eContextStatusMessage = null; -let eContextAddButton = null; -let isWorkbenchContextSetup = false; -export function setupWorkbenchContext() { - if (!isWorkbenchContextSetup) { - console.debug("Preparing UI for workbench context components..."); - eTemplateContextComponent = document.getElementById("template-context-component"); - if (eTemplateContextComponent === null) { - alert(localize("error.ui.context.noTemplate")); - throw Error(localize("error.ui.context.noTemplate")); - } - eTemplateContextComponent = eTemplateContextComponent.cloneNode(true).content; - document.getElementById("template-context-component").remove(); - const eContextTypes = eTemplateContextComponent.getElementById(idContextComponentTypes); - const eContextSets = eTemplateContextComponent.getElementById(idContextComponentSets); - const eContextUnits = eTemplateContextComponent.getElementById(idContextComponentUnit); - const eContextScales = eTemplateContextComponent.getElementById(idContextComponentScale); - if ([eContextTypes, eContextSets, eContextUnits, eContextScales].some((item) => item === null)) { - alert(localize("error.ui.context.noSets")); - throw Error(localize("error.ui.context.noSets")); - } - Object.keys(contextTypes).forEach(value => { - const eNewContextTypesOption = document.createElement("option"); - eNewContextTypesOption.setAttribute("value", value); - eNewContextTypesOption.innerText = contextTypes[value].name; - eContextTypes.appendChild(eNewContextTypesOption); - }); - Object.keys(sets).forEach(value => { - const eNewContextSetsOption = document.createElement("option"); - eNewContextSetsOption.setAttribute("value", value); - eNewContextSetsOption.innerText = sets[value].name; - eContextSets.appendChild(eNewContextSetsOption); - }); - Object.keys(units).forEach(unitKey => { - const eNewContextUnitsOption = document.createElement("option"); - eNewContextUnitsOption.setAttribute("value", unitKey); - eNewContextUnitsOption.innerText = units[unitKey].name; - eContextUnits.appendChild(eNewContextUnitsOption); - }); - Object.keys(scaleFactors).forEach(scaleKey => { - const eNewContextScalesOption = document.createElement("option"); - eNewContextScalesOption.setAttribute("value", scaleKey); - eNewContextScalesOption.innerText = scaleFactors[scaleKey].prefix; - eContextScales.appendChild(eNewContextScalesOption); - }); - eContextStatusMessage = document.getElementById("fw-text-context-middle"); - if (eContextStatusMessage === null) { - alert(localize("error.ui.context.noStatus")); - throw Error(localize("error.ui.context.noStatus")); - } - eContextAddButton = document.querySelector("button#fw-button-add-context"); - if (eContextAddButton === null) { - alert(localize("error.ui.context.missingButton")); - throw Error(localize("error.ui.context.missingButton")); - } - eContextAddButton.onclick = function () { - const eNewContextComponent = eTemplateContextComponent.cloneNode(true).firstElementChild; - if (eNewContextComponent === null) { - alert(localize("error.ui.context.component.cannotGetElement")); - throw Error(localize("error.ui.context.component.cannotGetElement")); - } - const newContextComponent = WorkbenchContextComponent.createNew(eNewContextComponent); - workbenchContextComponents.push(newContextComponent); - }; - isWorkbenchContextSetup = true; - } -} -//# sourceMappingURL=mvc_context.js.map \ No newline at end of file diff --git a/tools/items/formula-wizard/src/mvc_context.ts b/tools/items/formula-wizard/src/mvc_context.ts index 1e0fffc..09bbf11 100644 --- a/tools/items/formula-wizard/src/mvc_context.ts +++ b/tools/items/formula-wizard/src/mvc_context.ts @@ -1,4 +1,4 @@ -/*! +/* * Formula Wizard v0.0.2 * [Short desc here] * https://github.com/aziascreations/Web-NibblePoker @@ -52,13 +52,110 @@ const idContextComponentUnit = idContextComponentPrefix + "unit"; const idContextComponentScale = idContextComponentPrefix + "scale"; class WorkbenchContextComponentData { - //id: string; + id: string; + constructor(controllerId: string) { + this.id = controllerId; + } } class WorkbenchContextComponentInterface { + public rootElement: HTMLElement; + private readonly eIdLabel: HTMLLabelElement; + private readonly eIdInput: HTMLInputElement; + public readonly eDeleteButton: HTMLButtonElement; + private readonly eTypeLabel: HTMLLabelElement; + private readonly eTypeSelect: HTMLSelectElement; + private readonly eManualValueLabel: HTMLLabelElement; + private readonly eManualValueInput: HTMLInputElement; + + private readonly eManualValuesLabel: HTMLLabelElement; + private readonly eManualValuesInput: HTMLInputElement; + + private readonly eRangeFromLabel: HTMLLabelElement; + private readonly eRangeFromInput: HTMLInputElement; + private readonly eRangeToLabel: HTMLLabelElement; + private readonly eRangeToInput: HTMLInputElement; + private readonly eRangeStepLabel: HTMLLabelElement; + private readonly eRangeStepInput: HTMLInputElement; + + private readonly eDataSetLabel: HTMLLabelElement; + private readonly eDataSetSelect: HTMLSelectElement; + + private readonly eUnitLabel: HTMLLabelElement; + private readonly eUnitSelect: HTMLSelectElement; + private readonly eScaleLabel: HTMLLabelElement; + private readonly eScaleSelect: HTMLSelectElement; + + private readonly allElements: HTMLElement[]; + + constructor(controllerId: string, rootElement: HTMLElement) { + this.rootElement = rootElement; + + // Grabbing references to essential UI elements. + // All "null" checks are done below. + this.eIdLabel = rootElement.querySelector(`label[for="${idContextComponentId}"]`)!; + this.eIdInput = rootElement.querySelector(`input#${idContextComponentId}`)!; + + this.eDeleteButton = rootElement.querySelector(`button#${idContextComponentDelete}`)!; + + this.eTypeLabel = rootElement.querySelector(`label[for="${idContextComponentTypes}"]`)!; + this.eTypeSelect = rootElement.querySelector(`select#${idContextComponentTypes}`)!; + + this.eManualValueLabel = rootElement.querySelector(`label[for="${idContextComponentManualValue}"]`)!; + this.eManualValueInput = rootElement.querySelector(`input#${idContextComponentManualValue}`)!; + + this.eManualValuesLabel = rootElement.querySelector(`label[for="${idContextComponentManualValues}"]`)!; + this.eManualValuesInput = rootElement.querySelector(`input#${idContextComponentManualValues}`)!; + + this.eRangeFromLabel = rootElement.querySelector(`label[for="${idContextComponentRangeFrom}"]`)!; + this.eRangeFromInput = rootElement.querySelector(`input#${idContextComponentRangeFrom}`)!; + this.eRangeToLabel = rootElement.querySelector(`label[for="${idContextComponentRangeTo}"]`)!; + this.eRangeToInput = rootElement.querySelector(`input#${idContextComponentRangeTo}`)!; + this.eRangeStepLabel = rootElement.querySelector(`label[for="${idContextComponentRangeStep}"]`)!; + this.eRangeStepInput = rootElement.querySelector(`input#${idContextComponentRangeStep}`)!; + + this.eDataSetLabel = rootElement.querySelector(`label[for="${idContextComponentSets}"]`)!; + this.eDataSetSelect = rootElement.querySelector(`select#${idContextComponentSets}`)!; + + this.eUnitLabel = rootElement.querySelector(`label[for="${idContextComponentUnit}"]`)!; + this.eUnitSelect = rootElement.querySelector(`select#${idContextComponentUnit}`)!; + this.eScaleLabel = rootElement.querySelector(`label[for="${idContextComponentScale}"]`)!; + this.eScaleSelect = rootElement.querySelector(`select#${idContextComponentScale}`)!; + + // Making sure we got all elements. + this.allElements = [ + this.eIdLabel, this.eIdInput, this.eDeleteButton, this.eTypeLabel, this.eTypeSelect, + this.eManualValuesLabel, this.eManualValuesInput, this.eRangeFromLabel, this.eRangeFromInput, + this.eRangeToLabel, this.eRangeToInput, this.eRangeStepLabel, this.eRangeStepInput, this.eDataSetLabel, + this.eDataSetSelect, this.eUnitLabel, this.eUnitSelect, this.eScaleLabel, this.eScaleSelect, + this.eManualValueLabel, this.eManualValueInput + ]; + if(this.allElements.some((item) => item === null)) { + alert(localize("error.ui.context.component.missingElement")); + throw Error(localize("error.ui.context.component.missingElement")); + } + + // Appending the "idSuffix" to all the IDs and "for" attributes. + rootElement.querySelectorAll(`input, select`).forEach(eFormInput => { + if(eFormInput.hasAttribute("id")) { + eFormInput.setAttribute("id", eFormInput.getAttribute("id") + controllerId); + } + }); + rootElement.querySelectorAll(`label`).forEach(eFormLabel => { + if(eFormLabel.hasAttribute("for")) { + eFormLabel.setAttribute("for", eFormLabel.getAttribute("for") + controllerId); + } + }); + + // Other manual ID-related changes. + this.eDeleteButton.removeAttribute('id'); + + // Setting up default values in fields. + this.eIdInput.value = controllerId; + } } export class WorkbenchContextComponent { @@ -68,11 +165,28 @@ export class WorkbenchContextComponent { constructor(uiElement: WorkbenchContextComponentInterface, data: WorkbenchContextComponentData) { this.uiElement = uiElement; this.data = data; + + // Binding UI-sourced events to controller functions. + + // Setting actions & events. + //this.eTypeSelect.onchange = this.onTypeChange.bind(this); + this.uiElement.eDeleteButton.onclick = this.handleDelete.bind(this); + + // Forcing some actions + this.handleTypeChange(); } - public static createNew(eRootElement: HTMLElement): WorkbenchContextComponent { - // formulaVariant: FormulaVariant - return null!; + setId(newId: string): void { + + } + + handleDelete(): void { + this.uiElement.rootElement.remove(); + deleteWorkbenchComponent(this); + } + + handleTypeChange(): void { + } toJson(): string { @@ -82,6 +196,20 @@ export class WorkbenchContextComponent { fromJson(): boolean { return false; } + + public static createNew(eRootElement: HTMLElement): WorkbenchContextComponent { + const id: string = Date.now().toString(); + + return new WorkbenchContextComponent( + new WorkbenchContextComponentInterface( + id, + eRootElement, + ), + new WorkbenchContextComponentData( + id, + ), + ); + } } @@ -91,6 +219,18 @@ export class WorkbenchContextComponent { export let workbenchContextComponents: WorkbenchContextComponent[] = []; +function deleteWorkbenchComponent(deletedComponent: WorkbenchContextComponent) { + workbenchContextComponents = workbenchContextComponents.filter(item => item !== deletedComponent); + if(workbenchContextComponents.length < 1) { + eContextStatusMessage!.hidden = false; + } +} + + +// ---------------- +// ??? +// ---------------- + // let eTemplateContextComponent: HTMLElement | DocumentFragment | null = null; @@ -163,6 +303,9 @@ export function setupWorkbenchContext() { } eContextAddButton.onclick = function() { + console.group("Adding new context component to workbench..."); + + console.debug("Copying the template..."); // We only get the fragment via the template, we have to use this monstrosity to get a proper element out of it. const eNewContextComponent= (eTemplateContextComponent!.cloneNode(true) as DocumentFragment).firstElementChild as HTMLElement; @@ -171,15 +314,19 @@ export function setupWorkbenchContext() { throw Error(localize("error.ui.context.component.cannotGetElement")); } + console.debug("Instantiating and saving the 'WorkbenchContextComponent'..."); const newContextComponent = WorkbenchContextComponent.createNew( eNewContextComponent ); workbenchContextComponents.push(newContextComponent); - //eContextStatusMessage!.parentNode!.insertBefore(newContextComponent.uiElement, eContextStatusMessage); - //eContextStatusMessage!.hidden = true; - ////eContextStatusMessage!.parentNode!.insertBefore(newContextComponent.rootElement, eContextStatusMessage); - ////eContextStatusMessage!.hidden = true; + console.debug("> ID: " + newContextComponent.data.id); + + console.debug("Inserting the element in the DOM..."); + eContextStatusMessage!.parentNode!.insertBefore(newContextComponent.uiElement.rootElement, eContextStatusMessage!); + eContextStatusMessage!.hidden = true; + + console.groupEnd(); } isWorkbenchContextSetup = true; diff --git a/tools/items/formula-wizard/src/mvc_formula.ts b/tools/items/formula-wizard/src/mvc_formula.ts new file mode 100644 index 0000000..c807aa5 --- /dev/null +++ b/tools/items/formula-wizard/src/mvc_formula.ts @@ -0,0 +1,184 @@ +/* + * Formula Wizard v0.0.2 + * [Short desc here] + * https://github.com/aziascreations/Web-NibblePoker + * Copyright (c) 2023 Herwin Bozet + * Unlicense Licence + */ + +import {localize} from "./lang"; +import {isCatalogInitialized, catalogFormulas} from "./ui_catalog"; + +// ----------- +// Constants +// ----------- + +const ID_TEMPLATE_FORMULA = "template-workbench-formula"; +const ID_TEMPLATE_FORMULA_VALUE = ID_TEMPLATE_FORMULA + "-value"; + +const ID_FORMULA_PREFIX = "fw-workbench-formula-"; +const ID_FORMULA_SPAWN_POINT = ID_FORMULA_PREFIX + "spawn"; + +//const idWorkbenchFormulaPrefix = "fw-workbench-formula-"; +//const idWorkbenchFormulaSpawnPoint = idWorkbenchFormulaPrefix + "spawn"; +// +//// Formula template +//const idTemplateFormula = "template-workbench-formula"; +//const idFormulaName = idWorkbenchFormulaPrefix + "name"; +//const idFormulaInputs = idWorkbenchFormulaPrefix + "inputs"; +//const idFormulaOutputs = idWorkbenchFormulaPrefix + "outputs"; +// +//// FormulaUnit template +//const classTemplateFormulaValue = "formula-value-input-form"; +//const idTemplateFormulaValue = idTemplateFormula + "-value"; +//const idFormulaValuePrefix = idWorkbenchFormulaPrefix + "value-"; +//const idFormulaValueId = idFormulaValuePrefix + "id"; +//const idFormulaValueName = idFormulaValuePrefix + "name"; +//const idFormulaValueLink = idFormulaValuePrefix + "link"; +//const idFormulaValueTestValue = idFormulaValuePrefix + "test-value"; +//const idFormulaValueTestScale = idFormulaValuePrefix + "test-scale"; +//const idFormulaValueTestValueSet = idFormulaValuePrefix + "test-value-set"; + + +// --------- +// Globals +// --------- + +let eTemplateWorkbenchFormula: HTMLElement | DocumentFragment | null = null; +let eTemplateWorkbenchFormulaValue: HTMLElement | DocumentFragment | null = null; + +export let workbenchFormulas: WorkbenchFormula[] = []; + + +// ---------------------- +// Global-related utils +// ---------------------- + +function deleteWorkbenchFormula(deletedFormula: WorkbenchFormula, removeDom: boolean = true) { + workbenchFormulas = workbenchFormulas.filter(item => item !== deletedFormula); + //if(removeDom) { + // //deletedFormula.uiElement + //} + //if(workbenchContextComponents.length < 1) { + // eContextStatusMessage!.hidden = false; + //} +} + +// -------------------- +// Formula Values MVC +// -------------------- + +enum EWorkbenchFormulaValueTypes { + //UNKNOWN, + INPUT, + OUTPUT, +} + +class WorkbenchFormulaValueData { + id: string; + + constructor(controllerId: string) { + this.id = controllerId; + } +} + +class WorkbenchFormulaValueInterface { + +} + +class WorkbenchFormulaValue { + uiElement: WorkbenchFormulaValueInterface; + data: WorkbenchFormulaValueData; + + constructor(uiElement: WorkbenchFormulaValueInterface, data: WorkbenchFormulaValueData) { + this.uiElement = uiElement; + this.data = data; + } + + public static createNew(eRootElement: HTMLElement): WorkbenchFormulaValue { + const id: string = Date.now().toString(); + + return null!; + } +} + + +// -------------- +// Formulas MVC +// -------------- + +class WorkbenchFormulaData { + id: string; + + constructor(controllerId: string) { + this.id = controllerId; + } +} + +class WorkbenchFormulaInterface { + +} + +class WorkbenchFormula { + uiElement: WorkbenchFormulaInterface; + data: WorkbenchFormulaData; + + constructor(uiElement: WorkbenchFormulaInterface, data: WorkbenchFormulaData) { + this.uiElement = uiElement; + this.data = data; + } + + public static createNew(eRootElement: HTMLElement): WorkbenchFormula { + const id: string = Date.now().toString(); + + return null!; + } +} + + +// ---------------- +// ??? +// ---------------- + +let isWorkbenchFormulaSetup = false; + +export function setupWorkbenchFormula() { + if (!isWorkbenchFormulaSetup) { + console.group("Preparing UI for workbench formula components..."); + + console.debug("Checking if the catalog is ready..."); + if(!isCatalogInitialized()) { + console.groupEnd(); + alert(localize("error.ui.workbench.catalog.no-init")); + throw Error(localize("error.ui.workbench.catalog.no-init")); + } + + console.debug("Grabbing & processing the templates from the DOM..."); + eTemplateWorkbenchFormula = document.getElementById(ID_TEMPLATE_FORMULA); + eTemplateWorkbenchFormulaValue = document.getElementById(ID_TEMPLATE_FORMULA_VALUE); + if(eTemplateWorkbenchFormula === null || eTemplateWorkbenchFormulaValue === null) { + console.groupEnd(); + alert(localize("error.ui.workbench.noTemplate")); + throw Error(localize("error.ui.workbench.noTemplate")); + } + eTemplateWorkbenchFormula = (eTemplateWorkbenchFormula.cloneNode(true) as HTMLTemplateElement).content; + eTemplateWorkbenchFormulaValue = (eTemplateWorkbenchFormulaValue.cloneNode(true) as HTMLTemplateElement).content; + + console.debug("Grabbing the anchor point for new formulas..."); + const eWorkbenchFormulaSpawnPoint: HTMLAnchorElement | null = document.querySelector(`a#${ID_FORMULA_SPAWN_POINT}`); + if(eWorkbenchFormulaSpawnPoint === null) { + console.groupEnd(); + alert(localize("error.ui.workbench.noAnchor")); + throw Error(localize("error.ui.workbench.noAnchor")); + } + + // catalogFormulas + + + + + isWorkbenchFormulaSetup = true; + + console.groupEnd(); + } +} diff --git a/tools/items/formula-wizard/src/sets.js b/tools/items/formula-wizard/src/sets.js deleted file mode 100644 index a2ee032..0000000 --- a/tools/items/formula-wizard/src/sets.js +++ /dev/null @@ -1,41 +0,0 @@ -import { Decimal } from "../../../../resources/DecimalJs/10.4.3/decimal.min.mjs"; -import { localize } from "./lang.js"; -import { units, scaleFactors } from "./units.js"; -export class DataSet { - constructor(name, description, values, unit, scaleFactor) { - this.name = name; - this.description = description; - this.values = values; - this.unit = unit; - this.scaleFactor = scaleFactor; - if (unit.scale != scaleFactor.scale) { - alert(""); - throw Error(""); - } - } - getDataSet() { - return this.values; - } -} -const e3Range = [1, 2.2, 4.7]; -const e6Range = [1, 1.5, 2.2, 3.3, 4.7, 6.8]; -const e12Range = [1, 1.2, 1.5, 1.8, 2.2, 2.7, 3.3, 3.9, 4.7, 5.6, 6.8, 8.2]; -const e24Range = [ - 1, 1.1, 1.2, 1.3, 1.5, 1.6, 1.8, 2, 2.2, 2.4, 2.7, 3, 3.3, 3.6, 3.9, 4.3, 4.7, 5.1, 5.6, 6.2, 6.8, 7.5, 8.2, 9.1 -]; -const e48Range = [ - 1, 1.05, 1.1, 1.15, 1.21, 1.27, 1.33, 1.4, 1.47, 1.54, 1.62, 1.69, 1.78, 1.87, 1.96, 2.05, 2.15, 2.26, 2.37, 2.49, - 2.61, 2.74, 2.87, 3.01, 3.16, 3.32, 3.48, 3.65, 3.83, 4.02, 4.22, 4.42, 4.64, 4.87, 5.11, 5.36, 5.62, 5.9, 6.19, - 6.49, 6.81, 7.15, 7.5, 7.87, 8.25, 8.66, 9.09, 9.53 -]; -const resistorsScales = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]; -const capacitorScales = [10e-12, 10e-11, 10e-10, 10e-9, 10e-8, 10e-7, 10e-6, 10e-5, 10e-4, 10e-3, 10e-2]; -export const sets = { - RESISTOR_E3: new DataSet(localize("dataset.resistor-e3.name"), localize("dataset.resistor-e3.desc"), resistorsScales.flatMap((e3Scale) => e3Range.map((e3Multiplier) => new Decimal(e3Scale).times(e3Multiplier))), units.OHM, scaleFactors.SI_BASE), - RESISTOR_E6: new DataSet(localize("dataset.resistor-e6.name"), localize("dataset.resistor-e6.desc"), resistorsScales.flatMap((e6Scale) => e6Range.map((e6Multiplier) => new Decimal(e6Scale).times(e6Multiplier))), units.OHM, scaleFactors.SI_BASE), - RESISTOR_E12: new DataSet(localize("dataset.resistor-e12.name"), localize("dataset.resistor-e12.desc"), resistorsScales.flatMap((e12Scale) => e12Range.map((e12Multiplier) => new Decimal(e12Scale).times(e12Multiplier))), units.OHM, scaleFactors.SI_BASE), - RESISTOR_E24: new DataSet(localize("dataset.resistor-e24.name"), localize("dataset.resistor-e24.desc"), resistorsScales.flatMap((e24Scale) => e24Range.map((e24Multiplier) => new Decimal(e24Scale).times(e24Multiplier))), units.OHM, scaleFactors.SI_BASE), - RESISTOR_E48: new DataSet(localize("dataset.resistor-e48.name"), localize("dataset.resistor-e48.desc"), resistorsScales.flatMap((e48Scale) => e48Range.map((e48Multiplier) => new Decimal(e48Scale).times(e48Multiplier))), units.OHM, scaleFactors.SI_BASE), - CAPACITOR_IEC: new DataSet(localize("dataset.capacitor-iec.name"), localize("dataset.capacitor-iec.desc"), capacitorScales.flatMap((cScale) => e24Range.map((eMultiplier) => new Decimal(cScale).times(eMultiplier))), units.FARAD, scaleFactors.SI_BASE), -}; -//# sourceMappingURL=sets.js.map \ No newline at end of file diff --git a/tools/items/formula-wizard/src/tsconfig.json b/tools/items/formula-wizard/src/tsconfig.json deleted file mode 100644 index 5e7a0d6..0000000 --- a/tools/items/formula-wizard/src/tsconfig.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - - /* Language and Environment */ - "target": "es2019", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - - /* Modules */ - "module": "ES6", /* Specify what module code is generated. */ - "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ - // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ - // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ - // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ - // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - - /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - //"outFile": "./formula-wizard.js", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ - "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ - - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ - - /* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */ - "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ - }, - "files": [ - "./main.ts", - ], - "exclude": [ - "../../../../resources/DecimalJs/10.4.3" - ] -} diff --git a/tools/items/formula-wizard/src/ui_catalog.js b/tools/items/formula-wizard/src/ui_catalog.js deleted file mode 100644 index cb53bdf..0000000 --- a/tools/items/formula-wizard/src/ui_catalog.js +++ /dev/null @@ -1,69 +0,0 @@ -/*! - * Formula Wizard v0.0.2 - * [Short desc here] - * https://github.com/aziascreations/Web-NibblePoker - * Copyright (c) 2023 Herwin Bozet - * Unlicense Licence - */ -import { formulas } from "./formulas.js"; -const idCatalogPrefix = "fw-catalog-"; -const idCatalogCategoryPrefix = idCatalogPrefix + "category-"; -const idCatalogCategoryCount = idCatalogPrefix + "formula-count"; -export const eCategoryContainers = {}; -let IsCatalogInitialized = false; -export function initCatalog() { - if (!IsCatalogInitialized) { - console.debug("Populating formula catalog..."); - document.querySelectorAll('[id]').forEach((element) => { - if (element.id.startsWith(idCatalogCategoryPrefix)) { - eCategoryContainers[element.id.replace(idCatalogCategoryPrefix, "")] = element; - } - }); - const eFormulaCount = document.getElementById(idCatalogCategoryCount); - if (eFormulaCount !== null) { - eFormulaCount.innerText = Object.keys(formulas).length.toString(); - } - let eTemplateFormula = document.getElementById("template-formula-available"); - let eTemplateFormulaVariant = document.getElementById("template-formula-available-variant"); - if (eTemplateFormula === null || eTemplateFormulaVariant === null) { - alert("error.ui.catalog.noTemplate"); - throw Error("error.ui.catalog.noTemplate"); - } - Object.keys(formulas).forEach(formulaKey => { - const hasValidCategory = formulas[formulaKey].categories.every(function (categoryId) { - return Object.keys(eCategoryContainers).indexOf(categoryId) !== -1; - }); - if (hasValidCategory) { - let eNewFormula = eTemplateFormula.content.cloneNode(true); - let eNewFormulaTitle = eNewFormula.querySelector("p"); - if (eNewFormulaTitle !== null) { - eNewFormulaTitle.innerText = formulas[formulaKey].name; - } - let eNewFormulaVariants = eNewFormula.querySelector("div.fw-variants"); - if (eNewFormulaVariants === null) { - alert(""); - throw Error(""); - } - eNewFormulaVariants.innerHTML = ""; - formulas[formulaKey].variants.forEach(variant => { - let eNewFormulaVariant = eTemplateFormulaVariant.content.cloneNode(true); - let eNewFormulaVariantButton = eNewFormulaVariant.querySelector("button"); - if (eNewFormulaVariantButton === null) { - alert(""); - throw Error(""); - } - eNewFormulaVariantButton.innerHTML = variant.getMathMl(formulas[formulaKey]); - eNewFormulaVariantButton.title = variant.description; - eNewFormulaVariants.appendChild(eNewFormulaVariant); - }); - formulas[formulaKey].categories.forEach(categoryKey => { - if (Object.keys(eCategoryContainers).includes(categoryKey)) { - eCategoryContainers[categoryKey].appendChild(eNewFormula); - } - }); - } - }); - IsCatalogInitialized = true; - } -} -//# sourceMappingURL=ui_catalog.js.map \ No newline at end of file diff --git a/tools/items/formula-wizard/src/ui_catalog.ts b/tools/items/formula-wizard/src/ui_catalog.ts index 25cbd30..5a0e3f3 100644 --- a/tools/items/formula-wizard/src/ui_catalog.ts +++ b/tools/items/formula-wizard/src/ui_catalog.ts @@ -1,12 +1,16 @@ -/*! - * Formula Wizard v0.0.2 +/* + * Formula Wizard v1.0.0 - Formula Catalog + * -------------------------------------------------------------------------------- * [Short desc here] + * This module handles the indexation of all formulas and their elements to be + * show in the UI. + * -------------------------------------------------------------------------------- * https://github.com/aziascreations/Web-NibblePoker * Copyright (c) 2023 Herwin Bozet * Unlicense Licence */ -import {formulas} from "./formulas"; +import {formulas, Formula} from "./formulas"; const idCatalogPrefix = "fw-catalog-"; const idCatalogCategoryPrefix = idCatalogPrefix + "category-" @@ -16,26 +20,104 @@ const idCatalogCategoryCount = idCatalogPrefix + "formula-count" // The key is their ID without the prefix. (Result: electricity, chemistry, ...) export const eCategoryContainers: { [key: string]: HTMLElement } = {}; +// ---------------- +// ??? +// ---------------- + +export const catalogFormulas: CatalogFormula[] = []; + +class CatalogFormula { + formula: Formula; + eFormulaContainer: HTMLElement; + eVariantContainer: HTMLElement; + eCategories: HTMLElement[]; + eVariantContainers: HTMLElement[]; + eVariantButtons: HTMLButtonElement[]; + + constructor(formula: Formula, eCategories: HTMLElement[], eFormulaContainer: HTMLElement, + eVariantContainers: HTMLElement[], eVariantButtons: HTMLButtonElement[]) { + this.formula = formula; + this.eCategories = eCategories; + this.eFormulaContainer = eFormulaContainer; + this.eVariantContainers = eVariantContainers; + this.eVariantButtons = eVariantButtons; + + // Setting up the title + let eNewFormulaTitle = this.eFormulaContainer.querySelector("p"); + if(eNewFormulaTitle !== null) { + eNewFormulaTitle.innerText = this.formula.name; + } + + // Grabbing the spawn point for all variants + let eNewFormulaVariants = this.eFormulaContainer.querySelector("div.fw-variants"); + if(eNewFormulaVariants === null) { + alert("idk1"); + throw Error("idk1"); + } + this.eVariantContainer = eNewFormulaVariants as HTMLElement; + this.eVariantContainer.innerHTML = ""; + + // Setting up each variant + for(let i = 0; i < this.formula.variants.length; i++) { + this.eVariantButtons[i].innerHTML = this.formula.variants[i].getMathMl(this.formula); + this.eVariantButtons[i].title = this.formula.variants[i].description; + + // Now adding those buttons to the root element. + this.eVariantContainer.appendChild(this.eVariantContainers[i]); + } + + // NOTE: The "onclick" will be set in "mvc_formula.ts" since it will bind those button and the workbench + // formulas these buttons can spawn. + } + + insertIntoCategories() { + // Adding it to any relevant category. + this.eCategories.forEach(eCategory => { + eCategory.appendChild(this.eFormulaContainer); + }); + + // Preventing any double-insertion. + this.eCategories = []; + } + + // TODO: A function to easily bind a common given function. +} + + +// ---------------- +// ??? +// ---------------- + let IsCatalogInitialized = false; +/** + * Used by the Workbench's Formula MVC to determine if the actions on the buttons can be prepared. + * + * Will always return `true` once `initCatalog()` has been called at least once. + */ +export function isCatalogInitialized(): boolean { + return IsCatalogInitialized; +} + export function initCatalog() { if (!IsCatalogInitialized) { - console.debug("Populating formula catalog..."); + console.group("Preparing the formula catalog..."); + console.debug("Grabbing the category container elements..."); document.querySelectorAll('[id]').forEach((element ) => { if(element.id.startsWith(idCatalogCategoryPrefix)) { eCategoryContainers[element.id.replace(idCatalogCategoryPrefix, "")] = element as HTMLElement; } }); - // Showing the formula count. + console.debug("Setting up the formula count in the UI..."); const eFormulaCount = document.getElementById(idCatalogCategoryCount); if(eFormulaCount !== null) { //eFormulaCount.innerText = Object.keys(formulas).length + " "+ localize("ui.formulaCount"); eFormulaCount.innerText = Object.keys(formulas).length.toString(); } - // Grabbing the templates for formulas and their variants + console.debug("Grabbing the templates for formulas and their variants..."); let eTemplateFormula = document.getElementById("template-formula-available"); let eTemplateFormulaVariant = document.getElementById("template-formula-available-variant"); if(eTemplateFormula === null || eTemplateFormulaVariant === null) { @@ -43,57 +125,50 @@ export function initCatalog() { throw Error("error.ui.catalog.noTemplate"); } - // Adding the formulas and their variants to the page + console.debug("Preparing each formula for later use..."); Object.keys(formulas).forEach(formulaKey => { + // Checking if the formula has one or more matching category container element. const hasValidCategory: boolean = formulas[formulaKey].categories.every(function(categoryId) { return Object.keys(eCategoryContainers).indexOf(categoryId) !== -1; }); + if(hasValidCategory) { - // Preparing the common element for the formula + // Preparing the common element for the formula. let eNewFormula = (eTemplateFormula as HTMLTemplateElement).content.cloneNode(true) as HTMLElement; - let eNewFormulaTitle = eNewFormula.querySelector("p"); - if(eNewFormulaTitle !== null) { - //eNewFormulaTitle.innerText = localize(formulas[formulaKey].name); - eNewFormulaTitle.innerText = formulas[formulaKey].name; - } - - let eNewFormulaVariants = eNewFormula.querySelector("div.fw-variants"); - if(eNewFormulaVariants === null) { - alert(""); - throw Error(""); - } - eNewFormulaVariants.innerHTML = ""; + let eNewVariantsContainers: HTMLElement[] = []; + let eNewVariantsButtons: HTMLButtonElement[] = []; formulas[formulaKey].variants.forEach(variant => { let eNewFormulaVariant = (eTemplateFormulaVariant as HTMLTemplateElement).content.cloneNode(true) as HTMLElement; let eNewFormulaVariantButton = eNewFormulaVariant.querySelector("button"); if(eNewFormulaVariantButton === null) { - alert(""); - throw Error(""); + alert("idk2"); + throw Error("idk2"); } - eNewFormulaVariantButton.innerHTML = variant.getMathMl(formulas[formulaKey]); - eNewFormulaVariantButton.title = variant.description; - // FIXME: Add this back ! - //eNewFormulaVariantButton.onclick = function() { - // WorkbenchFormulaUiElement.createNew(variant); - //}; - - // @ts-ignore - "eNewFormulaVariants" cannot be null here ! - eNewFormulaVariants.appendChild(eNewFormulaVariant); + eNewVariantsContainers.push(eNewFormulaVariant); + eNewVariantsButtons.push(eNewFormulaVariantButton); }); - // Adding it to any relevant category. - formulas[formulaKey].categories.forEach(categoryKey => { - if(Object.keys(eCategoryContainers).includes(categoryKey)) { - // @ts-ignore - "eCategoryContainers[categoryKey]" cannot be null ! - eCategoryContainers[categoryKey].appendChild(eNewFormula); - } - }); + catalogFormulas.push( + new CatalogFormula( + formulas[formulaKey], + formulas[formulaKey].categories + .filter(categoryKey => Object.keys(eCategoryContainers).includes(categoryKey)) + .map(categoryKey => eCategoryContainers[categoryKey]), + eNewFormula, + eNewVariantsContainers, + eNewVariantsButtons + ) + ); } }); IsCatalogInitialized = true; + + console.debug(catalogFormulas); + + console.groupEnd(); } } diff --git a/tools/items/formula-wizard/src/units.js b/tools/items/formula-wizard/src/units.js deleted file mode 100644 index 2046c57..0000000 --- a/tools/items/formula-wizard/src/units.js +++ /dev/null @@ -1,197 +0,0 @@ -import { Decimal } from "../../../../resources/DecimalJs/10.4.3/decimal.min.mjs"; -import { localize } from "./lang.js"; -export class Unit { - constructor(unitKey, symbol, scale) { - this.name = localize("unit." + unitKey + ".name"); - this.symbol = symbol; - this.scale = scale; - this.description = localize("unit." + unitKey + ".desc"); - } -} -export const scales = { - SI: new class { - constructor() { - this.formatName = (unit) => { - return unit.symbol; - }; - this.formatSymbol = (unit) => { - return unit.symbol; - }; - this.scaleFactors = []; - } - }, - IMPERIAL_DISTANCE: new class { - constructor() { - this.formatName = (unit) => { - return unit.symbol; - }; - this.formatSymbol = (unit) => { - return unit.symbol; - }; - this.scaleFactors = []; - } - }, - IMPERIAL_WEIGHT: new class { - constructor() { - this.formatName = (unit) => { - return unit.symbol; - }; - this.formatSymbol = (unit) => { - return unit.symbol; - }; - this.scaleFactors = []; - } - }, - TIME_SECONDS: new class { - constructor() { - this.formatName = (unit) => { - return unit.symbol; - }; - this.formatSymbol = (unit) => { - return unit.symbol; - }; - this.scaleFactors = []; - } - }, - NONE: new class { - constructor() { - this.formatName = (unit) => { - return unit.name; - }; - this.formatSymbol = (unit) => { - return unit.symbol; - }; - this.scaleFactors = []; - } - }, -}; -export const scaleFactors = { - SI_GIGA: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1e9'); - this.prefix = "giga"; - this.suffix = ""; - this.symbol = "G"; - } - }, - SI_MEGA: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1e6'); - this.prefix = "mega"; - this.suffix = ""; - this.symbol = "M"; - } - }, - SI_KILO: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1e3'); - this.prefix = "kilo"; - this.suffix = ""; - this.symbol = "k"; - } - }, - SI_BASE: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1'); - this.prefix = ""; - this.suffix = ""; - this.symbol = ""; - } - }, - SI_CENTI: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1e-2'); - this.prefix = "centi"; - this.suffix = ""; - this.symbol = "c"; - } - }, - SI_MILLI: new class { - constructor() { - this.scale = scales.SI; - this.multiplier = new Decimal('1e-3'); - this.prefix = "milli"; - this.suffix = ""; - this.symbol = "m"; - } - }, - TIME_MILLI: new class { - constructor() { - this.scale = scales.TIME_SECONDS; - this.multiplier = new Decimal('1e-3'); - this.prefix = "milli"; - this.suffix = ""; - this.symbol = "m"; - } - }, - TIME_BASE: new class { - constructor() { - this.scale = scales.TIME_SECONDS; - this.multiplier = new Decimal('1'); - this.prefix = ""; - this.suffix = ""; - this.symbol = ""; - } - }, - TIME_MINUTE: new class { - constructor() { - this.scale = scales.TIME_SECONDS; - this.multiplier = new Decimal('60'); - this.prefix = ""; - this.suffix = ""; - this.symbol = ""; - } - }, - TIME_HOUR: new class { - constructor() { - this.scale = scales.TIME_SECONDS; - this.multiplier = new Decimal('3600'); - this.prefix = ""; - this.suffix = ""; - this.symbol = ""; - } - }, - TIME_DAY: new class { - constructor() { - this.scale = scales.TIME_SECONDS; - this.multiplier = new Decimal('86400'); - this.prefix = ""; - this.suffix = ""; - this.symbol = ""; - } - }, -}; -export const units = { - ANY: new Unit("any", "", scales.NONE), - WATT: new Unit("watt", "W", scales.SI), - VOLT: new Unit("volt", "V", scales.SI), - AMPERE: new Unit("ampere", "A", scales.SI), - OHM: new Unit("ohm", "Ω", scales.SI), - FARAD: new Unit("farad", "F", scales.SI), - METER: new Unit("meter", "m", scales.SI), - INCH: new Unit("inch", "in", scales.IMPERIAL_DISTANCE), - POUND: new Unit("pound", "p", scales.IMPERIAL_WEIGHT), -}; -export function scaleToBase(value, scaleFactor) { - return value.times(scaleFactor.multiplier); -} -export function scaleFromBase(value, scaleFactor) { - return value.dividedBy(scaleFactor.multiplier); -} -let areUnitsInitialized = false; -export function initUnits() { - if (!areUnitsInitialized) { - console.debug("Initializing scales & units..."); - Object.keys(scaleFactors).forEach(scaleFactorKey => { - const scaleFactor = scaleFactors[scaleFactorKey]; - scaleFactor.scale.scaleFactors.push(scaleFactor); - }); - areUnitsInitialized = true; - } -} -//# sourceMappingURL=units.js.map \ No newline at end of file diff --git a/tools/items/formula-wizard/src/units.min.js b/tools/items/formula-wizard/src/units.min.js deleted file mode 100644 index 2164cf3..0000000 --- a/tools/items/formula-wizard/src/units.min.js +++ /dev/null @@ -1 +0,0 @@ -import{Decimal as s}from"../../../../resources/DecimalJs/10.4.3/decimal.min.mjs";import{localize as t}from"./lang.js";export class Unit{constructor(s,i,e){this.name=t("unit."+s+".name"),this.symbol=i,this.scale=e,this.description=t("unit."+s+".desc")}}export const scales={SI:new class{constructor(){this.formatName=s=>s.symbol,this.formatSymbol=s=>s.symbol,this.scaleFactors=[]}},IMPERIAL_DISTANCE:new class{constructor(){this.formatName=s=>s.symbol,this.formatSymbol=s=>s.symbol,this.scaleFactors=[]}},IMPERIAL_WEIGHT:new class{constructor(){this.formatName=s=>s.symbol,this.formatSymbol=s=>s.symbol,this.scaleFactors=[]}},TIME_SECONDS:new class{constructor(){this.formatName=s=>s.symbol,this.formatSymbol=s=>s.symbol,this.scaleFactors=[]}},NONE:new class{constructor(){this.formatName=s=>s.name,this.formatSymbol=s=>s.symbol,this.scaleFactors=[]}}};export const scaleFactors={SI_GIGA:new class{constructor(){this.scale=scales.SI,this.multiplier=new s("1e9"),this.prefix="giga",this.suffix="",this.symbol="G"}},SI_MEGA:new class{constructor(){this.scale=scales.SI,this.multiplier=new s("1e6"),this.prefix="mega",this.suffix="",this.symbol="M"}},SI_KILO:new class{constructor(){this.scale=scales.SI,this.multiplier=new s("1e3"),this.prefix="kilo",this.suffix="",this.symbol="k"}},SI_BASE:new class{constructor(){this.scale=scales.SI,this.multiplier=new s("1"),this.prefix="",this.suffix="",this.symbol=""}},SI_CENTI:new class{constructor(){this.scale=scales.SI,this.multiplier=new s("1e-2"),this.prefix="centi",this.suffix="",this.symbol="c"}},SI_MILLI:new class{constructor(){this.scale=scales.SI,this.multiplier=new s("1e-3"),this.prefix="milli",this.suffix="",this.symbol="m"}},TIME_MILLI:new class{constructor(){this.scale=scales.TIME_SECONDS,this.multiplier=new s("1e-3"),this.prefix="milli",this.suffix="",this.symbol="m"}},TIME_BASE:new class{constructor(){this.scale=scales.TIME_SECONDS,this.multiplier=new s("1"),this.prefix="",this.suffix="",this.symbol=""}},TIME_MINUTE:new class{constructor(){this.scale=scales.TIME_SECONDS,this.multiplier=new s("60"),this.prefix="",this.suffix="",this.symbol=""}},TIME_HOUR:new class{constructor(){this.scale=scales.TIME_SECONDS,this.multiplier=new s("3600"),this.prefix="",this.suffix="",this.symbol=""}},TIME_DAY:new class{constructor(){this.scale=scales.TIME_SECONDS,this.multiplier=new s("86400"),this.prefix="",this.suffix="",this.symbol=""}}};export const units={ANY:new Unit("any","",scales.NONE),WATT:new Unit("watt","W",scales.SI),VOLT:new Unit("volt","V",scales.SI),AMPERE:new Unit("ampere","A",scales.SI),OHM:new Unit("ohm","Ω",scales.SI),FARAD:new Unit("farad","F",scales.SI),METER:new Unit("meter","m",scales.SI),INCH:new Unit("inch","in",scales.IMPERIAL_DISTANCE),POUND:new Unit("pound","p",scales.IMPERIAL_WEIGHT)};export function scaleToBase(s,t){return s.times(t.multiplier)}export function scaleFromBase(s,t){return s.dividedBy(t.multiplier)}let i=!1;export function initUnits(){i||(console.debug("Initializing scales & units..."),Object.keys(scaleFactors).forEach((s=>{const t=scaleFactors[s];t.scale.scaleFactors.push(t)})),i=!0)} \ No newline at end of file