Repository: piotrwitek/react-redux-typescript-guide Branch: master Commit: 47ca335db14a Files: 174 Total size: 995.7 KB Directory structure: gitextract_2uvb6dl9/ ├── .all-contributorsrc ├── .github/ │ ├── FUNDING.yml │ ├── ISSUE_TEMPLATE/ │ │ ├── bug_report.md │ │ ├── custom.md │ │ └── feature_request.md │ └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .vscode/ │ └── launch.json ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── CONTRIBUTORS.md ├── LICENSE ├── README.md ├── README_SOURCE.md ├── configs/ │ ├── jest.config.json │ └── jest.stubs.js ├── docs/ │ ├── build/ │ │ ├── 0.6e57cfb5.js │ │ └── bundle.a71e23e0.js │ └── index.html ├── generate-readme.js ├── generate-readme.sh ├── generate-styleguide.sh ├── is-git-status-clean.sh ├── package.json └── playground/ ├── .eslintrc.js ├── .gitignore ├── .prettierrc ├── .storybook/ │ ├── addons.js │ ├── config.js │ └── webpack.config.js ├── .vscode/ │ └── settings.json ├── README.md ├── index.html ├── package.json ├── public/ │ ├── index.html │ └── manifest.json ├── src/ │ ├── api/ │ │ ├── agent.ts │ │ ├── fixtures/ │ │ │ └── todos.json │ │ ├── index.ts │ │ ├── models.ts │ │ ├── todos.ts │ │ └── utils.ts │ ├── app.test.tsx │ ├── app.tsx │ ├── components/ │ │ ├── __snapshots__/ │ │ │ ├── class-counter-with-default-props.stories.storyshot │ │ │ ├── class-counter.stories.storyshot │ │ │ ├── fc-counter-with-default-props.stories.storyshot │ │ │ ├── fc-counter.stories.storyshot │ │ │ ├── fc-spread-attributes.stories.storyshot │ │ │ ├── generic-list.stories.storyshot │ │ │ └── mouse-provider.stories.storyshot │ │ ├── class-counter-with-default-props.md │ │ ├── class-counter-with-default-props.stories.tsx │ │ ├── class-counter-with-default-props.tsx │ │ ├── class-counter-with-default-props.usage.tsx │ │ ├── class-counter.md │ │ ├── class-counter.stories.tsx │ │ ├── class-counter.tsx │ │ ├── class-counter.usage.tsx │ │ ├── error-message.tsx │ │ ├── fc-counter-with-default-props.md │ │ ├── fc-counter-with-default-props.stories.tsx │ │ ├── fc-counter-with-default-props.tsx │ │ ├── fc-counter-with-default-props.usage.tsx │ │ ├── fc-counter.md │ │ ├── fc-counter.stories.tsx │ │ ├── fc-counter.tsx │ │ ├── fc-counter.usage.tsx │ │ ├── fc-spread-attributes.md │ │ ├── fc-spread-attributes.stories.tsx │ │ ├── fc-spread-attributes.tsx │ │ ├── fc-spread-attributes.usage.tsx │ │ ├── generic-list.md │ │ ├── generic-list.stories.tsx │ │ ├── generic-list.tsx │ │ ├── generic-list.usage.tsx │ │ ├── index.ts │ │ ├── mouse-provider.md │ │ ├── mouse-provider.stories.tsx │ │ ├── mouse-provider.tsx │ │ ├── mouse-provider.usage.tsx │ │ ├── name-provider.md │ │ ├── name-provider.tsx │ │ └── name-provider.usage.tsx │ ├── connected/ │ │ ├── fc-counter-connected-bind-action-creators.tsx │ │ ├── fc-counter-connected-bind-action-creators.usage.tsx │ │ ├── fc-counter-connected-own-props.spec.tsx │ │ ├── fc-counter-connected-own-props.tsx │ │ ├── fc-counter-connected-own-props.usage.tsx │ │ ├── fc-counter-connected.tsx │ │ ├── fc-counter-connected.usage.tsx │ │ └── index.ts │ ├── context/ │ │ ├── theme-consumer-class.tsx │ │ ├── theme-consumer.tsx │ │ ├── theme-context.ts │ │ └── theme-provider.tsx │ ├── features/ │ │ ├── app/ │ │ │ └── epics.ts │ │ ├── counters/ │ │ │ ├── actions.ts │ │ │ ├── actions.usage.ts │ │ │ ├── constants.ts │ │ │ ├── index.ts │ │ │ ├── reducer.ts │ │ │ └── selectors.ts │ │ ├── todos/ │ │ │ ├── __snapshots__/ │ │ │ │ └── reducer.spec.ts.snap │ │ │ ├── actions.ts │ │ │ ├── constants.ts │ │ │ ├── epics.spec.ts │ │ │ ├── epics.ts │ │ │ ├── index.ts │ │ │ ├── models.ts │ │ │ ├── reducer-ta.ts │ │ │ ├── reducer.spec.ts │ │ │ ├── reducer.ts │ │ │ └── selectors.ts │ │ └── todos-typesafe/ │ │ ├── actions.ts │ │ ├── index.ts │ │ ├── models.ts │ │ ├── reducer.ts │ │ └── selectors.ts │ ├── hoc/ │ │ ├── index.ts │ │ ├── with-connected-count.tsx │ │ ├── with-connected-count.usage.tsx │ │ ├── with-error-boundary.tsx │ │ ├── with-error-boundary.usage.tsx │ │ ├── with-state.tsx │ │ └── with-state.usage.tsx │ ├── hooks/ │ │ ├── react-redux-hooks.tsx │ │ ├── use-reducer.tsx │ │ ├── use-state.tsx │ │ └── use-theme-context.tsx │ ├── index.css │ ├── index.tsx │ ├── layout/ │ │ ├── layout-footer.tsx │ │ ├── layout-header.tsx │ │ └── layout.tsx │ ├── models/ │ │ ├── index.ts │ │ ├── nominal-types.ts │ │ └── user.ts │ ├── react-app-env.d.ts │ ├── routes/ │ │ ├── home.tsx │ │ └── not-found.tsx │ ├── serviceWorker.ts │ ├── services/ │ │ ├── index.ts │ │ ├── local-storage-service.ts │ │ ├── logger-service.ts │ │ └── types.d.ts │ ├── store/ │ │ ├── hooks.ts │ │ ├── index.ts │ │ ├── redux-router.ts │ │ ├── root-action.ts │ │ ├── root-epic.ts │ │ ├── root-reducer.ts │ │ ├── store.ts │ │ ├── types.d.ts │ │ └── utils.ts │ └── storyshots.disabled-test.ts ├── src-old/ │ ├── App.css │ ├── App.test.tsx │ ├── App.tsx │ ├── index.css │ ├── index.tsx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts ├── styleguide/ │ ├── docs/ │ │ └── intro.md │ ├── package.json │ └── styleguide.config.js ├── tsconfig.json ├── tsconfig.test.json └── typings/ ├── augmentations.d.ts ├── globals.d.ts ├── modules.d.ts ├── redux/ │ └── index.d.ts └── redux-thunk/ └── index.d.ts ================================================ FILE CONTENTS ================================================ ================================================ FILE: .all-contributorsrc ================================================ { "projectName": "react-redux-typescript-guide", "projectOwner": "piotrwitek", "repoType": "github", "repoHost": "https://github.com", "files": [ "./CONTRIBUTORS.md" ], "imageSize": 100, "commit": false, "contributors": [ { "login": "piotrwitek", "name": "Piotrek Witek", "avatar_url": "https://avatars0.githubusercontent.com/u/739075?v=4", "profile": "https://github.com/piotrwitek", "contributions": [ "code", "doc", "ideas", "review", "question" ] }, { "login": "kazup01", "name": "Kazz Yokomizo", "avatar_url": "https://avatars3.githubusercontent.com/u/8602615?v=4", "profile": "https://github.com/kazup01", "contributions": [ "financial", "fundingFinding" ] }, { "login": "jakeboone02", "name": "Jake Boone", "avatar_url": "https://avatars1.githubusercontent.com/u/366438?v=4", "profile": "https://github.com/jakeboone02", "contributions": [ "doc" ] }, { "login": "amitdahan", "name": "Amit Dahan", "avatar_url": "https://avatars1.githubusercontent.com/u/9748762?v=4", "profile": "https://github.com/amitdahan", "contributions": [ "doc" ] }, { "login": "gulderov", "name": "gulderov", "avatar_url": "https://avatars1.githubusercontent.com/u/98167?v=4", "profile": "https://github.com/gulderov", "contributions": [ "doc" ] }, { "login": "emp823", "name": "Erik Pearson", "avatar_url": "https://avatars1.githubusercontent.com/u/1964212?v=4", "profile": "https://github.com/emp823", "contributions": [ "doc" ] }, { "login": "flymason", "name": "Bryan Mason", "avatar_url": "https://avatars1.githubusercontent.com/u/5342677?v=4", "profile": "https://github.com/flymason", "contributions": [ "doc" ] }, { "login": "chodorowicz", "name": "Jakub Chodorowicz", "avatar_url": "https://avatars1.githubusercontent.com/u/119451?v=4", "profile": "http://www.jakub.chodorowicz.pl/", "contributions": [ "code" ] }, { "login": "mleg", "name": "Oleg Maslov", "avatar_url": "https://avatars1.githubusercontent.com/u/7266431?v=4", "profile": "https://github.com/mleg", "contributions": [ "bug" ] }, { "login": "awestbro", "name": "Aaron Westbrook", "avatar_url": "https://avatars0.githubusercontent.com/u/3393293?v=4", "profile": "https://github.com/awestbro", "contributions": [ "bug" ] }, { "login": "peterblazejewicz", "name": "Peter Blazejewicz", "avatar_url": "https://avatars3.githubusercontent.com/u/14539?v=4", "profile": "http://www.linkedin.com/in/peterblazejewicz", "contributions": [ "doc" ] }, { "login": "rubysolo", "name": "Solomon White", "avatar_url": "https://avatars3.githubusercontent.com/u/1642?v=4", "profile": "https://github.com/rubysolo", "contributions": [ "doc" ] }, { "login": "pino", "name": "Levi Rocha", "avatar_url": "https://avatars2.githubusercontent.com/u/8838006?v=4", "profile": "https://github.com/pino", "contributions": [ "doc" ] }, { "login": "loadbalance-sudachi-kun", "name": "Sudachi-kun", "avatar_url": "https://avatars1.githubusercontent.com/u/41281835?v=4", "profile": "http://cloudnative.co.jp", "contributions": [ "financial" ] }, { "login": "sosukesuzuki", "name": "Sosuke Suzuki", "avatar_url": "https://avatars1.githubusercontent.com/u/14838850?v=4", "profile": "http://sosukesuzuki.github.io", "contributions": [ "code" ] }, { "login": "chillitom", "name": "Tom Rathbone", "avatar_url": "https://avatars0.githubusercontent.com/u/74433?v=4", "profile": "https://github.com/chillitom", "contributions": [ "doc" ] }, { "login": "arshadkazmi42", "name": "Arshad Kazmi", "avatar_url": "https://avatars3.githubusercontent.com/u/4654382?v=4", "profile": "https://arshadkazmi42.github.io/", "contributions": [ "doc" ] }, { "login": "JeongUkJae", "name": "JeongUkJae", "avatar_url": "https://avatars1.githubusercontent.com/u/8815362?v=4", "profile": "https://jeongukjae.github.io", "contributions": [ "doc" ] } ] } ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: piotrekwitek # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: piotrwitek # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: ["https://www.buymeacoffee.com/piotrekwitek"] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] ================================================ FILE: .github/ISSUE_TEMPLATE/bug_report.md ================================================ --- name: Bug report about: Create a report to help us improve --- ## Description ## Steps to Reproduce ## Expected behavior ## Suggested solution(s) ## Project Dependencies - TypeScript Version: X.X.X - tsconfig.json: ## Environment (optional) - Browser and Version: XXX - OS: XXX - Node Version: XXX - Package Manager and Version: XXX ================================================ FILE: .github/ISSUE_TEMPLATE/custom.md ================================================ --- name: Question about: Have a question? Please check our spectrum community chat. --- First of all please check our spectrum community chat and we recommend to ask your question there for a quickest response and the indexing in search engines: - https://spectrum.chat/react-redux-ts The only good reason to use issue tracker for your questions would be for "special requests" that doesn't fit into bug reports and feature requests categories. ================================================ FILE: .github/ISSUE_TEMPLATE/feature_request.md ================================================ --- name: Feature request about: Suggest an idea for this project --- ## Is your feature request related to a real problem or use-case? ## Describe a solution including usage in code example ## Who does this impact? Who is this for? ## Describe alternatives you've considered (optional) ## Additional context (optional) ================================================ FILE: .github/PULL_REQUEST_TEMPLATE.md ================================================ ## Description ## Related issues: - Resolved #XXX ## Checklist * [ ] I have read [CONTRIBUTING.md](https://github.com/piotrwitek/react-redux-typescript-guide/blob/master/CONTRIBUTING.md) * [ ] I have edited `README_SOURCE.md` (NOT `README.md`) * [ ] I have run CI script locally `npm run ci-check` to generate an updated `README.md` * [ ] I have linked all related issues above * [ ] I have rebased my branch ================================================ FILE: .gitignore ================================================ # Logs logs *.log npm-debug.log* # Runtime data pids *.pid *.seed # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # nyc test coverage .nyc_output # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # node-waf configuration .lock-wscript # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directories node_modules jspm_packages # Optional npm cache directory .npm # Optional REPL history .node_repl_history temp/ playground/dist playground/storybook-static ================================================ FILE: .vscode/launch.json ================================================ { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "pwa-chrome", "request": "launch", "name": "Launch Chrome against localhost", "url": "http://localhost:3080", "webRoot": "${workspaceFolder}/playground/src", "sourceMapPathOverrides": { "webpack:///src/*": "${webRoot}/*" } } ] } ================================================ FILE: CODE_OF_CONDUCT.md ================================================ # Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at piotrek.witek@gmail.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq ================================================ FILE: CONTRIBUTING.md ================================================ # Contributing Guide ## General 1. Make sure you have read and understand the **Goals** section to be aligned with project goals. 2. Before submitting a PR please comment in the relevant issue (or create a new one if it doesn't exist yet) to discuss all the requirements (this will prevent rejecting the PR and wasting your work). 3. All workflow scripts (prettier, linter, tests) must pass successfully (it is run automatically on CI and will fail on github checks). ## Edit `README_SOURCE.md` to generate an updated `README.md` Don't edit `README.md` directly - it is generated automatically from `README_SOURCE.md` using an automated script. - Use `sh ./generate-readme.sh` script to generate updated `README.md` (this will inject code examples using type-checked source files from the `/playground` folder) - So to make changes in code examples edit source files in `/playground` folder **Source code inject directives:** ``` # Inject code block with highlighter ::codeblock='playground/src/components/fc-counter.tsx':: # Inject code block with highlighter and expander ::expander='playground/src/components/fc-counter.usage.tsx':: ``` ================================================ FILE: CONTRIBUTORS.md ================================================ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): | [
Piotrek Witek](https://github.com/piotrwitek)
[💻](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=piotrwitek "Code") [📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=piotrwitek "Documentation") [🤔](#ideas-piotrwitek "Ideas, Planning, & Feedback") [👀](#review-piotrwitek "Reviewed Pull Requests") [💬](#question-piotrwitek "Answering Questions") | [
Kazz Yokomizo](https://github.com/kazup01)
[💵](#financial-kazup01 "Financial") [🔍](#fundingFinding-kazup01 "Funding Finding") | [
Jake Boone](https://github.com/jakeboone02)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=jakeboone02 "Documentation") | [
Amit Dahan](https://github.com/amitdahan)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=amitdahan "Documentation") | [
gulderov](https://github.com/gulderov)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=gulderov "Documentation") | [
Erik Pearson](https://github.com/emp823)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=emp823 "Documentation") | [
Bryan Mason](https://github.com/flymason)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=flymason "Documentation") | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | [
Jakub Chodorowicz](http://www.jakub.chodorowicz.pl/)
[💻](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=chodorowicz "Code") | [
Oleg Maslov](https://github.com/mleg)
[🐛](https://github.com/piotrwitek/react-redux-typescript-guide/issues?q=author%3Amleg "Bug reports") | [
Aaron Westbrook](https://github.com/awestbro)
[🐛](https://github.com/piotrwitek/react-redux-typescript-guide/issues?q=author%3Aawestbro "Bug reports") | [
Peter Blazejewicz](http://www.linkedin.com/in/peterblazejewicz)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=peterblazejewicz "Documentation") | [
Solomon White](https://github.com/rubysolo)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=rubysolo "Documentation") | [
Levi Rocha](https://github.com/pino)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=pino "Documentation") | [
Sudachi-kun](http://cloudnative.co.jp)
[💵](#financial-loadbalance-sudachi-kun "Financial") | | [
Sosuke Suzuki](http://sosukesuzuki.github.io)
[💻](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=sosukesuzuki "Code") | [
Tom Rathbone](https://github.com/chillitom)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=chillitom "Documentation") | [
Arshad Kazmi](https://arshadkazmi42.github.io/)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=arshadkazmi42 "Documentation") | [
JeongUkJae](https://jeongukjae.github.io)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=JeongUkJae "Documentation") | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2016 Piotr Witek (http://piotrwitek.github.io) 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. ================================================ FILE: README.md ================================================
# React & Redux in TypeScript - Complete Guide _"This guide is a **living compendium** documenting the most important patterns and recipes on how to use **React** (and its Ecosystem) in a **functional style** using **TypeScript**. It will help you make your code **completely type-safe** while focusing on **inferring the types from implementation** so there is less noise coming from excessive type annotations and it's easier to write and maintain correct types in the long run."_ [![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/react-redux-ts) [![Join the chat at https://gitter.im/react-redux-typescript-guide/Lobby](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/react-redux-typescript-guide/Lobby) _Found it useful? Want more updates?_ [**Show your support by giving a :star:**](https://github.com/piotrwitek/react-redux-typescript-guide/stargazers) Buy Me a Coffee Become a Patron

## **What's new?** :tada: _Now updated to support **TypeScript v4.6**_ :tada: :rocket: _Updated to `typesafe-actions@5.x` :rocket:

### **Goals** - Complete type safety (with [`--strict`](https://www.typescriptlang.org/docs/handbook/compiler-options.html) flag) without losing type information downstream through all the layers of our application (e.g. no type assertions or hacking with `any` type) - Make type annotations concise by eliminating redundancy in types using advanced TypeScript Language features like **Type Inference** and **Control flow analysis** - Reduce repetition and complexity of types with TypeScript focused [complementary libraries](#react-redux-typescript-ecosystem) ### **React, Redux, Typescript Ecosystem** - [typesafe-actions](https://github.com/piotrwitek/typesafe-actions) - Typesafe utilities for "action-creators" in Redux / Flux Architecture - [utility-types](https://github.com/piotrwitek/utility-types) - Collection of generic types for TypeScript, complementing built-in mapped types and aliases - think lodash for reusable types. - [react-redux-typescript-scripts](https://github.com/piotrwitek/react-redux-typescript-scripts) - dev-tools configuration files shared between projects based on this guide ### **Examples** - Todo-App playground: [Codesandbox](https://codesandbox.io/s/github/piotrwitek/typesafe-actions/tree/master/codesandbox) - React, Redux, TypeScript - RealWorld App: [Github](https://github.com/piotrwitek/react-redux-typescript-realworld-app) | [Demo](https://react-redux-typescript-realworld-app.netlify.com/) ### **Playground Project** [![Build Status](https://semaphoreci.com/api/v1/piotrekwitek/react-redux-typescript-guide/branches/master/shields_badge.svg)](https://semaphoreci.com/piotrekwitek/react-redux-typescript-guide) Check out our Playground Project located in the `/playground` folder. It contains all source files of the code examples found in the guide. They are all tested with the most recent version of TypeScript and 3rd party type-definitions (like `@types/react` or `@types/react-redux`) to ensure the examples are up-to-date and not broken with updated definitions (It's based on `create-react-app --typescript`). > Playground project was created so that you can simply clone the repository locally and immediately play around with all the component patterns found in the guide. It will help you to learn all the examples from this guide in a real project environment without the need to create complicated environment setup by yourself. ## Contributing Guide You can help make this project better by contributing. If you're planning to contribute please make sure to check our contributing guide: [CONTRIBUTING.md](/CONTRIBUTING.md) ## Funding You can also help by funding issues. Issues like bug fixes or feature requests can be very quickly resolved when funded through the IssueHunt platform. I highly recommend to add a bounty to the issue that you're waiting for to increase priority and attract contributors willing to work on it. [![Let's fund issues in this repository](https://issuehunt.io/static/embed/issuehunt-button-v1.svg)](https://issuehunt.io/repos/76996763) --- 🌟 - _New or updated section_ ## Table of Contents - [React Types Cheatsheet](#react-types-cheatsheet) - [`React.FC` | `React.FunctionComponent`](#reactfcprops--reactfunctioncomponentprops) - [`React.Component`](#reactcomponentprops-state) - [`React.ComponentType`](#reactcomponenttypeprops) - [`React.ComponentProps`](#reactcomponentpropstypeof-xxx) - [`React.ReactElement` | `JSX.Element`](#reactreactelement--jsxelement) - [`React.ReactNode`](#reactreactnode) - [`React.CSSProperties`](#reactcssproperties) - [`React.XXXHTMLAttributes`](#reactxxxhtmlattributeshtmlxxxelement) - [`React.ReactEventHandler`](#reactreacteventhandlerhtmlxxxelement) - [`React.XXXEvent`](#reactxxxeventhtmlxxxelement) - [React](#react) - [Function Components - FC](#function-components---fc) - [- Counter Component](#--counter-component) - [- Counter Component with default props](#--counter-component-with-default-props) - [- Spreading attributes in Component](#--spreading-attributes-in-component) - [Class Components](#class-components) - [- Class Counter Component](#--class-counter-component) - [- Class Component with default props](#--class-component-with-default-props) - [Generic Components](#generic-components) - [- Generic List Component](#--generic-list-component) - [Hooks](#hooks) - [- useState](#--usestate) - [- useContext](#--usecontext) - [- useReducer](#--usereducer) - [Render Props](#render-props) - [- Name Provider Component](#--name-provider-component) - [- Mouse Provider Component](#--mouse-provider-component) - [Higher-Order Components](#higher-order-components) - [- HOC wrapping a component](#--hoc-wrapping-a-component) - [- HOC wrapping a component and injecting props](#--hoc-wrapping-a-component-and-injecting-props) - [- Nested HOC - wrapping a component, injecting props and connecting to redux 🌟](#--nested-hoc---wrapping-a-component-injecting-props-and-connecting-to-redux-) - [Redux Connected Components](#redux-connected-components) - [- Redux connected counter](#--redux-connected-counter) - [- Redux connected counter with own props](#--redux-connected-counter-with-own-props) - [- Redux connected counter via hooks](#--redux-connected-counter-via-hooks) - [- Redux connected counter with `redux-thunk` integration](#--redux-connected-counter-with-redux-thunk-integration) - [Context](#context) - [ThemeContext](#themecontext) - [ThemeProvider](#themeprovider) - [ThemeConsumer](#themeconsumer) - [ThemeConsumer in class component](#themeconsumer-in-class-component) - [Redux](#redux) - [Store Configuration](#store-configuration) - [Create Global Store Types](#create-global-store-types) - [Create Store](#create-store) - [Action Creators 🌟](#action-creators-) - [Reducers](#reducers) - [State with Type-level Immutability](#state-with-type-level-immutability) - [Typing reducer](#typing-reducer) - [Typing reducer with `typesafe-actions`](#typing-reducer-with-typesafe-actions) - [Testing reducer](#testing-reducer) - [Async Flow with `redux-observable`](#async-flow-with-redux-observable) - [Typing epics](#typing-epics) - [Testing epics](#testing-epics) - [Selectors with `reselect`](#selectors-with-reselect) - [Connect with `react-redux`](#connect-with-react-redux) - [Typing connected component](#typing-connected-component) - [Typing `useSelector` and `useDispatch`](#typing-useselector-and-usedispatch) - [Typing connected component with `redux-thunk` integration](#typing-connected-component-with-redux-thunk-integration) - [Configuration & Dev Tools](#configuration--dev-tools) - [Common Npm Scripts](#common-npm-scripts) - [tsconfig.json](#tsconfigjson) - [TSLib](#tslib) - [ESLint](#eslint) - [.eslintrc.js](#eslintrcjs) - [Jest](#jest) - [jest.config.json](#jestconfigjson) - [jest.stubs.js](#jeststubsjs) - [Style Guides](#style-guides) - [react-styleguidist](#react-styleguidist) - [FAQ](#faq) - [Ambient Modules](#ambient-modules) - [Imports in ambient modules](#imports-in-ambient-modules) - [Type-Definitions](#type-definitions) - [Missing type-definitions error](#missing-type-definitions-error) - [Using custom `d.ts` files for npm modules](#using-custom-dts-files-for-npm-modules) - [Type Augmentation](#type-augmentation) - [Augmenting library internal declarations - using relative import](#augmenting-library-internal-declarations---using-relative-import) - [Augmenting library public declarations - using node_modules import](#augmenting-library-public-declarations---using-node_modules-import) - [Misc](#misc) - [- should I still use React.PropTypes in TS?](#--should-i-still-use-reactproptypes-in-ts) - [- when to use `interface` declarations and when `type` aliases?](#--when-to-use-interface-declarations-and-when-type-aliases) - [- what's better default or named exports?](#--whats-better-default-or-named-exports) - [- how to best initialize class instance or static properties?](#--how-to-best-initialize-class-instance-or-static-properties) - [- how to best declare component handler functions?](#--how-to-best-declare-component-handler-functions) - [Tutorials & Articles](#tutorials--articles) - [Contributors](#contributors) --- # Installation ## Types for React & Redux ``` npm i -D @types/react @types/react-dom @types/react-redux ``` "react" - `@types/react` "react-dom" - `@types/react-dom` "redux" - (types included with npm package)* "react-redux" - `@types/react-redux` > *NB: Guide is based on types for Redux >= v4.x.x. [⇧ back to top](#table-of-contents) --- ## React Types Cheatsheet ### `React.FC` | `React.FunctionComponent` Type representing a functional component ```tsx const MyComponent: React.FC = ... ``` ### `React.Component` Type representing a class component ```tsx class MyComponent extends React.Component { ... ``` ### `React.ComponentType` Type representing union of (`React.FC | React.Component`) - used in HOC ```tsx const withState =

( WrappedComponent: React.ComponentType

, ) => { ... ``` ### `React.ComponentProps` Gets Props type of a specified component XXX (WARNING: does not work with statically declared default props and generic props) ```tsx type MyComponentProps = React.ComponentProps; ``` ### `React.ReactElement` | `JSX.Element` Type representing a concept of React Element - representation of a native DOM component (e.g. `

`), or a user-defined composite component (e.g. ``) ```tsx const elementOnly: React.ReactElement =
|| ; ``` ### `React.ReactNode` Type representing any possible type of React node (basically ReactElement (including Fragments and Portals) + primitive JS types) ```tsx const elementOrPrimitive: React.ReactNode = 'string' || 0 || false || null || undefined ||
|| ; const Component = ({ children: React.ReactNode }) => ... ``` ### `React.CSSProperties` Type representing style object in JSX - for css-in-js styles ```tsx const styles: React.CSSProperties = { flexDirection: 'row', ... const element =
` Type representing HTML attributes of specified HTML Element - for extending HTML Elements ```tsx const Input: React.FC> = props => { ... } ``` ### `React.ReactEventHandler` Type representing generic event handler - for declaring event handlers ```tsx const handleChange: React.ReactEventHandler = (ev) => { ... } ``` ### `React.XXXEvent` Type representing more specific event. Some common event examples: `ChangeEvent, FormEvent, FocusEvent, KeyboardEvent, MouseEvent, DragEvent, PointerEvent, WheelEvent, TouchEvent`. ```tsx const handleChange = (ev: React.MouseEvent) => { ... }
``` In code above `React.MouseEvent` is type of mouse event, and this event happened on `HTMLDivElement` [⇧ back to top](#table-of-contents) --- # React ## Function Components - FC ### - Counter Component ```tsx import * as React from 'react'; type Props = { label: string; count: number; onIncrement: () => void; }; export const FCCounter: React.FC = props => { const { label, count, onIncrement } = props; const handleIncrement = () => { onIncrement(); }; return (
{label}: {count}
); }; ``` [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/#fccounter) [⇧ back to top](#table-of-contents) ### - Counter Component with default props ```tsx import * as React from 'react'; type Props = { label: string; count: number; onIncrement: () => void; }; // React.FC is unaplicable here due not working properly with default props // https://github.com/facebook/create-react-app/pull/8177 export const FCCounterWithDefaultProps = (props: Props): JSX.Element => { const { label, count, onIncrement } = props; const handleIncrement = () => { onIncrement(); }; return (
{label}: {count}
); }; FCCounterWithDefaultProps.defaultProps = { count: 5 }; ``` [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/#fccounterwithdefaultprops) [⇧ back to top](#table-of-contents) ### - [Spreading attributes](https://facebook.github.io/react/docs/jsx-in-depth.html#spread-attributes) in Component ```tsx import * as React from 'react'; type Props = React.PropsWithChildren<{ className?: string; style?: React.CSSProperties; }>; export const FCSpreadAttributes: React.FC = (props) => { const { children, ...restProps } = props; return
{children}
; }; ``` [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/#fcspreadattributes) [⇧ back to top](#table-of-contents) --- ## Class Components ### - Class Counter Component ```tsx import * as React from 'react'; type Props = { label: string; }; type State = { count: number; }; export class ClassCounter extends React.Component { readonly state: State = { count: 0, }; handleIncrement = () => { this.setState({ count: this.state.count + 1 }); }; render() { const { handleIncrement } = this; const { label } = this.props; const { count } = this.state; return (
{label}: {count}
); } } ``` [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/#classcounter) [⇧ back to top](#table-of-contents) ### - Class Component with default props ```tsx import * as React from 'react'; type Props = { label: string; initialCount: number; }; type State = { count: number; }; export class ClassCounterWithDefaultProps extends React.Component< Props, State > { static defaultProps = { initialCount: 0, }; readonly state: State = { count: this.props.initialCount, }; handleIncrement = () => { this.setState({ count: this.state.count + 1 }); }; render() { const { handleIncrement } = this; const { label } = this.props; const { count } = this.state; return (
{label}: {count}
); } } ``` [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/#classcounterwithdefaultprops) [⇧ back to top](#table-of-contents) --- ## Generic Components - easily create typed component variations and reuse common logic - common use case is a generic list components ### - Generic List Component ```tsx import * as React from 'react'; export interface GenericListProps { items: T[]; itemRenderer: (item: T) => JSX.Element; } export class GenericList extends React.Component, {}> { render() { const { items, itemRenderer } = this.props; return (
{items.map(itemRenderer)}
); } } ``` [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/#genericlist) [⇧ back to top](#table-of-contents) --- ## Hooks > ### - useState > ```tsx import * as React from 'react'; type Props = { initialCount: number }; export default function Counter({initialCount}: Props) { const [count, setCount] = React.useState(initialCount); return ( <> Count: {count} ); } ``` [⇧ back to top](#table-of-contents) ### - useContext > ```tsx import * as React from 'react'; import ThemeContext from '../context/theme-context'; type Props = {}; export default function ThemeToggleButton(props: Props) { const { theme, toggleTheme } = React.useContext(ThemeContext); return ( ); } ``` [⇧ back to top](#table-of-contents) ### - useReducer > ```tsx import * as React from 'react'; interface State { count: number; } type Action = { type: 'reset' } | { type: 'increment' } | { type: 'decrement' }; function reducer(state: State, action: Action): State { switch (action.type) { case 'increment': return { count: state.count + 1 }; case 'decrement': return { count: state.count - 1 }; case 'reset': return { count: 0 }; default: throw new Error(); } } interface CounterProps { initialCount: number; } function Counter({ initialCount }: CounterProps) { const [state, dispatch] = React.useReducer(reducer, { count: initialCount, }); return ( <> Count: {state.count} ); } export default Counter; ``` [⇧ back to top](#table-of-contents) --- ## Render Props > ### - Name Provider Component Simple component using children as a render prop ```tsx import * as React from 'react'; interface NameProviderProps { children: (state: NameProviderState) => React.ReactNode; } interface NameProviderState { readonly name: string; } export class NameProvider extends React.Component { readonly state: NameProviderState = { name: 'Piotr' }; render() { return this.props.children(this.state); } } ``` [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/#nameprovider) [⇧ back to top](#table-of-contents) ### - Mouse Provider Component `Mouse` component found in [Render Props React Docs](https://reactjs.org/docs/render-props.html#use-render-props-for-cross-cutting-concerns) ```tsx import * as React from 'react'; export interface MouseProviderProps { render: (state: MouseProviderState) => React.ReactNode; } interface MouseProviderState { readonly x: number; readonly y: number; } export class MouseProvider extends React.Component { readonly state: MouseProviderState = { x: 0, y: 0 }; handleMouseMove = (event: React.MouseEvent) => { this.setState({ x: event.clientX, y: event.clientY, }); }; render() { return (
{/* Instead of providing a static representation of what renders, use the `render` prop to dynamically determine what to render. */} {this.props.render(this.state)}
); } } ``` [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/#mouseprovider) [⇧ back to top](#table-of-contents) --- ## Higher-Order Components > ### - HOC wrapping a component Adds state to a stateless counter ```tsx import React from 'react'; import { Diff } from 'utility-types'; // These props will be injected into the base component interface InjectedProps { count: number; onIncrement: () => void; } export const withState = ( BaseComponent: React.ComponentType ) => { type HocProps = Diff & { // here you can extend hoc with new props initialCount?: number; }; type HocState = { readonly count: number; }; return class Hoc extends React.Component { // Enhance component name for debugging and React-Dev-Tools static displayName = `withState(${BaseComponent.name})`; // reference to original wrapped component static readonly WrappedComponent = BaseComponent; readonly state: HocState = { count: Number(this.props.initialCount) || 0, }; handleIncrement = () => { this.setState({ count: this.state.count + 1 }); }; render() { const { ...restProps } = this.props; const { count } = this.state; return ( ); } }; }; ```
Click to expand

```tsx import * as React from 'react'; import { withState } from '../hoc'; import { FCCounter } from '../components'; const FCCounterWithState = withState(FCCounter); export default () => ; ```

[⇧ back to top](#table-of-contents) ### - HOC wrapping a component and injecting props Adds error handling using componentDidCatch to any component ```tsx import React from 'react'; const MISSING_ERROR = 'Error was swallowed during propagation.'; export const withErrorBoundary = ( BaseComponent: React.ComponentType ) => { type HocProps = React.PropsWithChildren<{ // here you can extend hoc with new props }>; type HocState = { readonly error: Error | null | undefined; }; return class Hoc extends React.Component { // Enhance component name for debugging and React-Dev-Tools static displayName = `withErrorBoundary(${BaseComponent.name})`; // reference to original wrapped component static readonly WrappedComponent = BaseComponent; readonly state: HocState = { error: undefined, }; componentDidCatch(error: Error | null, info: object) { this.setState({ error: error || new Error(MISSING_ERROR) }); this.logErrorToCloud(error, info); } logErrorToCloud = (error: Error | null, info: object) => { // TODO: send error report to service provider }; render() { const { children, ...restProps } = this.props; const { error } = this.state; if (error) { return ; } return children; } }; }; ```
Click to expand

```tsx import React, {useState} from 'react'; import { withErrorBoundary } from '../hoc'; import { ErrorMessage } from '../components'; const ErrorMessageWithErrorBoundary = withErrorBoundary(ErrorMessage); const BrokenComponent = () => { throw new Error('I\'m broken! Don\'t render me.'); }; const BrokenButton = () => { const [shouldRenderBrokenComponent, setShouldRenderBrokenComponent] = useState(false); if (shouldRenderBrokenComponent) { return ; } return ( ); }; export default () => ( ); ```

[⇧ back to top](#table-of-contents) ### - Nested HOC - wrapping a component, injecting props and connecting to redux 🌟 Adds error handling using componentDidCatch to any component ```tsx import { RootState } from 'MyTypes'; import React from 'react'; import { connect } from 'react-redux'; import { Diff } from 'utility-types'; import { countersActions, countersSelectors } from '../features/counters'; // These props will be injected into the base component interface InjectedProps { count: number; onIncrement: () => void; } export const withConnectedCount = ( BaseComponent: React.ComponentType ) => { const mapStateToProps = (state: RootState) => ({ count: countersSelectors.getReduxCounter(state.counters), }); const dispatchProps = { onIncrement: countersActions.increment, }; type HocProps = ReturnType & typeof dispatchProps & { // here you can extend ConnectedHoc with new props overrideCount?: number; }; class Hoc extends React.Component { // Enhance component name for debugging and React-Dev-Tools static displayName = `withConnectedCount(${BaseComponent.name})`; // reference to original wrapped component static readonly WrappedComponent = BaseComponent; render() { const { count, onIncrement, overrideCount, ...restProps } = this.props; return ( ); } } const ConnectedHoc = connect< ReturnType, typeof dispatchProps, // use "undefined" if NOT using dispatchProps Diff, RootState >( mapStateToProps, dispatchProps )(Hoc); return ConnectedHoc; }; ```
Click to expand

```tsx import * as React from 'react'; import { withConnectedCount } from '../hoc'; import { FCCounter } from '../components'; const FCCounterWithConnectedCount = withConnectedCount(FCCounter); export default () => ( ); ```

[⇧ back to top](#table-of-contents) --- ## Redux Connected Components ### - Redux connected counter ```tsx import Types from 'MyTypes'; import { connect } from 'react-redux'; import { countersActions, countersSelectors } from '../features/counters'; import { FCCounter } from '../components'; const mapStateToProps = (state: Types.RootState) => ({ count: countersSelectors.getReduxCounter(state.counters), }); const dispatchProps = { onIncrement: countersActions.increment, }; export const FCCounterConnected = connect( mapStateToProps, dispatchProps )(FCCounter); ```
Click to expand

```tsx import * as React from 'react'; import { FCCounterConnected } from '.'; export default () => ; ```

[⇧ back to top](#table-of-contents) ### - Redux connected counter with own props ```tsx import Types from 'MyTypes'; import { connect } from 'react-redux'; import { countersActions, countersSelectors } from '../features/counters'; import { FCCounter } from '../components'; type OwnProps = { initialCount?: number; }; const mapStateToProps = (state: Types.RootState, ownProps: OwnProps) => ({ count: countersSelectors.getReduxCounter(state.counters) + (ownProps.initialCount || 0), }); const dispatchProps = { onIncrement: countersActions.increment, }; export const FCCounterConnectedOwnProps = connect( mapStateToProps, dispatchProps )(FCCounter); ```
Click to expand

```tsx import * as React from 'react'; import { FCCounterConnectedOwnProps } from '.'; export default () => ( ); ```

[⇧ back to top](#table-of-contents) ### - Redux connected counter via hooks ```tsx import * as React from 'react'; import { FCCounter } from '../components'; import { increment } from '../features/counters/actions'; import { useSelector, useDispatch } from '../store/hooks'; const FCCounterConnectedHooksUsage: React.FC = () => { const counter = useSelector(state => state.counters.reduxCounter); const dispatch = useDispatch(); return dispatch(increment())}/>; }; export default FCCounterConnectedHooksUsage; ``` [⇧ back to top](#table-of-contents) ### - Redux connected counter with `redux-thunk` integration ```tsx import Types from 'MyTypes'; import { bindActionCreators, Dispatch } from 'redux'; import { connect } from 'react-redux'; import * as React from 'react'; import { countersActions } from '../features/counters'; // Thunk Action const incrementWithDelay = () => async (dispatch: Dispatch): Promise => { setTimeout(() => dispatch(countersActions.increment()), 1000); }; const mapStateToProps = (state: Types.RootState) => ({ count: state.counters.reduxCounter, }); const mapDispatchToProps = (dispatch: Dispatch) => bindActionCreators( { onIncrement: incrementWithDelay, }, dispatch ); type Props = ReturnType & ReturnType & { label: string; }; export const FCCounter: React.FC = props => { const { label, count, onIncrement } = props; const handleIncrement = () => { // Thunk action is correctly typed as promise onIncrement().then(() => { // ... }); }; return (
{label}: {count}
); }; export const FCCounterConnectedBindActionCreators = connect( mapStateToProps, mapDispatchToProps )(FCCounter); ```
Click to expand

```tsx import * as React from 'react'; import { FCCounterConnectedBindActionCreators } from '.'; export default () => ( ); ```

[⇧ back to top](#table-of-contents) ## Context > ### ThemeContext ```tsx import * as React from 'react'; export type Theme = React.CSSProperties; type Themes = { dark: Theme; light: Theme; }; export const themes: Themes = { dark: { color: 'black', backgroundColor: 'white', }, light: { color: 'white', backgroundColor: 'black', }, }; export type ThemeContextProps = { theme: Theme; toggleTheme?: () => void }; const ThemeContext = React.createContext({ theme: themes.light }); export default ThemeContext; ``` [⇧ back to top](#table-of-contents) ### ThemeProvider ```tsx import React from 'react'; import ThemeContext, { themes, Theme } from './theme-context'; import ToggleThemeButton from './theme-consumer'; interface State { theme: Theme; } export class ThemeProvider extends React.Component<{}, State> { readonly state: State = { theme: themes.light }; toggleTheme = () => { this.setState(state => ({ theme: state.theme === themes.light ? themes.dark : themes.light, })); } render() { const { theme } = this.state; const { toggleTheme } = this; return ( ); } } ``` [⇧ back to top](#table-of-contents) ### ThemeConsumer ```tsx import * as React from 'react'; import ThemeContext from './theme-context'; type Props = {}; export default function ToggleThemeButton(props: Props) { return ( {({ theme, toggleTheme }) => ); } } ``` [Implementation with Hooks](#--usecontext) [⇧ back to top](#table-of-contents) --- # Redux ## Store Configuration ### Create Global Store Types #### `RootState` - type representing root state-tree Can be imported in connected components to provide type-safety to Redux `connect` function #### `RootAction` - type representing union type of all action objects Can be imported in various layers receiving or sending redux actions like: reducers, sagas or redux-observables epics ```tsx import { StateType, ActionType } from 'typesafe-actions'; declare module 'MyTypes' { export type Store = StateType; export type RootAction = ActionType; export type RootState = StateType>; } declare module 'typesafe-actions' { interface Types { RootAction: ActionType; } } ``` [⇧ back to top](#table-of-contents) ### Create Store When creating a store instance we don't need to provide any additional types. It will set-up a **type-safe Store instance** using type inference. > The resulting store instance methods like `getState` or `dispatch` will be type checked and will expose all type errors ```tsx import { RootAction, RootState, Services } from 'MyTypes'; import { applyMiddleware, createStore } from 'redux'; import { createEpicMiddleware } from 'redux-observable'; import services from '../services'; import { routerMiddleware } from './redux-router'; import rootEpic from './root-epic'; import rootReducer from './root-reducer'; import { composeEnhancers } from './utils'; const epicMiddleware = createEpicMiddleware< RootAction, RootAction, RootState, Services >({ dependencies: services, }); // configure middlewares const middlewares = [epicMiddleware, routerMiddleware]; // compose enhancers const enhancer = composeEnhancers(applyMiddleware(...middlewares)); // rehydrate state on app start const initialState = {}; // create store const store = createStore( rootReducer, initialState, enhancer ); epicMiddleware.run(rootEpic); // export store singleton instance export default store; ``` --- ## Action Creators 🌟 > We'll be using a battle-tested helper library [`typesafe-actions`](https://github.com/piotrwitek/typesafe-actions#typesafe-actions) [![Latest Stable Version](https://img.shields.io/npm/v/typesafe-actions.svg)](https://www.npmjs.com/package/typesafe-actions) [![NPM Downloads](https://img.shields.io/npm/dt/typesafe-actions.svg)](https://www.npmjs.com/package/typesafe-actions) that's designed to make it easy and fun working with **Redux** in **TypeScript**. > To learn more please check this in-depth tutorial: [Typesafe-Actions - Tutorial](https://github.com/piotrwitek/typesafe-actions#tutorial)! A solution below is using a simple factory function to automate the creation of type-safe action creators. The goal is to decrease maintenance effort and reduce code repetition of type annotations for actions and creators. The result is completely typesafe action-creators and their actions. ```tsx /* eslint-disable */ import { action } from 'typesafe-actions'; import { ADD, INCREMENT } from './constants'; /* SIMPLE API */ export const increment = () => action(INCREMENT); export const add = (amount: number) => action(ADD, amount); /* ADVANCED API */ // More flexible allowing to create complex actions more easily // use can use "action-creator" instance in place of "type constant" // e.g. case getType(increment): return action.payload; // This will allow to completely eliminate need for "constants" in your application, more info here: // https://github.com/piotrwitek/typesafe-actions#constants import { createAction } from 'typesafe-actions'; import { Todo } from '../todos/models'; export const emptyAction = createAction(INCREMENT)(); export const payloadAction = createAction(ADD)(); export const payloadMetaAction = createAction(ADD)(); export const payloadCreatorAction = createAction( 'TOGGLE_TODO', (todo: Todo) => todo.id )(); ```
Click to expand

```tsx import { store } from '../../store/'; import { countersActions as counter } from '../counters'; // store.dispatch(counter.increment(1)); // Error: Expected 0 arguments, but got 1. store.dispatch(counter.increment()); // OK // store.dispatch(counter.add()); // Error: Expected 1 arguments, but got 0. store.dispatch(counter.add(1)); // OK ```

[⇧ back to top](#table-of-contents) --- ## Reducers ### State with Type-level Immutability Declare reducer `State` type with `readonly` modifier to get compile time immutability ```ts export type State = { readonly counter: number; readonly todos: ReadonlyArray; }; ``` Readonly modifier allow initialization, but will not allow reassignment by highlighting compiler errors ```ts export const initialState: State = { counter: 0, }; // OK initialState.counter = 3; // TS Error: cannot be mutated ``` It's great for **Arrays in JS** because it will error when using mutator methods like (`push`, `pop`, `splice`, ...), but it'll still allow immutable methods like (`concat`, `map`, `slice`,...). ```ts state.todos.push('Learn about tagged union types') // TS Error: Property 'push' does not exist on type 'ReadonlyArray' const newTodos = state.todos.concat('Learn about tagged union types') // OK ``` #### Caveat - `Readonly` is not recursive This means that the `readonly` modifier doesn't propagate immutability down the nested structure of objects. You'll need to mark each property on each level explicitly. > **TIP:** use `Readonly` or `ReadonlyArray` [Mapped types](https://www.typescriptlang.org/docs/handbook/advanced-types.html) ```ts export type State = Readonly<{ counterPairs: ReadonlyArray>, }>; state.counterPairs[0] = { immutableCounter1: 1, immutableCounter2: 1 }; // TS Error: cannot be mutated state.counterPairs[0].immutableCounter1 = 1; // TS Error: cannot be mutated state.counterPairs[0].immutableCounter2 = 1; // TS Error: cannot be mutated ``` #### Solution - recursive `Readonly` is called `DeepReadonly` To fix this we can use [`DeepReadonly`](https://github.com/piotrwitek/utility-types#deepreadonlyt) type (available from `utility-types`). ```ts import { DeepReadonly } from 'utility-types'; export type State = DeepReadonly<{ containerObject: { innerValue: number, numbers: number[], } }>; state.containerObject = { innerValue: 1 }; // TS Error: cannot be mutated state.containerObject.innerValue = 1; // TS Error: cannot be mutated state.containerObject.numbers.push(1); // TS Error: cannot use mutator methods ``` [⇧ back to top](#table-of-contents) ### Typing reducer > to understand following section make sure to learn about [Type Inference](https://www.typescriptlang.org/docs/handbook/type-inference.html), [Control flow analysis](https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#control-flow-based-type-analysis) and [Tagged union types](https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#tagged-union-types) ```tsx import { combineReducers } from 'redux'; import { ActionType } from 'typesafe-actions'; import { Todo, TodosFilter } from './models'; import * as actions from './actions'; import { ADD, CHANGE_FILTER, TOGGLE } from './constants'; export type TodosAction = ActionType; export type TodosState = Readonly<{ todos: Todo[]; todosFilter: TodosFilter; }>; const initialState: TodosState = { todos: [], todosFilter: TodosFilter.All, }; export default combineReducers({ todos: (state = initialState.todos, action) => { switch (action.type) { case ADD: return [...state, action.payload]; case TOGGLE: return state.map(item => item.id === action.payload ? { ...item, completed: !item.completed } : item ); default: return state; } }, todosFilter: (state = initialState.todosFilter, action) => { switch (action.type) { case CHANGE_FILTER: return action.payload; default: return state; } }, }); ``` [⇧ back to top](#table-of-contents) ### Typing reducer with `typesafe-actions` > Notice we are not required to use any generic type parameter in the API. Try to compare it with regular reducer as they are equivalent. ```tsx import { combineReducers } from 'redux'; import { createReducer } from 'typesafe-actions'; import { Todo, TodosFilter } from './models'; import { ADD, CHANGE_FILTER, TOGGLE } from './constants'; export type TodosState = Readonly<{ todos: Todo[]; todosFilter: TodosFilter; }>; const initialState: TodosState = { todos: [], todosFilter: TodosFilter.All, }; const todos = createReducer(initialState.todos) .handleType(ADD, (state, action) => [...state, action.payload]) .handleType(TOGGLE, (state, action) => state.map(item => item.id === action.payload ? { ...item, completed: !item.completed } : item ) ); const todosFilter = createReducer(initialState.todosFilter).handleType( CHANGE_FILTER, (state, action) => action.payload ); export default combineReducers({ todos, todosFilter, }); ``` [⇧ back to top](#table-of-contents) ### Testing reducer ```tsx import { todosReducer as reducer, todosActions as actions, } from './'; import { TodosState } from './reducer'; /** * FIXTURES */ const getInitialState = (initial?: Partial) => reducer(initial as TodosState, {} as any); /** * STORIES */ describe('Todos Stories', () => { describe('initial state', () => { it('should match a snapshot', () => { const initialState = getInitialState(); expect(initialState).toMatchSnapshot(); }); }); describe('adding todos', () => { it('should add a new todo as the first element', () => { const initialState = getInitialState(); expect(initialState.todos).toHaveLength(0); const state = reducer(initialState, actions.add('new todo')); expect(state.todos).toHaveLength(1); expect(state.todos[0].title).toEqual('new todo'); }); }); describe('toggling completion state', () => { it('should mark active todo as complete', () => { const activeTodo = { id: '1', completed: false, title: 'active todo' }; const initialState = getInitialState({ todos: [activeTodo] }); expect(initialState.todos[0].completed).toBeFalsy(); const state1 = reducer(initialState, actions.toggle(activeTodo.id)); expect(state1.todos[0].completed).toBeTruthy(); }); }); }); ``` [⇧ back to top](#table-of-contents) --- ## Async Flow with `redux-observable` ### Typing epics ```tsx import { RootAction, RootState, Services } from 'MyTypes'; import { Epic } from 'redux-observable'; import { tap, ignoreElements, filter } from 'rxjs/operators'; import { isOfType } from 'typesafe-actions'; import { todosConstants } from '../todos'; // contrived example!!! export const logAddAction: Epic = ( action$, state$, { logger } ) => action$.pipe( filter(isOfType(todosConstants.ADD)), // action is narrowed to: { type: "ADD_TODO"; payload: string; } tap(action => { logger.log( `action type must be equal: ${todosConstants.ADD} === ${action.type}` ); }), ignoreElements() ); ``` [⇧ back to top](#table-of-contents) ### Testing epics ```tsx import { StateObservable, ActionsObservable } from 'redux-observable'; import { RootState, RootAction } from 'MyTypes'; import { Subject } from 'rxjs'; import { add } from './actions'; import { logAddAction } from './epics'; // Simple typesafe mock of all the services, you dont't need to mock anything else // It is decoupled and reusable for all your tests, just put it in a separate file const services = { logger: { log: jest.fn(), }, localStorage: { loadState: jest.fn(), saveState: jest.fn(), }, }; describe('Todos Epics', () => { let state$: StateObservable; beforeEach(() => { state$ = new StateObservable( new Subject(), undefined as any ); }); describe('logging todos actions', () => { beforeEach(() => { services.logger.log.mockClear(); }); it('should call the logger service when adding a new todo', done => { const addTodoAction = add('new todo'); const action$ = ActionsObservable.of(addTodoAction); logAddAction(action$, state$, services) .toPromise() .then((outputAction: RootAction) => { expect(services.logger.log).toHaveBeenCalledTimes(1); expect(services.logger.log).toHaveBeenCalledWith( 'action type must be equal: todos/ADD === todos/ADD' ); // expect output undefined because we're using "ignoreElements" in epic expect(outputAction).toEqual(undefined); done(); }); }); }); }); ``` [⇧ back to top](#table-of-contents) --- ## Selectors with `reselect` ```tsx import { createSelector } from 'reselect'; import { TodosState } from './reducer'; export const getTodos = (state: TodosState) => state.todos; export const getTodosFilter = (state: TodosState) => state.todosFilter; export const getFilteredTodos = createSelector(getTodos, getTodosFilter, (todos, todosFilter) => { switch (todosFilter) { case 'completed': return todos.filter(t => t.completed); case 'active': return todos.filter(t => !t.completed); default: return todos; } }); ``` [⇧ back to top](#table-of-contents) --- ## Connect with `react-redux` ### Typing connected component _**NOTE**: Below you'll find a short explanation of concepts behind using `connect` with TypeScript. For more detailed examples please check [Redux Connected Components](#redux-connected-components) section._ ```tsx import MyTypes from 'MyTypes'; import { bindActionCreators, Dispatch, ActionCreatorsMapObject } from 'redux'; import { connect } from 'react-redux'; import { countersActions } from '../features/counters'; import { FCCounter } from '../components'; // Type annotation for "state" argument is mandatory to check // the correct shape of state object and injected props you can also // extend connected component Props interface by annotating `ownProps` argument const mapStateToProps = (state: MyTypes.RootState, ownProps: FCCounterProps) => ({ count: state.counters.reduxCounter, }); // "dispatch" argument needs an annotation to check the correct shape // of an action object when using dispatch function const mapDispatchToProps = (dispatch: Dispatch) => bindActionCreators({ onIncrement: countersActions.increment, }, dispatch); // shorter alternative is to use an object instead of mapDispatchToProps function const dispatchToProps = { onIncrement: countersActions.increment, }; // Notice we don't need to pass any generic type parameters to neither // the connect function below nor map functions declared above // because type inference will infer types from arguments annotations automatically // This is much cleaner and idiomatic approach export const FCCounterConnected = connect(mapStateToProps, mapDispatchToProps)(FCCounter); // You can add extra layer of validation of your action creators // by using bindActionCreators generic type parameter and RootAction type const mapDispatchToProps = (dispatch: Dispatch) => bindActionCreators>({ invalidActionCreator: () => 1, // Error: Type 'number' is not assignable to type '{ type: "todos/ADD"; payload: Todo; } | { ... } }, dispatch); ``` [⇧ back to top](#table-of-contents) ### Typing `useSelector` and `useDispatch` ```tsx import { Dispatch } from 'redux'; import { TypedUseSelectorHook, useSelector as useGenericSelector, useDispatch as useGenericDispatch } from 'react-redux'; import { RootState, RootAction } from 'MyTypes'; export const useSelector: TypedUseSelectorHook = useGenericSelector; export const useDispatch: () => Dispatch = useGenericDispatch; ``` [⇧ back to top](#table-of-contents) ### Typing connected component with `redux-thunk` integration _**NOTE**: When using thunk action creators you need to use `bindActionCreators`. Only this way you can get corrected dispatch props type signature like below.*_ _**WARNING**: As of now (Apr 2019) `bindActionCreators` signature of the latest `redux-thunk` release will not work as below, you need to use our modified type definitions that you can find here [`/playground/typings/redux-thunk/index.d.ts`](./playground/typings/redux-thunk/index.d.ts) and then add `paths` overload in your tsconfig like this: [`"paths":{"redux-thunk":["typings/redux-thunk"]}`](./playground/tsconfig.json)._ ```tsx const thunkAsyncAction = () => async (dispatch: Dispatch): Promise => { // dispatch actions, return Promise, etc. } const mapDispatchToProps = (dispatch: Dispatch) => bindActionCreators( { thunkAsyncAction, }, dispatch ); type DispatchProps = ReturnType; // { thunkAsyncAction: () => Promise; } /* Without "bindActionCreators" fix signature will be the same as the original "unbound" thunk function: */ // { thunkAsyncAction: () => (dispatch: Dispatch) => Promise; } ``` [⇧ back to top](#table-of-contents) --- # Configuration & Dev Tools ## Common Npm Scripts > Common TS-related npm scripts shared across projects ```json "prettier": "prettier --list-different 'src/**/*.ts' || (echo '\nPlease fix code formatting by running:\nnpm run prettier:fix\n'; exit 1)", "prettier:fix": "prettier --write 'src/**/*.ts'", "lint": "eslint ./src --ext .js,.jsx,.ts,.tsx", "tsc": "tsc -p ./ --noEmit", "tsc:watch": "tsc -p ./ --noEmit -w", "test": "jest --config jest.config.json", "test:watch": "jest --config jest.config.json --watch", "test:update": "jest --config jest.config.json -u" "ci-check": "npm run prettier && npm run lint && npm run tsc && npm run test", ``` [⇧ back to top](#table-of-contents) ## tsconfig.json We have recommended `tsconfig.json` that you can easily add to your project thanks to [`react-redux-typescript-scripts`](https://github.com/piotrwitek/react-redux-typescript-scripts) package.
Click to expand

```tsx { "compilerOptions": { "target": "ES6", "lib": [ "dom", "dom.iterable", "esnext" ], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, "module": "esnext", "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, "jsx": "react-jsx" }, "include": [ "src", "typings" ] } ```

[⇧ back to top](#table-of-contents) ## TSLib This library will cut down on your bundle size, thanks to using external runtime helpers instead of adding them per each file. > > Installation `npm i tslib` Then add this to your `tsconfig.json`: ```ts "compilerOptions": { "importHelpers": true } ``` [⇧ back to top](#table-of-contents) ## ESLint We have recommended config that will automatically add a parser & plugin for TypeScript thanks to [`react-redux-typescript-scripts`](https://github.com/piotrwitek/react-redux-typescript-scripts) package. > > Installation `npm i -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin` ### .eslintrc.js
Click to expand

```tsx module.exports = { root: true, parser: '@typescript-eslint/parser', plugins: ['@typescript-eslint'], extends: ['react-app', 'react-app/jest', 'prettier'], rules: { 'import/no-anonymous-default-export': 0 }, }; ```

[⇧ back to top](#table-of-contents) ## Jest > > Installation `npm i -D jest ts-jest @types/jest` ### jest.config.json
Click to expand

```tsx { "verbose": true, "transform": { ".(ts|tsx)": "ts-jest" }, "testRegex": "(/spec/.*|\\.(test|spec))\\.(ts|tsx|js)$", "moduleFileExtensions": ["ts", "tsx", "js"], "moduleNameMapper": { "^Components/(.*)": "./src/components/$1" }, "globals": { "window": {}, "ts-jest": { "tsConfig": "./tsconfig.json" } }, "setupFiles": ["./jest.stubs.js"], "testURL": "http://localhost/" } ```

### jest.stubs.js
Click to expand

```tsx // Global/Window object Stubs for Jest window.matchMedia = window.matchMedia || function () { return { matches: false, addListener: function () { }, removeListener: function () { }, }; }; window.requestAnimationFrame = function (callback) { setTimeout(callback); }; window.localStorage = { getItem: function () { }, setItem: function () { }, }; Object.values = () => []; ```

[⇧ back to top](#table-of-contents) ## Style Guides ### [react-styleguidist](https://github.com/styleguidist/react-styleguidist) [⟩⟩⟩ styleguide.config.js](/playground/styleguide.config.js) [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/) [⇧ back to top](#table-of-contents) --- # FAQ ## Ambient Modules ### Imports in ambient modules For type augmentation imports should stay outside of module declaration. ```ts import { Operator } from 'rxjs/Operator'; import { Observable } from 'rxjs/Observable'; declare module 'rxjs/Subject' { interface Subject { lift(operator: Operator): Observable; } } ``` When creating 3rd party type-definitions all the imports should be kept inside the module declaration, otherwise it will be treated as augmentation and show error ```ts declare module "react-custom-scrollbars" { import * as React from "react"; export interface positionValues { ... ``` [⇧ back to top](#table-of-contents) ## Type-Definitions ### Missing type-definitions error if you cannot find types for a third-party module you can provide your own types or disable type-checking for this module using [Shorthand Ambient Modules](https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Modules.md#shorthand-ambient-modules) ```tsx // typings/modules.d.ts declare module 'MyTypes'; declare module 'react-test-renderer'; declare module '@storybook/addon-storyshots' ``` ### Using custom `d.ts` files for npm modules If you want to use an alternative (customized) type-definitions for some npm module (that usually comes with it's own type-definitions), you can do it by adding an override in `paths` compiler option. ```ts { "compilerOptions": { "baseUrl": ".", "paths": { "redux": ["typings/redux"], // use an alternative type-definitions instead of the included one ... }, ..., } } ``` [⇧ back to top](#table-of-contents) ## Type Augmentation Strategies to fix issues coming from external type-definitions files (*.d.ts) ### Augmenting library internal declarations - using relative import ```ts // added missing autoFocus Prop on Input component in "antd@2.10.0" npm package declare module '../node_modules/antd/lib/input/Input' { export interface InputProps { autoFocus?: boolean; } } ``` ### Augmenting library public declarations - using node_modules import ```ts // fixed broken public type-definitions in "rxjs@5.4.1" npm package import { Operator } from 'rxjs/Operator'; import { Observable } from 'rxjs/Observable'; declare module 'rxjs/Subject' { interface Subject { lift(operator: Operator): Observable; } } ``` > More advanced scenarios for working with vendor type-definitions can be found here [Official TypeScript Docs](https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Modules.md#working-with-other-javascript-libraries) [⇧ back to top](#table-of-contents) ## Misc ### - should I still use React.PropTypes in TS? No. With TypeScript, using PropTypes is an unnecessary overhead. When declaring Props and State interfaces, you will get complete intellisense and design-time safety with static type checking. This way you'll be safe from runtime errors and you will save a lot of time on debugging. Additional benefit is an elegant and standardized method of documenting your component public API in the source code. [⇧ back to top](#table-of-contents) ### - when to use `interface` declarations and when `type` aliases? From practical side, using `interface` declaration will create an identity (interface name) in compiler errors, on the contrary `type` aliases doesn't create an identity and will be unwinded to show all the properties and nested types it consists of. Although I prefer to use `type` most of the time there are some places this can become too noisy when reading compiler errors and that's why I like to leverage this distinction to hide some of not so important type details in errors using interfaces identity. Related `ts-lint` rule: [⇧ back to top](#table-of-contents) ### - what's better default or named exports? A common flexible solution is to use module folder pattern, because you can leverage both named and default import when you see fit. With this solution you'll achieve better encapsulation and be able to safely refactor internal naming and folders structure without breaking your consumer code: ```ts // 1. create your component files (`select.tsx`) using default export in some folder: // components/select.tsx const Select: React.FC = (props) => { ... export default Select; // 2. in this folder create an `index.ts` file that will re-export components with named exports: // components/index.ts export { default as Select } from './select'; ... // 3. now you can import your components in both ways, with named export (better encapsulation) or using default export (internal access): // containers/container.tsx import { Select } from '@src/components'; or import Select from '@src/components/select'; ... ``` [⇧ back to top](#table-of-contents) ### - how to best initialize class instance or static properties? Prefered modern syntax is to use class Property Initializers ```tsx class ClassCounterWithInitialCount extends React.Component { // default props using Property Initializers static defaultProps: DefaultProps = { className: 'default-class', initialCount: 0, }; // initial state using Property Initializers state: State = { count: this.props.initialCount, }; ... } ``` [⇧ back to top](#table-of-contents) ### - how to best declare component handler functions? Prefered modern syntax is to use Class Fields with arrow functions ```tsx class ClassCounter extends React.Component { // handlers using Class Fields with arrow functions handleIncrement = () => { this.setState({ count: this.state.count + 1 }); }; ... } ``` [⇧ back to top](#table-of-contents) --- # Tutorials & Articles > Curated list of relevant in-depth tutorials Higher-Order Components: - [⇧ back to top](#table-of-contents) --- # Contributors Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): | [
Piotrek Witek](https://github.com/piotrwitek)
[💻](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=piotrwitek "Code") [📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=piotrwitek "Documentation") [🤔](#ideas-piotrwitek "Ideas, Planning, & Feedback") [👀](#review-piotrwitek "Reviewed Pull Requests") [💬](#question-piotrwitek "Answering Questions") | [
Kazz Yokomizo](https://github.com/kazup01)
[💵](#financial-kazup01 "Financial") [🔍](#fundingFinding-kazup01 "Funding Finding") | [
Jake Boone](https://github.com/jakeboone02)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=jakeboone02 "Documentation") | [
Amit Dahan](https://github.com/amitdahan)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=amitdahan "Documentation") | [
gulderov](https://github.com/gulderov)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=gulderov "Documentation") | [
Erik Pearson](https://github.com/emp823)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=emp823 "Documentation") | [
Bryan Mason](https://github.com/flymason)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=flymason "Documentation") | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | [
Jakub Chodorowicz](http://www.jakub.chodorowicz.pl/)
[💻](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=chodorowicz "Code") | [
Oleg Maslov](https://github.com/mleg)
[🐛](https://github.com/piotrwitek/react-redux-typescript-guide/issues?q=author%3Amleg "Bug reports") | [
Aaron Westbrook](https://github.com/awestbro)
[🐛](https://github.com/piotrwitek/react-redux-typescript-guide/issues?q=author%3Aawestbro "Bug reports") | [
Peter Blazejewicz](http://www.linkedin.com/in/peterblazejewicz)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=peterblazejewicz "Documentation") | [
Solomon White](https://github.com/rubysolo)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=rubysolo "Documentation") | [
Levi Rocha](https://github.com/pino)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=pino "Documentation") | [
Sudachi-kun](http://cloudnative.co.jp)
[💵](#financial-loadbalance-sudachi-kun "Financial") | | [
Sosuke Suzuki](http://sosukesuzuki.github.io)
[💻](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=sosukesuzuki "Code") | [
Tom Rathbone](https://github.com/chillitom)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=chillitom "Documentation") | [
Arshad Kazmi](https://arshadkazmi42.github.io/)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=arshadkazmi42 "Documentation") | [
JeongUkJae](https://jeongukjae.github.io)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=JeongUkJae "Documentation") | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! --- MIT License Copyright (c) 2017 Piotr Witek () ================================================ FILE: README_SOURCE.md ================================================
# React & Redux in TypeScript - Complete Guide _"This guide is a **living compendium** documenting the most important patterns and recipes on how to use **React** (and its Ecosystem) in a **functional style** using **TypeScript**. It will help you make your code **completely type-safe** while focusing on **inferring the types from implementation** so there is less noise coming from excessive type annotations and it's easier to write and maintain correct types in the long run."_ [![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/react-redux-ts) [![Join the chat at https://gitter.im/react-redux-typescript-guide/Lobby](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/react-redux-typescript-guide/Lobby) _Found it useful? Want more updates?_ [**Show your support by giving a :star:**](https://github.com/piotrwitek/react-redux-typescript-guide/stargazers) Buy Me a Coffee Become a Patron

## **What's new?** :tada: _Now updated to support **TypeScript v4.6**_ :tada: :rocket: _Updated to `typesafe-actions@5.x` :rocket:

### **Goals** - Complete type safety (with [`--strict`](https://www.typescriptlang.org/docs/handbook/compiler-options.html) flag) without losing type information downstream through all the layers of our application (e.g. no type assertions or hacking with `any` type) - Make type annotations concise by eliminating redundancy in types using advanced TypeScript Language features like **Type Inference** and **Control flow analysis** - Reduce repetition and complexity of types with TypeScript focused [complementary libraries](#react-redux-typescript-ecosystem) ### **React, Redux, Typescript Ecosystem** - [typesafe-actions](https://github.com/piotrwitek/typesafe-actions) - Typesafe utilities for "action-creators" in Redux / Flux Architecture - [utility-types](https://github.com/piotrwitek/utility-types) - Collection of generic types for TypeScript, complementing built-in mapped types and aliases - think lodash for reusable types. - [react-redux-typescript-scripts](https://github.com/piotrwitek/react-redux-typescript-scripts) - dev-tools configuration files shared between projects based on this guide ### **Examples** - Todo-App playground: [Codesandbox](https://codesandbox.io/s/github/piotrwitek/typesafe-actions/tree/master/codesandbox) - React, Redux, TypeScript - RealWorld App: [Github](https://github.com/piotrwitek/react-redux-typescript-realworld-app) | [Demo](https://react-redux-typescript-realworld-app.netlify.com/) ### **Playground Project** [![Build Status](https://semaphoreci.com/api/v1/piotrekwitek/react-redux-typescript-guide/branches/master/shields_badge.svg)](https://semaphoreci.com/piotrekwitek/react-redux-typescript-guide) Check out our Playground Project located in the `/playground` folder. It contains all source files of the code examples found in the guide. They are all tested with the most recent version of TypeScript and 3rd party type-definitions (like `@types/react` or `@types/react-redux`) to ensure the examples are up-to-date and not broken with updated definitions (It's based on `create-react-app --typescript`). > Playground project was created so that you can simply clone the repository locally and immediately play around with all the component patterns found in the guide. It will help you to learn all the examples from this guide in a real project environment without the need to create complicated environment setup by yourself. ## Contributing Guide You can help make this project better by contributing. If you're planning to contribute please make sure to check our contributing guide: [CONTRIBUTING.md](/CONTRIBUTING.md) ## Funding You can also help by funding issues. Issues like bug fixes or feature requests can be very quickly resolved when funded through the IssueHunt platform. I highly recommend to add a bounty to the issue that you're waiting for to increase priority and attract contributors willing to work on it. [![Let's fund issues in this repository](https://issuehunt.io/static/embed/issuehunt-button-v1.svg)](https://issuehunt.io/repos/76996763) --- 🌟 - _New or updated section_ ## Table of Contents - [React Types Cheatsheet](#react-types-cheatsheet) - [`React.FC` | `React.FunctionComponent`](#reactfcprops--reactfunctioncomponentprops) - [`React.Component`](#reactcomponentprops-state) - [`React.ComponentType`](#reactcomponenttypeprops) - [`React.ComponentProps`](#reactcomponentpropstypeof-xxx) - [`React.ReactElement` | `JSX.Element`](#reactreactelement--jsxelement) - [`React.ReactNode`](#reactreactnode) - [`React.CSSProperties`](#reactcssproperties) - [`React.XXXHTMLAttributes`](#reactxxxhtmlattributeshtmlxxxelement) - [`React.ReactEventHandler`](#reactreacteventhandlerhtmlxxxelement) - [`React.XXXEvent`](#reactxxxeventhtmlxxxelement) - [React](#react) - [Function Components - FC](#function-components---fc) - [- Counter Component](#--counter-component) - [- Counter Component with default props](#--counter-component-with-default-props) - [- Spreading attributes in Component](#--spreading-attributes-in-component) - [Class Components](#class-components) - [- Class Counter Component](#--class-counter-component) - [- Class Component with default props](#--class-component-with-default-props) - [Generic Components](#generic-components) - [- Generic List Component](#--generic-list-component) - [Hooks](#hooks) - [- useState](#--usestate) - [- useContext](#--usecontext) - [- useReducer](#--usereducer) - [Render Props](#render-props) - [- Name Provider Component](#--name-provider-component) - [- Mouse Provider Component](#--mouse-provider-component) - [Higher-Order Components](#higher-order-components) - [- HOC wrapping a component](#--hoc-wrapping-a-component) - [- HOC wrapping a component and injecting props](#--hoc-wrapping-a-component-and-injecting-props) - [- Nested HOC - wrapping a component, injecting props and connecting to redux 🌟](#--nested-hoc---wrapping-a-component-injecting-props-and-connecting-to-redux-) - [Redux Connected Components](#redux-connected-components) - [- Redux connected counter](#--redux-connected-counter) - [- Redux connected counter with own props](#--redux-connected-counter-with-own-props) - [- Redux connected counter via hooks](#--redux-connected-counter-via-hooks) - [- Redux connected counter with `redux-thunk` integration](#--redux-connected-counter-with-redux-thunk-integration) - [Context](#context) - [ThemeContext](#themecontext) - [ThemeProvider](#themeprovider) - [ThemeConsumer](#themeconsumer) - [ThemeConsumer in class component](#themeconsumer-in-class-component) - [Redux](#redux) - [Store Configuration](#store-configuration) - [Create Global Store Types](#create-global-store-types) - [Create Store](#create-store) - [Action Creators 🌟](#action-creators-) - [Reducers](#reducers) - [State with Type-level Immutability](#state-with-type-level-immutability) - [Typing reducer](#typing-reducer) - [Typing reducer with `typesafe-actions`](#typing-reducer-with-typesafe-actions) - [Testing reducer](#testing-reducer) - [Async Flow with `redux-observable`](#async-flow-with-redux-observable) - [Typing epics](#typing-epics) - [Testing epics](#testing-epics) - [Selectors with `reselect`](#selectors-with-reselect) - [Connect with `react-redux`](#connect-with-react-redux) - [Typing connected component](#typing-connected-component) - [Typing `useSelector` and `useDispatch`](#typing-useselector-and-usedispatch) - [Typing connected component with `redux-thunk` integration](#typing-connected-component-with-redux-thunk-integration) - [Configuration & Dev Tools](#configuration--dev-tools) - [Common Npm Scripts](#common-npm-scripts) - [tsconfig.json](#tsconfigjson) - [TSLib](#tslib) - [ESLint](#eslint) - [.eslintrc.js](#eslintrcjs) - [Jest](#jest) - [jest.config.json](#jestconfigjson) - [jest.stubs.js](#jeststubsjs) - [Style Guides](#style-guides) - [react-styleguidist](#react-styleguidist) - [FAQ](#faq) - [Ambient Modules](#ambient-modules) - [Imports in ambient modules](#imports-in-ambient-modules) - [Type-Definitions](#type-definitions) - [Missing type-definitions error](#missing-type-definitions-error) - [Using custom `d.ts` files for npm modules](#using-custom-dts-files-for-npm-modules) - [Type Augmentation](#type-augmentation) - [Augmenting library internal declarations - using relative import](#augmenting-library-internal-declarations---using-relative-import) - [Augmenting library public declarations - using node_modules import](#augmenting-library-public-declarations---using-node_modules-import) - [Misc](#misc) - [- should I still use React.PropTypes in TS?](#--should-i-still-use-reactproptypes-in-ts) - [- when to use `interface` declarations and when `type` aliases?](#--when-to-use-interface-declarations-and-when-type-aliases) - [- what's better default or named exports?](#--whats-better-default-or-named-exports) - [- how to best initialize class instance or static properties?](#--how-to-best-initialize-class-instance-or-static-properties) - [- how to best declare component handler functions?](#--how-to-best-declare-component-handler-functions) - [Tutorials & Articles](#tutorials--articles) - [Contributors](#contributors) --- # Installation ## Types for React & Redux ``` npm i -D @types/react @types/react-dom @types/react-redux ``` "react" - `@types/react` "react-dom" - `@types/react-dom` "redux" - (types included with npm package)* "react-redux" - `@types/react-redux` > *NB: Guide is based on types for Redux >= v4.x.x. [⇧ back to top](#table-of-contents) --- ## React Types Cheatsheet ### `React.FC` | `React.FunctionComponent` Type representing a functional component ```tsx const MyComponent: React.FC = ... ``` ### `React.Component` Type representing a class component ```tsx class MyComponent extends React.Component { ... ``` ### `React.ComponentType` Type representing union of (`React.FC | React.Component`) - used in HOC ```tsx const withState =

( WrappedComponent: React.ComponentType

, ) => { ... ``` ### `React.ComponentProps` Gets Props type of a specified component XXX (WARNING: does not work with statically declared default props and generic props) ```tsx type MyComponentProps = React.ComponentProps; ``` ### `React.ReactElement` | `JSX.Element` Type representing a concept of React Element - representation of a native DOM component (e.g. `

`), or a user-defined composite component (e.g. ``) ```tsx const elementOnly: React.ReactElement =
|| ; ``` ### `React.ReactNode` Type representing any possible type of React node (basically ReactElement (including Fragments and Portals) + primitive JS types) ```tsx const elementOrPrimitive: React.ReactNode = 'string' || 0 || false || null || undefined ||
|| ; const Component = ({ children: React.ReactNode }) => ... ``` ### `React.CSSProperties` Type representing style object in JSX - for css-in-js styles ```tsx const styles: React.CSSProperties = { flexDirection: 'row', ... const element =
` Type representing HTML attributes of specified HTML Element - for extending HTML Elements ```tsx const Input: React.FC> = props => { ... } ``` ### `React.ReactEventHandler` Type representing generic event handler - for declaring event handlers ```tsx const handleChange: React.ReactEventHandler = (ev) => { ... } ``` ### `React.XXXEvent` Type representing more specific event. Some common event examples: `ChangeEvent, FormEvent, FocusEvent, KeyboardEvent, MouseEvent, DragEvent, PointerEvent, WheelEvent, TouchEvent`. ```tsx const handleChange = (ev: React.MouseEvent) => { ... }
``` In code above `React.MouseEvent` is type of mouse event, and this event happened on `HTMLDivElement` [⇧ back to top](#table-of-contents) --- # React ## Function Components - FC ### - Counter Component ::codeblock='playground/src/components/fc-counter.tsx':: [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/#fccounter) [⇧ back to top](#table-of-contents) ### - Counter Component with default props ::codeblock='playground/src/components/fc-counter-with-default-props.tsx':: [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/#fccounterwithdefaultprops) [⇧ back to top](#table-of-contents) ### - [Spreading attributes](https://facebook.github.io/react/docs/jsx-in-depth.html#spread-attributes) in Component ::codeblock='playground/src/components/fc-spread-attributes.tsx':: [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/#fcspreadattributes) [⇧ back to top](#table-of-contents) --- ## Class Components ### - Class Counter Component ::codeblock='playground/src/components/class-counter.tsx':: [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/#classcounter) [⇧ back to top](#table-of-contents) ### - Class Component with default props ::codeblock='playground/src/components/class-counter-with-default-props.tsx':: [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/#classcounterwithdefaultprops) [⇧ back to top](#table-of-contents) --- ## Generic Components - easily create typed component variations and reuse common logic - common use case is a generic list components ### - Generic List Component ::codeblock='playground/src/components/generic-list.tsx':: [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/#genericlist) [⇧ back to top](#table-of-contents) --- ## Hooks > ### - useState > ::codeblock='playground/src/hooks/use-state.tsx':: [⇧ back to top](#table-of-contents) ### - useContext > ::codeblock='playground/src/hooks/use-theme-context.tsx':: [⇧ back to top](#table-of-contents) ### - useReducer > ::codeblock='playground/src/hooks/use-reducer.tsx':: [⇧ back to top](#table-of-contents) --- ## Render Props > ### - Name Provider Component Simple component using children as a render prop ::codeblock='playground/src/components/name-provider.tsx':: [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/#nameprovider) [⇧ back to top](#table-of-contents) ### - Mouse Provider Component `Mouse` component found in [Render Props React Docs](https://reactjs.org/docs/render-props.html#use-render-props-for-cross-cutting-concerns) ::codeblock='playground/src/components/mouse-provider.tsx':: [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/#mouseprovider) [⇧ back to top](#table-of-contents) --- ## Higher-Order Components > ### - HOC wrapping a component Adds state to a stateless counter ::codeblock='playground/src/hoc/with-state.tsx':: ::expander='playground/src/hoc/with-state.usage.tsx':: [⇧ back to top](#table-of-contents) ### - HOC wrapping a component and injecting props Adds error handling using componentDidCatch to any component ::codeblock='playground/src/hoc/with-error-boundary.tsx':: ::expander='playground/src/hoc/with-error-boundary.usage.tsx':: [⇧ back to top](#table-of-contents) ### - Nested HOC - wrapping a component, injecting props and connecting to redux 🌟 Adds error handling using componentDidCatch to any component ::codeblock='playground/src/hoc/with-connected-count.tsx':: ::expander='playground/src/hoc/with-connected-count.usage.tsx':: [⇧ back to top](#table-of-contents) --- ## Redux Connected Components ### - Redux connected counter ::codeblock='playground/src/connected/fc-counter-connected.tsx':: ::expander='playground/src/connected/fc-counter-connected.usage.tsx':: [⇧ back to top](#table-of-contents) ### - Redux connected counter with own props ::codeblock='playground/src/connected/fc-counter-connected-own-props.tsx':: ::expander='playground/src/connected/fc-counter-connected-own-props.usage.tsx':: [⇧ back to top](#table-of-contents) ### - Redux connected counter via hooks ::codeblock='playground/src/hooks/react-redux-hooks.tsx':: [⇧ back to top](#table-of-contents) ### - Redux connected counter with `redux-thunk` integration ::codeblock='playground/src/connected/fc-counter-connected-bind-action-creators.tsx':: ::expander='playground/src/connected/fc-counter-connected-bind-action-creators.usage.tsx':: [⇧ back to top](#table-of-contents) ## Context > ### ThemeContext ::codeblock='playground/src/context/theme-context.ts':: [⇧ back to top](#table-of-contents) ### ThemeProvider ::codeblock='playground/src/context/theme-provider.tsx':: [⇧ back to top](#table-of-contents) ### ThemeConsumer ::codeblock='playground/src/context/theme-consumer.tsx':: ### ThemeConsumer in class component ::codeblock='playground/src/context/theme-consumer-class.tsx':: [Implementation with Hooks](#--usecontext) [⇧ back to top](#table-of-contents) --- # Redux ## Store Configuration ### Create Global Store Types #### `RootState` - type representing root state-tree Can be imported in connected components to provide type-safety to Redux `connect` function #### `RootAction` - type representing union type of all action objects Can be imported in various layers receiving or sending redux actions like: reducers, sagas or redux-observables epics ::codeblock='playground/src/store/types.d.ts':: [⇧ back to top](#table-of-contents) ### Create Store When creating a store instance we don't need to provide any additional types. It will set-up a **type-safe Store instance** using type inference. > The resulting store instance methods like `getState` or `dispatch` will be type checked and will expose all type errors ::codeblock='playground/src/store/store.ts':: --- ## Action Creators 🌟 > We'll be using a battle-tested helper library [`typesafe-actions`](https://github.com/piotrwitek/typesafe-actions#typesafe-actions) [![Latest Stable Version](https://img.shields.io/npm/v/typesafe-actions.svg)](https://www.npmjs.com/package/typesafe-actions) [![NPM Downloads](https://img.shields.io/npm/dt/typesafe-actions.svg)](https://www.npmjs.com/package/typesafe-actions) that's designed to make it easy and fun working with **Redux** in **TypeScript**. > To learn more please check this in-depth tutorial: [Typesafe-Actions - Tutorial](https://github.com/piotrwitek/typesafe-actions#tutorial)! A solution below is using a simple factory function to automate the creation of type-safe action creators. The goal is to decrease maintenance effort and reduce code repetition of type annotations for actions and creators. The result is completely typesafe action-creators and their actions. ::codeblock='playground/src/features/counters/actions.ts':: ::expander='playground/src/features/counters/actions.usage.ts':: [⇧ back to top](#table-of-contents) --- ## Reducers ### State with Type-level Immutability Declare reducer `State` type with `readonly` modifier to get compile time immutability ```ts export type State = { readonly counter: number; readonly todos: ReadonlyArray; }; ``` Readonly modifier allow initialization, but will not allow reassignment by highlighting compiler errors ```ts export const initialState: State = { counter: 0, }; // OK initialState.counter = 3; // TS Error: cannot be mutated ``` It's great for **Arrays in JS** because it will error when using mutator methods like (`push`, `pop`, `splice`, ...), but it'll still allow immutable methods like (`concat`, `map`, `slice`,...). ```ts state.todos.push('Learn about tagged union types') // TS Error: Property 'push' does not exist on type 'ReadonlyArray' const newTodos = state.todos.concat('Learn about tagged union types') // OK ``` #### Caveat - `Readonly` is not recursive This means that the `readonly` modifier doesn't propagate immutability down the nested structure of objects. You'll need to mark each property on each level explicitly. > **TIP:** use `Readonly` or `ReadonlyArray` [Mapped types](https://www.typescriptlang.org/docs/handbook/advanced-types.html) ```ts export type State = Readonly<{ counterPairs: ReadonlyArray>, }>; state.counterPairs[0] = { immutableCounter1: 1, immutableCounter2: 1 }; // TS Error: cannot be mutated state.counterPairs[0].immutableCounter1 = 1; // TS Error: cannot be mutated state.counterPairs[0].immutableCounter2 = 1; // TS Error: cannot be mutated ``` #### Solution - recursive `Readonly` is called `DeepReadonly` To fix this we can use [`DeepReadonly`](https://github.com/piotrwitek/utility-types#deepreadonlyt) type (available from `utility-types`). ```ts import { DeepReadonly } from 'utility-types'; export type State = DeepReadonly<{ containerObject: { innerValue: number, numbers: number[], } }>; state.containerObject = { innerValue: 1 }; // TS Error: cannot be mutated state.containerObject.innerValue = 1; // TS Error: cannot be mutated state.containerObject.numbers.push(1); // TS Error: cannot use mutator methods ``` [⇧ back to top](#table-of-contents) ### Typing reducer > to understand following section make sure to learn about [Type Inference](https://www.typescriptlang.org/docs/handbook/type-inference.html), [Control flow analysis](https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#control-flow-based-type-analysis) and [Tagged union types](https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#tagged-union-types) ::codeblock='playground/src/features/todos/reducer.ts':: [⇧ back to top](#table-of-contents) ### Typing reducer with `typesafe-actions` > Notice we are not required to use any generic type parameter in the API. Try to compare it with regular reducer as they are equivalent. ::codeblock='playground/src/features/todos/reducer-ta.ts':: [⇧ back to top](#table-of-contents) ### Testing reducer ::codeblock='playground/src/features/todos/reducer.spec.ts':: [⇧ back to top](#table-of-contents) --- ## Async Flow with `redux-observable` ### Typing epics ::codeblock='playground/src/features/todos/epics.ts':: [⇧ back to top](#table-of-contents) ### Testing epics ::codeblock='playground/src/features/todos/epics.spec.ts':: [⇧ back to top](#table-of-contents) --- ## Selectors with `reselect` ::codeblock='playground/src/features/todos/selectors.ts':: [⇧ back to top](#table-of-contents) --- ## Connect with `react-redux` ### Typing connected component _**NOTE**: Below you'll find a short explanation of concepts behind using `connect` with TypeScript. For more detailed examples please check [Redux Connected Components](#redux-connected-components) section._ ```tsx import MyTypes from 'MyTypes'; import { bindActionCreators, Dispatch, ActionCreatorsMapObject } from 'redux'; import { connect } from 'react-redux'; import { countersActions } from '../features/counters'; import { FCCounter } from '../components'; // Type annotation for "state" argument is mandatory to check // the correct shape of state object and injected props you can also // extend connected component Props interface by annotating `ownProps` argument const mapStateToProps = (state: MyTypes.RootState, ownProps: FCCounterProps) => ({ count: state.counters.reduxCounter, }); // "dispatch" argument needs an annotation to check the correct shape // of an action object when using dispatch function const mapDispatchToProps = (dispatch: Dispatch) => bindActionCreators({ onIncrement: countersActions.increment, }, dispatch); // shorter alternative is to use an object instead of mapDispatchToProps function const dispatchToProps = { onIncrement: countersActions.increment, }; // Notice we don't need to pass any generic type parameters to neither // the connect function below nor map functions declared above // because type inference will infer types from arguments annotations automatically // This is much cleaner and idiomatic approach export const FCCounterConnected = connect(mapStateToProps, mapDispatchToProps)(FCCounter); // You can add extra layer of validation of your action creators // by using bindActionCreators generic type parameter and RootAction type const mapDispatchToProps = (dispatch: Dispatch) => bindActionCreators>({ invalidActionCreator: () => 1, // Error: Type 'number' is not assignable to type '{ type: "todos/ADD"; payload: Todo; } | { ... } }, dispatch); ``` [⇧ back to top](#table-of-contents) ### Typing `useSelector` and `useDispatch` ::codeblock='playground/src/store/hooks.ts':: [⇧ back to top](#table-of-contents) ### Typing connected component with `redux-thunk` integration _**NOTE**: When using thunk action creators you need to use `bindActionCreators`. Only this way you can get corrected dispatch props type signature like below.*_ _**WARNING**: As of now (Apr 2019) `bindActionCreators` signature of the latest `redux-thunk` release will not work as below, you need to use our modified type definitions that you can find here [`/playground/typings/redux-thunk/index.d.ts`](./playground/typings/redux-thunk/index.d.ts) and then add `paths` overload in your tsconfig like this: [`"paths":{"redux-thunk":["typings/redux-thunk"]}`](./playground/tsconfig.json)._ ```tsx const thunkAsyncAction = () => async (dispatch: Dispatch): Promise => { // dispatch actions, return Promise, etc. } const mapDispatchToProps = (dispatch: Dispatch) => bindActionCreators( { thunkAsyncAction, }, dispatch ); type DispatchProps = ReturnType; // { thunkAsyncAction: () => Promise; } /* Without "bindActionCreators" fix signature will be the same as the original "unbound" thunk function: */ // { thunkAsyncAction: () => (dispatch: Dispatch) => Promise; } ``` [⇧ back to top](#table-of-contents) --- # Configuration & Dev Tools ## Common Npm Scripts > Common TS-related npm scripts shared across projects ```json "prettier": "prettier --list-different 'src/**/*.ts' || (echo '\nPlease fix code formatting by running:\nnpm run prettier:fix\n'; exit 1)", "prettier:fix": "prettier --write 'src/**/*.ts'", "lint": "eslint ./src --ext .js,.jsx,.ts,.tsx", "tsc": "tsc -p ./ --noEmit", "tsc:watch": "tsc -p ./ --noEmit -w", "test": "jest --config jest.config.json", "test:watch": "jest --config jest.config.json --watch", "test:update": "jest --config jest.config.json -u" "ci-check": "npm run prettier && npm run lint && npm run tsc && npm run test", ``` [⇧ back to top](#table-of-contents) ## tsconfig.json We have recommended `tsconfig.json` that you can easily add to your project thanks to [`react-redux-typescript-scripts`](https://github.com/piotrwitek/react-redux-typescript-scripts) package. ::expander='playground/tsconfig.json':: [⇧ back to top](#table-of-contents) ## TSLib This library will cut down on your bundle size, thanks to using external runtime helpers instead of adding them per each file. > > Installation `npm i tslib` Then add this to your `tsconfig.json`: ```ts "compilerOptions": { "importHelpers": true } ``` [⇧ back to top](#table-of-contents) ## ESLint We have recommended config that will automatically add a parser & plugin for TypeScript thanks to [`react-redux-typescript-scripts`](https://github.com/piotrwitek/react-redux-typescript-scripts) package. > > Installation `npm i -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin` ### .eslintrc.js ::expander='playground/.eslintrc.js':: [⇧ back to top](#table-of-contents) ## Jest > > Installation `npm i -D jest ts-jest @types/jest` ### jest.config.json ::expander='configs/jest.config.json':: ### jest.stubs.js ::expander='configs/jest.stubs.js':: [⇧ back to top](#table-of-contents) ## Style Guides ### [react-styleguidist](https://github.com/styleguidist/react-styleguidist) [⟩⟩⟩ styleguide.config.js](/playground/styleguide.config.js) [⟩⟩⟩ demo](https://piotrwitek.github.io/react-redux-typescript-guide/) [⇧ back to top](#table-of-contents) --- # FAQ ## Ambient Modules ### Imports in ambient modules For type augmentation imports should stay outside of module declaration. ```ts import { Operator } from 'rxjs/Operator'; import { Observable } from 'rxjs/Observable'; declare module 'rxjs/Subject' { interface Subject { lift(operator: Operator): Observable; } } ``` When creating 3rd party type-definitions all the imports should be kept inside the module declaration, otherwise it will be treated as augmentation and show error ```ts declare module "react-custom-scrollbars" { import * as React from "react"; export interface positionValues { ... ``` [⇧ back to top](#table-of-contents) ## Type-Definitions ### Missing type-definitions error if you cannot find types for a third-party module you can provide your own types or disable type-checking for this module using [Shorthand Ambient Modules](https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Modules.md#shorthand-ambient-modules) ::codeblock='playground/typings/modules.d.ts':: ### Using custom `d.ts` files for npm modules If you want to use an alternative (customized) type-definitions for some npm module (that usually comes with it's own type-definitions), you can do it by adding an override in `paths` compiler option. ```ts { "compilerOptions": { "baseUrl": ".", "paths": { "redux": ["typings/redux"], // use an alternative type-definitions instead of the included one ... }, ..., } } ``` [⇧ back to top](#table-of-contents) ## Type Augmentation Strategies to fix issues coming from external type-definitions files (*.d.ts) ### Augmenting library internal declarations - using relative import ```ts // added missing autoFocus Prop on Input component in "antd@2.10.0" npm package declare module '../node_modules/antd/lib/input/Input' { export interface InputProps { autoFocus?: boolean; } } ``` ### Augmenting library public declarations - using node_modules import ```ts // fixed broken public type-definitions in "rxjs@5.4.1" npm package import { Operator } from 'rxjs/Operator'; import { Observable } from 'rxjs/Observable'; declare module 'rxjs/Subject' { interface Subject { lift(operator: Operator): Observable; } } ``` > More advanced scenarios for working with vendor type-definitions can be found here [Official TypeScript Docs](https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Modules.md#working-with-other-javascript-libraries) [⇧ back to top](#table-of-contents) ## Misc ### - should I still use React.PropTypes in TS? No. With TypeScript, using PropTypes is an unnecessary overhead. When declaring Props and State interfaces, you will get complete intellisense and design-time safety with static type checking. This way you'll be safe from runtime errors and you will save a lot of time on debugging. Additional benefit is an elegant and standardized method of documenting your component public API in the source code. [⇧ back to top](#table-of-contents) ### - when to use `interface` declarations and when `type` aliases? From practical side, using `interface` declaration will create an identity (interface name) in compiler errors, on the contrary `type` aliases doesn't create an identity and will be unwinded to show all the properties and nested types it consists of. Although I prefer to use `type` most of the time there are some places this can become too noisy when reading compiler errors and that's why I like to leverage this distinction to hide some of not so important type details in errors using interfaces identity. Related `ts-lint` rule: [⇧ back to top](#table-of-contents) ### - what's better default or named exports? A common flexible solution is to use module folder pattern, because you can leverage both named and default import when you see fit. With this solution you'll achieve better encapsulation and be able to safely refactor internal naming and folders structure without breaking your consumer code: ```ts // 1. create your component files (`select.tsx`) using default export in some folder: // components/select.tsx const Select: React.FC = (props) => { ... export default Select; // 2. in this folder create an `index.ts` file that will re-export components with named exports: // components/index.ts export { default as Select } from './select'; ... // 3. now you can import your components in both ways, with named export (better encapsulation) or using default export (internal access): // containers/container.tsx import { Select } from '@src/components'; or import Select from '@src/components/select'; ... ``` [⇧ back to top](#table-of-contents) ### - how to best initialize class instance or static properties? Prefered modern syntax is to use class Property Initializers ```tsx class ClassCounterWithInitialCount extends React.Component { // default props using Property Initializers static defaultProps: DefaultProps = { className: 'default-class', initialCount: 0, }; // initial state using Property Initializers state: State = { count: this.props.initialCount, }; ... } ``` [⇧ back to top](#table-of-contents) ### - how to best declare component handler functions? Prefered modern syntax is to use Class Fields with arrow functions ```tsx class ClassCounter extends React.Component { // handlers using Class Fields with arrow functions handleIncrement = () => { this.setState({ count: this.state.count + 1 }); }; ... } ``` [⇧ back to top](#table-of-contents) --- # Tutorials & Articles > Curated list of relevant in-depth tutorials Higher-Order Components: - [⇧ back to top](#table-of-contents) --- # Contributors Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): | [
Piotrek Witek](https://github.com/piotrwitek)
[💻](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=piotrwitek "Code") [📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=piotrwitek "Documentation") [🤔](#ideas-piotrwitek "Ideas, Planning, & Feedback") [👀](#review-piotrwitek "Reviewed Pull Requests") [💬](#question-piotrwitek "Answering Questions") | [
Kazz Yokomizo](https://github.com/kazup01)
[💵](#financial-kazup01 "Financial") [🔍](#fundingFinding-kazup01 "Funding Finding") | [
Jake Boone](https://github.com/jakeboone02)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=jakeboone02 "Documentation") | [
Amit Dahan](https://github.com/amitdahan)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=amitdahan "Documentation") | [
gulderov](https://github.com/gulderov)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=gulderov "Documentation") | [
Erik Pearson](https://github.com/emp823)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=emp823 "Documentation") | [
Bryan Mason](https://github.com/flymason)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=flymason "Documentation") | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | [
Jakub Chodorowicz](http://www.jakub.chodorowicz.pl/)
[💻](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=chodorowicz "Code") | [
Oleg Maslov](https://github.com/mleg)
[🐛](https://github.com/piotrwitek/react-redux-typescript-guide/issues?q=author%3Amleg "Bug reports") | [
Aaron Westbrook](https://github.com/awestbro)
[🐛](https://github.com/piotrwitek/react-redux-typescript-guide/issues?q=author%3Aawestbro "Bug reports") | [
Peter Blazejewicz](http://www.linkedin.com/in/peterblazejewicz)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=peterblazejewicz "Documentation") | [
Solomon White](https://github.com/rubysolo)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=rubysolo "Documentation") | [
Levi Rocha](https://github.com/pino)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=pino "Documentation") | [
Sudachi-kun](http://cloudnative.co.jp)
[💵](#financial-loadbalance-sudachi-kun "Financial") | | [
Sosuke Suzuki](http://sosukesuzuki.github.io)
[💻](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=sosukesuzuki "Code") | [
Tom Rathbone](https://github.com/chillitom)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=chillitom "Documentation") | [
Arshad Kazmi](https://arshadkazmi42.github.io/)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=arshadkazmi42 "Documentation") | [
JeongUkJae](https://jeongukjae.github.io)
[📖](https://github.com/piotrwitek/react-redux-typescript-guide/commits?author=JeongUkJae "Documentation") | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! --- MIT License Copyright (c) 2017 Piotr Witek () ================================================ FILE: configs/jest.config.json ================================================ { "verbose": true, "transform": { ".(ts|tsx)": "ts-jest" }, "testRegex": "(/spec/.*|\\.(test|spec))\\.(ts|tsx|js)$", "moduleFileExtensions": ["ts", "tsx", "js"], "moduleNameMapper": { "^Components/(.*)": "./src/components/$1" }, "globals": { "window": {}, "ts-jest": { "tsConfig": "./tsconfig.json" } }, "setupFiles": ["./jest.stubs.js"], "testURL": "http://localhost/" } ================================================ FILE: configs/jest.stubs.js ================================================ // Global/Window object Stubs for Jest window.matchMedia = window.matchMedia || function () { return { matches: false, addListener: function () { }, removeListener: function () { }, }; }; window.requestAnimationFrame = function (callback) { setTimeout(callback); }; window.localStorage = { getItem: function () { }, setItem: function () { }, }; Object.values = () => []; ================================================ FILE: docs/build/0.6e57cfb5.js ================================================ webpackJsonp([0],{409:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=n.n(r),o=n(1),s=n.n(o),a=n(113),l=n.n(a),c=n(411),u=(n.n(c),n(412)),d=(n.n(u),Object.assign||function(e){for(var t=1;t=15&&(d=!1,l=!0);var w=y&&(c||d&&(null==x||x<12.11)),S=n||s&&a>=9;function classTest(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var k=function(e,t){var n=e.className,r=classTest(t).exec(n);if(r){var i=n.slice(r.index+r[0].length);e.className=n.slice(0,r.index)+(i?r[1]+i:"")}};function removeChildren(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function removeChildrenAndAdd(e,t){return removeChildren(e).appendChild(t)}function elt(e,t,n,r){var i=document.createElement(e);if(n&&(i.className=n),r&&(i.style.cssText=r),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o=t)return s+(t-o);s+=a-o,s+=n-s%n,o=a+1}}var T=function(){this.id=null};T.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};function indexOf(e,t){for(var n=0;n=t)return r+Math.min(s,t-i);if(i+=o-r,r=o+1,(i+=n-i%n)>=t)return r}}var H=[""];function spaceStr(e){for(;H.length<=e;)H.push(lst(H)+" ");return H[e]}function lst(e){return e[e.length-1]}function map(e,t){for(var n=[],r=0;r"€"&&(e.toUpperCase()!=e.toLowerCase()||W.test(e))}function isWordChar(e,t){return t?!!(t.source.indexOf("\\w")>-1&&isWordCharBasic(e))||t.test(e):isWordCharBasic(e)}function isEmpty(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var E=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function isExtendingChar(e){return e.charCodeAt(0)>=768&&E.test(e)}function skipExtendingChars(e,t,n){for(;(n<0?t>0:tn?-1:1;;){if(t==n)return t;var i=(t+n)/2,o=r<0?Math.ceil(i):Math.floor(i);if(o==t)return e(o)?t:n;e(o)?n=o:t=o+r}}function getLine(e,t){if((t-=e.first)<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],o=i.chunkSize();if(t=e.first&&tn?Pos(n,getLine(e,n).text.length):function clipToLen(e,t){var n=e.ch;return null==n||n>t?Pos(e.line,t):n<0?Pos(e.line,0):e}(t,getLine(e,t.line).text.length)}function clipPosArray(e,t){for(var n=[],r=0;r=t:o.to>t);(r||(r=[])).push(new MarkedSpan(s,o.from,a?null:o.to))}}return r}(n,i,s),l=function markedSpansAfter(e,t,n){var r;if(e)for(var i=0;i=t:o.to>t)||o.from==t&&"bookmark"==s.type&&(!n||o.marker.insertLeft)){var a=null==o.from||(s.inclusiveLeft?o.from<=t:o.from0&&a)for(var b=0;b=0&&d<=0||u<=0&&d>=0)&&(u<=0&&(l.marker.inclusiveRight&&i.inclusiveLeft?cmp(c.to,n)>=0:cmp(c.to,n)>0)||u>=0&&(l.marker.inclusiveRight&&i.inclusiveLeft?cmp(c.from,r)<=0:cmp(c.from,r)<0)))return!0}}}function visualLine(e){for(var t;t=collapsedSpanAtStart(e);)e=t.find(-1,!0).line;return e}function visualLineNo(e,t){var n=getLine(e,t),r=visualLine(n);return n==r?t:lineNo(r)}function visualLineEndNo(e,t){if(t>e.lastLine())return t;var n,r=getLine(e,t);if(!lineIsHidden(e,r))return t;for(;n=collapsedSpanAtEnd(r);)r=n.find(1,!0).line;return lineNo(r)+1}function lineIsHidden(e,t){var n=F&&t.markedSpans;if(n)for(var r=void 0,i=0;it.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)})}var B=null;function getBidiPartAt(e,t,n){var r;B=null;for(var i=0;it)return i;o.to==t&&(o.from!=o.to&&"before"==n?r=i:B=i),o.from==t&&(o.from!=o.to&&"before"!=n?r=i:B=i)}return null!=r?r:B}var z=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";var n=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,r=/[stwN]/,i=/[LRr]/,o=/[Lb1n]/,s=/[1n]/;function BidiSpan(e,t,n){this.level=e,this.from=t,this.to=n}return function(a,l){var c="ltr"==l?"L":"R";if(0==a.length||"ltr"==l&&!n.test(a))return!1;for(var u=a.length,d=[],p=0;p-1&&(r[t]=i.slice(0,o).concat(i.slice(o+1)))}}}function signal(e,t){var n=getHandlers(e,t);if(n.length)for(var r=Array.prototype.slice.call(arguments,2),i=0;i0}function eventMixin(e){e.prototype.on=function(e,t){V(this,e,t)},e.prototype.off=function(e,t){off(this,e,t)}}function e_preventDefault(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function e_stopPropagation(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function e_defaultPrevented(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function e_stop(e){e_preventDefault(e),e_stopPropagation(e)}function e_target(e){return e.target||e.srcElement}function e_button(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),y&&e.ctrlKey&&1==t&&(t=3),t}var U,j=function(){if(s&&a<9)return!1;var e=elt("div");return"draggable"in e||"dragDrop"in e}();function zeroWidthElement(e){if(null==U){var t=elt("span","​");removeChildrenAndAdd(e,elt("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(U=t.offsetWidth<=1&&t.offsetHeight>2&&!(s&&a<8))}var n=U?elt("span","​"):elt("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}var G;function hasBadBidiRects(e){if(null!=G)return G;var t=removeChildrenAndAdd(e,document.createTextNode("AخA")),n=L(t,0,1).getBoundingClientRect(),r=L(t,1,2).getBoundingClientRect();return removeChildren(e),!(!n||n.left==n.right)&&(G=r.right-n.right<3)}var K=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,n=[],r=e.length;t<=r;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),s=o.indexOf("\r");-1!=s?(n.push(o.slice(0,s)),t+=s+1):(n.push(o),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},_=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(e){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(e){}return!(!t||t.parentElement()!=e)&&0!=t.compareEndPoints("StartToEnd",t)},$=function(){var e=elt("div");return"oncopy"in e||(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),q=null;var X={},Y={};function resolveMode(e){if("string"==typeof e&&Y.hasOwnProperty(e))e=Y[e];else if(e&&"string"==typeof e.name&&Y.hasOwnProperty(e.name)){var t=Y[e.name];"string"==typeof t&&(t={name:t}),(e=createObj(t,e)).name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return resolveMode("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return resolveMode("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function getMode(e,t){t=resolveMode(t);var n=X[t.name];if(!n)return getMode(e,"text/plain");var r=n(e,t);if(Z.hasOwnProperty(t.name)){var i=Z[t.name];for(var o in i)i.hasOwnProperty(o)&&(r.hasOwnProperty(o)&&(r["_"+o]=r[o]),r[o]=i[o])}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var s in t.modeProps)r[s]=t.modeProps[s];return r}var Z={};function extendMode(e,t){copyObj(t,Z.hasOwnProperty(e)?Z[e]:Z[e]={})}function copyState(e,t){if(!0===t)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n}function innerMode(e,t){for(var n;e.innerMode&&(n=e.innerMode(t))&&n.mode!=e;)t=n.state,e=n.mode;return n||{mode:e,state:t}}function startState(e,t,n){return!e.startState||e.startState(t,n)}var Q=function(e,t,n){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=n};Q.prototype.eol=function(){return this.pos>=this.string.length},Q.prototype.sol=function(){return this.pos==this.lineStart},Q.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Q.prototype.next=function(){if(this.post},Q.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Q.prototype.skipToEnd=function(){this.pos=this.string.length},Q.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Q.prototype.backUp=function(e){this.pos-=e},Q.prototype.column=function(){return this.lastColumnPos0?null:(r&&!1!==t&&(this.pos+=r[0].length),r)}var i=function(e){return n?e.toLowerCase():e};if(i(this.string.substr(this.pos,e.length))==i(e))return!1!==t&&(this.pos+=e.length),!0},Q.prototype.current=function(){return this.string.slice(this.start,this.pos)},Q.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Q.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Q.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var J=function(e,t){this.state=e,this.lookAhead=t},ee=function(e,t,n,r){this.state=t,this.doc=e,this.line=n,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};ee.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},ee.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},ee.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},ee.fromSaved=function(e,t,n){return t instanceof J?new ee(e,copyState(e.mode,t.state),n,t.lookAhead):new ee(e,copyState(e.mode,t),n)},ee.prototype.save=function(e){var t=!1!==e?copyState(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new J(t,this.maxLookAhead):t};function highlightLine(e,t,n,r){var i=[e.state.modeGen],o={};runMode(e,t.text,e.doc.mode,n,function(e,t){return i.push(e,t)},o,r);for(var s=n.state,a=function(r){n.baseTokens=i;var a=e.state.overlays[r],l=1,c=0;n.state=!0,runMode(e,t.text,a.mode,n,function(e,t){for(var n=l;ce&&i.splice(l,1,e,i[l+1],r),l+=2,c=Math.min(e,r)}if(t)if(a.opaque)i.splice(n,l-n,e,"overlay "+t),l=n+2;else for(;ne.options.maxHighlightLength&©State(e.doc.mode,r.state),o=highlightLine(e,t,r);i&&(r.state=i),t.stateAfter=r.save(!i),t.styles=o.styles,o.classes?t.styleClasses=o.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function getContextBefore(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return new ee(r,!0,t);var o=function findStartLine(e,t,n){for(var r,i,o=e.doc,s=n?-1:t-(e.doc.mode.innerMode?1e3:100),a=t;a>s;--a){if(a<=o.first)return o.first;var l=getLine(o,a-1),c=l.stateAfter;if(c&&(!n||a+(c instanceof J?c.lookAhead:0)<=o.modeFrontier))return a;var u=countColumn(l.text,null,e.options.tabSize);(null==i||r>u)&&(i=a-1,r=u)}return i}(e,t,n),s=o>r.first&&getLine(r,o-1).stateAfter,a=s?ee.fromSaved(r,s,o):new ee(r,startState(r.mode),o);return r.iter(o,t,function(n){processLine(e,n.text,a);var r=a.line;n.stateAfter=r==t-1||r%5==0||r>=i.viewFrom&&rt.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}var te=function(e,t,n){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=n};function takeToken(e,t,n,r){var i,o,s=e.doc,a=s.mode,l=getLine(s,(t=clipPos(s,t)).line),c=getContextBefore(e,t.line,n),u=new Q(l.text,e.options.tabSize,c);for(r&&(o=[]);(r||u.pose.options.maxHighlightLength?(a=!1,s&&processLine(e,t,r,d.pos),d.pos=t.length,l=null):l=extractLineClasses(readToken(n,d,r.state,p),o),p){var h=p[0].name;h&&(l="m-"+(l?h+" "+l:h))}if(!a||u!=l){for(;c1&&!/ /.test(e))return e;for(var n=t,r="",i=0;ic&&d.from<=c);p++);if(d.to>=u)return e(n,r,i,o,s,a,l);e(n,r.slice(0,d.to-c),i,o,null,a,l),o=null,r=r.slice(d.to-c),c=d.to}}}function buildCollapsedSpan(e,t,n,r){var i=!r&&n.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!r&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",n.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t,e.trailingSpace=!1}function insertLineContent(e,t,n){var r=e.markedSpans,i=e.text,o=0;if(r)for(var s,a,l,c,u,d,p,h=i.length,f=0,g=1,m="",v=0;;){if(v==f){l=c=u=d=a="",p=null,v=1/0;for(var y=[],b=void 0,C=0;Cf||w.collapsed&&x.to==f&&x.from==f)?(null!=x.to&&x.to!=f&&v>x.to&&(v=x.to,c=""),w.className&&(l+=" "+w.className),w.css&&(a=(a?a+";":"")+w.css),w.startStyle&&x.from==f&&(u+=" "+w.startStyle),w.endStyle&&x.to==v&&(b||(b=[])).push(w.endStyle,x.to),w.title&&!d&&(d=w.title),w.collapsed&&(!p||compareCollapsedMarkers(p.marker,w)<0)&&(p=x)):x.from>f&&v>x.from&&(v=x.from)}if(b)for(var S=0;S=h)break;for(var L=Math.min(h,v);;){if(m){var M=f+m.length;if(!p){var T=M>L?m.slice(0,L-f):m;t.addToken(t,T,s?s+l:l,u,f+T.length==v?c:"",d,a)}if(M>=L){m=m.slice(L-f),f=L;break}f=M,u=""}m=i.slice(o,o=n[g++]),s=interpretTokenStyle(n[g++],t.cm.options)}}else for(var O=1;On)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function measureChar(e,t,n,r){return measureCharPrepared(e,prepareMeasureForLine(e,t),n,r)}function findViewForLine(e,t){if(t>=e.display.viewFrom&&t=n.lineN&&t2&&o.push((l.bottom+c.top)/2-n.top)}}o.push(n.bottom-n.top)}}(e,t.view,t.rect),t.hasHeights=!0),(o=function measureCharInner(e,t,n,r){var i,o=nodeAndOffsetInLineMap(t.map,n,r),l=o.node,c=o.start,u=o.end,d=o.collapse;if(3==l.nodeType){for(var p=0;p<4;p++){for(;c&&isExtendingChar(t.line.text.charAt(o.coverStart+c));)--c;for(;o.coverStart+u1}(e))return t;var n=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*n,right:t.right*n,top:t.top*r,bottom:t.bottom*r}}(e.display.measure,i))}else{c>0&&(d=r="right");var h;i=e.options.lineWrapping&&(h=l.getClientRects()).length>1?h["right"==r?h.length-1:0]:l.getBoundingClientRect()}if(s&&a<9&&!c&&(!i||!i.left&&!i.right)){var f=l.parentNode.getClientRects()[0];i=f?{left:f.left,right:f.left+charWidth(e.display),top:f.top,bottom:f.bottom}:ae}for(var g=i.top-t.rect.top,m=i.bottom-t.rect.top,v=(g+m)/2,y=t.view.measure.heights,b=0;bt)&&(i=(o=l-a)-1,t>=l&&(s="right")),null!=i){if(r=e[c+2],a==l&&n==(r.insertLeft?"left":"right")&&(s=n),"left"==n&&0==i)for(;c&&e[c-2]==e[c-3]&&e[c-1].insertLeft;)r=e[2+(c-=3)],s="left";if("right"==n&&i==l-a)for(;c=0&&(n=e[i]).left==n.right;i--);return n}function clearLineMeasurementCacheFor(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t=r.text.length?(a=r.text.length,l="before"):a<=0&&(a=0,l="after"),!s)return get("before"==l?a-1:a,"before"==l);function getBidi(e,t,n){var r=1==s[t].level;return get(n?e-1:e,r!=n)}var c=getBidiPartAt(s,a,l),u=B,d=getBidi(a,c,"before"==l);return null!=u&&(d.other=getBidi(a,u,"before"!=l)),d}function estimateCoords(e,t){var n=0;t=clipPos(e.doc,t),e.options.lineWrapping||(n=charWidth(e.display)*t.ch);var r=getLine(e.doc,t.line),i=heightAtLine(r)+paddingTop(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function PosWithInfo(e,t,n,r,i){var o=Pos(e,t,n);return o.xRel=i,r&&(o.outside=!0),o}function coordsChar(e,t,n){var r=e.doc;if((n+=e.display.viewOffset)<0)return PosWithInfo(r.first,0,null,!0,-1);var i=lineAtHeight(r,n),o=r.first+r.size-1;if(i>o)return PosWithInfo(r.first+r.size-1,getLine(r,o).text.length,null,!0,1);t<0&&(t=0);for(var s=getLine(r,i);;){var a=coordsCharInner(e,s,i,t,n),l=collapsedSpanAtEnd(s),c=l&&l.find(0,!0);if(!l||!(a.ch>c.from.ch||a.ch==c.from.ch&&a.xRel>0))return a;i=lineNo(s=c.to.line)}}function wrappedLineExtent(e,t,n,r){r-=widgetTopHeight(t);var i=t.text.length,o=findFirst(function(t){return measureCharPrepared(e,n,t-1).bottom<=r},i,0);return{begin:o,end:i=findFirst(function(t){return measureCharPrepared(e,n,t).top>r},o,i)}}function wrappedLineExtentChar(e,t,n,r){n||(n=prepareMeasureForLine(e,t));return wrappedLineExtent(e,t,n,intoCoordSystem(e,t,measureCharPrepared(e,n,r),"line").top)}function boxIsAfter(e,t,n,r){return!(e.bottom<=n)&&(e.top>n||(r?e.left:e.right)>t)}function coordsCharInner(e,t,n,r,i){i-=heightAtLine(t);var o=prepareMeasureForLine(e,t),s=widgetTopHeight(t),a=0,l=t.text.length,c=!0,u=getOrder(t,e.doc.direction);if(u){var d=(e.options.lineWrapping?function coordsBidiPartWrapped(e,t,n,r,i,o,s){var a=wrappedLineExtent(e,t,r,s),l=a.begin,c=a.end;/\s/.test(t.text.charAt(c-1))&&c--;for(var u=null,d=null,p=0;p=c||h.to<=l)){var f=1!=h.level,g=measureCharPrepared(e,r,f?Math.min(c,h.to)-1:Math.max(l,h.from)).right,m=gm)&&(u=h,d=m)}}u||(u=i[i.length-1]);u.fromc&&(u={from:u.from,to:c,level:u.level});return u}:function coordsBidiPart(e,t,n,r,i,o,s){var a=findFirst(function(a){var l=i[a],c=1!=l.level;return boxIsAfter(cursorCoords(e,Pos(n,c?l.to:l.from,c?"before":"after"),"line",t,r),o,s,!0)},0,i.length-1),l=i[a];if(a>0){var c=1!=l.level,u=cursorCoords(e,Pos(n,c?l.from:l.to,c?"after":"before"),"line",t,r);boxIsAfter(u,o,s,!0)&&u.top>s&&(l=i[a-1])}return l})(e,t,n,o,u,r,i);a=(c=1!=d.level)?d.from:d.to-1,l=c?d.to:d.from-1}var p,h,f=null,g=null,m=findFirst(function(t){var n=measureCharPrepared(e,o,t);return n.top+=s,n.bottom+=s,!!boxIsAfter(n,r,i,!1)&&(n.top<=i&&n.left<=r&&(f=t,g=n),!0)},a,l),v=!1;if(g){var y=r-g.left=C.bottom}return PosWithInfo(n,m=skipExtendingChars(t.text,m,1),h,v,r-p)}var le;function textHeight(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==le){le=elt("pre");for(var t=0;t<49;++t)le.appendChild(document.createTextNode("x")),le.appendChild(elt("br"));le.appendChild(document.createTextNode("x"))}removeChildrenAndAdd(e.measure,le);var n=le.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),removeChildren(e.measure),n||1}function charWidth(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=elt("span","xxxxxxxxxx"),n=elt("pre",[t]);removeChildrenAndAdd(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function getDimensions(e){for(var t=e.display,n={},r={},i=t.gutters.clientLeft,o=t.gutters.firstChild,s=0;o;o=o.nextSibling,++s)n[e.options.gutters[s]]=o.offsetLeft+o.clientLeft+i,r[e.options.gutters[s]]=o.clientWidth;return{fixedPos:compensateForHScroll(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function compensateForHScroll(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function estimateHeight(e){var t=textHeight(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/charWidth(e.display)-3);return function(i){if(lineIsHidden(e.doc,i))return 0;var o=0;if(i.widgets)for(var s=0;s=e.display.viewTo)return null;if((t-=e.display.viewFrom)<0)return null;for(var n=e.display.view,r=0;r=e.display.viewTo||a.to().linet||t==n&&s.to==t)&&(r(Math.max(s.from,t),Math.min(s.to,n),1==s.level?"rtl":"ltr",o),i=!0)}i||r(t,n,"ltr")}(p,n||0,null==r?d:r,function(e,t,i,u){var h="ltr"==i,f=coords(e,h?"left":"right"),g=coords(t-1,h?"right":"left"),m=null==n&&0==e,v=null==r&&t==d,y=0==u,b=!p||u==p.length-1;if(g.top-f.top<=3){var C=(c?v:m)&&b,x=(c?m:v)&&y?a:(h?f:g).left,w=C?l:(h?g:f).right;add(x,f.top,w-x,f.bottom)}else{var S,k,L,M;h?(S=c&&m&&y?a:f.left,k=c?l:wrapX(e,i,"before"),L=c?a:wrapX(t,i,"after"),M=c&&v&&b?l:g.right):(S=c?wrapX(e,i,"before"):a,k=!c&&m&&y?l:f.right,L=!c&&v&&b?a:g.left,M=c?wrapX(t,i,"after"):l),add(S,f.top,k-S,f.bottom),f.bottom0?t.blinker=setInterval(function(){return t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function ensureFocus(e){e.state.focused||(e.display.input.focus(),onFocus(e))}function delayBlurEvent(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,onBlur(e))},100)}function onFocus(e,t){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(signal(e,"focus",e,t),e.state.focused=!0,addClass(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),l&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),restartBlink(e))}function onBlur(e,t){e.state.delayingBlurEvent||(e.state.focused&&(signal(e,"blur",e,t),e.state.focused=!1,k(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function updateHeightsInViewport(e){for(var t=e.display,n=t.lineDiv.offsetTop,r=0;r.005||u<-.005)&&(updateLineHeight(i.line,o),updateWidgetHeight(i.line),i.rest))for(var d=0;d=s&&(o=lineAtHeight(t,heightAtLine(getLine(t,l))-e.wrapper.clientHeight),s=l)}return{from:o,to:Math.max(s,o+1)}}function alignHorizontally(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var r=compensateForHScroll(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=r+"px",s=0;so&&(t.bottom=t.top+o);var a=e.doc.height+paddingVert(n),l=t.topa-r;if(t.topi+o){var u=Math.min(t.top,(c?a:t.bottom)-o);u!=i&&(s.scrollTop=u)}var d=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:n.scroller.scrollLeft,p=displayWidth(e)-(e.options.fixedGutter?n.gutters.offsetWidth:0),h=t.right-t.left>p;return h&&(t.right=t.left+p),t.left<10?s.scrollLeft=0:t.leftp+d-3&&(s.scrollLeft=t.right+(h?0:10)-p),s}function addToScrollTop(e,t){null!=t&&(resolveScrollToPos(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function ensureCursorVisible(e){resolveScrollToPos(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function scrollToCoords(e,t,n){null==t&&null==n||resolveScrollToPos(e),null!=t&&(e.curOp.scrollLeft=t),null!=n&&(e.curOp.scrollTop=n)}function resolveScrollToPos(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;scrollToCoordsRange(e,estimateCoords(e,t.from),estimateCoords(e,t.to),t.margin)}}function scrollToCoordsRange(e,t,n,r){var i=calculateScrollPos(e,{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top)-r,right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)+r});scrollToCoords(e,i.scrollLeft,i.scrollTop)}function updateScrollTop(e,t){Math.abs(e.doc.scrollTop-t)<2||(n||updateDisplaySimple(e,{top:t}),setScrollTop(e,t,!0),n&&updateDisplaySimple(e),startWorker(e,100))}function setScrollTop(e,t,n){t=Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t),(e.display.scroller.scrollTop!=t||n)&&(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function setScrollLeft(e,t,n,r){t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r||(e.doc.scrollLeft=t,alignHorizontally(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function measureForScrollbars(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+paddingVert(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?n:0,docHeight:r,scrollHeight:r+scrollGap(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}var ce=function(e,t,n){this.cm=n;var r=this.vert=elt("div",[elt("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=elt("div",[elt("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(r),e(i),V(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),V(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,s&&a<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};ce.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,n=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var i=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=n?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(n?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+o)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(0==r&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:n?r:0,bottom:t?r:0}},ce.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},ce.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},ce.prototype.zeroWidthHack=function(){var e=y&&!h?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new T,this.disableVert=new T},ce.prototype.enableZeroWidthBar=function(e,t,n){e.style.pointerEvents="auto";t.set(1e3,function maybeDisable(){var r=e.getBoundingClientRect();("vert"==n?document.elementFromPoint(r.right-1,(r.top+r.bottom)/2):document.elementFromPoint((r.right+r.left)/2,r.bottom-1))!=e?e.style.pointerEvents="none":t.set(1e3,maybeDisable)})},ce.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var ue=function(){};ue.prototype.update=function(){return{bottom:0,right:0}},ue.prototype.setScrollLeft=function(){},ue.prototype.setScrollTop=function(){},ue.prototype.clear=function(){};function updateScrollbars(e,t){t||(t=measureForScrollbars(e));var n=e.display.barWidth,r=e.display.barHeight;updateScrollbarsInner(e,t);for(var i=0;i<4&&n!=e.display.barWidth||r!=e.display.barHeight;i++)n!=e.display.barWidth&&e.options.lineWrapping&&updateHeightsInViewport(e),updateScrollbarsInner(e,measureForScrollbars(e)),n=e.display.barWidth,r=e.display.barHeight}function updateScrollbarsInner(e,t){var n=e.display,r=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=r.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=r.bottom)+"px",n.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=r.bottom+"px",n.scrollbarFiller.style.width=r.right+"px"):n.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r.bottom+"px",n.gutterFiller.style.width=t.gutterWidth+"px"):n.gutterFiller.style.display=""}var de={native:ce,null:ue};function initScrollbars(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&k(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new de[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),V(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,n){"horizontal"==n?setScrollLeft(e,t):updateScrollTop(e,t)},e),e.display.scrollbars.addClass&&addClass(e.display.wrapper,e.display.scrollbars.addClass)}var pe=0;function startOperation(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++pe},function pushOperation(e){oe?oe.ops.push(e):e.ownsGroup=oe={ops:[e],delayedCallbacks:[]}}(e.curOp)}function endOperation(e){!function finishOperation(e,t){var n=e.ownsGroup;if(n)try{!function fireCallbacksForOps(e){var t=e.delayedCallbacks,n=0;do{for(;n=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new he(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function endOperation_R2(e){var t=e.cm,n=t.display;e.updatedDisplay&&updateHeightsInViewport(t),e.barMeasure=measureForScrollbars(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=measureChar(t,n.maxLine,n.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+e.adjustWidthTo+scrollGap(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-displayWidth(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection())}function endOperation_W2(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!f){var o=elt("div","​",null,"position: absolute;\n top: "+(t.top-n.viewOffset-paddingTop(e.display))+"px;\n height: "+(t.bottom-t.top+scrollGap(e)+n.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}(t,function scrollPosIntoView(e,t,n,r){null==r&&(r=0);var i;e.options.lineWrapping||t!=n||(n="before"==(t=t.ch?Pos(t.line,"before"==t.sticky?t.ch-1:t.ch,"after"):t).sticky?Pos(t.line,t.ch+1,"before"):t);for(var o=0;o<5;o++){var s=!1,a=cursorCoords(e,t),l=n&&n!=t?cursorCoords(e,n):a,c=calculateScrollPos(e,i={left:Math.min(a.left,l.left),top:Math.min(a.top,l.top)-r,right:Math.max(a.left,l.left),bottom:Math.max(a.bottom,l.bottom)+r}),u=e.doc.scrollTop,d=e.doc.scrollLeft;if(null!=c.scrollTop&&(updateScrollTop(e,c.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(s=!0)),null!=c.scrollLeft&&(setScrollLeft(e,c.scrollLeft),Math.abs(e.doc.scrollLeft-d)>1&&(s=!0)),!s)break}return i}(t,clipPos(r,e.scrollToPos.from),clipPos(r,e.scrollToPos.to),e.scrollToPos.margin))}var i=e.maybeHiddenMarkers,o=e.maybeUnhiddenMarkers;if(i)for(var s=0;st)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)F&&visualLineNo(e.doc,t)i.viewFrom?resetView(e):(i.viewFrom+=r,i.viewTo+=r);else if(t<=i.viewFrom&&n>=i.viewTo)resetView(e);else if(t<=i.viewFrom){var o=viewCuttingPoint(e,n,n+r,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=r):resetView(e)}else if(n>=i.viewTo){var s=viewCuttingPoint(e,t,t,-1);s?(i.view=i.view.slice(0,s.index),i.viewTo=s.lineN):resetView(e)}else{var a=viewCuttingPoint(e,t,t,-1),l=viewCuttingPoint(e,n,n+r,1);a&&l?(i.view=i.view.slice(0,a.index).concat(buildViewArray(e,a.lineN,l.lineN)).concat(i.view.slice(l.index)),i.viewTo+=r):resetView(e)}var c=i.externalMeasured;c&&(n=i.lineN&&t=r.viewTo)){var o=r.view[findViewIndex(e,t)];if(null!=o.node){var s=o.changes||(o.changes=[]);-1==indexOf(s,n)&&s.push(n)}}}function resetView(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function viewCuttingPoint(e,t,n,r){var i,o=findViewIndex(e,t),s=e.display.view;if(!F||n==e.doc.first+e.doc.size)return{index:o,lineN:n};for(var a=e.display.viewFrom,l=0;l0){if(o==s.length-1)return null;i=a+s[o].size-t,o++}else i=a-t;t+=i,n+=i}for(;visualLineNo(e.doc,n)!=n;){if(o==(r<0?0:s.length-1))return null;n+=r*s[o-(r<0?1:0)].size,o+=r}return{index:o,lineN:n}}function countDirtyView(e){for(var t=e.display.view,n=0,r=0;r=e.display.viewTo)){var n=+new Date+e.options.workTime,r=getContextBefore(e,t.highlightFrontier),i=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(r.line>=e.display.viewFrom){var s=o.styles,a=o.text.length>e.options.maxHighlightLength?copyState(t.mode,r.state):null,l=highlightLine(e,o,r,!0);a&&(r.state=a),o.styles=l.styles;var c=o.styleClasses,u=l.classes;u?o.styleClasses=u:c&&(o.styleClasses=null);for(var d=!s||s.length!=o.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),p=0;!d&&pn)return startWorker(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),i.length&&runInOp(e,function(){for(var t=0;t=n.viewFrom&&t.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==countDirtyView(e))return!1;maybeUpdateLineNumberWidth(e)&&(resetView(e),t.dims=getDimensions(e));var i=r.first+r.size,o=Math.max(t.visible.from-e.options.viewportMargin,r.first),s=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFroms&&n.viewTo-s<20&&(s=Math.min(i,n.viewTo)),F&&(o=visualLineNo(e.doc,o),s=visualLineEndNo(e.doc,s));var a=o!=n.viewFrom||s!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;!function adjustView(e,t,n){var r=e.display;0==r.view.length||t>=r.viewTo||n<=r.viewFrom?(r.view=buildViewArray(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=buildViewArray(e,t,r.viewFrom).concat(r.view):r.viewFromn&&(r.view=r.view.slice(0,findViewIndex(e,n)))),r.viewTo=n}(e,o,s),n.viewOffset=heightAtLine(getLine(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var c=countDirtyView(e);if(!a&&0==c&&!t.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var u=function selectionSnapshot(e){if(e.hasFocus())return null;var t=activeElt();if(!t||!contains(e.display.lineDiv,t))return null;var n={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&contains(e.display.lineDiv,r.anchorNode)&&(n.anchorNode=r.anchorNode,n.anchorOffset=r.anchorOffset,n.focusNode=r.focusNode,n.focusOffset=r.focusOffset)}return n}(e);return c>4&&(n.lineDiv.style.display="none"),function patchDisplay(e,t,n){var r=e.display,i=e.options.lineNumbers,o=r.lineDiv,s=o.firstChild;function rm(t){var n=t.nextSibling;return l&&y&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),n}for(var a=r.view,c=r.viewFrom,u=0;u-1&&(p=!1),updateLineForChanges(e,d,c,n)),p&&(removeChildren(d.lineNumber),d.lineNumber.appendChild(document.createTextNode(lineNumberFor(e.options,c)))),s=d.node.nextSibling}else{var h=buildLineElement(e,d,c,n);o.insertBefore(h,s)}c+=d.size}for(;s;)s=rm(s)}(e,n.updateLineNumbers,t.dims),c>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,function restoreSelection(e){if(e&&e.activeElt&&e.activeElt!=activeElt()&&(e.activeElt.focus(),e.anchorNode&&contains(document.body,e.anchorNode)&&contains(document.body,e.focusNode))){var t=window.getSelection(),n=document.createRange();n.setEnd(e.anchorNode,e.anchorOffset),n.collapse(!1),t.removeAllRanges(),t.addRange(n),t.extend(e.focusNode,e.focusOffset)}}(u),removeChildren(n.cursorDiv),removeChildren(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,a&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,startWorker(e,400)),n.updateLineNumbers=null,!0}function postUpdateDisplay(e,t){for(var n=t.viewport,r=!0;(r&&e.options.lineWrapping&&t.oldDisplayWidth!=displayWidth(e)||(n&&null!=n.top&&(n={top:Math.min(e.doc.height+paddingVert(e.display)-displayHeight(e),n.top)}),t.visible=visibleLines(e.display,e.doc,n),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&updateDisplayIfNeeded(e,t);r=!1){updateHeightsInViewport(e);var i=measureForScrollbars(e);updateSelection(e),updateScrollbars(e,i),setDocumentHeight(e,i),t.force=!1}t.signal(e,"update",e),e.display.viewFrom==e.display.reportedViewFrom&&e.display.viewTo==e.display.reportedViewTo||(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function updateDisplaySimple(e,t){var n=new he(e,t);if(updateDisplayIfNeeded(e,n)){updateHeightsInViewport(e),postUpdateDisplay(e,n);var r=measureForScrollbars(e);updateSelection(e),updateScrollbars(e,r),setDocumentHeight(e,r),n.finish()}}function updateGutterSpace(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function setDocumentHeight(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+scrollGap(e)+"px"}function updateGutters(e){var t=e.display.gutters,n=e.options.gutters;removeChildren(t);for(var r=0;r-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}var fe=0,ge=null;s?ge=-.53:n?ge=15:u?ge=-.7:p&&(ge=-1/3);function wheelEventDelta(e){var t=e.wheelDeltaX,n=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==n&&e.detail&&e.axis==e.VERTICAL_AXIS?n=e.detail:null==n&&(n=e.wheelDelta),{x:t,y:n}}function wheelEventPixels(e){var t=wheelEventDelta(e);return t.x*=ge,t.y*=ge,t}function onScrollWheel(e,t){var r=wheelEventDelta(t),i=r.x,o=r.y,s=e.display,a=s.scroller,c=a.scrollWidth>a.clientWidth,u=a.scrollHeight>a.clientHeight;if(i&&c||o&&u){if(o&&y&&l)e:for(var p=t.target,h=s.view;p!=a;p=p.parentNode)for(var f=0;f=0&&cmp(e,r.to())<=0)return n}return-1};var ve=function(e,t){this.anchor=e,this.head=t};ve.prototype.from=function(){return minPos(this.anchor,this.head)},ve.prototype.to=function(){return maxPos(this.anchor,this.head)},ve.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function normalizeSelection(e,t){var n=e[t];e.sort(function(e,t){return cmp(e.from(),t.from())}),t=indexOf(e,n);for(var r=1;r=0){var s=minPos(o.from(),i.from()),a=maxPos(o.to(),i.to()),l=o.empty()?i.from()==i.head:o.from()==o.head;r<=t&&--t,e.splice(--r,2,new ve(l?a:s,l?s:a))}}return new me(e,t)}function simpleSelection(e,t){return new me([new ve(e,t||e)],0)}function changeEnd(e){return e.text?Pos(e.from.line+e.text.length-1,lst(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function adjustForChange(e,t){if(cmp(e,t.from)<0)return e;if(cmp(e,t.to)<=0)return changeEnd(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=changeEnd(t).ch-t.to.ch),Pos(n,r)}function computeSelAfterChange(e,t){for(var n=[],r=0;r1&&e.remove(i.line+1,d-1),e.insert(i.line+1,f)}signalLater(e,"change",e,t)}function linkedDocs(e,t,n){!function propagate(e,r,i){if(e.linked)for(var o=0;oa-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=function lastChangeEvent(e,t){return t?(clearSelectionEvents(e.done),lst(e.done)):e.done.length&&!lst(e.done).ranges?lst(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),lst(e.done)):void 0}(i,i.lastOp==r)))s=lst(o.changes),0==cmp(t.from,t.to)&&0==cmp(t.from,s.to)?s.to=changeEnd(t):o.changes.push(historyChangeFromChange(e,t));else{var l=lst(i.done);for(l&&l.ranges||pushSelectionToHistory(e.sel,i.done),o={changes:[historyChangeFromChange(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=a,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,s||signal(e,"historyAdded")}function addSelectionToHistory(e,t,n,r){var i=e.history,o=r&&r.origin;n==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||function selectionEventCanBeMerged(e,t,n,r){var i=t.charAt(0);return"*"==i||"+"==i&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}(e,o,lst(i.done),t))?i.done[i.done.length-1]=t:pushSelectionToHistory(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=n,r&&!1!==r.clearRedo&&clearSelectionEvents(i.undone)}function pushSelectionToHistory(e,t){var n=lst(t);n&&n.ranges&&n.equals(e)||t.push(e)}function attachLocalSpans(e,t,n,r){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),function(n){n.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=n.markedSpans),++o})}function removeClearedSpans(e){if(!e)return null;for(var t,n=0;n-1&&(lst(a)[d]=c[d],delete c[d])}}}return r}function extendRange(e,t,n,r){if(r){var i=e.anchor;if(n){var o=cmp(t,i)<0;o!=cmp(n,i)<0?(i=t,t=n):o!=cmp(t,n)<0&&(t=n)}return new ve(i,t)}return new ve(n||t,t)}function extendSelection(e,t,n,r,i){null==i&&(i=e.cm&&(e.cm.display.shift||e.extend)),setSelection(e,new me([extendRange(e.sel.primary(),t,n,i)],0),r)}function extendSelections(e,t,n){for(var r=[],i=e.cm&&(e.cm.display.shift||e.extend),o=0;o=t.ch:a.to>t.ch))){if(i&&(signal(l,"beforeCursorEnter"),l.explicitlyCleared)){if(o.markedSpans){--s;continue}break}if(!l.atomic)continue;if(n){var c=l.find(r<0?1:-1),u=void 0;if((r<0?l.inclusiveRight:l.inclusiveLeft)&&(c=movePos(e,c,-r,c&&c.line==t.line?o:null)),c&&c.line==t.line&&(u=cmp(c,n))&&(r<0?u<0:u>0))return skipAtomicInner(e,c,t,r,i)}var d=l.find(r<0?-1:1);return(r<0?l.inclusiveLeft:l.inclusiveRight)&&(d=movePos(e,d,r,d.line==t.line?o:null)),d?skipAtomicInner(e,d,t,r,i):null}}return t}function skipAtomic(e,t,n,r,i){var o=r||1,s=skipAtomicInner(e,t,n,o,i)||!i&&skipAtomicInner(e,t,n,o,!0)||skipAtomicInner(e,t,n,-o,i)||!i&&skipAtomicInner(e,t,n,-o,!0);return s||(e.cantEdit=!0,Pos(e.first,0))}function movePos(e,t,n,r){return n<0&&0==t.ch?t.line>e.first?clipPos(e,Pos(t.line-1)):null:n>0&&t.ch==(r||getLine(e,t.line)).text.length?t.line0)){var u=[l,1],d=cmp(c.from,a.from),p=cmp(c.to,a.to);(d<0||!s.inclusiveLeft&&!d)&&u.push({from:c.from,to:a.from}),(p>0||!s.inclusiveRight&&!p)&&u.push({from:a.to,to:c.to}),i.splice.apply(i,u),l+=u.length-3}}return i}(e,t.from,t.to);if(r)for(var i=r.length-1;i>=0;--i)makeChangeInner(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text,origin:t.origin});else makeChangeInner(e,t)}}function makeChangeInner(e,t){if(1!=t.text.length||""!=t.text[0]||0!=cmp(t.from,t.to)){var n=computeSelAfterChange(e,t);addChangeToHistory(e,t,n,e.cm?e.cm.curOp.id:NaN),makeChangeSingleDoc(e,t,n,stretchSpansOverChange(e,t));var r=[];linkedDocs(e,function(e,n){n||-1!=indexOf(r,e.history)||(rebaseHist(e.history,t),r.push(e.history)),makeChangeSingleDoc(e,t,null,stretchSpansOverChange(e,t))})}}function makeChangeFromHistory(e,t,n){if(!e.cm||!e.cm.state.suppressEdits||n){for(var r,i=e.history,o=e.sel,s="undo"==t?i.done:i.undone,a="undo"==t?i.undone:i.done,l=0;l=0;--p){var h=d(p);if(h)return h.v}}}}function shiftDoc(e,t){if(0!=t&&(e.first+=t,e.sel=new me(map(e.sel.ranges,function(e){return new ve(Pos(e.anchor.line+t,e.anchor.ch),Pos(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){regChange(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;re.lastLine())){if(t.from.lineo&&(t={from:t.from,to:Pos(o,getLine(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=getBetween(e,t.from,t.to),n||(n=computeSelAfterChange(e,t)),e.cm?function makeChangeSingleDocInEditor(e,t,n){var r=e.doc,i=e.display,o=t.from,s=t.to,a=!1,l=o.line;e.options.lineWrapping||(l=lineNo(visualLine(getLine(r,o.line))),r.iter(l,s.line+1,function(e){if(e==i.maxLine)return a=!0,!0}));r.sel.contains(t.from,t.to)>-1&&signalCursorActivity(e);updateDoc(r,t,n,estimateHeight(e)),e.options.lineWrapping||(r.iter(l,o.line+t.text.length,function(e){var t=lineLength(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,a=!1)}),a&&(e.curOp.updateMaxLine=!0));(function retreatFrontier(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontiern;r--){var i=getLine(e,r).stateAfter;if(i&&(!(i instanceof J)||r+i.lookAhead1||!(this.children[0]instanceof LeafChunk))){var a=[];this.collapse(a),this.children=[new LeafChunk(a)],this.children[0].parent=this}},collapse:function collapse(e){for(var t=0;t50){for(var s=i.lines.length%25+25,a=s;a10);e.parent.maybeSpill()}},iterN:function iterN(e,t,n){for(var r=0;re.display.maxLineLength&&(e.display.maxLine=c,e.display.maxLineLength=u,e.display.maxLineChanged=!0)}null!=r&&e&&this.collapsed&®Change(e,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&reCheckSelection(e.doc)),e&&signalLater(e,"markerCleared",e,this,r,i),t&&endOperation(e),this.parent&&this.parent.clear()}},Ce.prototype.find=function(e,t){null==e&&"bookmark"==this.type&&(e=1);for(var n,r,i=0;i0||0==s&&!1!==o.clearWhenEmpty)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=eltP("span",[o.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(conflictingCollapsedRange(e,t.line,t,n,o)||t.line!=n.line&&conflictingCollapsedRange(e,n.line,t,n,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");!function seeCollapsedSpans(){F=!0}()}o.addToHistory&&addChangeToHistory(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var a,l=t.line,c=e.cm;if(e.iter(l,n.line+1,function(e){c&&o.collapsed&&!c.options.lineWrapping&&visualLine(e)==c.display.maxLine&&(a=!0),o.collapsed&&l!=t.line&&updateLineHeight(e,0),function addMarkedSpan(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}(e,new MarkedSpan(o,l==t.line?t.ch:null,l==n.line?n.ch:null)),++l}),o.collapsed&&e.iter(t.line,n.line+1,function(t){lineIsHidden(e,t)&&updateLineHeight(t,0)}),o.clearOnEnter&&V(o,"beforeCursorEnter",function(){return o.clear()}),o.readOnly&&(!function seeReadOnlySpans(){I=!0}(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++be,o.atomic=!0),c){if(a&&(c.curOp.updateMaxLine=!0),o.collapsed)regChange(c,t.line,n.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var u=t.line;u<=n.line;u++)regLineChange(c,u,"text");o.atomic&&reCheckSelection(c.doc),signalLater(c,"markerAdded",c,o)}return o}var xe=function(e,t){this.markers=e,this.primary=t;for(var n=0;n=0;l--)makeChange(this,r[l]);a?setSelectionReplaceHistory(this,a):this.cm&&ensureCursorVisible(this.cm)}),undo:docMethodOp(function(){makeChangeFromHistory(this,"undo")}),redo:docMethodOp(function(){makeChangeFromHistory(this,"redo")}),undoSelection:docMethodOp(function(){makeChangeFromHistory(this,"undo",!0)}),redoSelection:docMethodOp(function(){makeChangeFromHistory(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,n=0,r=0;r=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,n){e=clipPos(this,e),t=clipPos(this,t);var r=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var s=o.markedSpans;if(s)for(var a=0;a=l.to||null==l.from&&i!=e.line||null!=l.from&&i==t.line&&l.from>=t.ch||n&&!n(l.marker)||r.push(l.marker.parent||l.marker)}++i}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var n=t.markedSpans;if(n)for(var r=0;re)return t=e,!0;e-=o,++n}),clipPos(this,Pos(n,t))},indexFromPos:function(e){var t=(e=clipPos(this,e)).ch;if(e.linet&&(t=e.from),null!=e.to&&e.to-1)return t.state.draggingText(e),void setTimeout(function(){return t.display.input.focus()},20);try{var u=e.dataTransfer.getData("Text");if(u){var d;if(t.state.draggingText&&!t.state.draggingText.copy&&(d=t.listSelections()),setSelectionNoUndo(t.doc,simpleSelection(n,n)),d)for(var p=0;p=0;t--)replaceRange(e.doc,"",r[t].from,r[t].to,"+delete");ensureCursorVisible(e)})}function moveCharLogically(e,t,n){var r=skipExtendingChars(e.text,t+n,n);return r<0||r>e.text.length?null:r}function moveLogically(e,t,n){var r=moveCharLogically(e,t.ch,n);return null==r?null:new Pos(t.line,r,n<0?"after":"before")}function endOfLine(e,t,n,r,i){if(e){var o=getOrder(n,t.doc.direction);if(o){var s,a=i<0?lst(o):o[0],l=i<0==(1==a.level)?"after":"before";if(a.level>0||"rtl"==t.doc.direction){var c=prepareMeasureForLine(t,n);s=i<0?n.text.length-1:0;var u=measureCharPrepared(t,c,s).top;s=findFirst(function(e){return measureCharPrepared(t,c,e).top==u},i<0==(1==a.level)?a.from:a.to-1,s),"before"==l&&(s=moveCharLogically(n,s,1))}else s=i<0?a.to:a.from;return new Pos(r,s,l)}}return new Pos(r,i<0?n.text.length:0,i<0?"before":"after")}var Ne={selectAll:selectAll,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),A)},killLine:function(e){return deleteNearSelection(e,function(t){if(t.empty()){var n=getLine(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line0)i=new Pos(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),Pos(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var s=getLine(e.doc,i.line-1).text;s&&(i=new Pos(i.line,1),e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+s.charAt(s.length-1),Pos(i.line-1,s.length-1),i,"+transpose"))}n.push(new ve(i,i))}e.setSelections(n)})},newlineAndIndent:function(e){return runInOp(e,function(){for(var t=e.listSelections(),n=t.length-1;n>=0;n--)e.replaceRange(e.doc.lineSeparator(),t[n].anchor,t[n].head,"+input");t=e.listSelections();for(var r=0;re&&0==cmp(t,this.pos)&&n==this.button};var Ee,Ie;function onMouseDown(e){var t=this.display;if(!(signalDOMEvent(this,e)||t.activeTouch&&t.input.supportsTouch()))if(t.input.ensurePolled(),t.shift=e.shiftKey,eventInWidget(t,e))l||(t.scroller.draggable=!1,setTimeout(function(){return t.scroller.draggable=!0},100));else if(!clickInGutter(this,e)){var n=posFromMouse(this,e),r=e_button(e),i=n?function clickRepeat(e,t){var n=+new Date;return Ie&&Ie.compare(n,e,t)?(Ee=Ie=null,"triple"):Ee&&Ee.compare(n,e,t)?(Ie=new We(n,e,t),Ee=null,"double"):(Ee=new We(n,e,t),Ie=null,"single")}(n,r):"single";window.focus(),1==r&&this.state.selectingText&&this.state.selectingText(e),n&&function handleMappedButton(e,t,n,r,i){var o="Click";"double"==r?o="Double"+o:"triple"==r&&(o="Triple"+o);return dispatchKey(e,addModifierNames(o=(1==t?"Left":2==t?"Middle":"Right")+o,i),i,function(t){if("string"==typeof t&&(t=Ne[t]),!t)return!1;var r=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),r=t(e,n)!=P}finally{e.state.suppressEdits=!1}return r})}(this,r,n,i,e)||(1==r?n?function leftButtonDown(e,t,n,r){s?setTimeout(bind(ensureFocus,e),0):e.curOp.focus=activeElt();var i,o=function configureMouse(e,t,n){var r=e.getOption("configureMouse"),i=r?r(e,t,n):{};if(null==i.unit){var o=b?n.shiftKey&&n.metaKey:n.altKey;i.unit=o?"rectangle":"single"==t?"char":"double"==t?"word":"line"}(null==i.extend||e.doc.extend)&&(i.extend=e.doc.extend||n.shiftKey);null==i.addNew&&(i.addNew=y?n.metaKey:n.ctrlKey);null==i.moveOnDrag&&(i.moveOnDrag=!(y?n.altKey:n.ctrlKey));return i}(e,n,r),c=e.doc.sel;e.options.dragDrop&&j&&!e.isReadOnly()&&"single"==n&&(i=c.contains(t))>-1&&(cmp((i=c.ranges[i]).from(),t)<0||t.xRel>0)&&(cmp(i.to(),t)>0||t.xRel<0)?function leftButtonStartDrag(e,t,n,r){var i=e.display,o=!1,c=operation(e,function(t){l&&(i.scroller.draggable=!1),e.state.draggingText=!1,off(document,"mouseup",c),off(document,"mousemove",u),off(i.scroller,"dragstart",d),off(i.scroller,"drop",c),o||(e_preventDefault(t),r.addNew||extendSelection(e.doc,n,null,null,r.extend),l||s&&9==a?setTimeout(function(){document.body.focus(),i.input.focus()},20):i.input.focus())}),u=function(e){o=o||Math.abs(t.clientX-e.clientX)+Math.abs(t.clientY-e.clientY)>=10},d=function(){return o=!0};l&&(i.scroller.draggable=!0);e.state.draggingText=c,c.copy=!r.moveOnDrag,i.scroller.dragDrop&&i.scroller.dragDrop();V(document,"mouseup",c),V(document,"mousemove",u),V(i.scroller,"dragstart",d),V(i.scroller,"drop",c),delayBlurEvent(e),setTimeout(function(){return i.input.focus()},20)}(e,r,t,o):function leftButtonSelect(e,t,n,r){var i=e.display,o=e.doc;e_preventDefault(t);var s,a,l=o.sel,c=l.ranges;r.addNew&&!r.extend?(a=o.sel.contains(n),s=a>-1?c[a]:new ve(n,n)):(s=o.sel.primary(),a=o.sel.primIndex);if("rectangle"==r.unit)r.addNew||(s=new ve(n,n)),n=posFromMouse(e,t,!0,!0),a=-1;else{var u=rangeForUnit(e,n,r.unit);s=r.extend?extendRange(s,u.anchor,u.head,r.extend):u}r.addNew?-1==a?(a=c.length,setSelection(o,normalizeSelection(c.concat([s]),a),{scroll:!1,origin:"*mouse"})):c.length>1&&c[a].empty()&&"char"==r.unit&&!r.extend?(setSelection(o,normalizeSelection(c.slice(0,a).concat(c.slice(a+1)),0),{scroll:!1,origin:"*mouse"}),l=o.sel):replaceOneSelection(o,a,s,N):(a=0,setSelection(o,new me([s],0),N),l=o.sel);var d=n;function extendTo(t){if(0!=cmp(d,t))if(d=t,"rectangle"==r.unit){for(var i=[],c=e.options.tabSize,u=countColumn(getLine(o,n.line).text,n.ch,c),p=countColumn(getLine(o,t.line).text,t.ch,c),h=Math.min(u,p),f=Math.max(u,p),g=Math.min(n.line,t.line),m=Math.min(e.lastLine(),Math.max(n.line,t.line));g<=m;g++){var v=getLine(o,g).text,y=findColumn(v,h,c);h==f?i.push(new ve(Pos(g,y),Pos(g,y))):v.length>y&&i.push(new ve(Pos(g,y),Pos(g,findColumn(v,f,c))))}i.length||i.push(new ve(n,n)),setSelection(o,normalizeSelection(l.ranges.slice(0,a).concat(i),a),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b,C=s,x=rangeForUnit(e,t,r.unit),w=C.anchor;cmp(x.anchor,w)>0?(b=x.head,w=minPos(C.from(),x.anchor)):(b=x.anchor,w=maxPos(C.to(),x.head));var S=l.ranges.slice(0);S[a]=function bidiSimplify(e,t){var n=t.anchor,r=t.head,i=getLine(e.doc,n.line);if(0==cmp(n,r)&&n.sticky==r.sticky)return t;var o=getOrder(i);if(!o)return t;var s=getBidiPartAt(o,n.ch,n.sticky),a=o[s];if(a.from!=n.ch&&a.to!=n.ch)return t;var l=s+(a.from==n.ch==(1!=a.level)?0:1);if(0==l||l==o.length)return t;var c;if(r.line!=n.line)c=(r.line-n.line)*("ltr"==e.doc.direction?1:-1)>0;else{var u=getBidiPartAt(o,r.ch,r.sticky),d=u-s||(r.ch-n.ch)*(1==a.level?-1:1);c=u==l-1||u==l?d<0:d>0}var p=o[l+(c?-1:0)],h=c==(1==p.level),f=h?p.from:p.to,g=h?"after":"before";return n.ch==f&&n.sticky==g?t:new ve(new Pos(n.line,f,g),r)}(e,new ve(clipPos(o,w),b)),setSelection(o,normalizeSelection(S,a),N)}}var p=i.wrapper.getBoundingClientRect(),h=0;function done(t){e.state.selectingText=!1,h=1/0,e_preventDefault(t),i.input.focus(),off(document,"mousemove",f),off(document,"mouseup",g),o.history.lastSelOrigin=null}var f=operation(e,function(t){e_button(t)?function extend(t){var n=++h;var s=posFromMouse(e,t,!0,"rectangle"==r.unit);if(!s)return;if(0!=cmp(s,d)){e.curOp.focus=activeElt(),extendTo(s);var a=visibleLines(i,o);(s.line>=a.to||s.linep.bottom?20:0;l&&setTimeout(operation(e,function(){h==n&&(i.scroller.scrollTop+=l,extend(t))}),50)}}(t):done(t)}),g=operation(e,done);e.state.selectingText=g,V(document,"mousemove",f),V(document,"mouseup",g)}(e,r,t,o)}(this,n,i,e):e_target(e)==t.scroller&&e_preventDefault(e):2==r?(n&&extendSelection(this.doc,n),setTimeout(function(){return t.input.focus()},20)):3==r&&(S?onContextMenu(this,e):delayBlurEvent(this)))}}function rangeForUnit(e,t,n){if("char"==n)return new ve(t,t);if("word"==n)return e.findWordAt(t);if("line"==n)return new ve(Pos(t.line,0),clipPos(e.doc,Pos(t.line+1,0)));var r=n(e,t);return new ve(r.from,r.to)}function gutterEvent(e,t,n,r){var i,o;if(t.touches)i=t.touches[0].clientX,o=t.touches[0].clientY;else try{i=t.clientX,o=t.clientY}catch(t){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&e_preventDefault(t);var s=e.display,a=s.lineDiv.getBoundingClientRect();if(o>a.bottom||!hasHandler(e,n))return e_defaultPrevented(t);o-=a.top-s.viewOffset;for(var l=0;l=i){return signal(e,n,e,lineAtHeight(e.doc,o),e.options.gutters[l],t),e_defaultPrevented(t)}}}function clickInGutter(e,t){return gutterEvent(e,t,"gutterClick",!0)}function onContextMenu(e,t){eventInWidget(e.display,t)||function contextMenuInGutter(e,t){if(!hasHandler(e,"gutterContextMenu"))return!1;return gutterEvent(e,t,"gutterContextMenu",!1)}(e,t)||signalDOMEvent(e,t,"contextmenu")||e.display.input.onContextMenu(t)}function themeChanged(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),clearCaches(e)}var Fe={toString:function(){return"CodeMirror.Init"}},Be={},ze={};function guttersChanged(e){updateGutters(e),regChange(e),alignHorizontally(e)}function dragDropChanged(e,t,n){if(!t!=!(n&&n!=Fe)){var r=e.display.dragFunctions,i=t?V:off;i(e.display.scroller,"dragstart",r.start),i(e.display.scroller,"dragenter",r.enter),i(e.display.scroller,"dragover",r.over),i(e.display.scroller,"dragleave",r.leave),i(e.display.scroller,"drop",r.drop)}}function wrappingChanged(e){e.options.lineWrapping?(addClass(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(k(e.display.wrapper,"CodeMirror-wrap"),findMaxLine(e)),estimateLineHeights(e),regChange(e),clearCaches(e),setTimeout(function(){return updateScrollbars(e)},100)}function CodeMirror$1(e,t){var r=this;if(!(this instanceof CodeMirror$1))return new CodeMirror$1(e,t);this.options=t=t?copyObj(t):{},copyObj(Be,t,!1),setGuttersForLineNumbers(t);var i=t.value;"string"==typeof i&&(i=new Se(i,t.mode,null,t.lineSeparator,t.direction)),this.doc=i;var o=new CodeMirror$1.inputStyles[t.inputStyle](this),c=this.display=new function Display(e,t,r){this.input=r,this.scrollbarFiller=elt("div",null,"CodeMirror-scrollbar-filler"),this.scrollbarFiller.setAttribute("cm-not-content","true"),this.gutterFiller=elt("div",null,"CodeMirror-gutter-filler"),this.gutterFiller.setAttribute("cm-not-content","true"),this.lineDiv=eltP("div",null,"CodeMirror-code"),this.selectionDiv=elt("div",null,null,"position: relative; z-index: 1"),this.cursorDiv=elt("div",null,"CodeMirror-cursors"),this.measure=elt("div",null,"CodeMirror-measure"),this.lineMeasure=elt("div",null,"CodeMirror-measure"),this.lineSpace=eltP("div",[this.measure,this.lineMeasure,this.selectionDiv,this.cursorDiv,this.lineDiv],null,"position: relative; outline: none");var i=eltP("div",[this.lineSpace],"CodeMirror-lines");this.mover=elt("div",[i],null,"position: relative"),this.sizer=elt("div",[this.mover],"CodeMirror-sizer"),this.sizerWidth=null,this.heightForcer=elt("div",null,null,"position: absolute; height: "+O+"px; width: 1px;"),this.gutters=elt("div",null,"CodeMirror-gutters"),this.lineGutter=null,this.scroller=elt("div",[this.sizer,this.heightForcer,this.gutters],"CodeMirror-scroll"),this.scroller.setAttribute("tabIndex","-1"),this.wrapper=elt("div",[this.scrollbarFiller,this.gutterFiller,this.scroller],"CodeMirror"),s&&a<8&&(this.gutters.style.zIndex=-1,this.scroller.style.paddingRight=0),l||n&&v||(this.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(this.wrapper):e(this.wrapper)),this.viewFrom=this.viewTo=t.first,this.reportedViewFrom=this.reportedViewTo=t.first,this.view=[],this.renderedView=null,this.externalMeasured=null,this.viewOffset=0,this.lastWrapHeight=this.lastWrapWidth=0,this.updateLineNumbers=null,this.nativeBarWidth=this.barHeight=this.barWidth=0,this.scrollbarsClipped=!1,this.lineNumWidth=this.lineNumInnerWidth=this.lineNumChars=null,this.alignWidgets=!1,this.cachedCharWidth=this.cachedTextHeight=this.cachedPaddingH=null,this.maxLine=null,this.maxLineLength=0,this.maxLineChanged=!1,this.wheelDX=this.wheelDY=this.wheelStartX=this.wheelStartY=null,this.shift=!1,this.selForContextMenu=null,this.activeTouch=null,r.init(this)}(e,i,o);c.wrapper.CodeMirror=this,updateGutters(this),themeChanged(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),initScrollbars(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new T,keySeq:null,specialChars:null},t.autofocus&&!v&&c.input.focus(),s&&a<11&&setTimeout(function(){return r.display.input.reset(!0)},20),function registerEventHandlers(e){var t=e.display;V(t.scroller,"mousedown",operation(e,onMouseDown)),V(t.scroller,"dblclick",s&&a<11?operation(e,function(t){if(!signalDOMEvent(e,t)){var n=posFromMouse(e,t);if(n&&!clickInGutter(e,t)&&!eventInWidget(e.display,t)){e_preventDefault(t);var r=e.findWordAt(n);extendSelection(e.doc,r.anchor,r.head)}}}):function(t){return signalDOMEvent(e,t)||e_preventDefault(t)});S||V(t.scroller,"contextmenu",function(t){return onContextMenu(e,t)});var n,r={end:0};function finishTouch(){t.activeTouch&&(n=setTimeout(function(){return t.activeTouch=null},1e3),(r=t.activeTouch).end=+new Date)}function farAway(e,t){if(null==t.left)return!0;var n=t.left-e.left,r=t.top-e.top;return n*n+r*r>400}V(t.scroller,"touchstart",function(i){if(!signalDOMEvent(e,i)&&!function isMouseLikeTouchEvent(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}(i)&&!clickInGutter(e,i)){t.input.ensurePolled(),clearTimeout(n);var o=+new Date;t.activeTouch={start:o,moved:!1,prev:o-r.end<=300?r:null},1==i.touches.length&&(t.activeTouch.left=i.touches[0].pageX,t.activeTouch.top=i.touches[0].pageY)}}),V(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),V(t.scroller,"touchend",function(n){var r=t.activeTouch;if(r&&!eventInWidget(t,n)&&null!=r.left&&!r.moved&&new Date-r.start<300){var i,o=e.coordsChar(t.activeTouch,"page");i=!r.prev||farAway(r,r.prev)?new ve(o,o):!r.prev.prev||farAway(r,r.prev.prev)?e.findWordAt(o):new ve(Pos(o.line,0),clipPos(e.doc,Pos(o.line+1,0))),e.setSelection(i.anchor,i.head),e.focus(),e_preventDefault(n)}finishTouch()}),V(t.scroller,"touchcancel",finishTouch),V(t.scroller,"scroll",function(){t.scroller.clientHeight&&(updateScrollTop(e,t.scroller.scrollTop),setScrollLeft(e,t.scroller.scrollLeft,!0),signal(e,"scroll",e))}),V(t.scroller,"mousewheel",function(t){return onScrollWheel(e,t)}),V(t.scroller,"DOMMouseScroll",function(t){return onScrollWheel(e,t)}),V(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(t){signalDOMEvent(e,t)||e_stop(t)},over:function(t){signalDOMEvent(e,t)||(!function onDragOver(e,t){var n=posFromMouse(e,t);if(n){var r=document.createDocumentFragment();drawSelectionCursor(e,n,r),e.display.dragCursor||(e.display.dragCursor=elt("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),removeChildrenAndAdd(e.display.dragCursor,r)}}(e,t),e_stop(t))},start:function(t){return function onDragStart(e,t){if(s&&(!e.state.draggingText||+new Date-ke<100))e_stop(t);else if(!signalDOMEvent(e,t)&&!eventInWidget(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!p)){var n=elt("img",null,null,"position: fixed; left: 0; top: 0;");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",d&&(n.width=n.height=1,e.display.wrapper.appendChild(n),n._top=n.offsetTop),t.dataTransfer.setDragImage(n,0,0),d&&n.parentNode.removeChild(n)}}(e,t)},drop:operation(e,onDrop),leave:function(t){signalDOMEvent(e,t)||clearDragCursor(e)}};var i=t.input.getField();V(i,"keyup",function(t){return onKeyUp.call(e,t)}),V(i,"keydown",operation(e,onKeyDown)),V(i,"keypress",operation(e,onKeyPress)),V(i,"focus",function(t){return onFocus(e,t)}),V(i,"blur",function(t){return onBlur(e,t)})}(this),ensureGlobalHandlers(),startOperation(this),this.curOp.forceUpdate=!0,attachDoc(this,i),t.autofocus&&!v||this.hasFocus()?setTimeout(bind(onFocus,this),20):onBlur(this);for(var u in ze)ze.hasOwnProperty(u)&&ze[u](r,t[u],Fe);maybeUpdateLineNumberWidth(this),t.finishInit&&t.finishInit(this);for(var h=0;h150)){if(!r)return;n="prev"}}else c=0,n="not";"prev"==n?c=t>o.first?countColumn(getLine(o,t-1).text,null,s):0:"add"==n?c=l+e.options.indentUnit:"subtract"==n?c=l-e.options.indentUnit:"number"==typeof n&&(c=l+n),c=Math.max(0,c);var d="",p=0;if(e.options.indentWithTabs)for(var h=Math.floor(c/s);h;--h)p+=s,d+="\t";if(p1)if(Ve&&Ve.text.join("\n")==t){if(r.ranges.length%Ve.text.length==0){l=[];for(var c=0;c=0;d--){var p=r.ranges[d],h=p.from(),f=p.to();p.empty()&&(n&&n>0?h=Pos(h.line,h.ch-n):e.state.overwrite&&!s?f=Pos(f.line,Math.min(getLine(o,f.line).text.length,f.ch+lst(a).length)):Ve&&Ve.lineWise&&Ve.text.join("\n")==t&&(h=f=Pos(h.line,0))),u=e.curOp.updateInput;var g={from:h,to:f,text:l?l[d%l.length]:a,origin:i||(s?"paste":e.state.cutIncoming?"cut":"+input")};makeChange(e.doc,g),signalLater(e,"inputRead",e,g)}t&&!s&&triggerElectric(e,t),ensureCursorVisible(e),e.curOp.updateInput=u,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function handlePaste(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");if(n)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||runInOp(t,function(){return applyTextInput(t,n,0,null,"paste")}),!0}function triggerElectric(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var n=e.doc.sel,r=n.ranges.length-1;r>=0;r--){var i=n.ranges[r];if(!(i.head.ch>100||r&&n.ranges[r-1].head.line==i.head.line)){var o=e.getModeAt(i.head),s=!1;if(o.electricChars){for(var a=0;a-1){s=indentLine(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(getLine(e.doc,i.head.line).text.slice(0,i.head.ch))&&(s=indentLine(e,i.head.line,"smart"));s&&signalLater(e,"electricInput",e,i.head.line)}}}function copyableRanges(e){for(var t=[],n=[],r=0;r=t.text.length?(n.ch=t.text.length,n.sticky="before"):n.ch<=0&&(n.ch=0,n.sticky="after");var o=getBidiPartAt(i,n.ch,n.sticky),s=i[o];if("ltr"==e.doc.direction&&s.level%2==0&&(r>0?s.to>n.ch:s.from=s.from&&p>=u.begin)){var h=d?"before":"after";return new Pos(n.line,p,h)}}var f=function(e,t,r){for(var o=function(e,t){return t?new Pos(n.line,l(e,1),"before"):new Pos(n.line,e,"after")};e>=0&&e0==(1!=s.level),c=a?r.begin:l(r.end,-1);if(s.from<=c&&c0?u.end:l(u.begin,-1);return null==m||r>0&&m==t.text.length||!(g=f(r>0?0:i.length-1,r,c(m)))?null:g}(e.cm,a,t,n):moveLogically(a,t,n))){if(r||!function findNextLine(){var r=t.line+n;return!(r=e.first+e.size)&&(t=new Pos(r,t.ch,t.sticky),a=getLine(e,r))}())return!1;t=endOfLine(i,e.cm,a,t.line,n)}else t=o;return!0}if("char"==r)moveOnce();else if("column"==r)moveOnce(!0);else if("word"==r||"group"==r)for(var l=null,c="group"==r,u=e.cm&&e.cm.getHelper(t,"wordChars"),d=!0;!(n<0)||moveOnce(!d);d=!1){var p=a.text.charAt(t.ch)||"\n",h=isWordChar(p,u)?"w":c&&"\n"==p?"n":!c||/\s/.test(p)?null:"p";if(!c||d||h||(h="s"),l&&l!=h){n<0&&(n=1,moveOnce(),t.sticky="after");break}if(h&&(l=h),n>0&&!moveOnce(!d))break}var f=skipAtomic(e,t,o,s,!0);return equalCursorPos(o,f)&&(f.hitSide=!0),f}function findPosV(e,t,n,r){var i,o=e.doc,s=t.left;if("page"==r){var a=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),l=Math.max(a-.5*textHeight(e.display),3);i=(n>0?t.bottom:t.top)+n*l}else"line"==r&&(i=n>0?t.bottom+3:t.top-3);for(var c;(c=coordsChar(e,s,i)).outside;){if(n<0?i<=0:i>=o.height){c.hitSide=!0;break}i+=5*n}return c}var Ue=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new T,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Ue.prototype.init=function(e){var t=this,n=this,r=n.cm,i=n.div=e.lineDiv;disableBrowserMagic(i,r.options.spellcheck),V(i,"paste",function(e){signalDOMEvent(r,e)||handlePaste(e,r)||a<=11&&setTimeout(operation(r,function(){return t.updateFromDOM()}),20)}),V(i,"compositionstart",function(e){t.composing={data:e.data,done:!1}}),V(i,"compositionupdate",function(e){t.composing||(t.composing={data:e.data,done:!1})}),V(i,"compositionend",function(e){t.composing&&(e.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),V(i,"touchstart",function(){return n.forceCompositionEnd()}),V(i,"input",function(){t.composing||t.readFromDOMSoon()});function onCopyCut(e){if(!signalDOMEvent(r,e)){if(r.somethingSelected())setLastCopied({lineWise:!1,text:r.getSelections()}),"cut"==e.type&&r.replaceSelection("",null,"cut");else{if(!r.options.lineWiseCopyCut)return;var t=copyableRanges(r);setLastCopied({lineWise:!0,text:t.text}),"cut"==e.type&&r.operation(function(){r.setSelections(t.ranges,0,A),r.replaceSelection("",null,"cut")})}if(e.clipboardData){e.clipboardData.clearData();var o=Ve.text.join("\n");if(e.clipboardData.setData("Text",o),e.clipboardData.getData("Text")==o)return void e.preventDefault()}var s=hiddenTextarea(),a=s.firstChild;r.display.lineSpace.insertBefore(s,r.display.lineSpace.firstChild),a.value=Ve.text.join("\n");var l=document.activeElement;M(a),setTimeout(function(){r.display.lineSpace.removeChild(s),l.focus(),l==i&&n.showPrimarySelection()},50)}}V(i,"copy",onCopyCut),V(i,"cut",onCopyCut)},Ue.prototype.prepareSelection=function(){var e=prepareSelection(this.cm,!1);return e.focus=this.cm.state.focused,e},Ue.prototype.showSelection=function(e,t){e&&this.cm.display.view.length&&((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))},Ue.prototype.showPrimarySelection=function(){var e=window.getSelection(),t=this.cm,r=t.doc.sel.primary(),i=r.from(),o=r.to();if(t.display.viewTo==t.display.viewFrom||i.line>=t.display.viewTo||o.line=t.display.viewFrom&&posToDOM(t,i)||{node:l[0].measure.map[2],offset:0},u=o.linee.firstLine()&&(r=Pos(r.line-1,getLine(e.doc,r.line-1).length)),i.ch==getLine(e.doc,i.line).text.length&&i.linet.viewTo-1)return!1;var o,s,a;r.line==t.viewFrom||0==(o=findViewIndex(e,r.line))?(s=lineNo(t.view[0].line),a=t.view[0].node):(s=lineNo(t.view[o].line),a=t.view[o-1].node.nextSibling);var l,c,u=findViewIndex(e,i.line);if(u==t.view.length-1?(l=t.viewTo-1,c=t.lineDiv.lastChild):(l=lineNo(t.view[u+1].line)-1,c=t.view[u+1].node.previousSibling),!a)return!1;for(var d=e.doc.splitLines(function domTextBetween(e,t,n,r,i){var o="",s=!1,a=e.doc.lineSeparator();function close(){s&&(o+=a,s=!1)}function addText(e){e&&(close(),o+=e)}function walk(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(null!=n)return void addText(n||t.textContent.replace(/\u200b/g,""));var o,l=t.getAttribute("cm-marker");if(l){var c=e.findMarks(Pos(r,0),Pos(i+1,0),function recognizeMarker(e){return function(t){return t.id==e}}(+l));return void(c.length&&(o=c[0].find(0))&&addText(getBetween(e.doc,o.from,o.to).join(a)))}if("false"==t.getAttribute("contenteditable"))return;var u=/^(pre|div|p)$/i.test(t.nodeName);u&&close();for(var d=0;d1&&p.length>1;)if(lst(d)==lst(p))d.pop(),p.pop(),l--;else{if(d[0]!=p[0])break;d.shift(),p.shift(),s++}for(var h=0,f=0,g=d[0],m=p[0],v=Math.min(g.length,m.length);hr.ch&&y.charCodeAt(y.length-f-1)==b.charCodeAt(b.length-f-1);)h--,f++;d[d.length-1]=y.slice(0,y.length-f).replace(/^\u200b+/,""),d[0]=d[0].slice(h).replace(/\u200b+$/,"");var x=Pos(s,h),w=Pos(l,p.length?lst(p).length-f:0);return d.length>1||d[0]||cmp(x,w)?(replaceRange(e.doc,d,x,w,"+input"),!0):void 0},Ue.prototype.ensurePolled=function(){this.forceCompositionEnd()},Ue.prototype.reset=function(){this.forceCompositionEnd()},Ue.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},Ue.prototype.readFromDOMSoon=function(){var e=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout(function(){if(e.readDOMTimeout=null,e.composing){if(!e.composing.done)return;e.composing=null}e.updateFromDOM()},80))},Ue.prototype.updateFromDOM=function(){var e=this;!this.cm.isReadOnly()&&this.pollContent()||runInOp(this.cm,function(){return regChange(e.cm)})},Ue.prototype.setUneditable=function(e){e.contentEditable="false"},Ue.prototype.onKeyPress=function(e){0!=e.charCode&&(e.preventDefault(),this.cm.isReadOnly()||operation(this.cm,applyTextInput)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0))},Ue.prototype.readOnlyChanged=function(e){this.div.contentEditable=String("nocursor"!=e)},Ue.prototype.onContextMenu=function(){},Ue.prototype.resetPosition=function(){},Ue.prototype.needsContentAttribute=!0;function posToDOM(e,t){var n=findViewForLine(e,t.line);if(!n||n.hidden)return null;var r=getLine(e.doc,t.line),i=mapFromLineView(n,r,t.line),o=getOrder(r,e.doc.direction),s="left";if(o){s=getBidiPartAt(o,t.ch)%2?"right":"left"}var a=nodeAndOffsetInLineMap(i.map,t.ch,s);return a.offset="right"==a.collapse?a.end:a.start,a}function badPos(e,t){return t&&(e.bad=!0),e}function domToPos(e,t,n){var r;if(t==e.display.lineDiv){if(!(r=e.display.lineDiv.childNodes[n]))return badPos(e.clipPos(Pos(e.display.viewTo-1)),!0);t=null,n=0}else for(r=t;;r=r.parentNode){if(!r||r==e.display.lineDiv)return null;if(r.parentNode&&r.parentNode==e.display.lineDiv)break}for(var i=0;i=9&&t.hasSelection&&(t.hasSelection=null),n.poll()}),V(o,"paste",function(e){signalDOMEvent(r,e)||handlePaste(e,r)||(r.state.pasteIncoming=!0,n.fastPoll())});function prepareCopyCut(e){if(!signalDOMEvent(r,e)){if(r.somethingSelected())setLastCopied({lineWise:!1,text:r.getSelections()});else{if(!r.options.lineWiseCopyCut)return;var t=copyableRanges(r);setLastCopied({lineWise:!0,text:t.text}),"cut"==e.type?r.setSelections(t.ranges,null,A):(n.prevInput="",o.value=t.text.join("\n"),M(o))}"cut"==e.type&&(r.state.cutIncoming=!0)}}V(o,"cut",prepareCopyCut),V(o,"copy",prepareCopyCut),V(e.scroller,"paste",function(t){eventInWidget(e,t)||signalDOMEvent(r,t)||(r.state.pasteIncoming=!0,n.focus())}),V(e.lineSpace,"selectstart",function(t){eventInWidget(e,t)||e_preventDefault(t)}),V(o,"compositionstart",function(){var e=r.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:e,range:r.markText(e,r.getCursor("to"),{className:"CodeMirror-composing"})}}),V(o,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},je.prototype.prepareSelection=function(){var e=this.cm,t=e.display,n=e.doc,r=prepareSelection(e);if(e.options.moveInputWithCursor){var i=cursorCoords(e,n.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),s=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+s.top-o.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+s.left-o.left))}return r},je.prototype.showSelection=function(e){var t=this.cm.display;removeChildrenAndAdd(t.cursorDiv,e.cursors),removeChildrenAndAdd(t.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},je.prototype.reset=function(e){if(!this.contextMenuPending&&!this.composing){var t=this.cm;if(t.somethingSelected()){this.prevInput="";var n=t.getSelection();this.textarea.value=n,t.state.focused&&M(this.textarea),s&&a>=9&&(this.hasSelection=n)}else e||(this.prevInput=this.textarea.value="",s&&a>=9&&(this.hasSelection=null))}},je.prototype.getField=function(){return this.textarea},je.prototype.supportsTouch=function(){return!1},je.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!v||activeElt()!=this.textarea))try{this.textarea.focus()}catch(e){}},je.prototype.blur=function(){this.textarea.blur()},je.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},je.prototype.receivedFocus=function(){this.slowPoll()},je.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},je.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0;t.polling.set(20,function p(){t.poll()||e?(t.pollingFast=!1,t.slowPoll()):(e=!0,t.polling.set(60,p))})},je.prototype.poll=function(){var e=this,t=this.cm,n=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||_(n)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var i=n.value;if(i==r&&!t.somethingSelected())return!1;if(s&&a>=9&&this.hasSelection===i||y&&/[\uf700-\uf7ff]/.test(i))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var o=i.charCodeAt(0);if(8203!=o||r||(r="​"),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var l=0,c=Math.min(r.length,i.length);l1e3||i.indexOf("\n")>-1?n.value=e.prevInput="":e.prevInput=i,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},je.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},je.prototype.onKeyPress=function(){s&&a>=9&&(this.hasSelection=null),this.fastPoll()},je.prototype.onContextMenu=function(e){var t=this,n=t.cm,r=n.display,i=t.textarea,o=posFromMouse(n,e),c=r.scroller.scrollTop;if(o&&!d){n.options.resetSelectionOnContextMenu&&-1==n.doc.sel.contains(o)&&operation(n,setSelection)(n.doc,simpleSelection(o),A);var u=i.style.cssText,p=t.wrapper.style.cssText;t.wrapper.style.cssText="position: absolute";var h=t.wrapper.getBoundingClientRect();i.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-h.top-5)+"px; left: "+(e.clientX-h.left-5)+"px;\n z-index: 1000; background: "+(s?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var f;if(l&&(f=window.scrollY),r.input.focus(),l&&window.scrollTo(null,f),r.input.reset(),n.somethingSelected()||(i.value=t.prevInput=" "),t.contextMenuPending=!0,r.selForContextMenu=n.doc.sel,clearTimeout(r.detectingSelectAll),s&&a>=9&&prepareSelectAllHack(),S){e_stop(e);var g=function(){off(window,"mouseup",g),setTimeout(rehide,20)};V(window,"mouseup",g)}else setTimeout(rehide,50)}function prepareSelectAllHack(){if(null!=i.selectionStart){var e=n.somethingSelected(),o="​"+(e?i.value:"");i.value="⇚",i.value=o,t.prevInput=e?"":"​",i.selectionStart=1,i.selectionEnd=o.length,r.selForContextMenu=n.doc.sel}}function rehide(){if(t.contextMenuPending=!1,t.wrapper.style.cssText=p,i.style.cssText=u,s&&a<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=c),null!=i.selectionStart){(!s||s&&a<9)&&prepareSelectAllHack();var e=0,o=function(){r.selForContextMenu==n.doc.sel&&0==i.selectionStart&&i.selectionEnd>0&&"​"==t.prevInput?operation(n,selectAll)(n):e++<10?r.detectingSelectAll=setTimeout(o,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(o,200)}}},je.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled="nocursor"==e},je.prototype.setUneditable=function(){},je.prototype.needsContentAttribute=!1;!function defineOptions(e){var t=e.optionHandlers;function option(n,r,i,o){e.defaults[n]=r,i&&(t[n]=o?function(e,t,n){n!=Fe&&i(e,t,n)}:i)}e.defineOption=option,e.Init=Fe,option("value","",function(e,t){return e.setValue(t)},!0),option("mode",null,function(e,t){e.doc.modeOption=t,loadMode(e)},!0),option("indentUnit",2,loadMode,!0),option("indentWithTabs",!1),option("smartIndent",!0),option("tabSize",4,function(e){resetModeState(e),clearCaches(e),regChange(e)},!0),option("lineSeparator",null,function(e,t){if(e.doc.lineSep=t,t){var n=[],r=e.doc.first;e.doc.iter(function(e){for(var i=0;;){var o=e.text.indexOf(t,i);if(-1==o)break;i=o+t.length,n.push(Pos(r,o))}r++});for(var i=n.length-1;i>=0;i--)replaceRange(e.doc,t,n[i],Pos(n[i].line,n[i].ch+t.length))}}),option("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g,function(e,t,n){e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g"),n!=Fe&&e.refresh()}),option("specialCharPlaceholder",defaultSpecialCharPlaceholder,function(e){return e.refresh()},!0),option("electricChars",!0),option("inputStyle",v?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),option("spellcheck",!1,function(e,t){return e.getInputField().spellcheck=t},!0),option("rtlMoveVisually",!C),option("wholeLineUpdateBefore",!0),option("theme","default",function(e){themeChanged(e),guttersChanged(e)},!0),option("keyMap","default",function(e,t,n){var r=getKeyMap(t),i=n!=Fe&&getKeyMap(n);i&&i.detach&&i.detach(e,r),r.attach&&r.attach(e,i||null)}),option("extraKeys",null),option("configureMouse",null),option("lineWrapping",!1,wrappingChanged,!0),option("gutters",[],function(e){setGuttersForLineNumbers(e.options),guttersChanged(e)},!0),option("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?compensateForHScroll(e.display)+"px":"0",e.refresh()},!0),option("coverGutterNextToScrollbar",!1,function(e){return updateScrollbars(e)},!0),option("scrollbarStyle","native",function(e){initScrollbars(e),updateScrollbars(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),option("lineNumbers",!1,function(e){setGuttersForLineNumbers(e.options),guttersChanged(e)},!0),option("firstLineNumber",1,guttersChanged,!0),option("lineNumberFormatter",function(e){return e},guttersChanged,!0),option("showCursorWhenSelecting",!1,updateSelection,!0),option("resetSelectionOnContextMenu",!0),option("lineWiseCopyCut",!0),option("pasteLinesPerSelection",!0),option("readOnly",!1,function(e,t){"nocursor"==t&&(onBlur(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)}),option("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),option("dragDrop",!0,dragDropChanged),option("allowDropFileTypes",null),option("cursorBlinkRate",530),option("cursorScrollMargin",0),option("cursorHeight",1,updateSelection,!0),option("singleCursorHeightPerLine",!0,updateSelection,!0),option("workTime",100),option("workDelay",100),option("flattenSpans",!0,resetModeState,!0),option("addModeClass",!1,resetModeState,!0),option("pollInterval",100),option("undoDepth",200,function(e,t){return e.doc.history.undoDepth=t}),option("historyEventDelay",1250),option("viewportMargin",10,function(e){return e.refresh()},!0),option("maxHighlightLength",1e4,resetModeState,!0),option("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),option("tabindex",null,function(e,t){return e.display.input.getField().tabIndex=t||""}),option("autofocus",null),option("direction","ltr",function(e,t){return e.doc.setDirection(t)},!0)}(CodeMirror$1),function(e){var t=e.optionHandlers,n=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,n){var r=this.options,i=r[e];r[e]==n&&"mode"!=e||(r[e]=n,t.hasOwnProperty(e)&&operation(this,t[e])(this,n,i),signal(this,"optionChange",this,e))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](getKeyMap(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,n=0;nn&&(indentLine(this,i.head.line,e,!0),n=i.head.line,r==this.doc.sel.primIndex&&ensureCursorVisible(this));else{var o=i.from(),s=i.to(),a=Math.max(n,o.line);n=Math.min(this.lastLine(),s.line-(s.ch?0:1))+1;for(var l=a;l0&&replaceOneSelection(this.doc,r,new ve(o,c[r].to()),A)}}}),getTokenAt:function(e,t){return takeToken(this,e,t)},getLineTokens:function(e,t){return takeToken(this,Pos(e),t,!0)},getTokenTypeAt:function(e){e=clipPos(this.doc,e);var t,n=getLineStyles(this,getLine(this.doc,e.line)),r=0,i=(n.length-1)/2,o=e.ch;if(0==o)t=n[2];else for(;;){var s=r+i>>1;if((s?n[2*s-1]:0)>=o)i=s;else{if(!(n[2*s+1]o&&(e=o,i=!0),r=getLine(this.doc,e)}else r=e;return intoCoordSystem(this,r,{top:0,left:0},t||"page",n||i).top+(i?this.doc.height-heightAtLine(r):0)},defaultTextHeight:function(){return textHeight(this.display)},defaultCharWidth:function(){return charWidth(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,r,i){var o=this.display,s=(e=cursorCoords(this,clipPos(this.doc,e))).bottom,a=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==r)s=e.top;else if("above"==r||"near"==r){var l=Math.max(o.wrapper.clientHeight,this.doc.height),c=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==r||e.bottom+t.offsetHeight>l)&&e.top>t.offsetHeight?s=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=l&&(s=e.bottom),a+t.offsetWidth>c&&(a=c-t.offsetWidth)}t.style.top=s+"px",t.style.left=t.style.right="","right"==i?(a=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?a=0:"middle"==i&&(a=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=a+"px"),n&&function scrollIntoView(e,t){var n=calculateScrollPos(e,t);null!=n.scrollTop&&updateScrollTop(e,n.scrollTop),null!=n.scrollLeft&&setScrollLeft(e,n.scrollLeft)}(this,{left:a,top:s,right:a+t.offsetWidth,bottom:s+t.offsetHeight})},triggerOnKeyDown:methodOp(onKeyDown),triggerOnKeyPress:methodOp(onKeyPress),triggerOnKeyUp:onKeyUp,triggerOnMouseDown:methodOp(onMouseDown),execCommand:function(e){if(Ne.hasOwnProperty(e))return Ne[e].call(null,this)},triggerElectric:methodOp(function(e){triggerElectric(this,e)}),findPosH:function(e,t,n,r){var i=1;t<0&&(i=-1,t=-t);for(var o=clipPos(this.doc,e),s=0;s0&&s(t.charAt(n-1));)--n;for(;r.5)&&estimateLineHeights(this),signal(this,"refresh",this)}),swapDoc:methodOp(function(e){var t=this.doc;return t.cm=null,attachDoc(this,e),clearCaches(this),this.display.input.reset(),scrollToCoords(this,e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,signalLater(this,"swapDoc",this,t),t}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},eventMixin(e),e.registerHelper=function(t,r,i){n.hasOwnProperty(t)||(n[t]=e[t]={_global:[]}),n[t][r]=i},e.registerGlobalHelper=function(t,r,i,o){e.registerHelper(t,r,o),n[t]._global.push({pred:i,val:o})}}(CodeMirror$1);var Ge="iter insert remove copy getEditor constructor".split(" ");for(var Ke in Se.prototype)Se.prototype.hasOwnProperty(Ke)&&indexOf(Ge,Ke)<0&&(CodeMirror$1.prototype[Ke]=function(e){return function(){return e.apply(this.doc,arguments)}}(Se.prototype[Ke]));return eventMixin(Se),CodeMirror$1.inputStyles={textarea:je,contenteditable:Ue},CodeMirror$1.defineMode=function(e){CodeMirror$1.defaults.mode||"null"==e||(CodeMirror$1.defaults.mode=e),function defineMode(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),X[e]=t}.apply(this,arguments)},CodeMirror$1.defineMIME=function defineMIME(e,t){Y[e]=t},CodeMirror$1.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),CodeMirror$1.defineMIME("text/plain","null"),CodeMirror$1.defineExtension=function(e,t){CodeMirror$1.prototype[e]=t},CodeMirror$1.defineDocExtension=function(e,t){Se.prototype[e]=t},CodeMirror$1.fromTextArea=function fromTextArea(e,t){if((t=t?copyObj(t):{}).value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),null==t.autofocus){var n=activeElt();t.autofocus=n==e||null!=e.getAttribute("autofocus")&&n==document.body}function save(){e.value=s.getValue()}var r;if(e.form&&(V(e.form,"submit",save),!t.leaveSubmitMethodAlone)){var i=e.form;r=i.submit;try{var o=i.submit=function(){save(),i.submit=r,i.submit(),i.submit=o}}catch(e){}}t.finishInit=function(t){t.save=save,t.getTextArea=function(){return e},t.toTextArea=function(){t.toTextArea=isNaN,save(),e.parentNode.removeChild(t.getWrapperElement()),e.style.display="",e.form&&(off(e.form,"submit",save),"function"==typeof e.form.submit&&(e.form.submit=r))}},e.style.display="none";var s=CodeMirror$1(function(t){return e.parentNode.insertBefore(t,e.nextSibling)},t);return s},function addLegacyProps(e){e.off=off,e.on=V,e.wheelEventPixels=wheelEventPixels,e.Doc=Se,e.splitLines=K,e.countColumn=countColumn,e.findColumn=findColumn,e.isWordChar=isWordCharBasic,e.Pass=P,e.signal=signal,e.Line=ne,e.changeEnd=changeEnd,e.scrollbarModel=de,e.Pos=Pos,e.cmpPos=cmp,e.modes=X,e.mimeModes=Y,e.resolveMode=resolveMode,e.getMode=getMode,e.modeExtensions=Z,e.extendMode=extendMode,e.copyState=copyState,e.startState=startState,e.innerMode=innerMode,e.commands=Ne,e.keyMap=Ae,e.keyName=keyName,e.isModifierKey=isModifierKey,e.lookupKey=lookupKey,e.normalizeKeyMap=normalizeKeyMap,e.StringStream=Q,e.SharedTextMarker=xe,e.TextMarker=Ce,e.LineWidget=ye,e.e_preventDefault=e_preventDefault,e.e_stopPropagation=e_stopPropagation,e.e_stop=e_stop,e.addClass=addClass,e.contains=contains,e.rmClass=k,e.keyNames=Me}(CodeMirror$1),CodeMirror$1.version="5.33.0",CodeMirror$1},e.exports=r();var r},411:function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){e(t,n);function __(){this.constructor=t}t.prototype=null===n?Object.create(n):(__.prototype=n.prototype,new __)}}();Object.defineProperty(t,"__esModule",{value:!0});var i,o=n(0),s="undefined"==typeof navigator;s||(i=n(410));var a=function(){function Shared(e,t){this.editor=e,this.props=t,this.notifyOfDeprecation()}return Shared.prototype.notifyOfDeprecation=function(){void 0!==this.props.autoScrollCursorOnSet&&console.warn("`autoScrollCursorOnSet` has been deprecated. Use `autoScroll` instead\n\nSee https://github.com/scniro/react-codemirror2#props"),void 0!==this.props.resetCursorOnSet&&console.warn("`resetCursorOnSet` has been deprecated. Use `autoCursor` instead\n\nSee https://github.com/scniro/react-codemirror2#props"),void 0!==this.props.onSet&&console.warn("`onSet` has been deprecated. User `editorDidMount` instead. See https://github.com/scniro/react-codemirror2#events"),void 0!==this.props.onBeforeSet&&console.warn("`onBeforeSet` has been deprecated. User `onBeforeChange` for `Controlled`. instead. See https://github.com/scniro/react-codemirror2#events")},Shared.prototype.wire=function(e){var t=this;switch(e){case"onBlur":this.editor.on("blur",function(e,n){t.props.onBlur(t.editor,n)});break;case"onCursor":this.editor.on("cursorActivity",function(e){t.props.onCursor(t.editor,t.editor.getCursor())});break;case"onCursorActivity":this.editor.on("cursorActivity",function(e){t.props.onCursorActivity(t.editor)});break;case"onDragEnter":this.editor.on("dragenter",function(e,n){t.props.onDragEnter(t.editor,n)});break;case"onDragOver":this.editor.on("dragover",function(e,n){t.props.onDragOver(t.editor,n)});break;case"onDrop":this.editor.on("drop",function(e,n){t.props.onDrop(t.editor,n)});break;case"onFocus":this.editor.on("focus",function(e,n){t.props.onFocus(t.editor,n)});break;case"onGutterClick":this.editor.on("gutterClick",function(e,n,r,i){t.props.onGutterClick(t.editor,n,r,i)});break;case"onKeyDown":this.editor.on("keydown",function(e,n){t.props.onKeyDown(t.editor,n)});break;case"onKeyPress":this.editor.on("keypress",function(e,n){t.props.onKeyPress(t.editor,n)});break;case"onKeyUp":this.editor.on("keyup",function(e,n){t.props.onKeyUp(t.editor,n)});break;case"onScroll":this.editor.on("scroll",function(e){t.props.onScroll(t.editor,t.editor.getScrollInfo())});break;case"onSelection":this.editor.on("beforeSelectionChange",function(e,n){t.props.onSelection(t.editor,n)});break;case"onUpdate":this.editor.on("update",function(e){t.props.onUpdate(t.editor)});break;case"onViewportChange":this.editor.on("viewportChange",function(e,n,r){t.props.onViewportChange(t.editor,n,r)})}},Shared}(),l=function(e){r(Controlled,e);function Controlled(t){var n=e.call(this,t)||this;return s?n:(n.deferred=null,n.emulating=!1,n.hydrated=!1,n.initCb=function(){n.props.editorDidConfigure&&n.props.editorDidConfigure(n.editor)},n.mounted=!1,n)}return Controlled.prototype.setCursor=function(e,t,n){var r=this.editor.getDoc();n&&this.editor.focus(),t?r.setCursor(e):r.setCursor(e,null,{scroll:!1})},Controlled.prototype.moveCursor=function(e,t){var n=this.editor.getDoc();t?n.setCursor(e):n.setCursor(e,null,{scroll:!1})},Controlled.prototype.hydrate=function(e){var t=this;Object.keys(e.options||{}).forEach(function(n){t.editor.setOption(n,e.options[n]),t.mirror.setOption(n,e.options[n])}),this.hydrated||(this.mounted&&this.deferred?this.resolveChange():this.initChange(e.value||"")),this.hydrated=!0},Controlled.prototype.initChange=function(e){this.emulating=!0;var t=this.editor.lastLine(),n=this.editor.getLine(this.editor.lastLine()).length;this.editor.replaceRange(e||"",{line:0,ch:0},{line:t,ch:n}),this.mirror.setValue(e),this.editor.clearHistory(),this.mirror.clearHistory(),this.emulating=!1},Controlled.prototype.resolveChange=function(){this.emulating=!0,"undo"===this.deferred.origin?this.editor.undo():"redo"===this.deferred.origin?this.editor.redo():this.editor.replaceRange(this.deferred.text,this.deferred.from,this.deferred.to,this.deferred.origin),this.emulating=!1,this.deferred=null},Controlled.prototype.mirrorChange=function(e){return"undo"===e.origin?(this.editor.setHistory(this.mirror.getHistory()),this.mirror.undo()):"redo"===e.origin?(this.editor.setHistory(this.mirror.getHistory()),this.mirror.redo()):this.mirror.replaceRange(e.text,e.from,e.to,e.origin),this.mirror.getValue()},Controlled.prototype.componentWillMount=function(){s||this.props.editorWillMount&&this.props.editorWillMount()},Controlled.prototype.componentDidMount=function(){var e=this;if(!s){if(this.props.defineMode&&this.props.defineMode.name&&this.props.defineMode.fn&&i.defineMode(this.props.defineMode.name,this.props.defineMode.fn),this.editor=i(this.ref),this.shared=new a(this.editor,this.props),this.mirror=i(function(){}),this.editor.on("electricInput",function(){e.mirror.setHistory(e.editor.getHistory())}),this.editor.on("cursorActivity",function(){e.mirror.setCursor(e.editor.getCursor())}),this.editor.on("beforeChange",function(t,n){if(!e.emulating){n.cancel(),e.deferred=n;var r=e.mirrorChange(e.deferred);e.props.onBeforeChange&&e.props.onBeforeChange(e.editor,e.deferred,r)}}),this.editor.on("change",function(t,n){e.mounted&&e.props.onChange&&e.props.onChange(e.editor,n,e.editor.getValue())}),this.props.onBlur&&this.shared.wire("onBlur"),this.props.onCursor&&this.shared.wire("onCursor"),this.props.onCursorActivity&&this.shared.wire("onCursorActivity"),this.props.onDragEnter&&this.shared.wire("onDragEnter"),this.props.onDragOver&&this.shared.wire("onDragOver"),this.props.onDrop&&this.shared.wire("onDrop"),this.props.onFocus&&this.shared.wire("onFocus"),this.props.onGutterClick&&this.shared.wire("onGutterClick"),this.props.onKeyDown&&this.shared.wire("onKeyDown"),this.props.onKeyPress&&this.shared.wire("onKeyPress"),this.props.onKeyUp&&this.shared.wire("onKeyUp"),this.props.onScroll&&this.shared.wire("onScroll"),this.props.onSelection&&this.shared.wire("onSelection"),this.props.onUpdate&&this.shared.wire("onUpdate"),this.props.onViewportChange&&this.shared.wire("onViewportChange"),this.hydrate(this.props),this.props.selection){this.editor.getDoc().setSelections(this.props.selection)}this.props.cursor&&this.setCursor(this.props.cursor,this.props.autoScroll||!1,this.props.autoFocus||!1),this.props.scroll&&this.editor.scrollTo(this.props.scroll.x,this.props.scroll.y),this.mounted=!0,this.props.editorDidMount&&this.props.editorDidMount(this.editor,this.editor.getValue(),this.initCb)}},Controlled.prototype.componentWillReceiveProps=function(e){if(!s){var t;e.value!==this.props.value&&(this.hydrated=!1),this.props.autoCursor||void 0===this.props.autoCursor||(t=this.editor.getCursor()),this.hydrate(e),this.props.autoCursor||void 0===this.props.autoCursor||this.moveCursor(t,this.props.autoScroll||!1)}},Controlled.prototype.componentWillUnmount=function(){s||this.props.editorWillUnmount&&this.props.editorWillUnmount(i)},Controlled.prototype.shouldComponentUpdate=function(e,t){return!s},Controlled.prototype.render=function(){var e=this;if(s)return null;var t=this.props.className?"react-codemirror2 "+this.props.className:"react-codemirror2";return o.createElement("div",{className:t,ref:function(t){return e.ref=t}})},Controlled}(o.Component);t.Controlled=l;var c=function(e){r(UnControlled,e);function UnControlled(t){var n=e.call(this,t)||this;return s?n:(n.continueChange=!1,n.hydrated=!1,n.initCb=function(){n.props.editorDidConfigure&&n.props.editorDidConfigure(n.editor)},n.mounted=!1,n.onBeforeChangeCb=function(){n.continueChange=!0},n)}return UnControlled.prototype.setCursor=function(e,t,n){var r=this.editor.getDoc();n&&this.editor.focus(),t?r.setCursor(e):r.setCursor(e,null,{scroll:!1})},UnControlled.prototype.moveCursor=function(e,t){var n=this.editor.getDoc();t?n.setCursor(e):n.setCursor(e,null,{scroll:!1})},UnControlled.prototype.hydrate=function(e){var t=this;if(Object.keys(e.options||{}).forEach(function(n){return t.editor.setOption(n,e.options[n])}),!this.hydrated){var n=this.editor.lastLine(),r=this.editor.getLine(this.editor.lastLine()).length;this.editor.replaceRange(e.value||"",{line:0,ch:0},{line:n,ch:r})}this.hydrated=!0},UnControlled.prototype.componentWillMount=function(){s||this.props.editorWillMount&&this.props.editorWillMount()},UnControlled.prototype.componentDidMount=function(){var e=this;if(!s){if(this.props.defineMode&&this.props.defineMode.name&&this.props.defineMode.fn&&i.defineMode(this.props.defineMode.name,this.props.defineMode.fn),this.editor=i(this.ref),this.shared=new a(this.editor,this.props),this.editor.on("beforeChange",function(t,n){e.props.onBeforeChange&&e.props.onBeforeChange(e.editor,n,null,e.onBeforeChangeCb)}),this.editor.on("change",function(t,n){if(e.mounted)if(e.props.onBeforeChange){if(!e.continueChange)return;e.props.onChange(e.editor,n,e.editor.getValue())}else e.props.onChange(e.editor,n,e.editor.getValue())}),this.props.onBlur&&this.shared.wire("onBlur"),this.props.onCursor&&this.shared.wire("onCursor"),this.props.onCursorActivity&&this.shared.wire("onCursorActivity"),this.props.onDragEnter&&this.shared.wire("onDragEnter"),this.props.onDragOver&&this.shared.wire("onDragOver"),this.props.onDrop&&this.shared.wire("onDrop"),this.props.onFocus&&this.shared.wire("onFocus"),this.props.onGutterClick&&this.shared.wire("onGutterClick"),this.props.onKeyDown&&this.shared.wire("onKeyDown"),this.props.onKeyPress&&this.shared.wire("onKeyPress"),this.props.onKeyUp&&this.shared.wire("onKeyUp"),this.props.onScroll&&this.shared.wire("onScroll"),this.props.onSelection&&this.shared.wire("onSelection"),this.props.onUpdate&&this.shared.wire("onUpdate"),this.props.onViewportChange&&this.shared.wire("onViewportChange"),this.hydrate(this.props),this.props.selection){this.editor.getDoc().setSelections(this.props.selection)}this.props.cursor&&this.setCursor(this.props.cursor,this.props.autoScroll||!1,this.props.autoFocus||!1),this.props.scroll&&this.editor.scrollTo(this.props.scroll.x,this.props.scroll.y),this.mounted=!0,this.editor.clearHistory(),this.props.editorDidMount&&this.props.editorDidMount(this.editor,this.editor.getValue(),this.initCb)}},UnControlled.prototype.componentWillReceiveProps=function(e){if(!s){var t;e.value!==this.props.value&&(this.hydrated=!1),this.props.autoCursor||void 0===this.props.autoCursor||(t=this.editor.getCursor()),this.hydrate(e),this.props.autoCursor||void 0===this.props.autoCursor||this.moveCursor(t,this.props.autoScroll||!1)}},UnControlled.prototype.componentWillUnmount=function(){s||this.props.editorWillUnmount&&this.props.editorWillUnmount(i)},UnControlled.prototype.shouldComponentUpdate=function(e,t){return!s},UnControlled.prototype.render=function(){var e=this;if(s)return null;var t=this.props.className?"react-codemirror2 "+this.props.className:"react-codemirror2";return o.createElement("div",{className:t,ref:function(t){return e.ref=t}})},UnControlled}(o.Component);t.UnControlled=c},412:function(e,t,n){(function(e){"use strict";function Context(e,t,n,r){this.state=e,this.mode=t,this.depth=n,this.prev=r}e.defineMode("jsx",function(t,n){var r=e.getMode(t,{name:"xml",allowMissing:!0,multilineTagIndentPastTag:!1,allowMissingTagName:!0}),i=e.getMode(t,n&&n.base||"javascript");function flatXMLIndent(e){var t=e.tagName;e.tagName=null;var n=r.indent(e,"");return e.tagName=t,n}function token(n,o){return o.context.mode==r?function xmlToken(n,o,s){if(2==s.depth)return n.match(/^.*?\*\//)?s.depth=1:n.skipToEnd(),"comment";if("{"==n.peek()){r.skipAttribute(s.state);var a=flatXMLIndent(s.state),l=s.state.context;if(l&&n.match(/^[^>]*>\s*$/,!1)){for(;l.prev&&!l.startOfLine;)l=l.prev;l.startOfLine?a-=t.indentUnit:s.prev.state.lexical&&(a=s.prev.state.lexical.indented)}else 1==s.depth&&(a+=t.indentUnit);return o.context=new Context(e.startState(i,a),i,0,o.context),null}if(1==s.depth){if("<"==n.peek())return r.skipAttribute(s.state),o.context=new Context(e.startState(r,flatXMLIndent(s.state)),r,0,o.context),null;if(n.match("//"))return n.skipToEnd(),"comment";if(n.match("/*"))return s.depth=2,token(n,o)}var c,u=r.token(n,s.state),d=n.current();/\btag\b/.test(u)?/>$/.test(d)?s.state.context?s.depth=0:o.context=o.context.prev:/^-1&&n.backUp(d.length-c);return u}(n,o,o.context):function jsToken(t,n,o){if("<"==t.peek()&&i.expressionAllowed(t,o.state))return i.skipExpression(o.state),n.context=new Context(e.startState(r,i.indent(o.state,"")),r,0,n.context),null;var s=i.token(t,o.state);if(!s&&null!=o.depth){var a=t.current();"{"==a?o.depth++:"}"==a&&0==--o.depth&&(n.context=n.context.prev)}return s}(n,o,o.context)}return{startState:function(){return{context:new Context(e.startState(i),i)}},copyState:function(t){return{context:function copyContext(t){return new Context(e.copyState(t.mode,t.state),t.mode,t.depth,t.prev&©Context(t.prev))}(t.context)}},token:token,indent:function(e,t,n){return e.context.mode.indent(e.context.state,t,n)},innerMode:function(e){return e.context}}},"xml","javascript"),e.defineMIME("text/jsx","jsx"),e.defineMIME("text/typescript-jsx",{name:"jsx",base:{name:"javascript",typescript:!0}})})(n(410),n(413),n(414))},413:function(e,t,n){(function(e){"use strict";var t={autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0},n={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,allowMissingTagName:!1,caseFold:!1};e.defineMode("xml",function(r,i){var o=r.indentUnit,s={},a=i.htmlMode?t:n;for(var l in a)s[l]=a[l];for(var l in i)s[l]=i[l];var c,u;function inText(e,t){function chain(n){return t.tokenize=n,n(e,t)}var n=e.next();if("<"==n)return e.eat("!")?e.eat("[")?e.match("CDATA[")?chain(inBlock("atom","]]>")):null:e.match("--")?chain(inBlock("comment","--\x3e")):e.match("DOCTYPE",!0,!0)?(e.eatWhile(/[\w\._\-]/),chain(function doctype(e){return function(t,n){for(var r;null!=(r=t.next());){if("<"==r)return n.tokenize=doctype(e+1),n.tokenize(t,n);if(">"==r){if(1==e){n.tokenize=inText;break}return n.tokenize=doctype(e-1),n.tokenize(t,n)}}return"meta"}}(1))):null:e.eat("?")?(e.eatWhile(/[\w\._\-]/),t.tokenize=inBlock("meta","?>"),"meta"):(c=e.eat("/")?"closeTag":"openTag",t.tokenize=inTag,"tag bracket");if("&"==n){return(e.eat("#")?e.eat("x")?e.eatWhile(/[a-fA-F\d]/)&&e.eat(";"):e.eatWhile(/[\d]/)&&e.eat(";"):e.eatWhile(/[\w\.\-:]/)&&e.eat(";"))?"atom":"error"}return e.eatWhile(/[^&<]/),null}inText.isInText=!0;function inTag(e,t){var n=e.next();if(">"==n||"/"==n&&e.eat(">"))return t.tokenize=inText,c=">"==n?"endTag":"selfcloseTag","tag bracket";if("="==n)return c="equals",null;if("<"==n){t.tokenize=inText,t.state=baseState,t.tagName=t.tagStart=null;var r=t.tokenize(e,t);return r?r+" tag error":"tag error"}return/[\'\"]/.test(n)?(t.tokenize=function inAttribute(e){var t=function(t,n){for(;!t.eol();)if(t.next()==e){n.tokenize=inTag;break}return"string"};return t.isInAttribute=!0,t}(n),t.stringStartCol=e.column(),t.tokenize(e,t)):(e.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function inBlock(e,t){return function(n,r){for(;!n.eol();){if(n.match(t)){r.tokenize=inText;break}n.next()}return e}}function popContext(e){e.context&&(e.context=e.context.prev)}function maybePopContext(e,t){for(var n;;){if(!e.context)return;if(n=e.context.tagName,!s.contextGrabbers.hasOwnProperty(n)||!s.contextGrabbers[n].hasOwnProperty(t))return;popContext(e)}}function baseState(e,t,n){return"openTag"==e?(n.tagStart=t.column(),tagNameState):"closeTag"==e?closeTagNameState:baseState}function tagNameState(e,t,n){return"word"==e?(n.tagName=t.current(),u="tag",attrState):s.allowMissingTagName&&"endTag"==e?(u="tag bracket",attrState(e,t,n)):(u="error",tagNameState)}function closeTagNameState(e,t,n){if("word"==e){var r=t.current();return n.context&&n.context.tagName!=r&&s.implicitlyClosed.hasOwnProperty(n.context.tagName)&&popContext(n),n.context&&n.context.tagName==r||!1===s.matchClosing?(u="tag",closeState):(u="tag error",closeStateErr)}return s.allowMissingTagName&&"endTag"==e?(u="tag bracket",closeState(e,t,n)):(u="error",closeStateErr)}function closeState(e,t,n){return"endTag"!=e?(u="error",closeState):(popContext(n),baseState)}function closeStateErr(e,t,n){return u="error",closeState(e,0,n)}function attrState(e,t,n){if("word"==e)return u="attribute",attrEqState;if("endTag"==e||"selfcloseTag"==e){var r=n.tagName,i=n.tagStart;return n.tagName=n.tagStart=null,"selfcloseTag"==e||s.autoSelfClosers.hasOwnProperty(r)?maybePopContext(n,r):(maybePopContext(n,r),n.context=new function Context(e,t,n){this.prev=e.context,this.tagName=t,this.indent=e.indented,this.startOfLine=n,(s.doNotIndent.hasOwnProperty(t)||e.context&&e.context.noIndent)&&(this.noIndent=!0)}(n,r,i==n.indented)),baseState}return u="error",attrState}function attrEqState(e,t,n){return"equals"==e?attrValueState:(s.allowMissing||(u="error"),attrState(e,0,n))}function attrValueState(e,t,n){return"string"==e?attrContinuedState:"word"==e&&s.allowUnquoted?(u="string",attrState):(u="error",attrState(e,0,n))}function attrContinuedState(e,t,n){return"string"==e?attrContinuedState:attrState(e,0,n)}return{startState:function(e){var t={tokenize:inText,state:baseState,indented:e||0,tagName:null,tagStart:null,context:null};return null!=e&&(t.baseIndent=e),t},token:function(e,t){if(!t.tagName&&e.sol()&&(t.indented=e.indentation()),e.eatSpace())return null;c=null;var n=t.tokenize(e,t);return(n||c)&&"comment"!=n&&(u=null,t.state=t.state(c||n,e,t),u&&(n="error"==u?n+" error":u)),n},indent:function(t,n,r){var i=t.context;if(t.tokenize.isInAttribute)return t.tagStart==t.indented?t.stringStartCol+1:t.indented+o;if(i&&i.noIndent)return e.Pass;if(t.tokenize!=inTag&&t.tokenize!=inText)return r?r.match(/^(\s*)/)[0].length:0;if(t.tagName)return!1!==s.multilineTagIndentPastTag?t.tagStart+t.tagName.length+2:t.tagStart+o*(s.multilineTagIndentFactor||1);if(s.alignCDATA&&/$/,blockCommentStart:"\x3c!--",blockCommentEnd:"--\x3e",configuration:s.htmlMode?"html":"xml",helperType:s.htmlMode?"html":"xml",skipAttribute:function(e){e.state==attrValueState&&(e.state=attrState)}}}),e.defineMIME("text/xml","xml"),e.defineMIME("application/xml","xml"),e.mimeModes.hasOwnProperty("text/html")||e.defineMIME("text/html",{name:"xml",htmlMode:!0})})(n(410))},414:function(e,t,n){(function(e){"use strict";e.defineMode("javascript",function(t,n){var r=t.indentUnit,i=n.statementIndent,o=n.jsonld,s=n.json||o,a=n.typescript,l=n.wordCharacters||/[\w$\xa1-\uffff]/,c=function(){function kw(e){return{type:e,style:"keyword"}}var e=kw("keyword a"),t=kw("keyword b"),n=kw("keyword c"),r=kw("keyword d"),i=kw("operator"),o={type:"atom",style:"atom"};return{if:kw("if"),while:e,with:e,else:t,do:t,try:t,finally:t,return:r,break:r,continue:r,new:kw("new"),delete:n,void:n,throw:n,debugger:kw("debugger"),var:kw("var"),const:kw("var"),let:kw("var"),function:kw("function"),catch:kw("catch"),for:kw("for"),switch:kw("switch"),case:kw("case"),default:kw("default"),in:i,typeof:i,instanceof:i,true:o,false:o,null:o,undefined:o,NaN:o,Infinity:o,this:kw("this"),class:kw("class"),super:kw("atom"),yield:n,export:kw("export"),import:kw("import"),extends:n,await:n}}(),u=/[+\-*&%=<>!?|~^@]/,d=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;var p,h;function ret(e,t,n){return p=e,h=n,t}function tokenBase(e,t){var n=e.next();if('"'==n||"'"==n)return t.tokenize=function tokenString(e){return function(t,n){var r,i=!1;if(o&&"@"==t.peek()&&t.match(d))return n.tokenize=tokenBase,ret("jsonld-keyword","meta");for(;null!=(r=t.next())&&(r!=e||i);)i=!i&&"\\"==r;return i||(n.tokenize=tokenBase),ret("string","string")}}(n),t.tokenize(e,t);if("."==n&&e.match(/^\d+(?:[eE][+\-]?\d+)?/))return ret("number","number");if("."==n&&e.match(".."))return ret("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(n))return ret(n);if("="==n&&e.eat(">"))return ret("=>","operator");if("0"==n&&e.eat(/x/i))return e.eatWhile(/[\da-f]/i),ret("number","number");if("0"==n&&e.eat(/o/i))return e.eatWhile(/[0-7]/i),ret("number","number");if("0"==n&&e.eat(/b/i))return e.eatWhile(/[01]/i),ret("number","number");if(/\d/.test(n))return e.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),ret("number","number");if("/"==n)return e.eat("*")?(t.tokenize=tokenComment,tokenComment(e,t)):e.eat("/")?(e.skipToEnd(),ret("comment","comment")):expressionAllowed(e,t,1)?(function readRegexp(e){for(var t,n=!1,r=!1;null!=(t=e.next());){if(!n){if("/"==t&&!r)return;"["==t?r=!0:r&&"]"==t&&(r=!1)}n=!n&&"\\"==t}}(e),e.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/),ret("regexp","string-2")):(e.eat("="),ret("operator","operator",e.current()));if("`"==n)return t.tokenize=tokenQuasi,tokenQuasi(e,t);if("#"==n)return e.skipToEnd(),ret("error","error");if(u.test(n))return">"==n&&t.lexical&&">"==t.lexical.type||(e.eat("=")?"!"!=n&&"="!=n||e.eat("="):/[<>*+\-]/.test(n)&&(e.eat(n),">"==n&&e.eat(n))),ret("operator","operator",e.current());if(l.test(n)){e.eatWhile(l);var r=e.current();if("."!=t.lastType){if(c.propertyIsEnumerable(r)){var i=c[r];return ret(i.type,i.style,r)}if("async"==r&&e.match(/^(\s|\/\*.*?\*\/)*[\(\w]/,!1))return ret("async","keyword",r)}return ret("variable","variable",r)}}function tokenComment(e,t){for(var n,r=!1;n=e.next();){if("/"==n&&r){t.tokenize=tokenBase;break}r="*"==n}return ret("comment","comment")}function tokenQuasi(e,t){for(var n,r=!1;null!=(n=e.next());){if(!r&&("`"==n||"$"==n&&e.eat("{"))){t.tokenize=tokenBase;break}r=!r&&"\\"==n}return ret("quasi","string-2",e.current())}var f="([{}])";function findFatArrow(e,t){t.fatArrowAt&&(t.fatArrowAt=null);var n=e.string.indexOf("=>",e.start);if(!(n<0)){if(a){var r=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(e.string.slice(e.start,n));r&&(n=r.index)}for(var i=0,o=!1,s=n-1;s>=0;--s){var c=e.string.charAt(s),u=f.indexOf(c);if(u>=0&&u<3){if(!i){++s;break}if(0==--i){"("==c&&(o=!0);break}}else if(u>=3&&u<6)++i;else if(l.test(c))o=!0;else{if(/["'\/]/.test(c))return;if(o&&!i){++s;break}}}o&&!i&&(t.fatArrowAt=s)}}var g={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,"jsonld-keyword":!0};function JSLexical(e,t,n,r,i,o){this.indented=e,this.column=t,this.type=n,this.prev=i,this.info=o,null!=r&&(this.align=r)}function inScope(e,t){for(var n=e.localVars;n;n=n.next)if(n.name==t)return!0;for(var r=e.context;r;r=r.prev)for(n=r.vars;n;n=n.next)if(n.name==t)return!0}var m={state:null,column:null,marked:null,cc:null};function pass(){for(var e=arguments.length-1;e>=0;e--)m.cc.push(arguments[e])}function cont(){return pass.apply(null,arguments),!0}function register(e){function inList(t){for(var n=t;n;n=n.next)if(n.name==e)return!0;return!1}var t=m.state;if(m.marked="def",t.context){if(inList(t.localVars))return;t.localVars={name:e,next:t.localVars}}else{if(inList(t.globalVars))return;n.globalVars&&(t.globalVars={name:e,next:t.globalVars})}}function isModifier(e){return"public"==e||"private"==e||"protected"==e||"abstract"==e||"readonly"==e}var v={name:"this",next:{name:"arguments"}};function pushcontext(){m.state.context={prev:m.state.context,vars:m.state.localVars},m.state.localVars=v}function popcontext(){m.state.localVars=m.state.context.vars,m.state.context=m.state.context.prev}function pushlex(e,t){var n=function(){var n=m.state,r=n.indented;if("stat"==n.lexical.type)r=n.lexical.indented;else for(var i=n.lexical;i&&")"==i.type&&i.align;i=i.prev)r=i.indented;n.lexical=new JSLexical(r,m.stream.column(),e,null,n.lexical,t)};return n.lex=!0,n}function poplex(){var e=m.state;e.lexical.prev&&(")"==e.lexical.type&&(e.indented=e.lexical.indented),e.lexical=e.lexical.prev)}poplex.lex=!0;function expect(e){return function exp(t){return t==e?cont():";"==e?pass():cont(exp)}}function statement(e,t){return"var"==e?cont(pushlex("vardef",t.length),vardef,expect(";"),poplex):"keyword a"==e?cont(pushlex("form"),parenExpr,statement,poplex):"keyword b"==e?cont(pushlex("form"),statement,poplex):"keyword d"==e?m.stream.match(/^\s*$/,!1)?cont():cont(pushlex("stat"),maybeexpression,expect(";"),poplex):"debugger"==e?cont(expect(";")):"{"==e?cont(pushlex("}"),block,poplex):";"==e?cont():"if"==e?("else"==m.state.lexical.info&&m.state.cc[m.state.cc.length-1]==poplex&&m.state.cc.pop()(),cont(pushlex("form"),parenExpr,statement,poplex,maybeelse)):"function"==e?cont(functiondef):"for"==e?cont(pushlex("form"),forspec,statement,poplex):"class"==e||a&&"interface"==t?(m.marked="keyword",cont(pushlex("form"),className,poplex)):"variable"==e?a&&"type"==t?(m.marked="keyword",cont(typeexpr,expect("operator"),typeexpr,expect(";"))):a&&"declare"==t?(m.marked="keyword",cont(statement)):a&&("module"==t||"enum"==t)&&m.stream.match(/^\s*\w/,!1)?(m.marked="keyword",cont(pushlex("form"),pattern,expect("{"),pushlex("}"),block,poplex,poplex)):a&&"namespace"==t?(m.marked="keyword",cont(pushlex("form"),expression,block,poplex)):cont(pushlex("stat"),maybelabel):"switch"==e?cont(pushlex("form"),parenExpr,expect("{"),pushlex("}","switch"),block,poplex,poplex):"case"==e?cont(expression,expect(":")):"default"==e?cont(expect(":")):"catch"==e?cont(pushlex("form"),pushcontext,expect("("),funarg,expect(")"),statement,poplex,popcontext):"export"==e?cont(pushlex("stat"),afterExport,poplex):"import"==e?cont(pushlex("stat"),afterImport,poplex):"async"==e?cont(statement):"@"==t?cont(expression,statement):pass(pushlex("stat"),expression,expect(";"),poplex)}function expression(e,t){return expressionInner(e,t,!1)}function expressionNoComma(e,t){return expressionInner(e,t,!0)}function parenExpr(e){return"("!=e?pass():cont(pushlex(")"),expression,expect(")"),poplex)}function expressionInner(e,t,n){if(m.state.fatArrowAt==m.stream.start){var r=n?arrowBodyNoComma:arrowBody;if("("==e)return cont(pushcontext,pushlex(")"),commasep(funarg,")"),poplex,expect("=>"),r,popcontext);if("variable"==e)return pass(pushcontext,pattern,expect("=>"),r,popcontext)}var i=n?maybeoperatorNoComma:maybeoperatorComma;return g.hasOwnProperty(e)?cont(i):"function"==e?cont(functiondef,i):"class"==e||a&&"interface"==t?(m.marked="keyword",cont(pushlex("form"),classExpression,poplex)):"keyword c"==e||"async"==e?cont(n?expressionNoComma:expression):"("==e?cont(pushlex(")"),maybeexpression,expect(")"),poplex,i):"operator"==e||"spread"==e?cont(n?expressionNoComma:expression):"["==e?cont(pushlex("]"),arrayLiteral,poplex,i):"{"==e?contCommasep(objprop,"}",null,i):"quasi"==e?pass(quasi,i):"new"==e?cont(function maybeTarget(e){return function(t){return"."==t?cont(e?targetNoComma:target):"variable"==t&&a?cont(maybeTypeArgs,e?maybeoperatorNoComma:maybeoperatorComma):pass(e?expressionNoComma:expression)}}(n)):cont()}function maybeexpression(e){return e.match(/[;\}\)\],]/)?pass():pass(expression)}function maybeoperatorComma(e,t){return","==e?cont(expression):maybeoperatorNoComma(e,t,!1)}function maybeoperatorNoComma(e,t,n){var r=0==n?maybeoperatorComma:maybeoperatorNoComma,i=0==n?expression:expressionNoComma;return"=>"==e?cont(pushcontext,n?arrowBodyNoComma:arrowBody,popcontext):"operator"==e?/\+\+|--/.test(t)||a&&"!"==t?cont(r):a&&"<"==t&&m.stream.match(/^([^>]|<.*?>)*>\s*\(/,!1)?cont(pushlex(">"),commasep(typeexpr,">"),poplex,r):"?"==t?cont(expression,expect(":"),i):cont(i):"quasi"==e?pass(quasi,r):";"!=e?"("==e?contCommasep(expressionNoComma,")","call",r):"."==e?cont(property,r):"["==e?cont(pushlex("]"),maybeexpression,expect("]"),poplex,r):a&&"as"==t?(m.marked="keyword",cont(typeexpr,r)):"regexp"==e?(m.state.lastType=m.marked="operator",m.stream.backUp(m.stream.pos-m.stream.start-1),cont(i)):void 0:void 0}function quasi(e,t){return"quasi"!=e?pass():"${"!=t.slice(t.length-2)?cont(quasi):cont(expression,continueQuasi)}function continueQuasi(e){if("}"==e)return m.marked="string-2",m.state.tokenize=tokenQuasi,cont(quasi)}function arrowBody(e){return findFatArrow(m.stream,m.state),pass("{"==e?statement:expression)}function arrowBodyNoComma(e){return findFatArrow(m.stream,m.state),pass("{"==e?statement:expressionNoComma)}function target(e,t){if("target"==t)return m.marked="keyword",cont(maybeoperatorComma)}function targetNoComma(e,t){if("target"==t)return m.marked="keyword",cont(maybeoperatorNoComma)}function maybelabel(e){return":"==e?cont(poplex,statement):pass(maybeoperatorComma,expect(";"),poplex)}function property(e){if("variable"==e)return m.marked="property",cont()}function objprop(e,t){if("async"==e)return m.marked="property",cont(objprop);if("variable"==e||"keyword"==m.style){if(m.marked="property","get"==t||"set"==t)return cont(getterSetter);var n;return a&&m.state.fatArrowAt==m.stream.start&&(n=m.stream.match(/^\s*:\s*/,!1))&&(m.state.fatArrowAt=m.stream.pos+n[0].length),cont(afterprop)}return"number"==e||"string"==e?(m.marked=o?"property":m.style+" property",cont(afterprop)):"jsonld-keyword"==e?cont(afterprop):a&&isModifier(t)?(m.marked="keyword",cont(objprop)):"["==e?cont(expression,maybetype,expect("]"),afterprop):"spread"==e?cont(expressionNoComma,afterprop):"*"==t?(m.marked="keyword",cont(objprop)):":"==e?pass(afterprop):void 0}function getterSetter(e){return"variable"!=e?pass(afterprop):(m.marked="property",cont(functiondef))}function afterprop(e){return":"==e?cont(expressionNoComma):"("==e?pass(functiondef):void 0}function commasep(e,t,n){function proceed(r,i){if(n?n.indexOf(r)>-1:","==r){var o=m.state.lexical;return"call"==o.info&&(o.pos=(o.pos||0)+1),cont(function(n,r){return n==t||r==t?pass():pass(e)},proceed)}return r==t||i==t?cont():cont(expect(t))}return function(n,r){return n==t||r==t?cont():pass(e,proceed)}}function contCommasep(e,t,n){for(var r=3;r"==e)return cont(typeexpr)}function typeprop(e,t){return"variable"==e||"keyword"==m.style?(m.marked="property",cont(typeprop)):"?"==t?cont(typeprop):":"==e?cont(typeexpr):"["==e?cont(expression,maybetype,expect("]"),typeprop):void 0}function typearg(e){return"variable"==e?cont(typearg):":"==e?cont(typeexpr):void 0}function afterType(e,t){return"<"==t?cont(pushlex(">"),commasep(typeexpr,">"),poplex,afterType):"|"==t||"."==e?cont(typeexpr):"["==e?cont(expect("]"),afterType):"extends"==t||"implements"==t?(m.marked="keyword",cont(typeexpr)):void 0}function maybeTypeArgs(e,t){if("<"==t)return cont(pushlex(">"),commasep(typeexpr,">"),poplex,afterType)}function typeparam(){return pass(typeexpr,maybeTypeDefault)}function maybeTypeDefault(e,t){if("="==t)return cont(typeexpr)}function vardef(){return pass(pattern,maybetype,maybeAssign,vardefCont)}function pattern(e,t){return a&&isModifier(t)?(m.marked="keyword",cont(pattern)):"variable"==e?(register(t),cont()):"spread"==e?cont(pattern):"["==e?contCommasep(pattern,"]"):"{"==e?contCommasep(proppattern,"}"):void 0}function proppattern(e,t){return"variable"!=e||m.stream.match(/^\s*:/,!1)?("variable"==e&&(m.marked="property"),"spread"==e?cont(pattern):"}"==e?pass():cont(expect(":"),pattern,maybeAssign)):(register(t),cont(maybeAssign))}function maybeAssign(e,t){if("="==t)return cont(expressionNoComma)}function vardefCont(e){if(","==e)return cont(vardef)}function maybeelse(e,t){if("keyword b"==e&&"else"==t)return cont(pushlex("form","else"),statement,poplex)}function forspec(e){if("("==e)return cont(pushlex(")"),forspec1,expect(")"),poplex)}function forspec1(e){return"var"==e?cont(vardef,expect(";"),forspec2):";"==e?cont(forspec2):"variable"==e?cont(formaybeinof):pass(expression,expect(";"),forspec2)}function formaybeinof(e,t){return"in"==t||"of"==t?(m.marked="keyword",cont(expression)):cont(maybeoperatorComma,forspec2)}function forspec2(e,t){return";"==e?cont(forspec3):"in"==t||"of"==t?(m.marked="keyword",cont(expression)):pass(expression,expect(";"),forspec3)}function forspec3(e){")"!=e&&cont(expression)}function functiondef(e,t){return"*"==t?(m.marked="keyword",cont(functiondef)):"variable"==e?(register(t),cont(functiondef)):"("==e?cont(pushcontext,pushlex(")"),commasep(funarg,")"),poplex,mayberettype,statement,popcontext):a&&"<"==t?cont(pushlex(">"),commasep(typeparam,">"),poplex,functiondef):void 0}function funarg(e,t){return"@"==t&&cont(expression,funarg),"spread"==e?cont(funarg):a&&isModifier(t)?(m.marked="keyword",cont(funarg)):pass(pattern,maybetype,maybeAssign)}function classExpression(e,t){return"variable"==e?className(e,t):classNameAfter(e,t)}function className(e,t){if("variable"==e)return register(t),cont(classNameAfter)}function classNameAfter(e,t){return"<"==t?cont(pushlex(">"),commasep(typeparam,">"),poplex,classNameAfter):"extends"==t||"implements"==t||a&&","==e?cont(a?typeexpr:expression,classNameAfter):"{"==e?cont(pushlex("}"),classBody,poplex):void 0}function classBody(e,t){return"async"==e||"variable"==e&&("static"==t||"get"==t||"set"==t||a&&isModifier(t))&&m.stream.match(/^\s+[\w$\xa1-\uffff]/,!1)?(m.marked="keyword",cont(classBody)):"variable"==e||"keyword"==m.style?(m.marked="property",cont(a?classfield:functiondef,classBody)):"["==e?cont(expression,maybetype,expect("]"),a?classfield:functiondef,classBody):"*"==t?(m.marked="keyword",cont(classBody)):";"==e?cont(classBody):"}"==e?cont():"@"==t?cont(expression,classBody):void 0}function classfield(e,t){return"?"==t?cont(classfield):":"==e?cont(typeexpr,maybeAssign):"="==t?cont(expressionNoComma):pass(functiondef)}function afterExport(e,t){return"*"==t?(m.marked="keyword",cont(maybeFrom,expect(";"))):"default"==t?(m.marked="keyword",cont(expression,expect(";"))):"{"==e?cont(commasep(exportField,"}"),maybeFrom,expect(";")):pass(statement)}function exportField(e,t){return"as"==t?(m.marked="keyword",cont(expect("variable"))):"variable"==e?pass(expressionNoComma,exportField):void 0}function afterImport(e){return"string"==e?cont():pass(importSpec,maybeMoreImports,maybeFrom)}function importSpec(e,t){return"{"==e?contCommasep(importSpec,"}"):("variable"==e&®ister(t),"*"==t&&(m.marked="keyword"),cont(maybeAs))}function maybeMoreImports(e){if(","==e)return cont(importSpec,maybeMoreImports)}function maybeAs(e,t){if("as"==t)return m.marked="keyword",cont(importSpec)}function maybeFrom(e,t){if("from"==t)return m.marked="keyword",cont(expression)}function arrayLiteral(e){return"]"==e?cont():pass(commasep(expressionNoComma,"]"))}function expressionAllowed(e,t,n){return t.tokenize==tokenBase&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(t.lastType)||"quasi"==t.lastType&&/\{\s*$/.test(e.string.slice(0,e.pos-(n||0)))}return{startState:function(e){var t={tokenize:tokenBase,lastType:"sof",cc:[],lexical:new JSLexical((e||0)-r,0,"block",!1),localVars:n.localVars,context:n.localVars&&{vars:n.localVars},indented:e||0};return n.globalVars&&"object"==typeof n.globalVars&&(t.globalVars=n.globalVars),t},token:function(e,t){if(e.sol()&&(t.lexical.hasOwnProperty("align")||(t.lexical.align=!1),t.indented=e.indentation(),findFatArrow(e,t)),t.tokenize!=tokenComment&&e.eatSpace())return null;var n=t.tokenize(e,t);return"comment"==p?n:(t.lastType="operator"!=p||"++"!=h&&"--"!=h?p:"incdec",function parseJS(e,t,n,r,i){var o=e.cc;for(m.state=e,m.stream=i,m.marked=null,m.cc=o,m.style=t,e.lexical.hasOwnProperty("align")||(e.lexical.align=!0);;)if((o.length?o.pop():s?expression:statement)(n,r)){for(;o.length&&o[o.length-1].lex;)o.pop()();return m.marked?m.marked:"variable"==n&&inScope(e,r)?"variable-2":t}}(t,n,p,h,e))},indent:function(t,o){if(t.tokenize==tokenComment)return e.Pass;if(t.tokenize!=tokenBase)return 0;var s,a=o&&o.charAt(0),l=t.lexical;if(!/^\s*else\b/.test(o))for(var c=t.cc.length-1;c>=0;--c){var d=t.cc[c];if(d==poplex)l=l.prev;else if(d!=maybeelse)break}for(;("stat"==l.type||"form"==l.type)&&("}"==a||(s=t.cc[t.cc.length-1])&&(s==maybeoperatorComma||s==maybeoperatorNoComma)&&!/^[,\.=+\-*:?[\(]/.test(o));)l=l.prev;i&&")"==l.type&&"stat"==l.prev.type&&(l=l.prev);var p=l.type,h=a==p;return"vardef"==p?l.indented+("operator"==t.lastType||","==t.lastType?l.info+1:0):"form"==p&&"{"==a?l.indented:"form"==p?l.indented+r:"stat"==p?l.indented+(function isContinuedStatement(e,t){return"operator"==e.lastType||","==e.lastType||u.test(t.charAt(0))||/[,.]/.test(t.charAt(0))}(t,o)?i||r:0):"switch"!=l.info||h||0==n.doubleIndentSwitch?l.align?l.column+(h?0:1):l.indented+(h?0:r):l.indented+(/^(?:case|default)\b/.test(o)?r:2*r)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:s?null:"/*",blockCommentEnd:s?null:"*/",blockCommentContinue:s?null:" * ",lineComment:s?null:"//",fold:"brace",closeBrackets:"()[]{}''\"\"``",helperType:s?"json":"javascript",jsonldMode:o,jsonMode:s,expressionAllowed:expressionAllowed,skipExpression:function(e){var t=e.cc[e.cc.length-1];t!=expression&&t!=expressionNoComma||e.cc.pop()}}}),e.registerHelper("wordChars","javascript",/[\w$]/),e.defineMIME("text/javascript","javascript"),e.defineMIME("text/ecmascript","javascript"),e.defineMIME("application/javascript","javascript"),e.defineMIME("application/x-javascript","javascript"),e.defineMIME("application/ecmascript","javascript"),e.defineMIME("application/json",{name:"javascript",json:!0}),e.defineMIME("application/x-json",{name:"javascript",json:!0}),e.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),e.defineMIME("text/typescript",{name:"javascript",typescript:!0}),e.defineMIME("application/typescript",{name:"javascript",typescript:!0})})(n(410))},415:function(e,t,n){var r=n(416);"string"==typeof r&&(r=[[e.i,r,""]]);var i={hmr:!0};i.transform=void 0;n(112)(r,i);r.locals&&(e.exports=r.locals)},416:function(e,t,n){(e.exports=n(111)(void 0)).push([e.i,"/* BASICS */\n\n.CodeMirror {\n /* Set height, width, borders, and global font properties here */\n font-family: monospace;\n height: 300px;\n color: black;\n direction: ltr;\n}\n\n/* PADDING */\n\n.CodeMirror-lines {\n padding: 4px 0; /* Vertical padding around content */\n}\n.CodeMirror pre {\n padding: 0 4px; /* Horizontal padding of content */\n}\n\n.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {\n background-color: white; /* The little square between H and V scrollbars */\n}\n\n/* GUTTER */\n\n.CodeMirror-gutters {\n border-right: 1px solid #ddd;\n background-color: #f7f7f7;\n white-space: nowrap;\n}\n.CodeMirror-linenumbers {}\n.CodeMirror-linenumber {\n padding: 0 3px 0 5px;\n min-width: 20px;\n text-align: right;\n color: #999;\n white-space: nowrap;\n}\n\n.CodeMirror-guttermarker { color: black; }\n.CodeMirror-guttermarker-subtle { color: #999; }\n\n/* CURSOR */\n\n.CodeMirror-cursor {\n border-left: 1px solid black;\n border-right: none;\n width: 0;\n}\n/* Shown when moving in bi-directional text */\n.CodeMirror div.CodeMirror-secondarycursor {\n border-left: 1px solid silver;\n}\n.cm-fat-cursor .CodeMirror-cursor {\n width: auto;\n border: 0 !important;\n background: #7e7;\n}\n.cm-fat-cursor div.CodeMirror-cursors {\n z-index: 1;\n}\n.cm-fat-cursor-mark {\n background-color: rgba(20, 255, 20, 0.5);\n -webkit-animation: blink 1.06s steps(1) infinite;\n -moz-animation: blink 1.06s steps(1) infinite;\n animation: blink 1.06s steps(1) infinite;\n}\n.cm-animate-fat-cursor {\n width: auto;\n border: 0;\n -webkit-animation: blink 1.06s steps(1) infinite;\n -moz-animation: blink 1.06s steps(1) infinite;\n animation: blink 1.06s steps(1) infinite;\n background-color: #7e7;\n}\n@-moz-keyframes blink {\n 0% {}\n 50% { background-color: transparent; }\n 100% {}\n}\n@-webkit-keyframes blink {\n 0% {}\n 50% { background-color: transparent; }\n 100% {}\n}\n@keyframes blink {\n 0% {}\n 50% { background-color: transparent; }\n 100% {}\n}\n\n/* Can style cursor different in overwrite (non-insert) mode */\n.CodeMirror-overwrite .CodeMirror-cursor {}\n\n.cm-tab { display: inline-block; text-decoration: inherit; }\n\n.CodeMirror-rulers {\n position: absolute;\n left: 0; right: 0; top: -50px; bottom: -20px;\n overflow: hidden;\n}\n.CodeMirror-ruler {\n border-left: 1px solid #ccc;\n top: 0; bottom: 0;\n position: absolute;\n}\n\n/* DEFAULT THEME */\n\n.cm-s-default .cm-header {color: blue;}\n.cm-s-default .cm-quote {color: #090;}\n.cm-negative {color: #d44;}\n.cm-positive {color: #292;}\n.cm-header, .cm-strong {font-weight: bold;}\n.cm-em {font-style: italic;}\n.cm-link {text-decoration: underline;}\n.cm-strikethrough {text-decoration: line-through;}\n\n.cm-s-default .cm-keyword {color: #708;}\n.cm-s-default .cm-atom {color: #219;}\n.cm-s-default .cm-number {color: #164;}\n.cm-s-default .cm-def {color: #00f;}\n.cm-s-default .cm-variable,\n.cm-s-default .cm-punctuation,\n.cm-s-default .cm-property,\n.cm-s-default .cm-operator {}\n.cm-s-default .cm-variable-2 {color: #05a;}\n.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}\n.cm-s-default .cm-comment {color: #a50;}\n.cm-s-default .cm-string {color: #a11;}\n.cm-s-default .cm-string-2 {color: #f50;}\n.cm-s-default .cm-meta {color: #555;}\n.cm-s-default .cm-qualifier {color: #555;}\n.cm-s-default .cm-builtin {color: #30a;}\n.cm-s-default .cm-bracket {color: #997;}\n.cm-s-default .cm-tag {color: #170;}\n.cm-s-default .cm-attribute {color: #00c;}\n.cm-s-default .cm-hr {color: #999;}\n.cm-s-default .cm-link {color: #00c;}\n\n.cm-s-default .cm-error {color: #f00;}\n.cm-invalidchar {color: #f00;}\n\n.CodeMirror-composing { border-bottom: 2px solid; }\n\n/* Default styles for common addons */\n\ndiv.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}\ndiv.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}\n.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }\n.CodeMirror-activeline-background {background: #e8f2ff;}\n\n/* STOP */\n\n/* The rest of this file contains styles related to the mechanics of\n the editor. You probably shouldn't touch them. */\n\n.CodeMirror {\n position: relative;\n overflow: hidden;\n background: white;\n}\n\n.CodeMirror-scroll {\n overflow: scroll !important; /* Things will break if this is overridden */\n /* 30px is the magic margin used to hide the element's real scrollbars */\n /* See overflow: hidden in .CodeMirror */\n margin-bottom: -30px; margin-right: -30px;\n padding-bottom: 30px;\n height: 100%;\n outline: none; /* Prevent dragging from highlighting the element */\n position: relative;\n}\n.CodeMirror-sizer {\n position: relative;\n border-right: 30px solid transparent;\n}\n\n/* The fake, visible scrollbars. Used to force redraw during scrolling\n before actual scrolling happens, thus preventing shaking and\n flickering artifacts. */\n.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {\n position: absolute;\n z-index: 6;\n display: none;\n}\n.CodeMirror-vscrollbar {\n right: 0; top: 0;\n overflow-x: hidden;\n overflow-y: scroll;\n}\n.CodeMirror-hscrollbar {\n bottom: 0; left: 0;\n overflow-y: hidden;\n overflow-x: scroll;\n}\n.CodeMirror-scrollbar-filler {\n right: 0; bottom: 0;\n}\n.CodeMirror-gutter-filler {\n left: 0; bottom: 0;\n}\n\n.CodeMirror-gutters {\n position: absolute; left: 0; top: 0;\n min-height: 100%;\n z-index: 3;\n}\n.CodeMirror-gutter {\n white-space: normal;\n height: 100%;\n display: inline-block;\n vertical-align: top;\n margin-bottom: -30px;\n}\n.CodeMirror-gutter-wrapper {\n position: absolute;\n z-index: 4;\n background: none !important;\n border: none !important;\n}\n.CodeMirror-gutter-background {\n position: absolute;\n top: 0; bottom: 0;\n z-index: 4;\n}\n.CodeMirror-gutter-elt {\n position: absolute;\n cursor: default;\n z-index: 4;\n}\n.CodeMirror-gutter-wrapper ::selection { background-color: transparent }\n.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }\n\n.CodeMirror-lines {\n cursor: text;\n min-height: 1px; /* prevents collapsing before first draw */\n}\n.CodeMirror pre {\n /* Reset some styles that the rest of the page might have set */\n -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;\n border-width: 0;\n background: transparent;\n font-family: inherit;\n font-size: inherit;\n margin: 0;\n white-space: pre;\n word-wrap: normal;\n line-height: inherit;\n color: inherit;\n z-index: 2;\n position: relative;\n overflow: visible;\n -webkit-tap-highlight-color: transparent;\n -webkit-font-variant-ligatures: contextual;\n font-variant-ligatures: contextual;\n}\n.CodeMirror-wrap pre {\n word-wrap: break-word;\n white-space: pre-wrap;\n word-break: normal;\n}\n\n.CodeMirror-linebackground {\n position: absolute;\n left: 0; right: 0; top: 0; bottom: 0;\n z-index: 0;\n}\n\n.CodeMirror-linewidget {\n position: relative;\n z-index: 2;\n padding: 0.1px; /* Force widget margins to stay inside of the container */\n}\n\n.CodeMirror-widget {}\n\n.CodeMirror-rtl pre { direction: rtl; }\n\n.CodeMirror-code {\n outline: none;\n}\n\n/* Force content-box sizing for the elements where we expect it */\n.CodeMirror-scroll,\n.CodeMirror-sizer,\n.CodeMirror-gutter,\n.CodeMirror-gutters,\n.CodeMirror-linenumber {\n -moz-box-sizing: content-box;\n box-sizing: content-box;\n}\n\n.CodeMirror-measure {\n position: absolute;\n width: 100%;\n height: 0;\n overflow: hidden;\n visibility: hidden;\n}\n\n.CodeMirror-cursor {\n position: absolute;\n pointer-events: none;\n}\n.CodeMirror-measure pre { position: static; }\n\ndiv.CodeMirror-cursors {\n visibility: hidden;\n position: relative;\n z-index: 3;\n}\ndiv.CodeMirror-dragcursors {\n visibility: visible;\n}\n\n.CodeMirror-focused div.CodeMirror-cursors {\n visibility: visible;\n}\n\n.CodeMirror-selected { background: #d9d9d9; }\n.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }\n.CodeMirror-crosshair { cursor: crosshair; }\n.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }\n.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }\n\n.cm-searching {\n background-color: #ffa;\n background-color: rgba(255, 255, 0, .4);\n}\n\n/* Used to force a border model for a node */\n.cm-force-border { padding-right: .1px; }\n\n@media print {\n /* Hide the cursor when printing */\n .CodeMirror div.CodeMirror-cursors {\n visibility: hidden;\n }\n}\n\n/* See issue #2901 */\n.cm-tab-wrap-hack:after { content: ''; }\n\n/* Help users use markselection to safely style text background */\nspan.CodeMirror-selectedtext { background: none; }\n",""])},417:function(e,t,n){var r=n(418);"string"==typeof r&&(r=[[e.i,r,""]]);var i={hmr:!0};i.transform=void 0;n(112)(r,i);r.locals&&(e.exports=r.locals)},418:function(e,t,n){(e.exports=n(111)(void 0)).push([e.i,"/*\n\n Name: Base16 Default Light\n Author: Chris Kempson (http://chriskempson.com)\n\n CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)\n Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)\n\n*/\n\n.cm-s-base16-light.CodeMirror { background: #f5f5f5; color: #202020; }\n.cm-s-base16-light div.CodeMirror-selected { background: #e0e0e0; }\n.cm-s-base16-light .CodeMirror-line::selection, .cm-s-base16-light .CodeMirror-line > span::selection, .cm-s-base16-light .CodeMirror-line > span > span::selection { background: #e0e0e0; }\n.cm-s-base16-light .CodeMirror-line::-moz-selection, .cm-s-base16-light .CodeMirror-line > span::-moz-selection, .cm-s-base16-light .CodeMirror-line > span > span::-moz-selection { background: #e0e0e0; }\n.cm-s-base16-light .CodeMirror-gutters { background: #f5f5f5; border-right: 0px; }\n.cm-s-base16-light .CodeMirror-guttermarker { color: #ac4142; }\n.cm-s-base16-light .CodeMirror-guttermarker-subtle { color: #b0b0b0; }\n.cm-s-base16-light .CodeMirror-linenumber { color: #b0b0b0; }\n.cm-s-base16-light .CodeMirror-cursor { border-left: 1px solid #505050; }\n\n.cm-s-base16-light span.cm-comment { color: #8f5536; }\n.cm-s-base16-light span.cm-atom { color: #aa759f; }\n.cm-s-base16-light span.cm-number { color: #aa759f; }\n\n.cm-s-base16-light span.cm-property, .cm-s-base16-light span.cm-attribute { color: #90a959; }\n.cm-s-base16-light span.cm-keyword { color: #ac4142; }\n.cm-s-base16-light span.cm-string { color: #f4bf75; }\n\n.cm-s-base16-light span.cm-variable { color: #90a959; }\n.cm-s-base16-light span.cm-variable-2 { color: #6a9fb5; }\n.cm-s-base16-light span.cm-def { color: #d28445; }\n.cm-s-base16-light span.cm-bracket { color: #202020; }\n.cm-s-base16-light span.cm-tag { color: #ac4142; }\n.cm-s-base16-light span.cm-link { color: #aa759f; }\n.cm-s-base16-light span.cm-error { background: #ac4142; color: #505050; }\n\n.cm-s-base16-light .CodeMirror-activeline-background { background: #DDDCDC; }\n.cm-s-base16-light .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }\n",""])}}); ================================================ FILE: docs/build/bundle.a71e23e0.js ================================================ !function(e){var t=window.webpackJsonp;window.webpackJsonp=function webpackJsonpCallback(n,i,a){for(var o,s,l=0,u=[];l0&&void 0!==arguments[0]?arguments[0]:"unnamed",t=arguments[1],n=arguments[2],o=n.jss,s=(0,a.default)(t),l=o.plugins.onCreateRule(e,s,n);if(l)return l;"@"===e[0]&&(0,r.default)(!1,"[JSS] Unknown at-rule %s",e);return new i.default(e,s,n)};var r=_interopRequireDefault(n(9)),i=_interopRequireDefault(n(16)),a=_interopRequireDefault(n(204));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}},function(e,t,n){var r=n(14),i=n(8),a="[object Symbol]";e.exports=function isSymbol(e){return"symbol"==typeof e||i(e)&&r(e)==a}},function(e,t,n){var r=n(30),i=1/0;e.exports=function toKey(e){if("string"==typeof e||r(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}},function(e,t,n){"use strict";n.d(t,"b",function(){return l}),n.d(t,"a",function(){return u});var r=n(134),i=n(238),a=n(309),o=n(313),s=n(315),l="rsg-code-editor",u="rsg-usage",c=[a.a];t.c={sectionToolbar:c,componentToolbar:c,exampleToolbar:c,exampleTabButtons:[{id:l,render:o.a}],exampleTabs:[{id:l,render:r.a}],docsTabButtons:[{id:u,render:s.a}],docsTabs:[{id:u,render:i.a}]}},function(e,t,n){var r=n(22),i=n(149),a=n(150),o=n(151),s=n(152),l=n(153);function Stack(e){var t=this.__data__=new r(e);this.size=t.size}Stack.prototype.clear=i,Stack.prototype.delete=a,Stack.prototype.get=o,Stack.prototype.has=s,Stack.prototype.set=l,e.exports=Stack},function(e,t,n){var r=n(13)(n(3),"Map");e.exports=r},function(e,t,n){var r=n(14),i=n(4),a="[object AsyncFunction]",o="[object Function]",s="[object GeneratorFunction]",l="[object Proxy]";e.exports=function isFunction(e){if(!i(e))return!1;var t=r(e);return t==o||t==s||t==a||t==l}},function(e,t,n){var r=n(160),i=n(167),a=n(169),o=n(170),s=n(171);function MapCache(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t-1&&e%1==0&&e<=n}},function(e,t,n){(function(e){var r=n(3),i=n(182),a="object"==typeof t&&t&&!t.nodeType&&t,o=a&&"object"==typeof e&&e&&!e.nodeType&&e,s=o&&o.exports===a?r.Buffer:void 0,l=(s?s.isBuffer:void 0)||i;e.exports=l}).call(t,n(28)(e))},function(e,t,n){var r=n(184),i=n(185),a=n(186),o=a&&a.isTypedArray,s=o?i(o):r;e.exports=s},function(e,t){var n=9007199254740991,r=/^(?:0|[1-9]\d*)$/;e.exports=function isIndex(e,t){return!!(t=null==t?n:t)&&("number"==typeof e||r.test(e))&&e>-1&&e%1==0&&e2&&void 0!==arguments[2]?arguments[2]:{},i="";if(!t)return i;var a=n.indent,o=void 0===a?0:a,s=t.fallbacks;if(o++,s)if(Array.isArray(s))for(var l=0;l1&&void 0!==arguments[1]&&arguments[1];if(!Array.isArray(e))return e;var n="";if(Array.isArray(e[0]))for(var i=0;i=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(e,["children","color","size","style","width","height"]),p=t.reactIconBase,h=void 0===p?{}:p,f=o||h.size||"1em";return i.default.createElement("svg",r({children:n,fill:"currentColor",preserveAspectRatio:"xMidYMid meet",height:u||f,width:l||f},h,c,{style:r({verticalAlign:"middle",color:a||h.color},h.style||{},s)}))};o.propTypes={color:a.default.string,size:a.default.oneOfType([a.default.string,a.default.number]),width:a.default.oneOfType([a.default.string,a.default.number]),height:a.default.oneOfType([a.default.string,a.default.number]),style:a.default.object},o.contextTypes={reactIconBase:a.default.shape(o.propTypes)},t.default=o,e.exports=t.default},function(e,t,n){"use strict";var r=n(342);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);n.n(r);t.NameProvider=class extends r.Component{constructor(){super(...arguments),this.state={name:"Piotr"}}render(){return this.props.children(this.state)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);n.n(r);t.MouseProvider=class extends r.Component{constructor(){super(...arguments),this.state={x:0,y:0},this.handleMouseMove=(e=>{this.setState({x:e.clientX,y:e.clientY})})}render(){return r.createElement("div",{style:{height:"100%"},onMouseMove:this.handleMouseMove},this.props.render(this.state))}}},function(e,t,n){"use strict";var r=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;e.exports=function shouldUseNative(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,o,s=function toObject(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),l=1;l=this.index)t.push(e);else for(var r=0;rn)return void t.splice(r,0,e)}},{key:"reset",value:function reset(){this.registry=[]}},{key:"remove",value:function remove(e){var t=this.registry.indexOf(e);this.registry.splice(t,1)}},{key:"toString",value:function toString(e){return this.registry.filter(function(e){return e.attached}).map(function(t){return t.toString(e)}).join("\n")}},{key:"index",get:function get(){return 0===this.registry.length?0:this.registry[this.registry.length-1].options.index}}]),SheetsRegistry}();t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(n(205));t.default=function(e){return e&&e[r.default]&&e===e[r.default]()}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function linkRule(e,t){e.renderable=t,e.rules&&t.cssRules&&e.rules.link(t.cssRules)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=_interopRequireDefault(n(9)),i=(_interopRequireDefault(n(79)),_interopRequireDefault(n(209)));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}t.default=function(){var e=0;return function(t,n){(e+=1)>1e10&&(0,r.default)(!1,"[JSS] You might have a memory leak. Rule counter is at %s.",e);var a="c",o="";return n&&(a=n.options.classNamePrefix||"c",null!=n.options.jss.id&&(o+=n.options.jss.id)),""+a+i.default+o+e}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t1&&(n=[t.shift()],t.forEach(function(e,t){if(a){var o="separator-"+(e.key||t);i=r.cloneElement(i,{key:o})}return n.push(i,e)})),r.createElement(e.inline?"span":"div",{className:e.className},n)}Group.propTypes={children:i.node,inline:i.bool,separator:i.node,className:i.string},Group.defaultProps={separator:" "},e.exports=Group},function(e,t,n){"use strict";(function(e){var r=n(243),i=n(244),a=n(245);t.Buffer=Buffer,t.SlowBuffer=function SlowBuffer(e){+e!=e&&(e=0);return Buffer.alloc(+e)},t.INSPECT_MAX_BYTES=50,Buffer.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function typedArraySupport(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=kMaxLength();function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(e,t){if(kMaxLength()=kMaxLength())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength().toString(16)+" bytes");return 0|e}Buffer.isBuffer=function isBuffer(e){return!(null==e||!e._isBuffer)},Buffer.compare=function compare(e,t){if(!Buffer.isBuffer(e)||!Buffer.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,a=Math.min(n,r);i>>1;case"base64":return base64ToBytes(e).length;default:if(r)return utf8ToBytes(e).length;t=(""+t).toLowerCase(),r=!0}}Buffer.byteLength=byteLength;Buffer.prototype._isBuffer=!0;function swap(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}Buffer.prototype.swap16=function swap16(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;tthis.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,n);case"utf8":case"utf-8":return utf8Slice(this,t,n);case"ascii":return asciiSlice(this,t,n);case"latin1":case"binary":return latin1Slice(this,t,n);case"base64":return base64Slice(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}.apply(this,arguments)},Buffer.prototype.equals=function equals(e){if(!Buffer.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Buffer.compare(this,e)},Buffer.prototype.inspect=function inspect(){var e="",n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},Buffer.prototype.compare=function compare(e,t,n,r,i){if(!Buffer.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;for(var a=i-r,o=n-t,s=Math.min(a,o),l=this.slice(r,i),u=e.slice(t,n),c=0;c2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=Buffer.from(t,r)),Buffer.isBuffer(t))return 0===t.length?-1:arrayIndexOf(e,t,n,r,i);if("number"==typeof t)return t&=255,Buffer.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):arrayIndexOf(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,n,r,i){var a=1,o=e.length,s=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function read(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}var l;if(i){var u=-1;for(l=n;lo&&(n=o-s),l=n;l>=0;l--){for(var c=!0,p=0;pi&&(r=i):r=i;var a=t.length;if(a%2!=0)throw new TypeError("Invalid hex string");r>a/2&&(r=a/2);for(var o=0;oi)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var a=!1;;)switch(r){case"hex":return hexWrite(this,e,t,n);case"utf8":case"utf-8":return f=t,d=n,blitBuffer(utf8ToBytes(e,(h=this).length-f),h,f,d);case"ascii":return asciiWrite(this,e,t,n);case"latin1":case"binary":return asciiWrite(this,e,t,n);case"base64":return u=this,c=t,p=n,blitBuffer(base64ToBytes(e),u,c,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=t,l=n,blitBuffer(function utf16leToBytes(e,t){for(var n,r,i,a=[],o=0;o>8,i=n%256,a.push(i),a.push(r);return a}(e,(o=this).length-s),o,s,l);default:if(a)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),a=!0}var o,s,l,u,c,p,h,f,d},Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function utf8Slice(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i239?4:a>223?3:a>191?2:1;if(i+l<=n){var u,c,p,h;switch(l){case 1:a<128&&(s=a);break;case 2:128==(192&(u=e[i+1]))&&(h=(31&a)<<6|63&u)>127&&(s=h);break;case 3:u=e[i+1],c=e[i+2],128==(192&u)&&128==(192&c)&&(h=(15&a)<<12|(63&u)<<6|63&c)>2047&&(h<55296||h>57343)&&(s=h);break;case 4:u=e[i+1],c=e[i+2],p=e[i+3],128==(192&u)&&128==(192&c)&&128==(192&p)&&(h=(15&a)<<18|(63&u)<<12|(63&c)<<6|63&p)>65535&&h<1114112&&(s=h)}}null===s?(s=65533,l=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),i+=l}return function decodeCodePointsArray(e){var t=e.length;if(t<=o)return String.fromCharCode.apply(String,e);var n="",r=0;for(;rr)&&(n=r);for(var i="",a=t;an&&(e=n),t<0?(t+=n)<0&&(t=0):t>n&&(t=n),tn)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(e,t,n){e|=0,t|=0,n||checkOffset(e,t,this.length);for(var r=this[e],i=1,a=0;++a0&&(i*=256);)r+=this[e+--t]*i;return r},Buffer.prototype.readUInt8=function readUInt8(e,t){return t||checkOffset(e,1,this.length),this[e]},Buffer.prototype.readUInt16LE=function readUInt16LE(e,t){return t||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUInt16BE=function readUInt16BE(e,t){return t||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUInt32LE=function readUInt32LE(e,t){return t||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUInt32BE=function readUInt32BE(e,t){return t||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function readIntLE(e,t,n){e|=0,t|=0,n||checkOffset(e,t,this.length);for(var r=this[e],i=1,a=0;++a=(i*=128)&&(r-=Math.pow(2,8*t)),r},Buffer.prototype.readIntBE=function readIntBE(e,t,n){e|=0,t|=0,n||checkOffset(e,t,this.length);for(var r=t,i=1,a=this[e+--r];r>0&&(i*=256);)a+=this[e+--r]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*t)),a},Buffer.prototype.readInt8=function readInt8(e,t){return t||checkOffset(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function readInt16LE(e,t){t||checkOffset(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},Buffer.prototype.readInt16BE=function readInt16BE(e,t){t||checkOffset(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},Buffer.prototype.readInt32LE=function readInt32LE(e,t){return t||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function readInt32BE(e,t){return t||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function readFloatLE(e,t){return t||checkOffset(e,4,this.length),i.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function readFloatBE(e,t){return t||checkOffset(e,4,this.length),i.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function readDoubleLE(e,t){return t||checkOffset(e,8,this.length),i.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function readDoubleBE(e,t){return t||checkOffset(e,8,this.length),i.read(this,e,!1,52,8)};function checkInt(e,t,n,r,i,a){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(e,t,n,r){if(e=+e,t|=0,n|=0,!r){checkInt(this,e,t,n,Math.pow(2,8*n)-1,0)}var i=1,a=0;for(this[t]=255&e;++a=0&&(a*=256);)this[t+i]=e/a&255;return t+n},Buffer.prototype.writeUInt8=function writeUInt8(e,t,n){return e=+e,t|=0,n||checkInt(this,e,t,1,255,0),Buffer.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1};function objectWriteUInt16(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,a=Math.min(e.length-n,2);i>>8*(r?i:1-i)}Buffer.prototype.writeUInt16LE=function writeUInt16LE(e,t,n){return e=+e,t|=0,n||checkInt(this,e,t,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):objectWriteUInt16(this,e,t,!0),t+2},Buffer.prototype.writeUInt16BE=function writeUInt16BE(e,t,n){return e=+e,t|=0,n||checkInt(this,e,t,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):objectWriteUInt16(this,e,t,!1),t+2};function objectWriteUInt32(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,a=Math.min(e.length-n,4);i>>8*(r?i:3-i)&255}Buffer.prototype.writeUInt32LE=function writeUInt32LE(e,t,n){return e=+e,t|=0,n||checkInt(this,e,t,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):objectWriteUInt32(this,e,t,!0),t+4},Buffer.prototype.writeUInt32BE=function writeUInt32BE(e,t,n){return e=+e,t|=0,n||checkInt(this,e,t,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):objectWriteUInt32(this,e,t,!1),t+4},Buffer.prototype.writeIntLE=function writeIntLE(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);checkInt(this,e,t,n,i-1,-i)}var a=0,o=1,s=0;for(this[t]=255&e;++a>0)-s&255;return t+n},Buffer.prototype.writeIntBE=function writeIntBE(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);checkInt(this,e,t,n,i-1,-i)}var a=n-1,o=1,s=0;for(this[t+a]=255&e;--a>=0&&(o*=256);)e<0&&0===s&&0!==this[t+a+1]&&(s=1),this[t+a]=(e/o>>0)-s&255;return t+n},Buffer.prototype.writeInt8=function writeInt8(e,t,n){return e=+e,t|=0,n||checkInt(this,e,t,1,127,-128),Buffer.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function writeInt16LE(e,t,n){return e=+e,t|=0,n||checkInt(this,e,t,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):objectWriteUInt16(this,e,t,!0),t+2},Buffer.prototype.writeInt16BE=function writeInt16BE(e,t,n){return e=+e,t|=0,n||checkInt(this,e,t,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):objectWriteUInt16(this,e,t,!1),t+2},Buffer.prototype.writeInt32LE=function writeInt32LE(e,t,n){return e=+e,t|=0,n||checkInt(this,e,t,4,2147483647,-2147483648),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):objectWriteUInt32(this,e,t,!0),t+4},Buffer.prototype.writeInt32BE=function writeInt32BE(e,t,n){return e=+e,t|=0,n||checkInt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):objectWriteUInt32(this,e,t,!1),t+4};function checkIEEE754(e,t,n,r,i,a){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function writeFloat(e,t,n,r,a){return a||checkIEEE754(e,0,n,4),i.write(e,t,n,r,23,4),n+4}Buffer.prototype.writeFloatLE=function writeFloatLE(e,t,n){return writeFloat(this,e,t,!0,n)},Buffer.prototype.writeFloatBE=function writeFloatBE(e,t,n){return writeFloat(this,e,t,!1,n)};function writeDouble(e,t,n,r,a){return a||checkIEEE754(e,0,n,8),i.write(e,t,n,r,52,8),n+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(e,t,n){return writeDouble(this,e,t,!0,n)},Buffer.prototype.writeDoubleBE=function writeDoubleBE(e,t,n){return writeDouble(this,e,t,!1,n)},Buffer.prototype.copy=function copy(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--i)e[i+t]=this[i+n];else if(a<1e3||!Buffer.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,e||(e=0);var a;if("number"==typeof e)for(a=t;a55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return a}function base64ToBytes(e){return r.toByteArray(function base64clean(e){if((e=function stringtrim(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(s,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function blitBuffer(e,t,n,r){for(var i=0;i=t.length||i>=e.length);++i)t[i+n]=e[i];return i}}).call(t,n(7))},function(e,t,n){"use strict";var r=n(246);n.d(t,"a",function(){return r.a})},function(e,t,n){var r=n(68),i=n(50);e.exports=function baseForOwn(e,t){return e&&r(e,t,i)}},function(e,t,n){var r=n(254),i=n(278),a=n(43),o=n(5),s=n(287);e.exports=function baseIteratee(e){return"function"==typeof e?e:null==e?a:"object"==typeof e?o(e)?i(e[0],e[1]):r(e):s(e)}},function(e,t,n){var r=n(256),i=n(8);e.exports=function baseIsEqual(e,t,n,a,o){return e===t||(null==e||null==t||!i(e)&&!i(t)?e!=e&&t!=t:r(e,t,n,a,baseIsEqual,o))}},function(e,t,n){var r=n(257),i=n(260),a=n(261),o=1,s=2;e.exports=function equalArrays(e,t,n,l,u,c){var p=n&o,h=e.length,f=t.length;if(h!=f&&!(p&&f>h))return!1;var d=c.get(e);if(d&&c.get(t))return d==t;var m=-1,g=!0,y=n&s?new r:void 0;for(c.set(e,t),c.set(t,e);++m0&&void 0!==arguments[0]?arguments[0]:{},t=e.name,n=e.slug,r=e.example,i=e.anchor,a=e.isolated,o=e.nochrome,s=e.absolute,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window.location,u=l.origin,c=l.pathname;o&&(c+="?nochrome");i?c+="#"+n:(a||o)&&(c+="#!/"+t);void 0!==r&&(c+="/"+r);if(s)return u+c;return c}},function(e,t,n){"use strict";var r=n(314);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";t.a=function getFilterRegExp(e){return e=e.replace(/[^a-z0-9]/gi,"").split("").join(".*"),new RegExp(e,"i")}},function(e,t,n){"use strict";var r=n(328);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";var r=n(331);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";var r=n(349);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";e.exports={HOMEPAGE:"https://react-styleguidist.js.org/",BUGS:"https://github.com/styleguidist/react-styleguidist/issues",DOCS_CONFIG:"https://react-styleguidist.js.org/docs/configuration.html",DOCS_COMPONENTS:"https://react-styleguidist.js.org/docs/components.html",DOCS_WEBPACK:"https://react-styleguidist.js.org/docs/webpack.html",DOCS_DOCUMENTING:"https://react-styleguidist.js.org/docs/documenting.html",DOCS_THIRDPARTIES:"https://react-styleguidist.js.org/docs/thirdparties.html"}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);n.n(r);t.SFCCounter=(e=>{const{label:t,count:n,onIncrement:i}=e;return r.createElement("div",null,r.createElement("span",null,t,": ",n," "),r.createElement("button",{type:"button",onClick:()=>{i()}},"Increment"))})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);n.n(r);t.GenericList=class extends r.Component{render(){const{items:e,itemRenderer:t}=this.props;return r.createElement("div",null,e.map(t))}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(386),i=n(0);n.n(i);t.SFCSpreadAttributes=(e=>{const{children:t}=e,n=r.a(e,["children"]);return i.createElement("div",Object.assign({},n),t)})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);n.n(r);t.StatefulCounter=class extends r.Component{constructor(){super(...arguments),this.state={count:0},this.handleIncrement=(()=>{this.setState({count:this.state.count+1})})}render(){const{handleIncrement:e}=this,{label:t}=this.props,{count:n}=this.state;return r.createElement("div",null,r.createElement("span",null,t,": ",n," "),r.createElement("button",{type:"button",onClick:e},"Increment"))}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);n.n(r);const i=(a=class extends r.Component{constructor(){super(...arguments),this.state={count:this.props.initialCount},this.handleIncrement=(()=>{this.setState({count:this.state.count+1})})}componentWillReceiveProps({initialCount:e}){null!=e&&e!==this.props.initialCount&&this.setState({count:e})}render(){const{handleIncrement:e}=this,{label:t}=this.props,{count:n}=this.state;return r.createElement("div",null,r.createElement("span",null,t,": ",n," "),r.createElement("button",{type:"button",onClick:e},"Increment"))}},a.defaultProps={initialCount:0},a);t.StatefulCounterWithDefault=i;var a},function(e,t){e.exports=function pad(e,t){var n="000000000"+e;return n.substr(n.length-t)}},function(e,t){e.exports=function(e){var t=[];return t.toString=function toString(){return this.map(function(t){var n=function cssWithMappingToString(e,t){var n=e[1]||"",r=e[3];if(!r)return n;if(t&&"function"==typeof btoa){var i=function toComment(e){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(e))))+" */"}(r),a=r.sources.map(function(e){return"/*# sourceURL="+r.sourceRoot+e+" */"});return[n].concat(a).concat([i]).join("\n")}return[n].join("\n")}(t,e);return t[2]?"@media "+t[2]+"{"+n+"}":n}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var r={},i=0;i=0&&l.splice(t,1)}function createStyleElement(e){var t=document.createElement("style");return e.attrs.type="text/css",addAttrs(t,e.attrs),insertStyleElement(e,t),t}function addAttrs(e,t){Object.keys(t).forEach(function(n){e.setAttribute(n,t[n])})}function addStyle(e,t){var n,r,i,a;if(t.transform&&e.css){if(!(a=t.transform(e.css)))return function(){};e.css=a}if(t.singleton){var l=s++;n=o||(o=createStyleElement(t)),r=applyToSingletonTag.bind(null,n,l,!1),i=applyToSingletonTag.bind(null,n,l,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function createLinkElement(e){var t=document.createElement("link");return e.attrs.type="text/css",e.attrs.rel="stylesheet",addAttrs(t,e.attrs),insertStyleElement(e,t),t}(t),r=function updateLink(e,t,n){var r=n.css,i=n.sourceMap,a=void 0===t.convertToAbsoluteUrls&&i;(t.convertToAbsoluteUrls||a)&&(r=u(r));i&&(r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */");var o=new Blob([r],{type:"text/css"}),s=e.href;e.href=URL.createObjectURL(o),s&&URL.revokeObjectURL(s)}.bind(null,n,t),i=function(){removeStyleElement(n),n.href&&URL.revokeObjectURL(n.href)}):(n=createStyleElement(t),r=function applyToTag(e,t){var n=t.css,r=t.media;r&&e.setAttribute("media",r);if(e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}.bind(null,n),i=function(){removeStyleElement(n)});return r(e),function updateStyle(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;r(e=t)}else i()}}var c=function(){var e=[];return function(t,n){return e[t]=n,e.filter(Boolean).join("\n")}}();function applyToSingletonTag(e,t,n,r){var i=n?"":r.css;if(e.styleSheet)e.styleSheet.cssText=c(t,i);else{var a=document.createTextNode(i),o=e.childNodes;o[t]&&e.removeChild(o[t]),o.length?e.insertBefore(a,o[t]):e.appendChild(a)}}},function(e,t,n){var r=n(4),i=n(235),a=n(236),o="Expected a function",s=Math.max,l=Math.min;e.exports=function debounce(e,t,n){var u,c,p,h,f,d,m=0,g=!1,y=!1,v=!0;if("function"!=typeof e)throw new TypeError(o);t=a(t)||0,r(n)&&(g=!!n.leading,p=(y="maxWait"in n)?s(a(n.maxWait)||0,t):p,v="trailing"in n?!!n.trailing:v);function invokeFunc(t){var n=u,r=c;return u=c=void 0,m=t,h=e.apply(r,n)}function shouldInvoke(e){var n=e-d;return void 0===d||n>=t||n<0||y&&e-m>=p}function timerExpired(){var e=i();if(shouldInvoke(e))return trailingEdge(e);f=setTimeout(timerExpired,function remainingWait(e){var n=t-(e-d);return y?l(n,p-(e-m)):n}(e))}function trailingEdge(e){return f=void 0,v&&u?invokeFunc(e):(u=c=void 0,h)}function debounced(){var e=i(),n=shouldInvoke(e);if(u=arguments,c=this,d=e,n){if(void 0===f)return function leadingEdge(e){return m=e,f=setTimeout(timerExpired,t),g?invokeFunc(e):h}(d);if(y)return f=setTimeout(timerExpired,t),invokeFunc(d)}return void 0===f&&(f=setTimeout(timerExpired,t)),h}return debounced.cancel=function cancel(){void 0!==f&&clearTimeout(f),m=0,u=d=c=f=void 0},debounced.flush=function flush(){return void 0===f?h:trailingEdge(i())},debounced}},function(e,t,n){e.exports=n(115)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});n(116);var r=n(0),i=n.n(r),a=n(63),o=n.n(a),s=n(32),l=n(316),u=n(363),c=n(364),p=n(376),h=(n(378),0);function renderStyleguide(){var e=n(380),t=window.location.hash,r=Object(c.a)(e.sections,t),a=r.sections,f=r.displayMode;if(document.title=Object(u.a)(a,e.config.title,f),"#/"===t){var d=window.location.pathname+window.location.search;history.replaceState("",document.title,d)}Object(p.a)(a),o.a.render(i.a.createElement(l.a,{codeRevision:h,config:e.config,slots:s.c,welcomeScreen:e.welcomeScreen,patterns:e.patterns,sections:a,displayMode:f}),document.getElementById("app"))}window.addEventListener("hashchange",renderStyleguide),renderStyleguide()},function(e,t,n){"use strict";var r=n(117),i=(n.n(r),n(118)),a=(n.n(i),n(120));n.n(a)},function(e,t){!function(){var e=/^\s*function\s+([^\(\s]*)\s*/;function _name(){var t,n;return this===Function||this===Function.prototype.constructor?n="Function":this!==Function.prototype&&(n=(t=(""+this).match(e))&&t[1]),n||""}var t=!("name"in Function.prototype&&"name"in function x(){}),n="function"==typeof Object.defineProperty&&function(){var e;try{Object.defineProperty(Function.prototype,"_xyz",{get:function(){return"blah"},configurable:!0}),e="blah"===Function.prototype._xyz,delete Function.prototype._xyz}catch(t){e=!1}return e}(),r="function"==typeof Object.prototype.__defineGetter__&&function(){var e;try{Function.prototype.__defineGetter__("_abc",function(){return"foo"}),e="foo"===Function.prototype._abc,delete Function.prototype._abc}catch(t){e=!1}return e}();Function.prototype._name=_name,t&&(n?Object.defineProperty(Function.prototype,"name",{get:function(){var e=_name.call(this);return this!==Function.prototype&&Object.defineProperty(this,"name",{value:e,configurable:!0}),e},configurable:!0}):r&&Function.prototype.__defineGetter__("name",function(){var e=_name.call(this);return this!==Function.prototype&&this.__defineGetter__("name",function(){return e}),e}))}()},function(e,t,n){"use strict";n(119).polyfill()},function(e,t,n){"use strict";function assign(e,t){if(void 0===e||null===e)throw new TypeError("Cannot convert first argument to object");for(var n=Object(e),r=1;r1)for(var n=1;nx.length&&x.push(e)}function P(e,t,n,r){var i=typeof e;"undefined"!==i&&"boolean"!==i||(e=null);var a=!1;if(null===e)a=!0;else switch(i){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case s:case l:case u:case c:a=!0}}if(a)return n(r,e,""===t?"."+Q(e,0):t),1;if(a=0,t=""===t?".":t+":",Array.isArray(e))for(var o=0;o=(o={attributeName:o,attributeNamespace:null,propertyName:a,mutationMethod:null,mustUseProperty:pa(s,t.MUST_USE_PROPERTY),hasBooleanValue:pa(s,t.HAS_BOOLEAN_VALUE),hasNumericValue:pa(s,t.HAS_NUMERIC_VALUE),hasPositiveNumericValue:pa(s,t.HAS_POSITIVE_NUMERIC_VALUE),hasOverloadedBooleanValue:pa(s,t.HAS_OVERLOADED_BOOLEAN_VALUE),hasStringBooleanValue:pa(s,t.HAS_STRING_BOOLEAN_VALUE)}).hasBooleanValue+o.hasNumericValue+o.hasOverloadedBooleanValue||E("50",a),i.hasOwnProperty(a)&&(o.attributeName=i[a]),r.hasOwnProperty(a)&&(o.attributeNamespace=r[a]),e.hasOwnProperty(a)&&(o.mutationMethod=e[a]),O[a]=o}}},O={};function va(e,t){if(R.hasOwnProperty(e)||2this.eventPool.length&&this.eventPool.push(e)}function Jb(e){e.eventPool=[],e.getPooled=Kb,e.release=Lb}function Mb(e,t,n,r){return T.call(this,e,t,n,r)}T.augmentClass(Mb,{data:null});function Nb(e,t,n,r){return T.call(this,e,t,n,r)}T.augmentClass(Nb,{data:null});var rt=[9,13,27,32],it=a.canUseDOM&&"CompositionEvent"in window,at=null;a.canUseDOM&&"documentMode"in document&&(at=document.documentMode);var ot;if(ot=a.canUseDOM&&"TextEvent"in window&&!at){var st=window.opera;ot=!("object"==typeof st&&"function"==typeof st.version&&12>=parseInt(st.version(),10))}var lt=ot,ut=a.canUseDOM&&(!it||at&&8=at),ct=String.fromCharCode(32),pt={beforeInput:{phasedRegistrationNames:{bubbled:"onBeforeInput",captured:"onBeforeInputCapture"},dependencies:["topCompositionEnd","topKeyPress","topTextInput","topPaste"]},compositionEnd:{phasedRegistrationNames:{bubbled:"onCompositionEnd",captured:"onCompositionEndCapture"},dependencies:"topBlur topCompositionEnd topKeyDown topKeyPress topKeyUp topMouseDown".split(" ")},compositionStart:{phasedRegistrationNames:{bubbled:"onCompositionStart",captured:"onCompositionStartCapture"},dependencies:"topBlur topCompositionStart topKeyDown topKeyPress topKeyUp topMouseDown".split(" ")},compositionUpdate:{phasedRegistrationNames:{bubbled:"onCompositionUpdate",captured:"onCompositionUpdateCapture"},dependencies:"topBlur topCompositionUpdate topKeyDown topKeyPress topKeyUp topMouseDown".split(" ")}},ht=!1;function dc(e,t){switch(e){case"topKeyUp":return-1!==rt.indexOf(t.keyCode);case"topKeyDown":return 229!==t.keyCode;case"topKeyPress":case"topMouseDown":case"topBlur":return!0;default:return!1}}function ec(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var ft=!1;var dt={eventTypes:pt,extractEvents:function(e,t,n,r){var i;if(it)e:{switch(e){case"topCompositionStart":var a=pt.compositionStart;break e;case"topCompositionEnd":a=pt.compositionEnd;break e;case"topCompositionUpdate":a=pt.compositionUpdate;break e}a=void 0}else ft?dc(e,n)&&(a=pt.compositionEnd):"topKeyDown"===e&&229===n.keyCode&&(a=pt.compositionStart);return a?(ut&&(ft||a!==pt.compositionStart?a===pt.compositionEnd&&ft&&(i=Fb()):(et._root=r,et._startText=Gb(),ft=!0)),a=Mb.getPooled(a,t,n,r),i?a.data=i:null!==(i=ec(n))&&(a.data=i),Ab(a),i=a):i=null,(e=lt?function gc(e,t){switch(e){case"topCompositionEnd":return ec(t);case"topKeyPress":return 32!==t.which?null:(ht=!0,ct);case"topTextInput":return(e=t.data)===ct&&ht?null:e;default:return null}}(e,n):function hc(e,t){if(ft)return"topCompositionEnd"===e||!it&&dc(e,t)?(e=Fb(),et._root=null,et._startText=null,et._fallbackText=null,ft=!1,e):null;switch(e){case"topPaste":return null;case"topKeyPress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1At.length&&At.push(e)}}}var Nt=Object.freeze({get _enabled(){return It},get _handleTopLevel(){return Lt},setHandleTopLevel:function(e){Lt=e},setEnabled:ud,isEnabled:function(){return It},trapBubbledEvent:U,trapCapturedEvent:wd,dispatchEvent:vd});function yd(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n["ms"+e]="MS"+t,n["O"+e]="o"+t.toLowerCase(),n}var Mt={animationend:yd("Animation","AnimationEnd"),animationiteration:yd("Animation","AnimationIteration"),animationstart:yd("Animation","AnimationStart"),transitionend:yd("Transition","TransitionEnd")},Dt={},Bt={};a.canUseDOM&&(Bt=document.createElement("div").style,"AnimationEvent"in window||(delete Mt.animationend.animation,delete Mt.animationiteration.animation,delete Mt.animationstart.animation),"TransitionEvent"in window||delete Mt.transitionend.transition);function Cd(e){if(Dt[e])return Dt[e];if(!Mt[e])return e;var t,n=Mt[e];for(t in n)if(n.hasOwnProperty(t)&&t in Bt)return Dt[e]=n[t];return""}var Ut={topAbort:"abort",topAnimationEnd:Cd("animationend")||"animationend",topAnimationIteration:Cd("animationiteration")||"animationiteration",topAnimationStart:Cd("animationstart")||"animationstart",topBlur:"blur",topCancel:"cancel",topCanPlay:"canplay",topCanPlayThrough:"canplaythrough",topChange:"change",topClick:"click",topClose:"close",topCompositionEnd:"compositionend",topCompositionStart:"compositionstart",topCompositionUpdate:"compositionupdate",topContextMenu:"contextmenu",topCopy:"copy",topCut:"cut",topDoubleClick:"dblclick",topDrag:"drag",topDragEnd:"dragend",topDragEnter:"dragenter",topDragExit:"dragexit",topDragLeave:"dragleave",topDragOver:"dragover",topDragStart:"dragstart",topDrop:"drop",topDurationChange:"durationchange",topEmptied:"emptied",topEncrypted:"encrypted",topEnded:"ended",topError:"error",topFocus:"focus",topInput:"input",topKeyDown:"keydown",topKeyPress:"keypress",topKeyUp:"keyup",topLoadedData:"loadeddata",topLoad:"load",topLoadedMetadata:"loadedmetadata",topLoadStart:"loadstart",topMouseDown:"mousedown",topMouseMove:"mousemove",topMouseOut:"mouseout",topMouseOver:"mouseover",topMouseUp:"mouseup",topPaste:"paste",topPause:"pause",topPlay:"play",topPlaying:"playing",topProgress:"progress",topRateChange:"ratechange",topScroll:"scroll",topSeeked:"seeked",topSeeking:"seeking",topSelectionChange:"selectionchange",topStalled:"stalled",topSuspend:"suspend",topTextInput:"textInput",topTimeUpdate:"timeupdate",topToggle:"toggle",topTouchCancel:"touchcancel",topTouchEnd:"touchend",topTouchMove:"touchmove",topTouchStart:"touchstart",topTransitionEnd:Cd("transitionend")||"transitionend",topVolumeChange:"volumechange",topWaiting:"waiting",topWheel:"wheel"},Ft={},$t=0,qt="_reactListenersID"+(""+Math.random()).slice(2);function Hd(e){return Object.prototype.hasOwnProperty.call(e,qt)||(e[qt]=$t++,Ft[e[qt]]={}),Ft[e[qt]]}function Id(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Jd(e,t){var n=Id(e);e=0;for(var r;n;){if(3===n.nodeType){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Id(n)}}function Kd(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&"text"===e.type||"textarea"===t||"true"===e.contentEditable)}var zt=a.canUseDOM&&"documentMode"in document&&11>=document.documentMode,Vt={select:{phasedRegistrationNames:{bubbled:"onSelect",captured:"onSelectCapture"},dependencies:"topBlur topContextMenu topFocus topKeyDown topKeyUp topMouseDown topMouseUp topSelectionChange".split(" ")}},Wt=null,Ht=null,Kt=null,Gt=!1;function Rd(e,t){if(Gt||null==Wt||Wt!==p())return null;var n=Wt;return"selectionStart"in n&&Kd(n)?n={start:n.selectionStart,end:n.selectionEnd}:window.getSelection?n={anchorNode:(n=window.getSelection()).anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}:n=void 0,Kt&&_(Kt,n)?null:(Kt=n,(e=T.getPooled(Vt.select,Ht,e,t)).type="select",e.target=Wt,Ab(e),e)}var Jt={eventTypes:Vt,extractEvents:function(e,t,n,r){var i,a=r.window===r?r.document:9===r.nodeType?r:r.ownerDocument;if(!(i=!a)){e:{a=Hd(a),i=Re.onSelect;for(var o=0;onn||(e.current=tn[nn],tn[nn]=null,nn--)}function W(e,t){tn[++nn]=e.current,e.current=t}new Set;var rn={current:S},an={current:!1},on=S;function ke(e){return le(e)?on:rn.current}function me(e,t){var n=e.type.contextTypes;if(!n)return S;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i,a={};for(i in n)a[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=a),a}function le(e){return 2===e.tag&&null!=e.type.childContextTypes}function ne(e){le(e)&&(V(an),V(rn))}function oe(e,t,n){null!=rn.cursor&&E("168"),W(rn,t),W(an,n)}function pe(e,t){var n=e.stateNode,r=e.type.childContextTypes;if("function"!=typeof n.getChildContext)return t;n=n.getChildContext();for(var i in n)i in r||E("108",jd(e)||"Unknown",i);return o({},t,n)}function qe(e){if(!le(e))return!1;var t=e.stateNode;return t=t&&t.__reactInternalMemoizedMergedChildContext||S,on=rn.current,W(rn,t),W(an,an.current),!0}function re(e,t){var n=e.stateNode;if(n||E("169"),t){var r=pe(e,on);n.__reactInternalMemoizedMergedChildContext=r,V(an),V(rn),W(rn,r)}else V(an);W(an,t)}function Y(e,t,n){this.tag=e,this.key=t,this.stateNode=this.type=null,this.sibling=this.child=this.return=null,this.index=0,this.memoizedState=this.updateQueue=this.memoizedProps=this.pendingProps=this.ref=null,this.internalContextTag=n,this.effectTag=0,this.lastEffect=this.firstEffect=this.nextEffect=null,this.expirationTime=0,this.alternate=null}function se(e,t,n){var r=e.alternate;return null===r?((r=new Y(e.tag,e.key,e.internalContextTag)).type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.effectTag=0,r.nextEffect=null,r.firstEffect=null,r.lastEffect=null),r.expirationTime=n,r.pendingProps=t,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r}function te(e,t,n){var r=void 0,i=e.type,a=e.key;return"function"==typeof i?((r=i.prototype&&i.prototype.isReactComponent?new Y(2,a,t):new Y(0,a,t)).type=i,r.pendingProps=e.props):"string"==typeof i?((r=new Y(5,a,t)).type=i,r.pendingProps=e.props):"object"==typeof i&&null!==i&&"number"==typeof i.tag?(r=i).pendingProps=e.props:E("130",null==i?i:typeof i,""),r.expirationTime=n,r}function ue(e,t,n,r){return(t=new Y(10,r,t)).pendingProps=e,t.expirationTime=n,t}function ve(e,t,n){return(t=new Y(6,null,t)).pendingProps=e,t.expirationTime=n,t}function we(e,t,n){return(t=new Y(7,e.key,t)).type=e.handler,t.pendingProps=e,t.expirationTime=n,t}function xe(e,t,n){return(e=new Y(9,null,t)).expirationTime=n,e}function ye(e,t,n){return(t=new Y(4,e.key,t)).pendingProps=e.children||[],t.expirationTime=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var sn=null,ln=null;function Be(e){return function(t){try{return e(t)}catch(e){}}}function De(e){"function"==typeof sn&&sn(e)}function Ee(e){"function"==typeof ln&&ln(e)}function Fe(e){return{baseState:e,expirationTime:0,first:null,last:null,callbackList:null,hasForceUpdate:!1,isInitialized:!1}}function Ge(e,t){null===e.last?e.first=e.last=t:(e.last.next=t,e.last=t),(0===e.expirationTime||e.expirationTime>t.expirationTime)&&(e.expirationTime=t.expirationTime)}function He(e,t){var n=e.alternate,r=e.updateQueue;null===r&&(r=e.updateQueue=Fe(null)),null!==n?null===(e=n.updateQueue)&&(e=n.updateQueue=Fe(null)):e=null,null===(e=e!==r?e:null)?Ge(r,t):null===r.last||null===e.last?(Ge(r,t),Ge(e,t)):(Ge(r,t),e.last=t)}function Ie(e,t,n,r){return"function"==typeof(e=e.partialState)?e.call(t,n,r):e}function Je(e,t,n,r,i,a){null!==e&&e.updateQueue===n&&(n=t.updateQueue={baseState:n.baseState,expirationTime:n.expirationTime,first:n.first,last:n.last,isInitialized:n.isInitialized,callbackList:null,hasForceUpdate:!1}),n.expirationTime=0,n.isInitialized?e=n.baseState:(e=n.baseState=t.memoizedState,n.isInitialized=!0);for(var s=!0,l=n.first,u=!1;null!==l;){var c=l.expirationTime;if(c>a){var p=n.expirationTime;(0===p||p>c)&&(n.expirationTime=c),u||(u=!0,n.baseState=e)}else u||(n.first=l.next,null===n.first&&(n.last=null)),l.isReplace?(e=Ie(l,r,e,i),s=!0):(c=Ie(l,r,e,i))&&(e=s?o({},e,c):o(e,c),s=!1),l.isForced&&(n.hasForceUpdate=!0),null!==l.callback&&(c=n.callbackList,null===c&&(c=n.callbackList=[]),c.push(l));l=l.next}return null!==n.callbackList?t.effectTag|=32:null!==n.first||n.hasForceUpdate||(t.updateQueue=null),u||(n.baseState=e),e}function Ke(e,t){var n=e.callbackList;if(null!==n)for(e.callbackList=null,e=0;el?(u=s,s=null):u=s.sibling;var p=G(e,s,r[l],i);if(null===p){null===s&&(s=u);break}t&&s&&null===p.alternate&&b(e,s),n=f(p,n,l),null===o?a=p:o.sibling=p,o=p,s=u}if(l===r.length)return c(e,s),a;if(null===s){for(;ll?(u=s,s=null):u=s.sibling;var h=G(e,s,p.value,i);if(null===h){s||(s=u);break}t&&s&&null===h.alternate&&b(e,s),n=f(h,n,l),null===o?a=h:o.sibling=h,o=h,s=u}if(p.done)return c(e,s),a;if(null===s){for(;!p.done;l++,p=r.next())p=z(e,p.value,i),null!==p&&(n=f(p,n,l),null===o?a=p:o.sibling=p,o=p);return a}for(s=d(e,s);!p.done;l++,p=r.next())p=I(s,e,l,p.value,i),null!==p&&(t&&null!==p.alternate&&s.delete(null===p.key?l:p.key),n=f(p,n,l),null===o?a=p:o.sibling=p,o=p);return t&&s.forEach(function(t){return b(e,t)}),a}(n,r,i,a);if(o&&$e(n,i),void 0===i)switch(n.tag){case 2:case 1:E("152",(a=n.type).displayName||a.name||"Component")}return c(n,r)}}var yn=af(!0),vn=af(!1);function df(e,t,n,r,i){function f(e,t,n){var r=t.expirationTime;t.child=null===e?vn(t,null,n,r):yn(t,e.child,n,r)}function g(e,t){var n=t.ref;null===n||e&&e.ref===n||(t.effectTag|=128)}function h(e,t,n,r){if(g(e,t),!n)return r&&re(t,!1),q(e,t);n=t.stateNode,jt.current=t;var i=n.render();return t.effectTag|=1,f(e,t,i),t.memoizedState=n.state,t.memoizedProps=n.props,r&&re(t,!0),t.child}function k(e){var t=e.stateNode;t.pendingContext?oe(0,t.pendingContext,t.pendingContext!==t.context):t.context&&oe(0,t.context,!1),u(e,t.containerInfo)}function q(e,t){if(null!==e&&t.child!==e.child&&E("153"),null!==t.child){var n=se(e=t.child,e.pendingProps,e.expirationTime);for(t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,n=n.sibling=se(e,e.pendingProps,e.expirationTime),n.return=t;n.sibling=null}return t.child}function v(e,t){switch(t.tag){case 3:k(t);break;case 2:qe(t);break;case 4:u(t,t.stateNode.containerInfo)}return null}var a=e.shouldSetTextContent,o=e.useSyncScheduling,s=e.shouldDeprioritizeSubtree,l=t.pushHostContext,u=t.pushHostContainer,c=n.enterHydrationState,p=n.resetHydrationState,d=n.tryToClaimNextHydratableInstance,m=(e=function Le(t,n,r,i){function e(e,t){t.updater=a,e.stateNode=t,t._reactInternalFiber=e}var a={isMounted:ld,enqueueSetState:function(e,r,i){e=e._reactInternalFiber,i=void 0===i?null:i;var a=n(e);He(e,{expirationTime:a,partialState:r,callback:i,isReplace:!1,isForced:!1,nextCallback:null,next:null}),t(e,a)},enqueueReplaceState:function(e,r,i){e=e._reactInternalFiber,i=void 0===i?null:i;var a=n(e);He(e,{expirationTime:a,partialState:r,callback:i,isReplace:!0,isForced:!1,nextCallback:null,next:null}),t(e,a)},enqueueForceUpdate:function(e,r){e=e._reactInternalFiber,r=void 0===r?null:r;var i=n(e);He(e,{expirationTime:i,partialState:null,callback:r,isReplace:!1,isForced:!0,nextCallback:null,next:null}),t(e,i)}};return{adoptClassInstance:e,constructClassInstance:function(t,n){var r=t.type,i=ke(t),a=2===t.tag&&null!=t.type.contextTypes,o=a?me(t,i):S;return e(t,n=new r(n,o)),a&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=i,t.__reactInternalMemoizedMaskedChildContext=o),n},mountClassInstance:function(e,t){var n=e.alternate,r=e.stateNode,i=r.state||null,o=e.pendingProps;o||E("158");var s=ke(e);r.props=o,r.state=e.memoizedState=i,r.refs=S,r.context=me(e,s),null!=e.type&&null!=e.type.prototype&&!0===e.type.prototype.unstable_isAsyncReactComponent&&(e.internalContextTag|=1),"function"==typeof r.componentWillMount&&(i=r.state,r.componentWillMount(),i!==r.state&&a.enqueueReplaceState(r,r.state,null),i=e.updateQueue,null!==i&&(r.state=Je(n,e,i,r,o,t))),"function"==typeof r.componentDidMount&&(e.effectTag|=4)},updateClassInstance:function(e,t,n){var o=t.stateNode;o.props=t.memoizedProps,o.state=t.memoizedState;var s=t.memoizedProps,l=t.pendingProps;l||(l=s,null==l&&E("159"));var u=o.context,c=ke(t);if(c=me(t,c),"function"!=typeof o.componentWillReceiveProps||s===l&&u===c||(u=o.state,o.componentWillReceiveProps(l,c),o.state!==u&&a.enqueueReplaceState(o,o.state,null)),u=t.memoizedState,n=null!==t.updateQueue?Je(e,t,t.updateQueue,o,l,n):u,!(s!==l||u!==n||an.current||null!==t.updateQueue&&t.updateQueue.hasForceUpdate))return"function"!=typeof o.componentDidUpdate||s===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=4),!1;var p=l;if(null===s||null!==t.updateQueue&&t.updateQueue.hasForceUpdate)p=!0;else{var h=t.stateNode,f=t.type;p="function"==typeof h.shouldComponentUpdate?h.shouldComponentUpdate(p,n,c):!(f.prototype&&f.prototype.isPureReactComponent&&_(s,p)&&_(u,n))}return p?("function"==typeof o.componentWillUpdate&&o.componentWillUpdate(l,n,c),"function"==typeof o.componentDidUpdate&&(t.effectTag|=4)):("function"!=typeof o.componentDidUpdate||s===e.memoizedProps&&u===e.memoizedState||(t.effectTag|=4),r(t,l),i(t,n)),o.props=l,o.state=n,o.context=c,p}}}(r,i,function(e,t){e.memoizedProps=t},function(e,t){e.memoizedState=t})).adoptClassInstance,y=e.constructClassInstance,b=e.mountClassInstance,x=e.updateClassInstance;return{beginWork:function(e,t,n){if(0===t.expirationTime||t.expirationTime>n)return v(0,t);switch(t.tag){case 0:null!==e&&E("155");var r=t.type,i=t.pendingProps,_=ke(t);return r=r(i,_=me(t,_)),t.effectTag|=1,"object"==typeof r&&null!==r&&"function"==typeof r.render?(t.tag=2,i=qe(t),m(t,r),b(t,n),t=h(e,t,!0,i)):(t.tag=1,f(e,t,r),t.memoizedProps=i,t=t.child),t;case 1:e:{if(i=t.type,n=t.pendingProps,r=t.memoizedProps,an.current)null===n&&(n=r);else if(null===n||r===n){t=q(e,t);break e}i=i(n,r=me(t,r=ke(t))),t.effectTag|=1,f(e,t,i),t.memoizedProps=n,t=t.child}return t;case 2:return i=qe(t),r=void 0,null===e?t.stateNode?E("153"):(y(t,t.pendingProps),b(t,n),r=!0):r=x(e,t,n),h(e,t,r,i);case 3:return k(t),null!==(i=t.updateQueue)?(r=t.memoizedState)===(i=Je(e,t,i,null,null,n))?(p(),t=q(e,t)):(r=i.element,_=t.stateNode,(null===e||null===e.child)&&_.hydrate&&c(t)?(t.effectTag|=2,t.child=vn(t,null,r,n)):(p(),f(e,t,r)),t.memoizedState=i,t=t.child):(p(),t=q(e,t)),t;case 5:l(t),null===e&&d(t),i=t.type;var w=t.memoizedProps;return null===(r=t.pendingProps)&&(r=w,null===r&&E("154")),_=null!==e?e.memoizedProps:null,an.current||null!==r&&w!==r?(w=r.children,a(i,r)?w=null:_&&a(i,_)&&(t.effectTag|=16),g(e,t),2147483647!==n&&!o&&s(i,r)?(t.expirationTime=2147483647,t=null):(f(e,t,w),t.memoizedProps=r,t=t.child)):t=q(e,t),t;case 6:return null===e&&d(t),null===(e=t.pendingProps)&&(e=t.memoizedProps),t.memoizedProps=e,null;case 8:t.tag=7;case 7:return i=t.pendingProps,an.current?null===i&&(i=e&&e.memoizedProps,null===i&&E("154")):null!==i&&t.memoizedProps!==i||(i=t.memoizedProps),r=i.children,t.stateNode=null===e?vn(t,t.stateNode,r,n):yn(t,t.stateNode,r,n),t.memoizedProps=i,t.stateNode;case 9:return null;case 4:e:{if(u(t,t.stateNode.containerInfo),i=t.pendingProps,an.current)null===i&&(i=e&&e.memoizedProps,null==i&&E("154"));else if(null===i||t.memoizedProps===i){t=q(e,t);break e}null===e?t.child=yn(t,null,i,n):f(e,t,i),t.memoizedProps=i,t=t.child}return t;case 10:e:{if(n=t.pendingProps,an.current)null===n&&(n=t.memoizedProps);else if(null===n||t.memoizedProps===n){t=q(e,t);break e}f(e,t,n),t.memoizedProps=n,t=t.child}return t;default:E("156")}},beginFailedWork:function(e,t,n){switch(t.tag){case 2:qe(t);break;case 3:k(t);break;default:E("157")}return t.effectTag|=64,null===e?t.child=null:t.child!==e.child&&(t.child=e.child),0===t.expirationTime||t.expirationTime>n?v(0,t):(t.firstEffect=null,t.lastEffect=null,t.child=null===e?vn(t,null,null,n):yn(t,e.child,null,n),2===t.tag&&(e=t.stateNode,t.memoizedProps=e.props,t.memoizedState=e.state),t.child)}}}var bn={};function kf(t){function b(e){ce=Q=!0;var t=e.stateNode;if(t.current===e&&E("177"),t.isReadyForCommit=!1,jt.current=null,1o.expirationTime)&&(a=o.expirationTime),o=o.sibling;i.expirationTime=a}if(null!==t)return t;if(null!==n&&(null===n.firstEffect&&(n.firstEffect=e.firstEffect),null!==e.lastEffect&&(null!==n.lastEffect&&(n.lastEffect.nextEffect=e.firstEffect),n.lastEffect=e.lastEffect),1t))if(te<=K)for(;null!==Z;)Z=k(Z)?e(Z):d(Z);else for(;null!==Z&&!A();)Z=k(Z)?e(Z):d(Z)}else if(!(0===te||te>t))if(te<=K)for(;null!==Z;)Z=d(Z);else for(;null!==Z&&!A();)Z=d(Z)}function g(t,n){if(Q&&E("243"),Q=!0,t.isReadyForCommit=!1,t!==ee||n!==te||null===Z){for(;-1t)&&(e.expirationTime=t),null!==e.alternate&&(0===e.alternate.expirationTime||e.alternate.expirationTime>t)&&(e.alternate.expirationTime=t),null===e.return){if(3!==e.tag)break;var n=e.stateNode;!Q&&n===ee&&tSe&&E("185"),null===r.nextScheduledRoot)r.remainingExpirationTime=i,null===fe?(he=fe=r,r.nextScheduledRoot=r):(fe=fe.nextScheduledRoot=r,fe.nextScheduledRoot=he);else{var a=r.remainingExpirationTime;(0===a||ide)return;B(me)}var t=M()-H;de=e,me=D(J,{timeout:10*(e-2)-t})}function N(){var e=0,t=null;if(null!==fe)for(var n=fe,r=he;null!==r;){var i=r.remainingExpirationTime;if(0===i){if((null===n||null===fe)&&E("244"),r===r.nextScheduledRoot){he=fe=r.nextScheduledRoot=null;break}if(r===he)he=i=r.nextScheduledRoot,fe.nextScheduledRoot=i,r.nextScheduledRoot=null;else{if(r===fe){(fe=n).nextScheduledRoot=he,r.nextScheduledRoot=null;break}n.nextScheduledRoot=r.nextScheduledRoot,r.nextScheduledRoot=null}r=n.nextScheduledRoot}else{if((0===e||iPe)&&(be=!0)}function Ob(e){null===ye&&E("246"),ye.remainingExpirationTime=0,_e||(_e=!0,xe=e)}var n=function hf(e){function b(e){return e===bn&&E("174"),e}var t=e.getChildHostContext,n=e.getRootHostContext,r={current:bn},i={current:bn},a={current:bn};return{getHostContext:function(){return b(r.current)},getRootHostContainer:function(){return b(a.current)},popHostContainer:function(e){V(r),V(i),V(a)},popHostContext:function(e){i.current===e&&(V(r),V(i))},pushHostContainer:function(e,t){W(a,t),t=n(t),W(i,e),W(r,t)},pushHostContext:function(e){var n=b(a.current),o=b(r.current);o!==(n=t(o,e.type,n))&&(W(i,e),W(r,n))},resetHostContainer:function(){r.current=bn,a.current=bn}}}(t),r=function jf(e){function b(e,t){var n=new Y(5,null,0);n.type="DELETED",n.stateNode=t,n.return=e,n.effectTag=8,null!==e.lastEffect?(e.lastEffect.nextEffect=n,e.lastEffect=n):e.firstEffect=e.lastEffect=n}function c(e,t){switch(e.tag){case 5:return null!==(t=n(t,e.type,e.pendingProps))&&(e.stateNode=t,!0);case 6:return null!==(t=r(t,e.pendingProps))&&(e.stateNode=t,!0);default:return!1}}function d(e){for(e=e.return;null!==e&&5!==e.tag&&3!==e.tag;)e=e.return;l=e}var t=e.shouldSetTextContent;if(!(e=e.hydration))return{enterHydrationState:function(){return!1},resetHydrationState:function(){},tryToClaimNextHydratableInstance:function(){},prepareToHydrateHostInstance:function(){E("175")},prepareToHydrateHostTextInstance:function(){E("176")},popHydrationState:function(){return!1}};var n=e.canHydrateInstance,r=e.canHydrateTextInstance,i=e.getNextHydratableSibling,a=e.getFirstHydratableChild,o=e.hydrateInstance,s=e.hydrateTextInstance,l=null,u=null,p=!1;return{enterHydrationState:function(e){return u=a(e.stateNode.containerInfo),l=e,p=!0},resetHydrationState:function(){u=l=null,p=!1},tryToClaimNextHydratableInstance:function(e){if(p){var t=u;if(t){if(!c(e,t)){if(!(t=i(t))||!c(e,t))return e.effectTag|=2,p=!1,void(l=e);b(l,u)}l=e,u=a(t)}else e.effectTag|=2,p=!1,l=e}},prepareToHydrateHostInstance:function(e,t,n){return t=o(e.stateNode,e.type,e.memoizedProps,t,n,e),e.updateQueue=t,null!==t},prepareToHydrateHostTextInstance:function(e){return s(e.stateNode,e.memoizedProps,e)},popHydrationState:function(e){if(e!==l)return!1;if(!p)return d(e),p=!0,!1;var n=e.type;if(5!==e.tag||"head"!==n&&"body"!==n&&!t(n,e.memoizedProps))for(n=u;n;)b(e,n),n=i(n);return d(e),u=l?i(e.stateNode):null,!0}}}(t),i=n.popHostContainer,a=n.popHostContext,o=n.resetHostContainer,s=df(t,n,r,u,y),l=s.beginWork,p=s.beginFailedWork,_=function ef(e,t,n){function d(e){e.effectTag|=4}var r=e.createInstance,i=e.createTextInstance,a=e.appendInitialChild,o=e.finalizeInitialChildren,s=e.prepareUpdate,l=e.persistence,u=t.getRootHostContainer,c=t.popHostContext,p=t.getHostContext,h=t.popHostContainer,f=n.prepareToHydrateHostInstance,m=n.prepareToHydrateHostTextInstance,g=n.popHydrationState,y=void 0,v=void 0,b=void 0;return e.mutation?(y=function(){},v=function(e,t,n){(t.updateQueue=n)&&d(t)},b=function(e,t,n,r){n!==r&&d(t)}):E(l?"235":"236"),{completeWork:function(e,t,n){var l=t.pendingProps;switch(null===l?l=t.memoizedProps:2147483647===t.expirationTime&&2147483647!==n||(t.pendingProps=null),t.tag){case 1:return null;case 2:return ne(t),null;case 3:return h(t),V(an),V(rn),(l=t.stateNode).pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),null!==e&&null!==e.child||(g(t),t.effectTag&=-3),y(t),null;case 5:c(t),n=u();var _=t.type;if(null!==e&&null!=t.stateNode){var x=e.memoizedProps,w=t.stateNode,k=p();w=s(w,_,x,l,n,k),v(e,t,w,_,x,l,n),e.ref!==t.ref&&(t.effectTag|=128)}else{if(!l)return null===t.stateNode&&E("166"),null;if(e=p(),g(t))f(t,n,e)&&d(t);else{e=r(_,l,n,e,t);e:for(x=t.child;null!==x;){if(5===x.tag||6===x.tag)a(e,x.stateNode);else if(4!==x.tag&&null!==x.child){x.child.return=x,x=x.child;continue}if(x===t)break;for(;null===x.sibling;){if(null===x.return||x.return===t)break e;x=x.return}x.sibling.return=x.return,x=x.sibling}o(e,_,l,n)&&d(t),t.stateNode=e}null!==t.ref&&(t.effectTag|=128)}return null;case 6:if(e&&null!=t.stateNode)b(e,t,e.memoizedProps,l);else{if("string"!=typeof l)return null===t.stateNode&&E("166"),null;e=u(),n=p(),g(t)?m(t)&&d(t):t.stateNode=i(l,e,n,t)}return null;case 7:(l=t.memoizedProps)||E("165"),t.tag=8,_=[];e:for((x=t.stateNode)&&(x.return=t);null!==x;){if(5===x.tag||6===x.tag||4===x.tag)E("247");else if(9===x.tag)_.push(x.type);else if(null!==x.child){x.child.return=x,x=x.child;continue}for(;null===x.sibling;){if(null===x.return||x.return===t)break e;x=x.return}x.sibling.return=x.return,x=x.sibling}return l=(x=l.handler)(l.props,_),t.child=yn(t,null!==e?e.child:null,l,n),t.child;case 8:return t.tag=7,null;case 9:case 10:return null;case 4:return h(t),y(t),null;case 0:E("167");default:E("156")}}}}(t,n,r).completeWork,x=(n=function ff(t,n){function c(e){var t=e.ref;if(null!==t)try{t(null)}catch(t){n(e,t)}}function d(t){switch(Ee(t),t.tag){case 2:c(t);var r=t.stateNode;if("function"==typeof r.componentWillUnmount)try{r.props=t.memoizedProps,r.state=t.memoizedState,r.componentWillUnmount()}catch(e){n(t,e)}break;case 5:c(t);break;case 7:e(t.stateNode);break;case 4:i&&g(t)}}function e(e){for(var t=e;;)if(d(t),null===t.child||i&&4===t.tag){if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return;t=t.return}t.sibling.return=t.return,t=t.sibling}else t.child.return=t,t=t.child}function f(e){return 5===e.tag||3===e.tag||4===e.tag}function g(t){for(var n=t,r=!1,i=void 0,a=void 0;;){if(!r){r=n.return;e:for(;;){switch(null===r&&E("160"),r.tag){case 5:i=r.stateNode,a=!1;break e;case 3:case 4:i=r.stateNode.containerInfo,a=!0;break e}r=r.return}r=!0}if(5===n.tag||6===n.tag)e(n),a?v(i,n.stateNode):y(i,n.stateNode);else if(4===n.tag?i=n.stateNode.containerInfo:d(n),null!==n.child){n.child.return=n,n=n.child;continue}if(n===t)break;for(;null===n.sibling;){if(null===n.return||n.return===t)return;4===(n=n.return).tag&&(r=!1)}n.sibling.return=n.return,n=n.sibling}}var r=t.getPublicInstance,i=t.mutation;t=t.persistence,i||E(t?"235":"236");var a=i.commitMount,o=i.commitUpdate,s=i.resetTextContent,l=i.commitTextUpdate,u=i.appendChild,p=i.appendChildToContainer,h=i.insertBefore,m=i.insertInContainerBefore,y=i.removeChild,v=i.removeChildFromContainer;return{commitResetTextContent:function(e){s(e.stateNode)},commitPlacement:function(e){e:{for(var t=e.return;null!==t;){if(f(t)){var n=t;break e}t=t.return}E("160"),n=void 0}var r=t=void 0;switch(n.tag){case 5:t=n.stateNode,r=!1;break;case 3:case 4:t=n.stateNode.containerInfo,r=!0;break;default:E("161")}16&n.effectTag&&(s(t),n.effectTag&=-17);e:t:for(n=e;;){for(;null===n.sibling;){if(null===n.return||f(n.return)){n=null;break e}n=n.return}for(n.sibling.return=n.return,n=n.sibling;5!==n.tag&&6!==n.tag;){if(2&n.effectTag)continue t;if(null===n.child||4===n.tag)continue t;n.child.return=n,n=n.child}if(!(2&n.effectTag)){n=n.stateNode;break e}}for(var i=e;;){if(5===i.tag||6===i.tag)n?r?m(t,i.stateNode,n):h(t,i.stateNode,n):r?p(t,i.stateNode):u(t,i.stateNode);else if(4!==i.tag&&null!==i.child){i.child.return=i,i=i.child;continue}if(i===e)break;for(;null===i.sibling;){if(null===i.return||i.return===e)return;i=i.return}i.sibling.return=i.return,i=i.sibling}},commitDeletion:function(e){g(e),e.return=null,e.child=null,e.alternate&&(e.alternate.child=null,e.alternate.return=null)},commitWork:function(e,t){switch(t.tag){case 2:break;case 5:var n=t.stateNode;if(null!=n){var r=t.memoizedProps;e=null!==e?e.memoizedProps:r;var i=t.type,a=t.updateQueue;t.updateQueue=null,null!==a&&o(n,a,i,e,r,t)}break;case 6:null===t.stateNode&&E("162"),n=t.memoizedProps,l(t.stateNode,null!==e?e.memoizedProps:n,n);break;case 3:break;default:E("163")}},commitLifeCycles:function(e,t){switch(t.tag){case 2:var n=t.stateNode;if(4&t.effectTag)if(null===e)n.props=t.memoizedProps,n.state=t.memoizedState,n.componentDidMount();else{var r=e.memoizedProps;e=e.memoizedState,n.props=t.memoizedProps,n.state=t.memoizedState,n.componentDidUpdate(r,e)}null!==(t=t.updateQueue)&&Ke(t,n);break;case 3:null!==(n=t.updateQueue)&&Ke(n,null!==t.child?t.child.stateNode:null);break;case 5:n=t.stateNode,null===e&&4&t.effectTag&&a(n,t.type,t.memoizedProps,t);break;case 6:case 4:break;default:E("163")}},commitAttachRef:function(e){var t=e.ref;if(null!==t){var n=e.stateNode;switch(e.tag){case 5:t(r(n));break;default:t(n)}}},commitDetachRef:function(e){null!==(e=e.ref)&&e(null)}}}(t,h)).commitResetTextContent,C=n.commitPlacement,R=n.commitDeletion,P=n.commitWork,O=n.commitLifeCycles,T=n.commitAttachRef,j=n.commitDetachRef,M=t.now,D=t.scheduleDeferredCallback,B=t.cancelDeferredCallback,U=t.useSyncScheduling,F=t.prepareForCommit,$=t.resetAfterCommit,H=M(),K=2,X=0,Q=!1,Z=null,ee=null,te=0,re=null,ie=null,ae=null,oe=null,le=null,ue=!1,ce=!1,pe=!1,he=null,fe=null,de=0,me=-1,ge=!1,ye=null,ve=0,be=!1,_e=!1,xe=null,we=null,ke=!1,Ce=!1,Se=1e3,Re=0,Pe=1;return{computeAsyncExpiration:v,computeExpirationForFiber:y,scheduleWork:u,batchedUpdates:function(e,t){var n=ke;ke=!0;try{return e(t)}finally{(ke=n)||ge||w(1,null)}},unbatchedUpdates:function(e){if(ke&&!Ce){Ce=!0;try{return e()}finally{Ce=!1}}return e()},flushSync:function(e){var t=ke;ke=!0;try{e:{var n=X;X=1;try{var r=e();break e}finally{X=n}r=void 0}return r}finally{ke=t,ge&&E("187"),w(1,null)}},deferredUpdates:function(e){var t=X;X=v();try{return e()}finally{X=t}}}}function lf(e){function b(e){return null===(e=function od(e){if(!(e=nd(e)))return null;for(var t=e;;){if(5===t.tag||6===t.tag)return t;if(t.child)t.child.return=t,t=t.child;else{if(t===e)break;for(;!t.sibling;){if(!t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}}return null}(e))?null:e.stateNode}var t=e.getPublicInstance,n=(e=kf(e)).computeAsyncExpiration,r=e.computeExpirationForFiber,i=e.scheduleWork;return{createContainer:function(e,t){var n=new Y(3,null,0);return e={current:n,containerInfo:e,pendingChildren:null,remainingExpirationTime:0,isReadyForCommit:!1,finishedWork:null,context:null,pendingContext:null,hydrate:t,nextScheduledRoot:null},n.stateNode=e},updateContainer:function(e,t,a,o){var s=t.current;if(a){a=a._reactInternalFiber;var l;e:{for(2===kd(a)&&2===a.tag||E("170"),l=a;3!==l.tag;){if(le(l)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break e}(l=l.return)||E("171")}l=l.stateNode.context}a=le(a)?pe(a,l):l}else a=S;null===t.context?t.context=a:t.pendingContext=a,t=void 0===(t=o)?null:t,He(s,{expirationTime:o=null!=e&&null!=e.type&&null!=e.type.prototype&&!0===e.type.prototype.unstable_isAsyncReactComponent?n():r(s),partialState:{element:e},callback:t,isReplace:!1,isForced:!1,nextCallback:null,next:null}),i(s,o)},batchedUpdates:e.batchedUpdates,unbatchedUpdates:e.unbatchedUpdates,deferredUpdates:e.deferredUpdates,flushSync:e.flushSync,getPublicRootInstance:function(e){if(!(e=e.current).child)return null;switch(e.child.tag){case 5:return t(e.child.stateNode);default:return e.child.stateNode}},findHostInstance:b,findHostInstanceWithNoPortals:function(e){return null===(e=function pd(e){if(!(e=nd(e)))return null;for(var t=e;;){if(5===t.tag||6===t.tag)return t;if(t.child&&4!==t.tag)t.child.return=t,t=t.child;else{if(t===e)break;for(;!t.sibling;){if(!t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}}return null}(e))?null:e.stateNode},injectIntoDevTools:function(e){var t=e.findFiberByHostInstance;return function Ce(e){if("undefined"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__)return!1;var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)return!0;try{var n=t.inject(e);sn=Be(function(e){return t.onCommitFiberRoot(n,e)}),ln=Be(function(e){return t.onCommitFiberUnmount(n,e)})}catch(e){}return!0}(o({},e,{findHostInstanceByFiber:function(e){return b(e)},findFiberByHostInstance:function(e){return t?t(e):null}}))}}}var _n=Object.freeze({default:lf}),xn=_n&&lf||_n,wn=xn.default?xn.default:xn;var kn="object"==typeof performance&&"function"==typeof performance.now,En=void 0;En=kn?function(){return performance.now()}:function(){return Date.now()};var Cn=void 0,Sn=void 0;if(a.canUseDOM)if("function"!=typeof requestIdleCallback||"function"!=typeof cancelIdleCallback){var Rn,Pn=null,On=!1,Tn=-1,jn=!1,An=0,In=33,Ln=33;Rn=kn?{didTimeout:!1,timeRemaining:function(){var e=An-performance.now();return 0=An-e){if(!(-1!==Tn&&Tn<=e))return void(jn||(jn=!0,requestAnimationFrame(Mn)));Rn.didTimeout=!0}else Rn.didTimeout=!1;Tn=-1,e=Pn,Pn=null,null!==e&&e(Rn)}},!1);var Mn=function(e){jn=!1;var t=e-An+Ln;tt&&(t=8),Ln=tn||r.hasOverloadedBooleanValue&&!1===n?Jf(e,t):r.mustUseProperty?e[r.propertyName]=n:(t=r.attributeName,(i=r.attributeNamespace)?e.setAttributeNS(i,t,""+n):r.hasBooleanValue||r.hasOverloadedBooleanValue&&!0===n?e.setAttribute(t,""):e.setAttribute(t,""+n))}else Kf(e,t,va(t,n)?n:null)}function Kf(e,t,n){(function Hf(e){return!!Un.hasOwnProperty(e)||!Bn.hasOwnProperty(e)&&(Dn.test(e)?Un[e]=!0:(Bn[e]=!0,!1))})(t)&&(null==n?e.removeAttribute(t):e.setAttribute(t,""+n))}function Jf(e,t){var n=wa(t);n?(t=n.mutationMethod)?t(e,void 0):n.mustUseProperty?e[n.propertyName]=!n.hasBooleanValue&&"":e.removeAttribute(n.attributeName):e.removeAttribute(t)}function Lf(e,t){var n=t.value,r=t.checked;return o({type:void 0,step:void 0,min:void 0,max:void 0},t,{defaultChecked:void 0,defaultValue:void 0,value:null!=n?n:e._wrapperState.initialValue,checked:null!=r?r:e._wrapperState.initialChecked})}function Mf(e,t){var n=t.defaultValue;e._wrapperState={initialChecked:null!=t.checked?t.checked:t.defaultChecked,initialValue:null!=t.value?t.value:n,controlled:"checkbox"===t.type||"radio"===t.type?null!=t.checked:null!=t.value}}function Nf(e,t){null!=(t=t.checked)&&If(e,"checked",t)}function Of(e,t){Nf(e,t);var n=t.value;null!=n?0===n&&""===e.value?e.value="0":"number"===t.type?(n!=(t=parseFloat(e.value)||0)||n==t&&e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n):(null==t.value&&null!=t.defaultValue&&e.defaultValue!==""+t.defaultValue&&(e.defaultValue=""+t.defaultValue),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked))}function Pf(e,t){switch(t.type){case"submit":case"reset":break;case"color":case"date":case"datetime":case"datetime-local":case"month":case"time":case"week":e.value="",e.value=e.defaultValue;break;default:e.value=e.value}""!==(t=e.name)&&(e.name=""),e.defaultChecked=!e.defaultChecked,e.defaultChecked=!e.defaultChecked,""!==t&&(e.name=t)}function Rf(e,t){return e=o({children:void 0},t),(t=function Qf(e){var t="";return i.Children.forEach(e,function(e){null==e||"string"!=typeof e&&"number"!=typeof e||(t+=e)}),t}(t.children))&&(e.children=t),e}function Sf(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i=t.length||E("93"),t=t[0]),n=""+t),null==n&&(n="")),e._wrapperState={initialValue:""+n}}function Wf(e,t){var n=t.value;null!=n&&(n=""+n,n!==e.value&&(e.value=n),null==t.defaultValue&&(e.defaultValue=n)),null!=t.defaultValue&&(e.defaultValue=t.defaultValue)}function Xf(e){var t=e.textContent;t===e._wrapperState.initialValue&&(e.value=t)}var Fn="http://www.w3.org/1999/xhtml",$n="http://www.w3.org/2000/svg";function Zf(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function $f(e,t){return null==e||"http://www.w3.org/1999/xhtml"===e?Zf(t):"http://www.w3.org/2000/svg"===e&&"foreignObject"===t?"http://www.w3.org/1999/xhtml":e}var qn,zn=void 0,Vn=(qn=function(e,t){if(e.namespaceURI!==$n||"innerHTML"in e)e.innerHTML=t;else{for((zn=zn||document.createElement("div")).innerHTML=""+t+"",t=zn.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}},"undefined"!=typeof MSApp&&MSApp.execUnsafeLocalFunction?function(e,t,n,r){MSApp.execUnsafeLocalFunction(function(){return qn(e,t)})}:qn);function cg(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var Wn={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Hn=["Webkit","ms","Moz","O"];Object.keys(Wn).forEach(function(e){Hn.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Wn[t]=Wn[e]})});function fg(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=0===n.indexOf("--"),i=n,a=t[n];i=null==a||"boolean"==typeof a||""===a?"":r||"number"!=typeof a||0===a||Wn.hasOwnProperty(i)&&Wn[i]?(""+a).trim():a+"px","float"===n&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var Kn=o({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function hg(e,t,n){t&&(Kn[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML)&&E("137",e,n()),null!=t.dangerouslySetInnerHTML&&(null!=t.children&&E("60"),"object"==typeof t.dangerouslySetInnerHTML&&"__html"in t.dangerouslySetInnerHTML||E("61")),null!=t.style&&"object"!=typeof t.style&&E("62",n()))}function ig(e,t){if(-1===e.indexOf("-"))return"string"==typeof t.is;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Gn=Fn,Jn=s.thatReturns("");function lg(e,t){var n=Hd(e=9===e.nodeType||11===e.nodeType?e:e.ownerDocument);t=Re[t];for(var r=0;r<\/script>",e=e.removeChild(e.firstChild)):e="string"==typeof t.is?n.createElement(e,{is:t.is}):n.createElement(e):e=n.createElementNS(r,e),e}function og(e,t){return(9===t.nodeType?t:t.ownerDocument).createTextNode(e)}function pg(e,t,n,r){var i=ig(t,n);switch(t){case"iframe":case"object":U("topLoad","load",e);var a=n;break;case"video":case"audio":for(a in Yn)Yn.hasOwnProperty(a)&&U(a,Yn[a],e);a=n;break;case"source":U("topError","error",e),a=n;break;case"img":case"image":U("topError","error",e),U("topLoad","load",e),a=n;break;case"form":U("topReset","reset",e),U("topSubmit","submit",e),a=n;break;case"details":U("topToggle","toggle",e),a=n;break;case"input":Mf(e,n),a=Lf(e,n),U("topInvalid","invalid",e),lg(r,"onChange");break;case"option":a=Rf(e,n);break;case"select":Tf(e,n),a=o({},n,{value:void 0}),U("topInvalid","invalid",e),lg(r,"onChange");break;case"textarea":Vf(e,n),a=Uf(e,n),U("topInvalid","invalid",e),lg(r,"onChange");break;default:a=n}hg(t,a,Jn);var l,u=a;for(l in u)if(u.hasOwnProperty(l)){var c=u[l];"style"===l?fg(e,c):"dangerouslySetInnerHTML"===l?null!=(c=c?c.__html:void 0)&&Vn(e,c):"children"===l?"string"==typeof c?("textarea"!==t||""!==c)&&cg(e,c):"number"==typeof c&&cg(e,""+c):"suppressContentEditableWarning"!==l&&"suppressHydrationWarning"!==l&&"autoFocus"!==l&&(Se.hasOwnProperty(l)?null!=c&&lg(r,l):i?Kf(e,l,c):null!=c&&If(e,l,c))}switch(t){case"input":Bc(e),Pf(e,n);break;case"textarea":Bc(e),Xf(e);break;case"option":null!=n.value&&e.setAttribute("value",n.value);break;case"select":e.multiple=!!n.multiple,null!=(t=n.value)?Sf(e,!!n.multiple,t,!1):null!=n.defaultValue&&Sf(e,!!n.multiple,n.defaultValue,!0);break;default:"function"==typeof a.onClick&&(e.onclick=s)}}function sg(e,t,n,r,i){var a=null;switch(t){case"input":n=Lf(e,n),r=Lf(e,r),a=[];break;case"option":n=Rf(e,n),r=Rf(e,r),a=[];break;case"select":n=o({},n,{value:void 0}),r=o({},r,{value:void 0}),a=[];break;case"textarea":n=Uf(e,n),r=Uf(e,r),a=[];break;default:"function"!=typeof n.onClick&&"function"==typeof r.onClick&&(e.onclick=s)}hg(t,r,Jn);var l,u;e=null;for(l in n)if(!r.hasOwnProperty(l)&&n.hasOwnProperty(l)&&null!=n[l])if("style"===l)for(u in t=n[l],t)t.hasOwnProperty(u)&&(e||(e={}),e[u]="");else"dangerouslySetInnerHTML"!==l&&"children"!==l&&"suppressContentEditableWarning"!==l&&"suppressHydrationWarning"!==l&&"autoFocus"!==l&&(Se.hasOwnProperty(l)?a||(a=[]):(a=a||[]).push(l,null));for(l in r){var c=r[l];if(t=null!=n?n[l]:void 0,r.hasOwnProperty(l)&&c!==t&&(null!=c||null!=t))if("style"===l)if(t){for(u in t)!t.hasOwnProperty(u)||c&&c.hasOwnProperty(u)||(e||(e={}),e[u]="");for(u in c)c.hasOwnProperty(u)&&t[u]!==c[u]&&(e||(e={}),e[u]=c[u])}else e||(a||(a=[]),a.push(l,e)),e=c;else"dangerouslySetInnerHTML"===l?(c=c?c.__html:void 0,t=t?t.__html:void 0,null!=c&&t!==c&&(a=a||[]).push(l,""+c)):"children"===l?t===c||"string"!=typeof c&&"number"!=typeof c||(a=a||[]).push(l,""+c):"suppressContentEditableWarning"!==l&&"suppressHydrationWarning"!==l&&(Se.hasOwnProperty(l)?(null!=c&&lg(i,l),a||t===c||(a=[])):(a=a||[]).push(l,c))}return e&&(a=a||[]).push("style",e),a}function tg(e,t,n,r,i){"input"===n&&"radio"===i.type&&null!=i.name&&Nf(e,i),ig(n,r),r=ig(n,i);for(var a=0;ar&&(i=r,r=e,e=i),i=Jd(n,e);var a=Jd(n,r);if(i&&a&&(1!==t.rangeCount||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==a.node||t.focusOffset!==a.offset)){var o=document.createRange();o.setStart(i.node,i.offset),t.removeAllRanges(),e>r?(t.addRange(o),t.extend(a.node,a.offset)):(o.setEnd(a.node,a.offset),t.addRange(o))}}for(t=[],e=n;e=e.parentNode;)1===e.nodeType&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(C(n),n=0;n-1}},function(e,t,n){var r=n(23);e.exports=function listCacheSet(e,t){var n=this.__data__,i=r(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this}},function(e,t,n){var r=n(22);e.exports=function stackClear(){this.__data__=new r,this.size=0}},function(e,t){e.exports=function stackDelete(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}},function(e,t){e.exports=function stackGet(e){return this.__data__.get(e)}},function(e,t){e.exports=function stackHas(e){return this.__data__.has(e)}},function(e,t,n){var r=n(22),i=n(34),a=n(36),o=200;e.exports=function stackSet(e,t){var n=this.__data__;if(n instanceof r){var s=n.__data__;if(!i||s.length1?n[a-1]:void 0,s=a>2?n[2]:void 0;for(o=e.length>3&&"function"==typeof o?(a--,o):void 0,s&&i(n[0],n[1],s)&&(o=a<3?void 0:o,a=1),t=Object(t);++r0){if(++t>=n)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}},function(e,t,n){var r=n(18),i=n(15),a=n(42),o=n(4);e.exports=function isIterateeCall(e,t,n){if(!o(n))return!1;var s=typeof t;return!!("number"==s?i(n)&&a(t,n.length):"string"==s&&t in n)&&r(n[t],e)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=function(e){return function extract(e){var t=null;for(var n in e){var i=e[n],a=void 0===i?"undefined":r(i);if("function"===a)t||(t={}),t[n]=i;else if("object"===a&&null!==i&&!Array.isArray(i)){var o=extract(i);o&&(t||(t={}),t[n]=o)}}return t}(e)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function defineProperties(e,t){for(var n=0;n0&&(this.refs[t]--,0===this.refs[t]&&this.sheets[t].detach()):(0,i.default)(!1,"SheetsManager: can't find sheet to unmanage")}},{key:"size",get:function get(){return this.keys.length}}]),SheetsManager}();t.default=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=function cloneStyle(e){if(null==e)return e;var t=void 0===e?"undefined":r(e);if("string"===t||"number"===t||"function"===t)return e;if(a(e))return e.map(cloneStyle);if((0,i.default)(e))return e;var n={};for(var o in e){var s=e[o];"object"!==(void 0===s?"undefined":r(s))?n[o]=s:n[o]=cloneStyle(s)}return n};var i=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(n(76));var a=Array.isArray},function(e,t,n){e.exports=n(206)},function(e,t,n){"use strict";(function(e,r){Object.defineProperty(t,"__esModule",{value:!0});var i=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(n(207));var a;a="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==e?e:r;var o=(0,i.default)(a);t.default=o}).call(t,n(7),n(28)(e))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function symbolObservablePonyfill(e){var t,n=e.Symbol;"function"==typeof n?n.observable?t=n.observable:(t=n("observable"),n.observable=t):t="@@observable";return t}},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});e.CSS;t.default=function(e){return e}}).call(t,n(7))},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});var n="2f1acc6c3a606b082e5eef5e54414ffb";null==e[n]&&(e[n]=0),t.default=e[n]++}).call(t,n(7))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=Object.assign||function(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{};return e.createGenerateClassName&&(this.options.createGenerateClassName=e.createGenerateClassName,this.generateClassName=e.createGenerateClassName()),null!=e.insertionPoint&&(this.options.insertionPoint=e.insertionPoint),(e.virtual||e.Renderer)&&(this.options.Renderer=e.Renderer||(e.virtual?y.default:g.default)),e.plugins&&this.use.apply(this,e.plugins),this}},{key:"createStyleSheet",value:function createStyleSheet(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.index;"number"!=typeof n&&(n=0===h.default.index?0:h.default.index+1);var r=new s.default(e,i({},t,{jss:this,generateClassName:t.generateClassName||this.generateClassName,insertionPoint:this.options.insertionPoint,Renderer:this.options.Renderer,index:n}));return this.plugins.onProcessSheet(r),r}},{key:"removeStyleSheet",value:function removeStyleSheet(e){return e.detach(),h.default.remove(e),this}},{key:"createRule",value:function createRule(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};"object"===(void 0===e?"undefined":r(e))&&(n=t,t=e,e=void 0);var i=n;i.jss=this,i.Renderer=this.options.Renderer,i.generateClassName||(i.generateClassName=this.generateClassName),i.classes||(i.classes={});var a=(0,m.default)(e,t,i);return!i.selector&&a instanceof f.default&&(a.selector="."+i.generateClassName(a)),this.plugins.onProcessRule(a),a}},{key:"use",value:function use(){for(var e=this,t=arguments.length,n=Array(t),r=0;r0&&void 0!==arguments[0]?arguments[0]:{indent:1},t=this.rules.toString(e);return t&&(t+="\n"),this.key+" {\n"+t+"}"}}]),KeyframesRule}();t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{indent:1},t=this.rules.toString(e);return t?this.key+" {\n"+t+"\n}":""}}]),ConditionalRule}();t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function defineProperties(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:0;return e.substr(t,e.indexOf("{")-1)};return function(t){if(t.type===l)return t.selectorText;if(t.type===u){var n=t.name;if(n)return"@keyframes "+n;var r=t.cssText;return"@"+e(r,r.indexOf("keyframes"))}return e(t.cssText)}}();function setSelector(e,t){return e.selectorText=t,e.selectorText===t}var p=function(){var e=void 0;return function(){return e||(e=document.head||document.getElementsByTagName("head")[0]),e}}(),h=function(){var e=void 0,t=!1;return function(n){var r={};e||(e=document.createElement("style"));for(var i=0;i0){var n=function findHigherSheet(e,t){for(var n=0;nt.index&&r.options.insertionPoint===t.insertionPoint)return r}return null}(t,e);if(n)return n.renderer.element;if(n=function findHighestSheet(e,t){for(var n=e.length-1;n>=0;n--){var r=e[n];if(r.attached&&r.options.insertionPoint===t.insertionPoint)return r}return null}(t,e))return n.renderer.element.nextElementSibling}var r=e.insertionPoint;if(r&&"string"==typeof r){var o=function findCommentNode(e){for(var t=p(),n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=!1,n=[],r=void 0,i=void 0,a=function setSelector(){i.selector=n.join(",\n")},o=h(a);return{onProcessRule:function onProcessRule(a,l){if(!l||l===r||"style"!==a.type)return;if(!p(a,l,e))return;i||(r=a.options.jss.createStyleSheet(null,s),i=r.addRule("reset",u(e.reset)),r.attach());var c=a.selector;-1===n.indexOf(c)&&(n.push(c),t=o())},onProcessSheet:function onProcessSheet(){!t&&n.length&&a()}}};var a=_interopRequireDefault(n(226)),o=_interopRequireDefault(n(227));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var s={meta:"jss-isolate",index:-1/0,link:!0},l={inherited:a.default,all:o.default},u=function getStyle(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"inherited";if("string"==typeof e)return l[e];if("object"===(void 0===e?"undefined":i(e))){if(Array.isArray(e)){var t=e[0],n=e[1];return r({},l[t],n)}return r({},a.default,e)}return a.default},c={keyframes:!0,conditional:!0},p=function shouldIsolate(e,t,n){var r=e.options.parent;if(r&&c[r.type])return!1;var i=null==n.isolate||n.isolate;return null!=t.options.isolate&&(i=t.options.isolate),null!=e.style.isolate&&(i=e.style.isolate,delete e.style.isolate),"string"==typeof i?i===e.key:i},h=function createDebounced(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=Date.now();return function(){var r=Date.now();return!(r-n0&&void 0!==arguments[0]?arguments[0]:{});return{onProcessStyle:function onProcessStyle(t,n){if("style"!==n.type)return t;for(var r in t)t[r]=iterate(r,t[r],e);return t},onChangeValue:function onChangeValue(t,n){return iterate(n,t,e)}}};function addCamelCasedVersion(e){var t=/(-[a-z])/g,n=function replace(e){return e[1].toUpperCase()},r={};for(var i in e)r[i]=e[i],r[i.replace(t,n)]=e[i];return r}var i=addCamelCasedVersion(function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(n(231)).default);function iterate(e,t,n){if(!t)return t;var a=t,o=void 0===t?"undefined":r(t);switch("object"===o&&Array.isArray(t)&&(o="array"),o){case"object":if("fallbacks"===e){for(var s in t)t[s]=iterate(s,t[s],n);break}for(var l in t)t[l]=iterate(e+"-"+l,t[l],n);break;case"array":for(var u=0;u-1)return registerClass(e,t.split(" "));var a=e.options.parent;if("$"===t[0]){var o=a.getRule(t.substr(1));return o?o===e?((0,r.default)(!1,"[JSS] Cyclic composition detected. \r\n%s",e),!1):(a.classes[e.key]+=" "+a.classes[o.key],!0):((0,r.default)(!1,"[JSS] Referenced rule is not defined. \r\n%s",e),!1)}return e.options.parent.classes[e.key]+=" "+t,!0}(t,e.composes),delete e.composes,e):e}}};var r=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(n(9))},function(e,t,n){"use strict";t.a={animation:"none 0s ease 0s 1 normal none running","backface-visibility":"visible",background:"transparent none repeat 0 0 / auto auto padding-box border-box scroll",border:"medium none currentColor","border-image":"none","border-radius":"0",bottom:"auto","box-shadow":"none",clear:"none",clip:"auto",columns:"auto","column-count":"auto","column-fill":"balance","column-gap":"normal","column-rule":"medium none currentColor","column-span":"1","column-width":"auto",content:"normal","counter-increment":"none","counter-reset":"none",float:"none",height:"auto",hyphens:"none",left:"auto",margin:"0","max-height":"none","max-width":"none","min-height":"0","min-width":"0",opacity:"1",outline:"medium none invert",overflow:"visible","overflow-x":"visible","overflow-y":"visible",padding:"0","page-break-after":"auto","page-break-before":"auto","page-break-inside":"auto",perspective:"none","perspective-origin":"50% 50%",position:"static",right:"auto","table-layout":"auto","text-decoration":"none",top:"auto",transform:"none","transform-origin":"50% 50% 0","transform-style":"flat",transition:"none 0s ease 0s","unicode-bidi":"normal","vertical-align":"baseline",width:"auto","z-index":"auto"}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),n.d(t,"spaceFactor",function(){return r}),n.d(t,"space",function(){return i}),n.d(t,"color",function(){return a}),n.d(t,"fontFamily",function(){return o}),n.d(t,"fontSize",function(){return s}),n.d(t,"mq",function(){return l}),n.d(t,"borderRadius",function(){return u}),n.d(t,"maxWidth",function(){return c}),n.d(t,"sidebarWidth",function(){return p}),n.d(t,"buttonTextTransform",function(){return h});var r=8,i=[r/2,r,2*r,3*r,4*r,5*r,6*r],a={base:"#333",light:"#999",lightest:"#ccc",link:"#1978c8",linkHover:"#f28a25",border:"#e8e8e8",name:"#7f9a44",type:"#b77daa",error:"#c00",baseBackground:"#fff",codeBackground:"#f5f5f5",sidebarBackground:"#f5f5f5"},o={base:["-apple-system","BlinkMacSystemFont",'"Segoe UI"','"Roboto"','"Oxygen"','"Ubuntu"','"Cantarell"','"Fira Sans"','"Droid Sans"','"Helvetica Neue"',"sans-serif"],monospace:["Consolas",'"Liberation Mono"',"Menlo","monospace"]},s={base:15,text:16,small:13,h1:48,h2:36,h3:24,h4:18,h5:16,h6:16},l={small:"@media (max-width: 600px)"},u=3,c=1e3,p=200,h="uppercase"},function(e,t,n){var r=n(3);e.exports=function(){return r.Date.now()}},function(e,t,n){var r=n(4),i=n(30),a=NaN,o=/^\s+|\s+$/g,s=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;e.exports=function toNumber(e){if("number"==typeof e)return e;if(i(e))return a;if(r(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=r(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(o,"");var n=l.test(e);return n||u.test(e)?c(e.slice(2),n?2:8):s.test(e)?a:+e}},function(e,t){e.exports=function(e){var t="undefined"!=typeof window&&window.location;if(!t)throw new Error("fixUrls requires window.location");if(!e||"string"!=typeof e)return e;var n=t.protocol+"//"+t.host,r=n+t.pathname.replace(/\/[^\/]*$/,"/");return e.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(e,t){var i=t.trim().replace(/^"(.*)"$/,function(e,t){return t}).replace(/^'(.*)'$/,function(e,t){return t});if(/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/)/i.test(i))return e;var a;return a=0===i.indexOf("//")?i:0===i.indexOf("/")?n+i:r+i.replace(/^\.\//,""),"url("+JSON.stringify(a)+")"})}},function(e,t,n){"use strict";var r=n(239);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";t.a=Usage;var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(240),l=n(307);function Usage(e){var t=e.props,n=t.props,r=t.methods,a=n&&i.a.createElement(s.a,{props:n}),o=r&&r.length>0&&i.a.createElement(l.a,{methods:r});return a||o?i.a.createElement("div",null,a,o):null}Usage.propTypes={props:o.a.shape({props:o.a.object,methods:o.a.array}).isRequired}},function(e,t,n){"use strict";var r=n(241);n.d(t,"a",function(){return r.a})},function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_exports__.a=PropsRenderer;var __WEBPACK_IMPORTED_MODULE_0_react__=__webpack_require__(0),__WEBPACK_IMPORTED_MODULE_0_react___default=__webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__),__WEBPACK_IMPORTED_MODULE_1_prop_types__=__webpack_require__(1),__WEBPACK_IMPORTED_MODULE_1_prop_types___default=__webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_prop_types__),__WEBPACK_IMPORTED_MODULE_2_react_group__=__webpack_require__(80),__WEBPACK_IMPORTED_MODULE_2_react_group___default=__webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_react_group__),__WEBPACK_IMPORTED_MODULE_3_javascript_stringify__=__webpack_require__(242),__WEBPACK_IMPORTED_MODULE_3_javascript_stringify___default=__webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_javascript_stringify__),__WEBPACK_IMPORTED_MODULE_4_rsg_components_Arguments__=__webpack_require__(82),__WEBPACK_IMPORTED_MODULE_5_rsg_components_Argument__=__webpack_require__(49),__WEBPACK_IMPORTED_MODULE_6_rsg_components_Code__=__webpack_require__(55),__WEBPACK_IMPORTED_MODULE_7_rsg_components_JsDoc__=__webpack_require__(56),__WEBPACK_IMPORTED_MODULE_8_rsg_components_Markdown__=__webpack_require__(10),__WEBPACK_IMPORTED_MODULE_9_rsg_components_Name__=__webpack_require__(54),__WEBPACK_IMPORTED_MODULE_10_rsg_components_Type__=__webpack_require__(94),__WEBPACK_IMPORTED_MODULE_11_rsg_components_Text__=__webpack_require__(93),__WEBPACK_IMPORTED_MODULE_12_rsg_components_Para__=__webpack_require__(52),__WEBPACK_IMPORTED_MODULE_13_rsg_components_Table__=__webpack_require__(96),__WEBPACK_IMPORTED_MODULE_14_lodash_map__=__webpack_require__(95),__WEBPACK_IMPORTED_MODULE_14_lodash_map___default=__webpack_require__.n(__WEBPACK_IMPORTED_MODULE_14_lodash_map__),__WEBPACK_IMPORTED_MODULE_15__util__=__webpack_require__(306),_extends=Object.assign||function(e){for(var t=1;t-1)return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_6_rsg_components_Code__.a,null,Object(__WEBPACK_IMPORTED_MODULE_15__util__.b)(Object(__WEBPACK_IMPORTED_MODULE_15__util__.c)(prop.defaultValue.value)));if("func"===propName)return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_11_rsg_components_Text__.a,{size:"small",color:"light",underlined:!0,title:Object(__WEBPACK_IMPORTED_MODULE_15__util__.b)(Object(__WEBPACK_IMPORTED_MODULE_15__util__.c)(prop.defaultValue.value))},"Function");if("shape"===propName||"object"===propName)try{var object=eval("("+prop.defaultValue.value+")");return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_11_rsg_components_Text__.a,{size:"small",color:"light",underlined:!0,title:__WEBPACK_IMPORTED_MODULE_3_javascript_stringify___default()(object,null,2)},"Shape")}catch(e){return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_11_rsg_components_Text__.a,{size:"small",color:"light",underlined:!0,title:prop.defaultValue.value},"Shape")}}return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_6_rsg_components_Code__.a,null,Object(__WEBPACK_IMPORTED_MODULE_15__util__.b)(Object(__WEBPACK_IMPORTED_MODULE_15__util__.c)(prop.defaultValue.value)))}return""}function renderDescription(e){var t=e.description,n=e.tags,r=void 0===n?{}:n,i=renderExtra(e),a=[].concat(_toConsumableArray(r.arg||[]),_toConsumableArray(r.argument||[]),_toConsumableArray(r.param||[])),o=r.return&&r.return[0]||r.returns&&r.returns[0];return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("div",null,t&&__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_8_rsg_components_Markdown__.a,{text:t}),i&&__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_12_rsg_components_Para__.a,null,i),__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_7_rsg_components_JsDoc__.a,r),a.length>0&&__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_4_rsg_components_Arguments__.a,{args:a,heading:!0}),o&&__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_5_rsg_components_Argument__.a,_extends({},o,{returns:!0})))}function renderExtra(e){var t=Object(__WEBPACK_IMPORTED_MODULE_15__util__.a)(e);if(!t)return null;switch(t.name){case"enum":return renderEnum(e);case"union":return renderUnion(e);case"shape":return renderShape(e.type.value);case"arrayOf":case"objectOf":return"shape"===t.value.name?renderShape(e.type.value.value):null;default:return null}}function renderUnion(e){if(!Array.isArray(Object(__WEBPACK_IMPORTED_MODULE_15__util__.a)(e).value))return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("span",null,Object(__WEBPACK_IMPORTED_MODULE_15__util__.a)(e).value);var t=Object(__WEBPACK_IMPORTED_MODULE_15__util__.a)(e).value.map(function(e,t){return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_10_rsg_components_Type__.a,{key:e.name+"-"+t},renderType(e))});return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("span",null,"One of type:"," ",__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_2_react_group___default.a,{separator:", ",inline:!0},t))}function renderName(e){var t=e.name,n=e.tags,r=void 0===n?{}:n;return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_9_rsg_components_Name__.a,{deprecated:!!r.deprecated},t)}function renderTypeColumn(e){return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_10_rsg_components_Type__.a,null,renderType(Object(__WEBPACK_IMPORTED_MODULE_15__util__.a)(e)))}function getRowKey(e){return e.name}function propsToArray(e){return __WEBPACK_IMPORTED_MODULE_14_lodash_map___default()(e,function(e,t){return _extends({},e,{name:t})})}var columns=[{caption:"Prop name",render:renderName},{caption:"Type",render:renderTypeColumn},{caption:"Default",render:renderDefault},{caption:"Description",render:renderDescription}];function PropsRenderer(e){var t=e.props;return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(__WEBPACK_IMPORTED_MODULE_13_rsg_components_Table__.a,{columns:columns,rows:(n=t,__WEBPACK_IMPORTED_MODULE_14_lodash_map___default()(n,function(e,t){return _extends({},e,{name:t})})),getRowKey:getRowKey});var n}PropsRenderer.propTypes={props:__WEBPACK_IMPORTED_MODULE_1_prop_types___default.a.object.isRequired}},function(e,t,n){(function(t){n=function(){var e=/[\\\'\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,n={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","'":"\\'",'"':'\\"',"\\":"\\\\"};function escapeChar(e){return n[e]||"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)}var r={};"break else new var case finally return void catch for switch while continue function this with default if throw delete in try do instanceof typeof abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws const goto private transient debugger implements protected volatile double import public let yield".split(" ").map(function(e){r[e]=!0});var i=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function isValidVariableName(e){return!r[e]&&i.test(e)}function toGlobalVariable(e){return"Function("+stringify("return this;")+")()"}function toPath(e){for(var t="",n=0;n-1)return void h.push(l.slice(),p[r]);c.push(e),p.push(l.slice())}if(!(l.length>i||s--<=0))return t(e,n,next)}:function(e,t){if(!(u.indexOf(e)>-1||l.length>i||s--<=0)){u.push(e);e=t(e,n,next);return u.pop(),e}};if("function"==typeof t){var d=f;f=function(e,n){return d(e,function(e,r,i){return t(e,r,function(e){return n(e,r,i)})})}}var m=f(e,stringify);if(h.length){for(var g=n?"\n":"",y=n?" = ":"=",v=";"+g,b=(d=n?"(function () {":"(function(){",["var x"+y+m]),_=0;_0?l-4:l;var u=0;for(t=0;t>16&255,s[u++]=r>>8&255,s[u++]=255&r;2===o?(r=i[e.charCodeAt(t)]<<2|i[e.charCodeAt(t+1)]>>4,s[u++]=255&r):1===o&&(r=i[e.charCodeAt(t)]<<10|i[e.charCodeAt(t+1)]<<4|i[e.charCodeAt(t+2)]>>2,s[u++]=r>>8&255,s[u++]=255&r);return s},t.fromByteArray=function fromByteArray(e){for(var t,n=e.length,i=n%3,a="",o=[],s=0,l=n-i;sl?l:s+16383));1===i?(t=e[n-1],a+=r[t>>2],a+=r[t<<4&63],a+="=="):2===i&&(t=(e[n-2]<<8)+e[n-1],a+=r[t>>10],a+=r[t>>4&63],a+=r[t<<2&63],a+="=");return o.push(a),o.join("")};for(var r=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,l=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function encodeChunk(e,t,n){for(var i,a=[],o=t;o>18&63]+r[s>>12&63]+r[s>>6&63]+r[63&s]);var s;return a.join("")}},function(e,t){t.read=function(e,t,n,r,i){var a,o,s=8*i-r-1,l=(1<>1,c=-7,p=n?i-1:0,h=n?-1:1,f=e[t+p];for(p+=h,a=f&(1<<-c)-1,f>>=-c,c+=s;c>0;a=256*a+e[t+p],p+=h,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=r;c>0;o=256*o+e[t+p],p+=h,c-=8);if(0===a)a=1-u;else{if(a===l)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,r),a-=u}return(f?-1:1)*o*Math.pow(2,a-r)},t.write=function(e,t,n,r,i,a){var o,s,l,u=8*a-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:a-1,d=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+p>=1?h/l:h*Math.pow(2,1-p))*l>=2&&(o++,l/=2),o+p>=c?(s=0,o=c):o+p>=1?(s=(t*l-1)*Math.pow(2,i),o+=p):(s=t*Math.pow(2,p-1)*Math.pow(2,i),o=0));i>=8;e[n+f]=255&s,f+=d,s/=256,i-=8);for(o=o<0;e[n+f]=255&o,f+=d,o/=256,u-=8);e[n+f-d]|=128*m}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){"use strict";var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(49),l=n(53),u=n(2),c=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(e,["classes","name","type","description","returns","block"]);return i.a.createElement(h.a,f({className:s&&t.block},p),o&&"Returns",n&&i.a.createElement("span",null,i.a.createElement(u.a,null,n),r&&":"),r&&i.a.createElement(c.a,null,r.name),r&&a&&" — ",a&&i.a.createElement(l.a,{text:""+a,inline:!0}))}ArgumentRenderer.propTypes={classes:o.a.object.isRequired,name:o.a.string,type:o.a.object,description:o.a.string,returns:o.a.bool,block:o.a.bool},t.a=Object(s.a)(function styles(e){return{block:{marginBottom:e.space[2]}}})(ArgumentRenderer)},function(e,t,n){"use strict";var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(249),l=n(251),u=n.n(l),c=n(44),p=n.n(c),h=n(2),f=n(92),d=n(93),m=n(52),g=n(293),y=Object.assign||function(e){for(var t=1;t[^\n]+(\n[^\n]+)*\n*)+\n{2,}/,p=/^ *> ?/gm,f=/^ {2,}\n/,d=/^(?:( *[-*_]) *){3,}(?:\n *)+\n/,m=/^\s*(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n *)+\n/,g=/^(?: {4}[^\n]+\n*)+(?:\n *)+\n/,y=/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,v=/^(?:\n *)*\n/,b=/\r\n?/g,_=/^\[\^(.*)\](:.*)\n/,x=/^\[\^(.*)\]/,w=/\f/g,k=/^\s*?\[(x|\s)\]/,E=/^ *(#{1,6}) *([^\n]+?) *#* *\n+/,C=/^([^\n]+)\n *(=|-){3,} *(?:\n *)+\n/,S=/^ *<([^ >/]+) ?([^>]*)\/{0}>(?=[\s\S]*<\/\1>)((?:[\s\S]*?(?:<\1[^>]*>[\s\S]*?<\/\1>)*[\s\S]*?)*?)<\/\1>\n*/,R=/^/,P=/^(data|aria)-[a-z_][a-z\d_.-]*$/,O=/^ *<([\w:]+)\s*((?:<.*?>|[^>])*)>(?!<\/\1>)\s*/,T=/^\{.*\}$/,j=/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,A=/^<([^ >]+@[^ >]+)>/,I=/^<([^ >]+:\/[^ >]+)>/,L=/ *\n+$/,N=/^$|\n *$/,M=/-([a-z])?/gi,D=/^(.*\|?.*)\n *(\|? *[-:]+ *\|[-| :]*)\n((?:.*\|.*\n)*)\n?/,B=/^((?:[^\n]|\n(?! *\n))+)(?:\n *)+\n/,U=/^\[([^\]]*)\]:\s*(\S+)\s*("([^"]*)")?/,F=/^!\[([^\]]*)\] ?\[([^\]]*)\]/,$=/^\[([^\]]*)\] ?\[([^\]]*)\]/,q=/\t/g,z=/(^ *\||\| *$)/g,V=/^ *:-+: *$/,W=/^ *:-+ *$/,H=/^ *-+: *$/,K=/ *\| */,G=/^[*_]{2}([\s\S]+?)[*_]{2}(?!\*|_)/,J=/^[*_]{1}([\s\S]+?)[*_]{1}(?!\*|_)/,Y=/^\\([^0-9A-Za-z\s])/,X=/^[\s\S]+?(?=[^0-9A-Z\s\u00c0-\uffff]|\d+\.|\n\n| {2,}\n|\w+:\S|$)/i,Q=/^~~(?=\S)([\s\S]*?\S)~~/,Z=/(^\n+|(\n|\s)+$)/g,ee=/\\([^0-9A-Z\s])/gi,te="(?:[*+-]|\\d+\\.)",ne="( *)("+te+") +",re=new RegExp("^"+ne),ie=new RegExp(ne+"[^\\n]*(?:\\n(?!\\1"+te+" )[^\\n]*)*(\\n|$)","gm"),ae=new RegExp("^( *)("+te+") [\\s\\S]+?(?:\\n{2,}(?! )(?!\\1"+te+" )\\n*|\\s*\\n*$)"),oe="(?:\\[[^\\]]*\\]|[^\\[\\]]|\\](?=[^\\[]*\\]))*",se="\\s*?(?:\\s+['\"]([\\s\\S]*?)['\"])?\\s*",le=new RegExp("^\\[("+oe+")\\]\\("+se+"\\)"),ue=new RegExp("^!\\[("+oe+")\\]\\("+se+"\\)");function parseTableAlignCapture(e){return H.test(e)?"right":V.test(e)?"center":W.test(e)?"left":null}function parseTable(e,t,n){n.inline=!0;var r=function parseTableHeader(e,t,n){return e[1].replace(z,"").trim().split(K).map(function(e){return t(e,n)})}(e,t,n),i=function parseTableAlign(e){return e[2].replace(z,"").trim().split(K).map(parseTableAlignCapture)}(e),a=function parseTableCells(e,t,n){return e[3].replace(z,"").trim().split("\n").map(function(e){return e.replace(z,"").split(K).map(function(e){return t(e.trim(),n)})})}(e,t,n);return n.inline=!1,{align:i,cells:a,header:r,type:"table"}}function getTableStyle(e,t){return null==e.align[t]?{}:{textAlign:e.align[t]}}function attributeValueToJSXPropValue(e,t){return"style"===e?t.split(/;\s?/).reduce(function(e,t){var n=t.slice(0,t.indexOf(":"));return e[n.replace(/(-[a-z])/g,function toUpper(e){return e[1].toUpperCase()})]=t.slice(n.length+1).trim(),e},{}):(function isInterpolation(e){return T.test(e)}(t)&&(t=t.slice(1,t.length-1)),"true"===t||"false"!==t&&t)}function parserFor(e){var t=Object.keys(e);t.sort(function(t,n){var r=e[t].order,i=e[n].order;return r!==i?r-i:t2?o-2:0),l=2;l\s)/g.test(e));var r=q(T(n?e:e.replace(Z,"")+"\n\n",{inline:n})),i=void 0;return r.length>1?i=h(n?"span":"div",null,r):1===r.length?"string"==typeof(i=r[0])&&(i=h("span",null,i)):i=h("span",null),i}function attrStringToMap(e){var t=e.match(s);return t?t.reduce(function(e,t,n){var r=t.indexOf("=");if(-1!==r){var s=function normalizeAttributeKey(e){return-1!==e.indexOf("-")&&null===e.match(P)&&(e=e.replace(M,function(e,t){return t.toUpperCase()})),e}(t.slice(0,r)),l=a(t.slice(r+1)),u=o[s]||s,c=e[u]=attributeValueToJSXPropValue(s,l);(S.test(c)||O.test(c))&&(e[u]=i.cloneElement(compile(c.trim()),{key:n}))}else e[o[t]||t]=!0;return e},{}):void 0}var n=[],b={},w={blockQuote:{match:blockRegex(c),order:pe,parse:function parse(e,t,n){return{content:t(e[0].replace(p,""),n)}},react:function react(e,t,n){return h("blockquote",{key:n.key},t(e.content,n))}},breakLine:{match:anyScopeRegex(f),order:pe,parse:captureNothing,react:function react(e,t,n){return h("br",{key:n.key})}},breakThematic:{match:blockRegex(d),order:pe,parse:captureNothing,react:function react(e,t,n){return h("hr",{key:n.key})}},codeBlock:{match:blockRegex(g),order:ce,parse:function parse(e){return{content:e[0].replace(/^ {4}/gm,"").replace(/\n+$/,""),lang:void 0}},react:function react(e,t,n){return h("pre",{key:n.key},h("code",{className:e.lang?"lang-"+e.lang:""},e.content))}},codeFenced:{match:blockRegex(m),order:ce,parse:function parse(e){return{content:e[3],lang:e[2]||void 0,type:"codeBlock"}}},codeInline:{match:inlineRegex(y),order:fe,parse:function parse(e){return{content:e[2]}},react:function react(e,t,n){return h("code",{key:n.key},e.content)}},footnote:{match:blockRegex(_),order:ce,parse:function parse(e){return n.push({footnote:e[2],identifier:e[1]}),{}},react:renderNothing},footnoteReference:{match:inlineRegex(x),order:pe,parse:function parse(e){return{content:e[1],target:"#"+e[1]}},react:function react(e,t,n){return h("a",{key:n.key,href:sanitizeUrl(e.target)},h("sup",{key:n.key},e.content))}},gfmTask:{match:inlineRegex(k),order:pe,parse:function parse(e){return{completed:"x"===e[1].toLowerCase()}},react:function react(e,t,n){return h("input",{checked:e.completed,key:n.key,readOnly:!0,type:"checkbox"})}},heading:{match:blockRegex(E),order:pe,parse:function parse(e,t,n){return{content:parseInline(t,e[2],n),level:e[1].length}},react:function react(e,t,n){return h("h"+e.level,{key:n.key},t(e.content,n))}},headingSetext:{match:blockRegex(C),order:ce,parse:function parse(e,t,n){return{content:parseInline(t,e[1],n),level:"="===e[2]?1:2,type:"heading"}}},htmlBlock:{match:anyScopeRegex(S),order:pe,parse:function parse(e,t,n){var r=e[3].match(S)?parseBlock:parseInline;return{attrs:attrStringToMap(e[2]),content:r(t,e[3].trim(),n),tag:e[1]}},react:function react(e,t,n){return h(e.tag,r({key:n.key},e.attrs),t(e.content,n))}},htmlComment:{match:anyScopeRegex(R),order:pe,parse:function parse(){return{}},react:renderNothing},htmlSelfClosing:{match:anyScopeRegex(O),order:pe,parse:function parse(e){return{attrs:attrStringToMap(e[2]),tag:e[1]}},react:function react(e,t,n){return h(e.tag,r({},e.attrs,{key:n.key}))}},image:{match:inlineRegex(ue),order:pe,parse:function parse(e){return{alt:e[1],target:unescapeUrl(e[2]),title:e[3]}},react:function react(e,t,n){return h("img",{key:n.key,alt:e.alt||void 0,title:e.title||void 0,src:sanitizeUrl(e.target)})}},link:{match:inlineRegex(le),order:fe,parse:function parse(e,t,n){return{content:t(e[1],n),target:unescapeUrl(e[2]),title:e[3]}},react:function react(e,t,n){return h("a",{key:n.key,href:sanitizeUrl(e.target),title:e.title},t(e.content,n))}},linkAngleBraceStyleDetector:{match:inlineRegex(I),order:ce,parse:function parse(e){return{content:[{content:e[1],type:"text"}],target:e[1],type:"link"}}},linkBareUrlDetector:{match:inlineRegex(j),order:ce,parse:function parse(e){return{content:[{content:e[1],type:"text"}],target:e[1],title:void 0,type:"link"}}},linkMailtoDetector:{match:inlineRegex(A),order:ce,parse:function parse(e){var t=e[1],n=e[1];return l.test(n)||(n="mailto:"+n),{content:[{content:t.replace("mailto:",""),type:"text"}],target:n,type:"link"}}},list:{match:function match(e,t,n){var r=N.test(n),i=t._list||!t.inline;return r&&i?ae.exec(e):null},order:pe,parse:function parse(e,t,n){var r=e[2],i=r.length>1,a=i?+r:void 0,o=e[0].replace(u,"\n").match(ie),s=!1;return{items:o.map(function(e,r){var i=re.exec(e)[0].length,a=new RegExp("^ {1,"+i+"}","gm"),l=e.replace(a,"").replace(re,""),u=r===o.length-1,c=-1!==l.indexOf("\n\n")||u&&s;s=c;var p=n.inline,h=n._list;n._list=!0;var f=void 0;c?(n.inline=!1,f=l.replace(L,"\n\n")):(n.inline=!0,f=l.replace(L,""));var d=t(f,n);return n.inline=p,n._list=h,d}),ordered:i,start:a}},react:function react(e,t,n){return h(e.ordered?"ol":"ul",{key:n.key,start:e.start},e.items.map(function generateListItem(e,r){return h("li",{key:r},t(e,n))}))}},newlineCoalescer:{match:blockRegex(v),order:fe,parse:captureNothing,react:function react(){return"\n"}},paragraph:{match:blockRegex(B),order:fe,parse:parseCaptureInline,react:function react(e,t,n){return h("p",{key:n.key},t(e.content,n))}},ref:{match:inlineRegex(U),order:ce,parse:function parse(e){return b[e[1]]={target:e[2],title:e[4]},{}},react:renderNothing},refImage:{match:inlineRegex(F),order:ce,parse:function parse(e){return{alt:e[1]||void 0,ref:e[2]}},react:function react(e,t,n){return h("img",{key:n.key,alt:e.alt,src:sanitizeUrl(b[e.ref].target),title:b[e.ref].title})}},refLink:{match:inlineRegex($),order:ce,parse:function parse(e,t,n){return{content:t(e[1],n),ref:e[2]}},react:function react(e,t,n){return h("a",{key:n.key,href:sanitizeUrl(b[e.ref].target),title:b[e.ref].title},t(e.content,n))}},table:{match:blockRegex(D),order:pe,parse:parseTable,react:function react(e,t,n){return h("table",{key:n.key},h("thead",null,h("tr",null,e.header.map(function generateHeaderCell(r,i){return h("th",{key:i,style:getTableStyle(e,i),scope:"col"},t(r,n))}))),h("tbody",null,e.cells.map(function generateTableRow(r,i){return h("tr",{key:i},r.map(function generateTableCell(r,i){return h("td",{key:i,style:getTableStyle(e,i)},t(r,n))}))})))}},text:{match:inlineRegex(X),order:de,parse:function parse(e){return{content:e[0]}},react:function react(e){return e.content}},textBolded:{match:inlineRegex(G),order:he,parse:parseCaptureInline,react:function react(e,t,n){return h("strong",{key:n.key},t(e.content,n))}},textEmphasized:{match:inlineRegex(J),order:fe,parse:function parse(e,t,n){return{content:t(e[2]||e[1],n)}},react:function react(e,t,n){return h("em",{key:n.key},t(e.content,n))}},textEscaped:{match:inlineRegex(Y),order:pe,parse:function parse(e){return{content:e[1],type:"text"}}},textStrikethroughed:{match:inlineRegex(Q),order:fe,parse:parseCaptureInline,react:function react(e,t,n){return h("del",{key:n.key},t(e.content,n))}}},T=parserFor(w),q=function reactFor(e){return function nestedReactOutput(t,n){if(n=n||{},Array.isArray(t)){for(var r=n.key,i=[],a=!1,o=0;o=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(e,["classes","children"]);return i.a.createElement("a",c({},r,{className:l()(t.link,r.className)}),n)}LinkRenderer.propTypes={children:o.a.node,className:o.a.string,classes:o.a.object.isRequired},t.a=Object(u.a)(function styles(e){var t=e.color;return{link:{"&, &:link, &:visited":{fontSize:"inherit",color:t.link,textDecoration:"none"},"&:hover, &:active":{isolate:!1,color:t.linkHover,cursor:"pointer"}}}})(LinkRenderer)},function(e,t,n){"use strict";var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(2),l=n(6),u=n.n(l),c=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(e,["classes","semantic","size","color","underlined","children"]),h=r||"span",f=u()(n.text,n[a+"Size"],n[o+"Color"],(t={},_defineProperty(t,n[r],r),_defineProperty(t,n.isUnderlined,s),t));return i.a.createElement(h,c({},p,{className:f}),l)}TextRenderer.propTypes={classes:o.a.object.isRequired,semantic:o.a.oneOf(["em","strong"]),size:o.a.oneOf(["inherit","small","base","text"]),color:o.a.oneOf(["base","light"]),underlined:o.a.bool,children:o.a.node.isRequired},TextRenderer.defaultProps={size:"inherit",color:"base",underlined:!1},t.a=Object(s.a)(function styles(e){var t=e.fontFamily,n=e.fontSize,r=e.color;return{text:{fontFamily:t.base},inheritSize:{fontSize:"inherit"},smallSize:{fontSize:n.small},baseSize:{fontSize:n.base},textSize:{fontSize:n.text},baseColor:{color:r.base},lightColor:{color:r.light},em:{fontStyle:"italic"},strong:{fontWeight:"bold"},isUnderlined:{borderBottom:[[1,"dotted",r.lightest]]}}})(TextRenderer)},function(e,t,n){"use strict";n.d(t,"b",function(){return l});var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(2),l=function styles(e){var t=e.space,n=e.color,r=e.fontFamily;return{para:{marginTop:0,marginBottom:t[2],color:n.base,fontFamily:r.base,fontSize:"inherit",lineHeight:1.5}}};function ParaRenderer(e){var t=e.classes,n=e.semantic,r=e.children,a=n||"div";return i.a.createElement(a,{className:t.para},r)}ParaRenderer.propTypes={classes:o.a.object.isRequired,semantic:o.a.oneOf(["p"]),children:o.a.node.isRequired},t.a=Object(s.a)(l)(ParaRenderer)},function(e,t,n){"use strict";var r=n(294);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(2),l=n(53);function MarkdownHeadingRenderer(e){var t=e.classes,n=e.level,r=e.children;return i.a.createElement("div",{className:t.spacing},i.a.createElement(l.a,{level:n},r))}MarkdownHeadingRenderer.propTypes={classes:o.a.object.isRequired,level:o.a.oneOf([1,2,3,4,5,6]).isRequired,children:o.a.node},t.a=Object(s.a)(function styles(e){return{spacing:{marginBottom:e.space[2]}}})(MarkdownHeadingRenderer)},function(e,t,n){"use strict";var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(6),l=n.n(s),u=n(2),c=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(e,["classes","level","children"]),o="h"+n,s=l()(t.heading,t["heading"+n]);return i.a.createElement(o,c({},a,{className:s}),r)}HeadingRenderer.propTypes={classes:o.a.object.isRequired,level:o.a.oneOf([1,2,3,4,5,6]).isRequired,children:o.a.node},t.a=Object(u.a)(function styles(e){var t=e.color,n=e.fontFamily,r=e.fontSize;return{heading:{margin:0,color:t.base,fontFamily:n.base,fontWeight:"normal"},heading1:{fontSize:r.h1},heading2:{fontSize:r.h2},heading3:{fontSize:r.h3},heading4:{fontSize:r.h4},heading5:{fontSize:r.h5},heading6:{fontSize:r.h6}}})(HeadingRenderer)},function(e,t,n){var r=n(297);"string"==typeof r&&(r=[[e.i,r,""]]);var i={hmr:!0};i.transform=void 0;n(112)(r,i);r.locals&&(e.exports=r.locals)},function(e,t,n){(e.exports=n(111)(void 0)).push([e.i,"/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */\n\n/* Tomorrow Comment */\n.hljs-comment,\n.hljs-quote {\n color: #8e908c;\n}\n\n/* Tomorrow Red */\n.hljs-variable,\n.hljs-template-variable,\n.hljs-tag,\n.hljs-name,\n.hljs-selector-id,\n.hljs-selector-class,\n.hljs-regexp,\n.hljs-deletion {\n color: #c82829;\n}\n\n/* Tomorrow Orange */\n.hljs-number,\n.hljs-built_in,\n.hljs-builtin-name,\n.hljs-literal,\n.hljs-type,\n.hljs-params,\n.hljs-meta,\n.hljs-link {\n color: #f5871f;\n}\n\n/* Tomorrow Yellow */\n.hljs-attribute {\n color: #eab700;\n}\n\n/* Tomorrow Green */\n.hljs-string,\n.hljs-symbol,\n.hljs-bullet,\n.hljs-addition {\n color: #718c00;\n}\n\n/* Tomorrow Blue */\n.hljs-title,\n.hljs-section {\n color: #4271ae;\n}\n\n/* Tomorrow Purple */\n.hljs-keyword,\n.hljs-selector-tag {\n color: #8959a8;\n}\n\n.hljs {\n display: block;\n overflow-x: auto;\n background: white;\n color: #4d4d4c;\n padding: 0.5em;\n}\n\n.hljs-emphasis {\n font-style: italic;\n}\n\n.hljs-strong {\n font-weight: bold;\n}\n",""])},function(e,t,n){"use strict";var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(55),l=n(2),u=n(6),c=n.n(u);function NameRenderer(e){var t=e.classes,n=e.children,r=e.deprecated,a=c()(t.name,function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},t.isDeprecated,r));return i.a.createElement(s.a,{className:a},n)}NameRenderer.propTypes={classes:o.a.object.isRequired,children:o.a.node.isRequired,deprecated:o.a.bool},t.a=Object(l.a)(function styles(e){var t=e.fontFamily,n=e.fontSize,r=e.color;return{name:{fontFamily:t.monospace,fontSize:n.small,color:r.name},isDeprecated:{color:r.light,textDecoration:"line-through"}}})(NameRenderer)},function(e,t,n){"use strict";var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(2);function CodeRenderer(e){var t=e.classes,n=e.className,r=e.children;return i.a.createElement("span",{className:n},i.a.createElement("code",{className:t.code},r))}CodeRenderer.propTypes={classes:o.a.object.isRequired,className:o.a.string,children:o.a.node},t.a=Object(s.a)(function styles(e){return{code:{display:"inline",fontFamily:e.fontFamily.monospace,fontSize:"inherit",color:"inherit",background:"transparent"}}})(CodeRenderer)},function(e,t,n){"use strict";var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(55),l=n(2);function TypeRenderer(e){var t=e.classes,n=e.children;return i.a.createElement(s.a,{className:t.type},n)}TypeRenderer.propTypes={classes:o.a.object.isRequired,children:o.a.node.isRequired},t.a=Object(l.a)(function styles(e){var t=e.fontFamily,n=e.fontSize,r=e.color;return{type:{fontFamily:t.monospace,fontSize:n.small,color:r.type}}})(TypeRenderer)},function(e,t,n){"use strict";t.a=JsDoc;var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(10),l=n(95),u=n.n(l),c=function paragraphs(e){return e.map(function(e){return e.description}).join("\n\n")},p={deprecated:function deprecated(e){return"**Deprecated:** "+e[0].description},see:function see(e){return c(e)},link:function link(e){return c(e)},author:function author(e){return function plural(e,t){return 1===e.length?t:t+"s"}(e,"Author")+": "+function list(e){return e.map(function(e){return e.description}).join(", ")}(e)},version:function version(e){return"Version: "+e[0].description},since:function since(e){return"Since: "+e[0].description}};function JsDoc(e){var t=function getMarkdown(e){return u()(p,function(t,n){return e[n]&&t(e[n])}).filter(Boolean).join("\n\n")}(e);return t?i.a.createElement(s.a,{text:t}):null}JsDoc.propTypes={deprecated:o.a.array,see:o.a.array,link:o.a.array,author:o.a.array,version:o.a.array,since:o.a.array}},function(e,t,n){var r=n(303),i=n(15);e.exports=function baseMap(e,t){var n=-1,a=i(e)?Array(e.length):[];return r(e,function(e,r,i){a[++n]=t(e,r,i)}),a}},function(e,t,n){var r=n(83),i=n(304)(r);e.exports=i},function(e,t,n){var r=n(15);e.exports=function createBaseEach(e,t){return function(n,i){if(null==n)return n;if(!r(n))return e(n,i);for(var a=n.length,o=t?a:-1,s=Object(n);(t?o--:++o0?i.a.createElement(s.a,e,"Props & methods"):null};l.propTypes={onClick:o.a.func.isRequired,name:o.a.string.isRequired,props:o.a.shape({props:o.a.object,methods:o.a.array}).isRequired,active:o.a.bool},t.a=l},function(e,t,n){"use strict";var r=n(317);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(318),l=n(325),u=n(101),c=n(359),p=n(361),h=n(104),f=(n.n(h),n(17)),d=function(){function defineProperties(e,t){for(var n=0;n0,content:n.length>0&&t.renderLevel(n)})});return i.a.createElement(s.a,{items:n})}},{key:"renderSections",value:function renderSections(){var e=this.state.searchTerm,t=this.props.sections,n=1===t.length?t[0].components:t,r=Object(u.a)(n,e);return this.renderLevel(r)}},{key:"render",value:function render(){var e=this,t=this.state.searchTerm;return i.a.createElement(l.a,{searchTerm:t,onSearchTermChange:function onSearchTermChange(t){return e.setState({searchTerm:t})}},this.renderSections())}}]),TableOfContents}();p.propTypes={sections:o.a.array.isRequired},t.a=p},function(e,t,n){"use strict";var r=n(321);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(6),l=n.n(s),u=n(92),c=n(2);function ComponentsListRenderer(e){var t=e.classes,n=e.items;return(n=n.filter(function(e){return e.name})).length?i.a.createElement("ul",{className:t.list},n.map(function(e){var n=e.heading,r=e.name,a=e.slug,o=e.content;return i.a.createElement("li",{className:l()(t.item,(!o||!o.props.items.length)&&t.isChild),key:r},i.a.createElement(u.a,{className:l()(n&&t.heading),href:"#"+a},r),o)})):null}ComponentsListRenderer.propTypes={items:o.a.array.isRequired,classes:o.a.object.isRequired},t.a=Object(c.a)(function styles(e){var t=e.color,n=e.fontFamily,r=e.fontSize,i=e.space,a=e.mq;return{list:{margin:0,paddingLeft:i[2]},item:{color:t.base,display:"block",margin:[[i[1],0,i[1],0]],fontFamily:n.base,fontSize:r.base,listStyle:"none",overflow:"hidden",textOverflow:"ellipsis"},isChild:function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},a.small,{display:"inline-block",margin:[[0,i[1],0,0]]}),heading:{color:t.base,marginTop:i[1],fontFamily:n.base,fontWeight:"bold"}}})(ComponentsListRenderer)},function(e,t,n){"use strict";var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(2);function TableOfContentsRenderer(e){var t=e.classes,n=e.children,r=e.searchTerm,a=e.onSearchTermChange;return i.a.createElement("div",null,i.a.createElement("div",{className:t.root},i.a.createElement("div",{className:t.search},i.a.createElement("input",{value:r,className:t.input,placeholder:"Filter by name",onChange:function onChange(e){return a(e.target.value)}})),n))}TableOfContentsRenderer.propTypes={classes:o.a.object.isRequired,children:o.a.node,searchTerm:o.a.string.isRequired,onSearchTermChange:o.a.func.isRequired},t.a=Object(s.a)(function styles(e){var t=e.space,n=e.color,r=e.fontFamily,i=e.fontSize,a=e.borderRadius;return{root:{fontFamily:r.base},search:{padding:t[2]},input:{display:"block",width:"100%",padding:t[1],color:n.base,backgroundColor:n.baseBackground,fontFamily:r.base,fontSize:i.base,border:[[1,n.border,"solid"]],borderRadius:a,transition:"border-color ease-in-out .15s","&:focus":{isolate:!1,borderColor:n.link,outline:0},"&::placeholder":{isolate:!1,fontFamily:r.base,fontSize:i.base,color:n.light}}}})(TableOfContentsRenderer)},function(e,t,n){"use strict";t.a=function filterSectionsByName(e,t){var n=Object(r.a)(t);return e.map(function(e){return a({},e,{sections:e.sections?filterSectionsByName(e.sections,t):[],components:e.components?Object(i.a)(e.components,t):[]})}).filter(function(e){return e.components.length>0||e.sections.length>0||n.test(e.name)})};var r=n(100),i=n(324),a=Object.assign||function(e){for(var t=1;t0&&console.clear(),this.executeCode()}},{key:"shouldComponentUpdate",value:function shouldComponentUpdate(e,t){return this.state.error!==t.error||this.props.code!==e.code}},{key:"componentDidUpdate",value:function componentDidUpdate(e){this.props.code!==e.code&&this.executeCode()}},{key:"componentWillUnmount",value:function componentWillUnmount(){this.unmountPreview()}},{key:"unmountPreview",value:function unmountPreview(){this.mountNode&&l.a.unmountComponentAtNode(this.mountNode)}},{key:"executeCode",value:function executeCode(){var e=this;this.setState({error:null});var t=this.props.code;if(t){var n=this.compileCode(t);if(n){var r=this.evalInContext(n),a=i.a.createElement(f.a,{onError:this.handleError},i.a.createElement(m,{component:r}));window.requestAnimationFrame(function(){e.unmountPreview();try{l.a.render(a,e.mountNode)}catch(t){e.handleError(t)}})}}}},{key:"compileCode",value:function compileCode(e){try{return function _compileCode(e,t){return Object(p.transform)(e,t).code}(e,this.context.config.compilerConfig)}catch(e){this.handleError(e)}return!1}},{key:"evalInContext",value:function evalInContext(e){var t="\n\t\t\tvar stateWrapper = {\n\t\t\t\tset initialState(value) {\n\t\t\t\t\t__setInitialState(value)\n\t\t\t\t},\n\t\t\t}\n\t\t\twith (stateWrapper) {\n\t\t\t\treturn eval("+JSON.stringify(e)+")\n\t\t\t}\n\t\t";return this.props.evalInContext(t)}},{key:"handleError",value:function handleError(e){this.unmountPreview(),this.setState({error:e.toString()}),console.error(e)}},{key:"render",value:function render(){var e=this,t=this.state.error;return i.a.createElement("div",null,i.a.createElement("div",{ref:function ref(t){return e.mountNode=t}}),t&&i.a.createElement(h.a,{message:t}))}}]),Preview}();g.propTypes={code:o.a.string.isRequired,evalInContext:o.a.func.isRequired},g.contextTypes={config:o.a.object.isRequired,codeRevision:o.a.number.isRequired},t.a=g},function(e,t){e.exports=function noop(){}},function(e,t,n){(function(e,n){(function(t){"use strict";var r={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},i="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",a={5:i,6:i+" const class extends export import super"},o="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠ-ࢴࢶ-ࢽऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿕ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞮꞰ-ꞷꟷ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭥꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",s="‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣔ-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఃా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ഁ-ഃാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ංඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ູົຼ່-ໍ໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠐-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭ᳲ-᳴᳸᳹᷀-᷵᷻-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱꤀-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_",l=new RegExp("["+o+"]"),u=new RegExp("["+o+s+"]");o=s=null;var c=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,17,26,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,449,56,264,8,2,36,18,0,50,29,881,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,0,32,6124,20,754,9486,1,3071,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,10591,541],p=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,1306,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,52,0,13,2,49,13,10,2,4,9,83,11,7,0,161,11,6,9,7,3,57,0,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,87,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,423,9,838,7,2,7,17,9,57,21,2,13,19882,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239];function isInAstralSet(e,t){for(var n=65536,r=0;re)return!1;if((n+=t[r+1])>=e)return!0}}function isIdentifierStart(e,t){return e<65?36===e:e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&l.test(String.fromCharCode(e)):!1!==t&&isInAstralSet(e,c)))}function isIdentifierChar(e,t){return e<48?36===e:e<58||!(e<65)&&(e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&u.test(String.fromCharCode(e)):!1!==t&&(isInAstralSet(e,c)||isInAstralSet(e,p)))))}var h=function TokenType(e,t){void 0===t&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null};function binop(e,t){return new h(e,{beforeExpr:!0,binop:t})}var f={beforeExpr:!0},d={startsExpr:!0},m={};function kw(e,t){return void 0===t&&(t={}),t.keyword=e,m[e]=new h(e,t)}var g={num:new h("num",d),regexp:new h("regexp",d),string:new h("string",d),name:new h("name",d),eof:new h("eof"),bracketL:new h("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new h("]"),braceL:new h("{",{beforeExpr:!0,startsExpr:!0}),braceR:new h("}"),parenL:new h("(",{beforeExpr:!0,startsExpr:!0}),parenR:new h(")"),comma:new h(",",f),semi:new h(";",f),colon:new h(":",f),dot:new h("."),question:new h("?",f),arrow:new h("=>",f),template:new h("template"),invalidTemplate:new h("invalidTemplate"),ellipsis:new h("...",f),backQuote:new h("`",d),dollarBraceL:new h("${",{beforeExpr:!0,startsExpr:!0}),eq:new h("=",{beforeExpr:!0,isAssign:!0}),assign:new h("_=",{beforeExpr:!0,isAssign:!0}),incDec:new h("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new h("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:binop("||",1),logicalAND:binop("&&",2),bitwiseOR:binop("|",3),bitwiseXOR:binop("^",4),bitwiseAND:binop("&",5),equality:binop("==/!=/===/!==",6),relational:binop("/<=/>=",7),bitShift:binop("<>/>>>",8),plusMin:new h("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:binop("%",10),star:binop("*",10),slash:binop("/",10),starstar:new h("**",{beforeExpr:!0}),_break:kw("break"),_case:kw("case",f),_catch:kw("catch"),_continue:kw("continue"),_debugger:kw("debugger"),_default:kw("default",f),_do:kw("do",{isLoop:!0,beforeExpr:!0}),_else:kw("else",f),_finally:kw("finally"),_for:kw("for",{isLoop:!0}),_function:kw("function",d),_if:kw("if"),_return:kw("return",f),_switch:kw("switch"),_throw:kw("throw",f),_try:kw("try"),_var:kw("var"),_const:kw("const"),_while:kw("while",{isLoop:!0}),_with:kw("with"),_new:kw("new",{beforeExpr:!0,startsExpr:!0}),_this:kw("this",d),_super:kw("super",d),_class:kw("class",d),_extends:kw("extends",f),_export:kw("export"),_import:kw("import"),_null:kw("null",d),_true:kw("true",d),_false:kw("false",d),_in:kw("in",{beforeExpr:!0,binop:7}),_instanceof:kw("instanceof",{beforeExpr:!0,binop:7}),_typeof:kw("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:kw("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:kw("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},y=/\r\n?|\n|\u2028|\u2029/,v=new RegExp(y.source,"g");function isNewLine(e){return 10===e||13===e||8232===e||8233===e}var b=/[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/,_=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,x=Object.prototype,w=x.hasOwnProperty,k=x.toString;function has(e,t){return w.call(e,t)}var E=Array.isArray||function(e){return"[object Array]"===k.call(e)},C=function Position(e,t){this.line=e,this.column=t};C.prototype.offset=function offset(e){return new C(this.line,this.column+e)};var S=function SourceLocation(e,t,n){this.start=t,this.end=n,null!==e.sourceFile&&(this.source=e.sourceFile)};function getLineInfo(e,t){for(var n=1,r=0;;){v.lastIndex=r;var i=v.exec(e);if(!(i&&i.index=2015&&(t.ecmaVersion-=2009),null==t.allowReserved&&(t.allowReserved=t.ecmaVersion<5),E(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}return E(t.onComment)&&(t.onComment=function pushComment(e,t){return function(n,r,i,a,o,s){var l={type:n?"Block":"Line",value:r,start:i,end:a};e.locations&&(l.loc=new S(this,o,s)),e.ranges&&(l.range=[i,a]),t.push(l)}}(t,t.onComment)),t}var P={};function keywordRegexp(e){return new RegExp("^(?:"+e.replace(/ /g,"|")+")$")}var O=function Parser(e,t,n){this.options=e=getOptions(e),this.sourceFile=e.sourceFile,this.keywords=keywordRegexp(a[e.ecmaVersion>=6?6:5]);var i="";if(!e.allowReserved){for(var o=e.ecmaVersion;!(i=r[o]);o--);"module"==e.sourceType&&(i+=" await")}this.reservedWords=keywordRegexp(i);var s=(i?i+" ":"")+r.strict;this.reservedWordsStrict=keywordRegexp(s),this.reservedWordsStrictBind=keywordRegexp(s+" "+r.strictBind),this.input=String(t),this.containsEsc=!1,this.loadPlugins(e.plugins),n?(this.pos=n,this.lineStart=this.input.lastIndexOf("\n",n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(y).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=g.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule="module"===e.sourceType,this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.inFunction=this.inGenerator=this.inAsync=!1,this.yieldPos=this.awaitPos=0,this.labels=[],0===this.pos&&e.allowHashBang&&"#!"===this.input.slice(0,2)&&this.skipLineComment(2),this.scopeStack=[],this.enterFunctionScope()};O.prototype.isKeyword=function isKeyword(e){return this.keywords.test(e)},O.prototype.isReservedWord=function isReservedWord(e){return this.reservedWords.test(e)},O.prototype.extend=function extend(e,t){this[e]=t(this[e])},O.prototype.loadPlugins=function loadPlugins(e){for(var t in e){var n=P[t];if(!n)throw new Error("Plugin '"+t+"' not found");n(this,e[t])}},O.prototype.parse=function parse(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)};var T=O.prototype,j=/^(?:'((?:\\.|[^'])*?)'|"((?:\\.|[^"])*?)"|;)/;T.strictDirective=function(e){for(;;){_.lastIndex=e,e+=_.exec(this.input)[0].length;var t=j.exec(this.input.slice(e));if(!t)return!1;if("use strict"==(t[1]||t[2]))return!0;e+=t[0].length}},T.eat=function(e){return this.type===e&&(this.next(),!0)},T.isContextual=function(e){return this.type===g.name&&this.value===e},T.eatContextual=function(e){return this.value===e&&this.eat(g.name)},T.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},T.canInsertSemicolon=function(){return this.type===g.eof||this.type===g.braceR||y.test(this.input.slice(this.lastTokEnd,this.start))},T.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},T.semicolon=function(){this.eat(g.semi)||this.insertSemicolon()||this.unexpected()},T.afterTrailingComma=function(e,t){if(this.type==e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},T.expect=function(e){this.eat(e)||this.unexpected()},T.unexpected=function(e){this.raise(null!=e?e:this.start,"Unexpected token")};function DestructuringErrors(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=-1}T.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,"Parenthesized pattern")}},T.checkExpressionErrors=function(e,t){var n=e?e.shorthandAssign:-1;if(!t)return n>=0;n>-1&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns")},T.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos=6&&(e.sourceType=this.options.sourceType),this.finishNode(e,"Program")};var I={kind:"loop"},L={kind:"switch"};A.isLet=function(){if(this.type!==g.name||this.options.ecmaVersion<6||"let"!=this.value)return!1;_.lastIndex=this.pos;var e=_.exec(this.input),t=this.pos+e[0].length,n=this.input.charCodeAt(t);if(91===n||123==n)return!0;if(isIdentifierStart(n,!0)){for(var r=t+1;isIdentifierChar(this.input.charCodeAt(r),!0);)++r;var i=this.input.slice(t,r);if(!this.isKeyword(i))return!0}return!1},A.isAsyncFunction=function(){if(this.type!==g.name||this.options.ecmaVersion<8||"async"!=this.value)return!1;_.lastIndex=this.pos;var e=_.exec(this.input),t=this.pos+e[0].length;return!(y.test(this.input.slice(this.pos,t))||"function"!==this.input.slice(t,t+8)||t+8!=this.input.length&&isIdentifierChar(this.input.charAt(t+8)))},A.parseStatement=function(e,t,n){var r,i=this.type,a=this.startNode();switch(this.isLet()&&(i=g._var,r="let"),i){case g._break:case g._continue:return this.parseBreakContinueStatement(a,i.keyword);case g._debugger:return this.parseDebuggerStatement(a);case g._do:return this.parseDoStatement(a);case g._for:return this.parseForStatement(a);case g._function:return!e&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(a,!1);case g._class:return e||this.unexpected(),this.parseClass(a,!0);case g._if:return this.parseIfStatement(a);case g._return:return this.parseReturnStatement(a);case g._switch:return this.parseSwitchStatement(a);case g._throw:return this.parseThrowStatement(a);case g._try:return this.parseTryStatement(a);case g._const:case g._var:return r=r||this.value,e||"var"==r||this.unexpected(),this.parseVarStatement(a,r);case g._while:return this.parseWhileStatement(a);case g._with:return this.parseWithStatement(a);case g.braceL:return this.parseBlock();case g.semi:return this.parseEmptyStatement(a);case g._export:case g._import:return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),i===g._import?this.parseImport(a):this.parseExport(a,n);default:if(this.isAsyncFunction()&&e)return this.next(),this.parseFunctionStatement(a,!0);var o=this.value,s=this.parseExpression();return i===g.name&&"Identifier"===s.type&&this.eat(g.colon)?this.parseLabeledStatement(a,o,s):this.parseExpressionStatement(a,s)}},A.parseBreakContinueStatement=function(e,t){var n="break"==t;this.next(),this.eat(g.semi)||this.insertSemicolon()?e.label=null:this.type!==g.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var r=0;r=6?this.eat(g.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")},A.parseForStatement=function(e){if(this.next(),this.labels.push(I),this.enterLexicalScope(),this.expect(g.parenL),this.type===g.semi)return this.parseFor(e,null);var t=this.isLet();if(this.type===g._var||this.type===g._const||t){var n=this.startNode(),r=t?"let":this.value;return this.next(),this.parseVar(n,!0,r),this.finishNode(n,"VariableDeclaration"),!(this.type===g._in||this.options.ecmaVersion>=6&&this.isContextual("of"))||1!==n.declarations.length||"var"!==r&&n.declarations[0].init?this.parseFor(e,n):this.parseForIn(e,n)}var i=new DestructuringErrors,a=this.parseExpression(!0,i);return this.type===g._in||this.options.ecmaVersion>=6&&this.isContextual("of")?(this.toAssignable(a),this.checkLVal(a),this.checkPatternErrors(i,!0),this.parseForIn(e,a)):(this.checkExpressionErrors(i,!0),this.parseFor(e,a))},A.parseFunctionStatement=function(e,t){return this.next(),this.parseFunction(e,!0,!1,t)},A.isFunction=function(){return this.type===g._function||this.isAsyncFunction()},A.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(!this.strict&&this.isFunction()),e.alternate=this.eat(g._else)?this.parseStatement(!this.strict&&this.isFunction()):null,this.finishNode(e,"IfStatement")},A.parseReturnStatement=function(e){return this.inFunction||this.options.allowReturnOutsideFunction||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(g.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")},A.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(g.braceL),this.labels.push(L),this.enterLexicalScope();for(var t,n=!1;this.type!=g.braceR;)if(this.type===g._case||this.type===g._default){var r=this.type===g._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),n=!0,t.test=null),this.expect(g.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(!0));return this.exitLexicalScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")},A.parseThrowStatement=function(e){return this.next(),y.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var N=[];A.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===g._catch){var t=this.startNode();this.next(),this.expect(g.parenL),t.param=this.parseBindingAtom(),this.enterLexicalScope(),this.checkLVal(t.param,"let"),this.expect(g.parenR),t.body=this.parseBlock(!1),this.exitLexicalScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(g._finally)?this.parseBlock():null,e.handler||e.finalizer||this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")},A.parseVarStatement=function(e,t){return this.next(),this.parseVar(e,!1,t),this.semicolon(),this.finishNode(e,"VariableDeclaration")},A.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(I),e.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(e,"WhileStatement")},A.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement(!1),this.finishNode(e,"WithStatement")},A.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")},A.parseLabeledStatement=function(e,t,n){for(var r=0,i=this.labels;r=0;o--){var s=this.labels[o];if(s.statementStart!=e.start)break;s.statementStart=this.start,s.kind=a}return this.labels.push({name:t,kind:a,statementStart:this.start}),e.body=this.parseStatement(!0),("ClassDeclaration"==e.body.type||"VariableDeclaration"==e.body.type&&"var"!=e.body.kind||"FunctionDeclaration"==e.body.type&&(this.strict||e.body.generator))&&this.raiseRecoverable(e.body.start,"Invalid labeled declaration"),this.labels.pop(),e.label=n,this.finishNode(e,"LabeledStatement")},A.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")},A.parseBlock=function(e){void 0===e&&(e=!0);var t=this.startNode();for(t.body=[],this.expect(g.braceL),e&&this.enterLexicalScope();!this.eat(g.braceR);){var n=this.parseStatement(!0);t.body.push(n)}return e&&this.exitLexicalScope(),this.finishNode(t,"BlockStatement")},A.parseFor=function(e,t){return e.init=t,this.expect(g.semi),e.test=this.type===g.semi?null:this.parseExpression(),this.expect(g.semi),e.update=this.type===g.parenR?null:this.parseExpression(),this.expect(g.parenR),this.exitLexicalScope(),e.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(e,"ForStatement")},A.parseForIn=function(e,t){var n=this.type===g._in?"ForInStatement":"ForOfStatement";return this.next(),e.left=t,e.right=this.parseExpression(),this.expect(g.parenR),this.exitLexicalScope(),e.body=this.parseStatement(!1),this.labels.pop(),this.finishNode(e,n)},A.parseVar=function(e,t,n){for(e.declarations=[],e.kind=n;;){var r=this.startNode();if(this.parseVarId(r,n),this.eat(g.eq)?r.init=this.parseMaybeAssign(t):"const"!==n||this.type===g._in||this.options.ecmaVersion>=6&&this.isContextual("of")?"Identifier"==r.id.type||t&&(this.type===g._in||this.isContextual("of"))?r.init=null:this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):this.unexpected(),e.declarations.push(this.finishNode(r,"VariableDeclarator")),!this.eat(g.comma))break}return e},A.parseVarId=function(e,t){e.id=this.parseBindingAtom(t),this.checkLVal(e.id,t,!1)},A.parseFunction=function(e,t,n,r){this.initFunction(e),this.options.ecmaVersion>=6&&!r&&(e.generator=this.eat(g.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&&(e.id="nullableID"===t&&this.type!=g.name?null:this.parseIdent(),e.id&&this.checkLVal(e.id,"var"));var i=this.inGenerator,a=this.inAsync,o=this.yieldPos,s=this.awaitPos,l=this.inFunction;return this.inGenerator=e.generator,this.inAsync=e.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),t||(e.id=this.type==g.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n),this.inGenerator=i,this.inAsync=a,this.yieldPos=o,this.awaitPos=s,this.inFunction=l,this.finishNode(e,t?"FunctionDeclaration":"FunctionExpression")},A.parseFunctionParams=function(e){this.expect(g.parenL),e.params=this.parseBindingList(g.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},A.parseClass=function(e,t){this.next(),this.parseClassId(e,t),this.parseClassSuper(e);var n=this.startNode(),r=!1;for(n.body=[],this.expect(g.braceL);!this.eat(g.braceR);)if(!this.eat(g.semi)){var i=this.startNode(),a=this.eat(g.star),o=!1,s=this.type===g.name&&"static"===this.value;this.parsePropertyName(i),i.static=s&&this.type!==g.parenL,i.static&&(a&&this.unexpected(),a=this.eat(g.star),this.parsePropertyName(i)),this.options.ecmaVersion>=8&&!a&&!i.computed&&"Identifier"===i.key.type&&"async"===i.key.name&&this.type!==g.parenL&&!this.canInsertSemicolon()&&(o=!0,this.parsePropertyName(i)),i.kind="method";var l=!1;if(!i.computed){var u=i.key;a||o||"Identifier"!==u.type||this.type===g.parenL||"get"!==u.name&&"set"!==u.name||(l=!0,i.kind=u.name,u=this.parsePropertyName(i)),!i.static&&("Identifier"===u.type&&"constructor"===u.name||"Literal"===u.type&&"constructor"===u.value)&&(r&&this.raise(u.start,"Duplicate constructor in the same class"),l&&this.raise(u.start,"Constructor can't have get/set modifier"),a&&this.raise(u.start,"Constructor can't be a generator"),o&&this.raise(u.start,"Constructor can't be an async method"),i.kind="constructor",r=!0)}if(this.parseClassMethod(n,i,a,o),l){var c="get"===i.kind?0:1;if(i.value.params.length!==c){var p=i.value.start;"get"===i.kind?this.raiseRecoverable(p,"getter should have no params"):this.raiseRecoverable(p,"setter should have exactly one param")}else"set"===i.kind&&"RestElement"===i.value.params[0].type&&this.raiseRecoverable(i.value.params[0].start,"Setter cannot use rest params")}}return e.body=this.finishNode(n,"ClassBody"),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")},A.parseClassMethod=function(e,t,n,r){t.value=this.parseMethod(n,r),e.body.push(this.finishNode(t,"MethodDefinition"))},A.parseClassId=function(e,t){e.id=this.type===g.name?this.parseIdent():!0===t?this.unexpected():null},A.parseClassSuper=function(e){e.superClass=this.eat(g._extends)?this.parseExprSubscripts():null},A.parseExport=function(e,t){if(this.next(),this.eat(g.star))return this.expectContextual("from"),e.source=this.type===g.string?this.parseExprAtom():this.unexpected(),this.semicolon(),this.finishNode(e,"ExportAllDeclaration");if(this.eat(g._default)){this.checkExport(t,"default",this.lastTokStart);var n;if(this.type===g._function||(n=this.isAsyncFunction())){var r=this.startNode();this.next(),n&&this.next(),e.declaration=this.parseFunction(r,"nullableID",!1,n)}else if(this.type===g._class){var i=this.startNode();e.declaration=this.parseClass(i,"nullableID")}else e.declaration=this.parseMaybeAssign(),this.semicolon();return this.finishNode(e,"ExportDefaultDeclaration")}if(this.shouldParseExportStatement())e.declaration=this.parseStatement(!0),"VariableDeclaration"===e.declaration.type?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id.name,e.declaration.id.start),e.specifiers=[],e.source=null;else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))e.source=this.type===g.string?this.parseExprAtom():this.unexpected();else{for(var a=0,o=e.specifiers;a=6&&e)switch(e.type){case"Identifier":this.inAsync&&"await"===e.name&&this.raise(e.start,"Can not use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":break;case"ObjectExpression":e.type="ObjectPattern";for(var n=0,r=e.properties;n=6&&(e.computed||e.method||e.shorthand))){var n,r=e.key;switch(r.type){case"Identifier":n=r.name;break;case"Literal":n=String(r.value);break;default:return}var i=e.kind;if(this.options.ecmaVersion>=6)"__proto__"===n&&"init"===i&&(t.proto&&this.raiseRecoverable(r.start,"Redefinition of __proto__ property"),t.proto=!0);else{var a=t[n="$"+n];if(a){("init"===i?this.strict&&a.init||a.get||a.set:a.init||a[i])&&this.raiseRecoverable(r.start,"Redefinition of property")}else a=t[n]={init:!1,get:!1,set:!1};a[i]=!0}}},D.parseExpression=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeAssign(e,t);if(this.type===g.comma){var a=this.startNodeAt(n,r);for(a.expressions=[i];this.eat(g.comma);)a.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(a,"SequenceExpression")}return i},D.parseMaybeAssign=function(e,t,n){if(this.inGenerator&&this.isContextual("yield"))return this.parseYield();var r=!1,i=-1,a=-1;t?(i=t.parenthesizedAssign,a=t.trailingComma,t.parenthesizedAssign=t.trailingComma=-1):(t=new DestructuringErrors,r=!0);var o=this.start,s=this.startLoc;this.type!=g.parenL&&this.type!=g.name||(this.potentialArrowAt=this.start);var l=this.parseMaybeConditional(e,t);if(n&&(l=n.call(this,l,o,s)),this.type.isAssign){this.checkPatternErrors(t,!0),r||DestructuringErrors.call(t);var u=this.startNodeAt(o,s);return u.operator=this.value,u.left=this.type===g.eq?this.toAssignable(l):l,t.shorthandAssign=-1,this.checkLVal(l),this.next(),u.right=this.parseMaybeAssign(e),this.finishNode(u,"AssignmentExpression")}return r&&this.checkExpressionErrors(t,!0),i>-1&&(t.parenthesizedAssign=i),a>-1&&(t.trailingComma=a),l},D.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(this.eat(g.question)){var a=this.startNodeAt(n,r);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect(g.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,"ConditionalExpression")}return i},D.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1);return this.checkExpressionErrors(t)?i:i.start==n&&"ArrowFunctionExpression"===i.type?i:this.parseExprOp(i,n,r,-1,e)},D.parseExprOp=function(e,t,n,r,i){var a=this.type.binop;if(null!=a&&(!i||this.type!==g._in)&&a>r){var o=this.type===g.logicalOR||this.type===g.logicalAND,s=this.value;this.next();var l=this.start,u=this.startLoc,c=this.parseExprOp(this.parseMaybeUnary(null,!1),l,u,a,i),p=this.buildBinary(t,n,e,c,s,o);return this.parseExprOp(p,t,n,r,i)}return e},D.buildBinary=function(e,t,n,r,i,a){var o=this.startNodeAt(e,t);return o.left=n,o.operator=i,o.right=r,this.finishNode(o,a?"LogicalExpression":"BinaryExpression")},D.parseMaybeUnary=function(e,t){var n,r=this.start,i=this.startLoc;if(this.inAsync&&this.isContextual("await"))n=this.parseAwait(),t=!0;else if(this.type.prefix){var a=this.startNode(),o=this.type===g.incDec;a.operator=this.value,a.prefix=!0,this.next(),a.argument=this.parseMaybeUnary(null,!0),this.checkExpressionErrors(e,!0),o?this.checkLVal(a.argument):this.strict&&"delete"===a.operator&&"Identifier"===a.argument.type?this.raiseRecoverable(a.start,"Deleting local variable in strict mode"):t=!0,n=this.finishNode(a,o?"UpdateExpression":"UnaryExpression")}else{if(n=this.parseExprSubscripts(e),this.checkExpressionErrors(e))return n;for(;this.type.postfix&&!this.canInsertSemicolon();){var s=this.startNodeAt(r,i);s.operator=this.value,s.prefix=!1,s.argument=n,this.checkLVal(n),this.next(),n=this.finishNode(s,"UpdateExpression")}}return!t&&this.eat(g.starstar)?this.buildBinary(r,i,n,this.parseMaybeUnary(null,!1),"**",!1):n},D.parseExprSubscripts=function(e){var t=this.start,n=this.startLoc,r=this.parseExprAtom(e),i="ArrowFunctionExpression"===r.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd);if(this.checkExpressionErrors(e)||i)return r;var a=this.parseSubscripts(r,t,n);return e&&"MemberExpression"===a.type&&(e.parenthesizedAssign>=a.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=a.start&&(e.parenthesizedBind=-1)),a},D.parseSubscripts=function(e,t,n,r){for(var i=this.options.ecmaVersion>=8&&"Identifier"===e.type&&"async"===e.name&&this.lastTokEnd==e.end&&!this.canInsertSemicolon(),a=void 0;;)if((a=this.eat(g.bracketL))||this.eat(g.dot)){var o=this.startNodeAt(t,n);o.object=e,o.property=a?this.parseExpression():this.parseIdent(!0),o.computed=!!a,a&&this.expect(g.bracketR),e=this.finishNode(o,"MemberExpression")}else if(!r&&this.eat(g.parenL)){var s=new DestructuringErrors,l=this.yieldPos,u=this.awaitPos;this.yieldPos=0,this.awaitPos=0;var c=this.parseExprList(g.parenR,this.options.ecmaVersion>=8,!1,s);if(i&&!this.canInsertSemicolon()&&this.eat(g.arrow))return this.checkPatternErrors(s,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=l,this.awaitPos=u,this.parseArrowExpression(this.startNodeAt(t,n),c,!0);this.checkExpressionErrors(s,!0),this.yieldPos=l||this.yieldPos,this.awaitPos=u||this.awaitPos;var p=this.startNodeAt(t,n);p.callee=e,p.arguments=c,e=this.finishNode(p,"CallExpression")}else{if(this.type!==g.backQuote)return e;var h=this.startNodeAt(t,n);h.tag=e,h.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(h,"TaggedTemplateExpression")}},D.parseExprAtom=function(e){var t,n=this.potentialArrowAt==this.start;switch(this.type){case g._super:return this.inFunction||this.raise(this.start,"'super' outside of function or class"),t=this.startNode(),this.next(),this.type!==g.dot&&this.type!==g.bracketL&&this.type!==g.parenL&&this.unexpected(),this.finishNode(t,"Super");case g._this:return t=this.startNode(),this.next(),this.finishNode(t,"ThisExpression");case g.name:var r=this.start,i=this.startLoc,a=this.parseIdent(this.type!==g.name);if(this.options.ecmaVersion>=8&&"async"===a.name&&!this.canInsertSemicolon()&&this.eat(g._function))return this.parseFunction(this.startNodeAt(r,i),!1,!1,!0);if(n&&!this.canInsertSemicolon()){if(this.eat(g.arrow))return this.parseArrowExpression(this.startNodeAt(r,i),[a],!1);if(this.options.ecmaVersion>=8&&"async"===a.name&&this.type===g.name)return a=this.parseIdent(),!this.canInsertSemicolon()&&this.eat(g.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(r,i),[a],!0)}return a;case g.regexp:var o=this.value;return(t=this.parseLiteral(o.value)).regex={pattern:o.pattern,flags:o.flags},t;case g.num:case g.string:return this.parseLiteral(this.value);case g._null:case g._true:case g._false:return(t=this.startNode()).value=this.type===g._null?null:this.type===g._true,t.raw=this.type.keyword,this.next(),this.finishNode(t,"Literal");case g.parenL:var s=this.start,l=this.parseParenAndDistinguishExpression(n);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(l)&&(e.parenthesizedAssign=s),e.parenthesizedBind<0&&(e.parenthesizedBind=s)),l;case g.bracketL:return t=this.startNode(),this.next(),t.elements=this.parseExprList(g.bracketR,!0,!0,e),this.finishNode(t,"ArrayExpression");case g.braceL:return this.parseObj(!1,e);case g._function:return t=this.startNode(),this.next(),this.parseFunction(t,!1);case g._class:return this.parseClass(this.startNode(),!1);case g._new:return this.parseNew();case g.backQuote:return this.parseTemplate();default:this.unexpected()}},D.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),this.next(),this.finishNode(t,"Literal")},D.parseParenExpression=function(){this.expect(g.parenL);var e=this.parseExpression();return this.expect(g.parenR),e},D.parseParenAndDistinguishExpression=function(e){var t,n=this.start,r=this.startLoc,i=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a,o,s=this.start,l=this.startLoc,u=[],c=!0,p=!1,h=new DestructuringErrors,f=this.yieldPos,d=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==g.parenR;){if(c?c=!1:this.expect(g.comma),i&&this.afterTrailingComma(g.parenR,!0)){p=!0;break}if(this.type===g.ellipsis){a=this.start,u.push(this.parseParenItem(this.parseRestBinding())),this.type===g.comma&&this.raise(this.start,"Comma is not permitted after the rest element");break}this.type!==g.parenL||o||(o=this.start),u.push(this.parseMaybeAssign(!1,h,this.parseParenItem))}var m=this.start,y=this.startLoc;if(this.expect(g.parenR),e&&!this.canInsertSemicolon()&&this.eat(g.arrow))return this.checkPatternErrors(h,!1),this.checkYieldAwaitInDefaultParams(),o&&this.unexpected(o),this.yieldPos=f,this.awaitPos=d,this.parseParenArrowList(n,r,u);u.length&&!p||this.unexpected(this.lastTokStart),a&&this.unexpected(a),this.checkExpressionErrors(h,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=d||this.awaitPos,u.length>1?((t=this.startNodeAt(s,l)).expressions=u,this.finishNodeAt(t,"SequenceExpression",m,y)):t=u[0]}else t=this.parseParenExpression();if(this.options.preserveParens){var v=this.startNodeAt(n,r);return v.expression=t,this.finishNode(v,"ParenthesizedExpression")}return t},D.parseParenItem=function(e){return e},D.parseParenArrowList=function(e,t,n){return this.parseArrowExpression(this.startNodeAt(e,t),n)};var B=[];D.parseNew=function(){var e=this.startNode(),t=this.parseIdent(!0);if(this.options.ecmaVersion>=6&&this.eat(g.dot))return e.meta=t,e.property=this.parseIdent(!0),"target"!==e.property.name&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is new.target"),this.inFunction||this.raiseRecoverable(e.start,"new.target can only be used in functions"),this.finishNode(e,"MetaProperty");var n=this.start,r=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(),n,r,!0),this.eat(g.parenL)?e.arguments=this.parseExprList(g.parenR,this.options.ecmaVersion>=8,!1):e.arguments=B,this.finishNode(e,"NewExpression")},D.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===g.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value,cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),n.tail=this.type===g.backQuote,this.finishNode(n,"TemplateElement")},D.parseTemplate=function(e){void 0===e&&(e={});var t=e.isTagged;void 0===t&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.expect(g.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(g.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,"TemplateLiteral")},D.isAsyncProp=function(e){return!e.computed&&"Identifier"===e.key.type&&"async"===e.key.name&&(this.type===g.name||this.type===g.num||this.type===g.string||this.type===g.bracketL||this.type.keyword)&&!y.test(this.input.slice(this.lastTokEnd,this.start))},D.parseObj=function(e,t){var n=this.startNode(),r=!0,i={};for(n.properties=[],this.next();!this.eat(g.braceR);){if(r)r=!1;else if(this.expect(g.comma),this.afterTrailingComma(g.braceR))break;var a=this.parseProperty(e,t);this.checkPropClash(a,i),n.properties.push(a)}return this.finishNode(n,e?"ObjectPattern":"ObjectExpression")},D.parseProperty=function(e,t){var n,r,i,a,o=this.startNode();return this.options.ecmaVersion>=6&&(o.method=!1,o.shorthand=!1,(e||t)&&(i=this.start,a=this.startLoc),e||(n=this.eat(g.star))),this.parsePropertyName(o),!e&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(o)?(r=!0,this.parsePropertyName(o,t)):r=!1,this.parsePropertyValue(o,e,n,r,i,a,t),this.finishNode(o,"Property")},D.parsePropertyValue=function(e,t,n,r,i,a,o){if((n||r)&&this.type===g.colon&&this.unexpected(),this.eat(g.colon))e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind="init";else if(this.options.ecmaVersion>=6&&this.type===g.parenL)t&&this.unexpected(),e.kind="init",e.method=!0,e.value=this.parseMethod(n,r);else if(t||!(this.options.ecmaVersion>=5)||e.computed||"Identifier"!==e.key.type||"get"!==e.key.name&&"set"!==e.key.name||this.type==g.comma||this.type==g.braceR)this.options.ecmaVersion>=6&&!e.computed&&"Identifier"===e.key.type?(this.checkUnreserved(e.key),e.kind="init",t?e.value=this.parseMaybeDefault(i,a,e.key):this.type===g.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,a,e.key)):e.value=e.key,e.shorthand=!0):this.unexpected();else{(n||r)&&this.unexpected(),e.kind=e.key.name,this.parsePropertyName(e),e.value=this.parseMethod(!1);var s="get"===e.kind?0:1;if(e.value.params.length!==s){var l=e.value.start;"get"===e.kind?this.raiseRecoverable(l,"getter should have no params"):this.raiseRecoverable(l,"setter should have exactly one param")}else"set"===e.kind&&"RestElement"===e.value.params[0].type&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")}},D.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(g.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(g.bracketR),e.key;e.computed=!1}return e.key=this.type===g.num||this.type===g.string?this.parseExprAtom():this.parseIdent(!0)},D.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=!1,e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},D.parseMethod=function(e,t){var n=this.startNode(),r=this.inGenerator,i=this.inAsync,a=this.yieldPos,o=this.awaitPos,s=this.inFunction;return this.initFunction(n),this.options.ecmaVersion>=6&&(n.generator=e),this.options.ecmaVersion>=8&&(n.async=!!t),this.inGenerator=n.generator,this.inAsync=n.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,this.enterFunctionScope(),this.expect(g.parenL),n.params=this.parseBindingList(g.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(n,!1),this.inGenerator=r,this.inAsync=i,this.yieldPos=a,this.awaitPos=o,this.inFunction=s,this.finishNode(n,"FunctionExpression")},D.parseArrowExpression=function(e,t,n){var r=this.inGenerator,i=this.inAsync,a=this.yieldPos,o=this.awaitPos,s=this.inFunction;return this.enterFunctionScope(),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.inGenerator=!1,this.inAsync=e.async,this.yieldPos=0,this.awaitPos=0,this.inFunction=!0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0),this.inGenerator=r,this.inAsync=i,this.yieldPos=a,this.awaitPos=o,this.inFunction=s,this.finishNode(e,"ArrowFunctionExpression")},D.parseFunctionBody=function(e,t){var n=t&&this.type!==g.braceL,r=this.strict,i=!1;if(n)e.body=this.parseMaybeAssign(),e.expression=!0,this.checkParams(e,!1);else{var a=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);r&&!a||(i=this.strictDirective(this.end))&&a&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list");var o=this.labels;this.labels=[],i&&(this.strict=!0),this.checkParams(e,!r&&!i&&!t&&this.isSimpleParamList(e.params)),e.body=this.parseBlock(!1),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=o}this.exitFunctionScope(),this.strict&&e.id&&this.checkLVal(e.id,"none"),this.strict=r},D.isSimpleParamList=function(e){for(var t=0,n=e;t0;)t[n]=arguments[n+1];for(var r=0,i=t;r=1;e--){var t=this.context[e];if("function"===t.token)return t.generator}return!1},H.updateContext=function(e){var t,n=this.type;n.keyword&&e==g.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},g.parenR.updateContext=g.braceR.updateContext=function(){if(1!=this.context.length){var e=this.context.pop();e===W.b_stat&&"function"===this.curContext().token&&(e=this.context.pop()),this.exprAllowed=!e.isExpr}else this.exprAllowed=!0},g.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?W.b_stat:W.b_expr),this.exprAllowed=!0},g.dollarBraceL.updateContext=function(){this.context.push(W.b_tmpl),this.exprAllowed=!0},g.parenL.updateContext=function(e){var t=e===g._if||e===g._for||e===g._with||e===g._while;this.context.push(t?W.p_stat:W.p_expr),this.exprAllowed=!0},g.incDec.updateContext=function(){},g._function.updateContext=g._class.updateContext=function(e){e.beforeExpr&&e!==g.semi&&e!==g._else&&(e!==g.colon&&e!==g.braceL||this.curContext()!==W.b_stat)?this.context.push(W.f_expr):this.context.push(W.f_stat),this.exprAllowed=!1},g.backQuote.updateContext=function(){this.curContext()===W.q_tmpl?this.context.pop():this.context.push(W.q_tmpl),this.exprAllowed=!1},g.star.updateContext=function(e){if(e==g._function){var t=this.context.length-1;this.context[t]===W.f_expr?this.context[t]=W.f_expr_gen:this.context[t]=W.f_gen}this.exprAllowed=!0},g.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&("of"==this.value&&!this.exprAllowed||"yield"==this.value&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var K=function Token(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new S(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},G=O.prototype,J="object"==typeof Packages&&"[object JavaPackage]"==Object.prototype.toString.call(Packages);G.next=function(){this.options.onToken&&this.options.onToken(new K(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},G.getToken=function(){return this.next(),new K(this)},"undefined"!=typeof Symbol&&(G[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===g.eof,value:t}}}}),G.curContext=function(){return this.context[this.context.length-1]},G.nextToken=function(){var e=this.curContext();return e&&e.preserveSpace||this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length?this.finishToken(g.eof):e.override?e.override(this):void this.readToken(this.fullCharCodeAtPos())},G.readToken=function(e){return isIdentifierStart(e,this.options.ecmaVersion>=6)||92===e?this.readWord():this.getTokenFromCode(e)},G.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=57344)return e;return(e<<10)+this.input.charCodeAt(this.pos+1)-56613888},G.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf("*/",this.pos+=2);if(-1===n&&this.raise(this.pos-2,"Unterminated comment"),this.pos=n+2,this.options.locations){v.lastIndex=t;for(var r;(r=v.exec(this.input))&&r.index8&&e<14||e>=5760&&b.test(String.fromCharCode(e))))break e;++this.pos}}},G.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},G.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&46===e&&46===t?(this.pos+=3,this.finishToken(g.ellipsis)):(++this.pos,this.finishToken(g.dot))},G.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===e?this.finishOp(g.assign,2):this.finishOp(g.slash,1)},G.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=42===e?g.star:g.modulo;return this.options.ecmaVersion>=7&&42==e&&42===t&&(++n,r=g.starstar,t=this.input.charCodeAt(this.pos+2)),61===t?this.finishOp(g.assign,n+1):this.finishOp(r,n)},G.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.finishOp(124===e?g.logicalOR:g.logicalAND,2):61===t?this.finishOp(g.assign,2):this.finishOp(124===e?g.bitwiseOR:g.bitwiseAND,1)},G.readToken_caret=function(){return 61===this.input.charCodeAt(this.pos+1)?this.finishOp(g.assign,2):this.finishOp(g.bitwiseXOR,1)},G.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?45!=t||this.inModule||62!=this.input.charCodeAt(this.pos+2)||0!==this.lastTokEnd&&!y.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(g.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===t?this.finishOp(g.assign,2):this.finishOp(g.plusMin,1)},G.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=62===e&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+n)?this.finishOp(g.assign,n+1):this.finishOp(g.bitShift,n)):33!=t||60!=e||this.inModule||45!=this.input.charCodeAt(this.pos+2)||45!=this.input.charCodeAt(this.pos+3)?(61===t&&(n=2),this.finishOp(g.relational,n)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},G.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(g.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===e&&62===t&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(g.arrow)):this.finishOp(61===e?g.eq:g.prefix,1)},G.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(g.parenL);case 41:return++this.pos,this.finishToken(g.parenR);case 59:return++this.pos,this.finishToken(g.semi);case 44:return++this.pos,this.finishToken(g.comma);case 91:return++this.pos,this.finishToken(g.bracketL);case 93:return++this.pos,this.finishToken(g.bracketR);case 123:return++this.pos,this.finishToken(g.braceL);case 125:return++this.pos,this.finishToken(g.braceR);case 58:return++this.pos,this.finishToken(g.colon);case 63:return++this.pos,this.finishToken(g.question);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(g.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(120===t||88===t)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(111===t||79===t)return this.readRadixNumber(8);if(98===t||66===t)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 126:return this.finishOp(g.prefix,1)}this.raise(this.pos,"Unexpected character '"+codePointToString(e)+"'")},G.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)};function tryCreateRegexp(e,t,n,r){try{return new RegExp(e,t)}catch(e){if(void 0!==n)throw e instanceof SyntaxError&&r.raise(n,"Error parsing regular expression: "+e.message),e}}var Y=!!tryCreateRegexp("￿","u");G.readRegexp=function(){for(var e,t,n=this,r=this.pos;;){n.pos>=n.input.length&&n.raise(r,"Unterminated regular expression");var i=n.input.charAt(n.pos);if(y.test(i)&&n.raise(r,"Unterminated regular expression"),e)e=!1;else{if("["===i)t=!0;else if("]"===i&&t)t=!1;else if("/"===i&&!t)break;e="\\"===i}++n.pos}var a=this.input.slice(r,this.pos);++this.pos;var o=this.readWord1(),s=a,l="";if(o){var u=/^[gim]*$/;this.options.ecmaVersion>=6&&(u=/^[gimuy]*$/),u.test(o)||this.raise(r,"Invalid regular expression flag"),o.indexOf("u")>=0&&(Y?l="u":(s=(s=s.replace(/\\u\{([0-9a-fA-F]+)\}/g,function(e,t,i){return(t=Number("0x"+t))>1114111&&n.raise(r+i+3,"Code point out of bounds"),"x"})).replace(/\\u([a-fA-F0-9]{4})|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"x"),l=l.replace("u","")))}var c=null;return J||(tryCreateRegexp(s,l,r,this),c=tryCreateRegexp(a,o)),this.finishToken(g.regexp,{pattern:a,flags:o,value:c})},G.readInt=function(e,t){for(var n=this.pos,r=0,i=0,a=null==t?1/0:t;i=97?o-97+10:o>=65?o-65+10:o>=48&&o<=57?o-48:1/0)>=e)break;++this.pos,r=r*e+s}return this.pos===n||null!=t&&this.pos-n!==t?null:r},G.readRadixNumber=function(e){this.pos+=2;var t=this.readInt(e);return null==t&&this.raise(this.start+2,"Expected number in radix "+e),isIdentifierStart(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(g.num,t)},G.readNumber=function(e){var t=this.pos,n=!1,r=48===this.input.charCodeAt(this.pos);e||null!==this.readInt(10)||this.raise(t,"Invalid number"),r&&this.pos==t+1&&(r=!1);var i=this.input.charCodeAt(this.pos);46!==i||r||(++this.pos,this.readInt(10),n=!0,i=this.input.charCodeAt(this.pos)),69!==i&&101!==i||r||(43!==(i=this.input.charCodeAt(++this.pos))&&45!==i||++this.pos,null===this.readInt(10)&&this.raise(t,"Invalid number"),n=!0),isIdentifierStart(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var a,o=this.input.slice(t,this.pos);return n?a=parseFloat(o):r&&1!==o.length?this.strict?this.raise(t,"Invalid number"):a=/[89]/.test(o)?parseInt(o,10):parseInt(o,8):a=parseInt(o,10),this.finishToken(g.num,a)},G.readCodePoint=function(){var e;if(123===this.input.charCodeAt(this.pos)){this.options.ecmaVersion<6&&this.unexpected();var t=++this.pos;e=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,e>1114111&&this.invalidStringToken(t,"Code point out of bounds")}else e=this.readHexChar(4);return e};function codePointToString(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}G.readString=function(e){for(var t="",n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var r=this.input.charCodeAt(this.pos);if(r===e)break;92===r?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):(isNewLine(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(g.string,t)};var X={};G.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e!==X)throw e;this.readInvalidTemplateToken()}this.inTemplateElement=!1},G.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw X;this.raise(e,t)},G.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var n=this.input.charCodeAt(this.pos);if(96===n||36===n&&123===this.input.charCodeAt(this.pos+1))return this.pos!==this.start||this.type!==g.template&&this.type!==g.invalidTemplate?(e+=this.input.slice(t,this.pos),this.finishToken(g.template,e)):36===n?(this.pos+=2,this.finishToken(g.dollarBraceL)):(++this.pos,this.finishToken(g.backQuote));if(92===n)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(isNewLine(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:10===this.input.charCodeAt(this.pos)&&++this.pos;case 10:e+="\n";break;default:e+=String.fromCharCode(n)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},G.readInvalidTemplateToken=function(){for(;this.pos=48&&t<=55){var n=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],r=parseInt(n,8);return r>255&&(n=n.slice(0,-1),r=parseInt(n,8)),"0"!==n&&(this.strict||e)&&this.invalidStringToken(this.pos-2,"Octal literal in strict mode"),this.pos+=n.length-1,String.fromCharCode(r)}return String.fromCharCode(t)}},G.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return null===n&&this.invalidStringToken(t,"Bad character escape sequence"),n},G.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"},re=/^[\da-fA-F]+$/,ie=/^\d+$/,ae={};"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split("").forEach(function(e,t){ae[t]=e});function encodeInteger(e){var t="";e<0?e=-e<<1|1:e<<=1;do{var n=31&e;(e>>=5)>0&&(n|=32),t+=ae[n]}while(e>0);return t}function Chunk(e,t,n){this.start=e,this.end=t,this.original=n,this.intro="",this.outro="",this.content=n,this.storeName=!1,this.edited=!1,Object.defineProperties(this,{previous:{writable:!0,value:null},next:{writable:!0,value:null}})}Chunk.prototype={appendLeft:function appendLeft(e){this.outro+=e},appendRight:function appendRight(e){this.intro=this.intro+e},clone:function clone(){var e=new Chunk(this.start,this.end,this.original);return e.intro=this.intro,e.outro=this.outro,e.content=this.content,e.storeName=this.storeName,e.edited=this.edited,e},contains:function contains(e){return this.start=t.end?1:-1;t;){if(l=e,(s=t).start<=l&&l=r.length)return"\t";var i=r.reduce(function(e,t){var n=/^ +/.exec(t)[0].length;return Math.min(n,e)},1/0);return new Array(i+1).join(" ")}(e)}}),this.byStart[0]=n,this.byEnd[e.length]=n}MagicString$1.prototype={addSourcemapLocation:function addSourcemapLocation(e){this.sourcemapLocations[e]=!0},append:function append(e){if("string"!=typeof e)throw new TypeError("outro content must be a string");return this.outro+=e,this},appendLeft:function appendLeft(e,t){if("string"!=typeof t)throw new TypeError("inserted content must be a string");this._split(e);var n=this.byEnd[e];return n?n.appendLeft(t):this.intro+=t,this},appendRight:function appendRight(e,t){if("string"!=typeof t)throw new TypeError("inserted content must be a string");this._split(e);var n=this.byStart[e];return n?n.appendRight(t):this.outro+=t,this},clone:function clone(){for(var e=new MagicString$1(this.original,{filename:this.filename}),t=this.firstChunk,n=e.firstChunk=e.lastSearchedChunk=t.clone();t;){e.byStart[n.start]=n,e.byEnd[n.end]=n;var r=t.next,i=r&&r.clone();i&&(n.next=i,i.previous=n,n=i),t=r}return e.lastChunk=n,this.indentExclusionRanges&&(e.indentExclusionRanges=this.indentExclusionRanges.slice()),Object.keys(this.sourcemapLocations).forEach(function(t){e.sourcemapLocations[t]=!0}),e},generateMap:function generateMap(e){var t=this;e=e||{};var n=Object.keys(this.storedNames),r=new Mappings(e.hires),i=getLocator(this.original);this.intro&&r.advance(this.intro),this.firstChunk.eachNext(function(e){var a=i(e.start);e.intro.length&&r.advance(e.intro),e.edited?r.addEdit(0,e.content,e.original,a,e.storeName?n.indexOf(e.original):-1):r.addUneditedChunk(0,e,t.original,a,t.sourcemapLocations),e.outro.length&&r.advance(e.outro)});return new SourceMap({file:e.file?e.file.split(/[\/\\]/).pop():null,sources:[e.source?function getRelativePath(e,t){var n=e.split(/[\/\\]/),r=t.split(/[\/\\]/);for(n.pop();n[0]===r[0];)n.shift(),r.shift();if(n.length)for(var i=n.length;i--;)n[i]="..";return n.concat(r).join("/")}(e.file||"",e.source):null],sourcesContent:e.includeContent?[this.original]:[null],names:n,mappings:r.encode()})},getIndentString:function getIndentString(){return null===this.indentStr?"\t":this.indentStr},indent:function indent(e,t){var n=/^[^\r\n]/gm;if(function isObject(e){return"[object Object]"===se.call(e)}(e)&&(t=e,e=void 0),""===(e=void 0!==e?e:this.indentStr||"\t"))return this;var r={};if((t=t||{}).exclude){("number"==typeof t.exclude[0]?[t.exclude]:t.exclude).forEach(function(e){for(var t=e[0];t=e&&n<=t)throw new Error("Cannot move a selection inside itself");this._split(e),this._split(t),this._split(n);var r=this.byStart[e],i=this.byEnd[t],a=r.previous,o=i.next,s=this.byStart[n];if(!s&&i===this.lastChunk)return this;var l=s?s.previous:this.lastChunk;return a&&(a.next=o),o&&(o.previous=a),l&&(l.next=r),s&&(s.previous=i),r.previous||(this.firstChunk=i.next),i.next||(this.lastChunk=r.previous,this.lastChunk.next=null),r.previous=l,i.next=s||null,l||(this.firstChunk=r),s||(this.lastChunk=i),this},overwrite:function overwrite(e,t,n,r){if("string"!=typeof n)throw new TypeError("replacement content must be a string");for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length;if(t>this.original.length)throw new Error("end is out of bounds");if(e===t)throw new Error("Cannot overwrite a zero-length range – use appendLeft or prependRight instead");this._split(e),this._split(t),!0===r&&(le.storeName||(console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string"),le.storeName=!0),r={storeName:!0});var i=void 0!==r&&r.storeName,a=void 0!==r&&r.contentOnly;if(i){var o=this.original.slice(e,t);this.storedNames[o]=!0}var s=this.byStart[e],l=this.byEnd[t];if(s){if(t>s.end&&s.next!==this.byStart[s.end])throw new Error("Cannot overwrite across a split point");if(s.edit(n,i,a),s!==l){for(var u=s.next;u!==l;)u.edit("",!1),u=u.next;u.edit("",!1)}}else{var c=new Chunk(e,t,"").edit(n,i);l.next=c,c.previous=l}return this},prepend:function prepend(e){if("string"!=typeof e)throw new TypeError("outro content must be a string");return this.intro=e+this.intro,this},prependLeft:function prependLeft(e,t){if("string"!=typeof t)throw new TypeError("inserted content must be a string");this._split(e);var n=this.byEnd[e];return n?n.prependLeft(t):this.intro=t+this.intro,this},prependRight:function prependRight(e,t){if("string"!=typeof t)throw new TypeError("inserted content must be a string");this._split(e);var n=this.byStart[e];return n?n.prependRight(t):this.outro=t+this.outro,this},remove:function remove(e,t){for(;e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length;if(e===t)return this;if(e<0||t>this.original.length)throw new Error("Character is out of bounds");if(e>t)throw new Error("end must be greater than start");this._split(e),this._split(t);for(var n=this.byStart[e];n;)n.intro="",n.outro="",n.edit(""),n=t>n.end?this.byStart[n.end]:null;return this},slice:function slice(e,t){for(void 0===e&&(e=0),void 0===t&&(t=this.original.length);e<0;)e+=this.original.length;for(;t<0;)t+=this.original.length;for(var n="",r=this.firstChunk;r&&(r.start>e||r.end<=e);){if(r.start=t)return n;r=r.next}if(r&&r.edited&&r.start!==e)throw new Error("Cannot use replaced character "+e+" as slice start anchor.");for(var i=r;r;){!r.intro||i===r&&r.start!==e||(n+=r.intro);var a=r.start=t;if(a&&r.edited&&r.end!==t)throw new Error("Cannot use replaced character "+t+" as slice end anchor.");var o=i===r?e-r.start:0,s=a?r.content.length+t-r.end:r.content.length;if(n+=r.content.slice(o,s),!r.outro||a&&r.end!==t||(n+=r.outro),a)break;r=r.next}return n},snip:function snip(e,t){var n=this.clone();return n.remove(0,e),n.remove(t,n.original.length),n},_split:function _split(e){if(!this.byStart[e]&&!this.byEnd[e])for(var t=this.lastSearchedChunk,n=e>t.end;;){if(t.contains(e))return this._splitChunk(t,e);t=n?this.byStart[t.end]:this.byEnd[t.start]}},_splitChunk:function _splitChunk(e,t){if(e.edited&&e.content.length){var n=getLocator(this.original)(t);throw new Error("Cannot split a chunk that has already been edited ("+n.line+":"+n.column+' – "'+e.original+'")')}var r=e.split(t);return this.byEnd[t]=e,this.byStart[t]=r,this.byEnd[r.end]=r,e===this.lastChunk&&(this.lastChunk=r),this.lastSearchedChunk=e,!0},toString:function toString(){for(var e=this.intro,t=this.firstChunk;t;)e+=t.toString(),t=t.next;return e+this.outro},trimLines:function trimLines(){return this.trim("[\\r\\n]")},trim:function trim(e){return this.trimStart(e).trimEnd(e)},trimEnd:function trimEnd(e){var t=new RegExp((e||"\\s")+"+$");if(this.outro=this.outro.replace(t,""),this.outro.length)return this;var n=this.lastChunk;do{var r=n.end,i=n.trimEnd(t);if(n.end!==r&&(this.lastChunk===n&&(this.lastChunk=n.next),this.byEnd[n.end]=n,this.byStart[n.next.start]=n.next,this.byEnd[n.next.end]=n.next),i)return this;n=n.previous}while(n);return this},trimStart:function trimStart(e){var t=new RegExp("^"+(e||"\\s")+"+");if(this.intro=this.intro.replace(t,""),this.intro.length)return this;var n=this.firstChunk;do{var r=n.end,i=n.trimStart(t);if(n.end!==r&&(n===this.lastChunk&&(this.lastChunk=n.next),this.byEnd[n.end]=n,this.byStart[n.next.start]=n.next,this.byEnd[n.next.end]=n.next),i)return this;n=n.next}while(n);return this}};var ue={Program:["body"],Literal:[]};function toJSON(e){var t={};return Object.keys(e).forEach(n=>{"parent"!==n&&"program"!==n&&"keys"!==n&&"__wrapped"!==n&&(Array.isArray(e[n])?t[n]=e[n].map(toJSON):e[n]&&e[n].toJSON?t[n]=e[n].toJSON():t[n]=e[n])}),t}class ce{constructor(e,t){e.parent=t,e.program=t.program||t,e.depth=t.depth+1,e.keys=ue[e.type],e.indentation=void 0;for(var n=0,r=ue[e.type];nt&&t.initialise(e)):i&&"object"==typeof i&&i.initialise(e)}}toJSON(){return toJSON(this)}toString(){return this.program.magicString.original.slice(this.start,this.end)}transpile(e,t){for(var n=0,r=this.keys;nn&&n.transpile(e,t)):i&&"object"==typeof i&&i.transpile(e,t)}}}function isArguments(e){return"Identifier"===e.type&&"arguments"===e.name}function spread(e,t,n,r,i){let a=t.length,o=-1;for(;a--;){const n=t[a];n&&"SpreadElement"===n.type&&(isArguments(n.argument)&&e.overwrite(n.argument.start,n.argument.end,r),o=a)}if(-1===o)return!1;if(i){for(a=0;a`${function pad(e,t){let n=String(e);return n+repeat(" ",t-n.length)}(t+r+1,a)} : ${e.replace(/\t/g," ")}`).join("\n");return l+="\n"+repeat(" ",a+3+s)+repeat("^",n)}class pe extends Error{constructor(e,t){if(super(e),this.name="CompileError",!t)return;const n=t.program.magicString.original,r=function locate(e,t){var n,r=e.split("\n"),i=r.length,a=0;for(n=0;nt)return{line:n+1,column:t-a,char:n};a=o}throw new Error("Could not determine location of character")}(n,t.start);this.message=e+` (${r.line}:${r.column})`,this.stack=(new Error).stack.replace(new RegExp(`.+new ${this.name}.+\\n`,"m"),""),this.loc=r,this.snippet=getSnippet(n,r,t.end-t.start)}toString(){return`${this.name}: ${this.message}\n${this.snippet}`}}const he=/(?:For(?:In|Of)?|While)Statement/;function findIndex(e,t){for(let n=0;nfe[e]=!0);class de extends ce{findScope(e){return e||!this.createdScope?this.parent.findScope(e):this.body.scope}initialise(e){if(this.body.createScope(),this.createdScope=!0,this.reassigned=Object.create(null),this.aliases=Object.create(null),super.initialise(e),e.letConst){const e=Object.keys(this.body.scope.declarations);let t=e.length;for(;t--;){const n=e[t],r=this.body.scope.declarations[n];let i=r.instances.length;for(;i--;){const e=r.instances[i].findNearest(/Function/);if(e&&e.depth>this.depth){this.shouldRewriteAsFunction=!0;break}}if(this.shouldRewriteAsFunction)break}}}transpile(e,t){const n="ForOfStatement"!=this.type&&("BlockStatement"!==this.body.type||"BlockStatement"===this.body.type&&this.body.synthetic);if(this.shouldRewriteAsFunction){const t=this.getIndentation(),n=t+e.getIndentString(),r=this.args?` ${this.args.join(", ")} `:"",i=this.params?` ${this.params.join(", ")} `:"",a=this.findScope(!0),o=a.createIdentifier("loop"),s=`var ${o} = function (${i}) `+(this.body.synthetic?`{\n${t}${e.getIndentString()}`:""),l=(this.body.synthetic?`\n${t}}`:"")+`;\n\n${t}`;if(e.prependRight(this.body.start,s),e.appendLeft(this.body.end,l),e.move(this.start,this.body.start,this.body.end),this.canBreak||this.canReturn){const i=a.createIdentifier("returned");let s=`{\n${n}var ${i} = ${o}(${r});\n`;this.canBreak&&(s+=`\n${n}if ( ${i} === 'break' ) break;`),this.canReturn&&(s+=`\n${n}if ( ${i} ) return ${i}.v;`),s+=`\n${t}}`,e.prependRight(this.body.end,s)}else{const i=`${o}(${r});`;"DoWhileStatement"===this.type?e.overwrite(this.start,this.body.start,`do {\n${n}${i}\n${t}}`):e.prependRight(this.body.end,i)}}else n&&(e.appendLeft(this.body.start,"{ "),e.prependRight(this.body.end," }"));super.transpile(e,t)}}function extractNames(e){const t=[];return me[e.type](t,e),t}const me={Identifier(e,t){e.push(t)},ObjectPattern(e,t){for(var n=0,r=t.properties;n{e.prependRight(n.left.end,`${r}if ( ${s} === void 0 ) ${s}`),e.move(n.left.end,n.right.end,t),e.appendLeft(n.right.end,i)});o||destructure(e,t,n.left,r,i,a)},ArrayPattern:function destructureArrayPattern(e,t,n,r,i,a){let o=n.start;n.elements.forEach((n,s)=>{n&&("RestElement"===n.type?handleProperty(e,t,o,n.argument,`${r}.slice(${s})`,i,a):handleProperty(e,t,o,n,`${r}[${s}]`,i,a),o=n.end)}),e.remove(o,n.end)},ObjectPattern:destructureObjectPattern};function destructure(e,t,n,r,i,a){ge[n.type](e,t,n,r,i,a)}function destructureIdentifier(e,t,n,r,i,a){a.push((t,a,o)=>{e.prependRight(n.start,i?a:`${a}var `),e.appendLeft(n.end,` = ${r}${o}`),e.move(n.start,n.end,t)})}function destructureObjectPattern(e,t,n,r,i,a){let o=n.start;const s=[];n.properties.forEach(n=>{let l,u;if("Property"===n.type){const t=n.computed||"Identifier"!==n.key.type,i=t?e.slice(n.key.start,n.key.end):n.key.name;l=t?`${r}[${i}]`:`${r}.${i}`,u=n.value,s.push(t?i:'"'+i+'"')}else{if("RestElement"!==n.type)throw new pe(this,`Unexpected node of type ${n.type} in object pattern`);{u=n.argument,l=t.createIdentifier("rest");const i=t.createIdentifier("n");a.push((t,a,u)=>{e.overwrite(n.start,o=n.argument.start,`${a}var ${l} = {}; for (var ${i} in ${r}) if([${s.join(", ")}].indexOf(${i}) === -1) ${l}[${i}] = ${r}[${i}]${u}`),e.move(n.start,o,t)})}}handleProperty(e,t,o,u,l,i,a),o=n.end}),e.remove(o,n.end)}function handleProperty(e,t,n,r,i,a,o){switch(r.type){case"Identifier":e.remove(n,r.start),destructureIdentifier(e,0,r,i,a,o);break;case"AssignmentPattern":{let s;const l="Identifier"===r.left.type;if(l){s=r.left.name;const e=t.findDeclaration(s);e&&(s=e.name)}else s=t.createIdentifier(i);o.push((t,n,o)=>{a?(e.prependRight(r.right.start,`${s} = ${i} === undefined ? `),e.appendLeft(r.right.end,` : ${i}`)):(e.prependRight(r.right.start,`${n}var ${s} = ${i}; if ( ${s} === void 0 ) ${s} = `),e.appendLeft(r.right.end,o)),e.move(r.right.start,r.right.end,t)}),l?e.remove(n,r.right.start):(e.remove(n,r.left.start),e.remove(r.left.end,r.right.start),handleProperty(e,t,n,r.left,s,a,o));break}case"ObjectPattern":{e.remove(n,n=r.start);let s=i;r.properties.length>1&&(s=t.createIdentifier(i),o.push((t,a,o)=>{e.prependRight(r.start,`${a}var ${s} = `),e.overwrite(r.start,n=r.start+1,i),e.appendLeft(n,o),e.overwrite(r.start,n=r.start+1,`${a}var ${s} = ${i}${o}`),e.move(r.start,n,t)})),destructureObjectPattern(e,t,r,s,a,o);break}case"ArrayPattern":if(e.remove(n,n=r.start),r.elements.filter(Boolean).length>1){const s=t.createIdentifier(i);o.push((t,a,o)=>{e.prependRight(r.start,`${a}var ${s} = `),e.overwrite(r.start,n=r.start+1,i,{contentOnly:!0}),e.appendLeft(n,o),e.move(r.start,n,t)}),r.elements.forEach((r,i)=>{r&&("RestElement"===r.type?handleProperty(e,t,n,r.argument,`${s}.slice(${i})`,a,o):handleProperty(e,t,n,r,`${s}[${i}]`,a,o),n=r.end)})}else{const s=findIndex(r.elements,Boolean),l=r.elements[s];"RestElement"===l.type?handleProperty(e,t,n,l.argument,`${i}.slice(${s})`,a,o):handleProperty(e,t,n,l,`${i}[${s}]`,a,o),n=l.end}e.remove(n,r.end);break;default:throw new Error(`Unexpected node type in destructuring (${r.type})`)}}const ye=e=>(ve=e,/-/.test(ve)?`'${e}'`:e);var ve;const be=e=>e?"":"true";var _e="undefined"!=typeof window?window:void 0!==n?n:"undefined"!=typeof self?self:{};function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var xe=createCommonjsModule(function(e,t){(function(){var n={function:!0,object:!0},r=n[typeof window]&&window||this,i=n.object&&t,a=n.object&&e&&!e.nodeType&&e,o=i&&a&&"object"==typeof _e&&_e;!o||o.global!==o&&o.window!==o&&o.self!==o||(r=o);var s=Object.prototype.hasOwnProperty,l=String.fromCharCode,u=Math.floor;function fromCodePoint(){var e,t,n=[],r=-1,i=arguments.length;if(!i)return"";for(var a="";++r1114111||u(o)!=o)throw RangeError("Invalid code point: "+o);o<=65535?n.push(o):(e=55296+((o-=65536)>>10),t=o%1024+56320,n.push(e,t)),(r+1==i||n.length>16384)&&(a+=l.apply(null,n),n.length=0)}return a}var c={};function assertType(e,t){if(-1==t.indexOf("|")){if(e==t)return;throw Error("Invalid node type: "+e+"; expected type: "+t)}if(!(t=s.call(c,t)?c[t]:c[t]=RegExp("^(?:"+t+")$")).test(e))throw Error("Invalid node type: "+e+"; expected types: "+t)}function generate(e){var t=e.type;if(s.call(p,t))return p[t](e);throw Error("Invalid node type: "+t)}function generateClassAtom(e){return assertType(e.type,"anchor|characterClassEscape|characterClassRange|dot|value"),generate(e)}var p={alternative:function generateAlternative(e){assertType(e.type,"alternative");for(var t=e.body,n=-1,r=t.length,i="";++n=55296&&n<=56319&&(r=lookahead().charCodeAt(0))>=56320&&r<=57343)return createValue("symbol",1024*(n-55296)+r-56320+65536,++s-2,s)}return createValue("symbol",n,s-1,s)}function createQuantifier(e,t,n,r){return null==r&&(n=s-1,r=s),addRaw({type:"quantifier",min:e,max:t,greedy:!0,body:null,range:[n,r]})}function createCharacterClass(e,t,n,r){return addRaw({type:"characterClass",body:e,negative:t,range:[n,r]})}function createClassRange(e,t,n,r){return e.codePoint>t.codePoint&&bail("invalid range in character class",e.raw+"-"+t.raw,n,r),addRaw({type:"characterClassRange",min:e,max:t,range:[n,r]})}function flattenBody(e){return"alternative"===e.type?e.body:[e]}function incr(t){t=t||1;var n=e.substring(s,s+t);return s+=t||1,n}function skip(e){match(e)||bail("character",e)}function match(t){if(e.indexOf(t,s)===s)return incr(t.length)}function lookahead(){return e[s]}function current(t){return e.indexOf(t,s)===s}function next(t){return e[s+1]===t}function matchReg(t){var n=e.substring(s).match(t);return n&&(n.range=[],n.range[0]=s,incr(n[0].length),n.range[1]=s),n}function parseDisjunction(){var e=[],t=s;for(e.push(parseAlternative());match("|");)e.push(parseAlternative());return 1===e.length?e[0]:function createDisjunction(e,t,n){return addRaw({type:"disjunction",body:e,range:[t,n]})}(e,t,s)}function parseAlternative(){for(var e,t=[],n=s;e=parseTerm();)t.push(e);return 1===t.length?t[0]:function createAlternative(e,t,n){return addRaw({type:"alternative",body:e,range:[t,n]})}(t,n,s)}function parseTerm(){if(s>=e.length||current("|")||current(")"))return null;var t=function parseAnchor(){return match("^")?createAnchor("start",1):match("$")?createAnchor("end",1):match("\\b")?createAnchor("boundary",2):match("\\B")?createAnchor("not-boundary",2):parseGroup("(?=","lookahead","(?!","negativeLookahead")}();if(t)return t;var n=function parseAtom(){var e;return(e=matchReg(/^[^^$\\.*+?(){[|]/))?createCharacter(e):match(".")?function createDot(){return addRaw({type:"dot",range:[s-1,s]})}():match("\\")?((e=parseAtomEscape())||bail("atomEscape"),e):(e=function parseCharacterClass(){var e,t=s;return(e=matchReg(/^\[\^/))?(e=parseClassRanges(),skip("]"),createCharacterClass(e,!0,t,s)):match("[")?(e=parseClassRanges(),skip("]"),createCharacterClass(e,!1,t,s)):null}())?e:parseGroup("(?:","ignore","(","normal")}();n||bail("Expected atom");var r=function parseQuantifier(){var e,t,n,r,i=s;return match("*")?t=createQuantifier(0):match("+")?t=createQuantifier(1):match("?")?t=createQuantifier(0,1):(e=matchReg(/^\{([0-9]+)\}/))?(n=parseInt(e[1],10),t=createQuantifier(n,n,e.range[0],e.range[1])):(e=matchReg(/^\{([0-9]+),\}/))?(n=parseInt(e[1],10),t=createQuantifier(n,void 0,e.range[0],e.range[1])):(e=matchReg(/^\{([0-9]+),([0-9]+)\}/))&&(n=parseInt(e[1],10),r=parseInt(e[2],10),n>r&&bail("numbers out of order in {} quantifier","",i,s),t=createQuantifier(n,r,e.range[0],e.range[1])),t&&match("?")&&(t.greedy=!1,t.range[1]+=1),t}()||!1;return r?(r.body=flattenBody(n),updateRawStart(r,n.range[0]),r):n}function parseGroup(e,t,n,r){var o=null,l=s;if(match(e))o=t;else{if(!match(n))return!1;o=r}var u=parseDisjunction();u||bail("Expected disjunction"),skip(")");var c=function createGroup(e,t,n,r){return addRaw({type:"group",behavior:e,body:t,range:[n,r]})}(o,flattenBody(u),l,s);return"normal"==o&&a&&i++,c}function parseUnicodeSurrogatePairEscape(e){if(o){var t,n;if("unicodeEscape"==e.kind&&(t=e.codePoint)>=55296&&t<=56319&¤t("\\")&&next("u")){var r=s;s++;var i=parseClassEscape();"unicodeEscape"==i.kind&&(n=i.codePoint)>=56320&&n<=57343?(e.range[1]=i.range[1],e.codePoint=1024*(t-55296)+n-56320+65536,e.type="value",e.kind="unicodeCodePointEscape",addRaw(e)):s=r}}return e}function parseClassEscape(){return parseAtomEscape(!0)}function parseAtomEscape(e){var t,a=s;if(t=function parseDecimalEscape(){var e,t;if(e=matchReg(/^(?!0)\d+/)){t=e[0];var n=parseInt(e[0],10);return n<=i?function createReference(e){return addRaw({type:"reference",matchIndex:parseInt(e,10),range:[s-1-e.length,s]})}(e[0]):(r.push(n),incr(-e[0].length),(e=matchReg(/^[0-7]{1,3}/))?createEscaped("octal",parseInt(e[0],8),e[0],1):updateRawStart(e=createCharacter(matchReg(/^[89]/)),e.range[0]-1))}return(e=matchReg(/^[0-7]{1,3}/))?(t=e[0],/^0{1,3}$/.test(t)?createEscaped("null",0,"0",t.length+1):createEscaped("octal",parseInt(t,8),t,1)):!!(e=matchReg(/^[dDsSwW]/))&&function createCharacterClassEscape(e){return addRaw({type:"characterClassEscape",value:e,range:[s-2,s]})}(e[0])}())return t;if(e){if(match("b"))return createEscaped("singleEscape",8,"\\b");match("B")&&bail("\\B not possible inside of CharacterClass","",a)}return t=function parseCharacterEscape(){var e;if(e=matchReg(/^[fnrtv]/)){var t=0;switch(e[0]){case"t":t=9;break;case"n":t=10;break;case"v":t=11;break;case"f":t=12;break;case"r":t=13}return createEscaped("singleEscape",t,"\\"+e[0])}return(e=matchReg(/^c([a-zA-Z])/))?createEscaped("controlLetter",e[1].charCodeAt(0)%32,e[1],2):(e=matchReg(/^x([0-9a-fA-F]{2})/))?createEscaped("hexadecimalEscape",parseInt(e[1],16),e[1],2):(e=matchReg(/^u([0-9a-fA-F]{4})/))?parseUnicodeSurrogatePairEscape(createEscaped("unicodeEscape",parseInt(e[1],16),e[1],2)):o&&(e=matchReg(/^u\{([0-9a-fA-F]+)\}/))?createEscaped("unicodeCodePointEscape",parseInt(e[1],16),e[1],4):n.unicodePropertyEscape&&o&&(e=matchReg(/^([pP])\{([^\}]+)\}/))?addRaw({type:"unicodePropertyEscape",negative:"P"===e[1],value:e[2],range:[e.range[0]-1,e.range[1]],raw:e[0]}):function parseIdentityEscape(){var e;return function isIdentifierPart(e){var t=new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ̀-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ҃-҇Ҋ-ԯԱ-Ֆՙա-և֑-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-٩ٮ-ۓە-ۜ۟-۪ۨ-ۼۿܐ-݊ݍ-ޱ߀-ߵߺࠀ-࠭ࡀ-࡛ࢠ-ࢲࣤ-ॣ०-९ॱ-ঃঅ-ঌএঐও-নপ-রলশ-হ়-ৄেৈো-ৎৗড়ঢ়য়-ৣ০-ৱਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹ਼ਾ-ੂੇੈੋ-੍ੑਖ਼-ੜਫ਼੦-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હ઼-ૅે-ૉો-્ૐૠ-ૣ૦-૯ଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହ଼-ୄେୈୋ-୍ୖୗଡ଼ଢ଼ୟ-ୣ୦-୯ୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-்ௐௗ௦-௯ఀ-ఃఅ-ఌఎ-ఐఒ-నప-హఽ-ౄె-ైొ-్ౕౖౘౙౠ-ౣ౦-౯ಁ-ಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ಼-ೄೆ-ೈೊ-್ೕೖೞೠ-ೣ೦-೯ೱೲഁ-ഃഅ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൎൗൠ-ൣ൦-൯ൺ-ൿංඃඅ-ඖක-නඳ-රලව-ෆ්ා-ුූෘ-ෟ෦-෯ෲෳก-ฺเ-๎๐-๙ກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙ໜ-ໟༀ༘༙༠-༩༹༵༷༾-ཇཉ-ཬཱ-྄྆-ྗྙ-ྼ࿆က-၉ၐ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ፝-፟ᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜌᜎ-᜔ᜠ-᜴ᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-៓ៗៜ៝០-៩᠋-᠍᠐-᠙ᠠ-ᡷᢀ-ᢪᢰ-ᣵᤀ-ᤞᤠ-ᤫᤰ-᤻᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-ᨛᨠ-ᩞ᩠-᩿᩼-᪉᪐-᪙ᪧ᪰-᪽ᬀ-ᭋ᭐-᭙᭫-᭳ᮀ-᯳ᰀ-᰷᱀-᱉ᱍ-ᱽ᳐-᳔᳒-ᳶ᳸᳹ᴀ-᷵᷼-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ‌‍‿⁀⁔ⁱⁿₐ-ₜ⃐-⃥⃜⃡-⃰ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ⵿-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〯〱-〵〸-〼ぁ-ゖ゙゚ゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-꙯ꙴ-꙽ꙿ-ꚝꚟ-꛱ꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞭꞰꞱꟷ-ꠧꡀ-ꡳꢀ-꣄꣐-꣙꣠-ꣷꣻ꤀-꤭ꤰ-꥓ꥠ-ꥼꦀ-꧀ꧏ-꧙ꧠ-ꧾꨀ-ꨶꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺ-ꫂꫛ-ꫝꫠ-ꫯꫲ-꫶ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭟꭤꭥꯀ-ꯪ꯬꯭꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ︀-️︠-︭︳︴﹍-﹏ﹰ-ﹴﹶ-ﻼ0-9A-Z_a-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ]");return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||92===e||e>=128&&t.test(String.fromCharCode(e))}(lookahead())?match("‌")?createEscaped("identifier",8204,"‌"):match("‍")?createEscaped("identifier",8205,"‍"):null:createEscaped("identifier",(e=incr()).charCodeAt(0),e,1)}()}()}function parseClassRanges(){var e;return current("]")?[]:((e=function parseNonemptyClassRanges(){var e=parseClassAtom();return e||bail("classAtom"),current("]")?[e]:parseHelperClassRanges(e)}())||bail("nonEmptyClassRanges"),e)}function parseHelperClassRanges(e){var t,n,r;if(current("-")&&!next("]")){skip("-"),(r=parseClassAtom())||bail("classAtom"),n=s;var i=parseClassRanges();return i||bail("classRanges"),t=e.range[0],"empty"===i.type?[createClassRange(e,r,t,n)]:[createClassRange(e,r,t,n)].concat(i)}return(r=function parseNonemptyClassRangesNoDash(){var e=parseClassAtom();return e||bail("classAtom"),current("]")?e:parseHelperClassRanges(e)}())||bail("nonEmptyClassRangesNoDash"),[e].concat(r)}function parseClassAtom(){return match("-")?createCharacter("-"):function parseClassAtomNoDash(){var e;return(e=matchReg(/^[^\\\]-]/))?createCharacter(e[0]):match("\\")?((e=parseClassEscape())||bail("classEscape"),parseUnicodeSurrogatePairEscape(e)):void 0}()}function bail(t,n,r,i){r=null==r?s:r,i=null==i?r:i;var a=Math.max(0,r-10),o=Math.min(i+10,e.length),l=" "+e.substring(a,o),u=" "+new Array(r-a+1).join(" ")+"^";throw SyntaxError(t+" at position "+r+(n?": "+n:"")+"\n"+l+"\n"+u)}var r=[],i=0,a=!0,o=-1!==(t||"").indexOf("u"),s=0;""===(e=String(e))&&(e="(?:)");var l=parseDisjunction();l.range[1]!==e.length&&bail("Could not parse entire input - got stuck","",l.range[1]);for(var u=0;u=n&&tn)return e;if(t<=r&&n>=i)e.splice(a,2);else{if(t>=r&&n=r&&t<=i)e[a+1]=t;else if(n>=r&&n<=i)return e[a]=n+1,e;a+=2}}return e},_=function(e,t){var n,r,i=0,a=null,o=e.length;if(t<0||t>1114111)throw RangeError(s);for(;i=n&&tt)return e.splice(null!=a?a+2:0,0,t,t+1),e;if(t==r)return t+1==e[i+2]?(e.splice(i,4,n,e[i+3]),e):(e[i+1]=t+1,e);a=i,i+=2}return e.push(t,t+1),e},x=function(e,t){for(var n,r,i=0,a=e.slice(),o=t.length;i1114111||n<0||n>1114111)throw RangeError(s);for(var r,i,a=0,l=!1,u=e.length;an)return e;r>=t&&r<=n&&(i>t&&i-1<=n?(e.splice(a,2),a-=2):(e.splice(a-1,2),a-=2))}else{if(r==n+1)return e[a]=t,e;if(r>n)return e.splice(a,0,t,n+1),e;if(t>=r&&t=r&&t=i&&(e[a]=t,e[a+1]=n+1,l=!0)}a+=2}return l||e.push(t,n+1),e},k=function(e,t){var n=0,r=e.length,i=e[n],a=e[r-1];if(r>=2&&(ta))return!1;for(;n=i&&t=40&&e<=43||e>=45&&e<=47||63==e||e>=91&&e<=94||e>=123&&e<=125?"\\"+T(e):e>=32&&e<=126?T(e):e<=255?"\\x"+m(g(e),2):"\\u"+m(g(e),4)},A=function(e){return e<=65535?j(e):"\\u{"+e.toString(16).toUpperCase()+"}"},I=function(e){var t=e.length,n=e.charCodeAt(0);return n>=55296&&n<=56319&&t>1?1024*(n-55296)+e.charCodeAt(1)-56320+65536:n},L=function(e){var t,n,r="",i=0,a=e.length;if(C(e))return j(e[0]);for(;i=55296&&n<=56319&&(a.push(t,55296),r.push(55296,n+1)),n>=56320&&n<=57343&&(a.push(t,55296),r.push(55296,56320),i.push(56320,n+1)),n>57343&&(a.push(t,55296),r.push(55296,56320),i.push(56320,57344),n<=65535?a.push(57344,n+1):(a.push(57344,65536),o.push(65536,n+1)))):t>=55296&&t<=56319?(n>=55296&&n<=56319&&r.push(t,n+1),n>=56320&&n<=57343&&(r.push(t,56320),i.push(56320,n+1)),n>57343&&(r.push(t,56320),i.push(56320,57344),n<=65535?a.push(57344,n+1):(a.push(57344,65536),o.push(65536,n+1)))):t>=56320&&t<=57343?(n>=56320&&n<=57343&&i.push(t,n+1),n>57343&&(i.push(t,57344),n<=65535?a.push(57344,n+1):(a.push(57344,65536),o.push(65536,n+1)))):t>57343&&t<=65535?n<=65535?a.push(t,n+1):(a.push(t,65536),o.push(65536,n+1)):o.push(t,n+1),s+=2;return{loneHighSurrogates:r,loneLowSurrogates:i,bmp:a,astral:o}}(e),a=i.loneHighSurrogates,o=i.loneLowSurrogates,s=i.bmp,l=i.astral,u=!E(a),c=!E(o),h=M(l);return t&&(s=x(s,a),u=!1,s=x(s,o),c=!1),E(s)||r.push(L(s)),h.length&&r.push(function(e){var t=[];return p(e,function(e){var n=e[0],r=e[1];t.push(L(n)+L(r))}),t.join("|")}(h)),u&&r.push(L(a)+"(?![\\uDC00-\\uDFFF])"),c&&r.push("(?:[^\\uD800-\\uDBFF]|^)"+L(o)),r.join("|")},B=function(e){return arguments.length>1&&(e=y.call(arguments)),this instanceof B?(this.data=[],e?this.add(e):this):(new B).add(e)};B.version="1.3.3";var U=B.prototype;!function(e,t){var n;for(n in t)c.call(t,n)&&(e[n]=t[n])}(U,{add:function(e){var t=this;return null==e?t:e instanceof B?(t.data=x(t.data,e.data),t):(arguments.length>1&&(e=y.call(arguments)),f(e)?(p(e,function(e){t.add(e)}),t):(t.data=_(t.data,d(e)?e:I(e)),t))},remove:function(e){var t=this;return null==e?t:e instanceof B?(t.data=function(e,t){for(var n,r,i=0,a=e.slice(),o=t.length;i1&&(e=y.call(arguments)),f(e)?(p(e,function(e){t.remove(e)}),t):(t.data=v(t.data,d(e)?e:I(e)),t))},addRange:function(e,t){return this.data=w(this.data,d(e)?e:I(e),d(t)?t:I(t)),this},removeRange:function(e,t){var n=d(e)?e:I(e),r=d(t)?t:I(t);return this.data=b(this.data,n,r),this},intersection:function(e){var t=e instanceof B?S(e.data):e;return this.data=function(e,t){for(var n,r=0,i=t.length,a=[];rt?n?Te.UNICODE_IGNORE_CASE.get(e):Te.UNICODE.get(e):Te.REGULAR.get(e),l=(e,t)=>{try{return function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}()}catch(n){throw new Error(`Failed to recognize value \`${t}\` for property `+`\`${e}\`.`)}},u=(e,t)=>{const n=e.split("="),i=n[0];let a;if(1==n.length)a=(e=>{try{const t=Pe("General_Category",e);return l("General_Category",t)}catch(e){}const t=Se(e);return l(t)})(i);else{const e=Se(i),t=Pe(e,n[1]);a=l(e,t)}return t?r.clone().remove(a):a.clone()};ke.prototype.iuAddRange=function(e,t){do{const t=h(e);t&&this.add(t)}while(++e<=t);return this};const c=(e,t)=>{let r=n(t,g.useUnicodeFlag?"u":"");switch(r.type){case"characterClass":case"group":case"value":break;default:r=p(r,t)}Object.assign(e,r)},p=(e,t)=>({type:"group",behavior:"ignore",body:[e],raw:`(?:${t})`}),h=e=>Oe.get(e)||!1,f=(e,t)=>{switch(e.type){case"dot":c(e,(d=g.unicode,m=g.dotAll,m?d?r:i:d?a:o).toString(t));break;case"characterClass":e=((e,t)=>{let n=ke();for(var a=0,o=e.body;af(e,t));break;case"value":const n=e.codePoint,l=ke(n);if(g.ignoreCase&&g.unicode&&!g.useUnicodeFlag){const e=h(n);e&&l.add(e)}c(e,l.toString(t));break;case"anchor":case"empty":case"group":case"reference":break;default:throw new Error(`Unknown term type: ${e.type}`)}return e};var d,m;const g={ignoreCase:!1,unicode:!1,dotAll:!1,useUnicodeFlag:!1};e.exports=((e,r,i)=>{const a={unicodePropertyEscape:i&&i.unicodePropertyEscape};g.ignoreCase=r&&r.includes("i"),g.unicode=r&&r.includes("u");const o=i&&i.dotAllFlag;g.dotAll=o&&r&&r.includes("s"),g.useUnicodeFlag=i&&i.useUnicodeFlag;const s={hasUnicodeFlag:g.useUnicodeFlag,bmpOnly:!g.unicode},l=n(e,r,a);return f(l,s),t(l)})});var Ae={ArrayExpression:class extends ce{initialise(e){if(e.spreadRest&&this.elements.length){const e=this.findLexicalBoundary();let t=this.elements.length;for(;t--;){const n=this.elements[t];n&&"SpreadElement"===n.type&&isArguments(n.argument)&&(this.argumentsArrayAlias=e.getArgumentsArrayAlias())}}super.initialise(e)}transpile(e,t){if(t.spreadRest){if(this.elements.length){let t=this.elements[this.elements.length-1];t&&/\s*,/.test(e.original.slice(t.end,this.end))&&e.overwrite(t.end,this.end-1," ")}if(1===this.elements.length){const t=this.elements[0];t&&"SpreadElement"===t.type&&(isArguments(t.argument)?e.overwrite(this.start,this.end,`[].concat( ${this.argumentsArrayAlias} )`):(e.overwrite(this.start,t.argument.start,"[].concat( "),e.overwrite(t.end,this.end," )")))}else spread(e,this.elements,this.start,this.argumentsArrayAlias)&&e.overwrite(this.end-1,this.end,")")}super.transpile(e,t)}},ArrowFunctionExpression:class extends ce{initialise(e){this.body.createScope(),super.initialise(e)}transpile(e,t){const n=1===this.params.length&&this.start===this.params[0].start;if(t.arrow||this.needsArguments(t)){let r=this.body.start;for(;"="!==e.original[r];)r-=1;e.remove(r,this.body.start),super.transpile(e,t),n&&(e.prependRight(this.params[0].start,"("),e.appendLeft(this.params[0].end,")")),this.parent&&"ExpressionStatement"===this.parent.type?e.prependRight(this.start,"!function"):e.prependRight(this.start,"function ")}else super.transpile(e,t);t.trailingFunctionCommas&&this.params.length&&!n&&removeTrailingComma(e,this.params[this.params.length-1].end)}needsArguments(e){return e.spreadRest&&this.params.filter(e=>"RestElement"===e.type).length>0}},AssignmentExpression:class extends ce{initialise(e){if("Identifier"===this.left.type){const e=this.findScope(!1).findDeclaration(this.left.name);if(e&&"const"===e.kind)throw new pe(`${this.left.name} is read-only`,this.left);const t=e&&e.node.ancestor(3);t&&"ForStatement"===t.type&&t.body.contains(this)&&(t.reassigned[this.left.name]=!0)}super.initialise(e)}transpile(e,t){"**="===this.operator&&t.exponentiation?this.transpileExponentiation(e,t):/Pattern/.test(this.left.type)&&t.destructuring&&this.transpileDestructuring(e,t),super.transpile(e,t)}transpileDestructuring(e){const t=this.findScope(!0),n=t.createIdentifier("assign"),r=[n],i=this.start;let a="";function use(t){e.prependRight(t.start,a),e.move(t.start,t.end,i),a=""}function write(e){a+=e}write(`(${n} = `),use(this.right);function destructure(n,i,a){if("Identifier"===n.type||"MemberExpression"===n.type)write(", "),use(n),write(` = ${i}`);else if("AssignmentPattern"===n.type)if("Identifier"===n.left.type){e.remove(n.start,n.right.start);const t=n.left.name;let r=i;a||(write(`, ${t} = ${i}`),r=t),write(`, ${t} = ${r} === void 0 ? `),use(n.right),write(` : ${r}`)}else{e.remove(n.left.end,n.right.start);const o=t.createIdentifier("temp");let s=i;r.push(o),a||(write(`, ${o} = ${i}`),s=o),write(`, ${o} = ${s} === void 0 ? `),use(n.right),write(` : ${s}`),destructure(n.left,o,!0)}else if("ArrayPattern"===n.type){const o=n.elements;if(1===o.length)e.remove(n.start,o[0].start),destructure(o[0],`${i}[0]`,!1),e.remove(o[0].end,n.end);else{if(!a){const e=t.createIdentifier("array");r.push(e),write(`, ${e} = ${i}`),i=e}let s=n.start;o.forEach((t,n)=>{t&&(e.remove(s,t.start),s=t.end,"RestElement"===t.type?(e.remove(t.start,t.argument.start),destructure(t.argument,`${i}.slice(${n})`,!1)):destructure(t,`${i}[${n}]`,!1))}),e.remove(s,n.end)}}else{if("ObjectPattern"!==n.type)throw new Error(`Unexpected node type in destructuring assignment (${n.type})`);{const o=n.properties;if(1==o.length){const t=o[0],r=t.computed||"Identifier"!==t.key.type?`${i}[${e.slice(t.key.start,t.key.end)}]`:`${i}.${t.key.name}`;e.remove(n.start,t.value.start),destructure(t.value,r,!1),e.remove(t.end,n.end)}else{if(!a){const e=t.createIdentifier("obj");r.push(e),write(`, ${e} = ${i}`),i=e}let s=n.start;o.forEach(t=>{const n=t.computed||"Identifier"!==t.key.type?`${i}[${e.slice(t.key.start,t.key.end)}]`:`${i}.${t.key.name}`;e.remove(s,t.value.start),s=t.end,destructure(t.value,n,!1)}),e.remove(s,n.end)}}}}destructure(this.left,n,!0),e.remove(this.left.end,this.right.start),"ExpressionStatement"===this.unparenthesizedParent().type?e.prependRight(i,`${a})`):e.prependRight(i,`${a}, ${n})`);const o=this.findNearest(/(?:Statement|Declaration)$/);e.appendLeft(o.start,`var ${r.join(", ")};\n${o.getIndentation()}`)}transpileExponentiation(e){const t=this.findScope(!1),n=e=>{const n=t.findDeclaration(e);return n?n.name:e};let r=this.left.end;for(;"*"!==e.original[r];)r+=1;e.remove(r,r+2);let i;const a=this.left.unparenthesize();if("Identifier"===a.type)i=n(a.name);else if("MemberExpression"===a.type){let r,o,s=!1,l=!1;const u=this.findNearest(/(?:Statement|Declaration)$/),c=u.getIndentation();if("Identifier"===a.property.type?o=a.computed?n(a.property.name):a.property.name:(o=t.createIdentifier("property"),l=!0),"Identifier"===a.object.type?r=n(a.object.name):(r=t.createIdentifier("object"),s=!0),a.start===u.start)s&&l?(e.prependRight(u.start,`var ${r} = `),e.overwrite(a.object.end,a.property.start,`;\n${c}var ${o} = `),e.overwrite(a.property.end,a.end,`;\n${c}${r}[${o}]`)):s?(e.prependRight(u.start,`var ${r} = `),e.appendLeft(a.object.end,`;\n${c}`),e.appendLeft(a.object.end,r)):l&&(e.prependRight(a.property.start,`var ${o} = `),e.appendLeft(a.property.end,`;\n${c}`),e.move(a.property.start,a.property.end,this.start),e.appendLeft(a.object.end,`[${o}]`),e.remove(a.object.end,a.property.start),e.remove(a.property.end,a.end));else{let t=[];s&&t.push(r),l&&t.push(o),t.length&&e.prependRight(u.start,`var ${t.join(", ")};\n${c}`),s&&l?(e.prependRight(a.start,`( ${r} = `),e.overwrite(a.object.end,a.property.start,`, ${o} = `),e.overwrite(a.property.end,a.end,`, ${r}[${o}]`)):s?(e.prependRight(a.start,`( ${r} = `),e.appendLeft(a.object.end,`, ${r}`)):l&&(e.prependRight(a.property.start,`( ${o} = `),e.appendLeft(a.property.end,", "),e.move(a.property.start,a.property.end,a.start),e.overwrite(a.object.end,a.property.start,`[${o}]`),e.remove(a.property.end,a.end)),l&&e.appendLeft(this.end," )")}i=r+(a.computed||l?`[${o}]`:`.${o}`)}e.prependRight(this.right.start,`Math.pow( ${i}, `),e.appendLeft(this.right.end," )")}},BinaryExpression:class extends ce{transpile(e,t){"**"===this.operator&&t.exponentiation&&(e.prependRight(this.start,"Math.pow( "),e.overwrite(this.left.end,this.right.start,", "),e.appendLeft(this.end," )")),super.transpile(e,t)}},BreakStatement:class extends ce{initialise(){const e=this.findNearest(he),t=this.findNearest("SwitchCase");e&&(!t||e.depth>t.depth)&&(e.canBreak=!0,this.loop=e)}transpile(e){if(this.loop&&this.loop.shouldRewriteAsFunction){if(this.label)throw new pe("Labels are not currently supported in a loop with locally-scoped variables",this);e.overwrite(this.start,this.start+5,"return 'break'")}}},CallExpression:class extends ce{initialise(e){if(e.spreadRest&&this.arguments.length>1){const e=this.findLexicalBoundary();let t=this.arguments.length;for(;t--;){const n=this.arguments[t];"SpreadElement"===n.type&&isArguments(n.argument)&&(this.argumentsArrayAlias=e.getArgumentsArrayAlias())}}super.initialise(e)}transpile(e,t){if(t.spreadRest&&this.arguments.length){let t,n=!1;const r=this.arguments[0];if(1===this.arguments.length?"SpreadElement"===r.type&&(e.remove(r.start,r.argument.start),n=!0):n=spread(e,this.arguments,r.start,this.argumentsArrayAlias),n){let n=null;if("Super"===this.callee.type?n=this.callee:"MemberExpression"===this.callee.type&&"Super"===this.callee.object.type&&(n=this.callee.object),n||"MemberExpression"!==this.callee.type)t="void 0";else if("Identifier"===this.callee.object.type)t=this.callee.object.name;else{t=this.findScope(!0).createIdentifier("ref");const n=this.callee.object,r=n.findNearest(/Function/),i=r?r.body.body:n.findNearest(/^Program$/).body,a=i[i.length-1],o=a.getIndentation();e.prependRight(n.start,`(${t} = `),e.appendLeft(n.end,")"),e.appendLeft(a.end,`\n${o}var ${t};`)}e.appendLeft(this.callee.end,".apply"),n?(n.noCall=!0,this.arguments.length>1&&("SpreadElement"!==r.type&&e.prependRight(r.start,"[ "),e.appendLeft(this.arguments[this.arguments.length-1].end," )"))):1===this.arguments.length?e.prependRight(r.start,`${t}, `):("SpreadElement"===r.type?e.appendLeft(r.start,`${t}, `):e.appendLeft(r.start,`${t}, [ `),e.appendLeft(this.arguments[this.arguments.length-1].end," )"))}}t.trailingFunctionCommas&&this.arguments.length&&removeTrailingComma(e,this.arguments[this.arguments.length-1].end),super.transpile(e,t)}},ClassBody:class extends ce{transpile(e,t,n,r){if(t.classes){const t=this.parent.name,i=e.getIndentString(),a=this.getIndentation()+(n?i:""),o=a+i,s=findIndex(this.body,e=>"constructor"===e.kind),l=this.body[s];let u="",c="";if(this.body.length?(e.remove(this.start,this.body[0].start),e.remove(this.body[this.body.length-1].end,this.end)):e.remove(this.start,this.end),l){l.value.body.isConstructorBody=!0;const t=this.body[s-1],r=this.body[s+1];s>0&&(e.remove(t.end,l.start),e.move(l.start,r?r.start:this.end-1,this.body[0].start)),n||e.appendLeft(l.end,";")}let p=!1!==this.program.options.namedFunctionExpressions,h=p||this.parent.superClass||"ClassDeclaration"!==this.parent.type;if(this.parent.superClass){let e=`if ( ${r} ) ${t}.__proto__ = ${r};\n${a}${t}.prototype = Object.create( ${r} && ${r}.prototype );\n${a}${t}.prototype.constructor = ${t};`;u+=l?`\n\n${a}`+e:(e=`function ${t} () {`+(r?`\n${o}${r}.apply(this, arguments);\n${a}}`:"}")+(n?"":";")+(this.body.length?`\n\n${a}`:"")+e)+`\n\n${a}`}else if(!l){let e="function "+(h?t+" ":"")+"() {}";"ClassDeclaration"===this.parent.type&&(e+=";"),this.body.length&&(e+=`\n\n${a}`),u+=e}const f=this.findScope(!1);let d,m,g=[],y=[];if(this.body.forEach((n,r)=>{if("constructor"===n.kind){let r=h?" "+t:"";return void e.overwrite(n.key.start,n.key.end,`function${r}`)}if(n.static){const t=" "==e.original[n.start+6]?7:6;e.remove(n.start,n.start+t)}const i="method"!==n.kind;let o,l=n.key.name;(fe[l]||n.value.body.scope.references[l])&&(l=f.createIdentifier(l));let u=!1;if(n.computed||"Literal"!==n.key.type||(u=!0,n.computed=!0),i){if(n.computed)throw new Error("Computed accessor properties are not currently supported");e.remove(n.start,n.key.start),n.static?(~y.indexOf(n.key.name)||y.push(n.key.name),m||(m=f.createIdentifier("staticAccessors")),o=`${m}`):(~g.indexOf(n.key.name)||g.push(n.key.name),d||(d=f.createIdentifier("prototypeAccessors")),o=`${d}`)}else o=n.static?`${t}`:`${t}.prototype`;n.computed||(o+="."),(s>0&&r===s+1||0===r&&s===this.body.length-1)&&(o=`\n\n${a}${o}`);let c=n.key.end;if(n.computed)if(u)e.prependRight(n.key.start,"["),e.appendLeft(n.key.end,"]");else{for(;"]"!==e.original[c];)c+=1;c+=1}const v=n.computed||i||!p?"":`${l} `,b=(i?`.${n.kind}`:"")+" = function"+(n.value.generator?"* ":" ")+v;e.remove(c,n.value.start),e.prependRight(n.value.start,b),e.appendLeft(n.end,";"),n.value.generator&&e.remove(n.start,n.key.start),e.prependRight(n.start,o)}),g.length||y.length){let e=[],n=[];g.length&&(e.push(`var ${d} = { ${g.map(e=>`${e}: { configurable: true }`).join(",")} };`),n.push(`Object.defineProperties( ${t}.prototype, ${d} );`)),y.length&&(e.push(`var ${m} = { ${y.map(e=>`${e}: { configurable: true }`).join(",")} };`),n.push(`Object.defineProperties( ${t}, ${m} );`)),l&&(u+=`\n\n${a}`),u+=e.join(`\n${a}`),l||(u+=`\n\n${a}`),c+=`\n\n${a}`+n.join(`\n${a}`)}l?e.appendLeft(l.end,u):e.prependRight(this.start,u),e.appendLeft(this.end,c)}super.transpile(e,t)}},ClassDeclaration:class extends ce{initialise(e){this.id?(this.name=this.id.name,this.findScope(!0).addDeclaration(this.id,"class")):this.name=this.findScope(!0).createIdentifier("defaultExport"),super.initialise(e)}transpile(e,t){if(t.classes){this.superClass||function deindent(e,t){const n=e.start,r=e.end,i=t.getIndentString(),a=i.length,o=n-a;e.program.indentExclusions[o]||t.original.slice(o,n)!==i||t.remove(o,n);const s=new RegExp(i+"\\S","g"),l=t.original.slice(n,r);let u;for(;u=s.exec(l);){const r=n+u.index;e.program.indentExclusions[r]||t.remove(r,r+a)}}(this.body,e);const n=this.superClass&&(this.superClass.name||"superclass"),r=this.getIndentation(),i=r+e.getIndentString(),a="ExportDefaultDeclaration"===this.parent.type;a&&e.remove(this.parent.start,this.start);let o=this.start;this.id?(e.overwrite(o,this.id.start,"var "),o=this.id.end):e.prependLeft(o,`var ${this.name}`),this.superClass?this.superClass.end===this.body.start?(e.remove(o,this.superClass.start),e.appendLeft(o,` = (function (${n}) {\n${i}`)):(e.overwrite(o,this.superClass.start," = "),e.overwrite(this.superClass.end,this.body.start,`(function (${n}) {\n${i}`)):o===this.body.start?e.appendLeft(o," = "):e.overwrite(o,this.body.start," = "),this.body.transpile(e,t,!!this.superClass,n);const s=a?`\n\n${r}export default ${this.name};`:"";this.superClass?(e.appendLeft(this.end,`\n\n${i}return ${this.name};\n${r}}(`),e.move(this.superClass.start,this.superClass.end,this.end),e.prependRight(this.end,`));${s}`)):s&&e.prependRight(this.end,s)}else this.body.transpile(e,t,!1,null)}},ClassExpression:class extends ce{initialise(e){this.name=(this.id?this.id.name:"VariableDeclarator"===this.parent.type?this.parent.id.name:"AssignmentExpression"!==this.parent.type?null:"Identifier"===this.parent.left.type?this.parent.left.name:"MemberExpression"===this.parent.left.type?this.parent.left.property.name:null)||this.findScope(!0).createIdentifier("anonymous"),super.initialise(e)}transpile(e,t){if(t.classes){const n=this.superClass&&(this.superClass.name||"superclass"),r=this.getIndentation(),i=r+e.getIndentString();this.superClass?(e.remove(this.start,this.superClass.start),e.remove(this.superClass.end,this.body.start),e.appendLeft(this.start,`(function (${n}) {\n${i}`)):e.overwrite(this.start,this.body.start,`(function () {\n${i}`),this.body.transpile(e,t,!0,n);const a=`\n\n${i}return ${this.name};\n${r}}(`;this.superClass?(e.appendLeft(this.end,a),e.move(this.superClass.start,this.superClass.end,this.end),e.prependRight(this.end,"))")):e.appendLeft(this.end,`\n\n${i}return ${this.name};\n${r}}())`)}else this.body.transpile(e,t,!1)}},ContinueStatement:class extends ce{transpile(e){const t=this.findNearest(he);if(t.shouldRewriteAsFunction){if(this.label)throw new pe("Labels are not currently supported in a loop with locally-scoped variables",this);e.overwrite(this.start,this.start+8,"return")}}},DoWhileStatement:de,ExportNamedDeclaration:class extends ce{initialise(e){if(e.moduleExport)throw new pe("export is not supported",this);super.initialise(e)}},ExportDefaultDeclaration:class extends ce{initialise(e){if(e.moduleExport)throw new pe("export is not supported",this);super.initialise(e)}},ForStatement:class extends de{findScope(e){return e||!this.createdScope?this.parent.findScope(e):this.body.scope}transpile(e,t){const n=this.getIndentation()+e.getIndentString();if(this.shouldRewriteAsFunction){const t="VariableDeclaration"===this.init.type?[].concat.apply([],this.init.declarations.map(e=>extractNames(e.id))):[],r=this.aliases;this.args=t.map(e=>e in this.aliases?this.aliases[e].outer:e),this.params=t.map(e=>e in this.aliases?this.aliases[e].inner:e);const i=Object.keys(this.reassigned).map(e=>`${r[e].outer} = ${r[e].inner};`);if(i.length)if(this.body.synthetic)e.appendLeft(this.body.body[0].end,`; ${i.join(" ")}`);else{const t=this.body.body[this.body.body.length-1];e.appendLeft(t.end,`\n\n${n}${i.join(`\n${n}`)}`)}}super.transpile(e,t)}},ForInStatement:class extends de{findScope(e){return e||!this.createdScope?this.parent.findScope(e):this.body.scope}transpile(e,t){if(this.shouldRewriteAsFunction){const e="VariableDeclaration"===this.left.type?[].concat.apply([],this.left.declarations.map(e=>extractNames(e.id))):[];this.args=e.map(e=>e in this.aliases?this.aliases[e].outer:e),this.params=e.map(e=>e in this.aliases?this.aliases[e].inner:e)}super.transpile(e,t)}},ForOfStatement:class extends de{initialise(e){if(e.forOf&&!e.dangerousForOf)throw new pe("for...of statements are not supported. Use `transforms: { forOf: false }` to skip transformation and disable this error, or `transforms: { dangerousForOf: true }` if you know what you're doing",this);super.initialise(e)}transpile(e,t){if(super.transpile(e,t),!t.dangerousForOf)return;if(!this.body.body[0])return void("VariableDeclaration"===this.left.type&&"var"===this.left.kind?(e.remove(this.start,this.left.start),e.appendLeft(this.left.end,";"),e.remove(this.left.end,this.end)):e.remove(this.start,this.end));const n=this.findScope(!0),r=this.getIndentation(),i=r+e.getIndentString(),a=n.createIdentifier("i"),o=n.createIdentifier("list");this.body.synthetic&&(e.prependRight(this.left.start,`{\n${i}`),e.appendLeft(this.body.body[0].end,`\n${r}}`));const s=this.body.body[0].start;e.remove(this.left.end,this.right.start),e.move(this.left.start,this.left.end,s),e.prependRight(this.right.start,`var ${a} = 0, ${o} = `),e.appendLeft(this.right.end,`; ${a} < ${o}.length; ${a} += 1`);const l="VariableDeclaration"===this.left.type&&this.left.declarations[0];if(l&&"Identifier"!==l.id.type){let t=[];const r=n.createIdentifier("ref");destructure(e,n,l.id,r,!1,t);let u=`;\n${i}`;t.forEach((e,n)=>{n===t.length-1&&(u=`;\n\n${i}`),e(s,"",u)}),e.appendLeft(this.left.start+this.left.kind.length+1,r),e.appendLeft(this.left.end,` = ${o}[${a}];\n${i}`)}else e.appendLeft(this.left.end,` = ${o}[${a}];\n\n${i}`)}},FunctionDeclaration:class extends ce{initialise(e){if(this.generator&&e.generator)throw new pe("Generators are not supported",this);this.body.createScope(),this.id&&this.findScope(!0).addDeclaration(this.id,"function"),super.initialise(e)}transpile(e,t){super.transpile(e,t),t.trailingFunctionCommas&&this.params.length&&removeTrailingComma(e,this.params[this.params.length-1].end)}},FunctionExpression:class extends ce{initialise(e){if(this.generator&&e.generator)throw new pe("Generators are not supported",this);this.body.createScope(),this.id&&this.body.scope.addDeclaration(this.id,"function"),super.initialise(e);const t=this.parent;let n;if(e.conciseMethodProperty&&"Property"===t.type&&"init"===t.kind&&t.method&&"Identifier"===t.key.type?n=t.key.name:e.classes&&"MethodDefinition"===t.type&&"method"===t.kind&&"Identifier"===t.key.type?n=t.key.name:this.id&&"Identifier"===this.id.type&&(n=this.id.alias||this.id.name),n)for(var r=0,i=this.params;re.depth&&(this.alias=e.getArgumentsAlias()),n&&n.body.contains(this)&&n.depth>e.depth&&(this.alias=e.getArgumentsAlias())}this.findScope(!1).addReference(this)}}transpile(e){this.alias&&e.overwrite(this.start,this.end,this.alias,{storeName:!0,contentOnly:!0})}},IfStatement:class extends ce{initialise(e){super.initialise(e)}transpile(e,t){("BlockStatement"!==this.consequent.type||"BlockStatement"===this.consequent.type&&this.consequent.synthetic)&&(e.appendLeft(this.consequent.start,"{ "),e.prependRight(this.consequent.end," }")),this.alternate&&"IfStatement"!==this.alternate.type&&("BlockStatement"!==this.alternate.type||"BlockStatement"===this.alternate.type&&this.alternate.synthetic)&&(e.appendLeft(this.alternate.start,"{ "),e.prependRight(this.alternate.end," }")),super.transpile(e,t)}},ImportDeclaration:class extends ce{initialise(e){if(e.moduleImport)throw new pe("import is not supported",this);super.initialise(e)}},ImportDefaultSpecifier:class extends ce{initialise(e){this.findScope(!0).addDeclaration(this.local,"import"),super.initialise(e)}},ImportSpecifier:class extends ce{initialise(e){this.findScope(!0).addDeclaration(this.local,"import"),super.initialise(e)}},JSXAttribute:class extends ce{transpile(e,t){const n=this.name;var r=n.start,i=n.name;const a=this.value?this.value.start:this.name.end;e.overwrite(r,a,`${ye(i)}: ${be(this.value)}`),super.transpile(e,t)}},JSXClosingElement:class extends ce{transpile(e){let t=!0;const n=this.parent.children[this.parent.children.length-1];(n&&function containsNewLine(e){return"Literal"===e.type&&!/\S/.test(e.value)&&/\n/.test(e.value)}(n)||this.parent.openingElement.attributes.length)&&(t=!1),e.overwrite(this.start,this.end,t?" )":")")}},JSXElement:class extends ce{transpile(e,t){super.transpile(e,t);const n=this.children.filter(e=>"Literal"!==e.type||/\S/.test(e.raw)||!/\n/.test(e.raw));if(n.length){let t,a=this.openingElement.end;for(t=0;t0&&(n.start===i?e.prependRight(i,", "):e.overwrite(i,n.start,", ")),a&&"JSXSpreadAttribute"!==n.type){const r=this.attributes[t-1],i=this.attributes[t+1];r&&"JSXSpreadAttribute"!==r.type||e.prependRight(n.start,"{ "),i&&"JSXSpreadAttribute"!==i.type||e.appendLeft(n.end," }")}i=n.end}let o,s;if(a)if(1===r)s=n?"',":",";else{if(!this.program.options.objectAssign)throw new pe("Mixed JSX attributes ending in spread requires specified objectAssign option with 'Object.assign' or polyfill helper.",this);s=n?`', ${this.program.options.objectAssign}({},`:`, ${this.program.options.objectAssign}({},`,o=")"}else s=n?"', {":", {",o=" }";e.prependRight(this.name.end,s),o&&e.appendLeft(this.attributes[r-1].end,o)}else e.appendLeft(this.name.end,n?"', null":", null"),i=this.name.end;this.selfClosing?e.overwrite(i,this.end,this.attributes.length?")":" )"):e.remove(i,this.end)}},JSXSpreadAttribute:class extends ce{transpile(e,t){e.remove(this.start,this.argument.start),e.remove(this.argument.end,this.end),super.transpile(e,t)}},Literal:class extends ce{initialise(){"string"==typeof this.value&&this.program.indentExclusionElements.push(this)}transpile(e,t){if(t.numericLiteral){const t=this.raw.slice(0,2);"0b"!==t&&"0o"!==t||e.overwrite(this.start,this.end,String(this.value),{storeName:!0,contentOnly:!0})}if(this.regex){const i=this.regex;var n=i.pattern,r=i.flags;if(t.stickyRegExp&&/y/.test(r))throw new pe("Regular expression sticky flag is not supported",this);t.unicodeRegExp&&/u/.test(r)&&e.overwrite(this.start,this.end,`/${je(n,r)}/${r.replace("u","")}`,{contentOnly:!0})}}},MemberExpression:class extends ce{transpile(e,t){t.reservedProperties&&fe[this.property.name]&&(e.overwrite(this.object.end,this.property.start,"['"),e.appendLeft(this.property.end,"']")),super.transpile(e,t)}},NewExpression:class extends ce{initialise(e){if(e.spreadRest&&this.arguments.length){const e=this.findLexicalBoundary();let t=this.arguments.length;for(;t--;){const n=this.arguments[t];if("SpreadElement"===n.type&&isArguments(n.argument)){this.argumentsArrayAlias=e.getArgumentsArrayAlias();break}}}super.initialise(e)}transpile(e,t){if(t.spreadRest&&this.arguments.length){const t=this.arguments[0];spread(e,this.arguments,t.start,this.argumentsArrayAlias,!0)&&(e.prependRight(this.start+"new".length," (Function.prototype.bind.apply("),e.overwrite(this.callee.end,t.start,", [ null ].concat( "),e.appendLeft(this.end," ))"))}super.transpile(e,t)}},ObjectExpression:class extends ce{transpile(e,t){super.transpile(e,t);let n=this.start+1,r=0,i=0,a=0,o=null,s=null;for(let e=0;e0?this.properties[n-1].end:p;if("Property"===a.type&&(a.computed||d&&!i)){if(0===n&&(o=this.start+1),d=a,u){const t=(l?`;\n${r}${u}`:`, ${u}`)+(a.computed?"":".");oi&&e.remove(i,a.value.start),e.appendLeft(i," = ")),a.method&&t.conciseMethodProperty&&e.prependRight(a.value.start,"function ")}else"SpreadElement"===a.type?u&&n>0&&(d||(d=this.properties[n-1]),e.appendLeft(d.end,`, ${u} )`),d=null,u=null):(!g&&i&&(e.prependRight(a.start,"{"),e.appendLeft(a.end,"}")),m=!0);if(g&&("SpreadElement"===a.type||a.computed)){let t=m?this.properties[this.properties.length-1].end:this.end-1;","==e.original[t]&&++t;const n=e.slice(t,h);e.prependLeft(o,n),e.remove(t,h),g=!1}let s=a.end;if(nthis.nearestFunction.depth)&&(this.loop.canReturn=!0,this.shouldWrap=!0),this.argument&&this.argument.initialise(e)}transpile(e,t){const n=this.shouldWrap&&this.loop&&this.loop.shouldRewriteAsFunction;this.argument?(n&&e.prependRight(this.argument.start,"{ v: "),this.argument.transpile(e,t),n&&e.appendLeft(this.argument.end," }")):n&&e.appendLeft(this.start+6," {}")}},SpreadElement:class extends ce{transpile(e,t){"ObjectExpression"==this.parent.type&&(e.remove(this.start,this.argument.start),e.remove(this.argument.end,this.end)),super.transpile(e,t)}},Super:class extends ce{initialise(e){if(e.classes){if(this.method=this.findNearest("MethodDefinition"),!this.method)throw new pe(this,"use of super outside class method");const e=this.findNearest("ClassBody").parent;if(this.superClassName=e.superClass&&(e.superClass.name||"superclass"),!this.superClassName)throw new pe("super used in base class",this);if(this.isCalled="CallExpression"===this.parent.type&&this===this.parent.callee,"constructor"!==this.method.kind&&this.isCalled)throw new pe("super() not allowed outside class constructor",this);if(this.isMember="MemberExpression"===this.parent.type,!this.isCalled&&!this.isMember)throw new pe("Unexpected use of `super` (expected `super(...)` or `super.*`)",this)}if(e.arrow){const e=this.findLexicalBoundary(),t=this.findNearest("ArrowFunctionExpression"),n=this.findNearest(he);t&&t.depth>e.depth&&(this.thisAlias=e.getThisAlias()),n&&n.body.contains(this)&&n.depth>e.depth&&(this.thisAlias=e.getThisAlias())}}transpile(e,t){if(t.classes){const t=this.isCalled||this.method.static?this.superClassName:`${this.superClassName}.prototype`;e.overwrite(this.start,this.end,t,{storeName:!0,contentOnly:!0});const n=this.isCalled?this.parent:this.parent.parent;if(n&&"CallExpression"===n.type){this.noCall||e.appendLeft(n.callee.end,".call");const t=this.thisAlias||"this";n.arguments.length?e.appendLeft(n.arguments[0].start,`${t}, `):e.appendLeft(n.end-1,`${t}`)}}}},TaggedTemplateExpression:class extends ce{initialise(e){if(e.templateString&&!e.dangerousTaggedTemplateString)throw new pe("Tagged template strings are not supported. Use `transforms: { templateString: false }` to skip transformation and disable this error, or `transforms: { dangerousTaggedTemplateString: true }` if you know what you're doing",this);super.initialise(e)}transpile(e,t){if(t.templateString&&t.dangerousTaggedTemplateString){const t=this.quasi.expressions.concat(this.quasi.quasis).sort((e,t)=>e.start-t.start),n=this.quasi.quasis.map(e=>JSON.stringify(e.value.cooked));e.overwrite(this.tag.end,t[0].start,`([${n.join(", ")}]`);let r=t[0].start;t.forEach(t=>{"TemplateElement"===t.type?e.remove(r,t.end):e.overwrite(r,t.start,", "),r=t.end}),e.overwrite(r,this.end,")")}super.transpile(e,t)}},TemplateElement:class extends ce{initialise(){this.program.indentExclusionElements.push(this)}},TemplateLiteral:class extends ce{transpile(e,t){if(super.transpile(e,t),t.templateString&&"TaggedTemplateExpression"!==this.parent.type){let t=this.expressions.concat(this.quasis).sort((e,t)=>e.start-t.start||e.end-t.end).filter((e,t)=>"TemplateElement"!==e.type||!!e.value.raw||!t);if(t.length>=3){const e=t[0];var n=t[2];"TemplateElement"===e.type&&""===e.value.raw&&"TemplateElement"===n.type&&t.shift()}const r=!(1===this.quasis.length&&0===this.expressions.length||"TemplateLiteral"===this.parent.type||"AssignmentExpression"===this.parent.type||"AssignmentPattern"===this.parent.type||"VariableDeclarator"===this.parent.type||"BinaryExpression"===this.parent.type&&"+"===this.parent.operator);r&&e.appendRight(this.start,"(");let i=this.start;t.forEach((t,n)=>{let a=0===n?r?"(":"":" + ";if("TemplateElement"===t.type)e.overwrite(i,t.end,a+JSON.stringify(t.value.cooked));else{const n="Identifier"!==t.type;n&&(a+="("),e.remove(i,t.start),a&&e.prependRight(t.start,a),n&&e.appendLeft(t.end,")")}i=t.end}),r&&e.appendLeft(i,")"),e.remove(i,this.end)}}},ThisExpression:class extends ce{initialise(e){if(e.arrow){const e=this.findLexicalBoundary(),t=this.findNearest("ArrowFunctionExpression"),n=this.findNearest(he);(t&&t.depth>e.depth||n&&n.body.contains(this)&&n.depth>e.depth||n&&n.right&&n.right.contains(this))&&(this.alias=e.getThisAlias())}}transpile(e){this.alias&&e.overwrite(this.start,this.end,this.alias,{storeName:!0,contentOnly:!0})}},UpdateExpression:class extends ce{initialise(e){if("Identifier"===this.argument.type){const e=this.findScope(!1).findDeclaration(this.argument.name);if(e&&"const"===e.kind)throw new pe(`${this.argument.name} is read-only`,this);const t=e&&e.node.ancestor(3);t&&"ForStatement"===t.type&&t.body.contains(this)&&(t.reassigned[this.argument.name]=!0)}super.initialise(e)}},VariableDeclaration:class extends ce{initialise(e){this.scope=this.findScope("var"===this.kind),this.declarations.forEach(t=>t.initialise(e))}transpile(e,t){const n=this.getIndentation();let r=this.kind;if(t.letConst&&"var"!==r&&(r="var",e.overwrite(this.start,this.start+this.kind.length,r,{storeName:!0})),t.destructuring&&"ForOfStatement"!==this.parent.type){let r,i=this.start;this.declarations.forEach((a,o)=>{if(a.transpile(e,t),"Identifier"===a.id.type)o>0&&"Identifier"!==this.declarations[o-1].id.type&&e.overwrite(i,a.id.start,"var ");else{const t=he.test(this.parent.type);0===o?e.remove(i,a.id.start):e.overwrite(i,a.id.start,`;\n${n}`);const r="Identifier"===a.init.type&&!a.init.rewritten,s=r?a.init.name:a.findScope(!0).createIdentifier("ref");i=a.start;let l=[];r?e.remove(a.id.end,a.end):l.push((t,n,r)=>{e.prependRight(a.id.end,`var ${s}`),e.appendLeft(a.init.end,`${r}`),e.move(a.id.end,a.end,t)}),destructure(e,a.findScope(!1),a.id,s,t,l);let u=t?"var ":"",c=t?", ":`;\n${n}`;l.forEach((e,n)=>{o===this.declarations.length-1&&n===l.length-1&&(c=t?"":";"),e(a.start,0===n?u:"",c)})}i=a.end,r="Identifier"!==a.id.type}),r&&this.end>i&&e.overwrite(i,this.end,"",{contentOnly:!0})}else this.declarations.forEach(n=>{n.transpile(e,t)})}},VariableDeclarator:class extends ce{initialise(e){let t=this.parent.kind;"let"===t&&"ForStatement"===this.parent.parent.type&&(t="for.let"),this.parent.scope.addDeclaration(this.id,t),super.initialise(e)}transpile(e,t){if(!this.init&&t.letConst&&"var"!==this.parent.kind){let t=this.findNearest(/Function|^For(In|Of)?Statement|^(?:Do)?WhileStatement/);!t||/Function/.test(t.type)||this.isLeftDeclaratorOfLoop()||e.appendLeft(this.id.end," = (void 0)")}this.id&&this.id.transpile(e,t),this.init&&this.init.transpile(e,t)}isLeftDeclaratorOfLoop(){return this.parent&&"VariableDeclaration"===this.parent.type&&this.parent.parent&&("ForInStatement"===this.parent.parent.type||"ForOfStatement"===this.parent.parent.type)&&this.parent.parent.left&&this.parent.parent.left.declarations[0]===this}},WhileStatement:de};const Ie={IfStatement:"consequent",ForStatement:"body",ForInStatement:"body",ForOfStatement:"body",WhileStatement:"body",DoWhileStatement:"body",ArrowFunctionExpression:"body"};function wrap(e,t){if(!e)return;if("length"in e){let n=e.length;for(;n--;)wrap(e[n],t);return}if(e.__wrapped)return;e.__wrapped=!0,ue[e.type]||(ue[e.type]=Object.keys(e).filter(t=>"object"==typeof e[t]));const n=Ie[e.type];if(n&&"BlockStatement"!==e[n].type){const t=e[n];e[n]={start:t.start,end:t.end,type:"BlockStatement",body:[t],synthetic:!0}}new ce(e,t);const r=("BlockStatement"===e.type?Le:Ae[e.type])||ce;e.__proto__=r.prototype}function Scope(e){e=e||{},this.parent=e.parent,this.isBlockScope=!!e.block;let t=this;for(;t.isBlockScope;)t=t.parent;this.functionScope=t,this.identifiers=[],this.declarations=Object.create(null),this.references=Object.create(null),this.blockScopedDeclarations=this.isBlockScope?null:Object.create(null),this.aliases=this.isBlockScope?null:Object.create(null)}Scope.prototype={addDeclaration(e,t){for(var n=0,r=extractNames(e);n{this.scope.addDeclaration(e,"param")})}initialise(e){this.thisAlias=null,this.argumentsAlias=null,this.defaultParameters=[],this.createdDeclarations=[],this.scope||this.createScope(),this.body.forEach(t=>t.initialise(e)),this.scope.consolidate()}findLexicalBoundary(){return"Program"===this.type?this:/^Function/.test(this.parent.type)?this:this.parent.findLexicalBoundary()}findScope(e){return e&&!this.isFunctionBlock?this.parent.findScope(e):this.scope}getArgumentsAlias(){return this.argumentsAlias||(this.argumentsAlias=this.scope.createIdentifier("arguments")),this.argumentsAlias}getArgumentsArrayAlias(){return this.argumentsArrayAlias||(this.argumentsArrayAlias=this.scope.createIdentifier("argsArray")),this.argumentsArrayAlias}getThisAlias(){return this.thisAlias||(this.thisAlias=this.scope.createIdentifier("this")),this.thisAlias}getIndentation(){if(void 0===this.indentation){const e=this.program.magicString.original,t=this.synthetic||!this.body.length;let n=t?this.start:this.body[0].start;for(;n&&"\n"!==e[n];)n-=1;for(this.indentation="";;){const t=e[n+=1];if(" "!==t&&"\t"!==t)break;this.indentation+=t}const r=this.program.magicString.getIndentString();let i=this.parent;for(;i;)"constructor"!==i.kind||i.parent.parent.superClass||(this.indentation=this.indentation.replace(r,"")),i=i.parent;t&&(this.indentation+=r)}return this.indentation}transpile(e,t){const n=this.getIndentation();let r=[];if(this.argumentsAlias&&r.push((t,n,r)=>{const i=`${n}var ${this.argumentsAlias} = arguments${r}`;e.appendLeft(t,i)}),this.thisAlias&&r.push((t,n,r)=>{const i=`${n}var ${this.thisAlias} = this${r}`;e.appendLeft(t,i)}),this.argumentsArrayAlias&&r.push((t,r,i)=>{const a=this.scope.createIdentifier("i"),o=`${r}var ${a} = arguments.length, ${this.argumentsArrayAlias} = Array(${a});\n${n}while ( ${a}-- ) ${this.argumentsArrayAlias}[${a}] = arguments[${a}]${i}`;e.appendLeft(t,o)}),/Function/.test(this.parent.type)&&this.transpileParameters(e,t,n,r),t.letConst&&this.isFunctionBlock&&this.transpileBlockScopedIdentifiers(e),super.transpile(e,t),this.createdDeclarations.length&&r.push((t,n,r)=>{const i=`${n}var ${this.createdDeclarations.join(", ")}${r}`;e.appendLeft(t,i)}),this.synthetic)if("ArrowFunctionExpression"===this.parent.type){const i=this.body[0];r.length?(e.appendLeft(this.start,"{").prependRight(this.end,`${this.parent.getIndentation()}}`),e.prependRight(i.start,`\n${n}return `),e.appendLeft(i.end,";\n")):t.arrow&&(e.prependRight(i.start,"{ return "),e.appendLeft(i.end,"; }"))}else r.length&&e.prependRight(this.start,"{").appendLeft(this.end,"}");let i;i=function isUseStrict(e){return!!e&&"ExpressionStatement"===e.type&&"Literal"===e.expression.type&&"use strict"===e.expression.value}(this.body[0])?this.body[0].end:this.synthetic||"Root"===this.parent.type?this.start:this.start+1;let a=`\n${n}`,o=";";r.forEach((e,t)=>{t===r.length-1&&(o=";\n"),e(i,a,o)})}declareIdentifier(e){const t=this.scope.createIdentifier(e);return this.createdDeclarations.push(t),t}transpileParameters(e,t,n,r){const i=this.parent.params;i.forEach(a=>{if("AssignmentPattern"===a.type&&"Identifier"===a.left.type)t.defaultParameter&&r.push((t,n,r)=>{const i=`${n}if ( ${a.left.name} === void 0 ) ${a.left.name}`;e.prependRight(a.left.end,i).move(a.left.end,a.right.end,t).appendLeft(a.right.end,r)});else if("RestElement"===a.type)t.spreadRest&&r.push((t,r,o)=>{const s=i[i.length-2];if(s)e.remove(s?s.end:a.start,a.end);else{let t=a.start,n=a.end;for(;/\s/.test(e.original[t-1]);)t-=1;for(;/\s/.test(e.original[n]);)n+=1;e.remove(t,n)}const l=a.argument.name,u=this.scope.createIdentifier("len"),c=i.length-1;c?e.prependRight(t,`${r}var ${l} = [], ${u} = arguments.length - ${c};\n${n}while ( ${u}-- > 0 ) ${l}[ ${u} ] = arguments[ ${u} + ${c} ]${o}`):e.prependRight(t,`${r}var ${l} = [], ${u} = arguments.length;\n${n}while ( ${u}-- ) ${l}[ ${u} ] = arguments[ ${u} ]${o}`)});else if("Identifier"!==a.type&&t.parameterDestructuring){const t=this.scope.createIdentifier("ref");destructure(e,this.scope,a,t,!1,r),e.prependRight(a.start,t)}})}transpileBlockScopedIdentifiers(e){Object.keys(this.scope.blockScopedDeclarations).forEach(t=>{for(var n=0,r=this.scope.blockScopedDeclarations[t];nnull,findScope:()=>null};const Ne={chrome:{48:1333689725,49:1342078975,50:1610514431,51:1610514431,52:2147385343},firefox:{43:1207307741,44:1207307741,45:1207307741,46:1476267485,47:1476296671,48:1476296671},safari:{8:1073741824,9:1328940894},ie:{8:0,9:1073741824,10:1073741824,11:1073770592},edge:{12:1591620701,13:1608399967},node:{"0.10":1075052608,.12:1091830852,4:1327398527,5:1327398527,6:1610514431}},Me=["arrow","classes","collections","computedProperty","conciseMethodProperty","constLoop","constRedef","defaultParameter","destructuring","extendNatives","forOf","generator","letConst","letLoop","letLoopScope","moduleExport","moduleImport","numericLiteral","objectProto","objectSuper","oldOctalLiteral","parameterDestructuring","spreadRest","stickyRegExp","symbol","templateString","unicodeEscape","unicodeIdentifier","unicodeRegExp","exponentiation","reservedProperties","trailingFunctionCommas"];var De=[function(e){if("5"!==e.version.substr(0,1))throw new Error("Unsupported acorn version "+e.version+", please use acorn 5");var t=e.tokTypes,n=e.Parser.prototype;function parseObj(e,n){let r=this.startNode(),i=!0,a={};for(r.properties=[],this.next();!this.eat(t.braceR);){if(i)i=!1;else if(this.expect(t.comma),this.afterTrailingComma(t.braceR))break;let o,s,l,u,c=this.startNode();if(this.options.ecmaVersion>=6){if(this.type===t.ellipsis){e?(this.next(),c.argument=this.parseIdent(),this.finishNode(c,"RestElement")):c=this.parseSpread(n),r.properties.push(c),this.type===t.comma&&(e?this.raise(this.start,"Comma is not permitted after the rest element"):n&&n.trailingComma<0&&(n.trailingComma=this.start));continue}c.method=!1,c.shorthand=!1,(e||n)&&(l=this.start,u=this.startLoc),e||(o=this.eat(t.star))}this.parsePropertyName(c),!e&&this.options.ecmaVersion>=8&&!o&&this.isAsyncProp(c)?(s=!0,this.parsePropertyName(c,n)):s=!1,this.parsePropertyValue(c,e,o,s,l,u,n),e||this.checkPropClash(c,a),r.properties.push(this.finishNode(c,"Property"))}return this.finishNode(r,e?"ObjectPattern":"ObjectExpression")}const r=e=>(function(t,n,r){if("ObjectPattern"!=t.type)return"Property"===t.type?this.checkLVal(t.value,n,r):e.apply(this,arguments);for(let e of t.properties)this.checkLVal(e,n,r)});return e.plugins.objectSpread=function objectSpreadPlugin(e){n.parseObj=parseObj,e.extend("checkLVal",r),e.extend("toAssignable",e=>(function(t,n){if(this.options.ecmaVersion>=6&&t){if("ObjectExpression"==t.type){t.type="ObjectPattern";for(let e of t.properties)this.toAssignable(e,n);return t}if("Property"===t.type)return"init"!==t.kind&&this.raise(t.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(t.value,n);if("SpreadElement"===t.type)return t.type="RestElement",this.toAssignable(t.argument,n)}return e.apply(this,arguments)})),e.extend("checkPatternExport",e=>(function(t,n){if("ObjectPattern"!=n.type)return"Property"===n.type?this.checkPatternExport(t,n.value):"RestElement"===n.type?this.checkPatternExport(t,n.argument):void e.apply(this,arguments);for(let e of n.properties)this.checkPatternExport(t,e)}))},e},function(e){var t=e.tokTypes,n=e.tokContexts;n.j_oTag=new e.TokContext("...",!0,!0),t.jsxName=new e.TokenType("jsxName"),t.jsxText=new e.TokenType("jsxText",{beforeExpr:!0}),t.jsxTagStart=new e.TokenType("jsxTagStart"),t.jsxTagEnd=new e.TokenType("jsxTagEnd"),t.jsxTagStart.updateContext=function(){this.context.push(n.j_expr),this.context.push(n.j_oTag),this.exprAllowed=!1},t.jsxTagEnd.updateContext=function(e){var r=this.context.pop();r===n.j_oTag&&e===t.slash||r===n.j_cTag?(this.context.pop(),this.exprAllowed=this.curContext()===n.j_expr):this.exprAllowed=!0};var r=e.Parser.prototype;r.jsx_readToken=function(){for(var n="",r=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated JSX contents");var i=this.input.charCodeAt(this.pos);switch(i){case 60:case 123:return this.pos===this.start?60===i&&this.exprAllowed?(++this.pos,this.finishToken(t.jsxTagStart)):this.getTokenFromCode(i):(n+=this.input.slice(r,this.pos),this.finishToken(t.jsxText,n));case 38:n+=this.input.slice(r,this.pos),n+=this.jsx_readEntity(),r=this.pos;break;default:e.isNewLine(i)?(n+=this.input.slice(r,this.pos),n+=this.jsx_readNewLine(!0),r=this.pos):++this.pos}}},r.jsx_readNewLine=function(e){var t,n=this.input.charCodeAt(this.pos);return++this.pos,13===n&&10===this.input.charCodeAt(this.pos)?(++this.pos,t=e?"\n":"\r\n"):t=String.fromCharCode(n),this.options.locations&&(++this.curLine,this.lineStart=this.pos),t},r.jsx_readString=function(n){for(var r="",i=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var a=this.input.charCodeAt(this.pos);if(a===n)break;38===a?(r+=this.input.slice(i,this.pos),r+=this.jsx_readEntity(),i=this.pos):e.isNewLine(a)?(r+=this.input.slice(i,this.pos),r+=this.jsx_readNewLine(!1),i=this.pos):++this.pos}return r+=this.input.slice(i,this.pos++),this.finishToken(t.string,r)},r.jsx_readEntity=function(){var e,t="",n=0,r=this.input[this.pos];"&"!==r&&this.raise(this.pos,"Entity must start with an ampersand");for(var i=++this.pos;this.pos")}return r.openingElement=a,r.closingElement=o,r.children=i,this.type===t.relational&&"<"===this.value&&this.raise(this.start,"Adjacent JSX elements must be wrapped in an enclosing tag"),this.finishNode(r,"JSXElement")},r.jsx_parseElement=function(){var e=this.start,t=this.startLoc;return this.next(),this.jsx_parseElementAt(e,t)},e.plugins.jsx=function(r,i){i&&("object"!=typeof i&&(i={}),r.options.plugins.jsx={allowNamespaces:!1!==i.allowNamespaces,allowNamespacedObjects:!!i.allowNamespacedObjects},r.extend("parseExprAtom",function(e){return function(n){return this.type===t.jsxText?this.parseLiteral(this.value):this.type===t.jsxTagStart?this.jsx_parseElement():e.call(this,n)}}),r.extend("readToken",function(r){return function(i){var a=this.curContext();if(a===n.j_expr)return this.jsx_readToken();if(a===n.j_oTag||a===n.j_cTag){if(e.isIdentifierStart(i))return this.jsx_readWord();if(62==i)return++this.pos,this.finishToken(t.jsxTagEnd);if((34===i||39===i)&&a==n.j_oTag)return this.jsx_readString(i)}return 60===i&&this.exprAllowed?(++this.pos,this.finishToken(t.jsxTagStart)):r.call(this,i)}}),r.extend("updateContext",function(e){return function(r){if(this.type==t.braceL){var i=this.curContext();i==n.j_oTag?this.context.push(n.b_expr):i==n.j_expr?this.context.push(n.b_tmpl):e.call(this,r),this.exprAllowed=!0}else{if(this.type!==t.slash||r!==t.jsxTagStart)return e.call(this,r);this.context.length-=2,this.context.push(n.j_cTag),this.exprAllowed=!1}}}))},e}].reduce((e,t)=>t(e),te).parse;const Be=["dangerousTaggedTemplateString","dangerousForOf"];function target(e){let t=Object.keys(e).length?4294967295:1073741824;Object.keys(e).forEach(n=>{const r=Ne[n];if(!r)throw new Error(`Unknown environment '${n}'. Please raise an issue at https://github.com/Rich-Harris/buble/issues`);const i=e[n];if(!(i in r))throw new Error(`Support data exists for the following versions of ${n}: ${Object.keys(r).join(", ")}. Please raise an issue at https://github.com/Rich-Harris/buble/issues`);const a=r[i];t&=a});let n=Object.create(null);return Me.forEach((e,r)=>{n[e]=!(t&1<{n[e]=!1}),n}t.target=target,t.transform=function transform(e,t){void 0===t&&(t={});let n,r=null;try{n=De(e,{ecmaVersion:8,preserveParens:!0,sourceType:"module",onComment:(e,t)=>{if(!r){let e=/@jsx\s+([^\s]+)/.exec(t);e&&(r=e[1])}},plugins:{jsx:!0,objectSpread:!0}}),t.jsx=r||t.jsx}catch(t){throw t.snippet=getSnippet(e,t.loc),t.toString=(()=>`${t.name}: ${t.message}\n${t.snippet}`),t}let i=target(t.target||{});return Object.keys(t.transforms||{}).forEach(e=>{if("modules"===e)return"moduleImport"in t.transforms||(i.moduleImport=t.transforms.modules),void("moduleExport"in t.transforms||(i.moduleExport=t.transforms.modules));if(!(e in i))throw new Error(`Unknown transform '${e}'`);i[e]=t.transforms[e]}),new Program(e,n,i,t).export(t)},t.VERSION="0.18.0",Object.defineProperty(t,"__esModule",{value:!0})})(t)}).call(t,n(81).Buffer,n(7))},function(e,t,n){"use strict";var r=n(339);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(2);function PlaygroundErrorRenderer(e){var t=e.classes,n=e.message;return i.a.createElement("pre",{className:t.root},n)}PlaygroundErrorRenderer.propTypes={classes:o.a.object.isRequired,message:o.a.string.isRequired},t.a=Object(s.a)(function styles(e){var t=e.fontFamily,n=e.fontSize,r=e.color;return{root:{margin:0,lineHeight:1.2,fontSize:n.small,fontFamily:t.monospace,color:r.error,whiteSpace:"pre"}}})(PlaygroundErrorRenderer)},function(e,t,n){"use strict";var r=n(341);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";var r=n(0),i=(n.n(r),n(1)),a=n.n(i),o=function(){function defineProperties(e,t){for(var n=0;n=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(a,["className"]);return i.a.createElement("div",{className:t.root},i.a.createElement("div",c({className:l()(t.preview,p)},h,{"data-preview":n}),r),i.a.createElement("div",{className:t.controls},i.a.createElement("div",{className:t.tabs},o),i.a.createElement("div",{className:t.toolbar},u)),i.a.createElement("div",{className:t.tab},s))}PlaygroundRenderer.propTypes={classes:o.a.object.isRequired,name:o.a.string.isRequired,preview:o.a.node.isRequired,previewProps:o.a.object.isRequired,tabButtons:o.a.node.isRequired,tabBody:o.a.node.isRequired,toolbar:o.a.node.isRequired},t.a=Object(u.a)(function styles(e){var t=e.space,n=e.color,r=e.borderRadius;return{root:{marginBottom:t[4]},preview:{padding:t[2],border:[[1,n.border,"solid"]],borderRadius:r},controls:{display:"flex",alignItems:"center"},toolbar:{marginLeft:"auto"},tab:{}}})(PlaygroundRenderer)},function(e,t,n){"use strict";var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(2);function ExamplesRenderer(e){var t=e.classes,n=e.children;return i.a.createElement("article",{className:t.root},n)}ExamplesRenderer.propTypes={classes:o.a.object.isRequired,children:o.a.node},t.a=Object(s.a)(function styles(){return{root:{}}})(ExamplesRenderer)},function(e,t,n){"use strict";var r=n(346);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";t.a=Components;var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(347),l=n(356);function Components(e){var t=e.components,n=e.depth;return i.a.createElement(l.a,null,t.map(function(e){return i.a.createElement(s.a,{key:e.filepath,component:e,depth:n})}))}Components.propTypes={components:o.a.array.isRequired,depth:o.a.number.isRequired}},function(e,t,n){"use strict";var r=n(348);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(102),l=n(103),u=n(56),c=n(10),p=n(58),h=n(351),f=n(32),d=n(17),m=Object.assign||function(e){for(var t=1;t0?i.a.createElement(s.a,{examples:x,name:o}):i.a.createElement(y,{name:o}),tabButtons:i.a.createElement(p.a,{name:"docsTabButtons",active:e,props:m({},r,{onClick:this.handleTabChange})}),tabBody:i.a.createElement(p.a,{name:"docsTabs",active:e,onlyActive:!0,props:r})}):null}}]),ReactComponent}();v.propTypes={component:o.a.object.isRequired,depth:o.a.number.isRequired},v.contextTypes={config:o.a.object.isRequired,displayMode:o.a.string},t.a=v},function(e,t,n){"use strict";t.a=SectionHeading;var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(58),l=n(350),u=n(98),c=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(e,["slotName","slotProps","children","id"]),p=Object(u.a)({slug:a,anchor:!0});return i.a.createElement(l.a,c({toolbar:i.a.createElement(s.a,{name:t,props:n}),id:a,href:p},o),r)}SectionHeading.propTypes={children:o.a.node,id:o.a.string.isRequired,slotName:o.a.string.isRequired,slotProps:o.a.object.isRequired,depth:o.a.number.isRequired,deprecated:o.a.bool}},function(e,t,n){"use strict";var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(6),l=n.n(s),u=n(53),c=n(2);function SectionHeadingRenderer(e){var t=e.classes,n=e.children,r=e.toolbar,a=e.id,o=e.href,s=e.depth,c=e.deprecated,p=Math.min(6,s),h=l()(t.sectionName,function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},t.isDeprecated,c));return i.a.createElement("div",{className:t.wrapper},i.a.createElement(u.a,{level:p,id:a},i.a.createElement("a",{href:o,className:h},n)),i.a.createElement("div",{className:t.toolbar},r))}SectionHeadingRenderer.propTypes={classes:o.a.object.isRequired,children:o.a.node,toolbar:o.a.node,id:o.a.string.isRequired,href:o.a.string.isRequired,depth:o.a.number.isRequired,deprecated:o.a.bool},t.a=Object(c.a)(function styles(e){var t=e.color;return{wrapper:{display:"flex",flexDirection:"row",alignItems:"center",marginBottom:e.space[1]},toolbar:{marginLeft:"auto"},sectionName:{"&:hover, &:active":{isolate:!1,textDecoration:"underline",cursor:"pointer"}},isDeprecated:{textDecoration:"line-through",color:t.light}}})(SectionHeadingRenderer)},function(e,t,n){"use strict";var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(352),l=n(2);function ReactComponentRenderer(e){var t=e.classes,n=e.name,r=e.heading,a=e.pathLine,o=e.description,l=e.docs,u=e.examples,c=e.tabButtons,p=e.tabBody;return i.a.createElement("div",{className:t.root,id:n+"-container"},i.a.createElement("header",{className:t.header},r,a&&i.a.createElement(s.a,null,a)),(o||l)&&i.a.createElement("div",{className:t.docs},o,l),c&&i.a.createElement("div",{className:t.tabs},i.a.createElement("div",{className:t.tabButtons},c),p),u)}ReactComponentRenderer.propTypes={classes:o.a.object.isRequired,name:o.a.string.isRequired,heading:o.a.node.isRequired,pathLine:o.a.string,tabButtons:o.a.node,tabBody:o.a.node,description:o.a.node,docs:o.a.node,examples:o.a.node,isolated:o.a.bool},t.a=Object(l.a)(function styles(e){var t=e.color,n=e.fontSize,r=e.space;return{root:{marginBottom:r[6]},header:{marginBottom:r[3]},tabs:{marginBottom:r[3]},tabButtons:{marginBottom:r[2]},docs:{color:t.base,fontSize:n.text}}})(ReactComponentRenderer)},function(e,t,n){"use strict";var r=n(353);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";var r=n(0),i=n.n(r),a=n(1),o=n.n(a),s=n(354),l=n.n(s),u=n(355),c=n.n(u),p=n(97),h=n(2);function PathlineRenderer(e){var t=e.classes,n=e.children;return i.a.createElement("div",{className:t.pathline},n,i.a.createElement(p.a,{small:!0,className:t.copyButton,onClick:function onClick(){return l()(n)},title:"Copy to clipboard"},i.a.createElement(c.a,null)))}PathlineRenderer.propTypes={classes:o.a.object.isRequired,children:o.a.string},t.a=Object(h.a)(function styles(e){var t=e.space,n=e.fontFamily,r=e.fontSize,i=e.color;return{pathline:{fontFamily:n.monospace,fontSize:r.small,color:i.light},copyButton:{marginLeft:t[0]}}})(PathlineRenderer)},function(e,t){e.exports=function clipboardCopy(e){var t=document.createElement("span");t.textContent=e,t.style.whiteSpace="pre";var n=document.createElement("iframe");n.sandbox="allow-same-origin",document.body.appendChild(n);var r=n.contentWindow;r.document.body.appendChild(t);var i=r.getSelection();i||(r=window,i=r.getSelection(),document.body.appendChild(t));var a=r.document.createRange();i.removeAllRanges(),a.selectNode(t),i.addRange(a);var o=!1;try{o=r.document.execCommand("copy")}catch(e){}return i.removeAllRanges(),t.remove(),n.remove(),o}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t any"},description:"",defaultValue:null,tags:{}},children:{required:!1,type:{name:"ReactNode"},description:"",defaultValue:null,tags:{}}},methods:[],doclets:{},examples:n(383)}},function(e,t,n){var r={"./sfc-counter.usage":n(384),react:n(0)},i=n(11).bind(null,r),a=n(12).bind(null,"var React = require('react');",i);e.exports=[{type:"markdown",content:'Usage:\n\n```jsx\nimport * as React from \'react\';\n\nimport { SFCCounter } from \'@src/components\';\n\nexport default class extends React.Component<{}, { count: number }> {\n state = { count: 0 };\n\n render() {\n return (\n <SFCCounter\n label={\'SFCCounter\'}\n count={this.state.count}\n onIncrement={() => { this.setState({ count: this.state.count + 1 }); }}\n />\n );\n }\n}\n\n```\n\nUsage Demo:'},{type:"code",content:"const Demo = require('./sfc-counter.usage').default;\n",settings:{},evalInContext:a},{type:"markdown",content:"[⇦ back to guide](https://github.com/piotrwitek/react-redux-typescript-guide#--stateless-counter)"}]},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=(n.n(r),n(20));t.default=class extends r.Component{constructor(){super(...arguments),this.state={count:0}}render(){return r.createElement(i.b,{label:"SFCCounter",count:this.state.count,onIncrement:()=>{this.setState({count:this.state.count+1})}})}}},function(e,t,n){"use strict";var r=n(0);n.n(r)},function(e,t,n){"use strict";t.a=function __rest(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(e);iimport * as React from \'react\';\n\nimport { SFCSpreadAttributes } from \'@src/components\';\n\nexport default () => (\n <SFCSpreadAttributes\n className={\'classy\'}\n style={{ backgroundColor: \'lightcyan\' }}\n >\n {`I\'ll spread every property you give me!`}\n </SFCSpreadAttributes>\n);\n\n```\n\nUsage Demo:'},{type:"code",content:"const Demo = require('./sfc-spread-attributes.usage').default;\n",settings:{},evalInContext:a},{type:"markdown",content:"[⇦ back to guide](https://github.com/piotrwitek/react-redux-typescript-guide#--spread-attributes-link)"}]},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=(n.n(r),n(20));t.default=(()=>r.createElement(i.c,{className:"classy",style:{backgroundColor:"lightcyan"}},"I'll spread every property you give me!"))},function(e,t,n){e.exports={displayName:"StatefulCounter",description:"",props:{children:{required:!1,type:{name:"ReactNode"},description:"",defaultValue:null,tags:{}},label:{required:!0,type:{name:"string"},description:"",defaultValue:null,tags:{}}},methods:[],doclets:{},examples:n(391)}},function(e,t,n){var r={"./stateful-counter.usage":n(392),react:n(0)},i=n(11).bind(null,r),a=n(12).bind(null,"var React = require('react');",i);e.exports=[{type:"markdown",content:'Usage:\n\n```jsx\nimport * as React from \'react\';\n\nimport { StatefulCounter } from \'@src/components\';\n\nexport default () => (\n <StatefulCounter\n label={\'StatefulCounter\'}\n />\n);\n\n```\n\nUsage Demo:'},{type:"code",content:"const Demo = require('./stateful-counter.usage').default;\n",settings:{},evalInContext:a},{type:"markdown",content:"[⇦ back to guide](https://github.com/piotrwitek/react-redux-typescript-guide#--stateful-counter)"}]},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=(n.n(r),n(20));t.default=(()=>r.createElement(i.d,{label:"StatefulCounter"}))},function(e,t,n){e.exports={displayName:"StatefulCounterWithDefault",description:"",props:{children:{required:!1,type:{name:"ReactNode"},description:"",defaultValue:null,tags:{}},label:{required:!0,type:{name:"string"},description:"",defaultValue:null,tags:{}},initialCount:{required:!1,type:{name:"number"},description:"",defaultValue:null,tags:{}}},methods:[],doclets:{},examples:n(394)}},function(e,t,n){var r={"./stateful-counter-with-default.usage":n(395),react:n(0)},i=n(11).bind(null,r),a=n(12).bind(null,"var React = require('react');",i);e.exports=[{type:"markdown",content:'Usage:\n\n```jsx\nimport * as React from \'react\';\n\nimport { StatefulCounterWithDefault } from \'@src/components\';\n\nexport default () => (\n <StatefulCounterWithDefault\n label={\'StatefulCounter\'}\n />\n);\n\n```\n\nUsage Demo:'},{type:"code",content:"const Demo = require('./stateful-counter-with-default.usage').default;\n",settings:{},evalInContext:a},{type:"markdown",content:"[⇦ back to guide](https://github.com/piotrwitek/react-redux-typescript-guide#--with-default-props)"}]},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=(n.n(r),n(20));t.default=(()=>r.createElement(i.e,{label:"StatefulCounter"}))},function(e,t,n){e.exports={displayName:"GenericList",description:"",props:{children:{required:!1,type:{name:"ReactNode"},description:"",defaultValue:null,tags:{}},items:{required:!0,type:{name:"T[]"},description:"",defaultValue:null,tags:{}},itemRenderer:{required:!0,type:{name:"(item: T) => Element"},description:"",defaultValue:null,tags:{}}},methods:[],doclets:{},examples:n(397)}},function(e,t,n){var r={"./generic-list.usage":n(398),react:n(0)},i=n(11).bind(null,r),a=n(12).bind(null,"var React = require('react');",i);e.exports=[{type:"markdown",content:'Usage:\n\n```jsx\nimport * as React from \'react\';\n\nimport { IUser, User } from \'@src/models\';\nimport { GenericList } from \'@src/components\';\n\nconst users = [\n new User(\'Rosamonte\', \'Especial\'),\n new User(\'Aguantadora\', \'Despalada\'),\n new User(\'Taragui\', \'Vitality\'),\n];\n\nexport class UserList extends GenericList<IUser> { }\n\nexport default () => (\n <UserList\n items={users}\n itemRenderer={(item) => <div key={item.id}>{item.fullName}</div>}\n />\n);\n\n```\n\nUsage Demo:'},{type:"code",content:"const Demo = require('./generic-list.usage').default;\n",settings:{},evalInContext:a},{type:"markdown",content:"[⇦ back to guide](https://github.com/piotrwitek/react-redux-typescript-guide#--generic-list)"}]},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=(n.n(r),n(399)),a=n(20);const o=[new i.a("Rosamonte","Especial"),new i.a("Aguantadora","Despalada"),new i.a("Taragui","Vitality")];class s extends a.a{}t.UserList=s,t.default=(()=>r.createElement(s,{items:o,itemRenderer:e=>r.createElement("div",{key:e.id},e.fullName)}))},function(e,t,n){"use strict";var r=n(400);n.d(t,"a",function(){return r.a})},function(e,t,n){"use strict";var r=n(401),i=n.n(r);class a{constructor(e,t){this.firstName=e,this.lastName=t,this.id=i()()}get fullName(){return`${this.firstName} ${this.lastName}`}static create(e){const t=new a(e.first_name,e.last_name);return t.id=e.id,t}serialize(){return{id:this.id,first_name:this.firstName,last_name:this.lastName}}}t.a=a},function(e,t,n){var r=n(402),i=n(110),a=0,o=4,s=36,l=Math.pow(s,o);function randomBlock(){return i((Math.random()*l<<0).toString(s),o)}function safeCounter(){return a=a ReactNode) | (string & ((state: NameProviderState) => ReactNode)) ..."},description:"",defaultValue:null,tags:{}}},methods:[],doclets:{},examples:n(404)}},function(e,t,n){var r={"./name-provider.usage":n(405),react:n(0)},i=n(11).bind(null,r),a=n(12).bind(null,"var React = require('react');",i);e.exports=[{type:"markdown",content:'Usage:\n\n```jsx\nimport * as React from \'react\';\n\nimport { NameProvider } from \'./name-provider\';\n\nexport default () => (\n <NameProvider>\n {({ name }) => (\n <div>{name}</div>\n )}\n </NameProvider>\n);\n\n```\n\nUsage Demo:'},{type:"code",content:"const Demo = require('./name-provider.usage').default;\n",settings:{},evalInContext:a},{type:"markdown",content:"[⇦ back to guide](https://github.com/piotrwitek/react-redux-typescript-guide#--name-provider)"}]},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=(n.n(r),n(59));t.default=(()=>r.createElement(i.NameProvider,null,({name:e})=>r.createElement("div",null,e)))},function(e,t,n){e.exports={displayName:"MouseProvider",description:"",props:{children:{required:!1,type:{name:"ReactNode"},description:"",defaultValue:null,tags:{}},render:{required:!0,type:{name:"(state: MouseProviderState) => ReactNode"},description:"",defaultValue:null,tags:{}}},methods:[],doclets:{},examples:n(407)}},function(e,t,n){var r={"./mouse-provider.usage":n(408),react:n(0)},i=n(11).bind(null,r),a=n(12).bind(null,"var React = require('react');",i);e.exports=[{type:"markdown",content:'Usage:\n\n```jsx\nimport * as React from \'react\';\n\nimport { MouseProvider } from \'./mouse-provider\';\n\nexport default () => (\n <MouseProvider\n render={mouse => (\n <p>The mouse position is {mouse.x}, {mouse.y}</p>\n )}\n />\n);\n\n```\n\nUsage Demo:'},{type:"code",content:"const Demo = require('./mouse-provider.usage').default;\n",settings:{},evalInContext:a},{type:"markdown",content:"[⇦ back to guide](https://github.com/piotrwitek/react-redux-typescript-guide#--mouse-provider)"}]},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=(n.n(r),n(60));t.default=(()=>r.createElement(i.MouseProvider,{render:e=>r.createElement("p",null,"The mouse position is ",e.x,", ",e.y)}))}]); ================================================ FILE: docs/index.html ================================================ React & Redux in TypeScript - Component Typing Patterns
================================================ FILE: generate-readme.js ================================================ const fs = require('fs'); const ROOT_PATH = `${__dirname}/`; const inputFiles = [ROOT_PATH + 'README_SOURCE.md']; const outputFile = ROOT_PATH + 'README.md'; const result = inputFiles .map(filePath => fs.readFileSync(filePath, 'utf8')) .map(injectCodeBlocks) .map(injectExpanders) .toString(); fs.writeFileSync(outputFile, result, 'utf8'); function injectCodeBlocks(text) { const regex = /::codeblock='(.+?)'::/g; return text.replace(regex, createMatchReplacer(withSourceWrapper)); } function injectExpanders(text) { const regex = /::expander='(.+?)'::/g; return text.replace(regex, createMatchReplacer(withDetailsWrapper)); } function createMatchReplacer(wrapper) { return (match, filePath) => { console.log(ROOT_PATH + filePath); const text = fs.readFileSync(ROOT_PATH + filePath, 'utf8'); return wrapper(text); }; } function withSourceWrapper(text) { return ` ${'```tsx'} ${text} ${'```'} `.trim(); } function withDetailsWrapper(text) { return `
Click to expand

${'```tsx'} ${text} ${'```'}

`.trim(); } ================================================ FILE: generate-readme.sh ================================================ #!/bin/bash node generate-readme.js ================================================ FILE: generate-styleguide.sh ================================================ #!/bin/bash cd playground && npm run styleguide:build ================================================ FILE: is-git-status-clean.sh ================================================ #!/bin/bash if output=$(git status --porcelain) && [ -z "$output" ]; then echo "Success!"; else (echo ">>> Please check CONTRIBUTING.md to learn how to properly amend README.md <<<\n" && false); fi ================================================ FILE: package.json ================================================ { "devDependencies": { "all-contributors-cli": "6.9.3", "doctoc": "1.4.0", "husky": "3.0.9" }, "scripts": { "ci-check": "npm run doctoc && npm run readme:generate", "doctoc": "doctoc --maxlevel=3 README_SOURCE.md", "readme:generate": "node generate-readme.js", "contributors:check": "all-contributors check", "contributors:add": "all-contributors add", "contributors:generate": "all-contributors generate", "is-git-status-clean": "sh ./is-git-status-clean.sh" }, "husky": { "hooks": { "pre-push": "npm run ci-check && npm run is-git-status-clean " } }, "dependencies": { "react": "18.1.0", "react-dom": "18.1.0" } } ================================================ FILE: playground/.eslintrc.js ================================================ module.exports = { root: true, parser: '@typescript-eslint/parser', plugins: ['@typescript-eslint'], extends: ['react-app', 'react-app/jest', 'prettier'], rules: { 'import/no-anonymous-default-export': 0 }, }; ================================================ FILE: playground/.gitignore ================================================ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # dependencies /node_modules /.pnp .pnp.js # testing /coverage # production /build # misc .DS_Store .env.local .env.development.local .env.test.local .env.production.local npm-debug.log* yarn-debug.log* yarn-error.log* ================================================ FILE: playground/.prettierrc ================================================ { "printWidth": 80, "semi": true, "singleQuote": true, "trailingComma": "es5" } ================================================ FILE: playground/.storybook/addons.js ================================================ import '@storybook/addon-actions/register'; import '@storybook/addon-links/register'; ================================================ FILE: playground/.storybook/config.js ================================================ import { configure } from '@storybook/react'; import requireContext from 'require-context.macro'; // We load every file in src directory ending with .stories.tsx const req = requireContext('../src', true, /.stories.tsx$/); function loadStories() { req.keys().forEach(filename => req(filename)); } configure(loadStories, module); ================================================ FILE: playground/.storybook/webpack.config.js ================================================ module.exports = ({ config, mode }) => { config.module.rules.push({ test: /\.(ts|tsx)$/, loader: require.resolve('babel-loader'), options: { presets: [['react-app', { flow: false, typescript: true }]], }, }); config.resolve.extensions.push('.ts', '.tsx'); return config; }; ================================================ FILE: playground/.vscode/settings.json ================================================ { "typescript.tsdk": "node_modules/typescript/lib" } ================================================ FILE: playground/README.md ================================================ This folder is a playground project for testing the code examples that can be found in the guide. They are all tested with the most recent supported version of TypeScript and third-party type-definitions (like `@types/react` or `@types/react-redux`) to ensure the examples are still working when new third-party type-definitions are released. ================================================ FILE: playground/index.html ================================================ React, Redux, Typescript Guide
================================================ FILE: playground/package.json ================================================ { "name": "playground", "description": "Playground Project for https://github.com/piotrwitek/react-redux-typescript-guide", "version": "1.0.0", "private": true, "author": "Piotr Witek (http://piotrwitek.github.io/)", "repository": "https://github.com/piotrwitek/react-redux-typescript-guide.git", "license": "MIT", "main": "src/index.tsx", "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", "reinstall": "rm -rf node_modules && npm install", "ci-check": "npm run lint && npm run tsc && npm run test", "lint": "eslint ./src --ext .js,.jsx,.ts,.tsx", "tsc": "tsc -p ./ --noEmit", "tsc:watch": "tsc -p ./ --noEmit -w", "storybook": "start-storybook -p 9009 -s public", "build-storybook": "build-storybook -s public" }, "dependencies": { "@lagunovsky/redux-react-router": "2.2.0", "@testing-library/jest-dom": "5.16.4", "@testing-library/react": "13.1.1", "@testing-library/user-event": "13.5.0", "@types/jest": "27.5.0", "@types/node": "16.11.33", "@types/react": "18.0.8", "@types/react-dom": "18.0.3", "@types/react-redux": "7.1.24", "@types/react-router-dom": "5.3.3", "axios": "0.26.1", "cuid": "2.1.8", "react": "18.1.0", "react-dom": "18.1.0", "react-redux": "7.2.8", "react-router-dom": "6.3.0", "react-scripts": "5.0.1", "redux": "4.1.2", "redux-observable": "1.2.0", "redux-thunk": "2.4.1", "reselect": "4.0.0", "rxjs": "6.5.3", "tslib": "2.4.0", "typesafe-actions": "5.1.0", "utility-types": "3.10.0" }, "devDependencies": { "@storybook/addon-actions": "5.2.5", "@storybook/addon-links": "5.2.5", "@storybook/addon-storyshots": "5.2.5", "@storybook/addons": "5.2.5", "@storybook/react": "5.2.5", "@typescript-eslint/eslint-plugin": "5.22.0", "@typescript-eslint/parser": "5.22.0", "eslint": "8.14.0", "eslint-config-prettier": "8.5.0", "require-context.macro": "1.2.2", "typescript": "4.6.4", "web-vitals": "2.1.4" }, "browserslist": { "production": [ ">0.2%", "not dead", "not op_mini all" ], "development": [ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" ] } } ================================================ FILE: playground/public/index.html ================================================ React, Redux, TypeScript Guide - Playground
================================================ FILE: playground/public/manifest.json ================================================ { "short_name": "RRTS Guide - Playground", "name": "React, Redux, TypeScript Guide - Playground", "icons": [ { "src": "favicon.ico", "sizes": "64x64 32x32 24x24 16x16", "type": "image/x-icon" } ], "start_url": ".", "display": "standalone", "theme_color": "#000000", "background_color": "#ffffff" } ================================================ FILE: playground/src/api/agent.ts ================================================ import axios from 'axios'; const URL = 'http://localhost:3000/api/'; const getToken = () => 'some-token'; const formatToken = (token: string) => { return `Token ${token}`; }; // Public export const setToken = (token: string) => { agentInstance.defaults.headers.common.Authorization = formatToken(token); }; const agentInstance = axios.create({ baseURL: URL, timeout: 4000, headers: { Authorization: formatToken(getToken()), }, }); export default agentInstance; ================================================ FILE: playground/src/api/fixtures/todos.json ================================================ { "id": 0, "text": "Example todo", "completed": false } ================================================ FILE: playground/src/api/index.ts ================================================ export { default as agent } from './agent'; export * from './agent'; export * from './models'; export * from './todos'; export * from './utils'; ================================================ FILE: playground/src/api/models.ts ================================================ export interface ITodoModel { id: string; text: string; completed: false; } ================================================ FILE: playground/src/api/todos.ts ================================================ import { ITodoModel } from './models'; import { resolveWithDelay } from './utils'; const pageSize = 10; // Mock API // tslint:disable-next-line:no-var-requires const todosResponse: ITodoModel[] = require('../fixtures/todos.json'); export const Todos = { getAll: (pageNumber: number = 0) => resolveWithDelay(todosResponse .slice(pageNumber * pageSize, (pageNumber * pageSize) + pageSize - 1)), get: (id: string) => resolveWithDelay(todosResponse .find(t => t.id === id)), create: (payload: ITodoModel) => resolveWithDelay(todosResponse .push(payload)), update: (payload: ITodoModel) => resolveWithDelay(todosResponse .map(t => t.id === payload.id ? payload : t)), delete: (id: string) => resolveWithDelay(todosResponse .filter(t => t.id !== id)), }; // Real API // const URL = '/todos'; // export const Todos = { // getAll: (pageNumber?: number) => // requests.get(`${URL}?${rangeQueryString(pageSize, pageNumber)}`), // get: (id: string) => // requests.get(`${URL}/${id}`), // create: (payload: ITodoModel) => // requests.post(`${URL}`, { payload }), // update: (payload: ITodoModel) => // requests.put(`${URL}/${payload.id}`, { todo: removeKeys(payload, ['id']) }), // delete: (id: string) => // requests.delete(`${URL}/${id}`), // }; ================================================ FILE: playground/src/api/utils.ts ================================================ export const resolveWithDelay = (value: T, time: number = 1000) => new Promise( (resolve) => setTimeout(() => resolve(value), time) ); export const rangeQueryString = (count: number, pageNumber?: number) => `limit=${count}&offset=${pageNumber ? pageNumber * count : 0}`; export const removeKeys = (payload: T, keys: Array) => { keys.forEach((key) => { delete payload[key]; }); return payload; }; ================================================ FILE: playground/src/app.test.tsx ================================================ import React from 'react'; import ReactDOM from 'react-dom'; import { App } from './app'; it('renders without crashing', () => { const div = document.createElement('div'); ReactDOM.render(, div); ReactDOM.unmountComponentAtNode(div); }); ================================================ FILE: playground/src/app.tsx ================================================ import React from 'react'; import { Provider } from 'react-redux'; import { Outlet, Route, Routes } from 'react-router-dom'; import { ReduxRouter } from '@lagunovsky/redux-react-router' import { Layout } from './layout/layout'; import { LayoutFooter } from './layout/layout-footer'; import { LayoutHeader } from './layout/layout-header'; import { Home } from './routes/home'; import { NotFound } from './routes/not-found'; import { history, store } from './store'; export function App() { return ( } renderFooter={() => } renderContent={() => } /> } > } /> } /> ); } ================================================ FILE: playground/src/components/__snapshots__/class-counter-with-default-props.stories.storyshot ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots ClassCounterWithDefaultProps with defaut initial count 1`] = `
ClassCounterWithDefaultProps : 0
`; exports[`Storyshots ClassCounterWithDefaultProps with initial count set 1`] = `
ClassCounterWithDefaultProps : 5
`; ================================================ FILE: playground/src/components/__snapshots__/class-counter.stories.storyshot ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots ClassCounter default 1`] = `
ClassCounter : 0
`; ================================================ FILE: playground/src/components/__snapshots__/fc-counter-with-default-props.stories.storyshot ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots FCCounterWithDefaultProps default 1`] = `
FCCounterWithDefaultProps : 5
`; ================================================ FILE: playground/src/components/__snapshots__/fc-counter.stories.storyshot ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots FCCounter default 1`] = `
FCCounter : 0
`; ================================================ FILE: playground/src/components/__snapshots__/fc-spread-attributes.stories.storyshot ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots FCSpreadAttributes default 1`] = `
I'll spread every property you give me!
`; ================================================ FILE: playground/src/components/__snapshots__/generic-list.stories.storyshot ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots GenericList default 1`] = `
Rosamonte Especial
Aguantadora Despalada
Taragui Vitality
`; ================================================ FILE: playground/src/components/__snapshots__/mouse-provider.stories.storyshot ================================================ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Storyshots MouseProvider default 1`] = `

The mouse position is 0 , 0

`; ================================================ FILE: playground/src/components/class-counter-with-default-props.md ================================================ Usage: ```jsx { "filePath": "./class-counter-with-default-props.usage.tsx" } ``` Usage Demo: ```jsx const Demo = require('./class-counter-with-default-props.usage').default; ``` [⇦ back to guide](https://github.com/piotrwitek/react-redux-typescript-guide#--with-default-props) ================================================ FILE: playground/src/components/class-counter-with-default-props.stories.tsx ================================================ import React from 'react'; import { storiesOf } from '@storybook/react'; import { ClassCounterWithDefaultProps } from '../components'; storiesOf('ClassCounterWithDefaultProps', module) .add('with defaut initial count', () => ( )) .add('with initial count set', () => ( )); ================================================ FILE: playground/src/components/class-counter-with-default-props.tsx ================================================ import * as React from 'react'; type Props = { label: string; initialCount: number; }; type State = { count: number; }; export class ClassCounterWithDefaultProps extends React.Component< Props, State > { static defaultProps = { initialCount: 0, }; readonly state: State = { count: this.props.initialCount, }; handleIncrement = () => { this.setState({ count: this.state.count + 1 }); }; render() { const { handleIncrement } = this; const { label } = this.props; const { count } = this.state; return (
{label}: {count}
); } } ================================================ FILE: playground/src/components/class-counter-with-default-props.usage.tsx ================================================ import * as React from 'react'; import { ClassCounterWithDefaultProps } from '.'; export default () => ( ); ================================================ FILE: playground/src/components/class-counter.md ================================================ Usage: ```jsx { "filePath": "./class-counter.usage.tsx" } ``` Usage Demo: ```jsx const Demo = require('./class-counter.usage').default; ``` [⇦ back to guide](https://github.com/piotrwitek/react-redux-typescript-guide#--class-counter) ================================================ FILE: playground/src/components/class-counter.stories.tsx ================================================ import React from 'react'; import { storiesOf } from '@storybook/react'; import { ClassCounter } from '../components'; storiesOf('ClassCounter', module).add('default', () => ( )); ================================================ FILE: playground/src/components/class-counter.tsx ================================================ import * as React from 'react'; type Props = { label: string; }; type State = { count: number; }; export class ClassCounter extends React.Component { readonly state: State = { count: 0, }; handleIncrement = () => { this.setState({ count: this.state.count + 1 }); }; render() { const { handleIncrement } = this; const { label } = this.props; const { count } = this.state; return (
{label}: {count}
); } } ================================================ FILE: playground/src/components/class-counter.usage.tsx ================================================ import * as React from 'react'; import { ClassCounter } from '.'; export default () => ; ================================================ FILE: playground/src/components/error-message.tsx ================================================ import * as React from 'react'; export const ErrorMessage: React.FC<{ onReset: () => void }> = ({ onReset, }) => { return (

{`Sorry there was an unexpected error`}

{`To continue: `} { onReset(); }} > {`go to home page`}
); }; export function test(props: any) { const Container = props.componentClass; return ; } ================================================ FILE: playground/src/components/fc-counter-with-default-props.md ================================================ Usage: ```jsx { "filePath": "./fc-counter-with-default-props.usage.tsx" } ``` Usage Demo: ```jsx const Demo = require('./fc-counter-with-default-props.usage').default; ``` [⇦ back to guide](https://github.com/piotrwitek/react-redux-typescript-guide#--fc-counter-with-default-props) ================================================ FILE: playground/src/components/fc-counter-with-default-props.stories.tsx ================================================ import React from 'react'; import { storiesOf } from '@storybook/react'; import { action } from '@storybook/addon-actions'; import { FCCounterWithDefaultProps } from '.'; storiesOf('FCCounterWithDefaultProps', module).add('default', () => ( )); ================================================ FILE: playground/src/components/fc-counter-with-default-props.tsx ================================================ import * as React from 'react'; type Props = { label: string; count: number; onIncrement: () => void; }; // React.FC is unaplicable here due not working properly with default props // https://github.com/facebook/create-react-app/pull/8177 export const FCCounterWithDefaultProps = (props: Props): JSX.Element => { const { label, count, onIncrement } = props; const handleIncrement = () => { onIncrement(); }; return (
{label}: {count}
); }; FCCounterWithDefaultProps.defaultProps = { count: 5 }; ================================================ FILE: playground/src/components/fc-counter-with-default-props.usage.tsx ================================================ import { action } from '@storybook/addon-actions'; import * as React from 'react'; import { FCCounterWithDefaultProps } from '.'; export default () => ( ); ================================================ FILE: playground/src/components/fc-counter.md ================================================ Usage: ```jsx { "filePath": "./fc-counter.usage.tsx" } ``` Usage Demo: ```jsx const Demo = require('./fc-counter.usage').default; ``` [⇦ back to guide](https://github.com/piotrwitek/react-redux-typescript-guide#--fc-counter) ================================================ FILE: playground/src/components/fc-counter.stories.tsx ================================================ import React from 'react'; import { storiesOf } from '@storybook/react'; import { action } from '@storybook/addon-actions'; import { FCCounter } from '../components'; storiesOf('FCCounter', module).add('default', () => ( )); ================================================ FILE: playground/src/components/fc-counter.tsx ================================================ import * as React from 'react'; type Props = { label: string; count: number; onIncrement: () => void; }; export const FCCounter: React.FC = props => { const { label, count, onIncrement } = props; const handleIncrement = () => { onIncrement(); }; return (
{label}: {count}
); }; ================================================ FILE: playground/src/components/fc-counter.usage.tsx ================================================ import * as React from 'react'; import { FCCounter } from '.'; export default class extends React.Component<{}, { count: number }> { state = { count: 0 }; render() { return ( { this.setState({ count: this.state.count + 1 }); }} /> ); } } ================================================ FILE: playground/src/components/fc-spread-attributes.md ================================================ Usage: ```jsx { "filePath": "./fc-spread-attributes.usage.tsx" } ``` Usage Demo: ```jsx const Demo = require('./fc-spread-attributes.usage').default; ``` [⇦ back to guide](https://github.com/piotrwitek/react-redux-typescript-guide#--spread-attributes-link) ================================================ FILE: playground/src/components/fc-spread-attributes.stories.tsx ================================================ import React from 'react'; import { storiesOf } from '@storybook/react'; import { FCSpreadAttributes } from '../components'; storiesOf('FCSpreadAttributes', module).add('default', () => ( {`I'll spread every property you give me!`} )); ================================================ FILE: playground/src/components/fc-spread-attributes.tsx ================================================ import * as React from 'react'; type Props = React.PropsWithChildren<{ className?: string; style?: React.CSSProperties; }>; export const FCSpreadAttributes: React.FC = (props) => { const { children, ...restProps } = props; return
{children}
; }; ================================================ FILE: playground/src/components/fc-spread-attributes.usage.tsx ================================================ import * as React from 'react'; import { FCSpreadAttributes } from '.'; export default () => ( {`I'll spread every property you give me!`} ); ================================================ FILE: playground/src/components/generic-list.md ================================================ Usage: ```jsx { "filePath": "./generic-list.usage.tsx" } ``` Usage Demo: ```jsx const Demo = require('./generic-list.usage').default; ``` [⇦ back to guide](https://github.com/piotrwitek/react-redux-typescript-guide#--generic-list) ================================================ FILE: playground/src/components/generic-list.stories.tsx ================================================ import React from 'react'; import { storiesOf } from '@storybook/react'; import { IUser, User } from '../models'; import { GenericList } from '../components'; const users = [ new User('Rosamonte', 'Especial'), new User('Aguantadora', 'Despalada'), new User('Taragui', 'Vitality'), ]; export class UserList extends GenericList {} storiesOf('GenericList', module).add('default', () => (
{item.fullName}
} /> )); ================================================ FILE: playground/src/components/generic-list.tsx ================================================ import * as React from 'react'; export interface GenericListProps { items: T[]; itemRenderer: (item: T) => JSX.Element; } export class GenericList extends React.Component, {}> { render() { const { items, itemRenderer } = this.props; return (
{items.map(itemRenderer)}
); } } ================================================ FILE: playground/src/components/generic-list.usage.tsx ================================================ import * as React from 'react'; import { IUser, User } from '../models'; import { GenericList } from '../components'; const users = [ new User('Rosamonte', 'Especial'), new User('Aguantadora', 'Despalada'), new User('Taragui', 'Vitality'), ]; export class UserList extends GenericList {} export default () => (
{item.fullName}
} /> ); ================================================ FILE: playground/src/components/index.ts ================================================ export * from './error-message'; export * from './generic-list'; export * from './fc-counter'; export * from './fc-counter-with-default-props'; export * from './fc-spread-attributes'; export * from './class-counter'; export * from './class-counter-with-default-props'; export * from './name-provider'; export * from './mouse-provider'; ================================================ FILE: playground/src/components/mouse-provider.md ================================================ Usage: ```jsx { "filePath": "./mouse-provider.usage.tsx" } ``` Usage Demo: ```jsx const Demo = require('./mouse-provider.usage').default; ``` [⇦ back to guide](https://github.com/piotrwitek/react-redux-typescript-guide#--mouse-provider) ================================================ FILE: playground/src/components/mouse-provider.stories.tsx ================================================ import React from 'react'; import { storiesOf } from '@storybook/react'; import { MouseProvider } from '../components'; storiesOf('MouseProvider', module).add('default', () => ( (

The mouse position is {mouse.x}, {mouse.y}

)} /> )); ================================================ FILE: playground/src/components/mouse-provider.tsx ================================================ import * as React from 'react'; export interface MouseProviderProps { render: (state: MouseProviderState) => React.ReactNode; } interface MouseProviderState { readonly x: number; readonly y: number; } export class MouseProvider extends React.Component { readonly state: MouseProviderState = { x: 0, y: 0 }; handleMouseMove = (event: React.MouseEvent) => { this.setState({ x: event.clientX, y: event.clientY, }); }; render() { return (
{/* Instead of providing a static representation of what renders, use the `render` prop to dynamically determine what to render. */} {this.props.render(this.state)}
); } } ================================================ FILE: playground/src/components/mouse-provider.usage.tsx ================================================ import * as React from 'react'; import { MouseProvider } from './mouse-provider'; export default () => ( (

The mouse position is {mouse.x}, {mouse.y}

)} /> ); ================================================ FILE: playground/src/components/name-provider.md ================================================ Usage: ```jsx { "filePath": "./name-provider.usage.tsx" } ``` Usage Demo: ```jsx const Demo = require('./name-provider.usage').default; ``` [⇦ back to guide](https://github.com/piotrwitek/react-redux-typescript-guide#--name-provider) ================================================ FILE: playground/src/components/name-provider.tsx ================================================ import * as React from 'react'; interface NameProviderProps { children: (state: NameProviderState) => React.ReactNode; } interface NameProviderState { readonly name: string; } export class NameProvider extends React.Component { readonly state: NameProviderState = { name: 'Piotr' }; render() { return this.props.children(this.state); } } ================================================ FILE: playground/src/components/name-provider.usage.tsx ================================================ import * as React from 'react'; import { NameProvider } from './name-provider'; export default () => ( {({ name }) => (
{name}
)}
); ================================================ FILE: playground/src/connected/fc-counter-connected-bind-action-creators.tsx ================================================ import Types from 'MyTypes'; import { bindActionCreators, Dispatch } from 'redux'; import { connect } from 'react-redux'; import * as React from 'react'; import { countersActions } from '../features/counters'; // Thunk Action const incrementWithDelay = () => async (dispatch: Dispatch): Promise => { setTimeout(() => dispatch(countersActions.increment()), 1000); }; const mapStateToProps = (state: Types.RootState) => ({ count: state.counters.reduxCounter, }); const mapDispatchToProps = (dispatch: Dispatch) => bindActionCreators( { onIncrement: incrementWithDelay, }, dispatch ); type Props = ReturnType & ReturnType & { label: string; }; export const FCCounter: React.FC = props => { const { label, count, onIncrement } = props; const handleIncrement = () => { // Thunk action is correctly typed as promise onIncrement().then(() => { // ... }); }; return (
{label}: {count}
); }; export const FCCounterConnectedBindActionCreators = connect( mapStateToProps, mapDispatchToProps )(FCCounter); ================================================ FILE: playground/src/connected/fc-counter-connected-bind-action-creators.usage.tsx ================================================ import * as React from 'react'; import { FCCounterConnectedBindActionCreators } from '.'; export default () => ( ); ================================================ FILE: playground/src/connected/fc-counter-connected-own-props.spec.tsx ================================================ import React from 'react'; import { createStore, combineReducers } from 'redux'; import { Provider } from 'react-redux'; import { render, fireEvent, cleanup, screen } from '@testing-library/react'; import { FCCounterConnectedOwnProps as ConnectedCounter } from './fc-counter-connected-own-props'; const reducer = combineReducers({ counters: combineReducers({ reduxCounter: (state: number = 0, action: any) => { switch (action.type) { case 'counters/INCREMENT': return state + 1; // action: { type: "INCREMENT"; } default: return state; } }, }), }); afterEach(cleanup); test('can render with redux with defaults', () => { const label = 'Counter 1'; renderWithRedux(); fireEvent.click(screen.getByText('Increment')); expect(screen.getByText(RegExp(label)).textContent).toBe(label + ': 1'); }); test('can render with redux with custom initial state', () => { const label = 'Counter 1'; renderWithRedux(, { initialState: { counters: { reduxCounter: 3 } }, }); fireEvent.click(screen.getByText('Increment')); expect(screen.getByText(RegExp(label)).textContent).toBe(label + ': 4'); }); // TODO: move to external utils // Redux Provider utility function renderWithRedux( jsx: JSX.Element, options: { initialState?: object } = {} ) { const store = createStore(reducer, options.initialState); const view = render({jsx}); return { view, store, }; } ================================================ FILE: playground/src/connected/fc-counter-connected-own-props.tsx ================================================ import Types from 'MyTypes'; import { connect } from 'react-redux'; import { countersActions, countersSelectors } from '../features/counters'; import { FCCounter } from '../components'; type OwnProps = { initialCount?: number; }; const mapStateToProps = (state: Types.RootState, ownProps: OwnProps) => ({ count: countersSelectors.getReduxCounter(state.counters) + (ownProps.initialCount || 0), }); const dispatchProps = { onIncrement: countersActions.increment, }; export const FCCounterConnectedOwnProps = connect( mapStateToProps, dispatchProps )(FCCounter); ================================================ FILE: playground/src/connected/fc-counter-connected-own-props.usage.tsx ================================================ import * as React from 'react'; import { FCCounterConnectedOwnProps } from '.'; export default () => ( ); ================================================ FILE: playground/src/connected/fc-counter-connected.tsx ================================================ import Types from 'MyTypes'; import { connect } from 'react-redux'; import { countersActions, countersSelectors } from '../features/counters'; import { FCCounter } from '../components'; const mapStateToProps = (state: Types.RootState) => ({ count: countersSelectors.getReduxCounter(state.counters), }); const dispatchProps = { onIncrement: countersActions.increment, }; export const FCCounterConnected = connect( mapStateToProps, dispatchProps )(FCCounter); ================================================ FILE: playground/src/connected/fc-counter-connected.usage.tsx ================================================ import * as React from 'react'; import { FCCounterConnected } from '.'; export default () => ; ================================================ FILE: playground/src/connected/index.ts ================================================ export * from './fc-counter-connected-bind-action-creators'; export * from './fc-counter-connected-own-props'; export * from './fc-counter-connected'; ================================================ FILE: playground/src/context/theme-consumer-class.tsx ================================================ import * as React from 'react'; import ThemeContext from './theme-context'; type Props = {}; export class ToggleThemeButtonClass extends React.Component { static contextType = ThemeContext; declare context: React.ContextType; render() { const { theme, toggleTheme } = this.context; return ( ); } } ================================================ FILE: playground/src/context/theme-consumer.tsx ================================================ import * as React from 'react'; import ThemeContext from './theme-context'; type Props = {}; export default function ToggleThemeButton(props: Props) { return ( {({ theme, toggleTheme }) => ); }; export default () => ( ); ================================================ FILE: playground/src/hoc/with-state.tsx ================================================ import React from 'react'; import { Diff } from 'utility-types'; // These props will be injected into the base component interface InjectedProps { count: number; onIncrement: () => void; } export const withState = ( BaseComponent: React.ComponentType ) => { type HocProps = Diff & { // here you can extend hoc with new props initialCount?: number; }; type HocState = { readonly count: number; }; return class Hoc extends React.Component { // Enhance component name for debugging and React-Dev-Tools static displayName = `withState(${BaseComponent.name})`; // reference to original wrapped component static readonly WrappedComponent = BaseComponent; readonly state: HocState = { count: Number(this.props.initialCount) || 0, }; handleIncrement = () => { this.setState({ count: this.state.count + 1 }); }; render() { const { ...restProps } = this.props; const { count } = this.state; return ( ); } }; }; ================================================ FILE: playground/src/hoc/with-state.usage.tsx ================================================ import * as React from 'react'; import { withState } from '../hoc'; import { FCCounter } from '../components'; const FCCounterWithState = withState(FCCounter); export default () => ; ================================================ FILE: playground/src/hooks/react-redux-hooks.tsx ================================================ import * as React from 'react'; import { FCCounter } from '../components'; import { increment } from '../features/counters/actions'; import { useSelector, useDispatch } from '../store/hooks'; const FCCounterConnectedHooksUsage: React.FC = () => { const counter = useSelector(state => state.counters.reduxCounter); const dispatch = useDispatch(); return dispatch(increment())}/>; }; export default FCCounterConnectedHooksUsage; ================================================ FILE: playground/src/hooks/use-reducer.tsx ================================================ import * as React from 'react'; interface State { count: number; } type Action = { type: 'reset' } | { type: 'increment' } | { type: 'decrement' }; function reducer(state: State, action: Action): State { switch (action.type) { case 'increment': return { count: state.count + 1 }; case 'decrement': return { count: state.count - 1 }; case 'reset': return { count: 0 }; default: throw new Error(); } } interface CounterProps { initialCount: number; } function Counter({ initialCount }: CounterProps) { const [state, dispatch] = React.useReducer(reducer, { count: initialCount, }); return ( <> Count: {state.count} ); } export default Counter; ================================================ FILE: playground/src/hooks/use-state.tsx ================================================ import * as React from 'react'; type Props = { initialCount: number }; export default function Counter({initialCount}: Props) { const [count, setCount] = React.useState(initialCount); return ( <> Count: {count} ); } ================================================ FILE: playground/src/hooks/use-theme-context.tsx ================================================ import * as React from 'react'; import ThemeContext from '../context/theme-context'; type Props = {}; export default function ThemeToggleButton(props: Props) { const { theme, toggleTheme } = React.useContext(ThemeContext); return ( ); } ================================================ FILE: playground/src/index.css ================================================ body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } code { font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; } ================================================ FILE: playground/src/index.tsx ================================================ // tslint:disable-next-line:no-import-side-effect import 'tslib'; // tslint:disable-next-line:no-import-side-effect import './index.css'; import React from 'react'; import ReactDOM from 'react-dom'; import * as serviceWorker from './serviceWorker'; import { App } from './app'; ReactDOM.render(, document.getElementById('root')); // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: https://bit.ly/CRA-PWA serviceWorker.unregister(); ================================================ FILE: playground/src/layout/layout-footer.tsx ================================================ import React from 'react'; export function LayoutFooter() { return (
React & Redux in TypeScript - Complete Guide
); } ================================================ FILE: playground/src/layout/layout-header.tsx ================================================ import React from 'react'; import { Link } from 'react-router-dom'; export function LayoutHeader() { return ( ); } ================================================ FILE: playground/src/layout/layout.tsx ================================================ import React from 'react'; type Props = { renderHeader: () => JSX.Element; renderContent: () => JSX.Element; renderFooter?: () => JSX.Element; }; export function Layout({ renderHeader, renderContent, renderFooter }: Props) { return (
{renderHeader()}
{renderContent()} {renderFooter && renderFooter()}
); } ================================================ FILE: playground/src/models/index.ts ================================================ export * from './user'; ================================================ FILE: playground/src/models/nominal-types.ts ================================================ // Nominal Typing // Usefull to model domain concepts that are using primitive data type for it's value // Method 1: using "interface" export interface Name extends String { _brand: 'Name'; } const createName = (name: string): Name => { // validation of business rules return name as any; }; // Method 2: using "type" type Surname = string & { _brand: 'Surname' }; const createSurname = (surname: string): Surname => { // validation of business rules return surname as any; }; type Person = { name: Name; surname: Surname; }; const person: Person = { name: createName('Piotr'), surname: createSurname('Witek'), }; // Type system will ensure that the domain objects can only contain correct data // person.name = 'Karol'; // error // person.name = person.surname; // error person.name = createName('Karol'); // OK! // person.surname = 'Mate'; // error // person.surname = person.name; // error person.surname = createSurname('Mate'); // OK! // easy casting to supertype export let str: string; str = person.name.toString(); // Method 1 & Method 2 str = person.surname; // Method 2 only ================================================ FILE: playground/src/models/user.ts ================================================ import cuid from 'cuid'; export interface IUserDTO { id: string; first_name: string; last_name: string; } export interface IUser { id: string; firstName: string; lastName: string; fullName: string; serialize(): IUserDTO; } export class User implements IUser { id: string = cuid(); get fullName(): string { return `${this.firstName} ${this.lastName}`; } constructor(public firstName: string, public lastName: string) {} static deserialize(dto: IUserDTO): IUser { const model = new User(dto.first_name, dto.last_name); model.id = dto.id; return model; } serialize(): IUserDTO { return { id: this.id, first_name: this.firstName, last_name: this.lastName, }; } } ================================================ FILE: playground/src/react-app-env.d.ts ================================================ /// ================================================ FILE: playground/src/routes/home.tsx ================================================ import React from 'react' import FCCounterUsage from '../components/fc-counter.usage'; import FCCounterWithDefaultPropsUsage from '../components/fc-counter-with-default-props.usage'; import FCSpreadAttributesUsage from '../components/fc-spread-attributes.usage'; import ClassCounterUsage from '../components/class-counter.usage'; import ClassCounterWithDefaultPropsUsage from '../components/class-counter-with-default-props.usage'; import UserListUsage from '../components/generic-list.usage'; import WithErrorBoundaryUsage from '../hoc/with-error-boundary.usage'; import WithStateUsage from '../hoc/with-state.usage'; import WithConnectedCountUsage from '../hoc/with-connected-count.usage'; export function Home() { return (
); }; ================================================ FILE: playground/src/routes/not-found.tsx ================================================ import React from 'react'; import { Link } from 'react-router-dom'; export function NotFound() { return (

Not found!

Go to the home page

); } ================================================ FILE: playground/src/serviceWorker.ts ================================================ // tslint:disable:no-console // This optional code is used to register a service worker. // register() is not called by default. // This lets the app load faster on subsequent visits in production, and gives // it offline capabilities. However, it also means that developers (and users) // will only see deployed updates on subsequent visits to a page, after all the // existing tabs open on the page have been closed, since previously cached // resources are updated in the background. // To learn more about the benefits of this model and instructions on how to // opt-in, read https://bit.ly/CRA-PWA const isLocalhost = Boolean( window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. window.location.hostname.match( /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ ) ); type Config = { onSuccess?: (registration: ServiceWorkerRegistration) => void; onUpdate?: (registration: ServiceWorkerRegistration) => void; }; export function register(config?: Config) { if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. const publicUrl = new URL( (process as { env: { [key: string]: string } }).env.PUBLIC_URL, window.location.href ); if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 return; } window.addEventListener('load', () => { const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. checkValidServiceWorker(swUrl, config); // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( 'This web app is being served cache-first by a service ' + 'worker. To learn more, visit https://bit.ly/CRA-PWA' ); }); } else { // Is not localhost. Just register service worker registerValidSW(swUrl, config); } }); } } function registerValidSW(swUrl: string, config?: Config) { navigator.serviceWorker .register(swUrl) .then(registration => { registration.onupdatefound = () => { const installingWorker = registration.installing; if (installingWorker == null) { return; } installingWorker.onstatechange = () => { if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the updated precached content has been fetched, // but the previous service worker will still serve the older // content until all client tabs are closed. console.log( 'New content is available and will be used when all ' + 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' ); // Execute callback if (config && config.onUpdate) { config.onUpdate(registration); } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. console.log('Content is cached for offline use.'); // Execute callback if (config && config.onSuccess) { config.onSuccess(registration); } } } }; }; }) .catch(error => { console.error('Error during service worker registration:', error); }); } function checkValidServiceWorker(swUrl: string, config?: Config) { // Check if the service worker can be found. If it can't reload the page. fetch(swUrl) .then(response => { // Ensure service worker exists, and that we really are getting a JS file. const contentType = response.headers.get('content-type'); if ( response.status === 404 || (contentType != null && contentType.indexOf('javascript') === -1) ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { window.location.reload(); }); }); } else { // Service worker found. Proceed as normal. registerValidSW(swUrl, config); } }) .catch(() => { console.log( 'No internet connection found. App is running in offline mode.' ); }); } export function unregister() { if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { registration.unregister(); }); } } ================================================ FILE: playground/src/services/index.ts ================================================ import * as logger from './logger-service'; import * as localStorage from './local-storage-service'; export default { logger, localStorage, }; ================================================ FILE: playground/src/services/local-storage-service.ts ================================================ const version = process.env.APP_VERSION; const STORAGE_KEY = `__SERIALIZED_STATE_TREE_v${version}__`; export function saveState(storeState: T): boolean { if (!localStorage) { return false; } try { const serializedState = JSON.stringify(storeState); localStorage.setItem(STORAGE_KEY, serializedState); return true; } catch (error) { throw new Error('store serialization failed'); } } export function loadState(): T | undefined { if (!localStorage) { return; } try { const serializedState = localStorage.getItem(STORAGE_KEY); if (serializedState == null) { return; } return JSON.parse(serializedState); } catch (error) { throw new Error('store deserialization failed'); } } ================================================ FILE: playground/src/services/logger-service.ts ================================================ // tslint:disable-next-line:no-console export const log = console.log; ================================================ FILE: playground/src/services/types.d.ts ================================================ declare module 'MyTypes' { export type Services = typeof import('./index').default; } ================================================ FILE: playground/src/store/hooks.ts ================================================ import { Dispatch } from 'redux'; import { TypedUseSelectorHook, useSelector as useGenericSelector, useDispatch as useGenericDispatch } from 'react-redux'; import { RootState, RootAction } from 'MyTypes'; export const useSelector: TypedUseSelectorHook = useGenericSelector; export const useDispatch: () => Dispatch = useGenericDispatch; ================================================ FILE: playground/src/store/index.ts ================================================ export { default as store } from './store'; export * from './redux-router'; ================================================ FILE: playground/src/store/redux-router.ts ================================================ import { createBrowserHistory } from 'history'; import { createRouterReducer } from '@lagunovsky/redux-react-router'; import { createRouterMiddleware } from '@lagunovsky/redux-react-router' export const history = createBrowserHistory(); export const routerReducer = createRouterReducer(history); export const routerMiddleware = createRouterMiddleware(history) ================================================ FILE: playground/src/store/root-action.ts ================================================ import * as todosActions from '../features/todos/actions'; import * as countersActions from '../features/counters/actions'; import { routerActions } from '@lagunovsky/redux-react-router' export default { router: routerActions, todos: todosActions, counters: countersActions, }; ================================================ FILE: playground/src/store/root-epic.ts ================================================ import { combineEpics } from 'redux-observable'; import * as todosEpics from '../features/todos/epics'; export default combineEpics(...Object.values(todosEpics)); ================================================ FILE: playground/src/store/root-reducer.ts ================================================ import { combineReducers } from 'redux'; import countersReducer from '../features/counters/reducer'; import todosReducer from '../features/todos/reducer'; import { routerReducer } from './redux-router'; const rootReducer = combineReducers({ router: routerReducer, todos: todosReducer, counters: countersReducer, }); export default rootReducer; ================================================ FILE: playground/src/store/store.ts ================================================ import { RootAction, RootState, Services } from 'MyTypes'; import { applyMiddleware, createStore } from 'redux'; import { createEpicMiddleware } from 'redux-observable'; import services from '../services'; import { routerMiddleware } from './redux-router'; import rootEpic from './root-epic'; import rootReducer from './root-reducer'; import { composeEnhancers } from './utils'; const epicMiddleware = createEpicMiddleware< RootAction, RootAction, RootState, Services >({ dependencies: services, }); // configure middlewares const middlewares = [epicMiddleware, routerMiddleware]; // compose enhancers const enhancer = composeEnhancers(applyMiddleware(...middlewares)); // rehydrate state on app start const initialState = {}; // create store const store = createStore( rootReducer, initialState, enhancer ); epicMiddleware.run(rootEpic); // export store singleton instance export default store; ================================================ FILE: playground/src/store/types.d.ts ================================================ import { StateType, ActionType } from 'typesafe-actions'; declare module 'MyTypes' { export type Store = StateType; export type RootAction = ActionType; export type RootState = StateType>; } declare module 'typesafe-actions' { interface Types { RootAction: ActionType; } } ================================================ FILE: playground/src/store/utils.ts ================================================ import { compose } from 'redux'; export const composeEnhancers = (process.env.NODE_ENV === 'development' && window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose; ================================================ FILE: playground/src/storyshots.disabled-test.ts ================================================ // import initStoryshots, { // multiSnapshotWithOptions, // } from '@storybook/addon-storyshots'; // initStoryshots({ // integrityOptions: { cwd: __dirname }, // test: multiSnapshotWithOptions({}), // }); export {} ================================================ FILE: playground/src-old/App.css ================================================ .App { text-align: center; } .App-logo { height: 40vmin; pointer-events: none; } @media (prefers-reduced-motion: no-preference) { .App-logo { animation: App-logo-spin infinite 20s linear; } } .App-header { background-color: #282c34; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: calc(10px + 2vmin); color: white; } .App-link { color: #61dafb; } @keyframes App-logo-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } ================================================ FILE: playground/src-old/App.test.tsx ================================================ import React from 'react'; import { render, screen } from '@testing-library/react'; import App from './App'; test('renders learn react link', () => { render(); const linkElement = screen.getByText(/learn react/i); expect(linkElement).toBeInTheDocument(); }); ================================================ FILE: playground/src-old/App.tsx ================================================ import React from 'react'; import logo from './logo.svg'; import './App.css'; function App() { return (
logo

Edit src/App.tsx and save to reload.

Learn React
); } export default App; ================================================ FILE: playground/src-old/index.css ================================================ body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } code { font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; } ================================================ FILE: playground/src-old/index.tsx ================================================ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; import App from './App'; import reportWebVitals from './reportWebVitals'; const root = ReactDOM.createRoot( document.getElementById('root') as HTMLElement ); root.render( ); // If you want to start measuring performance in your app, pass a function // to log results (for example: reportWebVitals(console.log)) // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals reportWebVitals(); ================================================ FILE: playground/src-old/react-app-env.d.ts ================================================ /// ================================================ FILE: playground/src-old/reportWebVitals.ts ================================================ import { ReportHandler } from 'web-vitals'; const reportWebVitals = (onPerfEntry?: ReportHandler) => { if (onPerfEntry && onPerfEntry instanceof Function) { import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { getCLS(onPerfEntry); getFID(onPerfEntry); getFCP(onPerfEntry); getLCP(onPerfEntry); getTTFB(onPerfEntry); }); } }; export default reportWebVitals; ================================================ FILE: playground/src-old/setupTests.ts ================================================ // jest-dom adds custom jest matchers for asserting on DOM nodes. // allows you to do things like: // expect(element).toHaveTextContent(/react/i) // learn more: https://github.com/testing-library/jest-dom import '@testing-library/jest-dom'; ================================================ FILE: playground/styleguide/docs/intro.md ================================================ ### Styleguide [⇦ back to guide](https://github.com/piotrwitek/react-redux-typescript-guide#table-of-contents) ================================================ FILE: playground/styleguide/package.json ================================================ { "name": "styleguide", "description": "Styleguide for https://github.com/piotrwitek/react-redux-typescript-guide", "version": "1.0.0", "private": true, "author": "Piotr Witek (http://piotrwitek.github.io/)", "repository": "https://github.com/piotrwitek/react-redux-typescript-guide.git", "license": "MIT", "main": "src/index.tsx", "scripts": { "styleguide": "styleguidist server", "styleguide:build": "styleguidist build" }, "dependencies": { "react-docgen-typescript": "1.12.3", "react-styleguidist": "8.0.6", "typescript": "3.1.6", "webpack-blocks": "1.0.0" } } ================================================ FILE: playground/styleguide/styleguide.config.js ================================================ const path = require('path'); const fs = require('fs'); const { createConfig } = require('webpack-blocks'); const typescript = require('@webpack-blocks/typescript'); const webpackConfig = createConfig([typescript()]); webpackConfig.resolve.alias = { '@src': path.join(__dirname, 'src') }; module.exports = { showUsage: false, styleguideDir: '../docs/', title: 'React & Redux in TypeScript - Component Typing Patterns', ignore: ['**/*.usage.tsx'], sections: [ { name: 'Introduction', content: './docs/intro.md', }, { name: 'Function Components', components: () => [ './src/components/fc-counter.tsx', './src/components/fc-spread-attributes.tsx', ], }, { name: 'Class Components', components: () => [ './src/components/class-counter.tsx', './src/components/class-counter-with-default-props.tsx', ], }, { name: 'Generic Components', components: () => ['./src/components/generic-list.tsx'], }, { name: 'Render Props', components: () => [ './src/components/name-provider.tsx', './src/components/mouse-provider.tsx', ], }, ], theme: { sidebarWidth: 300, }, propsParser: require('react-docgen-typescript').parse, webpackConfig: webpackConfig, updateExample: function(props, exampleFilePath) { if (typeof props.settings.filePath === 'string') { const { settings: { filePath }, } = props; delete props.settings.filePath; props.content = fs.readFileSync( path.resolve(exampleFilePath, '..', filePath), { encoding: 'utf-8' } ); props.settings.static = true; } return props; }, }; ================================================ FILE: playground/tsconfig.json ================================================ { "compilerOptions": { "target": "ES6", "lib": [ "dom", "dom.iterable", "esnext" ], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, "module": "esnext", "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, "jsx": "react-jsx" }, "include": [ "src", "typings" ] } ================================================ FILE: playground/tsconfig.test.json ================================================ { "extends": "./tsconfig.json", "compilerOptions": { "module": "commonjs" } } ================================================ FILE: playground/typings/augmentations.d.ts ================================================ // typings/augmentations.ts // import { Operator } from 'rxjs/Operator'; // import { Observable } from 'rxjs/Observable'; // declare module 'rxjs/Subject' { // // tslint:disable-next-line:interface-name // interface Subject { // lift(operator: Operator): Observable; // } // } ================================================ FILE: playground/typings/globals.d.ts ================================================ // typings/globals.d.ts declare interface Window { __REDUX_DEVTOOLS_EXTENSION__: any; __REDUX_DEVTOOLS_EXTENSION_COMPOSE__: any; } declare interface NodeModule { hot?: { accept: (path: string, callback: () => void) => void }; } declare interface System { import(module: string): Promise; } declare var System: System; // declare const process: any; // declare const require: any; ================================================ FILE: playground/typings/modules.d.ts ================================================ // typings/modules.d.ts declare module 'MyTypes'; declare module 'react-test-renderer'; declare module '@storybook/addon-storyshots' ================================================ FILE: playground/typings/redux/index.d.ts ================================================ /** * An *action* is a plain object that represents an intention to change the * state. Actions are the only way to get data into the store. Any data, * whether from UI events, network callbacks, or other sources such as * WebSockets needs to eventually be dispatched as actions. * * Actions must have a `type` field that indicates the type of action being * performed. Types can be defined as constants and imported from another * module. It's better to use strings for `type` than Symbols because strings * are serializable. * * Other than `type`, the structure of an action object is really up to you. * If you're interested, check out Flux Standard Action for recommendations on * how actions should be constructed. * * @template T the type of the action's `type` tag. */ export interface Action { type: T; } /* reducers */ /** * A *reducer* (also called a *reducing function*) is a function that accepts * an accumulation and a value and returns a new accumulation. They are used * to reduce a collection of values down to a single value * * Reducers are not unique to Redux—they are a fundamental concept in * functional programming. Even most non-functional languages, like * JavaScript, have a built-in API for reducing. In JavaScript, it's * `Array.prototype.reduce()`. * * In Redux, the accumulated value is the state object, and the values being * accumulated are actions. Reducers calculate a new state given the previous * state and an action. They must be *pure functions*—functions that return * the exact same output for given inputs. They should also be free of * side-effects. This is what enables exciting features like hot reloading and * time travel. * * Reducers are the most important concept in Redux. * * *Do not put API calls into reducers.* * * @template S The type of state consumed and produced by this reducer. * @template A The type of actions the reducer can potentially respond to. */ export type Reducer = (state: S | undefined, action: A) => S; /** * Object whose values correspond to different reducer functions. * * @template A The type of actions the reducers can potentially respond to. */ export type ReducersMapObject = { [K in keyof S]: Reducer; } /** * Turns an object whose values are different reducer functions, into a single * reducer function. It will call every child reducer, and gather their results * into a single state object, whose keys correspond to the keys of the passed * reducer functions. * * @template S Combined state object type. * * @param reducers An object whose values correspond to different reducer * functions that need to be combined into one. One handy way to obtain it * is to use ES6 `import * as reducers` syntax. The reducers may never * return undefined for any action. Instead, they should return their * initial state if the state passed to them was undefined, and the current * state for any unrecognized action. * * @returns A reducer function that invokes every reducer inside the passed * object, and builds a state object with the same shape. */ export function combineReducers(reducers: ReducersMapObject): Reducer; /* store */ /** * A *dispatching function* (or simply *dispatch function*) is a function that * accepts an action or an async action; it then may or may not dispatch one * or more actions to the store. * * We must distinguish between dispatching functions in general and the base * `dispatch` function provided by the store instance without any middleware. * * The base dispatch function *always* synchronously sends an action to the * store's reducer, along with the previous state returned by the store, to * calculate a new state. It expects actions to be plain objects ready to be * consumed by the reducer. * * Middleware wraps the base dispatch function. It allows the dispatch * function to handle async actions in addition to actions. Middleware may * transform, delay, ignore, or otherwise interpret actions or async actions * before passing them to the next middleware. * * @template D the type of things (actions or otherwise) which may be dispatched. */ export interface Dispatch { (action: A): A; } /** * Function to remove listener added by `Store.subscribe()`. */ export interface Unsubscribe { (): void; } /** * A store is an object that holds the application's state tree. * There should only be a single store in a Redux app, as the composition * happens on the reducer level. * * @template S The type of state held by this store. * @template A the type of actions which may be dispatched by this store. * @template N The type of non-actions which may be dispatched by this store. */ export interface Store { /** * Dispatches an action. It is the only way to trigger a state change. * * The `reducer` function, used to create the store, will be called with the * current state tree and the given `action`. Its return value will be * considered the **next** state of the tree, and the change listeners will * be notified. * * The base implementation only supports plain object actions. If you want * to dispatch a Promise, an Observable, a thunk, or something else, you * need to wrap your store creating function into the corresponding * middleware. For example, see the documentation for the `redux-thunk` * package. Even the middleware will eventually dispatch plain object * actions using this method. * * @param action A plain object representing “what changed”. It is a good * idea to keep actions serializable so you can record and replay user * sessions, or use the time travelling `redux-devtools`. An action must * have a `type` property which may not be `undefined`. It is a good idea * to use string constants for action types. * * @returns For convenience, the same action object you dispatched. * * Note that, if you use a custom middleware, it may wrap `dispatch()` to * return something else (for example, a Promise you can await). */ dispatch: Dispatch; /** * Reads the state tree managed by the store. * * @returns The current state tree of your application. */ getState(): S; /** * Adds a change listener. It will be called any time an action is * dispatched, and some part of the state tree may potentially have changed. * You may then call `getState()` to read the current state tree inside the * callback. * * You may call `dispatch()` from a change listener, with the following * caveats: * * 1. The subscriptions are snapshotted just before every `dispatch()` call. * If you subscribe or unsubscribe while the listeners are being invoked, * this will not have any effect on the `dispatch()` that is currently in * progress. However, the next `dispatch()` call, whether nested or not, * will use a more recent snapshot of the subscription list. * * 2. The listener should not expect to see all states changes, as the state * might have been updated multiple times during a nested `dispatch()` before * the listener is called. It is, however, guaranteed that all subscribers * registered before the `dispatch()` started will be called with the latest * state by the time it exits. * * @param listener A callback to be invoked on every dispatch. * @returns A function to remove this change listener. */ subscribe(listener: () => void): Unsubscribe; /** * Replaces the reducer currently used by the store to calculate the state. * * You might need this if your app implements code splitting and you want to * load some of the reducers dynamically. You might also need this if you * implement a hot reloading mechanism for Redux. * * @param nextReducer The reducer for the store to use instead. */ replaceReducer(nextReducer: Reducer): void; } export type DeepPartial = {[K in keyof T]?: DeepPartial }; /** * A store creator is a function that creates a Redux store. Like with * dispatching function, we must distinguish the base store creator, * `createStore(reducer, preloadedState)` exported from the Redux package, from * store creators that are returned from the store enhancers. * * @template S The type of state to be held by the store. * @template A The type of actions which may be dispatched. * @template D The type of all things which may be dispatched. */ export interface StoreCreator { (reducer: Reducer, enhancer?: StoreEnhancer): Store; (reducer: Reducer, preloadedState: DeepPartial, enhancer?: StoreEnhancer): Store; } /** * A store enhancer is a higher-order function that composes a store creator * to return a new, enhanced store creator. This is similar to middleware in * that it allows you to alter the store interface in a composable way. * * Store enhancers are much the same concept as higher-order components in * React, which are also occasionally called “component enhancers”. * * Because a store is not an instance, but rather a plain-object collection of * functions, copies can be easily created and modified without mutating the * original store. There is an example in `compose` documentation * demonstrating that. * * Most likely you'll never write a store enhancer, but you may use the one * provided by the developer tools. It is what makes time travel possible * without the app being aware it is happening. Amusingly, the Redux * middleware implementation is itself a store enhancer. * */ export type StoreEnhancer = (next: StoreEnhancerStoreCreator) => StoreEnhancerStoreCreator; export type GenericStoreEnhancer = StoreEnhancer; export type StoreEnhancerStoreCreator = (reducer: Reducer, preloadedState?: DeepPartial) => Store; /** * Creates a Redux store that holds the state tree. * The only way to change the data in the store is to call `dispatch()` on it. * * There should only be a single store in your app. To specify how different * parts of the state tree respond to actions, you may combine several * reducers * into a single reducer function by using `combineReducers`. * * @template S State object type. * * @param reducer A function that returns the next state tree, given the * current state tree and the action to handle. * * @param [preloadedState] The initial state. You may optionally specify it to * hydrate the state from the server in universal apps, or to restore a * previously serialized user session. If you use `combineReducers` to * produce the root reducer function, this must be an object with the same * shape as `combineReducers` keys. * * @param [enhancer] The store enhancer. You may optionally specify it to * enhance the store with third-party capabilities such as middleware, time * travel, persistence, etc. The only store enhancer that ships with Redux * is `applyMiddleware()`. * * @returns A Redux store that lets you read the state, dispatch actions and * subscribe to changes. */ export const createStore: StoreCreator; /* middleware */ export interface MiddlewareAPI { dispatch: Dispatch; getState(): S; } /** * A middleware is a higher-order function that composes a dispatch function * to return a new dispatch function. It often turns async actions into * actions. * * Middleware is composable using function composition. It is useful for * logging actions, performing side effects like routing, or turning an * asynchronous API call into a series of synchronous actions. */ export interface Middleware { (api: MiddlewareAPI): (next: Dispatch) => Dispatch; } /** * Creates a store enhancer that applies middleware to the dispatch method * of the Redux store. This is handy for a variety of tasks, such as * expressing asynchronous actions in a concise manner, or logging every * action payload. * * See `redux-thunk` package as an example of the Redux middleware. * * Because middleware is potentially asynchronous, this should be the first * store enhancer in the composition chain. * * Note that each middleware will be given the `dispatch` and `getState` * functions as named arguments. * * @param middlewares The middleware chain to be applied. * @returns A store enhancer applying the middleware. */ export function applyMiddleware(...middlewares: Middleware[]): GenericStoreEnhancer; /* action creators */ /** * An *action creator* is, quite simply, a function that creates an action. Do * not confuse the two terms—again, an action is a payload of information, and * an action creator is a factory that creates an action. * * Calling an action creator only produces an action, but does not dispatch * it. You need to call the store's `dispatch` function to actually cause the * mutation. Sometimes we say *bound action creators* to mean functions that * call an action creator and immediately dispatch its result to a specific * store instance. * * If an action creator needs to read the current state, perform an API call, * or cause a side effect, like a routing transition, it should return an * async action instead of an action. * * @template A Returned action type. */ export interface ActionCreator { (...args: any[]): A; } /** * Object whose values are action creator functions. */ export interface ActionCreatorsMapObject { [key: string]: ActionCreator; } /** * Turns an object whose values are action creators, into an object with the * same keys, but with every function wrapped into a `dispatch` call so they * may be invoked directly. This is just a convenience method, as you can call * `store.dispatch(MyActionCreators.doSomething())` yourself just fine. * * For convenience, you can also pass a single function as the first argument, * and get a function in return. * * @param actionCreator An object whose values are action creator functions. * One handy way to obtain it is to use ES6 `import * as` syntax. You may * also pass a single function. * * @param dispatch The `dispatch` function available on your Redux store. * * @returns The object mimicking the original object, but with every action * creator wrapped into the `dispatch` call. If you passed a function as * `actionCreator`, the return value will also be a single function. */ export function bindActionCreators>(actionCreator: C, dispatch: Dispatch): C; export function bindActionCreators< A extends ActionCreator, B extends ActionCreator >(actionCreator: A, dispatch: Dispatch): B; export function bindActionCreators>(actionCreators: M, dispatch: Dispatch): M; export function bindActionCreators< M extends ActionCreatorsMapObject, N extends ActionCreatorsMapObject >(actionCreators: M, dispatch: Dispatch): N; /* compose */ type Func0 = () => R; type Func1 = (a1: T1) => R; type Func2 = (a1: T1, a2: T2) => R; type Func3 = (a1: T1, a2: T2, a3: T3, ...args: any[]) => R; /** * Composes single-argument functions from right to left. The rightmost * function can take multiple arguments as it provides the signature for the * resulting composite function. * * @param funcs The functions to compose. * @returns R function obtained by composing the argument functions from right * to left. For example, `compose(f, g, h)` is identical to doing * `(...args) => f(g(h(...args)))`. */ export function compose(): (a: R) => R; export function compose(f: F): F; /* two functions */ export function compose( f1: (b: A) => R, f2: Func0 ): Func0; export function compose( f1: (b: A) => R, f2: Func1 ): Func1; export function compose( f1: (b: A) => R, f2: Func2 ): Func2; export function compose( f1: (b: A) => R, f2: Func3 ): Func3; /* three functions */ export function compose( f1: (b: B) => R, f2: (a: A) => B, f3: Func0 ): Func0; export function compose( f1: (b: B) => R, f2: (a: A) => B, f3: Func1 ): Func1; export function compose( f1: (b: B) => R, f2: (a: A) => B, f3: Func2 ): Func2; export function compose( f1: (b: B) => R, f2: (a: A) => B, f3: Func3 ): Func3; /* four functions */ export function compose( f1: (b: C) => R, f2: (a: B) => C, f3: (a: A) => B, f4: Func0 ): Func0; export function compose( f1: (b: C) => R, f2: (a: B) => C, f3: (a: A) => B, f4: Func1 ): Func1; export function compose( f1: (b: C) => R, f2: (a: B) => C, f3: (a: A) => B, f4: Func2 ): Func2; export function compose( f1: (b: C) => R, f2: (a: B) => C, f3: (a: A) => B, f4: Func3 ): Func3; /* rest */ export function compose( f1: (b: any) => R, ...funcs: Function[] ): (...args: any[]) => R; export function compose(...funcs: Function[]): (...args: any[]) => R; ================================================ FILE: playground/typings/redux-thunk/index.d.ts ================================================ import { Action, ActionCreatorsMapObject, AnyAction, Dispatch, Middleware, } from 'redux'; export interface ThunkDispatch { (thunkAction: ThunkAction): R; (action: T): T; } export type ThunkAction = ( dispatch: ThunkDispatch, getState: () => S, extraArgument: E ) => R; /** * Takes a ThunkAction and returns a function signature which matches how it would appear when processed using * bindActionCreators * * @template T ThunkAction to be wrapped */ export type ThunkActionDispatch< T extends (...args: any[]) => ThunkAction > = (...args: Parameters) => ReturnType>; export type ThunkMiddleware< S = {}, A extends Action = AnyAction, E = undefined > = Middleware, S, ThunkDispatch>; declare const thunk: ThunkMiddleware & { withExtraArgument(extraArgument: E): ThunkMiddleware<{}, AnyAction, E>; }; export default thunk; /** * Redux behaviour changed by middleware, so overloads here */ declare module 'redux' { /** * Overload for bindActionCreators redux function, returns expects responses * from thunk actions */ function bindActionCreators>( actionCreators: M, dispatch: Dispatch ): { [N in keyof M]: ReturnType extends ThunkAction ? (...args: Parameters) => ReturnType> : M[N] }; }