summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-10 10:25:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-03-10 10:25:35 +0000
commit00d53825e149d12a3112edc5ea5bcaf3306838ac (patch)
tree806c01b02663e86a62cb5f9099e5bbf9ae14fbca
parentInitial commit. (diff)
downloadicingaweb2-module-reporting-00d53825e149d12a3112edc5ea5bcaf3306838ac.tar.xz
icingaweb2-module-reporting-00d53825e149d12a3112edc5ea5bcaf3306838ac.zip
Adding upstream version 0.9.2+20200529.upstream/0.9.2+20200529upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--LICENSE339
-rw-r--r--README.md12
-rw-r--r--application/clicommands/ScheduleCommand.php24
-rw-r--r--application/controllers/ConfigController.php41
-rw-r--r--application/controllers/PlugController.php.disabled72
-rw-r--r--application/controllers/ReportController.php169
-rw-r--r--application/controllers/ReportController.php.modal126
-rw-r--r--application/controllers/ReportsController.php103
-rw-r--r--application/controllers/TemplateController.php84
-rw-r--r--application/controllers/TemplatesController.php90
-rw-r--r--application/controllers/TestController.php47
-rw-r--r--application/controllers/TimeframeController.php46
-rw-r--r--application/controllers/TimeframesController.php92
-rw-r--r--application/forms/ConfigureMailForm.php23
-rw-r--r--application/forms/SelectBackendForm.php28
-rw-r--r--application/views/scripts/config/backend.phtml6
-rw-r--r--application/views/scripts/config/mail.phtml6
-rw-r--r--composer.json7
-rw-r--r--composer.lock181
-rw-r--r--config/systemd/icinga-reporting.service10
-rw-r--r--configuration.php33
-rw-r--r--doc/02-Installation.md83
-rw-r--r--doc/80-Upgrading.md18
-rw-r--r--library/Reporting/Actions/SendMail.php121
-rw-r--r--library/Reporting/Cli/Command.php23
-rw-r--r--library/Reporting/Common/Macros.php49
-rw-r--r--library/Reporting/Database.php58
-rw-r--r--library/Reporting/Dimensions.php21
-rw-r--r--library/Reporting/Hook/ActionHook.php38
-rw-r--r--library/Reporting/Hook/ReportHook.php117
-rw-r--r--library/Reporting/Mail.php177
-rw-r--r--library/Reporting/ProvidedActions.php20
-rw-r--r--library/Reporting/ProvidedReports.php20
-rw-r--r--library/Reporting/Report.php417
-rw-r--r--library/Reporting/ReportData.php71
-rw-r--r--library/Reporting/ReportRow.php10
-rw-r--r--library/Reporting/Reportlet.php86
-rw-r--r--library/Reporting/Reports/SystemReport.php39
-rw-r--r--library/Reporting/RetryConnection.php66
-rw-r--r--library/Reporting/Schedule.php160
-rw-r--r--library/Reporting/Scheduler.php176
-rw-r--r--library/Reporting/Str.php37
-rw-r--r--library/Reporting/Timeframe.php168
-rw-r--r--library/Reporting/Timerange.php35
-rw-r--r--library/Reporting/Values.php21
-rw-r--r--library/Reporting/Web/Controller.php20
-rw-r--r--library/Reporting/Web/DivDecorator.php131
-rw-r--r--library/Reporting/Web/Flatpickr.php25
-rw-r--r--library/Reporting/Web/Forms/DecoratedElement.php17
-rw-r--r--library/Reporting/Web/Forms/ReportForm.php173
-rw-r--r--library/Reporting/Web/Forms/ScheduleForm.php170
-rw-r--r--library/Reporting/Web/Forms/SendForm.php63
-rw-r--r--library/Reporting/Web/Forms/TemplateForm.php283
-rw-r--r--library/Reporting/Web/Forms/TimeframeForm.php111
-rw-r--r--library/Reporting/Web/ReportsTimeframesAndTemplatesTabs.php37
-rw-r--r--library/Reporting/Web/Widget/CoverPage.php181
-rw-r--r--library/Reporting/Web/Widget/HeaderOrFooter.php94
-rw-r--r--library/Reporting/Web/Widget/Template.php183
-rw-r--r--library/vendor/ipl/Html/src/FormElement/FileElement.php15
-rw-r--r--library/vendor/ipl/web/src/Common/BaseTarget.php30
-rw-r--r--library/vendor/ipl/web/src/Compat/CompatController.php77
-rw-r--r--library/vendor/ipl/web/src/Compat/ViewRenderer.php66
-rw-r--r--library/vendor/ipl/web/src/Url.php15
-rw-r--r--library/vendor/ipl/web/src/Widget/ActionBar.php44
-rw-r--r--library/vendor/ipl/web/src/Widget/ActionLink.php29
-rw-r--r--library/vendor/ipl/web/src/Widget/ButtonLink.php9
-rw-r--r--library/vendor/ipl/web/src/Widget/Content.php15
-rw-r--r--library/vendor/ipl/web/src/Widget/Controls.php47
-rw-r--r--library/vendor/ipl/web/src/Widget/DropdownLink.php70
-rw-r--r--library/vendor/ipl/web/src/Widget/Icon.php29
-rw-r--r--library/vendor/ipl/web/src/Widget/Link.php81
-rw-r--r--library/vendor/ipl/web/src/Widget/Tabs.php13
-rw-r--r--module.info6
-rw-r--r--public/css/forms.less207
-rw-r--r--public/css/module.less182
-rw-r--r--public/css/system-report.css81
-rw-r--r--public/css/vendor/flatpickr.css784
-rw-r--r--public/css/vendor/flatpickr.min.css13
-rw-r--r--public/img/select-icon-2x.pngbin0 -> 190 bytes
-rw-r--r--public/img/select-icon.pngbin0 -> 155 bytes
-rw-r--r--public/img/textarea-corner-2x.pngbin0 -> 238 bytes
-rw-r--r--public/img/textarea-corner.pngbin0 -> 181 bytes
-rw-r--r--public/js/module.js60
-rw-r--r--public/js/vendor/flatpickr.js2605
-rw-r--r--public/js/vendor/flatpickr.min.js2
-rw-r--r--run.php18
-rw-r--r--schema/mysql-migrations/v0.10.0.sql12
-rw-r--r--schema/mysql-migrations/v0.9.1.sql9
-rw-r--r--schema/mysql.sql96
-rw-r--r--schema/postgresql.sql83
-rw-r--r--vendor/autoload.php7
-rw-r--r--vendor/composer/ClassLoader.php445
-rw-r--r--vendor/composer/LICENSE21
-rw-r--r--vendor/composer/autoload_classmap.php9
-rw-r--r--vendor/composer/autoload_files.php11
-rw-r--r--vendor/composer/autoload_namespaces.php9
-rw-r--r--vendor/composer/autoload_psr4.php11
-rw-r--r--vendor/composer/autoload_real.php70
-rw-r--r--vendor/composer/autoload_static.php44
-rw-r--r--vendor/composer/installed.json169
-rw-r--r--vendor/guzzlehttp/psr7/CHANGELOG.md246
-rw-r--r--vendor/guzzlehttp/psr7/LICENSE19
-rw-r--r--vendor/guzzlehttp/psr7/README.md745
-rw-r--r--vendor/guzzlehttp/psr7/composer.json49
-rw-r--r--vendor/guzzlehttp/psr7/src/AppendStream.php241
-rw-r--r--vendor/guzzlehttp/psr7/src/BufferStream.php137
-rw-r--r--vendor/guzzlehttp/psr7/src/CachingStream.php138
-rw-r--r--vendor/guzzlehttp/psr7/src/DroppingStream.php42
-rw-r--r--vendor/guzzlehttp/psr7/src/FnStream.php158
-rw-r--r--vendor/guzzlehttp/psr7/src/InflateStream.php52
-rw-r--r--vendor/guzzlehttp/psr7/src/LazyOpenStream.php39
-rw-r--r--vendor/guzzlehttp/psr7/src/LimitStream.php155
-rw-r--r--vendor/guzzlehttp/psr7/src/MessageTrait.php213
-rw-r--r--vendor/guzzlehttp/psr7/src/MultipartStream.php153
-rw-r--r--vendor/guzzlehttp/psr7/src/NoSeekStream.php22
-rw-r--r--vendor/guzzlehttp/psr7/src/PumpStream.php165
-rw-r--r--vendor/guzzlehttp/psr7/src/Request.php151
-rw-r--r--vendor/guzzlehttp/psr7/src/Response.php154
-rw-r--r--vendor/guzzlehttp/psr7/src/Rfc7230.php18
-rw-r--r--vendor/guzzlehttp/psr7/src/ServerRequest.php376
-rw-r--r--vendor/guzzlehttp/psr7/src/Stream.php267
-rw-r--r--vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php149
-rw-r--r--vendor/guzzlehttp/psr7/src/StreamWrapper.php161
-rw-r--r--vendor/guzzlehttp/psr7/src/UploadedFile.php316
-rw-r--r--vendor/guzzlehttp/psr7/src/Uri.php760
-rw-r--r--vendor/guzzlehttp/psr7/src/UriNormalizer.php216
-rw-r--r--vendor/guzzlehttp/psr7/src/UriResolver.php219
-rw-r--r--vendor/guzzlehttp/psr7/src/functions.php899
-rw-r--r--vendor/guzzlehttp/psr7/src/functions_include.php6
-rw-r--r--vendor/psr/http-message/CHANGELOG.md36
-rw-r--r--vendor/psr/http-message/LICENSE19
-rw-r--r--vendor/psr/http-message/README.md13
-rw-r--r--vendor/psr/http-message/composer.json26
-rw-r--r--vendor/psr/http-message/src/MessageInterface.php187
-rw-r--r--vendor/psr/http-message/src/RequestInterface.php129
-rw-r--r--vendor/psr/http-message/src/ResponseInterface.php68
-rw-r--r--vendor/psr/http-message/src/ServerRequestInterface.php261
-rw-r--r--vendor/psr/http-message/src/StreamInterface.php158
-rw-r--r--vendor/psr/http-message/src/UploadedFileInterface.php123
-rw-r--r--vendor/psr/http-message/src/UriInterface.php323
-rw-r--r--vendor/ralouphie/getallheaders/LICENSE21
-rw-r--r--vendor/ralouphie/getallheaders/README.md27
-rw-r--r--vendor/ralouphie/getallheaders/composer.json26
-rw-r--r--vendor/ralouphie/getallheaders/src/getallheaders.php46
144 files changed, 18281 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..ecbc059
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. \ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..278c5cc
--- /dev/null
+++ b/README.md
@@ -0,0 +1,12 @@
+# Icinga Reporting
+
+Icinga Reporting is the central component for reporting related functionality in the monitoring web frontend and
+framework Icinga Web 2. The engine allows you to create reports over a specified time period for ad-hoc and scheduled
+generation of reports. Other modules use the provided functionality in order to provide concrete reports.
+
+If you are looking for SLA reports for your hosts and services, please also install the
+[idoreports](https://github.com/Icinga/icingaweb2-module-idoreports) module.
+
+## Documentation
+
+* [Installation](doc/02-Installation.md)
diff --git a/application/clicommands/ScheduleCommand.php b/application/clicommands/ScheduleCommand.php
new file mode 100644
index 0000000..e554138
--- /dev/null
+++ b/application/clicommands/ScheduleCommand.php
@@ -0,0 +1,24 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Clicommands;
+
+use Icinga\Module\Reporting\Cli\Command;
+use Icinga\Module\Reporting\Scheduler;
+
+class ScheduleCommand extends Command
+{
+ /**
+ * Run all configured reports based on their schedule
+ *
+ * USAGE:
+ *
+ * icingacli reporting schedule run
+ */
+ public function runAction()
+ {
+ $scheduler = new Scheduler($this->getDb());
+
+ $scheduler->run();
+ }
+}
diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php
new file mode 100644
index 0000000..30fcc67
--- /dev/null
+++ b/application/controllers/ConfigController.php
@@ -0,0 +1,41 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Controllers;
+
+use Icinga\Application\Config;
+use Icinga\Module\Reporting\Forms\ConfigureMailForm;
+use Icinga\Module\Reporting\Forms\SelectBackendForm;
+use Icinga\Web\Controller;
+
+class ConfigController extends Controller
+{
+ public function init()
+ {
+ $this->assertPermission('config/modules');
+
+ parent::init();
+ }
+
+ public function backendAction()
+ {
+ $form = (new SelectBackendForm())
+ ->setIniConfig(Config::module('reporting'));
+
+ $form->handleRequest();
+
+ $this->view->tabs = $this->Module()->getConfigTabs()->activate('backend');
+ $this->view->form = $form;
+ }
+
+ public function mailAction()
+ {
+ $form = (new ConfigureMailForm())
+ ->setIniConfig(Config::module('reporting'));
+
+ $form->handleRequest();
+
+ $this->view->tabs = $this->Module()->getConfigTabs()->activate('mail');
+ $this->view->form = $form;
+ }
+}
diff --git a/application/controllers/PlugController.php.disabled b/application/controllers/PlugController.php.disabled
new file mode 100644
index 0000000..a2c6453
--- /dev/null
+++ b/application/controllers/PlugController.php.disabled
@@ -0,0 +1,72 @@
+<?php
+
+namespace Icinga\Module\Reporting\Controllers;
+
+use GuzzleHttp\Psr7\ServerRequest;
+use Icinga\Module\Reporting\Hook\ReportHook;
+use Icinga\Module\Reporting\Web\Forms\ReportForm;
+use Icinga\Module\Reporting\Web\Controller;
+use Icinga\Web\Hook;
+use Icinga\Web\Url;
+use ipl\Html\Html;
+
+class PlugController extends Controller
+{
+ public function indexAction()
+ {
+ $moduleToShow = strtolower($this->params->get('module', 'reporting'));
+
+ $reportsByModule = [];
+
+ foreach (ReportHook::getReports() as $class => $report) {
+ $moduleName = $report->getModuleName();
+
+ if (! isset($reportsByModule[$moduleName])) {
+ $reportsByModule[$moduleName] = [];
+ }
+
+ $reportsByModule[$moduleName][$class] = $report;
+ }
+
+ $editor = Html::tag('div', ['class' => 'editor']);
+
+ $nav = [];
+
+ $cards = [];
+
+ foreach ($reportsByModule as $moduleName => $reports) {
+ $link = Html::tag('a', ['href' => Url::fromRequest(['module' => $moduleName])], $moduleName);
+
+ $nav[] = $link;
+
+ if ($moduleName !== $moduleToShow) {
+ continue;
+ }
+
+ $link->getAttributes()->add('class', 'active');
+
+ foreach ($reports as $report) {
+ $cards[] = Html::tag(
+ 'div',
+ ['class' => 'card'],
+ [
+ Html::tag('div', ['class' => 'card-top'], $report->getPreview()),
+ Html::tag(
+ 'div',
+ ['class' => 'card-content'],
+ Html::tag('h5', ['class' => 'card-title'], $report->getName()),
+ Html::tag('p', ['class' => 'card-text'], $report->getDescription())
+ )
+ ]
+ );
+ }
+ }
+
+ $editor->add(Html::tag('div', ['class' => 'editor-nav'], $nav));
+ $editor->add(Html::tag('div', ['class' => 'editor-content'], $cards));
+
+ $this->addContent($editor);
+
+ $this->addContent(Html::tag('a', ['href' => 'plug', 'class' => 'modal-toggle', 'data-base-target' => 'modal-container'], 'Modal'));
+ }
+}
diff --git a/application/controllers/ReportController.php b/application/controllers/ReportController.php
new file mode 100644
index 0000000..35709cb
--- /dev/null
+++ b/application/controllers/ReportController.php
@@ -0,0 +1,169 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Controllers;
+
+use GuzzleHttp\Psr7\ServerRequest;
+use Icinga\Application\Hook;
+use Icinga\Module\Pdfexport\ProvidedHook\Pdfexport;
+use Icinga\Module\Reporting\Database;
+use Icinga\Module\Reporting\Report;
+use Icinga\Module\Reporting\Web\Controller;
+use Icinga\Module\Reporting\Web\Forms\ReportForm;
+use Icinga\Module\Reporting\Web\Forms\ScheduleForm;
+use Icinga\Module\Reporting\Web\Forms\SendForm;
+use Icinga\Web\StyleSheet;
+use ipl\Html\Error;
+use ipl\Html\Html;
+use ipl\Html\HtmlString;
+use reportingipl\Web\Url;
+use reportingipl\Web\Widget\ActionBar;
+use reportingipl\Web\Widget\DropdownLink;
+
+class ReportController extends Controller
+{
+ use Database;
+
+ /** @var Report */
+ protected $report;
+
+ public function init()
+ {
+ $this->report = Report::fromDb($this->params->getRequired('id'));
+ }
+
+ public function indexAction()
+ {
+ $this->setTitle($this->report->getName());
+
+ $this->addControl($this->assembleActions());
+
+ try {
+ $this->addContent($this->report->toHtml());
+ } catch (\Exception $e) {
+ $this->addContent(Error::show($e));
+ }
+ }
+
+ public function editAction()
+ {
+ $this->setTitle('Edit Report');
+
+ $values = [
+ 'name' => $this->report->getName(),
+ // TODO(el): Must cast to string here because ipl/html does not support integer return values for attribute callbacks
+ 'timeframe' => (string) $this->report->getTimeframe()->getId(),
+ ];
+
+ $reportlet = $this->report->getReportlets()[0];
+
+ $values['reportlet'] = $reportlet->getClass();
+
+ foreach ($reportlet->getConfig() as $name => $value) {
+ $values[$name] = $value;
+ }
+
+ $form = new ReportForm();
+ $form->setId($this->report->getId());
+ $form->populate($values);
+ $form->handleRequest(ServerRequest::fromGlobals());
+
+ $this->redirectForm($form, 'reporting/reports');
+
+ $this->addContent($form);
+ }
+
+ public function sendAction()
+ {
+ $this->setTitle('Send Report');
+
+ $form = new SendForm();
+ $form
+ ->setReport($this->report)
+ ->handleRequest(ServerRequest::fromGlobals());
+
+ $this->redirectForm($form, "reporting/report?id={$this->report->getId()}");
+
+ $this->addContent($form);
+ }
+
+ public function scheduleAction()
+ {
+ $this->setTitle('Schedule');
+
+ $form = new ScheduleForm();
+ $form
+ ->setReport($this->report)
+ ->handleRequest(ServerRequest::fromGlobals());
+
+ $this->redirectForm($form, "reporting/report?id={$this->report->getId()}");
+
+ $this->addContent($form);
+ }
+
+ public function downloadAction()
+ {
+ $type = $this->params->getRequired('type');
+
+ $name = sprintf(
+ '%s (%s) %s',
+ $this->report->getName(),
+ $this->report->getTimeframe()->getName(),
+ date('Y-m-d H:i')
+ );
+
+ switch ($type) {
+ case 'pdf':
+ /** @var Hook\PdfexportHook */
+ Pdfexport::first()->streamPdfFromHtml($this->report->toPdf(), $name);
+ exit;
+ case 'csv':
+ $response = $this->getResponse();
+ $response
+ ->setHeader('Content-Type', 'text/csv')
+ ->setHeader('Cache-Control', 'no-store')
+ ->setHeader(
+ 'Content-Disposition',
+ 'attachment; filename=' . $name . '.csv'
+ )
+ ->appendBody($this->report->toCsv())
+ ->sendResponse();
+ exit;
+ case 'json':
+ $response = $this->getResponse();
+ $response
+ ->setHeader('Content-Type', 'application/json')
+ ->setHeader('Cache-Control', 'no-store')
+ ->setHeader(
+ 'Content-Disposition',
+ 'inline; filename=' . $name . '.json'
+ )
+ ->appendBody($this->report->toJson())
+ ->sendResponse();
+ exit;
+ }
+ }
+
+ protected function assembleActions()
+ {
+ $reportId = $this->report->getId();
+
+ $download = (new DropdownLink('Download'))
+ ->addLink('PDF', Url::fromPath('reporting/report/download?type=pdf', ['id' => $reportId]));
+
+ if ($this->report->providesData()) {
+ $download->addLink('CSV', Url::fromPath('reporting/report/download?type=csv', ['id' => $reportId]));
+ $download->addLink('JSON', Url::fromPath('reporting/report/download?type=json', ['id' => $reportId]));
+ }
+
+ $actions = new ActionBar();
+
+ $actions
+ ->addLink('Modify', Url::fromPath('reporting/report/edit', ['id' => $reportId]), 'edit')
+ ->addLink('Schedule', Url::fromPath('reporting/report/schedule', ['id' => $reportId]), 'calendar-empty')
+ ->add($download)
+ ->addLink('Send', Url::fromPath('reporting/report/send', ['id' => $reportId]), 'forward');
+
+ return $actions;
+ }
+}
diff --git a/application/controllers/ReportController.php.modal b/application/controllers/ReportController.php.modal
new file mode 100644
index 0000000..915bf2b
--- /dev/null
+++ b/application/controllers/ReportController.php.modal
@@ -0,0 +1,126 @@
+<?php
+
+namespace Icinga\Module\Reporting\Controllers;
+
+use GuzzleHttp\Psr7\ServerRequest;
+use Icinga\Module\Reporting\Database;
+use Icinga\Module\Reporting\Report;
+use Icinga\Module\Reporting\Web\Controller;
+use Icinga\Module\Reporting\Web\Forms\ReportForm;
+use Icinga\Module\Reporting\Web\Forms\ScheduleForm;
+use Icinga\Module\Reporting\Web\Forms\SendForm;
+use ipl\Web\Widget\ModalToggle;
+use ipl\Web\Widget\Modal;
+use reportingipl\Web\Url;
+use reportingipl\Web\Widget\ActionBar;
+use reportingipl\Web\Widget\DropdownLink;
+
+class ReportController extends Controller
+{
+ use Database;
+
+ /** @var Report */
+ protected $report;
+
+ public function init()
+ {
+ $this->report = Report::fromDb($this->params->getRequired('id'));
+ }
+
+ public function indexAction()
+ {
+ $this->setTitle($this->report->getName());
+
+ $this->addControl($this->assembleActions());
+
+ $this->addContent($this->report->toHtml());
+ }
+
+ public function editAction()
+ {
+ $this->setTitle('Edit Report');
+
+ $values = [
+ 'name' => $this->report->getName(),
+ 'timeframe' => $this->report->getTimeframe()->getId(),
+ ];
+
+ $reportlet = $this->report->getReportlets()[0];
+
+ $values['reportlet'] = $reportlet->getClass();
+
+ foreach ($reportlet->getConfig() as $name => $value) {
+ $values[$name] = $value;
+ }
+
+ $form = new ReportForm();
+ $form->setId($this->report->getId());
+ $form->populate($values);
+ $form->handleRequest(ServerRequest::fromGlobals());
+
+ $this->redirectForm($form, 'reporting/reports');
+
+ $this->addContent($form);
+ }
+
+ public function sendAction()
+ {
+ $this->setTitle('Send Report');
+
+ $form = new SendForm();
+ $form
+ ->setReport($this->report)
+ ->handleRequest(ServerRequest::fromGlobals());
+
+ $this->redirectForm($form, "reporting/report?id={$this->report->getId()}");
+
+ $this->addContent(new Modal($form));
+ }
+
+ public function scheduleAction()
+ {
+ $this->setTitle('Schedule');
+
+ $form = new ScheduleForm();
+ $form
+ ->setReport($this->report)
+ ->handleRequest(ServerRequest::fromGlobals());
+
+ $this->redirectForm($form, "reporting/report?id={$this->report->getId()}");
+
+ $this->addContent(new Modal($form));
+
+ $this->getResponse()->setHeader('X-Icinga-History', 'no', true);
+ }
+
+ protected function assembleActions()
+ {
+ $reportId = $this->report->getId();
+
+ $download = (new DropdownLink('Download'))
+ ->addLink('PDF', Url::fromPath('reporting/report/download?type=pdf', ['id' => $reportId]));
+
+ $send = (new DropdownLink('Send', 'forward'))
+ ->addLink('PDF', Url::fromPath('reporting/report/send?type=pdf', ['id' => $reportId]));
+
+ if ($this->report->providesCsv()) {
+ $download->addLink('CSV', Url::fromPath('reporting/report/download?type=csv', ['id' => $reportId]));
+ $send->addLink('CSV', Url::fromPath('reporting/report/send?type=csv', ['id' => $reportId]));
+ }
+
+ if ($this->report->providesJson()) {
+ $download->addLink('JSON', Url::fromPath('reporting/report/download?type=json', ['id' => $reportId]));
+ $send->addLink('JSON', Url::fromPath('reporting/report/send?type=json', ['id' => $reportId]));
+ }
+
+ $actions = new ActionBar();
+
+ $actions
+ ->addLink('Modify', Url::fromPath('reporting/report/edit', ['id' => $reportId]), 'edit')
+ ->add(new ModalToggle('Schedule', Url::fromPath('reporting/report/schedule', ['id' => $reportId]), 'calendar-empty'))
+ ->add($download)
+ ->addLink('Send', Url::fromPath('reporting/report/send', ['id' => $reportId]), 'forward');
+
+ return $actions;
+ }
+}
diff --git a/application/controllers/ReportsController.php b/application/controllers/ReportsController.php
new file mode 100644
index 0000000..a8cb085
--- /dev/null
+++ b/application/controllers/ReportsController.php
@@ -0,0 +1,103 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Controllers;
+
+use GuzzleHttp\Psr7\ServerRequest;
+use Icinga\Module\Reporting\Database;
+use Icinga\Module\Reporting\Web\Controller;
+use Icinga\Module\Reporting\Web\Forms\ReportForm;
+use Icinga\Module\Reporting\Web\ReportsTimeframesAndTemplatesTabs;
+use ipl\Html\Html;
+use ipl\Sql\Select;
+use reportingipl\Web\Url;
+use reportingipl\Web\Widget\ButtonLink;
+use reportingipl\Web\Widget\Icon;
+use reportingipl\Web\Widget\Link;
+
+class ReportsController extends Controller
+{
+ use Database;
+ use ReportsTimeframesAndTemplatesTabs;
+
+ public function indexAction()
+ {
+ $this->createTabs()->activate('reports');
+
+ $newReport = new ButtonLink(
+ $this->translate('New Report'),
+ Url::fromPath('reporting/reports/new')->getAbsoluteUrl('&'),
+ 'plus'
+ );
+
+ $this->addControl($newReport);
+
+ $tableRows = [];
+
+ $select = (new Select())
+ ->from('report r')
+ ->columns(['r.*', 'timeframe' => 't.name'])
+ ->join('timeframe t', 'r.timeframe_id = t.id')
+ ->orderBy('r.mtime', SORT_DESC);
+
+ foreach ($this->getDb()->select($select) as $report) {
+ $url = Url::fromPath('reporting/report', ['id' => $report->id])->getAbsoluteUrl('&');
+
+ $tableRows[] = Html::tag('tr', ['href' => $url], [
+ Html::tag('td', null, $report->name),
+ Html::tag('td', null, $report->author),
+ Html::tag('td', null, $report->timeframe),
+ Html::tag('td', null, date('Y-m-d H:i', $report->ctime / 1000)),
+ Html::tag('td', null, date('Y-m-d H:i', $report->mtime / 1000)),
+ Html::tag('td', ['class' => 'icon-col'], [
+ new Link(
+ new Icon('edit'),
+ Url::fromPath('reporting/report/edit', ['id' => $report->id])
+ )
+ ])
+ ]);
+ }
+
+ if (! empty($tableRows)) {
+ $table = Html::tag(
+ 'table',
+ ['class' => 'common-table table-row-selectable', 'data-base-target' => '_next'],
+ [
+ Html::tag(
+ 'thead',
+ null,
+ Html::tag(
+ 'tr',
+ null,
+ [
+ Html::tag('th', null, 'Name'),
+ Html::tag('th', null, 'Author'),
+ Html::tag('th', null, 'Timeframe'),
+ Html::tag('th', null, 'Date Created'),
+ Html::tag('th', null, 'Date Modified'),
+ Html::tag('th')
+ ]
+ )
+ ),
+ Html::tag('tbody', null, $tableRows)
+ ]
+ );
+
+ $this->addContent($table);
+ } else {
+ $this->addContent(Html::tag('p', null, 'No reports created yet.'));
+ }
+ }
+
+ public function newAction()
+ {
+ $this->setTitle($this->translate('New Report'));
+
+ $form = new ReportForm();
+ $form->handleRequest(ServerRequest::fromGlobals());
+
+ $this->redirectForm($form, 'reporting/reports');
+
+ $this->addContent($form);
+ }
+}
diff --git a/application/controllers/TemplateController.php b/application/controllers/TemplateController.php
new file mode 100644
index 0000000..aa6f7d3
--- /dev/null
+++ b/application/controllers/TemplateController.php
@@ -0,0 +1,84 @@
+<?php
+// Icinga Reporting | (c) 2019 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Controllers;
+
+use DateTime;
+use GuzzleHttp\Psr7\ServerRequest;
+use Icinga\Module\Reporting\Database;
+use Icinga\Module\Reporting\Web\Controller;
+use Icinga\Module\Reporting\Web\Forms\TemplateForm;
+use Icinga\Module\Reporting\Web\Widget\Template;
+use ipl\Sql\Select;
+
+class TemplateController extends Controller
+{
+ use Database;
+
+ public function indexAction()
+ {
+ $this->createTabs()->activate('preview');
+
+ $template = Template::fromDb($this->params->getRequired('id'));
+
+ if ($template === null) {
+ throw new \Exception('Template not found');
+ }
+
+ $template
+ ->setMacros([
+ 'date' => (new DateTime())->format('jS M, Y'),
+ 'time_frame' => 'Time Frame',
+ 'title' => 'Icinga Report Preview'
+ ])
+ ->setPreview(true);
+
+ $this->addContent($template);
+ }
+
+ public function editAction()
+ {
+ $this->createTabs()->activate('edit');
+
+ $select = (new Select())
+ ->from('template')
+ ->columns(['id', 'settings'])
+ ->where(['id = ?' => $this->params->getRequired('id')]);
+
+ $template = $this->getDb()->select($select)->fetch();
+
+ if ($template === false) {
+ throw new \Exception('Template not found');
+ }
+
+ $template->settings = json_decode($template->settings, true);
+
+ $form = (new TemplateForm())
+ ->setTemplate($template);
+
+ $form->handleRequest(ServerRequest::fromGlobals());
+
+ $this->redirectForm($form, 'reporting/templates');
+
+ $this->addContent($form);
+ }
+
+ protected function createTabs()
+ {
+ $tabs = $this->getTabs();
+
+ $tabs->add('edit', [
+ 'title' => $this->translate('Edit template'),
+ 'label' => $this->translate('Edit Template'),
+ 'url' => 'reporting/template/edit?id=' . $this->params->getRequired('id')
+ ]);
+
+ $tabs->add('preview', [
+ 'title' => $this->translate('Preview template'),
+ 'label' => $this->translate('Preview'),
+ 'url' => 'reporting/template?id=' . $this->params->getRequired('id')
+ ]);
+
+ return $tabs;
+ }
+}
diff --git a/application/controllers/TemplatesController.php b/application/controllers/TemplatesController.php
new file mode 100644
index 0000000..9691e93
--- /dev/null
+++ b/application/controllers/TemplatesController.php
@@ -0,0 +1,90 @@
+<?php
+// Icinga Reporting | (c) 2019 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Controllers;
+
+use GuzzleHttp\Psr7\ServerRequest;
+use Icinga\Module\Reporting\Database;
+use Icinga\Module\Reporting\Web\Controller;
+use Icinga\Module\Reporting\Web\Forms\TemplateForm;
+use Icinga\Module\Reporting\Web\ReportsTimeframesAndTemplatesTabs;
+use ipl\Html\Html;
+use ipl\Sql\Select;
+use reportingipl\Web\Url;
+use reportingipl\Web\Widget\ButtonLink;
+
+class TemplatesController extends Controller
+{
+ use Database;
+ use ReportsTimeframesAndTemplatesTabs;
+
+ public function indexAction()
+ {
+ $this->createTabs()->activate('templates');
+
+ $newTemplate = new ButtonLink(
+ $this->translate('New Template'),
+ Url::fromPath('reporting/templates/new')->getAbsoluteUrl('&'),
+ 'plus'
+ );
+
+ $this->addControl($newTemplate);
+
+ $select = (new Select())
+ ->from('template')
+ ->columns(['id', 'name', 'author', 'ctime', 'mtime'])
+ ->orderBy('mtime', SORT_DESC);
+
+ foreach ($this->getDb()->select($select) as $template) {
+ $url = Url::fromPath('reporting/template/edit', ['id' => $template->id])->getAbsoluteUrl('&');
+
+ $tableRows[] = Html::tag('tr', ['href' => $url], [
+ Html::tag('td', null, $template->name),
+ Html::tag('td', null, $template->author),
+ Html::tag('td', null, date('Y-m-d H:i', $template->ctime / 1000)),
+ Html::tag('td', null, date('Y-m-d H:i', $template->mtime / 1000))
+ ]);
+ }
+
+ if (! empty($tableRows)) {
+ $table = Html::tag(
+ 'table',
+ ['class' => 'common-table table-row-selectable', 'data-base-target' => '_next'],
+ [
+ Html::tag(
+ 'thead',
+ null,
+ Html::tag(
+ 'tr',
+ null,
+ [
+ Html::tag('th', null, 'Name'),
+ Html::tag('th', null, 'Author'),
+ Html::tag('th', null, 'Date Created'),
+ Html::tag('th', null, 'Date Modified')
+ ]
+ )
+ ),
+ Html::tag('tbody', null, $tableRows)
+ ]
+ );
+
+ $this->addContent($table);
+ } else {
+ $this->addContent(Html::tag('p', null, 'No templates created yet.'));
+ }
+ }
+
+ public function newAction()
+ {
+ $this->setTitle('New Title');
+
+ $form = new TemplateForm();
+
+ $form->handleRequest(ServerRequest::fromGlobals());
+
+ $this->redirectForm($form, 'reporting/templates');
+
+ $this->addContent($form);
+ }
+}
diff --git a/application/controllers/TestController.php b/application/controllers/TestController.php
new file mode 100644
index 0000000..f92a2ac
--- /dev/null
+++ b/application/controllers/TestController.php
@@ -0,0 +1,47 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Controllers;
+
+use Icinga\Module\Reporting\Database;
+use Icinga\Module\Reporting\Timeframe;
+use Icinga\Module\Reporting\Web\Controller;
+use ipl\Html\Table;
+use ipl\Sql\Select;
+
+class TestController extends Controller
+{
+ use Database;
+
+ public function timeframesAction()
+ {
+ $select = (new Select())
+ ->from('timeframe')
+ ->columns('*');
+
+ $table = new Table();
+
+ $table->getAttributes()->add('class', 'common-table');
+
+ $table->getHeader()->add(Table::row(['Name', 'Title', 'Start', 'End'], null, 'th'));
+
+ foreach ($this->getDb()->select($select) as $row) {
+ $timeframe = (new Timeframe())
+ ->setName($row->name)
+ ->setTitle($row->title)
+ ->setStart($row->start)
+ ->setEnd($row->end);
+
+ $table->getBody()->add(Table::row([
+ $timeframe->getName(),
+ $timeframe->getTitle(),
+ $timeframe->getTimerange()->getStart()->format('Y-m-d H:i:s'),
+ $timeframe->getTimerange()->getEnd()->format('Y-m-d H:i:s')
+ ]));
+ }
+
+ $this->setTitle('Timeframes');
+
+ $this->addContent($table);
+ }
+}
diff --git a/application/controllers/TimeframeController.php b/application/controllers/TimeframeController.php
new file mode 100644
index 0000000..ae16ffc
--- /dev/null
+++ b/application/controllers/TimeframeController.php
@@ -0,0 +1,46 @@
+<?php
+// Icinga Reporting | (c) 2019 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Controllers;
+
+use GuzzleHttp\Psr7\ServerRequest;
+use Icinga\Module\Reporting\Database;
+use Icinga\Module\Reporting\Timeframe;
+use Icinga\Module\Reporting\Web\Controller;
+use Icinga\Module\Reporting\Web\Forms\TimeframeForm;
+
+class TimeframeController extends Controller
+{
+ use Database;
+
+ /** @var Timeframe */
+ protected $timeframe;
+
+ public function init()
+ {
+ $this->timeframe = Timeframe::fromDb($this->params->getRequired('id'));
+ }
+
+ public function editAction()
+ {
+ $this->setTitle($this->translate('Edit Time Frame'));
+
+ $values = [
+ 'name' => $this->timeframe->getName(),
+ 'start' => $this->timeframe->getStart(),
+ 'end' => $this->timeframe->getEnd()
+ ];
+
+
+ $form = (new TimeframeForm())
+ ->setId($this->timeframe->getId());
+
+ $form->populate($values);
+
+ $form->handleRequest(ServerRequest::fromGlobals());
+
+ $this->redirectForm($form, 'reporting/timeframes');
+
+ $this->addContent($form);
+ }
+}
diff --git a/application/controllers/TimeframesController.php b/application/controllers/TimeframesController.php
new file mode 100644
index 0000000..13d6a5e
--- /dev/null
+++ b/application/controllers/TimeframesController.php
@@ -0,0 +1,92 @@
+<?php
+// Icinga Reporting | (c) 2019 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Controllers;
+
+use GuzzleHttp\Psr7\ServerRequest;
+use Icinga\Module\Reporting\Database;
+use Icinga\Module\Reporting\Web\Controller;
+use Icinga\Module\Reporting\Web\Forms\TimeframeForm;
+use Icinga\Module\Reporting\Web\ReportsTimeframesAndTemplatesTabs;
+use ipl\Html\Html;
+use ipl\Sql\Select;
+use reportingipl\Web\Url;
+use reportingipl\Web\Widget\ButtonLink;
+
+class TimeframesController extends Controller
+{
+ use Database;
+ use ReportsTimeframesAndTemplatesTabs;
+
+ public function indexAction()
+ {
+ $this->createTabs()->activate('timeframes');
+
+ $new = new ButtonLink(
+ $this->translate('New Timeframe'),
+ Url::fromPath('reporting/timeframes/new')->getAbsoluteUrl('&'),
+ 'plus'
+ );
+
+ $this->addControl($new);
+
+ $tableRows = [];
+
+ $select = (new Select())
+ ->from('timeframe t')
+ ->columns('*');
+
+ foreach ($this->getDb()->select($select) as $timeframe) {
+ $url = Url::fromPath('reporting/timeframe/edit', ['id' => $timeframe->id])->getAbsoluteUrl('&');
+
+ $tableRows[] = Html::tag('tr', ['href' => $url], [
+ Html::tag('td', null, $timeframe->name),
+ Html::tag('td', null, $timeframe->start),
+ Html::tag('td', null, $timeframe->end),
+ Html::tag('td', null, date('Y-m-d H:i', $timeframe->ctime / 1000)),
+ Html::tag('td', null, date('Y-m-d H:i', $timeframe->mtime / 1000))
+ ]);
+ }
+
+ if (! empty($tableRows)) {
+ $table = Html::tag(
+ 'table',
+ ['class' => 'common-table table-row-selectable', 'data-base-target' => '_next'],
+ [
+ Html::tag(
+ 'thead',
+ null,
+ Html::tag(
+ 'tr',
+ null,
+ [
+ Html::tag('th', null, 'Name'),
+ Html::tag('th', null, 'Start'),
+ Html::tag('th', null, 'End'),
+ Html::tag('th', null, 'Date Created'),
+ Html::tag('th', null, 'Date Modified')
+ ]
+ )
+ ),
+ Html::tag('tbody', null, $tableRows)
+ ]
+ );
+
+ $this->addContent($table);
+ } else {
+ $this->addContent(Html::tag('p', null, 'No timeframes created yet.'));
+ }
+ }
+
+ public function newAction()
+ {
+ $this->setTitle($this->translate('New Timeframe'));
+
+ $form = new TimeframeForm();
+ $form->handleRequest(ServerRequest::fromGlobals());
+
+ $this->redirectForm($form, 'reporting/timeframes');
+
+ $this->addContent($form);
+ }
+}
diff --git a/application/forms/ConfigureMailForm.php b/application/forms/ConfigureMailForm.php
new file mode 100644
index 0000000..c27c934
--- /dev/null
+++ b/application/forms/ConfigureMailForm.php
@@ -0,0 +1,23 @@
+<?php
+// Icinga Reporting | (c) 2019 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Forms;
+
+use Icinga\Forms\ConfigForm;
+
+class ConfigureMailForm extends ConfigForm
+{
+ public function init()
+ {
+ $this->setName('reporting_mail');
+ $this->setSubmitLabel($this->translate('Save Changes'));
+ }
+
+ public function createElements(array $formData)
+ {
+ $this->addElement('text', 'mail_from', [
+ 'label' => $this->translate('From'),
+ 'placeholder' => 'reporting@icinga'
+ ]);
+ }
+}
diff --git a/application/forms/SelectBackendForm.php b/application/forms/SelectBackendForm.php
new file mode 100644
index 0000000..c0a0e0d
--- /dev/null
+++ b/application/forms/SelectBackendForm.php
@@ -0,0 +1,28 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Forms;
+
+use Icinga\Data\ResourceFactory;
+use Icinga\Forms\ConfigForm;
+
+class SelectBackendForm extends ConfigForm
+{
+ public function init()
+ {
+ $this->setName('reporting_backend');
+ $this->setSubmitLabel($this->translate('Save Changes'));
+ }
+
+ public function createElements(array $formData)
+ {
+ $dbResources = ResourceFactory::getResourceConfigs('db')->keys();
+
+ $this->addElement('select', 'backend_resource', [
+ 'label' => $this->translate('Database'),
+ 'description' => $this->translate('Database resource'),
+ 'multiOptions' => array_combine($dbResources, $dbResources),
+ 'required' => true
+ ]);
+ }
+}
diff --git a/application/views/scripts/config/backend.phtml b/application/views/scripts/config/backend.phtml
new file mode 100644
index 0000000..2574402
--- /dev/null
+++ b/application/views/scripts/config/backend.phtml
@@ -0,0 +1,6 @@
+<div class="controls">
+ <?= /** @var \Icinga\Web\Widget\Tabs $tabs */ $tabs ?>
+</div>
+<div class="content">
+ <?= /** @var \Icinga\Module\Reporting\Forms\SelectBackendForm $form */ $form ?>
+</div>
diff --git a/application/views/scripts/config/mail.phtml b/application/views/scripts/config/mail.phtml
new file mode 100644
index 0000000..d647a82
--- /dev/null
+++ b/application/views/scripts/config/mail.phtml
@@ -0,0 +1,6 @@
+<div class="controls">
+ <?= /** @var \Icinga\Web\Widget\Tabs $tabs */ $tabs ?>
+</div>
+<div class="content">
+ <?= /** @var \Icinga\Module\Reporting\Forms\ConfigureMailForm $form */ $form ?>
+</div>
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..7803717
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,7 @@
+{
+ "name": "icinga/icingaweb2-module-reporting",
+ "require": {
+ "guzzlehttp/psr7": "^1.5",
+ "ext-json": "*"
+ }
+}
diff --git a/composer.lock b/composer.lock
new file mode 100644
index 0000000..2321ef2
--- /dev/null
+++ b/composer.lock
@@ -0,0 +1,181 @@
+{
+ "_readme": [
+ "This file locks the dependencies of your project to a known state",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
+ "This file is @generated automatically"
+ ],
+ "content-hash": "6b6c5cd3b1f8ba4a8d1c169cd8a9ba00",
+ "packages": [
+ {
+ "name": "guzzlehttp/psr7",
+ "version": "1.6.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/psr7.git",
+ "reference": "239400de7a173fe9901b9ac7c06497751f00727a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a",
+ "reference": "239400de7a173fe9901b9ac7c06497751f00727a",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.4.0",
+ "psr/http-message": "~1.0",
+ "ralouphie/getallheaders": "^2.0.5 || ^3.0.0"
+ },
+ "provide": {
+ "psr/http-message-implementation": "1.0"
+ },
+ "require-dev": {
+ "ext-zlib": "*",
+ "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8"
+ },
+ "suggest": {
+ "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.6-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "GuzzleHttp\\Psr7\\": "src/"
+ },
+ "files": [
+ "src/functions_include.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ },
+ {
+ "name": "Tobias Schultze",
+ "homepage": "https://github.com/Tobion"
+ }
+ ],
+ "description": "PSR-7 message implementation that also provides common utility methods",
+ "keywords": [
+ "http",
+ "message",
+ "psr-7",
+ "request",
+ "response",
+ "stream",
+ "uri",
+ "url"
+ ],
+ "time": "2019-07-01T23:21:34+00:00"
+ },
+ {
+ "name": "psr/http-message",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/http-message.git",
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Http\\Message\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for HTTP messages",
+ "homepage": "https://github.com/php-fig/http-message",
+ "keywords": [
+ "http",
+ "http-message",
+ "psr",
+ "psr-7",
+ "request",
+ "response"
+ ],
+ "time": "2016-08-06T14:39:51+00:00"
+ },
+ {
+ "name": "ralouphie/getallheaders",
+ "version": "3.0.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/ralouphie/getallheaders.git",
+ "reference": "120b605dfeb996808c31b6477290a714d356e822"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
+ "reference": "120b605dfeb996808c31b6477290a714d356e822",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.6"
+ },
+ "require-dev": {
+ "php-coveralls/php-coveralls": "^2.1",
+ "phpunit/phpunit": "^5 || ^6.5"
+ },
+ "type": "library",
+ "autoload": {
+ "files": [
+ "src/getallheaders.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Ralph Khattar",
+ "email": "ralph.khattar@gmail.com"
+ }
+ ],
+ "description": "A polyfill for getallheaders.",
+ "time": "2019-03-08T08:55:37+00:00"
+ }
+ ],
+ "packages-dev": [],
+ "aliases": [],
+ "minimum-stability": "stable",
+ "stability-flags": [],
+ "prefer-stable": false,
+ "prefer-lowest": false,
+ "platform": {
+ "ext-json": "*"
+ },
+ "platform-dev": []
+}
diff --git a/config/systemd/icinga-reporting.service b/config/systemd/icinga-reporting.service
new file mode 100644
index 0000000..51cc155
--- /dev/null
+++ b/config/systemd/icinga-reporting.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Icinga Reporting Scheduler
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/icingacli reporting schedule run
+Restart=on-success
+
+[Install]
+WantedBy=multi-user.target
diff --git a/configuration.php b/configuration.php
new file mode 100644
index 0000000..69d93e8
--- /dev/null
+++ b/configuration.php
@@ -0,0 +1,33 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting {
+
+ use Icinga\Application\Version;
+
+ /** @var \Icinga\Application\Modules\Module $this */
+
+ $this->provideCssFile('forms.less');
+ $this->provideCssFile('system-report.css');
+
+ if (version_compare(Version::VERSION, '2.9.0', '<')) {
+ $this->provideJsFile('vendor/flatpickr.min.js');
+ $this->provideCssFile('vendor/flatpickr.min.css');
+ }
+
+ $this->menuSection(N_('Reporting'))->add(N_('Reports'), array(
+ 'url' => 'reporting/reports',
+ ));
+
+ $this->provideConfigTab('backend', array(
+ 'title' => $this->translate('Configure the database backend'),
+ 'label' => $this->translate('Backend'),
+ 'url' => 'config/backend'
+ ));
+
+ $this->provideConfigTab('mail', array(
+ 'title' => $this->translate('Configure mail'),
+ 'label' => $this->translate('Mail'),
+ 'url' => 'config/mail'
+ ));
+}
diff --git a/doc/02-Installation.md b/doc/02-Installation.md
new file mode 100644
index 0000000..f29f796
--- /dev/null
+++ b/doc/02-Installation.md
@@ -0,0 +1,83 @@
+# Installation <a id="installation"></a>
+
+## Requirements <a id="installation-requirements">
+
+* Icinga Web 2 (&gt;= 2.6)
+* PHP (&gt;= 5.6, preferably 7.x)
+* MySQL / MariaDB or PostgreSQL
+* Icinga Web 2 modules:
+ * [reactbundle](https://github.com/Icinga/icingaweb2-module-reactbundle) (>= 0.4)
+ * [Icinga PHP Library (ipl)](https://github.com/Icinga/icingaweb2-module-ipl) (>= 0.2.1)
+ * [pdfexport](https://github.com/Icinga/icingaweb2-module-pdfexport) (>= 0.9)
+
+## Database Setup <a id="installation-database-setup">
+
+### MySQL / MariaDB
+
+The module needs a MySQL/MariaDB database with the schema that's provided in the `etc/schema/mysql.sql` file.
+
+Example command for creating the MySQL/MariaDB database. Please change the password:
+
+```
+CREATE DATABASE reporting;
+GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON reporting.* TO reporting@localhost IDENTIFIED BY 'secret';
+```
+
+After, you can import the schema using the following command:
+
+```
+mysql -p -u root reporting < schema/mysql.sql
+```
+
+## PostgreSQL
+
+The module needs a PostgreSQL database with the schema that's provided in the `etc/schema/postgresql.sql` file.
+
+Example command for creating the PostgreSQL database. Please change the password:
+
+```sql
+CREATE USER reporting WITH PASSWORD 'secret';
+CREATE DATABASE reporting
+ WITH OWNER reporting
+ ENCODING 'UTF8'
+ LC_COLLATE = 'en_US.UTF-8'
+ LC_CTYPE = 'en_US.UTF-8';
+```
+
+After, you can import the schema using the following command:
+
+```
+psql -U reporting reporting -a -f schema/postgresql.sql
+```
+
+## Module Installation <a id="installation-module">
+
+1. Just drop this module to a `reporting` subfolder in your Icinga Web 2 module path.
+
+2. Log in with a privileged user in Icinga Web 2 and enable the module in `Configuration -> Modules -> reporting`.
+Or use the `icingacli` and run `icingacli module enable reporting`.
+
+3. Once you've set up the database, create a new Icinga Web 2 resource for it using the
+`Configuration -> Application -> Resources` menu. Make sure that you set the character set to `utf8mb4`.
+
+4. The next step involves telling the Reporting module which database resource to use. This can be done in
+`Configuration -> Modules -> reporting -> Backend`.
+
+This concludes the installation. You should now be able create reports.
+
+## Scheduler Daemon <a id="installation-scheduler-daemon">
+
+There is a daemon for generating and distributing reports on a schedule if configured:
+
+```
+icingacli reporting schedule run
+```
+
+This command schedules the execution of all applicable reports.
+
+You may configure this command as `systemd` service. Just copy the example service definition from
+`config/systemd/icinga-reporting.service` to `/etc/systemd/system/icinga-reporting.service` and enable it afterwards:
+
+```
+systemctl enable icinga-reporting.service
+```
diff --git a/doc/80-Upgrading.md b/doc/80-Upgrading.md
new file mode 100644
index 0000000..8252e6f
--- /dev/null
+++ b/doc/80-Upgrading.md
@@ -0,0 +1,18 @@
+# Upgrading Icinga Reporting <a id="upgrading"></a>
+
+Upgrading Icinga Reporting is straightforward.
+Usually the only manual steps involved are schema updates for the database.
+
+## Upgrading to Version 0.9.1 <a id="upgrading-to-v0.9.1"></a>
+
+Icinga Reporting version 0.9.1 requires a schema update for the database.
+The schema has been adjusted so that it is no longer necessary to adjust server settings
+if you're using a version of MySQL < 5.7 or MariaDB < 10.2.
+Further, the start dates for the provided time frames **Last Year** and **Current Year** have been fixed.
+Please find the upgrade script in **schema/mysql-migrations**.
+
+You may use the following command to apply the database schema upgrade file:
+
+```
+# mysql -u root -p reporting <schema/mysql-migrations/v0.9.1.sql
+```
diff --git a/library/Reporting/Actions/SendMail.php b/library/Reporting/Actions/SendMail.php
new file mode 100644
index 0000000..8b46014
--- /dev/null
+++ b/library/Reporting/Actions/SendMail.php
@@ -0,0 +1,121 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Actions;
+
+use Icinga\Application\Config;
+use Icinga\Application\Hook;
+use Icinga\Module\Reporting\Hook\ActionHook;
+use Icinga\Module\Reporting\Mail;
+use Icinga\Module\Reporting\Report;
+use Icinga\Util\StringHelper;
+use Icinga\Web\StyleSheet;
+use ipl\Html\Form;
+use ipl\Html\Html;
+use ipl\Html\HtmlString;
+
+class SendMail extends ActionHook
+{
+ public function getName()
+ {
+ return 'Send Mail';
+ }
+
+ public function execute(Report $report, array $config)
+ {
+ $name = sprintf(
+ '%s (%s) %s',
+ $report->getName(),
+ $report->getTimeframe()->getName(),
+ date('Y-m-d H:i')
+ );
+
+ $mail = new Mail();
+
+ $mail->setFrom(Config::module('reporting')->get('mail', 'from', 'reporting@icinga'));
+
+ switch ($config['type']) {
+ case 'pdf':
+ $pdfexport = null;
+
+ if (Hook::has('Pdfexport')) {
+ $pdfexport = Hook::first('Pdfexport');
+
+ if (! $pdfexport->isSupported()) {
+ throw new \Exception(
+ sprintf("Can't export: %s does not support exporting PDFs", get_class($pdfexport))
+ );
+ }
+ }
+
+ if (! $pdfexport) {
+ throw new \Exception("Can't export: No module found which provides PDF export");
+ }
+
+ $html = Html::tag(
+ 'html',
+ null,
+ [
+ Html::tag(
+ 'head',
+ null,
+ Html::tag(
+ 'style',
+ null,
+ new HtmlString(StyleSheet::forPdf())
+ )
+ ),
+ Html::tag(
+ 'body',
+ null,
+ Html::tag(
+ 'div',
+ ['class' => 'icinga-module module-reporting'],
+ new HtmlString($report->toHtml())
+ )
+ )
+ ]
+ );
+
+ $mail->attachPdf($pdfexport->htmlToPdf((string) $html), $name);
+
+ break;
+ case 'csv':
+ $mail->attachCsv($report->toCsv(), $name);
+
+ break;
+ case 'json':
+ $mail->attachJson($report->toJson(), $name);
+
+ break;
+ default:
+ throw new \InvalidArgumentException();
+
+ }
+
+ $recipients = StringHelper::trimSplit($config['recipients']);
+
+ $mail->send(null, $recipients);
+ }
+
+ public function initConfigForm(Form $form, Report $report)
+ {
+ $types = ['pdf' => 'PDF'];
+
+ if ($report->providesData()) {
+ $types['csv'] = 'CSV';
+ $types['json'] = 'JSON';
+ }
+
+ $form->addElement('select', 'type', [
+ 'required' => true,
+ 'label' => 'Type',
+ 'options' => $types
+ ]);
+
+ $form->addElement('textarea', 'recipients', [
+ 'required' => true,
+ 'label' => 'Recipients'
+ ]);
+ }
+}
diff --git a/library/Reporting/Cli/Command.php b/library/Reporting/Cli/Command.php
new file mode 100644
index 0000000..a89f77b
--- /dev/null
+++ b/library/Reporting/Cli/Command.php
@@ -0,0 +1,23 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Cli;
+
+use Icinga\Application\Icinga;
+use Icinga\Application\Version;
+use Icinga\Module\Reporting\Database;
+
+class Command extends \Icinga\Cli\Command
+{
+ use Database;
+
+ // Fix Web 2 issue where $configs is not properly initialized
+ protected $configs = [];
+
+ public function init()
+ {
+ if (version_compare(Version::VERSION, '2.7.0', '<')) {
+ Icinga::app()->getModuleManager()->loadEnabledModules();
+ }
+ }
+}
diff --git a/library/Reporting/Common/Macros.php b/library/Reporting/Common/Macros.php
new file mode 100644
index 0000000..052cdd2
--- /dev/null
+++ b/library/Reporting/Common/Macros.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace Icinga\Module\Reporting\Common;
+
+trait Macros
+{
+ protected $macros;
+
+ /**
+ * @param string $name
+ *
+ * @return mixed
+ */
+ public function getMacro($name)
+ {
+ return $this->macros[$name] ?: null;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getMacros()
+ {
+ return $this->macros;
+ }
+
+ /**
+ * @param mixed $macros
+ *
+ * @return $this
+ */
+ public function setMacros($macros)
+ {
+ $this->macros = $macros;
+
+ return $this;
+ }
+
+ public function resolveMacros($subject)
+ {
+ $macros = [];
+
+ foreach ((array) $this->macros as $key => $value) {
+ $macros['${' . $key . '}'] = $value;
+ }
+
+ return str_replace(array_keys($macros), array_values($macros), $subject);
+ }
+}
diff --git a/library/Reporting/Database.php b/library/Reporting/Database.php
new file mode 100644
index 0000000..554ee07
--- /dev/null
+++ b/library/Reporting/Database.php
@@ -0,0 +1,58 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting;
+
+use Icinga\Application\Config;
+use Icinga\Data\ResourceFactory;
+use ipl\Sql;
+
+trait Database
+{
+ protected function getDb($resource = null)
+ {
+ $config = new Sql\Config(ResourceFactory::getResourceConfig(
+ $resource ?: Config::module('reporting')->get('backend', 'resource', 'reporting')
+ ));
+
+ $config->options = [
+ \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_OBJ,
+ \PDO::MYSQL_ATTR_INIT_COMMAND => "SET SESSION SQL_MODE='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE"
+ . ",ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'"
+ ];
+
+ $conn = new RetryConnection($config);
+
+ return $conn;
+ }
+
+ protected function listTimeframes()
+ {
+ $select = (new Sql\Select())
+ ->from('timeframe')
+ ->columns(['id', 'name']);
+
+ $timeframes = [];
+
+ foreach ($this->getDb()->select($select) as $row) {
+ $timeframes[$row->id] = $row->name;
+ }
+
+ return $timeframes;
+ }
+
+ protected function listTemplates()
+ {
+ $select = (new Sql\Select())
+ ->from('template')
+ ->columns(['id', 'name']);
+
+ $templates = [];
+
+ foreach ($this->getDb()->select($select) as $row) {
+ $templates[$row->id] = $row->name;
+ }
+
+ return $templates;
+ }
+}
diff --git a/library/Reporting/Dimensions.php b/library/Reporting/Dimensions.php
new file mode 100644
index 0000000..dfedbc8
--- /dev/null
+++ b/library/Reporting/Dimensions.php
@@ -0,0 +1,21 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting;
+
+trait Dimensions
+{
+ protected $dimensions;
+
+ public function getDimensions()
+ {
+ return $this->dimensions;
+ }
+
+ public function setDimensions(array $dimensions)
+ {
+ $this->dimensions = $dimensions;
+
+ return $this;
+ }
+}
diff --git a/library/Reporting/Hook/ActionHook.php b/library/Reporting/Hook/ActionHook.php
new file mode 100644
index 0000000..ae3364e
--- /dev/null
+++ b/library/Reporting/Hook/ActionHook.php
@@ -0,0 +1,38 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Hook;
+
+use Icinga\Application\Hook;
+use Icinga\Module\Reporting\Report;
+use ipl\Html\Form;
+
+abstract class ActionHook
+{
+ /**
+ * @return string
+ */
+ abstract public function getName();
+
+ /**
+ * @param Report $report
+ * @param array $config
+ */
+ abstract public function execute(Report $report, array $config);
+
+ /**
+ * @param Form $form
+ */
+ public function initConfigForm(Form $form, Report $report)
+ {
+
+ }
+
+ /**
+ * @return ActionHook[]
+ */
+ final public static function getActions()
+ {
+ return Hook::all('reporting/Action');
+ }
+}
diff --git a/library/Reporting/Hook/ReportHook.php b/library/Reporting/Hook/ReportHook.php
new file mode 100644
index 0000000..7b9c259
--- /dev/null
+++ b/library/Reporting/Hook/ReportHook.php
@@ -0,0 +1,117 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Hook;
+
+use Icinga\Application\ClassLoader;
+use Icinga\Application\Hook;
+use Icinga\Module\Reporting\ReportData;
+use Icinga\Module\Reporting\Timerange;
+use ipl\Html\Form;
+use ipl\Html\ValidHtml;
+
+abstract class ReportHook
+{
+ /**
+ * Get the name of the report
+ *
+ * @return string
+ */
+ abstract public function getName();
+
+ /**
+ * @param Timerange $timerange
+ * @param array $config
+ *
+ * @return ReportData|null
+ */
+ public function getData(Timerange $timerange, array $config = null)
+ {
+ return null;
+ }
+
+ /**
+ * Get the HTML of the report
+ *
+ * @param Timerange $timerange
+ * @param array $config
+ *
+ * @return ValidHtml|null
+ */
+ public function getHtml(Timerange $timerange, array $config = null)
+ {
+ return null;
+ }
+
+ /**
+ * Initialize the report's configuration form
+ *
+ * @param Form $form
+ */
+ public function initConfigForm(Form $form)
+ {
+
+ }
+
+ /**
+ * Get the description of the report
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return null;
+ }
+
+ /**
+ * Get whether the report provides reporting data
+ *
+ * @return bool
+ */
+ public function providesData()
+ {
+ try {
+ $method = new \ReflectionMethod($this, 'getData');
+ } catch (\ReflectionException $e) {
+ return false;
+ }
+
+ return $method->getDeclaringClass()->getName() !== self::class;
+ }
+
+ /**
+ * Get whether the report provides HTML
+ *
+ * @return bool
+ */
+ public function providesHtml()
+ {
+ try {
+ $method = new \ReflectionMethod($this, 'getHtml');
+ } catch (\ReflectionException $e) {
+ return false;
+ }
+
+ return $method->getDeclaringClass()->getName() !== self::class;
+ }
+
+ /**
+ * Get the module name of the report
+ *
+ * @return string
+ */
+ final public function getModuleName()
+ {
+ return ClassLoader::extractModuleName(get_class($this));
+ }
+
+ /**
+ * Get all provided reports
+ *
+ * @return ReportHook[]
+ */
+ final public static function getReports()
+ {
+ return Hook::all('reporting/Report');
+ }
+}
diff --git a/library/Reporting/Mail.php b/library/Reporting/Mail.php
new file mode 100644
index 0000000..10de6c0
--- /dev/null
+++ b/library/Reporting/Mail.php
@@ -0,0 +1,177 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting;
+
+use Zend_Mail;
+use Zend_Mail_Transport_Sendmail;
+use Zend_Mime;
+use Zend_Mime_Part;
+
+class Mail
+{
+ /** @var string */
+ protected $from;
+
+ /** @var string */
+ protected $subject = 'Icinga Reporting';
+
+ /** @var Zend_Mail_Transport_Sendmail */
+ protected $transport;
+
+ /** @var array */
+ protected $attachments = [];
+
+ /**
+ * Get the from part
+ *
+ * @return string
+ */
+ public function getFrom()
+ {
+ if (isset($this->from)) {
+ return $this->from;
+ }
+
+ if (isset($_SERVER['SERVER_ADMIN'])) {
+ $this->from = $_SERVER['SERVER_ADMIN'];
+
+ return $this->from;
+ }
+
+ foreach (['HTTP_HOST', 'SERVER_NAME', 'HOSTNAME'] as $key) {
+ if (isset($_SEVER[$key])) {
+ $this->from = 'icinga-reporting@' . $_SERVER[$key];
+
+ return $this->from;
+ }
+ }
+
+ $this->from = 'icinga-reporting@localhost';
+
+ return $this->from;
+ }
+
+ /**
+ * Set the from part
+ *
+ * @param string $from
+ *
+ * @return $this
+ */
+ public function setFrom($from)
+ {
+ $this->from = $from;
+
+ return $this;
+ }
+
+ /**
+ * Get the subject
+ *
+ * @return string
+ */
+ public function getSubject()
+ {
+ return $this->subject;
+ }
+
+ /**
+ * Set the subject
+ *
+ * @param string $subject
+ *
+ * @return $this
+ */
+ public function setSubject($subject)
+ {
+ $this->subject = $subject;
+
+ return $this;
+ }
+
+ /**
+ * Get the mail transport
+ *
+ * @return Zend_Mail_Transport_Sendmail
+ */
+ public function getTransport()
+ {
+ if (! isset($this->transport)) {
+ $this->transport = new Zend_Mail_Transport_Sendmail('-f ' . escapeshellarg($this->getFrom()));
+ }
+
+ return $this->transport;
+ }
+
+ public function attachCsv($csv, $filename)
+ {
+ if (is_array($csv)) {
+ $csv = Str::putcsv($csv);
+ }
+
+ $attachment = new Zend_Mime_Part($csv);
+
+ $attachment->type = 'text/csv';
+ $attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
+ $attachment->encoding = Zend_Mime::ENCODING_BASE64;
+ $attachment->filename = basename($filename, '.csv') . '.csv';
+
+ $this->attachments[] = $attachment;
+
+ return $this;
+ }
+
+ public function attachJson($json, $filename)
+ {
+ if (is_array($json)) {
+ $json = json_encode($json);
+ }
+
+ $attachment = new Zend_Mime_Part($json);
+
+ $attachment->type = 'application/json';
+ $attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
+ $attachment->encoding = Zend_Mime::ENCODING_BASE64;
+ $attachment->filename = basename($filename, '.json') . '.json';
+
+ $this->attachments[] = $attachment;
+
+ return $this;
+ }
+
+ public function attachPdf($pdf, $filename)
+ {
+ $attachment = new Zend_Mime_Part($pdf);
+
+ $attachment->type = 'application/pdf';
+ $attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
+ $attachment->encoding = Zend_Mime::ENCODING_BASE64;
+ $attachment->filename = basename($filename, '.pdf') . '.pdf';
+
+ $this->attachments[] = $attachment;
+
+ return $this;
+ }
+
+ public function send($body, $recipient)
+ {
+ $mail = new Zend_Mail('UTF-8');
+
+ $mail->setFrom($this->getFrom());
+ $mail->addTo($recipient);
+ $mail->setSubject($this->getSubject());
+
+ if (strlen($body) !== strlen(strip_tags($body))) {
+ $mail->setBodyHtml($body);
+ } else {
+ $mail->setBodyText($body);
+ }
+
+ foreach ($this->attachments as $attachment) {
+ $mail->addAttachment($attachment);
+ }
+
+ $mail->send($this->getTransport());
+ }
+}
diff --git a/library/Reporting/ProvidedActions.php b/library/Reporting/ProvidedActions.php
new file mode 100644
index 0000000..2590d1f
--- /dev/null
+++ b/library/Reporting/ProvidedActions.php
@@ -0,0 +1,20 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting;
+
+use Icinga\Module\Reporting\Hook\ActionHook;
+
+trait ProvidedActions
+{
+ public function listActions()
+ {
+ $actions = [];
+
+ foreach (ActionHook::getActions() as $class => $action) {
+ $actions[$class] = $action->getName();
+ }
+
+ return $actions;
+ }
+}
diff --git a/library/Reporting/ProvidedReports.php b/library/Reporting/ProvidedReports.php
new file mode 100644
index 0000000..edfc2ce
--- /dev/null
+++ b/library/Reporting/ProvidedReports.php
@@ -0,0 +1,20 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting;
+
+use Icinga\Module\Reporting\Hook\ReportHook;
+
+trait ProvidedReports
+{
+ public function listReports()
+ {
+ $reports = [];
+
+ foreach (ReportHook::getReports() as $class => $report) {
+ $reports[$class] = $report->getName();
+ }
+
+ return $reports;
+ }
+}
diff --git a/library/Reporting/Report.php b/library/Reporting/Report.php
new file mode 100644
index 0000000..746021c
--- /dev/null
+++ b/library/Reporting/Report.php
@@ -0,0 +1,417 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting;
+
+use DateTime;
+use Exception;
+use Icinga\Module\Pdfexport\PrintableHtmlDocument;
+use Icinga\Module\Reporting\Web\Widget\Template;
+use ipl\Html\Html;
+use ipl\Html\HtmlDocument;
+use ipl\Html\HtmlString;
+use ipl\Sql;
+
+class Report
+{
+ use Database;
+
+ /** @var int */
+ protected $id;
+
+ /** @var string */
+ protected $name;
+
+ /** @var string */
+ protected $author;
+
+ /** @var Timeframe */
+ protected $timeframe;
+
+ /** @var Reportlet[] */
+ protected $reportlets;
+
+ /** @var Schedule */
+ protected $schedule;
+
+ /** @var Template */
+ protected $template;
+
+ /**
+ * @param int $id
+ *
+ * @return static
+ *
+ * @throws Exception
+ */
+ public static function fromDb($id)
+ {
+ $report = new static();
+
+ $db = $report->getDb();
+
+ $select = (new Sql\Select())
+ ->from('report')
+ ->columns('*')
+ ->where(['id = ?' => $id]);
+
+ $row = $db->select($select)->fetch();
+
+ if ($row === false) {
+ throw new Exception('Report not found');
+ }
+
+ $report
+ ->setId($row->id)
+ ->setName($row->name)
+ ->setAuthor($row->author)
+ ->setTimeframe(Timeframe::fromDb($row->timeframe_id))
+ ->setTemplate(Template::fromDb($row->template_id));
+
+ $select = (new Sql\Select())
+ ->from('reportlet')
+ ->columns('*')
+ ->where(['report_id = ?' => $id]);
+
+ $row = $db->select($select)->fetch();
+
+ if ($row === false) {
+ throw new Exception('No reportlets configured.');
+ }
+
+ $reportlet = new Reportlet();
+
+ $reportlet
+ ->setId($row->id)
+ ->setClass($row->class);
+
+ $select = (new Sql\Select())
+ ->from('config')
+ ->columns('*')
+ ->where(['reportlet_id = ?' => $row->id]);
+
+ $rows = $db->select($select)->fetchAll();
+
+ $config = [];
+
+ foreach ($rows as $row) {
+ $config[$row->name] = $row->value;
+ }
+
+ $reportlet->setConfig($config);
+
+ $report->setReportlets([$reportlet]);
+
+ $select = (new Sql\Select())
+ ->from('schedule')
+ ->columns('*')
+ ->where(['report_id = ?' => $id]);
+
+ $row = $db->select($select)->fetch();
+
+ if ($row !== false) {
+ $schedule = new Schedule();
+
+ $schedule
+ ->setId($row->id)
+ ->setStart((new \DateTime())->setTimestamp((int) $row->start / 1000))
+ ->setFrequency($row->frequency)
+ ->setAction($row->action)
+ ->setConfig(json_decode($row->config, true));
+
+ $report->setSchedule($schedule);
+ }
+
+ return $report;
+ }
+
+ /**
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * @param int $id
+ *
+ * @return $this
+ */
+ public function setId($id)
+ {
+ $this->id = $id;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * @param string $name
+ *
+ * @return $this
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getAuthor()
+ {
+ return $this->author;
+ }
+
+ /**
+ * @param string $author
+ *
+ * @return $this
+ */
+ public function setAuthor($author)
+ {
+ $this->author = $author;
+
+ return $this;
+ }
+
+ /**
+ * @return Timeframe
+ */
+ public function getTimeframe()
+ {
+ return $this->timeframe;
+ }
+
+ /**
+ * @param Timeframe $timeframe
+ *
+ * @return $this
+ */
+ public function setTimeframe(Timeframe $timeframe)
+ {
+ $this->timeframe = $timeframe;
+
+ return $this;
+ }
+
+ /**
+ * @return Reportlet[]
+ */
+ public function getReportlets()
+ {
+ return $this->reportlets;
+ }
+
+ /**
+ * @param Reportlet[] $reportlets
+ *
+ * @return $this
+ */
+ public function setReportlets(array $reportlets)
+ {
+ $this->reportlets = $reportlets;
+
+ return $this;
+ }
+
+ /**
+ * @return Schedule
+ */
+ public function getSchedule()
+ {
+ return $this->schedule;
+ }
+
+ /**
+ * @param Schedule $schedule
+ *
+ * @return $this
+ */
+ public function setSchedule(Schedule $schedule)
+ {
+ $this->schedule = $schedule;
+
+ return $this;
+ }
+
+ /**
+ * @return Template
+ */
+ public function getTemplate()
+ {
+ return $this->template;
+ }
+
+ /**
+ * @param Template $template
+ *
+ * @return $this
+ */
+ public function setTemplate($template)
+ {
+ $this->template = $template;
+
+ return $this;
+ }
+
+ public function providesData()
+ {
+ foreach ($this->getReportlets() as $reportlet) {
+ $implementation = $reportlet->getImplementation();
+
+ if ($implementation->providesData()) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @return HtmlDocument
+ */
+ public function toHtml()
+ {
+ $timerange = $this->getTimeframe()->getTimerange();
+
+ $html = new HtmlDocument();
+
+ foreach ($this->getReportlets() as $reportlet) {
+ $implementation = $reportlet->getImplementation();
+
+ $html->add($implementation->getHtml($timerange, $reportlet->getConfig()));
+ }
+
+ return $html;
+ }
+
+ /**
+ * @return string
+ */
+ public function toCsv()
+ {
+ $timerange = $this->getTimeframe()->getTimerange();
+
+ $csv = [];
+
+ foreach ($this->getReportlets() as $reportlet) {
+ $implementation = $reportlet->getImplementation();
+
+ if ($implementation->providesData()) {
+ $data = $implementation->getData($timerange, $reportlet->getConfig());
+ $csv[] = array_merge($data->getDimensions(), $data->getValues());
+ foreach ($data->getRows() as $row) {
+ $csv[] = array_merge($row->getDimensions(), $row->getValues());
+ }
+
+ break;
+ }
+ }
+
+ return Str::putcsv($csv);
+ }
+
+ /**
+ * @return string
+ */
+ public function toJson()
+ {
+ $timerange = $this->getTimeframe()->getTimerange();
+
+ $json = [];
+
+ foreach ($this->getReportlets() as $reportlet) {
+ $implementation = $reportlet->getImplementation();
+
+ if ($implementation->providesData()) {
+ $data = $implementation->getData($timerange, $reportlet->getConfig());
+ $dimensions = $data->getDimensions();
+ $values = $data->getValues();
+ foreach ($data->getRows() as $row) {
+ $json[] = \array_combine($dimensions, $row->getDimensions())
+ + \array_combine($values, $row->getValues());
+ }
+
+ break;
+ }
+ }
+
+ return json_encode($json);
+ }
+
+ /**
+ * @return PrintableHtmlDocument
+ *
+ * @throws Exception
+ */
+ public function toPdf()
+ {
+ $style = <<<'STYLE'
+<style type="text/css">
+@font-face {
+ font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
+}
+
+.header,
+.footer {
+ display: flex;
+ justify-content: space-between;
+
+ font-size: 8px;
+ margin-left: 0.75cm;
+ margin-right: 0.75cm;
+ width: 100%;
+
+ > * {
+ margin-left: .25em;
+ margin-right: .25em;
+ }
+}
+
+p {
+ margin: 0;
+}
+</style>
+STYLE;
+
+ $html = (new PrintableHtmlDocument())
+ ->setTitle($this->getName())
+ ->addAttributes(['class' => 'icinga-module module-reporting'])
+ ->add(new HtmlString($this->toHtml()));
+
+ if ($this->template !== null) {
+ $this->template->setMacros([
+ 'date' => (new DateTime())->format('jS M, Y'),
+ 'time_frame' => $this->timeframe->getName(),
+ 'title' => $this->name
+ ]);
+
+ $html->setCoverPage($this->template->getCoverPage()->setMacros($this->template->getMacros()));
+
+ $header = $this->template->getHeader()->setMacros($this->template->getMacros());
+ $html->setHeader(new HtmlString(
+ $style
+ . $header->render()
+ ));
+
+ $footer = $this->template->getFooter()->setMacros($this->template->getMacros());
+ $html->setFooter(new HtmlString(
+ $style
+ . $footer->render()
+ ));
+ }
+
+ return $html;
+ }
+}
diff --git a/library/Reporting/ReportData.php b/library/Reporting/ReportData.php
new file mode 100644
index 0000000..1ef9ec5
--- /dev/null
+++ b/library/Reporting/ReportData.php
@@ -0,0 +1,71 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting;
+
+class ReportData implements \Countable
+{
+ use Dimensions;
+ use Values;
+
+ /** @var ReportRow[]|null */
+ protected $rows;
+
+ public function getRows()
+ {
+ return $this->rows;
+ }
+
+ public function setRows(array $rows)
+ {
+ $this->rows = $rows;
+
+ return $this;
+ }
+
+ public function getAverages()
+ {
+ $totals = $this->getTotals();
+ $averages = [];
+ $count = \count($this);
+
+ foreach ($totals as $total) {
+ $averages[] = $total / $count;
+ }
+
+ return $averages;
+ }
+
+// public function getMaximums()
+// {
+// }
+
+// public function getMinimums()
+// {
+// }
+
+ public function getTotals()
+ {
+ $totals = [];
+
+ foreach ((array) $this->getRows() as $row) {
+ $i = 0;
+ foreach ((array) $row->getValues() as $value) {
+ if (! isset($totals[$i])) {
+ $totals[$i] = $value;
+ } else {
+ $totals[$i] += $value;
+ }
+
+ ++$i;
+ }
+ }
+
+ return $totals;
+ }
+
+ public function count()
+ {
+ return count((array) $this->getRows());
+ }
+}
diff --git a/library/Reporting/ReportRow.php b/library/Reporting/ReportRow.php
new file mode 100644
index 0000000..1536488
--- /dev/null
+++ b/library/Reporting/ReportRow.php
@@ -0,0 +1,10 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting;
+
+class ReportRow
+{
+ use Dimensions;
+ use Values;
+}
diff --git a/library/Reporting/Reportlet.php b/library/Reporting/Reportlet.php
new file mode 100644
index 0000000..2876a00
--- /dev/null
+++ b/library/Reporting/Reportlet.php
@@ -0,0 +1,86 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting;
+
+class Reportlet
+{
+ /** @var int */
+ protected $id;
+
+ /** @var string */
+ protected $class;
+
+ /** @var array */
+ protected $config;
+
+ /**
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * @param int $id
+ *
+ * @return $this
+ */
+ public function setId($id)
+ {
+ $this->id = $id;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getClass()
+ {
+ return $this->class;
+ }
+
+ /**
+ * @param string $class
+ *
+ * @return $this
+ */
+ public function setClass($class)
+ {
+ $this->class = $class;
+
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getConfig()
+ {
+ return $this->config;
+ }
+
+ /**
+ * @param array $config
+ *
+ * @return $this
+ */
+ public function setConfig($config)
+ {
+ $this->config = $config;
+
+ return $this;
+ }
+
+ /**
+ * @return \Icinga\Module\Reporting\Hook\ReportHook
+ */
+ public function getImplementation()
+ {
+ $class = $this->getClass();
+
+ return new $class;
+ }
+}
diff --git a/library/Reporting/Reports/SystemReport.php b/library/Reporting/Reports/SystemReport.php
new file mode 100644
index 0000000..8a3d8dd
--- /dev/null
+++ b/library/Reporting/Reports/SystemReport.php
@@ -0,0 +1,39 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Reports;
+
+use Icinga\Module\Reporting\Hook\ReportHook;
+use Icinga\Module\Reporting\Timerange;
+use ipl\Html\HtmlString;
+
+class SystemReport extends ReportHook
+{
+ public function getName()
+ {
+ return 'System';
+ }
+
+ public function getHtml(Timerange $timerange, array $config = null)
+ {
+ ob_start();
+ phpinfo();
+ $html = ob_get_clean();
+
+ $doc = new \DOMDocument();
+ @$doc->loadHTML($html);
+
+ $style = $doc->getElementsByTagName('style')->item(0);
+ $style->parentNode->removeChild($style);
+
+ $title = $doc->getElementsByTagName('title')->item(0);
+ $title->parentNode->removeChild($title);
+
+ $meta = $doc->getElementsByTagName('meta')->item(0);
+ $meta->parentNode->removeChild($meta);
+
+ $doc->getElementsByTagName('div')->item(0)->setAttribute('class', 'system-report');
+
+ return new HtmlString($doc->saveHTML());
+ }
+}
diff --git a/library/Reporting/RetryConnection.php b/library/Reporting/RetryConnection.php
new file mode 100644
index 0000000..ebadfd2
--- /dev/null
+++ b/library/Reporting/RetryConnection.php
@@ -0,0 +1,66 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting;
+
+use ipl\Sql\Connection;
+
+class RetryConnection extends Connection
+{
+ public function prepexec($stmt, $values = null)
+ {
+ try {
+ $sth = parent::prepexec($stmt, $values);
+ } catch (\Exception $e) {
+ $lostConnection = Str::contains($e->getMessage(), [
+ 'server has gone away',
+ 'no connection to the server',
+ 'Lost connection',
+ 'Error while sending',
+ 'is dead or not enabled',
+ 'decryption failed or bad record mac',
+ 'server closed the connection unexpectedly',
+ 'SSL connection has been closed unexpectedly',
+ 'Error writing data to the connection',
+ 'Resource deadlock avoided',
+ 'Transaction() on null',
+ 'child connection forced to terminate due to client_idle_limit',
+ 'query_wait_timeout',
+ 'reset by peer',
+ 'Physical connection is not usable',
+ 'TCP Provider: Error code 0x68',
+ 'ORA-03114',
+ 'Packets out of order. Expected',
+ 'Adaptive Server connection failed',
+ 'Communication link failure',
+ ]);
+
+ if (! $lostConnection) {
+ throw $e;
+ }
+
+ $this->disconnect();
+
+ try {
+ $this->connect();
+ } catch (\Exception $e) {
+ $noConnection = Str::contains($e->getMessage(), [
+ 'No such file or directory',
+ 'Connection refused'
+ ]);
+
+ if (! $noConnection) {
+ throw $e;
+ }
+
+ \sleep(10);
+
+ $this->connect();
+ }
+
+ $sth = parent::prepexec($stmt, $values);
+ }
+
+ return $sth;
+ }
+}
diff --git a/library/Reporting/Schedule.php b/library/Reporting/Schedule.php
new file mode 100644
index 0000000..e0ffa9f
--- /dev/null
+++ b/library/Reporting/Schedule.php
@@ -0,0 +1,160 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting;
+
+class Schedule
+{
+ /** @var int */
+ protected $id;
+
+ /** @var int */
+ protected $reportId;
+
+ /** @var \DateTime */
+ protected $start;
+
+ /** @var string */
+ protected $frequency;
+
+ /** @var string */
+ protected $action;
+
+ /** @var array */
+ protected $config;
+
+ /**
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * @param int $id
+ *
+ * @return $this
+ */
+ public function setId($id)
+ {
+ $this->id = $id;
+
+ return $this;
+ }
+
+ /**
+ * @return int
+ */
+ public function getReportId()
+ {
+ return $this->reportId;
+ }
+
+ /**
+ * @param int $id
+ *
+ * @return $this
+ */
+ public function setReportId($id)
+ {
+ $this->reportId = $id;
+
+ return $this;
+ }
+
+ /**
+ * @return \DateTime
+ */
+ public function getStart()
+ {
+ return $this->start;
+ }
+
+ /**
+ * @param \DateTime $start
+ *
+ * @return $this
+ */
+ public function setStart(\DateTime $start)
+ {
+ $this->start = $start;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getFrequency()
+ {
+ return $this->frequency;
+ }
+
+ /**
+ * @param string $frequency
+ *
+ * @return $this
+ */
+ public function setFrequency($frequency)
+ {
+ $this->frequency = $frequency;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getAction()
+ {
+ return $this->action;
+ }
+
+ /**
+ * @param string $action
+ *
+ * @return $this
+ */
+ public function setAction($action)
+ {
+ $this->action = $action;
+
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getConfig()
+ {
+ return $this->config;
+ }
+
+ /**
+ * @param array $config
+ *
+ * @return $this
+ */
+ public function setConfig(array $config)
+ {
+ $this->config = $config;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getChecksum()
+ {
+ return \md5(
+ $this->getId()
+ . $this->getReportId()
+ . $this->getStart()->format('Y-m-d H:i:s')
+ . $this->getAction()
+ . $this->getFrequency()
+ . \json_encode($this->getConfig())
+ );
+ }
+}
diff --git a/library/Reporting/Scheduler.php b/library/Reporting/Scheduler.php
new file mode 100644
index 0000000..1b8d9f6
--- /dev/null
+++ b/library/Reporting/Scheduler.php
@@ -0,0 +1,176 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting;
+
+use Cron\CronExpression;
+use ipl\Sql\Connection;
+use ipl\Sql\Select;
+use React\EventLoop\Factory as Loop;
+
+function datetime_get_time_of_day(\DateTime $dateTime)
+{
+ $midnight = clone $dateTime;
+ $midnight->modify('midnight');
+
+ $diff = $midnight->diff($dateTime);
+
+ return $diff->h * 60 * 60 + $diff->i * 60 + $diff->s;
+}
+
+class Scheduler
+{
+ protected $db;
+
+ protected $loop;
+
+ /** @var array */
+ protected $schedules = [];
+
+ /** @var array */
+ protected $timers = [];
+
+ public function __construct(Connection $db)
+ {
+ $this->db = $db;
+ $this->loop = Loop::create();
+ }
+
+ public function run()
+ {
+ $updateTimers = function () use (&$updateTimers) {
+ $this->updateTimers();
+
+ $this->loop->addTimer(60, $updateTimers);
+ };
+
+ $this->loop->futureTick($updateTimers);
+
+ $this->loop->run();
+ }
+
+ protected function fetchSchedules()
+ {
+ $schedules = [];
+
+ $select = (new Select())
+ ->from('schedule')
+ ->columns('*');
+
+ foreach ($this->db->select($select) as $row) {
+ $schedule = (new Schedule())
+ ->setId((int) $row->id)
+ ->setReportId((int) $row->report_id)
+ ->setAction($row->action)
+ ->setConfig(\json_decode($row->config, true))
+ ->setStart((new \DateTime())->setTimestamp((int) $row->start / 1000))
+ ->setFrequency($row->frequency);
+
+ $schedules[$schedule->getChecksum()] = $schedule;
+ }
+
+ return $schedules;
+ }
+
+ protected function updateTimers()
+ {
+ $schedules = $this->fetchSchedules();
+
+ $remove = \array_diff_key($this->schedules, $schedules);
+
+ foreach ($remove as $schedule) {
+ printf("Removing job %s.\n", "Schedule {$schedule->getId()}");
+
+ $checksum = $schedule->getChecksum();
+
+ if (isset($this->timers[$checksum])) {
+ $this->loop->cancelTimer($this->timers[$checksum]);
+ unset($this->timers[$checksum]);
+ } else {
+ printf("Can't find timer for job %s.\n", $checksum);
+ }
+ }
+
+ $add = \array_diff_key($schedules, $this->schedules);
+
+ foreach ($add as $schedule) {
+ $this->add($schedule);
+ }
+
+ $this->schedules = $schedules;
+ }
+
+
+ protected function add(Schedule $schedule)
+ {
+ $name = "Schedule {$schedule->getId()}";
+ $frequency = $schedule->getFrequency();
+ $start = clone $schedule->getStart();
+ $callback = function () use ($schedule) {
+ $actionClass = $schedule->getAction();
+ /** @var ActionHook $action */
+ $action = new $actionClass;
+
+ $action->execute(
+ Report::fromDb($schedule->getReportId()),
+ $schedule->getConfig()
+ );
+ };
+
+ switch ($frequency) {
+ case 'minutely':
+ $modify = '+1 minute';
+ break;
+ case 'hourly':
+ $modify = '+1 hour';
+ break;
+ case 'daily':
+ $modify = '+1 day';
+ break;
+ case 'weekly':
+ $modify = '+1 week';
+ break;
+ case 'monthly':
+ $modify = '+1 month';
+ break;
+ default:
+ throw new \InvalidArgumentException('Invalid frequency.');
+ }
+
+ $now = new \DateTime();
+
+ if ($start < $now) {
+// printf("Scheduling job %s to run immediately.\n", $name);
+// $this->loop->futureTick($callback);
+
+ while ($start < $now) {
+ $start->modify($modify);
+ }
+ }
+
+ $next = clone $start;
+ $next->modify($modify);
+ $interval = $next->getTimestamp() - $start->getTimestamp();
+
+ $current = $start->getTimestamp() - $now->getTimestamp();
+
+ printf("Scheduling job %s to run at %s.\n", $name, $start->format('Y-m-d H:i:s'));
+
+ $loop = function () use (&$loop, $name, $callback, $interval, $schedule) {
+ $callback();
+
+ $nextRun = (new \DateTime())
+ ->add(new \DateInterval("PT{$interval}S"));
+
+ printf("Scheduling job %s to run at %s.\n", $name, $nextRun->format('Y-m-d H:i:s'));
+
+ $timer = $this->loop->addTimer($interval, $loop);
+
+ $this->timers[$schedule->getChecksum()] = $timer;
+ };
+
+ $timer = $this->loop->addTimer($current, $loop);
+
+ $this->timers[$schedule->getChecksum()] = $timer;
+ }
+}
diff --git a/library/Reporting/Str.php b/library/Reporting/Str.php
new file mode 100644
index 0000000..d4c7355
--- /dev/null
+++ b/library/Reporting/Str.php
@@ -0,0 +1,37 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting;
+
+class Str
+{
+ public static function putcsv(array $data, $delimiter = ',', $enclosure = '"', $escape = '\\')
+ {
+ $fp = fopen('php://temp', 'r+b');
+
+ foreach ($data as $row) {
+ fputcsv($fp, $row, $delimiter, $enclosure, $escape);
+ }
+
+ rewind($fp);
+
+ $csv = stream_get_contents($fp);
+
+ fclose($fp);
+
+ $csv = rtrim($csv, "\n"); // fputcsv adds a newline
+
+ return $csv;
+ }
+
+ public static function contains($haystack, $needle)
+ {
+ foreach ((array) $needle as $n) {
+ if (\strpos($haystack, $n) !== false) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/library/Reporting/Timeframe.php b/library/Reporting/Timeframe.php
new file mode 100644
index 0000000..f295779
--- /dev/null
+++ b/library/Reporting/Timeframe.php
@@ -0,0 +1,168 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting;
+
+use ipl\Sql\Select;
+
+class Timeframe
+{
+ use Database;
+
+ /** @var int */
+ protected $id;
+
+ /** @var string */
+ protected $name;
+
+ /** @var string */
+ protected $title;
+
+ /** @var string */
+ protected $start;
+
+ /** @var string */
+ protected $end;
+
+ /**
+ * @param int $id
+ *
+ * @return static
+ *
+ * @throws \Exception
+ */
+ public static function fromDb($id)
+ {
+ $timeframe = new static();
+
+ $db = $timeframe->getDb();
+
+ $select = (new Select())
+ ->from('timeframe')
+ ->columns('*')
+ ->where(['id = ?' => $id]);
+
+ $row = $db->select($select)->fetch();
+
+ if ($row === false) {
+ throw new \Exception('Timeframe not found');
+ }
+
+ $timeframe
+ ->setId($row->id)
+ ->setName($row->name)
+ ->setTitle($row->title)
+ ->setStart($row->start)
+ ->setEnd($row->end);
+
+ return $timeframe;
+ }
+
+ /**
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * @param int $id
+ *
+ * @return $this
+ */
+ public function setId($id)
+ {
+ $this->id = $id;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * @param string $name
+ *
+ * @return $this
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * @param string $title
+ *
+ * @return $this
+ */
+ public function setTitle($title)
+ {
+ $this->title = $title;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getStart()
+ {
+ return $this->start;
+ }
+
+ /**
+ * @param string $start
+ *
+ * @return $this
+ */
+ public function setStart($start)
+ {
+ $this->start = $start;
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getEnd()
+ {
+ return $this->end;
+ }
+
+ /**
+ * @param string $end
+ *
+ * @return $this
+ */
+ public function setEnd($end)
+ {
+ $this->end = $end;
+
+ return $this;
+ }
+
+ public function getTimerange()
+ {
+ $start = new \DateTime($this->getStart());
+ $end = new \DateTime($this->getEnd());
+
+ return new Timerange($start, $end);
+ }
+}
diff --git a/library/Reporting/Timerange.php b/library/Reporting/Timerange.php
new file mode 100644
index 0000000..086bfb8
--- /dev/null
+++ b/library/Reporting/Timerange.php
@@ -0,0 +1,35 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting;
+
+class Timerange
+{
+ /** @var \DateTime */
+ protected $start;
+
+ /** @var \DateTime */
+ protected $end;
+
+ public function __construct(\DateTime $start, \DateTime $end)
+ {
+ $this->start = $start;
+ $this->end = $end;
+ }
+
+ /**
+ * @return \DateTime
+ */
+ public function getStart()
+ {
+ return $this->start;
+ }
+
+ /**
+ * @return \DateTime
+ */
+ public function getEnd()
+ {
+ return $this->end;
+ }
+}
diff --git a/library/Reporting/Values.php b/library/Reporting/Values.php
new file mode 100644
index 0000000..3aa9b24
--- /dev/null
+++ b/library/Reporting/Values.php
@@ -0,0 +1,21 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting;
+
+trait Values
+{
+ protected $values;
+
+ public function getValues()
+ {
+ return $this->values;
+ }
+
+ public function setValues(array $values)
+ {
+ $this->values = $values;
+
+ return $this;
+ }
+}
diff --git a/library/Reporting/Web/Controller.php b/library/Reporting/Web/Controller.php
new file mode 100644
index 0000000..98e2694
--- /dev/null
+++ b/library/Reporting/Web/Controller.php
@@ -0,0 +1,20 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Web;
+
+use ipl\Html\Form;
+use reportingipl\Web\Compat\CompatController;
+
+class Controller extends CompatController
+{
+ protected function redirectForm(Form $form, $url)
+ {
+ if ($form->hasBeenSubmitted()
+ && ((isset($form->valid) && $form->valid === true)
+ || $form->isValid())
+ ) {
+ $this->redirectNow($url);
+ }
+ }
+}
diff --git a/library/Reporting/Web/DivDecorator.php b/library/Reporting/Web/DivDecorator.php
new file mode 100644
index 0000000..f6f3584
--- /dev/null
+++ b/library/Reporting/Web/DivDecorator.php
@@ -0,0 +1,131 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Web;
+
+use ipl\Html\Attributes;
+use ipl\Html\BaseHtmlElement;
+use ipl\Html\FormDecorator\DecoratorInterface;
+use ipl\Html\FormElement\BaseFormElement;
+use ipl\Html\FormElement\SubmitElement;
+use ipl\Html\Html;
+
+class DivDecorator extends BaseHtmlElement implements DecoratorInterface
+{
+ protected $tag = 'div';
+
+ /** @var BaseFormElement */
+ protected $formElement;
+
+ /** @var bool */
+ protected $formElementAdded = false;
+
+ /**
+ * Set the form element to decorate
+ *
+ * @param BaseFormElement $formElement
+ *
+ * @return static
+ */
+ public function decorate(BaseFormElement $formElement)
+ {
+ $decorator = clone $this;
+
+ $decorator->formElement = $formElement;
+
+ // TODO(el): Should be SubmitElementInterface
+ if ($formElement instanceof SubmitElement) {
+ $class = 'form-control';
+ } else {
+ $class = 'form-element';
+ }
+
+ $decorator->getAttributes()->add('class', $class);
+
+ $formElement->prependWrapper($decorator);
+
+ return $decorator;
+ }
+
+ public function add($content)
+ {
+ if ($content === $this->formElement) {
+ if ($this->formElementAdded) {
+ return $this;
+ }
+
+ $this->formElementAdded = true;
+ }
+
+ parent::add($content);
+
+ return $this;
+ }
+
+ protected function assemble()
+ {
+ if ($this->formElement->hasBeenValidatedAndIsNotValid()) {
+ $this->getAttributes()->add('class', 'has-error');
+ }
+
+ $this->add([
+ $this->assembleLabel(),
+ $this->formElement
+ ]);
+
+ $this->afterFormElement();
+
+ $this->add([
+ $this->assembleDescription(),
+ $this->assembleErrors()
+ ]);
+ }
+
+ protected function assembleLabel()
+ {
+ $label = $this->formElement->getLabel();
+
+ if ($label !== null) {
+ $attributes = null;
+
+ if ($this->formElement->getAttributes()->has('id')) {
+ $attributes = new Attributes(['for' => $this->formElement->getAttributes()->get('id')]);
+ }
+
+ return Html::tag('label', $attributes, $label);
+ }
+
+ return null;
+ }
+
+ protected function assembleDescription()
+ {
+ $description = $this->formElement->getDescription();
+
+ if ($description !== null) {
+ return Html::tag('p', ['class' => 'form-element-description'], $description);
+ }
+
+ return null;
+ }
+
+ protected function assembleErrors()
+ {
+ $errors = [];
+
+ foreach ($this->formElement->getMessages() as $message) {
+ $errors[] = Html::tag('p', ['class' => 'form-element-error'], $message);
+ }
+
+ if (! empty($errors)) {
+ return $errors;
+ }
+
+ return null;
+ }
+
+ protected function afterFormElement()
+ {
+
+ }
+}
diff --git a/library/Reporting/Web/Flatpickr.php b/library/Reporting/Web/Flatpickr.php
new file mode 100644
index 0000000..efdd269
--- /dev/null
+++ b/library/Reporting/Web/Flatpickr.php
@@ -0,0 +1,25 @@
+<?php
+// Icinga Reporting | (c) 2019 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Web;
+
+use ipl\Html\FormElement\BaseFormElement;
+use ipl\Html\Html;
+
+class Flatpickr extends DivDecorator
+{
+ protected $defaultAttributes = ['class' => 'reporting-flatpickr'];
+
+ public function decorate(BaseFormElement $input)
+ {
+ parent::decorate($input);
+
+ $input->getAttributes()->set('data-input', true);
+ }
+
+ protected function afterFormElement()
+ {
+ $this->add(Html::tag('button', ['type' => 'button', 'class' => 'icon-calendar', 'data-toggle' => true]));
+ $this->add(Html::tag('button', ['type' => 'button', 'class' => 'icon-cancel', 'data-clear' => true]));
+ }
+}
diff --git a/library/Reporting/Web/Forms/DecoratedElement.php b/library/Reporting/Web/Forms/DecoratedElement.php
new file mode 100644
index 0000000..09645c5
--- /dev/null
+++ b/library/Reporting/Web/Forms/DecoratedElement.php
@@ -0,0 +1,17 @@
+<?php
+// Icinga Reporting | (c) 2019 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Web\Forms;
+
+use ipl\Html\FormDecorator\DecoratorInterface;
+
+trait DecoratedElement
+{
+ protected function addDecoratedElement(DecoratorInterface $decorator, $type, $name, array $attributes)
+ {
+ $element = $this->createElement($type, $name, $attributes);
+ $decorator->decorate($element);
+ $this->registerElement($element);
+ $this->add($element);
+ }
+}
diff --git a/library/Reporting/Web/Forms/ReportForm.php b/library/Reporting/Web/Forms/ReportForm.php
new file mode 100644
index 0000000..9b9280f
--- /dev/null
+++ b/library/Reporting/Web/Forms/ReportForm.php
@@ -0,0 +1,173 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Web\Forms;
+
+use Icinga\Authentication\Auth;
+use Icinga\Module\Reporting\Database;
+use Icinga\Module\Reporting\ProvidedReports;
+use Icinga\Module\Reporting\Web\DivDecorator;
+use ipl\Html\Form;
+use ipl\Html\FormElement\SubmitElementInterface;
+
+class ReportForm extends Form
+{
+ use Database;
+ use ProvidedReports;
+
+ /** @var bool Hack to disable the {@link onSuccess()} code upon deletion of the report */
+ protected $callOnSuccess;
+
+ protected $id;
+
+ public function setId($id)
+ {
+ $this->id = $id;
+
+ return $this;
+ }
+
+ protected function assemble()
+ {
+ $this->setDefaultElementDecorator(new DivDecorator());
+
+ $this->addElement('text', 'name', [
+ 'required' => true,
+ 'label' => 'Name'
+ ]);
+
+ $this->addElement('select', 'timeframe', [
+ 'required' => true,
+ 'label' => 'Timeframe',
+ 'options' => [null => 'Please choose'] + $this->listTimeframes(),
+ 'class' => 'autosubmit'
+ ]);
+
+ $this->addElement('select', 'template', [
+ 'label' => 'Template',
+ 'options' => [null => 'Please choose'] + $this->listTemplates()
+ ]);
+
+ $this->addElement('select', 'reportlet', [
+ 'required' => true,
+ 'label' => 'Report',
+ 'options' => [null => 'Please choose'] + $this->listReports(),
+ 'class' => 'autosubmit'
+ ]);
+
+ $values = $this->getValues();
+
+ if (isset($values['reportlet'])) {
+ $config = new Form();
+// $config->populate($this->getValues());
+
+ /** @var \Icinga\Module\Reporting\Hook\ReportHook $reportlet */
+ $reportlet = new $values['reportlet'];
+
+ $reportlet->initConfigForm($config);
+
+ foreach ($config->getElements() as $element) {
+ $this->addElement($element);
+ }
+ }
+
+ $this->addElement('submit', 'submit', [
+ 'label' => $this->id === null ? 'Create Report' : 'Update Report'
+ ]);
+
+ if ($this->id !== null) {
+ $this->addElement('submit', 'remove', [
+ 'label' => 'Remove Report',
+ 'class' => 'remove-button',
+ 'formnovalidate' => true
+ ]);
+
+ /** @var SubmitElementInterface $remove */
+ $remove = $this->getElement('remove');
+ if ($remove->hasBeenPressed()) {
+ $this->getDb()->delete('report', ['id = ?' => $this->id]);
+
+ // Stupid cheat because ipl/html is not capable of multiple submit buttons
+ $this->getSubmitButton()->setValue($this->getSubmitButton()->getButtonLabel());
+ $this->callOnSuccess = false;
+ $this->valid = true;
+
+ return;
+ }
+ }
+
+ // TODO(el): Remove once ipl/html's TextareaElement sets the value as content
+ foreach ($this->getElements() as $element) {
+ if ($element instanceof TextareaElement && $element->hasValue()) {
+ $element->setContent($element->getValue());
+ }
+ }
+ }
+
+ public function onSuccess()
+ {
+ if ($this->callOnSuccess === false) {
+ return;
+ }
+
+ $db = $this->getDb();
+
+ $values = $this->getValues();
+
+ $now = time() * 1000;
+
+ $db->beginTransaction();
+
+ if ($this->id === null) {
+ $db->insert('report', [
+ 'name' => $values['name'],
+ 'author' => Auth::getInstance()->getUser()->getUsername(),
+ 'timeframe_id' => $values['timeframe'],
+ 'template_id' => $values['template'],
+ 'ctime' => $now,
+ 'mtime' => $now
+ ]);
+
+ $reportId = $db->lastInsertId();
+ } else {
+ $db->update('report', [
+ 'name' => $values['name'],
+ 'timeframe_id' => $values['timeframe'],
+ 'template_id' => $values['template'],
+ 'mtime' => $now
+ ], ['id = ?' => $this->id]);
+
+ $reportId = $this->id;
+ }
+
+ unset($values['name']);
+ unset($values['timeframe']);
+
+ if ($this->id !== null) {
+ $db->delete('reportlet', ['report_id = ?' => $reportId]);
+ }
+
+ $db->insert('reportlet', [
+ 'report_id' => $reportId,
+ 'class' => $values['reportlet'],
+ 'ctime' => $now,
+ 'mtime' => $now
+ ]);
+
+ $reportletId = $db->lastInsertId();
+
+ unset($values['reportlet']);
+
+ foreach ($values as $name => $value) {
+ $db->insert('config', [
+ 'reportlet_id' => $reportletId,
+ 'name' => $name,
+ 'value' => $value,
+ 'ctime' => $now,
+ 'mtime' => $now
+ ]);
+ }
+
+ $db->commitTransaction();
+ }
+}
diff --git a/library/Reporting/Web/Forms/ScheduleForm.php b/library/Reporting/Web/Forms/ScheduleForm.php
new file mode 100644
index 0000000..5f2bb40
--- /dev/null
+++ b/library/Reporting/Web/Forms/ScheduleForm.php
@@ -0,0 +1,170 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Web\Forms;
+
+use Icinga\Authentication\Auth;
+use Icinga\Module\Reporting\Database;
+use Icinga\Module\Reporting\ProvidedActions;
+use Icinga\Module\Reporting\Report;
+use Icinga\Module\Reporting\Web\DivDecorator;
+use Icinga\Module\Reporting\Web\Flatpickr;
+use ipl\Html\Form;
+use ipl\Html\FormElement\SubmitElementInterface;
+use ipl\Html\FormElement\TextareaElement;
+
+class ScheduleForm extends Form
+{
+ use Database;
+ use DecoratedElement;
+ use ProvidedActions;
+
+ /** @var Report */
+ protected $report;
+
+ protected $id;
+
+ public function setReport(Report $report)
+ {
+ $this->report = $report;
+
+ $schedule = $report->getSchedule();
+
+ if ($schedule !== null) {
+ $this->setId($schedule->getId());
+
+ $values = [
+ 'start' => $schedule->getStart()->format('Y-m-d H:i'),
+ 'frequency' => $schedule->getFrequency(),
+ 'action' => $schedule->getAction()
+ ] + $schedule->getConfig();
+
+ $this->populate($values);
+ }
+
+ return $this;
+ }
+
+ public function setId($id)
+ {
+ $this->id = $id;
+
+ return $this;
+ }
+
+ protected function assemble()
+ {
+ $this->setDefaultElementDecorator(new DivDecorator());
+
+ $frequency = [
+ 'minutely' => 'Minutely',
+ 'hourly' => 'Hourly',
+ 'daily' => 'Daily',
+ 'weekly' => 'Weekly',
+ 'monthly' => 'Monthly'
+ ];
+
+ $this->addDecoratedElement(new Flatpickr(), 'text', 'start', [
+ 'required' => true,
+ 'label' => 'Start',
+ 'placeholder' => 'Choose date and time',
+ 'data-enable-time' => true
+ ]);
+
+ $this->addElement('select', 'frequency', [
+ 'required' => true,
+ 'label' => 'Frequency',
+ 'options' => [null => 'Please choose'] + $frequency,
+ ]);
+
+ $this->addElement('select', 'action', [
+ 'required' => true,
+ 'label' => 'Action',
+ 'options' => [null => 'Please choose'] + $this->listActions(),
+ 'class' => 'autosubmit'
+ ]);
+
+ $values = $this->getValues();
+
+ if (isset($values['action'])) {
+ $config = new Form();
+// $config->populate($this->getValues());
+
+ /** @var \Icinga\Module\Reporting\Hook\ActionHook $action */
+ $action = new $values['action'];
+
+ $action->initConfigForm($config, $this->report);
+
+ foreach ($config->getElements() as $element) {
+ $this->addElement($element);
+ }
+ }
+
+ $this->addElement('submit', 'submit', [
+ 'label' => $this->id === null ? 'Create Schedule' : 'Update Schedule'
+ ]);
+
+ if ($this->id !== null) {
+ $this->addElement('submit', 'remove', [
+ 'label' => 'Remove Schedule',
+ 'class' => 'remove-button',
+ 'formnovalidate' => true
+ ]);
+
+ /** @var SubmitElementInterface $remove */
+ $remove = $this->getElement('remove');
+ if ($remove->hasBeenPressed()) {
+ $this->getDb()->delete('schedule', ['id = ?' => $this->id]);
+
+ // Stupid cheat because ipl/html is not capable of multiple submit buttons
+ $this->getSubmitButton()->setValue($this->getSubmitButton()->getButtonLabel());
+ $this->valid = true;
+
+ return;
+ }
+ }
+
+ // TODO(el): Remove once ipl/html's TextareaElement sets the value as content
+ foreach ($this->getElements() as $element) {
+ if ($element instanceof TextareaElement && $element->hasValue()) {
+ $element->setContent($element->getValue());
+ }
+ }
+ }
+
+ public function onSuccess()
+ {
+ $db = $this->getDb();
+
+ $values = $this->getValues();
+
+ $now = time() * 1000;
+
+ $data = [
+ 'start' => \DateTime::createFromFormat('Y-m-d H:i', $values['start'])->getTimestamp() * 1000,
+ 'frequency' => $values['frequency'],
+ 'action' => $values['action'],
+ 'mtime' => $now
+ ];
+
+ unset($values['start']);
+ unset($values['frequency']);
+ unset($values['action']);
+
+ $data['config'] = json_encode($values);
+
+ $db->beginTransaction();
+
+ if ($this->id === null) {
+ $db->insert('schedule', $data + [
+ 'author' => Auth::getInstance()->getUser()->getUsername(),
+ 'report_id' => $this->report->getId(),
+ 'ctime' => $now
+ ]);
+ } else {
+ $db->update('schedule', $data, ['id = ?' => $this->id]);
+ }
+
+ $db->commitTransaction();
+ }
+}
diff --git a/library/Reporting/Web/Forms/SendForm.php b/library/Reporting/Web/Forms/SendForm.php
new file mode 100644
index 0000000..1e38ba4
--- /dev/null
+++ b/library/Reporting/Web/Forms/SendForm.php
@@ -0,0 +1,63 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Web\Forms;
+
+use Icinga\Module\Reporting\Actions\SendMail;
+use Icinga\Module\Reporting\Database;
+use Icinga\Module\Reporting\ProvidedReports;
+use Icinga\Module\Reporting\Report;
+use Icinga\Module\Reporting\Web\DivDecorator;
+use ipl\Html\Form;
+
+class SendForm extends Form
+{
+ use Database;
+ use ProvidedReports;
+
+ /** @var Report */
+ protected $report;
+
+ public function setReport(Report $report)
+ {
+ $this->report = $report;
+
+ return $this;
+ }
+
+ protected function assemble()
+ {
+ $this->setDefaultElementDecorator(new DivDecorator());
+
+ $types = ['pdf' => 'PDF'];
+
+ if ($this->report->providesData()) {
+ $types['csv'] = 'CSV';
+ $types['json'] = 'JSON';
+ }
+
+ $this->addElement('select', 'type', [
+ 'required' => true,
+ 'label' => 'Type',
+ 'options' => [null => 'Please choose'] + $types
+ ]);
+
+ $this->addElement('textarea', 'recipients', [
+ 'required' => true,
+ 'label' => 'Recipients'
+ ]);
+
+ $this->addElement('submit', 'submit', [
+ 'label' => 'Send Report'
+ ]);
+ }
+
+ public function onSuccess()
+ {
+ $values = $this->getValues();
+
+ $sendMail = new SendMail();
+
+ $sendMail->execute($this->report, $values);
+ }
+}
diff --git a/library/Reporting/Web/Forms/TemplateForm.php b/library/Reporting/Web/Forms/TemplateForm.php
new file mode 100644
index 0000000..569f9b1
--- /dev/null
+++ b/library/Reporting/Web/Forms/TemplateForm.php
@@ -0,0 +1,283 @@
+<?php
+// Icinga Reporting | (c) 2019 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Web\Forms;
+
+use Icinga\Authentication\Auth;
+use Icinga\Module\Reporting\Database;
+use Icinga\Module\Reporting\Web\DivDecorator;
+use ipl\Html\Form;
+use ipl\Html\FormElement\SubmitElementInterface;
+use ipl\Html\Html;
+use reportingipl\Html\FormElement\FileElement;
+
+class TemplateForm extends Form
+{
+ use Database;
+
+
+ /** @var bool Hack to disable the {@link onSuccess()} code upon deletion of the template */
+ protected $callOnSuccess;
+
+ protected $template;
+
+ public function getTemplate()
+ {
+ return $this->template;
+ }
+
+ public function setTemplate($template)
+ {
+ $this->template = $template;
+
+ if ($template->settings) {
+ $this->populate(array_filter($template->settings, function ($value) {
+ // Don't populate files
+ return ! is_array($value);
+ }));
+ }
+
+ return $this;
+ }
+
+ protected function assemble()
+ {
+ $this->setAttribute('enctype', 'multipart/form-data');
+
+ $this->setDefaultElementDecorator(new DivDecorator());
+
+ $this->add(Html::tag('h2', 'Template Settings'));
+
+ $this->addElement('text', 'name', [
+ 'label' => 'Name',
+ 'placeholder' => 'Template name',
+ 'required' => true
+ ]);
+
+ $this->add(Html::tag('h2', 'Cover Page Settings'));
+
+ $this->addElement(new FileElement('cover_page_background_image', [
+ 'label' => 'Background Image',
+ 'accept' => 'image/png, image/jpeg'
+ ]));
+
+ if ($this->template !== null
+ && isset($this->template->settings['cover_page_background_image'])
+ ) {
+ $this->add(Html::tag(
+ 'p',
+ ['style' => ['margin-left: 15em;']],
+ 'Upload a new background image to override the existing one'
+ ));
+
+ $this->addElement('checkbox', 'remove_cover_page_background_image', [
+ 'label' => 'Remove background image'
+ ]);
+ }
+
+ $this->addElement(new FileElement('cover_page_logo', [
+ 'label' => 'Logo',
+ 'accept' => 'image/png, image/jpeg'
+ ]));
+
+ if ($this->template !== null
+ && isset($this->template->settings['cover_page_logo'])
+ ) {
+ $this->add(Html::tag(
+ 'p',
+ ['style' => ['margin-left: 15em;']],
+ 'Upload a new logo to override the existing one'
+ ));
+
+ $this->addElement('checkbox', 'remove_cover_page_logo', [
+ 'label' => 'Remove Logo'
+ ]);
+ }
+
+ $this->addElement('textarea', 'title', [
+ 'label' => 'Title',
+ 'placeholder' => 'Report title'
+ ]);
+
+ $this->addElement('text', 'color', [
+ 'label' => 'Color',
+ 'placeholder' => 'CSS color code'
+ ]);
+
+ $this->add(Html::tag('h2', 'Header Settings'));
+
+ $this->addColumnSettings('header_column1', 'Column 1');
+ $this->addColumnSettings('header_column2', 'Column 2');
+ $this->addColumnSettings('header_column3', 'Column 3');
+
+ $this->add(Html::tag('h2', 'Footer Settings'));
+
+ $this->addColumnSettings('footer_column1', 'Column 1');
+ $this->addColumnSettings('footer_column2', 'Column 2');
+ $this->addColumnSettings('footer_column3', 'Column 3');
+
+ $this->addElement('submit', 'submit', [
+ 'label' => $this->template === null ? 'Create Template' : 'Update Template'
+ ]);
+
+ if ($this->template !== null) {
+ $this->addElement('submit', 'remove', [
+ 'label' => 'Remove Template',
+ 'class' => 'remove-button',
+ 'formnovalidate' => true
+ ]);
+
+ /** @var SubmitElementInterface $remove */
+ $remove = $this->getElement('remove');
+ if ($remove->hasBeenPressed()) {
+ $this->getDb()->delete('template', ['id = ?' => $this->template->id]);
+
+ // Stupid cheat because ipl/html is not capable of multiple submit buttons
+ $this->getSubmitButton()->setValue($this->getSubmitButton()->getButtonLabel());
+ $this->callOnSuccess = false;
+ $this->valid = true;
+
+ return;
+ }
+ }
+ }
+
+ public function onSuccess()
+ {
+ if ($this->callOnSuccess === false) {
+ return;
+ }
+
+ ini_set('upload_max_filesize', '10M');
+
+ $settings = $this->getValues();
+
+ try {
+ /** @var $uploadedFile \GuzzleHttp\Psr7\UploadedFile */
+ foreach ($this->getRequest()->getUploadedFiles() as $name => $uploadedFile) {
+ if ($uploadedFile->getError() === UPLOAD_ERR_NO_FILE) {
+ continue;
+ }
+
+ $settings[$name] = [
+ 'mime_type' => $uploadedFile->getClientMediaType(),
+ 'size' => $uploadedFile->getSize(),
+ 'content' => base64_encode((string) $uploadedFile->getStream())
+ ];
+ }
+
+ $db = $this->getDb();
+
+ $now = time() * 1000;
+
+ if ($this->template === null) {
+ $db->insert('template', [
+ 'name' => $settings['name'],
+ 'author' => Auth::getInstance()->getUser()->getUsername(),
+ 'settings' => json_encode($settings),
+ 'ctime' => $now,
+ 'mtime' => $now
+ ]);
+ } else {
+ if (isset($settings['remove_cover_page_background_image'])) {
+ unset($settings['cover_page_background_image']);
+ unset($settings['remove_cover_page_background_image']);
+ } elseif (! isset($settings['cover_page_background_image'])
+ && isset($this->template->settings['cover_page_background_image'])
+ ) {
+ $settings['cover_page_background_image'] = $this->template->settings['cover_page_background_image'];
+ }
+
+ if (isset($settings['remove_cover_page_logo'])) {
+ unset($settings['cover_page_logo']);
+ unset($settings['remove_cover_page_logo']);
+ } elseif (! isset($settings['cover_page_logo'])
+ && isset($this->template->settings['cover_page_logo'])
+ ) {
+ $settings['cover_page_logo'] = $this->template->settings['cover_page_logo'];
+ }
+
+ foreach (['header', 'footer'] as $headerOrFooter) {
+ for ($i = 1; $i <= 3; ++$i) {
+ $type = "{$headerOrFooter}_column{$i}_type";
+
+ if ($settings[$type] === 'image') {
+ $value = "{$headerOrFooter}_column{$i}_value";
+
+ if (! isset($settings[$value])
+ && isset($this->template->settings[$value])
+ ) {
+ $settings[$value] = $this->template->settings[$value];
+ }
+ }
+ }
+ }
+
+ $db->update('template', [
+ 'name' => $settings['name'],
+ 'settings' => json_encode($settings),
+ 'mtime' => $now
+ ], ['id = ?' => $this->template->id]);
+ }
+ } catch (\Exception $e) {
+ die($e->getMessage());
+ }
+ }
+
+ protected function addColumnSettings($name, $label)
+ {
+ $type = "{$name}_type";
+ $value = "{$name}_value";
+
+ $this->addElement('select', $type, [
+ 'class' => 'autosubmit',
+ 'label' => $label,
+ 'options' => [
+ null => 'None',
+ 'text' => 'Text',
+ 'image' => 'Image',
+ 'variable' => 'Variable'
+ ]
+ ]);
+
+ switch ($this->getValue($type, 'none')) {
+ case 'image':
+ $this->addElement(new FileElement($value, [
+ 'label' => 'Image',
+ 'accept' => 'image/png, image/jpeg'
+ ]));
+
+ if ($this->template !== null
+ && $this->template->settings[$type] === 'image'
+ && isset($this->template->settings[$value])
+ ) {
+ $this->add(Html::tag(
+ 'p',
+ ['style' => ['margin-left: 15em;']],
+ 'Upload a new image to override the existing one'
+ ));
+ }
+ break;
+ case 'variable':
+ $this->addElement('select', $value, [
+ 'label' => 'Variable',
+ 'options' => [
+ 'report_title' => 'Report Title',
+ 'time_frame' => 'Time Frame',
+ 'page_number' => 'Page Number',
+ 'total_number_of_pages' => 'Total Number of Pages',
+ 'page_of' => 'Page Number + Total Number of Pages',
+ 'date' => 'Date'
+ ],
+ 'value' => 'report_title'
+ ]);
+ break;
+ case 'text':
+ $this->addElement('text', $value, [
+ 'label' => 'Text',
+ 'placeholder' => 'Column text'
+ ]);
+ break;
+ }
+ }
+}
diff --git a/library/Reporting/Web/Forms/TimeframeForm.php b/library/Reporting/Web/Forms/TimeframeForm.php
new file mode 100644
index 0000000..809ce1b
--- /dev/null
+++ b/library/Reporting/Web/Forms/TimeframeForm.php
@@ -0,0 +1,111 @@
+<?php
+// Icinga Reporting | (c) 2019 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Web\Forms;
+
+use Icinga\Module\Reporting\Database;
+use Icinga\Module\Reporting\Web\DivDecorator;
+use Icinga\Module\Reporting\Web\Flatpickr;
+use ipl\Html\Form;
+use ipl\Html\FormElement\SubmitElementInterface;
+
+class TimeframeForm extends Form
+{
+ use Database;
+ use DecoratedElement;
+
+ protected $id;
+
+ public function setId($id)
+ {
+ $this->id = $id;
+
+ return $this;
+ }
+
+ protected function assemble()
+ {
+ $this->setDefaultElementDecorator(new DivDecorator());
+
+ $this->addElement('text', 'name', [
+ 'required' => true,
+ 'label' => 'Name'
+ ]);
+
+ $flatpickr = new Flatpickr();
+
+ $this->addDecoratedElement($flatpickr, 'text', 'start', [
+ 'required' => true,
+ 'label' => 'Start',
+ 'placeholder' => 'Select a start date or provide a textual datetime description',
+ 'data-allow-input' => true,
+ 'data-enable-time' => true,
+ 'data-enable-seconds' => true,
+ 'data-default-hour' => '00'
+ ]);
+
+ $this->addDecoratedElement($flatpickr, 'text', 'end', [
+ 'required' => true,
+ 'label' => 'End',
+ 'placeholder' => 'Select a end date or provide a textual datetime description',
+ 'data-allow-input' => true,
+ 'data-enable-time' => true,
+ 'data-enable-seconds' => true,
+ 'data-default-hour' => '23',
+ 'data-default-minute' => '59',
+ 'data-default-seconds' => '59'
+ ]);
+
+ $this->addElement('submit', 'submit', [
+ 'label' => $this->id === null ? 'Create Time Frame' : 'Update Time Frame'
+ ]);
+
+ if ($this->id !== null) {
+ $this->addElement('submit', 'remove', [
+ 'label' => 'Remove Time Frame',
+ 'class' => 'remove-button',
+ 'formnovalidate' => true
+ ]);
+
+ /** @var SubmitElementInterface $remove */
+ $remove = $this->getElement('remove');
+ if ($remove->hasBeenPressed()) {
+ $this->getDb()->delete('timeframe', ['id = ?' => $this->id]);
+
+ // Stupid cheat because ipl/html is not capable of multiple submit buttons
+ $this->getSubmitButton()->setValue($this->getSubmitButton()->getButtonLabel());
+ $this->valid = true;
+
+ return;
+ }
+ }
+ }
+
+ public function onSuccess()
+ {
+ $db = $this->getDb();
+
+ $values = $this->getValues();
+
+ $now = time() * 1000;
+
+ $end = $db->quoteIdentifier('end');
+
+ if ($this->id === null) {
+ $db->insert('timeframe', [
+ 'name' => $values['name'],
+ 'start' => $values['start'],
+ $end => $values['end'],
+ 'ctime' => $now,
+ 'mtime' => $now
+ ]);
+ } else {
+ $db->update('timeframe', [
+ 'name' => $values['name'],
+ 'start' => $values['start'],
+ $end => $values['end'],
+ 'mtime' => $now
+ ], ['id = ?' => $this->id]);
+ }
+ }
+}
diff --git a/library/Reporting/Web/ReportsTimeframesAndTemplatesTabs.php b/library/Reporting/Web/ReportsTimeframesAndTemplatesTabs.php
new file mode 100644
index 0000000..afb8b14
--- /dev/null
+++ b/library/Reporting/Web/ReportsTimeframesAndTemplatesTabs.php
@@ -0,0 +1,37 @@
+<?php
+// Icinga Reporting | (c) 2019 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Web;
+
+trait ReportsTimeframesAndTemplatesTabs
+{
+ /**
+ * Create tabs
+ *
+ * @return \Icinga\Web\Widget\Tabs
+ */
+ protected function createTabs()
+ {
+ $tabs = $this->getTabs();
+
+ $tabs->add('reports', [
+ 'title' => $this->translate('Show reports'),
+ 'label' => $this->translate('Reports'),
+ 'url' => 'reporting/reports'
+ ]);
+
+ $tabs->add('timeframes', [
+ 'title' => $this->translate('Show time frames'),
+ 'label' => $this->translate('Time Frames'),
+ 'url' => 'reporting/timeframes'
+ ]);
+
+ $tabs->add('templates', [
+ 'title' => $this->translate('Show templates'),
+ 'label' => $this->translate('Templates'),
+ 'url' => 'reporting/templates'
+ ]);
+
+ return $tabs;
+ }
+}
diff --git a/library/Reporting/Web/Widget/CoverPage.php b/library/Reporting/Web/Widget/CoverPage.php
new file mode 100644
index 0000000..545ef6a
--- /dev/null
+++ b/library/Reporting/Web/Widget/CoverPage.php
@@ -0,0 +1,181 @@
+<?php
+
+namespace Icinga\Module\Reporting\Web\Widget;
+
+use Icinga\Module\Reporting\Common\Macros;
+use ipl\Html\BaseHtmlElement;
+use ipl\Html\Html;
+
+class CoverPage extends BaseHtmlElement
+{
+ use Macros;
+
+ /** @var array */
+ protected $backgroundImage;
+
+ /** @var string */
+ protected $color;
+
+ /** @var array */
+ protected $logo;
+
+ /** @var string */
+ protected $title;
+
+ protected $tag = 'div';
+
+ protected $defaultAttributes = ['class' => 'cover-page page'];
+
+ /**
+ * @return bool
+ */
+ public function hasBackgroundImage()
+ {
+ return $this->backgroundImage !== null;
+ }
+
+ /**
+ * @return array
+ */
+ public function getBackgroundImage()
+ {
+ return $this->backgroundImage;
+ }
+
+ /**
+ * @param array $backgroundImage
+ *
+ * @return $this
+ */
+ public function setBackgroundImage($backgroundImage)
+ {
+ $this->backgroundImage = $backgroundImage;
+
+ return $this;
+ }
+
+ /**
+ * @return bool
+ */
+ public function hasColor()
+ {
+ return $this->color !== null;
+ }
+
+ /**
+ * @return string
+ */
+ public function getColor()
+ {
+ return $this->color;
+ }
+
+ /**
+ * @param string $color
+ *
+ * @return $this
+ */
+ public function setColor($color)
+ {
+ $this->color = $color;
+
+ return $this;
+ }
+
+ /**
+ * @return bool
+ */
+ public function hasLogo()
+ {
+ return $this->logo !== null;
+ }
+
+ /**
+ * @return array
+ */
+ public function getLogo()
+ {
+ return $this->logo;
+ }
+
+ /**
+ * @param array $logo
+ *
+ * @return $this
+ */
+ public function setLogo($logo)
+ {
+ $this->logo = $logo;
+
+ return $this;
+ }
+
+ public function hasTitle()
+ {
+ return $this->title !== null;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * @param string $title
+ *
+ * @return $this
+ */
+ public function setTitle($title)
+ {
+ $this->title = $title;
+
+ return $this;
+ }
+
+ protected function assemble()
+ {
+ if ($this->hasBackgroundImage()) {
+ $this
+ ->getAttributes()
+ ->add('style', "background-image: url('" . Template::getDataUrl($this->getBackgroundImage()) . "');");
+ }
+
+ $content = Html::tag('div', ['class' => 'cover-page-content']);
+
+ if ($this->hasColor()) {
+ $content->getAttributes()->add('style', "color: {$this->getColor()};");
+ }
+
+ if ($this->hasLogo()) {
+ $content->add(Html::tag(
+ 'img',
+ [
+ 'class' => 'logo',
+ 'src' => Template::getDataUrl($this->getLogo())
+ ]
+ ));
+ }
+
+ if ($this->hasTitle()) {
+ $title = array_map(function ($part) {
+ $part = trim($part);
+
+ if (! $part) {
+ return Html::tag('br');
+ } else {
+ return Html::tag('div', null, $part);
+ }
+ }, explode("\n", $this->resolveMacros($this->getTitle())));
+
+ $content->add(Html::tag(
+ 'h2',
+ $title
+ ));
+ }
+
+ $this->add($content);
+ }
+}
diff --git a/library/Reporting/Web/Widget/HeaderOrFooter.php b/library/Reporting/Web/Widget/HeaderOrFooter.php
new file mode 100644
index 0000000..8ee0101
--- /dev/null
+++ b/library/Reporting/Web/Widget/HeaderOrFooter.php
@@ -0,0 +1,94 @@
+<?php
+
+namespace Icinga\Module\Reporting\Web\Widget;
+
+use Icinga\Module\Reporting\Common\Macros;
+use ipl\Html\BaseHtmlElement;
+use ipl\Html\Html;
+
+class HeaderOrFooter extends BaseHtmlElement
+{
+ use Macros;
+
+ const HEADER = 'header';
+
+ const FOOTER = 'footer';
+
+ protected $type;
+
+ protected $data;
+
+ protected $tag = 'div';
+
+ public function __construct($type, array $data)
+ {
+ $this->type = $type;
+ $this->data = $data;
+ }
+
+ protected function resolveVariable($variable)
+ {
+ switch ($variable) {
+ case 'report_title':
+ $resolved = Html::tag('span', ['class' => 'title']);
+ break;
+ case 'time_frame':
+ $resolved = Html::tag('p', $this->getMacro('time_frame'));
+ break;
+ case 'page_number':
+ $resolved = Html::tag('span', ['class' => 'pageNumber']);
+ break;
+ case 'total_number_of_pages':
+ $resolved = Html::tag('span', ['class' => 'totalPages']);
+ break;
+ case 'page_of':
+ $resolved = Html::tag('p', Html::sprintf(
+ '%s / %s',
+ Html::tag('span', ['class' => 'pageNumber']),
+ Html::tag('span', ['class' => 'totalPages'])
+ ));
+ break;
+ case 'date':
+ $resolved = Html::tag('span', ['class' => 'date']);
+ break;
+ default:
+ $resolved = $variable;
+ break;
+ }
+
+ return $resolved;
+ }
+
+ protected function createColumn(array $data, $key)
+ {
+ $typeKey = "${key}_type";
+ $valueKey = "${key}_value";
+ $type = isset($data[$typeKey]) ? $data[$typeKey] : null;
+
+ switch ($type) {
+ case 'text':
+ $column = Html::tag('p', $data[$valueKey]);
+ break;
+ case 'image':
+ $column = Html::tag('img', ['height' => 13, 'src' => Template::getDataUrl($data[$valueKey])]);
+ break;
+ case 'variable':
+ $column = $this->resolveVariable($data[$valueKey]);
+ break;
+ default:
+ $column = Html::tag('div');
+ break;
+ }
+
+ return $column;
+ }
+
+ protected function assemble()
+ {
+ $this->getAttributes()->add('class', $this->type);
+
+ for ($i = 1; $i <= 3; ++$i) {
+ $this->add($this->createColumn($this->data, "{$this->type}_column{$i}"));
+ }
+ }
+}
diff --git a/library/Reporting/Web/Widget/Template.php b/library/Reporting/Web/Widget/Template.php
new file mode 100644
index 0000000..e780a3d
--- /dev/null
+++ b/library/Reporting/Web/Widget/Template.php
@@ -0,0 +1,183 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting\Web\Widget;
+
+use Icinga\Module\Reporting\Common\Macros;
+use Icinga\Module\Reporting\Database;
+use ipl\Html\BaseHtmlElement;
+use ipl\Html\Html;
+use ipl\Sql\Select;
+
+class Template extends BaseHtmlElement
+{
+ use Database;
+ use Macros;
+
+ protected $tag = 'div';
+
+ protected $defaultAttributes = ['class' => 'template'];
+
+ /** @var CoverPage */
+ protected $coverPage;
+
+ /** @var HeaderOrFooter */
+ protected $header;
+
+ /** @var HeaderOrFooter */
+ protected $footer;
+
+ protected $preview;
+
+ public static function getDataUrl(array $image = null)
+ {
+ if (empty($image)) {
+ return 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
+ }
+
+ return sprintf('data:%s;base64,%s', $image['mime_type'], $image['content']);
+ }
+
+ public static function fromDb($id)
+ {
+ $template = new static();
+
+ $select = (new Select())
+ ->from('template')
+ ->columns('*')
+ ->where(['id = ?' => $id]);
+
+ $row = $template->getDb()->select($select)->fetch();
+
+ if ($row === false) {
+ return null;
+ }
+
+ $row->settings = json_decode($row->settings, true);
+
+ $coverPage = (new CoverPage())
+ ->setColor($row->settings['color'])
+ ->setTitle($row->settings['title']);
+
+ if (isset($row->settings['cover_page_background_image'])) {
+ $coverPage->setBackgroundImage($row->settings['cover_page_background_image']);
+ }
+
+ if (isset($row->settings['cover_page_logo'])) {
+ $coverPage->setLogo($row->settings['cover_page_logo']);
+ }
+
+ $template
+ ->setCoverPage($coverPage)
+ ->setHeader(new HeaderOrFooter(HeaderOrFooter::HEADER, $row->settings))
+ ->setFooter(new HeaderOrFooter(HeaderOrFooter::FOOTER, $row->settings));
+
+ return $template;
+ }
+
+ /**
+ * @return CoverPage
+ */
+ public function getCoverPage()
+ {
+ return $this->coverPage;
+ }
+
+ /**
+ * @param CoverPage $coverPage
+ *
+ * @return $this
+ */
+ public function setCoverPage(CoverPage $coverPage)
+ {
+ $this->coverPage = $coverPage;
+
+ return $this;
+ }
+
+ /**
+ * @return HeaderOrFooter
+ */
+ public function getHeader()
+ {
+ return $this->header;
+ }
+
+ /**
+ * @param HeaderOrFooter $header
+ *
+ * @return $this
+ */
+ public function setHeader($header)
+ {
+ $this->header = $header;
+
+ return $this;
+ }
+
+ /**
+ * @return HeaderOrFooter
+ */
+ public function getFooter()
+ {
+ return $this->footer;
+ }
+
+ /**
+ * @param HeaderOrFooter $footer
+ *
+ * @return $this
+ */
+ public function setFooter($footer)
+ {
+ $this->footer = $footer;
+
+ return $this;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getPreview()
+ {
+ return $this->preview;
+ }
+
+ /**
+ * @param mixed $preview
+ *
+ * @return $this
+ */
+ public function setPreview($preview)
+ {
+ $this->preview = $preview;
+
+ return $this;
+ }
+
+ protected function assemble()
+ {
+ if ($this->preview) {
+ $this->getAttributes()->add('class', 'preview');
+ }
+
+ $this->add($this->getCoverPage()->setMacros($this->macros));
+
+// $page = Html::tag(
+// 'div',
+// ['class' => 'main'],
+// Html::tag('div', ['class' => 'page-content'], [
+// $this->header->setMacros($this->macros),
+// Html::tag(
+// 'div',
+// [
+// 'class' => 'main'
+// ]
+// ),
+// $this->footer->setMacros($this->macros)
+// ])
+// );
+//
+// $this->add($page);
+ }
+}
diff --git a/library/vendor/ipl/Html/src/FormElement/FileElement.php b/library/vendor/ipl/Html/src/FormElement/FileElement.php
new file mode 100644
index 0000000..88aeb8c
--- /dev/null
+++ b/library/vendor/ipl/Html/src/FormElement/FileElement.php
@@ -0,0 +1,15 @@
+<?php
+
+namespace reportingipl\Html\FormElement;
+
+use ipl\Html\FormElement\InputElement;
+
+class FileElement extends InputElement
+{
+ protected $type = 'file';
+
+ public function setValue($value)
+ {
+ return $this;
+ }
+}
diff --git a/library/vendor/ipl/web/src/Common/BaseTarget.php b/library/vendor/ipl/web/src/Common/BaseTarget.php
new file mode 100644
index 0000000..0d92f42
--- /dev/null
+++ b/library/vendor/ipl/web/src/Common/BaseTarget.php
@@ -0,0 +1,30 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace reportingipl\Web\Common;
+
+/**
+ * @method \ipl\Html\Attributes getAttributes()
+ */
+trait BaseTarget
+{
+ /**
+ * @return string|null
+ */
+ public function getBaseTarget()
+ {
+ return $this->getAttributes()->get('data-base-target')->getValue();
+ }
+
+ /**
+ * @param string $target
+ *
+ * @return $this
+ */
+ public function setBaseTarget($target)
+ {
+ $this->getAttributes()->set('data-base-target', $target);
+
+ return $this;
+ }
+}
diff --git a/library/vendor/ipl/web/src/Compat/CompatController.php b/library/vendor/ipl/web/src/Compat/CompatController.php
new file mode 100644
index 0000000..4d562da
--- /dev/null
+++ b/library/vendor/ipl/web/src/Compat/CompatController.php
@@ -0,0 +1,77 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace reportingipl\Web\Compat;
+
+use Icinga\Web\Controller;
+use ipl\Html\ValidHtml;
+use reportingipl\Web\Widget\Content;
+use reportingipl\Web\Widget\Controls;
+use reportingipl\Web\Widget\Tabs;
+
+class CompatController extends Controller
+{
+ /** @var Controls */
+ protected $controls;
+
+ /** @var Content */
+ protected $content;
+
+ /** @var Tabs */
+ protected $tabs;
+
+ protected function prepareInit()
+ {
+ parent::prepareInit();
+
+ unset($this->view->tabs);
+
+ $this->controls = new Controls();
+ $this->content = new Content();
+ $this->tabs = new Tabs();
+
+ $this->controls->setTabs($this->tabs);
+
+ ViewRenderer::inject();
+
+ $this->view->controls = $this->controls;
+ $this->view->content = $this->content;
+ }
+
+ /**
+ * Get the tabs
+ *
+ * @return Tabs
+ */
+ public function getTabs()
+ {
+ return $this->tabs;
+ }
+
+ protected function addControl(ValidHtml $control)
+ {
+ $this->controls->add($control);
+
+ return $this;
+ }
+
+ protected function addContent(ValidHtml $content)
+ {
+ $this->content->add($content);
+
+ return $this;
+ }
+
+ protected function setTitle($title, ...$args)
+ {
+ $title = vsprintf($title, $args);
+
+ $this->view->title = $title;
+
+ $this->getTabs()->add(uniqid(), [
+ 'active' => true,
+ 'label' => $title,
+ 'url' => $this->getRequest()->getUrl()
+ ]);
+ }
+}
diff --git a/library/vendor/ipl/web/src/Compat/ViewRenderer.php b/library/vendor/ipl/web/src/Compat/ViewRenderer.php
new file mode 100644
index 0000000..16427a2
--- /dev/null
+++ b/library/vendor/ipl/web/src/Compat/ViewRenderer.php
@@ -0,0 +1,66 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace reportingipl\Web\Compat;
+
+use Zend_Controller_Action_Helper_ViewRenderer as Zf1ViewRenderer;
+use Zend_Controller_Action_HelperBroker as Zf1HelperBroker;
+
+class ViewRenderer extends Zf1ViewRenderer
+{
+ /**
+ * Inject the view renderer
+ */
+ public static function inject()
+ {
+ /** @var \Zend_Controller_Action_Helper_ViewRenderer $viewRenderer */
+ $viewRenderer = Zf1HelperBroker::getStaticHelper('ViewRenderer');
+
+ $inject = new static();
+
+ foreach (get_object_vars($viewRenderer) as $property => $value) {
+ if ($property === '_inflector') {
+ continue;
+ }
+
+ $inject->$property = $value;
+ }
+
+ Zf1HelperBroker::removeHelper('ViewRenderer');
+ Zf1HelperBroker::addHelper($inject);
+ }
+
+ /**
+ * Render the view w/o using a view script
+ *
+ * {@inheritdoc}
+ */
+ public function render($action = null, $name = null, $noController = null)
+ {
+ $view = $this->view;
+
+ if (($view->controls->isEmpty() && $view->content->isEmpty())
+ || $this->getRequest()->getParam('error_handler') !== null
+ ) {
+ parent::render($action, $name, $noController);
+
+ return;
+ }
+
+ if ($name === null) {
+ $name = $this->getResponseSegment();
+ }
+
+ $this->getResponse()->appendBody(
+ $view->controls->render() . "\n" . $view->content->render(),
+ $name
+ );
+
+ $this->setNoRender();
+ }
+
+ public function getName()
+ {
+ return 'ViewRenderer';
+ }
+}
diff --git a/library/vendor/ipl/web/src/Url.php b/library/vendor/ipl/web/src/Url.php
new file mode 100644
index 0000000..abf8747
--- /dev/null
+++ b/library/vendor/ipl/web/src/Url.php
@@ -0,0 +1,15 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace reportingipl\Web;
+
+/**
+ * @TODO(el): Don't depend on Icinga Web's Url
+ */
+class Url extends \Icinga\Web\Url
+{
+ public function __toString()
+ {
+ return $this->getAbsoluteUrl('&');
+ }
+}
diff --git a/library/vendor/ipl/web/src/Widget/ActionBar.php b/library/vendor/ipl/web/src/Widget/ActionBar.php
new file mode 100644
index 0000000..2d658b6
--- /dev/null
+++ b/library/vendor/ipl/web/src/Widget/ActionBar.php
@@ -0,0 +1,44 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace reportingipl\Web\Widget;
+
+use ipl\Html\Attributes;
+use ipl\Html\BaseHtmlElement;
+use reportingipl\Web\Common\BaseTarget;
+use reportingipl\Web\Url;
+
+class ActionBar extends BaseHtmlElement
+{
+ use BaseTarget;
+
+ protected $contentSeparator = ' ';
+
+ protected $tag = 'div';
+
+ protected $defaultAttributes = ['class' => 'action-bar', 'data-base-target' => '_self'];
+
+ /**
+ * Create a action bar
+ *
+ * @param Attributes|array $attributes
+ */
+ public function __construct($attributes = null)
+ {
+ $this->getAttributes()->add(Attributes::wantAttributes($attributes));
+ }
+
+ /**
+ * @param mixed $content
+ * @param Url|string $url
+ * @param string $icon
+ *
+ * @return $this
+ */
+ public function addLink($content, $url, $icon = null)
+ {
+ $this->add(new ActionLink($content, $url, $icon));
+
+ return $this;
+ }
+}
diff --git a/library/vendor/ipl/web/src/Widget/ActionLink.php b/library/vendor/ipl/web/src/Widget/ActionLink.php
new file mode 100644
index 0000000..584e738
--- /dev/null
+++ b/library/vendor/ipl/web/src/Widget/ActionLink.php
@@ -0,0 +1,29 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace reportingipl\Web\Widget;
+
+use ipl\Html\Attributes;
+use reportingipl\Web\Url;
+
+class ActionLink extends Link
+{
+ protected $defaultAttributes = ['class' => 'action-link'];
+
+ /**
+ * Create a action link
+ *
+ * @param mixed $content
+ * @param Url|string $url
+ * @param string $icon
+ * @param Attributes|array $attributes
+ */
+ public function __construct($content, $url, $icon = null, $attributes = null)
+ {
+ parent::__construct($content, $url, $attributes);
+
+ if ($icon !== null) {
+ $this->prepend(new Icon($icon));
+ }
+ }
+}
diff --git a/library/vendor/ipl/web/src/Widget/ButtonLink.php b/library/vendor/ipl/web/src/Widget/ButtonLink.php
new file mode 100644
index 0000000..b217071
--- /dev/null
+++ b/library/vendor/ipl/web/src/Widget/ButtonLink.php
@@ -0,0 +1,9 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace reportingipl\Web\Widget;
+
+class ButtonLink extends ActionLink
+{
+ protected $defaultAttributes = ['class' => 'button-link', 'data-base-target' => '_main'];
+}
diff --git a/library/vendor/ipl/web/src/Widget/Content.php b/library/vendor/ipl/web/src/Widget/Content.php
new file mode 100644
index 0000000..23c72d7
--- /dev/null
+++ b/library/vendor/ipl/web/src/Widget/Content.php
@@ -0,0 +1,15 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace reportingipl\Web\Widget;
+
+use ipl\Html\BaseHtmlElement;
+
+class Content extends BaseHtmlElement
+{
+ protected $tag = 'div';
+
+ protected $contentSeparator = "\n";
+
+ protected $defaultAttributes = ['class' => 'content'];
+}
diff --git a/library/vendor/ipl/web/src/Widget/Controls.php b/library/vendor/ipl/web/src/Widget/Controls.php
new file mode 100644
index 0000000..b19e45b
--- /dev/null
+++ b/library/vendor/ipl/web/src/Widget/Controls.php
@@ -0,0 +1,47 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace reportingipl\Web\Widget;
+
+use ipl\Html\BaseHtmlElement;
+
+class Controls extends BaseHtmlElement
+{
+ protected $tag = 'div';
+
+ protected $contentSeparator = "\n";
+
+ protected $defaultAttributes = ['class' => 'controls'];
+
+ /** @var Tabs */
+ protected $tabs;
+
+ /**
+ * Get the tabs
+ *
+ * @return Tabs
+ */
+ public function getTabs()
+ {
+ return $this->tabs;
+ }
+
+ /**
+ * Set the tabs
+ *
+ * @param Tabs $tabs
+ *
+ * @return $this
+ */
+ public function setTabs(Tabs $tabs)
+ {
+ $this->tabs = $tabs;
+
+ return $this;
+ }
+
+ protected function assemble()
+ {
+ $this->prepend($this->getTabs());
+ }
+}
diff --git a/library/vendor/ipl/web/src/Widget/DropdownLink.php b/library/vendor/ipl/web/src/Widget/DropdownLink.php
new file mode 100644
index 0000000..906dcf9
--- /dev/null
+++ b/library/vendor/ipl/web/src/Widget/DropdownLink.php
@@ -0,0 +1,70 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace reportingipl\Web\Widget;
+
+use Icinga\Web\Url;
+use ipl\Html\Attributes;
+use ipl\Html\BaseHtmlElement;
+use ipl\Html\Html;
+
+class DropdownLink extends BaseHtmlElement
+{
+ protected $tag = 'div';
+
+ protected $defaultAttributes = ['class' => 'dropdown'];
+
+ /** @var array */
+ protected $links = [];
+
+ /**
+ * Create a dropdown link
+ *
+ * @param mixed $content
+ * @param \ipl\Html\Attributes|array $attributes
+ */
+ public function __construct($content, $attributes = null)
+ {
+ $toggle = new ActionLink($content, '#');
+
+ $toggle->getAttributes()->add([
+ 'class' => 'dropdown-toggle',
+ 'role' => 'button',
+ 'aria-haspopup' => true,
+ 'aria-expanded' => false
+ ]);
+
+ $this->hasBeenAssembled = true;
+
+ $this
+ ->setContent($toggle)
+ ->getAttributes()
+ ->add(Attributes::wantAttributes($attributes));
+
+ $this->hasBeenAssembled = false;
+ }
+
+ /**
+ * @param mixed $content
+ * @param Url|string $url
+ * @param string $icon
+ *
+ * @return $this
+ */
+ public function addLink($content, $url, $icon = null)
+ {
+ $link = new ActionLink($content, $url, $icon);
+
+ $link->getAttributes()->add('class', 'dropdown-item');
+ $link->getAttributes()->add('target', '_blank');
+
+ $this->links[] = $link;
+
+ return $this;
+ }
+
+ protected function assemble()
+ {
+ $this->add(Html::tag('div', ['class' => 'dropdown-menu'], $this->links));
+ }
+}
diff --git a/library/vendor/ipl/web/src/Widget/Icon.php b/library/vendor/ipl/web/src/Widget/Icon.php
new file mode 100644
index 0000000..0a03d18
--- /dev/null
+++ b/library/vendor/ipl/web/src/Widget/Icon.php
@@ -0,0 +1,29 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace reportingipl\Web\Widget;
+
+use ipl\Html\Attributes;
+use ipl\Html\BaseHtmlElement;
+
+class Icon extends BaseHtmlElement
+{
+ protected $tag = 'i';
+
+ /**
+ * Create a icon element
+ *
+ * Creates a icon element from the given name and HTML attributes. The icon element's tag will be <i>. The given
+ * name will be used as automatically added CSS class for the icon element in the format 'icon-$name'. In addition,
+ * the CSS class 'icon' will be automatically added too.
+ *
+ * @param string $name The name of the icon
+ * @param \ipl\Html\Attributes|array $attributes The HTML attributes for the element
+ */
+ public function __construct($name, $attributes = null)
+ {
+ $this->getAttributes()
+ ->add('class', ['icon', "icon-$name"])
+ ->add(Attributes::wantAttributes($attributes));
+ }
+}
diff --git a/library/vendor/ipl/web/src/Widget/Link.php b/library/vendor/ipl/web/src/Widget/Link.php
new file mode 100644
index 0000000..8c7cac8
--- /dev/null
+++ b/library/vendor/ipl/web/src/Widget/Link.php
@@ -0,0 +1,81 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace reportingipl\Web\Widget;
+
+use ipl\Html\Attribute;
+use ipl\Html\Attributes;
+use ipl\Html\BaseHtmlElement;
+use reportingipl\Web\Common\BaseTarget;
+use reportingipl\Web\Url;
+
+class Link extends BaseHtmlElement
+{
+ use BaseTarget;
+
+ protected $tag = 'a';
+
+ /** @var Url */
+ protected $url;
+
+ /**
+ * Create a link element
+ *
+ * @param mixed $content
+ * @param Url|string $url
+ * @param \ipl\Html\Attributes|array $attributes
+ */
+ public function __construct($content, $url, $attributes = null)
+ {
+ $this->hasBeenAssembled = true;
+
+ $this
+ ->setContent($content)
+ ->setUrl($url)
+ ->getAttributes()
+ ->add(Attributes::wantAttributes($attributes))
+ ->registerAttributeCallback('href', [$this, 'getHrefAttribute']);
+
+ $this->hasBeenAssembled = false;
+ }
+
+ /**
+ * Get the URL of the link
+ *
+ * @return Url
+ */
+ public function getUrl()
+ {
+ return $this->url;
+ }
+
+ /**
+ * Set the URL of the link
+ *
+ * @param Url|string $url
+ *
+ * @return $this
+ */
+ public function setUrl($url)
+ {
+ if (! $url instanceof \Icinga\Web\Url) {
+ try {
+ $url = Url::fromPath($url);
+ } catch (\Exception $e) {
+ $url = "Invalid: {$e->getMessage()}";
+ }
+ }
+
+ $this->url = $url;
+
+ return $this;
+ }
+
+ /**
+ * @return Attribute
+ */
+ public function getHrefAttribute()
+ {
+ return new Attribute('href', (string) $this->getUrl());
+ }
+}
diff --git a/library/vendor/ipl/web/src/Widget/Tabs.php b/library/vendor/ipl/web/src/Widget/Tabs.php
new file mode 100644
index 0000000..2e8c865
--- /dev/null
+++ b/library/vendor/ipl/web/src/Widget/Tabs.php
@@ -0,0 +1,13 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace reportingipl\Web\Widget;
+
+use ipl\Html\ValidHtml;
+
+/**
+ * @TODO(el): Don't depend on Icinga Web's Tabs
+ */
+class Tabs extends \Icinga\Web\Widget\Tabs implements ValidHtml
+{
+}
diff --git a/module.info b/module.info
new file mode 100644
index 0000000..b4b8314
--- /dev/null
+++ b/module.info
@@ -0,0 +1,6 @@
+Module: Reporting
+Version: 0.10.0
+Depends: ipl
+Depends: pdfexport
+Depends: reactbundle
+Description: Reporting
diff --git a/public/css/forms.less b/public/css/forms.less
new file mode 100644
index 0000000..bcc8889
--- /dev/null
+++ b/public/css/forms.less
@@ -0,0 +1,207 @@
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+.form-element,
+.form-controls {
+ display: flex;
+ margin: .5em 0;
+}
+
+.form-control {
+ display: inline-block;
+ float: right;
+
+ &:not(:last-child) {
+ margin-left: .5em;
+ }
+
+ &:last-child {
+ .clearfix();
+ }
+}
+
+.form-element label {
+ width: 14em;
+ text-align: right;
+ margin-right: 1em;
+}
+
+.form-element input:not([type="checkbox"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
+.form-element textarea,
+.form-element select {
+ flex-grow: 1;
+ background: #DAE3E6;
+}
+
+.form-element label,
+.form-element input,
+.form-element button,
+.form-controls button,
+.form-controls input,
+.form-element select,
+.form-element textarea {
+ padding: .5625em;
+ border-radius: .25em;
+ font-size: inherit;
+ border: none;
+ -webkit-appearance: none;
+ -moz-appearance: none;
+ -ms-appearance: none;
+ appearance: none;
+}
+
+.form-element textarea {
+ background-image: url(../static/img?file=textarea-corner-2x.png&module_name=reporting);
+ background-repeat: no-repeat;
+ background-position: bottom right;
+ background-size: 1em 1em;
+}
+
+
+.form-element select {
+ padding-right: 1.5625em;
+}
+
+/* Remove native dropdown arrow in IE10+ */
+.form-element select::-ms-expand {
+ display: none;
+ opacity: 0
+}
+
+.form-controls input:not(:last-child),
+.form-controls button:not(:last-child) {
+ margin-right: 1em;
+}
+
+.form-element select {
+ background-image: url(../static/img?file=select-icon-2x.png&module_name=reporting);
+ background-repeat: no-repeat;
+ background-position: right center;
+ background-size: contain;
+}
+
+/* Primary button styles */
+.form-controls input[type="submit"] {
+ background: #0095BF;
+ color: white;
+}
+
+.form-controls button:hover {
+ background: rgba(0,0,0,.1);
+ cursor: pointer;
+}
+
+input[type="submit"].remove-button {
+ background-color: white;
+ color: @color-critical;
+ border: 1px solid @color-critical;
+
+ &:hover {
+ background-color: @color-critical;
+ color: white;
+ }
+}
+
+.form-controls button:hover {
+ background: rgba(0,0,0,.1);
+ cursor: pointer;
+}
+
+/* Default button styles */
+.form-controls button {
+ color: #0095bf;
+ border: 1px solid #0095bf;
+ background: none;
+}
+
+.form-controls input:hover {
+ cursor: pointer;
+ background: #DAE3E6;
+}
+
+/* IPL toggle styles */
+
+input[type="checkbox"] {
+ display: inline-block;
+ border: 1px solid #DAE3E6;
+ background: #DAE3E6;
+ position: relative;
+ height: 1.5em;
+ width: 3em;
+ margin: .313em 0;
+ vertical-align: middle;
+ border-radius: 1em;
+ -webkit-appearance: none;
+ -moz-appearance: none;
+ appearance: none;
+}
+
+input[type="checkbox"]:hover {
+ cursor: pointer;
+ background: gray
+}
+
+input[type="checkbox"]:before {
+ border-radius: 1em;
+ content: "";
+ display: block;
+ position: absolute;
+ width: 1.25em;
+ height: 1.25em;
+ top: 0em;
+ left: 0em;
+ background: white;
+ transition: left .2s ease;
+ -webkit-box-shadow: 0 0 4px rgba(0,0,0,.5);
+ -moz-box-shadow: 0 0 4px rgba(0,0,0,.5);
+ box-shadow: 0 0 4px rgba(0,0,0,.5);
+}
+
+input[type="checkbox"]:checked {
+ border-color: #0095bf;
+ background: rgba(0, 149, 191, 0.3)
+}
+
+input[type="checkbox"]:checked:hover {
+ background: maroon;
+}
+
+input[type="checkbox"]:checked:before {
+ left: 1.5em;
+ background: #0095bf;
+}
+
+/* disabled */
+.form-element.disabled label {
+ color: #9a9a9a
+}
+
+.form-element.disabled input {
+ background: #f5f5f5;
+ border: none;
+}
+
+.form-element.disabled input[type="checkbox"] {
+ border: 1px solid #f5f5f5;
+}
+
+.form-element.disabled input[type="checkbox"]:before {
+ -webkit-box-shadow: 0 0 4px rgba(0,0,0,.1);
+ -moz-box-shadow: 0 0 4px rgba(0,0,0,.1);
+ box-shadow: 0 0 4px rgba(0,0,0,.1);
+}
+
+.form-element-error {
+ width: 100%;
+ margin: 0 0 0.5em 15em;
+ padding: 0.5625em;
+ color: @color-critical;
+}
+
+.form-element {
+ flex-wrap: wrap;
+}
+
+input[type="submit"] {
+ .button();
+ border-width: 1px;
+}
diff --git a/public/css/module.less b/public/css/module.less
new file mode 100644
index 0000000..e11dbe6
--- /dev/null
+++ b/public/css/module.less
@@ -0,0 +1,182 @@
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+.flatpickr-calendar {
+ position: fixed;
+}
+
+.flatpickr-day {
+ &.selected,
+ &.selected:hover {
+ border-color: @icinga-blue;
+ background: @icinga-blue;
+ }
+}
+
+.sla-column {
+ border-radius: 0.5em;
+ color: #fff;
+ text-align: center;
+ width: 10em;
+
+ &.ok {
+ background-color: @color-ok;
+ }
+
+ &.nok {
+ background-color: @color-critical;
+ }
+}
+
+.sla-table > tbody::before {
+ content: "\200C";
+ display: block;
+ line-height: 0.5em;
+}
+
+/**
+ * Mixin to add subtile box-shadow to make element seem to hover above the background
+ */
+.elevate() {
+ box-shadow: 0 0 2em 0 rgba(0,0,0,.2);
+}
+
+.dropdown {
+ display: inline-block;
+ position: relative;
+}
+
+.dropdown-toggle::after {
+ content: "";
+ display: inline-block;
+ width: 0;
+ height: 0;
+ margin-left: .255em;
+ vertical-align: .255em;
+ border-top: .3em solid;
+ border-right: .3em solid transparent;
+ border-bottom: 0;
+ border-left: .3em solid transparent;
+}
+
+.dropdown-menu {
+ display: none;
+ min-width: 10em;
+ border: 1px solid #ddd;
+ background: white;
+ margin: -.25em;
+ border-radius: .25em;
+ padding: .25em;
+
+ position: absolute;
+}
+
+.dropdown:hover > .dropdown-menu {
+ display: block;
+ .elevate();
+}
+
+.dropdown-item {
+ display: block;
+ padding: .5em;
+ margin: -.25em;
+
+ &.action-link:hover {
+ padding: .5em;
+ .rounded-corners(0)
+ }
+}
+
+.action-bar .dropdown:first-child:hover .dropdown-menu {
+ left: .25em;
+}
+
+.action-bar .dropdown:last-child:hover .dropdown-menu {
+ right: .25em;
+}
+
+.action-bar > *:not(:last-child) {
+ margin-right: .5em;
+}
+
+@font-family-print: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
+
+.page-size-a4 {
+ background-color: white;
+ box-shadow: 0 0 0.25cm rgba(0,0,0,0.5);
+ display: block;
+ margin: 0 auto 0.5cm;
+ font-family: @font-family-print;
+ page-break-after: always;
+ height: 29.7cm;
+ width: 21cm;
+}
+
+.page-content {
+ display: flex;
+ flex-direction: column;
+}
+
+.cover-page {
+ background-repeat: no-repeat;
+ background-position: center;
+}
+
+.cover-page-content {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-direction: column;
+
+ height: 100%;
+ width: 100%;
+
+ h2 {
+ text-align: center;
+ }
+}
+
+@gutter: 0.5em;
+
+.grid {
+ display: flex;
+ justify-content: space-between;
+
+ &.with-gutters {
+ margin-left: -0.5 * @gutter;
+ margin-right: -0.5 * @gutter;
+
+ > * {
+ margin-left: 0.5 * @gutter;
+ margin-right: 0.5 * @gutter;
+ }
+ }
+}
+
+.main {
+ flex: 1;
+
+ display: flex;
+ align-items: center;
+ flex-direction: column;
+ justify-content: space-around;
+}
+
+.preview .main {
+ background-image: url(../static/img?file=graph-dummy.svg&module_name=reporting);;
+ background-position: center center;
+ background-repeat: no-repeat;
+ background-size: contain;
+}
+
+.header,
+.footer {
+ .grid();
+}
+
+@media print {
+ font-family: @font-family-print;
+}
+
+.preview .page {
+ .page-size-a4();
+}
diff --git a/public/css/system-report.css b/public/css/system-report.css
new file mode 100644
index 0000000..cf42ae6
--- /dev/null
+++ b/public/css/system-report.css
@@ -0,0 +1,81 @@
+/* Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2 */
+
+.system-report {
+ background-color: #fff;
+ color: #222;
+ font-family: sans-serif;
+
+ width: 100%;
+}
+.system-report pre {
+ margin: 0;
+ font-family: monospace;
+}
+.system-report a:link {
+ color: #009;
+ text-decoration: none;
+ background-color: #fff;
+}
+.system-report a:hover {
+ text-decoration: underline;
+}
+.system-report table {
+ border-collapse: collapse;
+ border: 0;
+ width: 934px;
+ box-shadow: 1px 2px 3px #ccc;
+}
+.system-report .center {
+ text-align: center;
+}
+.system-report .center table {
+ margin: 1em auto;
+ text-align: left;
+}
+.system-report .center th {
+ text-align: center !important;
+}
+.system-report td,
+.system-report th {
+ border: 1px solid #666;
+ font-size: 75%;
+ vertical-align: baseline;
+ padding: 4px 5px;
+}
+.system-report h1 {
+ font-size: 150%;
+}
+.system-report h2 {
+ font-size: 125%;
+}
+.system-report .p {
+ text-align: left;
+}
+.system-report .e {
+ background-color: #ccf;
+ width: 300px;
+ font-weight: bold;
+}
+.system-report .h {
+ background-color: #99c;
+ font-weight: bold;
+}
+.system-report .v {
+ background-color: #ddd;
+ max-width: 300px;
+ overflow-x: auto;
+ word-wrap: break-word;
+}
+.system-report .v i {
+ color: #999;
+}
+.system-report img {
+ float: right;
+ border: 0;
+}
+.system-report hr {
+ width: 934px;
+ background-color: #ccc;
+ border: 0;
+ height: 1px;
+}
diff --git a/public/css/vendor/flatpickr.css b/public/css/vendor/flatpickr.css
new file mode 100644
index 0000000..64eb467
--- /dev/null
+++ b/public/css/vendor/flatpickr.css
@@ -0,0 +1,784 @@
+.flatpickr-calendar {
+ background: transparent;
+ opacity: 0;
+ display: none;
+ text-align: center;
+ visibility: hidden;
+ padding: 0;
+ -webkit-animation: none;
+ animation: none;
+ direction: ltr;
+ border: 0;
+ font-size: 14px;
+ line-height: 24px;
+ border-radius: 5px;
+ position: absolute;
+ width: 307.875px;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+ -ms-touch-action: manipulation;
+ touch-action: manipulation;
+ background: #fff;
+ -webkit-box-shadow: 1px 0 0 #e6e6e6, -1px 0 0 #e6e6e6, 0 1px 0 #e6e6e6, 0 -1px 0 #e6e6e6, 0 3px 13px rgba(0,0,0,0.08);
+ box-shadow: 1px 0 0 #e6e6e6, -1px 0 0 #e6e6e6, 0 1px 0 #e6e6e6, 0 -1px 0 #e6e6e6, 0 3px 13px rgba(0,0,0,0.08);
+}
+.flatpickr-calendar.open,
+.flatpickr-calendar.inline {
+ opacity: 1;
+ max-height: 640px;
+ visibility: visible;
+}
+.flatpickr-calendar.open {
+ display: inline-block;
+ z-index: 99999;
+}
+.flatpickr-calendar.animate.open {
+ -webkit-animation: fpFadeInDown 300ms cubic-bezier(0.23, 1, 0.32, 1);
+ animation: fpFadeInDown 300ms cubic-bezier(0.23, 1, 0.32, 1);
+}
+.flatpickr-calendar.inline {
+ display: block;
+ position: relative;
+ top: 2px;
+}
+.flatpickr-calendar.static {
+ position: absolute;
+ top: calc(100% + 2px);
+}
+.flatpickr-calendar.static.open {
+ z-index: 999;
+ display: block;
+}
+.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+1) .flatpickr-day.inRange:nth-child(7n+7) {
+ -webkit-box-shadow: none !important;
+ box-shadow: none !important;
+}
+.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+2) .flatpickr-day.inRange:nth-child(7n+1) {
+ -webkit-box-shadow: -2px 0 0 #e6e6e6, 5px 0 0 #e6e6e6;
+ box-shadow: -2px 0 0 #e6e6e6, 5px 0 0 #e6e6e6;
+}
+.flatpickr-calendar .hasWeeks .dayContainer,
+.flatpickr-calendar .hasTime .dayContainer {
+ border-bottom: 0;
+ border-bottom-right-radius: 0;
+ border-bottom-left-radius: 0;
+}
+.flatpickr-calendar .hasWeeks .dayContainer {
+ border-left: 0;
+}
+.flatpickr-calendar.showTimeInput.hasTime .flatpickr-time {
+ height: 40px;
+ border-top: 1px solid #e6e6e6;
+}
+.flatpickr-calendar.noCalendar.hasTime .flatpickr-time {
+ height: auto;
+}
+.flatpickr-calendar:before,
+.flatpickr-calendar:after {
+ position: absolute;
+ display: block;
+ pointer-events: none;
+ border: solid transparent;
+ content: '';
+ height: 0;
+ width: 0;
+ left: 22px;
+}
+.flatpickr-calendar.rightMost:before,
+.flatpickr-calendar.rightMost:after {
+ left: auto;
+ right: 22px;
+}
+.flatpickr-calendar:before {
+ border-width: 5px;
+ margin: 0 -5px;
+}
+.flatpickr-calendar:after {
+ border-width: 4px;
+ margin: 0 -4px;
+}
+.flatpickr-calendar.arrowTop:before,
+.flatpickr-calendar.arrowTop:after {
+ bottom: 100%;
+}
+.flatpickr-calendar.arrowTop:before {
+ border-bottom-color: #e6e6e6;
+}
+.flatpickr-calendar.arrowTop:after {
+ border-bottom-color: #fff;
+}
+.flatpickr-calendar.arrowBottom:before,
+.flatpickr-calendar.arrowBottom:after {
+ top: 100%;
+}
+.flatpickr-calendar.arrowBottom:before {
+ border-top-color: #e6e6e6;
+}
+.flatpickr-calendar.arrowBottom:after {
+ border-top-color: #fff;
+}
+.flatpickr-calendar:focus {
+ outline: 0;
+}
+.flatpickr-wrapper {
+ position: relative;
+ display: inline-block;
+}
+.flatpickr-months {
+ display: -webkit-box;
+ display: -webkit-flex;
+ display: -ms-flexbox;
+ display: flex;
+}
+.flatpickr-months .flatpickr-month {
+ background: transparent;
+ color: rgba(0,0,0,0.9);
+ fill: rgba(0,0,0,0.9);
+ height: 34px;
+ line-height: 1;
+ text-align: center;
+ position: relative;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ overflow: hidden;
+ -webkit-box-flex: 1;
+ -webkit-flex: 1;
+ -ms-flex: 1;
+ flex: 1;
+}
+.flatpickr-months .flatpickr-prev-month,
+.flatpickr-months .flatpickr-next-month {
+ text-decoration: none;
+ cursor: pointer;
+ position: absolute;
+ top: 0;
+ height: 34px;
+ padding: 10px;
+ z-index: 3;
+ color: rgba(0,0,0,0.9);
+ fill: rgba(0,0,0,0.9);
+}
+.flatpickr-months .flatpickr-prev-month.flatpickr-disabled,
+.flatpickr-months .flatpickr-next-month.flatpickr-disabled {
+ display: none;
+}
+.flatpickr-months .flatpickr-prev-month i,
+.flatpickr-months .flatpickr-next-month i {
+ position: relative;
+}
+.flatpickr-months .flatpickr-prev-month.flatpickr-prev-month,
+.flatpickr-months .flatpickr-next-month.flatpickr-prev-month {
+/*
+ /*rtl:begin:ignore*/
+/*
+ */
+ left: 0;
+/*
+ /*rtl:end:ignore*/
+/*
+ */
+}
+/*
+ /*rtl:begin:ignore*/
+/*
+ /*rtl:end:ignore*/
+.flatpickr-months .flatpickr-prev-month.flatpickr-next-month,
+.flatpickr-months .flatpickr-next-month.flatpickr-next-month {
+/*
+ /*rtl:begin:ignore*/
+/*
+ */
+ right: 0;
+/*
+ /*rtl:end:ignore*/
+/*
+ */
+}
+/*
+ /*rtl:begin:ignore*/
+/*
+ /*rtl:end:ignore*/
+.flatpickr-months .flatpickr-prev-month:hover,
+.flatpickr-months .flatpickr-next-month:hover {
+ color: #959ea9;
+}
+.flatpickr-months .flatpickr-prev-month:hover svg,
+.flatpickr-months .flatpickr-next-month:hover svg {
+ fill: #f64747;
+}
+.flatpickr-months .flatpickr-prev-month svg,
+.flatpickr-months .flatpickr-next-month svg {
+ width: 14px;
+ height: 14px;
+}
+.flatpickr-months .flatpickr-prev-month svg path,
+.flatpickr-months .flatpickr-next-month svg path {
+ -webkit-transition: fill 0.1s;
+ transition: fill 0.1s;
+ fill: inherit;
+}
+.numInputWrapper {
+ position: relative;
+ height: auto;
+}
+.numInputWrapper input,
+.numInputWrapper span {
+ display: inline-block;
+}
+.numInputWrapper input {
+ width: 100%;
+}
+.numInputWrapper input::-ms-clear {
+ display: none;
+}
+.numInputWrapper input::-webkit-outer-spin-button,
+.numInputWrapper input::-webkit-inner-spin-button {
+ margin: 0;
+ -webkit-appearance: none;
+}
+.numInputWrapper span {
+ position: absolute;
+ right: 0;
+ width: 14px;
+ padding: 0 4px 0 2px;
+ height: 50%;
+ line-height: 50%;
+ opacity: 0;
+ cursor: pointer;
+ border: 1px solid rgba(57,57,57,0.15);
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+}
+.numInputWrapper span:hover {
+ background: rgba(0,0,0,0.1);
+}
+.numInputWrapper span:active {
+ background: rgba(0,0,0,0.2);
+}
+.numInputWrapper span:after {
+ display: block;
+ content: "";
+ position: absolute;
+}
+.numInputWrapper span.arrowUp {
+ top: 0;
+ border-bottom: 0;
+}
+.numInputWrapper span.arrowUp:after {
+ border-left: 4px solid transparent;
+ border-right: 4px solid transparent;
+ border-bottom: 4px solid rgba(57,57,57,0.6);
+ top: 26%;
+}
+.numInputWrapper span.arrowDown {
+ top: 50%;
+}
+.numInputWrapper span.arrowDown:after {
+ border-left: 4px solid transparent;
+ border-right: 4px solid transparent;
+ border-top: 4px solid rgba(57,57,57,0.6);
+ top: 40%;
+}
+.numInputWrapper span svg {
+ width: inherit;
+ height: auto;
+}
+.numInputWrapper span svg path {
+ fill: rgba(0,0,0,0.5);
+}
+.numInputWrapper:hover {
+ background: rgba(0,0,0,0.05);
+}
+.numInputWrapper:hover span {
+ opacity: 1;
+}
+.flatpickr-current-month {
+ font-size: 135%;
+ line-height: inherit;
+ font-weight: 300;
+ color: inherit;
+ position: absolute;
+ width: 75%;
+ left: 12.5%;
+ padding: 7.48px 0 0 0;
+ line-height: 1;
+ height: 34px;
+ display: inline-block;
+ text-align: center;
+ -webkit-transform: translate3d(0px, 0px, 0px);
+ transform: translate3d(0px, 0px, 0px);
+}
+.flatpickr-current-month span.cur-month {
+ font-family: inherit;
+ font-weight: 700;
+ color: inherit;
+ display: inline-block;
+ margin-left: 0.5ch;
+ padding: 0;
+}
+.flatpickr-current-month span.cur-month:hover {
+ background: rgba(0,0,0,0.05);
+}
+.flatpickr-current-month .numInputWrapper {
+ width: 6ch;
+ width: 7ch\0;
+ display: inline-block;
+}
+.flatpickr-current-month .numInputWrapper span.arrowUp:after {
+ border-bottom-color: rgba(0,0,0,0.9);
+}
+.flatpickr-current-month .numInputWrapper span.arrowDown:after {
+ border-top-color: rgba(0,0,0,0.9);
+}
+.flatpickr-current-month input.cur-year {
+ background: transparent;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+ color: inherit;
+ cursor: text;
+ padding: 0 0 0 0.5ch;
+ margin: 0;
+ display: inline-block;
+ font-size: inherit;
+ font-family: inherit;
+ font-weight: 300;
+ line-height: inherit;
+ height: auto;
+ border: 0;
+ border-radius: 0;
+ vertical-align: initial;
+ -webkit-appearance: textfield;
+ -moz-appearance: textfield;
+ appearance: textfield;
+}
+.flatpickr-current-month input.cur-year:focus {
+ outline: 0;
+}
+.flatpickr-current-month input.cur-year[disabled],
+.flatpickr-current-month input.cur-year[disabled]:hover {
+ font-size: 100%;
+ color: rgba(0,0,0,0.5);
+ background: transparent;
+ pointer-events: none;
+}
+.flatpickr-current-month .flatpickr-monthDropdown-months {
+ appearance: menulist;
+ background: transparent;
+ border: none;
+ border-radius: 0;
+ box-sizing: border-box;
+ color: inherit;
+ cursor: pointer;
+ font-size: inherit;
+ font-family: inherit;
+ font-weight: 300;
+ height: auto;
+ line-height: inherit;
+ margin: -1px 0 0 0;
+ outline: none;
+ padding: 0 0 0 0.5ch;
+ position: relative;
+ vertical-align: initial;
+ -webkit-box-sizing: border-box;
+ -webkit-appearance: menulist;
+ -moz-appearance: menulist;
+ width: auto;
+}
+.flatpickr-current-month .flatpickr-monthDropdown-months:focus,
+.flatpickr-current-month .flatpickr-monthDropdown-months:active {
+ outline: none;
+}
+.flatpickr-current-month .flatpickr-monthDropdown-months:hover {
+ background: rgba(0,0,0,0.05);
+}
+.flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month {
+ background-color: transparent;
+ outline: none;
+ padding: 0;
+}
+.flatpickr-weekdays {
+ background: transparent;
+ text-align: center;
+ overflow: hidden;
+ width: 100%;
+ display: -webkit-box;
+ display: -webkit-flex;
+ display: -ms-flexbox;
+ display: flex;
+ -webkit-box-align: center;
+ -webkit-align-items: center;
+ -ms-flex-align: center;
+ align-items: center;
+ height: 28px;
+}
+.flatpickr-weekdays .flatpickr-weekdaycontainer {
+ display: -webkit-box;
+ display: -webkit-flex;
+ display: -ms-flexbox;
+ display: flex;
+ -webkit-box-flex: 1;
+ -webkit-flex: 1;
+ -ms-flex: 1;
+ flex: 1;
+}
+span.flatpickr-weekday {
+ cursor: default;
+ font-size: 90%;
+ background: transparent;
+ color: rgba(0,0,0,0.54);
+ line-height: 1;
+ margin: 0;
+ text-align: center;
+ display: block;
+ -webkit-box-flex: 1;
+ -webkit-flex: 1;
+ -ms-flex: 1;
+ flex: 1;
+ font-weight: bolder;
+}
+.dayContainer,
+.flatpickr-weeks {
+ padding: 1px 0 0 0;
+}
+.flatpickr-days {
+ position: relative;
+ overflow: hidden;
+ display: -webkit-box;
+ display: -webkit-flex;
+ display: -ms-flexbox;
+ display: flex;
+ -webkit-box-align: start;
+ -webkit-align-items: flex-start;
+ -ms-flex-align: start;
+ align-items: flex-start;
+ width: 307.875px;
+}
+.flatpickr-days:focus {
+ outline: 0;
+}
+.dayContainer {
+ padding: 0;
+ outline: 0;
+ text-align: left;
+ width: 307.875px;
+ min-width: 307.875px;
+ max-width: 307.875px;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+ display: inline-block;
+ display: -ms-flexbox;
+ display: -webkit-box;
+ display: -webkit-flex;
+ display: flex;
+ -webkit-flex-wrap: wrap;
+ flex-wrap: wrap;
+ -ms-flex-wrap: wrap;
+ -ms-flex-pack: justify;
+ -webkit-justify-content: space-around;
+ justify-content: space-around;
+ -webkit-transform: translate3d(0px, 0px, 0px);
+ transform: translate3d(0px, 0px, 0px);
+ opacity: 1;
+}
+.dayContainer + .dayContainer {
+ -webkit-box-shadow: -1px 0 0 #e6e6e6;
+ box-shadow: -1px 0 0 #e6e6e6;
+}
+.flatpickr-day {
+ background: none;
+ border: 1px solid transparent;
+ border-radius: 150px;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+ color: #393939;
+ cursor: pointer;
+ font-weight: 400;
+ width: 14.2857143%;
+ -webkit-flex-basis: 14.2857143%;
+ -ms-flex-preferred-size: 14.2857143%;
+ flex-basis: 14.2857143%;
+ max-width: 39px;
+ height: 39px;
+ line-height: 39px;
+ margin: 0;
+ display: inline-block;
+ position: relative;
+ -webkit-box-pack: center;
+ -webkit-justify-content: center;
+ -ms-flex-pack: center;
+ justify-content: center;
+ text-align: center;
+}
+.flatpickr-day.inRange,
+.flatpickr-day.prevMonthDay.inRange,
+.flatpickr-day.nextMonthDay.inRange,
+.flatpickr-day.today.inRange,
+.flatpickr-day.prevMonthDay.today.inRange,
+.flatpickr-day.nextMonthDay.today.inRange,
+.flatpickr-day:hover,
+.flatpickr-day.prevMonthDay:hover,
+.flatpickr-day.nextMonthDay:hover,
+.flatpickr-day:focus,
+.flatpickr-day.prevMonthDay:focus,
+.flatpickr-day.nextMonthDay:focus {
+ cursor: pointer;
+ outline: 0;
+ background: #e6e6e6;
+ border-color: #e6e6e6;
+}
+.flatpickr-day.today {
+ border-color: #959ea9;
+}
+.flatpickr-day.today:hover,
+.flatpickr-day.today:focus {
+ border-color: #959ea9;
+ background: #959ea9;
+ color: #fff;
+}
+.flatpickr-day.selected,
+.flatpickr-day.startRange,
+.flatpickr-day.endRange,
+.flatpickr-day.selected.inRange,
+.flatpickr-day.startRange.inRange,
+.flatpickr-day.endRange.inRange,
+.flatpickr-day.selected:focus,
+.flatpickr-day.startRange:focus,
+.flatpickr-day.endRange:focus,
+.flatpickr-day.selected:hover,
+.flatpickr-day.startRange:hover,
+.flatpickr-day.endRange:hover,
+.flatpickr-day.selected.prevMonthDay,
+.flatpickr-day.startRange.prevMonthDay,
+.flatpickr-day.endRange.prevMonthDay,
+.flatpickr-day.selected.nextMonthDay,
+.flatpickr-day.startRange.nextMonthDay,
+.flatpickr-day.endRange.nextMonthDay {
+ background: #569ff7;
+ -webkit-box-shadow: none;
+ box-shadow: none;
+ color: #fff;
+ border-color: #569ff7;
+}
+.flatpickr-day.selected.startRange,
+.flatpickr-day.startRange.startRange,
+.flatpickr-day.endRange.startRange {
+ border-radius: 50px 0 0 50px;
+}
+.flatpickr-day.selected.endRange,
+.flatpickr-day.startRange.endRange,
+.flatpickr-day.endRange.endRange {
+ border-radius: 0 50px 50px 0;
+}
+.flatpickr-day.selected.startRange + .endRange:not(:nth-child(7n+1)),
+.flatpickr-day.startRange.startRange + .endRange:not(:nth-child(7n+1)),
+.flatpickr-day.endRange.startRange + .endRange:not(:nth-child(7n+1)) {
+ -webkit-box-shadow: -10px 0 0 #569ff7;
+ box-shadow: -10px 0 0 #569ff7;
+}
+.flatpickr-day.selected.startRange.endRange,
+.flatpickr-day.startRange.startRange.endRange,
+.flatpickr-day.endRange.startRange.endRange {
+ border-radius: 50px;
+}
+.flatpickr-day.inRange {
+ border-radius: 0;
+ -webkit-box-shadow: -5px 0 0 #e6e6e6, 5px 0 0 #e6e6e6;
+ box-shadow: -5px 0 0 #e6e6e6, 5px 0 0 #e6e6e6;
+}
+.flatpickr-day.flatpickr-disabled,
+.flatpickr-day.flatpickr-disabled:hover,
+.flatpickr-day.prevMonthDay,
+.flatpickr-day.nextMonthDay,
+.flatpickr-day.notAllowed,
+.flatpickr-day.notAllowed.prevMonthDay,
+.flatpickr-day.notAllowed.nextMonthDay {
+ color: rgba(57,57,57,0.3);
+ background: transparent;
+ border-color: transparent;
+ cursor: default;
+}
+.flatpickr-day.flatpickr-disabled,
+.flatpickr-day.flatpickr-disabled:hover {
+ cursor: not-allowed;
+ color: rgba(57,57,57,0.1);
+}
+.flatpickr-day.week.selected {
+ border-radius: 0;
+ -webkit-box-shadow: -5px 0 0 #569ff7, 5px 0 0 #569ff7;
+ box-shadow: -5px 0 0 #569ff7, 5px 0 0 #569ff7;
+}
+.flatpickr-day.hidden {
+ visibility: hidden;
+}
+.rangeMode .flatpickr-day {
+ margin-top: 1px;
+}
+.flatpickr-weekwrapper {
+ float: left;
+}
+.flatpickr-weekwrapper .flatpickr-weeks {
+ padding: 0 12px;
+ -webkit-box-shadow: 1px 0 0 #e6e6e6;
+ box-shadow: 1px 0 0 #e6e6e6;
+}
+.flatpickr-weekwrapper .flatpickr-weekday {
+ float: none;
+ width: 100%;
+ line-height: 28px;
+}
+.flatpickr-weekwrapper span.flatpickr-day,
+.flatpickr-weekwrapper span.flatpickr-day:hover {
+ display: block;
+ width: 100%;
+ max-width: none;
+ color: rgba(57,57,57,0.3);
+ background: transparent;
+ cursor: default;
+ border: none;
+}
+.flatpickr-innerContainer {
+ display: block;
+ display: -webkit-box;
+ display: -webkit-flex;
+ display: -ms-flexbox;
+ display: flex;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+ overflow: hidden;
+}
+.flatpickr-rContainer {
+ display: inline-block;
+ padding: 0;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+}
+.flatpickr-time {
+ text-align: center;
+ outline: 0;
+ display: block;
+ height: 0;
+ line-height: 40px;
+ max-height: 40px;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+ overflow: hidden;
+ display: -webkit-box;
+ display: -webkit-flex;
+ display: -ms-flexbox;
+ display: flex;
+}
+.flatpickr-time:after {
+ content: "";
+ display: table;
+ clear: both;
+}
+.flatpickr-time .numInputWrapper {
+ -webkit-box-flex: 1;
+ -webkit-flex: 1;
+ -ms-flex: 1;
+ flex: 1;
+ width: 40%;
+ height: 40px;
+ float: left;
+}
+.flatpickr-time .numInputWrapper span.arrowUp:after {
+ border-bottom-color: #393939;
+}
+.flatpickr-time .numInputWrapper span.arrowDown:after {
+ border-top-color: #393939;
+}
+.flatpickr-time.hasSeconds .numInputWrapper {
+ width: 26%;
+}
+.flatpickr-time.time24hr .numInputWrapper {
+ width: 49%;
+}
+.flatpickr-time input {
+ background: transparent;
+ -webkit-box-shadow: none;
+ box-shadow: none;
+ border: 0;
+ border-radius: 0;
+ text-align: center;
+ margin: 0;
+ padding: 0;
+ height: inherit;
+ line-height: inherit;
+ color: #393939;
+ font-size: 14px;
+ position: relative;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+ -webkit-appearance: textfield;
+ -moz-appearance: textfield;
+ appearance: textfield;
+}
+.flatpickr-time input.flatpickr-hour {
+ font-weight: bold;
+}
+.flatpickr-time input.flatpickr-minute,
+.flatpickr-time input.flatpickr-second {
+ font-weight: 400;
+}
+.flatpickr-time input:focus {
+ outline: 0;
+ border: 0;
+}
+.flatpickr-time .flatpickr-time-separator,
+.flatpickr-time .flatpickr-am-pm {
+ height: inherit;
+ float: left;
+ line-height: inherit;
+ color: #393939;
+ font-weight: bold;
+ width: 2%;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-align-self: center;
+ -ms-flex-item-align: center;
+ align-self: center;
+}
+.flatpickr-time .flatpickr-am-pm {
+ outline: 0;
+ width: 18%;
+ cursor: pointer;
+ text-align: center;
+ font-weight: 400;
+}
+.flatpickr-time input:hover,
+.flatpickr-time .flatpickr-am-pm:hover,
+.flatpickr-time input:focus,
+.flatpickr-time .flatpickr-am-pm:focus {
+ background: #eee;
+}
+.flatpickr-input[readonly] {
+ cursor: pointer;
+}
+@-webkit-keyframes fpFadeInDown {
+ from {
+ opacity: 0;
+ -webkit-transform: translate3d(0, -20px, 0);
+ transform: translate3d(0, -20px, 0);
+ }
+ to {
+ opacity: 1;
+ -webkit-transform: translate3d(0, 0, 0);
+ transform: translate3d(0, 0, 0);
+ }
+}
+@keyframes fpFadeInDown {
+ from {
+ opacity: 0;
+ -webkit-transform: translate3d(0, -20px, 0);
+ transform: translate3d(0, -20px, 0);
+ }
+ to {
+ opacity: 1;
+ -webkit-transform: translate3d(0, 0, 0);
+ transform: translate3d(0, 0, 0);
+ }
+}
diff --git a/public/css/vendor/flatpickr.min.css b/public/css/vendor/flatpickr.min.css
new file mode 100644
index 0000000..46c57b7
--- /dev/null
+++ b/public/css/vendor/flatpickr.min.css
@@ -0,0 +1,13 @@
+.flatpickr-calendar{background:transparent;opacity:0;display:none;text-align:center;visibility:hidden;padding:0;-webkit-animation:none;animation:none;direction:ltr;border:0;font-size:14px;line-height:24px;border-radius:5px;position:absolute;width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-touch-action:manipulation;touch-action:manipulation;background:#fff;-webkit-box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08);box-shadow:1px 0 0 #e6e6e6,-1px 0 0 #e6e6e6,0 1px 0 #e6e6e6,0 -1px 0 #e6e6e6,0 3px 13px rgba(0,0,0,0.08);}.flatpickr-calendar.open,.flatpickr-calendar.inline{opacity:1;max-height:640px;visibility:visible}.flatpickr-calendar.open{display:inline-block;z-index:99999}.flatpickr-calendar.animate.open{-webkit-animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1);animation:fpFadeInDown 300ms cubic-bezier(.23,1,.32,1)}.flatpickr-calendar.inline{display:block;position:relative;top:2px}.flatpickr-calendar.static{position:absolute;top:calc(100% + 2px);}.flatpickr-calendar.static.open{z-index:999;display:block}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+1) .flatpickr-day.inRange:nth-child(7n+7){-webkit-box-shadow:none !important;box-shadow:none !important}.flatpickr-calendar.multiMonth .flatpickr-days .dayContainer:nth-child(n+2) .flatpickr-day.inRange:nth-child(7n+1){-webkit-box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6;box-shadow:-2px 0 0 #e6e6e6,5px 0 0 #e6e6e6}.flatpickr-calendar .hasWeeks .dayContainer,.flatpickr-calendar .hasTime .dayContainer{border-bottom:0;border-bottom-right-radius:0;border-bottom-left-radius:0}.flatpickr-calendar .hasWeeks .dayContainer{border-left:0}.flatpickr-calendar.showTimeInput.hasTime .flatpickr-time{height:40px;border-top:1px solid #e6e6e6}.flatpickr-calendar.noCalendar.hasTime .flatpickr-time{height:auto}.flatpickr-calendar:before,.flatpickr-calendar:after{position:absolute;display:block;pointer-events:none;border:solid transparent;content:'';height:0;width:0;left:22px}.flatpickr-calendar.rightMost:before,.flatpickr-calendar.rightMost:after{left:auto;right:22px}.flatpickr-calendar:before{border-width:5px;margin:0 -5px}.flatpickr-calendar:after{border-width:4px;margin:0 -4px}.flatpickr-calendar.arrowTop:before,.flatpickr-calendar.arrowTop:after{bottom:100%}.flatpickr-calendar.arrowTop:before{border-bottom-color:#e6e6e6}.flatpickr-calendar.arrowTop:after{border-bottom-color:#fff}.flatpickr-calendar.arrowBottom:before,.flatpickr-calendar.arrowBottom:after{top:100%}.flatpickr-calendar.arrowBottom:before{border-top-color:#e6e6e6}.flatpickr-calendar.arrowBottom:after{border-top-color:#fff}.flatpickr-calendar:focus{outline:0}.flatpickr-wrapper{position:relative;display:inline-block}.flatpickr-months{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}.flatpickr-months .flatpickr-month{background:transparent;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9);height:34px;line-height:1;text-align:center;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.flatpickr-months .flatpickr-prev-month,.flatpickr-months .flatpickr-next-month{text-decoration:none;cursor:pointer;position:absolute;top:0;height:34px;padding:10px;z-index:3;color:rgba(0,0,0,0.9);fill:rgba(0,0,0,0.9);}.flatpickr-months .flatpickr-prev-month.flatpickr-disabled,.flatpickr-months .flatpickr-next-month.flatpickr-disabled{display:none}.flatpickr-months .flatpickr-prev-month i,.flatpickr-months .flatpickr-next-month i{position:relative}.flatpickr-months .flatpickr-prev-month.flatpickr-prev-month,.flatpickr-months .flatpickr-next-month.flatpickr-prev-month{/*
+ /*rtl:begin:ignore*/left:0;/*
+ /*rtl:end:ignore*/}/*
+ /*rtl:begin:ignore*/
+/*
+ /*rtl:end:ignore*/
+.flatpickr-months .flatpickr-prev-month.flatpickr-next-month,.flatpickr-months .flatpickr-next-month.flatpickr-next-month{/*
+ /*rtl:begin:ignore*/right:0;/*
+ /*rtl:end:ignore*/}/*
+ /*rtl:begin:ignore*/
+/*
+ /*rtl:end:ignore*/
+.flatpickr-months .flatpickr-prev-month:hover,.flatpickr-months .flatpickr-next-month:hover{color:#959ea9;}.flatpickr-months .flatpickr-prev-month:hover svg,.flatpickr-months .flatpickr-next-month:hover svg{fill:#f64747}.flatpickr-months .flatpickr-prev-month svg,.flatpickr-months .flatpickr-next-month svg{width:14px;height:14px;}.flatpickr-months .flatpickr-prev-month svg path,.flatpickr-months .flatpickr-next-month svg path{-webkit-transition:fill .1s;transition:fill .1s;fill:inherit}.numInputWrapper{position:relative;height:auto;}.numInputWrapper input,.numInputWrapper span{display:inline-block}.numInputWrapper input{width:100%;}.numInputWrapper input::-ms-clear{display:none}.numInputWrapper input::-webkit-outer-spin-button,.numInputWrapper input::-webkit-inner-spin-button{margin:0;-webkit-appearance:none}.numInputWrapper span{position:absolute;right:0;width:14px;padding:0 4px 0 2px;height:50%;line-height:50%;opacity:0;cursor:pointer;border:1px solid rgba(57,57,57,0.15);-webkit-box-sizing:border-box;box-sizing:border-box;}.numInputWrapper span:hover{background:rgba(0,0,0,0.1)}.numInputWrapper span:active{background:rgba(0,0,0,0.2)}.numInputWrapper span:after{display:block;content:"";position:absolute}.numInputWrapper span.arrowUp{top:0;border-bottom:0;}.numInputWrapper span.arrowUp:after{border-left:4px solid transparent;border-right:4px solid transparent;border-bottom:4px solid rgba(57,57,57,0.6);top:26%}.numInputWrapper span.arrowDown{top:50%;}.numInputWrapper span.arrowDown:after{border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid rgba(57,57,57,0.6);top:40%}.numInputWrapper span svg{width:inherit;height:auto;}.numInputWrapper span svg path{fill:rgba(0,0,0,0.5)}.numInputWrapper:hover{background:rgba(0,0,0,0.05);}.numInputWrapper:hover span{opacity:1}.flatpickr-current-month{font-size:135%;line-height:inherit;font-weight:300;color:inherit;position:absolute;width:75%;left:12.5%;padding:7.48px 0 0 0;line-height:1;height:34px;display:inline-block;text-align:center;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0);}.flatpickr-current-month span.cur-month{font-family:inherit;font-weight:700;color:inherit;display:inline-block;margin-left:.5ch;padding:0;}.flatpickr-current-month span.cur-month:hover{background:rgba(0,0,0,0.05)}.flatpickr-current-month .numInputWrapper{width:6ch;width:7ch\0;display:inline-block;}.flatpickr-current-month .numInputWrapper span.arrowUp:after{border-bottom-color:rgba(0,0,0,0.9)}.flatpickr-current-month .numInputWrapper span.arrowDown:after{border-top-color:rgba(0,0,0,0.9)}.flatpickr-current-month input.cur-year{background:transparent;-webkit-box-sizing:border-box;box-sizing:border-box;color:inherit;cursor:text;padding:0 0 0 .5ch;margin:0;display:inline-block;font-size:inherit;font-family:inherit;font-weight:300;line-height:inherit;height:auto;border:0;border-radius:0;vertical-align:initial;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield;}.flatpickr-current-month input.cur-year:focus{outline:0}.flatpickr-current-month input.cur-year[disabled],.flatpickr-current-month input.cur-year[disabled]:hover{font-size:100%;color:rgba(0,0,0,0.5);background:transparent;pointer-events:none}.flatpickr-current-month .flatpickr-monthDropdown-months{appearance:menulist;background:transparent;border:none;border-radius:0;box-sizing:border-box;color:inherit;cursor:pointer;font-size:inherit;font-family:inherit;font-weight:300;height:auto;line-height:inherit;margin:-1px 0 0 0;outline:none;padding:0 0 0 .5ch;position:relative;vertical-align:initial;-webkit-box-sizing:border-box;-webkit-appearance:menulist;-moz-appearance:menulist;width:auto;}.flatpickr-current-month .flatpickr-monthDropdown-months:focus,.flatpickr-current-month .flatpickr-monthDropdown-months:active{outline:none}.flatpickr-current-month .flatpickr-monthDropdown-months:hover{background:rgba(0,0,0,0.05)}.flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month{background-color:transparent;outline:none;padding:0}.flatpickr-weekdays{background:transparent;text-align:center;overflow:hidden;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;height:28px;}.flatpickr-weekdays .flatpickr-weekdaycontainer{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}span.flatpickr-weekday{cursor:default;font-size:90%;background:transparent;color:rgba(0,0,0,0.54);line-height:1;margin:0;text-align:center;display:block;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;font-weight:bolder}.dayContainer,.flatpickr-weeks{padding:1px 0 0 0}.flatpickr-days{position:relative;overflow:hidden;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-align:start;-webkit-align-items:flex-start;-ms-flex-align:start;align-items:flex-start;width:307.875px;}.flatpickr-days:focus{outline:0}.dayContainer{padding:0;outline:0;text-align:left;width:307.875px;min-width:307.875px;max-width:307.875px;-webkit-box-sizing:border-box;box-sizing:border-box;display:inline-block;display:-ms-flexbox;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-wrap:wrap;-ms-flex-pack:justify;-webkit-justify-content:space-around;justify-content:space-around;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0);opacity:1;}.dayContainer + .dayContainer{-webkit-box-shadow:-1px 0 0 #e6e6e6;box-shadow:-1px 0 0 #e6e6e6}.flatpickr-day{background:none;border:1px solid transparent;border-radius:150px;-webkit-box-sizing:border-box;box-sizing:border-box;color:#393939;cursor:pointer;font-weight:400;width:14.2857143%;-webkit-flex-basis:14.2857143%;-ms-flex-preferred-size:14.2857143%;flex-basis:14.2857143%;max-width:39px;height:39px;line-height:39px;margin:0;display:inline-block;position:relative;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;text-align:center;}.flatpickr-day.inRange,.flatpickr-day.prevMonthDay.inRange,.flatpickr-day.nextMonthDay.inRange,.flatpickr-day.today.inRange,.flatpickr-day.prevMonthDay.today.inRange,.flatpickr-day.nextMonthDay.today.inRange,.flatpickr-day:hover,.flatpickr-day.prevMonthDay:hover,.flatpickr-day.nextMonthDay:hover,.flatpickr-day:focus,.flatpickr-day.prevMonthDay:focus,.flatpickr-day.nextMonthDay:focus{cursor:pointer;outline:0;background:#e6e6e6;border-color:#e6e6e6}.flatpickr-day.today{border-color:#959ea9;}.flatpickr-day.today:hover,.flatpickr-day.today:focus{border-color:#959ea9;background:#959ea9;color:#fff}.flatpickr-day.selected,.flatpickr-day.startRange,.flatpickr-day.endRange,.flatpickr-day.selected.inRange,.flatpickr-day.startRange.inRange,.flatpickr-day.endRange.inRange,.flatpickr-day.selected:focus,.flatpickr-day.startRange:focus,.flatpickr-day.endRange:focus,.flatpickr-day.selected:hover,.flatpickr-day.startRange:hover,.flatpickr-day.endRange:hover,.flatpickr-day.selected.prevMonthDay,.flatpickr-day.startRange.prevMonthDay,.flatpickr-day.endRange.prevMonthDay,.flatpickr-day.selected.nextMonthDay,.flatpickr-day.startRange.nextMonthDay,.flatpickr-day.endRange.nextMonthDay{background:#569ff7;-webkit-box-shadow:none;box-shadow:none;color:#fff;border-color:#569ff7}.flatpickr-day.selected.startRange,.flatpickr-day.startRange.startRange,.flatpickr-day.endRange.startRange{border-radius:50px 0 0 50px}.flatpickr-day.selected.endRange,.flatpickr-day.startRange.endRange,.flatpickr-day.endRange.endRange{border-radius:0 50px 50px 0}.flatpickr-day.selected.startRange + .endRange:not(:nth-child(7n+1)),.flatpickr-day.startRange.startRange + .endRange:not(:nth-child(7n+1)),.flatpickr-day.endRange.startRange + .endRange:not(:nth-child(7n+1)){-webkit-box-shadow:-10px 0 0 #569ff7;box-shadow:-10px 0 0 #569ff7}.flatpickr-day.selected.startRange.endRange,.flatpickr-day.startRange.startRange.endRange,.flatpickr-day.endRange.startRange.endRange{border-radius:50px}.flatpickr-day.inRange{border-radius:0;-webkit-box-shadow:-5px 0 0 #e6e6e6,5px 0 0 #e6e6e6;box-shadow:-5px 0 0 #e6e6e6,5px 0 0 #e6e6e6}.flatpickr-day.flatpickr-disabled,.flatpickr-day.flatpickr-disabled:hover,.flatpickr-day.prevMonthDay,.flatpickr-day.nextMonthDay,.flatpickr-day.notAllowed,.flatpickr-day.notAllowed.prevMonthDay,.flatpickr-day.notAllowed.nextMonthDay{color:rgba(57,57,57,0.3);background:transparent;border-color:transparent;cursor:default}.flatpickr-day.flatpickr-disabled,.flatpickr-day.flatpickr-disabled:hover{cursor:not-allowed;color:rgba(57,57,57,0.1)}.flatpickr-day.week.selected{border-radius:0;-webkit-box-shadow:-5px 0 0 #569ff7,5px 0 0 #569ff7;box-shadow:-5px 0 0 #569ff7,5px 0 0 #569ff7}.flatpickr-day.hidden{visibility:hidden}.rangeMode .flatpickr-day{margin-top:1px}.flatpickr-weekwrapper{float:left;}.flatpickr-weekwrapper .flatpickr-weeks{padding:0 12px;-webkit-box-shadow:1px 0 0 #e6e6e6;box-shadow:1px 0 0 #e6e6e6}.flatpickr-weekwrapper .flatpickr-weekday{float:none;width:100%;line-height:28px}.flatpickr-weekwrapper span.flatpickr-day,.flatpickr-weekwrapper span.flatpickr-day:hover{display:block;width:100%;max-width:none;color:rgba(57,57,57,0.3);background:transparent;cursor:default;border:none}.flatpickr-innerContainer{display:block;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-sizing:border-box;box-sizing:border-box;overflow:hidden;}.flatpickr-rContainer{display:inline-block;padding:0;-webkit-box-sizing:border-box;box-sizing:border-box}.flatpickr-time{text-align:center;outline:0;display:block;height:0;line-height:40px;max-height:40px;-webkit-box-sizing:border-box;box-sizing:border-box;overflow:hidden;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}.flatpickr-time:after{content:"";display:table;clear:both}.flatpickr-time .numInputWrapper{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;width:40%;height:40px;float:left;}.flatpickr-time .numInputWrapper span.arrowUp:after{border-bottom-color:#393939}.flatpickr-time .numInputWrapper span.arrowDown:after{border-top-color:#393939}.flatpickr-time.hasSeconds .numInputWrapper{width:26%}.flatpickr-time.time24hr .numInputWrapper{width:49%}.flatpickr-time input{background:transparent;-webkit-box-shadow:none;box-shadow:none;border:0;border-radius:0;text-align:center;margin:0;padding:0;height:inherit;line-height:inherit;color:#393939;font-size:14px;position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield;}.flatpickr-time input.flatpickr-hour{font-weight:bold}.flatpickr-time input.flatpickr-minute,.flatpickr-time input.flatpickr-second{font-weight:400}.flatpickr-time input:focus{outline:0;border:0}.flatpickr-time .flatpickr-time-separator,.flatpickr-time .flatpickr-am-pm{height:inherit;float:left;line-height:inherit;color:#393939;font-weight:bold;width:2%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-align-self:center;-ms-flex-item-align:center;align-self:center}.flatpickr-time .flatpickr-am-pm{outline:0;width:18%;cursor:pointer;text-align:center;font-weight:400}.flatpickr-time input:hover,.flatpickr-time .flatpickr-am-pm:hover,.flatpickr-time input:focus,.flatpickr-time .flatpickr-am-pm:focus{background:#eee}.flatpickr-input[readonly]{cursor:pointer}@-webkit-keyframes fpFadeInDown{from{opacity:0;-webkit-transform:translate3d(0,-20px,0);transform:translate3d(0,-20px,0)}to{opacity:1;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}}@keyframes fpFadeInDown{from{opacity:0;-webkit-transform:translate3d(0,-20px,0);transform:translate3d(0,-20px,0)}to{opacity:1;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}} \ No newline at end of file
diff --git a/public/img/select-icon-2x.png b/public/img/select-icon-2x.png
new file mode 100644
index 0000000..8d24b10
--- /dev/null
+++ b/public/img/select-icon-2x.png
Binary files differ
diff --git a/public/img/select-icon.png b/public/img/select-icon.png
new file mode 100644
index 0000000..0cf5132
--- /dev/null
+++ b/public/img/select-icon.png
Binary files differ
diff --git a/public/img/textarea-corner-2x.png b/public/img/textarea-corner-2x.png
new file mode 100644
index 0000000..ee9cb50
--- /dev/null
+++ b/public/img/textarea-corner-2x.png
Binary files differ
diff --git a/public/img/textarea-corner.png b/public/img/textarea-corner.png
new file mode 100644
index 0000000..3a2242c
--- /dev/null
+++ b/public/img/textarea-corner.png
Binary files differ
diff --git a/public/js/module.js b/public/js/module.js
new file mode 100644
index 0000000..d972fb1
--- /dev/null
+++ b/public/js/module.js
@@ -0,0 +1,60 @@
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+;(function (Icinga) {
+
+ 'use strict';
+
+ var Reporting = function(module) {
+ this.module = module;
+
+ this.initialize();
+ };
+
+ Reporting.prototype.initialize = function () {
+ if (typeof $().flatpickr === 'function') {
+ this.module.on('rendered', function (event) {
+ var $container = $('<div>');
+ event.target.insertAdjacentElement('beforeend', $container[0]);
+ $('.reporting-flatpickr').each(function() {
+ var $el = $(this);
+ var data = $el.find('input').data();
+ var options = {
+ appendTo: $container[0],
+ dateFormat: 'Y-m-d',
+ wrap: true
+ };
+
+ if (data.hasOwnProperty('enableTime')) {
+ options.enableTime = true;
+ options.dateFormat += ' H:i';
+ options.defaultHour = data.defaultHour || 12;
+ options.defaultMinute = data.defaultMinute || 0;
+ }
+
+ if (data.hasOwnProperty('enableSeconds')) {
+ options.enableSeconds = true;
+ options.dateFormat += ':S';
+ options.defaultSeconds = data.defaultSeconds || 0;
+ }
+
+ if (data.hasOwnProperty('allowInput')) {
+ options.allowInput = true;
+ options.clickOpens = false;
+ options.parseDate = function() {
+ // Accept any date string but don't update the value of the input
+ // If the dev console is open this will issue a warning.
+ return true;
+ };
+ }
+
+ console.log(options);
+
+ $el.flatpickr(options);
+ });
+ });
+ }
+ };
+
+ Icinga.availableModules.reporting = Reporting;
+
+}(Icinga));
diff --git a/public/js/vendor/flatpickr.js b/public/js/vendor/flatpickr.js
new file mode 100644
index 0000000..15d7397
--- /dev/null
+++ b/public/js/vendor/flatpickr.js
@@ -0,0 +1,2605 @@
+/* flatpickr v4.6.3, @license MIT */
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+ typeof define === 'function' && define.amd ? define(factory) :
+ (global = global || self, global.flatpickr = factory());
+}(this, function () { 'use strict';
+
+ /*! *****************************************************************************
+ Copyright (c) Microsoft Corporation. All rights reserved.
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+ this file except in compliance with the License. You may obtain a copy of the
+ License at http://www.apache.org/licenses/LICENSE-2.0
+
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
+ MERCHANTABLITY OR NON-INFRINGEMENT.
+
+ See the Apache Version 2.0 License for specific language governing permissions
+ and limitations under the License.
+ ***************************************************************************** */
+
+ var __assign = function() {
+ __assign = Object.assign || function __assign(t) {
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
+ s = arguments[i];
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
+ }
+ return t;
+ };
+ return __assign.apply(this, arguments);
+ };
+
+ var HOOKS = [
+ "onChange",
+ "onClose",
+ "onDayCreate",
+ "onDestroy",
+ "onKeyDown",
+ "onMonthChange",
+ "onOpen",
+ "onParseConfig",
+ "onReady",
+ "onValueUpdate",
+ "onYearChange",
+ "onPreCalendarPosition",
+ ];
+ var defaults = {
+ _disable: [],
+ _enable: [],
+ allowInput: false,
+ altFormat: "F j, Y",
+ altInput: false,
+ altInputClass: "form-control input",
+ animate: typeof window === "object" &&
+ window.navigator.userAgent.indexOf("MSIE") === -1,
+ ariaDateFormat: "F j, Y",
+ clickOpens: true,
+ closeOnSelect: true,
+ conjunction: ", ",
+ dateFormat: "Y-m-d",
+ defaultHour: 12,
+ defaultMinute: 0,
+ defaultSeconds: 0,
+ disable: [],
+ disableMobile: false,
+ enable: [],
+ enableSeconds: false,
+ enableTime: false,
+ errorHandler: function (err) {
+ return typeof console !== "undefined" && console.warn(err);
+ },
+ getWeek: function (givenDate) {
+ var date = new Date(givenDate.getTime());
+ date.setHours(0, 0, 0, 0);
+ // Thursday in current week decides the year.
+ date.setDate(date.getDate() + 3 - ((date.getDay() + 6) % 7));
+ // January 4 is always in week 1.
+ var week1 = new Date(date.getFullYear(), 0, 4);
+ // Adjust to Thursday in week 1 and count number of weeks from date to week1.
+ return (1 +
+ Math.round(((date.getTime() - week1.getTime()) / 86400000 -
+ 3 +
+ ((week1.getDay() + 6) % 7)) /
+ 7));
+ },
+ hourIncrement: 1,
+ ignoredFocusElements: [],
+ inline: false,
+ locale: "default",
+ minuteIncrement: 5,
+ mode: "single",
+ monthSelectorType: "dropdown",
+ nextArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M13.207 8.472l-7.854 7.854-0.707-0.707 7.146-7.146-7.146-7.148 0.707-0.707 7.854 7.854z' /></svg>",
+ noCalendar: false,
+ now: new Date(),
+ onChange: [],
+ onClose: [],
+ onDayCreate: [],
+ onDestroy: [],
+ onKeyDown: [],
+ onMonthChange: [],
+ onOpen: [],
+ onParseConfig: [],
+ onReady: [],
+ onValueUpdate: [],
+ onYearChange: [],
+ onPreCalendarPosition: [],
+ plugins: [],
+ position: "auto",
+ positionElement: undefined,
+ prevArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M5.207 8.471l7.146 7.147-0.707 0.707-7.853-7.854 7.854-7.853 0.707 0.707-7.147 7.146z' /></svg>",
+ shorthandCurrentMonth: false,
+ showMonths: 1,
+ static: false,
+ time_24hr: false,
+ weekNumbers: false,
+ wrap: false
+ };
+
+ var english = {
+ weekdays: {
+ shorthand: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
+ longhand: [
+ "Sunday",
+ "Monday",
+ "Tuesday",
+ "Wednesday",
+ "Thursday",
+ "Friday",
+ "Saturday",
+ ]
+ },
+ months: {
+ shorthand: [
+ "Jan",
+ "Feb",
+ "Mar",
+ "Apr",
+ "May",
+ "Jun",
+ "Jul",
+ "Aug",
+ "Sep",
+ "Oct",
+ "Nov",
+ "Dec",
+ ],
+ longhand: [
+ "January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July",
+ "August",
+ "September",
+ "October",
+ "November",
+ "December",
+ ]
+ },
+ daysInMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
+ firstDayOfWeek: 0,
+ ordinal: function (nth) {
+ var s = nth % 100;
+ if (s > 3 && s < 21)
+ return "th";
+ switch (s % 10) {
+ case 1:
+ return "st";
+ case 2:
+ return "nd";
+ case 3:
+ return "rd";
+ default:
+ return "th";
+ }
+ },
+ rangeSeparator: " to ",
+ weekAbbreviation: "Wk",
+ scrollTitle: "Scroll to increment",
+ toggleTitle: "Click to toggle",
+ amPM: ["AM", "PM"],
+ yearAriaLabel: "Year",
+ hourAriaLabel: "Hour",
+ minuteAriaLabel: "Minute",
+ time_24hr: false
+ };
+
+ var pad = function (number) { return ("0" + number).slice(-2); };
+ var int = function (bool) { return (bool === true ? 1 : 0); };
+ /* istanbul ignore next */
+ function debounce(func, wait, immediate) {
+ if (immediate === void 0) { immediate = false; }
+ var timeout;
+ return function () {
+ var context = this, args = arguments;
+ timeout !== null && clearTimeout(timeout);
+ timeout = window.setTimeout(function () {
+ timeout = null;
+ if (!immediate)
+ func.apply(context, args);
+ }, wait);
+ if (immediate && !timeout)
+ func.apply(context, args);
+ };
+ }
+ var arrayify = function (obj) {
+ return obj instanceof Array ? obj : [obj];
+ };
+
+ function toggleClass(elem, className, bool) {
+ if (bool === true)
+ return elem.classList.add(className);
+ elem.classList.remove(className);
+ }
+ function createElement(tag, className, content) {
+ var e = window.document.createElement(tag);
+ className = className || "";
+ content = content || "";
+ e.className = className;
+ if (content !== undefined)
+ e.textContent = content;
+ return e;
+ }
+ function clearNode(node) {
+ while (node.firstChild)
+ node.removeChild(node.firstChild);
+ }
+ function findParent(node, condition) {
+ if (condition(node))
+ return node;
+ else if (node.parentNode)
+ return findParent(node.parentNode, condition);
+ return undefined; // nothing found
+ }
+ function createNumberInput(inputClassName, opts) {
+ var wrapper = createElement("div", "numInputWrapper"), numInput = createElement("input", "numInput " + inputClassName), arrowUp = createElement("span", "arrowUp"), arrowDown = createElement("span", "arrowDown");
+ if (navigator.userAgent.indexOf("MSIE 9.0") === -1) {
+ numInput.type = "number";
+ }
+ else {
+ numInput.type = "text";
+ numInput.pattern = "\\d*";
+ }
+ if (opts !== undefined)
+ for (var key in opts)
+ numInput.setAttribute(key, opts[key]);
+ wrapper.appendChild(numInput);
+ wrapper.appendChild(arrowUp);
+ wrapper.appendChild(arrowDown);
+ return wrapper;
+ }
+ function getEventTarget(event) {
+ if (typeof event.composedPath === "function") {
+ var path = event.composedPath();
+ return path[0];
+ }
+ return event.target;
+ }
+
+ var doNothing = function () { return undefined; };
+ var monthToStr = function (monthNumber, shorthand, locale) { return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber]; };
+ var revFormat = {
+ D: doNothing,
+ F: function (dateObj, monthName, locale) {
+ dateObj.setMonth(locale.months.longhand.indexOf(monthName));
+ },
+ G: function (dateObj, hour) {
+ dateObj.setHours(parseFloat(hour));
+ },
+ H: function (dateObj, hour) {
+ dateObj.setHours(parseFloat(hour));
+ },
+ J: function (dateObj, day) {
+ dateObj.setDate(parseFloat(day));
+ },
+ K: function (dateObj, amPM, locale) {
+ dateObj.setHours((dateObj.getHours() % 12) +
+ 12 * int(new RegExp(locale.amPM[1], "i").test(amPM)));
+ },
+ M: function (dateObj, shortMonth, locale) {
+ dateObj.setMonth(locale.months.shorthand.indexOf(shortMonth));
+ },
+ S: function (dateObj, seconds) {
+ dateObj.setSeconds(parseFloat(seconds));
+ },
+ U: function (_, unixSeconds) { return new Date(parseFloat(unixSeconds) * 1000); },
+ W: function (dateObj, weekNum, locale) {
+ var weekNumber = parseInt(weekNum);
+ var date = new Date(dateObj.getFullYear(), 0, 2 + (weekNumber - 1) * 7, 0, 0, 0, 0);
+ date.setDate(date.getDate() - date.getDay() + locale.firstDayOfWeek);
+ return date;
+ },
+ Y: function (dateObj, year) {
+ dateObj.setFullYear(parseFloat(year));
+ },
+ Z: function (_, ISODate) { return new Date(ISODate); },
+ d: function (dateObj, day) {
+ dateObj.setDate(parseFloat(day));
+ },
+ h: function (dateObj, hour) {
+ dateObj.setHours(parseFloat(hour));
+ },
+ i: function (dateObj, minutes) {
+ dateObj.setMinutes(parseFloat(minutes));
+ },
+ j: function (dateObj, day) {
+ dateObj.setDate(parseFloat(day));
+ },
+ l: doNothing,
+ m: function (dateObj, month) {
+ dateObj.setMonth(parseFloat(month) - 1);
+ },
+ n: function (dateObj, month) {
+ dateObj.setMonth(parseFloat(month) - 1);
+ },
+ s: function (dateObj, seconds) {
+ dateObj.setSeconds(parseFloat(seconds));
+ },
+ u: function (_, unixMillSeconds) {
+ return new Date(parseFloat(unixMillSeconds));
+ },
+ w: doNothing,
+ y: function (dateObj, year) {
+ dateObj.setFullYear(2000 + parseFloat(year));
+ }
+ };
+ var tokenRegex = {
+ D: "(\\w+)",
+ F: "(\\w+)",
+ G: "(\\d\\d|\\d)",
+ H: "(\\d\\d|\\d)",
+ J: "(\\d\\d|\\d)\\w+",
+ K: "",
+ M: "(\\w+)",
+ S: "(\\d\\d|\\d)",
+ U: "(.+)",
+ W: "(\\d\\d|\\d)",
+ Y: "(\\d{4})",
+ Z: "(.+)",
+ d: "(\\d\\d|\\d)",
+ h: "(\\d\\d|\\d)",
+ i: "(\\d\\d|\\d)",
+ j: "(\\d\\d|\\d)",
+ l: "(\\w+)",
+ m: "(\\d\\d|\\d)",
+ n: "(\\d\\d|\\d)",
+ s: "(\\d\\d|\\d)",
+ u: "(.+)",
+ w: "(\\d\\d|\\d)",
+ y: "(\\d{2})"
+ };
+ var formats = {
+ // get the date in UTC
+ Z: function (date) { return date.toISOString(); },
+ // weekday name, short, e.g. Thu
+ D: function (date, locale, options) {
+ return locale.weekdays.shorthand[formats.w(date, locale, options)];
+ },
+ // full month name e.g. January
+ F: function (date, locale, options) {
+ return monthToStr(formats.n(date, locale, options) - 1, false, locale);
+ },
+ // padded hour 1-12
+ G: function (date, locale, options) {
+ return pad(formats.h(date, locale, options));
+ },
+ // hours with leading zero e.g. 03
+ H: function (date) { return pad(date.getHours()); },
+ // day (1-30) with ordinal suffix e.g. 1st, 2nd
+ J: function (date, locale) {
+ return locale.ordinal !== undefined
+ ? date.getDate() + locale.ordinal(date.getDate())
+ : date.getDate();
+ },
+ // AM/PM
+ K: function (date, locale) { return locale.amPM[int(date.getHours() > 11)]; },
+ // shorthand month e.g. Jan, Sep, Oct, etc
+ M: function (date, locale) {
+ return monthToStr(date.getMonth(), true, locale);
+ },
+ // seconds 00-59
+ S: function (date) { return pad(date.getSeconds()); },
+ // unix timestamp
+ U: function (date) { return date.getTime() / 1000; },
+ W: function (date, _, options) {
+ return options.getWeek(date);
+ },
+ // full year e.g. 2016
+ Y: function (date) { return date.getFullYear(); },
+ // day in month, padded (01-30)
+ d: function (date) { return pad(date.getDate()); },
+ // hour from 1-12 (am/pm)
+ h: function (date) { return (date.getHours() % 12 ? date.getHours() % 12 : 12); },
+ // minutes, padded with leading zero e.g. 09
+ i: function (date) { return pad(date.getMinutes()); },
+ // day in month (1-30)
+ j: function (date) { return date.getDate(); },
+ // weekday name, full, e.g. Thursday
+ l: function (date, locale) {
+ return locale.weekdays.longhand[date.getDay()];
+ },
+ // padded month number (01-12)
+ m: function (date) { return pad(date.getMonth() + 1); },
+ // the month number (1-12)
+ n: function (date) { return date.getMonth() + 1; },
+ // seconds 0-59
+ s: function (date) { return date.getSeconds(); },
+ // Unix Milliseconds
+ u: function (date) { return date.getTime(); },
+ // number of the day of the week
+ w: function (date) { return date.getDay(); },
+ // last two digits of year e.g. 16 for 2016
+ y: function (date) { return String(date.getFullYear()).substring(2); }
+ };
+
+ var createDateFormatter = function (_a) {
+ var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c;
+ return function (dateObj, frmt, overrideLocale) {
+ var locale = overrideLocale || l10n;
+ if (config.formatDate !== undefined) {
+ return config.formatDate(dateObj, frmt, locale);
+ }
+ return frmt
+ .split("")
+ .map(function (c, i, arr) {
+ return formats[c] && arr[i - 1] !== "\\"
+ ? formats[c](dateObj, locale, config)
+ : c !== "\\"
+ ? c
+ : "";
+ })
+ .join("");
+ };
+ };
+ var createDateParser = function (_a) {
+ var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c;
+ return function (date, givenFormat, timeless, customLocale) {
+ if (date !== 0 && !date)
+ return undefined;
+ var locale = customLocale || l10n;
+ var parsedDate;
+ var dateOrig = date;
+ if (date instanceof Date)
+ parsedDate = new Date(date.getTime());
+ else if (typeof date !== "string" &&
+ date.toFixed !== undefined // timestamp
+ )
+ // create a copy
+ parsedDate = new Date(date);
+ else if (typeof date === "string") {
+ // date string
+ var format = givenFormat || (config || defaults).dateFormat;
+ var datestr = String(date).trim();
+ if (datestr === "today") {
+ parsedDate = new Date();
+ timeless = true;
+ }
+ else if (/Z$/.test(datestr) ||
+ /GMT$/.test(datestr) // datestrings w/ timezone
+ )
+ parsedDate = new Date(date);
+ else if (config && config.parseDate)
+ parsedDate = config.parseDate(date, format);
+ else {
+ parsedDate =
+ !config || !config.noCalendar
+ ? new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0)
+ : new Date(new Date().setHours(0, 0, 0, 0));
+ var matched = void 0, ops = [];
+ for (var i = 0, matchIndex = 0, regexStr = ""; i < format.length; i++) {
+ var token_1 = format[i];
+ var isBackSlash = token_1 === "\\";
+ var escaped = format[i - 1] === "\\" || isBackSlash;
+ if (tokenRegex[token_1] && !escaped) {
+ regexStr += tokenRegex[token_1];
+ var match = new RegExp(regexStr).exec(date);
+ if (match && (matched = true)) {
+ ops[token_1 !== "Y" ? "push" : "unshift"]({
+ fn: revFormat[token_1],
+ val: match[++matchIndex]
+ });
+ }
+ }
+ else if (!isBackSlash)
+ regexStr += "."; // don't really care
+ ops.forEach(function (_a) {
+ var fn = _a.fn, val = _a.val;
+ return (parsedDate = fn(parsedDate, val, locale) || parsedDate);
+ });
+ }
+ parsedDate = matched ? parsedDate : undefined;
+ }
+ }
+ /* istanbul ignore next */
+ if (!(parsedDate instanceof Date && !isNaN(parsedDate.getTime()))) {
+ config.errorHandler(new Error("Invalid date provided: " + dateOrig));
+ return undefined;
+ }
+ if (timeless === true)
+ parsedDate.setHours(0, 0, 0, 0);
+ return parsedDate;
+ };
+ };
+ /**
+ * Compute the difference in dates, measured in ms
+ */
+ function compareDates(date1, date2, timeless) {
+ if (timeless === void 0) { timeless = true; }
+ if (timeless !== false) {
+ return (new Date(date1.getTime()).setHours(0, 0, 0, 0) -
+ new Date(date2.getTime()).setHours(0, 0, 0, 0));
+ }
+ return date1.getTime() - date2.getTime();
+ }
+ var isBetween = function (ts, ts1, ts2) {
+ return ts > Math.min(ts1, ts2) && ts < Math.max(ts1, ts2);
+ };
+ var duration = {
+ DAY: 86400000
+ };
+
+ if (typeof Object.assign !== "function") {
+ Object.assign = function (target) {
+ var args = [];
+ for (var _i = 1; _i < arguments.length; _i++) {
+ args[_i - 1] = arguments[_i];
+ }
+ if (!target) {
+ throw TypeError("Cannot convert undefined or null to object");
+ }
+ var _loop_1 = function (source) {
+ if (source) {
+ Object.keys(source).forEach(function (key) { return (target[key] = source[key]); });
+ }
+ };
+ for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
+ var source = args_1[_a];
+ _loop_1(source);
+ }
+ return target;
+ };
+ }
+
+ var DEBOUNCED_CHANGE_MS = 300;
+ function FlatpickrInstance(element, instanceConfig) {
+ var self = {
+ config: __assign({}, defaults, flatpickr.defaultConfig),
+ l10n: english
+ };
+ self.parseDate = createDateParser({ config: self.config, l10n: self.l10n });
+ self._handlers = [];
+ self.pluginElements = [];
+ self.loadedPlugins = [];
+ self._bind = bind;
+ self._setHoursFromDate = setHoursFromDate;
+ self._positionCalendar = positionCalendar;
+ self.changeMonth = changeMonth;
+ self.changeYear = changeYear;
+ self.clear = clear;
+ self.close = close;
+ self._createElement = createElement;
+ self.destroy = destroy;
+ self.isEnabled = isEnabled;
+ self.jumpToDate = jumpToDate;
+ self.open = open;
+ self.redraw = redraw;
+ self.set = set;
+ self.setDate = setDate;
+ self.toggle = toggle;
+ function setupHelperFunctions() {
+ self.utils = {
+ getDaysInMonth: function (month, yr) {
+ if (month === void 0) { month = self.currentMonth; }
+ if (yr === void 0) { yr = self.currentYear; }
+ if (month === 1 && ((yr % 4 === 0 && yr % 100 !== 0) || yr % 400 === 0))
+ return 29;
+ return self.l10n.daysInMonth[month];
+ }
+ };
+ }
+ function init() {
+ self.element = self.input = element;
+ self.isOpen = false;
+ parseConfig();
+ setupLocale();
+ setupInputs();
+ setupDates();
+ setupHelperFunctions();
+ if (!self.isMobile)
+ build();
+ bindEvents();
+ if (self.selectedDates.length || self.config.noCalendar) {
+ if (self.config.enableTime) {
+ setHoursFromDate(self.config.noCalendar
+ ? self.latestSelectedDateObj || self.config.minDate
+ : undefined);
+ }
+ updateValue(false);
+ }
+ setCalendarWidth();
+ self.showTimeInput =
+ self.selectedDates.length > 0 || self.config.noCalendar;
+ var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
+ /* TODO: investigate this further
+
+ Currently, there is weird positioning behavior in safari causing pages
+ to scroll up. https://github.com/chmln/flatpickr/issues/563
+
+ However, most browsers are not Safari and positioning is expensive when used
+ in scale. https://github.com/chmln/flatpickr/issues/1096
+ */
+ if (!self.isMobile && isSafari) {
+ positionCalendar();
+ }
+ triggerEvent("onReady");
+ }
+ function bindToInstance(fn) {
+ return fn.bind(self);
+ }
+ function setCalendarWidth() {
+ var config = self.config;
+ if (config.weekNumbers === false && config.showMonths === 1)
+ return;
+ else if (config.noCalendar !== true) {
+ window.requestAnimationFrame(function () {
+ if (self.calendarContainer !== undefined) {
+ self.calendarContainer.style.visibility = "hidden";
+ self.calendarContainer.style.display = "block";
+ }
+ if (self.daysContainer !== undefined) {
+ var daysWidth = (self.days.offsetWidth + 1) * config.showMonths;
+ self.daysContainer.style.width = daysWidth + "px";
+ self.calendarContainer.style.width =
+ daysWidth +
+ (self.weekWrapper !== undefined
+ ? self.weekWrapper.offsetWidth
+ : 0) +
+ "px";
+ self.calendarContainer.style.removeProperty("visibility");
+ self.calendarContainer.style.removeProperty("display");
+ }
+ });
+ }
+ }
+ /**
+ * The handler for all events targeting the time inputs
+ */
+ function updateTime(e) {
+ if (self.selectedDates.length === 0) {
+ setDefaultTime();
+ }
+ if (e !== undefined && e.type !== "blur") {
+ timeWrapper(e);
+ }
+ var prevValue = self._input.value;
+ setHoursFromInputs();
+ updateValue();
+ if (self._input.value !== prevValue) {
+ self._debouncedChange();
+ }
+ }
+ function ampm2military(hour, amPM) {
+ return (hour % 12) + 12 * int(amPM === self.l10n.amPM[1]);
+ }
+ function military2ampm(hour) {
+ switch (hour % 24) {
+ case 0:
+ case 12:
+ return 12;
+ default:
+ return hour % 12;
+ }
+ }
+ /**
+ * Syncs the selected date object time with user's time input
+ */
+ function setHoursFromInputs() {
+ if (self.hourElement === undefined || self.minuteElement === undefined)
+ return;
+ var hours = (parseInt(self.hourElement.value.slice(-2), 10) || 0) % 24, minutes = (parseInt(self.minuteElement.value, 10) || 0) % 60, seconds = self.secondElement !== undefined
+ ? (parseInt(self.secondElement.value, 10) || 0) % 60
+ : 0;
+ if (self.amPM !== undefined) {
+ hours = ampm2military(hours, self.amPM.textContent);
+ }
+ var limitMinHours = self.config.minTime !== undefined ||
+ (self.config.minDate &&
+ self.minDateHasTime &&
+ self.latestSelectedDateObj &&
+ compareDates(self.latestSelectedDateObj, self.config.minDate, true) ===
+ 0);
+ var limitMaxHours = self.config.maxTime !== undefined ||
+ (self.config.maxDate &&
+ self.maxDateHasTime &&
+ self.latestSelectedDateObj &&
+ compareDates(self.latestSelectedDateObj, self.config.maxDate, true) ===
+ 0);
+ if (limitMaxHours) {
+ var maxTime = self.config.maxTime !== undefined
+ ? self.config.maxTime
+ : self.config.maxDate;
+ hours = Math.min(hours, maxTime.getHours());
+ if (hours === maxTime.getHours())
+ minutes = Math.min(minutes, maxTime.getMinutes());
+ if (minutes === maxTime.getMinutes())
+ seconds = Math.min(seconds, maxTime.getSeconds());
+ }
+ if (limitMinHours) {
+ var minTime = self.config.minTime !== undefined
+ ? self.config.minTime
+ : self.config.minDate;
+ hours = Math.max(hours, minTime.getHours());
+ if (hours === minTime.getHours())
+ minutes = Math.max(minutes, minTime.getMinutes());
+ if (minutes === minTime.getMinutes())
+ seconds = Math.max(seconds, minTime.getSeconds());
+ }
+ setHours(hours, minutes, seconds);
+ }
+ /**
+ * Syncs time input values with a date
+ */
+ function setHoursFromDate(dateObj) {
+ var date = dateObj || self.latestSelectedDateObj;
+ if (date)
+ setHours(date.getHours(), date.getMinutes(), date.getSeconds());
+ }
+ function setDefaultHours() {
+ var hours = self.config.defaultHour;
+ var minutes = self.config.defaultMinute;
+ var seconds = self.config.defaultSeconds;
+ if (self.config.minDate !== undefined) {
+ var minHr = self.config.minDate.getHours();
+ var minMinutes = self.config.minDate.getMinutes();
+ hours = Math.max(hours, minHr);
+ if (hours === minHr)
+ minutes = Math.max(minMinutes, minutes);
+ if (hours === minHr && minutes === minMinutes)
+ seconds = self.config.minDate.getSeconds();
+ }
+ if (self.config.maxDate !== undefined) {
+ var maxHr = self.config.maxDate.getHours();
+ var maxMinutes = self.config.maxDate.getMinutes();
+ hours = Math.min(hours, maxHr);
+ if (hours === maxHr)
+ minutes = Math.min(maxMinutes, minutes);
+ if (hours === maxHr && minutes === maxMinutes)
+ seconds = self.config.maxDate.getSeconds();
+ }
+ setHours(hours, minutes, seconds);
+ }
+ /**
+ * Sets the hours, minutes, and optionally seconds
+ * of the latest selected date object and the
+ * corresponding time inputs
+ * @param {Number} hours the hour. whether its military
+ * or am-pm gets inferred from config
+ * @param {Number} minutes the minutes
+ * @param {Number} seconds the seconds (optional)
+ */
+ function setHours(hours, minutes, seconds) {
+ if (self.latestSelectedDateObj !== undefined) {
+ self.latestSelectedDateObj.setHours(hours % 24, minutes, seconds || 0, 0);
+ }
+ if (!self.hourElement || !self.minuteElement || self.isMobile)
+ return;
+ self.hourElement.value = pad(!self.config.time_24hr
+ ? ((12 + hours) % 12) + 12 * int(hours % 12 === 0)
+ : hours);
+ self.minuteElement.value = pad(minutes);
+ if (self.amPM !== undefined)
+ self.amPM.textContent = self.l10n.amPM[int(hours >= 12)];
+ if (self.secondElement !== undefined)
+ self.secondElement.value = pad(seconds);
+ }
+ /**
+ * Handles the year input and incrementing events
+ * @param {Event} event the keyup or increment event
+ */
+ function onYearInput(event) {
+ var year = parseInt(event.target.value) + (event.delta || 0);
+ if (year / 1000 > 1 ||
+ (event.key === "Enter" && !/[^\d]/.test(year.toString()))) {
+ changeYear(year);
+ }
+ }
+ /**
+ * Essentially addEventListener + tracking
+ * @param {Element} element the element to addEventListener to
+ * @param {String} event the event name
+ * @param {Function} handler the event handler
+ */
+ function bind(element, event, handler, options) {
+ if (event instanceof Array)
+ return event.forEach(function (ev) { return bind(element, ev, handler, options); });
+ if (element instanceof Array)
+ return element.forEach(function (el) { return bind(el, event, handler, options); });
+ element.addEventListener(event, handler, options);
+ self._handlers.push({
+ element: element,
+ event: event,
+ handler: handler,
+ options: options
+ });
+ }
+ /**
+ * A mousedown handler which mimics click.
+ * Minimizes latency, since we don't need to wait for mouseup in most cases.
+ * Also, avoids handling right clicks.
+ *
+ * @param {Function} handler the event handler
+ */
+ function onClick(handler) {
+ return function (evt) {
+ evt.which === 1 && handler(evt);
+ };
+ }
+ function triggerChange() {
+ triggerEvent("onChange");
+ }
+ /**
+ * Adds all the necessary event listeners
+ */
+ function bindEvents() {
+ if (self.config.wrap) {
+ ["open", "close", "toggle", "clear"].forEach(function (evt) {
+ Array.prototype.forEach.call(self.element.querySelectorAll("[data-" + evt + "]"), function (el) {
+ return bind(el, "click", self[evt]);
+ });
+ });
+ }
+ if (self.isMobile) {
+ setupMobile();
+ return;
+ }
+ var debouncedResize = debounce(onResize, 50);
+ self._debouncedChange = debounce(triggerChange, DEBOUNCED_CHANGE_MS);
+ if (self.daysContainer && !/iPhone|iPad|iPod/i.test(navigator.userAgent))
+ bind(self.daysContainer, "mouseover", function (e) {
+ if (self.config.mode === "range")
+ onMouseOver(e.target);
+ });
+ bind(window.document.body, "keydown", onKeyDown);
+ if (!self.config.inline && !self.config.static)
+ bind(window, "resize", debouncedResize);
+ if (window.ontouchstart !== undefined)
+ bind(window.document, "touchstart", documentClick);
+ else
+ bind(window.document, "mousedown", onClick(documentClick));
+ bind(window.document, "focus", documentClick, { capture: true });
+ if (self.config.clickOpens === true) {
+ bind(self._input, "focus", self.open);
+ bind(self._input, "mousedown", onClick(self.open));
+ }
+ if (self.daysContainer !== undefined) {
+ bind(self.monthNav, "mousedown", onClick(onMonthNavClick));
+ bind(self.monthNav, ["keyup", "increment"], onYearInput);
+ bind(self.daysContainer, "mousedown", onClick(selectDate));
+ }
+ if (self.timeContainer !== undefined &&
+ self.minuteElement !== undefined &&
+ self.hourElement !== undefined) {
+ var selText = function (e) {
+ return e.target.select();
+ };
+ bind(self.timeContainer, ["increment"], updateTime);
+ bind(self.timeContainer, "blur", updateTime, { capture: true });
+ bind(self.timeContainer, "mousedown", onClick(timeIncrement));
+ bind([self.hourElement, self.minuteElement], ["focus", "click"], selText);
+ if (self.secondElement !== undefined)
+ bind(self.secondElement, "focus", function () { return self.secondElement && self.secondElement.select(); });
+ if (self.amPM !== undefined) {
+ bind(self.amPM, "mousedown", onClick(function (e) {
+ updateTime(e);
+ triggerChange();
+ }));
+ }
+ }
+ }
+ /**
+ * Set the calendar view to a particular date.
+ * @param {Date} jumpDate the date to set the view to
+ * @param {boolean} triggerChange if change events should be triggered
+ */
+ function jumpToDate(jumpDate, triggerChange) {
+ var jumpTo = jumpDate !== undefined
+ ? self.parseDate(jumpDate)
+ : self.latestSelectedDateObj ||
+ (self.config.minDate && self.config.minDate > self.now
+ ? self.config.minDate
+ : self.config.maxDate && self.config.maxDate < self.now
+ ? self.config.maxDate
+ : self.now);
+ var oldYear = self.currentYear;
+ var oldMonth = self.currentMonth;
+ try {
+ if (jumpTo !== undefined) {
+ self.currentYear = jumpTo.getFullYear();
+ self.currentMonth = jumpTo.getMonth();
+ }
+ }
+ catch (e) {
+ /* istanbul ignore next */
+ e.message = "Invalid date supplied: " + jumpTo;
+ self.config.errorHandler(e);
+ }
+ if (triggerChange && self.currentYear !== oldYear) {
+ triggerEvent("onYearChange");
+ buildMonthSwitch();
+ }
+ if (triggerChange &&
+ (self.currentYear !== oldYear || self.currentMonth !== oldMonth)) {
+ triggerEvent("onMonthChange");
+ }
+ self.redraw();
+ }
+ /**
+ * The up/down arrow handler for time inputs
+ * @param {Event} e the click event
+ */
+ function timeIncrement(e) {
+ if (~e.target.className.indexOf("arrow"))
+ incrementNumInput(e, e.target.classList.contains("arrowUp") ? 1 : -1);
+ }
+ /**
+ * Increments/decrements the value of input associ-
+ * ated with the up/down arrow by dispatching an
+ * "increment" event on the input.
+ *
+ * @param {Event} e the click event
+ * @param {Number} delta the diff (usually 1 or -1)
+ * @param {Element} inputElem the input element
+ */
+ function incrementNumInput(e, delta, inputElem) {
+ var target = e && e.target;
+ var input = inputElem ||
+ (target && target.parentNode && target.parentNode.firstChild);
+ var event = createEvent("increment");
+ event.delta = delta;
+ input && input.dispatchEvent(event);
+ }
+ function build() {
+ var fragment = window.document.createDocumentFragment();
+ self.calendarContainer = createElement("div", "flatpickr-calendar");
+ self.calendarContainer.tabIndex = -1;
+ if (!self.config.noCalendar) {
+ fragment.appendChild(buildMonthNav());
+ self.innerContainer = createElement("div", "flatpickr-innerContainer");
+ if (self.config.weekNumbers) {
+ var _a = buildWeeks(), weekWrapper = _a.weekWrapper, weekNumbers = _a.weekNumbers;
+ self.innerContainer.appendChild(weekWrapper);
+ self.weekNumbers = weekNumbers;
+ self.weekWrapper = weekWrapper;
+ }
+ self.rContainer = createElement("div", "flatpickr-rContainer");
+ self.rContainer.appendChild(buildWeekdays());
+ if (!self.daysContainer) {
+ self.daysContainer = createElement("div", "flatpickr-days");
+ self.daysContainer.tabIndex = -1;
+ }
+ buildDays();
+ self.rContainer.appendChild(self.daysContainer);
+ self.innerContainer.appendChild(self.rContainer);
+ fragment.appendChild(self.innerContainer);
+ }
+ if (self.config.enableTime) {
+ fragment.appendChild(buildTime());
+ }
+ toggleClass(self.calendarContainer, "rangeMode", self.config.mode === "range");
+ toggleClass(self.calendarContainer, "animate", self.config.animate === true);
+ toggleClass(self.calendarContainer, "multiMonth", self.config.showMonths > 1);
+ self.calendarContainer.appendChild(fragment);
+ var customAppend = self.config.appendTo !== undefined &&
+ self.config.appendTo.nodeType !== undefined;
+ if (self.config.inline || self.config.static) {
+ self.calendarContainer.classList.add(self.config.inline ? "inline" : "static");
+ if (self.config.inline) {
+ if (!customAppend && self.element.parentNode)
+ self.element.parentNode.insertBefore(self.calendarContainer, self._input.nextSibling);
+ else if (self.config.appendTo !== undefined)
+ self.config.appendTo.appendChild(self.calendarContainer);
+ }
+ if (self.config.static) {
+ var wrapper = createElement("div", "flatpickr-wrapper");
+ if (self.element.parentNode)
+ self.element.parentNode.insertBefore(wrapper, self.element);
+ wrapper.appendChild(self.element);
+ if (self.altInput)
+ wrapper.appendChild(self.altInput);
+ wrapper.appendChild(self.calendarContainer);
+ }
+ }
+ if (!self.config.static && !self.config.inline)
+ (self.config.appendTo !== undefined
+ ? self.config.appendTo
+ : window.document.body).appendChild(self.calendarContainer);
+ }
+ function createDay(className, date, dayNumber, i) {
+ var dateIsEnabled = isEnabled(date, true), dayElement = createElement("span", "flatpickr-day " + className, date.getDate().toString());
+ dayElement.dateObj = date;
+ dayElement.$i = i;
+ dayElement.setAttribute("aria-label", self.formatDate(date, self.config.ariaDateFormat));
+ if (className.indexOf("hidden") === -1 &&
+ compareDates(date, self.now) === 0) {
+ self.todayDateElem = dayElement;
+ dayElement.classList.add("today");
+ dayElement.setAttribute("aria-current", "date");
+ }
+ if (dateIsEnabled) {
+ dayElement.tabIndex = -1;
+ if (isDateSelected(date)) {
+ dayElement.classList.add("selected");
+ self.selectedDateElem = dayElement;
+ if (self.config.mode === "range") {
+ toggleClass(dayElement, "startRange", self.selectedDates[0] &&
+ compareDates(date, self.selectedDates[0], true) === 0);
+ toggleClass(dayElement, "endRange", self.selectedDates[1] &&
+ compareDates(date, self.selectedDates[1], true) === 0);
+ if (className === "nextMonthDay")
+ dayElement.classList.add("inRange");
+ }
+ }
+ }
+ else {
+ dayElement.classList.add("flatpickr-disabled");
+ }
+ if (self.config.mode === "range") {
+ if (isDateInRange(date) && !isDateSelected(date))
+ dayElement.classList.add("inRange");
+ }
+ if (self.weekNumbers &&
+ self.config.showMonths === 1 &&
+ className !== "prevMonthDay" &&
+ dayNumber % 7 === 1) {
+ self.weekNumbers.insertAdjacentHTML("beforeend", "<span class='flatpickr-day'>" + self.config.getWeek(date) + "</span>");
+ }
+ triggerEvent("onDayCreate", dayElement);
+ return dayElement;
+ }
+ function focusOnDayElem(targetNode) {
+ targetNode.focus();
+ if (self.config.mode === "range")
+ onMouseOver(targetNode);
+ }
+ function getFirstAvailableDay(delta) {
+ var startMonth = delta > 0 ? 0 : self.config.showMonths - 1;
+ var endMonth = delta > 0 ? self.config.showMonths : -1;
+ for (var m = startMonth; m != endMonth; m += delta) {
+ var month = self.daysContainer.children[m];
+ var startIndex = delta > 0 ? 0 : month.children.length - 1;
+ var endIndex = delta > 0 ? month.children.length : -1;
+ for (var i = startIndex; i != endIndex; i += delta) {
+ var c = month.children[i];
+ if (c.className.indexOf("hidden") === -1 && isEnabled(c.dateObj))
+ return c;
+ }
+ }
+ return undefined;
+ }
+ function getNextAvailableDay(current, delta) {
+ var givenMonth = current.className.indexOf("Month") === -1
+ ? current.dateObj.getMonth()
+ : self.currentMonth;
+ var endMonth = delta > 0 ? self.config.showMonths : -1;
+ var loopDelta = delta > 0 ? 1 : -1;
+ for (var m = givenMonth - self.currentMonth; m != endMonth; m += loopDelta) {
+ var month = self.daysContainer.children[m];
+ var startIndex = givenMonth - self.currentMonth === m
+ ? current.$i + delta
+ : delta < 0
+ ? month.children.length - 1
+ : 0;
+ var numMonthDays = month.children.length;
+ for (var i = startIndex; i >= 0 && i < numMonthDays && i != (delta > 0 ? numMonthDays : -1); i += loopDelta) {
+ var c = month.children[i];
+ if (c.className.indexOf("hidden") === -1 &&
+ isEnabled(c.dateObj) &&
+ Math.abs(current.$i - i) >= Math.abs(delta))
+ return focusOnDayElem(c);
+ }
+ }
+ self.changeMonth(loopDelta);
+ focusOnDay(getFirstAvailableDay(loopDelta), 0);
+ return undefined;
+ }
+ function focusOnDay(current, offset) {
+ var dayFocused = isInView(document.activeElement || document.body);
+ var startElem = current !== undefined
+ ? current
+ : dayFocused
+ ? document.activeElement
+ : self.selectedDateElem !== undefined && isInView(self.selectedDateElem)
+ ? self.selectedDateElem
+ : self.todayDateElem !== undefined && isInView(self.todayDateElem)
+ ? self.todayDateElem
+ : getFirstAvailableDay(offset > 0 ? 1 : -1);
+ if (startElem === undefined)
+ return self._input.focus();
+ if (!dayFocused)
+ return focusOnDayElem(startElem);
+ getNextAvailableDay(startElem, offset);
+ }
+ function buildMonthDays(year, month) {
+ var firstOfMonth = (new Date(year, month, 1).getDay() - self.l10n.firstDayOfWeek + 7) % 7;
+ var prevMonthDays = self.utils.getDaysInMonth((month - 1 + 12) % 12);
+ var daysInMonth = self.utils.getDaysInMonth(month), days = window.document.createDocumentFragment(), isMultiMonth = self.config.showMonths > 1, prevMonthDayClass = isMultiMonth ? "prevMonthDay hidden" : "prevMonthDay", nextMonthDayClass = isMultiMonth ? "nextMonthDay hidden" : "nextMonthDay";
+ var dayNumber = prevMonthDays + 1 - firstOfMonth, dayIndex = 0;
+ // prepend days from the ending of previous month
+ for (; dayNumber <= prevMonthDays; dayNumber++, dayIndex++) {
+ days.appendChild(createDay(prevMonthDayClass, new Date(year, month - 1, dayNumber), dayNumber, dayIndex));
+ }
+ // Start at 1 since there is no 0th day
+ for (dayNumber = 1; dayNumber <= daysInMonth; dayNumber++, dayIndex++) {
+ days.appendChild(createDay("", new Date(year, month, dayNumber), dayNumber, dayIndex));
+ }
+ // append days from the next month
+ for (var dayNum = daysInMonth + 1; dayNum <= 42 - firstOfMonth &&
+ (self.config.showMonths === 1 || dayIndex % 7 !== 0); dayNum++, dayIndex++) {
+ days.appendChild(createDay(nextMonthDayClass, new Date(year, month + 1, dayNum % daysInMonth), dayNum, dayIndex));
+ }
+ //updateNavigationCurrentMonth();
+ var dayContainer = createElement("div", "dayContainer");
+ dayContainer.appendChild(days);
+ return dayContainer;
+ }
+ function buildDays() {
+ if (self.daysContainer === undefined) {
+ return;
+ }
+ clearNode(self.daysContainer);
+ // TODO: week numbers for each month
+ if (self.weekNumbers)
+ clearNode(self.weekNumbers);
+ var frag = document.createDocumentFragment();
+ for (var i = 0; i < self.config.showMonths; i++) {
+ var d = new Date(self.currentYear, self.currentMonth, 1);
+ d.setMonth(self.currentMonth + i);
+ frag.appendChild(buildMonthDays(d.getFullYear(), d.getMonth()));
+ }
+ self.daysContainer.appendChild(frag);
+ self.days = self.daysContainer.firstChild;
+ if (self.config.mode === "range" && self.selectedDates.length === 1) {
+ onMouseOver();
+ }
+ }
+ function buildMonthSwitch() {
+ if (self.config.showMonths > 1 ||
+ self.config.monthSelectorType !== "dropdown")
+ return;
+ var shouldBuildMonth = function (month) {
+ if (self.config.minDate !== undefined &&
+ self.currentYear === self.config.minDate.getFullYear() &&
+ month < self.config.minDate.getMonth()) {
+ return false;
+ }
+ return !(self.config.maxDate !== undefined &&
+ self.currentYear === self.config.maxDate.getFullYear() &&
+ month > self.config.maxDate.getMonth());
+ };
+ self.monthsDropdownContainer.tabIndex = -1;
+ self.monthsDropdownContainer.innerHTML = "";
+ for (var i = 0; i < 12; i++) {
+ if (!shouldBuildMonth(i))
+ continue;
+ var month = createElement("option", "flatpickr-monthDropdown-month");
+ month.value = new Date(self.currentYear, i).getMonth().toString();
+ month.textContent = monthToStr(i, self.config.shorthandCurrentMonth, self.l10n);
+ month.tabIndex = -1;
+ if (self.currentMonth === i) {
+ month.selected = true;
+ }
+ self.monthsDropdownContainer.appendChild(month);
+ }
+ }
+ function buildMonth() {
+ var container = createElement("div", "flatpickr-month");
+ var monthNavFragment = window.document.createDocumentFragment();
+ var monthElement;
+ if (self.config.showMonths > 1 ||
+ self.config.monthSelectorType === "static") {
+ monthElement = createElement("span", "cur-month");
+ }
+ else {
+ self.monthsDropdownContainer = createElement("select", "flatpickr-monthDropdown-months");
+ bind(self.monthsDropdownContainer, "change", function (e) {
+ var target = e.target;
+ var selectedMonth = parseInt(target.value, 10);
+ self.changeMonth(selectedMonth - self.currentMonth);
+ triggerEvent("onMonthChange");
+ });
+ buildMonthSwitch();
+ monthElement = self.monthsDropdownContainer;
+ }
+ var yearInput = createNumberInput("cur-year", { tabindex: "-1" });
+ var yearElement = yearInput.getElementsByTagName("input")[0];
+ yearElement.setAttribute("aria-label", self.l10n.yearAriaLabel);
+ if (self.config.minDate) {
+ yearElement.setAttribute("min", self.config.minDate.getFullYear().toString());
+ }
+ if (self.config.maxDate) {
+ yearElement.setAttribute("max", self.config.maxDate.getFullYear().toString());
+ yearElement.disabled =
+ !!self.config.minDate &&
+ self.config.minDate.getFullYear() === self.config.maxDate.getFullYear();
+ }
+ var currentMonth = createElement("div", "flatpickr-current-month");
+ currentMonth.appendChild(monthElement);
+ currentMonth.appendChild(yearInput);
+ monthNavFragment.appendChild(currentMonth);
+ container.appendChild(monthNavFragment);
+ return {
+ container: container,
+ yearElement: yearElement,
+ monthElement: monthElement
+ };
+ }
+ function buildMonths() {
+ clearNode(self.monthNav);
+ self.monthNav.appendChild(self.prevMonthNav);
+ if (self.config.showMonths) {
+ self.yearElements = [];
+ self.monthElements = [];
+ }
+ for (var m = self.config.showMonths; m--;) {
+ var month = buildMonth();
+ self.yearElements.push(month.yearElement);
+ self.monthElements.push(month.monthElement);
+ self.monthNav.appendChild(month.container);
+ }
+ self.monthNav.appendChild(self.nextMonthNav);
+ }
+ function buildMonthNav() {
+ self.monthNav = createElement("div", "flatpickr-months");
+ self.yearElements = [];
+ self.monthElements = [];
+ self.prevMonthNav = createElement("span", "flatpickr-prev-month");
+ self.prevMonthNav.innerHTML = self.config.prevArrow;
+ self.nextMonthNav = createElement("span", "flatpickr-next-month");
+ self.nextMonthNav.innerHTML = self.config.nextArrow;
+ buildMonths();
+ Object.defineProperty(self, "_hidePrevMonthArrow", {
+ get: function () { return self.__hidePrevMonthArrow; },
+ set: function (bool) {
+ if (self.__hidePrevMonthArrow !== bool) {
+ toggleClass(self.prevMonthNav, "flatpickr-disabled", bool);
+ self.__hidePrevMonthArrow = bool;
+ }
+ }
+ });
+ Object.defineProperty(self, "_hideNextMonthArrow", {
+ get: function () { return self.__hideNextMonthArrow; },
+ set: function (bool) {
+ if (self.__hideNextMonthArrow !== bool) {
+ toggleClass(self.nextMonthNav, "flatpickr-disabled", bool);
+ self.__hideNextMonthArrow = bool;
+ }
+ }
+ });
+ self.currentYearElement = self.yearElements[0];
+ updateNavigationCurrentMonth();
+ return self.monthNav;
+ }
+ function buildTime() {
+ self.calendarContainer.classList.add("hasTime");
+ if (self.config.noCalendar)
+ self.calendarContainer.classList.add("noCalendar");
+ self.timeContainer = createElement("div", "flatpickr-time");
+ self.timeContainer.tabIndex = -1;
+ var separator = createElement("span", "flatpickr-time-separator", ":");
+ var hourInput = createNumberInput("flatpickr-hour", {
+ "aria-label": self.l10n.hourAriaLabel
+ });
+ self.hourElement = hourInput.getElementsByTagName("input")[0];
+ var minuteInput = createNumberInput("flatpickr-minute", {
+ "aria-label": self.l10n.minuteAriaLabel
+ });
+ self.minuteElement = minuteInput.getElementsByTagName("input")[0];
+ self.hourElement.tabIndex = self.minuteElement.tabIndex = -1;
+ self.hourElement.value = pad(self.latestSelectedDateObj
+ ? self.latestSelectedDateObj.getHours()
+ : self.config.time_24hr
+ ? self.config.defaultHour
+ : military2ampm(self.config.defaultHour));
+ self.minuteElement.value = pad(self.latestSelectedDateObj
+ ? self.latestSelectedDateObj.getMinutes()
+ : self.config.defaultMinute);
+ self.hourElement.setAttribute("step", self.config.hourIncrement.toString());
+ self.minuteElement.setAttribute("step", self.config.minuteIncrement.toString());
+ self.hourElement.setAttribute("min", self.config.time_24hr ? "0" : "1");
+ self.hourElement.setAttribute("max", self.config.time_24hr ? "23" : "12");
+ self.minuteElement.setAttribute("min", "0");
+ self.minuteElement.setAttribute("max", "59");
+ self.timeContainer.appendChild(hourInput);
+ self.timeContainer.appendChild(separator);
+ self.timeContainer.appendChild(minuteInput);
+ if (self.config.time_24hr)
+ self.timeContainer.classList.add("time24hr");
+ if (self.config.enableSeconds) {
+ self.timeContainer.classList.add("hasSeconds");
+ var secondInput = createNumberInput("flatpickr-second");
+ self.secondElement = secondInput.getElementsByTagName("input")[0];
+ self.secondElement.value = pad(self.latestSelectedDateObj
+ ? self.latestSelectedDateObj.getSeconds()
+ : self.config.defaultSeconds);
+ self.secondElement.setAttribute("step", self.minuteElement.getAttribute("step"));
+ self.secondElement.setAttribute("min", "0");
+ self.secondElement.setAttribute("max", "59");
+ self.timeContainer.appendChild(createElement("span", "flatpickr-time-separator", ":"));
+ self.timeContainer.appendChild(secondInput);
+ }
+ if (!self.config.time_24hr) {
+ // add self.amPM if appropriate
+ self.amPM = createElement("span", "flatpickr-am-pm", self.l10n.amPM[int((self.latestSelectedDateObj
+ ? self.hourElement.value
+ : self.config.defaultHour) > 11)]);
+ self.amPM.title = self.l10n.toggleTitle;
+ self.amPM.tabIndex = -1;
+ self.timeContainer.appendChild(self.amPM);
+ }
+ return self.timeContainer;
+ }
+ function buildWeekdays() {
+ if (!self.weekdayContainer)
+ self.weekdayContainer = createElement("div", "flatpickr-weekdays");
+ else
+ clearNode(self.weekdayContainer);
+ for (var i = self.config.showMonths; i--;) {
+ var container = createElement("div", "flatpickr-weekdaycontainer");
+ self.weekdayContainer.appendChild(container);
+ }
+ updateWeekdays();
+ return self.weekdayContainer;
+ }
+ function updateWeekdays() {
+ if (!self.weekdayContainer) {
+ return;
+ }
+ var firstDayOfWeek = self.l10n.firstDayOfWeek;
+ var weekdays = self.l10n.weekdays.shorthand.slice();
+ if (firstDayOfWeek > 0 && firstDayOfWeek < weekdays.length) {
+ weekdays = weekdays.splice(firstDayOfWeek, weekdays.length).concat(weekdays.splice(0, firstDayOfWeek));
+ }
+ for (var i = self.config.showMonths; i--;) {
+ self.weekdayContainer.children[i].innerHTML = "\n <span class='flatpickr-weekday'>\n " + weekdays.join("</span><span class='flatpickr-weekday'>") + "\n </span>\n ";
+ }
+ }
+ /* istanbul ignore next */
+ function buildWeeks() {
+ self.calendarContainer.classList.add("hasWeeks");
+ var weekWrapper = createElement("div", "flatpickr-weekwrapper");
+ weekWrapper.appendChild(createElement("span", "flatpickr-weekday", self.l10n.weekAbbreviation));
+ var weekNumbers = createElement("div", "flatpickr-weeks");
+ weekWrapper.appendChild(weekNumbers);
+ return {
+ weekWrapper: weekWrapper,
+ weekNumbers: weekNumbers
+ };
+ }
+ function changeMonth(value, isOffset) {
+ if (isOffset === void 0) { isOffset = true; }
+ var delta = isOffset ? value : value - self.currentMonth;
+ if ((delta < 0 && self._hidePrevMonthArrow === true) ||
+ (delta > 0 && self._hideNextMonthArrow === true))
+ return;
+ self.currentMonth += delta;
+ if (self.currentMonth < 0 || self.currentMonth > 11) {
+ self.currentYear += self.currentMonth > 11 ? 1 : -1;
+ self.currentMonth = (self.currentMonth + 12) % 12;
+ triggerEvent("onYearChange");
+ buildMonthSwitch();
+ }
+ buildDays();
+ triggerEvent("onMonthChange");
+ updateNavigationCurrentMonth();
+ }
+ function clear(triggerChangeEvent, toInitial) {
+ if (triggerChangeEvent === void 0) { triggerChangeEvent = true; }
+ if (toInitial === void 0) { toInitial = true; }
+ self.input.value = "";
+ if (self.altInput !== undefined)
+ self.altInput.value = "";
+ if (self.mobileInput !== undefined)
+ self.mobileInput.value = "";
+ self.selectedDates = [];
+ self.latestSelectedDateObj = undefined;
+ if (toInitial === true) {
+ self.currentYear = self._initialDate.getFullYear();
+ self.currentMonth = self._initialDate.getMonth();
+ }
+ self.showTimeInput = false;
+ if (self.config.enableTime === true) {
+ setDefaultHours();
+ }
+ self.redraw();
+ if (triggerChangeEvent)
+ // triggerChangeEvent is true (default) or an Event
+ triggerEvent("onChange");
+ }
+ function close() {
+ self.isOpen = false;
+ if (!self.isMobile) {
+ if (self.calendarContainer !== undefined) {
+ self.calendarContainer.classList.remove("open");
+ }
+ if (self._input !== undefined) {
+ self._input.classList.remove("active");
+ }
+ }
+ triggerEvent("onClose");
+ }
+ function destroy() {
+ if (self.config !== undefined)
+ triggerEvent("onDestroy");
+ for (var i = self._handlers.length; i--;) {
+ var h = self._handlers[i];
+ h.element.removeEventListener(h.event, h.handler, h.options);
+ }
+ self._handlers = [];
+ if (self.mobileInput) {
+ if (self.mobileInput.parentNode)
+ self.mobileInput.parentNode.removeChild(self.mobileInput);
+ self.mobileInput = undefined;
+ }
+ else if (self.calendarContainer && self.calendarContainer.parentNode) {
+ if (self.config.static && self.calendarContainer.parentNode) {
+ var wrapper = self.calendarContainer.parentNode;
+ wrapper.lastChild && wrapper.removeChild(wrapper.lastChild);
+ if (wrapper.parentNode) {
+ while (wrapper.firstChild)
+ wrapper.parentNode.insertBefore(wrapper.firstChild, wrapper);
+ wrapper.parentNode.removeChild(wrapper);
+ }
+ }
+ else
+ self.calendarContainer.parentNode.removeChild(self.calendarContainer);
+ }
+ if (self.altInput) {
+ self.input.type = "text";
+ if (self.altInput.parentNode)
+ self.altInput.parentNode.removeChild(self.altInput);
+ delete self.altInput;
+ }
+ if (self.input) {
+ self.input.type = self.input._type;
+ self.input.classList.remove("flatpickr-input");
+ self.input.removeAttribute("readonly");
+ self.input.value = "";
+ }
+ [
+ "_showTimeInput",
+ "latestSelectedDateObj",
+ "_hideNextMonthArrow",
+ "_hidePrevMonthArrow",
+ "__hideNextMonthArrow",
+ "__hidePrevMonthArrow",
+ "isMobile",
+ "isOpen",
+ "selectedDateElem",
+ "minDateHasTime",
+ "maxDateHasTime",
+ "days",
+ "daysContainer",
+ "_input",
+ "_positionElement",
+ "innerContainer",
+ "rContainer",
+ "monthNav",
+ "todayDateElem",
+ "calendarContainer",
+ "weekdayContainer",
+ "prevMonthNav",
+ "nextMonthNav",
+ "monthsDropdownContainer",
+ "currentMonthElement",
+ "currentYearElement",
+ "navigationCurrentMonth",
+ "selectedDateElem",
+ "config",
+ ].forEach(function (k) {
+ try {
+ delete self[k];
+ }
+ catch (_) { }
+ });
+ }
+ function isCalendarElem(elem) {
+ if (self.config.appendTo && self.config.appendTo.contains(elem))
+ return true;
+ return self.calendarContainer.contains(elem);
+ }
+ function documentClick(e) {
+ if (self.isOpen && !self.config.inline) {
+ var eventTarget_1 = getEventTarget(e);
+ var isCalendarElement = isCalendarElem(eventTarget_1);
+ var isInput = eventTarget_1 === self.input ||
+ eventTarget_1 === self.altInput ||
+ self.element.contains(eventTarget_1) ||
+ // web components
+ // e.path is not present in all browsers. circumventing typechecks
+ (e.path &&
+ e.path.indexOf &&
+ (~e.path.indexOf(self.input) ||
+ ~e.path.indexOf(self.altInput)));
+ var lostFocus = e.type === "blur"
+ ? isInput &&
+ e.relatedTarget &&
+ !isCalendarElem(e.relatedTarget)
+ : !isInput &&
+ !isCalendarElement &&
+ !isCalendarElem(e.relatedTarget);
+ var isIgnored = !self.config.ignoredFocusElements.some(function (elem) {
+ return elem.contains(eventTarget_1);
+ });
+ if (lostFocus && isIgnored) {
+ if (self.timeContainer !== undefined &&
+ self.minuteElement !== undefined &&
+ self.hourElement !== undefined) {
+ updateTime();
+ }
+ self.close();
+ if (self.config.mode === "range" && self.selectedDates.length === 1) {
+ self.clear(false);
+ self.redraw();
+ }
+ }
+ }
+ }
+ function changeYear(newYear) {
+ if (!newYear ||
+ (self.config.minDate && newYear < self.config.minDate.getFullYear()) ||
+ (self.config.maxDate && newYear > self.config.maxDate.getFullYear()))
+ return;
+ var newYearNum = newYear, isNewYear = self.currentYear !== newYearNum;
+ self.currentYear = newYearNum || self.currentYear;
+ if (self.config.maxDate &&
+ self.currentYear === self.config.maxDate.getFullYear()) {
+ self.currentMonth = Math.min(self.config.maxDate.getMonth(), self.currentMonth);
+ }
+ else if (self.config.minDate &&
+ self.currentYear === self.config.minDate.getFullYear()) {
+ self.currentMonth = Math.max(self.config.minDate.getMonth(), self.currentMonth);
+ }
+ if (isNewYear) {
+ self.redraw();
+ triggerEvent("onYearChange");
+ buildMonthSwitch();
+ }
+ }
+ function isEnabled(date, timeless) {
+ if (timeless === void 0) { timeless = true; }
+ var dateToCheck = self.parseDate(date, undefined, timeless); // timeless
+ if ((self.config.minDate &&
+ dateToCheck &&
+ compareDates(dateToCheck, self.config.minDate, timeless !== undefined ? timeless : !self.minDateHasTime) < 0) ||
+ (self.config.maxDate &&
+ dateToCheck &&
+ compareDates(dateToCheck, self.config.maxDate, timeless !== undefined ? timeless : !self.maxDateHasTime) > 0))
+ return false;
+ if (self.config.enable.length === 0 && self.config.disable.length === 0)
+ return true;
+ if (dateToCheck === undefined)
+ return false;
+ var bool = self.config.enable.length > 0, array = bool ? self.config.enable : self.config.disable;
+ for (var i = 0, d = void 0; i < array.length; i++) {
+ d = array[i];
+ if (typeof d === "function" &&
+ d(dateToCheck) // disabled by function
+ )
+ return bool;
+ else if (d instanceof Date &&
+ dateToCheck !== undefined &&
+ d.getTime() === dateToCheck.getTime())
+ // disabled by date
+ return bool;
+ else if (typeof d === "string" && dateToCheck !== undefined) {
+ // disabled by date string
+ var parsed = self.parseDate(d, undefined, true);
+ return parsed && parsed.getTime() === dateToCheck.getTime()
+ ? bool
+ : !bool;
+ }
+ else if (
+ // disabled by range
+ typeof d === "object" &&
+ dateToCheck !== undefined &&
+ d.from &&
+ d.to &&
+ dateToCheck.getTime() >= d.from.getTime() &&
+ dateToCheck.getTime() <= d.to.getTime())
+ return bool;
+ }
+ return !bool;
+ }
+ function isInView(elem) {
+ if (self.daysContainer !== undefined)
+ return (elem.className.indexOf("hidden") === -1 &&
+ self.daysContainer.contains(elem));
+ return false;
+ }
+ function onKeyDown(e) {
+ // e.key e.keyCode
+ // "Backspace" 8
+ // "Tab" 9
+ // "Enter" 13
+ // "Escape" (IE "Esc") 27
+ // "ArrowLeft" (IE "Left") 37
+ // "ArrowUp" (IE "Up") 38
+ // "ArrowRight" (IE "Right") 39
+ // "ArrowDown" (IE "Down") 40
+ // "Delete" (IE "Del") 46
+ var isInput = e.target === self._input;
+ var allowInput = self.config.allowInput;
+ var allowKeydown = self.isOpen && (!allowInput || !isInput);
+ var allowInlineKeydown = self.config.inline && isInput && !allowInput;
+ if (e.keyCode === 13 && isInput) {
+ if (allowInput) {
+ self.setDate(self._input.value, true, e.target === self.altInput
+ ? self.config.altFormat
+ : self.config.dateFormat);
+ return e.target.blur();
+ }
+ else {
+ self.open();
+ }
+ }
+ else if (isCalendarElem(e.target) ||
+ allowKeydown ||
+ allowInlineKeydown) {
+ var isTimeObj = !!self.timeContainer &&
+ self.timeContainer.contains(e.target);
+ switch (e.keyCode) {
+ case 13:
+ if (isTimeObj) {
+ e.preventDefault();
+ updateTime();
+ focusAndClose();
+ }
+ else
+ selectDate(e);
+ break;
+ case 27: // escape
+ e.preventDefault();
+ focusAndClose();
+ break;
+ case 8:
+ case 46:
+ if (isInput && !self.config.allowInput) {
+ e.preventDefault();
+ self.clear();
+ }
+ break;
+ case 37:
+ case 39:
+ if (!isTimeObj && !isInput) {
+ e.preventDefault();
+ if (self.daysContainer !== undefined &&
+ (allowInput === false ||
+ (document.activeElement && isInView(document.activeElement)))) {
+ var delta_1 = e.keyCode === 39 ? 1 : -1;
+ if (!e.ctrlKey)
+ focusOnDay(undefined, delta_1);
+ else {
+ e.stopPropagation();
+ changeMonth(delta_1);
+ focusOnDay(getFirstAvailableDay(1), 0);
+ }
+ }
+ }
+ else if (self.hourElement)
+ self.hourElement.focus();
+ break;
+ case 38:
+ case 40:
+ e.preventDefault();
+ var delta = e.keyCode === 40 ? 1 : -1;
+ if ((self.daysContainer && e.target.$i !== undefined) ||
+ e.target === self.input ||
+ e.target === self.altInput) {
+ if (e.ctrlKey) {
+ e.stopPropagation();
+ changeYear(self.currentYear - delta);
+ focusOnDay(getFirstAvailableDay(1), 0);
+ }
+ else if (!isTimeObj)
+ focusOnDay(undefined, delta * 7);
+ }
+ else if (e.target === self.currentYearElement) {
+ changeYear(self.currentYear - delta);
+ }
+ else if (self.config.enableTime) {
+ if (!isTimeObj && self.hourElement)
+ self.hourElement.focus();
+ updateTime(e);
+ self._debouncedChange();
+ }
+ break;
+ case 9:
+ if (isTimeObj) {
+ var elems = [
+ self.hourElement,
+ self.minuteElement,
+ self.secondElement,
+ self.amPM,
+ ]
+ .concat(self.pluginElements)
+ .filter(function (x) { return x; });
+ var i = elems.indexOf(e.target);
+ if (i !== -1) {
+ var target = elems[i + (e.shiftKey ? -1 : 1)];
+ e.preventDefault();
+ (target || self._input).focus();
+ }
+ }
+ else if (!self.config.noCalendar &&
+ self.daysContainer &&
+ self.daysContainer.contains(e.target) &&
+ e.shiftKey) {
+ e.preventDefault();
+ self._input.focus();
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ if (self.amPM !== undefined && e.target === self.amPM) {
+ switch (e.key) {
+ case self.l10n.amPM[0].charAt(0):
+ case self.l10n.amPM[0].charAt(0).toLowerCase():
+ self.amPM.textContent = self.l10n.amPM[0];
+ setHoursFromInputs();
+ updateValue();
+ break;
+ case self.l10n.amPM[1].charAt(0):
+ case self.l10n.amPM[1].charAt(0).toLowerCase():
+ self.amPM.textContent = self.l10n.amPM[1];
+ setHoursFromInputs();
+ updateValue();
+ break;
+ }
+ }
+ if (isInput || isCalendarElem(e.target)) {
+ triggerEvent("onKeyDown", e);
+ }
+ }
+ function onMouseOver(elem) {
+ if (self.selectedDates.length !== 1 ||
+ (elem &&
+ (!elem.classList.contains("flatpickr-day") ||
+ elem.classList.contains("flatpickr-disabled"))))
+ return;
+ var hoverDate = elem
+ ? elem.dateObj.getTime()
+ : self.days.firstElementChild.dateObj.getTime(), initialDate = self.parseDate(self.selectedDates[0], undefined, true).getTime(), rangeStartDate = Math.min(hoverDate, self.selectedDates[0].getTime()), rangeEndDate = Math.max(hoverDate, self.selectedDates[0].getTime());
+ var containsDisabled = false;
+ var minRange = 0, maxRange = 0;
+ for (var t = rangeStartDate; t < rangeEndDate; t += duration.DAY) {
+ if (!isEnabled(new Date(t), true)) {
+ containsDisabled =
+ containsDisabled || (t > rangeStartDate && t < rangeEndDate);
+ if (t < initialDate && (!minRange || t > minRange))
+ minRange = t;
+ else if (t > initialDate && (!maxRange || t < maxRange))
+ maxRange = t;
+ }
+ }
+ for (var m = 0; m < self.config.showMonths; m++) {
+ var month = self.daysContainer.children[m];
+ var _loop_1 = function (i, l) {
+ var dayElem = month.children[i], date = dayElem.dateObj;
+ var timestamp = date.getTime();
+ var outOfRange = (minRange > 0 && timestamp < minRange) ||
+ (maxRange > 0 && timestamp > maxRange);
+ if (outOfRange) {
+ dayElem.classList.add("notAllowed");
+ ["inRange", "startRange", "endRange"].forEach(function (c) {
+ dayElem.classList.remove(c);
+ });
+ return "continue";
+ }
+ else if (containsDisabled && !outOfRange)
+ return "continue";
+ ["startRange", "inRange", "endRange", "notAllowed"].forEach(function (c) {
+ dayElem.classList.remove(c);
+ });
+ if (elem !== undefined) {
+ elem.classList.add(hoverDate <= self.selectedDates[0].getTime()
+ ? "startRange"
+ : "endRange");
+ if (initialDate < hoverDate && timestamp === initialDate)
+ dayElem.classList.add("startRange");
+ else if (initialDate > hoverDate && timestamp === initialDate)
+ dayElem.classList.add("endRange");
+ if (timestamp >= minRange &&
+ (maxRange === 0 || timestamp <= maxRange) &&
+ isBetween(timestamp, initialDate, hoverDate))
+ dayElem.classList.add("inRange");
+ }
+ };
+ for (var i = 0, l = month.children.length; i < l; i++) {
+ _loop_1(i, l);
+ }
+ }
+ }
+ function onResize() {
+ if (self.isOpen && !self.config.static && !self.config.inline)
+ positionCalendar();
+ }
+ function setDefaultTime() {
+ self.setDate(self.config.minDate !== undefined
+ ? new Date(self.config.minDate.getTime())
+ : new Date(), true);
+ setDefaultHours();
+ updateValue();
+ }
+ function open(e, positionElement) {
+ if (positionElement === void 0) { positionElement = self._positionElement; }
+ if (self.isMobile === true) {
+ if (e) {
+ e.preventDefault();
+ e.target && e.target.blur();
+ }
+ if (self.mobileInput !== undefined) {
+ self.mobileInput.focus();
+ self.mobileInput.click();
+ }
+ triggerEvent("onOpen");
+ return;
+ }
+ if (self._input.disabled || self.config.inline)
+ return;
+ var wasOpen = self.isOpen;
+ self.isOpen = true;
+ if (!wasOpen) {
+ self.calendarContainer.classList.add("open");
+ self._input.classList.add("active");
+ triggerEvent("onOpen");
+ positionCalendar(positionElement);
+ }
+ if (self.config.enableTime === true && self.config.noCalendar === true) {
+ if (self.selectedDates.length === 0) {
+ setDefaultTime();
+ }
+ if (self.config.allowInput === false &&
+ (e === undefined ||
+ !self.timeContainer.contains(e.relatedTarget))) {
+ setTimeout(function () { return self.hourElement.select(); }, 50);
+ }
+ }
+ }
+ function minMaxDateSetter(type) {
+ return function (date) {
+ var dateObj = (self.config["_" + type + "Date"] = self.parseDate(date, self.config.dateFormat));
+ var inverseDateObj = self.config["_" + (type === "min" ? "max" : "min") + "Date"];
+ if (dateObj !== undefined) {
+ self[type === "min" ? "minDateHasTime" : "maxDateHasTime"] =
+ dateObj.getHours() > 0 ||
+ dateObj.getMinutes() > 0 ||
+ dateObj.getSeconds() > 0;
+ }
+ if (self.selectedDates) {
+ self.selectedDates = self.selectedDates.filter(function (d) { return isEnabled(d); });
+ if (!self.selectedDates.length && type === "min")
+ setHoursFromDate(dateObj);
+ updateValue();
+ }
+ if (self.daysContainer) {
+ redraw();
+ if (dateObj !== undefined)
+ self.currentYearElement[type] = dateObj.getFullYear().toString();
+ else
+ self.currentYearElement.removeAttribute(type);
+ self.currentYearElement.disabled =
+ !!inverseDateObj &&
+ dateObj !== undefined &&
+ inverseDateObj.getFullYear() === dateObj.getFullYear();
+ }
+ };
+ }
+ function parseConfig() {
+ var boolOpts = [
+ "wrap",
+ "weekNumbers",
+ "allowInput",
+ "clickOpens",
+ "time_24hr",
+ "enableTime",
+ "noCalendar",
+ "altInput",
+ "shorthandCurrentMonth",
+ "inline",
+ "static",
+ "enableSeconds",
+ "disableMobile",
+ ];
+ var userConfig = __assign({}, instanceConfig, JSON.parse(JSON.stringify(element.dataset || {})));
+ var formats = {};
+ self.config.parseDate = userConfig.parseDate;
+ self.config.formatDate = userConfig.formatDate;
+ Object.defineProperty(self.config, "enable", {
+ get: function () { return self.config._enable; },
+ set: function (dates) {
+ self.config._enable = parseDateRules(dates);
+ }
+ });
+ Object.defineProperty(self.config, "disable", {
+ get: function () { return self.config._disable; },
+ set: function (dates) {
+ self.config._disable = parseDateRules(dates);
+ }
+ });
+ var timeMode = userConfig.mode === "time";
+ if (!userConfig.dateFormat && (userConfig.enableTime || timeMode)) {
+ var defaultDateFormat = flatpickr.defaultConfig.dateFormat || defaults.dateFormat;
+ formats.dateFormat =
+ userConfig.noCalendar || timeMode
+ ? "H:i" + (userConfig.enableSeconds ? ":S" : "")
+ : defaultDateFormat + " H:i" + (userConfig.enableSeconds ? ":S" : "");
+ }
+ if (userConfig.altInput &&
+ (userConfig.enableTime || timeMode) &&
+ !userConfig.altFormat) {
+ var defaultAltFormat = flatpickr.defaultConfig.altFormat || defaults.altFormat;
+ formats.altFormat =
+ userConfig.noCalendar || timeMode
+ ? "h:i" + (userConfig.enableSeconds ? ":S K" : " K")
+ : defaultAltFormat + (" h:i" + (userConfig.enableSeconds ? ":S" : "") + " K");
+ }
+ if (!userConfig.altInputClass) {
+ self.config.altInputClass =
+ self.input.className + " " + self.config.altInputClass;
+ }
+ Object.defineProperty(self.config, "minDate", {
+ get: function () { return self.config._minDate; },
+ set: minMaxDateSetter("min")
+ });
+ Object.defineProperty(self.config, "maxDate", {
+ get: function () { return self.config._maxDate; },
+ set: minMaxDateSetter("max")
+ });
+ var minMaxTimeSetter = function (type) { return function (val) {
+ self.config[type === "min" ? "_minTime" : "_maxTime"] = self.parseDate(val, "H:i:S");
+ }; };
+ Object.defineProperty(self.config, "minTime", {
+ get: function () { return self.config._minTime; },
+ set: minMaxTimeSetter("min")
+ });
+ Object.defineProperty(self.config, "maxTime", {
+ get: function () { return self.config._maxTime; },
+ set: minMaxTimeSetter("max")
+ });
+ if (userConfig.mode === "time") {
+ self.config.noCalendar = true;
+ self.config.enableTime = true;
+ }
+ Object.assign(self.config, formats, userConfig);
+ for (var i = 0; i < boolOpts.length; i++)
+ self.config[boolOpts[i]] =
+ self.config[boolOpts[i]] === true ||
+ self.config[boolOpts[i]] === "true";
+ HOOKS.filter(function (hook) { return self.config[hook] !== undefined; }).forEach(function (hook) {
+ self.config[hook] = arrayify(self.config[hook] || []).map(bindToInstance);
+ });
+ self.isMobile =
+ !self.config.disableMobile &&
+ !self.config.inline &&
+ self.config.mode === "single" &&
+ !self.config.disable.length &&
+ !self.config.enable.length &&
+ !self.config.weekNumbers &&
+ /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
+ for (var i = 0; i < self.config.plugins.length; i++) {
+ var pluginConf = self.config.plugins[i](self) || {};
+ for (var key in pluginConf) {
+ if (HOOKS.indexOf(key) > -1) {
+ self.config[key] = arrayify(pluginConf[key])
+ .map(bindToInstance)
+ .concat(self.config[key]);
+ }
+ else if (typeof userConfig[key] === "undefined")
+ self.config[key] = pluginConf[key];
+ }
+ }
+ triggerEvent("onParseConfig");
+ }
+ function setupLocale() {
+ if (typeof self.config.locale !== "object" &&
+ typeof flatpickr.l10ns[self.config.locale] === "undefined")
+ self.config.errorHandler(new Error("flatpickr: invalid locale " + self.config.locale));
+ self.l10n = __assign({}, flatpickr.l10ns["default"], (typeof self.config.locale === "object"
+ ? self.config.locale
+ : self.config.locale !== "default"
+ ? flatpickr.l10ns[self.config.locale]
+ : undefined));
+ tokenRegex.K = "(" + self.l10n.amPM[0] + "|" + self.l10n.amPM[1] + "|" + self.l10n.amPM[0].toLowerCase() + "|" + self.l10n.amPM[1].toLowerCase() + ")";
+ var userConfig = __assign({}, instanceConfig, JSON.parse(JSON.stringify(element.dataset || {})));
+ if (userConfig.time_24hr === undefined &&
+ flatpickr.defaultConfig.time_24hr === undefined) {
+ self.config.time_24hr = self.l10n.time_24hr;
+ }
+ self.formatDate = createDateFormatter(self);
+ self.parseDate = createDateParser({ config: self.config, l10n: self.l10n });
+ }
+ function positionCalendar(customPositionElement) {
+ if (self.calendarContainer === undefined)
+ return;
+ triggerEvent("onPreCalendarPosition");
+ var positionElement = customPositionElement || self._positionElement;
+ var calendarHeight = Array.prototype.reduce.call(self.calendarContainer.children, (function (acc, child) { return acc + child.offsetHeight; }), 0), calendarWidth = self.calendarContainer.offsetWidth, configPos = self.config.position.split(" "), configPosVertical = configPos[0], configPosHorizontal = configPos.length > 1 ? configPos[1] : null, inputBounds = positionElement.getBoundingClientRect(), distanceFromBottom = window.innerHeight - inputBounds.bottom, showOnTop = configPosVertical === "above" ||
+ (configPosVertical !== "below" &&
+ distanceFromBottom < calendarHeight &&
+ inputBounds.top > calendarHeight);
+ var top = window.pageYOffset +
+ inputBounds.top +
+ (!showOnTop ? positionElement.offsetHeight + 2 : -calendarHeight - 2);
+ toggleClass(self.calendarContainer, "arrowTop", !showOnTop);
+ toggleClass(self.calendarContainer, "arrowBottom", showOnTop);
+ if (self.config.inline)
+ return;
+ var left = window.pageXOffset +
+ inputBounds.left -
+ (configPosHorizontal != null && configPosHorizontal === "center"
+ ? (calendarWidth - inputBounds.width) / 2
+ : 0);
+ var right = window.document.body.offsetWidth - (window.pageXOffset + inputBounds.right);
+ var rightMost = left + calendarWidth > window.document.body.offsetWidth;
+ var centerMost = right + calendarWidth > window.document.body.offsetWidth;
+ toggleClass(self.calendarContainer, "rightMost", rightMost);
+ if (self.config.static)
+ return;
+ self.calendarContainer.style.top = top + "px";
+ if (!rightMost) {
+ self.calendarContainer.style.left = left + "px";
+ self.calendarContainer.style.right = "auto";
+ }
+ else if (!centerMost) {
+ self.calendarContainer.style.left = "auto";
+ self.calendarContainer.style.right = right + "px";
+ }
+ else {
+ var doc = document.styleSheets[0];
+ // some testing environments don't have css support
+ if (doc === undefined)
+ return;
+ var bodyWidth = window.document.body.offsetWidth;
+ var centerLeft = Math.max(0, bodyWidth / 2 - calendarWidth / 2);
+ var centerBefore = ".flatpickr-calendar.centerMost:before";
+ var centerAfter = ".flatpickr-calendar.centerMost:after";
+ var centerIndex = doc.cssRules.length;
+ var centerStyle = "{left:" + inputBounds.left + "px;right:auto;}";
+ toggleClass(self.calendarContainer, "rightMost", false);
+ toggleClass(self.calendarContainer, "centerMost", true);
+ doc.insertRule(centerBefore + "," + centerAfter + centerStyle, centerIndex);
+ self.calendarContainer.style.left = centerLeft + "px";
+ self.calendarContainer.style.right = "auto";
+ }
+ }
+ function redraw() {
+ if (self.config.noCalendar || self.isMobile)
+ return;
+ updateNavigationCurrentMonth();
+ buildDays();
+ }
+ function focusAndClose() {
+ self._input.focus();
+ if (window.navigator.userAgent.indexOf("MSIE") !== -1 ||
+ navigator.msMaxTouchPoints !== undefined) {
+ // hack - bugs in the way IE handles focus keeps the calendar open
+ setTimeout(self.close, 0);
+ }
+ else {
+ self.close();
+ }
+ }
+ function selectDate(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ var isSelectable = function (day) {
+ return day.classList &&
+ day.classList.contains("flatpickr-day") &&
+ !day.classList.contains("flatpickr-disabled") &&
+ !day.classList.contains("notAllowed");
+ };
+ var t = findParent(e.target, isSelectable);
+ if (t === undefined)
+ return;
+ var target = t;
+ var selectedDate = (self.latestSelectedDateObj = new Date(target.dateObj.getTime()));
+ var shouldChangeMonth = (selectedDate.getMonth() < self.currentMonth ||
+ selectedDate.getMonth() >
+ self.currentMonth + self.config.showMonths - 1) &&
+ self.config.mode !== "range";
+ self.selectedDateElem = target;
+ if (self.config.mode === "single")
+ self.selectedDates = [selectedDate];
+ else if (self.config.mode === "multiple") {
+ var selectedIndex = isDateSelected(selectedDate);
+ if (selectedIndex)
+ self.selectedDates.splice(parseInt(selectedIndex), 1);
+ else
+ self.selectedDates.push(selectedDate);
+ }
+ else if (self.config.mode === "range") {
+ if (self.selectedDates.length === 2) {
+ self.clear(false, false);
+ }
+ self.latestSelectedDateObj = selectedDate;
+ self.selectedDates.push(selectedDate);
+ // unless selecting same date twice, sort ascendingly
+ if (compareDates(selectedDate, self.selectedDates[0], true) !== 0)
+ self.selectedDates.sort(function (a, b) { return a.getTime() - b.getTime(); });
+ }
+ setHoursFromInputs();
+ if (shouldChangeMonth) {
+ var isNewYear = self.currentYear !== selectedDate.getFullYear();
+ self.currentYear = selectedDate.getFullYear();
+ self.currentMonth = selectedDate.getMonth();
+ if (isNewYear) {
+ triggerEvent("onYearChange");
+ buildMonthSwitch();
+ }
+ triggerEvent("onMonthChange");
+ }
+ updateNavigationCurrentMonth();
+ buildDays();
+ updateValue();
+ if (self.config.enableTime)
+ setTimeout(function () { return (self.showTimeInput = true); }, 50);
+ // maintain focus
+ if (!shouldChangeMonth &&
+ self.config.mode !== "range" &&
+ self.config.showMonths === 1)
+ focusOnDayElem(target);
+ else if (self.selectedDateElem !== undefined &&
+ self.hourElement === undefined) {
+ self.selectedDateElem && self.selectedDateElem.focus();
+ }
+ if (self.hourElement !== undefined)
+ self.hourElement !== undefined && self.hourElement.focus();
+ if (self.config.closeOnSelect) {
+ var single = self.config.mode === "single" && !self.config.enableTime;
+ var range = self.config.mode === "range" &&
+ self.selectedDates.length === 2 &&
+ !self.config.enableTime;
+ if (single || range) {
+ focusAndClose();
+ }
+ }
+ triggerChange();
+ }
+ var CALLBACKS = {
+ locale: [setupLocale, updateWeekdays],
+ showMonths: [buildMonths, setCalendarWidth, buildWeekdays],
+ minDate: [jumpToDate],
+ maxDate: [jumpToDate]
+ };
+ function set(option, value) {
+ if (option !== null && typeof option === "object") {
+ Object.assign(self.config, option);
+ for (var key in option) {
+ if (CALLBACKS[key] !== undefined)
+ CALLBACKS[key].forEach(function (x) { return x(); });
+ }
+ }
+ else {
+ self.config[option] = value;
+ if (CALLBACKS[option] !== undefined)
+ CALLBACKS[option].forEach(function (x) { return x(); });
+ else if (HOOKS.indexOf(option) > -1)
+ self.config[option] = arrayify(value);
+ }
+ self.redraw();
+ updateValue(false);
+ }
+ function setSelectedDate(inputDate, format) {
+ var dates = [];
+ if (inputDate instanceof Array)
+ dates = inputDate.map(function (d) { return self.parseDate(d, format); });
+ else if (inputDate instanceof Date || typeof inputDate === "number")
+ dates = [self.parseDate(inputDate, format)];
+ else if (typeof inputDate === "string") {
+ switch (self.config.mode) {
+ case "single":
+ case "time":
+ dates = [self.parseDate(inputDate, format)];
+ break;
+ case "multiple":
+ dates = inputDate
+ .split(self.config.conjunction)
+ .map(function (date) { return self.parseDate(date, format); });
+ break;
+ case "range":
+ dates = inputDate
+ .split(self.l10n.rangeSeparator)
+ .map(function (date) { return self.parseDate(date, format); });
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ self.config.errorHandler(new Error("Invalid date supplied: " + JSON.stringify(inputDate)));
+ self.selectedDates = dates.filter(function (d) { return d instanceof Date && isEnabled(d, false); });
+ if (self.config.mode === "range")
+ self.selectedDates.sort(function (a, b) { return a.getTime() - b.getTime(); });
+ }
+ function setDate(date, triggerChange, format) {
+ if (triggerChange === void 0) { triggerChange = false; }
+ if (format === void 0) { format = self.config.dateFormat; }
+ if ((date !== 0 && !date) || (date instanceof Array && date.length === 0))
+ return self.clear(triggerChange);
+ setSelectedDate(date, format);
+ self.showTimeInput = self.selectedDates.length > 0;
+ self.latestSelectedDateObj =
+ self.selectedDates[self.selectedDates.length - 1];
+ self.redraw();
+ jumpToDate();
+ setHoursFromDate();
+ if (self.selectedDates.length === 0) {
+ self.clear(false);
+ }
+ updateValue(triggerChange);
+ if (triggerChange)
+ triggerEvent("onChange");
+ }
+ function parseDateRules(arr) {
+ return arr
+ .slice()
+ .map(function (rule) {
+ if (typeof rule === "string" ||
+ typeof rule === "number" ||
+ rule instanceof Date) {
+ return self.parseDate(rule, undefined, true);
+ }
+ else if (rule &&
+ typeof rule === "object" &&
+ rule.from &&
+ rule.to)
+ return {
+ from: self.parseDate(rule.from, undefined),
+ to: self.parseDate(rule.to, undefined)
+ };
+ return rule;
+ })
+ .filter(function (x) { return x; }); // remove falsy values
+ }
+ function setupDates() {
+ self.selectedDates = [];
+ self.now = self.parseDate(self.config.now) || new Date();
+ // Workaround IE11 setting placeholder as the input's value
+ var preloadedDate = self.config.defaultDate ||
+ ((self.input.nodeName === "INPUT" ||
+ self.input.nodeName === "TEXTAREA") &&
+ self.input.placeholder &&
+ self.input.value === self.input.placeholder
+ ? null
+ : self.input.value);
+ if (preloadedDate)
+ setSelectedDate(preloadedDate, self.config.dateFormat);
+ self._initialDate =
+ self.selectedDates.length > 0
+ ? self.selectedDates[0]
+ : self.config.minDate &&
+ self.config.minDate.getTime() > self.now.getTime()
+ ? self.config.minDate
+ : self.config.maxDate &&
+ self.config.maxDate.getTime() < self.now.getTime()
+ ? self.config.maxDate
+ : self.now;
+ self.currentYear = self._initialDate.getFullYear();
+ self.currentMonth = self._initialDate.getMonth();
+ if (self.selectedDates.length > 0)
+ self.latestSelectedDateObj = self.selectedDates[0];
+ if (self.config.minTime !== undefined)
+ self.config.minTime = self.parseDate(self.config.minTime, "H:i");
+ if (self.config.maxTime !== undefined)
+ self.config.maxTime = self.parseDate(self.config.maxTime, "H:i");
+ self.minDateHasTime =
+ !!self.config.minDate &&
+ (self.config.minDate.getHours() > 0 ||
+ self.config.minDate.getMinutes() > 0 ||
+ self.config.minDate.getSeconds() > 0);
+ self.maxDateHasTime =
+ !!self.config.maxDate &&
+ (self.config.maxDate.getHours() > 0 ||
+ self.config.maxDate.getMinutes() > 0 ||
+ self.config.maxDate.getSeconds() > 0);
+ Object.defineProperty(self, "showTimeInput", {
+ get: function () { return self._showTimeInput; },
+ set: function (bool) {
+ self._showTimeInput = bool;
+ if (self.calendarContainer)
+ toggleClass(self.calendarContainer, "showTimeInput", bool);
+ self.isOpen && positionCalendar();
+ }
+ });
+ }
+ function setupInputs() {
+ self.input = self.config.wrap
+ ? element.querySelector("[data-input]")
+ : element;
+ /* istanbul ignore next */
+ if (!self.input) {
+ self.config.errorHandler(new Error("Invalid input element specified"));
+ return;
+ }
+ // hack: store previous type to restore it after destroy()
+ self.input._type = self.input.type;
+ self.input.type = "text";
+ self.input.classList.add("flatpickr-input");
+ self._input = self.input;
+ if (self.config.altInput) {
+ // replicate self.element
+ self.altInput = createElement(self.input.nodeName, self.config.altInputClass);
+ self._input = self.altInput;
+ self.altInput.placeholder = self.input.placeholder;
+ self.altInput.disabled = self.input.disabled;
+ self.altInput.required = self.input.required;
+ self.altInput.tabIndex = self.input.tabIndex;
+ self.altInput.type = "text";
+ self.input.setAttribute("type", "hidden");
+ if (!self.config.static && self.input.parentNode)
+ self.input.parentNode.insertBefore(self.altInput, self.input.nextSibling);
+ }
+ if (!self.config.allowInput)
+ self._input.setAttribute("readonly", "readonly");
+ self._positionElement = self.config.positionElement || self._input;
+ }
+ function setupMobile() {
+ var inputType = self.config.enableTime
+ ? self.config.noCalendar
+ ? "time"
+ : "datetime-local"
+ : "date";
+ self.mobileInput = createElement("input", self.input.className + " flatpickr-mobile");
+ self.mobileInput.step = self.input.getAttribute("step") || "any";
+ self.mobileInput.tabIndex = 1;
+ self.mobileInput.type = inputType;
+ self.mobileInput.disabled = self.input.disabled;
+ self.mobileInput.required = self.input.required;
+ self.mobileInput.placeholder = self.input.placeholder;
+ self.mobileFormatStr =
+ inputType === "datetime-local"
+ ? "Y-m-d\\TH:i:S"
+ : inputType === "date"
+ ? "Y-m-d"
+ : "H:i:S";
+ if (self.selectedDates.length > 0) {
+ self.mobileInput.defaultValue = self.mobileInput.value = self.formatDate(self.selectedDates[0], self.mobileFormatStr);
+ }
+ if (self.config.minDate)
+ self.mobileInput.min = self.formatDate(self.config.minDate, "Y-m-d");
+ if (self.config.maxDate)
+ self.mobileInput.max = self.formatDate(self.config.maxDate, "Y-m-d");
+ self.input.type = "hidden";
+ if (self.altInput !== undefined)
+ self.altInput.type = "hidden";
+ try {
+ if (self.input.parentNode)
+ self.input.parentNode.insertBefore(self.mobileInput, self.input.nextSibling);
+ }
+ catch (_a) { }
+ bind(self.mobileInput, "change", function (e) {
+ self.setDate(e.target.value, false, self.mobileFormatStr);
+ triggerEvent("onChange");
+ triggerEvent("onClose");
+ });
+ }
+ function toggle(e) {
+ if (self.isOpen === true)
+ return self.close();
+ self.open(e);
+ }
+ function triggerEvent(event, data) {
+ // If the instance has been destroyed already, all hooks have been removed
+ if (self.config === undefined)
+ return;
+ var hooks = self.config[event];
+ if (hooks !== undefined && hooks.length > 0) {
+ for (var i = 0; hooks[i] && i < hooks.length; i++)
+ hooks[i](self.selectedDates, self.input.value, self, data);
+ }
+ if (event === "onChange") {
+ self.input.dispatchEvent(createEvent("change"));
+ // many front-end frameworks bind to the input event
+ self.input.dispatchEvent(createEvent("input"));
+ }
+ }
+ function createEvent(name) {
+ var e = document.createEvent("Event");
+ e.initEvent(name, true, true);
+ return e;
+ }
+ function isDateSelected(date) {
+ for (var i = 0; i < self.selectedDates.length; i++) {
+ if (compareDates(self.selectedDates[i], date) === 0)
+ return "" + i;
+ }
+ return false;
+ }
+ function isDateInRange(date) {
+ if (self.config.mode !== "range" || self.selectedDates.length < 2)
+ return false;
+ return (compareDates(date, self.selectedDates[0]) >= 0 &&
+ compareDates(date, self.selectedDates[1]) <= 0);
+ }
+ function updateNavigationCurrentMonth() {
+ if (self.config.noCalendar || self.isMobile || !self.monthNav)
+ return;
+ self.yearElements.forEach(function (yearElement, i) {
+ var d = new Date(self.currentYear, self.currentMonth, 1);
+ d.setMonth(self.currentMonth + i);
+ if (self.config.showMonths > 1 ||
+ self.config.monthSelectorType === "static") {
+ self.monthElements[i].textContent =
+ monthToStr(d.getMonth(), self.config.shorthandCurrentMonth, self.l10n) + " ";
+ }
+ else {
+ self.monthsDropdownContainer.value = d.getMonth().toString();
+ }
+ yearElement.value = d.getFullYear().toString();
+ });
+ self._hidePrevMonthArrow =
+ self.config.minDate !== undefined &&
+ (self.currentYear === self.config.minDate.getFullYear()
+ ? self.currentMonth <= self.config.minDate.getMonth()
+ : self.currentYear < self.config.minDate.getFullYear());
+ self._hideNextMonthArrow =
+ self.config.maxDate !== undefined &&
+ (self.currentYear === self.config.maxDate.getFullYear()
+ ? self.currentMonth + 1 > self.config.maxDate.getMonth()
+ : self.currentYear > self.config.maxDate.getFullYear());
+ }
+ function getDateStr(format) {
+ return self.selectedDates
+ .map(function (dObj) { return self.formatDate(dObj, format); })
+ .filter(function (d, i, arr) {
+ return self.config.mode !== "range" ||
+ self.config.enableTime ||
+ arr.indexOf(d) === i;
+ })
+ .join(self.config.mode !== "range"
+ ? self.config.conjunction
+ : self.l10n.rangeSeparator);
+ }
+ /**
+ * Updates the values of inputs associated with the calendar
+ */
+ function updateValue(triggerChange) {
+ if (triggerChange === void 0) { triggerChange = true; }
+ if (self.mobileInput !== undefined && self.mobileFormatStr) {
+ self.mobileInput.value =
+ self.latestSelectedDateObj !== undefined
+ ? self.formatDate(self.latestSelectedDateObj, self.mobileFormatStr)
+ : "";
+ }
+ self.input.value = getDateStr(self.config.dateFormat);
+ if (self.altInput !== undefined) {
+ self.altInput.value = getDateStr(self.config.altFormat);
+ }
+ if (triggerChange !== false)
+ triggerEvent("onValueUpdate");
+ }
+ function onMonthNavClick(e) {
+ var isPrevMonth = self.prevMonthNav.contains(e.target);
+ var isNextMonth = self.nextMonthNav.contains(e.target);
+ if (isPrevMonth || isNextMonth) {
+ changeMonth(isPrevMonth ? -1 : 1);
+ }
+ else if (self.yearElements.indexOf(e.target) >= 0) {
+ e.target.select();
+ }
+ else if (e.target.classList.contains("arrowUp")) {
+ self.changeYear(self.currentYear + 1);
+ }
+ else if (e.target.classList.contains("arrowDown")) {
+ self.changeYear(self.currentYear - 1);
+ }
+ }
+ function timeWrapper(e) {
+ e.preventDefault();
+ var isKeyDown = e.type === "keydown", input = e.target;
+ if (self.amPM !== undefined && e.target === self.amPM) {
+ self.amPM.textContent =
+ self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
+ }
+ var min = parseFloat(input.getAttribute("min")), max = parseFloat(input.getAttribute("max")), step = parseFloat(input.getAttribute("step")), curValue = parseInt(input.value, 10), delta = e.delta ||
+ (isKeyDown ? (e.which === 38 ? 1 : -1) : 0);
+ var newValue = curValue + step * delta;
+ if (typeof input.value !== "undefined" && input.value.length === 2) {
+ var isHourElem = input === self.hourElement, isMinuteElem = input === self.minuteElement;
+ if (newValue < min) {
+ newValue =
+ max +
+ newValue +
+ int(!isHourElem) +
+ (int(isHourElem) && int(!self.amPM));
+ if (isMinuteElem)
+ incrementNumInput(undefined, -1, self.hourElement);
+ }
+ else if (newValue > max) {
+ newValue =
+ input === self.hourElement ? newValue - max - int(!self.amPM) : min;
+ if (isMinuteElem)
+ incrementNumInput(undefined, 1, self.hourElement);
+ }
+ if (self.amPM &&
+ isHourElem &&
+ (step === 1
+ ? newValue + curValue === 23
+ : Math.abs(newValue - curValue) > step)) {
+ self.amPM.textContent =
+ self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
+ }
+ input.value = pad(newValue);
+ }
+ }
+ init();
+ return self;
+ }
+ /* istanbul ignore next */
+ function _flatpickr(nodeList, config) {
+ // static list
+ var nodes = Array.prototype.slice
+ .call(nodeList)
+ .filter(function (x) { return x instanceof HTMLElement; });
+ var instances = [];
+ for (var i = 0; i < nodes.length; i++) {
+ var node = nodes[i];
+ try {
+ if (node.getAttribute("data-fp-omit") !== null)
+ continue;
+ if (node._flatpickr !== undefined) {
+ node._flatpickr.destroy();
+ node._flatpickr = undefined;
+ }
+ node._flatpickr = FlatpickrInstance(node, config || {});
+ instances.push(node._flatpickr);
+ }
+ catch (e) {
+ console.error(e);
+ }
+ }
+ return instances.length === 1 ? instances[0] : instances;
+ }
+ /* istanbul ignore next */
+ if (typeof HTMLElement !== "undefined" &&
+ typeof HTMLCollection !== "undefined" &&
+ typeof NodeList !== "undefined") {
+ // browser env
+ HTMLCollection.prototype.flatpickr = NodeList.prototype.flatpickr = function (config) {
+ return _flatpickr(this, config);
+ };
+ HTMLElement.prototype.flatpickr = function (config) {
+ return _flatpickr([this], config);
+ };
+ }
+ /* istanbul ignore next */
+ var flatpickr = function (selector, config) {
+ if (typeof selector === "string") {
+ return _flatpickr(window.document.querySelectorAll(selector), config);
+ }
+ else if (selector instanceof Node) {
+ return _flatpickr([selector], config);
+ }
+ else {
+ return _flatpickr(selector, config);
+ }
+ };
+ /* istanbul ignore next */
+ flatpickr.defaultConfig = {};
+ flatpickr.l10ns = {
+ en: __assign({}, english),
+ "default": __assign({}, english)
+ };
+ flatpickr.localize = function (l10n) {
+ flatpickr.l10ns["default"] = __assign({}, flatpickr.l10ns["default"], l10n);
+ };
+ flatpickr.setDefaults = function (config) {
+ flatpickr.defaultConfig = __assign({}, flatpickr.defaultConfig, config);
+ };
+ flatpickr.parseDate = createDateParser({});
+ flatpickr.formatDate = createDateFormatter({});
+ flatpickr.compareDates = compareDates;
+ /* istanbul ignore next */
+ if (typeof jQuery !== "undefined" && typeof jQuery.fn !== "undefined") {
+ jQuery.fn.flatpickr = function (config) {
+ return _flatpickr(this, config);
+ };
+ }
+ // eslint-disable-next-line @typescript-eslint/camelcase
+ Date.prototype.fp_incr = function (days) {
+ return new Date(this.getFullYear(), this.getMonth(), this.getDate() + (typeof days === "string" ? parseInt(days, 10) : days));
+ };
+ if (typeof window !== "undefined") {
+ window.flatpickr = flatpickr;
+ }
+
+ return flatpickr;
+
+}));
diff --git a/public/js/vendor/flatpickr.min.js b/public/js/vendor/flatpickr.min.js
new file mode 100644
index 0000000..c850b7c
--- /dev/null
+++ b/public/js/vendor/flatpickr.min.js
@@ -0,0 +1,2 @@
+/* flatpickr v4.6.3,, @license MIT */
+!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).flatpickr=t()}(this,function(){"use strict";var e=function(){return(e=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},t=["onChange","onClose","onDayCreate","onDestroy","onKeyDown","onMonthChange","onOpen","onParseConfig","onReady","onValueUpdate","onYearChange","onPreCalendarPosition"],n={_disable:[],_enable:[],allowInput:!1,altFormat:"F j, Y",altInput:!1,altInputClass:"form-control input",animate:"object"==typeof window&&-1===window.navigator.userAgent.indexOf("MSIE"),ariaDateFormat:"F j, Y",clickOpens:!0,closeOnSelect:!0,conjunction:", ",dateFormat:"Y-m-d",defaultHour:12,defaultMinute:0,defaultSeconds:0,disable:[],disableMobile:!1,enable:[],enableSeconds:!1,enableTime:!1,errorHandler:function(e){return"undefined"!=typeof console&&console.warn(e)},getWeek:function(e){var t=new Date(e.getTime());t.setHours(0,0,0,0),t.setDate(t.getDate()+3-(t.getDay()+6)%7);var n=new Date(t.getFullYear(),0,4);return 1+Math.round(((t.getTime()-n.getTime())/864e5-3+(n.getDay()+6)%7)/7)},hourIncrement:1,ignoredFocusElements:[],inline:!1,locale:"default",minuteIncrement:5,mode:"single",monthSelectorType:"dropdown",nextArrow:"<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M13.207 8.472l-7.854 7.854-0.707-0.707 7.146-7.146-7.146-7.148 0.707-0.707 7.854 7.854z' /></svg>",noCalendar:!1,now:new Date,onChange:[],onClose:[],onDayCreate:[],onDestroy:[],onKeyDown:[],onMonthChange:[],onOpen:[],onParseConfig:[],onReady:[],onValueUpdate:[],onYearChange:[],onPreCalendarPosition:[],plugins:[],position:"auto",positionElement:void 0,prevArrow:"<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M5.207 8.471l7.146 7.147-0.707 0.707-7.853-7.854 7.854-7.853 0.707 0.707-7.147 7.146z' /></svg>",shorthandCurrentMonth:!1,showMonths:1,static:!1,time_24hr:!1,weekNumbers:!1,wrap:!1},a={weekdays:{shorthand:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longhand:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},months:{shorthand:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longhand:["January","February","March","April","May","June","July","August","September","October","November","December"]},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0,ordinal:function(e){var t=e%100;if(t>3&&t<21)return"th";switch(t%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}},rangeSeparator:" to ",weekAbbreviation:"Wk",scrollTitle:"Scroll to increment",toggleTitle:"Click to toggle",amPM:["AM","PM"],yearAriaLabel:"Year",hourAriaLabel:"Hour",minuteAriaLabel:"Minute",time_24hr:!1},i=function(e){return("0"+e).slice(-2)},o=function(e){return!0===e?1:0};function r(e,t,n){var a;return void 0===n&&(n=!1),function(){var i=this,o=arguments;null!==a&&clearTimeout(a),a=window.setTimeout(function(){a=null,n||e.apply(i,o)},t),n&&!a&&e.apply(i,o)}}var l=function(e){return e instanceof Array?e:[e]};function c(e,t,n){if(!0===n)return e.classList.add(t);e.classList.remove(t)}function d(e,t,n){var a=window.document.createElement(e);return t=t||"",n=n||"",a.className=t,void 0!==n&&(a.textContent=n),a}function s(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function u(e,t){var n=d("div","numInputWrapper"),a=d("input","numInput "+e),i=d("span","arrowUp"),o=d("span","arrowDown");if(-1===navigator.userAgent.indexOf("MSIE 9.0")?a.type="number":(a.type="text",a.pattern="\\d*"),void 0!==t)for(var r in t)a.setAttribute(r,t[r]);return n.appendChild(a),n.appendChild(i),n.appendChild(o),n}var f=function(){},m=function(e,t,n){return n.months[t?"shorthand":"longhand"][e]},g={D:f,F:function(e,t,n){e.setMonth(n.months.longhand.indexOf(t))},G:function(e,t){e.setHours(parseFloat(t))},H:function(e,t){e.setHours(parseFloat(t))},J:function(e,t){e.setDate(parseFloat(t))},K:function(e,t,n){e.setHours(e.getHours()%12+12*o(new RegExp(n.amPM[1],"i").test(t)))},M:function(e,t,n){e.setMonth(n.months.shorthand.indexOf(t))},S:function(e,t){e.setSeconds(parseFloat(t))},U:function(e,t){return new Date(1e3*parseFloat(t))},W:function(e,t,n){var a=parseInt(t),i=new Date(e.getFullYear(),0,2+7*(a-1),0,0,0,0);return i.setDate(i.getDate()-i.getDay()+n.firstDayOfWeek),i},Y:function(e,t){e.setFullYear(parseFloat(t))},Z:function(e,t){return new Date(t)},d:function(e,t){e.setDate(parseFloat(t))},h:function(e,t){e.setHours(parseFloat(t))},i:function(e,t){e.setMinutes(parseFloat(t))},j:function(e,t){e.setDate(parseFloat(t))},l:f,m:function(e,t){e.setMonth(parseFloat(t)-1)},n:function(e,t){e.setMonth(parseFloat(t)-1)},s:function(e,t){e.setSeconds(parseFloat(t))},u:function(e,t){return new Date(parseFloat(t))},w:f,y:function(e,t){e.setFullYear(2e3+parseFloat(t))}},p={D:"(\\w+)",F:"(\\w+)",G:"(\\d\\d|\\d)",H:"(\\d\\d|\\d)",J:"(\\d\\d|\\d)\\w+",K:"",M:"(\\w+)",S:"(\\d\\d|\\d)",U:"(.+)",W:"(\\d\\d|\\d)",Y:"(\\d{4})",Z:"(.+)",d:"(\\d\\d|\\d)",h:"(\\d\\d|\\d)",i:"(\\d\\d|\\d)",j:"(\\d\\d|\\d)",l:"(\\w+)",m:"(\\d\\d|\\d)",n:"(\\d\\d|\\d)",s:"(\\d\\d|\\d)",u:"(.+)",w:"(\\d\\d|\\d)",y:"(\\d{2})"},h={Z:function(e){return e.toISOString()},D:function(e,t,n){return t.weekdays.shorthand[h.w(e,t,n)]},F:function(e,t,n){return m(h.n(e,t,n)-1,!1,t)},G:function(e,t,n){return i(h.h(e,t,n))},H:function(e){return i(e.getHours())},J:function(e,t){return void 0!==t.ordinal?e.getDate()+t.ordinal(e.getDate()):e.getDate()},K:function(e,t){return t.amPM[o(e.getHours()>11)]},M:function(e,t){return m(e.getMonth(),!0,t)},S:function(e){return i(e.getSeconds())},U:function(e){return e.getTime()/1e3},W:function(e,t,n){return n.getWeek(e)},Y:function(e){return e.getFullYear()},d:function(e){return i(e.getDate())},h:function(e){return e.getHours()%12?e.getHours()%12:12},i:function(e){return i(e.getMinutes())},j:function(e){return e.getDate()},l:function(e,t){return t.weekdays.longhand[e.getDay()]},m:function(e){return i(e.getMonth()+1)},n:function(e){return e.getMonth()+1},s:function(e){return e.getSeconds()},u:function(e){return e.getTime()},w:function(e){return e.getDay()},y:function(e){return String(e.getFullYear()).substring(2)}},v=function(e){var t=e.config,i=void 0===t?n:t,o=e.l10n,r=void 0===o?a:o;return function(e,t,n){var a=n||r;return void 0!==i.formatDate?i.formatDate(e,t,a):t.split("").map(function(t,n,o){return h[t]&&"\\"!==o[n-1]?h[t](e,a,i):"\\"!==t?t:""}).join("")}},D=function(e){var t=e.config,i=void 0===t?n:t,o=e.l10n,r=void 0===o?a:o;return function(e,t,a,o){if(0===e||e){var l,c=o||r,d=e;if(e instanceof Date)l=new Date(e.getTime());else if("string"!=typeof e&&void 0!==e.toFixed)l=new Date(e);else if("string"==typeof e){var s=t||(i||n).dateFormat,u=String(e).trim();if("today"===u)l=new Date,a=!0;else if(/Z$/.test(u)||/GMT$/.test(u))l=new Date(e);else if(i&&i.parseDate)l=i.parseDate(e,s);else{l=i&&i.noCalendar?new Date((new Date).setHours(0,0,0,0)):new Date((new Date).getFullYear(),0,1,0,0,0,0);for(var f=void 0,m=[],h=0,v=0,D="";h<s.length;h++){var w=s[h],b="\\"===w,C="\\"===s[h-1]||b;if(p[w]&&!C){D+=p[w];var M=new RegExp(D).exec(e);M&&(f=!0)&&m["Y"!==w?"push":"unshift"]({fn:g[w],val:M[++v]})}else b||(D+=".");m.forEach(function(e){var t=e.fn,n=e.val;return l=t(l,n,c)||l})}l=f?l:void 0}}if(l instanceof Date&&!isNaN(l.getTime()))return!0===a&&l.setHours(0,0,0,0),l;i.errorHandler(new Error("Invalid date provided: "+d))}}};function w(e,t,n){return void 0===n&&(n=!0),!1!==n?new Date(e.getTime()).setHours(0,0,0,0)-new Date(t.getTime()).setHours(0,0,0,0):e.getTime()-t.getTime()}var b=function(e,t,n){return e>Math.min(t,n)&&e<Math.max(t,n)},C={DAY:864e5};"function"!=typeof Object.assign&&(Object.assign=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(!e)throw TypeError("Cannot convert undefined or null to object");for(var a=function(t){t&&Object.keys(t).forEach(function(n){return e[n]=t[n]})},i=0,o=t;i<o.length;i++){a(o[i])}return e});var M=300;function y(f,g){var h={config:e({},n,E.defaultConfig),l10n:a};function y(e){return e.bind(h)}function x(){var e=h.config;!1===e.weekNumbers&&1===e.showMonths||!0!==e.noCalendar&&window.requestAnimationFrame(function(){if(void 0!==h.calendarContainer&&(h.calendarContainer.style.visibility="hidden",h.calendarContainer.style.display="block"),void 0!==h.daysContainer){var t=(h.days.offsetWidth+1)*e.showMonths;h.daysContainer.style.width=t+"px",h.calendarContainer.style.width=t+(void 0!==h.weekWrapper?h.weekWrapper.offsetWidth:0)+"px",h.calendarContainer.style.removeProperty("visibility"),h.calendarContainer.style.removeProperty("display")}})}function T(e){0===h.selectedDates.length&&ie(),void 0!==e&&"blur"!==e.type&&function(e){e.preventDefault();var t="keydown"===e.type,n=e.target;void 0!==h.amPM&&e.target===h.amPM&&(h.amPM.textContent=h.l10n.amPM[o(h.amPM.textContent===h.l10n.amPM[0])]);var a=parseFloat(n.getAttribute("min")),r=parseFloat(n.getAttribute("max")),l=parseFloat(n.getAttribute("step")),c=parseInt(n.value,10),d=e.delta||(t?38===e.which?1:-1:0),s=c+l*d;if(void 0!==n.value&&2===n.value.length){var u=n===h.hourElement,f=n===h.minuteElement;s<a?(s=r+s+o(!u)+(o(u)&&o(!h.amPM)),f&&j(void 0,-1,h.hourElement)):s>r&&(s=n===h.hourElement?s-r-o(!h.amPM):a,f&&j(void 0,1,h.hourElement)),h.amPM&&u&&(1===l?s+c===23:Math.abs(s-c)>l)&&(h.amPM.textContent=h.l10n.amPM[o(h.amPM.textContent===h.l10n.amPM[0])]),n.value=i(s)}}(e);var t=h._input.value;k(),we(),h._input.value!==t&&h._debouncedChange()}function k(){if(void 0!==h.hourElement&&void 0!==h.minuteElement){var e,t,n=(parseInt(h.hourElement.value.slice(-2),10)||0)%24,a=(parseInt(h.minuteElement.value,10)||0)%60,i=void 0!==h.secondElement?(parseInt(h.secondElement.value,10)||0)%60:0;void 0!==h.amPM&&(e=n,t=h.amPM.textContent,n=e%12+12*o(t===h.l10n.amPM[1]));var r=void 0!==h.config.minTime||h.config.minDate&&h.minDateHasTime&&h.latestSelectedDateObj&&0===w(h.latestSelectedDateObj,h.config.minDate,!0);if(void 0!==h.config.maxTime||h.config.maxDate&&h.maxDateHasTime&&h.latestSelectedDateObj&&0===w(h.latestSelectedDateObj,h.config.maxDate,!0)){var l=void 0!==h.config.maxTime?h.config.maxTime:h.config.maxDate;(n=Math.min(n,l.getHours()))===l.getHours()&&(a=Math.min(a,l.getMinutes())),a===l.getMinutes()&&(i=Math.min(i,l.getSeconds()))}if(r){var c=void 0!==h.config.minTime?h.config.minTime:h.config.minDate;(n=Math.max(n,c.getHours()))===c.getHours()&&(a=Math.max(a,c.getMinutes())),a===c.getMinutes()&&(i=Math.max(i,c.getSeconds()))}O(n,a,i)}}function I(e){var t=e||h.latestSelectedDateObj;t&&O(t.getHours(),t.getMinutes(),t.getSeconds())}function S(){var e=h.config.defaultHour,t=h.config.defaultMinute,n=h.config.defaultSeconds;if(void 0!==h.config.minDate){var a=h.config.minDate.getHours(),i=h.config.minDate.getMinutes();(e=Math.max(e,a))===a&&(t=Math.max(i,t)),e===a&&t===i&&(n=h.config.minDate.getSeconds())}if(void 0!==h.config.maxDate){var o=h.config.maxDate.getHours(),r=h.config.maxDate.getMinutes();(e=Math.min(e,o))===o&&(t=Math.min(r,t)),e===o&&t===r&&(n=h.config.maxDate.getSeconds())}O(e,t,n)}function O(e,t,n){void 0!==h.latestSelectedDateObj&&h.latestSelectedDateObj.setHours(e%24,t,n||0,0),h.hourElement&&h.minuteElement&&!h.isMobile&&(h.hourElement.value=i(h.config.time_24hr?e:(12+e)%12+12*o(e%12==0)),h.minuteElement.value=i(t),void 0!==h.amPM&&(h.amPM.textContent=h.l10n.amPM[o(e>=12)]),void 0!==h.secondElement&&(h.secondElement.value=i(n)))}function _(e){var t=parseInt(e.target.value)+(e.delta||0);(t/1e3>1||"Enter"===e.key&&!/[^\d]/.test(t.toString()))&&Q(t)}function F(e,t,n,a){return t instanceof Array?t.forEach(function(t){return F(e,t,n,a)}):e instanceof Array?e.forEach(function(e){return F(e,t,n,a)}):(e.addEventListener(t,n,a),void h._handlers.push({element:e,event:t,handler:n,options:a}))}function N(e){return function(t){1===t.which&&e(t)}}function Y(){ge("onChange")}function A(e,t){var n=void 0!==e?h.parseDate(e):h.latestSelectedDateObj||(h.config.minDate&&h.config.minDate>h.now?h.config.minDate:h.config.maxDate&&h.config.maxDate<h.now?h.config.maxDate:h.now),a=h.currentYear,i=h.currentMonth;try{void 0!==n&&(h.currentYear=n.getFullYear(),h.currentMonth=n.getMonth())}catch(e){e.message="Invalid date supplied: "+n,h.config.errorHandler(e)}t&&h.currentYear!==a&&(ge("onYearChange"),K()),!t||h.currentYear===a&&h.currentMonth===i||ge("onMonthChange"),h.redraw()}function P(e){~e.target.className.indexOf("arrow")&&j(e,e.target.classList.contains("arrowUp")?1:-1)}function j(e,t,n){var a=e&&e.target,i=n||a&&a.parentNode&&a.parentNode.firstChild,o=pe("increment");o.delta=t,i&&i.dispatchEvent(o)}function H(e,t,n,a){var i=X(t,!0),o=d("span","flatpickr-day "+e,t.getDate().toString());return o.dateObj=t,o.$i=a,o.setAttribute("aria-label",h.formatDate(t,h.config.ariaDateFormat)),-1===e.indexOf("hidden")&&0===w(t,h.now)&&(h.todayDateElem=o,o.classList.add("today"),o.setAttribute("aria-current","date")),i?(o.tabIndex=-1,he(t)&&(o.classList.add("selected"),h.selectedDateElem=o,"range"===h.config.mode&&(c(o,"startRange",h.selectedDates[0]&&0===w(t,h.selectedDates[0],!0)),c(o,"endRange",h.selectedDates[1]&&0===w(t,h.selectedDates[1],!0)),"nextMonthDay"===e&&o.classList.add("inRange")))):o.classList.add("flatpickr-disabled"),"range"===h.config.mode&&function(e){return!("range"!==h.config.mode||h.selectedDates.length<2)&&w(e,h.selectedDates[0])>=0&&w(e,h.selectedDates[1])<=0}(t)&&!he(t)&&o.classList.add("inRange"),h.weekNumbers&&1===h.config.showMonths&&"prevMonthDay"!==e&&n%7==1&&h.weekNumbers.insertAdjacentHTML("beforeend","<span class='flatpickr-day'>"+h.config.getWeek(t)+"</span>"),ge("onDayCreate",o),o}function L(e){e.focus(),"range"===h.config.mode&&ne(e)}function W(e){for(var t=e>0?0:h.config.showMonths-1,n=e>0?h.config.showMonths:-1,a=t;a!=n;a+=e)for(var i=h.daysContainer.children[a],o=e>0?0:i.children.length-1,r=e>0?i.children.length:-1,l=o;l!=r;l+=e){var c=i.children[l];if(-1===c.className.indexOf("hidden")&&X(c.dateObj))return c}}function R(e,t){var n=ee(document.activeElement||document.body),a=void 0!==e?e:n?document.activeElement:void 0!==h.selectedDateElem&&ee(h.selectedDateElem)?h.selectedDateElem:void 0!==h.todayDateElem&&ee(h.todayDateElem)?h.todayDateElem:W(t>0?1:-1);return void 0===a?h._input.focus():n?void function(e,t){for(var n=-1===e.className.indexOf("Month")?e.dateObj.getMonth():h.currentMonth,a=t>0?h.config.showMonths:-1,i=t>0?1:-1,o=n-h.currentMonth;o!=a;o+=i)for(var r=h.daysContainer.children[o],l=n-h.currentMonth===o?e.$i+t:t<0?r.children.length-1:0,c=r.children.length,d=l;d>=0&&d<c&&d!=(t>0?c:-1);d+=i){var s=r.children[d];if(-1===s.className.indexOf("hidden")&&X(s.dateObj)&&Math.abs(e.$i-d)>=Math.abs(t))return L(s)}h.changeMonth(i),R(W(i),0)}(a,t):L(a)}function B(e,t){for(var n=(new Date(e,t,1).getDay()-h.l10n.firstDayOfWeek+7)%7,a=h.utils.getDaysInMonth((t-1+12)%12),i=h.utils.getDaysInMonth(t),o=window.document.createDocumentFragment(),r=h.config.showMonths>1,l=r?"prevMonthDay hidden":"prevMonthDay",c=r?"nextMonthDay hidden":"nextMonthDay",s=a+1-n,u=0;s<=a;s++,u++)o.appendChild(H(l,new Date(e,t-1,s),s,u));for(s=1;s<=i;s++,u++)o.appendChild(H("",new Date(e,t,s),s,u));for(var f=i+1;f<=42-n&&(1===h.config.showMonths||u%7!=0);f++,u++)o.appendChild(H(c,new Date(e,t+1,f%i),f,u));var m=d("div","dayContainer");return m.appendChild(o),m}function J(){if(void 0!==h.daysContainer){s(h.daysContainer),h.weekNumbers&&s(h.weekNumbers);for(var e=document.createDocumentFragment(),t=0;t<h.config.showMonths;t++){var n=new Date(h.currentYear,h.currentMonth,1);n.setMonth(h.currentMonth+t),e.appendChild(B(n.getFullYear(),n.getMonth()))}h.daysContainer.appendChild(e),h.days=h.daysContainer.firstChild,"range"===h.config.mode&&1===h.selectedDates.length&&ne()}}function K(){if(!(h.config.showMonths>1||"dropdown"!==h.config.monthSelectorType)){var e=function(e){return!(void 0!==h.config.minDate&&h.currentYear===h.config.minDate.getFullYear()&&e<h.config.minDate.getMonth())&&!(void 0!==h.config.maxDate&&h.currentYear===h.config.maxDate.getFullYear()&&e>h.config.maxDate.getMonth())};h.monthsDropdownContainer.tabIndex=-1,h.monthsDropdownContainer.innerHTML="";for(var t=0;t<12;t++)if(e(t)){var n=d("option","flatpickr-monthDropdown-month");n.value=new Date(h.currentYear,t).getMonth().toString(),n.textContent=m(t,h.config.shorthandCurrentMonth,h.l10n),n.tabIndex=-1,h.currentMonth===t&&(n.selected=!0),h.monthsDropdownContainer.appendChild(n)}}}function U(){var e,t=d("div","flatpickr-month"),n=window.document.createDocumentFragment();h.config.showMonths>1||"static"===h.config.monthSelectorType?e=d("span","cur-month"):(h.monthsDropdownContainer=d("select","flatpickr-monthDropdown-months"),F(h.monthsDropdownContainer,"change",function(e){var t=e.target,n=parseInt(t.value,10);h.changeMonth(n-h.currentMonth),ge("onMonthChange")}),K(),e=h.monthsDropdownContainer);var a=u("cur-year",{tabindex:"-1"}),i=a.getElementsByTagName("input")[0];i.setAttribute("aria-label",h.l10n.yearAriaLabel),h.config.minDate&&i.setAttribute("min",h.config.minDate.getFullYear().toString()),h.config.maxDate&&(i.setAttribute("max",h.config.maxDate.getFullYear().toString()),i.disabled=!!h.config.minDate&&h.config.minDate.getFullYear()===h.config.maxDate.getFullYear());var o=d("div","flatpickr-current-month");return o.appendChild(e),o.appendChild(a),n.appendChild(o),t.appendChild(n),{container:t,yearElement:i,monthElement:e}}function q(){s(h.monthNav),h.monthNav.appendChild(h.prevMonthNav),h.config.showMonths&&(h.yearElements=[],h.monthElements=[]);for(var e=h.config.showMonths;e--;){var t=U();h.yearElements.push(t.yearElement),h.monthElements.push(t.monthElement),h.monthNav.appendChild(t.container)}h.monthNav.appendChild(h.nextMonthNav)}function $(){h.weekdayContainer?s(h.weekdayContainer):h.weekdayContainer=d("div","flatpickr-weekdays");for(var e=h.config.showMonths;e--;){var t=d("div","flatpickr-weekdaycontainer");h.weekdayContainer.appendChild(t)}return z(),h.weekdayContainer}function z(){if(h.weekdayContainer){var e=h.l10n.firstDayOfWeek,t=h.l10n.weekdays.shorthand.slice();e>0&&e<t.length&&(t=t.splice(e,t.length).concat(t.splice(0,e)));for(var n=h.config.showMonths;n--;)h.weekdayContainer.children[n].innerHTML="\n <span class='flatpickr-weekday'>\n "+t.join("</span><span class='flatpickr-weekday'>")+"\n </span>\n "}}function G(e,t){void 0===t&&(t=!0);var n=t?e:e-h.currentMonth;n<0&&!0===h._hidePrevMonthArrow||n>0&&!0===h._hideNextMonthArrow||(h.currentMonth+=n,(h.currentMonth<0||h.currentMonth>11)&&(h.currentYear+=h.currentMonth>11?1:-1,h.currentMonth=(h.currentMonth+12)%12,ge("onYearChange"),K()),J(),ge("onMonthChange"),ve())}function V(e){return!(!h.config.appendTo||!h.config.appendTo.contains(e))||h.calendarContainer.contains(e)}function Z(e){if(h.isOpen&&!h.config.inline){var t="function"==typeof(r=e).composedPath?r.composedPath()[0]:r.target,n=V(t),a=t===h.input||t===h.altInput||h.element.contains(t)||e.path&&e.path.indexOf&&(~e.path.indexOf(h.input)||~e.path.indexOf(h.altInput)),i="blur"===e.type?a&&e.relatedTarget&&!V(e.relatedTarget):!a&&!n&&!V(e.relatedTarget),o=!h.config.ignoredFocusElements.some(function(e){return e.contains(t)});i&&o&&(void 0!==h.timeContainer&&void 0!==h.minuteElement&&void 0!==h.hourElement&&T(),h.close(),"range"===h.config.mode&&1===h.selectedDates.length&&(h.clear(!1),h.redraw()))}var r}function Q(e){if(!(!e||h.config.minDate&&e<h.config.minDate.getFullYear()||h.config.maxDate&&e>h.config.maxDate.getFullYear())){var t=e,n=h.currentYear!==t;h.currentYear=t||h.currentYear,h.config.maxDate&&h.currentYear===h.config.maxDate.getFullYear()?h.currentMonth=Math.min(h.config.maxDate.getMonth(),h.currentMonth):h.config.minDate&&h.currentYear===h.config.minDate.getFullYear()&&(h.currentMonth=Math.max(h.config.minDate.getMonth(),h.currentMonth)),n&&(h.redraw(),ge("onYearChange"),K())}}function X(e,t){void 0===t&&(t=!0);var n=h.parseDate(e,void 0,t);if(h.config.minDate&&n&&w(n,h.config.minDate,void 0!==t?t:!h.minDateHasTime)<0||h.config.maxDate&&n&&w(n,h.config.maxDate,void 0!==t?t:!h.maxDateHasTime)>0)return!1;if(0===h.config.enable.length&&0===h.config.disable.length)return!0;if(void 0===n)return!1;for(var a=h.config.enable.length>0,i=a?h.config.enable:h.config.disable,o=0,r=void 0;o<i.length;o++){if("function"==typeof(r=i[o])&&r(n))return a;if(r instanceof Date&&void 0!==n&&r.getTime()===n.getTime())return a;if("string"==typeof r&&void 0!==n){var l=h.parseDate(r,void 0,!0);return l&&l.getTime()===n.getTime()?a:!a}if("object"==typeof r&&void 0!==n&&r.from&&r.to&&n.getTime()>=r.from.getTime()&&n.getTime()<=r.to.getTime())return a}return!a}function ee(e){return void 0!==h.daysContainer&&(-1===e.className.indexOf("hidden")&&h.daysContainer.contains(e))}function te(e){var t=e.target===h._input,n=h.config.allowInput,a=h.isOpen&&(!n||!t),i=h.config.inline&&t&&!n;if(13===e.keyCode&&t){if(n)return h.setDate(h._input.value,!0,e.target===h.altInput?h.config.altFormat:h.config.dateFormat),e.target.blur();h.open()}else if(V(e.target)||a||i){var o=!!h.timeContainer&&h.timeContainer.contains(e.target);switch(e.keyCode){case 13:o?(e.preventDefault(),T(),de()):se(e);break;case 27:e.preventDefault(),de();break;case 8:case 46:t&&!h.config.allowInput&&(e.preventDefault(),h.clear());break;case 37:case 39:if(o||t)h.hourElement&&h.hourElement.focus();else if(e.preventDefault(),void 0!==h.daysContainer&&(!1===n||document.activeElement&&ee(document.activeElement))){var r=39===e.keyCode?1:-1;e.ctrlKey?(e.stopPropagation(),G(r),R(W(1),0)):R(void 0,r)}break;case 38:case 40:e.preventDefault();var l=40===e.keyCode?1:-1;h.daysContainer&&void 0!==e.target.$i||e.target===h.input||e.target===h.altInput?e.ctrlKey?(e.stopPropagation(),Q(h.currentYear-l),R(W(1),0)):o||R(void 0,7*l):e.target===h.currentYearElement?Q(h.currentYear-l):h.config.enableTime&&(!o&&h.hourElement&&h.hourElement.focus(),T(e),h._debouncedChange());break;case 9:if(o){var c=[h.hourElement,h.minuteElement,h.secondElement,h.amPM].concat(h.pluginElements).filter(function(e){return e}),d=c.indexOf(e.target);if(-1!==d){var s=c[d+(e.shiftKey?-1:1)];e.preventDefault(),(s||h._input).focus()}}else!h.config.noCalendar&&h.daysContainer&&h.daysContainer.contains(e.target)&&e.shiftKey&&(e.preventDefault(),h._input.focus())}}if(void 0!==h.amPM&&e.target===h.amPM)switch(e.key){case h.l10n.amPM[0].charAt(0):case h.l10n.amPM[0].charAt(0).toLowerCase():h.amPM.textContent=h.l10n.amPM[0],k(),we();break;case h.l10n.amPM[1].charAt(0):case h.l10n.amPM[1].charAt(0).toLowerCase():h.amPM.textContent=h.l10n.amPM[1],k(),we()}(t||V(e.target))&&ge("onKeyDown",e)}function ne(e){if(1===h.selectedDates.length&&(!e||e.classList.contains("flatpickr-day")&&!e.classList.contains("flatpickr-disabled"))){for(var t=e?e.dateObj.getTime():h.days.firstElementChild.dateObj.getTime(),n=h.parseDate(h.selectedDates[0],void 0,!0).getTime(),a=Math.min(t,h.selectedDates[0].getTime()),i=Math.max(t,h.selectedDates[0].getTime()),o=!1,r=0,l=0,c=a;c<i;c+=C.DAY)X(new Date(c),!0)||(o=o||c>a&&c<i,c<n&&(!r||c>r)?r=c:c>n&&(!l||c<l)&&(l=c));for(var d=0;d<h.config.showMonths;d++)for(var s=h.daysContainer.children[d],u=function(a,i){var c=s.children[a],d=c.dateObj.getTime(),u=r>0&&d<r||l>0&&d>l;return u?(c.classList.add("notAllowed"),["inRange","startRange","endRange"].forEach(function(e){c.classList.remove(e)}),"continue"):o&&!u?"continue":(["startRange","inRange","endRange","notAllowed"].forEach(function(e){c.classList.remove(e)}),void(void 0!==e&&(e.classList.add(t<=h.selectedDates[0].getTime()?"startRange":"endRange"),n<t&&d===n?c.classList.add("startRange"):n>t&&d===n&&c.classList.add("endRange"),d>=r&&(0===l||d<=l)&&b(d,n,t)&&c.classList.add("inRange"))))},f=0,m=s.children.length;f<m;f++)u(f)}}function ae(){!h.isOpen||h.config.static||h.config.inline||le()}function ie(){h.setDate(void 0!==h.config.minDate?new Date(h.config.minDate.getTime()):new Date,!0),S(),we()}function oe(e){return function(t){var n=h.config["_"+e+"Date"]=h.parseDate(t,h.config.dateFormat),a=h.config["_"+("min"===e?"max":"min")+"Date"];void 0!==n&&(h["min"===e?"minDateHasTime":"maxDateHasTime"]=n.getHours()>0||n.getMinutes()>0||n.getSeconds()>0),h.selectedDates&&(h.selectedDates=h.selectedDates.filter(function(e){return X(e)}),h.selectedDates.length||"min"!==e||I(n),we()),h.daysContainer&&(ce(),void 0!==n?h.currentYearElement[e]=n.getFullYear().toString():h.currentYearElement.removeAttribute(e),h.currentYearElement.disabled=!!a&&void 0!==n&&a.getFullYear()===n.getFullYear())}}function re(){"object"!=typeof h.config.locale&&void 0===E.l10ns[h.config.locale]&&h.config.errorHandler(new Error("flatpickr: invalid locale "+h.config.locale)),h.l10n=e({},E.l10ns.default,"object"==typeof h.config.locale?h.config.locale:"default"!==h.config.locale?E.l10ns[h.config.locale]:void 0),p.K="("+h.l10n.amPM[0]+"|"+h.l10n.amPM[1]+"|"+h.l10n.amPM[0].toLowerCase()+"|"+h.l10n.amPM[1].toLowerCase()+")",void 0===e({},g,JSON.parse(JSON.stringify(f.dataset||{}))).time_24hr&&void 0===E.defaultConfig.time_24hr&&(h.config.time_24hr=h.l10n.time_24hr),h.formatDate=v(h),h.parseDate=D({config:h.config,l10n:h.l10n})}function le(e){if(void 0!==h.calendarContainer){ge("onPreCalendarPosition");var t=e||h._positionElement,n=Array.prototype.reduce.call(h.calendarContainer.children,function(e,t){return e+t.offsetHeight},0),a=h.calendarContainer.offsetWidth,i=h.config.position.split(" "),o=i[0],r=i.length>1?i[1]:null,l=t.getBoundingClientRect(),d=window.innerHeight-l.bottom,s="above"===o||"below"!==o&&d<n&&l.top>n,u=window.pageYOffset+l.top+(s?-n-2:t.offsetHeight+2);if(c(h.calendarContainer,"arrowTop",!s),c(h.calendarContainer,"arrowBottom",s),!h.config.inline){var f=window.pageXOffset+l.left-(null!=r&&"center"===r?(a-l.width)/2:0),m=window.document.body.offsetWidth-(window.pageXOffset+l.right),g=f+a>window.document.body.offsetWidth,p=m+a>window.document.body.offsetWidth;if(c(h.calendarContainer,"rightMost",g),!h.config.static)if(h.calendarContainer.style.top=u+"px",g)if(p){var v=document.styleSheets[0];if(void 0===v)return;var D=window.document.body.offsetWidth,w=Math.max(0,D/2-a/2),b=v.cssRules.length,C="{left:"+l.left+"px;right:auto;}";c(h.calendarContainer,"rightMost",!1),c(h.calendarContainer,"centerMost",!0),v.insertRule(".flatpickr-calendar.centerMost:before,.flatpickr-calendar.centerMost:after"+C,b),h.calendarContainer.style.left=w+"px",h.calendarContainer.style.right="auto"}else h.calendarContainer.style.left="auto",h.calendarContainer.style.right=m+"px";else h.calendarContainer.style.left=f+"px",h.calendarContainer.style.right="auto"}}}function ce(){h.config.noCalendar||h.isMobile||(ve(),J())}function de(){h._input.focus(),-1!==window.navigator.userAgent.indexOf("MSIE")||void 0!==navigator.msMaxTouchPoints?setTimeout(h.close,0):h.close()}function se(e){e.preventDefault(),e.stopPropagation();var t=function e(t,n){return n(t)?t:t.parentNode?e(t.parentNode,n):void 0}(e.target,function(e){return e.classList&&e.classList.contains("flatpickr-day")&&!e.classList.contains("flatpickr-disabled")&&!e.classList.contains("notAllowed")});if(void 0!==t){var n=t,a=h.latestSelectedDateObj=new Date(n.dateObj.getTime()),i=(a.getMonth()<h.currentMonth||a.getMonth()>h.currentMonth+h.config.showMonths-1)&&"range"!==h.config.mode;if(h.selectedDateElem=n,"single"===h.config.mode)h.selectedDates=[a];else if("multiple"===h.config.mode){var o=he(a);o?h.selectedDates.splice(parseInt(o),1):h.selectedDates.push(a)}else"range"===h.config.mode&&(2===h.selectedDates.length&&h.clear(!1,!1),h.latestSelectedDateObj=a,h.selectedDates.push(a),0!==w(a,h.selectedDates[0],!0)&&h.selectedDates.sort(function(e,t){return e.getTime()-t.getTime()}));if(k(),i){var r=h.currentYear!==a.getFullYear();h.currentYear=a.getFullYear(),h.currentMonth=a.getMonth(),r&&(ge("onYearChange"),K()),ge("onMonthChange")}if(ve(),J(),we(),h.config.enableTime&&setTimeout(function(){return h.showTimeInput=!0},50),i||"range"===h.config.mode||1!==h.config.showMonths?void 0!==h.selectedDateElem&&void 0===h.hourElement&&h.selectedDateElem&&h.selectedDateElem.focus():L(n),void 0!==h.hourElement&&void 0!==h.hourElement&&h.hourElement.focus(),h.config.closeOnSelect){var l="single"===h.config.mode&&!h.config.enableTime,c="range"===h.config.mode&&2===h.selectedDates.length&&!h.config.enableTime;(l||c)&&de()}Y()}}h.parseDate=D({config:h.config,l10n:h.l10n}),h._handlers=[],h.pluginElements=[],h.loadedPlugins=[],h._bind=F,h._setHoursFromDate=I,h._positionCalendar=le,h.changeMonth=G,h.changeYear=Q,h.clear=function(e,t){void 0===e&&(e=!0);void 0===t&&(t=!0);h.input.value="",void 0!==h.altInput&&(h.altInput.value="");void 0!==h.mobileInput&&(h.mobileInput.value="");h.selectedDates=[],h.latestSelectedDateObj=void 0,!0===t&&(h.currentYear=h._initialDate.getFullYear(),h.currentMonth=h._initialDate.getMonth());h.showTimeInput=!1,!0===h.config.enableTime&&S();h.redraw(),e&&ge("onChange")},h.close=function(){h.isOpen=!1,h.isMobile||(void 0!==h.calendarContainer&&h.calendarContainer.classList.remove("open"),void 0!==h._input&&h._input.classList.remove("active"));ge("onClose")},h._createElement=d,h.destroy=function(){void 0!==h.config&&ge("onDestroy");for(var e=h._handlers.length;e--;){var t=h._handlers[e];t.element.removeEventListener(t.event,t.handler,t.options)}if(h._handlers=[],h.mobileInput)h.mobileInput.parentNode&&h.mobileInput.parentNode.removeChild(h.mobileInput),h.mobileInput=void 0;else if(h.calendarContainer&&h.calendarContainer.parentNode)if(h.config.static&&h.calendarContainer.parentNode){var n=h.calendarContainer.parentNode;if(n.lastChild&&n.removeChild(n.lastChild),n.parentNode){for(;n.firstChild;)n.parentNode.insertBefore(n.firstChild,n);n.parentNode.removeChild(n)}}else h.calendarContainer.parentNode.removeChild(h.calendarContainer);h.altInput&&(h.input.type="text",h.altInput.parentNode&&h.altInput.parentNode.removeChild(h.altInput),delete h.altInput);h.input&&(h.input.type=h.input._type,h.input.classList.remove("flatpickr-input"),h.input.removeAttribute("readonly"),h.input.value="");["_showTimeInput","latestSelectedDateObj","_hideNextMonthArrow","_hidePrevMonthArrow","__hideNextMonthArrow","__hidePrevMonthArrow","isMobile","isOpen","selectedDateElem","minDateHasTime","maxDateHasTime","days","daysContainer","_input","_positionElement","innerContainer","rContainer","monthNav","todayDateElem","calendarContainer","weekdayContainer","prevMonthNav","nextMonthNav","monthsDropdownContainer","currentMonthElement","currentYearElement","navigationCurrentMonth","selectedDateElem","config"].forEach(function(e){try{delete h[e]}catch(e){}})},h.isEnabled=X,h.jumpToDate=A,h.open=function(e,t){void 0===t&&(t=h._positionElement);if(!0===h.isMobile)return e&&(e.preventDefault(),e.target&&e.target.blur()),void 0!==h.mobileInput&&(h.mobileInput.focus(),h.mobileInput.click()),void ge("onOpen");if(h._input.disabled||h.config.inline)return;var n=h.isOpen;h.isOpen=!0,n||(h.calendarContainer.classList.add("open"),h._input.classList.add("active"),ge("onOpen"),le(t));!0===h.config.enableTime&&!0===h.config.noCalendar&&(0===h.selectedDates.length&&ie(),!1!==h.config.allowInput||void 0!==e&&h.timeContainer.contains(e.relatedTarget)||setTimeout(function(){return h.hourElement.select()},50))},h.redraw=ce,h.set=function(e,n){if(null!==e&&"object"==typeof e)for(var a in Object.assign(h.config,e),e)void 0!==ue[a]&&ue[a].forEach(function(e){return e()});else h.config[e]=n,void 0!==ue[e]?ue[e].forEach(function(e){return e()}):t.indexOf(e)>-1&&(h.config[e]=l(n));h.redraw(),we(!1)},h.setDate=function(e,t,n){void 0===t&&(t=!1);void 0===n&&(n=h.config.dateFormat);if(0!==e&&!e||e instanceof Array&&0===e.length)return h.clear(t);fe(e,n),h.showTimeInput=h.selectedDates.length>0,h.latestSelectedDateObj=h.selectedDates[h.selectedDates.length-1],h.redraw(),A(),I(),0===h.selectedDates.length&&h.clear(!1);we(t),t&&ge("onChange")},h.toggle=function(e){if(!0===h.isOpen)return h.close();h.open(e)};var ue={locale:[re,z],showMonths:[q,x,$],minDate:[A],maxDate:[A]};function fe(e,t){var n=[];if(e instanceof Array)n=e.map(function(e){return h.parseDate(e,t)});else if(e instanceof Date||"number"==typeof e)n=[h.parseDate(e,t)];else if("string"==typeof e)switch(h.config.mode){case"single":case"time":n=[h.parseDate(e,t)];break;case"multiple":n=e.split(h.config.conjunction).map(function(e){return h.parseDate(e,t)});break;case"range":n=e.split(h.l10n.rangeSeparator).map(function(e){return h.parseDate(e,t)})}else h.config.errorHandler(new Error("Invalid date supplied: "+JSON.stringify(e)));h.selectedDates=n.filter(function(e){return e instanceof Date&&X(e,!1)}),"range"===h.config.mode&&h.selectedDates.sort(function(e,t){return e.getTime()-t.getTime()})}function me(e){return e.slice().map(function(e){return"string"==typeof e||"number"==typeof e||e instanceof Date?h.parseDate(e,void 0,!0):e&&"object"==typeof e&&e.from&&e.to?{from:h.parseDate(e.from,void 0),to:h.parseDate(e.to,void 0)}:e}).filter(function(e){return e})}function ge(e,t){if(void 0!==h.config){var n=h.config[e];if(void 0!==n&&n.length>0)for(var a=0;n[a]&&a<n.length;a++)n[a](h.selectedDates,h.input.value,h,t);"onChange"===e&&(h.input.dispatchEvent(pe("change")),h.input.dispatchEvent(pe("input")))}}function pe(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!0),t}function he(e){for(var t=0;t<h.selectedDates.length;t++)if(0===w(h.selectedDates[t],e))return""+t;return!1}function ve(){h.config.noCalendar||h.isMobile||!h.monthNav||(h.yearElements.forEach(function(e,t){var n=new Date(h.currentYear,h.currentMonth,1);n.setMonth(h.currentMonth+t),h.config.showMonths>1||"static"===h.config.monthSelectorType?h.monthElements[t].textContent=m(n.getMonth(),h.config.shorthandCurrentMonth,h.l10n)+" ":h.monthsDropdownContainer.value=n.getMonth().toString(),e.value=n.getFullYear().toString()}),h._hidePrevMonthArrow=void 0!==h.config.minDate&&(h.currentYear===h.config.minDate.getFullYear()?h.currentMonth<=h.config.minDate.getMonth():h.currentYear<h.config.minDate.getFullYear()),h._hideNextMonthArrow=void 0!==h.config.maxDate&&(h.currentYear===h.config.maxDate.getFullYear()?h.currentMonth+1>h.config.maxDate.getMonth():h.currentYear>h.config.maxDate.getFullYear()))}function De(e){return h.selectedDates.map(function(t){return h.formatDate(t,e)}).filter(function(e,t,n){return"range"!==h.config.mode||h.config.enableTime||n.indexOf(e)===t}).join("range"!==h.config.mode?h.config.conjunction:h.l10n.rangeSeparator)}function we(e){void 0===e&&(e=!0),void 0!==h.mobileInput&&h.mobileFormatStr&&(h.mobileInput.value=void 0!==h.latestSelectedDateObj?h.formatDate(h.latestSelectedDateObj,h.mobileFormatStr):""),h.input.value=De(h.config.dateFormat),void 0!==h.altInput&&(h.altInput.value=De(h.config.altFormat)),!1!==e&&ge("onValueUpdate")}function be(e){var t=h.prevMonthNav.contains(e.target),n=h.nextMonthNav.contains(e.target);t||n?G(t?-1:1):h.yearElements.indexOf(e.target)>=0?e.target.select():e.target.classList.contains("arrowUp")?h.changeYear(h.currentYear+1):e.target.classList.contains("arrowDown")&&h.changeYear(h.currentYear-1)}return function(){h.element=h.input=f,h.isOpen=!1,function(){var a=["wrap","weekNumbers","allowInput","clickOpens","time_24hr","enableTime","noCalendar","altInput","shorthandCurrentMonth","inline","static","enableSeconds","disableMobile"],i=e({},g,JSON.parse(JSON.stringify(f.dataset||{}))),o={};h.config.parseDate=i.parseDate,h.config.formatDate=i.formatDate,Object.defineProperty(h.config,"enable",{get:function(){return h.config._enable},set:function(e){h.config._enable=me(e)}}),Object.defineProperty(h.config,"disable",{get:function(){return h.config._disable},set:function(e){h.config._disable=me(e)}});var r="time"===i.mode;if(!i.dateFormat&&(i.enableTime||r)){var c=E.defaultConfig.dateFormat||n.dateFormat;o.dateFormat=i.noCalendar||r?"H:i"+(i.enableSeconds?":S":""):c+" H:i"+(i.enableSeconds?":S":"")}if(i.altInput&&(i.enableTime||r)&&!i.altFormat){var d=E.defaultConfig.altFormat||n.altFormat;o.altFormat=i.noCalendar||r?"h:i"+(i.enableSeconds?":S K":" K"):d+" h:i"+(i.enableSeconds?":S":"")+" K"}i.altInputClass||(h.config.altInputClass=h.input.className+" "+h.config.altInputClass),Object.defineProperty(h.config,"minDate",{get:function(){return h.config._minDate},set:oe("min")}),Object.defineProperty(h.config,"maxDate",{get:function(){return h.config._maxDate},set:oe("max")});var s=function(e){return function(t){h.config["min"===e?"_minTime":"_maxTime"]=h.parseDate(t,"H:i:S")}};Object.defineProperty(h.config,"minTime",{get:function(){return h.config._minTime},set:s("min")}),Object.defineProperty(h.config,"maxTime",{get:function(){return h.config._maxTime},set:s("max")}),"time"===i.mode&&(h.config.noCalendar=!0,h.config.enableTime=!0),Object.assign(h.config,o,i);for(var u=0;u<a.length;u++)h.config[a[u]]=!0===h.config[a[u]]||"true"===h.config[a[u]];t.filter(function(e){return void 0!==h.config[e]}).forEach(function(e){h.config[e]=l(h.config[e]||[]).map(y)}),h.isMobile=!h.config.disableMobile&&!h.config.inline&&"single"===h.config.mode&&!h.config.disable.length&&!h.config.enable.length&&!h.config.weekNumbers&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);for(var u=0;u<h.config.plugins.length;u++){var m=h.config.plugins[u](h)||{};for(var p in m)t.indexOf(p)>-1?h.config[p]=l(m[p]).map(y).concat(h.config[p]):void 0===i[p]&&(h.config[p]=m[p])}ge("onParseConfig")}(),re(),h.input=h.config.wrap?f.querySelector("[data-input]"):f,h.input?(h.input._type=h.input.type,h.input.type="text",h.input.classList.add("flatpickr-input"),h._input=h.input,h.config.altInput&&(h.altInput=d(h.input.nodeName,h.config.altInputClass),h._input=h.altInput,h.altInput.placeholder=h.input.placeholder,h.altInput.disabled=h.input.disabled,h.altInput.required=h.input.required,h.altInput.tabIndex=h.input.tabIndex,h.altInput.type="text",h.input.setAttribute("type","hidden"),!h.config.static&&h.input.parentNode&&h.input.parentNode.insertBefore(h.altInput,h.input.nextSibling)),h.config.allowInput||h._input.setAttribute("readonly","readonly"),h._positionElement=h.config.positionElement||h._input):h.config.errorHandler(new Error("Invalid input element specified")),function(){h.selectedDates=[],h.now=h.parseDate(h.config.now)||new Date;var e=h.config.defaultDate||("INPUT"!==h.input.nodeName&&"TEXTAREA"!==h.input.nodeName||!h.input.placeholder||h.input.value!==h.input.placeholder?h.input.value:null);e&&fe(e,h.config.dateFormat),h._initialDate=h.selectedDates.length>0?h.selectedDates[0]:h.config.minDate&&h.config.minDate.getTime()>h.now.getTime()?h.config.minDate:h.config.maxDate&&h.config.maxDate.getTime()<h.now.getTime()?h.config.maxDate:h.now,h.currentYear=h._initialDate.getFullYear(),h.currentMonth=h._initialDate.getMonth(),h.selectedDates.length>0&&(h.latestSelectedDateObj=h.selectedDates[0]),void 0!==h.config.minTime&&(h.config.minTime=h.parseDate(h.config.minTime,"H:i")),void 0!==h.config.maxTime&&(h.config.maxTime=h.parseDate(h.config.maxTime,"H:i")),h.minDateHasTime=!!h.config.minDate&&(h.config.minDate.getHours()>0||h.config.minDate.getMinutes()>0||h.config.minDate.getSeconds()>0),h.maxDateHasTime=!!h.config.maxDate&&(h.config.maxDate.getHours()>0||h.config.maxDate.getMinutes()>0||h.config.maxDate.getSeconds()>0),Object.defineProperty(h,"showTimeInput",{get:function(){return h._showTimeInput},set:function(e){h._showTimeInput=e,h.calendarContainer&&c(h.calendarContainer,"showTimeInput",e),h.isOpen&&le()}})}(),h.utils={getDaysInMonth:function(e,t){return void 0===e&&(e=h.currentMonth),void 0===t&&(t=h.currentYear),1===e&&(t%4==0&&t%100!=0||t%400==0)?29:h.l10n.daysInMonth[e]}},h.isMobile||function(){var e=window.document.createDocumentFragment();if(h.calendarContainer=d("div","flatpickr-calendar"),h.calendarContainer.tabIndex=-1,!h.config.noCalendar){if(e.appendChild((h.monthNav=d("div","flatpickr-months"),h.yearElements=[],h.monthElements=[],h.prevMonthNav=d("span","flatpickr-prev-month"),h.prevMonthNav.innerHTML=h.config.prevArrow,h.nextMonthNav=d("span","flatpickr-next-month"),h.nextMonthNav.innerHTML=h.config.nextArrow,q(),Object.defineProperty(h,"_hidePrevMonthArrow",{get:function(){return h.__hidePrevMonthArrow},set:function(e){h.__hidePrevMonthArrow!==e&&(c(h.prevMonthNav,"flatpickr-disabled",e),h.__hidePrevMonthArrow=e)}}),Object.defineProperty(h,"_hideNextMonthArrow",{get:function(){return h.__hideNextMonthArrow},set:function(e){h.__hideNextMonthArrow!==e&&(c(h.nextMonthNav,"flatpickr-disabled",e),h.__hideNextMonthArrow=e)}}),h.currentYearElement=h.yearElements[0],ve(),h.monthNav)),h.innerContainer=d("div","flatpickr-innerContainer"),h.config.weekNumbers){var t=function(){h.calendarContainer.classList.add("hasWeeks");var e=d("div","flatpickr-weekwrapper");e.appendChild(d("span","flatpickr-weekday",h.l10n.weekAbbreviation));var t=d("div","flatpickr-weeks");return e.appendChild(t),{weekWrapper:e,weekNumbers:t}}(),n=t.weekWrapper,a=t.weekNumbers;h.innerContainer.appendChild(n),h.weekNumbers=a,h.weekWrapper=n}h.rContainer=d("div","flatpickr-rContainer"),h.rContainer.appendChild($()),h.daysContainer||(h.daysContainer=d("div","flatpickr-days"),h.daysContainer.tabIndex=-1),J(),h.rContainer.appendChild(h.daysContainer),h.innerContainer.appendChild(h.rContainer),e.appendChild(h.innerContainer)}h.config.enableTime&&e.appendChild(function(){h.calendarContainer.classList.add("hasTime"),h.config.noCalendar&&h.calendarContainer.classList.add("noCalendar"),h.timeContainer=d("div","flatpickr-time"),h.timeContainer.tabIndex=-1;var e=d("span","flatpickr-time-separator",":"),t=u("flatpickr-hour",{"aria-label":h.l10n.hourAriaLabel});h.hourElement=t.getElementsByTagName("input")[0];var n=u("flatpickr-minute",{"aria-label":h.l10n.minuteAriaLabel});if(h.minuteElement=n.getElementsByTagName("input")[0],h.hourElement.tabIndex=h.minuteElement.tabIndex=-1,h.hourElement.value=i(h.latestSelectedDateObj?h.latestSelectedDateObj.getHours():h.config.time_24hr?h.config.defaultHour:function(e){switch(e%24){case 0:case 12:return 12;default:return e%12}}(h.config.defaultHour)),h.minuteElement.value=i(h.latestSelectedDateObj?h.latestSelectedDateObj.getMinutes():h.config.defaultMinute),h.hourElement.setAttribute("step",h.config.hourIncrement.toString()),h.minuteElement.setAttribute("step",h.config.minuteIncrement.toString()),h.hourElement.setAttribute("min",h.config.time_24hr?"0":"1"),h.hourElement.setAttribute("max",h.config.time_24hr?"23":"12"),h.minuteElement.setAttribute("min","0"),h.minuteElement.setAttribute("max","59"),h.timeContainer.appendChild(t),h.timeContainer.appendChild(e),h.timeContainer.appendChild(n),h.config.time_24hr&&h.timeContainer.classList.add("time24hr"),h.config.enableSeconds){h.timeContainer.classList.add("hasSeconds");var a=u("flatpickr-second");h.secondElement=a.getElementsByTagName("input")[0],h.secondElement.value=i(h.latestSelectedDateObj?h.latestSelectedDateObj.getSeconds():h.config.defaultSeconds),h.secondElement.setAttribute("step",h.minuteElement.getAttribute("step")),h.secondElement.setAttribute("min","0"),h.secondElement.setAttribute("max","59"),h.timeContainer.appendChild(d("span","flatpickr-time-separator",":")),h.timeContainer.appendChild(a)}return h.config.time_24hr||(h.amPM=d("span","flatpickr-am-pm",h.l10n.amPM[o((h.latestSelectedDateObj?h.hourElement.value:h.config.defaultHour)>11)]),h.amPM.title=h.l10n.toggleTitle,h.amPM.tabIndex=-1,h.timeContainer.appendChild(h.amPM)),h.timeContainer}()),c(h.calendarContainer,"rangeMode","range"===h.config.mode),c(h.calendarContainer,"animate",!0===h.config.animate),c(h.calendarContainer,"multiMonth",h.config.showMonths>1),h.calendarContainer.appendChild(e);var r=void 0!==h.config.appendTo&&void 0!==h.config.appendTo.nodeType;if((h.config.inline||h.config.static)&&(h.calendarContainer.classList.add(h.config.inline?"inline":"static"),h.config.inline&&(!r&&h.element.parentNode?h.element.parentNode.insertBefore(h.calendarContainer,h._input.nextSibling):void 0!==h.config.appendTo&&h.config.appendTo.appendChild(h.calendarContainer)),h.config.static)){var l=d("div","flatpickr-wrapper");h.element.parentNode&&h.element.parentNode.insertBefore(l,h.element),l.appendChild(h.element),h.altInput&&l.appendChild(h.altInput),l.appendChild(h.calendarContainer)}h.config.static||h.config.inline||(void 0!==h.config.appendTo?h.config.appendTo:window.document.body).appendChild(h.calendarContainer)}(),function(){if(h.config.wrap&&["open","close","toggle","clear"].forEach(function(e){Array.prototype.forEach.call(h.element.querySelectorAll("[data-"+e+"]"),function(t){return F(t,"click",h[e])})}),h.isMobile)!function(){var e=h.config.enableTime?h.config.noCalendar?"time":"datetime-local":"date";h.mobileInput=d("input",h.input.className+" flatpickr-mobile"),h.mobileInput.step=h.input.getAttribute("step")||"any",h.mobileInput.tabIndex=1,h.mobileInput.type=e,h.mobileInput.disabled=h.input.disabled,h.mobileInput.required=h.input.required,h.mobileInput.placeholder=h.input.placeholder,h.mobileFormatStr="datetime-local"===e?"Y-m-d\\TH:i:S":"date"===e?"Y-m-d":"H:i:S",h.selectedDates.length>0&&(h.mobileInput.defaultValue=h.mobileInput.value=h.formatDate(h.selectedDates[0],h.mobileFormatStr)),h.config.minDate&&(h.mobileInput.min=h.formatDate(h.config.minDate,"Y-m-d")),h.config.maxDate&&(h.mobileInput.max=h.formatDate(h.config.maxDate,"Y-m-d")),h.input.type="hidden",void 0!==h.altInput&&(h.altInput.type="hidden");try{h.input.parentNode&&h.input.parentNode.insertBefore(h.mobileInput,h.input.nextSibling)}catch(e){}F(h.mobileInput,"change",function(e){h.setDate(e.target.value,!1,h.mobileFormatStr),ge("onChange"),ge("onClose")})}();else{var e=r(ae,50);h._debouncedChange=r(Y,M),h.daysContainer&&!/iPhone|iPad|iPod/i.test(navigator.userAgent)&&F(h.daysContainer,"mouseover",function(e){"range"===h.config.mode&&ne(e.target)}),F(window.document.body,"keydown",te),h.config.inline||h.config.static||F(window,"resize",e),void 0!==window.ontouchstart?F(window.document,"touchstart",Z):F(window.document,"mousedown",N(Z)),F(window.document,"focus",Z,{capture:!0}),!0===h.config.clickOpens&&(F(h._input,"focus",h.open),F(h._input,"mousedown",N(h.open))),void 0!==h.daysContainer&&(F(h.monthNav,"mousedown",N(be)),F(h.monthNav,["keyup","increment"],_),F(h.daysContainer,"mousedown",N(se))),void 0!==h.timeContainer&&void 0!==h.minuteElement&&void 0!==h.hourElement&&(F(h.timeContainer,["increment"],T),F(h.timeContainer,"blur",T,{capture:!0}),F(h.timeContainer,"mousedown",N(P)),F([h.hourElement,h.minuteElement],["focus","click"],function(e){return e.target.select()}),void 0!==h.secondElement&&F(h.secondElement,"focus",function(){return h.secondElement&&h.secondElement.select()}),void 0!==h.amPM&&F(h.amPM,"mousedown",N(function(e){T(e),Y()})))}}(),(h.selectedDates.length||h.config.noCalendar)&&(h.config.enableTime&&I(h.config.noCalendar?h.latestSelectedDateObj||h.config.minDate:void 0),we(!1)),x(),h.showTimeInput=h.selectedDates.length>0||h.config.noCalendar;var a=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);!h.isMobile&&a&&le(),ge("onReady")}(),h}function x(e,t){for(var n=Array.prototype.slice.call(e).filter(function(e){return e instanceof HTMLElement}),a=[],i=0;i<n.length;i++){var o=n[i];try{if(null!==o.getAttribute("data-fp-omit"))continue;void 0!==o._flatpickr&&(o._flatpickr.destroy(),o._flatpickr=void 0),o._flatpickr=y(o,t||{}),a.push(o._flatpickr)}catch(e){console.error(e)}}return 1===a.length?a[0]:a}"undefined"!=typeof HTMLElement&&"undefined"!=typeof HTMLCollection&&"undefined"!=typeof NodeList&&(HTMLCollection.prototype.flatpickr=NodeList.prototype.flatpickr=function(e){return x(this,e)},HTMLElement.prototype.flatpickr=function(e){return x([this],e)});var E=function(e,t){return"string"==typeof e?x(window.document.querySelectorAll(e),t):e instanceof Node?x([e],t):x(e,t)};return E.defaultConfig={},E.l10ns={en:e({},a),default:e({},a)},E.localize=function(t){E.l10ns.default=e({},E.l10ns.default,t)},E.setDefaults=function(t){E.defaultConfig=e({},E.defaultConfig,t)},E.parseDate=D({}),E.formatDate=v({}),E.compareDates=w,"undefined"!=typeof jQuery&&void 0!==jQuery.fn&&(jQuery.fn.flatpickr=function(e){return x(this,e)}),Date.prototype.fp_incr=function(e){return new Date(this.getFullYear(),this.getMonth(),this.getDate()+("string"==typeof e?parseInt(e,10):e))},"undefined"!=typeof window&&(window.flatpickr=E),E}); \ No newline at end of file
diff --git a/run.php b/run.php
new file mode 100644
index 0000000..6194378
--- /dev/null
+++ b/run.php
@@ -0,0 +1,18 @@
+<?php
+// Icinga Reporting | (c) 2018 Icinga GmbH | GPLv2
+
+namespace Icinga\Module\Reporting {
+
+ use Icinga\Application\Icinga;
+
+ require __DIR__ . '/vendor/autoload.php';
+
+ /** @var \Icinga\Application\Modules\Module $this */
+
+ $this->provideHook('reporting/Report', '\\Icinga\\Module\\Reporting\\Reports\\SystemReport');
+
+ $this->provideHook('reporting/Action', '\\Icinga\\Module\\Reporting\\Actions\\SendMail');
+
+ Icinga::app()->getLoader()->registerNamespace('reportingipl\Web', __DIR__ . '/library/vendor/ipl/web/src');
+ Icinga::app()->getLoader()->registerNamespace('reportingipl\Html', __DIR__ . '/library/vendor/ipl/Html/src');
+}
diff --git a/schema/mysql-migrations/v0.10.0.sql b/schema/mysql-migrations/v0.10.0.sql
new file mode 100644
index 0000000..638135b
--- /dev/null
+++ b/schema/mysql-migrations/v0.10.0.sql
@@ -0,0 +1,12 @@
+CREATE TABLE template (
+ id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ author varchar(255) NOT NULL COLLATE utf8mb4_unicode_ci,
+ name varchar(128) NOT NULL COLLATE utf8mb4_unicode_ci,
+ settings longblob NOT NULL,
+ ctime bigint(20) unsigned NOT NULL,
+ mtime bigint(20) unsigned NOT NULL,
+ PRIMARY KEY(id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
+
+ALTER TABLE report ADD COLUMN template_id int(10) unsigned NULL DEFAULT NULL AFTER timeframe_id;
+ALTER TABLE report ADD CONSTRAINT report_template FOREIGN KEY (template_id) REFERENCES template (id);
diff --git a/schema/mysql-migrations/v0.9.1.sql b/schema/mysql-migrations/v0.9.1.sql
new file mode 100644
index 0000000..bd71b37
--- /dev/null
+++ b/schema/mysql-migrations/v0.9.1.sql
@@ -0,0 +1,9 @@
+UPDATE timeframe SET start = 'first day of January this year midnight' WHERE name = 'Current Year';
+UPDATE timeframe SET start = 'first day of January last year midnight' WHERE name = 'Last Year';
+UPDATE timeframe SET ctime = UNIX_TIMESTAMP() * 1000, mtime = UNIX_TIMESTAMP() * 1000;
+
+ALTER TABLE timeframe MODIFY COLUMN name varchar(128) NOT NULL COLLATE utf8mb4_unicode_ci;
+ALTER TABLE timeframe ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=default;
+
+ALTER TABLE report MODIFY COLUMN name varchar(128) NOT NULL COLLATE utf8mb4_unicode_ci;
+ALTER TABLE report ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=default;
diff --git a/schema/mysql.sql b/schema/mysql.sql
new file mode 100644
index 0000000..5f70481
--- /dev/null
+++ b/schema/mysql.sql
@@ -0,0 +1,96 @@
+CREATE TABLE template (
+ id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ author varchar(255) NOT NULL COLLATE utf8mb4_unicode_ci,
+ name varchar(128) NOT NULL COLLATE utf8mb4_unicode_ci,
+ settings longblob NOT NULL,
+ ctime bigint(20) unsigned NOT NULL,
+ mtime bigint(20) unsigned NOT NULL,
+ PRIMARY KEY(id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
+
+CREATE TABLE timeframe (
+ id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ name varchar(128) NOT NULL COLLATE utf8mb4_unicode_ci,
+ title varchar(255) NULL DEFAULT NULL COLLATE utf8mb4_unicode_ci,
+ start varchar(255) NOT NULL COLLATE utf8mb4_unicode_ci,
+ end varchar(255) NOT NULL COLLATE utf8mb4_unicode_ci,
+ ctime bigint(20) unsigned NOT NULL,
+ mtime bigint(20) unsigned NOT NULL,
+ PRIMARY KEY(id),
+ UNIQUE KEY timeframe (name)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
+
+INSERT INTO timeframe (name, title, start, end, ctime, mtime) VALUES
+ ('4 Hours', null, '-4 hours', 'now', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000),
+ ('25 Hours', null, '-25 hours', 'now', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000),
+ ('One Week', null, '-1 week', 'now', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000),
+ ('One Month', null, '-1 month', 'now', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000),
+ ('One Year', null, '-1 year', 'now', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000),
+ ('Current Day', null, 'midnight', 'now', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000),
+ ('Last Day', null, 'yesterday midnight', 'yesterday 23:59:59', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000),
+ ('Current Week', null, 'monday this week midnight', 'sunday this week 23:59:59', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000),
+ ('Last Week', null, 'monday last week midnight', 'sunday last week 23:59:59', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000),
+ ('Current Month', null, 'first day of this month midnight', 'now', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000),
+ ('Last Month', null, 'first day of last month midnight', 'last day of last month 23:59:59', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000),
+ ('Current Year', null, 'first day of January this year midnight', 'now', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000),
+ ('Last Year', null, 'first day of January last year midnight', 'last day of December last year 23:59:59', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000);
+
+CREATE TABLE report (
+ id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ timeframe_id int(10) unsigned NOT NULL,
+ template_id int(10) unsigned NULL DEFAULT NULL,
+ author varchar(255) NOT NULL COLLATE utf8mb4_unicode_ci,
+ name varchar(128) NOT NULL COLLATE utf8mb4_unicode_ci,
+ ctime bigint(20) unsigned NOT NULL,
+ mtime bigint(20) unsigned NOT NULL,
+ PRIMARY KEY(id),
+ UNIQUE KEY report (name),
+ CONSTRAINT report_timeframe FOREIGN KEY (timeframe_id) REFERENCES timeframe (id),
+ CONSTRAINT report_template FOREIGN KEY (template_id) REFERENCES template (id)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
+
+CREATE TABLE reportlet (
+ id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ report_id int(10) unsigned NOT NULL,
+ class varchar(255) NOT NULL,
+ ctime bigint(20) unsigned NOT NULL,
+ mtime bigint(20) unsigned NOT NULL,
+ PRIMARY KEY(id),
+ CONSTRAINT reportlet_report FOREIGN KEY (report_id) REFERENCES report (id) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
+
+CREATE TABLE config (
+ id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ reportlet_id int(10) unsigned NOT NULL,
+ name varchar(255) NOT NULL COLLATE utf8mb4_unicode_ci,
+ value text NULL DEFAULT NULL,
+ ctime bigint(20) unsigned NOT NULL,
+ mtime bigint(20) unsigned NOT NULL,
+ PRIMARY KEY(id),
+ CONSTRAINT config_reportlet FOREIGN KEY (reportlet_id) REFERENCES reportlet (id) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
+
+CREATE TABLE schedule (
+ id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ report_id int(10) unsigned NOT NULL,
+ author varchar(255) NOT NULL COLLATE utf8mb4_unicode_ci,
+ start bigint(20) unsigned NOT NULL,
+ frequency enum('minutely', 'hourly', 'daily', 'weekly', 'monthly'),
+ action varchar(255) NOT NULL,
+ config text NULL DEFAULT NULL,
+ ctime bigint(20) unsigned NOT NULL,
+ mtime bigint(20) unsigned NOT NULL,
+ PRIMARY KEY(id),
+ CONSTRAINT schedule_report FOREIGN KEY (report_id) REFERENCES report (id) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
+
+-- CREATE TABLE share (
+-- id int(10) unsigned NOT NULL AUTO_INCREMENT,
+-- report_id int(10) unsigned NOT NULL,
+-- username varchar(255) NOT NULL COLLATE utf8mb4_unicode_ci,
+-- restriction enum('none', 'owner', 'consumer'),
+-- ctime bigint(20) unsigned NOT NULL,
+-- mtime bigint(20) unsigned NOT NULL,
+-- PRIMARY KEY(id),
+-- CONSTRAINT share_report FOREIGN KEY (report_id) REFERENCES report (id) ON DELETE CASCADE ON UPDATE CASCADE
+-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
diff --git a/schema/postgresql.sql b/schema/postgresql.sql
new file mode 100644
index 0000000..329a65f
--- /dev/null
+++ b/schema/postgresql.sql
@@ -0,0 +1,83 @@
+CREATE OR REPLACE FUNCTION unix_timestamp(timestamp with time zone DEFAULT NOW()) RETURNS bigint
+ AS 'SELECT EXTRACT(EPOCH FROM $1)::bigint'
+ LANGUAGE SQL;
+
+CREATE TYPE frequency AS ENUM ('minutely', 'hourly', 'daily', 'weekly', 'monthly');
+
+CREATE TABLE template (
+ id serial PRIMARY KEY,
+ author varchar(255) NOT NULL,
+ name varchar(128) NOT NULL,
+ settings text NOT NULL,
+ ctime bigint NOT NULL,
+ mtime bigint NOT NULL
+);
+
+CREATE TABLE timeframe (
+ id serial PRIMARY KEY,
+ name varchar(128) NOT NULL UNIQUE,
+ title varchar(255) DEFAULT NULL,
+ start varchar(255) NOT NULL,
+ "end" varchar(255) NOT NULL,
+ ctime bigint NOT NULL DEFAULT unix_timestamp() * 1000,
+ mtime bigint NOT NULL DEFAULT unix_timestamp() * 1000
+);
+
+INSERT INTO timeframe (name, title, start, "end") VALUES
+ ('4 Hours', null, '-4 hours', 'now'),
+ ('25 Hours', null, '-25 hours', 'now'),
+ ('One Week', null, '-1 week', 'now'),
+ ('One Month', null, '-1 month', 'now'),
+ ('One Year', null, '-1 year', 'now'),
+ ('Current Day', null, 'midnight', 'now'),
+ ('Last Day', null, 'yesterday midnight', 'yesterday 23:59:59'),
+ ('Current Week', null, 'monday this week midnight', 'sunday this week 23:59:59'),
+ ('Last Week', null, 'monday last week midnight', 'sunday last week 23:59:59'),
+ ('Current Month', null, 'first day of this month midnight', 'now'),
+ ('Last Month', null, 'first day of last month midnight', 'last day of last month 23:59:59'),
+ ('Current Year', null, 'first day of January this year midnight', 'now'),
+ ('Last Year', null, 'first day of January last year midnight', 'last day of December last year 23:59:59');
+
+CREATE TABLE report (
+ id serial PRIMARY KEY,
+ timeframe_id int NOT NULL,
+ template_id int NULL DEFAULT NULL,
+ author varchar(255) NOT NULL,
+ name varchar(128) NOT NULL UNIQUE,
+ ctime bigint NOT NULL DEFAULT unix_timestamp() * 1000,
+ mtime bigint NOT NULL DEFAULT unix_timestamp() * 1000,
+ CONSTRAINT report_timeframe FOREIGN KEY (timeframe_id) REFERENCES timeframe (id),
+ CONSTRAINT report_template FOREIGN KEY (template_id) REFERENCES template (id)
+);
+
+CREATE TABLE reportlet (
+ id serial PRIMARY KEY,
+ report_id int NOT NULL,
+ class varchar(255) NOT NULL,
+ ctime bigint NOT NULL DEFAULT unix_timestamp() * 1000,
+ mtime bigint NOT NULL DEFAULT unix_timestamp() * 1000,
+ CONSTRAINT reportlet_report FOREIGN KEY (report_id) REFERENCES report (id) ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+CREATE TABLE config (
+ id serial PRIMARY KEY,
+ reportlet_id int NOT NULL,
+ name varchar(255) NOT NULL,
+ value text DEFAULT NULL,
+ ctime bigint NOT NULL DEFAULT unix_timestamp() * 1000,
+ mtime bigint NOT NULL DEFAULT unix_timestamp() * 1000,
+ CONSTRAINT config_reportlet FOREIGN KEY (reportlet_id) REFERENCES reportlet (id) ON DELETE CASCADE ON UPDATE CASCADE
+);
+
+CREATE TABLE schedule (
+ id serial PRIMARY KEY,
+ report_id int NOT NULL,
+ author varchar(255) NOT NULL,
+ start bigint NOT NULL,
+ frequency frequency,
+ action varchar(255) NOT NULL,
+ config text DEFAULT NULL,
+ ctime bigint NOT NULL DEFAULT unix_timestamp() * 1000,
+ mtime bigint NOT NULL DEFAULT unix_timestamp() * 1000,
+ CONSTRAINT schedule_report FOREIGN KEY (report_id) REFERENCES report (id) ON DELETE CASCADE ON UPDATE CASCADE
+);
diff --git a/vendor/autoload.php b/vendor/autoload.php
new file mode 100644
index 0000000..e74ef28
--- /dev/null
+++ b/vendor/autoload.php
@@ -0,0 +1,7 @@
+<?php
+
+// autoload.php @generated by Composer
+
+require_once __DIR__ . '/composer/autoload_real.php';
+
+return ComposerAutoloaderInitae69f138d27af1289714a48b26fe4147::getLoader();
diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php
new file mode 100644
index 0000000..fce8549
--- /dev/null
+++ b/vendor/composer/ClassLoader.php
@@ -0,0 +1,445 @@
+<?php
+
+/*
+ * This file is part of Composer.
+ *
+ * (c) Nils Adermann <naderman@naderman.de>
+ * Jordi Boggiano <j.boggiano@seld.be>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Composer\Autoload;
+
+/**
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
+ *
+ * $loader = new \Composer\Autoload\ClassLoader();
+ *
+ * // register classes with namespaces
+ * $loader->add('Symfony\Component', __DIR__.'/component');
+ * $loader->add('Symfony', __DIR__.'/framework');
+ *
+ * // activate the autoloader
+ * $loader->register();
+ *
+ * // to enable searching the include path (eg. for PEAR packages)
+ * $loader->setUseIncludePath(true);
+ *
+ * In this example, if you try to use a class in the Symfony\Component
+ * namespace or one of its children (Symfony\Component\Console for instance),
+ * the autoloader will first look for the class under the component/
+ * directory, and it will then fallback to the framework/ directory if not
+ * found before giving up.
+ *
+ * This class is loosely based on the Symfony UniversalClassLoader.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ * @author Jordi Boggiano <j.boggiano@seld.be>
+ * @see http://www.php-fig.org/psr/psr-0/
+ * @see http://www.php-fig.org/psr/psr-4/
+ */
+class ClassLoader
+{
+ // PSR-4
+ private $prefixLengthsPsr4 = array();
+ private $prefixDirsPsr4 = array();
+ private $fallbackDirsPsr4 = array();
+
+ // PSR-0
+ private $prefixesPsr0 = array();
+ private $fallbackDirsPsr0 = array();
+
+ private $useIncludePath = false;
+ private $classMap = array();
+ private $classMapAuthoritative = false;
+ private $missingClasses = array();
+ private $apcuPrefix;
+
+ public function getPrefixes()
+ {
+ if (!empty($this->prefixesPsr0)) {
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
+ }
+
+ return array();
+ }
+
+ public function getPrefixesPsr4()
+ {
+ return $this->prefixDirsPsr4;
+ }
+
+ public function getFallbackDirs()
+ {
+ return $this->fallbackDirsPsr0;
+ }
+
+ public function getFallbackDirsPsr4()
+ {
+ return $this->fallbackDirsPsr4;
+ }
+
+ public function getClassMap()
+ {
+ return $this->classMap;
+ }
+
+ /**
+ * @param array $classMap Class to filename map
+ */
+ public function addClassMap(array $classMap)
+ {
+ if ($this->classMap) {
+ $this->classMap = array_merge($this->classMap, $classMap);
+ } else {
+ $this->classMap = $classMap;
+ }
+ }
+
+ /**
+ * Registers a set of PSR-0 directories for a given prefix, either
+ * appending or prepending to the ones previously set for this prefix.
+ *
+ * @param string $prefix The prefix
+ * @param array|string $paths The PSR-0 root directories
+ * @param bool $prepend Whether to prepend the directories
+ */
+ public function add($prefix, $paths, $prepend = false)
+ {
+ if (!$prefix) {
+ if ($prepend) {
+ $this->fallbackDirsPsr0 = array_merge(
+ (array) $paths,
+ $this->fallbackDirsPsr0
+ );
+ } else {
+ $this->fallbackDirsPsr0 = array_merge(
+ $this->fallbackDirsPsr0,
+ (array) $paths
+ );
+ }
+
+ return;
+ }
+
+ $first = $prefix[0];
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
+
+ return;
+ }
+ if ($prepend) {
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
+ (array) $paths,
+ $this->prefixesPsr0[$first][$prefix]
+ );
+ } else {
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
+ $this->prefixesPsr0[$first][$prefix],
+ (array) $paths
+ );
+ }
+ }
+
+ /**
+ * Registers a set of PSR-4 directories for a given namespace, either
+ * appending or prepending to the ones previously set for this namespace.
+ *
+ * @param string $prefix The prefix/namespace, with trailing '\\'
+ * @param array|string $paths The PSR-4 base directories
+ * @param bool $prepend Whether to prepend the directories
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function addPsr4($prefix, $paths, $prepend = false)
+ {
+ if (!$prefix) {
+ // Register directories for the root namespace.
+ if ($prepend) {
+ $this->fallbackDirsPsr4 = array_merge(
+ (array) $paths,
+ $this->fallbackDirsPsr4
+ );
+ } else {
+ $this->fallbackDirsPsr4 = array_merge(
+ $this->fallbackDirsPsr4,
+ (array) $paths
+ );
+ }
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
+ // Register directories for a new namespace.
+ $length = strlen($prefix);
+ if ('\\' !== $prefix[$length - 1]) {
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
+ }
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
+ } elseif ($prepend) {
+ // Prepend directories for an already registered namespace.
+ $this->prefixDirsPsr4[$prefix] = array_merge(
+ (array) $paths,
+ $this->prefixDirsPsr4[$prefix]
+ );
+ } else {
+ // Append directories for an already registered namespace.
+ $this->prefixDirsPsr4[$prefix] = array_merge(
+ $this->prefixDirsPsr4[$prefix],
+ (array) $paths
+ );
+ }
+ }
+
+ /**
+ * Registers a set of PSR-0 directories for a given prefix,
+ * replacing any others previously set for this prefix.
+ *
+ * @param string $prefix The prefix
+ * @param array|string $paths The PSR-0 base directories
+ */
+ public function set($prefix, $paths)
+ {
+ if (!$prefix) {
+ $this->fallbackDirsPsr0 = (array) $paths;
+ } else {
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
+ }
+ }
+
+ /**
+ * Registers a set of PSR-4 directories for a given namespace,
+ * replacing any others previously set for this namespace.
+ *
+ * @param string $prefix The prefix/namespace, with trailing '\\'
+ * @param array|string $paths The PSR-4 base directories
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function setPsr4($prefix, $paths)
+ {
+ if (!$prefix) {
+ $this->fallbackDirsPsr4 = (array) $paths;
+ } else {
+ $length = strlen($prefix);
+ if ('\\' !== $prefix[$length - 1]) {
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
+ }
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
+ }
+ }
+
+ /**
+ * Turns on searching the include path for class files.
+ *
+ * @param bool $useIncludePath
+ */
+ public function setUseIncludePath($useIncludePath)
+ {
+ $this->useIncludePath = $useIncludePath;
+ }
+
+ /**
+ * Can be used to check if the autoloader uses the include path to check
+ * for classes.
+ *
+ * @return bool
+ */
+ public function getUseIncludePath()
+ {
+ return $this->useIncludePath;
+ }
+
+ /**
+ * Turns off searching the prefix and fallback directories for classes
+ * that have not been registered with the class map.
+ *
+ * @param bool $classMapAuthoritative
+ */
+ public function setClassMapAuthoritative($classMapAuthoritative)
+ {
+ $this->classMapAuthoritative = $classMapAuthoritative;
+ }
+
+ /**
+ * Should class lookup fail if not found in the current class map?
+ *
+ * @return bool
+ */
+ public function isClassMapAuthoritative()
+ {
+ return $this->classMapAuthoritative;
+ }
+
+ /**
+ * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
+ *
+ * @param string|null $apcuPrefix
+ */
+ public function setApcuPrefix($apcuPrefix)
+ {
+ $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
+ }
+
+ /**
+ * The APCu prefix in use, or null if APCu caching is not enabled.
+ *
+ * @return string|null
+ */
+ public function getApcuPrefix()
+ {
+ return $this->apcuPrefix;
+ }
+
+ /**
+ * Registers this instance as an autoloader.
+ *
+ * @param bool $prepend Whether to prepend the autoloader or not
+ */
+ public function register($prepend = false)
+ {
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
+ }
+
+ /**
+ * Unregisters this instance as an autoloader.
+ */
+ public function unregister()
+ {
+ spl_autoload_unregister(array($this, 'loadClass'));
+ }
+
+ /**
+ * Loads the given class or interface.
+ *
+ * @param string $class The name of the class
+ * @return bool|null True if loaded, null otherwise
+ */
+ public function loadClass($class)
+ {
+ if ($file = $this->findFile($class)) {
+ includeFile($file);
+
+ return true;
+ }
+ }
+
+ /**
+ * Finds the path to the file where the class is defined.
+ *
+ * @param string $class The name of the class
+ *
+ * @return string|false The path if found, false otherwise
+ */
+ public function findFile($class)
+ {
+ // class map lookup
+ if (isset($this->classMap[$class])) {
+ return $this->classMap[$class];
+ }
+ if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
+ return false;
+ }
+ if (null !== $this->apcuPrefix) {
+ $file = apcu_fetch($this->apcuPrefix.$class, $hit);
+ if ($hit) {
+ return $file;
+ }
+ }
+
+ $file = $this->findFileWithExtension($class, '.php');
+
+ // Search for Hack files if we are running on HHVM
+ if (false === $file && defined('HHVM_VERSION')) {
+ $file = $this->findFileWithExtension($class, '.hh');
+ }
+
+ if (null !== $this->apcuPrefix) {
+ apcu_add($this->apcuPrefix.$class, $file);
+ }
+
+ if (false === $file) {
+ // Remember that this class does not exist.
+ $this->missingClasses[$class] = true;
+ }
+
+ return $file;
+ }
+
+ private function findFileWithExtension($class, $ext)
+ {
+ // PSR-4 lookup
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
+
+ $first = $class[0];
+ if (isset($this->prefixLengthsPsr4[$first])) {
+ $subPath = $class;
+ while (false !== $lastPos = strrpos($subPath, '\\')) {
+ $subPath = substr($subPath, 0, $lastPos);
+ $search = $subPath . '\\';
+ if (isset($this->prefixDirsPsr4[$search])) {
+ $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
+ foreach ($this->prefixDirsPsr4[$search] as $dir) {
+ if (file_exists($file = $dir . $pathEnd)) {
+ return $file;
+ }
+ }
+ }
+ }
+ }
+
+ // PSR-4 fallback dirs
+ foreach ($this->fallbackDirsPsr4 as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
+ return $file;
+ }
+ }
+
+ // PSR-0 lookup
+ if (false !== $pos = strrpos($class, '\\')) {
+ // namespaced class name
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
+ } else {
+ // PEAR-like class name
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
+ }
+
+ if (isset($this->prefixesPsr0[$first])) {
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
+ if (0 === strpos($class, $prefix)) {
+ foreach ($dirs as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
+ return $file;
+ }
+ }
+ }
+ }
+ }
+
+ // PSR-0 fallback dirs
+ foreach ($this->fallbackDirsPsr0 as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
+ return $file;
+ }
+ }
+
+ // PSR-0 include paths.
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
+ return $file;
+ }
+
+ return false;
+ }
+}
+
+/**
+ * Scope isolated include.
+ *
+ * Prevents access to $this/self from included files.
+ */
+function includeFile($file)
+{
+ include $file;
+}
diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE
new file mode 100644
index 0000000..f27399a
--- /dev/null
+++ b/vendor/composer/LICENSE
@@ -0,0 +1,21 @@
+
+Copyright (c) Nils Adermann, Jordi Boggiano
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php
new file mode 100644
index 0000000..7a91153
--- /dev/null
+++ b/vendor/composer/autoload_classmap.php
@@ -0,0 +1,9 @@
+<?php
+
+// autoload_classmap.php @generated by Composer
+
+$vendorDir = dirname(dirname(__FILE__));
+$baseDir = dirname($vendorDir);
+
+return array(
+);
diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php
new file mode 100644
index 0000000..e183d0e
--- /dev/null
+++ b/vendor/composer/autoload_files.php
@@ -0,0 +1,11 @@
+<?php
+
+// autoload_files.php @generated by Composer
+
+$vendorDir = dirname(dirname(__FILE__));
+$baseDir = dirname($vendorDir);
+
+return array(
+ '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
+ 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
+);
diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php
new file mode 100644
index 0000000..b7fc012
--- /dev/null
+++ b/vendor/composer/autoload_namespaces.php
@@ -0,0 +1,9 @@
+<?php
+
+// autoload_namespaces.php @generated by Composer
+
+$vendorDir = dirname(dirname(__FILE__));
+$baseDir = dirname($vendorDir);
+
+return array(
+);
diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php
new file mode 100644
index 0000000..ae02f9e
--- /dev/null
+++ b/vendor/composer/autoload_psr4.php
@@ -0,0 +1,11 @@
+<?php
+
+// autoload_psr4.php @generated by Composer
+
+$vendorDir = dirname(dirname(__FILE__));
+$baseDir = dirname($vendorDir);
+
+return array(
+ 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
+ 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
+);
diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php
new file mode 100644
index 0000000..b8c603a
--- /dev/null
+++ b/vendor/composer/autoload_real.php
@@ -0,0 +1,70 @@
+<?php
+
+// autoload_real.php @generated by Composer
+
+class ComposerAutoloaderInitae69f138d27af1289714a48b26fe4147
+{
+ private static $loader;
+
+ public static function loadClassLoader($class)
+ {
+ if ('Composer\Autoload\ClassLoader' === $class) {
+ require __DIR__ . '/ClassLoader.php';
+ }
+ }
+
+ public static function getLoader()
+ {
+ if (null !== self::$loader) {
+ return self::$loader;
+ }
+
+ spl_autoload_register(array('ComposerAutoloaderInitae69f138d27af1289714a48b26fe4147', 'loadClassLoader'), true, true);
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader();
+ spl_autoload_unregister(array('ComposerAutoloaderInitae69f138d27af1289714a48b26fe4147', 'loadClassLoader'));
+
+ $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
+ if ($useStaticLoader) {
+ require_once __DIR__ . '/autoload_static.php';
+
+ call_user_func(\Composer\Autoload\ComposerStaticInitae69f138d27af1289714a48b26fe4147::getInitializer($loader));
+ } else {
+ $map = require __DIR__ . '/autoload_namespaces.php';
+ foreach ($map as $namespace => $path) {
+ $loader->set($namespace, $path);
+ }
+
+ $map = require __DIR__ . '/autoload_psr4.php';
+ foreach ($map as $namespace => $path) {
+ $loader->setPsr4($namespace, $path);
+ }
+
+ $classMap = require __DIR__ . '/autoload_classmap.php';
+ if ($classMap) {
+ $loader->addClassMap($classMap);
+ }
+ }
+
+ $loader->register(true);
+
+ if ($useStaticLoader) {
+ $includeFiles = Composer\Autoload\ComposerStaticInitae69f138d27af1289714a48b26fe4147::$files;
+ } else {
+ $includeFiles = require __DIR__ . '/autoload_files.php';
+ }
+ foreach ($includeFiles as $fileIdentifier => $file) {
+ composerRequireae69f138d27af1289714a48b26fe4147($fileIdentifier, $file);
+ }
+
+ return $loader;
+ }
+}
+
+function composerRequireae69f138d27af1289714a48b26fe4147($fileIdentifier, $file)
+{
+ if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
+ require $file;
+
+ $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
+ }
+}
diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php
new file mode 100644
index 0000000..2c6b62f
--- /dev/null
+++ b/vendor/composer/autoload_static.php
@@ -0,0 +1,44 @@
+<?php
+
+// autoload_static.php @generated by Composer
+
+namespace Composer\Autoload;
+
+class ComposerStaticInitae69f138d27af1289714a48b26fe4147
+{
+ public static $files = array (
+ '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
+ 'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
+ );
+
+ public static $prefixLengthsPsr4 = array (
+ 'P' =>
+ array (
+ 'Psr\\Http\\Message\\' => 17,
+ ),
+ 'G' =>
+ array (
+ 'GuzzleHttp\\Psr7\\' => 16,
+ ),
+ );
+
+ public static $prefixDirsPsr4 = array (
+ 'Psr\\Http\\Message\\' =>
+ array (
+ 0 => __DIR__ . '/..' . '/psr/http-message/src',
+ ),
+ 'GuzzleHttp\\Psr7\\' =>
+ array (
+ 0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
+ ),
+ );
+
+ public static function getInitializer(ClassLoader $loader)
+ {
+ return \Closure::bind(function () use ($loader) {
+ $loader->prefixLengthsPsr4 = ComposerStaticInitae69f138d27af1289714a48b26fe4147::$prefixLengthsPsr4;
+ $loader->prefixDirsPsr4 = ComposerStaticInitae69f138d27af1289714a48b26fe4147::$prefixDirsPsr4;
+
+ }, null, ClassLoader::class);
+ }
+}
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
new file mode 100644
index 0000000..ab54942
--- /dev/null
+++ b/vendor/composer/installed.json
@@ -0,0 +1,169 @@
+[
+ {
+ "name": "guzzlehttp/psr7",
+ "version": "1.6.1",
+ "version_normalized": "1.6.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/psr7.git",
+ "reference": "239400de7a173fe9901b9ac7c06497751f00727a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a",
+ "reference": "239400de7a173fe9901b9ac7c06497751f00727a",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.4.0",
+ "psr/http-message": "~1.0",
+ "ralouphie/getallheaders": "^2.0.5 || ^3.0.0"
+ },
+ "provide": {
+ "psr/http-message-implementation": "1.0"
+ },
+ "require-dev": {
+ "ext-zlib": "*",
+ "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8"
+ },
+ "suggest": {
+ "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses"
+ },
+ "time": "2019-07-01T23:21:34+00:00",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.6-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-4": {
+ "GuzzleHttp\\Psr7\\": "src/"
+ },
+ "files": [
+ "src/functions_include.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ },
+ {
+ "name": "Tobias Schultze",
+ "homepage": "https://github.com/Tobion"
+ }
+ ],
+ "description": "PSR-7 message implementation that also provides common utility methods",
+ "keywords": [
+ "http",
+ "message",
+ "psr-7",
+ "request",
+ "response",
+ "stream",
+ "uri",
+ "url"
+ ]
+ },
+ {
+ "name": "psr/http-message",
+ "version": "1.0.1",
+ "version_normalized": "1.0.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/http-message.git",
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "time": "2016-08-06T14:39:51+00:00",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-4": {
+ "Psr\\Http\\Message\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for HTTP messages",
+ "homepage": "https://github.com/php-fig/http-message",
+ "keywords": [
+ "http",
+ "http-message",
+ "psr",
+ "psr-7",
+ "request",
+ "response"
+ ]
+ },
+ {
+ "name": "ralouphie/getallheaders",
+ "version": "3.0.3",
+ "version_normalized": "3.0.3.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/ralouphie/getallheaders.git",
+ "reference": "120b605dfeb996808c31b6477290a714d356e822"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
+ "reference": "120b605dfeb996808c31b6477290a714d356e822",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.6"
+ },
+ "require-dev": {
+ "php-coveralls/php-coveralls": "^2.1",
+ "phpunit/phpunit": "^5 || ^6.5"
+ },
+ "time": "2019-03-08T08:55:37+00:00",
+ "type": "library",
+ "installation-source": "dist",
+ "autoload": {
+ "files": [
+ "src/getallheaders.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Ralph Khattar",
+ "email": "ralph.khattar@gmail.com"
+ }
+ ],
+ "description": "A polyfill for getallheaders."
+ }
+]
diff --git a/vendor/guzzlehttp/psr7/CHANGELOG.md b/vendor/guzzlehttp/psr7/CHANGELOG.md
new file mode 100644
index 0000000..8a3743d
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/CHANGELOG.md
@@ -0,0 +1,246 @@
+# Change Log
+
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
+and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+
+
+## [Unreleased]
+
+
+## [1.6.0]
+
+### Added
+
+- Allowed version `^3.0` of `ralouphie/getallheaders` dependency (#244)
+- Added MIME type for WEBP image format (#246)
+- Added more validation of values according to PSR-7 and RFC standards, e.g. status code range (#250, #272)
+
+### Changed
+
+- Tests don't pass with HHVM 4.0, so HHVM support got dropped. Other libraries like composer have done the same. (#262)
+- Accept port number 0 to be valid (#270)
+
+### Fixed
+
+- Fixed subsequent reads from `php://input` in ServerRequest (#247)
+- Fixed readable/writable detection for certain stream modes (#248)
+- Fixed encoding of special characters in the `userInfo` component of an URI (#253)
+
+
+## [1.5.2] - 2018-12-04
+
+### Fixed
+
+- Check body size when getting the message summary
+
+
+## [1.5.1] - 2018-12-04
+
+### Fixed
+
+- Get the summary of a body only if it is readable
+
+
+## [1.5.0] - 2018-12-03
+
+### Added
+
+- Response first-line to response string exception (fixes #145)
+- A test for #129 behavior
+- `get_message_body_summary` function in order to get the message summary
+- `3gp` and `mkv` mime types
+
+### Changed
+
+- Clarify exception message when stream is detached
+
+### Deprecated
+
+- Deprecated parsing folded header lines as per RFC 7230
+
+### Fixed
+
+- Fix `AppendStream::detach` to not close streams
+- `InflateStream` preserves `isSeekable` attribute of the underlying stream
+- `ServerRequest::getUriFromGlobals` to support URLs in query parameters
+
+
+Several other fixes and improvements.
+
+
+## [1.4.2] - 2017-03-20
+
+### Fixed
+
+- Reverted BC break to `Uri::resolve` and `Uri::removeDotSegments` by removing
+ calls to `trigger_error` when deprecated methods are invoked.
+
+
+## [1.4.1] - 2017-02-27
+
+### Added
+
+- Rriggering of silenced deprecation warnings.
+
+### Fixed
+
+- Reverted BC break by reintroducing behavior to automagically fix a URI with a
+ relative path and an authority by adding a leading slash to the path. It's only
+ deprecated now.
+
+
+## [1.4.0] - 2017-02-21
+
+### Added
+
+- Added common URI utility methods based on RFC 3986 (see documentation in the readme):
+ - `Uri::isDefaultPort`
+ - `Uri::isAbsolute`
+ - `Uri::isNetworkPathReference`
+ - `Uri::isAbsolutePathReference`
+ - `Uri::isRelativePathReference`
+ - `Uri::isSameDocumentReference`
+ - `Uri::composeComponents`
+ - `UriNormalizer::normalize`
+ - `UriNormalizer::isEquivalent`
+ - `UriResolver::relativize`
+
+### Changed
+
+- Ensure `ServerRequest::getUriFromGlobals` returns a URI in absolute form.
+- Allow `parse_response` to parse a response without delimiting space and reason.
+- Ensure each URI modification results in a valid URI according to PSR-7 discussions.
+ Invalid modifications will throw an exception instead of returning a wrong URI or
+ doing some magic.
+ - `(new Uri)->withPath('foo')->withHost('example.com')` will throw an exception
+ because the path of a URI with an authority must start with a slash "/" or be empty
+ - `(new Uri())->withScheme('http')` will return `'http://localhost'`
+
+### Deprecated
+
+- `Uri::resolve` in favor of `UriResolver::resolve`
+- `Uri::removeDotSegments` in favor of `UriResolver::removeDotSegments`
+
+### Fixed
+
+- `Stream::read` when length parameter <= 0.
+- `copy_to_stream` reads bytes in chunks instead of `maxLen` into memory.
+- `ServerRequest::getUriFromGlobals` when `Host` header contains port.
+- Compatibility of URIs with `file` scheme and empty host.
+
+
+## [1.3.1] - 2016-06-25
+
+### Fixed
+
+- `Uri::__toString` for network path references, e.g. `//example.org`.
+- Missing lowercase normalization for host.
+- Handling of URI components in case they are `'0'` in a lot of places,
+ e.g. as a user info password.
+- `Uri::withAddedHeader` to correctly merge headers with different case.
+- Trimming of header values in `Uri::withAddedHeader`. Header values may
+ be surrounded by whitespace which should be ignored according to RFC 7230
+ Section 3.2.4. This does not apply to header names.
+- `Uri::withAddedHeader` with an array of header values.
+- `Uri::resolve` when base path has no slash and handling of fragment.
+- Handling of encoding in `Uri::with(out)QueryValue` so one can pass the
+ key/value both in encoded as well as decoded form to those methods. This is
+ consistent with withPath, withQuery etc.
+- `ServerRequest::withoutAttribute` when attribute value is null.
+
+
+## [1.3.0] - 2016-04-13
+
+### Added
+
+- Remaining interfaces needed for full PSR7 compatibility
+ (ServerRequestInterface, UploadedFileInterface, etc.).
+- Support for stream_for from scalars.
+
+### Changed
+
+- Can now extend Uri.
+
+### Fixed
+- A bug in validating request methods by making it more permissive.
+
+
+## [1.2.3] - 2016-02-18
+
+### Fixed
+
+- Support in `GuzzleHttp\Psr7\CachingStream` for seeking forward on remote
+ streams, which can sometimes return fewer bytes than requested with `fread`.
+- Handling of gzipped responses with FNAME headers.
+
+
+## [1.2.2] - 2016-01-22
+
+### Added
+
+- Support for URIs without any authority.
+- Support for HTTP 451 'Unavailable For Legal Reasons.'
+- Support for using '0' as a filename.
+- Support for including non-standard ports in Host headers.
+
+
+## [1.2.1] - 2015-11-02
+
+### Changes
+
+- Now supporting negative offsets when seeking to SEEK_END.
+
+
+## [1.2.0] - 2015-08-15
+
+### Changed
+
+- Body as `"0"` is now properly added to a response.
+- Now allowing forward seeking in CachingStream.
+- Now properly parsing HTTP requests that contain proxy targets in
+ `parse_request`.
+- functions.php is now conditionally required.
+- user-info is no longer dropped when resolving URIs.
+
+
+## [1.1.0] - 2015-06-24
+
+### Changed
+
+- URIs can now be relative.
+- `multipart/form-data` headers are now overridden case-insensitively.
+- URI paths no longer encode the following characters because they are allowed
+ in URIs: "(", ")", "*", "!", "'"
+- A port is no longer added to a URI when the scheme is missing and no port is
+ present.
+
+
+## 1.0.0 - 2015-05-19
+
+Initial release.
+
+Currently unsupported:
+
+- `Psr\Http\Message\ServerRequestInterface`
+- `Psr\Http\Message\UploadedFileInterface`
+
+
+
+[Unreleased]: https://github.com/guzzle/psr7/compare/1.6.0...HEAD
+[1.6.0]: https://github.com/guzzle/psr7/compare/1.5.2...1.6.0
+[1.5.2]: https://github.com/guzzle/psr7/compare/1.5.1...1.5.2
+[1.5.1]: https://github.com/guzzle/psr7/compare/1.5.0...1.5.1
+[1.5.0]: https://github.com/guzzle/psr7/compare/1.4.2...1.5.0
+[1.4.2]: https://github.com/guzzle/psr7/compare/1.4.1...1.4.2
+[1.4.1]: https://github.com/guzzle/psr7/compare/1.4.0...1.4.1
+[1.4.0]: https://github.com/guzzle/psr7/compare/1.3.1...1.4.0
+[1.3.1]: https://github.com/guzzle/psr7/compare/1.3.0...1.3.1
+[1.3.0]: https://github.com/guzzle/psr7/compare/1.2.3...1.3.0
+[1.2.3]: https://github.com/guzzle/psr7/compare/1.2.2...1.2.3
+[1.2.2]: https://github.com/guzzle/psr7/compare/1.2.1...1.2.2
+[1.2.1]: https://github.com/guzzle/psr7/compare/1.2.0...1.2.1
+[1.2.0]: https://github.com/guzzle/psr7/compare/1.1.0...1.2.0
+[1.1.0]: https://github.com/guzzle/psr7/compare/1.0.0...1.1.0
diff --git a/vendor/guzzlehttp/psr7/LICENSE b/vendor/guzzlehttp/psr7/LICENSE
new file mode 100644
index 0000000..581d95f
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2015 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/vendor/guzzlehttp/psr7/README.md b/vendor/guzzlehttp/psr7/README.md
new file mode 100644
index 0000000..c60a6a3
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/README.md
@@ -0,0 +1,745 @@
+# PSR-7 Message Implementation
+
+This repository contains a full [PSR-7](http://www.php-fig.org/psr/psr-7/)
+message implementation, several stream decorators, and some helpful
+functionality like query string parsing.
+
+
+[![Build Status](https://travis-ci.org/guzzle/psr7.svg?branch=master)](https://travis-ci.org/guzzle/psr7)
+
+
+# Stream implementation
+
+This package comes with a number of stream implementations and stream
+decorators.
+
+
+## AppendStream
+
+`GuzzleHttp\Psr7\AppendStream`
+
+Reads from multiple streams, one after the other.
+
+```php
+use GuzzleHttp\Psr7;
+
+$a = Psr7\stream_for('abc, ');
+$b = Psr7\stream_for('123.');
+$composed = new Psr7\AppendStream([$a, $b]);
+
+$composed->addStream(Psr7\stream_for(' Above all listen to me'));
+
+echo $composed; // abc, 123. Above all listen to me.
+```
+
+
+## BufferStream
+
+`GuzzleHttp\Psr7\BufferStream`
+
+Provides a buffer stream that can be written to fill a buffer, and read
+from to remove bytes from the buffer.
+
+This stream returns a "hwm" metadata value that tells upstream consumers
+what the configured high water mark of the stream is, or the maximum
+preferred size of the buffer.
+
+```php
+use GuzzleHttp\Psr7;
+
+// When more than 1024 bytes are in the buffer, it will begin returning
+// false to writes. This is an indication that writers should slow down.
+$buffer = new Psr7\BufferStream(1024);
+```
+
+
+## CachingStream
+
+The CachingStream is used to allow seeking over previously read bytes on
+non-seekable streams. This can be useful when transferring a non-seekable
+entity body fails due to needing to rewind the stream (for example, resulting
+from a redirect). Data that is read from the remote stream will be buffered in
+a PHP temp stream so that previously read bytes are cached first in memory,
+then on disk.
+
+```php
+use GuzzleHttp\Psr7;
+
+$original = Psr7\stream_for(fopen('http://www.google.com', 'r'));
+$stream = new Psr7\CachingStream($original);
+
+$stream->read(1024);
+echo $stream->tell();
+// 1024
+
+$stream->seek(0);
+echo $stream->tell();
+// 0
+```
+
+
+## DroppingStream
+
+`GuzzleHttp\Psr7\DroppingStream`
+
+Stream decorator that begins dropping data once the size of the underlying
+stream becomes too full.
+
+```php
+use GuzzleHttp\Psr7;
+
+// Create an empty stream
+$stream = Psr7\stream_for();
+
+// Start dropping data when the stream has more than 10 bytes
+$dropping = new Psr7\DroppingStream($stream, 10);
+
+$dropping->write('01234567890123456789');
+echo $stream; // 0123456789
+```
+
+
+## FnStream
+
+`GuzzleHttp\Psr7\FnStream`
+
+Compose stream implementations based on a hash of functions.
+
+Allows for easy testing and extension of a provided stream without needing
+to create a concrete class for a simple extension point.
+
+```php
+
+use GuzzleHttp\Psr7;
+
+$stream = Psr7\stream_for('hi');
+$fnStream = Psr7\FnStream::decorate($stream, [
+ 'rewind' => function () use ($stream) {
+ echo 'About to rewind - ';
+ $stream->rewind();
+ echo 'rewound!';
+ }
+]);
+
+$fnStream->rewind();
+// Outputs: About to rewind - rewound!
+```
+
+
+## InflateStream
+
+`GuzzleHttp\Psr7\InflateStream`
+
+Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
+
+This stream decorator skips the first 10 bytes of the given stream to remove
+the gzip header, converts the provided stream to a PHP stream resource,
+then appends the zlib.inflate filter. The stream is then converted back
+to a Guzzle stream resource to be used as a Guzzle stream.
+
+
+## LazyOpenStream
+
+`GuzzleHttp\Psr7\LazyOpenStream`
+
+Lazily reads or writes to a file that is opened only after an IO operation
+take place on the stream.
+
+```php
+use GuzzleHttp\Psr7;
+
+$stream = new Psr7\LazyOpenStream('/path/to/file', 'r');
+// The file has not yet been opened...
+
+echo $stream->read(10);
+// The file is opened and read from only when needed.
+```
+
+
+## LimitStream
+
+`GuzzleHttp\Psr7\LimitStream`
+
+LimitStream can be used to read a subset or slice of an existing stream object.
+This can be useful for breaking a large file into smaller pieces to be sent in
+chunks (e.g. Amazon S3's multipart upload API).
+
+```php
+use GuzzleHttp\Psr7;
+
+$original = Psr7\stream_for(fopen('/tmp/test.txt', 'r+'));
+echo $original->getSize();
+// >>> 1048576
+
+// Limit the size of the body to 1024 bytes and start reading from byte 2048
+$stream = new Psr7\LimitStream($original, 1024, 2048);
+echo $stream->getSize();
+// >>> 1024
+echo $stream->tell();
+// >>> 0
+```
+
+
+## MultipartStream
+
+`GuzzleHttp\Psr7\MultipartStream`
+
+Stream that when read returns bytes for a streaming multipart or
+multipart/form-data stream.
+
+
+## NoSeekStream
+
+`GuzzleHttp\Psr7\NoSeekStream`
+
+NoSeekStream wraps a stream and does not allow seeking.
+
+```php
+use GuzzleHttp\Psr7;
+
+$original = Psr7\stream_for('foo');
+$noSeek = new Psr7\NoSeekStream($original);
+
+echo $noSeek->read(3);
+// foo
+var_export($noSeek->isSeekable());
+// false
+$noSeek->seek(0);
+var_export($noSeek->read(3));
+// NULL
+```
+
+
+## PumpStream
+
+`GuzzleHttp\Psr7\PumpStream`
+
+Provides a read only stream that pumps data from a PHP callable.
+
+When invoking the provided callable, the PumpStream will pass the amount of
+data requested to read to the callable. The callable can choose to ignore
+this value and return fewer or more bytes than requested. Any extra data
+returned by the provided callable is buffered internally until drained using
+the read() function of the PumpStream. The provided callable MUST return
+false when there is no more data to read.
+
+
+## Implementing stream decorators
+
+Creating a stream decorator is very easy thanks to the
+`GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that
+implement `Psr\Http\Message\StreamInterface` by proxying to an underlying
+stream. Just `use` the `StreamDecoratorTrait` and implement your custom
+methods.
+
+For example, let's say we wanted to call a specific function each time the last
+byte is read from a stream. This could be implemented by overriding the
+`read()` method.
+
+```php
+use Psr\Http\Message\StreamInterface;
+use GuzzleHttp\Psr7\StreamDecoratorTrait;
+
+class EofCallbackStream implements StreamInterface
+{
+ use StreamDecoratorTrait;
+
+ private $callback;
+
+ public function __construct(StreamInterface $stream, callable $cb)
+ {
+ $this->stream = $stream;
+ $this->callback = $cb;
+ }
+
+ public function read($length)
+ {
+ $result = $this->stream->read($length);
+
+ // Invoke the callback when EOF is hit.
+ if ($this->eof()) {
+ call_user_func($this->callback);
+ }
+
+ return $result;
+ }
+}
+```
+
+This decorator could be added to any existing stream and used like so:
+
+```php
+use GuzzleHttp\Psr7;
+
+$original = Psr7\stream_for('foo');
+
+$eofStream = new EofCallbackStream($original, function () {
+ echo 'EOF!';
+});
+
+$eofStream->read(2);
+$eofStream->read(1);
+// echoes "EOF!"
+$eofStream->seek(0);
+$eofStream->read(3);
+// echoes "EOF!"
+```
+
+
+## PHP StreamWrapper
+
+You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a
+PSR-7 stream as a PHP stream resource.
+
+Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP
+stream from a PSR-7 stream.
+
+```php
+use GuzzleHttp\Psr7\StreamWrapper;
+
+$stream = GuzzleHttp\Psr7\stream_for('hello!');
+$resource = StreamWrapper::getResource($stream);
+echo fread($resource, 6); // outputs hello!
+```
+
+
+# Function API
+
+There are various functions available under the `GuzzleHttp\Psr7` namespace.
+
+
+## `function str`
+
+`function str(MessageInterface $message)`
+
+Returns the string representation of an HTTP message.
+
+```php
+$request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com');
+echo GuzzleHttp\Psr7\str($request);
+```
+
+
+## `function uri_for`
+
+`function uri_for($uri)`
+
+This function accepts a string or `Psr\Http\Message\UriInterface` and returns a
+UriInterface for the given value. If the value is already a `UriInterface`, it
+is returned as-is.
+
+```php
+$uri = GuzzleHttp\Psr7\uri_for('http://example.com');
+assert($uri === GuzzleHttp\Psr7\uri_for($uri));
+```
+
+
+## `function stream_for`
+
+`function stream_for($resource = '', array $options = [])`
+
+Create a new stream based on the input type.
+
+Options is an associative array that can contain the following keys:
+
+* - metadata: Array of custom metadata.
+* - size: Size of the stream.
+
+This method accepts the following `$resource` types:
+
+- `Psr\Http\Message\StreamInterface`: Returns the value as-is.
+- `string`: Creates a stream object that uses the given string as the contents.
+- `resource`: Creates a stream object that wraps the given PHP stream resource.
+- `Iterator`: If the provided value implements `Iterator`, then a read-only
+ stream object will be created that wraps the given iterable. Each time the
+ stream is read from, data from the iterator will fill a buffer and will be
+ continuously called until the buffer is equal to the requested read size.
+ Subsequent read calls will first read from the buffer and then call `next`
+ on the underlying iterator until it is exhausted.
+- `object` with `__toString()`: If the object has the `__toString()` method,
+ the object will be cast to a string and then a stream will be returned that
+ uses the string value.
+- `NULL`: When `null` is passed, an empty stream object is returned.
+- `callable` When a callable is passed, a read-only stream object will be
+ created that invokes the given callable. The callable is invoked with the
+ number of suggested bytes to read. The callable can return any number of
+ bytes, but MUST return `false` when there is no more data to return. The
+ stream object that wraps the callable will invoke the callable until the
+ number of requested bytes are available. Any additional bytes will be
+ buffered and used in subsequent reads.
+
+```php
+$stream = GuzzleHttp\Psr7\stream_for('foo');
+$stream = GuzzleHttp\Psr7\stream_for(fopen('/path/to/file', 'r'));
+
+$generator = function ($bytes) {
+ for ($i = 0; $i < $bytes; $i++) {
+ yield ' ';
+ }
+}
+
+$stream = GuzzleHttp\Psr7\stream_for($generator(100));
+```
+
+
+## `function parse_header`
+
+`function parse_header($header)`
+
+Parse an array of header values containing ";" separated data into an array of
+associative arrays representing the header key value pair data of the header.
+When a parameter does not contain a value, but just contains a key, this
+function will inject a key with a '' string value.
+
+
+## `function normalize_header`
+
+`function normalize_header($header)`
+
+Converts an array of header values that may contain comma separated headers
+into an array of headers with no comma separated values.
+
+
+## `function modify_request`
+
+`function modify_request(RequestInterface $request, array $changes)`
+
+Clone and modify a request with the given changes. This method is useful for
+reducing the number of clones needed to mutate a message.
+
+The changes can be one of:
+
+- method: (string) Changes the HTTP method.
+- set_headers: (array) Sets the given headers.
+- remove_headers: (array) Remove the given headers.
+- body: (mixed) Sets the given body.
+- uri: (UriInterface) Set the URI.
+- query: (string) Set the query string value of the URI.
+- version: (string) Set the protocol version.
+
+
+## `function rewind_body`
+
+`function rewind_body(MessageInterface $message)`
+
+Attempts to rewind a message body and throws an exception on failure. The body
+of the message will only be rewound if a call to `tell()` returns a value other
+than `0`.
+
+
+## `function try_fopen`
+
+`function try_fopen($filename, $mode)`
+
+Safely opens a PHP stream resource using a filename.
+
+When fopen fails, PHP normally raises a warning. This function adds an error
+handler that checks for errors and throws an exception instead.
+
+
+## `function copy_to_string`
+
+`function copy_to_string(StreamInterface $stream, $maxLen = -1)`
+
+Copy the contents of a stream into a string until the given number of bytes
+have been read.
+
+
+## `function copy_to_stream`
+
+`function copy_to_stream(StreamInterface $source, StreamInterface $dest, $maxLen = -1)`
+
+Copy the contents of a stream into another stream until the given number of
+bytes have been read.
+
+
+## `function hash`
+
+`function hash(StreamInterface $stream, $algo, $rawOutput = false)`
+
+Calculate a hash of a Stream. This method reads the entire stream to calculate
+a rolling hash (based on PHP's hash_init functions).
+
+
+## `function readline`
+
+`function readline(StreamInterface $stream, $maxLength = null)`
+
+Read a line from the stream up to the maximum allowed buffer length.
+
+
+## `function parse_request`
+
+`function parse_request($message)`
+
+Parses a request message string into a request object.
+
+
+## `function parse_response`
+
+`function parse_response($message)`
+
+Parses a response message string into a response object.
+
+
+## `function parse_query`
+
+`function parse_query($str, $urlEncoding = true)`
+
+Parse a query string into an associative array.
+
+If multiple values are found for the same key, the value of that key value pair
+will become an array. This function does not parse nested PHP style arrays into
+an associative array (e.g., `foo[a]=1&foo[b]=2` will be parsed into
+`['foo[a]' => '1', 'foo[b]' => '2']`).
+
+
+## `function build_query`
+
+`function build_query(array $params, $encoding = PHP_QUERY_RFC3986)`
+
+Build a query string from an array of key value pairs.
+
+This function can use the return value of parse_query() to build a query string.
+This function does not modify the provided keys when an array is encountered
+(like http_build_query would).
+
+
+## `function mimetype_from_filename`
+
+`function mimetype_from_filename($filename)`
+
+Determines the mimetype of a file by looking at its extension.
+
+
+## `function mimetype_from_extension`
+
+`function mimetype_from_extension($extension)`
+
+Maps a file extensions to a mimetype.
+
+
+# Additional URI Methods
+
+Aside from the standard `Psr\Http\Message\UriInterface` implementation in form of the `GuzzleHttp\Psr7\Uri` class,
+this library also provides additional functionality when working with URIs as static methods.
+
+## URI Types
+
+An instance of `Psr\Http\Message\UriInterface` can either be an absolute URI or a relative reference.
+An absolute URI has a scheme. A relative reference is used to express a URI relative to another URI,
+the base URI. Relative references can be divided into several forms according to
+[RFC 3986 Section 4.2](https://tools.ietf.org/html/rfc3986#section-4.2):
+
+- network-path references, e.g. `//example.com/path`
+- absolute-path references, e.g. `/path`
+- relative-path references, e.g. `subpath`
+
+The following methods can be used to identify the type of the URI.
+
+### `GuzzleHttp\Psr7\Uri::isAbsolute`
+
+`public static function isAbsolute(UriInterface $uri): bool`
+
+Whether the URI is absolute, i.e. it has a scheme.
+
+### `GuzzleHttp\Psr7\Uri::isNetworkPathReference`
+
+`public static function isNetworkPathReference(UriInterface $uri): bool`
+
+Whether the URI is a network-path reference. A relative reference that begins with two slash characters is
+termed an network-path reference.
+
+### `GuzzleHttp\Psr7\Uri::isAbsolutePathReference`
+
+`public static function isAbsolutePathReference(UriInterface $uri): bool`
+
+Whether the URI is a absolute-path reference. A relative reference that begins with a single slash character is
+termed an absolute-path reference.
+
+### `GuzzleHttp\Psr7\Uri::isRelativePathReference`
+
+`public static function isRelativePathReference(UriInterface $uri): bool`
+
+Whether the URI is a relative-path reference. A relative reference that does not begin with a slash character is
+termed a relative-path reference.
+
+### `GuzzleHttp\Psr7\Uri::isSameDocumentReference`
+
+`public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null): bool`
+
+Whether the URI is a same-document reference. A same-document reference refers to a URI that is, aside from its
+fragment component, identical to the base URI. When no base URI is given, only an empty URI reference
+(apart from its fragment) is considered a same-document reference.
+
+## URI Components
+
+Additional methods to work with URI components.
+
+### `GuzzleHttp\Psr7\Uri::isDefaultPort`
+
+`public static function isDefaultPort(UriInterface $uri): bool`
+
+Whether the URI has the default port of the current scheme. `Psr\Http\Message\UriInterface::getPort` may return null
+or the standard port. This method can be used independently of the implementation.
+
+### `GuzzleHttp\Psr7\Uri::composeComponents`
+
+`public static function composeComponents($scheme, $authority, $path, $query, $fragment): string`
+
+Composes a URI reference string from its various components according to
+[RFC 3986 Section 5.3](https://tools.ietf.org/html/rfc3986#section-5.3). Usually this method does not need to be called
+manually but instead is used indirectly via `Psr\Http\Message\UriInterface::__toString`.
+
+### `GuzzleHttp\Psr7\Uri::fromParts`
+
+`public static function fromParts(array $parts): UriInterface`
+
+Creates a URI from a hash of [`parse_url`](http://php.net/manual/en/function.parse-url.php) components.
+
+
+### `GuzzleHttp\Psr7\Uri::withQueryValue`
+
+`public static function withQueryValue(UriInterface $uri, $key, $value): UriInterface`
+
+Creates a new URI with a specific query string value. Any existing query string values that exactly match the
+provided key are removed and replaced with the given key value pair. A value of null will set the query string
+key without a value, e.g. "key" instead of "key=value".
+
+### `GuzzleHttp\Psr7\Uri::withQueryValues`
+
+`public static function withQueryValues(UriInterface $uri, array $keyValueArray): UriInterface`
+
+Creates a new URI with multiple query string values. It has the same behavior as `withQueryValue()` but for an
+associative array of key => value.
+
+### `GuzzleHttp\Psr7\Uri::withoutQueryValue`
+
+`public static function withoutQueryValue(UriInterface $uri, $key): UriInterface`
+
+Creates a new URI with a specific query string value removed. Any existing query string values that exactly match the
+provided key are removed.
+
+## Reference Resolution
+
+`GuzzleHttp\Psr7\UriResolver` provides methods to resolve a URI reference in the context of a base URI according
+to [RFC 3986 Section 5](https://tools.ietf.org/html/rfc3986#section-5). This is for example also what web browsers
+do when resolving a link in a website based on the current request URI.
+
+### `GuzzleHttp\Psr7\UriResolver::resolve`
+
+`public static function resolve(UriInterface $base, UriInterface $rel): UriInterface`
+
+Converts the relative URI into a new URI that is resolved against the base URI.
+
+### `GuzzleHttp\Psr7\UriResolver::removeDotSegments`
+
+`public static function removeDotSegments(string $path): string`
+
+Removes dot segments from a path and returns the new path according to
+[RFC 3986 Section 5.2.4](https://tools.ietf.org/html/rfc3986#section-5.2.4).
+
+### `GuzzleHttp\Psr7\UriResolver::relativize`
+
+`public static function relativize(UriInterface $base, UriInterface $target): UriInterface`
+
+Returns the target URI as a relative reference from the base URI. This method is the counterpart to resolve():
+
+```php
+(string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target))
+```
+
+One use-case is to use the current request URI as base URI and then generate relative links in your documents
+to reduce the document size or offer self-contained downloadable document archives.
+
+```php
+$base = new Uri('http://example.com/a/b/');
+echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'.
+echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'.
+echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'.
+echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//example.org/a/b/'.
+```
+
+## Normalization and Comparison
+
+`GuzzleHttp\Psr7\UriNormalizer` provides methods to normalize and compare URIs according to
+[RFC 3986 Section 6](https://tools.ietf.org/html/rfc3986#section-6).
+
+### `GuzzleHttp\Psr7\UriNormalizer::normalize`
+
+`public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS): UriInterface`
+
+Returns a normalized URI. The scheme and host component are already normalized to lowercase per PSR-7 UriInterface.
+This methods adds additional normalizations that can be configured with the `$flags` parameter which is a bitmask
+of normalizations to apply. The following normalizations are available:
+
+- `UriNormalizer::PRESERVING_NORMALIZATIONS`
+
+ Default normalizations which only include the ones that preserve semantics.
+
+- `UriNormalizer::CAPITALIZE_PERCENT_ENCODING`
+
+ All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized.
+
+ Example: `http://example.org/a%c2%b1b` → `http://example.org/a%C2%B1b`
+
+- `UriNormalizer::DECODE_UNRESERVED_CHARACTERS`
+
+ Decodes percent-encoded octets of unreserved characters. For consistency, percent-encoded octets in the ranges of
+ ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should
+ not be created by URI producers and, when found in a URI, should be decoded to their corresponding unreserved
+ characters by URI normalizers.
+
+ Example: `http://example.org/%7Eusern%61me/` → `http://example.org/~username/`
+
+- `UriNormalizer::CONVERT_EMPTY_PATH`
+
+ Converts the empty path to "/" for http and https URIs.
+
+ Example: `http://example.org` → `http://example.org/`
+
+- `UriNormalizer::REMOVE_DEFAULT_HOST`
+
+ Removes the default host of the given URI scheme from the URI. Only the "file" scheme defines the default host
+ "localhost". All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile` are equivalent according to
+ RFC 3986.
+
+ Example: `file://localhost/myfile` → `file:///myfile`
+
+- `UriNormalizer::REMOVE_DEFAULT_PORT`
+
+ Removes the default port of the given URI scheme from the URI.
+
+ Example: `http://example.org:80/` → `http://example.org/`
+
+- `UriNormalizer::REMOVE_DOT_SEGMENTS`
+
+ Removes unnecessary dot-segments. Dot-segments in relative-path references are not removed as it would
+ change the semantics of the URI reference.
+
+ Example: `http://example.org/../a/b/../c/./d.html` → `http://example.org/a/c/d.html`
+
+- `UriNormalizer::REMOVE_DUPLICATE_SLASHES`
+
+ Paths which include two or more adjacent slashes are converted to one. Webservers usually ignore duplicate slashes
+ and treat those URIs equivalent. But in theory those URIs do not need to be equivalent. So this normalization
+ may change the semantics. Encoded slashes (%2F) are not removed.
+
+ Example: `http://example.org//foo///bar.html` → `http://example.org/foo/bar.html`
+
+- `UriNormalizer::SORT_QUERY_PARAMETERS`
+
+ Sort query parameters with their values in alphabetical order. However, the order of parameters in a URI may be
+ significant (this is not defined by the standard). So this normalization is not safe and may change the semantics
+ of the URI.
+
+ Example: `?lang=en&article=fred` → `?article=fred&lang=en`
+
+### `GuzzleHttp\Psr7\UriNormalizer::isEquivalent`
+
+`public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS): bool`
+
+Whether two URIs can be considered equivalent. Both URIs are normalized automatically before comparison with the given
+`$normalizations` bitmask. The method also accepts relative URI references and returns true when they are equivalent.
+This of course assumes they will be resolved against the same base URI. If this is not the case, determination of
+equivalence or difference of relative references does not mean anything.
diff --git a/vendor/guzzlehttp/psr7/composer.json b/vendor/guzzlehttp/psr7/composer.json
new file mode 100644
index 0000000..168a055
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/composer.json
@@ -0,0 +1,49 @@
+{
+ "name": "guzzlehttp/psr7",
+ "type": "library",
+ "description": "PSR-7 message implementation that also provides common utility methods",
+ "keywords": ["request", "response", "message", "stream", "http", "uri", "url", "psr-7"],
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ },
+ {
+ "name": "Tobias Schultze",
+ "homepage": "https://github.com/Tobion"
+ }
+ ],
+ "require": {
+ "php": ">=5.4.0",
+ "psr/http-message": "~1.0",
+ "ralouphie/getallheaders": "^2.0.5 || ^3.0.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8",
+ "ext-zlib": "*"
+ },
+ "provide": {
+ "psr/http-message-implementation": "1.0"
+ },
+ "suggest": {
+ "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses"
+ },
+ "autoload": {
+ "psr-4": {
+ "GuzzleHttp\\Psr7\\": "src/"
+ },
+ "files": ["src/functions_include.php"]
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "GuzzleHttp\\Tests\\Psr7\\": "tests/"
+ }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.6-dev"
+ }
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/AppendStream.php b/vendor/guzzlehttp/psr7/src/AppendStream.php
new file mode 100644
index 0000000..472a0d6
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/AppendStream.php
@@ -0,0 +1,241 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Reads from multiple streams, one after the other.
+ *
+ * This is a read-only stream decorator.
+ */
+class AppendStream implements StreamInterface
+{
+ /** @var StreamInterface[] Streams being decorated */
+ private $streams = [];
+
+ private $seekable = true;
+ private $current = 0;
+ private $pos = 0;
+
+ /**
+ * @param StreamInterface[] $streams Streams to decorate. Each stream must
+ * be readable.
+ */
+ public function __construct(array $streams = [])
+ {
+ foreach ($streams as $stream) {
+ $this->addStream($stream);
+ }
+ }
+
+ public function __toString()
+ {
+ try {
+ $this->rewind();
+ return $this->getContents();
+ } catch (\Exception $e) {
+ return '';
+ }
+ }
+
+ /**
+ * Add a stream to the AppendStream
+ *
+ * @param StreamInterface $stream Stream to append. Must be readable.
+ *
+ * @throws \InvalidArgumentException if the stream is not readable
+ */
+ public function addStream(StreamInterface $stream)
+ {
+ if (!$stream->isReadable()) {
+ throw new \InvalidArgumentException('Each stream must be readable');
+ }
+
+ // The stream is only seekable if all streams are seekable
+ if (!$stream->isSeekable()) {
+ $this->seekable = false;
+ }
+
+ $this->streams[] = $stream;
+ }
+
+ public function getContents()
+ {
+ return copy_to_string($this);
+ }
+
+ /**
+ * Closes each attached stream.
+ *
+ * {@inheritdoc}
+ */
+ public function close()
+ {
+ $this->pos = $this->current = 0;
+ $this->seekable = true;
+
+ foreach ($this->streams as $stream) {
+ $stream->close();
+ }
+
+ $this->streams = [];
+ }
+
+ /**
+ * Detaches each attached stream.
+ *
+ * Returns null as it's not clear which underlying stream resource to return.
+ *
+ * {@inheritdoc}
+ */
+ public function detach()
+ {
+ $this->pos = $this->current = 0;
+ $this->seekable = true;
+
+ foreach ($this->streams as $stream) {
+ $stream->detach();
+ }
+
+ $this->streams = [];
+ }
+
+ public function tell()
+ {
+ return $this->pos;
+ }
+
+ /**
+ * Tries to calculate the size by adding the size of each stream.
+ *
+ * If any of the streams do not return a valid number, then the size of the
+ * append stream cannot be determined and null is returned.
+ *
+ * {@inheritdoc}
+ */
+ public function getSize()
+ {
+ $size = 0;
+
+ foreach ($this->streams as $stream) {
+ $s = $stream->getSize();
+ if ($s === null) {
+ return null;
+ }
+ $size += $s;
+ }
+
+ return $size;
+ }
+
+ public function eof()
+ {
+ return !$this->streams ||
+ ($this->current >= count($this->streams) - 1 &&
+ $this->streams[$this->current]->eof());
+ }
+
+ public function rewind()
+ {
+ $this->seek(0);
+ }
+
+ /**
+ * Attempts to seek to the given position. Only supports SEEK_SET.
+ *
+ * {@inheritdoc}
+ */
+ public function seek($offset, $whence = SEEK_SET)
+ {
+ if (!$this->seekable) {
+ throw new \RuntimeException('This AppendStream is not seekable');
+ } elseif ($whence !== SEEK_SET) {
+ throw new \RuntimeException('The AppendStream can only seek with SEEK_SET');
+ }
+
+ $this->pos = $this->current = 0;
+
+ // Rewind each stream
+ foreach ($this->streams as $i => $stream) {
+ try {
+ $stream->rewind();
+ } catch (\Exception $e) {
+ throw new \RuntimeException('Unable to seek stream '
+ . $i . ' of the AppendStream', 0, $e);
+ }
+ }
+
+ // Seek to the actual position by reading from each stream
+ while ($this->pos < $offset && !$this->eof()) {
+ $result = $this->read(min(8096, $offset - $this->pos));
+ if ($result === '') {
+ break;
+ }
+ }
+ }
+
+ /**
+ * Reads from all of the appended streams until the length is met or EOF.
+ *
+ * {@inheritdoc}
+ */
+ public function read($length)
+ {
+ $buffer = '';
+ $total = count($this->streams) - 1;
+ $remaining = $length;
+ $progressToNext = false;
+
+ while ($remaining > 0) {
+
+ // Progress to the next stream if needed.
+ if ($progressToNext || $this->streams[$this->current]->eof()) {
+ $progressToNext = false;
+ if ($this->current === $total) {
+ break;
+ }
+ $this->current++;
+ }
+
+ $result = $this->streams[$this->current]->read($remaining);
+
+ // Using a loose comparison here to match on '', false, and null
+ if ($result == null) {
+ $progressToNext = true;
+ continue;
+ }
+
+ $buffer .= $result;
+ $remaining = $length - strlen($buffer);
+ }
+
+ $this->pos += strlen($buffer);
+
+ return $buffer;
+ }
+
+ public function isReadable()
+ {
+ return true;
+ }
+
+ public function isWritable()
+ {
+ return false;
+ }
+
+ public function isSeekable()
+ {
+ return $this->seekable;
+ }
+
+ public function write($string)
+ {
+ throw new \RuntimeException('Cannot write to an AppendStream');
+ }
+
+ public function getMetadata($key = null)
+ {
+ return $key ? null : [];
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/BufferStream.php b/vendor/guzzlehttp/psr7/src/BufferStream.php
new file mode 100644
index 0000000..af4d4c2
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/BufferStream.php
@@ -0,0 +1,137 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Provides a buffer stream that can be written to to fill a buffer, and read
+ * from to remove bytes from the buffer.
+ *
+ * This stream returns a "hwm" metadata value that tells upstream consumers
+ * what the configured high water mark of the stream is, or the maximum
+ * preferred size of the buffer.
+ */
+class BufferStream implements StreamInterface
+{
+ private $hwm;
+ private $buffer = '';
+
+ /**
+ * @param int $hwm High water mark, representing the preferred maximum
+ * buffer size. If the size of the buffer exceeds the high
+ * water mark, then calls to write will continue to succeed
+ * but will return false to inform writers to slow down
+ * until the buffer has been drained by reading from it.
+ */
+ public function __construct($hwm = 16384)
+ {
+ $this->hwm = $hwm;
+ }
+
+ public function __toString()
+ {
+ return $this->getContents();
+ }
+
+ public function getContents()
+ {
+ $buffer = $this->buffer;
+ $this->buffer = '';
+
+ return $buffer;
+ }
+
+ public function close()
+ {
+ $this->buffer = '';
+ }
+
+ public function detach()
+ {
+ $this->close();
+ }
+
+ public function getSize()
+ {
+ return strlen($this->buffer);
+ }
+
+ public function isReadable()
+ {
+ return true;
+ }
+
+ public function isWritable()
+ {
+ return true;
+ }
+
+ public function isSeekable()
+ {
+ return false;
+ }
+
+ public function rewind()
+ {
+ $this->seek(0);
+ }
+
+ public function seek($offset, $whence = SEEK_SET)
+ {
+ throw new \RuntimeException('Cannot seek a BufferStream');
+ }
+
+ public function eof()
+ {
+ return strlen($this->buffer) === 0;
+ }
+
+ public function tell()
+ {
+ throw new \RuntimeException('Cannot determine the position of a BufferStream');
+ }
+
+ /**
+ * Reads data from the buffer.
+ */
+ public function read($length)
+ {
+ $currentLength = strlen($this->buffer);
+
+ if ($length >= $currentLength) {
+ // No need to slice the buffer because we don't have enough data.
+ $result = $this->buffer;
+ $this->buffer = '';
+ } else {
+ // Slice up the result to provide a subset of the buffer.
+ $result = substr($this->buffer, 0, $length);
+ $this->buffer = substr($this->buffer, $length);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Writes data to the buffer.
+ */
+ public function write($string)
+ {
+ $this->buffer .= $string;
+
+ // TODO: What should happen here?
+ if (strlen($this->buffer) >= $this->hwm) {
+ return false;
+ }
+
+ return strlen($string);
+ }
+
+ public function getMetadata($key = null)
+ {
+ if ($key == 'hwm') {
+ return $this->hwm;
+ }
+
+ return $key ? null : [];
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/CachingStream.php b/vendor/guzzlehttp/psr7/src/CachingStream.php
new file mode 100644
index 0000000..ed68f08
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/CachingStream.php
@@ -0,0 +1,138 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Stream decorator that can cache previously read bytes from a sequentially
+ * read stream.
+ */
+class CachingStream implements StreamInterface
+{
+ use StreamDecoratorTrait;
+
+ /** @var StreamInterface Stream being wrapped */
+ private $remoteStream;
+
+ /** @var int Number of bytes to skip reading due to a write on the buffer */
+ private $skipReadBytes = 0;
+
+ /**
+ * We will treat the buffer object as the body of the stream
+ *
+ * @param StreamInterface $stream Stream to cache
+ * @param StreamInterface $target Optionally specify where data is cached
+ */
+ public function __construct(
+ StreamInterface $stream,
+ StreamInterface $target = null
+ ) {
+ $this->remoteStream = $stream;
+ $this->stream = $target ?: new Stream(fopen('php://temp', 'r+'));
+ }
+
+ public function getSize()
+ {
+ return max($this->stream->getSize(), $this->remoteStream->getSize());
+ }
+
+ public function rewind()
+ {
+ $this->seek(0);
+ }
+
+ public function seek($offset, $whence = SEEK_SET)
+ {
+ if ($whence == SEEK_SET) {
+ $byte = $offset;
+ } elseif ($whence == SEEK_CUR) {
+ $byte = $offset + $this->tell();
+ } elseif ($whence == SEEK_END) {
+ $size = $this->remoteStream->getSize();
+ if ($size === null) {
+ $size = $this->cacheEntireStream();
+ }
+ $byte = $size + $offset;
+ } else {
+ throw new \InvalidArgumentException('Invalid whence');
+ }
+
+ $diff = $byte - $this->stream->getSize();
+
+ if ($diff > 0) {
+ // Read the remoteStream until we have read in at least the amount
+ // of bytes requested, or we reach the end of the file.
+ while ($diff > 0 && !$this->remoteStream->eof()) {
+ $this->read($diff);
+ $diff = $byte - $this->stream->getSize();
+ }
+ } else {
+ // We can just do a normal seek since we've already seen this byte.
+ $this->stream->seek($byte);
+ }
+ }
+
+ public function read($length)
+ {
+ // Perform a regular read on any previously read data from the buffer
+ $data = $this->stream->read($length);
+ $remaining = $length - strlen($data);
+
+ // More data was requested so read from the remote stream
+ if ($remaining) {
+ // If data was written to the buffer in a position that would have
+ // been filled from the remote stream, then we must skip bytes on
+ // the remote stream to emulate overwriting bytes from that
+ // position. This mimics the behavior of other PHP stream wrappers.
+ $remoteData = $this->remoteStream->read(
+ $remaining + $this->skipReadBytes
+ );
+
+ if ($this->skipReadBytes) {
+ $len = strlen($remoteData);
+ $remoteData = substr($remoteData, $this->skipReadBytes);
+ $this->skipReadBytes = max(0, $this->skipReadBytes - $len);
+ }
+
+ $data .= $remoteData;
+ $this->stream->write($remoteData);
+ }
+
+ return $data;
+ }
+
+ public function write($string)
+ {
+ // When appending to the end of the currently read stream, you'll want
+ // to skip bytes from being read from the remote stream to emulate
+ // other stream wrappers. Basically replacing bytes of data of a fixed
+ // length.
+ $overflow = (strlen($string) + $this->tell()) - $this->remoteStream->tell();
+ if ($overflow > 0) {
+ $this->skipReadBytes += $overflow;
+ }
+
+ return $this->stream->write($string);
+ }
+
+ public function eof()
+ {
+ return $this->stream->eof() && $this->remoteStream->eof();
+ }
+
+ /**
+ * Close both the remote stream and buffer stream
+ */
+ public function close()
+ {
+ $this->remoteStream->close() && $this->stream->close();
+ }
+
+ private function cacheEntireStream()
+ {
+ $target = new FnStream(['write' => 'strlen']);
+ copy_to_stream($this, $target);
+
+ return $this->tell();
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/DroppingStream.php b/vendor/guzzlehttp/psr7/src/DroppingStream.php
new file mode 100644
index 0000000..8935c80
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/DroppingStream.php
@@ -0,0 +1,42 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Stream decorator that begins dropping data once the size of the underlying
+ * stream becomes too full.
+ */
+class DroppingStream implements StreamInterface
+{
+ use StreamDecoratorTrait;
+
+ private $maxLength;
+
+ /**
+ * @param StreamInterface $stream Underlying stream to decorate.
+ * @param int $maxLength Maximum size before dropping data.
+ */
+ public function __construct(StreamInterface $stream, $maxLength)
+ {
+ $this->stream = $stream;
+ $this->maxLength = $maxLength;
+ }
+
+ public function write($string)
+ {
+ $diff = $this->maxLength - $this->stream->getSize();
+
+ // Begin returning 0 when the underlying stream is too large.
+ if ($diff <= 0) {
+ return 0;
+ }
+
+ // Write the stream or a subset of the stream if needed.
+ if (strlen($string) < $diff) {
+ return $this->stream->write($string);
+ }
+
+ return $this->stream->write(substr($string, 0, $diff));
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/FnStream.php b/vendor/guzzlehttp/psr7/src/FnStream.php
new file mode 100644
index 0000000..73daea6
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/FnStream.php
@@ -0,0 +1,158 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Compose stream implementations based on a hash of functions.
+ *
+ * Allows for easy testing and extension of a provided stream without needing
+ * to create a concrete class for a simple extension point.
+ */
+class FnStream implements StreamInterface
+{
+ /** @var array */
+ private $methods;
+
+ /** @var array Methods that must be implemented in the given array */
+ private static $slots = ['__toString', 'close', 'detach', 'rewind',
+ 'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write',
+ 'isReadable', 'read', 'getContents', 'getMetadata'];
+
+ /**
+ * @param array $methods Hash of method name to a callable.
+ */
+ public function __construct(array $methods)
+ {
+ $this->methods = $methods;
+
+ // Create the functions on the class
+ foreach ($methods as $name => $fn) {
+ $this->{'_fn_' . $name} = $fn;
+ }
+ }
+
+ /**
+ * Lazily determine which methods are not implemented.
+ * @throws \BadMethodCallException
+ */
+ public function __get($name)
+ {
+ throw new \BadMethodCallException(str_replace('_fn_', '', $name)
+ . '() is not implemented in the FnStream');
+ }
+
+ /**
+ * The close method is called on the underlying stream only if possible.
+ */
+ public function __destruct()
+ {
+ if (isset($this->_fn_close)) {
+ call_user_func($this->_fn_close);
+ }
+ }
+
+ /**
+ * An unserialize would allow the __destruct to run when the unserialized value goes out of scope.
+ * @throws \LogicException
+ */
+ public function __wakeup()
+ {
+ throw new \LogicException('FnStream should never be unserialized');
+ }
+
+ /**
+ * Adds custom functionality to an underlying stream by intercepting
+ * specific method calls.
+ *
+ * @param StreamInterface $stream Stream to decorate
+ * @param array $methods Hash of method name to a closure
+ *
+ * @return FnStream
+ */
+ public static function decorate(StreamInterface $stream, array $methods)
+ {
+ // If any of the required methods were not provided, then simply
+ // proxy to the decorated stream.
+ foreach (array_diff(self::$slots, array_keys($methods)) as $diff) {
+ $methods[$diff] = [$stream, $diff];
+ }
+
+ return new self($methods);
+ }
+
+ public function __toString()
+ {
+ return call_user_func($this->_fn___toString);
+ }
+
+ public function close()
+ {
+ return call_user_func($this->_fn_close);
+ }
+
+ public function detach()
+ {
+ return call_user_func($this->_fn_detach);
+ }
+
+ public function getSize()
+ {
+ return call_user_func($this->_fn_getSize);
+ }
+
+ public function tell()
+ {
+ return call_user_func($this->_fn_tell);
+ }
+
+ public function eof()
+ {
+ return call_user_func($this->_fn_eof);
+ }
+
+ public function isSeekable()
+ {
+ return call_user_func($this->_fn_isSeekable);
+ }
+
+ public function rewind()
+ {
+ call_user_func($this->_fn_rewind);
+ }
+
+ public function seek($offset, $whence = SEEK_SET)
+ {
+ call_user_func($this->_fn_seek, $offset, $whence);
+ }
+
+ public function isWritable()
+ {
+ return call_user_func($this->_fn_isWritable);
+ }
+
+ public function write($string)
+ {
+ return call_user_func($this->_fn_write, $string);
+ }
+
+ public function isReadable()
+ {
+ return call_user_func($this->_fn_isReadable);
+ }
+
+ public function read($length)
+ {
+ return call_user_func($this->_fn_read, $length);
+ }
+
+ public function getContents()
+ {
+ return call_user_func($this->_fn_getContents);
+ }
+
+ public function getMetadata($key = null)
+ {
+ return call_user_func($this->_fn_getMetadata, $key);
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/InflateStream.php b/vendor/guzzlehttp/psr7/src/InflateStream.php
new file mode 100644
index 0000000..5e4f602
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/InflateStream.php
@@ -0,0 +1,52 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
+ *
+ * This stream decorator skips the first 10 bytes of the given stream to remove
+ * the gzip header, converts the provided stream to a PHP stream resource,
+ * then appends the zlib.inflate filter. The stream is then converted back
+ * to a Guzzle stream resource to be used as a Guzzle stream.
+ *
+ * @link http://tools.ietf.org/html/rfc1952
+ * @link http://php.net/manual/en/filters.compression.php
+ */
+class InflateStream implements StreamInterface
+{
+ use StreamDecoratorTrait;
+
+ public function __construct(StreamInterface $stream)
+ {
+ // read the first 10 bytes, ie. gzip header
+ $header = $stream->read(10);
+ $filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header);
+ // Skip the header, that is 10 + length of filename + 1 (nil) bytes
+ $stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength);
+ $resource = StreamWrapper::getResource($stream);
+ stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ);
+ $this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource));
+ }
+
+ /**
+ * @param StreamInterface $stream
+ * @param $header
+ * @return int
+ */
+ private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header)
+ {
+ $filename_header_length = 0;
+
+ if (substr(bin2hex($header), 6, 2) === '08') {
+ // we have a filename, read until nil
+ $filename_header_length = 1;
+ while ($stream->read(1) !== chr(0)) {
+ $filename_header_length++;
+ }
+ }
+
+ return $filename_header_length;
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/LazyOpenStream.php b/vendor/guzzlehttp/psr7/src/LazyOpenStream.php
new file mode 100644
index 0000000..02cec3a
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/LazyOpenStream.php
@@ -0,0 +1,39 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Lazily reads or writes to a file that is opened only after an IO operation
+ * take place on the stream.
+ */
+class LazyOpenStream implements StreamInterface
+{
+ use StreamDecoratorTrait;
+
+ /** @var string File to open */
+ private $filename;
+
+ /** @var string $mode */
+ private $mode;
+
+ /**
+ * @param string $filename File to lazily open
+ * @param string $mode fopen mode to use when opening the stream
+ */
+ public function __construct($filename, $mode)
+ {
+ $this->filename = $filename;
+ $this->mode = $mode;
+ }
+
+ /**
+ * Creates the underlying stream lazily when required.
+ *
+ * @return StreamInterface
+ */
+ protected function createStream()
+ {
+ return stream_for(try_fopen($this->filename, $this->mode));
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/LimitStream.php b/vendor/guzzlehttp/psr7/src/LimitStream.php
new file mode 100644
index 0000000..e4f239e
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/LimitStream.php
@@ -0,0 +1,155 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+
+/**
+ * Decorator used to return only a subset of a stream
+ */
+class LimitStream implements StreamInterface
+{
+ use StreamDecoratorTrait;
+
+ /** @var int Offset to start reading from */
+ private $offset;
+
+ /** @var int Limit the number of bytes that can be read */
+ private $limit;
+
+ /**
+ * @param StreamInterface $stream Stream to wrap
+ * @param int $limit Total number of bytes to allow to be read
+ * from the stream. Pass -1 for no limit.
+ * @param int $offset Position to seek to before reading (only
+ * works on seekable streams).
+ */
+ public function __construct(
+ StreamInterface $stream,
+ $limit = -1,
+ $offset = 0
+ ) {
+ $this->stream = $stream;
+ $this->setLimit($limit);
+ $this->setOffset($offset);
+ }
+
+ public function eof()
+ {
+ // Always return true if the underlying stream is EOF
+ if ($this->stream->eof()) {
+ return true;
+ }
+
+ // No limit and the underlying stream is not at EOF
+ if ($this->limit == -1) {
+ return false;
+ }
+
+ return $this->stream->tell() >= $this->offset + $this->limit;
+ }
+
+ /**
+ * Returns the size of the limited subset of data
+ * {@inheritdoc}
+ */
+ public function getSize()
+ {
+ if (null === ($length = $this->stream->getSize())) {
+ return null;
+ } elseif ($this->limit == -1) {
+ return $length - $this->offset;
+ } else {
+ return min($this->limit, $length - $this->offset);
+ }
+ }
+
+ /**
+ * Allow for a bounded seek on the read limited stream
+ * {@inheritdoc}
+ */
+ public function seek($offset, $whence = SEEK_SET)
+ {
+ if ($whence !== SEEK_SET || $offset < 0) {
+ throw new \RuntimeException(sprintf(
+ 'Cannot seek to offset %s with whence %s',
+ $offset,
+ $whence
+ ));
+ }
+
+ $offset += $this->offset;
+
+ if ($this->limit !== -1) {
+ if ($offset > $this->offset + $this->limit) {
+ $offset = $this->offset + $this->limit;
+ }
+ }
+
+ $this->stream->seek($offset);
+ }
+
+ /**
+ * Give a relative tell()
+ * {@inheritdoc}
+ */
+ public function tell()
+ {
+ return $this->stream->tell() - $this->offset;
+ }
+
+ /**
+ * Set the offset to start limiting from
+ *
+ * @param int $offset Offset to seek to and begin byte limiting from
+ *
+ * @throws \RuntimeException if the stream cannot be seeked.
+ */
+ public function setOffset($offset)
+ {
+ $current = $this->stream->tell();
+
+ if ($current !== $offset) {
+ // If the stream cannot seek to the offset position, then read to it
+ if ($this->stream->isSeekable()) {
+ $this->stream->seek($offset);
+ } elseif ($current > $offset) {
+ throw new \RuntimeException("Could not seek to stream offset $offset");
+ } else {
+ $this->stream->read($offset - $current);
+ }
+ }
+
+ $this->offset = $offset;
+ }
+
+ /**
+ * Set the limit of bytes that the decorator allows to be read from the
+ * stream.
+ *
+ * @param int $limit Number of bytes to allow to be read from the stream.
+ * Use -1 for no limit.
+ */
+ public function setLimit($limit)
+ {
+ $this->limit = $limit;
+ }
+
+ public function read($length)
+ {
+ if ($this->limit == -1) {
+ return $this->stream->read($length);
+ }
+
+ // Check if the current position is less than the total allowed
+ // bytes + original offset
+ $remaining = ($this->offset + $this->limit) - $this->stream->tell();
+ if ($remaining > 0) {
+ // Only return the amount of requested data, ensuring that the byte
+ // limit is not exceeded
+ return $this->stream->read(min($remaining, $length));
+ }
+
+ return '';
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/MessageTrait.php b/vendor/guzzlehttp/psr7/src/MessageTrait.php
new file mode 100644
index 0000000..a7966d1
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/MessageTrait.php
@@ -0,0 +1,213 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Trait implementing functionality common to requests and responses.
+ */
+trait MessageTrait
+{
+ /** @var array Map of all registered headers, as original name => array of values */
+ private $headers = [];
+
+ /** @var array Map of lowercase header name => original name at registration */
+ private $headerNames = [];
+
+ /** @var string */
+ private $protocol = '1.1';
+
+ /** @var StreamInterface */
+ private $stream;
+
+ public function getProtocolVersion()
+ {
+ return $this->protocol;
+ }
+
+ public function withProtocolVersion($version)
+ {
+ if ($this->protocol === $version) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->protocol = $version;
+ return $new;
+ }
+
+ public function getHeaders()
+ {
+ return $this->headers;
+ }
+
+ public function hasHeader($header)
+ {
+ return isset($this->headerNames[strtolower($header)]);
+ }
+
+ public function getHeader($header)
+ {
+ $header = strtolower($header);
+
+ if (!isset($this->headerNames[$header])) {
+ return [];
+ }
+
+ $header = $this->headerNames[$header];
+
+ return $this->headers[$header];
+ }
+
+ public function getHeaderLine($header)
+ {
+ return implode(', ', $this->getHeader($header));
+ }
+
+ public function withHeader($header, $value)
+ {
+ $this->assertHeader($header);
+ $value = $this->normalizeHeaderValue($value);
+ $normalized = strtolower($header);
+
+ $new = clone $this;
+ if (isset($new->headerNames[$normalized])) {
+ unset($new->headers[$new->headerNames[$normalized]]);
+ }
+ $new->headerNames[$normalized] = $header;
+ $new->headers[$header] = $value;
+
+ return $new;
+ }
+
+ public function withAddedHeader($header, $value)
+ {
+ $this->assertHeader($header);
+ $value = $this->normalizeHeaderValue($value);
+ $normalized = strtolower($header);
+
+ $new = clone $this;
+ if (isset($new->headerNames[$normalized])) {
+ $header = $this->headerNames[$normalized];
+ $new->headers[$header] = array_merge($this->headers[$header], $value);
+ } else {
+ $new->headerNames[$normalized] = $header;
+ $new->headers[$header] = $value;
+ }
+
+ return $new;
+ }
+
+ public function withoutHeader($header)
+ {
+ $normalized = strtolower($header);
+
+ if (!isset($this->headerNames[$normalized])) {
+ return $this;
+ }
+
+ $header = $this->headerNames[$normalized];
+
+ $new = clone $this;
+ unset($new->headers[$header], $new->headerNames[$normalized]);
+
+ return $new;
+ }
+
+ public function getBody()
+ {
+ if (!$this->stream) {
+ $this->stream = stream_for('');
+ }
+
+ return $this->stream;
+ }
+
+ public function withBody(StreamInterface $body)
+ {
+ if ($body === $this->stream) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->stream = $body;
+ return $new;
+ }
+
+ private function setHeaders(array $headers)
+ {
+ $this->headerNames = $this->headers = [];
+ foreach ($headers as $header => $value) {
+ if (is_int($header)) {
+ // Numeric array keys are converted to int by PHP but having a header name '123' is not forbidden by the spec
+ // and also allowed in withHeader(). So we need to cast it to string again for the following assertion to pass.
+ $header = (string) $header;
+ }
+ $this->assertHeader($header);
+ $value = $this->normalizeHeaderValue($value);
+ $normalized = strtolower($header);
+ if (isset($this->headerNames[$normalized])) {
+ $header = $this->headerNames[$normalized];
+ $this->headers[$header] = array_merge($this->headers[$header], $value);
+ } else {
+ $this->headerNames[$normalized] = $header;
+ $this->headers[$header] = $value;
+ }
+ }
+ }
+
+ private function normalizeHeaderValue($value)
+ {
+ if (!is_array($value)) {
+ return $this->trimHeaderValues([$value]);
+ }
+
+ if (count($value) === 0) {
+ throw new \InvalidArgumentException('Header value can not be an empty array.');
+ }
+
+ return $this->trimHeaderValues($value);
+ }
+
+ /**
+ * Trims whitespace from the header values.
+ *
+ * Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field.
+ *
+ * header-field = field-name ":" OWS field-value OWS
+ * OWS = *( SP / HTAB )
+ *
+ * @param string[] $values Header values
+ *
+ * @return string[] Trimmed header values
+ *
+ * @see https://tools.ietf.org/html/rfc7230#section-3.2.4
+ */
+ private function trimHeaderValues(array $values)
+ {
+ return array_map(function ($value) {
+ if (!is_scalar($value) && null !== $value) {
+ throw new \InvalidArgumentException(sprintf(
+ 'Header value must be scalar or null but %s provided.',
+ is_object($value) ? get_class($value) : gettype($value)
+ ));
+ }
+
+ return trim((string) $value, " \t");
+ }, $values);
+ }
+
+ private function assertHeader($header)
+ {
+ if (!is_string($header)) {
+ throw new \InvalidArgumentException(sprintf(
+ 'Header name must be a string but %s provided.',
+ is_object($header) ? get_class($header) : gettype($header)
+ ));
+ }
+
+ if ($header === '') {
+ throw new \InvalidArgumentException('Header name can not be empty.');
+ }
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/MultipartStream.php b/vendor/guzzlehttp/psr7/src/MultipartStream.php
new file mode 100644
index 0000000..c0fd584
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/MultipartStream.php
@@ -0,0 +1,153 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Stream that when read returns bytes for a streaming multipart or
+ * multipart/form-data stream.
+ */
+class MultipartStream implements StreamInterface
+{
+ use StreamDecoratorTrait;
+
+ private $boundary;
+
+ /**
+ * @param array $elements Array of associative arrays, each containing a
+ * required "name" key mapping to the form field,
+ * name, a required "contents" key mapping to a
+ * StreamInterface/resource/string, an optional
+ * "headers" associative array of custom headers,
+ * and an optional "filename" key mapping to a
+ * string to send as the filename in the part.
+ * @param string $boundary You can optionally provide a specific boundary
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function __construct(array $elements = [], $boundary = null)
+ {
+ $this->boundary = $boundary ?: sha1(uniqid('', true));
+ $this->stream = $this->createStream($elements);
+ }
+
+ /**
+ * Get the boundary
+ *
+ * @return string
+ */
+ public function getBoundary()
+ {
+ return $this->boundary;
+ }
+
+ public function isWritable()
+ {
+ return false;
+ }
+
+ /**
+ * Get the headers needed before transferring the content of a POST file
+ */
+ private function getHeaders(array $headers)
+ {
+ $str = '';
+ foreach ($headers as $key => $value) {
+ $str .= "{$key}: {$value}\r\n";
+ }
+
+ return "--{$this->boundary}\r\n" . trim($str) . "\r\n\r\n";
+ }
+
+ /**
+ * Create the aggregate stream that will be used to upload the POST data
+ */
+ protected function createStream(array $elements)
+ {
+ $stream = new AppendStream();
+
+ foreach ($elements as $element) {
+ $this->addElement($stream, $element);
+ }
+
+ // Add the trailing boundary with CRLF
+ $stream->addStream(stream_for("--{$this->boundary}--\r\n"));
+
+ return $stream;
+ }
+
+ private function addElement(AppendStream $stream, array $element)
+ {
+ foreach (['contents', 'name'] as $key) {
+ if (!array_key_exists($key, $element)) {
+ throw new \InvalidArgumentException("A '{$key}' key is required");
+ }
+ }
+
+ $element['contents'] = stream_for($element['contents']);
+
+ if (empty($element['filename'])) {
+ $uri = $element['contents']->getMetadata('uri');
+ if (substr($uri, 0, 6) !== 'php://') {
+ $element['filename'] = $uri;
+ }
+ }
+
+ list($body, $headers) = $this->createElement(
+ $element['name'],
+ $element['contents'],
+ isset($element['filename']) ? $element['filename'] : null,
+ isset($element['headers']) ? $element['headers'] : []
+ );
+
+ $stream->addStream(stream_for($this->getHeaders($headers)));
+ $stream->addStream($body);
+ $stream->addStream(stream_for("\r\n"));
+ }
+
+ /**
+ * @return array
+ */
+ private function createElement($name, StreamInterface $stream, $filename, array $headers)
+ {
+ // Set a default content-disposition header if one was no provided
+ $disposition = $this->getHeader($headers, 'content-disposition');
+ if (!$disposition) {
+ $headers['Content-Disposition'] = ($filename === '0' || $filename)
+ ? sprintf('form-data; name="%s"; filename="%s"',
+ $name,
+ basename($filename))
+ : "form-data; name=\"{$name}\"";
+ }
+
+ // Set a default content-length header if one was no provided
+ $length = $this->getHeader($headers, 'content-length');
+ if (!$length) {
+ if ($length = $stream->getSize()) {
+ $headers['Content-Length'] = (string) $length;
+ }
+ }
+
+ // Set a default Content-Type if one was not supplied
+ $type = $this->getHeader($headers, 'content-type');
+ if (!$type && ($filename === '0' || $filename)) {
+ if ($type = mimetype_from_filename($filename)) {
+ $headers['Content-Type'] = $type;
+ }
+ }
+
+ return [$stream, $headers];
+ }
+
+ private function getHeader(array $headers, $key)
+ {
+ $lowercaseHeader = strtolower($key);
+ foreach ($headers as $k => $v) {
+ if (strtolower($k) === $lowercaseHeader) {
+ return $v;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/NoSeekStream.php b/vendor/guzzlehttp/psr7/src/NoSeekStream.php
new file mode 100644
index 0000000..2332218
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/NoSeekStream.php
@@ -0,0 +1,22 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Stream decorator that prevents a stream from being seeked
+ */
+class NoSeekStream implements StreamInterface
+{
+ use StreamDecoratorTrait;
+
+ public function seek($offset, $whence = SEEK_SET)
+ {
+ throw new \RuntimeException('Cannot seek a NoSeekStream');
+ }
+
+ public function isSeekable()
+ {
+ return false;
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/PumpStream.php b/vendor/guzzlehttp/psr7/src/PumpStream.php
new file mode 100644
index 0000000..ffb5440
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/PumpStream.php
@@ -0,0 +1,165 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Provides a read only stream that pumps data from a PHP callable.
+ *
+ * When invoking the provided callable, the PumpStream will pass the amount of
+ * data requested to read to the callable. The callable can choose to ignore
+ * this value and return fewer or more bytes than requested. Any extra data
+ * returned by the provided callable is buffered internally until drained using
+ * the read() function of the PumpStream. The provided callable MUST return
+ * false when there is no more data to read.
+ */
+class PumpStream implements StreamInterface
+{
+ /** @var callable */
+ private $source;
+
+ /** @var int */
+ private $size;
+
+ /** @var int */
+ private $tellPos = 0;
+
+ /** @var array */
+ private $metadata;
+
+ /** @var BufferStream */
+ private $buffer;
+
+ /**
+ * @param callable $source Source of the stream data. The callable MAY
+ * accept an integer argument used to control the
+ * amount of data to return. The callable MUST
+ * return a string when called, or false on error
+ * or EOF.
+ * @param array $options Stream options:
+ * - metadata: Hash of metadata to use with stream.
+ * - size: Size of the stream, if known.
+ */
+ public function __construct(callable $source, array $options = [])
+ {
+ $this->source = $source;
+ $this->size = isset($options['size']) ? $options['size'] : null;
+ $this->metadata = isset($options['metadata']) ? $options['metadata'] : [];
+ $this->buffer = new BufferStream();
+ }
+
+ public function __toString()
+ {
+ try {
+ return copy_to_string($this);
+ } catch (\Exception $e) {
+ return '';
+ }
+ }
+
+ public function close()
+ {
+ $this->detach();
+ }
+
+ public function detach()
+ {
+ $this->tellPos = false;
+ $this->source = null;
+ }
+
+ public function getSize()
+ {
+ return $this->size;
+ }
+
+ public function tell()
+ {
+ return $this->tellPos;
+ }
+
+ public function eof()
+ {
+ return !$this->source;
+ }
+
+ public function isSeekable()
+ {
+ return false;
+ }
+
+ public function rewind()
+ {
+ $this->seek(0);
+ }
+
+ public function seek($offset, $whence = SEEK_SET)
+ {
+ throw new \RuntimeException('Cannot seek a PumpStream');
+ }
+
+ public function isWritable()
+ {
+ return false;
+ }
+
+ public function write($string)
+ {
+ throw new \RuntimeException('Cannot write to a PumpStream');
+ }
+
+ public function isReadable()
+ {
+ return true;
+ }
+
+ public function read($length)
+ {
+ $data = $this->buffer->read($length);
+ $readLen = strlen($data);
+ $this->tellPos += $readLen;
+ $remaining = $length - $readLen;
+
+ if ($remaining) {
+ $this->pump($remaining);
+ $data .= $this->buffer->read($remaining);
+ $this->tellPos += strlen($data) - $readLen;
+ }
+
+ return $data;
+ }
+
+ public function getContents()
+ {
+ $result = '';
+ while (!$this->eof()) {
+ $result .= $this->read(1000000);
+ }
+
+ return $result;
+ }
+
+ public function getMetadata($key = null)
+ {
+ if (!$key) {
+ return $this->metadata;
+ }
+
+ return isset($this->metadata[$key]) ? $this->metadata[$key] : null;
+ }
+
+ private function pump($length)
+ {
+ if ($this->source) {
+ do {
+ $data = call_user_func($this->source, $length);
+ if ($data === false || $data === null) {
+ $this->source = null;
+ return;
+ }
+ $this->buffer->write($data);
+ $length -= strlen($data);
+ } while ($length > 0);
+ }
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/Request.php b/vendor/guzzlehttp/psr7/src/Request.php
new file mode 100644
index 0000000..59f337d
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/Request.php
@@ -0,0 +1,151 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use InvalidArgumentException;
+use Psr\Http\Message\RequestInterface;
+use Psr\Http\Message\StreamInterface;
+use Psr\Http\Message\UriInterface;
+
+/**
+ * PSR-7 request implementation.
+ */
+class Request implements RequestInterface
+{
+ use MessageTrait;
+
+ /** @var string */
+ private $method;
+
+ /** @var null|string */
+ private $requestTarget;
+
+ /** @var UriInterface */
+ private $uri;
+
+ /**
+ * @param string $method HTTP method
+ * @param string|UriInterface $uri URI
+ * @param array $headers Request headers
+ * @param string|null|resource|StreamInterface $body Request body
+ * @param string $version Protocol version
+ */
+ public function __construct(
+ $method,
+ $uri,
+ array $headers = [],
+ $body = null,
+ $version = '1.1'
+ ) {
+ $this->assertMethod($method);
+ if (!($uri instanceof UriInterface)) {
+ $uri = new Uri($uri);
+ }
+
+ $this->method = strtoupper($method);
+ $this->uri = $uri;
+ $this->setHeaders($headers);
+ $this->protocol = $version;
+
+ if (!isset($this->headerNames['host'])) {
+ $this->updateHostFromUri();
+ }
+
+ if ($body !== '' && $body !== null) {
+ $this->stream = stream_for($body);
+ }
+ }
+
+ public function getRequestTarget()
+ {
+ if ($this->requestTarget !== null) {
+ return $this->requestTarget;
+ }
+
+ $target = $this->uri->getPath();
+ if ($target == '') {
+ $target = '/';
+ }
+ if ($this->uri->getQuery() != '') {
+ $target .= '?' . $this->uri->getQuery();
+ }
+
+ return $target;
+ }
+
+ public function withRequestTarget($requestTarget)
+ {
+ if (preg_match('#\s#', $requestTarget)) {
+ throw new InvalidArgumentException(
+ 'Invalid request target provided; cannot contain whitespace'
+ );
+ }
+
+ $new = clone $this;
+ $new->requestTarget = $requestTarget;
+ return $new;
+ }
+
+ public function getMethod()
+ {
+ return $this->method;
+ }
+
+ public function withMethod($method)
+ {
+ $this->assertMethod($method);
+ $new = clone $this;
+ $new->method = strtoupper($method);
+ return $new;
+ }
+
+ public function getUri()
+ {
+ return $this->uri;
+ }
+
+ public function withUri(UriInterface $uri, $preserveHost = false)
+ {
+ if ($uri === $this->uri) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->uri = $uri;
+
+ if (!$preserveHost || !isset($this->headerNames['host'])) {
+ $new->updateHostFromUri();
+ }
+
+ return $new;
+ }
+
+ private function updateHostFromUri()
+ {
+ $host = $this->uri->getHost();
+
+ if ($host == '') {
+ return;
+ }
+
+ if (($port = $this->uri->getPort()) !== null) {
+ $host .= ':' . $port;
+ }
+
+ if (isset($this->headerNames['host'])) {
+ $header = $this->headerNames['host'];
+ } else {
+ $header = 'Host';
+ $this->headerNames['host'] = 'Host';
+ }
+ // Ensure Host is the first header.
+ // See: http://tools.ietf.org/html/rfc7230#section-5.4
+ $this->headers = [$header => [$host]] + $this->headers;
+ }
+
+ private function assertMethod($method)
+ {
+ if (!is_string($method) || $method === '') {
+ throw new \InvalidArgumentException('Method must be a non-empty string.');
+ }
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/Response.php b/vendor/guzzlehttp/psr7/src/Response.php
new file mode 100644
index 0000000..e7e04d8
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/Response.php
@@ -0,0 +1,154 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * PSR-7 response implementation.
+ */
+class Response implements ResponseInterface
+{
+ use MessageTrait;
+
+ /** @var array Map of standard HTTP status code/reason phrases */
+ private static $phrases = [
+ 100 => 'Continue',
+ 101 => 'Switching Protocols',
+ 102 => 'Processing',
+ 200 => 'OK',
+ 201 => 'Created',
+ 202 => 'Accepted',
+ 203 => 'Non-Authoritative Information',
+ 204 => 'No Content',
+ 205 => 'Reset Content',
+ 206 => 'Partial Content',
+ 207 => 'Multi-status',
+ 208 => 'Already Reported',
+ 300 => 'Multiple Choices',
+ 301 => 'Moved Permanently',
+ 302 => 'Found',
+ 303 => 'See Other',
+ 304 => 'Not Modified',
+ 305 => 'Use Proxy',
+ 306 => 'Switch Proxy',
+ 307 => 'Temporary Redirect',
+ 400 => 'Bad Request',
+ 401 => 'Unauthorized',
+ 402 => 'Payment Required',
+ 403 => 'Forbidden',
+ 404 => 'Not Found',
+ 405 => 'Method Not Allowed',
+ 406 => 'Not Acceptable',
+ 407 => 'Proxy Authentication Required',
+ 408 => 'Request Time-out',
+ 409 => 'Conflict',
+ 410 => 'Gone',
+ 411 => 'Length Required',
+ 412 => 'Precondition Failed',
+ 413 => 'Request Entity Too Large',
+ 414 => 'Request-URI Too Large',
+ 415 => 'Unsupported Media Type',
+ 416 => 'Requested range not satisfiable',
+ 417 => 'Expectation Failed',
+ 418 => 'I\'m a teapot',
+ 422 => 'Unprocessable Entity',
+ 423 => 'Locked',
+ 424 => 'Failed Dependency',
+ 425 => 'Unordered Collection',
+ 426 => 'Upgrade Required',
+ 428 => 'Precondition Required',
+ 429 => 'Too Many Requests',
+ 431 => 'Request Header Fields Too Large',
+ 451 => 'Unavailable For Legal Reasons',
+ 500 => 'Internal Server Error',
+ 501 => 'Not Implemented',
+ 502 => 'Bad Gateway',
+ 503 => 'Service Unavailable',
+ 504 => 'Gateway Time-out',
+ 505 => 'HTTP Version not supported',
+ 506 => 'Variant Also Negotiates',
+ 507 => 'Insufficient Storage',
+ 508 => 'Loop Detected',
+ 511 => 'Network Authentication Required',
+ ];
+
+ /** @var string */
+ private $reasonPhrase = '';
+
+ /** @var int */
+ private $statusCode = 200;
+
+ /**
+ * @param int $status Status code
+ * @param array $headers Response headers
+ * @param string|null|resource|StreamInterface $body Response body
+ * @param string $version Protocol version
+ * @param string|null $reason Reason phrase (when empty a default will be used based on the status code)
+ */
+ public function __construct(
+ $status = 200,
+ array $headers = [],
+ $body = null,
+ $version = '1.1',
+ $reason = null
+ ) {
+ $this->assertStatusCodeIsInteger($status);
+ $status = (int) $status;
+ $this->assertStatusCodeRange($status);
+
+ $this->statusCode = $status;
+
+ if ($body !== '' && $body !== null) {
+ $this->stream = stream_for($body);
+ }
+
+ $this->setHeaders($headers);
+ if ($reason == '' && isset(self::$phrases[$this->statusCode])) {
+ $this->reasonPhrase = self::$phrases[$this->statusCode];
+ } else {
+ $this->reasonPhrase = (string) $reason;
+ }
+
+ $this->protocol = $version;
+ }
+
+ public function getStatusCode()
+ {
+ return $this->statusCode;
+ }
+
+ public function getReasonPhrase()
+ {
+ return $this->reasonPhrase;
+ }
+
+ public function withStatus($code, $reasonPhrase = '')
+ {
+ $this->assertStatusCodeIsInteger($code);
+ $code = (int) $code;
+ $this->assertStatusCodeRange($code);
+
+ $new = clone $this;
+ $new->statusCode = $code;
+ if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) {
+ $reasonPhrase = self::$phrases[$new->statusCode];
+ }
+ $new->reasonPhrase = $reasonPhrase;
+ return $new;
+ }
+
+ private function assertStatusCodeIsInteger($statusCode)
+ {
+ if (filter_var($statusCode, FILTER_VALIDATE_INT) === false) {
+ throw new \InvalidArgumentException('Status code must be an integer value.');
+ }
+ }
+
+ private function assertStatusCodeRange($statusCode)
+ {
+ if ($statusCode < 100 || $statusCode >= 600) {
+ throw new \InvalidArgumentException('Status code must be an integer value between 1xx and 5xx.');
+ }
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/Rfc7230.php b/vendor/guzzlehttp/psr7/src/Rfc7230.php
new file mode 100644
index 0000000..505e474
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/Rfc7230.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+final class Rfc7230
+{
+ /**
+ * Header related regular expressions (copied from amphp/http package)
+ * (Note: once we require PHP 7.x we could just depend on the upstream package)
+ *
+ * Note: header delimiter (\r\n) is modified to \r?\n to accept line feed only delimiters for BC reasons.
+ *
+ * @link https://github.com/amphp/http/blob/v1.0.1/src/Rfc7230.php#L12-L15
+ * @license https://github.com/amphp/http/blob/v1.0.1/LICENSE
+ */
+ const HEADER_REGEX = "(^([^()<>@,;:\\\"/[\]?={}\x01-\x20\x7F]++):[ \t]*+((?:[ \t]*+[\x21-\x7E\x80-\xFF]++)*+)[ \t]*+\r?\n)m";
+ const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)";
+}
diff --git a/vendor/guzzlehttp/psr7/src/ServerRequest.php b/vendor/guzzlehttp/psr7/src/ServerRequest.php
new file mode 100644
index 0000000..1a09a6c
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/ServerRequest.php
@@ -0,0 +1,376 @@
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use InvalidArgumentException;
+use Psr\Http\Message\ServerRequestInterface;
+use Psr\Http\Message\UriInterface;
+use Psr\Http\Message\StreamInterface;
+use Psr\Http\Message\UploadedFileInterface;
+
+/**
+ * Server-side HTTP request
+ *
+ * Extends the Request definition to add methods for accessing incoming data,
+ * specifically server parameters, cookies, matched path parameters, query
+ * string arguments, body parameters, and upload file information.
+ *
+ * "Attributes" are discovered via decomposing the request (and usually
+ * specifically the URI path), and typically will be injected by the application.
+ *
+ * Requests are considered immutable; all methods that might change state are
+ * implemented such that they retain the internal state of the current
+ * message and return a new instance that contains the changed state.
+ */
+class ServerRequest extends Request implements ServerRequestInterface
+{
+ /**
+ * @var array
+ */
+ private $attributes = [];
+
+ /**
+ * @var array
+ */
+ private $cookieParams = [];
+
+ /**
+ * @var null|array|object
+ */
+ private $parsedBody;
+
+ /**
+ * @var array
+ */
+ private $queryParams = [];
+
+ /**
+ * @var array
+ */
+ private $serverParams;
+
+ /**
+ * @var array
+ */
+ private $uploadedFiles = [];
+
+ /**
+ * @param string $method HTTP method
+ * @param string|UriInterface $uri URI
+ * @param array $headers Request headers
+ * @param string|null|resource|StreamInterface $body Request body
+ * @param string $version Protocol version
+ * @param array $serverParams Typically the $_SERVER superglobal
+ */
+ public function __construct(
+ $method,
+ $uri,
+ array $headers = [],
+ $body = null,
+ $version = '1.1',
+ array $serverParams = []
+ ) {
+ $this->serverParams = $serverParams;
+
+ parent::__construct($method, $uri, $headers, $body, $version);
+ }
+
+ /**
+ * Return an UploadedFile instance array.
+ *
+ * @param array $files A array which respect $_FILES structure
+ * @throws InvalidArgumentException for unrecognized values
+ * @return array
+ */
+ public static function normalizeFiles(array $files)
+ {
+ $normalized = [];
+
+ foreach ($files as $key => $value) {
+ if ($value instanceof UploadedFileInterface) {
+ $normalized[$key] = $value;
+ } elseif (is_array($value) && isset($value['tmp_name'])) {
+ $normalized[$key] = self::createUploadedFileFromSpec($value);
+ } elseif (is_array($value)) {
+ $normalized[$key] = self::normalizeFiles($value);
+ continue;
+ } else {
+ throw new InvalidArgumentException('Invalid value in files specification');
+ }
+ }
+
+ return $normalized;
+ }
+
+ /**
+ * Create and return an UploadedFile instance from a $_FILES specification.
+ *
+ * If the specification represents an array of values, this method will
+ * delegate to normalizeNestedFileSpec() and return that return value.
+ *
+ * @param array $value $_FILES struct
+ * @return array|UploadedFileInterface
+ */
+ private static function createUploadedFileFromSpec(array $value)
+ {
+ if (is_array($value['tmp_name'])) {
+ return self::normalizeNestedFileSpec($value);
+ }
+
+ return new UploadedFile(
+ $value['tmp_name'],
+ (int) $value['size'],
+ (int) $value['error'],
+ $value['name'],
+ $value['type']
+ );
+ }
+
+ /**
+ * Normalize an array of file specifications.
+ *
+ * Loops through all nested files and returns a normalized array of
+ * UploadedFileInterface instances.
+ *
+ * @param array $files
+ * @return UploadedFileInterface[]
+ */
+ private static function normalizeNestedFileSpec(array $files = [])
+ {
+ $normalizedFiles = [];
+
+ foreach (array_keys($files['tmp_name']) as $key) {
+ $spec = [
+ 'tmp_name' => $files['tmp_name'][$key],
+ 'size' => $files['size'][$key],
+ 'error' => $files['error'][$key],
+ 'name' => $files['name'][$key],
+ 'type' => $files['type'][$key],
+ ];
+ $normalizedFiles[$key] = self::createUploadedFileFromSpec($spec);
+ }
+
+ return $normalizedFiles;
+ }
+
+ /**
+ * Return a ServerRequest populated with superglobals:
+ * $_GET
+ * $_POST
+ * $_COOKIE
+ * $_FILES
+ * $_SERVER
+ *
+ * @return ServerRequestInterface
+ */
+ public static function fromGlobals()
+ {
+ $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
+ $headers = getallheaders();
+ $uri = self::getUriFromGlobals();
+ $body = new CachingStream(new LazyOpenStream('php://input', 'r+'));
+ $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1';
+
+ $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $_SERVER);
+
+ return $serverRequest
+ ->withCookieParams($_COOKIE)
+ ->withQueryParams($_GET)
+ ->withParsedBody($_POST)
+ ->withUploadedFiles(self::normalizeFiles($_FILES));
+ }
+
+ private static function extractHostAndPortFromAuthority($authority)
+ {
+ $uri = 'http://'.$authority;
+ $parts = parse_url($uri);
+ if (false === $parts) {
+ return [null, null];
+ }
+
+ $host = isset($parts['host']) ? $parts['host'] : null;
+ $port = isset($parts['port']) ? $parts['port'] : null;
+
+ return [$host, $port];
+ }
+
+ /**
+ * Get a Uri populated with values from $_SERVER.
+ *
+ * @return UriInterface
+ */
+ public static function getUriFromGlobals()
+ {
+ $uri = new Uri('');
+
+ $uri = $uri->withScheme(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http');
+
+ $hasPort = false;
+ if (isset($_SERVER['HTTP_HOST'])) {
+ list($host, $port) = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']);
+ if ($host !== null) {
+ $uri = $uri->withHost($host);
+ }
+
+ if ($port !== null) {
+ $hasPort = true;
+ $uri = $uri->withPort($port);
+ }
+ } elseif (isset($_SERVER['SERVER_NAME'])) {
+ $uri = $uri->withHost($_SERVER['SERVER_NAME']);
+ } elseif (isset($_SERVER['SERVER_ADDR'])) {
+ $uri = $uri->withHost($_SERVER['SERVER_ADDR']);
+ }
+
+ if (!$hasPort && isset($_SERVER['SERVER_PORT'])) {
+ $uri = $uri->withPort($_SERVER['SERVER_PORT']);
+ }
+
+ $hasQuery = false;
+ if (isset($_SERVER['REQUEST_URI'])) {
+ $requestUriParts = explode('?', $_SERVER['REQUEST_URI'], 2);
+ $uri = $uri->withPath($requestUriParts[0]);
+ if (isset($requestUriParts[1])) {
+ $hasQuery = true;
+ $uri = $uri->withQuery($requestUriParts[1]);
+ }
+ }
+
+ if (!$hasQuery && isset($_SERVER['QUERY_STRING'])) {
+ $uri = $uri->withQuery($_SERVER['QUERY_STRING']);
+ }
+
+ return $uri;
+ }
+
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getServerParams()
+ {
+ return $this->serverParams;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getUploadedFiles()
+ {
+ return $this->uploadedFiles;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function withUploadedFiles(array $uploadedFiles)
+ {
+ $new = clone $this;
+ $new->uploadedFiles = $uploadedFiles;
+
+ return $new;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getCookieParams()
+ {
+ return $this->cookieParams;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function withCookieParams(array $cookies)
+ {
+ $new = clone $this;
+ $new->cookieParams = $cookies;
+
+ return $new;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getQueryParams()
+ {
+ return $this->queryParams;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function withQueryParams(array $query)
+ {
+ $new = clone $this;
+ $new->queryParams = $query;
+
+ return $new;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getParsedBody()
+ {
+ return $this->parsedBody;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function withParsedBody($data)
+ {
+ $new = clone $this;
+ $new->parsedBody = $data;
+
+ return $new;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAttributes()
+ {
+ return $this->attributes;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getAttribute($attribute, $default = null)
+ {
+ if (false === array_key_exists($attribute, $this->attributes)) {
+ return $default;
+ }
+
+ return $this->attributes[$attribute];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function withAttribute($attribute, $value)
+ {
+ $new = clone $this;
+ $new->attributes[$attribute] = $value;
+
+ return $new;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function withoutAttribute($attribute)
+ {
+ if (false === array_key_exists($attribute, $this->attributes)) {
+ return $this;
+ }
+
+ $new = clone $this;
+ unset($new->attributes[$attribute]);
+
+ return $new;
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/Stream.php b/vendor/guzzlehttp/psr7/src/Stream.php
new file mode 100644
index 0000000..d9e7409
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/Stream.php
@@ -0,0 +1,267 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * PHP stream implementation.
+ *
+ * @var $stream
+ */
+class Stream implements StreamInterface
+{
+ /**
+ * Resource modes.
+ *
+ * @var string
+ *
+ * @see http://php.net/manual/function.fopen.php
+ * @see http://php.net/manual/en/function.gzopen.php
+ */
+ const READABLE_MODES = '/r|a\+|ab\+|w\+|wb\+|x\+|xb\+|c\+|cb\+/';
+ const WRITABLE_MODES = '/a|w|r\+|rb\+|rw|x|c/';
+
+ private $stream;
+ private $size;
+ private $seekable;
+ private $readable;
+ private $writable;
+ private $uri;
+ private $customMetadata;
+
+ /**
+ * This constructor accepts an associative array of options.
+ *
+ * - size: (int) If a read stream would otherwise have an indeterminate
+ * size, but the size is known due to foreknowledge, then you can
+ * provide that size, in bytes.
+ * - metadata: (array) Any additional metadata to return when the metadata
+ * of the stream is accessed.
+ *
+ * @param resource $stream Stream resource to wrap.
+ * @param array $options Associative array of options.
+ *
+ * @throws \InvalidArgumentException if the stream is not a stream resource
+ */
+ public function __construct($stream, $options = [])
+ {
+ if (!is_resource($stream)) {
+ throw new \InvalidArgumentException('Stream must be a resource');
+ }
+
+ if (isset($options['size'])) {
+ $this->size = $options['size'];
+ }
+
+ $this->customMetadata = isset($options['metadata'])
+ ? $options['metadata']
+ : [];
+
+ $this->stream = $stream;
+ $meta = stream_get_meta_data($this->stream);
+ $this->seekable = $meta['seekable'];
+ $this->readable = (bool)preg_match(self::READABLE_MODES, $meta['mode']);
+ $this->writable = (bool)preg_match(self::WRITABLE_MODES, $meta['mode']);
+ $this->uri = $this->getMetadata('uri');
+ }
+
+ /**
+ * Closes the stream when the destructed
+ */
+ public function __destruct()
+ {
+ $this->close();
+ }
+
+ public function __toString()
+ {
+ try {
+ $this->seek(0);
+ return (string) stream_get_contents($this->stream);
+ } catch (\Exception $e) {
+ return '';
+ }
+ }
+
+ public function getContents()
+ {
+ if (!isset($this->stream)) {
+ throw new \RuntimeException('Stream is detached');
+ }
+
+ $contents = stream_get_contents($this->stream);
+
+ if ($contents === false) {
+ throw new \RuntimeException('Unable to read stream contents');
+ }
+
+ return $contents;
+ }
+
+ public function close()
+ {
+ if (isset($this->stream)) {
+ if (is_resource($this->stream)) {
+ fclose($this->stream);
+ }
+ $this->detach();
+ }
+ }
+
+ public function detach()
+ {
+ if (!isset($this->stream)) {
+ return null;
+ }
+
+ $result = $this->stream;
+ unset($this->stream);
+ $this->size = $this->uri = null;
+ $this->readable = $this->writable = $this->seekable = false;
+
+ return $result;
+ }
+
+ public function getSize()
+ {
+ if ($this->size !== null) {
+ return $this->size;
+ }
+
+ if (!isset($this->stream)) {
+ return null;
+ }
+
+ // Clear the stat cache if the stream has a URI
+ if ($this->uri) {
+ clearstatcache(true, $this->uri);
+ }
+
+ $stats = fstat($this->stream);
+ if (isset($stats['size'])) {
+ $this->size = $stats['size'];
+ return $this->size;
+ }
+
+ return null;
+ }
+
+ public function isReadable()
+ {
+ return $this->readable;
+ }
+
+ public function isWritable()
+ {
+ return $this->writable;
+ }
+
+ public function isSeekable()
+ {
+ return $this->seekable;
+ }
+
+ public function eof()
+ {
+ if (!isset($this->stream)) {
+ throw new \RuntimeException('Stream is detached');
+ }
+
+ return feof($this->stream);
+ }
+
+ public function tell()
+ {
+ if (!isset($this->stream)) {
+ throw new \RuntimeException('Stream is detached');
+ }
+
+ $result = ftell($this->stream);
+
+ if ($result === false) {
+ throw new \RuntimeException('Unable to determine stream position');
+ }
+
+ return $result;
+ }
+
+ public function rewind()
+ {
+ $this->seek(0);
+ }
+
+ public function seek($offset, $whence = SEEK_SET)
+ {
+ $whence = (int) $whence;
+
+ if (!isset($this->stream)) {
+ throw new \RuntimeException('Stream is detached');
+ }
+ if (!$this->seekable) {
+ throw new \RuntimeException('Stream is not seekable');
+ }
+ if (fseek($this->stream, $offset, $whence) === -1) {
+ throw new \RuntimeException('Unable to seek to stream position '
+ . $offset . ' with whence ' . var_export($whence, true));
+ }
+ }
+
+ public function read($length)
+ {
+ if (!isset($this->stream)) {
+ throw new \RuntimeException('Stream is detached');
+ }
+ if (!$this->readable) {
+ throw new \RuntimeException('Cannot read from non-readable stream');
+ }
+ if ($length < 0) {
+ throw new \RuntimeException('Length parameter cannot be negative');
+ }
+
+ if (0 === $length) {
+ return '';
+ }
+
+ $string = fread($this->stream, $length);
+ if (false === $string) {
+ throw new \RuntimeException('Unable to read from stream');
+ }
+
+ return $string;
+ }
+
+ public function write($string)
+ {
+ if (!isset($this->stream)) {
+ throw new \RuntimeException('Stream is detached');
+ }
+ if (!$this->writable) {
+ throw new \RuntimeException('Cannot write to a non-writable stream');
+ }
+
+ // We can't know the size after writing anything
+ $this->size = null;
+ $result = fwrite($this->stream, $string);
+
+ if ($result === false) {
+ throw new \RuntimeException('Unable to write to stream');
+ }
+
+ return $result;
+ }
+
+ public function getMetadata($key = null)
+ {
+ if (!isset($this->stream)) {
+ return $key ? null : [];
+ } elseif (!$key) {
+ return $this->customMetadata + stream_get_meta_data($this->stream);
+ } elseif (isset($this->customMetadata[$key])) {
+ return $this->customMetadata[$key];
+ }
+
+ $meta = stream_get_meta_data($this->stream);
+
+ return isset($meta[$key]) ? $meta[$key] : null;
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php b/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php
new file mode 100644
index 0000000..daec6f5
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php
@@ -0,0 +1,149 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Stream decorator trait
+ * @property StreamInterface stream
+ */
+trait StreamDecoratorTrait
+{
+ /**
+ * @param StreamInterface $stream Stream to decorate
+ */
+ public function __construct(StreamInterface $stream)
+ {
+ $this->stream = $stream;
+ }
+
+ /**
+ * Magic method used to create a new stream if streams are not added in
+ * the constructor of a decorator (e.g., LazyOpenStream).
+ *
+ * @param string $name Name of the property (allows "stream" only).
+ *
+ * @return StreamInterface
+ */
+ public function __get($name)
+ {
+ if ($name == 'stream') {
+ $this->stream = $this->createStream();
+ return $this->stream;
+ }
+
+ throw new \UnexpectedValueException("$name not found on class");
+ }
+
+ public function __toString()
+ {
+ try {
+ if ($this->isSeekable()) {
+ $this->seek(0);
+ }
+ return $this->getContents();
+ } catch (\Exception $e) {
+ // Really, PHP? https://bugs.php.net/bug.php?id=53648
+ trigger_error('StreamDecorator::__toString exception: '
+ . (string) $e, E_USER_ERROR);
+ return '';
+ }
+ }
+
+ public function getContents()
+ {
+ return copy_to_string($this);
+ }
+
+ /**
+ * Allow decorators to implement custom methods
+ *
+ * @param string $method Missing method name
+ * @param array $args Method arguments
+ *
+ * @return mixed
+ */
+ public function __call($method, array $args)
+ {
+ $result = call_user_func_array([$this->stream, $method], $args);
+
+ // Always return the wrapped object if the result is a return $this
+ return $result === $this->stream ? $this : $result;
+ }
+
+ public function close()
+ {
+ $this->stream->close();
+ }
+
+ public function getMetadata($key = null)
+ {
+ return $this->stream->getMetadata($key);
+ }
+
+ public function detach()
+ {
+ return $this->stream->detach();
+ }
+
+ public function getSize()
+ {
+ return $this->stream->getSize();
+ }
+
+ public function eof()
+ {
+ return $this->stream->eof();
+ }
+
+ public function tell()
+ {
+ return $this->stream->tell();
+ }
+
+ public function isReadable()
+ {
+ return $this->stream->isReadable();
+ }
+
+ public function isWritable()
+ {
+ return $this->stream->isWritable();
+ }
+
+ public function isSeekable()
+ {
+ return $this->stream->isSeekable();
+ }
+
+ public function rewind()
+ {
+ $this->seek(0);
+ }
+
+ public function seek($offset, $whence = SEEK_SET)
+ {
+ $this->stream->seek($offset, $whence);
+ }
+
+ public function read($length)
+ {
+ return $this->stream->read($length);
+ }
+
+ public function write($string)
+ {
+ return $this->stream->write($string);
+ }
+
+ /**
+ * Implement in subclasses to dynamically create streams when requested.
+ *
+ * @return StreamInterface
+ * @throws \BadMethodCallException
+ */
+ protected function createStream()
+ {
+ throw new \BadMethodCallException('Not implemented');
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/StreamWrapper.php b/vendor/guzzlehttp/psr7/src/StreamWrapper.php
new file mode 100644
index 0000000..0f3a285
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/StreamWrapper.php
@@ -0,0 +1,161 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Converts Guzzle streams into PHP stream resources.
+ */
+class StreamWrapper
+{
+ /** @var resource */
+ public $context;
+
+ /** @var StreamInterface */
+ private $stream;
+
+ /** @var string r, r+, or w */
+ private $mode;
+
+ /**
+ * Returns a resource representing the stream.
+ *
+ * @param StreamInterface $stream The stream to get a resource for
+ *
+ * @return resource
+ * @throws \InvalidArgumentException if stream is not readable or writable
+ */
+ public static function getResource(StreamInterface $stream)
+ {
+ self::register();
+
+ if ($stream->isReadable()) {
+ $mode = $stream->isWritable() ? 'r+' : 'r';
+ } elseif ($stream->isWritable()) {
+ $mode = 'w';
+ } else {
+ throw new \InvalidArgumentException('The stream must be readable, '
+ . 'writable, or both.');
+ }
+
+ return fopen('guzzle://stream', $mode, null, self::createStreamContext($stream));
+ }
+
+ /**
+ * Creates a stream context that can be used to open a stream as a php stream resource.
+ *
+ * @param StreamInterface $stream
+ *
+ * @return resource
+ */
+ public static function createStreamContext(StreamInterface $stream)
+ {
+ return stream_context_create([
+ 'guzzle' => ['stream' => $stream]
+ ]);
+ }
+
+ /**
+ * Registers the stream wrapper if needed
+ */
+ public static function register()
+ {
+ if (!in_array('guzzle', stream_get_wrappers())) {
+ stream_wrapper_register('guzzle', __CLASS__);
+ }
+ }
+
+ public function stream_open($path, $mode, $options, &$opened_path)
+ {
+ $options = stream_context_get_options($this->context);
+
+ if (!isset($options['guzzle']['stream'])) {
+ return false;
+ }
+
+ $this->mode = $mode;
+ $this->stream = $options['guzzle']['stream'];
+
+ return true;
+ }
+
+ public function stream_read($count)
+ {
+ return $this->stream->read($count);
+ }
+
+ public function stream_write($data)
+ {
+ return (int) $this->stream->write($data);
+ }
+
+ public function stream_tell()
+ {
+ return $this->stream->tell();
+ }
+
+ public function stream_eof()
+ {
+ return $this->stream->eof();
+ }
+
+ public function stream_seek($offset, $whence)
+ {
+ $this->stream->seek($offset, $whence);
+
+ return true;
+ }
+
+ public function stream_cast($cast_as)
+ {
+ $stream = clone($this->stream);
+
+ return $stream->detach();
+ }
+
+ public function stream_stat()
+ {
+ static $modeMap = [
+ 'r' => 33060,
+ 'rb' => 33060,
+ 'r+' => 33206,
+ 'w' => 33188,
+ 'wb' => 33188
+ ];
+
+ return [
+ 'dev' => 0,
+ 'ino' => 0,
+ 'mode' => $modeMap[$this->mode],
+ 'nlink' => 0,
+ 'uid' => 0,
+ 'gid' => 0,
+ 'rdev' => 0,
+ 'size' => $this->stream->getSize() ?: 0,
+ 'atime' => 0,
+ 'mtime' => 0,
+ 'ctime' => 0,
+ 'blksize' => 0,
+ 'blocks' => 0
+ ];
+ }
+
+ public function url_stat($path, $flags)
+ {
+ return [
+ 'dev' => 0,
+ 'ino' => 0,
+ 'mode' => 0,
+ 'nlink' => 0,
+ 'uid' => 0,
+ 'gid' => 0,
+ 'rdev' => 0,
+ 'size' => 0,
+ 'atime' => 0,
+ 'mtime' => 0,
+ 'ctime' => 0,
+ 'blksize' => 0,
+ 'blocks' => 0
+ ];
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/UploadedFile.php b/vendor/guzzlehttp/psr7/src/UploadedFile.php
new file mode 100644
index 0000000..e62bd5c
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/UploadedFile.php
@@ -0,0 +1,316 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use InvalidArgumentException;
+use Psr\Http\Message\StreamInterface;
+use Psr\Http\Message\UploadedFileInterface;
+use RuntimeException;
+
+class UploadedFile implements UploadedFileInterface
+{
+ /**
+ * @var int[]
+ */
+ private static $errors = [
+ UPLOAD_ERR_OK,
+ UPLOAD_ERR_INI_SIZE,
+ UPLOAD_ERR_FORM_SIZE,
+ UPLOAD_ERR_PARTIAL,
+ UPLOAD_ERR_NO_FILE,
+ UPLOAD_ERR_NO_TMP_DIR,
+ UPLOAD_ERR_CANT_WRITE,
+ UPLOAD_ERR_EXTENSION,
+ ];
+
+ /**
+ * @var string
+ */
+ private $clientFilename;
+
+ /**
+ * @var string
+ */
+ private $clientMediaType;
+
+ /**
+ * @var int
+ */
+ private $error;
+
+ /**
+ * @var null|string
+ */
+ private $file;
+
+ /**
+ * @var bool
+ */
+ private $moved = false;
+
+ /**
+ * @var int
+ */
+ private $size;
+
+ /**
+ * @var StreamInterface|null
+ */
+ private $stream;
+
+ /**
+ * @param StreamInterface|string|resource $streamOrFile
+ * @param int $size
+ * @param int $errorStatus
+ * @param string|null $clientFilename
+ * @param string|null $clientMediaType
+ */
+ public function __construct(
+ $streamOrFile,
+ $size,
+ $errorStatus,
+ $clientFilename = null,
+ $clientMediaType = null
+ ) {
+ $this->setError($errorStatus);
+ $this->setSize($size);
+ $this->setClientFilename($clientFilename);
+ $this->setClientMediaType($clientMediaType);
+
+ if ($this->isOk()) {
+ $this->setStreamOrFile($streamOrFile);
+ }
+ }
+
+ /**
+ * Depending on the value set file or stream variable
+ *
+ * @param mixed $streamOrFile
+ * @throws InvalidArgumentException
+ */
+ private function setStreamOrFile($streamOrFile)
+ {
+ if (is_string($streamOrFile)) {
+ $this->file = $streamOrFile;
+ } elseif (is_resource($streamOrFile)) {
+ $this->stream = new Stream($streamOrFile);
+ } elseif ($streamOrFile instanceof StreamInterface) {
+ $this->stream = $streamOrFile;
+ } else {
+ throw new InvalidArgumentException(
+ 'Invalid stream or file provided for UploadedFile'
+ );
+ }
+ }
+
+ /**
+ * @param int $error
+ * @throws InvalidArgumentException
+ */
+ private function setError($error)
+ {
+ if (false === is_int($error)) {
+ throw new InvalidArgumentException(
+ 'Upload file error status must be an integer'
+ );
+ }
+
+ if (false === in_array($error, UploadedFile::$errors)) {
+ throw new InvalidArgumentException(
+ 'Invalid error status for UploadedFile'
+ );
+ }
+
+ $this->error = $error;
+ }
+
+ /**
+ * @param int $size
+ * @throws InvalidArgumentException
+ */
+ private function setSize($size)
+ {
+ if (false === is_int($size)) {
+ throw new InvalidArgumentException(
+ 'Upload file size must be an integer'
+ );
+ }
+
+ $this->size = $size;
+ }
+
+ /**
+ * @param mixed $param
+ * @return boolean
+ */
+ private function isStringOrNull($param)
+ {
+ return in_array(gettype($param), ['string', 'NULL']);
+ }
+
+ /**
+ * @param mixed $param
+ * @return boolean
+ */
+ private function isStringNotEmpty($param)
+ {
+ return is_string($param) && false === empty($param);
+ }
+
+ /**
+ * @param string|null $clientFilename
+ * @throws InvalidArgumentException
+ */
+ private function setClientFilename($clientFilename)
+ {
+ if (false === $this->isStringOrNull($clientFilename)) {
+ throw new InvalidArgumentException(
+ 'Upload file client filename must be a string or null'
+ );
+ }
+
+ $this->clientFilename = $clientFilename;
+ }
+
+ /**
+ * @param string|null $clientMediaType
+ * @throws InvalidArgumentException
+ */
+ private function setClientMediaType($clientMediaType)
+ {
+ if (false === $this->isStringOrNull($clientMediaType)) {
+ throw new InvalidArgumentException(
+ 'Upload file client media type must be a string or null'
+ );
+ }
+
+ $this->clientMediaType = $clientMediaType;
+ }
+
+ /**
+ * Return true if there is no upload error
+ *
+ * @return boolean
+ */
+ private function isOk()
+ {
+ return $this->error === UPLOAD_ERR_OK;
+ }
+
+ /**
+ * @return boolean
+ */
+ public function isMoved()
+ {
+ return $this->moved;
+ }
+
+ /**
+ * @throws RuntimeException if is moved or not ok
+ */
+ private function validateActive()
+ {
+ if (false === $this->isOk()) {
+ throw new RuntimeException('Cannot retrieve stream due to upload error');
+ }
+
+ if ($this->isMoved()) {
+ throw new RuntimeException('Cannot retrieve stream after it has already been moved');
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ * @throws RuntimeException if the upload was not successful.
+ */
+ public function getStream()
+ {
+ $this->validateActive();
+
+ if ($this->stream instanceof StreamInterface) {
+ return $this->stream;
+ }
+
+ return new LazyOpenStream($this->file, 'r+');
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * @see http://php.net/is_uploaded_file
+ * @see http://php.net/move_uploaded_file
+ * @param string $targetPath Path to which to move the uploaded file.
+ * @throws RuntimeException if the upload was not successful.
+ * @throws InvalidArgumentException if the $path specified is invalid.
+ * @throws RuntimeException on any error during the move operation, or on
+ * the second or subsequent call to the method.
+ */
+ public function moveTo($targetPath)
+ {
+ $this->validateActive();
+
+ if (false === $this->isStringNotEmpty($targetPath)) {
+ throw new InvalidArgumentException(
+ 'Invalid path provided for move operation; must be a non-empty string'
+ );
+ }
+
+ if ($this->file) {
+ $this->moved = php_sapi_name() == 'cli'
+ ? rename($this->file, $targetPath)
+ : move_uploaded_file($this->file, $targetPath);
+ } else {
+ copy_to_stream(
+ $this->getStream(),
+ new LazyOpenStream($targetPath, 'w')
+ );
+
+ $this->moved = true;
+ }
+
+ if (false === $this->moved) {
+ throw new RuntimeException(
+ sprintf('Uploaded file could not be moved to %s', $targetPath)
+ );
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * @return int|null The file size in bytes or null if unknown.
+ */
+ public function getSize()
+ {
+ return $this->size;
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * @see http://php.net/manual/en/features.file-upload.errors.php
+ * @return int One of PHP's UPLOAD_ERR_XXX constants.
+ */
+ public function getError()
+ {
+ return $this->error;
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * @return string|null The filename sent by the client or null if none
+ * was provided.
+ */
+ public function getClientFilename()
+ {
+ return $this->clientFilename;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getClientMediaType()
+ {
+ return $this->clientMediaType;
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/Uri.php b/vendor/guzzlehttp/psr7/src/Uri.php
new file mode 100644
index 0000000..825a25e
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/Uri.php
@@ -0,0 +1,760 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\UriInterface;
+
+/**
+ * PSR-7 URI implementation.
+ *
+ * @author Michael Dowling
+ * @author Tobias Schultze
+ * @author Matthew Weier O'Phinney
+ */
+class Uri implements UriInterface
+{
+ /**
+ * Absolute http and https URIs require a host per RFC 7230 Section 2.7
+ * but in generic URIs the host can be empty. So for http(s) URIs
+ * we apply this default host when no host is given yet to form a
+ * valid URI.
+ */
+ const HTTP_DEFAULT_HOST = 'localhost';
+
+ private static $defaultPorts = [
+ 'http' => 80,
+ 'https' => 443,
+ 'ftp' => 21,
+ 'gopher' => 70,
+ 'nntp' => 119,
+ 'news' => 119,
+ 'telnet' => 23,
+ 'tn3270' => 23,
+ 'imap' => 143,
+ 'pop' => 110,
+ 'ldap' => 389,
+ ];
+
+ private static $charUnreserved = 'a-zA-Z0-9_\-\.~';
+ private static $charSubDelims = '!\$&\'\(\)\*\+,;=';
+ private static $replaceQuery = ['=' => '%3D', '&' => '%26'];
+
+ /** @var string Uri scheme. */
+ private $scheme = '';
+
+ /** @var string Uri user info. */
+ private $userInfo = '';
+
+ /** @var string Uri host. */
+ private $host = '';
+
+ /** @var int|null Uri port. */
+ private $port;
+
+ /** @var string Uri path. */
+ private $path = '';
+
+ /** @var string Uri query string. */
+ private $query = '';
+
+ /** @var string Uri fragment. */
+ private $fragment = '';
+
+ /**
+ * @param string $uri URI to parse
+ */
+ public function __construct($uri = '')
+ {
+ // weak type check to also accept null until we can add scalar type hints
+ if ($uri != '') {
+ $parts = parse_url($uri);
+ if ($parts === false) {
+ throw new \InvalidArgumentException("Unable to parse URI: $uri");
+ }
+ $this->applyParts($parts);
+ }
+ }
+
+ public function __toString()
+ {
+ return self::composeComponents(
+ $this->scheme,
+ $this->getAuthority(),
+ $this->path,
+ $this->query,
+ $this->fragment
+ );
+ }
+
+ /**
+ * Composes a URI reference string from its various components.
+ *
+ * Usually this method does not need to be called manually but instead is used indirectly via
+ * `Psr\Http\Message\UriInterface::__toString`.
+ *
+ * PSR-7 UriInterface treats an empty component the same as a missing component as
+ * getQuery(), getFragment() etc. always return a string. This explains the slight
+ * difference to RFC 3986 Section 5.3.
+ *
+ * Another adjustment is that the authority separator is added even when the authority is missing/empty
+ * for the "file" scheme. This is because PHP stream functions like `file_get_contents` only work with
+ * `file:///myfile` but not with `file:/myfile` although they are equivalent according to RFC 3986. But
+ * `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to
+ * that format).
+ *
+ * @param string $scheme
+ * @param string $authority
+ * @param string $path
+ * @param string $query
+ * @param string $fragment
+ *
+ * @return string
+ *
+ * @link https://tools.ietf.org/html/rfc3986#section-5.3
+ */
+ public static function composeComponents($scheme, $authority, $path, $query, $fragment)
+ {
+ $uri = '';
+
+ // weak type checks to also accept null until we can add scalar type hints
+ if ($scheme != '') {
+ $uri .= $scheme . ':';
+ }
+
+ if ($authority != ''|| $scheme === 'file') {
+ $uri .= '//' . $authority;
+ }
+
+ $uri .= $path;
+
+ if ($query != '') {
+ $uri .= '?' . $query;
+ }
+
+ if ($fragment != '') {
+ $uri .= '#' . $fragment;
+ }
+
+ return $uri;
+ }
+
+ /**
+ * Whether the URI has the default port of the current scheme.
+ *
+ * `Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used
+ * independently of the implementation.
+ *
+ * @param UriInterface $uri
+ *
+ * @return bool
+ */
+ public static function isDefaultPort(UriInterface $uri)
+ {
+ return $uri->getPort() === null
+ || (isset(self::$defaultPorts[$uri->getScheme()]) && $uri->getPort() === self::$defaultPorts[$uri->getScheme()]);
+ }
+
+ /**
+ * Whether the URI is absolute, i.e. it has a scheme.
+ *
+ * An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true
+ * if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative
+ * to another URI, the base URI. Relative references can be divided into several forms:
+ * - network-path references, e.g. '//example.com/path'
+ * - absolute-path references, e.g. '/path'
+ * - relative-path references, e.g. 'subpath'
+ *
+ * @param UriInterface $uri
+ *
+ * @return bool
+ * @see Uri::isNetworkPathReference
+ * @see Uri::isAbsolutePathReference
+ * @see Uri::isRelativePathReference
+ * @link https://tools.ietf.org/html/rfc3986#section-4
+ */
+ public static function isAbsolute(UriInterface $uri)
+ {
+ return $uri->getScheme() !== '';
+ }
+
+ /**
+ * Whether the URI is a network-path reference.
+ *
+ * A relative reference that begins with two slash characters is termed an network-path reference.
+ *
+ * @param UriInterface $uri
+ *
+ * @return bool
+ * @link https://tools.ietf.org/html/rfc3986#section-4.2
+ */
+ public static function isNetworkPathReference(UriInterface $uri)
+ {
+ return $uri->getScheme() === '' && $uri->getAuthority() !== '';
+ }
+
+ /**
+ * Whether the URI is a absolute-path reference.
+ *
+ * A relative reference that begins with a single slash character is termed an absolute-path reference.
+ *
+ * @param UriInterface $uri
+ *
+ * @return bool
+ * @link https://tools.ietf.org/html/rfc3986#section-4.2
+ */
+ public static function isAbsolutePathReference(UriInterface $uri)
+ {
+ return $uri->getScheme() === ''
+ && $uri->getAuthority() === ''
+ && isset($uri->getPath()[0])
+ && $uri->getPath()[0] === '/';
+ }
+
+ /**
+ * Whether the URI is a relative-path reference.
+ *
+ * A relative reference that does not begin with a slash character is termed a relative-path reference.
+ *
+ * @param UriInterface $uri
+ *
+ * @return bool
+ * @link https://tools.ietf.org/html/rfc3986#section-4.2
+ */
+ public static function isRelativePathReference(UriInterface $uri)
+ {
+ return $uri->getScheme() === ''
+ && $uri->getAuthority() === ''
+ && (!isset($uri->getPath()[0]) || $uri->getPath()[0] !== '/');
+ }
+
+ /**
+ * Whether the URI is a same-document reference.
+ *
+ * A same-document reference refers to a URI that is, aside from its fragment
+ * component, identical to the base URI. When no base URI is given, only an empty
+ * URI reference (apart from its fragment) is considered a same-document reference.
+ *
+ * @param UriInterface $uri The URI to check
+ * @param UriInterface|null $base An optional base URI to compare against
+ *
+ * @return bool
+ * @link https://tools.ietf.org/html/rfc3986#section-4.4
+ */
+ public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null)
+ {
+ if ($base !== null) {
+ $uri = UriResolver::resolve($base, $uri);
+
+ return ($uri->getScheme() === $base->getScheme())
+ && ($uri->getAuthority() === $base->getAuthority())
+ && ($uri->getPath() === $base->getPath())
+ && ($uri->getQuery() === $base->getQuery());
+ }
+
+ return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === '';
+ }
+
+ /**
+ * Removes dot segments from a path and returns the new path.
+ *
+ * @param string $path
+ *
+ * @return string
+ *
+ * @deprecated since version 1.4. Use UriResolver::removeDotSegments instead.
+ * @see UriResolver::removeDotSegments
+ */
+ public static function removeDotSegments($path)
+ {
+ return UriResolver::removeDotSegments($path);
+ }
+
+ /**
+ * Converts the relative URI into a new URI that is resolved against the base URI.
+ *
+ * @param UriInterface $base Base URI
+ * @param string|UriInterface $rel Relative URI
+ *
+ * @return UriInterface
+ *
+ * @deprecated since version 1.4. Use UriResolver::resolve instead.
+ * @see UriResolver::resolve
+ */
+ public static function resolve(UriInterface $base, $rel)
+ {
+ if (!($rel instanceof UriInterface)) {
+ $rel = new self($rel);
+ }
+
+ return UriResolver::resolve($base, $rel);
+ }
+
+ /**
+ * Creates a new URI with a specific query string value removed.
+ *
+ * Any existing query string values that exactly match the provided key are
+ * removed.
+ *
+ * @param UriInterface $uri URI to use as a base.
+ * @param string $key Query string key to remove.
+ *
+ * @return UriInterface
+ */
+ public static function withoutQueryValue(UriInterface $uri, $key)
+ {
+ $result = self::getFilteredQueryString($uri, [$key]);
+
+ return $uri->withQuery(implode('&', $result));
+ }
+
+ /**
+ * Creates a new URI with a specific query string value.
+ *
+ * Any existing query string values that exactly match the provided key are
+ * removed and replaced with the given key value pair.
+ *
+ * A value of null will set the query string key without a value, e.g. "key"
+ * instead of "key=value".
+ *
+ * @param UriInterface $uri URI to use as a base.
+ * @param string $key Key to set.
+ * @param string|null $value Value to set
+ *
+ * @return UriInterface
+ */
+ public static function withQueryValue(UriInterface $uri, $key, $value)
+ {
+ $result = self::getFilteredQueryString($uri, [$key]);
+
+ $result[] = self::generateQueryString($key, $value);
+
+ return $uri->withQuery(implode('&', $result));
+ }
+
+ /**
+ * Creates a new URI with multiple specific query string values.
+ *
+ * It has the same behavior as withQueryValue() but for an associative array of key => value.
+ *
+ * @param UriInterface $uri URI to use as a base.
+ * @param array $keyValueArray Associative array of key and values
+ *
+ * @return UriInterface
+ */
+ public static function withQueryValues(UriInterface $uri, array $keyValueArray)
+ {
+ $result = self::getFilteredQueryString($uri, array_keys($keyValueArray));
+
+ foreach ($keyValueArray as $key => $value) {
+ $result[] = self::generateQueryString($key, $value);
+ }
+
+ return $uri->withQuery(implode('&', $result));
+ }
+
+ /**
+ * Creates a URI from a hash of `parse_url` components.
+ *
+ * @param array $parts
+ *
+ * @return UriInterface
+ * @link http://php.net/manual/en/function.parse-url.php
+ *
+ * @throws \InvalidArgumentException If the components do not form a valid URI.
+ */
+ public static function fromParts(array $parts)
+ {
+ $uri = new self();
+ $uri->applyParts($parts);
+ $uri->validateState();
+
+ return $uri;
+ }
+
+ public function getScheme()
+ {
+ return $this->scheme;
+ }
+
+ public function getAuthority()
+ {
+ $authority = $this->host;
+ if ($this->userInfo !== '') {
+ $authority = $this->userInfo . '@' . $authority;
+ }
+
+ if ($this->port !== null) {
+ $authority .= ':' . $this->port;
+ }
+
+ return $authority;
+ }
+
+ public function getUserInfo()
+ {
+ return $this->userInfo;
+ }
+
+ public function getHost()
+ {
+ return $this->host;
+ }
+
+ public function getPort()
+ {
+ return $this->port;
+ }
+
+ public function getPath()
+ {
+ return $this->path;
+ }
+
+ public function getQuery()
+ {
+ return $this->query;
+ }
+
+ public function getFragment()
+ {
+ return $this->fragment;
+ }
+
+ public function withScheme($scheme)
+ {
+ $scheme = $this->filterScheme($scheme);
+
+ if ($this->scheme === $scheme) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->scheme = $scheme;
+ $new->removeDefaultPort();
+ $new->validateState();
+
+ return $new;
+ }
+
+ public function withUserInfo($user, $password = null)
+ {
+ $info = $this->filterUserInfoComponent($user);
+ if ($password !== null) {
+ $info .= ':' . $this->filterUserInfoComponent($password);
+ }
+
+ if ($this->userInfo === $info) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->userInfo = $info;
+ $new->validateState();
+
+ return $new;
+ }
+
+ public function withHost($host)
+ {
+ $host = $this->filterHost($host);
+
+ if ($this->host === $host) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->host = $host;
+ $new->validateState();
+
+ return $new;
+ }
+
+ public function withPort($port)
+ {
+ $port = $this->filterPort($port);
+
+ if ($this->port === $port) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->port = $port;
+ $new->removeDefaultPort();
+ $new->validateState();
+
+ return $new;
+ }
+
+ public function withPath($path)
+ {
+ $path = $this->filterPath($path);
+
+ if ($this->path === $path) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->path = $path;
+ $new->validateState();
+
+ return $new;
+ }
+
+ public function withQuery($query)
+ {
+ $query = $this->filterQueryAndFragment($query);
+
+ if ($this->query === $query) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->query = $query;
+
+ return $new;
+ }
+
+ public function withFragment($fragment)
+ {
+ $fragment = $this->filterQueryAndFragment($fragment);
+
+ if ($this->fragment === $fragment) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->fragment = $fragment;
+
+ return $new;
+ }
+
+ /**
+ * Apply parse_url parts to a URI.
+ *
+ * @param array $parts Array of parse_url parts to apply.
+ */
+ private function applyParts(array $parts)
+ {
+ $this->scheme = isset($parts['scheme'])
+ ? $this->filterScheme($parts['scheme'])
+ : '';
+ $this->userInfo = isset($parts['user'])
+ ? $this->filterUserInfoComponent($parts['user'])
+ : '';
+ $this->host = isset($parts['host'])
+ ? $this->filterHost($parts['host'])
+ : '';
+ $this->port = isset($parts['port'])
+ ? $this->filterPort($parts['port'])
+ : null;
+ $this->path = isset($parts['path'])
+ ? $this->filterPath($parts['path'])
+ : '';
+ $this->query = isset($parts['query'])
+ ? $this->filterQueryAndFragment($parts['query'])
+ : '';
+ $this->fragment = isset($parts['fragment'])
+ ? $this->filterQueryAndFragment($parts['fragment'])
+ : '';
+ if (isset($parts['pass'])) {
+ $this->userInfo .= ':' . $this->filterUserInfoComponent($parts['pass']);
+ }
+
+ $this->removeDefaultPort();
+ }
+
+ /**
+ * @param string $scheme
+ *
+ * @return string
+ *
+ * @throws \InvalidArgumentException If the scheme is invalid.
+ */
+ private function filterScheme($scheme)
+ {
+ if (!is_string($scheme)) {
+ throw new \InvalidArgumentException('Scheme must be a string');
+ }
+
+ return strtolower($scheme);
+ }
+
+ /**
+ * @param string $component
+ *
+ * @return string
+ *
+ * @throws \InvalidArgumentException If the user info is invalid.
+ */
+ private function filterUserInfoComponent($component)
+ {
+ if (!is_string($component)) {
+ throw new \InvalidArgumentException('User info must be a string');
+ }
+
+ return preg_replace_callback(
+ '/(?:[^%' . self::$charUnreserved . self::$charSubDelims . ']+|%(?![A-Fa-f0-9]{2}))/',
+ [$this, 'rawurlencodeMatchZero'],
+ $component
+ );
+ }
+
+ /**
+ * @param string $host
+ *
+ * @return string
+ *
+ * @throws \InvalidArgumentException If the host is invalid.
+ */
+ private function filterHost($host)
+ {
+ if (!is_string($host)) {
+ throw new \InvalidArgumentException('Host must be a string');
+ }
+
+ return strtolower($host);
+ }
+
+ /**
+ * @param int|null $port
+ *
+ * @return int|null
+ *
+ * @throws \InvalidArgumentException If the port is invalid.
+ */
+ private function filterPort($port)
+ {
+ if ($port === null) {
+ return null;
+ }
+
+ $port = (int) $port;
+ if (0 > $port || 0xffff < $port) {
+ throw new \InvalidArgumentException(
+ sprintf('Invalid port: %d. Must be between 0 and 65535', $port)
+ );
+ }
+
+ return $port;
+ }
+
+ /**
+ * @param UriInterface $uri
+ * @param array $keys
+ *
+ * @return array
+ */
+ private static function getFilteredQueryString(UriInterface $uri, array $keys)
+ {
+ $current = $uri->getQuery();
+
+ if ($current === '') {
+ return [];
+ }
+
+ $decodedKeys = array_map('rawurldecode', $keys);
+
+ return array_filter(explode('&', $current), function ($part) use ($decodedKeys) {
+ return !in_array(rawurldecode(explode('=', $part)[0]), $decodedKeys, true);
+ });
+ }
+
+ /**
+ * @param string $key
+ * @param string|null $value
+ *
+ * @return string
+ */
+ private static function generateQueryString($key, $value)
+ {
+ // Query string separators ("=", "&") within the key or value need to be encoded
+ // (while preventing double-encoding) before setting the query string. All other
+ // chars that need percent-encoding will be encoded by withQuery().
+ $queryString = strtr($key, self::$replaceQuery);
+
+ if ($value !== null) {
+ $queryString .= '=' . strtr($value, self::$replaceQuery);
+ }
+
+ return $queryString;
+ }
+
+ private function removeDefaultPort()
+ {
+ if ($this->port !== null && self::isDefaultPort($this)) {
+ $this->port = null;
+ }
+ }
+
+ /**
+ * Filters the path of a URI
+ *
+ * @param string $path
+ *
+ * @return string
+ *
+ * @throws \InvalidArgumentException If the path is invalid.
+ */
+ private function filterPath($path)
+ {
+ if (!is_string($path)) {
+ throw new \InvalidArgumentException('Path must be a string');
+ }
+
+ return preg_replace_callback(
+ '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
+ [$this, 'rawurlencodeMatchZero'],
+ $path
+ );
+ }
+
+ /**
+ * Filters the query string or fragment of a URI.
+ *
+ * @param string $str
+ *
+ * @return string
+ *
+ * @throws \InvalidArgumentException If the query or fragment is invalid.
+ */
+ private function filterQueryAndFragment($str)
+ {
+ if (!is_string($str)) {
+ throw new \InvalidArgumentException('Query and fragment must be a string');
+ }
+
+ return preg_replace_callback(
+ '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/',
+ [$this, 'rawurlencodeMatchZero'],
+ $str
+ );
+ }
+
+ private function rawurlencodeMatchZero(array $match)
+ {
+ return rawurlencode($match[0]);
+ }
+
+ private function validateState()
+ {
+ if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) {
+ $this->host = self::HTTP_DEFAULT_HOST;
+ }
+
+ if ($this->getAuthority() === '') {
+ if (0 === strpos($this->path, '//')) {
+ throw new \InvalidArgumentException('The path of a URI without an authority must not start with two slashes "//"');
+ }
+ if ($this->scheme === '' && false !== strpos(explode('/', $this->path, 2)[0], ':')) {
+ throw new \InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon');
+ }
+ } elseif (isset($this->path[0]) && $this->path[0] !== '/') {
+ @trigger_error(
+ 'The path of a URI with an authority must start with a slash "/" or be empty. Automagically fixing the URI ' .
+ 'by adding a leading slash to the path is deprecated since version 1.4 and will throw an exception instead.',
+ E_USER_DEPRECATED
+ );
+ $this->path = '/'. $this->path;
+ //throw new \InvalidArgumentException('The path of a URI with an authority must start with a slash "/" or be empty');
+ }
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/UriNormalizer.php b/vendor/guzzlehttp/psr7/src/UriNormalizer.php
new file mode 100644
index 0000000..384c29e
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/UriNormalizer.php
@@ -0,0 +1,216 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\UriInterface;
+
+/**
+ * Provides methods to normalize and compare URIs.
+ *
+ * @author Tobias Schultze
+ *
+ * @link https://tools.ietf.org/html/rfc3986#section-6
+ */
+final class UriNormalizer
+{
+ /**
+ * Default normalizations which only include the ones that preserve semantics.
+ *
+ * self::CAPITALIZE_PERCENT_ENCODING | self::DECODE_UNRESERVED_CHARACTERS | self::CONVERT_EMPTY_PATH |
+ * self::REMOVE_DEFAULT_HOST | self::REMOVE_DEFAULT_PORT | self::REMOVE_DOT_SEGMENTS
+ */
+ const PRESERVING_NORMALIZATIONS = 63;
+
+ /**
+ * All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized.
+ *
+ * Example: http://example.org/a%c2%b1b → http://example.org/a%C2%B1b
+ */
+ const CAPITALIZE_PERCENT_ENCODING = 1;
+
+ /**
+ * Decodes percent-encoded octets of unreserved characters.
+ *
+ * For consistency, percent-encoded octets in the ranges of ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39),
+ * hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should not be created by URI producers and,
+ * when found in a URI, should be decoded to their corresponding unreserved characters by URI normalizers.
+ *
+ * Example: http://example.org/%7Eusern%61me/ → http://example.org/~username/
+ */
+ const DECODE_UNRESERVED_CHARACTERS = 2;
+
+ /**
+ * Converts the empty path to "/" for http and https URIs.
+ *
+ * Example: http://example.org → http://example.org/
+ */
+ const CONVERT_EMPTY_PATH = 4;
+
+ /**
+ * Removes the default host of the given URI scheme from the URI.
+ *
+ * Only the "file" scheme defines the default host "localhost".
+ * All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile`
+ * are equivalent according to RFC 3986. The first format is not accepted
+ * by PHPs stream functions and thus already normalized implicitly to the
+ * second format in the Uri class. See `GuzzleHttp\Psr7\Uri::composeComponents`.
+ *
+ * Example: file://localhost/myfile → file:///myfile
+ */
+ const REMOVE_DEFAULT_HOST = 8;
+
+ /**
+ * Removes the default port of the given URI scheme from the URI.
+ *
+ * Example: http://example.org:80/ → http://example.org/
+ */
+ const REMOVE_DEFAULT_PORT = 16;
+
+ /**
+ * Removes unnecessary dot-segments.
+ *
+ * Dot-segments in relative-path references are not removed as it would
+ * change the semantics of the URI reference.
+ *
+ * Example: http://example.org/../a/b/../c/./d.html → http://example.org/a/c/d.html
+ */
+ const REMOVE_DOT_SEGMENTS = 32;
+
+ /**
+ * Paths which include two or more adjacent slashes are converted to one.
+ *
+ * Webservers usually ignore duplicate slashes and treat those URIs equivalent.
+ * But in theory those URIs do not need to be equivalent. So this normalization
+ * may change the semantics. Encoded slashes (%2F) are not removed.
+ *
+ * Example: http://example.org//foo///bar.html → http://example.org/foo/bar.html
+ */
+ const REMOVE_DUPLICATE_SLASHES = 64;
+
+ /**
+ * Sort query parameters with their values in alphabetical order.
+ *
+ * However, the order of parameters in a URI may be significant (this is not defined by the standard).
+ * So this normalization is not safe and may change the semantics of the URI.
+ *
+ * Example: ?lang=en&article=fred → ?article=fred&lang=en
+ *
+ * Note: The sorting is neither locale nor Unicode aware (the URI query does not get decoded at all) as the
+ * purpose is to be able to compare URIs in a reproducible way, not to have the params sorted perfectly.
+ */
+ const SORT_QUERY_PARAMETERS = 128;
+
+ /**
+ * Returns a normalized URI.
+ *
+ * The scheme and host component are already normalized to lowercase per PSR-7 UriInterface.
+ * This methods adds additional normalizations that can be configured with the $flags parameter.
+ *
+ * PSR-7 UriInterface cannot distinguish between an empty component and a missing component as
+ * getQuery(), getFragment() etc. always return a string. This means the URIs "/?#" and "/" are
+ * treated equivalent which is not necessarily true according to RFC 3986. But that difference
+ * is highly uncommon in reality. So this potential normalization is implied in PSR-7 as well.
+ *
+ * @param UriInterface $uri The URI to normalize
+ * @param int $flags A bitmask of normalizations to apply, see constants
+ *
+ * @return UriInterface The normalized URI
+ * @link https://tools.ietf.org/html/rfc3986#section-6.2
+ */
+ public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS)
+ {
+ if ($flags & self::CAPITALIZE_PERCENT_ENCODING) {
+ $uri = self::capitalizePercentEncoding($uri);
+ }
+
+ if ($flags & self::DECODE_UNRESERVED_CHARACTERS) {
+ $uri = self::decodeUnreservedCharacters($uri);
+ }
+
+ if ($flags & self::CONVERT_EMPTY_PATH && $uri->getPath() === '' &&
+ ($uri->getScheme() === 'http' || $uri->getScheme() === 'https')
+ ) {
+ $uri = $uri->withPath('/');
+ }
+
+ if ($flags & self::REMOVE_DEFAULT_HOST && $uri->getScheme() === 'file' && $uri->getHost() === 'localhost') {
+ $uri = $uri->withHost('');
+ }
+
+ if ($flags & self::REMOVE_DEFAULT_PORT && $uri->getPort() !== null && Uri::isDefaultPort($uri)) {
+ $uri = $uri->withPort(null);
+ }
+
+ if ($flags & self::REMOVE_DOT_SEGMENTS && !Uri::isRelativePathReference($uri)) {
+ $uri = $uri->withPath(UriResolver::removeDotSegments($uri->getPath()));
+ }
+
+ if ($flags & self::REMOVE_DUPLICATE_SLASHES) {
+ $uri = $uri->withPath(preg_replace('#//++#', '/', $uri->getPath()));
+ }
+
+ if ($flags & self::SORT_QUERY_PARAMETERS && $uri->getQuery() !== '') {
+ $queryKeyValues = explode('&', $uri->getQuery());
+ sort($queryKeyValues);
+ $uri = $uri->withQuery(implode('&', $queryKeyValues));
+ }
+
+ return $uri;
+ }
+
+ /**
+ * Whether two URIs can be considered equivalent.
+ *
+ * Both URIs are normalized automatically before comparison with the given $normalizations bitmask. The method also
+ * accepts relative URI references and returns true when they are equivalent. This of course assumes they will be
+ * resolved against the same base URI. If this is not the case, determination of equivalence or difference of
+ * relative references does not mean anything.
+ *
+ * @param UriInterface $uri1 An URI to compare
+ * @param UriInterface $uri2 An URI to compare
+ * @param int $normalizations A bitmask of normalizations to apply, see constants
+ *
+ * @return bool
+ * @link https://tools.ietf.org/html/rfc3986#section-6.1
+ */
+ public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS)
+ {
+ return (string) self::normalize($uri1, $normalizations) === (string) self::normalize($uri2, $normalizations);
+ }
+
+ private static function capitalizePercentEncoding(UriInterface $uri)
+ {
+ $regex = '/(?:%[A-Fa-f0-9]{2})++/';
+
+ $callback = function (array $match) {
+ return strtoupper($match[0]);
+ };
+
+ return
+ $uri->withPath(
+ preg_replace_callback($regex, $callback, $uri->getPath())
+ )->withQuery(
+ preg_replace_callback($regex, $callback, $uri->getQuery())
+ );
+ }
+
+ private static function decodeUnreservedCharacters(UriInterface $uri)
+ {
+ $regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i';
+
+ $callback = function (array $match) {
+ return rawurldecode($match[0]);
+ };
+
+ return
+ $uri->withPath(
+ preg_replace_callback($regex, $callback, $uri->getPath())
+ )->withQuery(
+ preg_replace_callback($regex, $callback, $uri->getQuery())
+ );
+ }
+
+ private function __construct()
+ {
+ // cannot be instantiated
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/UriResolver.php b/vendor/guzzlehttp/psr7/src/UriResolver.php
new file mode 100644
index 0000000..c1cb8a2
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/UriResolver.php
@@ -0,0 +1,219 @@
+<?php
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\UriInterface;
+
+/**
+ * Resolves a URI reference in the context of a base URI and the opposite way.
+ *
+ * @author Tobias Schultze
+ *
+ * @link https://tools.ietf.org/html/rfc3986#section-5
+ */
+final class UriResolver
+{
+ /**
+ * Removes dot segments from a path and returns the new path.
+ *
+ * @param string $path
+ *
+ * @return string
+ * @link http://tools.ietf.org/html/rfc3986#section-5.2.4
+ */
+ public static function removeDotSegments($path)
+ {
+ if ($path === '' || $path === '/') {
+ return $path;
+ }
+
+ $results = [];
+ $segments = explode('/', $path);
+ foreach ($segments as $segment) {
+ if ($segment === '..') {
+ array_pop($results);
+ } elseif ($segment !== '.') {
+ $results[] = $segment;
+ }
+ }
+
+ $newPath = implode('/', $results);
+
+