[
  {
    "path": ".github/FUNDING.yml",
    "content": "custom: ['http://sampler.dev/sponsor']\n"
  },
  {
    "path": ".gitignore",
    "content": "*.dll\n*.so\n*.dylib\n*.test\n*.out\n*.db\n.idea/\n*.iml\n*.iws"
  },
  {
    "path": ".travis.yml",
    "content": "language: go\ngo:\n  - 1.12.x\n  - master\nos:\n  - linux\n  - osx\naddons:\n  apt:\n    packages:\n      - libasound2-dev\ndist: trusty\nsudo: false\ninstall: true\nscript:\n  - env GO111MODULE=on go build\n  - env GO111MODULE=on go test -v ./...\n"
  },
  {
    "path": "Dockerfile",
    "content": "FROM ubuntu:focal\n\nENV Sampler=/usr/local/bin/sampler\n\nRUN apt-get update && apt-get upgrade --yes && apt-get install libasound-dev wget --yes \\\n  && wget https://github.com/sqshq/sampler/releases/download/v1.1.0/sampler-1.1.0-linux-amd64 -O $Sampler \\\n  && chmod +x $Sampler\n  \nENTRYPOINT [\"sampler\"]\n"
  },
  {
    "path": "LICENSE.md",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>."
  },
  {
    "path": "README.md",
    "content": "# Sampler. Visualization for any shell command.\n[![Build Status](https://travis-ci.com/sqshq/sampler.svg?token=LdyRhxxjDFnAz1bJg8fq&branch=master)](https://travis-ci.com/sqshq/sampler) [![Go Report Card](https://goreportcard.com/badge/github.com/sqshq/sampler)](https://goreportcard.com/report/github.com/sqshq/sampler)\n\nSampler is a tool for shell commands execution, visualization and alerting. Configured with a simple YAML file.\n\n![sampler](https://user-images.githubusercontent.com/6069066/56404396-70b14d00-6234-11e9-93cd-54461bf40c96.gif)\n\n## Why do I need it?\nOne can sample any dynamic process right from the terminal — observe changes in the database, monitor MQ in-flight messages,  trigger a deployment script and get notification when it's done. \n\nIf there is a way to get a metric using a shell command, then it can be visualized with Sampler momentarily.\n\n## Installation\n\n### macOS\n\n[HomeBrew](https://brew.sh):\n```bash\nbrew install sampler\n```\n\n[MacPorts](https://www.macports.org):\n```bash\nsudo port install sampler\n```\n\nor\n```bash\nsudo curl -Lo /usr/local/bin/sampler https://github.com/sqshq/sampler/releases/download/v1.1.0/sampler-1.1.0-darwin-amd64\nsudo chmod +x /usr/local/bin/sampler\n```\n\n### Linux\n```bash\nsudo wget https://github.com/sqshq/sampler/releases/download/v1.1.0/sampler-1.1.0-linux-amd64 -O /usr/local/bin/sampler\nsudo chmod +x /usr/local/bin/sampler\n```\nNote: `libasound2-dev` system library is required to be installed for Sampler to play a [trigger](https://github.com/sqshq/sampler#triggers) sound tone. Usually the library is in place, but if not - you can install it with your favorite package manager, e.g `apt install libasound2-dev`\n#### Packaging status\n- [Fedora](https://apps.fedoraproject.org/packages/golang-github-sqshq-sampler) `sudo dnf install golang-github-sqshq-sampler` (F31+)\n- [Arch](https://aur.archlinux.org/packages/sampler) `yay -S sampler`\n### Windows (experimental)\nRecommended to use with advanced console emulators, e.g. [Cmder](https://cmder.app/)\n\nVia [Chocolatey](https://chocolatey.org/docs)\n```powershell\nchoco install sampler\n```\nor\n\n[Download .exe](https://github.com/sqshq/sampler/releases/download/v1.1.0/sampler-1.1.0-windows-amd64.exe)\n\n### Docker\n\n```\n# Create a configuration file\nvim config.yml\n\n# Build the container image\ndocker build --tag sampler .\n\n# Run a container\ndocker run --interactive --tty --volume $(pwd)/config.yml:/root/config.yml sampler --config /root/config.yml\n```\n\n## Usage\nYou specify shell commands, Sampler executes them with a required rate. The output is used for visualization.\n\nUsing Sampler is basically a 3-step process:\n- Define your shell commands in a YAML configuration file\n- Run `sampler -c config.yml`\n- Adjust components size and location on UI\n\n## But there are so many monitoring systems already\nSampler is by no means an alternative to full-scale monitoring systems, but rather an easy to setup development tool.\n\nIf spinning up and configuring [Prometheus with Grafana](https://prometheus.io) is complete overkill for you task, Sampler might be the right solution. No servers, no databases, no deploy - you specify shell commands, and it just works.\n\n## Then it should be installed on every server I monitor?\nNo, you can run Sampler on local, but still gather telemetry from multiple remote machines. Any visualization might have `init` command, where you can ssh to a remote server. See the [SSH example](https://github.com/sqshq/sampler#ssh)\n\n## Contents\n\n- [Components](#components)\n  - [Runchart](#runchart)\n  - [Sparkline](#sparkline)\n  - [Barchart](#barchart)\n  - [Gauge](#gauge)\n  - [Textbox](#textbox)\n  - [Asciibox](#asciibox)\n- [Bells and whistles](#bells-and-whistles)\n  - [Triggers (conditional actions)](#triggers)\n  - [Interactive shell (database interaction, remote server access, etc)](#interactive-shell-support)\n  - [Variables](#variables)\n  - [Color theme](#color-theme)\n- [Real-world recipes (contributions welcome!)](#real-world-recipes)\n  - [Databases (MySQL, PostgreSQL, MongoDB, Neo4j)](#databases)\n  - [Kafka](#kafka)\n  - [Docker](#docker)\n  - [SSH](#ssh)\n  - [JMX](#jmx)\n\n## Components\nThe following is a list of configuration examples for each component type, with macOS compatible sampling scripts. \n\n### Runchart\n![runchart](https://user-images.githubusercontent.com/6069066/59168666-aff96d00-8b04-11e9-99b6-34d8bae37bd2.png)\n```yml\nruncharts:\n  - title: Search engine response time\n    rate-ms: 500        # sampling rate, default = 1000\n    scale: 2            # number of digits after sample decimal point, default = 1\n    legend:\n      enabled: true     # enables item labels, default = true\n      details: false    # enables item statistics: cur/min/max/dlt values, default = true\n    items:\n      - label: GOOGLE\n        sample: curl -o /dev/null -s -w '%{time_total}'  https://www.google.com\n        color: 178      # 8-bit color number, default one is chosen from a pre-defined palette\n      - label: YAHOO\n        sample: curl -o /dev/null -s -w '%{time_total}'  https://search.yahoo.com\n      - label: BING\n        sample: curl -o /dev/null -s -w '%{time_total}'  https://www.bing.com\n```\n### Sparkline\n![sparkline](https://user-images.githubusercontent.com/6069066/59167746-de754900-8b00-11e9-9305-c9a4176634d2.png)\n```yml\nsparklines:\n  - title: CPU usage\n    rate-ms: 200\n    scale: 0\n    sample: ps -A -o %cpu | awk '{s+=$1} END {print s}'\n  - title: Free memory pages\n    rate-ms: 200\n    scale: 0\n    sample: memory_pressure | grep 'Pages free' | awk '{print $3}'\n```\n### Barchart\n![barchart](https://user-images.githubusercontent.com/6069066/59167751-de754900-8b00-11e9-8d01-efd04ae1eec6.png)\n```yml\nbarcharts:\n  - title: Local network activity\n    rate-ms: 500        # sampling rate, default = 1000\n    scale: 0            # number of digits after sample decimal point, default = 1\n    items:\n      - label: UDP bytes in\n        sample: nettop -J bytes_in -l 1 -m udp | awk '{sum += $4} END {print sum}'\n      - label: UDP bytes out\n        sample: nettop -J bytes_out -l 1 -m udp | awk '{sum += $4} END {print sum}'\n      - label: TCP bytes in\n        sample: nettop -J bytes_in -l 1 -m tcp | awk '{sum += $4} END {print sum}'\n      - label: TCP bytes out\n        sample: nettop -J bytes_out -l 1 -m tcp | awk '{sum += $4} END {print sum}'\n```\n### Gauge\n![gauge](https://user-images.githubusercontent.com/6069066/59318799-4c06ae00-8c96-11e9-868a-7fef803f3739.png)\n```yml\ngauges:\n  - title: Minute progress\n    rate-ms: 500        # sampling rate, default = 1000\n    scale: 2            # number of digits after sample decimal point, default = 1\n    percent-only: false # toggle display of the current value, default = false\n    color: 178          # 8-bit color number, default one is chosen from a pre-defined palette\n    cur:\n      sample: date +%S  # sample script for current value\n    max:\n      sample: echo 60   # sample script for max value\n    min:\n      sample: echo 0    # sample script for min value\n  - title: Year progress\n    cur:\n      sample: date +%j\n    max:\n      sample: echo 365\n    min:\n      sample: echo 0\n```\n### Textbox\n![textbox](https://user-images.githubusercontent.com/6069066/59168949-192db000-8b06-11e9-900b-0e92ff494f62.png)\n```yml\ntextboxes:\n  - title: Local weather\n    rate-ms: 10000      # sampling rate, default = 1000\n    sample: curl wttr.in?0ATQF\n    border: false       # border around the item, default = true\n    color: 178          # 8-bit color number, default is white\n  - title: Docker containers stats\n    rate-ms: 500\n    sample: docker stats --no-stream --format \"table {{.Name}}\\t{{.CPUPerc}}\\t{{.MemUsage}}\\t{{.PIDs}}\"\n```\n### Asciibox\n![asciibox](https://user-images.githubusercontent.com/6069066/59169283-aa515680-8b07-11e9-8beb-716a387aed1b.png)\n```yml\nasciiboxes:\n  - title: UTC time\n    rate-ms: 500        # sampling rate, default = 1000\n    font: 3d            # font type, default = 2d\n    border: false       # border around the item, default = true    \n    color: 43           # 8-bit color number, default is white\n    sample: env TZ=UTC date +%r\n```\n\n## Bells and whistles\n\n### Triggers\nTriggers allow to perform conditional actions, like visual/sound alerts or an arbitrary shell command.\nThe following examples illustrate the concept.\n\n#### Clock gauge, which shows minute progress and announces current time at the beginning of each minute\n\n```yml\ngauges:\n  - title: MINUTE PROGRESS\n    position: [[0, 18], [80, 0]]  \n    cur:\n      sample: date +%S\n    max:\n      sample: echo 60\n    min:\n      sample: echo 0\n    triggers:\n      - title: CLOCK BELL EVERY MINUTE\n        condition: '[ $label == \"cur\" ] && [ $cur -eq 0 ] && echo 1 || echo 0'  # expects \"1\" as TRUE indicator\n        actions:\n          terminal-bell: true  # standard terminal bell, default = false\n          sound: true    # NASA quindar tone, default = false\n          visual: false  # notification with current value on top of the component area, default = false\n          script: say -v samantha `date +%I:%M%p`  # an arbitrary script, which can use $cur, $prev and $label variables\n```\n\n#### Search engine latency chart, which alerts user when latency exceeds a threshold\n\n```yml\nruncharts:\n  - title: SEARCH ENGINE RESPONSE TIME (sec)\n    rate-ms: 200\n    items:\n      - label: GOOGLE\n        sample: curl -o /dev/null -s -w '%{time_total}'  https://www.google.com\n      - label: YAHOO\n        sample: curl -o /dev/null -s -w '%{time_total}'  https://search.yahoo.com     \n    triggers:\n      - title: Latency threshold exceeded\n        condition: echo \"$prev < 0.3 && $cur > 0.3\" |bc -l  # expects \"1\" as TRUE indicator\n        actions:\n          terminal-bell: true  # standard terminal bell, default = false\n          sound: true   # NASA quindar tone, default = false\n          visual: true  # visual notification on top of the component area, default = false\n          script: 'say alert: ${label} latency exceeded ${cur} second' # an arbitrary script, which can use $cur, $prev and $label variables\n```\n\n### Interactive shell support\nIn addition to the `sample` command, one can specify `init` command (executed only once before sampling) and `transform` command (to post-process `sample` command output). That covers interactive shell use case, e.g. to establish connection to a database only once, and then perform polling within interactive shell session.\n\n#### Basic mode\n```yml\ntextboxes:\n  - title: MongoDB polling\n    rate-ms: 500\n    init: mongo --quiet --host=localhost test # executes only once to start the interactive session\n    sample: Date.now();                       # executes with a required rate, in scope of the interactive session\n    transform: echo result = $sample          # executes in scope of local session, $sample variable is available for transformation\n```\n\n#### PTY mode\nIn some cases interactive shell won't work, because its stdin is not a terminal. We can fool it, using PTY mode:\n```yml\ntextboxes:\n  - title: Neo4j polling\n    pty: true  # enables pseudo-terminal mode, default = false\n    init: cypher-shell -u neo4j -p pwd --format plain\n    sample: RETURN rand();\n    transform: echo \"$sample\" | tail -n 1\n  - title: Top on a remote server\n    pty: true  # enables pseudo-terminal mode, default = false\n    init: ssh -i ~/user.pem ec2-user@1.2.3.4\n    sample: top    \n```\n\n#### Multistep init\nIt is also possible to execute multiple init commands one after another, before you start sampling.\n```yml\ntextboxes:\n  - title: Java application uptime\n    multistep-init:\n      - java -jar jmxterm-1.0.0-uber.jar\n      - open host:port # or local PID\n      - bean java.lang:type=Runtime\n    sample: get Uptime\n```    \n\n### Variables\nIf the configuration file contains repeated patterns, they can be extracted into the `variables` section.\nAlso variables can be specified using `-v`/`--variable` flag on startup, and any system environment variables will also be available in the scripts.\n\n```yml\nvariables:\n    mongoconnection: mongo --quiet --host=localhost test\nbarcharts:\n  - title: MongoDB documents by status\n    items:\n      - label: IN_PROGRESS\n        init: $mongoconnection\n        sample: db.getCollection('events').find({status:'IN_PROGRESS'}).count()\n      - label: SUCCESS\n        init: $mongoconnection\n        sample: db.getCollection('events').find({status:'SUCCESS'}).count()\n      - label: FAIL\n        init: $mongoconnection\n        sample: db.getCollection('events').find({status:'FAIL'}).count()\n```\n\n### Color theme\n![light-theme](https://user-images.githubusercontent.com/6069066/59959405-994c0200-9484-11e9-856b-c4d18716e1de.png)\n```yml\ntheme: light # default = dark\nsparklines:\n  - title: CPU usage\n    sample: ps -A -o %cpu | awk '{s+=$1} END {print s}'\n```\n\n## Real-world recipes\n### Databases\nThe following are different database connection examples. Interactive shell (init script) usage is recommended to establish connection only once and then reuse it during sampling.\n\n<details><summary>MySQL</summary>\n\n```yml\n# prerequisite: installed mysql shell\n\nvariables:\n  mysql_connection: mysql -u root -s --database mysql --skip-column-names\nsparklines:  \n  - title: MySQL (random number example)\n    pty: true\n    init: $mysql_connection\n    sample: select rand();\n```\n\n</details>\n\n<details><summary>PostgreSQL</summary>\n\n```yml\n# prerequisite: installed psql shell\n\nvariables:\n  PGPASSWORD: pwd\n  postgres_connection: psql -h localhost -U postgres --no-align --tuples-only\nsparklines:\n  - title: PostgreSQL (random number example)\n    init: $postgres_connection\n    sample: select random();\n```\n\n</details>\n\n<details><summary>MongoDB</summary>\n\n```yml\n# prerequisite: installed mongo shell\n\nvariables:\n  mongo_connection: mongo --quiet --host=localhost test\nsparklines:\n  - title: MongoDB (random number example)\n    init: $mongo_connection\n    sample: Math.random();\n```\n\n</details>\n\n<details><summary>Neo4j</summary>\n\n```yml\n# prerequisite: installed cypher shell\n\nvariables:\n  neo4j_connection: cypher-shell -u neo4j -p pwd --format plain\nsparklines:\n  - title: Neo4j (random number example)\n    pty: true\n    init: $neo4j_connection\n    sample: RETURN rand();\n    transform: echo \"$sample\" | tail -n 1\n```\n\n</details>\n\n### Kafka\n\n<details><summary>Kafka lag per consumer group</summary>\n\n```yml\nvariables:\n  kafka_connection: $KAFKA_HOME/bin/kafka-consumer-groups --bootstrap-server localhost:9092\nruncharts:\n  - title: Kafka lag per consumer group\n    rate-ms: 5000\n    scale: 0\n    items:\n      - label: A->B\n        sample: $kafka_connection --group group_a --describe | awk 'NR>1 {sum += $5} END {print sum}'\n      - label: B->C\n        sample: $kafka_connection --group group_b --describe | awk 'NR>1 {sum += $5} END {print sum}'\n      - label: C->D\n        sample: $kafka_connection --group group_c --describe | awk 'NR>1 {sum += $5} END {print sum}'\n```\n\n</details>\n\n### Docker\n\n<details><summary>Docker containers stats (CPU, MEM, O/I)</summary>\n\n```yml\ntextboxes:\n  - title: Docker containers stats\n    sample: docker stats --no-stream --format \"table {{.Name}}\\t{{.CPUPerc}}\\t{{.MemPerc}}\\t{{.MemUsage}}\\t{{.NetIO}}\\t{{.BlockIO}}\\t{{.PIDs}}\"\n```\n\n</details>\n\n### SSH\n\n<details><summary>TOP command on a remote server</summary>\n\n```yml\nvariables:\n  sshconnection: ssh -i ~/my-key-pair.pem ec2-user@1.2.3.4\ntextboxes:\n  - title: SSH\n    pty: true\n    init: $sshconnection\n    sample: top\n```\n\n</details>\n\n### JMX\n\n<details><summary>Java application uptime example</summary>\n\n```yml\n# prerequisite: download [jmxterm jar file](https://docs.cyclopsgroup.org/jmxterm)\n\ntextboxes:\n  - title: Java application uptime\n    multistep-init:\n      - java -jar jmxterm-1.0.0-uber.jar\n      - open host:port # or local PID\n      - bean java.lang:type=Runtime\n    sample: get Uptime\n    transform: echo $sample | tr -dc '0-9' | awk '{printf \"%.1f min\", $1/1000/60}'\n```\n\n</details>\n"
  },
  {
    "path": "asset/bindata.go",
    "content": "// Code generated by go-bindata. (@generated) DO NOT EDIT.\n// sources:\n// 3d.flf\n// 2d.flf\n// quindar-tone.mp3\npackage asset\n\nimport (\n\t\"bytes\"\n\t\"compress/gzip\"\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"time\"\n)\n\nfunc bindataRead(data []byte, name string) ([]byte, error) {\n\tgz, err := gzip.NewReader(bytes.NewBuffer(data))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Read %q: %v\", name, err)\n\t}\n\n\tvar buf bytes.Buffer\n\t_, err = io.Copy(&buf, gz)\n\tclErr := gz.Close()\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Read %q: %v\", name, err)\n\t}\n\tif clErr != nil {\n\t\treturn nil, err\n\t}\n\n\treturn buf.Bytes(), nil\n}\n\ntype asset struct {\n\tbytes []byte\n\tinfo  os.FileInfo\n}\n\ntype bindataFileInfo struct {\n\tname    string\n\tsize    int64\n\tmode    os.FileMode\n\tmodTime time.Time\n}\n\nfunc (fi bindataFileInfo) Name() string {\n\treturn fi.name\n}\nfunc (fi bindataFileInfo) Size() int64 {\n\treturn fi.size\n}\nfunc (fi bindataFileInfo) Mode() os.FileMode {\n\treturn fi.mode\n}\nfunc (fi bindataFileInfo) ModTime() time.Time {\n\treturn fi.modTime\n}\nfunc (fi bindataFileInfo) IsDir() bool {\n\treturn false\n}\nfunc (fi bindataFileInfo) Sys() interface{} {\n\treturn nil\n}\n\nvar _data3dFlf = []byte(\"\\x1f\\x8b\\x08\\x00\\x00\\x00\\x00\\x00\\x00\\xff\\xb4\\x5a\\x5d\\x6b\\x5b\\x49\\x0f\\xbe\\xf7\\xaf\\xd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3\\x05\\x06\\x08\\x79\\x14\\x07\\x21\\x8d\\x80\\x87\\xf1\\x91\\x00\\x81\\x42\\x1a\\x41\\xc0\\x40\\x21\\x2f\\x13\\x90\\xd0\\x2c\\x58\\x2f\\xed\\x56\\xb7\\x00\\x14\\xe2\\x6a\\x19\\x03\\x09\\x91\\x70\\x99\\x1f\\x5f\\xe6\\xe7\\x97\\x79\\x2d\\x99\\x95\\x85\\x1d\\x4a\\x6f\\x12\\x67\\x05\\x36\\x7e\\x49\\x19\\x38\\x7d\\x12\\xb7\\x11\\x07\\xf1\\x37\\x49\\x15\\x90\\x36\\xf9\\xfb\\x0d\\xa5\\x95\\x30\\xc4\\xbf\\x4b\\xdf\\x27\\x99\\x91\\x30\\x6f\\x55\\x84\\xe4\\xcd\\x7a\\x58\\xe8\\x4d\\x8b\\x62\\x45\\x78\\x51\\x44\\xc0\\x86\\xa8\\x0b\\xe5\\xf3\\xc0\\x5b\\x89\\x7b\\x24\\x82\\x90\\x55\\x92\\xb5\\x9d\\x37\\x01\\x5d\\x20\\x60\\x35\\x77\\x81\\x8a\\xf2\\x59\\xfd\\x05\\x2c\\xfe\\x93\\x84\\x8c\\xeb\\x23\\x20\\xcb\\x88\\x3c\\x91\\x6d\\xe6\\x09\\xcf\\xd2\\x84\\xb2\\xf8\\x90\\xff\\x96\\x01\\xd2\\xa4\\x3a\\xe1\\xbe\\xb0\\xac\\xf3\\xa2\\x72\\x7c\\x8e\\x1a\\x0c\\x3c\\x7b\\xc6\\x38\\x7a\\x96\\x07\\x03\\x22\\x44\\xf9\\x31\\xc9\\x19\\xff\\x34\\x6c\\xd6\\x00\\x2b\\xba\\x5a\\xc0\\x73\\x56\\x01\\x61\\xd6\\x76\\x40\\x9e\\xd4\\x80\\x3d\\xf8\\x61\\x1b\\x8e\\x16\\x95\\x21\\x93\\x1d\\x89\\x71\\x19\\xcb\\x5a\\x0e\\x5a\\xae\\xb3\\xe1\\x64\\x0c\\xf9\\x53\\x6c\\x64\\x71\\x0c\\xd0\\x62\\xe3\\x7c\\x45\\x9c\\xa5\\x53\\x6f\\xe9\\x02\\xf1\\x39\\x75\\xa1\\xb2\\x18\\x3b\\xac\\xb6\\xcf\\x96\\x11\\xe2\\xbf\\x79\\xa9\\x2e\\x8e\\xb3\\xe3\\x75\\x21\\xee\\x21\\x1f\\x54\\x20\\x3e\\x96\\x6a\\xf1\\x6a\\xfb\\x95\\x27\\x80\\xba\\x41\\x07\\x0d\\x88\\x0f\\xac\\x21\\x9e\\x80\\x38\\x40\\x0b\\xad\\xb3\\x7e\\x6b\\xfa\\x4e\\xf9\\x6e\\x5c\\x81\\xc9\\x49\\x24\\xbd\\x50\\x36\\x6e\\xf6\\xbf\\xe8\\x5d\\x11\\x20\\x9e\\x6f\\xb2\\x73\\x06\\x30\\x04\\x33\\x07\\x4c\\x3e\\xaa\\xfe\\xcf\\x30\\x51\\x4d\\xd1\\x06\\xf2\\xf9\\xf3\\xb7\\x23\\x47\\xe0\\x86\\x94\\x7f\\x64\\xaf\\xa4\\x5b\\x4d\\xc6\\x78\\x78\\x85\\xc3\\x5b\\xe3\\x05\\xd1\\x7d\\x2b\\x4b\\x10\\x15\\x1f\\x2d\\xfe\\x99\\x8f\\x3c\\xfb\\xb3\\xf1\\xe5\\xec\\xa0\\x71\\xd1\\x3c\\x98\\xb2\\x62\\x73\\x34\\x42\\x40\\xac\\x28\\x14\\xb6\\x0f\\x10\\x0c\\xe1\\x07\\x3e\\x90\\xa0\\xec\\x1f\\x15\\x20\\x01\\x20\\x8d\\x0f\\x31\\xb1\\x38\\x4f\\xde\\x75\\x53\\x2c\\x22\\x59\\x99\\xba\\x0d\\x92\\x6e\\x81\\xed\\x40\\x62\\x4e\\x6d\\x15\\x7d\\xb3\\x18\\x42\\x25\\x22\\x2b\\x6b\\x61\\x5b\\x0a\\x6c\\x97\\xf9\\x00\\x10\\x01\\x95\\xf8\\xe2\\x98\\x09\\x57\\x0e\\xde\\xb0\\xd0\\x2c\\xd4\\x11\\x0d\\x53\\xd8\\xa8\\x86\\x91\\x90\\x02\\xad\\x88\\x55\\x12\\x03\\xcf\\x39\\x1a\\x9e\\x8a\\xb0\\x32\\x93\\xa3\\x4c\\x31\\x48\\x81\\xc4\\xc7\\x6b\\x27\\x9f\\xa3\\x61\\xf6\\x10\\x41\\x8d\\x73\\x63\\x40\\x69\\xdb\\x8c\\x1a\\x95\\xdf\\xb1\\x78\\x22\\x6c\\x46\\x65\\x61\\x35\\x89\\x98\\xa1\\x61\\xaa\\xcf\\xd5\\xd8\\x30\\x89\\x27\\x24\\x99\\x13\\xa8\\x0a\\x7e\\xa6\\x86\\x45\\x5a\\x25\\x04\\x48\\xcb\\xe5\\xc7\\xb1\\xc1\\x46\\xe2\\x68\\x13\\x7f\\xc5\\xd4\\x53\\x78\\x60\\x53\\x47\\x5d\\x3b\\x46\\xbf\\x21\\xa0\\x43\\xd6\\x04\\xd6\\x5f\\xad\\x35\\xad\\x81\\xe0\\xc5\\xac\\x69\\x26\\x6a\\x5a\\xb9\\x15\\x96\\x40\\xa2\\x16\\x05\\x15\\xc4\\x61\\x75\\xed\\x5e\\xf6\\x30\\xc4\\x12\\xe5\\x53\\x89\\x86\\x92\\xc4\\xb0\\xcb\\x48\\x68\\xd2\\xb0\\xd4\\x7b\\xee\\xb8\\x85\\x24\\xb1\\x0a\\x12\\x42\\xeb\\x85\\x48\\x79\\x01\\x98\\x7e\\xd3\\x20\\x2e\\xb7\\x02\\x58\\xb1\\x22\\xba\\xf4\\x9b\\x62\\x74\\x0c\\xf7\\xcf\\x12\\xed\\x27\\xe2\\xb1\\xd5\\x83\\x9a\\x96\\x0d\\x36\\x00\\x26\\xdc\\xa8\\xe0\\x12\\x88\\x94\\x8f\\x26\\xb5\\x3a\\x40\\x13\\x50\\x27\\x18\\x6e\\xf3\\x6b\\x80\\x75\\x25\\x6e\\x10\\x7b\\xc9\\x36\\x7b\\x20\\x3f\\xca\\x06\\x93\\xbd\\x2e\\xd1\\x49\\xe8\\x38\\xca\\x45\\x0f\\x91\\x8c\\xe5\\xb8\\xf2\\xa1\\x12\\x88\\x5c\\x2c\\xa1\\x2e\\x90\\xe0\\xc6\\x19\\x04\\xcd\\xff\\xc4\\x09\\x02\\x27\\x61\\x99\\xe9\\xf2\\x58\\xb4\\xd8\\x09\\xad\\x4f\\x90\\x9b\\xb0\\x1b\\x38\\x52\\xdd\\x38\\x56\\x85\\x94\\xb1\\x8b\\xc7\\x71\\x2c\\x55\\x86\\x33\\xae\\x90\\x68\\x76\\x46\\x26\\xed\\x12\\xe9\\x44\\x65\\x7d\\x70\\xc5\\x86\\x55\\x53\\xa0\\xcf\\xe1\\xd6\\x69\\x54\\xf1\\x20\\x16\\x51\\xcc\\xf2\\xd5\\x51\\x6d\\x22\\x02\\x86\\xd8\\x4a\\x69\\xf4\\xf2\\xa8\\x1b\\x2b\\x2b\\x50\\xd8\\xc0\\xcb\\xca\\x6a\\x30\\x0d\\x62\\xc1\\xc3\\x62\\x4a\\xd6\\x8e\\x8a\\x11\\x4d\\xe4\\x9d\\x47\\x48\\x16\\x36\\x64\\x25\\xc3\\xf6\\x1c\\xc9\\xc0\\x27\\x21\\x55\\x23\\x81\\x2a\\x87\\x01\\xe7\\x30\\xf0\\x12\\x0e\\x63\\xe0\\x89\\x6b\\x7b\\x61\\xfc\\xa4\\x48\\x79\\xd0\\x16\\x6b\\x71\\x9a\\xeb\\x12\\x89\\xdf\\x86\\x1e\\x4a\\xda\\x37\\x0b\\xbe\\x80\\x53\\x09\\xcd\\x84\\x25\\x8d\\xa5\\x22\\xa7\\xaf\\xec\\x8d\\xb6\\x07\\x94\\xed\\xc6\\x33\\x54\\x9d\\xb2\\x11\\x55\\x75\\x9b\\xe2\\x54\\x51\\x75\\x90\\xda\\xf4\\x74\\x55\\x97\\xef\\xb4\\xbe\\x03\\x5b\\x04\\x1b\\x7f\\x95\\x96\\xc2\\xd9\\x9e\\xe3\\xbf\\xc3\\x26\\x10\\x9a\\xbc\\x24\\xfd\\xb8\\xec\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e\\x2c\\x53\\x91\\x34\\x95\\x1c\\x44\\xe0\\x33\\x87\\xda\\x1e\\x7b\\x16\\xd9\\x3f\\x06\\x47\\x00\\xec\\xfe\\x8e\\xfa\\xc0\\x85\\x54\\xeb\\x0c\\xe0\\x48\\xcf\\xc6\\xd3\\x43\\x1e\\xa8\\x58\\xca\\xb2\\x9d\\x96\\x85\\x9d\\x8c\\xa5\\xf1\\xdc\\x49\\xe7\\xd9\\xb7\\xb3\\x47\\x3b\\xa1\\xb5\\x40\\x4c\\x58\\x85\\x52\\x60\\x90\\x52\\x8a\\x6f\\x67\\x6d\\xce\\x16\\xc8\\xb5\\x2c\\xc0\\x74\\x2c\\x08\\x85\\x38\\x03\\x62\\xac\\x61\\xf3\\x15\\x80\\xbb\\x5e\\x1a\\xba\\x5d\\x9a\\x04\\x3b\\xf8\\x47\\xa3\\x63\\xc5\\x4d\\x9b\\x28\\x4d\\x66\\x57\\xdc\\x97\\xda\\x7e\\xf4\\x52\\x23\\xe8\\xa5\\x06\\x9e\\x73\\xa9\\x31\\xb6\\x5f\\xdf\\x61\\x33\\xd7\\x54\\x9b\\x70\\x91\\xda\\x87\\xb9\\xd7\\x76\\x11\\x74\\xbf\\xbd\\x2c\\x66\\xcc\\xe4\\x86\\xb3\\x46\\xe9\\xad\\x25\\x6b\\xc8\\x90\\xc3\\x59\\x63\\x7b\\x52\\xd6\\xe8\\x47\\x12\\xe9\\xa4\\x7d\\x58\\x7a\\x87\\x7a\\xff\\x56\\x8e\\x61\\xbc\\x2f\\x61\\x94\\x54\\xdc\\xd2\\xd4\\x39\\xbe\\x1f\\x51\\xba\\x11\\xa4\\xbd\\x08\\x8c\\x23\\x98\\xf0\\xa1\\xe1\\x03\\xb4\\xdb\\xef\\x82\\x66\\x4b\\x47\\x6e\\x1f\\x44\\xe5\\xc3\\x5a\\x88\\xe9\\x5c\\x28\\xf9\\xf3\\x55\\x7d\\xf5\\x3b\\x75\\xdb\\x34\\xcf\\xae\\xc0\\xd9\\x15\\x0c\\x5d\\x7f\\x12\\x91\\x9e\\x3e\\xda\\x22\\x89\\x72\\x7c\\x73\\x76\\xe5\\x0d\\xcb\\x58\\x16\\x14\\xf6\\x04\\x32\\x57\\x73\\x2f\\x51\\x77\\xea\\xe7\\xa6\\xfc\\x13\\xbe\\xf1\\x71\\x5c\\x35\\xa8\\x0a\\xb4\\x8f\\x0f\\x9d\\xb9\\xe5\\x4f\\x65\\xcf\\xd0\\xbf\\x93\\xd7\\xb2\\xb2\\x14\\x95\\xa6\\xc0\\x12\\x3f\\x99\\xa1\\x2b\\x6c\\xec\\x1d\\xe6\\x2b\\x14\\x8e\\x26\\xec\\x94\\xab\\xe1\\x48\\xcc\\x55\\x58\\xd3\\xe8\\x40\\x7a\\x5d\\xc1\\xe7\\xaf\\xda\\x3b\\x18\\x11\\x46\\xb7\\xa2\\x1c\\x50\\x8a\\x9a\\x26\\x16\\x1b\\x5c\\x70\\x94\\xa4\\x10\\x8b\\xcb\\x5a\\x89\\x45\\xdc\\x79\\x59\\xcd\\xc0\\x57\\x85\\x83\\x18\\x1b\\x3c\\xae\\xc5\\x34\\x78\\x47\\xd2\\x44\\x61\\x39\\x28\\x34\\xc1\\x64\\x3a\\x60\\x1e\\x07\\x7c\\xd9\\x0f\\x6d\\xb5\\xa0\\x74\\x7d\\x5a\\x3d\\x38\\xc1\\xdf\\x8b\\xe9\\x0b\\xcb\\x89\\xab\\x08\\x3a\\x74\\x15\\x31\\xe0\\x7a\\x0b\\x20\\x7d\\x71\\xa2\\x6b\\xf2\\x7d\\xaf\\xee\\xbc\\xec\\xdb\\x33\\xdf\\x88\\xe7\\xfa\\x63\\x10\\x9a\\x6d\\x85\\x66\\xe3\\x66\\x73\\x63\\x7c\\xee\\x31\\xb8\\x84\\x4d\\xde\\x62\\xc9\\x4a\\xb6\\x3d\\x59\\x97\\x19\\x96\\xc4\\xd0\\x96\\xc2\\x07\\xad\\xa8\\x77\\xd4\\xe5\\x7d\\x12\\x6b\\x9e\\x5a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e\\xab\\xf6\\x5e\\x0f\\xe2\\x67\\x15\\x92\\x3e\\x59\\x8a\\x8e\\x91\\xd6\\xa0\\xbc\\xf0\\x91\\xea\\xf7\\xf6\\xe8\\x76\\x99\\xa2\\x17\\x70\\x87\\x5d\\x43\\x1b\\xe4\\xa3\\xdb\\x65\\x2e\\xa5\\xae\\x51\\xcd\\xdb\\x0e\\x18\\x46\\x2e\\x05\\x4f\\x40\\xad\\x3a\\xdd\\xd4\\x6b\\xce\\xe9\\x39\\xaf\\x68\\x45\\xbe\\x90\\x28\\x6c\\xe1\\x5f\\x66\\x53\\xd4\\xac\\xad\\x0a\\xf5\\xbf\\x00\\x00\\x00\\xff\\xff\\xb2\\x63\\x04\\xcd\\x51\\x2c\\x00\\x00\")\n\nfunc data3dFlfBytes() ([]byte, error) {\n\treturn bindataRead(\n\t\t_data3dFlf,\n\t\t\"3d.flf\",\n\t)\n}\n\nfunc data3dFlf() (*asset, error) {\n\tbytes, err := data3dFlfBytes()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tinfo := bindataFileInfo{name: \"3d.flf\", size: 11345, mode: os.FileMode(420), modTime: time.Unix(1550435406, 0)}\n\ta := &asset{bytes: bytes, info: info}\n\treturn a, nil\n}\n\nvar _data2dFlf = []byte(\"\\x1f\\x8b\\x08\\x00\\x00\\x00\\x00\\x00\\x00\\xff\\xb4\\x7d\\x6d\\x73\\xda\\x48\\xb6\\xff\\x7b\\x3e\\xc5\\x79\\x31\\xf5\\x0f\\xd4\\x3f\\xb8\\x8d\\x6c\\x63\\xbb\\x2a\\x9b\\x32\\x06\\xd9\\xd6\\x04\\x83\\x57\\x40\\x66\\x93\\xd1\\x54\\x0f\\x89\\x49\\x4c\\x0d\\x81\\x94\\x8d\\x77\\x6e\\xea\\xea\\x7e\\xf7\\x5b\\xea\\x67\\x75\\x9f\\x96\\x5a\\xce\\xde\\xd4\\xae\\xc1\\x18\\x9d\\x5f\\x9f\\xee\\x3e\\xe7\\x77\\x1e\\x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\\xeb\\x27\\xd7\\x44\\x6e\\x9a\\x4c\\xae\\x82\\xf2\\xc6\\xc5\\x64\\xd3\\x8e\\xc3\\x0e\\x6a\\x32\\xd9\\x2e\\x17\\x28\\x85\\x3a\\xf4\\x4f\\x69\\x76\\xd0\\x56\\x86\\xc7\\xa6\\x57\\x0c\\x36\\x13\\x9b\\x4a\\x9a\\xbd\\x36\\x68\\xc2\\x1c\\x9e\\x14\\x5a\\xfc\\x22\\xad\\x48\\x00\\xf0\\x4d\\xa1\\x67\\xc9\\xb3\\xa1\\xf9\\xce\\xc8\\xc1\\x70\\x06\\x75\\x1b\\x5a\\x38\\x1f\\x86\\x25\\x87\\x0f\\xd2\\xbc\\xe4\\x5f\\x33\\x9f\\x15\\x83\\x83\\xe7\\x38\\x1f\\x1c\\x59\\xaf\\x2b\\xa8\\x75\\x65\\xce\\xbb\\x8c\\x5c\\xe7\\x3f\\xc0\\x18\\x36\\x05\\x35\\x1a\\x21\\x86\\xe6\\x1e\\x9f\\x89\\xe9\\x2c\\xc3\\x09\\xd3\\x67\\xba\\xc8\\xa0\\xbf\\xe8\\x6a\\xca\\xfe\\x2e\\x22\\x11\\x11\\x8d\\x58\\xc3\\x16\\xc4\\x44\\x25\\x09\\x9a\\xb1\\x41\\x6e\\xe2\\x29\\x33\\x90\\xdc\\x20\\x99\\x93\\x42\\xa0\\x7b\\x97\\x81\\x44\\x5e\\x18\\x20\\x67\\xeb\\x57\\xdc\\xe8\\x72\\x38\\x10\\xcb\\x45\\x73\\x73\\x4b\\x29\\x0d\\xe5\\x22\\x60\\xef\\x6a\\x16\\x46\\xb2\\x59\\xce\\xf9\\x5a\\x0c\\x34\\x23\\x6a\\xcc\\xa0\\x83\\x35\\x28\\xcf\\x91\\x33\\xc3\\x99\\xd2\\x14\\x32\\x75\\x7d\\xa6\\x67\\x38\\x73\\xf0\\x7f\\x8a\\x0f\\xf1\\xfd\\x2c\\xed\\x07\\x34\\xa5\\xf9\\x76\\x55\\x20\\x72\\xc9\\x8a\\xc3\\x90\\xe1\\x0d\\x28\\x9d\\xbd\\x17\\x13\\xc5\\x68\\x59\\x30\\xa3\\x19\\xee\\xd5\\x88\\x96\\x42\\x63\\x00\\xd4\\x18\\xc2\\x66\\x9b\\xf2\\x7d\\x26\\x82\\xbd\\x4c\\xbb\\xde\\xe2\\x17\\x45\\x8a\\x19\\xbc\\x07\\x15\\xf5\\x65\\x16\\x31\\x96\\x04\\x95\\x65\\x59\\xe2\\x2c\\x89\\x96\\x50\\x57\\xae\\x21\\x5a\\x0a\\x55\\xe2\\x54\\x2c\\xae\\x1c\\xb3\\x6d\\x42\\x6c\\x44\\x6a\\x30\\xea\\xc2\\xf7\\x2a\\xd0\\xa9\\x0d\\xac\\xa8\\x0c\\x64\\x7c\\xf1\\x7f\\xc9\\xf4\\xa4\\xe5\\x71\\x67\\x9a\\xfb\\xe2\\xf2\\xbc\\xb8\\x46\\x4d\\x98\\x9a\\x2a\\x39\\x49\\x72\\x7a\\x32\\x35\\x31\\xb6\\x63\\x90\\xfb\\xc4\\x8d\\xe3\\x95\\x49\\x73\\x84\\x62\\xc2\\x19\\xef\\x67\\x7c\\x90\\x22\\x81\\x28\\xbf\\x20\\x21\\x7c\\xd5\\x3b\\x27\\x0e\\xb0\\x82\\x0c\\xe0\\x58\\x58\\xc6\\xa2\\xa5\\x51\\x91\\x0d\\x9a\\x64\\xdd\\x36\\x76\\xe9\\x6b\\xd4\\xdf\\x6b\\xcf\\xe7\\x44\\x7c\\x9a\\x5d\\x0f\\xd0\\x00\\x5b\\x03\\x6b\\xc6\\x91\\xb0\\x9a\\x59\\xad\\xa5\\x04\\xed\\xf5\\xa9\\x1c\\x5c\\xf0\\x80\\x51\\x4c\\xc8\\x94\\x07\\xf3\\x61\\xea\\x2f\\x2b\\x36\\x95\\x5c\\x2a\\x7d\\x9e\\x43\\x4d\\xa1\\xb3\\x2a\\xf6\\x88\\x0e\\x7e\\xea\\x66\\xd5\\xa0\\x08\\x84\\x45\\x75\\x94\\xe9\\x26\\xff\\x66\\x6e\\xc3\\x5e\\x65\\x9c\\x2a\\x86\\xa3\\x58\\x94\\xc8\\x1d\\x6b\\x0e\\x49\\xa0\\xdb\\xb4\\x09\\xca\\xfd\\x22\\x6c\\x69\\x0f\\x03\\x1d\\x4c\\x69\\x27\\xb3\\x09\\x33\\xd5\\xfe\\xd3\\x62\\x8c\\xb2\\xfa\\x16\\x49\\x22\\x21\\x32\\x34\\x9e\\x43\\x6b\\x9b\\xd8\\xbc\\x55\\x93\\x4e\\xd4\\x20\\x2b\\xde\\x3a\\xb0\\x18\\xf3\\x65\\xfb\\x86\\xfb\\xc9\\xf2\\xe6\\xa6\\xca\\xdf\\xbd\\x32\\xa3\\x56\\x85\\xe5\\x1a\\xd4\\x85\\x8e\\xbf\\xa4\\x11\\xca\\x1a\\x0c\\xdb\\x98\\xa5\\xcd\\x4d\\xf5\\xee\\x94\\x21\\xaa\\x69\\x15\\xc5\\x95\\x6e\\xa0\\x26\\x47\\x56\\x11\\x20\\x56\\x98\\x2c\\x04\\x10\\x07\\x23\\x2a\\xf4\\x62\\xe3\\xfa\\x92\\x88\\x92\\x94\\x92\\x20\\x4b\\x96\\xed\\x3e\\x10\\xea\\x7b\\x2b\\xcc\\x00\\x61\\xbc\\x46\\xfa\\x3b\\xde\\xc0\\x58\\x1e\\x2a\\x22\\x11\\x22\\xe8\\x4e\\xb2\\x9d\\x3d\\xdb\\x3c\\x93\\x54\\xd9\\x1a\\x27\\xb8\\x37\\xf0\\xa6\\x54\\x6b\\x53\\x95\\x28\\xaf\\x95\\x2a\\x5b\\x95\\x93\\x27\\x59\\xb1\\x24\\xe5\\x2d\\xbc\\x35\\x7e\\x67\\x99\\x98\\x60\\x39\\x92\\x73\\x9a\\x23\\x92\\xd9\\xf0\\x57\\x27\\x5e\\x6a\\xd3\\x0e\\x95\\x8e\\x89\\xd0\\xcc\\xb2\\xbf\\x02\\x01\\x09\\xf3\\x90\\x8b\\xcd\\x50\\xb3\\x2e\\x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8\\xea\\xb3\\xe1\\x62\\xec\\xf7\\x52\\xd2\\x49\\x71\\xa2\\x11\\x6b\\x98\\xfb\\xf6\\xc4\\xd9\\x29\\x00\\xf3\\xad\\x81\\x0e\\x4a\\x15\\xd3\\x32\\xb3\\x81\\xa0\\x5a\\x08\\xb2\\x89\\x60\\x86\\x2a\\x0c\\xe6\\x0c\\xe0\\xfd\\x62\\x7c\\x3d\\x48\\xe1\\x2a\\x1d\\x70\\x8e\\x99\\x4e\\x0a\\xf1\\x83\\x74\\x1e\\xa7\\x72\\x0b\\xc8\\x24\\xb3\\x70\\x05\\xcc\\x91\\xcb\\x34\\x83\\xb0\\x8f\\x44\\x99\\x86\\x00\\x29\\xf6\\x3c\\x57\\x88\\x17\\xfe\\xcb\\x8d\\x2c\\x85\\x7a\\x8e\\xa3\\xde\\x0c\\xc6\\x57\\x26\\xa4\\x46\\x94\\x59\\x53\\xce\\xfb\\x57\\x1d\\x89\\xa7\\x4b\\x4c\\x94\\x94\\x03\\x6e\\x05\\x76\\x7e\\xe8\\x82\\x31\\x0b\\x93\\x4a\\xce\\x54\\x2d\\x52\\xe9\\xc9\\x4c\\xce\\xd0\\x94\\x99\\x5e\\x49\\x57\\x5a\\xd6\\xd6\\xaf\\xaf\\x18\\x84\\x19\\x70\\xfd\\x73\\x11\\xcf\\xca\\xdc\\x22\\x3a\\x64\\xa2\\x69\\xa3\\x5a\\xee\\xbc\\x6a\\x96\\x59\\x79\\x44\\xef\\x3c\\x02\\x18\\x0f\\xe6\\xc9\\x04\\x86\\x83\\xbb\\x64\\x3e\\x18\\xc3\\x38\\x9e\\xcf\\xe3\\x14\\x06\\xf0\\x5b\\x32\\xbf\\x81\\xeb\\x74\\xf0\\x3e\\x6e\\x99\\x5d\\xbf\\x82\\x9a\\xa4\\x6b\\x0f\\x0a\\xdb\\x7b\\xe7\\x47\\xd5\\x18\\xcc\\xcf\\xc8\\x48\\x44\\x4a\\x26\\x0d\\x31\\x8e\\xab\\x31\\x86\\x49\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xea\\x28\\x3a\\xa9\\x42\\xc0\\x5d\\x6a\\x43\\x84\\x7e\\x15\\x42\\x88\\x43\\x0d\\x83\\x39\\xad\\x82\\xc1\\xdd\\x69\\x43\\x45\\xce\\xaa\\x10\\x02\\x9c\\x69\\x18\\xca\\x79\\x15\\x8a\\x9d\\x5b\\xc8\\x55\\x69\\xb7\\x3b\\xfa\\x64\\xe7\\xab\\x00\\x98\\xa3\\x43\\x1c\\x26\\x2e\\x25\\xef\\x62\\x73\\x99\\x2e\\xf7\\x4f\\x50\\x1b\\xb8\\x00\\x30\\x0e\\x06\\x38\\xad\\x00\\x81\\xd4\\x43\\x91\\xdc\\x8c\\x02\\xa0\\xc1\\x91\\x07\\x99\\x4b\\x1c\\x45\\xa8\\x74\\x2c\\x93\\x50\\x51\\xc7\\x45\\xd8\\xd1\\x86\\xe8\\x08\\x37\\x6a\\x2c\\x83\\x50\\xd1\\x46\\xb0\\x6c\\xdc\\xb2\\xbd\\x99\\x83\\x32\\x8a\\x60\\x00\\xdc\\xb0\\xc3\\x32\\x06\\x93\\xfa\\xe5\\xe1\\x35\\xd1\\x21\\xb0\\xb6\\x11\\x6e\\xdc\\xe5\\x7c\\x81\\x8a\\x22\\x4a\\x56\\xd1\\xcc\\x8a\\x8e\\x70\\xfb\\xb5\\x32\\x04\\xa3\\x9a\\xea\\x97\\x84\\xdb\\x69\\x40\\x4e\\x00\\xd6\\xb1\\xca\\x52\\x31\\x89\\x89\\xc6\\x8d\\x33\\x30\\x23\\x80\\xb0\\xd3\\x71\\xd1\\x31\\x6e\\x9b\\x22\\x1f\\x28\\xc2\\x28\\x7e\\x81\\x6c\\xab\\x03\\x2d\\x3e\\x92\\x7d\\x34\\xd5\\x82\\x71\\x69\\xf6\\x18\\x37\\x45\\x2c\\x03\\x28\\x87\\x9c\\xa1\\xc7\\x43\\xa2\\x63\\xdc\\x1c\\x9b\\x65\\x01\\x55\\x9d\\xdd\\xe8\\x18\\x37\\xca\\x66\\x39\\x40\\x35\\x02\\x6e\\x9a\\x2f\\xc8\\x00\\xaa\\x61\\x70\\x03\\x6d\\x16\\xff\\x57\\x23\\xe0\\xc6\\xd9\\x3c\\xfa\\xaf\\x46\\x39\\x05\\x18\\x25\\xef\\x93\\x59\\x39\\xee\\x57\\x21\\x92\\x0a\\xa5\\x0b\\xd9\\x76\\xe9\\xa1\\x90\\x6c\\xcb\\xc3\\xcd\\xd7\\xc9\\x03\\xca\\x84\\xa1\\x4f\\x22\\x49\\x9b\\x86\\x36\\x21\\x72\\xd8\\x76\\x32\\xc0\\x81\\x70\\x63\\x7e\\x79\\x2e\\xe0\\x90\\xec\\x09\\x6e\\xc8\\x2f\\xcf\\x04\\x5c\\x04\\xdc\\xa2\\x7f\\x32\\x0f\\x70\\x61\\x70\\xb3\\xfe\\xb9\\x2c\\xc0\\x45\\xc1\\x4d\\xdb\\x97\\x03\\x04\\x4c\\x97\\x75\\x60\\x28\\x3a\\xc1\\x4d\\x1b\\xcf\\x00\\x1a\\x1d\\x4f\\x8b\\x4e\\x70\\x73\\xfe\\xf0\\x73\\x53\\x64\\x29\\x70\\xf8\\x5f\\x87\\x3d\\x6f\\xf5\\x54\\x84\\x88\\xaa\\xe1\\x6b\\x84\\x6d\\xda\\x6c\\xc3\\x4a\\xcf\\x0c\\x07\\xdf\\x5a\\x0e\\x8a\\x0a\\xd7\\x80\\x50\\xa0\\xa4\\x41\\xac\\xcb\\x50\\x6a\\x3a\\x29\\x97\\x69\\xcc\\x4b\\x8e\\xea\\x5c\\x66\\x96\\x89\\xb4\\xbf\\x91\\x32\\xf8\\xd6\\xb2\\x40\\x8c\\x63\\x72\\xa6\\x47\\x09\\xd6\\xa5\\xa6\\x9b\\x32\\xbd\\x9e\\x4e\\xe2\\x77\\x1e\\xf7\\x58\\xab\\x4c\\x9b\\xb6\\x25\\x4e\\x65\\xce\\x86\\xa1\\x84\\x9f\\x5e\\x36\\x50\\x7c\\x15\\x99\\xa1\\x6d\\x8f\\x2a\\x00\\xa6\\x46\\x04\\xac\\xcf\\x3d\\xfa\\x6f\\x04\\x62\\x30\\x78\\xdc\\xe7\\x80\\xe8\\x4d\\xa6\\xf6\\x58\\xdd\\x79\\x68\\x26\\xde\\x57\\x8e\\x19\\x62\\x2e\\x52\\x9e\\x3f\\x07\\x46\\x23\\x59\\x53\\x55\\x70\\x42\\xc1\\x91\\x24\\x10\\xd1\\x09\\x49\\x90\\x3e\\x83\\x6a\\x7d\\x46\\xd3\\xb9\\x91\\x1f\\xfe\\xfe\\x87\\xc9\\x90\\x4d\\xd5\\xb9\\xac\\x52\\xa7\\x04\\x64\\xe2\\x34\\xd2\\x66\\x58\\xb3\\x3a\\x03\\xe1\\x64\\xb2\\x4c\\xda\\x3c\\x35\\xd2\\xf6\\x60\\x4d\\x46\\x95\\x0b\\x63\\x82\\x48\\x8c\\x46\\x5a\\xc4\\x1e\\x2d\\x46\\x3e\\x2d\\x28\\x55\\x81\\xb5\\x5b\\x63\\xc5\\x6e\\xb7\\x61\\x30\\x57\\xa8\\x16\\x16\\x48\\x21\\xf8\\x85\\xb7\\x00\\x14\\x20\\xde\\x42\\xfe\\x08\\xad\\xc3\\xaa\\xde\\xbc\\xba\\xdb\\x90\\xd5\\xb5\\xc4\\x3d\\xda\\x39\\xcd\\x89\\xc4\\xcb\\x29\\xda\\x97\\x60\\x98\\x38\\xd3\\x38\\x88\\xd0\\xed\\x76\\xf3\\x97\\x6b\\x56\\xd3\\xad\\xab\\xe2\\xcd\\xd0\\x0e\\x1a\\xc3\\xa9\\xac\\x1a\\x94\\x79\\x93\\x3a\\xbc\\x19\\x92\\x75\\x33\\x14\\x1f\\xd7\\xc4\\xb5\\xbc\\xd9\\x48\\x99\\xca\\x2a\\x82\\x04\\xc9\\xb2\\x22\\xba\\xbc\\x10\\x6b\\xe4\\x24\\x29\\xb5\\xba\\xf8\\x98\\x26\\xae\\xf2\\x69\\xbe\\xdb\\x40\\xab\\xf5\\xc1\\xd9\\xc6\\x07\\x74\\x61\\x52\\x4f\\x40\\xd5\\x85\\x41\\x78\\xfb\\x79\\x5e\\x7e\\x0e\\x57\\xa5\\x4d\\x15\\x3f\\xf7\\x70\\xb6\\x41\\x51\\x6c\\xdf\\xec\\xd7\\x43\\xf3\\x7f\\xcf\\xc7\\x34\\x71\\x95\\x57\\x6b\\xbe\\x22\\x38\\xcb\\x60\\x20\\xfc\\xda\\x2c\\xb8\\xc8\\xc6\\xc4\\xfb\\x18\\xe6\\x1a\\x63\\x65\\x4a\\x32\\xec\\x50\\x03\\x05\\xb7\\x85\\x81\\xa9\\x82\\xd3\\x0c\\x8a\\x64\\x46\\x1a\\x54\\x1e\\x12\\x0b\\xba\\x07\\x8a\\x21\\xf9\\x18\\xe7\\xda\\x0a\\x68\\x51\\xb6\\x0c\\x57\\x08\\x67\\x1c\\x0b\\xc4\\x28\\x0a\\x34\\xbd\\x9f\\xab\\x00\\xf1\\xf6\\x98\\xae\\x11\\xa3\\xa4\\xbf\\xff\\xf1\\x13\\xfa\\x44\\x38\\xd1\\x60\\x40\\x85\\x97\\xf9\\x09\\x9d\\x7c\\x5c\\x73\\x1d\\x7a\\x8e\\xa6\\x42\\xa3\\x0e\\xe5\\xb5\\x6f\\x06\\x84\\x93\\x8d\\x0b\\x63\\xba\\x81\\x40\\x7d\\x3a\\x9d\\x4e\\x47\\xc2\\xf8\\xd8\\xe6\\x06\\xd9\\xdb\\x2c\\x6b\\xe1\\xc3\\x27\\x90\\x39\\x47\\x56\\xab\\x6e\\x74\\x67\\x58\\x38\\xe5\\xa0\\x48\\xea\\x7e\\x51\\xc8\\x55\\xd9\\x27\\xac\\x52\\xc9\\x90\\x7c\\xbc\\x73\\x63\\x45\\x1e\\xe6\\x21\\xdc\\x7f\\x34\\xbb\\x75\\x9f\\xe1\\xe0\\xa4\\x83\\xa1\\xf0\\xa0\\xf0\\x1f\\x4d\\x6f\\x6d\\x64\\x28\\x3e\\xde\\x49\\xca\\x15\\x45\\xc2\\x3d\\x69\\xe8\\xa3\\x04\\x98\\xe8\\xca\\xb2\\xb7\\x2a\\x55\\x02\\x6f\\xf2\\x57\\xd4\\xe6\\x99\\x30\\x1f\\xaf\\x24\\xe5\\x08\\x89\\xa8\\x7e\\x6b\\x83\\x81\\xe2\\x64\\x62\\x49\\x96\\x91\\x97\\x44\\xa8\\x2b\\xfb\\x33\\xc9\\x3e\\x1e\\x49\\x1c\\x67\\xd8\\x78\\xd0\\x38\\x6d\\x58\\x82\\xf9\\xd1\\xe2\\xca\\xce\\x07\\x13\\xe6\\x63\\x86\\xc4\\x8a\\x0b\\x42\\x9f\\x28\\x61\\x44\\x1c\\x11\\x4e\\x07\\x8e\\x64\\x90\\xc5\\x2d\\xb1\\x6f\\x8d\\x17\\x9a\\x53\\x2e\\x54\\xca\\x3c\\xf2\\x79\\xff\\xc4\\x75\\xca\\x94\\x47\\x64\\x4d\\xe6\\xd6\\xd3\\x7c\\x1c\\x4d\\xe7\\xe3\\x78\\x36\\x83\\xa4\\xa5\\x42\\x30\\xa8\\x99\\xd8\\x23\\xd7\\xa5\\x27\\xd7\\x83\\xf9\\x22\\x8d\\x21\\xf9\\x55\\xcc\\x27\\xe8\\x29\\xd5\\x77\\xb7\\x83\\x7e\\xab\\x13\\xbc\\xdc\\xad\\x47\\x33\\x10\\xdb\\x9d\\x97\\x21\\x6a\\x0a\\x87\\x7a\\xe4\\xe2\\x1e\\x65\\x50\\x77\\x29\\x33\\xe1\\x3e\\x27\\xfe\\x2b\\x1e\\xa0\\xa8\\x08\\x85\\x15\\x29\\xf2\\x0b\\xf5\\x04\\x11\\x83\\x9a\\x54\\x58\\x5f\\xbe\\x25\\x54\\x22\\xe2\\xae\\x1c\\xc7\\x23\\x99\\xac\\x87\\xf0\\x91\\x4b\\x0d\\xf8\\xab\\x75\\xd7\\x35\\x93\\xee\\x73\\xdf\\xef\\x6c\\xf6\\x33\\x1f\\xfb\\x44\\xe4\\x83\\x4c\\x5e\\x81\\x4c\\xc1\\x0f\\xc4\\x7d\\x36\\xfc\\x2e\\x6d\\xa1\\x47\\xc1\\xb2\\x12\\x08\\xf7\\xdf\\x18\\x8c\\x44\\x09\\xb9\\x11\\xbc\\xa3\\x01\\xf0\\x96\\xc7\\xbb\\xb4\\xd4\\x17\\xd7\\x77\\x2e\\xe7\\x44\\x86\\xbe\\xbe\\xdb\\xcb\\x99\\x54\\xdf\\x29\\xa1\\xb1\\xd5\\x53\\x05\\x91\\xbd\\xe5\\xec\\xfc\\x94\\xd4\\xc0\\x39\\x0b\\xe3\\x09\\xe0\\x8f\\x06\\xe8\\xe0\\x2d\\x10\\xe2\\x38\\x2e\\xdc\\xca\\x2e\\xab\\xc7\\x6c\\x4d\\xb6\\x33\\xd6\\xea\\x51\\x9b\\x6b\\x3a\\xac\\x1a\\x75\\x19\\x46\\x8a\\xc6\\x5e\\x55\\xf7\\xd6\\x58\\xcd\\x51\\x8d\\x0e\\x22\\xa7\\xa1\\x32\\xa9\\x29\\x84\\x65\\xcd\\xe7\\x3d\\xae\\xd4\\x20\\x10\\x44\\xbe\\x43\\x0e\\x35\\x31\\x90\\xab\\x6a\\x5d\\x4a\\xf7\\x04\\x79\\x96\\x44\\x78\\xed\\x5a\\x85\\x3c\\x6d\\x6f\\x2f\\x92\\x02\\x52\\x38\\xa5\\x4f\\x9c\\xbb\\xf9\\x19\\x86\\xef\\xa0\\xd9\\xd8\\x0e\\xc6\\x34\\x04\\x11\\xcf\\x78\\xc9\\x09\\x11\\x22\\x09\\x3b\\x42\\x5f\\xa9\\x0b\\xde\\x30\\x73\\x50\\x0c\\xd6\\x61\\xab\\x44\\x08\\x66\\x15\\xc7\\xbe\\xc3\\xa2\\x13\\xcb\\x92\\xe5\\x0d\\x2b\\xcd\\x1f\\x80\\xc4\\x60\\xf0\\xee\\xd8\\xc4\\xad\\xf7\\x4b\\x87\\x24\\x0f\\x6a\\x37\\x08\\x53\\x8f\\x7d\\x67\\xc1\\x27\\x98\\xe9\\x35\\xd2\\xa6\\x43\\x3b\\x26\\x10\\xde\\xfd\\x76\\x60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x22\\x71\\x15\\x2b\\xd7\\x16\\x39\\xbd\\x71\\xea\\xe3\\x2f\\xe4\\x30\\xff\\xef\\x7f\\x00\\x2f\\x3c\\xf3\\x45\\x6e\\x72\\x47\\x32\\x83\\xf2\\xf5\\x68\\x3e\\xda\\xf7\\xbd\\x11\\xf9\\xb4\\xaa\\xf0\\x47\\x7b\\x33\\x00\\xbc\\x3b\\xf3\\xd1\\x49\\x3c\\xc0\\x48\\x3c\\xea\\x9e\\xa3\\xca\\x04\\xfb\\x3a\\x35\\x1f\\x91\\xc6\\x2d\\xfd\\xfd\\x8f\\xc6\\x0f\\x26\\x67\\x20\\x78\\x97\\x06\\x81\\x90\\xa7\\xf5\\x02\\x9f\\x04\\xcb\\x84\\xfb\\xfa\\x34\\x1f\\xdd\\x60\\xfd\\x65\\xa3\\xc7\\x3b\\x34\\x1f\\xbd\\x61\\x7a\\xf0\\xc8\\x71\\x3a\\x1a\\x4f\\x27\\xd7\\xfc\\x66\\x73\\x30\\xff\\xc3\\x40\\x32\\x5e\\x93\\x2d\\xab\\x6e\\x4d\\x68\\x1b\\x0d\\x4f\\x41\\x8e\\x4e\\x0e\\x2e\\x53\\x4f\\xf4\\xc3\\x5f\\xf8\\x85\\xa3\\x33\\x90\\xec\\xce\\x4e\\x9b\\x72\\x1b\\x53\\xbc\\xf3\\x8b\\xf7\\x55\\x5c\\x7e\\x0e\\xe6\\x9a\\x32\\xb3\\xe2\\x5f\\x72\\x7e\\x88\\x0b\\x2e\\xc1\\x74\\xe8\\x9e\\xb1\\xa9\\x17\\x5d\\xbc\\x88\\x46\\x23\\x28\\xd1\\x9b\\xf1\\xbc\\x3e\\x90\\x8f\\x49\\x52\\xd9\\x51\\xc5\\xb8\\xff\\x37\\x00\\x00\\xff\\xff\\x51\\x0d\\xcb\\x5c\\xc3\\x6e\\x00\\x00\")\n\nfunc data2dFlfBytes() ([]byte, error) {\n\treturn bindataRead(\n\t\t_data2dFlf,\n\t\t\"2d.flf\",\n\t)\n}\n\nfunc data2dFlf() (*asset, error) {\n\tbytes, err := data2dFlfBytes()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tinfo := bindataFileInfo{name: \"2d.flf\", size: 28355, mode: os.FileMode(420), modTime: time.Unix(1550434995, 0)}\n\ta := &asset{bytes: bytes, info: info}\n\treturn a, nil\n}\n\nvar _dataQuindarToneMp3 = []byte(\"\\x1f\\x8b\\x08\\x00\\x00\\x00\\x00\\x00\\x00\\xff\\xec\\x9a\\x79\\x5c\\x53\\xd7\\xb6\\xc7\\x57\\x26\\x08\\x61\\x30\\x02\\x02\\x02\\xd5\\x18\\x44\\x11\\x21\\x03\\x84\\x90\\x44\\x22\\x81\\x24\\x08\\x42\\x24\\x0c\\x75\\xa8\\xd6\\x26\\x24\\x07\\x48\\x21\\x83\\x19\\x18\\xf4\\xaa\\xb1\\xb6\\x8a\\x56\\x5b\\x40\\xc5\\x58\\xd0\\x82\\x28\\xe2\\x40\\x8b\\x5a\\x9f\\xd3\\x6d\\x8d\\x62\\x1d\\x0a\\x58\\x54\\x54\\x6c\\xb5\\xc5\\xb6\\x58\\xb1\\xad\\xca\\xd5\\x56\\xab\\x96\\xbc\\x4f\\x12\\x50\\x69\\x7b\\xfb\\xec\\xbb\\xbe\\x0f\\xca\\xe3\\xf7\\x4f\\x3c\\x39\\x7b\\xaf\\xe5\\x6f\\x9f\\x6f\\xd6\\x3a\\xfb\\x1c\\x12\\x04\\xe1\\x18\\x00\\x80\\x09\\x1e\\xe2\\xd4\\x84\\xa9\\x00\\xc3\\x96\\x01\\x4c\\x17\\x89\\x21\\x2a\\xba\\x40\\x23\\x95\\xe5\\x20\\x7a\\x52\\x06\\x92\\xa5\\x50\\x71\\xc9\\x37\\x0f\\x1e\\x22\\x93\\x14\\x72\\x2e\\x79\\x5a\\x84\\x88\\x26\\xd2\\xf0\\x91\\x6c\\x45\\xfc\\x5c\\x2d\\x92\\x36\\x77\\x4a\\xba\\x6c\\x6e\\x8e\\x8c\\x2d\\x27\\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\x79\\x88\\x4a\\x1f\\xd0\\x37\\x44\\x2a\\x92\\xf9\\x77\\x42\\xa4\\x22\\x99\\x7d\\x02\\xc8\\x65\\x8f\\x66\\x6b\\x0c\\xda\\x5c\\xdb\\xe2\\xc9\\x65\\x54\\x24\\x17\\x51\\x22\\x2a\\xbd\\x8e\\x4a\\xa7\\xd0\\x7f\\xef\\x52\\xf0\\xef\\x5c\\x2a\\xed\\x09\\x05\\x85\\x2a\\xa9\\x52\\x21\\x13\\x21\\x72\\x85\\xd4\\x3e\\xb7\\x40\\xa9\\xe1\\x88\\x10\\xbd\\x54\\x2e\\xd5\\x4b\\x05\\x52\\x3d\\xc2\\x25\\x87\\xd1\\xe8\\xe1\\xa1\\x34\\x76\\x68\\x18\\x2d\\x9d\\xce\\xe6\\x84\\xb3\\x38\\x8c\\x88\\xf1\\x34\\x16\\x87\\x46\\x7b\\x3c\\x5e\\x2d\\x57\\x64\\x16\\x3e\\xe5\\x68\\x91\\x88\\x93\\xa0\\xd2\\xe9\\xa5\\x2a\\x19\\x92\\x20\\xe0\\x92\\x0b\\x94\\x1a\\x8a\\x42\\x21\\xe7\\x08\\x23\\x19\\x91\\x7c\\x66\\x98\\x50\\xc8\\x0e\\xa3\\x0b\\xc3\\xe9\\xf4\\x58\\x76\\x58\\x04\\x8b\\xc9\\xa7\\x31\\xe3\\x62\\xe2\\x62\\xf8\\x8c\\xb8\\x27\\xa6\\x0b\\xd4\\x32\\x83\\xd5\\x71\\xef\\x74\\xf9\\xdf\\x9b\\x9e\\xac\\x55\\x64\\x29\\x54\\xd2\\xdc\\x3f\\x0b\\x13\\x16\\x2b\\x88\\x89\\x65\\xb1\\xf8\\x7c\\x96\\x3d\\x0c\\x5b\\x20\\xe0\\x0b\\x05\\x71\\x34\\x41\\x78\\x8c\\x20\\x2e\\x86\\x16\\x6b\\x0b\\x23\\x97\\x71\\x32\\xd5\\x5a\\xa5\\x54\\xcf\\x25\\x4b\\x0d\\x72\\x85\\x9a\\xaa\\xd4\\x20\\x59\\x36\\x58\\x49\\x51\\xf6\\x14\\xf1\\x0a\\x9d\\x5e\\xad\\x2d\\xb4\\x7d\\x65\\x27\\x38\\x0d\\x99\\x63\\x3f\\xb2\\x1f\\xe6\\x2a\\xec\\x07\\x24\\x1b\\x57\\x1c\\xa9\\xcc\\x8a\\x36\\x97\\xac\\x93\\xe6\\x21\\x72\\x72\\x9f\\x53\\x8a\\x3f\\x59\\xab\\xa7\\xfa\\x5f\\x3e\\x8a\\x90\\x9f\\x8d\\xa8\\xfa\\x5e\\x97\\x08\\x0e\\x83\\xc1\\x89\\x60\\x3d\\x71\\x5d\\x1e\\x0d\\xd6\\xa9\\x33\\xf5\\xf9\\x52\\x2d\\x12\\x93\\x85\\xa8\\xf4\\xbd\\x35\\x20\\xc6\\x20\\x57\\xd8\\x7e\\x7b\\xfc\\x34\\x26\\x29\\x68\\x9a\\x42\\x25\\x57\\xe7\\xeb\\xc6\\xf5\\x9d\\x28\\xcb\\x96\\xaa\\xb2\\x10\\x39\\x97\\x4c\\x55\\xf6\\xd0\\x43\\xa6\\x3e\\x43\\xc7\\xfc\\xe7\\xd9\\xf1\\xb3\\x74\\x2a\\x0c\\x7f\\x0a\\x90\\xff\\xc2\\xa9\\xed\\x37\\x17\\xce\\x78\\x81\\xae\\xad\\x90\\xf1\\x3c\\x3b\\x7e\\xa6\\x4e\\x23\\x9e\\x81\\xd3\\x3e\\xf5\\xb4\\xdf\\xae\\xad\\x4c\\xad\\xca\\x43\\xb4\\xfa\\xdf\\xbb\\xd6\\x48\\xb5\\x52\\x25\\xa2\\x47\\xb4\\x3a\\x2e\\x39\\x53\\xab\\x56\\x92\\xec\\x05\\x52\\x9d\\x95\\x35\\x81\\x24\\x53\\xcb\\x11\\x19\\x77\\xcc\\x1c\\x83\\x5a\\x3f\\x21\\x4f\\xad\\xcd\\x50\\xe8\\xec\\xff\\x26\\xe9\\xd5\\xa4\\x27\\xea\\xe8\\xb3\\x5c\\x6f\\xe6\\x73\\xb1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af\\xa7\\xbd\\x12\\x31\\xf9\\xdc\\x17\\x07\\x17\\x9a\\x0f\\xd7\\xcb\\x5d\\xfc\\xdc\\x50\\x2b\\xde\\x63\\xca\\x4f\\xef\\x26\\x7d\\x84\\xdd\\x09\\x90\\xb0\\x11\\x00\\x0b\\x70\\xea\\xc7\\xbb\\xfe\\x00\\x96\\x5a\\xf6\\x68\\x09\\x17\\x9b\\xfd\\x72\\x39\\x67\\x7c\\xa9\\xdf\\xa9\\x63\\x12\\x70\\x5d\\xbf\\x58\\x5c\\xda\\x8e\\xe3\\xc5\\x37\\x08\\x68\\x2b\\x66\\xce\\xa0\\xb5\\xec\\x9b\\xdc\\x34\\x71\\xd1\\x25\\x16\\x0c\\x23\\x61\\xd1\\x43\\xd9\\x57\\x97\\xee\\xb2\\x3c\\x4b\\x3d\\xa8\\x97\\x08\\x80\\x50\\x3f\\x2c\\x35\\x7f\\xa4\\xd9\\x46\\x5c\\x3b\\xa0\\x1c\\x18\\x69\\x7c\\xb3\\xdf\\x71\\x00\\x08\\x34\\x03\\x60\\x9f\\x69\\xbe\\x7e\\x17\\x80\\xcb\\xc1\\xe6\\x42\\x80\\x87\\x3f\\xbd\\x7e\\x3e\\x3f\\x6a\\xb4\\xf1\\x6a\\xd7\\x2f\\x3b\\x66\\x17\\xcd\\xff\\x4c\\xdf\\x28\\x96\\x10\\x40\\x0a\\x73\\x41\\xcc\\xe7\\x56\\x8e\\x70\\x81\\x7c\\xf4\\x28\\x57\\x37\\x63\\xe9\\x37\\x6d\\xf5\\x07\\x1b\\x9b\\x2e\\xcf\\x07\\xd8\\x50\\xdd\\x70\\x60\\xb6\\x78\\x8f\\x68\\x43\\xf4\\x0a\\xdc\\xdb\\xcd\\xfb\\x29\\x95\\x44\\x42\\xf2\\x76\\x08\\x02\\x33\\x78\\x49\\xdc\\x87\\x2c\\xc1\\x98\\x97\\x64\\x50\\xca\\x1d\\xca\\x63\\x40\\xb2\\x09\\x64\\x66\\xca\\x45\\xff\\x9d\\x3c\\xcf\\x45\\x7b\\xfb\\xdb\\xef\\x73\\xa7\\x07\\xf5\\x92\\x2d\\x30\\xe4\\x81\\xe7\\x69\\xcd\\xf8\\x2e\\xf3\\x08\\x70\\xd2\\x00\\xa0\\x1c\\x5c\\xd2\\x26\\x99\\x9d\\x07\\x28\\x71\\x96\\x76\\x00\\xd4\\xba\\xba\\x4a\\x18\\x79\\x66\\x9b\\xeb\\xa2\\x99\\x6b\\x5c\\x00\\x5f\\xe9\\x24\\x3a\\x59\\x56\\x48\\x04\\x13\\xda\\x48\\x9e\\x6e\\x72\\x2f\\xbd\\xb2\\x9d\\x87\\x59\\x82\\x7a\\xc5\\x87\\x51\\xb4\\x9f\\x84\\x4f\\xd6\\x5b\\x7b\\xc1\\x29\\x13\\x0f\\x20\\xfa\\xe1\\x6f\\x26\\x59\\x36\\xb1\\xc8\\x5c\\xe7\\x62\\x02\\x9c\\xb1\\x96\\x88\\x89\\x23\\xc8\\xf4\\xb9\\x95\\x38\\x94\\x39\\xee\\xc3\\x91\\x09\\xbb\\x78\\x2e\\x7b\\xfa\\xdb\\xdc\\x0b\\xa0\\x5e\\xe2\\x52\\x0b\\x50\\x5d\\xe6\\x40\\x3b\\x71\\xb8\\xa0\\x94\\xc4\\x76\\xc7\\x81\\x4a\\x5c\\x8f\\xda\\x01\\xc0\\xef\\x67\\x3c\\x80\\x63\\xf7\\x91\\x06\\x11\\xab\\x73\\x8b\\xbc\\x89\\x73\\x97\\x7a\\x74\\x61\\xde\\x0a\\xd7\\x98\\xf6\\xf3\\x05\\xe8\\x13\\xc6\\xad\\xcb\\xf9\\x6b\\x1a\\x61\\x68\\xb1\\x95\\x38\\xb7\\x0a\\x80\\x4b\\x25\\x53\\x5a\\x7e\\x1a\\x9a\\x3f\\x8d\\x58\\x0f\\x3e\\x78\\x23\\xde\\x88\\x4e\\x42\\x1f\\xb9\\xf3\\x5e\\x6e\\xbc\\x51\\x59\\x23\\xa0\\x94\\x81\\xf3\\x90\\xfe\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x5d\\x64\\xa3\\x2b\\x3d\\x97\\x06\\x40\\xe0\\xdd\\x40\\xec\\x9a\\xdc\\x85\\x1d\\x1a\\x93\\xff\\x0e\\x60\\x59\\x89\\x2b\\x17\\x03\\x58\\x9a\\x34\\xa9\\x92\\xaf\\x46\\xf9\\x23\\x17\\xd3\\xaa\\xc4\\x4e\\xa3\\x80\\x87\\x47\\x99\\x30\\x1f\\x8e\\x5b\\xd6\\x36\\xaa\\x6a\\xf7\\xde\\x21\\x27\\x57\\xef\\xd8\\x01\\xec\\xfe\\x36\\xf5\\x02\\xa8\\x77\\xe7\\x70\\xca\\x4a\\x1c\\xb9\\x87\\xb8\\x82\\x34\\xee\\xc0\\xae\\x71\\xdd\\x00\\x80\\x62\\x7e\\x06\\x28\\xcb\\xcf\\x8d\\x37\\x8f\\x6c\\x5c\\xfa\\xda\\xcb\\x5e\\xc3\\x81\\x26\\xc1\\x7a\\x41\\xab\\xb9\\x64\\x4b\\x93\\x89\\xf7\\x69\\xb0\\xdf\\x3f\\x67\\xbb\\x0d\\x07\\xad\\xd1\\xc9\\xba\\xc9\\xc0\\x97\\xf3\\x00\\x2c\\x27\\xda\\x28\\x27\\x2f\\xc4\\x3a\\x7f\\x55\\x9e\\x89\\xbf\\xf1\\x32\\x54\\x01\\xd6\\xe4\\x16\\x9a\\xb0\\x66\\xdf\\x4b\\x1f\\x74\\xee\\xff\\x87\\x58\\x8e\\x3e\\xbd\\xf4\\xfd\\xfe\\xf6\\xf5\\x22\\xa8\\x0f\\x71\\xbd\\x4f\\x47\\x3c\\x53\\xa2\\x07\\x36\\x71\\x96\\x9e\\xed\\xaa\\xc7\\x72\\x23\\x8c\\xb4\\xcc\\x10\\x5c\\xc8\\x60\\x5f\\x7c\\x67\\x2f\\xf6\\x5d\\x2c\\x48\\x66\\x61\\x9a\\xd0\\x6b\\x18\\xcd\\xfe\\x6e\\x17\\x6f\\xdf\\xf4\\xdb\\xf8\\x12\\xac\\x51\\x00\\x80\\xf3\\xc7\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\\xee\\x36\\x54\\x92\\x69\\x61\\x8e\\xb2\\x21\\xd5\\x7e\\x4c\\x47\\x54\\xbd\\x18\\x1b\\x7a\\xe7\\xee\\x7b\\x21\\x30\\x6b\\x69\\x7f\\xfb\\x7c\\x0e\\xf5\\xf8\\x9d\\x83\\x63\\x97\\x79\\x58\\xcf\\xd3\\x11\\x5a\\x4a\\x82\\x39\\x7a\\x80\\x11\\x67\\x06\\x88\\xfc\\x64\\x15\\x0f\\xa2\\x2d\\x94\\xce\\x55\\x95\\x1d\\x71\\xcb\\xee\\x25\\xe0\\x55\\xaa\\x7b\\x24\\x14\\x16\\xbc\\x87\\xb0\\x12\\x7c\\x25\\xbe\\x2e\\x12\\x31\\x96\\x16\\x89\\xe2\\x3b\\x48\\xaf\\x30\\xd6\\xe1\\x5a\\x03\\xb7\\xef\\xf9\\xd7\\x59\\x42\\xa5\\x5f\\x41\\x51\\x51\\xd1\\xb2\\xb7\\xdc\\x67\\xb7\\xc2\\x48\\x72\\x6c\\xdc\\xd1\\x2d\\x02\\x4a\\x52\\xc3\\xa6\\xd3\\x39\\xcd\\xdb\\xb3\\xde\\x58\\xff\\x66\\x47\\xc8\\xfd\\xf1\\x1f\\xee\\x19\\x41\\x8f\\x61\\x85\\x4e\\x88\\xe5\\x11\\xce\\xfb\\x66\\xde\\x32\\x0f\\x1f\\xdb\\xed\\xd3\\x16\\x6f\\xca\\x16\\xbe\\xbf\\xdc\\xbd\\x0c\\xd5\\x8e\\x1f\\xf1\\x21\\xcf\\x1c\\xff\\xa6\\x77\\x2e\\x25\\x2a\\x72\\x44\\x7e\\xc8\\xe4\\xcd\\xf5\\xdd\\x2f\\x1d\\xd9\\x50\\x33\\x41\\xef\\xe7\\xb7\\x70\\x45\\xab\\xf0\\xf8\\x8d\\xc8\\x6f\\xfd\\x8f\\x6c\\x18\\x35\\x2d\\x74\\xda\\x7b\\x15\\x8d\\xfe\\x9b\\x8b\\xfd\\xce\\xdf\\x47\\xfa\\x7b\\xb1\\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e3\\x76\\xbc\\xb1\\x6c\\xeb\\xb9\\x3c\\x8f\\xd5\\x15\\x6b\\xbd\\xd1\\x0f\\xb9\\xc2\\x4f\\x91\\x24\\x85\\x77\\xc0\\x36\\xc3\\x38\\x25\\x7b\\xf5\\xb4\\x29\\x65\\x67\\x85\\x9f\\x26\\x4d\\x59\\x39\\xcc\\xa5\\x69\\x12\\x9d\\x13\\x56\\xbd\\xf6\\xcc\\x25\\x43\\x38\\xb3\\x62\\xd3\\x77\\x9d\\x73\\x32\\xd8\\x22\\x8f\\xcd\\x57\\x9a\\xa6\\xbc\\x53\\xa3\\x48\\x3b\\x56\\x72\\x8e\\xb3\\xba\\x83\\x91\\x4e\\xf7\\x99\\x92\\x26\\xfc\\xb4\\xe8\\x2a\\x67\\x75\\x4a\\xd5\\xd8\\xe2\\x0e\\xcf\\xce\\xb3\\x82\\x4e\\x64\\x0d\\x27\\xbb\\x36\\x33\\x83\\xfd\\xce\\xe6\\xf4\\x65\\xdf\\xb1\\x85\\xbe\\x04\\x83\\xab\\xf8\\x98\\x94\\x2d\\xf2\\xa8\\x91\\xdd\\x5b\\xec\\x3d\\xd6\\x2b\\xc0\\x74\\x26\\x65\\x52\\x6a\\x45\\xcd\\xdb\\x0c\\xc6\\x75\\xdf\\x25\\xbb\\x4e\\x6c\\x60\\x14\\x9f\\x9f\\xfa\\xad\\x69\\xfd\\x28\\x51\\xd6\\x38\\x36\\x7f\\x4b\\xb0\\x6f\\xc8\\xdc\\xb8\\x67\\x76\\xc3\\xd0\\xf3\\xce\\x21\\xfb\\x5c\\xe1\\xaf\\xf3\\xb2\\xa7\\xd8\\xbb\\x2a\\x00\\x8a\\x02\\x00\\xa4\\x01\\x55\\xe3\\xfe\\xf7\\xea\\xb7\\x3f\\x97\\x1d\\x90\\x4a\\x8f\\x99\\xd4\\xaf\\xf9\\xff\\x3b\\x00\\x00\\xff\\xff\\xd6\\x2f\\xcb\\x16\\x21\\x4a\\x00\\x00\")\n\nfunc dataQuindarToneMp3Bytes() ([]byte, error) {\n\treturn bindataRead(\n\t\t_dataQuindarToneMp3,\n\t\t\"quindar-tone.mp3\",\n\t)\n}\n\nfunc dataQuindarToneMp3() (*asset, error) {\n\tbytes, err := dataQuindarToneMp3Bytes()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tinfo := bindataFileInfo{name: \"quindar-tone.mp3\", size: 18977, mode: os.FileMode(420), modTime: time.Unix(1379677344, 0)}\n\ta := &asset{bytes: bytes, info: info}\n\treturn a, nil\n}\n\n// Asset loads and returns the asset for the given name.\n// It returns an error if the asset could not be found or\n// could not be loaded.\nfunc Asset(name string) ([]byte, error) {\n\tcannonicalName := strings.Replace(name, \"\\\\\", \"/\", -1)\n\tif f, ok := _bindata[cannonicalName]; ok {\n\t\ta, err := f()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Asset %s can't read by error: %v\", name, err)\n\t\t}\n\t\treturn a.bytes, nil\n\t}\n\treturn nil, fmt.Errorf(\"Asset %s not found\", name)\n}\n\n// MustAsset is like Asset but panics when Asset would return an error.\n// It simplifies safe initialization of global variables.\nfunc MustAsset(name string) []byte {\n\ta, err := Asset(name)\n\tif err != nil {\n\t\tpanic(\"asset: Asset(\" + name + \"): \" + err.Error())\n\t}\n\n\treturn a\n}\n\n// AssetInfo loads and returns the asset info for the given name.\n// It returns an error if the asset could not be found or\n// could not be loaded.\nfunc AssetInfo(name string) (os.FileInfo, error) {\n\tcannonicalName := strings.Replace(name, \"\\\\\", \"/\", -1)\n\tif f, ok := _bindata[cannonicalName]; ok {\n\t\ta, err := f()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"AssetInfo %s can't read by error: %v\", name, err)\n\t\t}\n\t\treturn a.info, nil\n\t}\n\treturn nil, fmt.Errorf(\"AssetInfo %s not found\", name)\n}\n\n// AssetNames returns the names of the assets.\nfunc AssetNames() []string {\n\tnames := make([]string, 0, len(_bindata))\n\tfor name := range _bindata {\n\t\tnames = append(names, name)\n\t}\n\treturn names\n}\n\n// _bindata is a table, holding each asset generator, mapped to its name.\nvar _bindata = map[string]func() (*asset, error){\n\t\"3d.flf\":           data3dFlf,\n\t\"2d.flf\":           data2dFlf,\n\t\"quindar-tone.mp3\": dataQuindarToneMp3,\n}\n\n// AssetDir returns the file names below a certain\n// directory embedded in the file by go-bindata.\n// For example if you run go-bindata on data/... and data contains the\n// following hierarchy:\n//     data/\n//       foo.txt\n//       img/\n//         a.png\n//         b.png\n// then AssetDir(\"data\") would return []string{\"foo.txt\", \"img\"}\n// AssetDir(\"data/img\") would return []string{\"a.png\", \"b.png\"}\n// AssetDir(\"foo.txt\") and AssetDir(\"notexist\") would return an error\n// AssetDir(\"\") will return []string{\"data\"}.\nfunc AssetDir(name string) ([]string, error) {\n\tnode := _bintree\n\tif len(name) != 0 {\n\t\tcannonicalName := strings.Replace(name, \"\\\\\", \"/\", -1)\n\t\tpathList := strings.Split(cannonicalName, \"/\")\n\t\tfor _, p := range pathList {\n\t\t\tnode = node.Children[p]\n\t\t\tif node == nil {\n\t\t\t\treturn nil, fmt.Errorf(\"Asset %s not found\", name)\n\t\t\t}\n\t\t}\n\t}\n\tif node.Func != nil {\n\t\treturn nil, fmt.Errorf(\"Asset %s not found\", name)\n\t}\n\trv := make([]string, 0, len(node.Children))\n\tfor childName := range node.Children {\n\t\trv = append(rv, childName)\n\t}\n\treturn rv, nil\n}\n\ntype bintree struct {\n\tFunc     func() (*asset, error)\n\tChildren map[string]*bintree\n}\n\nvar _bintree = &bintree{nil, map[string]*bintree{\n\t\"data\": &bintree{nil, map[string]*bintree{\n\t\t\"3d.flf\":           &bintree{data3dFlf, map[string]*bintree{}},\n\t\t\"2d.flf\":           &bintree{data2dFlf, map[string]*bintree{}},\n\t\t\"quindar-tone.mp3\": &bintree{dataQuindarToneMp3, map[string]*bintree{}},\n\t}},\n}}\n\n// RestoreAsset restores an asset under the given directory\nfunc RestoreAsset(dir, name string) error {\n\tdata, err := Asset(name)\n\tif err != nil {\n\t\treturn err\n\t}\n\tinfo, err := AssetInfo(name)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\n// RestoreAssets restores an asset under the given directory recursively\nfunc RestoreAssets(dir, name string) error {\n\tchildren, err := AssetDir(name)\n\t// File\n\tif err != nil {\n\t\treturn RestoreAsset(dir, name)\n\t}\n\t// Dir\n\tfor _, child := range children {\n\t\terr = RestoreAssets(dir, filepath.Join(name, child))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc _filePath(dir, name string) string {\n\tcannonicalName := strings.Replace(name, \"\\\\\", \"/\", -1)\n\treturn filepath.Join(append([]string{dir}, strings.Split(cannonicalName, \"/\")...)...)\n}\n"
  },
  {
    "path": "asset/file.go",
    "content": "package asset\n\nimport (\n\t\"bytes\"\n\t\"io\"\n)\n\ntype AssetFile struct {\n\treader io.Reader\n}\n\nfunc NewAssetFile(data []byte) AssetFile {\n\treturn AssetFile{bytes.NewReader(data)}\n}\n\nfunc (a AssetFile) Read(p []byte) (n int, err error) {\n\treturn a.reader.Read(p)\n}\n\nfunc (a AssetFile) Close() error {\n\treturn nil\n}\n"
  },
  {
    "path": "asset/player.go",
    "content": "package asset\n\nimport (\n\t\"github.com/hajimehoshi/go-mp3\"\n\t\"github.com/hajimehoshi/oto\"\n\t\"io\"\n\t\"log\"\n)\n\ntype AudioPlayer struct {\n\tplayer *oto.Player\n\tbeep   []byte\n}\n\nfunc NewAudioPlayer() *AudioPlayer {\n\n\tbytes, err := Asset(\"quindar-tone.mp3\")\n\tif err != nil {\n\t\tlog.Fatal(\"Failed to find audio file\")\n\t}\n\n\tplayer, err := oto.NewPlayer(44100, 2, 2, 8192)\n\tif err != nil {\n\t\t// it is expected to fail when some of the system\n\t\t// libraries are not available (e.g. libasound2)\n\t\t// it is not the main functionality of the application,\n\t\t// so we allow startup in no-sound mode\n\t\treturn nil\n\t}\n\n\treturn &AudioPlayer{\n\t\tplayer: player,\n\t\tbeep:   bytes,\n\t}\n}\n\nfunc (a *AudioPlayer) Beep() {\n\n\tdecoder, err := mp3.NewDecoder(NewAssetFile(a.beep))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tif _, err := io.Copy(a.player, decoder); err != nil {\n\t\tpanic(err)\n\t}\n}\n\nfunc (a *AudioPlayer) Close() {\n\t_ = a.player.Close()\n}\n"
  },
  {
    "path": "component/alert.go",
    "content": "package component\n\nimport (\n\t\"fmt\"\n\tui \"github.com/gizak/termui/v3\"\n\t\"github.com/sqshq/sampler/component/util\"\n\t\"github.com/sqshq/sampler/console\"\n\t\"github.com/sqshq/sampler/data\"\n\t\"image\"\n\t\"strings\"\n)\n\nfunc RenderAlert(alert *data.Alert, area image.Rectangle, buffer *ui.Buffer) {\n\n\tif alert == nil {\n\t\treturn\n\t}\n\n\tcolor := console.ColorWhite\n\n\tif alert.Color != nil {\n\t\tcolor = *alert.Color\n\t}\n\n\twidth := util.Max([]int{len(alert.Title), len(alert.Text)}) + 10\n\n\tif width > area.Dx() {\n\t\twidth = area.Dx()\n\t}\n\n\tcells := ui.WrapCells(ui.ParseStyles(fmt.Sprintf(\"%s\\n%s\\n\",\n\t\tstrings.ToUpper(alert.Title), alert.Text), ui.NewStyle(console.ColorWhite)), uint(width))\n\n\tvar lines []string\n\tline := \"\"\n\n\tfor i := 0; i < len(cells); i++ {\n\t\tif cells[i].Rune == '\\n' {\n\t\t\tlines = append(lines, line)\n\t\t\tline = \"\"\n\t\t} else {\n\t\t\tline += string(cells[i].Rune)\n\t\t}\n\t}\n\n\tblock := *ui.NewBlock()\n\tblock.SetRect(util.GetRectCoordinates(area, width, len(lines)))\n\tblock.BorderStyle = ui.Style{Fg: color, Bg: ui.ColorClear}\n\tblock.Draw(buffer)\n\n\tbuffer.Fill(ui.NewCell(' ', ui.NewStyle(console.ColorBlack)), block.Inner)\n\n\tfor i := 0; i < len(lines); i++ {\n\t\tbuffer.SetString(lines[i],\n\t\t\tui.NewStyle(color), util.GetMiddlePoint(block.Inner, lines[i], i-1))\n\t}\n}\n"
  },
  {
    "path": "component/asciibox/asciibox.go",
    "content": "package asciibox\n\nimport (\n\tui \"github.com/gizak/termui/v3\"\n\tfl \"github.com/mbndr/figlet4go\"\n\t\"github.com/sqshq/sampler/asset\"\n\t\"github.com/sqshq/sampler/component\"\n\t\"github.com/sqshq/sampler/config\"\n\t\"github.com/sqshq/sampler/console\"\n\t\"github.com/sqshq/sampler/data\"\n\t\"image\"\n\t\"strings\"\n)\n\n// AsciiBox represents a component with ascii-style text\ntype AsciiBox struct {\n\t*ui.Block\n\t*data.Consumer\n\talert   *data.Alert\n\tascii   string\n\tstyle   ui.Style\n\trender  *fl.AsciiRender\n\toptions *fl.RenderOptions\n\tpalette console.Palette\n}\n\nconst asciiFontExtension = \".flf\"\n\nfunc NewAsciiBox(c config.AsciiBoxConfig, palette console.Palette) *AsciiBox {\n\n\toptions := fl.NewRenderOptions()\n\toptions.FontName = string(*c.Font)\n\n\tfontStr, err := asset.Asset(options.FontName + asciiFontExtension)\n\tif err != nil {\n\t\tpanic(\"Failed to load the font: \" + err.Error())\n\t}\n\n\trender := fl.NewAsciiRender()\n\t_ = render.LoadBindataFont(fontStr, options.FontName)\n\n\tcolor := c.Color\n\tif color == nil {\n\t\tcolor = &palette.BaseColor\n\t}\n\n\tbox := AsciiBox{\n\t\tBlock:    component.NewBlock(c.Title, *c.Border, palette),\n\t\tConsumer: data.NewConsumer(),\n\t\tstyle:    ui.NewStyle(*color),\n\t\trender:   render,\n\t\toptions:  options,\n\t\tpalette:  palette,\n\t}\n\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase sample := <-box.SampleChannel:\n\t\t\t\tbox.renderText(sample)\n\t\t\tcase alert := <-box.AlertChannel:\n\t\t\t\tbox.alert = alert\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn &box\n}\n\nfunc (a *AsciiBox) renderText(sample *data.Sample) {\n\ttext := strings.TrimSpace(sample.Value)\n\tlines := strings.Split(text, \"\\n\")\n\ta.ascii = \"\"\n\tfor _, line := range lines {\n\t\tascii, _ := a.render.RenderOpts(line, a.options)\n\t\ta.ascii += ascii + \"\\n\"\n\t}\n}\n\nfunc (a *AsciiBox) Draw(buffer *ui.Buffer) {\n\n\tbuffer.Fill(ui.NewCell(' ', ui.NewStyle(ui.ColorBlack)), a.GetRect())\n\ta.Block.Draw(buffer)\n\n\tpoint := a.Inner.Min\n\tcells := ui.ParseStyles(a.ascii, a.style)\n\n\tfor i := 0; i < len(cells) && point.Y < a.Inner.Max.Y; i++ {\n\t\tif cells[i].Rune == '\\n' {\n\t\t\tpoint = image.Pt(a.Inner.Min.X, point.Y+1)\n\t\t} else if point.In(a.Inner) {\n\t\t\tbuffer.SetCell(cells[i], point)\n\t\t\tpoint = point.Add(image.Pt(1, 0))\n\t\t}\n\t}\n\n\tcomponent.RenderAlert(a.alert, a.Rectangle, buffer)\n}\n"
  },
  {
    "path": "component/barchart/barchart.go",
    "content": "package barchart\n\nimport (\n\t\"fmt\"\n\tui \"github.com/gizak/termui/v3\"\n\trw \"github.com/mattn/go-runewidth\"\n\t\"github.com/sqshq/sampler/component\"\n\t\"github.com/sqshq/sampler/component/util\"\n\t\"github.com/sqshq/sampler/config\"\n\t\"github.com/sqshq/sampler/console\"\n\t\"github.com/sqshq/sampler/data\"\n\t\"image\"\n\t\"math\"\n)\n\nconst (\n\tbarIndent int = 1\n)\n\n// BarChart presents categorical data with rectangular bars\ntype BarChart struct {\n\t*ui.Block\n\t*data.Consumer\n\tbars     []bar\n\tscale    int\n\tmaxValue float64\n\tcount    int64\n\tpalette  console.Palette\n}\n\ntype bar struct {\n\tlabel string\n\tcolor ui.Color\n\tvalue float64\n\tdelta float64\n}\n\nfunc NewBarChart(c config.BarChartConfig, palette console.Palette) *BarChart {\n\n\tchart := BarChart{\n\t\tBlock:    component.NewBlock(c.Title, true, palette),\n\t\tConsumer: data.NewConsumer(),\n\t\tbars:     []bar{},\n\t\tscale:    *c.Scale,\n\t\tmaxValue: -math.MaxFloat64,\n\t\tpalette:  palette,\n\t}\n\n\tfor _, i := range c.Items {\n\t\tchart.addBar(*i.Label, *i.Color)\n\t}\n\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase sample := <-chart.SampleChannel:\n\t\t\t\tchart.consumeSample(sample)\n\t\t\tcase alert := <-chart.AlertChannel:\n\t\t\t\tchart.Alert = alert\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn &chart\n}\n\nfunc (b *BarChart) consumeSample(sample *data.Sample) {\n\n\tb.count++\n\n\tfloat, err := util.ParseFloat(sample.Value)\n\n\tif err != nil {\n\t\tb.HandleConsumeFailure(\"Failed to parse a number\", err, sample)\n\t\treturn\n\t}\n\n\tb.HandleConsumeSuccess()\n\n\tindex := -1\n\tfor i, bar := range b.bars {\n\t\tif bar.label == sample.Label {\n\t\t\tindex = i\n\t\t}\n\t}\n\n\tbar := b.bars[index]\n\tbar.delta = float - bar.value\n\tbar.value = float\n\tb.bars[index] = bar\n\n\tif float > b.maxValue {\n\t\tb.maxValue = float\n\t}\n\n\t// normalize bars height once in a while\n\tif b.count%500 == 0 {\n\t\tb.reselectMaxValue()\n\t}\n}\n\nfunc (b *BarChart) addBar(label string, color ui.Color) {\n\tb.bars = append(b.bars, bar{label: label, color: color, value: 0})\n}\n\nfunc (b *BarChart) reselectMaxValue() {\n\tmaxValue := -math.MaxFloat64\n\tfor _, bar := range b.bars {\n\t\tif bar.value > maxValue {\n\t\t\tmaxValue = bar.value\n\t\t}\n\t}\n\tb.maxValue = maxValue\n}\n\n// Draw renders the barchart\nfunc (b *BarChart) Draw(buffer *ui.Buffer) {\n\tb.Block.Draw(buffer)\n\n\tbarWidth := int(math.Floor(float64(b.Inner.Dx()-len(b.bars)*barIndent) / float64(len(b.bars))))\n\tbarXCoordinate := b.Inner.Min.X + barIndent\n\n\tlabelStyle := ui.NewStyle(b.palette.BaseColor)\n\n\tfor _, bar := range b.bars {\n\n\t\t// draw bar\n\t\theight := int((bar.value / b.maxValue) * float64(b.Inner.Dy()-1))\n\t\tif height <= 1 {\n\t\t\theight = 2\n\t\t}\n\n\t\tmaxYCoordinate := b.Inner.Max.Y - height\n\t\tfor x := barXCoordinate; x < ui.MinInt(barXCoordinate+barWidth, b.Inner.Max.X-barIndent); x++ {\n\t\t\tfor y := b.Inner.Max.Y - 2; y >= maxYCoordinate; y-- {\n\t\t\t\tc := ui.NewCell(console.SymbolHorizontalBar, ui.NewStyle(bar.color))\n\t\t\t\tbuffer.SetCell(c, image.Pt(x, y))\n\t\t\t}\n\t\t}\n\n\t\t// draw label\n\t\tlabelXCoordinate := barXCoordinate +\n\t\t\tint(float64(barWidth)/2) -\n\t\t\tint(float64(rw.StringWidth(bar.label))/2)\n\t\tbuffer.SetString(\n\t\t\tbar.label,\n\t\t\tlabelStyle,\n\t\t\timage.Pt(labelXCoordinate, b.Inner.Max.Y-1))\n\n\t\t// draw value & delta\n\t\tvalue := util.FormatValue(bar.value, b.scale)\n\t\tif bar.delta != 0 {\n\t\t\tvalue = fmt.Sprintf(\"%s/%s\", value, util.FormatDelta(bar.delta, b.scale))\n\t\t}\n\t\tvalueXCoordinate := barXCoordinate +\n\t\t\tint(float64(barWidth)/2) -\n\t\t\tint(float64(rw.StringWidth(value))/2)\n\t\tbuffer.SetString(\n\t\t\tvalue,\n\t\t\tlabelStyle,\n\t\t\timage.Pt(valueXCoordinate, maxYCoordinate-1))\n\n\t\tbarXCoordinate += barWidth + barIndent\n\t}\n\n\tcomponent.RenderAlert(b.Alert, b.Rectangle, buffer)\n}\n"
  },
  {
    "path": "component/block.go",
    "content": "package component\n\nimport (\n\t\"fmt\"\n\tui \"github.com/gizak/termui/v3\"\n\t\"github.com/sqshq/sampler/console\"\n)\n\nfunc NewBlock(title string, border bool, palette console.Palette) *ui.Block {\n\tstyle := ui.Style{Fg: palette.BaseColor, Bg: ui.ColorClear}\n\tblock := ui.NewBlock()\n\tblock.Border = border\n\tblock.BorderStyle = style\n\tblock.TitleStyle = style\n\tif len(title) > 0 {\n\t\tblock.Title = fmt.Sprintf(\" %s \", title)\n\t}\n\treturn block\n}\n"
  },
  {
    "path": "component/component.go",
    "content": "package component\n\nimport (\n\tui \"github.com/gizak/termui/v3\"\n\t\"github.com/sqshq/sampler/config\"\n\t\"github.com/sqshq/sampler/data\"\n)\n\ntype Component struct {\n\tui.Drawable\n\t*data.Consumer\n\tType     config.ComponentType\n\tTitle    string\n\tLocation config.Location\n\tSize     config.Size\n\tRateMs   int\n}\n\nfunc NewComponent(dbl ui.Drawable, cmr *data.Consumer, cfg config.ComponentConfig) *Component {\n\treturn &Component{\n\t\tDrawable: dbl,\n\t\tConsumer: cmr,\n\t\tType:     cfg.Type,\n\t\tTitle:    cfg.Title,\n\t\tLocation: cfg.GetLocation(),\n\t\tSize:     cfg.GetSize(),\n\t\tRateMs:   *cfg.RateMs,\n\t}\n}\n\nfunc (c *Component) Move(x, y int) {\n\tc.Location.X += x\n\tc.Location.Y += y\n\tc.normalize()\n}\n\nfunc (c *Component) Resize(x, y int) {\n\tc.Size.X += x\n\tc.Size.Y += y\n\tc.normalize()\n}\n\nfunc (c *Component) normalize() {\n\tif c.Location.X < 0 {\n\t\tc.Location.X = 0\n\t}\n\tif c.Location.Y < 0 {\n\t\tc.Location.Y = 0\n\t}\n}\n"
  },
  {
    "path": "component/gauge/gauge.go",
    "content": "package gauge\n\nimport (\n\t\"fmt\"\n\tui \"github.com/gizak/termui/v3\"\n\t\"github.com/sqshq/sampler/component\"\n\t\"github.com/sqshq/sampler/component/util\"\n\t\"github.com/sqshq/sampler/config\"\n\t\"github.com/sqshq/sampler/console\"\n\t\"github.com/sqshq/sampler/data\"\n\t\"image\"\n)\n\nconst (\n\tMinValueLabel = \"min\"\n\tMaxValueLabel = \"max\"\n\tCurValueLabel = \"cur\"\n)\n\n// Gauge displays cur value between specified min and max values\ntype Gauge struct {\n\t*ui.Block\n\t*data.Consumer\n\tminValue    float64\n\tmaxValue    float64\n\tcurValue    float64\n\tcolor       ui.Color\n\tscale       int\n\tpercentOnly bool\n\tpalette     console.Palette\n}\n\nfunc NewGauge(c config.GaugeConfig, palette console.Palette) *Gauge {\n\n\tg := Gauge{\n\t\tBlock:       component.NewBlock(c.Title, true, palette),\n\t\tConsumer:    data.NewConsumer(),\n\t\tcolor:       *c.Color,\n\t\tscale:       *c.Scale,\n\t\tpercentOnly: *c.PercentOnly,\n\t\tpalette:     palette,\n\t}\n\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase sample := <-g.SampleChannel:\n\t\t\t\tg.ConsumeSample(sample)\n\t\t\tcase alert := <-g.AlertChannel:\n\t\t\t\tg.Alert = alert\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn &g\n}\n\nfunc (g *Gauge) ConsumeSample(sample *data.Sample) {\n\n\tfloat, err := util.ParseFloat(sample.Value)\n\tif err != nil {\n\t\tg.HandleConsumeFailure(\"Failed to parse a number\", err, sample)\n\t\treturn\n\t}\n\n\tg.HandleConsumeSuccess()\n\n\tswitch sample.Label {\n\tcase MinValueLabel:\n\t\tg.minValue = float\n\t\tbreak\n\tcase MaxValueLabel:\n\t\tg.maxValue = float\n\t\tbreak\n\tcase CurValueLabel:\n\t\tg.curValue = float\n\t\tbreak\n\t}\n}\n\nfunc (g *Gauge) Draw(buffer *ui.Buffer) {\n\n\tg.Block.Draw(buffer)\n\n\tpercent := calculatePercent(g)\n\n\tvar label string\n\tif g.percentOnly {\n\t\tlabel = fmt.Sprintf(\" %v%% \", util.FormatValue(percent, g.scale))\n\t} else {\n\t\tlabel = fmt.Sprintf(\" %v%% (%v) \", util.FormatValue(percent, g.scale), util.FormatValue(g.curValue, g.scale))\n\t}\n\n\t// draw bar\n\tbarWidth := int((percent / 100) * float64(g.Inner.Dx()))\n\tif barWidth == 0 {\n\t\tbarWidth = 1\n\t} else if barWidth > g.Dx()-2 {\n\t\tbarWidth = g.Dx() - 2\n\t}\n\tbuffer.Fill(\n\t\tui.NewCell(console.SymbolVerticalBar, ui.NewStyle(g.color)),\n\t\timage.Rect(g.Inner.Min.X+1, g.Inner.Min.Y, g.Inner.Min.X+barWidth, g.Inner.Max.Y),\n\t)\n\n\t// draw label\n\tlabelXCoordinate := g.Inner.Min.X + (g.Inner.Dx() / 2) - int(float64(len(label))/2)\n\tlabelYCoordinate := g.Inner.Min.Y + ((g.Inner.Dy() - 1) / 2)\n\tif labelYCoordinate < g.Inner.Max.Y {\n\t\tfor i, char := range label {\n\t\t\tstyle := ui.NewStyle(g.palette.BaseColor)\n\t\t\tif labelXCoordinate+i+1 <= g.Inner.Min.X+barWidth {\n\t\t\t\tstyle = ui.NewStyle(g.palette.BaseColor, ui.ColorClear)\n\t\t\t}\n\t\t\tbuffer.SetCell(ui.NewCell(char, style), image.Pt(labelXCoordinate+i, labelYCoordinate))\n\t\t}\n\t}\n\n\tcomponent.RenderAlert(g.Alert, g.Rectangle, buffer)\n}\n\nfunc calculatePercent(g *Gauge) float64 {\n\tif g.curValue != g.minValue && g.maxValue != g.minValue {\n\t\treturn (100 * (g.curValue - g.minValue)) / (g.maxValue - g.minValue)\n\t}\n\treturn 0\n}\n"
  },
  {
    "path": "component/gauge/gauge_test.go",
    "content": "package gauge\n\nimport \"testing\"\n\nfunc Test_calculatePercent(t *testing.T) {\n\ttype args struct {\n\t\tg *Gauge\n\t}\n\ttests := []struct {\n\t\tname string\n\t\targs args\n\t\twant float64\n\t}{\n\t\t{\"should calculate percent between 0 and 60\", args{&Gauge{minValue: 0, maxValue: 60, curValue: 45}}, 75},\n\t\t{\"should calculate percent between 10 and 60\", args{&Gauge{minValue: 10, maxValue: 60, curValue: 59}}, 98},\n\t\t{\"should calculate percent between -20 and 60\", args{&Gauge{minValue: -20, maxValue: 60, curValue: 0}}, 25},\n\t\t{\"should calculate percent when cur value = min value\", args{&Gauge{minValue: -10, maxValue: 60, curValue: -10}}, 0},\n\t\t{\"should calculate percent when min value = max value\", args{&Gauge{minValue: -124, maxValue: -124, curValue: -124}}, 0},\n\t}\n\tfor _, tt := range tests {\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tif got := calculatePercent(tt.args.g); got != tt.want {\n\t\t\t\tt.Errorf(\"calculatePercent() = %v, want %v\", got, tt.want)\n\t\t\t}\n\t\t})\n\t}\n}\n"
  },
  {
    "path": "component/layout/layout.go",
    "content": "package layout\n\nimport (\n\tui \"github.com/gizak/termui/v3\"\n\t\"github.com/sqshq/sampler/component\"\n\t\"github.com/sqshq/sampler/component/runchart\"\n\t\"github.com/sqshq/sampler/component/util\"\n\t\"github.com/sqshq/sampler/config\"\n\t\"github.com/sqshq/sampler/console\"\n\t\"github.com/sqshq/sampler/data\"\n\t\"image\"\n\t\"math\"\n\t\"time\"\n)\n\n// Layout represents component arrangement on the screen\ntype Layout struct {\n\tui.Block\n\tComponents       []*component.Component\n\tstatusbar        *component.StatusBar\n\tmenu             *component.Menu\n\tChangeModeEvents chan Mode\n\tmode             Mode\n\tselection        int\n\tpositionsChanged bool\n\tstartupTime      time.Time\n}\n\ntype Mode rune\n\nconst (\n\tModeDefault          Mode = 0\n\tModeIntro            Mode = 1\n\tModePause            Mode = 2\n\tModeComponentSelect  Mode = 3\n\tModeMenuOptionSelect Mode = 4\n\tModeComponentMove    Mode = 5\n\tModeComponentResize  Mode = 6\n\tModeChartPinpoint    Mode = 7\n)\n\nconst (\n\tminDimension    = 3\n\tstatusbarHeight = 1\n)\n\nfunc NewLayout(statusline *component.StatusBar, menu *component.Menu) *Layout {\n\n\twidth, height := ui.TerminalDimensions()\n\tblock := *ui.NewBlock()\n\tblock.SetRect(0, 0, width, height)\n\tstatusline.SetRect(0, height-statusbarHeight, width, height)\n\n\treturn &Layout{\n\t\tBlock:            block,\n\t\tComponents:       make([]*component.Component, 0),\n\t\tstatusbar:        statusline,\n\t\tmenu:             menu,\n\t\tmode:             ModeDefault,\n\t\tselection:        0,\n\t\tChangeModeEvents: make(chan Mode, 10),\n\t\tstartupTime:      time.Now(),\n\t}\n}\n\nfunc (l *Layout) AddComponent(cpt *component.Component) {\n\tl.Components = append(l.Components, cpt)\n}\n\nfunc (l *Layout) StartWithIntro() {\n\tl.mode = ModeIntro\n}\n\nfunc (l *Layout) changeMode(m Mode) {\n\tif m == ModeComponentResize || m == ModeComponentMove {\n\t\tl.positionsChanged = true\n\t}\n\tl.mode = m\n\tl.ChangeModeEvents <- m\n}\n\nfunc (l *Layout) HandleMouseClick(x int, y int) {\n\tif l.mode == ModeIntro {\n\t\treturn\n\t}\n\tl.menu.Idle()\n\tselected, i := l.findComponentAtPoint(image.Point{X: x, Y: y})\n\tif selected == nil {\n\t\tl.changeMode(ModeDefault)\n\t} else {\n\t\tl.selection = i\n\t\tl.menu.Highlight(selected)\n\t\tl.changeMode(ModeComponentSelect)\n\t}\n}\n\nfunc (l *Layout) HandleKeyboardEvent(e string) {\n\n\tselected := l.getSelection()\n\n\tswitch e {\n\tcase console.KeyPause1, console.KeyPause2:\n\t\tif l.mode == ModePause {\n\t\t\tl.changeMode(ModeDefault)\n\t\t\tl.statusbar.TogglePause()\n\t\t} else {\n\t\t\tif selected.Type == config.TypeRunChart {\n\t\t\t\tselected.CommandChannel <- &data.Command{Type: runchart.CommandDisableSelection}\n\t\t\t}\n\t\t\tl.menu.Idle()\n\t\t\tl.changeMode(ModePause)\n\t\t\tl.statusbar.TogglePause()\n\t\t}\n\tcase console.KeyEnter:\n\t\tswitch l.mode {\n\t\tcase ModeComponentSelect:\n\t\t\tl.menu.Choose()\n\t\t\tl.changeMode(ModeMenuOptionSelect)\n\t\tcase ModeMenuOptionSelect:\n\t\t\toption := l.menu.GetSelectedOption()\n\t\t\tswitch option {\n\t\t\tcase component.MenuOptionMove:\n\t\t\t\tl.changeMode(ModeComponentMove)\n\t\t\t\tl.menu.MoveOrResize()\n\t\t\tcase component.MenuOptionResize:\n\t\t\t\tl.changeMode(ModeComponentResize)\n\t\t\t\tl.menu.MoveOrResize()\n\t\t\tcase component.MenuOptionPinpoint:\n\t\t\t\tl.changeMode(ModeChartPinpoint)\n\t\t\t\tl.menu.Idle()\n\t\t\t\tselected.CommandChannel <- &data.Command{Type: runchart.CommandMoveSelection, Value: 0}\n\t\t\tcase component.MenuOptionResume:\n\t\t\t\tl.changeMode(ModeDefault)\n\t\t\t\tl.menu.Idle()\n\t\t\t}\n\t\tcase ModeComponentMove:\n\t\t\tfallthrough\n\t\tcase ModeComponentResize:\n\t\t\tl.menu.Idle()\n\t\t\tl.changeMode(ModeDefault)\n\t\t\tbreak\n\t\t}\n\tcase console.KeyEsc:\n\t\tl.resetAlerts()\n\t\tswitch l.mode {\n\t\tcase ModeChartPinpoint:\n\t\t\tselected.CommandChannel <- &data.Command{Type: runchart.CommandDisableSelection}\n\t\t\tfallthrough\n\t\tcase ModeComponentSelect:\n\t\t\tfallthrough\n\t\tcase ModeMenuOptionSelect:\n\t\t\tl.menu.Idle()\n\t\t\tl.changeMode(ModeDefault)\n\t\tcase ModeComponentMove:\n\t\t\tfallthrough\n\t\tcase ModeComponentResize:\n\t\t\tl.menu.Idle()\n\t\t\tl.changeMode(ModeDefault)\n\t\t}\n\tcase console.KeyLeft:\n\t\tswitch l.mode {\n\t\tcase ModeDefault:\n\t\t\tl.changeMode(ModeComponentSelect)\n\t\t\tl.menu.Highlight(l.getComponent(l.selection))\n\t\tcase ModeChartPinpoint:\n\t\t\tselected.CommandChannel <- &data.Command{Type: runchart.CommandMoveSelection, Value: -1}\n\t\tcase ModeComponentSelect:\n\t\t\tl.moveSelection(e)\n\t\t\tl.menu.Highlight(l.getComponent(l.selection))\n\t\tcase ModeComponentMove:\n\t\t\tselected.Move(-1, 0)\n\t\tcase ModeComponentResize:\n\t\t\tselected.Resize(-1, 0)\n\t\t}\n\tcase console.KeyRight:\n\t\tswitch l.mode {\n\t\tcase ModeDefault:\n\t\t\tl.changeMode(ModeComponentSelect)\n\t\t\tl.menu.Highlight(l.getComponent(l.selection))\n\t\tcase ModeChartPinpoint:\n\t\t\tselected.CommandChannel <- &data.Command{Type: runchart.CommandMoveSelection, Value: 1}\n\t\tcase ModeComponentSelect:\n\t\t\tl.moveSelection(e)\n\t\t\tl.menu.Highlight(l.getComponent(l.selection))\n\t\tcase ModeComponentMove:\n\t\t\tselected.Move(1, 0)\n\t\tcase ModeComponentResize:\n\t\t\tselected.Resize(1, 0)\n\t\t}\n\tcase console.KeyUp:\n\t\tswitch l.mode {\n\t\tcase ModeDefault:\n\t\t\tl.changeMode(ModeComponentSelect)\n\t\t\tl.menu.Highlight(l.getComponent(l.selection))\n\t\tcase ModeComponentSelect:\n\t\t\tl.moveSelection(e)\n\t\t\tl.menu.Highlight(l.getComponent(l.selection))\n\t\tcase ModeMenuOptionSelect:\n\t\t\tl.menu.Up()\n\t\tcase ModeComponentMove:\n\t\t\tselected.Move(0, -1)\n\t\tcase ModeComponentResize:\n\t\t\tselected.Resize(0, -1)\n\t\t}\n\tcase console.KeyDown:\n\t\tswitch l.mode {\n\t\tcase ModeDefault:\n\t\t\tl.changeMode(ModeComponentSelect)\n\t\t\tl.menu.Highlight(l.getComponent(l.selection))\n\t\tcase ModeComponentSelect:\n\t\t\tl.moveSelection(e)\n\t\t\tl.menu.Highlight(l.getComponent(l.selection))\n\t\tcase ModeMenuOptionSelect:\n\t\t\tl.menu.Down()\n\t\tcase ModeComponentMove:\n\t\t\tselected.Move(0, 1)\n\t\tcase ModeComponentResize:\n\t\t\tselected.Resize(0, 1)\n\t\t}\n\t}\n}\n\nfunc (l *Layout) ChangeDimensions(width, height int) {\n\tl.SetRect(0, 0, width, height)\n}\n\nfunc (l *Layout) getComponent(i int) *component.Component {\n\treturn l.Components[i]\n}\n\nfunc (l *Layout) getSelection() *component.Component {\n\treturn l.Components[l.selection]\n}\n\nfunc (l *Layout) moveSelection(direction string) {\n\n\tpreviouslySelected := l.getSelection()\n\tnewlySelectedIndex := l.selection + 1\n\n\tfor i, current := range l.Components {\n\n\t\tif current == previouslySelected {\n\t\t\tcontinue\n\t\t}\n\n\t\tif newlySelectedIndex >= len(l.Components) {\n\t\t\tnewlySelectedIndex = i\n\t\t}\n\n\t\tvar previouslySelectedCornerPoint image.Point\n\t\tvar newlySelectedCornerPoint image.Point\n\t\tvar currentCornerPoint image.Point\n\n\t\tswitch direction {\n\t\tcase console.KeyLeft:\n\t\t\tpreviouslySelectedCornerPoint = util.GetRectLeftSideCenter(previouslySelected.GetRect())\n\t\t\tnewlySelectedCornerPoint = util.GetRectRightSideCenter(l.getComponent(newlySelectedIndex).GetRect())\n\t\t\tcurrentCornerPoint = util.GetRectRightSideCenter(current.GetRect())\n\t\tcase console.KeyRight:\n\t\t\tpreviouslySelectedCornerPoint = util.GetRectRightSideCenter(previouslySelected.GetRect())\n\t\t\tnewlySelectedCornerPoint = util.GetRectLeftSideCenter(l.getComponent(newlySelectedIndex).GetRect())\n\t\t\tcurrentCornerPoint = util.GetRectLeftSideCenter(current.GetRect())\n\t\tcase console.KeyUp:\n\t\t\tpreviouslySelectedCornerPoint = util.GetRectTopSideCenter(previouslySelected.GetRect())\n\t\t\tnewlySelectedCornerPoint = util.GetRectBottomSideCenter(l.getComponent(newlySelectedIndex).GetRect())\n\t\t\tcurrentCornerPoint = util.GetRectBottomSideCenter(current.GetRect())\n\t\tcase console.KeyDown:\n\t\t\tpreviouslySelectedCornerPoint = util.GetRectBottomSideCenter(previouslySelected.GetRect())\n\t\t\tnewlySelectedCornerPoint = util.GetRectTopSideCenter(l.getComponent(newlySelectedIndex).GetRect())\n\t\t\tcurrentCornerPoint = util.GetRectTopSideCenter(current.GetRect())\n\t\t}\n\n\t\tswitch direction {\n\t\tcase console.KeyLeft:\n\t\t\tfallthrough\n\t\tcase console.KeyRight:\n\t\t\tif ui.AbsInt(currentCornerPoint.X-previouslySelectedCornerPoint.X) <= ui.AbsInt(newlySelectedCornerPoint.X-previouslySelectedCornerPoint.X) {\n\t\t\t\tif ui.AbsInt(currentCornerPoint.Y-previouslySelectedCornerPoint.Y) <= ui.AbsInt(newlySelectedCornerPoint.Y-previouslySelectedCornerPoint.Y) {\n\t\t\t\t\tnewlySelectedIndex = i\n\t\t\t\t}\n\t\t\t}\n\t\tcase console.KeyUp:\n\t\t\tfallthrough\n\t\tcase console.KeyDown:\n\t\t\tif ui.AbsInt(currentCornerPoint.Y-previouslySelectedCornerPoint.Y) <= ui.AbsInt(newlySelectedCornerPoint.Y-previouslySelectedCornerPoint.Y) {\n\t\t\t\tif ui.AbsInt(currentCornerPoint.X-previouslySelectedCornerPoint.X) <= ui.AbsInt(newlySelectedCornerPoint.X-previouslySelectedCornerPoint.X) {\n\t\t\t\t\tnewlySelectedIndex = i\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif newlySelectedIndex < len(l.Components) {\n\t\tl.selection = newlySelectedIndex\n\t}\n}\n\nfunc (l *Layout) Draw(buffer *ui.Buffer) {\n\n\tcolumnWidth := float64(l.GetRect().Dx()) / float64(console.ColumnsCount)\n\trowHeight := float64(l.GetRect().Dy()-statusbarHeight) / float64(console.RowsCount)\n\n\tfor _, c := range l.Components {\n\t\trectangle := calculateComponentCoordinates(c, columnWidth, rowHeight)\n\t\tc.SetRect(rectangle.Min.X, rectangle.Min.Y, rectangle.Max.X, rectangle.Max.Y)\n\t}\n\n\tfor _, c := range l.Components {\n\t\tc.Draw(buffer)\n\t}\n\n\tl.statusbar.SetRect(\n\t\t0, l.GetRect().Dy()-statusbarHeight,\n\t\tl.GetRect().Dx(), l.GetRect().Dy())\n\n\tl.statusbar.Draw(buffer)\n\tl.menu.Draw(buffer)\n}\n\nfunc (l *Layout) findComponentAtPoint(point image.Point) (*component.Component, int) {\n\n\tcolumnWidth := float64(l.GetRect().Dx()) / float64(console.ColumnsCount)\n\trowHeight := float64(l.GetRect().Dy()-statusbarHeight) / float64(console.RowsCount)\n\n\tfor i, c := range l.Components {\n\n\t\trectangle := calculateComponentCoordinates(c, columnWidth, rowHeight)\n\n\t\tif point.In(rectangle) {\n\t\t\treturn c, i\n\t\t}\n\t}\n\n\treturn nil, -1\n}\n\nfunc calculateComponentCoordinates(c *component.Component, columnWidth float64, rowHeight float64) image.Rectangle {\n\n\tx1 := math.Floor(float64(c.Location.X) * columnWidth)\n\ty1 := math.Floor(float64(c.Location.Y) * rowHeight)\n\tx2 := x1 + math.Floor(float64(c.Size.X))*columnWidth\n\ty2 := y1 + math.Floor(float64(c.Size.Y))*rowHeight\n\n\tif x2-x1 < minDimension {\n\t\tx2 = x1 + minDimension\n\t}\n\n\tif y2-y1 < minDimension {\n\t\ty2 = y1 + minDimension\n\t}\n\n\treturn image.Rectangle{Min: image.Point{\n\t\tX: int(x1), Y: int(y1)},\n\t\tMax: image.Point{X: int(x2), Y: int(y2)},\n\t}\n}\n\nfunc (l *Layout) resetAlerts() {\n\tfor _, c := range l.Components {\n\t\tc.AlertChannel <- nil\n\t}\n}\n\nfunc (l *Layout) WerePositionsChanged() bool {\n\treturn l.positionsChanged\n}\n"
  },
  {
    "path": "component/menu.go",
    "content": "package component\n\nimport (\n\tui \"github.com/gizak/termui/v3\"\n\t\"github.com/sqshq/sampler/component/util\"\n\t\"github.com/sqshq/sampler/config\"\n\t\"github.com/sqshq/sampler/console\"\n\t\"image\"\n)\n\ntype Menu struct {\n\t*ui.Block\n\toptions   []menuOption\n\tcomponent Component\n\tmode      menuMode\n\toption    menuOption\n\tpalette   console.Palette\n}\n\ntype menuMode rune\n\nconst (\n\tmenuModeIdle          menuMode = 0\n\tmenuModeHighlight     menuMode = 1\n\tmenuModeOptionSelect  menuMode = 2\n\tmenuModeMoveAndResize menuMode = 3\n)\n\ntype menuOption string\n\nconst (\n\tMenuOptionMove     menuOption = \"MOVE\"\n\tMenuOptionResize   menuOption = \"RESIZE\"\n\tMenuOptionPinpoint menuOption = \"PINPOINT\"\n\tMenuOptionResume   menuOption = \"RESUME\"\n)\n\nconst (\n\tminimalMenuHeight = 8\n)\n\nfunc NewMenu(palette console.Palette) *Menu {\n\treturn &Menu{\n\t\tBlock:   NewBlock(\"\", true, palette),\n\t\toptions: []menuOption{MenuOptionMove, MenuOptionResize, MenuOptionPinpoint, MenuOptionResume},\n\t\tmode:    menuModeIdle,\n\t\toption:  MenuOptionMove,\n\t\tpalette: palette,\n\t}\n}\n\nfunc (m *Menu) GetSelectedOption() menuOption {\n\treturn m.option\n}\n\nfunc (m *Menu) Highlight(component *Component) {\n\tm.component = *component\n\tm.updateDimensions()\n\tm.mode = menuModeHighlight\n\tm.Title = component.Title\n}\n\nfunc (m *Menu) Choose() {\n\tm.mode = menuModeOptionSelect\n}\n\nfunc (m *Menu) Idle() {\n\tm.mode = menuModeIdle\n}\n\nfunc (m *Menu) Up() {\n\tfor i := 1; i < len(m.options); i++ {\n\t\tif m.options[i] == m.option {\n\t\t\tm.option = m.options[i-1]\n\t\t\tbreak\n\t\t}\n\t}\n\tif m.option == MenuOptionPinpoint && m.component.Type != config.TypeRunChart {\n\t\tm.Up()\n\t}\n}\n\nfunc (m *Menu) Down() {\n\tfor i := 0; i < len(m.options)-1; i++ {\n\t\tif m.options[i] == m.option {\n\t\t\tm.option = m.options[i+1]\n\t\t\tbreak\n\t\t}\n\t}\n\tif m.option == MenuOptionPinpoint && m.component.Type != config.TypeRunChart {\n\t\tm.Down()\n\t}\n}\n\nfunc (m *Menu) MoveOrResize() {\n\tm.mode = menuModeMoveAndResize\n}\n\nfunc (m *Menu) Draw(buffer *ui.Buffer) {\n\n\tif m.mode == menuModeIdle {\n\t\treturn\n\t}\n\n\tm.updateDimensions()\n\tbuffer.Fill(ui.NewCell(' ', ui.NewStyle(m.palette.ReverseColor)), m.GetRect())\n\n\tif m.Dy() > minimalMenuHeight {\n\t\tm.drawInnerBorder(buffer)\n\t}\n\n\tm.Block.Draw(buffer)\n\n\tswitch m.mode {\n\tcase menuModeHighlight:\n\t\tm.renderHighlight(buffer)\n\tcase menuModeMoveAndResize:\n\t\tm.renderMoveAndResize(buffer)\n\tcase menuModeOptionSelect:\n\t\tm.renderOptions(buffer)\n\t}\n}\n\nfunc (m *Menu) renderHighlight(buffer *ui.Buffer) {\n\n\toptionsText := \"<ENTER> to view options\"\n\tresumeText := \"<ESC> to resume\"\n\n\tif m.Dy() <= minimalMenuHeight {\n\t\tbuffer.SetString(\n\t\t\toptionsText,\n\t\t\tui.NewStyle(console.ColorDarkGrey),\n\t\t\tutil.GetMiddlePoint(m.Block.Rectangle, optionsText, -1),\n\t\t)\n\t\treturn\n\t}\n\n\tm.printAllDirectionsArrowSign(buffer, -1)\n\n\toptionsTextPoint := util.GetMiddlePoint(m.Block.Rectangle, optionsText, 3)\n\tif optionsTextPoint.Y+1 < m.Inner.Max.Y {\n\t\tbuffer.SetString(\n\t\t\toptionsText,\n\t\t\tui.NewStyle(console.ColorDarkGrey),\n\t\t\tutil.GetMiddlePoint(m.Block.Rectangle, optionsText, 3),\n\t\t)\n\t}\n\n\tresumeTextPoint := util.GetMiddlePoint(m.Block.Rectangle, resumeText, 4)\n\tif resumeTextPoint.Y+1 < m.Inner.Max.Y {\n\t\tbuffer.SetString(\n\t\t\tresumeText,\n\t\t\tui.NewStyle(console.ColorDarkGrey),\n\t\t\tresumeTextPoint,\n\t\t)\n\t}\n}\n\nfunc (m *Menu) renderMoveAndResize(buffer *ui.Buffer) {\n\n\tsaveText := \"<ENTER> to save changes\"\n\n\tif m.Dy() <= minimalMenuHeight {\n\t\tbuffer.SetString(saveText, ui.NewStyle(console.ColorDarkGrey), util.GetMiddlePoint(m.Block.Rectangle, saveText, -1))\n\t\treturn\n\t}\n\n\tm.printAllDirectionsArrowSign(buffer, -1)\n\tbuffer.SetString(saveText, ui.NewStyle(console.ColorDarkGrey), util.GetMiddlePoint(m.Block.Rectangle, saveText, 3))\n}\n\nfunc (m *Menu) printAllDirectionsArrowSign(buffer *ui.Buffer, y int) {\n\n\tarrows := []string{\n\t\t\"  ↑  \",\n\t\t\"←   →\",\n\t\t\"  ↓  \",\n\t}\n\n\tfor i, a := range arrows {\n\t\tutil.PrintString(\n\t\t\ta,\n\t\t\tui.NewStyle(console.ColorOlive),\n\t\t\tutil.GetMiddlePoint(m.Block.Rectangle, a, i+y),\n\t\t\tbuffer,\n\t\t)\n\t}\n}\n\nfunc (m *Menu) renderOptions(buffer *ui.Buffer) {\n\n\thighlightedStyle := ui.NewStyle(m.palette.ReverseColor, console.ColorOlive)\n\tregularStyle := ui.NewStyle(m.palette.BaseColor, m.palette.ReverseColor)\n\n\toffset := 1\n\tfor _, option := range m.options {\n\n\t\tstyle := regularStyle\n\t\tif m.option == option {\n\t\t\tstyle = highlightedStyle\n\t\t}\n\n\t\tif option != MenuOptionPinpoint || m.component.Type == config.TypeRunChart {\n\t\t\toffset += 2\n\t\t\tpoint := util.GetMiddlePoint(m.Block.Rectangle, string(option), offset-6)\n\t\t\tbuffer.SetString(string(option), style, point)\n\t\t}\n\t}\n}\n\nfunc (m *Menu) updateDimensions() {\n\tr := m.component.GetRect()\n\tm.SetRect(r.Min.X, r.Min.Y, r.Max.X, r.Max.Y)\n}\n\nfunc (m *Menu) drawInnerBorder(buffer *ui.Buffer) {\n\n\tverticalCell := ui.Cell{ui.VERTICAL_LINE, m.BorderStyle}\n\thorizontalCell := ui.Cell{ui.HORIZONTAL_LINE, m.BorderStyle}\n\n\t// draw lines\n\tbuffer.Fill(horizontalCell, image.Rect(m.Min.X+2, m.Min.Y+2, m.Max.X-2, m.Min.Y))\n\tbuffer.Fill(horizontalCell, image.Rect(m.Min.X+2, m.Max.Y-2, m.Max.X-2, m.Max.Y))\n\tbuffer.Fill(verticalCell, image.Rect(m.Min.X+2, m.Min.Y+1, m.Min.X+3, m.Max.Y-1))\n\tbuffer.Fill(verticalCell, image.Rect(m.Max.X-2, m.Min.Y, m.Max.X-3, m.Max.Y))\n\n\t// draw corners\n\tbuffer.SetCell(ui.Cell{ui.TOP_LEFT, m.BorderStyle}, image.Pt(m.Min.X+2, m.Min.Y+1))\n\tbuffer.SetCell(ui.Cell{ui.TOP_RIGHT, m.BorderStyle}, image.Pt(m.Max.X-3, m.Min.Y+1))\n\tbuffer.SetCell(ui.Cell{ui.BOTTOM_LEFT, m.BorderStyle}, image.Pt(m.Min.X+2, m.Max.Y-2))\n\tbuffer.SetCell(ui.Cell{ui.BOTTOM_RIGHT, m.BorderStyle}, image.Pt(m.Max.X-3, m.Max.Y-2))\n}\n"
  },
  {
    "path": "component/runchart/grid.go",
    "content": "package runchart\n\nimport (\n\tui \"github.com/gizak/termui/v3\"\n\t\"github.com/sqshq/sampler/component/util\"\n\t\"image\"\n\t\"math\"\n\t\"time\"\n)\n\nconst defaultValueLength = 4\n\ntype chartGrid struct {\n\ttimeRange    TimeRange\n\ttimePerPoint time.Duration\n\tvalueExtrema ValueExtrema\n\tlinesCount   int\n\tmaxTimeWidth int\n\tminTimeWidth int\n}\n\nfunc (c *RunChart) newChartGrid() chartGrid {\n\n\tlinesCount := (c.Inner.Max.X - c.Inner.Min.X - c.grid.minTimeWidth) / xAxisGridWidth\n\ttimeRange := c.getTimeRange(linesCount)\n\n\treturn chartGrid{\n\t\ttimeRange:    timeRange,\n\t\ttimePerPoint: c.timescale / time.Duration(xAxisGridWidth),\n\t\tvalueExtrema: getLocalExtrema(c.lines, timeRange),\n\t\tlinesCount:   linesCount,\n\t\tmaxTimeWidth: c.Inner.Max.X,\n\t\tminTimeWidth: defaultValueLength,\n\t}\n}\n\nfunc (c *RunChart) renderAxes(buffer *ui.Buffer) {\n\n\t// draw y axis labels\n\tif c.grid.valueExtrema.max != c.grid.valueExtrema.min {\n\t\tlabelsCount := (c.Inner.Dy() - xAxisLabelsHeight - 1) / (yAxisLabelsIndent + yAxisLabelsHeight)\n\t\tvaluePerY := (c.grid.valueExtrema.max - c.grid.valueExtrema.min) / float64(c.Inner.Dy()-xAxisLabelsHeight-3)\n\t\tfor i := 0; i < int(labelsCount); i++ {\n\t\t\tval := c.grid.valueExtrema.max - (valuePerY * float64(i) * (yAxisLabelsIndent + yAxisLabelsHeight))\n\t\t\tfmt := util.FormatValue(val, c.scale)\n\t\t\tif len(fmt) > c.grid.minTimeWidth {\n\t\t\t\tc.grid.minTimeWidth = len(fmt)\n\t\t\t}\n\t\t\tbuffer.SetString(\n\t\t\t\tfmt,\n\t\t\t\tui.NewStyle(c.palette.BaseColor),\n\t\t\t\timage.Pt(c.Inner.Min.X, 1+c.Inner.Min.Y+i*(yAxisLabelsIndent+yAxisLabelsHeight)))\n\t\t}\n\t} else {\n\t\tfmt := util.FormatValue(c.grid.valueExtrema.max, c.scale)\n\t\tc.grid.minTimeWidth = len(fmt)\n\t\tbuffer.SetString(\n\t\t\tfmt,\n\t\t\tui.NewStyle(c.palette.BaseColor),\n\t\t\timage.Pt(c.Inner.Min.X, c.Inner.Min.Y+c.Inner.Dy()/2))\n\t}\n\n\t// draw origin cell\n\tbuffer.SetCell(\n\t\tui.NewCell(ui.BOTTOM_LEFT, ui.NewStyle(c.palette.BaseColor)),\n\t\timage.Pt(c.Inner.Min.X+c.grid.minTimeWidth, c.Inner.Max.Y-xAxisLabelsHeight-1))\n\n\t// draw x axis line\n\tfor i := c.grid.minTimeWidth + 1; i < c.Inner.Dx(); i++ {\n\t\tbuffer.SetCell(\n\t\t\tui.NewCell(ui.HORIZONTAL_DASH, ui.NewStyle(c.palette.BaseColor)),\n\t\t\timage.Pt(i+c.Inner.Min.X, c.Inner.Max.Y-xAxisLabelsHeight-1))\n\t}\n\n\t// draw grid lines\n\tfor y := 0; y < c.Inner.Dy()-xAxisLabelsHeight-2; y = y + 2 {\n\t\tfor x := 1; x <= c.grid.linesCount; x++ {\n\t\t\tbuffer.SetCell(\n\t\t\t\tui.NewCell(ui.VERTICAL_DASH, ui.NewStyle(c.palette.MediumColor)),\n\t\t\t\timage.Pt(c.grid.maxTimeWidth-x*xAxisGridWidth, y+c.Inner.Min.Y+1))\n\t\t}\n\t}\n\n\t// draw y axis line\n\tfor i := 0; i < c.Inner.Dy()-xAxisLabelsHeight-1; i++ {\n\t\tbuffer.SetCell(\n\t\t\tui.NewCell(ui.VERTICAL_DASH, ui.NewStyle(c.palette.BaseColor)),\n\t\t\timage.Pt(c.Inner.Min.X+c.grid.minTimeWidth, i+c.Inner.Min.Y))\n\t}\n\n\t// draw x axis time labels\n\tfor i := 1; i <= c.grid.linesCount; i++ {\n\t\tlabelTime := c.grid.timeRange.max.Add(time.Duration(-i) * c.timescale)\n\t\tbuffer.SetString(\n\t\t\tlabelTime.Format(\"15:04:05\"),\n\t\t\tui.NewStyle(c.palette.BaseColor),\n\t\t\timage.Pt(c.grid.maxTimeWidth-xAxisLabelsWidth/2-i*(xAxisGridWidth), c.Inner.Max.Y-1))\n\t}\n}\n\nfunc (c *RunChart) getTimeRange(linesCount int) TimeRange {\n\n\tif c.mode == ModePinpoint {\n\t\treturn c.grid.timeRange\n\t}\n\n\twidth := time.Duration(c.timescale.Nanoseconds() * int64(linesCount))\n\tmax := time.Now()\n\n\treturn TimeRange{\n\t\tmax: max,\n\t\tmin: max.Add(-width),\n\t}\n}\n\nfunc getLocalExtrema(items []TimeLine, timeRange TimeRange) ValueExtrema {\n\n\tif len(items) == 0 {\n\t\treturn ValueExtrema{0, 0}\n\t}\n\n\tvar max, min = -math.MaxFloat64, math.MaxFloat64\n\n\tfor _, item := range items {\n\t\tstarted := false\n\t\tfor i := len(item.points) - 1; i > 0; i-- {\n\t\t\tpoint := item.points[i]\n\t\t\tif timeRange.isInRange(point.time) {\n\t\t\t\tstarted = true\n\t\t\t} else if started == true && !timeRange.isInRange(point.time) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif point.value > max && timeRange.isInRange(point.time) {\n\t\t\t\tmax = point.value\n\t\t\t}\n\t\t\tif point.value < min && timeRange.isInRange(point.time) {\n\t\t\t\tmin = point.value\n\t\t\t}\n\t\t}\n\t}\n\n\treturn ValueExtrema{max: max, min: min}\n}\n\nfunc (r *TimeRange) isInRange(time time.Time) bool {\n\treturn time.After(r.min) && time.Before(r.max)\n}\n"
  },
  {
    "path": "component/runchart/legend.go",
    "content": "package runchart\n\nimport (\n\t\"fmt\"\n\tui \"github.com/gizak/termui/v3\"\n\t\"github.com/sqshq/sampler/component/util\"\n\t\"image\"\n\t\"math\"\n)\n\nconst (\n\txAxisLegendIndent = 10\n\tyAxisLegendIndent = 1\n\theightOnDefault   = 2\n\theightOnPinpoint  = 4\n\theightOnDetails   = 6\n\n\ttimeFormat = \"15:04:05.000\"\n)\n\ntype legend struct {\n\tEnabled bool\n\tDetails bool\n}\n\nfunc (c *RunChart) renderLegend(buffer *ui.Buffer, rectangle image.Rectangle) {\n\n\tif !c.legend.Enabled {\n\t\treturn\n\t}\n\n\theight := heightOnDefault\n\n\tif c.mode == ModePinpoint {\n\t\theight = heightOnPinpoint\n\t} else if c.legend.Details {\n\t\theight = heightOnDetails\n\t}\n\n\trowCount := (c.Dy() - 2*yAxisLegendIndent) / (height + yAxisLegendIndent)\n\tcolumnCount := int(math.Ceil(float64(len(c.lines)) / float64(rowCount)))\n\tcolumnWidth := getColumnWidth(c.mode, c.lines, c.scale)\n\n\tfor col := 0; col < columnCount; col++ {\n\t\tfor row := 0; row < rowCount; row++ {\n\n\t\t\tlineIndex := row + rowCount*col\n\t\t\tif len(c.lines) <= lineIndex {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tline := c.lines[row+rowCount*col]\n\n\t\t\tx := c.Inner.Max.X - (columnWidth+xAxisLegendIndent)*(col+1)\n\t\t\ty := c.Inner.Min.Y + yAxisLegendIndent + row*height\n\n\t\t\ttitleStyle := ui.NewStyle(line.color)\n\t\t\tdetailsStyle := ui.NewStyle(c.palette.BaseColor)\n\n\t\t\tbuffer.SetString(string(ui.DOT), titleStyle, image.Pt(x-2, y))\n\t\t\tbuffer.SetString(line.label, titleStyle, image.Pt(x, y))\n\n\t\t\tif c.mode == ModePinpoint {\n\t\t\t\tbuffer.SetString(fmt.Sprintf(\"time  %s\", line.selectionPoint.time.Format(\"15:04:05.000\")), detailsStyle, image.Pt(x, y+1))\n\t\t\t\tbuffer.SetString(fmt.Sprintf(\"value %s\", util.FormatValue(line.selectionPoint.value, c.scale)), detailsStyle, image.Pt(x, y+2))\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif !c.legend.Details {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tdetails := [4]string{\n\t\t\t\tfmt.Sprintf(\"cur  %s\", util.FormatValue(getCurrentValue(line), c.scale)),\n\t\t\t\tfmt.Sprintf(\"dlt %s\", util.FormatDelta(getDiffWithPreviousValue(line), c.scale)),\n\t\t\t\tfmt.Sprintf(\"max  %s\", util.FormatValue(line.extrema.max, c.scale)),\n\t\t\t\tfmt.Sprintf(\"min  %s\", util.FormatValue(line.extrema.min, c.scale)),\n\t\t\t}\n\n\t\t\tfor i, detail := range details {\n\t\t\t\tbuffer.SetString(detail, detailsStyle, image.Pt(x, y+i+yAxisLegendIndent))\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc getColumnWidth(mode Mode, lines []TimeLine, scale int) int {\n\n\tif mode == ModePinpoint {\n\t\treturn len(timeFormat)\n\t}\n\n\twidth := len(util.FormatValue(0, scale))\n\tfor _, line := range lines {\n\t\tif len(line.label) > width {\n\t\t\twidth = len(line.label)\n\t\t}\n\t}\n\treturn width\n}\n\nfunc getDiffWithPreviousValue(line TimeLine) float64 {\n\tif len(line.points) < 2 {\n\t\treturn 0\n\t}\n\treturn line.points[len(line.points)-1].value - line.points[len(line.points)-2].value\n}\n\nfunc getCurrentValue(line TimeLine) float64 {\n\tif len(line.points) == 0 {\n\t\treturn 0\n\t}\n\treturn line.points[len(line.points)-1].value\n}\n"
  },
  {
    "path": "component/runchart/runchart.go",
    "content": "package runchart\n\nimport (\n\t\"github.com/sqshq/sampler/component\"\n\t\"github.com/sqshq/sampler/component/util\"\n\t\"github.com/sqshq/sampler/config\"\n\t\"github.com/sqshq/sampler/console\"\n\t\"github.com/sqshq/sampler/data\"\n\t\"image\"\n\t\"math\"\n\t\"sync\"\n\t\"time\"\n\n\tui \"github.com/gizak/termui/v3\"\n)\n\nconst (\n\txAxisGridWidth     = xAxisLabelsIndent + xAxisLabelsWidth\n\txAxisLabelsHeight  = 1\n\txAxisLabelsWidth   = 8\n\txAxisLabelsIndent  = 2\n\tyAxisLabelsHeight  = 1\n\tyAxisLabelsIndent  = 1\n\thistoryReserveMin  = 2\n\txBrailleMultiplier = 2\n\tyBrailleMultiplier = 4\n)\n\ntype Mode int\n\nconst (\n\tModeDefault  Mode = 0\n\tModePinpoint Mode = 1\n)\n\nconst (\n\tCommandDisableSelection = \"DISABLE_SELECTION\"\n\tCommandMoveSelection    = \"MOVE_SELECTION\"\n)\n\n// RunChart displays observed data in a time sequence\ntype RunChart struct {\n\t*ui.Block\n\t*data.Consumer\n\tlines     []TimeLine\n\tgrid      chartGrid\n\ttimescale time.Duration\n\tmutex     *sync.Mutex\n\tmode      Mode\n\tselection time.Time\n\tscale     int\n\tlegend    legend\n\tpalette   console.Palette\n}\n\ntype TimePoint struct {\n\tvalue      float64\n\ttime       time.Time\n\tcoordinate int\n}\n\ntype TimeLine struct {\n\tpoints              []TimePoint\n\textrema             ValueExtrema\n\tcolor               ui.Color\n\tlabel               string\n\tselectionCoordinate int\n\tselectionPoint      TimePoint\n}\n\ntype TimeRange struct {\n\tmax time.Time\n\tmin time.Time\n}\n\ntype ValueExtrema struct {\n\tmax float64\n\tmin float64\n}\n\nfunc NewRunChart(c config.RunChartConfig, palette console.Palette) *RunChart {\n\n\tchart := RunChart{\n\t\tBlock:     component.NewBlock(c.Title, true, palette),\n\t\tConsumer:  data.NewConsumer(),\n\t\tlines:     []TimeLine{},\n\t\ttimescale: calculateTimescale(*c.RateMs),\n\t\tmutex:     &sync.Mutex{},\n\t\tscale:     *c.Scale,\n\t\tmode:      ModeDefault,\n\t\tlegend:    legend{Enabled: c.Legend.Enabled, Details: c.Legend.Details},\n\t\tpalette:   palette,\n\t}\n\n\tfor _, i := range c.Items {\n\t\tchart.AddLine(*i.Label, *i.Color)\n\t}\n\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase sample := <-chart.SampleChannel:\n\t\t\t\tchart.consumeSample(sample)\n\t\t\tcase alert := <-chart.AlertChannel:\n\t\t\t\tchart.Alert = alert\n\t\t\tcase command := <-chart.CommandChannel:\n\t\t\t\tswitch command.Type {\n\t\t\t\tcase CommandDisableSelection:\n\t\t\t\t\tchart.disableSelection()\n\t\t\t\tcase CommandMoveSelection:\n\t\t\t\t\tchart.moveSelection(command.Value.(int))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn &chart\n}\n\nfunc (c *RunChart) newTimePoint(value float64) TimePoint {\n\tnow := time.Now()\n\treturn TimePoint{\n\t\tvalue:      value,\n\t\ttime:       now,\n\t\tcoordinate: c.calculateTimeCoordinate(now),\n\t}\n}\n\nfunc (c *RunChart) Draw(buffer *ui.Buffer) {\n\n\tc.mutex.Lock()\n\tc.Block.Draw(buffer)\n\tc.grid = c.newChartGrid()\n\n\tdrawArea := image.Rect(\n\t\tc.Inner.Min.X+c.grid.minTimeWidth+2, c.Inner.Min.Y,\n\t\tc.Inner.Max.X, c.Inner.Max.Y-xAxisLabelsHeight-1,\n\t)\n\n\tc.renderAxes(buffer)\n\tc.renderLines(buffer, drawArea)\n\tc.renderLegend(buffer, drawArea)\n\tcomponent.RenderAlert(c.Alert, c.Rectangle, buffer)\n\tc.mutex.Unlock()\n}\n\nfunc (c *RunChart) AddLine(Label string, color ui.Color) {\n\tline := TimeLine{\n\t\tpoints:  []TimePoint{},\n\t\tcolor:   color,\n\t\tlabel:   Label,\n\t\textrema: ValueExtrema{max: -math.MaxFloat64, min: math.MaxFloat64},\n\t}\n\tc.lines = append(c.lines, line)\n}\n\nfunc (c *RunChart) consumeSample(sample *data.Sample) {\n\n\tfloat, err := util.ParseFloat(sample.Value)\n\tif err != nil {\n\t\tc.HandleConsumeFailure(\"Failed to parse a number\", err, sample)\n\t\treturn\n\t}\n\n\tc.HandleConsumeSuccess()\n\n\tc.mutex.Lock()\n\n\tindex := -1\n\tfor i, line := range c.lines {\n\t\tif line.label == sample.Label {\n\t\t\tindex = i\n\t\t}\n\t}\n\n\tline := c.lines[index]\n\n\tif float < line.extrema.min {\n\t\tline.extrema.min = float\n\t}\n\tif float > line.extrema.max {\n\t\tline.extrema.max = float\n\t}\n\n\tline.points = append(line.points, c.newTimePoint(float))\n\tc.lines[index] = line\n\n\tif len(line.points)%100 == 0 {\n\t\tc.trimOutOfRangeValues()\n\t}\n\n\tc.mutex.Unlock()\n}\n\nfunc (c *RunChart) renderLines(buffer *ui.Buffer, drawArea image.Rectangle) {\n\n\tcanvas := ui.NewCanvas()\n\tcanvas.Rectangle = drawArea\n\n\tif len(c.lines) == 0 || len(c.lines[0].points) == 0 {\n\t\treturn\n\t}\n\n\tselectionCoordinate := c.calculateTimeCoordinate(c.selection)\n\tselectionPoints := make(map[int]image.Point)\n\n\tprobe := c.lines[0].points[0]\n\tprobeCalculatedCoordinate := c.calculateTimeCoordinate(probe.time)\n\tdelta := probe.coordinate - probeCalculatedCoordinate\n\n\tfor i, line := range c.lines {\n\n\t\txPoint := make(map[int]image.Point)\n\t\txOrder := make([]int, 0)\n\n\t\t// move selection on a delta, if it was instantiated after cursor move\n\t\tif line.selectionCoordinate != 0 {\n\t\t\tline.selectionCoordinate -= delta\n\t\t\tc.lines[i].selectionCoordinate = line.selectionCoordinate\n\t\t}\n\n\t\tfor j, timePoint := range line.points {\n\n\t\t\ttimePoint.coordinate -= delta\n\t\t\tline.points[j] = timePoint\n\n\t\t\tvar y int\n\t\t\tif c.grid.valueExtrema.max == c.grid.valueExtrema.min {\n\t\t\t\ty = (drawArea.Dy() - 2) / 2\n\t\t\t} else {\n\t\t\t\tvaluePerY := (c.grid.valueExtrema.max - c.grid.valueExtrema.min) / float64(drawArea.Dy()-2)\n\t\t\t\ty = int(float64(timePoint.value-c.grid.valueExtrema.min) / valuePerY)\n\t\t\t}\n\n\t\t\tpoint := image.Pt(timePoint.coordinate, drawArea.Max.Y-y-1)\n\n\t\t\tif _, exists := xPoint[point.X]; exists {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif !point.In(drawArea) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif line.selectionCoordinate == 0 {\n\t\t\t\t// instantiate selection coordinate as the closest point to the cursor time\n\t\t\t\tif len(line.points) > j+1 && ui.AbsInt(timePoint.coordinate-selectionCoordinate) > ui.AbsInt(line.points[j+1].coordinate-selectionCoordinate) {\n\t\t\t\t\tselectionPoints[i] = point\n\t\t\t\t\tc.lines[i].selectionPoint = timePoint\n\t\t\t\t}\n\t\t\t} else if timePoint.coordinate == line.selectionCoordinate {\n\t\t\t\tselectionPoints[i] = point\n\t\t\t}\n\n\t\t\txPoint[point.X] = point\n\t\t\txOrder = append(xOrder, point.X)\n\t\t}\n\n\t\tfor i, x := range xOrder {\n\n\t\t\tcurrentPoint := xPoint[x]\n\t\t\tvar previousPoint image.Point\n\n\t\t\tif i == 0 {\n\t\t\t\tpreviousPoint = currentPoint\n\t\t\t} else {\n\t\t\t\tpreviousPoint = xPoint[xOrder[i-1]]\n\t\t\t}\n\n\t\t\tcanvas.SetLine(\n\t\t\t\tbraillePoint(previousPoint),\n\t\t\t\tbraillePoint(currentPoint),\n\t\t\t\tline.color,\n\t\t\t)\n\t\t}\n\t}\n\n\tcanvas.Draw(buffer)\n\n\tif c.mode == ModePinpoint {\n\t\tfor lineIndex, point := range selectionPoints {\n\t\t\tbuffer.SetCell(ui.NewCell(console.SymbolSelection, ui.NewStyle(c.lines[lineIndex].color)), point)\n\t\t\tif c.lines[lineIndex].selectionCoordinate == 0 {\n\t\t\t\tc.lines[lineIndex].selectionCoordinate = point.X\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc (c *RunChart) trimOutOfRangeValues() {\n\n\tminRangeTime := c.grid.timeRange.min.Add(-time.Minute * time.Duration(historyReserveMin))\n\n\tfor i, item := range c.lines {\n\t\tlastOutOfRangeValueIndex := -1\n\n\t\tfor j, point := range item.points {\n\t\t\tif point.time.Before(minRangeTime) {\n\t\t\t\tlastOutOfRangeValueIndex = j\n\t\t\t}\n\t\t}\n\n\t\tif lastOutOfRangeValueIndex > 0 {\n\t\t\titem.points = append(item.points[:0], item.points[lastOutOfRangeValueIndex+1:]...)\n\t\t\tc.lines[i] = item\n\t\t}\n\t}\n}\n\nfunc (c *RunChart) calculateTimeCoordinate(t time.Time) int {\n\ttimeDeltaWithGridMaxTime := c.grid.timeRange.max.Sub(t).Nanoseconds()\n\ttimeDeltaToPaddingRelation := float64(timeDeltaWithGridMaxTime) / float64(c.timescale.Nanoseconds())\n\treturn c.grid.maxTimeWidth - int(math.Ceil(float64(xAxisGridWidth)*timeDeltaToPaddingRelation))\n}\n\nfunc (c *RunChart) moveSelection(shift int) {\n\n\tif c.mode == ModeDefault {\n\t\tc.mode = ModePinpoint\n\t\tc.selection = getMidRangeTime(c.grid.timeRange)\n\t\treturn\n\t}\n\n\tc.selection = c.selection.Add(c.grid.timePerPoint * time.Duration(shift))\n\tif c.selection.After(c.grid.timeRange.max) {\n\t\tc.selection = c.grid.timeRange.max\n\t} else if c.selection.Before(c.grid.timeRange.min) {\n\t\tc.selection = c.grid.timeRange.min\n\t}\n\n\tfor i := range c.lines {\n\t\tc.lines[i].selectionCoordinate = 0\n\t}\n}\n\nfunc (c *RunChart) disableSelection() {\n\tif c.mode == ModePinpoint {\n\t\tc.mode = ModeDefault\n\t\treturn\n\t}\n}\n\nfunc getMidRangeTime(r TimeRange) time.Time {\n\tdelta := r.max.Sub(r.min)\n\treturn r.max.Add(-delta / 2)\n}\n\n// time duration between grid lines\nfunc calculateTimescale(rateMs int) time.Duration {\n\n\tmultiplier := rateMs * xAxisGridWidth / 2\n\ttimescale := time.Duration(time.Millisecond * time.Duration(multiplier)).Round(time.Second)\n\n\tif timescale.Seconds() == 0 {\n\t\treturn time.Second\n\t}\n\n\treturn timescale\n}\n\nfunc braillePoint(point image.Point) image.Point {\n\treturn image.Point{X: point.X * xBrailleMultiplier, Y: point.Y * yBrailleMultiplier}\n}\n"
  },
  {
    "path": "component/sparkline/sparkline.go",
    "content": "package sparkline\n\nimport (\n\tui \"github.com/gizak/termui/v3\"\n\t\"github.com/sqshq/sampler/component\"\n\t\"github.com/sqshq/sampler/component/util\"\n\t\"github.com/sqshq/sampler/config\"\n\t\"github.com/sqshq/sampler/console\"\n\t\"github.com/sqshq/sampler/data\"\n\t\"image\"\n\t\"sync\"\n)\n\n// SparkLine displays general shape of a measurement variation over time\ntype SparkLine struct {\n\t*ui.Block\n\t*data.Consumer\n\tvalues   []float64\n\tmaxValue float64\n\tminValue float64\n\tscale    int\n\tgradient []ui.Color\n\tpalette  console.Palette\n\tmutex    *sync.Mutex\n}\n\nfunc NewSparkLine(c config.SparkLineConfig, palette console.Palette) *SparkLine {\n\n\tline := &SparkLine{\n\t\tBlock:    component.NewBlock(c.Title, true, palette),\n\t\tConsumer: data.NewConsumer(),\n\t\tvalues:   []float64{},\n\t\tscale:    *c.Scale,\n\t\tgradient: *c.Gradient,\n\t\tpalette:  palette,\n\t\tmutex:    &sync.Mutex{},\n\t}\n\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase sample := <-line.SampleChannel:\n\t\t\t\tline.consumeSample(sample)\n\t\t\tcase alert := <-line.AlertChannel:\n\t\t\t\tline.Alert = alert\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn line\n}\n\nfunc (s *SparkLine) consumeSample(sample *data.Sample) {\n\n\tfloat, err := util.ParseFloat(sample.Value)\n\tif err != nil {\n\t\ts.HandleConsumeFailure(\"Failed to parse a number\", err, sample)\n\t\treturn\n\t}\n\n\ts.HandleConsumeSuccess()\n\n\ts.values = append(s.values, float)\n\tmax, min := s.values[0], s.values[0]\n\n\tfor i := len(s.values) - 1; i >= 0; i-- {\n\t\tif len(s.values)-i > s.Dx() {\n\t\t\tbreak\n\t\t}\n\t\tif s.values[i] > max {\n\t\t\tmax = s.values[i]\n\t\t}\n\t\tif s.values[i] < min {\n\t\t\tmin = s.values[i]\n\t\t}\n\t}\n\n\ts.maxValue = max\n\ts.minValue = min\n\n\tif len(s.values)%100 == 0 {\n\t\ts.mutex.Lock()\n\t\ts.trimOutOfRangeValues(s.Dx())\n\t\ts.mutex.Unlock()\n\t}\n}\n\nfunc (s *SparkLine) trimOutOfRangeValues(maxSize int) {\n\tif maxSize < len(s.values) {\n\t\ts.values = append(s.values[:0], s.values[len(s.values)-maxSize:]...)\n\t}\n}\n\nfunc (s *SparkLine) Draw(buffer *ui.Buffer) {\n\n\ts.mutex.Lock()\n\n\ttextStyle := ui.NewStyle(s.palette.BaseColor)\n\n\theight := s.Dy() - 2\n\tminValue := util.FormatValue(s.minValue, s.scale)\n\tmaxValue := util.FormatValue(s.maxValue, s.scale)\n\tcurValue := util.FormatValue(0, s.scale)\n\n\tif len(s.values) > 0 {\n\t\tcurValue = util.FormatValue(s.values[len(s.values)-1], s.scale)\n\t}\n\n\tindent := 2 + util.Max([]int{\n\t\tlen(minValue), len(maxValue), len(curValue),\n\t})\n\n\tfor i := len(s.values) - 1; i >= 0; i-- {\n\n\t\tn := len(s.values) - i\n\n\t\tif n > s.Dx()-indent-3 {\n\t\t\tbreak\n\t\t}\n\n\t\ttop := 0\n\n\t\tif s.maxValue != s.minValue {\n\t\t\ttop = int((s.values[i] - s.minValue) * float64(height) / (s.maxValue - s.minValue))\n\t\t}\n\n\t\tfor j := 0; j <= top; j++ {\n\t\t\tbuffer.SetCell(ui.NewCell(console.SymbolVerticalBar, ui.NewStyle(console.GetGradientColor(s.gradient, j, height))), image.Pt(s.Inner.Max.X-n-indent, s.Inner.Max.Y-j-1))\n\t\t}\n\n\t\tif i == len(s.values)-1 {\n\t\t\tbuffer.SetString(curValue, textStyle, image.Pt(s.Inner.Max.X-n-indent+2, s.Inner.Max.Y-top-1))\n\t\t\tif s.maxValue != s.minValue {\n\t\t\t\tbuffer.SetString(minValue, textStyle, image.Pt(s.Inner.Max.X-n-indent+2, s.Max.Y-2))\n\t\t\t\tbuffer.SetString(maxValue, textStyle, image.Pt(s.Inner.Max.X-n-indent+2, s.Min.Y+1))\n\t\t\t}\n\t\t}\n\t}\n\n\ts.mutex.Unlock()\n\n\ts.Block.Draw(buffer)\n\tcomponent.RenderAlert(s.Alert, s.Rectangle, buffer)\n}\n"
  },
  {
    "path": "component/sparkline/sparkline_test.go",
    "content": "package sparkline\n\nimport (\n\t\"testing\"\n)\n\nfunc TestSparkLine_trimOutOfRangeValues(t *testing.T) {\n\ttype Sparkline struct {\n\t\tmaxSize      int\n\t\texpectedSize int\n\t\tvalues       []float64\n\t}\n\ttests := []struct {\n\t\tname      string\n\t\tsparkline Sparkline\n\t}{\n\t\t{\"should trimOutOfRangeValues values to the max size\", Sparkline{maxSize: 5, expectedSize: 5, values: []float64{1, 2, 3, 4, 5, 6, 7, 8}}},\n\t\t{\"should not trimOutOfRangeValues values if max size is bigger than values len\", Sparkline{maxSize: 5, expectedSize: 3, values: []float64{1, 2, 3}}},\n\t}\n\tfor _, tt := range tests {\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\ts := &SparkLine{\n\t\t\t\tvalues: tt.sparkline.values,\n\t\t\t}\n\t\t\ts.trimOutOfRangeValues(tt.sparkline.maxSize)\n\t\t\tif len(s.values) != tt.sparkline.expectedSize {\n\t\t\t\tt.Errorf(\"Values size after trimOutOfRangeValues is %v, but needed to be %v\", len(s.values), tt.sparkline.expectedSize)\n\t\t\t}\n\t\t})\n\t}\n}\n"
  },
  {
    "path": "component/statusbar.go",
    "content": "package component\n\nimport (\n\t\"fmt\"\n\tui \"github.com/gizak/termui/v3\"\n\t\"github.com/sqshq/sampler/console\"\n\t\"image\"\n)\n\nconst (\n\tpauseText      = \"  P A U S E D  \"\n\tbindingsIndent = 3\n)\n\ntype StatusBar struct {\n\t*ui.Block\n\tkeyBindings []string\n\ttext        string\n\tpause       bool\n}\n\nfunc NewStatusBar(configFileName string, palette console.Palette) *StatusBar {\n\n\tblock := *ui.NewBlock()\n\tblock.Border = false\n\ttext := fmt.Sprintf(\" %s %s @ %s\", console.AppTitle, console.AppVersion, configFileName)\n\n\treturn &StatusBar{\n\t\tBlock: NewBlock(\"\", false, palette),\n\t\ttext:  text,\n\t\tkeyBindings: []string{\n\t\t\t\"(q) quit\",\n\t\t\t\"(p) pause\",\n\t\t\t\"(<->) selection\",\n\t\t\t\"(ESC) reset alerts\",\n\t\t},\n\t}\n}\n\nfunc (s *StatusBar) Draw(buffer *ui.Buffer) {\n\n\tbuffer.Fill(ui.NewCell(' ', ui.NewStyle(console.ColorClear, console.GetMenuColorReverse())), s.GetRect())\n\n\tindent := bindingsIndent\n\tfor _, binding := range s.keyBindings {\n\t\tbuffer.SetString(binding, ui.NewStyle(console.GetMenuColor(), console.GetMenuColorReverse()), image.Pt(s.Max.X-len(binding)-indent, s.Min.Y))\n\t\tindent += bindingsIndent + len(binding)\n\t}\n\n\tbuffer.SetString(s.text, ui.NewStyle(console.GetMenuColor(), console.GetMenuColorReverse()), s.Min)\n\n\tif s.pause {\n\t\tbuffer.SetString(pauseText, ui.NewStyle(console.GetMenuColorReverse(), console.GetMenuColor()), image.Pt(s.Max.X-s.Dx()/2-len(pauseText)/2, s.Min.Y))\n\t}\n\n\ts.Block.Draw(buffer)\n}\n\nfunc (s *StatusBar) TogglePause() {\n\ts.pause = !s.pause\n}\n"
  },
  {
    "path": "component/textbox/textbox.go",
    "content": "package textbox\n\nimport (\n\tui \"github.com/gizak/termui/v3\"\n\t\"github.com/sqshq/sampler/component\"\n\t\"github.com/sqshq/sampler/config\"\n\t\"github.com/sqshq/sampler/console\"\n\t\"github.com/sqshq/sampler/data\"\n\t\"image\"\n)\n\n// TextBox represents a component with regular text\ntype TextBox struct {\n\t*ui.Block\n\t*data.Consumer\n\talert  *data.Alert\n\ttext   string\n\tborder bool\n\tstyle  ui.Style\n}\n\nfunc NewTextBox(c config.TextBoxConfig, palette console.Palette) *TextBox {\n\n\tcolor := c.Color\n\tif color == nil {\n\t\tcolor = &palette.BaseColor\n\t}\n\n\tbox := TextBox{\n\t\tBlock:    component.NewBlock(c.Title, *c.Border, palette),\n\t\tConsumer: data.NewConsumer(),\n\t\tstyle:    ui.NewStyle(*color),\n\t}\n\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase sample := <-box.SampleChannel:\n\t\t\t\tbox.text = sample.Value\n\t\t\tcase alert := <-box.AlertChannel:\n\t\t\t\tbox.alert = alert\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn &box\n}\n\nfunc (t *TextBox) Draw(buffer *ui.Buffer) {\n\n\tt.Block.Draw(buffer)\n\n\tcells := ui.ParseStyles(t.text, ui.Theme.Paragraph.Text)\n\tcells = ui.WrapCells(cells, uint(t.Inner.Dx()-2))\n\n\trows := ui.SplitCells(cells, '\\n')\n\n\tfor y, row := range rows {\n\t\tif y+t.Inner.Min.Y >= t.Inner.Max.Y-1 {\n\t\t\tbreak\n\t\t}\n\t\trow = ui.TrimCells(row, t.Inner.Dx()-2)\n\t\tfor _, cx := range ui.BuildCellWithXArray(row) {\n\t\t\tx, cell := cx.X, cx.Cell\n\t\t\tcell.Style = t.style\n\t\t\tbuffer.SetCell(cell, image.Pt(x+1, y+1).Add(t.Inner.Min))\n\t\t}\n\t}\n\n\tcomponent.RenderAlert(t.alert, t.Rectangle, buffer)\n}\n"
  },
  {
    "path": "component/util/format.go",
    "content": "package util\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\tui \"github.com/gizak/termui/v3\"\n\t\"image\"\n\t\"math\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nvar AsciiLogo = []string{\n\t\"                               __         \",\n\t\"   _________  ____ ___  ____  / /__  _____\",\n\t\"  / ___/ __ `/ __ `__ \\\\/ __ \\\\/ / _ \\\\/ ___/\",\n\t\" (__  ) /_/ / / / / / / /_/ / /  __/ /    \",\n\t\"/____/\\\\__,_/_/ /_/ /_/ .___/_/\\\\___/_/     \",\n\t\"                    /_/                   \",\n}\n\nfunc FormatValue(value float64, scale int) string {\n\tif math.Abs(value) == math.MaxFloat64 {\n\t\treturn \"Inf\"\n\t}\n\treturn formatTrailingDigits(addRadixChars(value), scale)\n}\n\nfunc FormatDelta(value float64, scale int) string {\n\n\tabs := math.Abs(value)\n\tval := value\n\tscl := scale\n\n\tpostfix := \"\"\n\n\tif abs > 1000 && abs < 1000000 {\n\t\tval = float64(value) / 1000\n\t\tpostfix = \"k\"\n\t} else if abs > 1000000 && abs < 1000000000 {\n\t\tval = float64(value) / 1000000\n\t\tpostfix = \"M\"\n\t} else if abs > 1000000000 {\n\t\tval = float64(value) / 1000000000\n\t\tpostfix = \"B\"\n\t}\n\n\tif abs > 1000 {\n\t\tscl = 1\n\t}\n\n\tif val == 0 {\n\t\treturn \" 0\"\n\t} else if val > 0 {\n\t\treturn fmt.Sprintf(\"+%s%s\", FormatValue(val, scl), postfix)\n\t} else {\n\t\treturn fmt.Sprintf(\"%s%s\", FormatValue(val, scl), postfix)\n\t}\n}\n\nfunc addRadixChars(value float64) string {\n\tbuf := &bytes.Buffer{}\n\tif value < 0 {\n\t\tbuf.Write([]byte{'-'})\n\t\tvalue = 0 - value\n\t}\n\n\tradix := []byte{','}\n\n\tparts := strings.Split(strconv.FormatFloat(value, 'f', -1, 64), \".\")\n\tpos := 0\n\tif len(parts[0])%3 != 0 {\n\t\tpos += len(parts[0]) % 3\n\t\tbuf.WriteString(parts[0][:pos])\n\t\tbuf.Write(radix)\n\t}\n\tfor ; pos < len(parts[0]); pos += 3 {\n\t\tbuf.WriteString(parts[0][pos : pos+3])\n\t\tbuf.Write(radix)\n\t}\n\tbuf.Truncate(buf.Len() - 1)\n\n\tif len(parts) > 1 {\n\t\tbuf.Write([]byte{'.'})\n\t\tbuf.WriteString(parts[1])\n\t}\n\treturn buf.String()\n}\n\nfunc formatTrailingDigits(value string, scale int) string {\n\n\tif i := strings.Index(value, \".\"); i >= 0 {\n\n\t\tformatted := value\n\n\t\tif scale <= 0 {\n\t\t\tformatted = value[:i]\n\t\t}\n\n\t\ti++\n\t\tif i+scale < len(value) {\n\t\t\tformatted = value[:i+scale]\n\t\t}\n\n\t\tformatted = strings.TrimRight(formatted, \"0\")\n\n\t\treturn strings.TrimRight(formatted, \".\")\n\t}\n\n\treturn value\n}\n\nfunc GetMiddlePoint(rectangle image.Rectangle, text string, offset int) image.Point {\n\treturn image.Pt(rectangle.Min.X+rectangle.Dx()/2-len(text)/2, rectangle.Max.Y-rectangle.Dy()/2+offset)\n}\n\nfunc PrintString(s string, style ui.Style, p image.Point, buffer *ui.Buffer) {\n\tfor i, char := range s {\n\t\tbuffer.SetCell(ui.Cell{Rune: char, Style: style}, image.Pt(p.X+i, p.Y))\n\t}\n}\n"
  },
  {
    "path": "component/util/format_test.go",
    "content": "package util\n\nimport \"testing\"\n\nfunc TestFormatValue(t *testing.T) {\n\ttype args struct {\n\t\tvalue float64\n\t\tscale int\n\t}\n\ttests := []struct {\n\t\tname string\n\t\targs args\n\t\twant string\n\t}{\n\t\t{\"should format float value with scale = 1\", args{94.123, 1}, \"94.1\"},\n\t\t{\"should format float value with scale = 0\", args{94.123, 0}, \"94\"},\n\t\t{\"should format float value with trailing zeros\", args{94.100, 5}, \"94.1\"},\n\t\t{\"should format float value with radix char and trailing zeros\", args{9423000.00123, 2}, \"9,423,000\"},\n\t}\n\tfor _, tt := range tests {\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tif got := FormatValue(tt.args.value, tt.args.scale); got != tt.want {\n\t\t\t\tt.Errorf(\"FormatValue() = %v, want %v\", got, tt.want)\n\t\t\t}\n\t\t})\n\t}\n}\n"
  },
  {
    "path": "component/util/geometry.go",
    "content": "package util\n\nimport (\n\t\"image\"\n)\n\nfunc GetRectLeftSideCenter(rect image.Rectangle) image.Point {\n\treturn image.Point{\n\t\tX: rect.Min.X,\n\t\tY: rect.Min.Y + rect.Dy()/2,\n\t}\n}\n\nfunc GetRectRightSideCenter(rect image.Rectangle) image.Point {\n\treturn image.Point{\n\t\tX: rect.Max.X,\n\t\tY: rect.Min.Y + rect.Dy()/2,\n\t}\n}\n\nfunc GetRectTopSideCenter(rect image.Rectangle) image.Point {\n\treturn image.Point{\n\t\tX: rect.Min.X + rect.Dx()/2,\n\t\tY: rect.Min.Y,\n\t}\n}\n\nfunc GetRectBottomSideCenter(rect image.Rectangle) image.Point {\n\treturn image.Point{\n\t\tX: rect.Min.X + rect.Dx()/2,\n\t\tY: rect.Max.Y,\n\t}\n}\n\nfunc GetRectCoordinates(area image.Rectangle, width int, height int) (int, int, int, int) {\n\tx1 := area.Min.X + area.Dx()/2 - width/2\n\ty1 := area.Min.Y + area.Dy()/2 - height\n\treturn x1, y1, x1 + width, y1 + height + 2\n}\n"
  },
  {
    "path": "component/util/geometry_test.go",
    "content": "package util\n\nimport \"testing\"\nimport \"image\"\n\nfunc TestGetRectLeftSideCenter(t *testing.T) {\n\trect := image.Rect(10, 10, 20, 20)\n\texpected := image.Point{\n\t\tX: 10,\n\t\tY: 15,\n\t}\n\tresult := GetRectLeftSideCenter(rect)\n\tif result != expected {\n\t\tt.Errorf(\"GetRectLeftSideCenter was incorrect. Expected %v, got %v.\", expected, result)\n\t}\n}\n\nfunc TestGetRectRightSideCenter(t *testing.T) {\n\trect := image.Rect(10, 10, 20, 21)\n\texpected := image.Point{\n\t\tX: 20,\n\t\tY: 15,\n\t}\n\tresult := GetRectRightSideCenter(rect)\n\tif result != expected {\n\t\tt.Errorf(\"GetRectRightSideCenter was incorrect. Expected %v, got %v.\", expected, result)\n\t}\n}\n\nfunc TestGetRectTopSideCenter(t *testing.T) {\n\trect := image.Rect(10, 10, 20, 20)\n\texpected := image.Point{\n\t\tX: 15,\n\t\tY: 10,\n\t}\n\tresult := GetRectTopSideCenter(rect)\n\tif result != expected {\n\t\tt.Errorf(\"GetRectTopSideCenter was incorrect. Expected %v, got %v.\", expected, result)\n\t}\n}\n\nfunc TestGetRectBottomSideCenter(t *testing.T) {\n\trect := image.Rect(10, 9, 20, 20)\n\texpected := image.Point{\n\t\tX: 15,\n\t\tY: 20,\n\t}\n\tresult := GetRectBottomSideCenter(rect)\n\tif result != expected {\n\t\tt.Errorf(\"GetRectBottomSideCenter was incorrect. Expected %v, got %v.\", expected, result)\n\t}\n}\n"
  },
  {
    "path": "component/util/math.go",
    "content": "package util\n\nfunc Max(numbers []int) int {\n\n\tmax := numbers[0]\n\n\tfor _, n := range numbers {\n\t\tif n > max {\n\t\t\tmax = n\n\t\t}\n\t}\n\n\treturn max\n}\n"
  },
  {
    "path": "component/util/parse.go",
    "content": "package util\n\nimport (\n\t\"strconv\"\n\t\"strings\"\n)\n\nfunc ParseFloat(input string) (float64, error) {\n\n\tclean := strings.TrimSpace(input)\n\tclean = strings.Replace(clean, \",\", \".\", -1) // replace decimal comma with decimal point\n\n\tif strings.Contains(clean, \"\\n\") {\n\t\tlastIndex := strings.LastIndex(clean, \"\\n\")\n\t\tclean = clean[lastIndex+1:]\n\t}\n\n\treturn strconv.ParseFloat(clean, 64)\n}\n"
  },
  {
    "path": "component/util/parse_test.go",
    "content": "package util\n\nimport \"testing\"\n\nfunc TestParseFloat(t *testing.T) {\n\ttype args struct {\n\t\tinput string\n\t}\n\ttests := []struct {\n\t\tname    string\n\t\targs    args\n\t\twant    float64\n\t\twantErr bool\n\t}{\n\t\t{\"should parse a regular number\", args{\"123\"}, 123, false},\n\t\t{\"should parse a float with decimal point\", args{\"123.456\"}, 123.456, false},\n\t\t{\"should parse a float with decimal comma\", args{\"123,456\"}, 123.456, false},\n\t\t{\"should parse a regular number with spaces, tabs and line breaks\", args{\"         \\t 123 \\t \\n    \"}, 123, false},\n\t\t{\"should parse a last line in the given string\", args{\"123\\n456\"}, 456, false},\n\t}\n\tfor _, tt := range tests {\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tgot, err := ParseFloat(tt.args.input)\n\t\t\tif (err != nil) != tt.wantErr {\n\t\t\t\tt.Errorf(\"ParseFloat() error = %v, wantErr %v\", err, tt.wantErr)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif got != tt.want {\n\t\t\t\tt.Errorf(\"ParseFloat() = %v, want %v\", got, tt.want)\n\t\t\t}\n\t\t})\n\t}\n}\n"
  },
  {
    "path": "config/arrangement.go",
    "content": "package config\n\nimport (\n\tui \"github.com/gizak/termui/v3\"\n\t\"github.com/sqshq/sampler/console\"\n\t\"image\"\n)\n\nfunc (c *Config) setDefaultArrangement() {\n\n\tcomponents := getComponents(c)\n\n\tif allHaveNoPosition(components) {\n\t\tsetSingleComponentPosition(components[0])\n\t}\n\n\tfor _, component := range components {\n\t\tif component.Position == nil || len(component.Position) == 0 {\n\n\t\t\tlc := getLargestComponent(components)\n\t\t\tle := getLargestEmptySpaceRectangle(components)\n\n\t\t\tif getSquare(lc) > le.Dx()*le.Dy()*2 {\n\t\t\t\tarrangeIntoLargestComponent(component, lc)\n\t\t\t} else {\n\t\t\t\tarrangeIntoLargestEmptySpace(component, le)\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc arrangeIntoLargestComponent(component *ComponentConfig, lc *ComponentConfig) {\n\n\tlr := lc.GetRectangle()\n\tvar w, h, ws, hs int\n\n\tif lr.Dx()/2 > lr.Dy() {\n\t\tw = lr.Dx() / 2\n\t\th = lr.Dy()\n\t\tws = w\n\t\ths = 0\n\t} else {\n\t\tw = lr.Dx()\n\t\th = lr.Dy() / 2\n\t\tws = 0\n\t\ths = h\n\t}\n\tcomponent.Position = [][]int{\n\t\t{lr.Min.X + ws, lr.Min.Y + hs},\n\t\t{w, h},\n\t}\n\tlc.Position = [][]int{\n\t\t{lr.Min.X, lr.Min.Y},\n\t\t{w, h},\n\t}\n}\n\nfunc arrangeIntoLargestEmptySpace(component *ComponentConfig, le image.Rectangle) {\n\tcomponent.Position = [][]int{\n\t\t{le.Min.X, le.Min.Y},\n\t\t{le.Dx(), le.Dy()},\n\t}\n}\n\nfunc allHaveNoPosition(components []*ComponentConfig) bool {\n\tfor _, component := range components {\n\t\tif component.Position != nil {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n\nfunc getLargestComponent(components []*ComponentConfig) *ComponentConfig {\n\n\tlargestComponent := components[0]\n\n\tfor _, component := range components {\n\t\tif getSquare(component) > getSquare(largestComponent) {\n\t\t\tlargestComponent = component\n\t\t}\n\t}\n\n\treturn largestComponent\n}\n\nfunc getSquare(c *ComponentConfig) int {\n\tr := c.GetRectangle()\n\treturn r.Dx() * r.Dy()\n}\n\nfunc getComponents(c *Config) []*ComponentConfig {\n\n\tvar components []*ComponentConfig\n\n\tfor i := range c.RunCharts {\n\t\tcomponents = append(components, &c.RunCharts[i].ComponentConfig)\n\t}\n\tfor i := range c.BarCharts {\n\t\tcomponents = append(components, &c.BarCharts[i].ComponentConfig)\n\t}\n\tfor i := range c.Gauges {\n\t\tcomponents = append(components, &c.Gauges[i].ComponentConfig)\n\t}\n\tfor i := range c.SparkLines {\n\t\tcomponents = append(components, &c.SparkLines[i].ComponentConfig)\n\t}\n\tfor i := range c.AsciiBoxes {\n\t\tcomponents = append(components, &c.AsciiBoxes[i].ComponentConfig)\n\t}\n\tfor i := range c.TextBoxes {\n\t\tcomponents = append(components, &c.TextBoxes[i].ComponentConfig)\n\t}\n\n\treturn components\n}\n\nfunc setSingleComponentPosition(c *ComponentConfig) {\n\tw := int(console.ColumnsCount)\n\th := int(console.RowsCount * 0.6)\n\tc.Position = [][]int{\n\t\t{(console.ColumnsCount - w) / 2, (console.RowsCount - h) / 2},\n\t\t{w, h},\n\t}\n}\n\nfunc getLargestEmptySpaceRectangle(components []*ComponentConfig) image.Rectangle {\n\n\tgrid := [console.RowsCount][console.ColumnsCount]int{}\n\n\tfor _, component := range components {\n\t\trect := component.GetRectangle()\n\t\tfor r := ui.MinInt(console.RowsCount, rect.Min.Y); r < ui.MinInt(console.RowsCount, rect.Max.Y); r++ {\n\t\t\tfor c := ui.MinInt(console.ColumnsCount, rect.Min.X); c < ui.MinInt(console.ColumnsCount, rect.Max.X); c++ {\n\t\t\t\tgrid[r][c] = 1\n\t\t\t}\n\t\t}\n\t}\n\n\tmr := image.ZR\n\n\tfor row := 0; row < console.RowsCount; row++ {\n\t\thistogram := createHistogram(grid, row)\n\t\tr := calcMaxRectangle(histogram, row)\n\t\tif r.Dx()*r.Dy() > mr.Dx()*mr.Dy() {\n\t\t\tmr = r\n\t\t}\n\t}\n\n\treturn mr\n}\n\nfunc calcMaxRectangle(histogram [console.ColumnsCount]int, row int) image.Rectangle {\n\n\tmaxRectangle := image.ZR\n\tmaxArea := 0\n\n\tfor i := 0; i < len(histogram); i++ {\n\n\t\theight := histogram[i]\n\t\tif height > maxArea {\n\t\t\tmaxArea = height\n\t\t\tmaxRectangle = image.Rect(i, row, i, row+height)\n\t\t}\n\n\t\tfor j := i - 1; j >= 0; j-- {\n\t\t\twidth := i - j + 1\n\t\t\theight = ui.MinInt(height, histogram[j])\n\t\t\tif width*height > maxArea {\n\t\t\t\tmaxArea = width * height\n\t\t\t\tmaxRectangle = image.Rect(j, row, j+width, row+height)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn maxRectangle\n}\n\nfunc createHistogram(grid [console.RowsCount][console.ColumnsCount]int, row int) [console.ColumnsCount]int {\n\thistogram := [console.ColumnsCount]int{}\n\tfor column := 0; column < console.ColumnsCount; column++ {\n\t\thistogram[column] = countEmptyCellsBelow(grid, row, column)\n\t}\n\treturn histogram\n}\n\nfunc countEmptyCellsBelow(grid [console.RowsCount][console.ColumnsCount]int, row int, column int) int {\n\tcount := 0\n\tfor r := row; r < console.RowsCount; r++ {\n\t\tif grid[r][column] == 1 {\n\t\t\treturn count\n\t\t}\n\t\tcount++\n\t}\n\treturn count\n}\n"
  },
  {
    "path": "config/component.go",
    "content": "package config\n\nimport (\n\tui \"github.com/gizak/termui/v3\"\n\t\"github.com/sqshq/sampler/console\"\n\t\"image\"\n)\n\ntype ComponentType rune\n\nconst (\n\tTypeRunChart  ComponentType = 0\n\tTypeBarChart  ComponentType = 1\n\tTypeSparkLine ComponentType = 2\n\tTypeTextBox   ComponentType = 3\n\tTypeAsciiBox  ComponentType = 4\n\tTypeGauge     ComponentType = 5\n)\n\ntype ComponentConfig struct {\n\tTitle    string          `yaml:\"title\"`\n\tPosition [][]int         `yaml:\"position,flow\"`\n\tRateMs   *int            `yaml:\"rate-ms,omitempty\"`\n\tTriggers []TriggerConfig `yaml:\"triggers,omitempty\"`\n\tType     ComponentType   `yaml:\",omitempty\"`\n}\n\nfunc (c *ComponentConfig) GetLocation() Location {\n\treturn Location{X: c.Position[0][0], Y: c.Position[0][1]}\n}\n\nfunc (c *ComponentConfig) GetSize() Size {\n\treturn Size{X: c.Position[1][0], Y: c.Position[1][1]}\n}\n\nfunc (c *ComponentConfig) GetRectangle() image.Rectangle {\n\tif c.Position == nil || len(c.Position) == 0 {\n\t\treturn image.ZR\n\t}\n\treturn image.Rect(\n\t\tc.Position[0][0],\n\t\tc.Position[0][1],\n\t\tc.Position[0][0]+c.Position[1][0],\n\t\tc.Position[0][1]+c.Position[1][1])\n}\n\ntype TriggerConfig struct {\n\tTitle     string         `yaml:\"title\"`\n\tCondition string         `yaml:\"condition\"`\n\tActions   *ActionsConfig `yaml:\"actions,omitempty\"`\n}\n\ntype ActionsConfig struct {\n\tTerminalBell *bool   `yaml:\"terminal-bell,omitempty\"`\n\tSound        *bool   `yaml:\"sound,omitempty\"`\n\tVisual       *bool   `yaml:\"visual,omitempty\"`\n\tScript       *string `yaml:\"script,omitempty\"`\n}\n\ntype GaugeConfig struct {\n\tComponentConfig `yaml:\",inline\"`\n\tScale           *int      `yaml:\"scale,omitempty\"`\n\tColor           *ui.Color `yaml:\"color,omitempty\"`\n\tPercentOnly     *bool     `yaml:\"percent-only,omitempty\"`\n\tCur             Item      `yaml:\"cur\"`\n\tMax             Item      `yaml:\"max\"`\n\tMin             Item      `yaml:\"min\"`\n}\n\ntype SparkLineConfig struct {\n\tComponentConfig `yaml:\",inline\"`\n\tScale           *int        `yaml:\"scale,omitempty\"`\n\tItem            Item        `yaml:\",inline\"`\n\tGradient        *[]ui.Color `yaml:\",omitempty\"`\n}\n\ntype BarChartConfig struct {\n\tComponentConfig `yaml:\",inline\"`\n\tScale           *int   `yaml:\"scale,omitempty\"`\n\tItems           []Item `yaml:\"items\"`\n}\n\ntype AsciiBoxConfig struct {\n\tComponentConfig `yaml:\",inline\"`\n\tItem            `yaml:\",inline\"`\n\tBorder          *bool              `yaml:\"border,omitempty\"`\n\tFont            *console.AsciiFont `yaml:\"font,omitempty\"`\n}\n\ntype TextBoxConfig struct {\n\tComponentConfig `yaml:\",inline\"`\n\tItem            `yaml:\",inline\"`\n\tBorder          *bool `yaml:\"border,omitempty\"`\n}\n\ntype RunChartConfig struct {\n\tComponentConfig `yaml:\",inline\"`\n\tLegend          *LegendConfig `yaml:\"legend,omitempty\"`\n\tScale           *int          `yaml:\"scale,omitempty\"`\n\tItems           []Item        `yaml:\"items\"`\n}\n\ntype LegendConfig struct {\n\tEnabled bool `yaml:\"enabled\"`\n\tDetails bool `yaml:\"details\"`\n}\n\ntype Item struct {\n\tLabel               *string   `yaml:\"label,omitempty\"`\n\tColor               *ui.Color `yaml:\"color,omitempty\"`\n\tPty                 *bool     `yaml:\"pty,omitempty\"`\n\tInitScript          *string   `yaml:\"init,omitempty\"`\n\tMultiStepInitScript *[]string `yaml:\"multistep-init,omitempty\"`\n\tSampleScript        *string   `yaml:\"sample\"`\n\tTransformScript     *string   `yaml:\"transform,omitempty\"`\n}\n\ntype Location struct {\n\tX int\n\tY int\n}\n\ntype Size struct {\n\tX int\n\tY int\n}\n\ntype ComponentSettings struct {\n\tType     ComponentType\n\tTitle    string\n\tSize     Size\n\tLocation Location\n}\n\nfunc getPosition(location Location, size Size) [][]int {\n\treturn [][]int{\n\t\t{location.X, location.Y},\n\t\t{size.X, size.Y},\n\t}\n}\n"
  },
  {
    "path": "config/config.go",
    "content": "package config\n\nimport (\n\t\"fmt\"\n\t\"github.com/jessevdk/go-flags\"\n\t\"github.com/sqshq/sampler/console\"\n\t\"gopkg.in/yaml.v3\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n)\n\ntype Config struct {\n\tTheme      *console.Theme    `yaml:\"theme,omitempty\"`\n\tVariables  map[string]string `yaml:\"variables,omitempty\"`\n\tRunCharts  []RunChartConfig  `yaml:\"runcharts,omitempty\"`\n\tBarCharts  []BarChartConfig  `yaml:\"barcharts,omitempty\"`\n\tGauges     []GaugeConfig     `yaml:\"gauges,omitempty\"`\n\tSparkLines []SparkLineConfig `yaml:\"sparklines,omitempty\"`\n\tTextBoxes  []TextBoxConfig   `yaml:\"textboxes,omitempty\"`\n\tAsciiBoxes []AsciiBoxConfig  `yaml:\"asciiboxes,omitempty\"`\n}\n\nfunc LoadConfig() (*Config, Options) {\n\n\tvar opt Options\n\t_, err := flags.Parse(&opt)\n\n\tif err != nil {\n\t\tconsole.Exit(\"\")\n\t}\n\n\tif opt.Version == true {\n\t\tconsole.Exit(console.AppVersion)\n\t}\n\n\tif opt.ConfigFile == nil {\n\t\tconsole.Exit(\"Please specify config file using --config flag. Example: sampler --config example.yml\")\n\t}\n\n\tcfg := readFile(opt.ConfigFile)\n\tcfg.validate()\n\tcfg.setDefaults()\n\n\treturn cfg, opt\n}\n\nfunc Update(settings []ComponentSettings, options Options) {\n\tcfg := readFile(options.ConfigFile)\n\tfor _, s := range settings {\n\t\tcomponentConfig := cfg.findComponent(s.Type, s.Title)\n\t\tcomponentConfig.Position = getPosition(s.Location, s.Size)\n\t}\n\tsaveFile(cfg, options.ConfigFile)\n}\n\nfunc (c *Config) findComponent(componentType ComponentType, componentTitle string) *ComponentConfig {\n\n\tswitch componentType {\n\tcase TypeRunChart:\n\t\tfor i, component := range c.RunCharts {\n\t\t\tif component.Title == componentTitle {\n\t\t\t\treturn &c.RunCharts[i].ComponentConfig\n\t\t\t}\n\t\t}\n\tcase TypeBarChart:\n\t\tfor i, component := range c.BarCharts {\n\t\t\tif component.Title == componentTitle {\n\t\t\t\treturn &c.BarCharts[i].ComponentConfig\n\t\t\t}\n\t\t}\n\tcase TypeGauge:\n\t\tfor i, component := range c.Gauges {\n\t\t\tif component.Title == componentTitle {\n\t\t\t\treturn &c.Gauges[i].ComponentConfig\n\t\t\t}\n\t\t}\n\tcase TypeSparkLine:\n\t\tfor i, component := range c.SparkLines {\n\t\t\tif component.Title == componentTitle {\n\t\t\t\treturn &c.SparkLines[i].ComponentConfig\n\t\t\t}\n\t\t}\n\tcase TypeAsciiBox:\n\t\tfor i, component := range c.AsciiBoxes {\n\t\t\tif component.Title == componentTitle {\n\t\t\t\treturn &c.AsciiBoxes[i].ComponentConfig\n\t\t\t}\n\t\t}\n\tcase TypeTextBox:\n\t\tfor i, component := range c.TextBoxes {\n\t\t\tif component.Title == componentTitle {\n\t\t\t\treturn &c.TextBoxes[i].ComponentConfig\n\t\t\t}\n\t\t}\n\t}\n\n\tpanic(fmt.Sprintf(\n\t\t\"Failed to find component type %v with title %v\", componentType, componentTitle))\n}\n\nfunc readFile(location *string) *Config {\n\n\tyamlFile, err := ioutil.ReadFile(*location)\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to read config file: %s\", *location)\n\t}\n\n\tcfg := new(Config)\n\terr = yaml.Unmarshal(yamlFile, cfg)\n\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to read config file: %v\", err)\n\t}\n\n\treturn cfg\n}\n\nfunc saveFile(config *Config, fileName *string) {\n\tfile, err := yaml.Marshal(config)\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to marshal config file: %v\", err)\n\t}\n\terr = ioutil.WriteFile(*fileName, file, os.ModePerm)\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to save config file: %v\", err)\n\t}\n}\n"
  },
  {
    "path": "config/default.go",
    "content": "package config\n\nimport (\n\t\"github.com/sqshq/sampler/console\"\n)\n\nconst (\n\tdefaultRateMs = 1000\n\tdefaultScale  = 1\n\tdefaultTheme  = console.ThemeDark\n)\n\nfunc (c *Config) setDefaults() {\n\tc.setDefaultValues()\n\tc.setDefaultItemSettings()\n\tc.setDefaultArrangement()\n}\n\nfunc (c *Config) setDefaultValues() {\n\n\tif c.Theme == nil {\n\t\tt := defaultTheme\n\t\tc.Theme = &t\n\t}\n\n\tfor i, chart := range c.RunCharts {\n\n\t\tsetDefaultTriggersValues(chart.Triggers)\n\t\tchart.ComponentConfig.Type = TypeRunChart\n\n\t\tif chart.RateMs == nil {\n\t\t\tr := defaultRateMs\n\t\t\tchart.RateMs = &r\n\t\t}\n\t\tif chart.Scale == nil {\n\t\t\tp := defaultScale\n\t\t\tchart.Scale = &p\n\t\t}\n\t\tif chart.Legend == nil {\n\t\t\tchart.Legend = &LegendConfig{true, true}\n\t\t\tc.RunCharts[i] = chart\n\t\t}\n\t\tc.RunCharts[i] = chart\n\t}\n\n\tfor i, line := range c.SparkLines {\n\n\t\tsetDefaultTriggersValues(line.Triggers)\n\t\tline.ComponentConfig.Type = TypeSparkLine\n\t\tline.Item.Label = &line.Title\n\n\t\tif line.RateMs == nil {\n\t\t\tr := defaultRateMs\n\t\t\tline.RateMs = &r\n\t\t}\n\t\tif line.Scale == nil {\n\t\t\tp := defaultScale\n\t\t\tline.Scale = &p\n\t\t}\n\t\tc.SparkLines[i] = line\n\t}\n\n\tfor i, chart := range c.BarCharts {\n\n\t\tsetDefaultTriggersValues(chart.Triggers)\n\t\tchart.ComponentConfig.Type = TypeBarChart\n\n\t\tif chart.RateMs == nil {\n\t\t\tr := defaultRateMs\n\t\t\tchart.RateMs = &r\n\t\t}\n\t\tif chart.Scale == nil {\n\t\t\tp := defaultScale\n\t\t\tchart.Scale = &p\n\t\t}\n\t\tc.BarCharts[i] = chart\n\t}\n\n\tfor i, g := range c.Gauges {\n\n\t\tsetDefaultTriggersValues(g.Triggers)\n\t\tg.ComponentConfig.Type = TypeGauge\n\n\t\tif g.RateMs == nil {\n\t\t\tr := defaultRateMs\n\t\t\tg.RateMs = &r\n\t\t}\n\t\tif g.Scale == nil {\n\t\t\tp := defaultScale\n\t\t\tg.Scale = &p\n\t\t}\n\n\t\tcur := \"cur\"\n\t\tmax := \"max\"\n\t\tmin := \"min\"\n\n\t\tg.Cur.Label = &cur\n\t\tg.Max.Label = &max\n\t\tg.Min.Label = &min\n\n\t\tc.Gauges[i] = g\n\t}\n\n\tfor i, box := range c.AsciiBoxes {\n\n\t\tsetDefaultTriggersValues(box.Triggers)\n\t\tbox.ComponentConfig.Type = TypeAsciiBox\n\n\t\tif box.RateMs == nil {\n\t\t\tr := defaultRateMs\n\t\t\tbox.RateMs = &r\n\t\t}\n\t\tif box.Label == nil {\n\t\t\tlabel := box.Title\n\t\t\tbox.Label = &label\n\t\t}\n\t\tif box.Font == nil {\n\t\t\tfont := console.AsciiFont2D\n\t\t\tbox.Font = &font\n\t\t}\n\t\tif box.Border == nil {\n\t\t\tborder := true\n\t\t\tbox.Border = &border\n\t\t}\n\t\tc.AsciiBoxes[i] = box\n\t}\n\n\tfor i, box := range c.TextBoxes {\n\n\t\tsetDefaultTriggersValues(box.Triggers)\n\t\tbox.ComponentConfig.Type = TypeTextBox\n\n\t\tif box.RateMs == nil {\n\t\t\tr := defaultRateMs\n\t\t\tbox.RateMs = &r\n\t\t}\n\t\tif box.Label == nil {\n\t\t\tlabel := box.Title\n\t\t\tbox.Label = &label\n\t\t}\n\t\tif box.Border == nil {\n\t\t\tborder := true\n\t\t\tbox.Border = &border\n\t\t}\n\n\t\tc.TextBoxes[i] = box\n\t}\n}\n\nfunc setDefaultTriggersValues(triggers []TriggerConfig) {\n\n\tdefaultTerminalBell := false\n\tdefaultSound := false\n\tdefaultVisual := false\n\n\tfor i, trigger := range triggers {\n\n\t\tif trigger.Actions == nil {\n\t\t\ttrigger.Actions = &ActionsConfig{TerminalBell: &defaultTerminalBell, Sound: &defaultSound, Visual: &defaultVisual, Script: nil}\n\t\t} else {\n\t\t\tif trigger.Actions.TerminalBell == nil {\n\t\t\t\ttrigger.Actions.TerminalBell = &defaultTerminalBell\n\t\t\t}\n\t\t\tif trigger.Actions.Sound == nil {\n\t\t\t\ttrigger.Actions.Sound = &defaultSound\n\t\t\t}\n\t\t\tif trigger.Actions.Visual == nil {\n\t\t\t\ttrigger.Actions.Visual = &defaultVisual\n\t\t\t}\n\t\t}\n\n\t\ttriggers[i] = trigger\n\t}\n}\n\nfunc (c *Config) setDefaultItemSettings() {\n\n\tpalette := console.GetPalette(*c.Theme)\n\tcolorsCount := len(palette.ContentColors)\n\tdefaultPty := false\n\tdefaultPercentOnly := false\n\n\tfor _, ch := range c.RunCharts {\n\t\tfor j, item := range ch.Items {\n\t\t\tif item.Color == nil {\n\t\t\t\titem.Color = &palette.ContentColors[j%colorsCount]\n\t\t\t}\n\t\t\tif item.Pty == nil {\n\t\t\t\titem.Pty = &defaultPty\n\t\t\t}\n\t\t\tch.Items[j] = item\n\t\t}\n\t}\n\n\tfor _, b := range c.BarCharts {\n\t\tfor j, item := range b.Items {\n\t\t\tif item.Color == nil {\n\t\t\t\titem.Color = &palette.ContentColors[j%colorsCount]\n\t\t\t}\n\t\t\tif item.Pty == nil {\n\t\t\t\titem.Pty = &defaultPty\n\t\t\t}\n\t\t\tb.Items[j] = item\n\t\t}\n\t}\n\n\tfor i, s := range c.SparkLines {\n\t\ts.Gradient = &palette.GradientColors[i%(len(palette.GradientColors))]\n\t\tif s.Item.Pty == nil {\n\t\t\ts.Item.Pty = &defaultPty\n\t\t}\n\t\tc.SparkLines[i] = s\n\t}\n\n\tfor i, g := range c.Gauges {\n\t\tif g.Min.Pty == nil {\n\t\t\tg.Min.Pty = &defaultPty\n\t\t}\n\t\tif g.Max.Pty == nil {\n\t\t\tg.Max.Pty = &defaultPty\n\t\t}\n\t\tif g.Cur.Pty == nil {\n\t\t\tg.Cur.Pty = &defaultPty\n\t\t}\n\t\tif g.Color == nil {\n\t\t\tg.Color = &palette.ContentColors[i%colorsCount]\n\t\t}\n\t\tif g.PercentOnly == nil {\n\t\t\tg.PercentOnly = &defaultPercentOnly\n\t\t}\n\t\tc.Gauges[i] = g\n\t}\n\n\tfor i, a := range c.AsciiBoxes {\n\t\tif a.Item.Pty == nil {\n\t\t\ta.Item.Pty = &defaultPty\n\t\t}\n\t\tc.AsciiBoxes[i] = a\n\t}\n\n\tfor i, t := range c.TextBoxes {\n\t\tif t.Item.Pty == nil {\n\t\t\tt.Item.Pty = &defaultPty\n\t\t}\n\t\tc.TextBoxes[i] = t\n\t}\n}\n"
  },
  {
    "path": "config/options.go",
    "content": "package config\n\n// Options with cli flags\ntype Options struct {\n\tConfigFile  *string  `short:\"c\" long:\"config\" description:\"Path to YAML config file\"`\n\tEnvironment []string `short:\"e\" long:\"env\" description:\"Specify name=value variable to use in script placeholder as $name. This flag takes precedence over the same name variables, specified in config yml\"`\n\tVersion     bool     `short:\"v\" long:\"version\" description:\"Print version\"`\n}\n"
  },
  {
    "path": "config/validator.go",
    "content": "package config\n\nimport (\n\t\"fmt\"\n\t\"github.com/sqshq/sampler/console\"\n)\n\nfunc (c *Config) validate() {\n\n\tvar components []ComponentConfig\n\n\tfor _, c := range c.RunCharts {\n\t\tcomponents = append(components, c.ComponentConfig)\n\t\tvalidateLabelsUniqueness(c.Title, c.Items)\n\t\tvalidateItemsScripts(c.Title, c.Items)\n\t}\n\tfor _, c := range c.BarCharts {\n\t\tcomponents = append(components, c.ComponentConfig)\n\t\tvalidateLabelsUniqueness(c.Title, c.Items)\n\t\tvalidateItemsScripts(c.Title, c.Items)\n\t}\n\tfor _, c := range c.SparkLines {\n\t\tcomponents = append(components, c.ComponentConfig)\n\t\tvalidateItemScripts(c.Title, c.Item)\n\t}\n\tfor _, c := range c.Gauges {\n\t\tcomponents = append(components, c.ComponentConfig)\n\t\tvalidateItemScripts(c.Title, c.Min)\n\t\tvalidateItemScripts(c.Title, c.Max)\n\t\tvalidateItemScripts(c.Title, c.Cur)\n\t}\n\tfor _, c := range c.AsciiBoxes {\n\t\tcomponents = append(components, c.ComponentConfig)\n\t\tvalidateItemScripts(c.Title, c.Item)\n\t}\n\tfor _, c := range c.TextBoxes {\n\t\tcomponents = append(components, c.ComponentConfig)\n\t\tvalidateItemScripts(c.Title, c.Item)\n\t}\n\n\tvalidateTitlesUniqueness(components)\n}\n\nfunc validateItemsScripts(title string, items []Item) {\n\tfor _, i := range items {\n\t\tvalidateItemScripts(title, i)\n\t}\n}\n\nfunc validateItemScripts(title string, i Item) {\n\tif i.InitScript != nil && i.MultiStepInitScript != nil {\n\t\tconsole.Exit(fmt.Sprintf(\"Config validation error: both init and multistep-init scripts are not allowed for '%s'\", title))\n\t}\n\tif i.SampleScript == nil {\n\t\tconsole.Exit(fmt.Sprintf(\"Config validation error: sample script should be specified for '%s'\", title))\n\t}\n}\n\nfunc validateLabelsUniqueness(title string, items []Item) {\n\tlabels := make(map[string]bool)\n\tfor _, i := range items {\n\t\tlabel := *i.Label\n\t\tif _, contains := labels[label]; contains {\n\t\t\tconsole.Exit(fmt.Sprintf(\"Config validation error: item labels should be unique. Please rename '%s' for '%s'\", label, title))\n\t\t}\n\t\tlabels[label] = true\n\t}\n}\n\nfunc validateTitlesUniqueness(components []ComponentConfig) {\n\ttitles := make(map[string]bool)\n\tfor _, c := range components {\n\t\tif _, contains := titles[c.Title]; contains {\n\t\t\tconsole.Exit(fmt.Sprintf(\"Config validation error: component titles should be unique. Please rename '%s'\", c.Title))\n\t\t}\n\t\ttitles[c.Title] = true\n\t}\n}\n"
  },
  {
    "path": "console/console.go",
    "content": "package console\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"time\"\n\n\tui \"github.com/gizak/termui/v3\"\n)\n\nconst (\n\tMaxRenderInterval = 1000 * time.Millisecond\n\tMinRenderInterval = 100 * time.Millisecond\n\tColumnsCount      = 80\n\tRowsCount         = 40\n\tAppTitle          = \"sampler\"\n\tAppVersion        = \"1.1.0\"\n)\n\nconst (\n\tBellCharacter = \"\\a\"\n)\n\ntype AsciiFont string\n\nconst (\n\tAsciiFont2D AsciiFont = \"2d\"\n\tAsciiFont3D AsciiFont = \"3d\"\n)\n\nfunc Init() {\n\n\tfmt.Printf(\"\\033]0;%s\\007\", AppTitle)\n\n\tif err := ui.Init(); err != nil {\n\t\tlog.Fatalf(\"Failed to initialize ui: %v\", err)\n\t}\n}\n\n// Close function calls Close from termui package,\n// which closes termbox-go\nfunc Close() {\n\tui.Close()\n}\n\n// Exit function exits the program successfully\nfunc Exit(message string) {\n\tif len(message) > 0 {\n\t\tprintln(message)\n\t}\n\tos.Exit(0)\n}\n"
  },
  {
    "path": "console/palette.go",
    "content": "package console\n\nimport (\n\t\"fmt\"\n\t\"runtime\"\n\n\tui \"github.com/gizak/termui/v3\"\n)\n\ntype Theme string\n\nconst (\n\tThemeDark  Theme = \"dark\"\n\tThemeLight Theme = \"light\"\n)\n\nconst (\n\tColorOlive       ui.Color = 178\n\tColorDeepSkyBlue ui.Color = 39\n\tColorDeepPink    ui.Color = 198\n\tColorCian        ui.Color = 43\n\tColorOrange      ui.Color = 166\n\tColorPurple      ui.Color = 129\n\tColorGreen       ui.Color = 64\n\tColorDarkRed     ui.Color = 88\n\tColorBlueViolet  ui.Color = 57\n\tColorDarkGrey    ui.Color = 238\n\tColorLightGrey   ui.Color = 254\n\tColorGrey        ui.Color = 242\n\tColorWhite       ui.Color = 15\n\tColorBlack       ui.Color = 0\n\tColorClear       ui.Color = -1\n)\n\nconst (\n\tmenuColorNix            ui.Color = 255\n\tmenuColorReverseNix     ui.Color = 235\n\tmenuColorWindows        ui.Color = 255\n\tmenuColorReverseWindows ui.Color = 0\n)\n\ntype Palette struct {\n\tContentColors  []ui.Color\n\tGradientColors [][]ui.Color\n\tBaseColor      ui.Color\n\tMediumColor    ui.Color\n\tReverseColor   ui.Color\n}\n\n// GetPalette returns a color palette based on specified theme\nfunc GetPalette(theme Theme) Palette {\n\tswitch theme {\n\tcase ThemeDark:\n\t\treturn Palette{\n\t\t\tContentColors:  []ui.Color{ColorOlive, ColorDeepSkyBlue, ColorDeepPink, ColorWhite, ColorGrey, ColorGreen, ColorOrange, ColorCian, ColorPurple},\n\t\t\tGradientColors: [][]ui.Color{{39, 33, 62, 93, 164, 161}, {95, 138, 180, 179, 178, 178}},\n\t\t\tBaseColor:      ColorWhite,\n\t\t\tMediumColor:    ColorDarkGrey,\n\t\t\tReverseColor:   ColorBlack,\n\t\t}\n\tcase ThemeLight:\n\t\treturn Palette{\n\t\t\tContentColors:  []ui.Color{ColorBlack, ColorDarkRed, ColorBlueViolet, ColorGrey, ColorGreen},\n\t\t\tGradientColors: [][]ui.Color{{250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 16}},\n\t\t\tBaseColor:      ColorBlack,\n\t\t\tMediumColor:    ColorLightGrey,\n\t\t\tReverseColor:   ColorWhite,\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"Specified theme is not supported: %v\", theme))\n\t}\n}\n\n// GetMenuColor returns a color based on the\n// operating system target\nfunc GetMenuColor() ui.Color {\n\tswitch runtime.GOOS {\n\tcase \"windows\":\n\t\treturn menuColorWindows\n\tdefault:\n\t\treturn menuColorNix\n\t}\n}\n\n// GetMenuColorReverse returns a color based on the\n// operating system target\nfunc GetMenuColorReverse() ui.Color {\n\tswitch runtime.GOOS {\n\tcase \"windows\":\n\t\treturn menuColorReverseWindows\n\tdefault:\n\t\treturn menuColorReverseNix\n\t}\n}\n\nfunc GetGradientColor(gradient []ui.Color, cur int, max int) ui.Color {\n\tratio := float64(len(gradient)) / float64(max)\n\tindex := int(ratio * float64(cur))\n\tif index > len(gradient)-1 {\n\t\tindex = len(gradient) - 1\n\t}\n\treturn gradient[index]\n}\n"
  },
  {
    "path": "console/palette_test.go",
    "content": "package console\n\nimport (\n\t\"testing\"\n\n\tui \"github.com/gizak/termui/v3\"\n)\n\nfunc TestGetPalette(t *testing.T) {\n\tvar (\n\t\tdarkPalette = Palette{\n\t\t\tBaseColor:    ColorWhite,\n\t\t\tReverseColor: ColorBlack,\n\t\t}\n\t\tlightPalette = Palette{\n\t\t\tBaseColor:    ColorBlack,\n\t\t\tReverseColor: ColorWhite,\n\t\t}\n\t)\n\n\ttests := []struct {\n\t\tname  string\n\t\tinput Theme\n\t\tPalette\n\t}{\n\t\t{\"should return dark theme with base color white\", ThemeDark, darkPalette},\n\t\t{\"should return light theme with base color black\", ThemeLight, lightPalette},\n\t}\n\n\tfor _, test := range tests {\n\t\tpalette := GetPalette(test.input)\n\t\tif got := palette.BaseColor; got != test.BaseColor {\n\t\t\tt.Errorf(\"GetPalette(%q) = %d, want %d\", test.input, got, test.BaseColor)\n\t\t}\n\t}\n}\n\nfunc TestGetPaletteInvalidTheme(t *testing.T) {\n\tconst invalid Theme = \"invalid\"\n\n\tdefer func() {\n\t\tif r := recover(); r == nil {\n\t\t\tt.Errorf(\"GetPalette(%q) should have panicked\", invalid)\n\t\t}\n\t}()\n\n\tGetPalette(invalid)\n}\n\nfunc TestGetGradientColor(t *testing.T) {\n\ttype args struct {\n\t\tgradient []ui.Color\n\t\tcur      int\n\t\tmax      int\n\t}\n\n\tvar (\n\t\tlightThemeGradientInput = args{\n\t\t\tgradient: []ui.Color{\n\t\t\t\t250, 248, 246, 244, 242, 240, 238, 236, 234, 232, 16,\n\t\t\t},\n\t\t\tcur: 200,\n\t\t\tmax: 250,\n\t\t}\n\n\t\tdarkThemeGradientInput = args{\n\t\t\tgradient: []ui.Color{\n\t\t\t\t39, 33, 62, 93, 164, 161,\n\t\t\t},\n\t\t\tcur: 40,\n\t\t\tmax: 180,\n\t\t}\n\n\t\tgrey ui.Color = 234\n\n\t\tblue ui.Color = 33\n\t)\n\n\ttests := []struct {\n\t\tname string\n\t\targs\n\t\twant ui.Color\n\t}{\n\t\t{\"should return color grey\", lightThemeGradientInput, grey},\n\t\t{\"should return color blue\", darkThemeGradientInput, blue},\n\t}\n\n\tfor _, test := range tests {\n\t\tgradientColor := GetGradientColor(\n\t\t\ttest.gradient,\n\t\t\ttest.cur,\n\t\t\ttest.max,\n\t\t)\n\n\t\tif got := gradientColor; got != test.want {\n\t\t\tt.Errorf(\"GetGradientColor(%v) = %d, want %d\", test.args, got, test.want)\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "console/signal.go",
    "content": "package console\n\nconst (\n\tSignalResize = \"<Resize>\"\n\tSignalClick  = \"<MouseLeft>\"\n)\n\nconst (\n\tKeyPause1 = \"p\"\n\tKeyPause2 = \"P\"\n\tKeyQuit1  = \"q\"\n\tKeyQuit2  = \"Q\"\n\tKeyQuit3  = \"<C-c>\"\n\tKeyLeft   = \"<Left>\"\n\tKeyRight  = \"<Right>\"\n\tKeyUp     = \"<Up>\"\n\tKeyDown   = \"<Down>\"\n\tKeyEnter  = \"<Enter>\"\n\tKeyEsc    = \"<Escape>\"\n)\n"
  },
  {
    "path": "console/symbol.go",
    "content": "package console\n\nconst (\n\tSymbolSelection     rune = '▲'\n\tSymbolVerticalBar   rune = '▎'\n\tSymbolHorizontalBar rune = '═'\n)\n"
  },
  {
    "path": "data/consumer.go",
    "content": "package data\n\nimport (\n\tui \"github.com/gizak/termui/v3\"\n\t\"strings\"\n)\n\ntype Consumer struct {\n\tSampleChannel  chan *Sample\n\tAlertChannel   chan *Alert\n\tCommandChannel chan *Command\n\tAlert          *Alert\n}\n\nfunc (c *Consumer) HandleConsumeSuccess() {\n\tif c.Alert != nil && c.Alert.Recoverable {\n\t\tc.Alert = nil\n\t}\n}\n\nfunc (c *Consumer) HandleConsumeFailure(title string, err error, sample *Sample) {\n\tc.AlertChannel <- &Alert{\n\t\tTitle:       strings.ToUpper(title),\n\t\tText:        err.Error(),\n\t\tColor:       sample.Color,\n\t\tRecoverable: true,\n\t}\n}\n\ntype Sample struct {\n\tLabel string\n\tValue string\n\tColor *ui.Color\n}\n\ntype Alert struct {\n\tTitle       string\n\tText        string\n\tColor       *ui.Color\n\tRecoverable bool\n}\n\ntype Command struct {\n\tType  string\n\tValue interface{}\n}\n\nfunc NewConsumer() *Consumer {\n\treturn &Consumer{\n\t\tSampleChannel:  make(chan *Sample, 10),\n\t\tAlertChannel:   make(chan *Alert, 10),\n\t\tCommandChannel: make(chan *Command, 10),\n\t}\n}\n"
  },
  {
    "path": "data/consumer_test.go",
    "content": "package data\n\nimport (\n\t\"errors\"\n\t\"reflect\"\n\t\"testing\"\n)\n\nfunc TestConsumer_HandleConsumeSuccess(t *testing.T) {\n\ttests := []struct {\n\t\tname          string\n\t\texistingAlert *Alert\n\t\texpectedAlert *Alert\n\t}{\n\t\t{\"alert nil\", nil, nil},\n\t\t{\"alert present, not recoverable\", &Alert{Recoverable: false}, &Alert{Recoverable: false}},\n\t\t{\"alert present, recoverable\", &Alert{Recoverable: true}, nil},\n\t}\n\tfor _, tt := range tests {\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tc := NewConsumer()\n\t\t\tc.Alert = tt.existingAlert\n\t\t\tc.HandleConsumeSuccess()\n\t\t\tif !reflect.DeepEqual(c.Alert, tt.expectedAlert) {\n\t\t\t\tt.Errorf(\"unexpected alert state after HandleConsumeSuccess(), want %v, got %v\", tt.expectedAlert, c.Alert)\n\t\t\t}\n\t\t})\n\t}\n}\n\nfunc TestConsumer_HandleConsumeFailure(t *testing.T) {\n\ttests := []struct {\n\t\tname   string\n\t\ttitle  string\n\t\terr    error\n\t\tsample *Sample\n\t\twant   *Alert\n\t}{\n\t\t{\n\t\t\t\"basic\",\n\t\t\t\"test\",\n\t\t\terrors.New(\"test\"),\n\t\t\t&Sample{\n\t\t\t\tLabel: \"test\",\n\t\t\t\tValue: \"test\",\n\t\t\t\tColor: nil,\n\t\t\t},\n\t\t\t&Alert{\n\t\t\t\tTitle:       \"TEST\",\n\t\t\t\tText:        \"test\",\n\t\t\t\tColor:       nil,\n\t\t\t\tRecoverable: true,\n\t\t\t},\n\t\t},\n\t}\n\tfor _, tt := range tests {\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tc := NewConsumer()\n\t\t\tc.HandleConsumeFailure(tt.title, tt.err, tt.sample)\n\t\t\tgot := <-c.AlertChannel\n\t\t\tif !reflect.DeepEqual(tt.want, got) {\n\t\t\t\tt.Errorf(\"unexpected alert state after HandleConsumeFailure(), want %v, got %v\", got, tt.want)\n\t\t\t}\n\t\t})\n\t}\n}\n\nfunc TestNewConsumer(t *testing.T) {\n\ttests := []struct {\n\t\tname      string\n\t\tcheckFunc func(c *Consumer) bool\n\t}{\n\t\t{\n\t\t\t\"initialized after creation\",\n\t\t\tfunc(c *Consumer) bool {\n\t\t\t\treturn c != nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"alert is nil after creation\",\n\t\t\tfunc(c *Consumer) bool {\n\t\t\t\treturn c.Alert == nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"command channel is initialized after creation\",\n\t\t\tfunc(c *Consumer) bool {\n\t\t\t\treturn c.CommandChannel != nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"alert channel is initialized after creation\",\n\t\t\tfunc(c *Consumer) bool {\n\t\t\t\treturn c.AlertChannel != nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t\"sample channel is initialized after creation\",\n\t\t\tfunc(c *Consumer) bool {\n\t\t\t\treturn c.SampleChannel != nil\n\t\t\t},\n\t\t},\n\t}\n\tfor _, tt := range tests {\n\t\tt.Run(tt.name, func(t *testing.T) {\n\t\t\tif got := NewConsumer(); !tt.checkFunc(got) {\n\t\t\t\tt.Errorf(\"unexpected consumer state after NewConsumer() = %v\", got)\n\t\t\t}\n\t\t})\n\t}\n}\n"
  },
  {
    "path": "data/error.go",
    "content": "package data\n\nimport (\n\t\"fmt\"\n\t\"os/exec\"\n)\n\nfunc getErrorMessage(err error) string {\n\n\texitErr, ok := err.(*exec.ExitError)\n\tmessage := err.Error()\n\n\tif ok {\n\t\tstderr := string(exitErr.Stderr)\n\t\tif len(stderr) != 0 {\n\t\t\tmessage = fmt.Sprintf(\"%.200s\", stderr)\n\t\t}\n\t}\n\n\treturn message\n}\n"
  },
  {
    "path": "data/int.go",
    "content": "package data\n\nimport \"time\"\n\nconst (\n\tstartupTimeout  = 200 * time.Millisecond\n\tminAwaitTimeout = 100 * time.Millisecond\n\tmaxAwaitTimeout = 1 * time.Second\n)\n\ntype InteractiveShell interface {\n\tinit() error\n\texecute() (string, error)\n}\n"
  },
  {
    "path": "data/int_basic.go",
    "content": "package data\n\nimport (\n\t\"bufio\"\n\t\"errors\"\n\t\"fmt\"\n\t\"github.com/lunixbochs/vtclean\"\n\t\"io\"\n\t\"os/exec\"\n\t\"strings\"\n\t\"time\"\n)\n\n// BasicInteractiveShell represents non-PTY interactive shell sampling metadata\ntype BasicInteractiveShell struct {\n\titem      *Item\n\tvariables []string\n\tstdoutCh  chan string\n\tstderrCh  chan string\n\tstdin     io.WriteCloser\n\tcmd       *exec.Cmd\n\terrCount  int\n\ttimeout   time.Duration\n}\n\nfunc (s *BasicInteractiveShell) init() error {\n\n\tcmd := exec.Command(\"sh\", \"-c\", s.item.initScripts[0])\n\tenrichEnvVariables(cmd, s.variables)\n\n\tstdout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tstderr, err := cmd.StderrPipe()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tstdin, err := cmd.StdinPipe()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tstdoutScanner := bufio.NewScanner(stdout)\n\tstderrScanner := bufio.NewScanner(stderr)\n\n\tstdoutCh := make(chan string)\n\tstderrCh := make(chan string)\n\n\tgo func() {\n\t\tfor stdoutScanner.Scan() {\n\t\t\tstdoutCh <- stdoutScanner.Text()\n\t\t\tstderrCh <- stderrScanner.Text()\n\t\t}\n\t}()\n\n\ts.stdoutCh = stdoutCh\n\ts.stderrCh = stderrCh\n\ts.stdin = stdin\n\ts.cmd = cmd\n\n\terr = cmd.Start()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor i := 1; i < len(s.item.initScripts); i++ {\n\t\t_, err := io.WriteString(s.stdin, fmt.Sprintf(\" %s\\n\", s.item.initScripts[i]))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\ttime.Sleep(startupTimeout) // TODO wait until cmd complete\n\t}\n\n\treturn nil\n}\n\nfunc (s *BasicInteractiveShell) execute() (string, error) {\n\n\tif s.stdin == nil {\n\t\treturn \"\", nil\n\t}\n\n\t_, err := io.WriteString(s.stdin, fmt.Sprintf(\" %s\\n\", s.item.sampleScript))\n\tif err != nil {\n\t\ts.errCount++\n\t\tif s.errCount > errorThreshold {\n\t\t\t_ = s.cmd.Wait()\n\t\t\ts.item.basicShell = nil // restart session\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"failed to execute command: %s\", err)\n\t}\n\n\ttimeout := make(chan bool, 1)\n\n\tgo func() {\n\t\ttime.Sleep(s.timeout)\n\t\ttimeout <- true\n\t}()\n\n\tvar resultText strings.Builder\n\tvar errorText strings.Builder\n\n\tfor {\n\t\tselect {\n\t\tcase stdout := <-s.stdoutCh:\n\t\t\tif len(stdout) > 0 {\n\t\t\t\tresultText.WriteString(stdout)\n\t\t\t\tresultText.WriteString(\"\\n\")\n\t\t\t}\n\t\tcase stderr := <-s.stderrCh:\n\t\t\tif len(stderr) > 0 {\n\t\t\t\terrorText.WriteString(stderr)\n\t\t\t\terrorText.WriteString(\"\\n\")\n\t\t\t}\n\t\tcase <-timeout:\n\t\t\tif errorText.Len() > 0 {\n\t\t\t\treturn \"\", errors.New(errorText.String())\n\t\t\t}\n\t\t\treturn s.item.transform(vtclean.Clean(resultText.String(), false))\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "data/int_pty.go",
    "content": "//+build !windows\n\npackage data\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"github.com/kr/pty\"\n\t\"github.com/lunixbochs/vtclean\"\n\t\"io\"\n\t\"os/exec\"\n\t\"strings\"\n\t\"time\"\n)\n\n// PtyInteractiveShell represents PTY interactive shell sampling metadata\ntype PtyInteractiveShell struct {\n\titem      *Item\n\tvariables []string\n\tcmd       *exec.Cmd\n\tfile      io.WriteCloser\n\tch        chan string\n\terrCount  int\n\ttimeout   time.Duration\n}\n\nfunc (s *PtyInteractiveShell) init() error {\n\n\tcmd := exec.Command(\"sh\", \"-c\", s.item.initScripts[0])\n\tenrichEnvVariables(cmd, s.variables)\n\n\tfile, err := pty.Start(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tscanner := bufio.NewScanner(file)\n\tchannel := make(chan string)\n\n\tgo func() {\n\t\tfor scanner.Scan() {\n\t\t\tchannel <- scanner.Text()\n\t\t}\n\t}()\n\n\ts.cmd = cmd\n\ts.file = file\n\ts.ch = channel\n\n\t_, err = file.Read(make([]byte, 4096))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttime.Sleep(startupTimeout)\n\n\tfor i := 1; i < len(s.item.initScripts); i++ {\n\t\t_, err = io.WriteString(s.file, fmt.Sprintf(\" %s\\n\", s.item.initScripts[i]))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\ttime.Sleep(startupTimeout) // TODO wait until cmd complete\n\t}\n\n\treturn nil\n}\n\nfunc (s *PtyInteractiveShell) execute() (string, error) {\n\n\t_, err := io.WriteString(s.file, fmt.Sprintf(\" %s\\n\", s.item.sampleScript))\n\tif err != nil {\n\t\ts.errCount++\n\t\tif s.errCount > errorThreshold {\n\t\t\t_ = s.cmd.Wait()\n\t\t\t_ = s.file.Close()\n\t\t\ts.item.ptyShell = nil // restart session\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"failed to execute command: %s\", err)\n\t}\n\n\tsoftTimeout := make(chan bool, 1)\n\thardTimeout := make(chan bool, 1)\n\n\tgo func() {\n\t\ttime.Sleep(s.getAwaitTimeout() / 2)\n\t\tsoftTimeout <- true\n\t\ttime.Sleep(s.getAwaitTimeout() * 100)\n\t\thardTimeout <- true\n\t}()\n\n\tvar builder strings.Builder\n\tsoftTimeoutElapsed := false\n\nawait:\n\tfor {\n\t\tselect {\n\t\tcase out := <-s.ch:\n\t\t\tcout := vtclean.Clean(out, false)\n\t\t\tif len(cout) > 0 && !strings.Contains(cout, s.item.sampleScript) {\n\t\t\t\tbuilder.WriteString(cout)\n\t\t\t\tbuilder.WriteString(\"\\n\")\n\t\t\t\tif softTimeoutElapsed {\n\t\t\t\t\tbreak await\n\t\t\t\t}\n\t\t\t}\n\t\tcase <-softTimeout:\n\t\t\tif builder.Len() > 0 {\n\t\t\t\tbreak await\n\t\t\t} else {\n\t\t\t\tsoftTimeoutElapsed = true\n\t\t\t}\n\t\tcase <-hardTimeout:\n\t\t\tbreak await\n\t\t}\n\t}\n\n\tsample := strings.TrimSpace(builder.String())\n\n\treturn s.item.transform(sample)\n}\n\nfunc (s *PtyInteractiveShell) getAwaitTimeout() time.Duration {\n\n\tif s.timeout > maxAwaitTimeout {\n\t\treturn maxAwaitTimeout\n\t} else if s.timeout < minAwaitTimeout {\n\t\treturn minAwaitTimeout\n\t}\n\n\treturn s.timeout\n}\n"
  },
  {
    "path": "data/int_pty_windows.go",
    "content": "package data\n\nimport (\n\t\"errors\"\n\t\"time\"\n)\n\ntype PtyInteractiveShell struct {\n\titem      *Item\n\tvariables []string\n\ttimeout   time.Duration\n}\n\nfunc (s *PtyInteractiveShell) init() error {\n\treturn errors.New(\"PTY mode is not supported on Windows\")\n}\n\nfunc (s *PtyInteractiveShell) execute() (string, error) {\n\treturn \"\", errors.New(\"PTY mode is not supported on Windows\")\n}\n"
  },
  {
    "path": "data/item.go",
    "content": "package data\n\nimport (\n\tui \"github.com/gizak/termui/v3\"\n\t\"github.com/lunixbochs/vtclean\"\n\t\"github.com/sqshq/sampler/config\"\n\t\"os\"\n\t\"os/exec\"\n\t\"time\"\n)\n\nconst errorThreshold = 10\n\ntype Item struct {\n\tlabel           string\n\tinitScripts     []string\n\tsampleScript    string\n\ttransformScript *string\n\tcolor           *ui.Color\n\trateMs          int\n\tpty             bool\n\tbasicShell      InteractiveShell\n\tptyShell        InteractiveShell\n}\n\nfunc NewItems(cfgs []config.Item, rateMs int) []*Item {\n\n\titems := make([]*Item, 0)\n\n\tfor _, i := range cfgs {\n\t\titem := &Item{\n\t\t\tlabel:           *i.Label,\n\t\t\tsampleScript:    *i.SampleScript,\n\t\t\tinitScripts:     getInitScripts(i),\n\t\t\ttransformScript: i.TransformScript,\n\t\t\tcolor:           i.Color,\n\t\t\trateMs:          rateMs,\n\t\t\tpty:             *i.Pty,\n\t\t}\n\t\titems = append(items, item)\n\t}\n\treturn items\n}\n\nfunc (i *Item) nextValue(variables []string) (string, error) {\n\n\tif len(i.initScripts) > 0 && i.basicShell == nil && i.ptyShell == nil {\n\t\terr := i.initInteractiveShell(variables)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\tif i.basicShell != nil {\n\t\treturn i.basicShell.execute()\n\t} else if i.ptyShell != nil {\n\t\treturn i.ptyShell.execute()\n\t} else {\n\t\treturn i.execute(variables, i.sampleScript)\n\t}\n}\n\nfunc (i *Item) execute(variables []string, script string) (string, error) {\n\n\tcmd := exec.Command(\"sh\", \"-c\", script)\n\tenrichEnvVariables(cmd, variables)\n\n\toutput, err := cmd.Output()\n\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\to := string(output)\n\n\treturn vtclean.Clean(o, false), nil\n}\n\nfunc (i *Item) initInteractiveShell(v []string) error {\n\n\ttimeout := time.Duration(i.rateMs) * time.Millisecond * 3 / 4\n\n\tif i.pty {\n\t\ti.ptyShell = &PtyInteractiveShell{item: i, variables: v, timeout: timeout}\n\t\treturn i.ptyShell.init()\n\t}\n\n\ti.basicShell = &BasicInteractiveShell{item: i, variables: v, timeout: timeout}\n\n\treturn i.basicShell.init()\n}\n\nfunc (i *Item) transform(sample string) (string, error) {\n\n\tif i.transformScript != nil && len(sample) > 0 {\n\t\treturn i.execute([]string{\"sample=\" + sample}, *i.transformScript)\n\t}\n\n\treturn sample, nil\n}\n\nfunc enrichEnvVariables(cmd *exec.Cmd, variables []string) {\n\tcmd.Env = os.Environ()\n\tfor _, variable := range variables {\n\t\tcmd.Env = append(cmd.Env, variable)\n\t}\n}\n\nfunc getInitScripts(item config.Item) []string {\n\tif item.MultiStepInitScript != nil {\n\t\treturn *item.MultiStepInitScript\n\t} else if item.InitScript != nil {\n\t\treturn []string{*item.InitScript}\n\t} else {\n\t\treturn []string{}\n\t}\n}\n"
  },
  {
    "path": "data/sampler.go",
    "content": "package data\n\nimport (\n\t\"fmt\"\n\t\"github.com/sqshq/sampler/config\"\n\t\"time\"\n)\n\ntype Sampler struct {\n\tconsumer        *Consumer\n\titems           []*Item\n\ttriggers        []*Trigger\n\ttriggersChannel chan *Sample\n\tvariables       []string\n\tpause           bool\n}\n\nfunc NewSampler(consumer *Consumer, items []*Item, triggers []*Trigger, options config.Options, fileVariables map[string]string, rateMs int) *Sampler {\n\n\tticker := time.NewTicker(time.Duration(rateMs) * time.Millisecond)\n\n\tsampler := &Sampler{\n\t\tconsumer,\n\t\titems,\n\t\ttriggers,\n\t\tmake(chan *Sample),\n\t\tmergeVariables(fileVariables, options.Environment),\n\t\tfalse,\n\t}\n\n\tgo func() {\n\t\tfor ; true; <-ticker.C {\n\t\t\tfor _, item := range sampler.items {\n\t\t\t\tif !sampler.pause {\n\t\t\t\t\tgo sampler.sample(item, options)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase sample := <-sampler.triggersChannel:\n\t\t\t\tfor _, t := range sampler.triggers {\n\t\t\t\t\tif !sampler.pause {\n\t\t\t\t\t\tt.Execute(sample)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn sampler\n}\n\nfunc (s *Sampler) sample(item *Item, options config.Options) {\n\n\tval, err := item.nextValue(s.variables)\n\n\tif len(val) > 0 {\n\t\tsample := &Sample{Label: item.label, Value: val, Color: item.color}\n\t\ts.consumer.SampleChannel <- sample\n\t\ts.triggersChannel <- sample\n\t} else if err != nil {\n\t\ts.consumer.AlertChannel <- &Alert{\n\t\t\tTitle:       \"Sampling failure\",\n\t\t\tText:        getErrorMessage(err),\n\t\t\tColor:       item.color,\n\t\t\tRecoverable: true,\n\t\t}\n\t}\n}\n\n// option variables takes precedence over the file variables with the same name\nfunc mergeVariables(fileVariables map[string]string, optionsVariables []string) []string {\n\n\tresult := optionsVariables\n\n\tfor key, value := range fileVariables {\n\t\tresult = append([]string{fmt.Sprintf(\"%s=%s\", key, value)}, result...)\n\t}\n\n\treturn result\n}\n\nfunc (s *Sampler) Pause(pause bool) {\n\ts.pause = pause\n}\n"
  },
  {
    "path": "data/trigger.go",
    "content": "package data\n\nimport (\n\t\"fmt\"\n\t\"github.com/sqshq/sampler/asset\"\n\t\"github.com/sqshq/sampler/config\"\n\t\"github.com/sqshq/sampler/console\"\n\t\"os\"\n\t\"os/exec\"\n\t\"regexp\"\n)\n\nconst (\n\tTrueIndicator = \"1\"\n\tInitialValue  = \"0\"\n)\n\ntype Trigger struct {\n\ttitle         string\n\tcondition     string\n\tactions       *Actions\n\tconsumer      *Consumer\n\tvaluesByLabel map[string]Values\n\toptions       config.Options\n\tplayer        *asset.AudioPlayer\n\tdigitsRegexp  *regexp.Regexp\n}\n\ntype Actions struct {\n\tterminalBell bool\n\tsound        bool\n\tvisual       bool\n\tscript       *string\n}\n\ntype Values struct {\n\tcurrent  string\n\tprevious string\n}\n\nfunc NewTriggers(cfgs []config.TriggerConfig, consumer *Consumer, options config.Options, player *asset.AudioPlayer) []*Trigger {\n\n\ttriggers := make([]*Trigger, 0)\n\n\tfor _, cfg := range cfgs {\n\t\ttriggers = append(triggers, NewTrigger(cfg, consumer, options, player))\n\t}\n\n\treturn triggers\n}\n\nfunc NewTrigger(config config.TriggerConfig, consumer *Consumer, options config.Options, player *asset.AudioPlayer) *Trigger {\n\treturn &Trigger{\n\t\ttitle:         config.Title,\n\t\tcondition:     config.Condition,\n\t\tconsumer:      consumer,\n\t\tvaluesByLabel: make(map[string]Values),\n\t\toptions:       options,\n\t\tplayer:        player,\n\t\tdigitsRegexp:  regexp.MustCompile(\"[^0-9]+\"),\n\t\tactions: &Actions{\n\t\t\tterminalBell: *config.Actions.TerminalBell,\n\t\t\tsound:        *config.Actions.Sound,\n\t\t\tvisual:       *config.Actions.Visual,\n\t\t\tscript:       config.Actions.Script,\n\t\t},\n\t}\n}\n\nfunc (t *Trigger) Execute(sample *Sample) {\n\tif t.evaluate(sample) {\n\n\t\tif t.actions.terminalBell {\n\t\t\tfmt.Print(console.BellCharacter)\n\t\t}\n\n\t\tif t.actions.sound && t.player != nil {\n\t\t\tt.player.Beep()\n\t\t}\n\n\t\tif t.actions.visual {\n\t\t\tt.consumer.AlertChannel <- &Alert{\n\t\t\t\tTitle:       t.title,\n\t\t\t\tText:        fmt.Sprintf(\"%s: %v\", sample.Label, sample.Value),\n\t\t\t\tColor:       sample.Color,\n\t\t\t\tRecoverable: false,\n\t\t\t}\n\t\t}\n\n\t\tif t.actions.script != nil {\n\t\t\t_, _ = t.runScript(*t.actions.script, sample.Label, t.valuesByLabel[sample.Label])\n\t\t}\n\t}\n}\n\nfunc (t *Trigger) evaluate(sample *Sample) bool {\n\n\tif values, ok := t.valuesByLabel[sample.Label]; ok {\n\t\tvalues.previous = values.current\n\t\tvalues.current = sample.Value\n\t\tt.valuesByLabel[sample.Label] = values\n\t} else {\n\t\tt.valuesByLabel[sample.Label] = Values{previous: InitialValue, current: sample.Value}\n\t}\n\n\toutput, err := t.runScript(t.condition, sample.Label, t.valuesByLabel[sample.Label])\n\n\tif err != nil {\n\t\tt.consumer.AlertChannel <- &Alert{\n\t\t\tTitle:       \"Trigger condition failure\",\n\t\t\tText:        getErrorMessage(err),\n\t\t\tColor:       sample.Color,\n\t\t\tRecoverable: true,\n\t\t}\n\t}\n\n\treturn t.digitsRegexp.ReplaceAllString(string(output), \"\") == TrueIndicator\n}\n\nfunc (t *Trigger) runScript(script, label string, data Values) ([]byte, error) {\n\n\tcmd := exec.Command(\"sh\", \"-c\", script)\n\tcmd.Env = os.Environ()\n\n\tfor _, variable := range t.options.Environment {\n\t\tcmd.Env = append(cmd.Env, variable)\n\t}\n\n\tcmd.Env = append(cmd.Env,\n\t\tfmt.Sprintf(\"prev=%v\", data.previous),\n\t\tfmt.Sprintf(\"cur=%v\", data.current),\n\t\tfmt.Sprintf(\"label=%v\", label))\n\n\treturn cmd.Output()\n}\n"
  },
  {
    "path": "event/handler.go",
    "content": "package event\n\nimport (\n\tui \"github.com/gizak/termui/v3\"\n\t\"github.com/sqshq/sampler/component/layout\"\n\t\"github.com/sqshq/sampler/config\"\n\t\"github.com/sqshq/sampler/console\"\n\t\"github.com/sqshq/sampler/data\"\n\t\"time\"\n)\n\nconst (\n\trefreshRateToRenderRateRatio = 0.5\n)\n\ntype Handler struct {\n\tsamplers      []*data.Sampler\n\toptions       config.Options\n\tlayout        *layout.Layout\n\trenderTicker  *time.Ticker\n\tconsoleEvents <-chan ui.Event\n\trenderRate    time.Duration\n}\n\nfunc NewHandler(samplers []*data.Sampler, options config.Options, layout *layout.Layout) *Handler {\n\trenderRate := calcMinRenderRate(layout)\n\treturn &Handler{\n\t\tsamplers:      samplers,\n\t\toptions:       options,\n\t\tlayout:        layout,\n\t\tconsoleEvents: ui.PollEvents(),\n\t\trenderTicker:  time.NewTicker(renderRate),\n\t\trenderRate:    renderRate,\n\t}\n}\n\nfunc (h *Handler) HandleEvents() {\n\n\t// initial render\n\tui.Render(h.layout)\n\n\tfor {\n\t\tselect {\n\t\tcase mode := <-h.layout.ChangeModeEvents:\n\t\t\th.handleModeChange(mode)\n\t\tcase <-h.renderTicker.C:\n\t\t\tui.Render(h.layout)\n\t\tcase e := <-h.consoleEvents:\n\t\t\tswitch e.ID {\n\t\t\tcase console.SignalClick:\n\t\t\t\tpayload := e.Payload.(ui.Mouse)\n\t\t\t\th.layout.HandleMouseClick(payload.X, payload.Y)\n\t\t\tcase console.KeyQuit1, console.KeyQuit2, console.KeyQuit3:\n\t\t\t\tif h.layout.WerePositionsChanged() {\n\t\t\t\t\th.updateConfigFile()\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\tcase console.SignalResize:\n\t\t\t\tpayload := e.Payload.(ui.Resize)\n\t\t\t\th.layout.ChangeDimensions(payload.Width, payload.Height)\n\t\t\tdefault:\n\t\t\t\th.layout.HandleKeyboardEvent(e.ID)\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc (h *Handler) handleModeChange(m layout.Mode) {\n\n\t// render the change before switching the tickers\n\tui.Render(h.layout)\n\th.renderTicker.Stop()\n\n\tswitch m {\n\tcase layout.ModeDefault:\n\t\th.renderTicker = time.NewTicker(h.renderRate)\n\t\th.pause(false)\n\tcase layout.ModePause:\n\t\th.pause(true)\n\t\t// proceed with stopped timer\n\tdefault:\n\t\th.renderTicker = time.NewTicker(console.MinRenderInterval)\n\t\th.pause(false)\n\t}\n}\n\nfunc (h *Handler) pause(pause bool) {\n\tfor _, s := range h.samplers {\n\t\ts.Pause(pause)\n\t}\n}\n\nfunc (h *Handler) updateConfigFile() {\n\tvar settings []config.ComponentSettings\n\tfor _, c := range h.layout.Components {\n\t\tsettings = append(settings,\n\t\t\tconfig.ComponentSettings{Type: c.Type, Title: c.Title, Size: c.Size, Location: c.Location})\n\t}\n\tconfig.Update(settings, h.options)\n}\n\nfunc calcMinRenderRate(layout *layout.Layout) time.Duration {\n\n\tminRateMs := layout.Components[0].RateMs\n\tfor _, c := range layout.Components {\n\t\tif c.RateMs < minRateMs {\n\t\t\tminRateMs = c.RateMs\n\t\t}\n\t}\n\n\trenderRate := time.Duration(\n\t\tint(float64(minRateMs)*refreshRateToRenderRateRatio)) * time.Millisecond\n\n\tif renderRate < console.MinRenderInterval {\n\t\treturn console.MinRenderInterval\n\t}\n\n\tif renderRate > console.MaxRenderInterval {\n\t\treturn console.MaxRenderInterval\n\t}\n\n\treturn renderRate\n}\n"
  },
  {
    "path": "example.yml",
    "content": "runcharts:\n  - title: Search engine response time\n    position: [[0, 0], [45, 19]]\n    rate-ms: 500\n    triggers:\n      - title: Latency threshold exceeded\n        condition: echo \"$prev < 0.8 && $cur > 0.8\" |bc -l\n        actions:\n            terminal-bell: true\n            sound: true\n            visual: true\n            script: 'say alert: ${label} latency exceeded ${cur} second'\n    legend:\n        enabled: true\n        details: false\n    scale: 2\n    items:\n      - label: GOOGLE\n        color: 178\n        sample: curl -o /dev/null -s -w '%{time_total}'  https://www.google.com\n      - label: YAHOO\n        sample: curl -o /dev/null -s -w '%{time_total}'  https://search.yahoo.com\n      - label: BING\n        sample: curl -o /dev/null -s -w '%{time_total}'  https://www.bing.com\nbarcharts:\n  - title: Local network activity\n    position: [[45, 20], [35, 8]]\n    rate-ms: 500\n    scale: 0\n    items:\n      - label: UDP bytes in\n        sample: nettop -J bytes_in -l 1 -m udp | awk '{sum += $4} END {print sum}'\n      - label: UDP bytes out\n        sample: nettop -J bytes_out -l 1 -m udp | awk '{sum += $4} END {print sum}'\n      - label: TCP bytes in\n        sample: nettop -J bytes_in -l 1 -m tcp | awk '{sum += $4} END {print sum}'\n      - label: TCP bytes out\n        sample: nettop -J bytes_out -l 1 -m tcp | awk '{sum += $4} END {print sum}'\ngauges:\n  - title: YEAR PROGRESS\n    position: [[45, 0], [35, 2]]\n    cur:\n        sample: date +%j\n    max:\n        sample: echo 365\n    min:\n        sample: echo 0\n  - title: DAY PROGRESS\n    position: [[45, 3], [35, 2]]\n    cur:\n        sample: date +%H\n    max:\n        sample: echo 24\n    min:\n        sample: echo 0\n  - title: HOUR PROGRESS\n    position: [[45, 6], [35, 2]]\n    cur:\n        sample: date +%M\n    max:\n        sample: echo 60\n    min:\n        sample: echo 0\n  - title: MINUTE PROGRESS\n    position: [[45, 9], [35, 2]]\n    triggers:\n      - title: CLOCK BELL EVERY MINUTE\n        condition: '[ $label == \"cur\" ] && [ $cur -eq 0 ] && echo 1 || echo 0'\n        actions:\n            sound: true\n            script: say -v samantha `date +%I:%M%p`\n    cur:\n        sample: date +%S\n    max:\n        sample: echo 60\n    min:\n        sample: echo 0\nsparklines:\n  - title: CPU usage\n    position: [[0, 20], [22, 8]]\n    rate-ms: 200\n    scale: 0\n    sample: ps -A -o %cpu | awk '{s+=$1} END {print s}'\n  - title: Free memory pages\n    position: [[22, 20], [23, 8]]\n    rate-ms: 200\n    scale: 0\n    sample: memory_pressure | grep 'Pages free' | awk '{print $3}'\ntextboxes:\n  - title: Docker containers stats\n    position: [[0, 29], [45, 10]]\n    rate-ms: 500\n    sample: docker stats --no-stream --format \"table {{.Name}}\\t{{.CPUPerc}}\\t{{.MemUsage}}\\t{{.PIDs}}\"\n  - title: Local weather\n    position: [[69, 31], [13, 7]]\n    rate-ms: 10000\n    sample: curl wttr.in?0ATQF\n    border: false\n  - title: New York weather\n    position: [[45, 31], [13, 7]]\n    rate-ms: 10000\n    sample: curl wttr.in/newyork?0ATQF\n    transform: echo 1\n    border: false\n  - title: San Francisco weather\n    position: [[56, 31], [13, 7]]\n    rate-ms: 10000\n    sample: curl wttr.in/sanfrancisco?0ATQF\n    border: false\nasciiboxes:\n  - title: UTC time\n    position: [[45, 12], [35, 7]]\n    rate-ms: 500\n    sample: env TZ=UTC date +%r\n    border: false\n    font: 3d\n"
  },
  {
    "path": "go.mod",
    "content": "module github.com/sqshq/sampler\n\ngo 1.17\n\nrequire (\n\tgithub.com/gizak/termui/v3 v3.0.0\n\tgithub.com/hajimehoshi/go-mp3 v0.1.1\n\tgithub.com/hajimehoshi/oto v0.1.1\n\tgithub.com/jessevdk/go-flags v1.4.0\n\tgithub.com/kr/pty v1.1.5\n\tgithub.com/lunixbochs/vtclean v1.0.0\n\tgithub.com/mattn/go-runewidth v0.0.4\n\tgithub.com/mbndr/figlet4go v0.0.0-20190224160619-d6cef5b186ea\n\tgopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22\n)\n\nrequire (\n\tgithub.com/cjbassi/drawille-go v0.0.0-20190126131713-27dc511fe6fd // indirect\n\tgithub.com/gopherjs/gopherjs v0.0.0-20180628210949-0892b62f0d9f // indirect\n\tgithub.com/gopherjs/gopherwasm v0.1.1 // indirect\n\tgithub.com/mitchellh/go-homedir v1.1.0 // indirect\n\tgithub.com/mitchellh/go-wordwrap v1.0.0 // indirect\n\tgithub.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d // indirect\n\tgolang.org/x/arch v0.0.0-20181203225421-5a4828bb7045 // indirect\n\tgopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 // indirect\n)\n"
  },
  {
    "path": "go.sum",
    "content": "github.com/cjbassi/drawille-go v0.0.0-20190126131713-27dc511fe6fd h1:XtfPmj9tQRilnrEmI1HjQhxXWRhEM+m8CACtaMJE/kM=\ngithub.com/cjbassi/drawille-go v0.0.0-20190126131713-27dc511fe6fd/go.mod h1:vjcQJUZJYD3MeVGhtZXSMnCHfUNZxsyYzJt90eCYxK4=\ngithub.com/gizak/termui/v3 v3.0.0 h1:NYTUG6ig/sJK05O5FyhWemwlVPO8ilNpvS/PgRtrKAE=\ngithub.com/gizak/termui/v3 v3.0.0/go.mod h1:uinu2dMdtMI+FTIdEFUJQT5y+KShnhQRshvPblXq3lY=\ngithub.com/gopherjs/gopherjs v0.0.0-20180628210949-0892b62f0d9f h1:FDM3EtwZLyhW48YRiyqjivNlNZjAObv4xt4NnJaU+NQ=\ngithub.com/gopherjs/gopherjs v0.0.0-20180628210949-0892b62f0d9f/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=\ngithub.com/gopherjs/gopherwasm v0.1.1 h1:R/3+SfgCFStiql6ICfyfke1WtpglfjIvTEBux8R1euc=\ngithub.com/gopherjs/gopherwasm v0.1.1/go.mod h1:kx4n9a+MzHH0BJJhvlsQ65hqLFXDO/m256AsaDPQ+/4=\ngithub.com/hajimehoshi/go-mp3 v0.1.1 h1:Y33fAdTma70fkrxnc9u50Uq0lV6eZ+bkAlssdMmCwUc=\ngithub.com/hajimehoshi/go-mp3 v0.1.1/go.mod h1:4i+c5pDNKDrxl1iu9iG90/+fhP37lio6gNhjCx9WBJw=\ngithub.com/hajimehoshi/oto v0.1.1 h1:EG+WxxeAfde1mI0adhLYvGbKgDCxm7bCTd6g+JIA6vI=\ngithub.com/hajimehoshi/oto v0.1.1/go.mod h1:hUiLWeBQnbDu4pZsAhOnGqMI1ZGibS6e2qhQdfpwz04=\ngithub.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=\ngithub.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=\ngithub.com/kr/pty v1.1.4 h1:5Myjjh3JY/NaAi4IsUbHADytDyl1VE1Y9PXDlL+P/VQ=\ngithub.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=\ngithub.com/kr/pty v1.1.5 h1:hyz3dwM5QLc1Rfoz4FuWJQG5BN7tc6K1MndAUnGpQr4=\ngithub.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=\ngithub.com/lunixbochs/vtclean v1.0.0 h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+LVb8=\ngithub.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=\ngithub.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=\ngithub.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=\ngithub.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=\ngithub.com/mbndr/figlet4go v0.0.0-20190224160619-d6cef5b186ea h1:mQncVDBpKkAecPcH2IMGpKUQYhwowlafQbfkz2QFqkc=\ngithub.com/mbndr/figlet4go v0.0.0-20190224160619-d6cef5b186ea/go.mod h1:QzTGLGoOqLHUBK8/EZ0v4Fa4CdyXmdyRwCHcl0YbeO4=\ngithub.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=\ngithub.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=\ngithub.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=\ngithub.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4=\ngithub.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=\ngithub.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d h1:x3S6kxmy49zXVVyhcnrFqxvNVCBPb2KZ9hV2RBdS840=\ngithub.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=\ngolang.org/x/arch v0.0.0-20181203225421-5a4828bb7045/go.mod h1:cYlCBUl1MsqxdiKgmc4uh7TxZfWSFLOGSRR090WDxt8=\ngopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=\ngopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=\ngopkg.in/yaml.v3 v3.0.0-20190502103701-55513cacd4ae/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=\ngopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22 h1:0efs3hwEZhFKsCoP8l6dDB1AZWMgnEl3yWXWRZTOaEA=\ngopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=\n"
  },
  {
    "path": "main.go",
    "content": "package main\n\nimport (\n\tui \"github.com/gizak/termui/v3\"\n\t\"github.com/sqshq/sampler/asset\"\n\t\"github.com/sqshq/sampler/component\"\n\t\"github.com/sqshq/sampler/component/asciibox\"\n\t\"github.com/sqshq/sampler/component/barchart\"\n\t\"github.com/sqshq/sampler/component/gauge\"\n\t\"github.com/sqshq/sampler/component/layout\"\n\t\"github.com/sqshq/sampler/component/runchart\"\n\t\"github.com/sqshq/sampler/component/sparkline\"\n\t\"github.com/sqshq/sampler/component/textbox\"\n\t\"github.com/sqshq/sampler/config\"\n\t\"github.com/sqshq/sampler/console\"\n\t\"github.com/sqshq/sampler/data\"\n\t\"github.com/sqshq/sampler/event\"\n\t\"time\"\n)\n\ntype Starter struct {\n\tplayer  *asset.AudioPlayer\n\tlout    *layout.Layout\n\tpalette console.Palette\n\topt     config.Options\n\tcfg     config.Config\n}\n\nfunc (s *Starter) startAll() []*data.Sampler {\n\tsamplers := make([]*data.Sampler, 0)\n\tfor _, c := range s.cfg.RunCharts {\n\t\tcpt := runchart.NewRunChart(c, s.palette)\n\t\tsamplers = append(samplers, s.start(cpt, cpt.Consumer, c.ComponentConfig, c.Items, c.Triggers))\n\t}\n\tfor _, c := range s.cfg.SparkLines {\n\t\tcpt := sparkline.NewSparkLine(c, s.palette)\n\t\tsamplers = append(samplers, s.start(cpt, cpt.Consumer, c.ComponentConfig, []config.Item{c.Item}, c.Triggers))\n\t}\n\tfor _, c := range s.cfg.BarCharts {\n\t\tcpt := barchart.NewBarChart(c, s.palette)\n\t\tsamplers = append(samplers, s.start(cpt, cpt.Consumer, c.ComponentConfig, c.Items, c.Triggers))\n\t}\n\tfor _, c := range s.cfg.Gauges {\n\t\tcpt := gauge.NewGauge(c, s.palette)\n\t\tsamplers = append(samplers, s.start(cpt, cpt.Consumer, c.ComponentConfig, []config.Item{c.Cur, c.Min, c.Max}, c.Triggers))\n\t}\n\tfor _, c := range s.cfg.AsciiBoxes {\n\t\tcpt := asciibox.NewAsciiBox(c, s.palette)\n\t\tsamplers = append(samplers, s.start(cpt, cpt.Consumer, c.ComponentConfig, []config.Item{c.Item}, c.Triggers))\n\t}\n\tfor _, c := range s.cfg.TextBoxes {\n\t\tcpt := textbox.NewTextBox(c, s.palette)\n\t\tsamplers = append(samplers, s.start(cpt, cpt.Consumer, c.ComponentConfig, []config.Item{c.Item}, c.Triggers))\n\t}\n\treturn samplers\n}\n\nfunc (s *Starter) start(drawable ui.Drawable, consumer *data.Consumer, componentConfig config.ComponentConfig, itemsConfig []config.Item, triggersConfig []config.TriggerConfig) *data.Sampler {\n\tcpt := component.NewComponent(drawable, consumer, componentConfig)\n\ttriggers := data.NewTriggers(triggersConfig, consumer, s.opt, s.player)\n\titems := data.NewItems(itemsConfig, *componentConfig.RateMs)\n\ts.lout.AddComponent(cpt)\n\ttime.Sleep(10 * time.Millisecond) // desync coroutines\n\treturn data.NewSampler(consumer, items, triggers, s.opt, s.cfg.Variables, *componentConfig.RateMs)\n}\n\nfunc main() {\n\n\tcfg, opt := config.LoadConfig()\n\n\tconsole.Init()\n\tdefer console.Close()\n\n\tplayer := asset.NewAudioPlayer()\n\tif player != nil {\n\t\tdefer player.Close()\n\t}\n\n\tpalette := console.GetPalette(*cfg.Theme)\n\tlout := layout.NewLayout(component.NewStatusBar(*opt.ConfigFile, palette), component.NewMenu(palette))\n\n\tstarter := &Starter{player, lout, palette, opt, *cfg}\n\tsamplers := starter.startAll()\n\n\thandler := event.NewHandler(samplers, opt, lout)\n\thandler.HandleEvents()\n}\n"
  }
]